diff --git a/examples/babylonjs/index.html b/examples/babylonjs/index.html index 92d32ee3..4b931acc 100644 --- a/examples/babylonjs/index.html +++ b/examples/babylonjs/index.html @@ -13,15 +13,15 @@ - - + + - + - + - + diff --git a/libs/babylonjs/6.46.0/babylon.glTF2FileLoader.js b/libs/babylonjs/6.46.0/babylon.glTF2FileLoader.js new file mode 100644 index 00000000..625597ef --- /dev/null +++ b/libs/babylonjs/6.46.0/babylon.glTF2FileLoader.js @@ -0,0 +1,8602 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("babylonjs")); + else if(typeof define === 'function' && define.amd) + define("babylonjs-loaders", ["babylonjs"], factory); + else if(typeof exports === 'object') + exports["babylonjs-loaders"] = factory(require("babylonjs")); + else + root["LOADERS"] = factory(root["BABYLON"]); +})((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), (__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__) => { +return /******/ (() => { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts": +/*!******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_lights_image_based: () => (/* binding */ EXT_lights_image_based) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/Textures/rawCubeTexture */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + +var NAME = "EXT_lights_image_based"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_lights_image_based/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_lights_image_based = /** @class */ (function () { + /** + * @internal + */ + function EXT_lights_image_based(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + EXT_lights_image_based.prototype.dispose = function () { + this._loader = null; + delete this._lights; + }; + /** @internal */ + EXT_lights_image_based.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._lights = extension.lights; + } + }; + /** + * @internal + */ + EXT_lights_image_based.prototype.loadSceneAsync = function (context, scene) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) { + _this._loader._allMaterialsDirtyRequired = true; + var promises = new Array(); + promises.push(_this._loader.loadSceneAsync(context, scene)); + _this._loader.logOpen("".concat(extensionContext)); + var light = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/light"), _this._lights, extension.light); + promises.push(_this._loadLightAsync("/extensions/".concat(_this.name, "/lights/").concat(extension.light), light).then(function (texture) { + _this._loader.babylonScene.environmentTexture = texture; + })); + _this._loader.logClose(); + return Promise.all(promises).then(function () { }); + }); + }; + EXT_lights_image_based.prototype._loadLightAsync = function (context, light) { + var _this = this; + if (!light._loaded) { + var promises = new Array(); + this._loader.logOpen("".concat(context)); + var imageData_1 = new Array(light.specularImages.length); + var _loop_1 = function (mipmap) { + var faces = light.specularImages[mipmap]; + imageData_1[mipmap] = new Array(faces.length); + var _loop_2 = function (face) { + var specularImageContext = "".concat(context, "/specularImages/").concat(mipmap, "/").concat(face); + this_1._loader.logOpen("".concat(specularImageContext)); + var index = faces[face]; + var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(specularImageContext, this_1._loader.gltf.images, index); + promises.push(this_1._loader.loadImageAsync("/images/".concat(index), image).then(function (data) { + imageData_1[mipmap][face] = data; + })); + this_1._loader.logClose(); + }; + for (var face = 0; face < faces.length; face++) { + _loop_2(face); + } + }; + var this_1 = this; + for (var mipmap = 0; mipmap < light.specularImages.length; mipmap++) { + _loop_1(mipmap); + } + this._loader.logClose(); + light._loaded = Promise.all(promises).then(function () { + var babylonTexture = new babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.RawCubeTexture(_this._loader.babylonScene, null, light.specularImageSize); + babylonTexture.name = light.name || "environment"; + light._babylonTexture = babylonTexture; + if (light.intensity != undefined) { + babylonTexture.level = light.intensity; + } + if (light.rotation) { + var rotation = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(light.rotation); + // Invert the rotation so that positive rotation is counter-clockwise. + if (!_this._loader.babylonScene.useRightHandedSystem) { + rotation = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Inverse(rotation); + } + babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromQuaternionToRef(rotation, babylonTexture.getReflectionTextureMatrix()); + } + if (!light.irradianceCoefficients) { + throw new Error("".concat(context, ": Irradiance coefficients are missing")); + } + var sphericalHarmonics = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.SphericalHarmonics.FromArray(light.irradianceCoefficients); + sphericalHarmonics.scaleInPlace(light.intensity); + sphericalHarmonics.convertIrradianceToLambertianRadiance(); + var sphericalPolynomial = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.SphericalPolynomial.FromHarmonics(sphericalHarmonics); + // Compute the lod generation scale to fit exactly to the number of levels available. + var lodGenerationScale = (imageData_1.length - 1) / babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Scalar.Log2(light.specularImageSize); + return babylonTexture.updateRGBDAsync(imageData_1, sphericalPolynomial, lodGenerationScale); + }); + } + return light._loaded.then(function () { + return light._babylonTexture; + }); + }; + return EXT_lights_image_based; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_lights_image_based(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* binding */ EXT_mesh_gpu_instancing) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Meshes/thinInstanceMesh */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "EXT_mesh_gpu_instancing"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_mesh_gpu_instancing/README.md) + * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_mesh_gpu_instancing = /** @class */ (function () { + /** + * @internal + */ + function EXT_mesh_gpu_instancing(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + EXT_mesh_gpu_instancing.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + EXT_mesh_gpu_instancing.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + _this._loader._disableInstancedMesh++; + var promise = _this._loader.loadNodeAsync("/nodes/".concat(node.index), node, assign); + _this._loader._disableInstancedMesh--; + if (!node._primitiveBabylonMeshes) { + return promise; + } + var promises = new Array(); + var instanceCount = 0; + var loadAttribute = function (attribute) { + if (extension.attributes[attribute] == undefined) { + promises.push(Promise.resolve(null)); + return; + } + var accessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/attributes/").concat(attribute), _this._loader.gltf.accessors, extension.attributes[attribute]); + promises.push(_this._loader._loadFloatAccessorAsync("/accessors/".concat(accessor.bufferView), accessor)); + if (instanceCount === 0) { + instanceCount = accessor.count; + } + else if (instanceCount !== accessor.count) { + throw new Error("".concat(extensionContext, "/attributes: Instance buffer accessors do not have the same count.")); + } + }; + loadAttribute("TRANSLATION"); + loadAttribute("ROTATION"); + loadAttribute("SCALE"); + return promise.then(function (babylonTransformNode) { + return Promise.all(promises).then(function (_a) { + var translationBuffer = _a[0], rotationBuffer = _a[1], scaleBuffer = _a[2]; + var matrices = new Float32Array(instanceCount * 16); + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0].copyFromFloats(0, 0, 0); // translation + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0].copyFromFloats(0, 0, 0, 1); // rotation + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1].copyFromFloats(1, 1, 1); // scale + for (var i = 0; i < instanceCount; ++i) { + translationBuffer && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(translationBuffer, i * 3, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0]); + rotationBuffer && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArrayToRef(rotationBuffer, i * 4, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0]); + scaleBuffer && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(scaleBuffer, i * 3, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1]); + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Matrix.ComposeToRef(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1], babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0], babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0], babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0]); + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0].copyToArray(matrices, i * 16); + } + for (var _i = 0, _b = node._primitiveBabylonMeshes; _i < _b.length; _i++) { + var babylonMesh = _b[_i]; + babylonMesh.thinInstanceSetBuffer("matrix", matrices, 16, true); + } + return babylonTransformNode; + }); + }); + }); + }; + return EXT_mesh_gpu_instancing; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_mesh_gpu_instancing(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_meshopt_compression: () => (/* binding */ EXT_meshopt_compression) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/Compression/meshoptCompression */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "EXT_meshopt_compression"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_meshopt_compression/README.md) + * + * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js + * @since 5.0.0 + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_meshopt_compression = /** @class */ (function () { + /** + * @internal + */ + function EXT_meshopt_compression(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this.enabled = loader.isExtensionUsed(NAME); + this._loader = loader; + } + /** @internal */ + EXT_meshopt_compression.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + EXT_meshopt_compression.prototype.loadBufferViewAsync = function (context, bufferView) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, bufferView, this.name, function (extensionContext, extension) { + var bufferViewMeshopt = bufferView; + if (bufferViewMeshopt._meshOptData) { + return bufferViewMeshopt._meshOptData; + } + var buffer = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/buffer"), _this._loader.gltf.buffers, extension.buffer); + bufferViewMeshopt._meshOptData = _this._loader.loadBufferAsync("/buffers/".concat(buffer.index), buffer, extension.byteOffset || 0, extension.byteLength).then(function (buffer) { + return babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__.MeshoptCompression.Default.decodeGltfBufferAsync(buffer, extension.count, extension.byteStride, extension.mode, extension.filter); + }); + return bufferViewMeshopt._meshOptData; + }); + }; + return EXT_meshopt_compression; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_meshopt_compression(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts": +/*!************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_texture_webp: () => (/* binding */ EXT_texture_webp) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "EXT_texture_webp"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_texture_webp/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_texture_webp = /** @class */ (function () { + /** + * @internal + */ + function EXT_texture_webp(loader) { + /** The name of this extension. */ + this.name = NAME; + this._loader = loader; + this.enabled = loader.isExtensionUsed(NAME); + } + /** @internal */ + EXT_texture_webp.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + EXT_texture_webp.prototype._loadTextureAsync = function (context, texture, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, texture, this.name, function (extensionContext, extension) { + var sampler = texture.sampler == undefined ? _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.DefaultSampler : _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/sampler"), _this._loader.gltf.samplers, texture.sampler); + var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/source"), _this._loader.gltf.images, extension.source); + return _this._loader._createTextureAsync(context, sampler, image, function (babylonTexture) { + assign(babylonTexture); + }, undefined, !texture._textureInfo.nonColorData); + }); + }; + return EXT_texture_webp; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_texture_webp(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts": +/*!************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ExtrasAsMetadata: () => (/* binding */ ExtrasAsMetadata) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "ExtrasAsMetadata"; +/** + * Store glTF extras (if present) in BJS objects' metadata + */ +var ExtrasAsMetadata = /** @class */ (function () { + /** + * @internal + */ + function ExtrasAsMetadata(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines whether this extension is enabled. + */ + this.enabled = true; + this._loader = loader; + } + ExtrasAsMetadata.prototype._assignExtras = function (babylonObject, gltfProp) { + if (gltfProp.extras && Object.keys(gltfProp.extras).length > 0) { + var metadata = (babylonObject.metadata = babylonObject.metadata || {}); + var gltf = (metadata.gltf = metadata.gltf || {}); + gltf.extras = gltfProp.extras; + } + }; + /** @internal */ + ExtrasAsMetadata.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + ExtrasAsMetadata.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return this._loader.loadNodeAsync(context, node, function (babylonTransformNode) { + _this._assignExtras(babylonTransformNode, node); + assign(babylonTransformNode); + }); + }; + /** + * @internal + */ + ExtrasAsMetadata.prototype.loadCameraAsync = function (context, camera, assign) { + var _this = this; + return this._loader.loadCameraAsync(context, camera, function (babylonCamera) { + _this._assignExtras(babylonCamera, camera); + assign(babylonCamera); + }); + }; + /** + * @internal + */ + ExtrasAsMetadata.prototype.createMaterial = function (context, material, babylonDrawMode) { + var babylonMaterial = this._loader.createMaterial(context, material, babylonDrawMode); + this._assignExtras(babylonMaterial, material); + return babylonMaterial; + }; + return ExtrasAsMetadata; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new ExtrasAsMetadata(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.data.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.data.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ animationPointerTree: () => (/* binding */ animationPointerTree) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoaderAnimation */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts"); +/* eslint-disable @typescript-eslint/naming-convention */ + + + + +function getColor3(_target, source, offset, scale) { + return babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(source, offset).scale(scale); +} +function getAlpha(_target, source, offset, scale) { + return source[offset + 3] * scale; +} +function getFloat(_target, source, offset, scale) { + return source[offset] * scale; +} +function getMinusFloat(_target, source, offset, scale) { + return -source[offset] * scale; +} +function getNextFloat(_target, source, offset, scale) { + return source[offset + 1] * scale; +} +function getFloatBy2(_target, source, offset, scale) { + return source[offset] * scale * 2; +} +function getTextureTransformTree(textureName) { + return { + scale: [ + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".uScale"), getFloat, function () { return 2; }), + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".vScale"), getNextFloat, function () { return 2; }), + ], + offset: [ + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".uOffset"), getFloat, function () { return 2; }), + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".vOffset"), getNextFloat, function () { return 2; }), + ], + rotation: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".wAng"), getMinusFloat, function () { return 1; })], + }; +} +var CameraAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(CameraAnimationPropertyInfo, _super); + function CameraAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + CameraAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + callback(target._babylonCamera, this._buildAnimation(name, fps, keys)); + }; + return CameraAnimationPropertyInfo; +}(_glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.AnimationPropertyInfo)); +var MaterialAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(MaterialAnimationPropertyInfo, _super); + function MaterialAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + MaterialAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + for (var fillMode in target._data) { + callback(target._data[fillMode].babylonMaterial, this._buildAnimation(name, fps, keys)); + } + }; + return MaterialAnimationPropertyInfo; +}(_glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.AnimationPropertyInfo)); +var LightAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(LightAnimationPropertyInfo, _super); + function LightAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + LightAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + callback(target._babylonLight, this._buildAnimation(name, fps, keys)); + }; + return LightAnimationPropertyInfo; +}(_glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.AnimationPropertyInfo)); +var nodesTree = { + __array__: (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({ __target__: true }, _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.nodeAnimationData), +}; +var camerasTree = { + __array__: { + __target__: true, + orthographic: { + xmag: [ + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoLeft", getMinusFloat, function () { return 1; }), + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoRight", getNextFloat, function () { return 1; }), + ], + ymag: [ + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoBottom", getMinusFloat, function () { return 1; }), + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoTop", getNextFloat, function () { return 1; }), + ], + zfar: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "maxZ", getFloat, function () { return 1; })], + znear: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "minZ", getFloat, function () { return 1; })], + }, + perspective: { + yfov: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "fov", getFloat, function () { return 1; })], + zfar: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "maxZ", getFloat, function () { return 1; })], + znear: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "minZ", getFloat, function () { return 1; })], + }, + }, +}; +var materialsTree = { + __array__: { + __target__: true, + pbrMetallicRoughness: { + baseColorFactor: [ + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "albedoColor", getColor3, function () { return 4; }), + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "alpha", getAlpha, function () { return 4; }), + ], + metallicFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "metallic", getFloat, function () { return 1; })], + roughnessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "roughness", getFloat, function () { return 1; })], + baseColorTexture: { + extensions: { + KHR_texture_transform: getTextureTransformTree("albedoTexture"), + }, + }, + }, + emissiveFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "emissiveColor", getColor3, function () { return 3; })], + normalTexture: { + scale: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "bumpTexture.level", getFloat, function () { return 1; })], + }, + occlusionTexture: { + strength: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "ambientTextureStrength", getFloat, function () { return 1; })], + extensions: { + KHR_texture_transform: getTextureTransformTree("ambientTexture"), + }, + }, + emissiveTexture: { + extensions: { + KHR_texture_transform: getTextureTransformTree("emissiveTexture"), + }, + }, + extensions: { + KHR_materials_ior: { + ior: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "indexOfRefraction", getFloat, function () { return 1; })], + }, + KHR_materials_clearcoat: { + clearcoatFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "clearCoat.intensity", getFloat, function () { return 1; })], + clearcoatRoughnessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "clearCoat.roughness", getFloat, function () { return 1; })], + }, + KHR_materials_sheen: { + sheenColorFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "sheen.color", getColor3, function () { return 3; })], + sheenRoughnessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "sheen.roughness", getFloat, function () { return 1; })], + }, + KHR_materials_specular: { + specularFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "metallicF0Factor", getFloat, function () { return 1; })], + specularColorFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "metallicReflectanceColor", getColor3, function () { return 3; })], + }, + KHR_materials_emissive_strength: { + emissiveStrength: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "emissiveIntensity", getFloat, function () { return 1; })], + }, + KHR_materials_transmission: { + transmissionFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.refractionIntensity", getFloat, function () { return 1; })], + }, + KHR_materials_volume: { + attenuationColor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "subSurface.tintColor", getColor3, function () { return 3; })], + attenuationDistance: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.tintColorAtDistance", getFloat, function () { return 1; })], + thicknessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.maximumThickness", getFloat, function () { return 1; })], + }, + KHR_materials_dispersion: { + dispersion: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.dispersion", getFloat, function () { return 1; })], + }, + KHR_materials_iridescence: { + iridescenceFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.intensity", getFloat, function () { return 1; })], + iridescenceIor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.indexOfRefraction", getFloat, function () { return 1; })], + iridescenceThicknessMinimum: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.minimumThickness", getFloat, function () { return 1; })], + iridescenceThicknessMaximum: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.maximumThickness", getFloat, function () { return 1; })], + }, + KHR_materials_anisotropy: { + anisotropyStrength: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "anisotropy.intensity", getFloat, function () { return 1; })], + anisotropyRotation: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "anisotropy.angle", getFloat, function () { return 1; })], + }, + }, + }, +}; +var extensionsTree = { + KHR_lights_punctual: { + lights: { + __array__: { + __target__: true, + color: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "diffuse", getColor3, function () { return 3; })], + intensity: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "intensity", getFloat, function () { return 1; })], + range: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "range", getFloat, function () { return 1; })], + spot: { + innerConeAngle: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "innerAngle", getFloatBy2, function () { return 1; })], + outerConeAngle: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "angle", getFloatBy2, function () { return 1; })], + }, + }, + }, + }, +}; +/** @internal */ +var animationPointerTree = { + nodes: nodesTree, + materials: materialsTree, + cameras: camerasTree, + extensions: extensionsTree, +}; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.ts": +/*!*****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.ts ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_animation_pointer: () => (/* binding */ KHR_animation_pointer) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _KHR_animation_pointer_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./KHR_animation_pointer.data */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.data.ts"); +/* harmony import */ var _gltfPathToObjectConverter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gltfPathToObjectConverter */ "../../../dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts"); + + + + + +var NAME = "KHR_animation_pointer"; +/** + * Class to convert an animation pointer path to a smart object that + * gets data from the animation buffer and creates animations. + */ +var AnimationPointerPathToObjectConverter = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__extends)(AnimationPointerPathToObjectConverter, _super); + function AnimationPointerPathToObjectConverter(gltf) { + return _super.call(this, gltf, _KHR_animation_pointer_data__WEBPACK_IMPORTED_MODULE_2__.animationPointerTree) || this; + } + return AnimationPointerPathToObjectConverter; +}(_gltfPathToObjectConverter__WEBPACK_IMPORTED_MODULE_3__.GLTFPathToObjectConverter)); +/** + * [Specification PR](https://github.com/KhronosGroup/glTF/pull/2147) + * !!! Experimental Extension Subject to Changes !!! + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_animation_pointer = /** @class */ (function () { + /** + * @internal + */ + function KHR_animation_pointer(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this._pathToObjectConverter = new AnimationPointerPathToObjectConverter(this._loader.gltf); + } + Object.defineProperty(KHR_animation_pointer.prototype, "enabled", { + /** + * Defines whether this extension is enabled. + */ + get: function () { + return this._loader.isExtensionUsed(NAME); + }, + enumerable: false, + configurable: true + }); + /** @internal */ + KHR_animation_pointer.prototype.dispose = function () { + this._loader = null; + delete this._pathToObjectConverter; // GC + }; + /** + * Loads a glTF animation channel. + * @param context The context when loading the asset + * @param animationContext The context of the animation when loading the asset + * @param animation The glTF animation property + * @param channel The glTF animation channel property + * @param onLoad Called for each animation loaded + * @returns A void promise that resolves when the load is complete or null if not handled + */ + KHR_animation_pointer.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, onLoad) { + var _a; + var extension = (_a = channel.target.extensions) === null || _a === void 0 ? void 0 : _a.KHR_animation_pointer; + if (!extension || !this._pathToObjectConverter) { + return null; + } + if (channel.target.path !== "pointer" /* AnimationChannelTargetPath.POINTER */) { + babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.Warn("".concat(context, "/target/path: Value (").concat(channel.target.path, ") must be (").concat("pointer" /* AnimationChannelTargetPath.POINTER */, ") when using the ").concat(this.name, " extension")); + } + if (channel.target.node != undefined) { + babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.Warn("".concat(context, "/target/node: Value (").concat(channel.target.node, ") must not be present when using the ").concat(this.name, " extension")); + } + var extensionContext = "".concat(context, "/extensions/").concat(this.name); + var pointer = extension.pointer; + if (!pointer) { + throw new Error("".concat(extensionContext, ": Pointer is missing")); + } + try { + var targetInfo = this._pathToObjectConverter.convert(pointer); + return this._loader._loadAnimationChannelFromTargetInfoAsync(context, animationContext, animation, channel, targetInfo, onLoad); + } + catch (e) { + babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.Warn("".concat(extensionContext, "/pointer: Invalid pointer (").concat(pointer, ") skipped")); + return null; + } + }; + return KHR_animation_pointer; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_animation_pointer(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_draco_mesh_compression: () => (/* binding */ KHR_draco_mesh_compression) +/* harmony export */ }); +/* harmony import */ var babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Buffers/buffer */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_draco_mesh_compression"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_draco_mesh_compression/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_draco_mesh_compression = /** @class */ (function () { + /** + * @internal + */ + function KHR_draco_mesh_compression(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines whether to use the normalized flag from the glTF accessor instead of the Draco data. Defaults to true. + */ + this.useNormalizedFlagFromAccessor = true; + this._loader = loader; + this.enabled = babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_draco_mesh_compression.prototype.dispose = function () { + delete this.dracoCompression; + this._loader = null; + }; + /** + * @internal + */ + KHR_draco_mesh_compression.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) { + if (primitive.mode != undefined) { + if (primitive.mode !== 4 /* MeshPrimitiveMode.TRIANGLES */ && primitive.mode !== 5 /* MeshPrimitiveMode.TRIANGLE_STRIP */) { + throw new Error("".concat(context, ": Unsupported mode ").concat(primitive.mode)); + } + } + var attributes = {}; + var normalized = {}; + var loadAttribute = function (name, kind) { + var uniqueId = extension.attributes[name]; + if (uniqueId == undefined) { + return; + } + babylonMesh._delayInfo = babylonMesh._delayInfo || []; + if (babylonMesh._delayInfo.indexOf(kind) === -1) { + babylonMesh._delayInfo.push(kind); + } + attributes[kind] = uniqueId; + if (_this.useNormalizedFlagFromAccessor) { + var accessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.TryGet(_this._loader.gltf.accessors, primitive.attributes[name]); + if (accessor) { + normalized[kind] = accessor.normalized || false; + } + } + }; + loadAttribute("POSITION", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind); + loadAttribute("NORMAL", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind); + loadAttribute("TANGENT", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind); + loadAttribute("TEXCOORD_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind); + loadAttribute("TEXCOORD_1", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind); + loadAttribute("TEXCOORD_2", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV3Kind); + loadAttribute("TEXCOORD_3", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV4Kind); + loadAttribute("TEXCOORD_4", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV5Kind); + loadAttribute("TEXCOORD_5", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV6Kind); + loadAttribute("JOINTS_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind); + loadAttribute("WEIGHTS_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind); + loadAttribute("COLOR_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind); + var bufferView = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(extensionContext, _this._loader.gltf.bufferViews, extension.bufferView); + if (!bufferView._dracoBabylonGeometry) { + bufferView._dracoBabylonGeometry = _this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) { + var dracoCompression = _this.dracoCompression || babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.Default; + return dracoCompression._decodeMeshToGeometryForGltfAsync(babylonMesh.name, _this._loader.babylonScene, data, attributes, normalized).catch(function (error) { + throw new Error("".concat(context, ": ").concat(error.message)); + }); + }); + } + return bufferView._dracoBabylonGeometry; + }); + }; + return KHR_draco_mesh_compression; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_draco_mesh_compression(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity.ts": +/*!*************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity.ts ***! + \*************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_interactivity: () => (/* binding */ KHR_interactivity) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_FlowGraph_flowGraphCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/FlowGraph/flowGraph */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_FlowGraph_flowGraphCoordinator__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_FlowGraph_flowGraphCoordinator__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _interactivityFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interactivityFunctions */ "../../../dev/loaders/src/glTF/2.0/Extensions/interactivityFunctions.ts"); +/* harmony import */ var _interactivityPathToObjectConverter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./interactivityPathToObjectConverter */ "../../../dev/loaders/src/glTF/2.0/Extensions/interactivityPathToObjectConverter.ts"); + + + + + +var NAME = "KHR_interactivity"; +/** + * Loader extension for KHR_interactivity + */ +var KHR_interactivity = /** @class */ (function () { + /** + * @internal + * @param _loader + */ + function KHR_interactivity(_loader) { + this._loader = _loader; + /** + * The name of this extension. + */ + this.name = NAME; + this.enabled = this._loader.isExtensionUsed(NAME); + this._pathConverter = new _interactivityPathToObjectConverter__WEBPACK_IMPORTED_MODULE_3__.InteractivityPathToObjectConverter(this._loader.gltf); + } + KHR_interactivity.prototype.dispose = function () { + this._loader = null; + delete this._pathConverter; + }; + KHR_interactivity.prototype.onReady = function () { + var _a; + if (!this._loader.babylonScene || !this._pathConverter) { + return; + } + var scene = this._loader.babylonScene; + var interactivityDefinition = (_a = this._loader.gltf.extensions) === null || _a === void 0 ? void 0 : _a.KHR_interactivity; + var json = (0,_interactivityFunctions__WEBPACK_IMPORTED_MODULE_2__.convertGLTFToSerializedFlowGraph)(interactivityDefinition); + var coordinator = new babylonjs_FlowGraph_flowGraphCoordinator__WEBPACK_IMPORTED_MODULE_1__.FlowGraphCoordinator({ scene: scene }); + babylonjs_FlowGraph_flowGraphCoordinator__WEBPACK_IMPORTED_MODULE_1__.FlowGraph.Parse(json, { coordinator: coordinator, pathConverter: this._pathConverter }); + coordinator.start(); + }; + return KHR_interactivity; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_interactivity(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts": +/*!***************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts ***! + \***************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_lights: () => (/* binding */ KHR_lights) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Lights/light */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + + + +var NAME = "KHR_lights_punctual"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_lights_punctual/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_lights = /** @class */ (function () { + /** + * @internal + */ + function KHR_lights(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_lights.prototype.dispose = function () { + this._loader = null; + delete this._lights; + }; + /** @internal */ + KHR_lights.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._lights = extension.lights; + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(this._lights); + } + }; + /** + * @internal + */ + KHR_lights.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + _this._loader._allMaterialsDirtyRequired = true; + return _this._loader.loadNodeAsync(context, node, function (babylonMesh) { + var babylonLight; + var light = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(extensionContext, _this._lights, extension.light); + var name = light.name || babylonMesh.name; + _this._loader.babylonScene._blockEntityCollection = !!_this._loader._assetContainer; + switch (light.type) { + case "directional" /* KHRLightsPunctual_LightType.DIRECTIONAL */: { + var babylonDirectionalLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.DirectionalLight(name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Backward(), _this._loader.babylonScene); + babylonDirectionalLight.position.setAll(0); + babylonLight = babylonDirectionalLight; + break; + } + case "point" /* KHRLightsPunctual_LightType.POINT */: { + babylonLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.PointLight(name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), _this._loader.babylonScene); + break; + } + case "spot" /* KHRLightsPunctual_LightType.SPOT */: { + var babylonSpotLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.SpotLight(name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Backward(), 0, 1, _this._loader.babylonScene); + babylonSpotLight.angle = ((light.spot && light.spot.outerConeAngle) || Math.PI / 4) * 2; + babylonSpotLight.innerAngle = ((light.spot && light.spot.innerConeAngle) || 0) * 2; + babylonLight = babylonSpotLight; + break; + } + default: { + _this._loader.babylonScene._blockEntityCollection = false; + throw new Error("".concat(extensionContext, ": Invalid light type (").concat(light.type, ")")); + } + } + babylonLight._parentContainer = _this._loader._assetContainer; + _this._loader.babylonScene._blockEntityCollection = false; + light._babylonLight = babylonLight; + babylonLight.falloffType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light.FALLOFF_GLTF; + babylonLight.diffuse = light.color ? babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(light.color) : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + babylonLight.intensity = light.intensity == undefined ? 1 : light.intensity; + babylonLight.range = light.range == undefined ? Number.MAX_VALUE : light.range; + babylonLight.parent = babylonMesh; + _this._loader._babylonLights.push(babylonLight); + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.AddPointerMetadata(babylonLight, extensionContext); + assign(babylonMesh); + }); + }); + }; + return KHR_lights; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_lights(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts": +/*!********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts ***! + \********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_anisotropy: () => (/* binding */ KHR_materials_anisotropy) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_anisotropy"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_anisotropy) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_anisotropy = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_anisotropy(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 195; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_anisotropy.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_anisotropy.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_anisotropy.prototype._loadIridescencePropertiesAsync = function (context, properties, babylonMaterial) { + var _a, _b; + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.anisotropy.isEnabled = true; + babylonMaterial.anisotropy.intensity = (_a = properties.anisotropyStrength) !== null && _a !== void 0 ? _a : 0; + babylonMaterial.anisotropy.angle = (_b = properties.anisotropyRotation) !== null && _b !== void 0 ? _b : 0; + if (properties.anisotropyTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/anisotropyTexture"), properties.anisotropyTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Anisotropy Intensity)"); + babylonMaterial.anisotropy.texture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_anisotropy; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_anisotropy(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_clearcoat: () => (/* binding */ KHR_materials_clearcoat) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_clearcoat"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md) + * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_clearcoat = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_clearcoat(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 190; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_clearcoat.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_clearcoat.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadClearCoatPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_clearcoat.prototype._loadClearCoatPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.clearCoat.isEnabled = true; + babylonMaterial.clearCoat.useRoughnessFromMainTexture = false; + babylonMaterial.clearCoat.remapF0OnInterfaceChange = false; + if (properties.clearcoatFactor != undefined) { + babylonMaterial.clearCoat.intensity = properties.clearcoatFactor; + } + else { + babylonMaterial.clearCoat.intensity = 0; + } + if (properties.clearcoatTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatTexture"), properties.clearcoatTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (ClearCoat Intensity)"); + babylonMaterial.clearCoat.texture = texture; + })); + } + if (properties.clearcoatRoughnessFactor != undefined) { + babylonMaterial.clearCoat.roughness = properties.clearcoatRoughnessFactor; + } + else { + babylonMaterial.clearCoat.roughness = 0; + } + if (properties.clearcoatRoughnessTexture) { + properties.clearcoatRoughnessTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatRoughnessTexture"), properties.clearcoatRoughnessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (ClearCoat Roughness)"); + babylonMaterial.clearCoat.textureRoughness = texture; + })); + } + if (properties.clearcoatNormalTexture) { + properties.clearcoatNormalTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatNormalTexture"), properties.clearcoatNormalTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (ClearCoat Normal)"); + babylonMaterial.clearCoat.bumpTexture = texture; + })); + babylonMaterial.invertNormalMapX = !babylonMaterial.getScene().useRightHandedSystem; + babylonMaterial.invertNormalMapY = babylonMaterial.getScene().useRightHandedSystem; + if (properties.clearcoatNormalTexture.scale != undefined) { + babylonMaterial.clearCoat.bumpTexture.level = properties.clearcoatNormalTexture.scale; + } + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_clearcoat; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_clearcoat(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts": +/*!********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts ***! + \********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_dispersion: () => (/* binding */ KHR_materials_dispersion) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_dispersion"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/87bd64a7f5e23c84b6aef2e6082069583ed0ddb4/extensions/2.0/Khronos/KHR_materials_dispersion/README.md) + * @experimental + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_dispersion = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_dispersion(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 174; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_dispersion.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_dispersion.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadDispersionPropertiesAsync(extensionContext, material, babylonMaterial, extension)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_dispersion.prototype._loadDispersionPropertiesAsync = function (context, material, babylonMaterial, extension) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + // If transparency isn't enabled already, this extension shouldn't do anything. + // i.e. it requires either the KHR_materials_transmission or KHR_materials_translucency extensions. + if (!babylonMaterial.subSurface.isRefractionEnabled || !extension.dispersion) { + return Promise.resolve(); + } + babylonMaterial.subSurface.isDispersionEnabled = true; + babylonMaterial.subSurface.dispersion = extension.dispersion; + return Promise.resolve(); + }; + return KHR_materials_dispersion; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_dispersion(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts": +/*!***************************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts ***! + \***************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_emissive_strength: () => (/* binding */ KHR_materials_emissive_strength) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_emissive_strength"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_emissive_strength = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_emissive_strength(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 170; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_emissive_strength.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_emissive_strength.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + return _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial).then(function () { + _this._loadEmissiveProperties(extensionContext, extension, babylonMaterial); + }); + }); + }; + KHR_materials_emissive_strength.prototype._loadEmissiveProperties = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + if (properties.emissiveStrength !== undefined) { + babylonMaterial.emissiveColor.scaleToRef(properties.emissiveStrength, babylonMaterial.emissiveColor); + } + }; + return KHR_materials_emissive_strength; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_emissive_strength(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_ior.ts": +/*!*************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_ior.ts ***! + \*************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_ior: () => (/* binding */ KHR_materials_ior) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_ior"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_ior = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_ior(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 180; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_ior.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_ior.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadIorPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_ior.prototype._loadIorPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + if (properties.ior !== undefined) { + babylonMaterial.indexOfRefraction = properties.ior; + } + else { + babylonMaterial.indexOfRefraction = KHR_materials_ior._DEFAULT_IOR; + } + return Promise.resolve(); + }; + /** + * Default ior Value from the spec. + */ + KHR_materials_ior._DEFAULT_IOR = 1.5; + return KHR_materials_ior; +}()); +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_ior(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts": +/*!*********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts ***! + \*********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_iridescence: () => (/* binding */ KHR_materials_iridescence) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_iridescence"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_iridescence/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_iridescence = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_iridescence(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 195; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_iridescence.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_iridescence.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_iridescence.prototype._loadIridescencePropertiesAsync = function (context, properties, babylonMaterial) { + var _a, _b, _c, _d, _e; + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.iridescence.isEnabled = true; + babylonMaterial.iridescence.intensity = (_a = properties.iridescenceFactor) !== null && _a !== void 0 ? _a : 0; + babylonMaterial.iridescence.indexOfRefraction = (_c = (_b = properties.iridescenceIor) !== null && _b !== void 0 ? _b : properties.iridescenceIOR) !== null && _c !== void 0 ? _c : 1.3; + babylonMaterial.iridescence.minimumThickness = (_d = properties.iridescenceThicknessMinimum) !== null && _d !== void 0 ? _d : 100; + babylonMaterial.iridescence.maximumThickness = (_e = properties.iridescenceThicknessMaximum) !== null && _e !== void 0 ? _e : 400; + if (properties.iridescenceTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/iridescenceTexture"), properties.iridescenceTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Iridescence Intensity)"); + babylonMaterial.iridescence.texture = texture; + })); + } + if (properties.iridescenceThicknessTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/iridescenceThicknessTexture"), properties.iridescenceThicknessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Iridescence Thickness)"); + babylonMaterial.iridescence.thicknessTexture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_iridescence; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_iridescence(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts": +/*!*******************************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_pbrSpecularGlossiness: () => (/* binding */ KHR_materials_pbrSpecularGlossiness) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_pbrSpecularGlossiness"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_pbrSpecularGlossiness = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_pbrSpecularGlossiness(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 200; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_pbrSpecularGlossiness.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_pbrSpecularGlossiness.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadSpecularGlossinessPropertiesAsync(extensionContext, extension, babylonMaterial)); + _this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_pbrSpecularGlossiness.prototype._loadSpecularGlossinessPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.metallic = null; + babylonMaterial.roughness = null; + if (properties.diffuseFactor) { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.diffuseFactor); + babylonMaterial.alpha = properties.diffuseFactor[3]; + } + else { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + } + babylonMaterial.reflectivityColor = properties.specularFactor ? babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.specularFactor) : babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + babylonMaterial.microSurface = properties.glossinessFactor == undefined ? 1 : properties.glossinessFactor; + if (properties.diffuseTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/diffuseTexture"), properties.diffuseTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Diffuse)"); + babylonMaterial.albedoTexture = texture; + })); + } + if (properties.specularGlossinessTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularGlossinessTexture"), properties.specularGlossinessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Specular Glossiness)"); + babylonMaterial.reflectivityTexture = texture; + babylonMaterial.reflectivityTexture.hasAlpha = true; + })); + babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true; + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_pbrSpecularGlossiness; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_pbrSpecularGlossiness(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts": +/*!***************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts ***! + \***************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_sheen: () => (/* binding */ KHR_materials_sheen) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_sheen"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_sheen/README.md) + * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_sheen = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_sheen(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 190; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_sheen.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_sheen.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadSheenPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_sheen.prototype._loadSheenPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.sheen.isEnabled = true; + babylonMaterial.sheen.intensity = 1; + if (properties.sheenColorFactor != undefined) { + babylonMaterial.sheen.color = babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.sheenColorFactor); + } + else { + babylonMaterial.sheen.color = babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.Black(); + } + if (properties.sheenColorTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/sheenColorTexture"), properties.sheenColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Sheen Color)"); + babylonMaterial.sheen.texture = texture; + })); + } + if (properties.sheenRoughnessFactor !== undefined) { + babylonMaterial.sheen.roughness = properties.sheenRoughnessFactor; + } + else { + babylonMaterial.sheen.roughness = 0; + } + if (properties.sheenRoughnessTexture) { + properties.sheenRoughnessTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/sheenRoughnessTexture"), properties.sheenRoughnessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Sheen Roughness)"); + babylonMaterial.sheen.textureRoughness = texture; + })); + } + babylonMaterial.sheen.albedoScaling = true; + babylonMaterial.sheen.useRoughnessFromMainTexture = false; + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_sheen; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_sheen(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts": +/*!******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_specular: () => (/* binding */ KHR_materials_specular) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_specular"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_specular/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_specular = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_specular(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 190; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_specular.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_specular.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_specular.prototype._loadSpecularPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + if (properties.specularFactor !== undefined) { + babylonMaterial.metallicF0Factor = properties.specularFactor; + } + if (properties.specularColorFactor !== undefined) { + babylonMaterial.metallicReflectanceColor = babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.specularColorFactor); + } + if (properties.specularTexture) { + properties.specularTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularTexture"), properties.specularTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Specular F0 Strength)"); + babylonMaterial.metallicReflectanceTexture = texture; + babylonMaterial.useOnlyMetallicFromMetallicReflectanceTexture = true; + })); + } + if (properties.specularColorTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularColorTexture"), properties.specularColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Specular F0 Color)"); + babylonMaterial.reflectanceTexture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_specular; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_specular(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_translucency.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_translucency.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_translucency: () => (/* binding */ KHR_materials_translucency) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_translucency"; +/** + * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825) + * !!! Experimental Extension Subject to Changes !!! + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_translucency = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_translucency(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 174; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + if (this.enabled) { + loader.parent.transparencyAsCoverage = true; + } + } + /** @internal */ + KHR_materials_translucency.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_translucency.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadTranslucentPropertiesAsync(extensionContext, material, babylonMaterial, extension)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_translucency.prototype._loadTranslucentPropertiesAsync = function (context, material, babylonMaterial, extension) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var pbrMaterial = babylonMaterial; + // Enables "translucency" texture which represents diffusely-transmitted light. + pbrMaterial.subSurface.isTranslucencyEnabled = true; + // Since this extension models thin-surface transmission only, we must make the + // internal IOR == 1.0 and set the thickness to 0. + pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0; + pbrMaterial.subSurface.minimumThickness = 0.0; + pbrMaterial.subSurface.maximumThickness = 0.0; + // Albedo colour will tint transmission. + pbrMaterial.subSurface.useAlbedoToTintTranslucency = true; + if (extension.translucencyFactor !== undefined) { + pbrMaterial.subSurface.translucencyIntensity = extension.translucencyFactor; + } + else { + pbrMaterial.subSurface.translucencyIntensity = 0.0; + pbrMaterial.subSurface.isTranslucencyEnabled = false; + return Promise.resolve(); + } + if (extension.translucencyTexture) { + extension.translucencyTexture.nonColorData = true; + return this._loader.loadTextureInfoAsync("".concat(context, "/translucencyTexture"), extension.translucencyTexture).then(function (texture) { + pbrMaterial.subSurface.translucencyIntensityTexture = texture; + }); + } + else { + return Promise.resolve(); + } + }; + return KHR_materials_translucency; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_translucency(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_transmission: () => (/* binding */ KHR_materials_transmission) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + + + +/** + * A class to handle setting up the rendering of opaque objects to be shown through transmissive objects. + */ +var TransmissionHelper = /** @class */ (function () { + /** + * constructor + * @param options Defines the options we want to customize the helper + * @param scene The scene to add the material to + */ + function TransmissionHelper(options, scene) { + var _this = this; + this._opaqueRenderTarget = null; + this._opaqueMeshesCache = []; + this._transparentMeshesCache = []; + this._materialObservers = {}; + this._options = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, TransmissionHelper._GetDefaultOptions()), options); + this._scene = scene; + this._scene._transmissionHelper = this; + this.onErrorObservable = new babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._scene.onDisposeObservable.addOnce(function () { + _this.dispose(); + }); + this._parseScene(); + this._setupRenderTargets(); + } + /** + * Creates the default options for the helper. + * @returns the default options + */ + TransmissionHelper._GetDefaultOptions = function () { + return { + renderSize: 1024, + samples: 4, + lodGenerationScale: 1, + lodGenerationOffset: -4, + renderTargetTextureType: babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Constants.TEXTURETYPE_HALF_FLOAT, + generateMipmaps: true, + }; + }; + /** + * Updates the background according to the new options + * @param options + */ + TransmissionHelper.prototype.updateOptions = function (options) { + var _this = this; + // First check if any options are actually being changed. If not, exit. + var newValues = Object.keys(options).filter(function (key) { return _this._options[key] !== options[key]; }); + if (!newValues.length) { + return; + } + var newOptions = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, this._options), options); + var oldOptions = this._options; + this._options = newOptions; + // If size changes, recreate everything + if (newOptions.renderSize !== oldOptions.renderSize || + newOptions.renderTargetTextureType !== oldOptions.renderTargetTextureType || + newOptions.generateMipmaps !== oldOptions.generateMipmaps || + !this._opaqueRenderTarget) { + this._setupRenderTargets(); + } + else { + this._opaqueRenderTarget.samples = newOptions.samples; + this._opaqueRenderTarget.lodGenerationScale = newOptions.lodGenerationScale; + this._opaqueRenderTarget.lodGenerationOffset = newOptions.lodGenerationOffset; + } + }; + /** + * @returns the opaque render target texture or null if not available. + */ + TransmissionHelper.prototype.getOpaqueTarget = function () { + return this._opaqueRenderTarget; + }; + TransmissionHelper.prototype._shouldRenderAsTransmission = function (material) { + if (!material) { + return false; + } + if (material instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial && material.subSurface.isRefractionEnabled) { + return true; + } + return false; + }; + TransmissionHelper.prototype._addMesh = function (mesh) { + var _this = this; + this._materialObservers[mesh.uniqueId] = mesh.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)); + // we need to defer the processing because _addMesh may be called as part as an instance mesh creation, in which case some + // internal properties are not setup yet, like _sourceMesh (needed when doing mesh.material below) + babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Tools.SetImmediate(function () { + if (_this._shouldRenderAsTransmission(mesh.material)) { + mesh.material.refractionTexture = _this._opaqueRenderTarget; + if (_this._transparentMeshesCache.indexOf(mesh) === -1) { + _this._transparentMeshesCache.push(mesh); + } + } + else { + if (_this._opaqueMeshesCache.indexOf(mesh) === -1) { + _this._opaqueMeshesCache.push(mesh); + } + } + }); + }; + TransmissionHelper.prototype._removeMesh = function (mesh) { + mesh.onMaterialChangedObservable.remove(this._materialObservers[mesh.uniqueId]); + delete this._materialObservers[mesh.uniqueId]; + var idx = this._transparentMeshesCache.indexOf(mesh); + if (idx !== -1) { + this._transparentMeshesCache.splice(idx, 1); + } + idx = this._opaqueMeshesCache.indexOf(mesh); + if (idx !== -1) { + this._opaqueMeshesCache.splice(idx, 1); + } + }; + TransmissionHelper.prototype._parseScene = function () { + this._scene.meshes.forEach(this._addMesh.bind(this)); + // Listen for when a mesh is added to the scene and add it to our cache lists. + this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)); + // Listen for when a mesh is removed from to the scene and remove it from our cache lists. + this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this)); + }; + // When one of the meshes in the scene has its material changed, make sure that it's in the correct cache list. + TransmissionHelper.prototype._onMeshMaterialChanged = function (mesh) { + var transparentIdx = this._transparentMeshesCache.indexOf(mesh); + var opaqueIdx = this._opaqueMeshesCache.indexOf(mesh); + // If the material is transparent, make sure that it's added to the transparent list and removed from the opaque list + var useTransmission = this._shouldRenderAsTransmission(mesh.material); + if (useTransmission) { + if (mesh.material instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial) { + mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget; + } + if (opaqueIdx !== -1) { + this._opaqueMeshesCache.splice(opaqueIdx, 1); + this._transparentMeshesCache.push(mesh); + } + else if (transparentIdx === -1) { + this._transparentMeshesCache.push(mesh); + } + // If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list + } + else { + if (transparentIdx !== -1) { + this._transparentMeshesCache.splice(transparentIdx, 1); + this._opaqueMeshesCache.push(mesh); + } + else if (opaqueIdx === -1) { + this._opaqueMeshesCache.push(mesh); + } + } + }; + /** + * @internal + * Check if the opaque render target has not been disposed and can still be used. + * @returns + */ + TransmissionHelper.prototype._isRenderTargetValid = function () { + var _a; + return ((_a = this._opaqueRenderTarget) === null || _a === void 0 ? void 0 : _a.getInternalTexture()) !== null; + }; + /** + * @internal + * Setup the render targets according to the specified options. + */ + TransmissionHelper.prototype._setupRenderTargets = function () { + var _this = this; + var _a, _b; + if (this._opaqueRenderTarget) { + this._opaqueRenderTarget.dispose(); + } + this._opaqueRenderTarget = new babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.RenderTargetTexture("opaqueSceneTexture", this._options.renderSize, this._scene, this._options.generateMipmaps, undefined, this._options.renderTargetTextureType); + this._opaqueRenderTarget.ignoreCameraViewport = true; + this._opaqueRenderTarget.renderList = this._opaqueMeshesCache; + this._opaqueRenderTarget.clearColor = (_b = (_a = this._options.clearColor) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : this._scene.clearColor.clone(); + this._opaqueRenderTarget.gammaSpace = false; + this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale; + this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset; + this._opaqueRenderTarget.samples = this._options.samples; + this._opaqueRenderTarget.renderSprites = true; + this._opaqueRenderTarget.renderParticles = true; + var sceneImageProcessingapplyByPostProcess; + var saveSceneEnvIntensity; + this._opaqueRenderTarget.onBeforeBindObservable.add(function (opaqueRenderTarget) { + saveSceneEnvIntensity = _this._scene.environmentIntensity; + _this._scene.environmentIntensity = 1.0; + sceneImageProcessingapplyByPostProcess = _this._scene.imageProcessingConfiguration.applyByPostProcess; + if (!_this._options.clearColor) { + _this._scene.clearColor.toLinearSpaceToRef(opaqueRenderTarget.clearColor, _this._scene.getEngine().useExactSrgbConversions); + } + else { + opaqueRenderTarget.clearColor.copyFrom(_this._options.clearColor); + } + // we do not use the applyByPostProcess setter to avoid flagging all the materials as "image processing dirty"! + _this._scene.imageProcessingConfiguration._applyByPostProcess = true; + }); + this._opaqueRenderTarget.onAfterUnbindObservable.add(function () { + _this._scene.environmentIntensity = saveSceneEnvIntensity; + _this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess; + }); + this._transparentMeshesCache.forEach(function (mesh) { + if (_this._shouldRenderAsTransmission(mesh.material)) { + mesh.material.refractionTexture = _this._opaqueRenderTarget; + } + }); + }; + /** + * Dispose all the elements created by the Helper. + */ + TransmissionHelper.prototype.dispose = function () { + this._scene._transmissionHelper = undefined; + if (this._opaqueRenderTarget) { + this._opaqueRenderTarget.dispose(); + this._opaqueRenderTarget = null; + } + this._transparentMeshesCache = []; + this._opaqueMeshesCache = []; + }; + return TransmissionHelper; +}()); +var NAME = "KHR_materials_transmission"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_transmission/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_transmission = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_transmission(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 175; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + if (this.enabled) { + loader.parent.transparencyAsCoverage = true; + } + } + /** @internal */ + KHR_materials_transmission.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_transmission.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadTransparentPropertiesAsync(extensionContext, material, babylonMaterial, extension)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_transmission.prototype._loadTransparentPropertiesAsync = function (context, material, babylonMaterial, extension) { + var _a, _b; + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var pbrMaterial = babylonMaterial; + // Enables "refraction" texture which represents transmitted light. + pbrMaterial.subSurface.isRefractionEnabled = true; + // Since this extension models thin-surface transmission only, we must make IOR = 1.0 + pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0; + // Albedo colour will tint transmission. + pbrMaterial.subSurface.useAlbedoToTintRefraction = true; + if (extension.transmissionFactor !== undefined) { + pbrMaterial.subSurface.refractionIntensity = extension.transmissionFactor; + var scene = pbrMaterial.getScene(); + if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper) { + new TransmissionHelper({}, pbrMaterial.getScene()); + } + else if (pbrMaterial.subSurface.refractionIntensity && !((_a = scene._transmissionHelper) === null || _a === void 0 ? void 0 : _a._isRenderTargetValid())) { + // If the render target is not valid, recreate it. + (_b = scene._transmissionHelper) === null || _b === void 0 ? void 0 : _b._setupRenderTargets(); + } + } + else { + pbrMaterial.subSurface.refractionIntensity = 0.0; + pbrMaterial.subSurface.isRefractionEnabled = false; + return Promise.resolve(); + } + pbrMaterial.subSurface.minimumThickness = 0.0; + pbrMaterial.subSurface.maximumThickness = 0.0; + if (extension.transmissionTexture) { + extension.transmissionTexture.nonColorData = true; + return this._loader.loadTextureInfoAsync("".concat(context, "/transmissionTexture"), extension.transmissionTexture, undefined).then(function (texture) { + pbrMaterial.subSurface.refractionIntensityTexture = texture; + pbrMaterial.subSurface.useGltfStyleTextures = true; + }); + } + else { + return Promise.resolve(); + } + }; + return KHR_materials_transmission; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_transmission(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts": +/*!***************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts ***! + \***************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_unlit: () => (/* binding */ KHR_materials_unlit) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_unlit"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_unlit/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_unlit = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_unlit(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 210; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_unlit.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_unlit.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function () { + return _this._loadUnlitPropertiesAsync(context, material, babylonMaterial); + }); + }; + KHR_materials_unlit.prototype._loadUnlitPropertiesAsync = function (context, material, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.unlit = true; + var properties = material.pbrMetallicRoughness; + if (properties) { + if (properties.baseColorFactor) { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.baseColorFactor); + babylonMaterial.alpha = properties.baseColorFactor[3]; + } + else { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + } + if (properties.baseColorTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/baseColorTexture"), properties.baseColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Base Color)"); + babylonMaterial.albedoTexture = texture; + })); + } + } + if (material.doubleSided) { + babylonMaterial.backFaceCulling = false; + babylonMaterial.twoSidedLighting = true; + } + this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial); + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_unlit; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_unlit(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts": +/*!******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_variants: () => (/* binding */ KHR_materials_variants) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/mesh */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_variants"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_variants/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_variants = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_variants(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_variants.prototype.dispose = function () { + this._loader = null; + }; + /** + * Gets the list of available variant names for this asset. + * @param rootMesh The glTF root mesh + * @returns the list of all the variant names for this model + */ + KHR_materials_variants.GetAvailableVariants = function (rootMesh) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + return []; + } + return Object.keys(extensionMetadata.variants); + }; + /** + * Gets the list of available variant names for this asset. + * @param rootMesh The glTF root mesh + * @returns the list of all the variant names for this model + */ + KHR_materials_variants.prototype.getAvailableVariants = function (rootMesh) { + return KHR_materials_variants.GetAvailableVariants(rootMesh); + }; + /** + * Select a variant given a variant name or a list of variant names. + * @param rootMesh The glTF root mesh + * @param variantName The variant name(s) to select. + */ + KHR_materials_variants.SelectVariant = function (rootMesh, variantName) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + throw new Error("Cannot select variant on a glTF mesh that does not have the ".concat(NAME, " extension")); + } + var select = function (variantName) { + var entries = extensionMetadata.variants[variantName]; + if (entries) { + for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { + var entry = entries_1[_i]; + entry.mesh.material = entry.material; + } + } + }; + if (variantName instanceof Array) { + for (var _i = 0, variantName_1 = variantName; _i < variantName_1.length; _i++) { + var name_1 = variantName_1[_i]; + select(name_1); + } + } + else { + select(variantName); + } + extensionMetadata.lastSelected = variantName; + }; + /** + * Select a variant given a variant name or a list of variant names. + * @param rootMesh The glTF root mesh + * @param variantName The variant name(s) to select. + */ + KHR_materials_variants.prototype.selectVariant = function (rootMesh, variantName) { + KHR_materials_variants.SelectVariant(rootMesh, variantName); + }; + /** + * Reset back to the original before selecting a variant. + * @param rootMesh The glTF root mesh + */ + KHR_materials_variants.Reset = function (rootMesh) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + throw new Error("Cannot reset on a glTF mesh that does not have the ".concat(NAME, " extension")); + } + for (var _i = 0, _a = extensionMetadata.original; _i < _a.length; _i++) { + var entry = _a[_i]; + entry.mesh.material = entry.material; + } + extensionMetadata.lastSelected = null; + }; + /** + * Reset back to the original before selecting a variant. + * @param rootMesh The glTF root mesh + */ + KHR_materials_variants.prototype.reset = function (rootMesh) { + KHR_materials_variants.Reset(rootMesh); + }; + /** + * Gets the last selected variant name(s) or null if original. + * @param rootMesh The glTF root mesh + * @returns The selected variant name(s). + */ + KHR_materials_variants.GetLastSelectedVariant = function (rootMesh) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the ".concat(NAME, " extension")); + } + return extensionMetadata.lastSelected; + }; + /** + * Gets the last selected variant name(s) or null if original. + * @param rootMesh The glTF root mesh + * @returns The selected variant name(s). + */ + KHR_materials_variants.prototype.getLastSelectedVariant = function (rootMesh) { + return KHR_materials_variants.GetLastSelectedVariant(rootMesh); + }; + KHR_materials_variants._GetExtensionMetadata = function (rootMesh) { + var _a, _b; + return ((_b = (_a = rootMesh === null || rootMesh === void 0 ? void 0 : rootMesh._internalMetadata) === null || _a === void 0 ? void 0 : _a.gltf) === null || _b === void 0 ? void 0 : _b[NAME]) || null; + }; + /** @internal */ + KHR_materials_variants.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._variants = extension.variants; + } + }; + /** + * @internal + */ + KHR_materials_variants.prototype._loadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, function (babylonMesh) { + assign(babylonMesh); + if (babylonMesh instanceof babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.Mesh) { + var babylonDrawMode = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader._GetDrawMode(context, primitive.mode); + var root_1 = _this._loader.rootBabylonMesh; + var metadata = root_1 ? (root_1._internalMetadata = root_1._internalMetadata || {}) : {}; + var gltf = (metadata.gltf = metadata.gltf || {}); + var extensionMetadata_1 = (gltf[NAME] = gltf[NAME] || { lastSelected: null, original: [], variants: {} }); + // Store the original material. + extensionMetadata_1.original.push({ mesh: babylonMesh, material: babylonMesh.material }); + var _loop_1 = function (mappingIndex) { + var mapping = extension.mappings[mappingIndex]; + var material = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/mappings/").concat(mappingIndex, "/material"), _this._loader.gltf.materials, mapping.material); + promises.push(_this._loader._loadMaterialAsync("#/materials/".concat(mapping.material), material, babylonMesh, babylonDrawMode, function (babylonMaterial) { + var _loop_2 = function (mappingVariantIndex) { + var variantIndex = mapping.variants[mappingVariantIndex]; + var variant = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("/extensions/".concat(NAME, "/variants/").concat(variantIndex), _this._variants, variantIndex); + extensionMetadata_1.variants[variant.name] = extensionMetadata_1.variants[variant.name] || []; + extensionMetadata_1.variants[variant.name].push({ + mesh: babylonMesh, + material: babylonMaterial, + }); + // Replace the target when original mesh is cloned + babylonMesh.onClonedObservable.add(function (newOne) { + var newMesh = newOne; + var metadata = null; + var newRoot = newMesh; + // Find root to get medata + do { + newRoot = newRoot.parent; + if (!newRoot) { + return; + } + metadata = KHR_materials_variants._GetExtensionMetadata(newRoot); + } while (metadata === null); + // Need to clone the metadata on the root (first time only) + if (root_1 && metadata === KHR_materials_variants._GetExtensionMetadata(root_1)) { + // Copy main metadata + newRoot._internalMetadata = {}; + for (var key in root_1._internalMetadata) { + newRoot._internalMetadata[key] = root_1._internalMetadata[key]; + } + // Copy the gltf metadata + newRoot._internalMetadata.gltf = []; + for (var key in root_1._internalMetadata.gltf) { + newRoot._internalMetadata.gltf[key] = root_1._internalMetadata.gltf[key]; + } + // Duplicate the extension specific metadata + newRoot._internalMetadata.gltf[NAME] = { lastSelected: null, original: [], variants: {} }; + for (var _i = 0, _a = metadata.original; _i < _a.length; _i++) { + var original = _a[_i]; + newRoot._internalMetadata.gltf[NAME].original.push({ + mesh: original.mesh, + material: original.material, + }); + } + for (var key in metadata.variants) { + if (Object.prototype.hasOwnProperty.call(metadata.variants, key)) { + newRoot._internalMetadata.gltf[NAME].variants[key] = []; + for (var _b = 0, _c = metadata.variants[key]; _b < _c.length; _b++) { + var variantEntry = _c[_b]; + newRoot._internalMetadata.gltf[NAME].variants[key].push({ + mesh: variantEntry.mesh, + material: variantEntry.material, + }); + } + } + } + metadata = newRoot._internalMetadata.gltf[NAME]; + } + // Relocate + for (var _d = 0, _e = metadata.original; _d < _e.length; _d++) { + var target = _e[_d]; + if (target.mesh === babylonMesh) { + target.mesh = newMesh; + } + } + for (var _f = 0, _g = metadata.variants[variant.name]; _f < _g.length; _f++) { + var target = _g[_f]; + if (target.mesh === babylonMesh) { + target.mesh = newMesh; + } + } + }); + }; + for (var mappingVariantIndex = 0; mappingVariantIndex < mapping.variants.length; ++mappingVariantIndex) { + _loop_2(mappingVariantIndex); + } + })); + }; + // For each mapping, look at the variants and make a new entry for them. + for (var mappingIndex = 0; mappingIndex < extension.mappings.length; ++mappingIndex) { + _loop_1(mappingIndex); + } + } + })); + return Promise.all(promises).then(function (_a) { + var babylonMesh = _a[0]; + return babylonMesh; + }); + }); + }; + return KHR_materials_variants; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_variants(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts": +/*!****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts ***! + \****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_volume: () => (/* binding */ KHR_materials_volume) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_volume"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_volume/README.md) + * @since 5.0.0 + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_volume = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_volume(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 173; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + if (this.enabled) { + // We need to disable instance usage because the attenuation factor depends on the node scale of each individual mesh + this._loader._disableInstancedMesh++; + } + } + /** @internal */ + KHR_materials_volume.prototype.dispose = function () { + if (this.enabled) { + this._loader._disableInstancedMesh--; + } + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_volume.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadVolumePropertiesAsync(extensionContext, material, babylonMaterial, extension)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_volume.prototype._loadVolumePropertiesAsync = function (context, material, babylonMaterial, extension) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + // If transparency isn't enabled already, this extension shouldn't do anything. + // i.e. it requires either the KHR_materials_transmission or KHR_materials_translucency extensions. + if ((!babylonMaterial.subSurface.isRefractionEnabled && !babylonMaterial.subSurface.isTranslucencyEnabled) || !extension.thicknessFactor) { + return Promise.resolve(); + } + // IOR in this extension only affects interior. + babylonMaterial.subSurface.volumeIndexOfRefraction = babylonMaterial.indexOfRefraction; + var attenuationDistance = extension.attenuationDistance !== undefined ? extension.attenuationDistance : Number.MAX_VALUE; + babylonMaterial.subSurface.tintColorAtDistance = attenuationDistance; + if (extension.attenuationColor !== undefined && extension.attenuationColor.length == 3) { + babylonMaterial.subSurface.tintColor.copyFromFloats(extension.attenuationColor[0], extension.attenuationColor[1], extension.attenuationColor[2]); + } + babylonMaterial.subSurface.minimumThickness = 0.0; + babylonMaterial.subSurface.maximumThickness = extension.thicknessFactor; + babylonMaterial.subSurface.useThicknessAsDepth = true; + if (extension.thicknessTexture) { + extension.thicknessTexture.nonColorData = true; + return this._loader.loadTextureInfoAsync("".concat(context, "/thicknessTexture"), extension.thicknessTexture).then(function (texture) { + babylonMaterial.subSurface.thicknessTexture = texture; + babylonMaterial.subSurface.useGltfStyleTextures = true; + }); + } + else { + return Promise.resolve(); + } + }; + return KHR_materials_volume; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_volume(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts": +/*!*****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_mesh_quantization: () => (/* binding */ KHR_mesh_quantization) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "KHR_mesh_quantization"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_mesh_quantization = /** @class */ (function () { + /** + * @internal + */ + function KHR_mesh_quantization(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this.enabled = loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_mesh_quantization.prototype.dispose = function () { }; + return KHR_mesh_quantization; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_mesh_quantization(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts": +/*!**************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_texture_basisu: () => (/* binding */ KHR_texture_basisu) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "KHR_texture_basisu"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_texture_basisu = /** @class */ (function () { + /** + * @internal + */ + function KHR_texture_basisu(loader) { + /** The name of this extension. */ + this.name = NAME; + this._loader = loader; + this.enabled = loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_texture_basisu.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_texture_basisu.prototype._loadTextureAsync = function (context, texture, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, texture, this.name, function (extensionContext, extension) { + var sampler = texture.sampler == undefined ? _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.DefaultSampler : _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/sampler"), _this._loader.gltf.samplers, texture.sampler); + var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/source"), _this._loader.gltf.images, extension.source); + return _this._loader._createTextureAsync(context, sampler, image, function (babylonTexture) { + assign(babylonTexture); + }, texture._textureInfo.nonColorData ? { useRGBAIfASTCBC7NotAvailableWhenUASTC: true } : undefined, !texture._textureInfo.nonColorData); + }); + }; + return KHR_texture_basisu; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_texture_basisu(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts": +/*!*****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_texture_transform: () => (/* binding */ KHR_texture_transform) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/Textures/texture */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_texture_transform"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_transform/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_texture_transform = /** @class */ (function () { + /** + * @internal + */ + function KHR_texture_transform(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_texture_transform.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_texture_transform.prototype.loadTextureInfoAsync = function (context, textureInfo, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, textureInfo, this.name, function (extensionContext, extension) { + return _this._loader.loadTextureInfoAsync(context, textureInfo, function (babylonTexture) { + if (!(babylonTexture instanceof babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__.Texture)) { + throw new Error("".concat(extensionContext, ": Texture type not supported")); + } + if (extension.offset) { + babylonTexture.uOffset = extension.offset[0]; + babylonTexture.vOffset = extension.offset[1]; + } + // Always rotate around the origin. + babylonTexture.uRotationCenter = 0; + babylonTexture.vRotationCenter = 0; + if (extension.rotation) { + babylonTexture.wAng = -extension.rotation; + } + if (extension.scale) { + babylonTexture.uScale = extension.scale[0]; + babylonTexture.vScale = extension.scale[1]; + } + if (extension.texCoord != undefined) { + babylonTexture.coordinatesIndex = extension.texCoord; + } + assign(babylonTexture); + }); + }); + }; + return KHR_texture_transform; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_texture_transform(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts": +/*!***********************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts ***! + \***********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_xmp_json_ld: () => (/* binding */ KHR_xmp_json_ld) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "KHR_xmp_json_ld"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_xmp_json_ld/README.md) + * @since 5.0.0 + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_xmp_json_ld = /** @class */ (function () { + /** + * @internal + */ + function KHR_xmp_json_ld(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 100; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_xmp_json_ld.prototype.dispose = function () { + this._loader = null; + }; + /** + * Called after the loader state changes to LOADING. + */ + KHR_xmp_json_ld.prototype.onLoading = function () { + var _a, _b, _c; + if (this._loader.rootBabylonMesh === null) { + return; + } + var xmp_gltf = (_a = this._loader.gltf.extensions) === null || _a === void 0 ? void 0 : _a.KHR_xmp_json_ld; + var xmp_node = (_c = (_b = this._loader.gltf.asset) === null || _b === void 0 ? void 0 : _b.extensions) === null || _c === void 0 ? void 0 : _c.KHR_xmp_json_ld; + if (xmp_gltf && xmp_node) { + var packet = +xmp_node.packet; + if (xmp_gltf.packets && packet < xmp_gltf.packets.length) { + this._loader.rootBabylonMesh.metadata = this._loader.rootBabylonMesh.metadata || {}; + this._loader.rootBabylonMesh.metadata.xmp = xmp_gltf.packets[packet]; + } + } + }; + return KHR_xmp_json_ld; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_xmp_json_ld(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts": +/*!**************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_audio_emitter: () => (/* binding */ MSFT_audio_emitter) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Audio/weightedsound */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + + +var NAME = "MSFT_audio_emitter"; +/** + * [Specification](https://github.com/najadojo/glTF/blob/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter/README.md) + * !!! Experimental Extension Subject to Changes !!! + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_audio_emitter = /** @class */ (function () { + /** + * @internal + */ + function MSFT_audio_emitter(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_audio_emitter.prototype.dispose = function () { + this._loader = null; + this._clips = null; + this._emitters = null; + }; + /** @internal */ + MSFT_audio_emitter.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._clips = extension.clips; + this._emitters = extension.emitters; + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(this._clips); + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(this._emitters); + } + }; + /** + * @internal + */ + MSFT_audio_emitter.prototype.loadSceneAsync = function (context, scene) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadSceneAsync(context, scene)); + for (var _i = 0, _a = extension.emitters; _i < _a.length; _i++) { + var emitterIndex = _a[_i]; + var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/emitters"), _this._emitters, emitterIndex); + if (emitter.refDistance != undefined || + emitter.maxDistance != undefined || + emitter.rolloffFactor != undefined || + emitter.distanceModel != undefined || + emitter.innerAngle != undefined || + emitter.outerAngle != undefined) { + throw new Error("".concat(extensionContext, ": Direction or Distance properties are not allowed on emitters attached to a scene")); + } + promises.push(_this._loadEmitterAsync("".concat(extensionContext, "/emitters/").concat(emitter.index), emitter)); + } + return Promise.all(promises).then(function () { }); + }); + }; + /** + * @internal + */ + MSFT_audio_emitter.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + var promises = new Array(); + return _this._loader + .loadNodeAsync(extensionContext, node, function (babylonMesh) { + var _loop_1 = function (emitterIndex) { + var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/emitters"), _this._emitters, emitterIndex); + promises.push(_this._loadEmitterAsync("".concat(extensionContext, "/emitters/").concat(emitter.index), emitter).then(function () { + for (var _i = 0, _a = emitter._babylonSounds; _i < _a.length; _i++) { + var sound = _a[_i]; + sound.attachToMesh(babylonMesh); + if (emitter.innerAngle != undefined || emitter.outerAngle != undefined) { + sound.setLocalDirectionToMesh(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Forward()); + sound.setDirectionalCone(2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.innerAngle == undefined ? Math.PI : emitter.innerAngle), 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.outerAngle == undefined ? Math.PI : emitter.outerAngle), 0); + } + } + })); + }; + for (var _i = 0, _a = extension.emitters; _i < _a.length; _i++) { + var emitterIndex = _a[_i]; + _loop_1(emitterIndex); + } + assign(babylonMesh); + }) + .then(function (babylonMesh) { + return Promise.all(promises).then(function () { + return babylonMesh; + }); + }); + }); + }; + /** + * @internal + */ + MSFT_audio_emitter.prototype.loadAnimationAsync = function (context, animation) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, animation, this.name, function (extensionContext, extension) { + return _this._loader.loadAnimationAsync(context, animation).then(function (babylonAnimationGroup) { + var promises = new Array(); + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(extension.events); + for (var _i = 0, _a = extension.events; _i < _a.length; _i++) { + var event_1 = _a[_i]; + promises.push(_this._loadAnimationEventAsync("".concat(extensionContext, "/events/").concat(event_1.index), context, animation, event_1, babylonAnimationGroup)); + } + return Promise.all(promises).then(function () { + return babylonAnimationGroup; + }); + }); + }); + }; + MSFT_audio_emitter.prototype._loadClipAsync = function (context, clip) { + if (clip._objectURL) { + return clip._objectURL; + } + var promise; + if (clip.uri) { + promise = this._loader.loadUriAsync(context, clip, clip.uri); + } + else { + var bufferView = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(context, "/bufferView"), this._loader.gltf.bufferViews, clip.bufferView); + promise = this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView); + } + clip._objectURL = promise.then(function (data) { + return URL.createObjectURL(new Blob([data], { type: clip.mimeType })); + }); + return clip._objectURL; + }; + MSFT_audio_emitter.prototype._loadEmitterAsync = function (context, emitter) { + var _this = this; + emitter._babylonSounds = emitter._babylonSounds || []; + if (!emitter._babylonData) { + var clipPromises = new Array(); + var name_1 = emitter.name || "emitter".concat(emitter.index); + var options_1 = { + loop: false, + autoplay: false, + volume: emitter.volume == undefined ? 1 : emitter.volume, + }; + var _loop_2 = function (i) { + var clipContext = "/extensions/".concat(this_1.name, "/clips"); + var clip = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(clipContext, this_1._clips, emitter.clips[i].clip); + clipPromises.push(this_1._loadClipAsync("".concat(clipContext, "/").concat(emitter.clips[i].clip), clip).then(function (objectURL) { + var sound = (emitter._babylonSounds[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Sound(name_1, objectURL, _this._loader.babylonScene, null, options_1)); + sound.refDistance = emitter.refDistance || 1; + sound.maxDistance = emitter.maxDistance || 256; + sound.rolloffFactor = emitter.rolloffFactor || 1; + sound.distanceModel = emitter.distanceModel || "exponential"; + })); + }; + var this_1 = this; + for (var i = 0; i < emitter.clips.length; i++) { + _loop_2(i); + } + var promise = Promise.all(clipPromises).then(function () { + var weights = emitter.clips.map(function (clip) { + return clip.weight || 1; + }); + var weightedSound = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.WeightedSound(emitter.loop || false, emitter._babylonSounds, weights); + if (emitter.innerAngle) { + weightedSound.directionalConeInnerAngle = 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.innerAngle); + } + if (emitter.outerAngle) { + weightedSound.directionalConeOuterAngle = 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.outerAngle); + } + if (emitter.volume) { + weightedSound.volume = emitter.volume; + } + emitter._babylonData.sound = weightedSound; + }); + emitter._babylonData = { + loaded: promise, + }; + } + return emitter._babylonData.loaded; + }; + MSFT_audio_emitter.prototype._getEventAction = function (context, sound, action, time, startOffset) { + switch (action) { + case "play" /* IMSFTAudioEmitter_AnimationEventAction.play */: { + return function (currentFrame) { + var frameOffset = (startOffset || 0) + (currentFrame - time); + sound.play(frameOffset); + }; + } + case "stop" /* IMSFTAudioEmitter_AnimationEventAction.stop */: { + return function () { + sound.stop(); + }; + } + case "pause" /* IMSFTAudioEmitter_AnimationEventAction.pause */: { + return function () { + sound.pause(); + }; + } + default: { + throw new Error("".concat(context, ": Unsupported action ").concat(action)); + } + } + }; + MSFT_audio_emitter.prototype._loadAnimationEventAsync = function (context, animationContext, animation, event, babylonAnimationGroup) { + var _this = this; + if (babylonAnimationGroup.targetedAnimations.length == 0) { + return Promise.resolve(); + } + var babylonAnimation = babylonAnimationGroup.targetedAnimations[0]; + var emitterIndex = event.emitter; + var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("/extensions/".concat(this.name, "/emitters"), this._emitters, emitterIndex); + return this._loadEmitterAsync(context, emitter).then(function () { + var sound = emitter._babylonData.sound; + if (sound) { + var babylonAnimationEvent = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.AnimationEvent(event.time, _this._getEventAction(context, sound, event.action, event.time, event.startOffset)); + babylonAnimation.animation.addEvent(babylonAnimationEvent); + // Make sure all started audio stops when this animation is terminated. + babylonAnimationGroup.onAnimationGroupEndObservable.add(function () { + sound.stop(); + }); + babylonAnimationGroup.onAnimationGroupPauseObservable.add(function () { + sound.pause(); + }); + } + }); + }; + return MSFT_audio_emitter; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_audio_emitter(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts": +/*!****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_lod: () => (/* binding */ MSFT_lod) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/deferred */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "MSFT_lod"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/MSFT_lod/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_lod = /** @class */ (function () { + /** + * @internal + */ + function MSFT_lod(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 100; + /** + * Maximum number of LODs to load, starting from the lowest LOD. + */ + this.maxLODsToLoad = 10; + /** + * Observable raised when all node LODs of one level are loaded. + * The event data is the index of the loaded LOD starting from zero. + * Dispose the loader to cancel the loading of the next level of LODs. + */ + this.onNodeLODsLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when all material LODs of one level are loaded. + * The event data is the index of the loaded LOD starting from zero. + * Dispose the loader to cancel the loading of the next level of LODs. + */ + this.onMaterialLODsLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._bufferLODs = new Array(); + this._nodeIndexLOD = null; + this._nodeSignalLODs = new Array(); + this._nodePromiseLODs = new Array(); + this._nodeBufferLODs = new Array(); + this._materialIndexLOD = null; + this._materialSignalLODs = new Array(); + this._materialPromiseLODs = new Array(); + this._materialBufferLODs = new Array(); + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_lod.prototype.dispose = function () { + this._loader = null; + this._nodeIndexLOD = null; + this._nodeSignalLODs.length = 0; + this._nodePromiseLODs.length = 0; + this._nodeBufferLODs.length = 0; + this._materialIndexLOD = null; + this._materialSignalLODs.length = 0; + this._materialPromiseLODs.length = 0; + this._materialBufferLODs.length = 0; + this.onMaterialLODsLoadedObservable.clear(); + this.onNodeLODsLoadedObservable.clear(); + }; + /** @internal */ + MSFT_lod.prototype.onReady = function () { + var _this = this; + var _loop_1 = function (indexLOD) { + var promise = Promise.all(this_1._nodePromiseLODs[indexLOD]).then(function () { + if (indexLOD !== 0) { + _this._loader.endPerformanceCounter("Node LOD ".concat(indexLOD)); + _this._loader.log("Loaded node LOD ".concat(indexLOD)); + } + _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD); + if (indexLOD !== _this._nodePromiseLODs.length - 1) { + _this._loader.startPerformanceCounter("Node LOD ".concat(indexLOD + 1)); + _this._loadBufferLOD(_this._nodeBufferLODs, indexLOD + 1); + if (_this._nodeSignalLODs[indexLOD]) { + _this._nodeSignalLODs[indexLOD].resolve(); + } + } + }); + this_1._loader._completePromises.push(promise); + }; + var this_1 = this; + for (var indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) { + _loop_1(indexLOD); + } + var _loop_2 = function (indexLOD) { + var promise = Promise.all(this_2._materialPromiseLODs[indexLOD]).then(function () { + if (indexLOD !== 0) { + _this._loader.endPerformanceCounter("Material LOD ".concat(indexLOD)); + _this._loader.log("Loaded material LOD ".concat(indexLOD)); + } + _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD); + if (indexLOD !== _this._materialPromiseLODs.length - 1) { + _this._loader.startPerformanceCounter("Material LOD ".concat(indexLOD + 1)); + _this._loadBufferLOD(_this._materialBufferLODs, indexLOD + 1); + if (_this._materialSignalLODs[indexLOD]) { + _this._materialSignalLODs[indexLOD].resolve(); + } + } + }); + this_2._loader._completePromises.push(promise); + }; + var this_2 = this; + for (var indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) { + _loop_2(indexLOD); + } + }; + /** + * @internal + */ + MSFT_lod.prototype.loadSceneAsync = function (context, scene) { + var promise = this._loader.loadSceneAsync(context, scene); + this._loadBufferLOD(this._bufferLODs, 0); + return promise; + }; + /** + * @internal + */ + MSFT_lod.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + var firstPromise; + var nodeLODs = _this._getLODs(extensionContext, node, _this._loader.gltf.nodes, extension.ids); + _this._loader.logOpen("".concat(extensionContext)); + var _loop_3 = function (indexLOD) { + var nodeLOD = nodeLODs[indexLOD]; + if (indexLOD !== 0) { + _this._nodeIndexLOD = indexLOD; + _this._nodeSignalLODs[indexLOD] = _this._nodeSignalLODs[indexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + } + var assignWrap = function (babylonTransformNode) { + assign(babylonTransformNode); + babylonTransformNode.setEnabled(false); + }; + var promise = _this._loader.loadNodeAsync("/nodes/".concat(nodeLOD.index), nodeLOD, assignWrap).then(function (babylonMesh) { + if (indexLOD !== 0) { + // TODO: should not rely on _babylonTransformNode + var previousNodeLOD = nodeLODs[indexLOD - 1]; + if (previousNodeLOD._babylonTransformNode) { + _this._disposeTransformNode(previousNodeLOD._babylonTransformNode); + delete previousNodeLOD._babylonTransformNode; + } + } + babylonMesh.setEnabled(true); + return babylonMesh; + }); + _this._nodePromiseLODs[indexLOD] = _this._nodePromiseLODs[indexLOD] || []; + if (indexLOD === 0) { + firstPromise = promise; + } + else { + _this._nodeIndexLOD = null; + _this._nodePromiseLODs[indexLOD].push(promise); + } + }; + for (var indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) { + _loop_3(indexLOD); + } + _this._loader.logClose(); + return firstPromise; + }); + }; + /** + * @internal + */ + MSFT_lod.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) { + var _this = this; + // Don't load material LODs if already loading a node LOD. + if (this._nodeIndexLOD) { + return null; + } + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var firstPromise; + var materialLODs = _this._getLODs(extensionContext, material, _this._loader.gltf.materials, extension.ids); + _this._loader.logOpen("".concat(extensionContext)); + var _loop_4 = function (indexLOD) { + var materialLOD = materialLODs[indexLOD]; + if (indexLOD !== 0) { + _this._materialIndexLOD = indexLOD; + } + var promise = _this._loader + ._loadMaterialAsync("/materials/".concat(materialLOD.index), materialLOD, babylonMesh, babylonDrawMode, function (babylonMaterial) { + if (indexLOD === 0) { + assign(babylonMaterial); + } + }) + .then(function (babylonMaterial) { + if (indexLOD !== 0) { + assign(babylonMaterial); + // TODO: should not rely on _data + var previousDataLOD = materialLODs[indexLOD - 1]._data; + if (previousDataLOD[babylonDrawMode]) { + _this._disposeMaterials([previousDataLOD[babylonDrawMode].babylonMaterial]); + delete previousDataLOD[babylonDrawMode]; + } + } + return babylonMaterial; + }); + _this._materialPromiseLODs[indexLOD] = _this._materialPromiseLODs[indexLOD] || []; + if (indexLOD === 0) { + firstPromise = promise; + } + else { + _this._materialIndexLOD = null; + _this._materialPromiseLODs[indexLOD].push(promise); + } + }; + for (var indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) { + _loop_4(indexLOD); + } + _this._loader.logClose(); + return firstPromise; + }); + }; + /** + * @internal + */ + MSFT_lod.prototype._loadUriAsync = function (context, property, uri) { + var _this = this; + // Defer the loading of uris if loading a node or material LOD. + if (this._nodeIndexLOD !== null) { + this._loader.log("deferred"); + var previousIndexLOD = this._nodeIndexLOD - 1; + this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(function () { + return _this._loader.loadUriAsync(context, property, uri); + }); + } + else if (this._materialIndexLOD !== null) { + this._loader.log("deferred"); + var previousIndexLOD = this._materialIndexLOD - 1; + this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + return this._materialSignalLODs[previousIndexLOD].promise.then(function () { + return _this._loader.loadUriAsync(context, property, uri); + }); + } + return null; + }; + /** + * @internal + */ + MSFT_lod.prototype.loadBufferAsync = function (context, buffer, byteOffset, byteLength) { + if (this._loader.parent.useRangeRequests && !buffer.uri) { + if (!this._loader.bin) { + throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk")); + } + var loadAsync = function (bufferLODs, indexLOD) { + var start = byteOffset; + var end = start + byteLength - 1; + var bufferLOD = bufferLODs[indexLOD]; + if (bufferLOD) { + bufferLOD.start = Math.min(bufferLOD.start, start); + bufferLOD.end = Math.max(bufferLOD.end, end); + } + else { + bufferLOD = { start: start, end: end, loaded: new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred() }; + bufferLODs[indexLOD] = bufferLOD; + } + return bufferLOD.loaded.promise.then(function (data) { + return new Uint8Array(data.buffer, data.byteOffset + byteOffset - bufferLOD.start, byteLength); + }); + }; + this._loader.log("deferred"); + if (this._nodeIndexLOD !== null) { + return loadAsync(this._nodeBufferLODs, this._nodeIndexLOD); + } + else if (this._materialIndexLOD !== null) { + return loadAsync(this._materialBufferLODs, this._materialIndexLOD); + } + else { + return loadAsync(this._bufferLODs, 0); + } + } + return null; + }; + MSFT_lod.prototype._loadBufferLOD = function (bufferLODs, indexLOD) { + var bufferLOD = bufferLODs[indexLOD]; + if (bufferLOD) { + this._loader.log("Loading buffer range [".concat(bufferLOD.start, "-").concat(bufferLOD.end, "]")); + this._loader.bin.readAsync(bufferLOD.start, bufferLOD.end - bufferLOD.start + 1).then(function (data) { + bufferLOD.loaded.resolve(data); + }, function (error) { + bufferLOD.loaded.reject(error); + }); + } + }; + /** + * @returns an array of LOD properties from lowest to highest. + * @param context + * @param property + * @param array + * @param ids + */ + MSFT_lod.prototype._getLODs = function (context, property, array, ids) { + if (this.maxLODsToLoad <= 0) { + throw new Error("maxLODsToLoad must be greater than zero"); + } + var properties = []; + for (var i = ids.length - 1; i >= 0; i--) { + properties.push(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(context, "/ids/").concat(ids[i]), array, ids[i])); + if (properties.length === this.maxLODsToLoad) { + return properties; + } + } + properties.push(property); + return properties; + }; + MSFT_lod.prototype._disposeTransformNode = function (babylonTransformNode) { + var _this = this; + var babylonMaterials = []; + var babylonMaterial = babylonTransformNode.material; + if (babylonMaterial) { + babylonMaterials.push(babylonMaterial); + } + for (var _i = 0, _a = babylonTransformNode.getChildMeshes(); _i < _a.length; _i++) { + var babylonMesh = _a[_i]; + if (babylonMesh.material) { + babylonMaterials.push(babylonMesh.material); + } + } + babylonTransformNode.dispose(); + var babylonMaterialsToDispose = babylonMaterials.filter(function (babylonMaterial) { return _this._loader.babylonScene.meshes.every(function (mesh) { return mesh.material != babylonMaterial; }); }); + this._disposeMaterials(babylonMaterialsToDispose); + }; + MSFT_lod.prototype._disposeMaterials = function (babylonMaterials) { + var babylonTextures = {}; + for (var _i = 0, babylonMaterials_1 = babylonMaterials; _i < babylonMaterials_1.length; _i++) { + var babylonMaterial = babylonMaterials_1[_i]; + for (var _a = 0, _b = babylonMaterial.getActiveTextures(); _a < _b.length; _a++) { + var babylonTexture = _b[_a]; + babylonTextures[babylonTexture.uniqueId] = babylonTexture; + } + babylonMaterial.dispose(); + } + for (var uniqueId in babylonTextures) { + for (var _c = 0, _d = this._loader.babylonScene.materials; _c < _d.length; _c++) { + var babylonMaterial = _d[_c]; + if (babylonMaterial.hasTexture(babylonTextures[uniqueId])) { + delete babylonTextures[uniqueId]; + } + } + } + for (var uniqueId in babylonTextures) { + babylonTextures[uniqueId].dispose(); + } + }; + return MSFT_lod; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_lod(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts": +/*!**************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_minecraftMesh: () => (/* binding */ MSFT_minecraftMesh) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "MSFT_minecraftMesh"; +/** @internal */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_minecraftMesh = /** @class */ (function () { + /** @internal */ + function MSFT_minecraftMesh(loader) { + /** @internal */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_minecraftMesh.prototype.dispose = function () { + this._loader = null; + }; + /** @internal */ + MSFT_minecraftMesh.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtraAsync(context, material, this.name, function (extraContext, extra) { + if (extra) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(extraContext, ": Material type not supported")); + } + var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial); + if (babylonMaterial.needAlphaBlending()) { + babylonMaterial.forceDepthWrite = true; + babylonMaterial.separateCullingPass = true; + } + babylonMaterial.backFaceCulling = babylonMaterial.forceDepthWrite; + babylonMaterial.twoSidedLighting = true; + return promise; + } + return null; + }); + }; + return MSFT_minecraftMesh; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_minecraftMesh(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts": +/*!************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_sRGBFactors: () => (/* binding */ MSFT_sRGBFactors) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "MSFT_sRGBFactors"; +/** @internal */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_sRGBFactors = /** @class */ (function () { + /** @internal */ + function MSFT_sRGBFactors(loader) { + /** @internal */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_sRGBFactors.prototype.dispose = function () { + this._loader = null; + }; + /** @internal */ + MSFT_sRGBFactors.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtraAsync(context, material, this.name, function (extraContext, extra) { + if (extra) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(extraContext, ": Material type not supported")); + } + var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial); + var useExactSrgbConversions = babylonMaterial.getScene().getEngine().useExactSrgbConversions; + if (!babylonMaterial.albedoTexture) { + babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor, useExactSrgbConversions); + } + if (!babylonMaterial.reflectivityTexture) { + babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor, useExactSrgbConversions); + } + return promise; + } + return null; + }); + }; + return MSFT_sRGBFactors; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_sRGBFactors(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts": +/*!*********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts ***! + \*********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFPathToObjectConverter: () => (/* binding */ GLTFPathToObjectConverter) +/* harmony export */ }); +/** + * A converter that takes a glTF Object Model JSON Pointer + * and transforms it into an ObjectAccessorContainer, allowing + * objects referenced in the glTF to be associated with their + * respective Babylon.js objects. + */ +var GLTFPathToObjectConverter = /** @class */ (function () { + function GLTFPathToObjectConverter(_gltf, _infoTree) { + this._gltf = _gltf; + this._infoTree = _infoTree; + } + /** + * The pointer string is represented by a [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901). + * := /// + * := "nodes" | "materials" | "meshes" | "cameras" | "extensions" + * := | + * := | + * := "extensions"// + * := | / + * := W+ + * := D+ + * + * Examples: + * - "/nodes/0/rotation" + * - "/materials/2/emissiveFactor" + * - "/materials/2/pbrMetallicRoughness/baseColorFactor" + * - "/materials/2/extensions/KHR_materials_emissive_strength/emissiveStrength" + * + * @param path The path to convert + * @returns The object and info associated with the path + */ + GLTFPathToObjectConverter.prototype.convert = function (path) { + var objectTree = this._gltf; + var infoTree = this._infoTree; + var target = undefined; + if (!path.startsWith("/")) { + throw new Error("Path must start with a /"); + } + var parts = path.split("/"); + parts.shift(); + for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { + var part = parts_1[_i]; + if (infoTree.__array__) { + infoTree = infoTree.__array__; + } + else { + infoTree = infoTree[part]; + if (!infoTree) { + throw new Error("Path ".concat(path, " is invalid")); + } + } + if (objectTree === undefined) { + throw new Error("Path ".concat(path, " is invalid")); + } + objectTree = objectTree[part]; + if (infoTree.__target__) { + target = objectTree; + } + } + return { + object: target, + info: infoTree, + }; + }; + return GLTFPathToObjectConverter; +}()); + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/index.ts": +/*!*************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/index.ts ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_lights_image_based: () => (/* reexport safe */ _EXT_lights_image_based__WEBPACK_IMPORTED_MODULE_0__.EXT_lights_image_based), +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* reexport safe */ _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_1__.EXT_mesh_gpu_instancing), +/* harmony export */ EXT_meshopt_compression: () => (/* reexport safe */ _EXT_meshopt_compression__WEBPACK_IMPORTED_MODULE_2__.EXT_meshopt_compression), +/* harmony export */ EXT_texture_webp: () => (/* reexport safe */ _EXT_texture_webp__WEBPACK_IMPORTED_MODULE_3__.EXT_texture_webp), +/* harmony export */ ExtrasAsMetadata: () => (/* reexport safe */ _ExtrasAsMetadata__WEBPACK_IMPORTED_MODULE_30__.ExtrasAsMetadata), +/* harmony export */ KHR_animation_pointer: () => (/* reexport safe */ _KHR_animation_pointer__WEBPACK_IMPORTED_MODULE_24__.KHR_animation_pointer), +/* harmony export */ KHR_draco_mesh_compression: () => (/* reexport safe */ _KHR_draco_mesh_compression__WEBPACK_IMPORTED_MODULE_4__.KHR_draco_mesh_compression), +/* harmony export */ KHR_interactivity: () => (/* reexport safe */ _KHR_interactivity__WEBPACK_IMPORTED_MODULE_29__.KHR_interactivity), +/* harmony export */ KHR_lights: () => (/* reexport safe */ _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_5__.KHR_lights), +/* harmony export */ KHR_materials_anisotropy: () => (/* reexport safe */ _KHR_materials_anisotropy__WEBPACK_IMPORTED_MODULE_10__.KHR_materials_anisotropy), +/* harmony export */ KHR_materials_clearcoat: () => (/* reexport safe */ _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_8__.KHR_materials_clearcoat), +/* harmony export */ KHR_materials_dispersion: () => (/* reexport safe */ _KHR_materials_dispersion__WEBPACK_IMPORTED_MODULE_19__.KHR_materials_dispersion), +/* harmony export */ KHR_materials_emissive_strength: () => (/* reexport safe */ _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_11__.KHR_materials_emissive_strength), +/* harmony export */ KHR_materials_ior: () => (/* reexport safe */ _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_14__.KHR_materials_ior), +/* harmony export */ KHR_materials_iridescence: () => (/* reexport safe */ _KHR_materials_iridescence__WEBPACK_IMPORTED_MODULE_9__.KHR_materials_iridescence), +/* harmony export */ KHR_materials_pbrSpecularGlossiness: () => (/* reexport safe */ _KHR_materials_pbrSpecularGlossiness__WEBPACK_IMPORTED_MODULE_6__.KHR_materials_pbrSpecularGlossiness), +/* harmony export */ KHR_materials_sheen: () => (/* reexport safe */ _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_12__.KHR_materials_sheen), +/* harmony export */ KHR_materials_specular: () => (/* reexport safe */ _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_13__.KHR_materials_specular), +/* harmony export */ KHR_materials_translucency: () => (/* reexport safe */ _KHR_materials_translucency__WEBPACK_IMPORTED_MODULE_17__.KHR_materials_translucency), +/* harmony export */ KHR_materials_transmission: () => (/* reexport safe */ _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_16__.KHR_materials_transmission), +/* harmony export */ KHR_materials_unlit: () => (/* reexport safe */ _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_unlit), +/* harmony export */ KHR_materials_variants: () => (/* reexport safe */ _KHR_materials_variants__WEBPACK_IMPORTED_MODULE_15__.KHR_materials_variants), +/* harmony export */ KHR_materials_volume: () => (/* reexport safe */ _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_18__.KHR_materials_volume), +/* harmony export */ KHR_mesh_quantization: () => (/* reexport safe */ _KHR_mesh_quantization__WEBPACK_IMPORTED_MODULE_20__.KHR_mesh_quantization), +/* harmony export */ KHR_texture_basisu: () => (/* reexport safe */ _KHR_texture_basisu__WEBPACK_IMPORTED_MODULE_21__.KHR_texture_basisu), +/* harmony export */ KHR_texture_transform: () => (/* reexport safe */ _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_22__.KHR_texture_transform), +/* harmony export */ KHR_xmp_json_ld: () => (/* reexport safe */ _KHR_xmp_json_ld__WEBPACK_IMPORTED_MODULE_23__.KHR_xmp_json_ld), +/* harmony export */ MSFT_audio_emitter: () => (/* reexport safe */ _MSFT_audio_emitter__WEBPACK_IMPORTED_MODULE_25__.MSFT_audio_emitter), +/* harmony export */ MSFT_lod: () => (/* reexport safe */ _MSFT_lod__WEBPACK_IMPORTED_MODULE_26__.MSFT_lod), +/* harmony export */ MSFT_minecraftMesh: () => (/* reexport safe */ _MSFT_minecraftMesh__WEBPACK_IMPORTED_MODULE_27__.MSFT_minecraftMesh), +/* harmony export */ MSFT_sRGBFactors: () => (/* reexport safe */ _MSFT_sRGBFactors__WEBPACK_IMPORTED_MODULE_28__.MSFT_sRGBFactors) +/* harmony export */ }); +/* harmony import */ var _EXT_lights_image_based__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EXT_lights_image_based */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts"); +/* harmony import */ var _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EXT_mesh_gpu_instancing */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts"); +/* harmony import */ var _EXT_meshopt_compression__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./EXT_meshopt_compression */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts"); +/* harmony import */ var _EXT_texture_webp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./EXT_texture_webp */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts"); +/* harmony import */ var _KHR_draco_mesh_compression__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./KHR_draco_mesh_compression */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts"); +/* harmony import */ var _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./KHR_lights_punctual */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"); +/* harmony import */ var _KHR_materials_pbrSpecularGlossiness__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./KHR_materials_pbrSpecularGlossiness */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts"); +/* harmony import */ var _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./KHR_materials_unlit */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts"); +/* harmony import */ var _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./KHR_materials_clearcoat */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts"); +/* harmony import */ var _KHR_materials_iridescence__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./KHR_materials_iridescence */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts"); +/* harmony import */ var _KHR_materials_anisotropy__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./KHR_materials_anisotropy */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts"); +/* harmony import */ var _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./KHR_materials_emissive_strength */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts"); +/* harmony import */ var _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./KHR_materials_sheen */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts"); +/* harmony import */ var _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./KHR_materials_specular */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts"); +/* harmony import */ var _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./KHR_materials_ior */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_ior.ts"); +/* harmony import */ var _KHR_materials_variants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./KHR_materials_variants */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts"); +/* harmony import */ var _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./KHR_materials_transmission */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"); +/* harmony import */ var _KHR_materials_translucency__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./KHR_materials_translucency */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_translucency.ts"); +/* harmony import */ var _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./KHR_materials_volume */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts"); +/* harmony import */ var _KHR_materials_dispersion__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./KHR_materials_dispersion */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts"); +/* harmony import */ var _KHR_mesh_quantization__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./KHR_mesh_quantization */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts"); +/* harmony import */ var _KHR_texture_basisu__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./KHR_texture_basisu */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts"); +/* harmony import */ var _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./KHR_texture_transform */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts"); +/* harmony import */ var _KHR_xmp_json_ld__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./KHR_xmp_json_ld */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts"); +/* harmony import */ var _KHR_animation_pointer__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./KHR_animation_pointer */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.ts"); +/* harmony import */ var _MSFT_audio_emitter__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./MSFT_audio_emitter */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts"); +/* harmony import */ var _MSFT_lod__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./MSFT_lod */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts"); +/* harmony import */ var _MSFT_minecraftMesh__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./MSFT_minecraftMesh */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts"); +/* harmony import */ var _MSFT_sRGBFactors__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./MSFT_sRGBFactors */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts"); +/* harmony import */ var _KHR_interactivity__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./KHR_interactivity */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity.ts"); +/* harmony import */ var _ExtrasAsMetadata__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./ExtrasAsMetadata */ "../../../dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts"); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/interactivityFunctions.ts": +/*!******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/interactivityFunctions.ts ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ convertGLTFToSerializedFlowGraph: () => (/* binding */ convertGLTFToSerializedFlowGraph) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/FlowGraph/flowGraphConnection */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _interactivityUtils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./interactivityUtils */ "../../../dev/loaders/src/glTF/2.0/Extensions/interactivityUtils.ts"); + + + +function convertValueWithType(configObject, definition, context) { + if (configObject.type !== undefined) { + // get the type on the gltf definition + var type = definition.types && definition.types[configObject.type]; + if (!type) { + throw new Error("".concat(context, ": Unknown type: ").concat(configObject.type)); + } + var signature = type.signature; + if (!signature) { + throw new Error("".concat(context, ": Type ").concat(configObject.type, " has no signature")); + } + var convertedType = _interactivityUtils__WEBPACK_IMPORTED_MODULE_1__.gltfTypeToBabylonType[signature]; + return { + value: configObject.value, + className: convertedType, + }; + } + else { + return configObject.value; + } +} +function convertConfiguration(gltfBlock, definition, id) { + var _a; + var converted = {}; + var configurationList = (_a = gltfBlock.configuration) !== null && _a !== void 0 ? _a : []; + for (var _i = 0, configurationList_1 = configurationList; _i < configurationList_1.length; _i++) { + var configObject = configurationList_1[_i]; + if (configObject.id === "customEvent") { + var customEvent = definition.customEvents && definition.customEvents[configObject.value]; + if (!customEvent) { + throw new Error("/extensions/KHR_interactivity/nodes/".concat(id, ": Unknown custom event: ").concat(configObject.value)); + } + converted.eventId = customEvent.id; + converted.eventData = customEvent.values.map(function (v) { return v.id; }); + } + else if (configObject.id === "variable") { + var variable = definition.variables && definition.variables[configObject.value]; + if (!variable) { + throw new Error("/extensions/KHR_interactivity/nodes/".concat(id, ": Unknown variable: ").concat(configObject.value)); + } + converted.variableName = variable.id; + } + else if (configObject.id === "path") { + // Convert from a GLTF path to a reference to the Babylon.js object + var pathValue = configObject.value; + converted.path = pathValue; + } + else { + converted[configObject.id] = convertValueWithType(configObject, definition, "/extensions/KHR_interactivity/nodes/".concat(id)); + } + } + return converted; +} +function convertBlock(id, gltfBlock, definition) { + var className = _interactivityUtils__WEBPACK_IMPORTED_MODULE_1__.gltfToFlowGraphTypeMap[gltfBlock.type]; + if (!className) { + throw new Error("/extensions/KHR_interactivity/nodes/".concat(id, ": Unknown block type: ").concat(gltfBlock.type)); + } + var uniqueId = id.toString(); + var config = convertConfiguration(gltfBlock, definition, uniqueId); + var metadata = gltfBlock.metadata; + var dataInputs = []; + var dataOutputs = []; + var signalInputs = []; + var signalOutputs = []; + return { + className: className, + config: config, + uniqueId: uniqueId, + metadata: metadata, + dataInputs: dataInputs, + dataOutputs: dataOutputs, + signalInputs: signalInputs, + signalOutputs: signalOutputs, + }; +} +/** + * @internal + * Converts a glTF Interactivity Extension to a serialized flow graph. + * @param gltf the interactivity data + * @returns a serialized flow graph + */ +function convertGLTFToSerializedFlowGraph(gltf) { + var _a, _b, _c; + // create an empty serialized context to store the values of the connections + var context = { + uniqueId: (0,babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.RandomGUID)(), + _userVariables: {}, + _connectionValues: {}, + }; + var executionContexts = [context]; + // Blocks converted to the flow graph json format + var flowGraphJsonBlocks = []; + for (var i = 0; i < gltf.nodes.length; i++) { + var gltfBlock = gltf.nodes[i]; + var flowGraphJsonBlock = convertBlock(i, gltfBlock, gltf); + flowGraphJsonBlocks.push(flowGraphJsonBlock); + } + // Parse the connections + for (var i = 0; i < gltf.nodes.length; i++) { + var gltfBlock = gltf.nodes[i]; + // get the block that was created in the previous step + var fgBlock = flowGraphJsonBlocks[i]; + var gltfFlows = (_a = gltfBlock.flows) !== null && _a !== void 0 ? _a : []; + var _loop_1 = function (flow) { + var socketOutName = flow.id; + // create an output connection for the flow graph block + var socketOut = { + uniqueId: (0,babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.RandomGUID)(), + name: socketOutName, + _connectionType: babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.FlowGraphConnectionType.Output, + connectedPointIds: [], + }; + fgBlock.signalOutputs.push(socketOut); + // get the input node of this flow + var nodeInId = flow.node; + var nodeInSocketName = flow.socket; + // find the corresponding flow graph node + var nodeIn = flowGraphJsonBlocks[nodeInId]; + if (!nodeIn) { + throw new Error("/extensions/KHR_interactivity/nodes/".concat(i, ": Could not find node with id ").concat(nodeInId, " that connects its input with with node ").concat(i, "'s output ").concat(socketOutName)); + } + // in all of the flow graph input connections, find the one with the same name as the socket + var socketIn = nodeIn.signalInputs.find(function (s) { return s.name === nodeInSocketName; }); + // if the socket doesn't exist, create the input socket for the connection + if (!socketIn) { + socketIn = { + uniqueId: (0,babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.RandomGUID)(), + name: nodeInSocketName, + _connectionType: babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.FlowGraphConnectionType.Input, + connectedPointIds: [], + }; + nodeIn.signalInputs.push(socketIn); + } + // connect the sockets + socketIn.connectedPointIds.push(socketOut.uniqueId); + socketOut.connectedPointIds.push(socketIn.uniqueId); + }; + // for each output flow of the gltf block + for (var _i = 0, gltfFlows_1 = gltfFlows; _i < gltfFlows_1.length; _i++) { + var flow = gltfFlows_1[_i]; + _loop_1(flow); + } + // for each input value of the gltf block + var gltfValues = (_b = gltfBlock.values) !== null && _b !== void 0 ? _b : []; + var _loop_2 = function (value) { + var socketInName = value.id; + // create an input data connection for the flow graph block + var socketIn = { + uniqueId: (0,babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.RandomGUID)(), + name: socketInName, + _connectionType: babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.FlowGraphConnectionType.Input, + connectedPointIds: [], + }; + fgBlock.dataInputs.push(socketIn); + if (value.value !== undefined) { + // if the value is set on the socket itself, store it in the context + var convertedValue = convertValueWithType(value, gltf, "/extensions/KHR_interactivity/nodes/".concat(i)); + // convertBlockInputType(gltfBlock, value, convertedValue, `/extensions/KHR_interactivity/nodes/${i}`); + context._connectionValues[socketIn.uniqueId] = convertedValue; + } + else if (value.node !== undefined && value.socket !== undefined) { + // if the value is connected with the output data of another socket, connect the two + var nodeOutId = value.node; + var nodeOutSocketName_1 = value.socket; + // find the flow graph node that owns that output socket + var nodeOut = flowGraphJsonBlocks[nodeOutId]; + if (!nodeOut) { + throw new Error("/extensions/KHR_interactivity/nodes/".concat(i, ": Could not find node with id ").concat(nodeOutId, " that connects its output with node").concat(i, "'s input ").concat(socketInName)); + } + var socketOut = nodeOut.dataOutputs.find(function (s) { return s.name === nodeOutSocketName_1; }); + // if the socket doesn't exist, create it + if (!socketOut) { + socketOut = { + uniqueId: (0,babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.RandomGUID)(), + name: nodeOutSocketName_1, + _connectionType: babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.FlowGraphConnectionType.Output, + connectedPointIds: [], + }; + nodeOut.dataOutputs.push(socketOut); + } + // connect the sockets + socketIn.connectedPointIds.push(socketOut.uniqueId); + socketOut.connectedPointIds.push(socketIn.uniqueId); + } + else { + throw new Error("/extensions/KHR_interactivity/nodes/".concat(i, ": Invalid socket ").concat(socketInName, " in node ").concat(i)); + } + }; + for (var _d = 0, gltfValues_1 = gltfValues; _d < gltfValues_1.length; _d++) { + var value = gltfValues_1[_d]; + _loop_2(value); + } + } + var variables = (_c = gltf.variables) !== null && _c !== void 0 ? _c : []; + // Parse variables + for (var i = 0; i < variables.length; i++) { + var variable = variables[i]; + var variableName = variable.id; + context._userVariables[variableName] = convertValueWithType(variable, gltf, "/extensions/KHR_interactivity/variables/".concat(i)); + } + return { + allBlocks: flowGraphJsonBlocks, + executionContexts: executionContexts, + }; +} + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/interactivityPathToObjectConverter.ts": +/*!******************************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/interactivityPathToObjectConverter.ts ***! + \******************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ InteractivityPathToObjectConverter: () => (/* binding */ InteractivityPathToObjectConverter) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var _gltfPathToObjectConverter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./gltfPathToObjectConverter */ "../../../dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts"); + + +/** + * Class to convert an interactivity pointer path to a smart object + */ +var InteractivityPathToObjectConverter = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__extends)(InteractivityPathToObjectConverter, _super); + function InteractivityPathToObjectConverter(gltf) { + return _super.call(this, gltf, gltfTree) || this; + } + return InteractivityPathToObjectConverter; +}(_gltfPathToObjectConverter__WEBPACK_IMPORTED_MODULE_0__.GLTFPathToObjectConverter)); + +var nodesTree = { + __array__: { + __target__: true, + translation: { + type: "Vector3", + get: function (node) { + var babylonObject = node._babylonTransformNode; + return babylonObject.position; + }, + set: function (value, node) { + var babylonObject = node._babylonTransformNode; + babylonObject.position = value; + }, + getObject: function (node) { + return node._babylonTransformNode; + }, + }, + }, +}; +var gltfTree = { + nodes: nodesTree, +}; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/interactivityUtils.ts": +/*!**************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/interactivityUtils.ts ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ gltfToFlowGraphTypeMap: () => (/* binding */ gltfToFlowGraphTypeMap), +/* harmony export */ gltfTypeToBabylonType: () => (/* binding */ gltfTypeToBabylonType) +/* harmony export */ }); +/* harmony import */ var babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__); +/* eslint-disable @typescript-eslint/naming-convention */ + + + + + + + + + + + + + + +var gltfToFlowGraphTypeMap = { + "lifecycle/onStart": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSceneReadyEventBlock.ClassName, + "lifecycle/onTick": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSceneTickEventBlock.ClassName, + log: babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphConsoleLogBlock.ClassName, + "flow/delay": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphTimerBlock.ClassName, + "customEvent/send": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSendCustomEventBlock.ClassName, + "customEvent/receive": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphReceiveCustomEventBlock.ClassName, + "flow/sequence": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSequenceBlock.ClassName, + "world/get": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphGetPropertyBlock.ClassName, + "world/set": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSetPropertyBlock.ClassName, + "flow/doN": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphDoNBlock.ClassName, + "variable/get": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphGetVariableBlock.ClassName, + "variable/set": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSetVariableBlock.ClassName, + "flow/whileLoop": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphWhileLoopBlock.ClassName, + "math/random": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphRandomBlock.ClassName, + "math/e": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphEBlock.ClassName, + "math/pi": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphPiBlock.ClassName, + "math/inf": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphInfBlock.ClassName, + "math/nan": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphNaNBlock.ClassName, + "math/abs": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAbsBlock.ClassName, + "math/sign": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSignBlock.ClassName, + "math/trunc": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphTruncBlock.ClassName, + "math/floor": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphFloorBlock.ClassName, + "math/ceil": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCeilBlock.ClassName, + "math/fract": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphFractBlock.ClassName, + "math/neg": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphNegBlock.ClassName, + "math/add": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAddBlock.ClassName, + "math/sub": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSubtractBlock.ClassName, + "math/mul": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphMultiplyBlock.ClassName, + "math/div": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphDivideBlock.ClassName, + "math/rem": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphRemainderBlock.ClassName, + "math/min": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphMinBlock.ClassName, + "math/max": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphMaxBlock.ClassName, + "math/clamp": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphClampBlock.ClassName, + "math/saturate": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSaturateBlock.ClassName, + "math/mix": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphInterpolateBlock.ClassName, + "math/eq": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphEqBlock.ClassName, + "math/lt": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphLessThanBlock.ClassName, + "math/le": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphLessThanOrEqualBlock.ClassName, + "math/gt": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphGreaterThanBlock.ClassName, + "math/ge": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphGreaterThanOrEqualBlock.ClassName, + "math/isnan": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphIsNanBlock.ClassName, + "math/isinf": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphIsInfBlock.ClassName, + "math/rad": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphDegToRadBlock.ClassName, + "math/deg": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphRadToDegBlock.ClassName, + "math/sin": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSinBlock.ClassName, + "math/cos": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCosBlock.ClassName, + "math/tan": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphTanBlock.ClassName, + "math/asin": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAsinBlock.ClassName, + "math/acos": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAcosBlock.ClassName, + "math/atan": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAtanBlock.ClassName, + "math/atan2": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAtan2Block.ClassName, + "math/sinh": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSinhBlock.ClassName, + "math/cosh": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCoshBlock.ClassName, + "math/tanh": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphTanhBlock.ClassName, + "math/asinh": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAsinhBlock.ClassName, + "math/acosh": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAcoshBlock.ClassName, + "math/atanh": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAtanhBlock.ClassName, + "math/exp": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphExpBlock.ClassName, + "math/log": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphLogBlock.ClassName, + "math/log2": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphLog2Block.ClassName, + "math/log10": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphLog10Block.ClassName, + "math/sqrt": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSqrtBlock.ClassName, + "math/cbrt": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCubeRootBlock.ClassName, + "math/pow": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphPowBlock.ClassName, + "math/length": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphLengthBlock.ClassName, + "math/normalize": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphNormalizeBlock.ClassName, + "math/dot": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphDotBlock.ClassName, + "math/cross": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCrossBlock.ClassName, + "math/rotate2d": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphRotate2DBlock.ClassName, + "math/rotate3d": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphRotate3DBlock.ClassName, + "math/transpose": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphTransposeBlock.ClassName, + "math/determinant": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphDeterminantBlock.ClassName, + "math/inverse": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphInvertMatrixBlock.ClassName, + "math/matmul": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphMatMulBlock.ClassName, + "math/not": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphBitwiseNotBlock.ClassName, + "math/and": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphBitwiseAndBlock.ClassName, + "math/or": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphBitwiseOrBlock.ClassName, + "math/xor": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphBitwiseXorBlock.ClassName, + "math/asr": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphBitwiseRightShiftBlock.ClassName, + "math/lsl": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphBitwiseLeftShiftBlock.ClassName, + "math/clz": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCountLeadingZerosBlock.ClassName, + "math/ctz": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCountTrailingZerosBlock.ClassName, + "math/popcnt": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCountOneBitsBlock.ClassName, +}; +var gltfTypeToBabylonType = { + float2: "Vector2", + float3: "Vector3", + float4: "Vector4", + float4x4: "Matrix", + int: "FlowGraphInteger", +}; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts": +/*!*******************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoader.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ArrayItem: () => (/* binding */ ArrayItem), +/* harmony export */ GLTFLoader: () => (/* binding */ GLTFLoader) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Culling/boundingInfo */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFFileLoader */ "../../../dev/loaders/src/glTF/glTFFileLoader.ts"); +/* harmony import */ var _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderAnimation */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts"); + + + + + + + + + + + + + + + + + + + + + + + + + +// https://stackoverflow.com/a/48218209 +function mergeDeep() { + var objects = []; + for (var _i = 0; _i < arguments.length; _i++) { + objects[_i] = arguments[_i]; + } + var isObject = function (obj) { return obj && typeof obj === "object"; }; + return objects.reduce(function (prev, obj) { + Object.keys(obj).forEach(function (key) { + var pVal = prev[key]; + var oVal = obj[key]; + if (Array.isArray(pVal) && Array.isArray(oVal)) { + prev[key] = pVal.concat.apply(pVal, oVal); + } + else if (isObject(pVal) && isObject(oVal)) { + prev[key] = mergeDeep(pVal, oVal); + } + else { + prev[key] = oVal; + } + }); + return prev; + }, {}); +} +/** + * Helper class for working with arrays when loading the glTF asset + */ +var ArrayItem = /** @class */ (function () { + function ArrayItem() { + } + /** + * Gets an item from the given array. + * @param context The context when loading the asset + * @param array The array to get the item from + * @param index The index to the array + * @returns The array item + */ + ArrayItem.Get = function (context, array, index) { + if (!array || index == undefined || !array[index]) { + throw new Error("".concat(context, ": Failed to find index (").concat(index, ")")); + } + return array[index]; + }; + /** + * Gets an item from the given array or returns null if not available. + * @param array The array to get the item from + * @param index The index to the array + * @returns The array item or null + */ + ArrayItem.TryGet = function (array, index) { + if (!array || index == undefined || !array[index]) { + return null; + } + return array[index]; + }; + /** + * Assign an `index` field to each item of the given array. + * @param array The array of items + */ + ArrayItem.Assign = function (array) { + if (array) { + for (var index = 0; index < array.length; index++) { + array[index].index = index; + } + } + }; + return ArrayItem; +}()); + +/** + * The glTF 2.0 loader + */ +var GLTFLoader = /** @class */ (function () { + /** + * @internal + */ + function GLTFLoader(parent) { + /** @internal */ + this._completePromises = new Array(); + /** @internal */ + this._assetContainer = null; + /** Storage */ + this._babylonLights = []; + /** @internal */ + this._disableInstancedMesh = 0; + /** @internal */ + this._allMaterialsDirtyRequired = false; + this._extensions = new Array(); + this._disposed = false; + this._rootUrl = null; + this._fileName = null; + this._uniqueRootUrl = null; + this._bin = null; + this._rootBabylonMesh = null; + this._defaultBabylonMaterialData = {}; + this._postSceneLoadActions = new Array(); + this._parent = parent; + } + /** + * Registers a loader extension. + * @param name The name of the loader extension. + * @param factory The factory function that creates the loader extension. + */ + GLTFLoader.RegisterExtension = function (name, factory) { + if (GLTFLoader.UnregisterExtension(name)) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Extension with the name '".concat(name, "' already exists")); + } + GLTFLoader._RegisteredExtensions[name] = { + factory: factory, + }; + }; + /** + * Unregisters a loader extension. + * @param name The name of the loader extension. + * @returns A boolean indicating whether the extension has been unregistered + */ + GLTFLoader.UnregisterExtension = function (name) { + if (!GLTFLoader._RegisteredExtensions[name]) { + return false; + } + delete GLTFLoader._RegisteredExtensions[name]; + return true; + }; + Object.defineProperty(GLTFLoader.prototype, "gltf", { + /** + * The object that represents the glTF JSON. + */ + get: function () { + if (!this._gltf) { + throw new Error("glTF JSON is not available"); + } + return this._gltf; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "bin", { + /** + * The BIN chunk of a binary glTF. + */ + get: function () { + return this._bin; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "parent", { + /** + * The parent file loader. + */ + get: function () { + return this._parent; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "babylonScene", { + /** + * The Babylon scene when loading the asset. + */ + get: function () { + if (!this._babylonScene) { + throw new Error("Scene is not available"); + } + return this._babylonScene; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "rootBabylonMesh", { + /** + * The root Babylon node when loading the asset. + */ + get: function () { + return this._rootBabylonMesh; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "rootUrl", { + /** + * The root url when loading the asset. + */ + get: function () { + return this._rootUrl; + }, + enumerable: false, + configurable: true + }); + /** @internal */ + GLTFLoader.prototype.dispose = function () { + if (this._disposed) { + return; + } + this._disposed = true; + this._completePromises.length = 0; + this._extensions.forEach(function (extension) { return extension.dispose && extension.dispose(); }); + this._extensions.length = 0; + this._gltf = null; // TODO + this._bin = null; + this._babylonScene = null; // TODO + this._rootBabylonMesh = null; + this._defaultBabylonMaterialData = {}; + this._postSceneLoadActions.length = 0; + this._parent.dispose(); + }; + /** + * @internal + */ + GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, container, data, rootUrl, onProgress, fileName) { + var _this = this; + if (fileName === void 0) { fileName = ""; } + return Promise.resolve().then(function () { + _this._babylonScene = scene; + _this._assetContainer = container; + _this._loadData(data); + var nodes = null; + if (meshesNames) { + var nodeMap_1 = {}; + if (_this._gltf.nodes) { + for (var _i = 0, _a = _this._gltf.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.name) { + nodeMap_1[node.name] = node.index; + } + } + } + var names = meshesNames instanceof Array ? meshesNames : [meshesNames]; + nodes = names.map(function (name) { + var node = nodeMap_1[name]; + if (node === undefined) { + throw new Error("Failed to find node '".concat(name, "'")); + } + return node; + }); + } + return _this._loadAsync(rootUrl, fileName, nodes, function () { + return { + meshes: _this._getMeshes(), + particleSystems: [], + skeletons: _this._getSkeletons(), + animationGroups: _this._getAnimationGroups(), + lights: _this._babylonLights, + transformNodes: _this._getTransformNodes(), + geometries: _this._getGeometries(), + spriteManagers: [], + }; + }); + }); + }; + /** + * @internal + */ + GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) { + var _this = this; + if (fileName === void 0) { fileName = ""; } + return Promise.resolve().then(function () { + _this._babylonScene = scene; + _this._loadData(data); + return _this._loadAsync(rootUrl, fileName, null, function () { return undefined; }); + }); + }; + GLTFLoader.prototype._loadAsync = function (rootUrl, fileName, nodes, resultFunc) { + var _this = this; + return Promise.resolve() + .then(function () { + _this._rootUrl = rootUrl; + _this._uniqueRootUrl = !rootUrl.startsWith("file:") && fileName ? rootUrl : "".concat(rootUrl).concat(Date.now(), "/"); + _this._fileName = fileName; + _this._allMaterialsDirtyRequired = false; + _this._loadExtensions(); + _this._checkExtensions(); + var loadingToReadyCounterName = "".concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING], " => ").concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.READY]); + var loadingToCompleteCounterName = "".concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING], " => ").concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.COMPLETE]); + _this._parent._startPerformanceCounter(loadingToReadyCounterName); + _this._parent._startPerformanceCounter(loadingToCompleteCounterName); + _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING); + _this._extensionsOnLoading(); + var promises = new Array(); + // Block the marking of materials dirty until the scene is loaded. + var oldBlockMaterialDirtyMechanism = _this._babylonScene.blockMaterialDirtyMechanism; + _this._babylonScene.blockMaterialDirtyMechanism = true; + if (!_this.parent.loadOnlyMaterials) { + if (nodes) { + promises.push(_this.loadSceneAsync("/nodes", { nodes: nodes, index: -1 })); + } + else if (_this._gltf.scene != undefined || (_this._gltf.scenes && _this._gltf.scenes[0])) { + var scene = ArrayItem.Get("/scene", _this._gltf.scenes, _this._gltf.scene || 0); + promises.push(_this.loadSceneAsync("/scenes/".concat(scene.index), scene)); + } + } + if (!_this.parent.skipMaterials && _this.parent.loadAllMaterials && _this._gltf.materials) { + for (var m = 0; m < _this._gltf.materials.length; ++m) { + var material = _this._gltf.materials[m]; + var context_1 = "/materials/" + m; + var babylonDrawMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode; + promises.push(_this._loadMaterialAsync(context_1, material, null, babylonDrawMode, function () { })); + } + } + // Restore the blocking of material dirty. + if (_this._allMaterialsDirtyRequired) { + // This can happen if we add a light for instance as it will impact the whole scene. + // This automatically resets everything if needed. + _this._babylonScene.blockMaterialDirtyMechanism = oldBlockMaterialDirtyMechanism; + } + else { + // By default a newly created material is dirty so there is no need to flag the full scene as dirty. + // For perf reasons, we then bypass blockMaterialDirtyMechanism as this would "dirty" the entire scene. + _this._babylonScene._forceBlockMaterialDirtyMechanism(oldBlockMaterialDirtyMechanism); + } + if (_this._parent.compileMaterials) { + promises.push(_this._compileMaterialsAsync()); + } + if (_this._parent.compileShadowGenerators) { + promises.push(_this._compileShadowGeneratorsAsync()); + } + var resultPromise = Promise.all(promises).then(function () { + if (_this._rootBabylonMesh && _this._rootBabylonMesh !== _this._parent.customRootNode) { + _this._rootBabylonMesh.setEnabled(true); + } + _this._extensionsOnReady(); + _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.READY); + _this._startAnimations(); + return resultFunc(); + }); + return resultPromise.then(function (result) { + _this._parent._endPerformanceCounter(loadingToReadyCounterName); + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Tools.SetImmediate(function () { + if (!_this._disposed) { + Promise.all(_this._completePromises).then(function () { + _this._parent._endPerformanceCounter(loadingToCompleteCounterName); + _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.COMPLETE); + _this._parent.onCompleteObservable.notifyObservers(undefined); + _this._parent.onCompleteObservable.clear(); + _this.dispose(); + }, function (error) { + _this._parent.onErrorObservable.notifyObservers(error); + _this._parent.onErrorObservable.clear(); + _this.dispose(); + }); + } + }); + return result; + }); + }) + .catch(function (error) { + if (!_this._disposed) { + _this._parent.onErrorObservable.notifyObservers(error); + _this._parent.onErrorObservable.clear(); + _this.dispose(); + } + throw error; + }); + }; + GLTFLoader.prototype._loadData = function (data) { + this._gltf = data.json; + this._setupData(); + if (data.bin) { + var buffers = this._gltf.buffers; + if (buffers && buffers[0] && !buffers[0].uri) { + var binaryBuffer = buffers[0]; + if (binaryBuffer.byteLength < data.bin.byteLength - 3 || binaryBuffer.byteLength > data.bin.byteLength) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Binary buffer length (".concat(binaryBuffer.byteLength, ") from JSON does not match chunk length (").concat(data.bin.byteLength, ")")); + } + this._bin = data.bin; + } + else { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Unexpected BIN chunk"); + } + } + }; + GLTFLoader.prototype._setupData = function () { + ArrayItem.Assign(this._gltf.accessors); + ArrayItem.Assign(this._gltf.animations); + ArrayItem.Assign(this._gltf.buffers); + ArrayItem.Assign(this._gltf.bufferViews); + ArrayItem.Assign(this._gltf.cameras); + ArrayItem.Assign(this._gltf.images); + ArrayItem.Assign(this._gltf.materials); + ArrayItem.Assign(this._gltf.meshes); + ArrayItem.Assign(this._gltf.nodes); + ArrayItem.Assign(this._gltf.samplers); + ArrayItem.Assign(this._gltf.scenes); + ArrayItem.Assign(this._gltf.skins); + ArrayItem.Assign(this._gltf.textures); + if (this._gltf.nodes) { + var nodeParents = {}; + for (var _i = 0, _a = this._gltf.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.children) { + for (var _b = 0, _c = node.children; _b < _c.length; _b++) { + var index = _c[_b]; + nodeParents[index] = node.index; + } + } + } + var rootNode = this._createRootNode(); + for (var _d = 0, _e = this._gltf.nodes; _d < _e.length; _d++) { + var node = _e[_d]; + var parentIndex = nodeParents[node.index]; + node.parent = parentIndex === undefined ? rootNode : this._gltf.nodes[parentIndex]; + } + } + }; + GLTFLoader.prototype._loadExtensions = function () { + for (var name_1 in GLTFLoader._RegisteredExtensions) { + var extension = GLTFLoader._RegisteredExtensions[name_1].factory(this); + if (extension.name !== name_1) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(extension.name, " !== ").concat(name_1)); + } + this._extensions.push(extension); + this._parent.onExtensionLoadedObservable.notifyObservers(extension); + } + this._extensions.sort(function (a, b) { return (a.order || Number.MAX_VALUE) - (b.order || Number.MAX_VALUE); }); + this._parent.onExtensionLoadedObservable.clear(); + }; + GLTFLoader.prototype._checkExtensions = function () { + if (this._gltf.extensionsRequired) { + var _loop_1 = function (name_2) { + var available = this_1._extensions.some(function (extension) { return extension.name === name_2 && extension.enabled; }); + if (!available) { + throw new Error("Required extension ".concat(name_2, " is not available")); + } + }; + var this_1 = this; + for (var _i = 0, _a = this._gltf.extensionsRequired; _i < _a.length; _i++) { + var name_2 = _a[_i]; + _loop_1(name_2); + } + } + }; + GLTFLoader.prototype._createRootNode = function () { + if (this._parent.customRootNode !== undefined) { + this._rootBabylonMesh = this._parent.customRootNode; + return { + // eslint-disable-next-line @typescript-eslint/naming-convention + _babylonTransformNode: this._rootBabylonMesh === null ? undefined : this._rootBabylonMesh, + index: -1, + }; + } + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var rootMesh = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Mesh("__root__", this._babylonScene); + this._rootBabylonMesh = rootMesh; + this._rootBabylonMesh._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + this._rootBabylonMesh.setEnabled(false); + var rootNode = { + // eslint-disable-next-line @typescript-eslint/naming-convention + _babylonTransformNode: this._rootBabylonMesh, + index: -1, + }; + switch (this._parent.coordinateSystemMode) { + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderCoordinateSystemMode.AUTO: { + if (!this._babylonScene.useRightHandedSystem) { + rootNode.rotation = [0, 1, 0, 0]; + rootNode.scale = [1, 1, -1]; + GLTFLoader._LoadTransform(rootNode, this._rootBabylonMesh); + } + break; + } + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED: { + this._babylonScene.useRightHandedSystem = true; + break; + } + default: { + throw new Error("Invalid coordinate system mode (".concat(this._parent.coordinateSystemMode, ")")); + } + } + this._parent.onMeshLoadedObservable.notifyObservers(rootMesh); + return rootNode; + }; + /** + * Loads a glTF scene. + * @param context The context when loading the asset + * @param scene The glTF scene property + * @returns A promise that resolves when the load is complete + */ + GLTFLoader.prototype.loadSceneAsync = function (context, scene) { + var _this = this; + var extensionPromise = this._extensionsLoadSceneAsync(context, scene); + if (extensionPromise) { + return extensionPromise; + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(scene.name || "")); + if (scene.nodes) { + for (var _i = 0, _a = scene.nodes; _i < _a.length; _i++) { + var index = _a[_i]; + var node = ArrayItem.Get("".concat(context, "/nodes/").concat(index), this._gltf.nodes, index); + promises.push(this.loadNodeAsync("/nodes/".concat(node.index), node, function (babylonMesh) { + babylonMesh.parent = _this._rootBabylonMesh; + })); + } + } + for (var _b = 0, _c = this._postSceneLoadActions; _b < _c.length; _b++) { + var action = _c[_b]; + action(); + } + promises.push(this._loadAnimationsAsync()); + this.logClose(); + return Promise.all(promises).then(function () { }); + }; + GLTFLoader.prototype._forEachPrimitive = function (node, callback) { + if (node._primitiveBabylonMeshes) { + for (var _i = 0, _a = node._primitiveBabylonMeshes; _i < _a.length; _i++) { + var babylonMesh = _a[_i]; + callback(babylonMesh); + } + } + }; + GLTFLoader.prototype._getGeometries = function () { + var geometries = []; + var nodes = this._gltf.nodes; + if (nodes) { + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; + this._forEachPrimitive(node, function (babylonMesh) { + var geometry = babylonMesh.geometry; + if (geometry && geometries.indexOf(geometry) === -1) { + geometries.push(geometry); + } + }); + } + } + return geometries; + }; + GLTFLoader.prototype._getMeshes = function () { + var meshes = []; + // Root mesh is always first, if available. + if (this._rootBabylonMesh instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.AbstractMesh) { + meshes.push(this._rootBabylonMesh); + } + var nodes = this._gltf.nodes; + if (nodes) { + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; + this._forEachPrimitive(node, function (babylonMesh) { + meshes.push(babylonMesh); + }); + } + } + return meshes; + }; + GLTFLoader.prototype._getTransformNodes = function () { + var transformNodes = []; + var nodes = this._gltf.nodes; + if (nodes) { + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var node = nodes_3[_i]; + if (node._babylonTransformNode && node._babylonTransformNode.getClassName() === "TransformNode") { + transformNodes.push(node._babylonTransformNode); + } + if (node._babylonTransformNodeForSkin) { + transformNodes.push(node._babylonTransformNodeForSkin); + } + } + } + return transformNodes; + }; + GLTFLoader.prototype._getSkeletons = function () { + var skeletons = []; + var skins = this._gltf.skins; + if (skins) { + for (var _i = 0, skins_1 = skins; _i < skins_1.length; _i++) { + var skin = skins_1[_i]; + if (skin._data) { + skeletons.push(skin._data.babylonSkeleton); + } + } + } + return skeletons; + }; + GLTFLoader.prototype._getAnimationGroups = function () { + var animationGroups = []; + var animations = this._gltf.animations; + if (animations) { + for (var _i = 0, animations_1 = animations; _i < animations_1.length; _i++) { + var animation = animations_1[_i]; + if (animation._babylonAnimationGroup) { + animationGroups.push(animation._babylonAnimationGroup); + } + } + } + return animationGroups; + }; + GLTFLoader.prototype._startAnimations = function () { + switch (this._parent.animationStartMode) { + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.NONE: { + // do nothing + break; + } + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.FIRST: { + var babylonAnimationGroups = this._getAnimationGroups(); + if (babylonAnimationGroups.length !== 0) { + babylonAnimationGroups[0].start(true); + } + break; + } + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.ALL: { + var babylonAnimationGroups = this._getAnimationGroups(); + for (var _i = 0, babylonAnimationGroups_1 = babylonAnimationGroups; _i < babylonAnimationGroups_1.length; _i++) { + var babylonAnimationGroup = babylonAnimationGroups_1[_i]; + babylonAnimationGroup.start(true); + } + break; + } + default: { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode, ")")); + return; + } + } + }; + /** + * Loads a glTF node. + * @param context The context when loading the asset + * @param node The glTF node property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded Babylon mesh when the load is complete + */ + GLTFLoader.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadNodeAsync(context, node, assign); + if (extensionPromise) { + return extensionPromise; + } + if (node._babylonTransformNode) { + throw new Error("".concat(context, ": Invalid recursive node hierarchy")); + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(node.name || "")); + var loadNode = function (babylonTransformNode) { + GLTFLoader.AddPointerMetadata(babylonTransformNode, context); + GLTFLoader._LoadTransform(node, babylonTransformNode); + if (node.camera != undefined) { + var camera = ArrayItem.Get("".concat(context, "/camera"), _this._gltf.cameras, node.camera); + promises.push(_this.loadCameraAsync("/cameras/".concat(camera.index), camera, function (babylonCamera) { + babylonCamera.parent = babylonTransformNode; + })); + } + if (node.children) { + for (var _i = 0, _a = node.children; _i < _a.length; _i++) { + var index = _a[_i]; + var childNode = ArrayItem.Get("".concat(context, "/children/").concat(index), _this._gltf.nodes, index); + promises.push(_this.loadNodeAsync("/nodes/".concat(childNode.index), childNode, function (childBabylonMesh) { + childBabylonMesh.parent = babylonTransformNode; + })); + } + } + assign(babylonTransformNode); + }; + if (node.mesh == undefined || node.skin != undefined) { + var nodeName = node.name || "node".concat(node.index); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var transformNode = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TransformNode(nodeName, this._babylonScene); + transformNode._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + if (node.mesh == undefined) { + node._babylonTransformNode = transformNode; + } + else { + node._babylonTransformNodeForSkin = transformNode; + } + loadNode(transformNode); + } + if (node.mesh != undefined) { + if (node.skin == undefined) { + var mesh = ArrayItem.Get("".concat(context, "/mesh"), this._gltf.meshes, node.mesh); + promises.push(this._loadMeshAsync("/meshes/".concat(mesh.index), node, mesh, loadNode)); + } + else { + // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note) + // This code path will place the skinned mesh as a sibling of the skeleton root node without loading the + // transform, which effectively ignores the transform of the skinned mesh, as per spec. + var mesh = ArrayItem.Get("".concat(context, "/mesh"), this._gltf.meshes, node.mesh); + promises.push(this._loadMeshAsync("/meshes/".concat(mesh.index), node, mesh, function (babylonTransformNode) { + var babylonTransformNodeForSkin = node._babylonTransformNodeForSkin; + // Merge the metadata from the skin node to the skinned mesh in case a loader extension added metadata. + babylonTransformNode.metadata = mergeDeep(babylonTransformNodeForSkin.metadata, babylonTransformNode.metadata || {}); + var skin = ArrayItem.Get("".concat(context, "/skin"), _this._gltf.skins, node.skin); + promises.push(_this._loadSkinAsync("/skins/".concat(skin.index), node, skin, function (babylonSkeleton) { + _this._forEachPrimitive(node, function (babylonMesh) { + babylonMesh.skeleton = babylonSkeleton; + }); + // Wait until all the nodes are parented before parenting the skinned mesh. + _this._postSceneLoadActions.push(function () { + if (skin.skeleton != undefined) { + // Place the skinned mesh node as a sibling of the skeleton root node. + // Handle special case when the parent of the skeleton root is the skinned mesh. + var parentNode = ArrayItem.Get("/skins/".concat(skin.index, "/skeleton"), _this._gltf.nodes, skin.skeleton).parent; + if (node.index === parentNode.index) { + babylonTransformNode.parent = babylonTransformNodeForSkin.parent; + } + else { + babylonTransformNode.parent = parentNode._babylonTransformNode; + } + } + else { + babylonTransformNode.parent = _this._rootBabylonMesh; + } + _this._parent.onSkinLoadedObservable.notifyObservers({ node: babylonTransformNodeForSkin, skinnedNode: babylonTransformNode }); + }); + })); + })); + } + } + this.logClose(); + return Promise.all(promises).then(function () { + _this._forEachPrimitive(node, function (babylonMesh) { + if (babylonMesh.geometry && babylonMesh.geometry.useBoundingInfoFromGeometry) { + // simply apply the world matrices to the bounding info - the extends are already ok + babylonMesh._updateBoundingInfo(); + } + else { + babylonMesh.refreshBoundingInfo(true); + } + }); + return node._babylonTransformNode; + }); + }; + GLTFLoader.prototype._loadMeshAsync = function (context, node, mesh, assign) { + var primitives = mesh.primitives; + if (!primitives || !primitives.length) { + throw new Error("".concat(context, ": Primitives are missing")); + } + if (primitives[0].index == undefined) { + ArrayItem.Assign(primitives); + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(mesh.name || "")); + var name = node.name || "node".concat(node.index); + if (primitives.length === 1) { + var primitive = mesh.primitives[0]; + promises.push(this._loadMeshPrimitiveAsync("".concat(context, "/primitives/").concat(primitive.index), name, node, mesh, primitive, function (babylonMesh) { + node._babylonTransformNode = babylonMesh; + node._primitiveBabylonMeshes = [babylonMesh]; + })); + } + else { + this._babylonScene._blockEntityCollection = !!this._assetContainer; + node._babylonTransformNode = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TransformNode(name, this._babylonScene); + node._babylonTransformNode._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + node._primitiveBabylonMeshes = []; + for (var _i = 0, primitives_1 = primitives; _i < primitives_1.length; _i++) { + var primitive = primitives_1[_i]; + promises.push(this._loadMeshPrimitiveAsync("".concat(context, "/primitives/").concat(primitive.index), "".concat(name, "_primitive").concat(primitive.index), node, mesh, primitive, function (babylonMesh) { + babylonMesh.parent = node._babylonTransformNode; + node._primitiveBabylonMeshes.push(babylonMesh); + })); + } + } + assign(node._babylonTransformNode); + this.logClose(); + return Promise.all(promises).then(function () { + return node._babylonTransformNode; + }); + }; + /** + * @internal Define this method to modify the default behavior when loading data for mesh primitives. + * @param context The context when loading the asset + * @param name The mesh name when loading the asset + * @param node The glTF node when loading the asset + * @param mesh The glTF mesh when loading the asset + * @param primitive The glTF mesh primitive property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled + */ + GLTFLoader.prototype._loadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) { + var _this = this; + var extensionPromise = this._extensionsLoadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign); + if (extensionPromise) { + return extensionPromise; + } + this.logOpen("".concat(context)); + var shouldInstance = this._disableInstancedMesh === 0 && this._parent.createInstances && node.skin == undefined && !mesh.primitives[0].targets; + var babylonAbstractMesh; + var promise; + if (shouldInstance && primitive._instanceData) { + this._babylonScene._blockEntityCollection = !!this._assetContainer; + babylonAbstractMesh = primitive._instanceData.babylonSourceMesh.createInstance(name); + babylonAbstractMesh._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + promise = primitive._instanceData.promise; + } + else { + var promises = new Array(); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonMesh_1 = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Mesh(name, this._babylonScene); + babylonMesh_1._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + babylonMesh_1.overrideMaterialSideOrientation = this._babylonScene.useRightHandedSystem ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.CounterClockWiseSideOrientation : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.ClockWiseSideOrientation; + this._createMorphTargets(context, node, mesh, primitive, babylonMesh_1); + promises.push(this._loadVertexDataAsync(context, primitive, babylonMesh_1).then(function (babylonGeometry) { + return _this._loadMorphTargetsAsync(context, primitive, babylonMesh_1, babylonGeometry).then(function () { + if (_this._disposed) { + return; + } + _this._babylonScene._blockEntityCollection = !!_this._assetContainer; + babylonGeometry.applyToMesh(babylonMesh_1); + babylonGeometry._parentContainer = _this._assetContainer; + _this._babylonScene._blockEntityCollection = false; + }); + })); + var babylonDrawMode = GLTFLoader._GetDrawMode(context, primitive.mode); + if (primitive.material == undefined) { + var babylonMaterial = this._defaultBabylonMaterialData[babylonDrawMode]; + if (!babylonMaterial) { + babylonMaterial = this._createDefaultMaterial("__GLTFLoader._default", babylonDrawMode); + this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial); + this._defaultBabylonMaterialData[babylonDrawMode] = babylonMaterial; + } + babylonMesh_1.material = babylonMaterial; + } + else if (!this.parent.skipMaterials) { + var material = ArrayItem.Get("".concat(context, "/material"), this._gltf.materials, primitive.material); + promises.push(this._loadMaterialAsync("/materials/".concat(material.index), material, babylonMesh_1, babylonDrawMode, function (babylonMaterial) { + babylonMesh_1.material = babylonMaterial; + })); + } + promise = Promise.all(promises); + if (shouldInstance) { + primitive._instanceData = { + babylonSourceMesh: babylonMesh_1, + promise: promise, + }; + } + babylonAbstractMesh = babylonMesh_1; + } + GLTFLoader.AddPointerMetadata(babylonAbstractMesh, context); + this._parent.onMeshLoadedObservable.notifyObservers(babylonAbstractMesh); + assign(babylonAbstractMesh); + this.logClose(); + return promise.then(function () { + return babylonAbstractMesh; + }); + }; + GLTFLoader.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) { + var _this = this; + var extensionPromise = this._extensionsLoadVertexDataAsync(context, primitive, babylonMesh); + if (extensionPromise) { + return extensionPromise; + } + var attributes = primitive.attributes; + if (!attributes) { + throw new Error("".concat(context, ": Attributes are missing")); + } + var promises = new Array(); + var babylonGeometry = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Geometry(babylonMesh.name, this._babylonScene); + if (primitive.indices == undefined) { + babylonMesh.isUnIndexed = true; + } + else { + var accessor = ArrayItem.Get("".concat(context, "/indices"), this._gltf.accessors, primitive.indices); + promises.push(this._loadIndicesAccessorAsync("/accessors/".concat(accessor.index), accessor).then(function (data) { + babylonGeometry.setIndices(data); + })); + } + var loadAttribute = function (name, kind, callback) { + if (attributes[name] == undefined) { + return; + } + babylonMesh._delayInfo = babylonMesh._delayInfo || []; + if (babylonMesh._delayInfo.indexOf(kind) === -1) { + babylonMesh._delayInfo.push(kind); + } + var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(name), _this._gltf.accessors, attributes[name]); + promises.push(_this._loadVertexAccessorAsync("/accessors/".concat(accessor.index), accessor, kind).then(function (babylonVertexBuffer) { + var _a, _b; + if (babylonVertexBuffer.getKind() === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind && !_this.parent.alwaysComputeBoundingBox && !babylonMesh.skeleton) { + if (accessor.min && accessor.max) { + var min = (_a = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0]).copyFromFloats.apply(_a, accessor.min); + var max = (_b = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1]).copyFromFloats.apply(_b, accessor.max); + if (accessor.normalized && accessor.componentType !== 5126 /* AccessorComponentType.FLOAT */) { + var divider = 1; + switch (accessor.componentType) { + case 5120 /* AccessorComponentType.BYTE */: + divider = 127.0; + break; + case 5121 /* AccessorComponentType.UNSIGNED_BYTE */: + divider = 255.0; + break; + case 5122 /* AccessorComponentType.SHORT */: + divider = 32767.0; + break; + case 5123 /* AccessorComponentType.UNSIGNED_SHORT */: + divider = 65535.0; + break; + } + var oneOverDivider = 1 / divider; + min.scaleInPlace(oneOverDivider); + max.scaleInPlace(oneOverDivider); + } + babylonGeometry._boundingInfo = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.BoundingInfo(min, max); + babylonGeometry.useBoundingInfoFromGeometry = true; + } + } + babylonGeometry.setVerticesBuffer(babylonVertexBuffer, accessor.count); + })); + if (kind == babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind) { + babylonMesh.numBoneInfluencers = 8; + } + if (callback) { + callback(accessor); + } + }; + loadAttribute("POSITION", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind); + loadAttribute("NORMAL", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind); + loadAttribute("TANGENT", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind); + loadAttribute("TEXCOORD_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind); + loadAttribute("TEXCOORD_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind); + loadAttribute("TEXCOORD_2", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV3Kind); + loadAttribute("TEXCOORD_3", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV4Kind); + loadAttribute("TEXCOORD_4", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV5Kind); + loadAttribute("TEXCOORD_5", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV6Kind); + loadAttribute("JOINTS_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind); + loadAttribute("WEIGHTS_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind); + loadAttribute("JOINTS_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind); + loadAttribute("WEIGHTS_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsExtraKind); + loadAttribute("COLOR_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind, function (accessor) { + if (accessor.type === "VEC4" /* AccessorType.VEC4 */) { + babylonMesh.hasVertexAlpha = true; + } + }); + return Promise.all(promises).then(function () { + return babylonGeometry; + }); + }; + GLTFLoader.prototype._createMorphTargets = function (context, node, mesh, primitive, babylonMesh) { + if (!primitive.targets) { + return; + } + if (node._numMorphTargets == undefined) { + node._numMorphTargets = primitive.targets.length; + } + else if (primitive.targets.length !== node._numMorphTargets) { + throw new Error("".concat(context, ": Primitives do not have the same number of targets")); + } + var targetNames = mesh.extras ? mesh.extras.targetNames : null; + this._babylonScene._blockEntityCollection = !!this._assetContainer; + babylonMesh.morphTargetManager = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.MorphTargetManager(this._babylonScene); + babylonMesh.morphTargetManager._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + babylonMesh.morphTargetManager.areUpdatesFrozen = true; + for (var index = 0; index < primitive.targets.length; index++) { + var weight = node.weights ? node.weights[index] : mesh.weights ? mesh.weights[index] : 0; + var name_3 = targetNames ? targetNames[index] : "morphTarget".concat(index); + babylonMesh.morphTargetManager.addTarget(new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.MorphTarget(name_3, weight, babylonMesh.getScene())); + // TODO: tell the target whether it has positions, normals, tangents + } + }; + GLTFLoader.prototype._loadMorphTargetsAsync = function (context, primitive, babylonMesh, babylonGeometry) { + if (!primitive.targets) { + return Promise.resolve(); + } + var promises = new Array(); + var morphTargetManager = babylonMesh.morphTargetManager; + for (var index = 0; index < morphTargetManager.numTargets; index++) { + var babylonMorphTarget = morphTargetManager.getTarget(index); + promises.push(this._loadMorphTargetVertexDataAsync("".concat(context, "/targets/").concat(index), babylonGeometry, primitive.targets[index], babylonMorphTarget)); + } + return Promise.all(promises).then(function () { + morphTargetManager.areUpdatesFrozen = false; + }); + }; + GLTFLoader.prototype._loadMorphTargetVertexDataAsync = function (context, babylonGeometry, attributes, babylonMorphTarget) { + var _this = this; + var promises = new Array(); + var loadAttribute = function (attribute, kind, setData) { + if (attributes[attribute] == undefined) { + return; + } + var babylonVertexBuffer = babylonGeometry.getVertexBuffer(kind); + if (!babylonVertexBuffer) { + return; + } + var accessor = ArrayItem.Get("".concat(context, "/").concat(attribute), _this._gltf.accessors, attributes[attribute]); + promises.push(_this._loadFloatAccessorAsync("/accessors/".concat(accessor.index), accessor).then(function (data) { + setData(babylonVertexBuffer, data); + })); + }; + loadAttribute("POSITION", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind, function (babylonVertexBuffer, data) { + var positions = new Float32Array(data.length); + babylonVertexBuffer.forEach(data.length, function (value, index) { + positions[index] = data[index] + value; + }); + babylonMorphTarget.setPositions(positions); + }); + loadAttribute("NORMAL", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind, function (babylonVertexBuffer, data) { + var normals = new Float32Array(data.length); + babylonVertexBuffer.forEach(normals.length, function (value, index) { + normals[index] = data[index] + value; + }); + babylonMorphTarget.setNormals(normals); + }); + loadAttribute("TANGENT", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind, function (babylonVertexBuffer, data) { + var tangents = new Float32Array((data.length / 3) * 4); + var dataIndex = 0; + babylonVertexBuffer.forEach((data.length / 3) * 4, function (value, index) { + // Tangent data for morph targets is stored as xyz delta. + // The vertexData.tangent is stored as xyzw. + // So we need to skip every fourth vertexData.tangent. + if ((index + 1) % 4 !== 0) { + tangents[dataIndex] = data[dataIndex] + value; + dataIndex++; + } + }); + babylonMorphTarget.setTangents(tangents); + }); + return Promise.all(promises).then(function () { }); + }; + GLTFLoader._LoadTransform = function (node, babylonNode) { + // Ignore the TRS of skinned nodes. + // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note) + if (node.skin != undefined) { + return; + } + var position = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(); + var rotation = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity(); + var scaling = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.One(); + if (node.matrix) { + var matrix = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArray(node.matrix); + matrix.decompose(scaling, rotation, position); + } + else { + if (node.translation) { + position = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.translation); + } + if (node.rotation) { + rotation = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(node.rotation); + } + if (node.scale) { + scaling = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.scale); + } + } + babylonNode.position = position; + babylonNode.rotationQuaternion = rotation; + babylonNode.scaling = scaling; + }; + GLTFLoader.prototype._loadSkinAsync = function (context, node, skin, assign) { + var _this = this; + var extensionPromise = this._extensionsLoadSkinAsync(context, node, skin); + if (extensionPromise) { + return extensionPromise; + } + if (skin._data) { + assign(skin._data.babylonSkeleton); + return skin._data.promise; + } + var skeletonId = "skeleton".concat(skin.index); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonSkeleton = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Skeleton(skin.name || skeletonId, skeletonId, this._babylonScene); + babylonSkeleton._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + this._loadBones(context, skin, babylonSkeleton); + var promise = this._loadSkinInverseBindMatricesDataAsync(context, skin).then(function (inverseBindMatricesData) { + _this._updateBoneMatrices(babylonSkeleton, inverseBindMatricesData); + }); + skin._data = { + babylonSkeleton: babylonSkeleton, + promise: promise, + }; + assign(babylonSkeleton); + return promise; + }; + GLTFLoader.prototype._loadBones = function (context, skin, babylonSkeleton) { + if (skin.skeleton == undefined || this._parent.alwaysComputeSkeletonRootNode) { + var rootNode = this._findSkeletonRootNode("".concat(context, "/joints"), skin.joints); + if (rootNode) { + if (skin.skeleton === undefined) { + skin.skeleton = rootNode.index; + } + else { + var isParent = function (a, b) { + for (; b.parent; b = b.parent) { + if (b.parent === a) { + return true; + } + } + return false; + }; + var skeletonNode = ArrayItem.Get("".concat(context, "/skeleton"), this._gltf.nodes, skin.skeleton); + if (skeletonNode !== rootNode && !isParent(skeletonNode, rootNode)) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root")); + skin.skeleton = rootNode.index; + } + } + } + else { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Failed to find common root")); + } + } + var babylonBones = {}; + for (var _i = 0, _a = skin.joints; _i < _a.length; _i++) { + var index = _a[_i]; + var node = ArrayItem.Get("".concat(context, "/joints/").concat(index), this._gltf.nodes, index); + this._loadBone(node, skin, babylonSkeleton, babylonBones); + } + }; + GLTFLoader.prototype._findSkeletonRootNode = function (context, joints) { + if (joints.length === 0) { + return null; + } + var paths = {}; + for (var _i = 0, joints_1 = joints; _i < joints_1.length; _i++) { + var index = joints_1[_i]; + var path = []; + var node = ArrayItem.Get("".concat(context, "/").concat(index), this._gltf.nodes, index); + while (node.index !== -1) { + path.unshift(node); + node = node.parent; + } + paths[index] = path; + } + var rootNode = null; + for (var i = 0;; ++i) { + var path = paths[joints[0]]; + if (i >= path.length) { + return rootNode; + } + var node = path[i]; + for (var j = 1; j < joints.length; ++j) { + path = paths[joints[j]]; + if (i >= path.length || node !== path[i]) { + return rootNode; + } + } + rootNode = node; + } + }; + GLTFLoader.prototype._loadBone = function (node, skin, babylonSkeleton, babylonBones) { + var babylonBone = babylonBones[node.index]; + if (babylonBone) { + return babylonBone; + } + var parentBabylonBone = null; + if (node.index !== skin.skeleton) { + if (node.parent && node.parent.index !== -1) { + parentBabylonBone = this._loadBone(node.parent, skin, babylonSkeleton, babylonBones); + } + else if (skin.skeleton !== undefined) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("/skins/".concat(skin.index, "/skeleton: Skeleton node is not a common root")); + } + } + var boneIndex = skin.joints.indexOf(node.index); + babylonBone = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Bone(node.name || "joint".concat(node.index), babylonSkeleton, parentBabylonBone, this._getNodeMatrix(node), null, null, boneIndex); + babylonBones[node.index] = babylonBone; + // Wait until the scene is loaded to ensure the transform nodes are loaded. + this._postSceneLoadActions.push(function () { + // Link the Babylon bone with the corresponding Babylon transform node. + // A glTF joint is a pointer to a glTF node in the glTF node hierarchy similar to Unity3D. + babylonBone.linkTransformNode(node._babylonTransformNode); + }); + return babylonBone; + }; + GLTFLoader.prototype._loadSkinInverseBindMatricesDataAsync = function (context, skin) { + if (skin.inverseBindMatrices == undefined) { + return Promise.resolve(null); + } + var accessor = ArrayItem.Get("".concat(context, "/inverseBindMatrices"), this._gltf.accessors, skin.inverseBindMatrices); + return this._loadFloatAccessorAsync("/accessors/".concat(accessor.index), accessor); + }; + GLTFLoader.prototype._updateBoneMatrices = function (babylonSkeleton, inverseBindMatricesData) { + for (var _i = 0, _a = babylonSkeleton.bones; _i < _a.length; _i++) { + var babylonBone = _a[_i]; + var baseMatrix = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.Identity(); + var boneIndex = babylonBone._index; + if (inverseBindMatricesData && boneIndex !== -1) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArrayToRef(inverseBindMatricesData, boneIndex * 16, baseMatrix); + baseMatrix.invertToRef(baseMatrix); + } + var babylonParentBone = babylonBone.getParent(); + if (babylonParentBone) { + baseMatrix.multiplyToRef(babylonParentBone.getAbsoluteInverseBindMatrix(), baseMatrix); + } + babylonBone.updateMatrix(baseMatrix, false, false); + babylonBone._updateAbsoluteBindMatrices(undefined, false); + } + }; + GLTFLoader.prototype._getNodeMatrix = function (node) { + return node.matrix + ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArray(node.matrix) + : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.Compose(node.scale ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.scale) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.One(), node.rotation ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(node.rotation) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity(), node.translation ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.translation) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero()); + }; + /** + * Loads a glTF camera. + * @param context The context when loading the asset + * @param camera The glTF camera property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded Babylon camera when the load is complete + */ + GLTFLoader.prototype.loadCameraAsync = function (context, camera, assign) { + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadCameraAsync(context, camera, assign); + if (extensionPromise) { + return extensionPromise; + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(camera.name || "")); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonCamera = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.FreeCamera(camera.name || "camera".concat(camera.index), babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), this._babylonScene, false); + babylonCamera._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + babylonCamera.ignoreParentScaling = true; + camera._babylonCamera = babylonCamera; + // Rotation by 180 as glTF has a different convention than Babylon. + babylonCamera.rotation.set(0, Math.PI, 0); + switch (camera.type) { + case "perspective" /* CameraType.PERSPECTIVE */: { + var perspective = camera.perspective; + if (!perspective) { + throw new Error("".concat(context, ": Camera perspective properties are missing")); + } + babylonCamera.fov = perspective.yfov; + babylonCamera.minZ = perspective.znear; + babylonCamera.maxZ = perspective.zfar || 0; + break; + } + case "orthographic" /* CameraType.ORTHOGRAPHIC */: { + if (!camera.orthographic) { + throw new Error("".concat(context, ": Camera orthographic properties are missing")); + } + babylonCamera.mode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Camera.ORTHOGRAPHIC_CAMERA; + babylonCamera.orthoLeft = -camera.orthographic.xmag; + babylonCamera.orthoRight = camera.orthographic.xmag; + babylonCamera.orthoBottom = -camera.orthographic.ymag; + babylonCamera.orthoTop = camera.orthographic.ymag; + babylonCamera.minZ = camera.orthographic.znear; + babylonCamera.maxZ = camera.orthographic.zfar; + break; + } + default: { + throw new Error("".concat(context, ": Invalid camera type (").concat(camera.type, ")")); + } + } + GLTFLoader.AddPointerMetadata(babylonCamera, context); + this._parent.onCameraLoadedObservable.notifyObservers(babylonCamera); + assign(babylonCamera); + this.logClose(); + return Promise.all(promises).then(function () { + return babylonCamera; + }); + }; + GLTFLoader.prototype._loadAnimationsAsync = function () { + var animations = this._gltf.animations; + if (!animations) { + return Promise.resolve(); + } + var promises = new Array(); + for (var index = 0; index < animations.length; index++) { + var animation = animations[index]; + promises.push(this.loadAnimationAsync("/animations/".concat(animation.index), animation).then(function (animationGroup) { + // Delete the animation group if it ended up not having any animations in it. + if (animationGroup.targetedAnimations.length === 0) { + animationGroup.dispose(); + } + })); + } + return Promise.all(promises).then(function () { }); + }; + /** + * Loads a glTF animation. + * @param context The context when loading the asset + * @param animation The glTF animation property + * @returns A promise that resolves with the loaded Babylon animation group when the load is complete + */ + GLTFLoader.prototype.loadAnimationAsync = function (context, animation) { + var promise = this._extensionsLoadAnimationAsync(context, animation); + if (promise) { + return promise; + } + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonAnimationGroup = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.AnimationGroup(animation.name || "animation".concat(animation.index), this._babylonScene); + babylonAnimationGroup._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + animation._babylonAnimationGroup = babylonAnimationGroup; + var promises = new Array(); + ArrayItem.Assign(animation.channels); + ArrayItem.Assign(animation.samplers); + for (var _i = 0, _a = animation.channels; _i < _a.length; _i++) { + var channel = _a[_i]; + promises.push(this._loadAnimationChannelAsync("".concat(context, "/channels/").concat(channel.index), context, animation, channel, function (babylonTarget, babylonAnimation) { + babylonTarget.animations = babylonTarget.animations || []; + babylonTarget.animations.push(babylonAnimation); + babylonAnimationGroup.addTargetedAnimation(babylonAnimation, babylonTarget); + })); + } + return Promise.all(promises).then(function () { + babylonAnimationGroup.normalize(0); + return babylonAnimationGroup; + }); + }; + /** + * @hidden + * Loads a glTF animation channel. + * @param context The context when loading the asset + * @param animationContext The context of the animation when loading the asset + * @param animation The glTF animation property + * @param channel The glTF animation channel property + * @param onLoad Called for each animation loaded + * @returns A void promise that resolves when the load is complete + */ + GLTFLoader.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, onLoad) { + var promise = this._extensionsLoadAnimationChannelAsync(context, animationContext, animation, channel, onLoad); + if (promise) { + return promise; + } + if (channel.target.node == undefined) { + return Promise.resolve(); + } + var targetNode = ArrayItem.Get("".concat(context, "/target/node"), this._gltf.nodes, channel.target.node); + // Ignore animations that have no animation targets. + if ((channel.target.path === "weights" /* AnimationChannelTargetPath.WEIGHTS */ && !targetNode._numMorphTargets) || + (channel.target.path !== "weights" /* AnimationChannelTargetPath.WEIGHTS */ && !targetNode._babylonTransformNode)) { + return Promise.resolve(); + } + var properties; + switch (channel.target.path) { + case "translation" /* AnimationChannelTargetPath.TRANSLATION */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.translation; + break; + } + case "rotation" /* AnimationChannelTargetPath.ROTATION */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.rotation; + break; + } + case "scale" /* AnimationChannelTargetPath.SCALE */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.scale; + break; + } + case "weights" /* AnimationChannelTargetPath.WEIGHTS */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.weights; + break; + } + default: { + throw new Error("".concat(context, "/target/path: Invalid value (").concat(channel.target.path, ")")); + } + } + var targetInfo = { + object: targetNode, + info: properties, + }; + return this._loadAnimationChannelFromTargetInfoAsync(context, animationContext, animation, channel, targetInfo, onLoad); + }; + /** + * @hidden + * Loads a glTF animation channel. + * @param context The context when loading the asset + * @param animationContext The context of the animation when loading the asset + * @param animation The glTF animation property + * @param channel The glTF animation channel property + * @param targetInfo The glTF target and properties + * @param onLoad Called for each animation loaded + * @returns A void promise that resolves when the load is complete + */ + GLTFLoader.prototype._loadAnimationChannelFromTargetInfoAsync = function (context, animationContext, animation, channel, targetInfo, onLoad) { + var fps = this.parent.targetFps; + var invfps = 1 / fps; + var sampler = ArrayItem.Get("".concat(context, "/sampler"), animation.samplers, channel.sampler); + return this._loadAnimationSamplerAsync("".concat(animationContext, "/samplers/").concat(channel.sampler), sampler).then(function (data) { + var numAnimations = 0; + var target = targetInfo.object; + var propertyInfos = targetInfo.info; + // Extract the corresponding values from the read value. + // GLTF values may be dispatched to several Babylon properties. + // For example, baseColorFactor [`r`, `g`, `b`, `a`] is dispatched to + // - albedoColor as Color3(`r`, `g`, `b`) + // - alpha as `a` + for (var _i = 0, propertyInfos_1 = propertyInfos; _i < propertyInfos_1.length; _i++) { + var propertyInfo = propertyInfos_1[_i]; + var stride = propertyInfo.getStride(target); + var input = data.input; + var output = data.output; + var keys = new Array(input.length); + var outputOffset = 0; + switch (data.interpolation) { + case "STEP" /* AnimationSamplerInterpolation.STEP */: { + for (var index = 0; index < input.length; index++) { + var value = propertyInfo.getValue(target, output, outputOffset, 1); + outputOffset += stride; + keys[index] = { + frame: input[index] * fps, + value: value, + interpolation: babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.AnimationKeyInterpolation.STEP, + }; + } + break; + } + case "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */: { + for (var index = 0; index < input.length; index++) { + var inTangent = propertyInfo.getValue(target, output, outputOffset, invfps); + outputOffset += stride; + var value = propertyInfo.getValue(target, output, outputOffset, 1); + outputOffset += stride; + var outTangent = propertyInfo.getValue(target, output, outputOffset, invfps); + outputOffset += stride; + keys[index] = { + frame: input[index] * fps, + inTangent: inTangent, + value: value, + outTangent: outTangent, + }; + } + break; + } + case "LINEAR" /* AnimationSamplerInterpolation.LINEAR */: { + for (var index = 0; index < input.length; index++) { + var value = propertyInfo.getValue(target, output, outputOffset, 1); + outputOffset += stride; + keys[index] = { + frame: input[index] * fps, + value: value, + }; + } + break; + } + } + if (outputOffset > 0) { + var name_4 = "".concat(animation.name || "animation".concat(animation.index), "_channel").concat(channel.index, "_").concat(numAnimations); + propertyInfo.buildAnimations(target, name_4, fps, keys, function (babylonAnimatable, babylonAnimation) { + ++numAnimations; + onLoad(babylonAnimatable, babylonAnimation); + }); + } + } + }); + }; + GLTFLoader.prototype._loadAnimationSamplerAsync = function (context, sampler) { + if (sampler._data) { + return sampler._data; + } + var interpolation = sampler.interpolation || "LINEAR" /* AnimationSamplerInterpolation.LINEAR */; + switch (interpolation) { + case "STEP" /* AnimationSamplerInterpolation.STEP */: + case "LINEAR" /* AnimationSamplerInterpolation.LINEAR */: + case "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */: { + break; + } + default: { + throw new Error("".concat(context, "/interpolation: Invalid value (").concat(sampler.interpolation, ")")); + } + } + var inputAccessor = ArrayItem.Get("".concat(context, "/input"), this._gltf.accessors, sampler.input); + var outputAccessor = ArrayItem.Get("".concat(context, "/output"), this._gltf.accessors, sampler.output); + sampler._data = Promise.all([ + this._loadFloatAccessorAsync("/accessors/".concat(inputAccessor.index), inputAccessor), + this._loadFloatAccessorAsync("/accessors/".concat(outputAccessor.index), outputAccessor), + ]).then(function (_a) { + var inputData = _a[0], outputData = _a[1]; + return { + input: inputData, + interpolation: interpolation, + output: outputData, + }; + }); + return sampler._data; + }; + /** + * Loads a glTF buffer. + * @param context The context when loading the asset + * @param buffer The glTF buffer property + * @param byteOffset The byte offset to use + * @param byteLength The byte length to use + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadBufferAsync = function (context, buffer, byteOffset, byteLength) { + var extensionPromise = this._extensionsLoadBufferAsync(context, buffer, byteOffset, byteLength); + if (extensionPromise) { + return extensionPromise; + } + if (!buffer._data) { + if (buffer.uri) { + buffer._data = this.loadUriAsync("".concat(context, "/uri"), buffer, buffer.uri); + } + else { + if (!this._bin) { + throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk")); + } + buffer._data = this._bin.readAsync(0, buffer.byteLength); + } + } + return buffer._data.then(function (data) { + try { + return new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength); + } + catch (e) { + throw new Error("".concat(context, ": ").concat(e.message)); + } + }); + }; + /** + * Loads a glTF buffer view. + * @param context The context when loading the asset + * @param bufferView The glTF buffer view property + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadBufferViewAsync = function (context, bufferView) { + var extensionPromise = this._extensionsLoadBufferViewAsync(context, bufferView); + if (extensionPromise) { + return extensionPromise; + } + if (bufferView._data) { + return bufferView._data; + } + var buffer = ArrayItem.Get("".concat(context, "/buffer"), this._gltf.buffers, bufferView.buffer); + bufferView._data = this.loadBufferAsync("/buffers/".concat(buffer.index), buffer, bufferView.byteOffset || 0, bufferView.byteLength); + return bufferView._data; + }; + GLTFLoader.prototype._loadAccessorAsync = function (context, accessor, constructor) { + var _this = this; + if (accessor._data) { + return accessor._data; + } + var numComponents = GLTFLoader._GetNumComponents(context, accessor.type); + var byteStride = numComponents * babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(accessor.componentType); + var length = numComponents * accessor.count; + if (accessor.bufferView == undefined) { + accessor._data = Promise.resolve(new constructor(length)); + } + else { + var bufferView_1 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView); + accessor._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView_1.index), bufferView_1).then(function (data) { + if (accessor.componentType === 5126 /* AccessorComponentType.FLOAT */ && !accessor.normalized && (!bufferView_1.byteStride || bufferView_1.byteStride === byteStride)) { + return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, length); + } + else { + var typedArray_1 = new constructor(length); + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ForEach(data, accessor.byteOffset || 0, bufferView_1.byteStride || byteStride, numComponents, accessor.componentType, typedArray_1.length, accessor.normalized || false, function (value, index) { + typedArray_1[index] = value; + }); + return typedArray_1; + } + }); + } + if (accessor.sparse) { + var sparse_1 = accessor.sparse; + accessor._data = accessor._data.then(function (data) { + var typedArray = data; + var indicesBufferView = ArrayItem.Get("".concat(context, "/sparse/indices/bufferView"), _this._gltf.bufferViews, sparse_1.indices.bufferView); + var valuesBufferView = ArrayItem.Get("".concat(context, "/sparse/values/bufferView"), _this._gltf.bufferViews, sparse_1.values.bufferView); + return Promise.all([ + _this.loadBufferViewAsync("/bufferViews/".concat(indicesBufferView.index), indicesBufferView), + _this.loadBufferViewAsync("/bufferViews/".concat(valuesBufferView.index), valuesBufferView), + ]).then(function (_a) { + var indicesData = _a[0], valuesData = _a[1]; + var indices = GLTFLoader._GetTypedArray("".concat(context, "/sparse/indices"), sparse_1.indices.componentType, indicesData, sparse_1.indices.byteOffset, sparse_1.count); + var sparseLength = numComponents * sparse_1.count; + var values; + if (accessor.componentType === 5126 /* AccessorComponentType.FLOAT */ && !accessor.normalized) { + values = GLTFLoader._GetTypedArray("".concat(context, "/sparse/values"), accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength); + } + else { + var sparseData = GLTFLoader._GetTypedArray("".concat(context, "/sparse/values"), accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength); + values = new constructor(sparseLength); + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ForEach(sparseData, 0, byteStride, numComponents, accessor.componentType, values.length, accessor.normalized || false, function (value, index) { + values[index] = value; + }); + } + var valuesIndex = 0; + for (var indicesIndex = 0; indicesIndex < indices.length; indicesIndex++) { + var dataIndex = indices[indicesIndex] * numComponents; + for (var componentIndex = 0; componentIndex < numComponents; componentIndex++) { + typedArray[dataIndex++] = values[valuesIndex++]; + } + } + return typedArray; + }); + }); + } + return accessor._data; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadFloatAccessorAsync = function (context, accessor) { + return this._loadAccessorAsync(context, accessor, Float32Array); + }; + /** + * @internal + */ + GLTFLoader.prototype._loadIndicesAccessorAsync = function (context, accessor) { + if (accessor.type !== "SCALAR" /* AccessorType.SCALAR */) { + throw new Error("".concat(context, "/type: Invalid value ").concat(accessor.type)); + } + if (accessor.componentType !== 5121 /* AccessorComponentType.UNSIGNED_BYTE */ && + accessor.componentType !== 5123 /* AccessorComponentType.UNSIGNED_SHORT */ && + accessor.componentType !== 5125 /* AccessorComponentType.UNSIGNED_INT */) { + throw new Error("".concat(context, "/componentType: Invalid value ").concat(accessor.componentType)); + } + if (accessor._data) { + return accessor._data; + } + if (accessor.sparse) { + var constructor = GLTFLoader._GetTypedArrayConstructor("".concat(context, "/componentType"), accessor.componentType); + accessor._data = this._loadAccessorAsync(context, accessor, constructor); + } + else { + var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView); + accessor._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) { + return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, accessor.count); + }); + } + return accessor._data; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadVertexBufferViewAsync = function (bufferView) { + if (bufferView._babylonBuffer) { + return bufferView._babylonBuffer; + } + var engine = this._babylonScene.getEngine(); + bufferView._babylonBuffer = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) { + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Buffer(engine, data, false); + }); + return bufferView._babylonBuffer; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadVertexAccessorAsync = function (context, accessor, kind) { + var _a; + if ((_a = accessor._babylonVertexBuffer) === null || _a === void 0 ? void 0 : _a[kind]) { + return accessor._babylonVertexBuffer[kind]; + } + if (!accessor._babylonVertexBuffer) { + accessor._babylonVertexBuffer = {}; + } + var engine = this._babylonScene.getEngine(); + if (accessor.sparse || accessor.bufferView == undefined) { + accessor._babylonVertexBuffer[kind] = this._loadFloatAccessorAsync(context, accessor).then(function (data) { + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(engine, data, kind, false); + }); + } + // Load joint indices as a float array since the shaders expect float data but glTF uses unsigned byte/short. + // This prevents certain platforms (e.g. D3D) from having to convert the data to float on the fly. + else if (kind === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind || kind === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind) { + accessor._babylonVertexBuffer[kind] = this._loadFloatAccessorAsync(context, accessor).then(function (data) { + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(engine, data, kind, false); + }); + } + else { + var bufferView_2 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView); + accessor._babylonVertexBuffer[kind] = this._loadVertexBufferViewAsync(bufferView_2).then(function (babylonBuffer) { + var numComponents = GLTFLoader._GetNumComponents(context, accessor.type); + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(engine, babylonBuffer, kind, false, undefined, bufferView_2.byteStride, undefined, accessor.byteOffset, numComponents, accessor.componentType, accessor.normalized, true, undefined, true); + }); + } + return accessor._babylonVertexBuffer[kind]; + }; + GLTFLoader.prototype._loadMaterialMetallicRoughnessPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + if (properties) { + if (properties.baseColorFactor) { + babylonMaterial.albedoColor = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.baseColorFactor); + babylonMaterial.alpha = properties.baseColorFactor[3]; + } + else { + babylonMaterial.albedoColor = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + } + babylonMaterial.metallic = properties.metallicFactor == undefined ? 1 : properties.metallicFactor; + babylonMaterial.roughness = properties.roughnessFactor == undefined ? 1 : properties.roughnessFactor; + if (properties.baseColorTexture) { + promises.push(this.loadTextureInfoAsync("".concat(context, "/baseColorTexture"), properties.baseColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Base Color)"); + babylonMaterial.albedoTexture = texture; + })); + } + if (properties.metallicRoughnessTexture) { + properties.metallicRoughnessTexture.nonColorData = true; + promises.push(this.loadTextureInfoAsync("".concat(context, "/metallicRoughnessTexture"), properties.metallicRoughnessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Metallic Roughness)"); + babylonMaterial.metallicTexture = texture; + })); + babylonMaterial.useMetallnessFromMetallicTextureBlue = true; + babylonMaterial.useRoughnessFromMetallicTextureGreen = true; + babylonMaterial.useRoughnessFromMetallicTextureAlpha = false; + } + } + return Promise.all(promises).then(function () { }); + }; + /** + * @internal + */ + GLTFLoader.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) { + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign); + if (extensionPromise) { + return extensionPromise; + } + material._data = material._data || {}; + var babylonData = material._data[babylonDrawMode]; + if (!babylonData) { + this.logOpen("".concat(context, " ").concat(material.name || "")); + var babylonMaterial = this.createMaterial(context, material, babylonDrawMode); + babylonData = { + babylonMaterial: babylonMaterial, + babylonMeshes: [], + promise: this.loadMaterialPropertiesAsync(context, material, babylonMaterial), + }; + material._data[babylonDrawMode] = babylonData; + GLTFLoader.AddPointerMetadata(babylonMaterial, context); + this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial); + this.logClose(); + } + if (babylonMesh) { + babylonData.babylonMeshes.push(babylonMesh); + babylonMesh.onDisposeObservable.addOnce(function () { + var index = babylonData.babylonMeshes.indexOf(babylonMesh); + if (index !== -1) { + babylonData.babylonMeshes.splice(index, 1); + } + }); + } + assign(babylonData.babylonMaterial); + return babylonData.promise.then(function () { + return babylonData.babylonMaterial; + }); + }; + GLTFLoader.prototype._createDefaultMaterial = function (name, babylonDrawMode) { + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonMaterial = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial(name, this._babylonScene); + babylonMaterial._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + // Moved to mesh so user can change materials on gltf meshes: babylonMaterial.sideOrientation = this._babylonScene.useRightHandedSystem ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation; + babylonMaterial.fillMode = babylonDrawMode; + babylonMaterial.enableSpecularAntiAliasing = true; + babylonMaterial.useRadianceOverAlpha = !this._parent.transparencyAsCoverage; + babylonMaterial.useSpecularOverAlpha = !this._parent.transparencyAsCoverage; + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_OPAQUE; + babylonMaterial.metallic = 1; + babylonMaterial.roughness = 1; + return babylonMaterial; + }; + /** + * Creates a Babylon material from a glTF material. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonDrawMode The draw mode for the Babylon material + * @returns The Babylon material + */ + GLTFLoader.prototype.createMaterial = function (context, material, babylonDrawMode) { + var extensionPromise = this._extensionsCreateMaterial(context, material, babylonDrawMode); + if (extensionPromise) { + return extensionPromise; + } + var name = material.name || "material".concat(material.index); + var babylonMaterial = this._createDefaultMaterial(name, babylonDrawMode); + return babylonMaterial; + }; + /** + * Loads properties from a glTF material into a Babylon material. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonMaterial The Babylon material + * @returns A promise that resolves when the load is complete + */ + GLTFLoader.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var extensionPromise = this._extensionsLoadMaterialPropertiesAsync(context, material, babylonMaterial); + if (extensionPromise) { + return extensionPromise; + } + var promises = new Array(); + promises.push(this.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + if (material.pbrMetallicRoughness) { + promises.push(this._loadMaterialMetallicRoughnessPropertiesAsync("".concat(context, "/pbrMetallicRoughness"), material.pbrMetallicRoughness, babylonMaterial)); + } + this.loadMaterialAlphaProperties(context, material, babylonMaterial); + return Promise.all(promises).then(function () { }); + }; + /** + * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonMaterial The Babylon material + * @returns A promise that resolves when the load is complete + */ + GLTFLoader.prototype.loadMaterialBasePropertiesAsync = function (context, material, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.emissiveColor = material.emissiveFactor ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(material.emissiveFactor) : new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3(0, 0, 0); + if (material.doubleSided) { + babylonMaterial.backFaceCulling = false; + babylonMaterial.twoSidedLighting = true; + } + if (material.normalTexture) { + material.normalTexture.nonColorData = true; + promises.push(this.loadTextureInfoAsync("".concat(context, "/normalTexture"), material.normalTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Normal)"); + babylonMaterial.bumpTexture = texture; + })); + babylonMaterial.invertNormalMapX = !this._babylonScene.useRightHandedSystem; + babylonMaterial.invertNormalMapY = this._babylonScene.useRightHandedSystem; + if (material.normalTexture.scale != undefined && babylonMaterial.bumpTexture) { + babylonMaterial.bumpTexture.level = material.normalTexture.scale; + } + babylonMaterial.forceIrradianceInFragment = true; + } + if (material.occlusionTexture) { + material.occlusionTexture.nonColorData = true; + promises.push(this.loadTextureInfoAsync("".concat(context, "/occlusionTexture"), material.occlusionTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Occlusion)"); + babylonMaterial.ambientTexture = texture; + })); + babylonMaterial.useAmbientInGrayScale = true; + if (material.occlusionTexture.strength != undefined) { + babylonMaterial.ambientTextureStrength = material.occlusionTexture.strength; + } + } + if (material.emissiveTexture) { + promises.push(this.loadTextureInfoAsync("".concat(context, "/emissiveTexture"), material.emissiveTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Emissive)"); + babylonMaterial.emissiveTexture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + /** + * Loads the alpha properties from a glTF material into a Babylon material. + * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonMaterial The Babylon material + */ + GLTFLoader.prototype.loadMaterialAlphaProperties = function (context, material, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var alphaMode = material.alphaMode || "OPAQUE" /* MaterialAlphaMode.OPAQUE */; + switch (alphaMode) { + case "OPAQUE" /* MaterialAlphaMode.OPAQUE */: { + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_OPAQUE; + babylonMaterial.alpha = 1.0; // Force alpha to 1.0 for opaque mode. + break; + } + case "MASK" /* MaterialAlphaMode.MASK */: { + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_ALPHATEST; + babylonMaterial.alphaCutOff = material.alphaCutoff == undefined ? 0.5 : material.alphaCutoff; + if (babylonMaterial.albedoTexture) { + babylonMaterial.albedoTexture.hasAlpha = true; + } + break; + } + case "BLEND" /* MaterialAlphaMode.BLEND */: { + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_ALPHABLEND; + if (babylonMaterial.albedoTexture) { + babylonMaterial.albedoTexture.hasAlpha = true; + babylonMaterial.useAlphaFromAlbedoTexture = true; + } + break; + } + default: { + throw new Error("".concat(context, "/alphaMode: Invalid value (").concat(material.alphaMode, ")")); + } + } + }; + /** + * Loads a glTF texture info. + * @param context The context when loading the asset + * @param textureInfo The glTF texture info property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded Babylon texture when the load is complete + */ + GLTFLoader.prototype.loadTextureInfoAsync = function (context, textureInfo, assign) { + var _this = this; + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadTextureInfoAsync(context, textureInfo, assign); + if (extensionPromise) { + return extensionPromise; + } + this.logOpen("".concat(context)); + if (textureInfo.texCoord >= 6) { + throw new Error("".concat(context, "/texCoord: Invalid value (").concat(textureInfo.texCoord, ")")); + } + var texture = ArrayItem.Get("".concat(context, "/index"), this._gltf.textures, textureInfo.index); + texture._textureInfo = textureInfo; + var promise = this._loadTextureAsync("/textures/".concat(textureInfo.index), texture, function (babylonTexture) { + babylonTexture.coordinatesIndex = textureInfo.texCoord || 0; + GLTFLoader.AddPointerMetadata(babylonTexture, context); + _this._parent.onTextureLoadedObservable.notifyObservers(babylonTexture); + assign(babylonTexture); + }); + this.logClose(); + return promise; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadTextureAsync = function (context, texture, assign) { + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadTextureAsync(context, texture, assign); + if (extensionPromise) { + return extensionPromise; + } + this.logOpen("".concat(context, " ").concat(texture.name || "")); + var sampler = texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get("".concat(context, "/sampler"), this._gltf.samplers, texture.sampler); + var image = ArrayItem.Get("".concat(context, "/source"), this._gltf.images, texture.source); + var promise = this._createTextureAsync(context, sampler, image, assign, undefined, !texture._textureInfo.nonColorData); + this.logClose(); + return promise; + }; + /** + * @internal + */ + GLTFLoader.prototype._createTextureAsync = function (context, sampler, image, assign, textureLoaderOptions, useSRGBBuffer) { + var _this = this; + if (assign === void 0) { assign = function () { }; } + var samplerData = this._loadSampler("/samplers/".concat(sampler.index), sampler); + var promises = new Array(); + var deferred = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var textureCreationOptions = { + noMipmap: samplerData.noMipMaps, + invertY: false, + samplingMode: samplerData.samplingMode, + onLoad: function () { + if (!_this._disposed) { + deferred.resolve(); + } + }, + onError: function (message, exception) { + if (!_this._disposed) { + deferred.reject(new Error("".concat(context, ": ").concat(exception && exception.message ? exception.message : message || "Failed to load texture"))); + } + }, + mimeType: image.mimeType, + loaderOptions: textureLoaderOptions, + useSRGBBuffer: !!useSRGBBuffer && this._parent.useSRGBBuffers, + }; + var babylonTexture = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture(null, this._babylonScene, textureCreationOptions); + babylonTexture._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + promises.push(deferred.promise); + promises.push(this.loadImageAsync("/images/".concat(image.index), image).then(function (data) { + var name = image.uri || "".concat(_this._fileName, "#image").concat(image.index); + var dataUrl = "data:".concat(_this._uniqueRootUrl).concat(name); + babylonTexture.updateURL(dataUrl, data); + })); + babylonTexture.wrapU = samplerData.wrapU; + babylonTexture.wrapV = samplerData.wrapV; + assign(babylonTexture); + return Promise.all(promises).then(function () { + return babylonTexture; + }); + }; + GLTFLoader.prototype._loadSampler = function (context, sampler) { + if (!sampler._data) { + sampler._data = { + noMipMaps: sampler.minFilter === 9728 /* TextureMinFilter.NEAREST */ || sampler.minFilter === 9729 /* TextureMinFilter.LINEAR */, + samplingMode: GLTFLoader._GetTextureSamplingMode(context, sampler), + wrapU: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapS"), sampler.wrapS), + wrapV: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapT"), sampler.wrapT), + }; + } + return sampler._data; + }; + /** + * Loads a glTF image. + * @param context The context when loading the asset + * @param image The glTF image property + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadImageAsync = function (context, image) { + if (!image._data) { + this.logOpen("".concat(context, " ").concat(image.name || "")); + if (image.uri) { + image._data = this.loadUriAsync("".concat(context, "/uri"), image, image.uri); + } + else { + var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, image.bufferView); + image._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView); + } + this.logClose(); + } + return image._data; + }; + /** + * Loads a glTF uri. + * @param context The context when loading the asset + * @param property The glTF property associated with the uri + * @param uri The base64 or relative uri + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadUriAsync = function (context, property, uri) { + var _this = this; + var extensionPromise = this._extensionsLoadUriAsync(context, property, uri); + if (extensionPromise) { + return extensionPromise; + } + if (!GLTFLoader._ValidateUri(uri)) { + throw new Error("".concat(context, ": '").concat(uri, "' is invalid")); + } + if ((0,babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.IsBase64DataUrl)(uri)) { + var data = new Uint8Array((0,babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.DecodeBase64UrlToBinary)(uri)); + this.log("".concat(context, ": Decoded ").concat(uri.substr(0, 64), "... (").concat(data.length, " bytes)")); + return Promise.resolve(data); + } + this.log("".concat(context, ": Loading ").concat(uri)); + return this._parent.preprocessUrlAsync(this._rootUrl + uri).then(function (url) { + return new Promise(function (resolve, reject) { + _this._parent._loadFile(_this._babylonScene, url, function (data) { + if (!_this._disposed) { + _this.log("".concat(context, ": Loaded ").concat(uri, " (").concat(data.byteLength, " bytes)")); + resolve(new Uint8Array(data)); + } + }, true, function (request) { + reject(new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.LoadFileError("".concat(context, ": Failed to load '").concat(uri, "'").concat(request ? ": " + request.status + " " + request.statusText : ""), request)); + }); + }); + }); + }; + /** + * Adds a JSON pointer to the _internalMetadata of the Babylon object at `._internalMetadata.gltf.pointers`. + * @param babylonObject the Babylon object with _internalMetadata + * @param pointer the JSON pointer + */ + GLTFLoader.AddPointerMetadata = function (babylonObject, pointer) { + babylonObject.metadata = babylonObject.metadata || {}; + var metadata = (babylonObject._internalMetadata = babylonObject._internalMetadata || {}); + var gltf = (metadata.gltf = metadata.gltf || {}); + var pointers = (gltf.pointers = gltf.pointers || []); + pointers.push(pointer); + }; + GLTFLoader._GetTextureWrapMode = function (context, mode) { + // Set defaults if undefined + mode = mode == undefined ? 10497 /* TextureWrapMode.REPEAT */ : mode; + switch (mode) { + case 33071 /* TextureWrapMode.CLAMP_TO_EDGE */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.CLAMP_ADDRESSMODE; + case 33648 /* TextureWrapMode.MIRRORED_REPEAT */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.MIRROR_ADDRESSMODE; + case 10497 /* TextureWrapMode.REPEAT */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.WRAP_ADDRESSMODE; + default: + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Invalid value (").concat(mode, ")")); + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.WRAP_ADDRESSMODE; + } + }; + GLTFLoader._GetTextureSamplingMode = function (context, sampler) { + // Set defaults if undefined + var magFilter = sampler.magFilter == undefined ? 9729 /* TextureMagFilter.LINEAR */ : sampler.magFilter; + var minFilter = sampler.minFilter == undefined ? 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */ : sampler.minFilter; + if (magFilter === 9729 /* TextureMagFilter.LINEAR */) { + switch (minFilter) { + case 9728 /* TextureMinFilter.NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST; + case 9729 /* TextureMinFilter.LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR; + case 9984 /* TextureMinFilter.NEAREST_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST_MIPNEAREST; + case 9985 /* TextureMinFilter.LINEAR_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPNEAREST; + case 9986 /* TextureMinFilter.NEAREST_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST_MIPLINEAR; + case 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPLINEAR; + default: + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")")); + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPLINEAR; + } + } + else { + if (magFilter !== 9728 /* TextureMagFilter.NEAREST */) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/magFilter: Invalid value (").concat(magFilter, ")")); + } + switch (minFilter) { + case 9728 /* TextureMinFilter.NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST; + case 9729 /* TextureMinFilter.LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR; + case 9984 /* TextureMinFilter.NEAREST_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPNEAREST; + case 9985 /* TextureMinFilter.LINEAR_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR_MIPNEAREST; + case 9986 /* TextureMinFilter.NEAREST_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPLINEAR; + case 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR_MIPLINEAR; + default: + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")")); + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPNEAREST; + } + } + }; + GLTFLoader._GetTypedArrayConstructor = function (context, componentType) { + switch (componentType) { + case 5120 /* AccessorComponentType.BYTE */: + return Int8Array; + case 5121 /* AccessorComponentType.UNSIGNED_BYTE */: + return Uint8Array; + case 5122 /* AccessorComponentType.SHORT */: + return Int16Array; + case 5123 /* AccessorComponentType.UNSIGNED_SHORT */: + return Uint16Array; + case 5125 /* AccessorComponentType.UNSIGNED_INT */: + return Uint32Array; + case 5126 /* AccessorComponentType.FLOAT */: + return Float32Array; + default: + throw new Error("".concat(context, ": Invalid component type ").concat(componentType)); + } + }; + GLTFLoader._GetTypedArray = function (context, componentType, bufferView, byteOffset, length) { + var buffer = bufferView.buffer; + byteOffset = bufferView.byteOffset + (byteOffset || 0); + var constructor = GLTFLoader._GetTypedArrayConstructor("".concat(context, "/componentType"), componentType); + var componentTypeLength = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(componentType); + if (byteOffset % componentTypeLength !== 0) { + // HACK: Copy the buffer if byte offset is not a multiple of component type byte length. + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Copying buffer as byte offset (").concat(byteOffset, ") is not a multiple of component type byte length (").concat(componentTypeLength, ")")); + return new constructor(buffer.slice(byteOffset, byteOffset + length * componentTypeLength), 0); + } + return new constructor(buffer, byteOffset, length); + }; + GLTFLoader._GetNumComponents = function (context, type) { + switch (type) { + case "SCALAR": + return 1; + case "VEC2": + return 2; + case "VEC3": + return 3; + case "VEC4": + return 4; + case "MAT2": + return 4; + case "MAT3": + return 9; + case "MAT4": + return 16; + } + throw new Error("".concat(context, ": Invalid type (").concat(type, ")")); + }; + GLTFLoader._ValidateUri = function (uri) { + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Tools.IsBase64(uri) || uri.indexOf("..") === -1; + }; + /** + * @internal + */ + GLTFLoader._GetDrawMode = function (context, mode) { + if (mode == undefined) { + mode = 4 /* MeshPrimitiveMode.TRIANGLES */; + } + switch (mode) { + case 0 /* MeshPrimitiveMode.POINTS */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.PointListDrawMode; + case 1 /* MeshPrimitiveMode.LINES */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineListDrawMode; + case 2 /* MeshPrimitiveMode.LINE_LOOP */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineLoopDrawMode; + case 3 /* MeshPrimitiveMode.LINE_STRIP */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineStripDrawMode; + case 4 /* MeshPrimitiveMode.TRIANGLES */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode; + case 5 /* MeshPrimitiveMode.TRIANGLE_STRIP */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleStripDrawMode; + case 6 /* MeshPrimitiveMode.TRIANGLE_FAN */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFanDrawMode; + } + throw new Error("".concat(context, ": Invalid mesh primitive mode (").concat(mode, ")")); + }; + GLTFLoader.prototype._compileMaterialsAsync = function () { + var _this = this; + this._parent._startPerformanceCounter("Compile materials"); + var promises = new Array(); + if (this._gltf.materials) { + for (var _i = 0, _a = this._gltf.materials; _i < _a.length; _i++) { + var material = _a[_i]; + if (material._data) { + for (var babylonDrawMode in material._data) { + var babylonData = material._data[babylonDrawMode]; + for (var _b = 0, _c = babylonData.babylonMeshes; _b < _c.length; _b++) { + var babylonMesh = _c[_b]; + // Ensure nonUniformScaling is set if necessary. + babylonMesh.computeWorldMatrix(true); + var babylonMaterial = babylonData.babylonMaterial; + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh)); + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { useInstances: true })); + if (this._parent.useClipPlane) { + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { clipPlane: true })); + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { clipPlane: true, useInstances: true })); + } + } + } + } + } + } + return Promise.all(promises).then(function () { + _this._parent._endPerformanceCounter("Compile materials"); + }); + }; + GLTFLoader.prototype._compileShadowGeneratorsAsync = function () { + var _this = this; + this._parent._startPerformanceCounter("Compile shadow generators"); + var promises = new Array(); + var lights = this._babylonScene.lights; + for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) { + var light = lights_1[_i]; + var generator = light.getShadowGenerator(); + if (generator) { + promises.push(generator.forceCompilationAsync()); + } + } + return Promise.all(promises).then(function () { + _this._parent._endPerformanceCounter("Compile shadow generators"); + }); + }; + GLTFLoader.prototype._forEachExtensions = function (action) { + for (var _i = 0, _a = this._extensions; _i < _a.length; _i++) { + var extension = _a[_i]; + if (extension.enabled) { + action(extension); + } + } + }; + GLTFLoader.prototype._applyExtensions = function (property, functionName, actionAsync) { + for (var _i = 0, _a = this._extensions; _i < _a.length; _i++) { + var extension = _a[_i]; + if (extension.enabled) { + var id = "".concat(extension.name, ".").concat(functionName); + var loaderProperty = property; + loaderProperty._activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions || {}; + var activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions; + if (!activeLoaderExtensionFunctions[id]) { + activeLoaderExtensionFunctions[id] = true; + try { + var result = actionAsync(extension); + if (result) { + return result; + } + } + finally { + delete activeLoaderExtensionFunctions[id]; + } + } + } + } + return null; + }; + GLTFLoader.prototype._extensionsOnLoading = function () { + this._forEachExtensions(function (extension) { return extension.onLoading && extension.onLoading(); }); + }; + GLTFLoader.prototype._extensionsOnReady = function () { + this._forEachExtensions(function (extension) { return extension.onReady && extension.onReady(); }); + }; + GLTFLoader.prototype._extensionsLoadSceneAsync = function (context, scene) { + return this._applyExtensions(scene, "loadScene", function (extension) { return extension.loadSceneAsync && extension.loadSceneAsync(context, scene); }); + }; + GLTFLoader.prototype._extensionsLoadNodeAsync = function (context, node, assign) { + return this._applyExtensions(node, "loadNode", function (extension) { return extension.loadNodeAsync && extension.loadNodeAsync(context, node, assign); }); + }; + GLTFLoader.prototype._extensionsLoadCameraAsync = function (context, camera, assign) { + return this._applyExtensions(camera, "loadCamera", function (extension) { return extension.loadCameraAsync && extension.loadCameraAsync(context, camera, assign); }); + }; + GLTFLoader.prototype._extensionsLoadVertexDataAsync = function (context, primitive, babylonMesh) { + return this._applyExtensions(primitive, "loadVertexData", function (extension) { return extension._loadVertexDataAsync && extension._loadVertexDataAsync(context, primitive, babylonMesh); }); + }; + GLTFLoader.prototype._extensionsLoadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) { + return this._applyExtensions(primitive, "loadMeshPrimitive", function (extension) { return extension._loadMeshPrimitiveAsync && extension._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign); }); + }; + GLTFLoader.prototype._extensionsLoadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) { + return this._applyExtensions(material, "loadMaterial", function (extension) { return extension._loadMaterialAsync && extension._loadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign); }); + }; + GLTFLoader.prototype._extensionsCreateMaterial = function (context, material, babylonDrawMode) { + return this._applyExtensions(material, "createMaterial", function (extension) { return extension.createMaterial && extension.createMaterial(context, material, babylonDrawMode); }); + }; + GLTFLoader.prototype._extensionsLoadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + return this._applyExtensions(material, "loadMaterialProperties", function (extension) { return extension.loadMaterialPropertiesAsync && extension.loadMaterialPropertiesAsync(context, material, babylonMaterial); }); + }; + GLTFLoader.prototype._extensionsLoadTextureInfoAsync = function (context, textureInfo, assign) { + return this._applyExtensions(textureInfo, "loadTextureInfo", function (extension) { return extension.loadTextureInfoAsync && extension.loadTextureInfoAsync(context, textureInfo, assign); }); + }; + GLTFLoader.prototype._extensionsLoadTextureAsync = function (context, texture, assign) { + return this._applyExtensions(texture, "loadTexture", function (extension) { return extension._loadTextureAsync && extension._loadTextureAsync(context, texture, assign); }); + }; + GLTFLoader.prototype._extensionsLoadAnimationAsync = function (context, animation) { + return this._applyExtensions(animation, "loadAnimation", function (extension) { return extension.loadAnimationAsync && extension.loadAnimationAsync(context, animation); }); + }; + GLTFLoader.prototype._extensionsLoadAnimationChannelAsync = function (context, animationContext, animation, channel, onLoad) { + return this._applyExtensions(animation, "loadAnimationChannel", function (extension) { return extension._loadAnimationChannelAsync && extension._loadAnimationChannelAsync(context, animationContext, animation, channel, onLoad); }); + }; + GLTFLoader.prototype._extensionsLoadSkinAsync = function (context, node, skin) { + return this._applyExtensions(skin, "loadSkin", function (extension) { return extension._loadSkinAsync && extension._loadSkinAsync(context, node, skin); }); + }; + GLTFLoader.prototype._extensionsLoadUriAsync = function (context, property, uri) { + return this._applyExtensions(property, "loadUri", function (extension) { return extension._loadUriAsync && extension._loadUriAsync(context, property, uri); }); + }; + GLTFLoader.prototype._extensionsLoadBufferViewAsync = function (context, bufferView) { + return this._applyExtensions(bufferView, "loadBufferView", function (extension) { return extension.loadBufferViewAsync && extension.loadBufferViewAsync(context, bufferView); }); + }; + GLTFLoader.prototype._extensionsLoadBufferAsync = function (context, buffer, byteOffset, byteLength) { + return this._applyExtensions(buffer, "loadBuffer", function (extension) { return extension.loadBufferAsync && extension.loadBufferAsync(context, buffer, byteOffset, byteLength); }); + }; + /** + * Helper method called by a loader extension to load an glTF extension. + * @param context The context when loading the asset + * @param property The glTF property to load the extension from + * @param extensionName The name of the extension to load + * @param actionAsync The action to run + * @returns The promise returned by actionAsync or null if the extension does not exist + */ + GLTFLoader.LoadExtensionAsync = function (context, property, extensionName, actionAsync) { + if (!property.extensions) { + return null; + } + var extensions = property.extensions; + var extension = extensions[extensionName]; + if (!extension) { + return null; + } + return actionAsync("".concat(context, "/extensions/").concat(extensionName), extension); + }; + /** + * Helper method called by a loader extension to load a glTF extra. + * @param context The context when loading the asset + * @param property The glTF property to load the extra from + * @param extensionName The name of the extension to load + * @param actionAsync The action to run + * @returns The promise returned by actionAsync or null if the extra does not exist + */ + GLTFLoader.LoadExtraAsync = function (context, property, extensionName, actionAsync) { + if (!property.extras) { + return null; + } + var extras = property.extras; + var extra = extras[extensionName]; + if (!extra) { + return null; + } + return actionAsync("".concat(context, "/extras/").concat(extensionName), extra); + }; + /** + * Checks for presence of an extension. + * @param name The name of the extension to check + * @returns A boolean indicating the presence of the given extension name in `extensionsUsed` + */ + GLTFLoader.prototype.isExtensionUsed = function (name) { + return !!this._gltf.extensionsUsed && this._gltf.extensionsUsed.indexOf(name) !== -1; + }; + /** + * Increments the indentation level and logs a message. + * @param message The message to log + */ + GLTFLoader.prototype.logOpen = function (message) { + this._parent._logOpen(message); + }; + /** + * Decrements the indentation level. + */ + GLTFLoader.prototype.logClose = function () { + this._parent._logClose(); + }; + /** + * Logs a message + * @param message The message to log + */ + GLTFLoader.prototype.log = function (message) { + this._parent._log(message); + }; + /** + * Starts a performance counter. + * @param counterName The name of the performance counter + */ + GLTFLoader.prototype.startPerformanceCounter = function (counterName) { + this._parent._startPerformanceCounter(counterName); + }; + /** + * Ends a performance counter. + * @param counterName The name of the performance counter + */ + GLTFLoader.prototype.endPerformanceCounter = function (counterName) { + this._parent._endPerformanceCounter(counterName); + }; + GLTFLoader._RegisteredExtensions = {}; + /** + * The default glTF sampler. + */ + GLTFLoader.DefaultSampler = { index: -1 }; + return GLTFLoader; +}()); +_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFFileLoader._CreateGLTF2Loader = function (parent) { return new GLTFLoader(parent); }; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts": +/*!****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ AnimationPropertyInfo: () => (/* binding */ AnimationPropertyInfo), +/* harmony export */ TransformNodeAnimationPropertyInfo: () => (/* binding */ TransformNodeAnimationPropertyInfo), +/* harmony export */ WeightAnimationPropertyInfo: () => (/* binding */ WeightAnimationPropertyInfo), +/* harmony export */ getQuaternion: () => (/* binding */ getQuaternion), +/* harmony export */ getVector3: () => (/* binding */ getVector3), +/* harmony export */ getWeights: () => (/* binding */ getWeights), +/* harmony export */ nodeAnimationData: () => (/* binding */ nodeAnimationData) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__); + + + +/** @internal */ +function getVector3(_target, source, offset, scale) { + return babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(source, offset).scaleInPlace(scale); +} +/** @internal */ +function getQuaternion(_target, source, offset, scale) { + return babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(source, offset).scaleInPlace(scale); +} +/** @internal */ +function getWeights(target, source, offset, scale) { + var value = new Array(target._numMorphTargets); + for (var i = 0; i < value.length; i++) { + value[i] = source[offset++] * scale; + } + return value; +} +/** @internal */ +var AnimationPropertyInfo = /** @class */ (function () { + /** @internal */ + function AnimationPropertyInfo(type, name, getValue, getStride) { + this.type = type; + this.name = name; + this.getValue = getValue; + this.getStride = getStride; + } + AnimationPropertyInfo.prototype._buildAnimation = function (name, fps, keys) { + var babylonAnimation = new babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation(name, this.name, fps, this.type); + babylonAnimation.setKeys(keys); + return babylonAnimation; + }; + return AnimationPropertyInfo; +}()); + +/** @internal */ +var TransformNodeAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__extends)(TransformNodeAnimationPropertyInfo, _super); + function TransformNodeAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + TransformNodeAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + callback(target._babylonTransformNode, this._buildAnimation(name, fps, keys)); + }; + return TransformNodeAnimationPropertyInfo; +}(AnimationPropertyInfo)); + +/** @internal */ +var WeightAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__extends)(WeightAnimationPropertyInfo, _super); + function WeightAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + WeightAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + if (target._numMorphTargets) { + var _loop_1 = function (targetIndex) { + var babylonAnimation = new babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation("".concat(name, "_").concat(targetIndex), this_1.name, fps, this_1.type); + babylonAnimation.setKeys(keys.map(function (key) { return ({ + frame: key.frame, + inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined, + value: key.value[targetIndex], + outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined, + interpolation: key.interpolation, + }); })); + if (target._primitiveBabylonMeshes) { + for (var _i = 0, _a = target._primitiveBabylonMeshes; _i < _a.length; _i++) { + var babylonMesh = _a[_i]; + if (babylonMesh.morphTargetManager) { + var morphTarget = babylonMesh.morphTargetManager.getTarget(targetIndex); + var babylonAnimationClone = babylonAnimation.clone(); + morphTarget.animations.push(babylonAnimationClone); + callback(morphTarget, babylonAnimationClone); + } + } + } + }; + var this_1 = this; + for (var targetIndex = 0; targetIndex < target._numMorphTargets; targetIndex++) { + _loop_1(targetIndex); + } + } + }; + return WeightAnimationPropertyInfo; +}(AnimationPropertyInfo)); + +/** @internal */ +var nodeAnimationData = { + translation: [new TransformNodeAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_VECTOR3, "position", getVector3, function () { return 3; })], + rotation: [new TransformNodeAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_QUATERNION, "rotationQuaternion", getQuaternion, function () { return 4; })], + scale: [new TransformNodeAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_VECTOR3, "scaling", getVector3, function () { return 3; })], + weights: [new WeightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "influence", getWeights, function (target) { return target._numMorphTargets; })], +}; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoaderExtension.ts": +/*!****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoaderExtension.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts": +/*!*****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts ***! + \*****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/index.ts": +/*!**************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/index.ts ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ArrayItem: () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem), +/* harmony export */ EXT_lights_image_based: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_lights_image_based), +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_mesh_gpu_instancing), +/* harmony export */ EXT_meshopt_compression: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_meshopt_compression), +/* harmony export */ EXT_texture_webp: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_texture_webp), +/* harmony export */ ExtrasAsMetadata: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.ExtrasAsMetadata), +/* harmony export */ GLTFLoader: () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader), +/* harmony export */ KHR_animation_pointer: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_animation_pointer), +/* harmony export */ KHR_draco_mesh_compression: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_draco_mesh_compression), +/* harmony export */ KHR_interactivity: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_interactivity), +/* harmony export */ KHR_lights: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_lights), +/* harmony export */ KHR_materials_anisotropy: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_anisotropy), +/* harmony export */ KHR_materials_clearcoat: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_clearcoat), +/* harmony export */ KHR_materials_dispersion: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_dispersion), +/* harmony export */ KHR_materials_emissive_strength: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_emissive_strength), +/* harmony export */ KHR_materials_ior: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_ior), +/* harmony export */ KHR_materials_iridescence: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_iridescence), +/* harmony export */ KHR_materials_pbrSpecularGlossiness: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_pbrSpecularGlossiness), +/* harmony export */ KHR_materials_sheen: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_sheen), +/* harmony export */ KHR_materials_specular: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_specular), +/* harmony export */ KHR_materials_translucency: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_translucency), +/* harmony export */ KHR_materials_transmission: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_transmission), +/* harmony export */ KHR_materials_unlit: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_unlit), +/* harmony export */ KHR_materials_variants: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_variants), +/* harmony export */ KHR_materials_volume: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_volume), +/* harmony export */ KHR_mesh_quantization: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_mesh_quantization), +/* harmony export */ KHR_texture_basisu: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_texture_basisu), +/* harmony export */ KHR_texture_transform: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_texture_transform), +/* harmony export */ KHR_xmp_json_ld: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_xmp_json_ld), +/* harmony export */ MSFT_audio_emitter: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_audio_emitter), +/* harmony export */ MSFT_lod: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_lod), +/* harmony export */ MSFT_minecraftMesh: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_minecraftMesh), +/* harmony export */ MSFT_sRGBFactors: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_sRGBFactors) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var _glTFLoaderExtension__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoaderExtension */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderExtension.ts"); +/* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts"); +/* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Extensions/index */ "../../../dev/loaders/src/glTF/2.0/Extensions/index.ts"); +/* eslint-disable import/no-internal-modules */ + + + + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/glTFFileLoader.ts": +/*!*******************************************************!*\ + !*** ../../../dev/loaders/src/glTF/glTFFileLoader.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFFileLoader: () => (/* binding */ GLTFFileLoader), +/* harmony export */ GLTFLoaderAnimationStartMode: () => (/* binding */ GLTFLoaderAnimationStartMode), +/* harmony export */ GLTFLoaderCoordinateSystemMode: () => (/* binding */ GLTFLoaderCoordinateSystemMode), +/* harmony export */ GLTFLoaderState: () => (/* binding */ GLTFLoaderState) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/error */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFValidation */ "../../../dev/loaders/src/glTF/glTFValidation.ts"); + + + + + + + + + +function readAsync(arrayBuffer, byteOffset, byteLength) { + try { + return Promise.resolve(new Uint8Array(arrayBuffer, byteOffset, byteLength)); + } + catch (e) { + return Promise.reject(e); + } +} +function readViewAsync(arrayBufferView, byteOffset, byteLength) { + try { + if (byteOffset < 0 || byteOffset >= arrayBufferView.byteLength) { + throw new RangeError("Offset is out of range."); + } + if (byteOffset + byteLength > arrayBufferView.byteLength) { + throw new RangeError("Length is out of range."); + } + return Promise.resolve(new Uint8Array(arrayBufferView.buffer, arrayBufferView.byteOffset + byteOffset, byteLength)); + } + catch (e) { + return Promise.reject(e); + } +} +/** + * Mode that determines the coordinate system to use. + */ +var GLTFLoaderCoordinateSystemMode; +(function (GLTFLoaderCoordinateSystemMode) { + /** + * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene. + */ + GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["AUTO"] = 0] = "AUTO"; + /** + * Sets the useRightHandedSystem flag on the scene. + */ + GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["FORCE_RIGHT_HANDED"] = 1] = "FORCE_RIGHT_HANDED"; +})(GLTFLoaderCoordinateSystemMode || (GLTFLoaderCoordinateSystemMode = {})); +/** + * Mode that determines what animations will start. + */ +var GLTFLoaderAnimationStartMode; +(function (GLTFLoaderAnimationStartMode) { + /** + * No animation will start. + */ + GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["NONE"] = 0] = "NONE"; + /** + * The first animation will start. + */ + GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["FIRST"] = 1] = "FIRST"; + /** + * All animations will start. + */ + GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["ALL"] = 2] = "ALL"; +})(GLTFLoaderAnimationStartMode || (GLTFLoaderAnimationStartMode = {})); +/** + * Loader state. + */ +var GLTFLoaderState; +(function (GLTFLoaderState) { + /** + * The asset is loading. + */ + GLTFLoaderState[GLTFLoaderState["LOADING"] = 0] = "LOADING"; + /** + * The asset is ready for rendering. + */ + GLTFLoaderState[GLTFLoaderState["READY"] = 1] = "READY"; + /** + * The asset is completely loaded. + */ + GLTFLoaderState[GLTFLoaderState["COMPLETE"] = 2] = "COMPLETE"; +})(GLTFLoaderState || (GLTFLoaderState = {})); +/** + * File loader for loading glTF files into a scene. + */ +var GLTFFileLoader = /** @class */ (function () { + function GLTFFileLoader() { + // -------------- + // Common options + // -------------- + /** + * Raised when the asset has been parsed + */ + this.onParsedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + // ---------- + // V2 options + // ---------- + /** + * The coordinate system mode. Defaults to AUTO. + */ + this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO; + /** + * The animation start mode. Defaults to FIRST. + */ + this.animationStartMode = GLTFLoaderAnimationStartMode.FIRST; + /** + * Defines if the loader should compile materials before raising the success callback. Defaults to false. + */ + this.compileMaterials = false; + /** + * Defines if the loader should also compile materials with clip planes. Defaults to false. + */ + this.useClipPlane = false; + /** + * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false. + */ + this.compileShadowGenerators = false; + /** + * Defines if the Alpha blended materials are only applied as coverage. + * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials. + * If true, no extra effects are applied to transparent pixels. + */ + this.transparencyAsCoverage = false; + /** + * Defines if the loader should use range requests when load binary glTF files from HTTP. + * Enabling will disable offline support and glTF validator. + * Defaults to false. + */ + this.useRangeRequests = false; + /** + * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true. + */ + this.createInstances = true; + /** + * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false. + */ + this.alwaysComputeBoundingBox = false; + /** + * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false. + */ + this.loadAllMaterials = false; + /** + * If true, load only the materials defined in the file. Defaults to false. + */ + this.loadOnlyMaterials = false; + /** + * If true, do not load any materials defined in the file. Defaults to false. + */ + this.skipMaterials = false; + /** + * If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true. + */ + this.useSRGBBuffers = true; + /** + * When loading glTF animations, which are defined in seconds, target them to this FPS. Defaults to 60. + */ + this.targetFps = 60; + /** + * Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using `skin.skeleton`. Defaults to false. + * Set this to true if loading assets with invalid `skin.skeleton` values. + */ + this.alwaysComputeSkeletonRootNode = false; + /** + * Function called before loading a url referenced by the asset. + * @param url url referenced by the asset + * @returns Async url to load + */ + this.preprocessUrlAsync = function (url) { return Promise.resolve(url); }; + /** + * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh. + * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...) + */ + this.onMeshLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Callback raised when the loader creates a skin after parsing the glTF properties of the skin node. + * @see https://doc.babylonjs.com/features/featuresDeepDive/importers/glTF/glTFSkinning#ignoring-the-transform-of-the-skinned-mesh + * @param node - the transform node that corresponds to the original glTF skin node used for animations + * @param skinnedNode - the transform node that is the skinned mesh itself or the parent of the skinned meshes + */ + this.onSkinLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the loader creates a texture after parsing the glTF properties of the texture. + */ + this.onTextureLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the loader creates a material after parsing the glTF properties of the material. + */ + this.onMaterialLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the loader creates a camera after parsing the glTF properties of the camera. + */ + this.onCameraLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the asset is completely loaded, immediately before the loader is disposed. + * For assets with LODs, raised when all of the LODs are complete. + * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise. + */ + this.onCompleteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when an error occurs. + */ + this.onErrorObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised after the loader is disposed. + */ + this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised after a loader extension is created. + * Set additional options for a loader extension in this event. + */ + this.onExtensionLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Defines if the loader should validate the asset. + */ + this.validate = false; + /** + * Observable raised after validation when validate is set to true. The event data is the result of the validation. + */ + this.onValidatedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._loader = null; + this._state = null; + this._requests = new Array(); + /** + * Name of the loader ("gltf") + */ + this.name = "gltf"; + /** @internal */ + this.extensions = { + ".gltf": { isBinary: false }, + ".glb": { isBinary: true }, + }; + /** + * Observable raised when the loader state changes. + */ + this.onLoaderStateChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._logIndentLevel = 0; + this._loggingEnabled = false; + /** @internal */ + this._log = this._logDisabled; + this._capturePerformanceCounters = false; + /** @internal */ + this._startPerformanceCounter = this._startPerformanceCounterDisabled; + /** @internal */ + this._endPerformanceCounter = this._endPerformanceCounterDisabled; + } + Object.defineProperty(GLTFFileLoader.prototype, "onParsed", { + /** + * Raised when the asset has been parsed + */ + set: function (callback) { + if (this._onParsedObserver) { + this.onParsedObservable.remove(this._onParsedObserver); + } + this._onParsedObserver = this.onParsedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onMeshLoaded", { + /** + * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh. + * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...) + */ + set: function (callback) { + if (this._onMeshLoadedObserver) { + this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver); + } + this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onTextureLoaded", { + /** + * Callback raised when the loader creates a texture after parsing the glTF properties of the texture. + */ + set: function (callback) { + if (this._onTextureLoadedObserver) { + this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver); + } + this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onMaterialLoaded", { + /** + * Callback raised when the loader creates a material after parsing the glTF properties of the material. + */ + set: function (callback) { + if (this._onMaterialLoadedObserver) { + this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver); + } + this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onCameraLoaded", { + /** + * Callback raised when the loader creates a camera after parsing the glTF properties of the camera. + */ + set: function (callback) { + if (this._onCameraLoadedObserver) { + this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver); + } + this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onComplete", { + /** + * Callback raised when the asset is completely loaded, immediately before the loader is disposed. + * For assets with LODs, raised when all of the LODs are complete. + * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise. + */ + set: function (callback) { + if (this._onCompleteObserver) { + this.onCompleteObservable.remove(this._onCompleteObserver); + } + this._onCompleteObserver = this.onCompleteObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onError", { + /** + * Callback raised when an error occurs. + */ + set: function (callback) { + if (this._onErrorObserver) { + this.onErrorObservable.remove(this._onErrorObserver); + } + this._onErrorObserver = this.onErrorObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onDispose", { + /** + * Callback raised after the loader is disposed. + */ + set: function (callback) { + if (this._onDisposeObserver) { + this.onDisposeObservable.remove(this._onDisposeObserver); + } + this._onDisposeObserver = this.onDisposeObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onExtensionLoaded", { + /** + * Callback raised after a loader extension is created. + */ + set: function (callback) { + if (this._onExtensionLoadedObserver) { + this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver); + } + this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "loggingEnabled", { + /** + * Defines if the loader logging is enabled. + */ + get: function () { + return this._loggingEnabled; + }, + set: function (value) { + if (this._loggingEnabled === value) { + return; + } + this._loggingEnabled = value; + if (this._loggingEnabled) { + this._log = this._logEnabled; + } + else { + this._log = this._logDisabled; + } + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "capturePerformanceCounters", { + /** + * Defines if the loader should capture performance counters. + */ + get: function () { + return this._capturePerformanceCounters; + }, + set: function (value) { + if (this._capturePerformanceCounters === value) { + return; + } + this._capturePerformanceCounters = value; + if (this._capturePerformanceCounters) { + this._startPerformanceCounter = this._startPerformanceCounterEnabled; + this._endPerformanceCounter = this._endPerformanceCounterEnabled; + } + else { + this._startPerformanceCounter = this._startPerformanceCounterDisabled; + this._endPerformanceCounter = this._endPerformanceCounterDisabled; + } + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onValidated", { + /** + * Callback raised after a loader extension is created. + */ + set: function (callback) { + if (this._onValidatedObserver) { + this.onValidatedObservable.remove(this._onValidatedObserver); + } + this._onValidatedObserver = this.onValidatedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + /** + * Disposes the loader, releases resources during load, and cancels any outstanding requests. + */ + GLTFFileLoader.prototype.dispose = function () { + if (this._loader) { + this._loader.dispose(); + this._loader = null; + } + for (var _i = 0, _a = this._requests; _i < _a.length; _i++) { + var request = _a[_i]; + request.abort(); + } + this._requests.length = 0; + delete this._progressCallback; + this.preprocessUrlAsync = function (url) { return Promise.resolve(url); }; + this.onMeshLoadedObservable.clear(); + this.onSkinLoadedObservable.clear(); + this.onTextureLoadedObservable.clear(); + this.onMaterialLoadedObservable.clear(); + this.onCameraLoadedObservable.clear(); + this.onCompleteObservable.clear(); + this.onExtensionLoadedObservable.clear(); + this.onDisposeObservable.notifyObservers(undefined); + this.onDisposeObservable.clear(); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.loadFile = function (scene, fileOrUrl, rootUrl, onSuccess, onProgress, useArrayBuffer, onError, name) { + var _this = this; + if (ArrayBuffer.isView(fileOrUrl)) { + this._loadBinary(scene, fileOrUrl, rootUrl, onSuccess, onError, name); + return null; + } + this._progressCallback = onProgress; + var fileName = fileOrUrl.name || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.GetFilename(fileOrUrl); + if (useArrayBuffer) { + if (this.useRangeRequests) { + if (this.validate) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("glTF validation is not supported when range requests are enabled"); + } + var fileRequest_1 = { + abort: function () { }, + onCompleteObservable: new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(), + }; + var dataBuffer = { + readAsync: function (byteOffset, byteLength) { + return new Promise(function (resolve, reject) { + _this._loadFile(scene, fileOrUrl, function (data) { + resolve(new Uint8Array(data)); + }, true, function (error) { + reject(error); + }, function (webRequest) { + webRequest.setRequestHeader("Range", "bytes=".concat(byteOffset, "-").concat(byteOffset + byteLength - 1)); + }); + }); + }, + byteLength: 0, + }; + this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader(dataBuffer)).then(function (loaderData) { + fileRequest_1.onCompleteObservable.notifyObservers(fileRequest_1); + onSuccess(loaderData); + }, onError ? function (error) { return onError(undefined, error); } : undefined); + return fileRequest_1; + } + return this._loadFile(scene, fileOrUrl, function (data) { + _this._validate(scene, new Uint8Array(data, 0, data.byteLength), rootUrl, fileName); + _this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({ + readAsync: function (byteOffset, byteLength) { return readAsync(data, byteOffset, byteLength); }, + byteLength: data.byteLength, + })).then(function (loaderData) { + onSuccess(loaderData); + }, onError ? function (error) { return onError(undefined, error); } : undefined); + }, true, onError); + } + else { + return this._loadFile(scene, fileOrUrl, function (data) { + _this._validate(scene, data, rootUrl, fileName); + onSuccess({ json: _this._parseJson(data) }); + }, false, onError); + } + }; + GLTFFileLoader.prototype._loadBinary = function (scene, data, rootUrl, onSuccess, onError, fileName) { + this._validate(scene, new Uint8Array(data.buffer, data.byteOffset, data.byteLength), rootUrl, fileName); + this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({ + readAsync: function (byteOffset, byteLength) { return readViewAsync(data, byteOffset, byteLength); }, + byteLength: data.byteLength, + })).then(function (loaderData) { + onSuccess(loaderData); + }, onError ? function (error) { return onError(undefined, error); } : undefined); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fileName) { + var _this = this; + return Promise.resolve().then(function () { + _this.onParsedObservable.notifyObservers(data); + _this.onParsedObservable.clear(); + _this._log("Loading ".concat(fileName || "")); + _this._loader = _this._getLoader(data); + return _this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) { + var _this = this; + return Promise.resolve().then(function () { + _this.onParsedObservable.notifyObservers(data); + _this.onParsedObservable.clear(); + _this._log("Loading ".concat(fileName || "")); + _this._loader = _this._getLoader(data); + return _this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress, fileName) { + var _this = this; + return Promise.resolve().then(function () { + _this.onParsedObservable.notifyObservers(data); + _this.onParsedObservable.clear(); + _this._log("Loading ".concat(fileName || "")); + _this._loader = _this._getLoader(data); + // Prepare the asset container. + var container = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.AssetContainer(scene); + // Get materials/textures when loading to add to container + var materials = []; + _this.onMaterialLoadedObservable.add(function (material) { + materials.push(material); + }); + var textures = []; + _this.onTextureLoadedObservable.add(function (texture) { + textures.push(texture); + }); + var cameras = []; + _this.onCameraLoadedObservable.add(function (camera) { + cameras.push(camera); + }); + var morphTargetManagers = []; + _this.onMeshLoadedObservable.add(function (mesh) { + if (mesh.morphTargetManager) { + morphTargetManagers.push(mesh.morphTargetManager); + } + }); + return _this._loader.importMeshAsync(null, scene, container, data, rootUrl, onProgress, fileName).then(function (result) { + Array.prototype.push.apply(container.geometries, result.geometries); + Array.prototype.push.apply(container.meshes, result.meshes); + Array.prototype.push.apply(container.particleSystems, result.particleSystems); + Array.prototype.push.apply(container.skeletons, result.skeletons); + Array.prototype.push.apply(container.animationGroups, result.animationGroups); + Array.prototype.push.apply(container.materials, materials); + Array.prototype.push.apply(container.textures, textures); + Array.prototype.push.apply(container.lights, result.lights); + Array.prototype.push.apply(container.transformNodes, result.transformNodes); + Array.prototype.push.apply(container.cameras, cameras); + Array.prototype.push.apply(container.morphTargetManagers, morphTargetManagers); + return container; + }); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.canDirectLoad = function (data) { + return ((data.indexOf("asset") !== -1 && data.indexOf("version") !== -1) || + data.startsWith("data:base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat. + data.startsWith("data:;base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("data:application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("data:model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded)); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.directLoad = function (scene, data) { + if (data.startsWith("base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat. + data.startsWith(";base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded)) { + var arrayBuffer_1 = (0,babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DecodeBase64UrlToBinary)(data); + this._validate(scene, new Uint8Array(arrayBuffer_1, 0, arrayBuffer_1.byteLength)); + return this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({ + readAsync: function (byteOffset, byteLength) { return readAsync(arrayBuffer_1, byteOffset, byteLength); }, + byteLength: arrayBuffer_1.byteLength, + })); + } + this._validate(scene, data); + return Promise.resolve({ json: this._parseJson(data) }); + }; + /** @internal */ + GLTFFileLoader.prototype.createPlugin = function () { + return new GLTFFileLoader(); + }; + Object.defineProperty(GLTFFileLoader.prototype, "loaderState", { + /** + * The loader state or null if the loader is not active. + */ + get: function () { + return this._state; + }, + enumerable: false, + configurable: true + }); + /** + * Returns a promise that resolves when the asset is completely loaded. + * @returns a promise that resolves when the asset is completely loaded. + */ + GLTFFileLoader.prototype.whenCompleteAsync = function () { + var _this = this; + return new Promise(function (resolve, reject) { + _this.onCompleteObservable.addOnce(function () { + resolve(); + }); + _this.onErrorObservable.addOnce(function (reason) { + reject(reason); + }); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype._setState = function (state) { + if (this._state === state) { + return; + } + this._state = state; + this.onLoaderStateChangedObservable.notifyObservers(this._state); + this._log(GLTFLoaderState[this._state]); + }; + /** + * @internal + */ + GLTFFileLoader.prototype._loadFile = function (scene, fileOrUrl, onSuccess, useArrayBuffer, onError, onOpened) { + var _this = this; + var request = scene._loadFile(fileOrUrl, onSuccess, function (event) { + _this._onProgress(event, request); + }, true, useArrayBuffer, onError, onOpened); + request.onCompleteObservable.add(function (request) { + _this._requests.splice(_this._requests.indexOf(request), 1); + }); + this._requests.push(request); + return request; + }; + GLTFFileLoader.prototype._onProgress = function (event, request) { + if (!this._progressCallback) { + return; + } + request._lengthComputable = event.lengthComputable; + request._loaded = event.loaded; + request._total = event.total; + var lengthComputable = true; + var loaded = 0; + var total = 0; + for (var _i = 0, _a = this._requests; _i < _a.length; _i++) { + var request_1 = _a[_i]; + if (request_1._lengthComputable === undefined || request_1._loaded === undefined || request_1._total === undefined) { + return; + } + lengthComputable = lengthComputable && request_1._lengthComputable; + loaded += request_1._loaded; + total += request_1._total; + } + this._progressCallback({ + lengthComputable: lengthComputable, + loaded: loaded, + total: lengthComputable ? total : 0, + }); + }; + GLTFFileLoader.prototype._validate = function (scene, data, rootUrl, fileName) { + var _this = this; + if (rootUrl === void 0) { rootUrl = ""; } + if (fileName === void 0) { fileName = ""; } + if (!this.validate) { + return; + } + this._startPerformanceCounter("Validate JSON"); + _glTFValidation__WEBPACK_IMPORTED_MODULE_1__.GLTFValidation.ValidateAsync(data, rootUrl, fileName, function (uri) { + return _this.preprocessUrlAsync(rootUrl + uri).then(function (url) { + return scene._loadFileAsync(url, undefined, true, true).then(function (data) { + return new Uint8Array(data, 0, data.byteLength); + }); + }); + }).then(function (result) { + _this._endPerformanceCounter("Validate JSON"); + _this.onValidatedObservable.notifyObservers(result); + _this.onValidatedObservable.clear(); + }, function (reason) { + _this._endPerformanceCounter("Validate JSON"); + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Failed to validate: ".concat(reason.message)); + _this.onValidatedObservable.clear(); + }); + }; + GLTFFileLoader.prototype._getLoader = function (loaderData) { + var asset = loaderData.json.asset || {}; + this._log("Asset version: ".concat(asset.version)); + asset.minVersion && this._log("Asset minimum version: ".concat(asset.minVersion)); + asset.generator && this._log("Asset generator: ".concat(asset.generator)); + var version = GLTFFileLoader._parseVersion(asset.version); + if (!version) { + throw new Error("Invalid version: " + asset.version); + } + if (asset.minVersion !== undefined) { + var minVersion = GLTFFileLoader._parseVersion(asset.minVersion); + if (!minVersion) { + throw new Error("Invalid minimum version: " + asset.minVersion); + } + if (GLTFFileLoader._compareVersion(minVersion, { major: 2, minor: 0 }) > 0) { + throw new Error("Incompatible minimum version: " + asset.minVersion); + } + } + var createLoaders = { + 1: GLTFFileLoader._CreateGLTF1Loader, + 2: GLTFFileLoader._CreateGLTF2Loader, + }; + var createLoader = createLoaders[version.major]; + if (!createLoader) { + throw new Error("Unsupported version: " + asset.version); + } + return createLoader(this); + }; + GLTFFileLoader.prototype._parseJson = function (json) { + this._startPerformanceCounter("Parse JSON"); + this._log("JSON length: ".concat(json.length)); + var parsed = JSON.parse(json); + this._endPerformanceCounter("Parse JSON"); + return parsed; + }; + GLTFFileLoader.prototype._unpackBinaryAsync = function (dataReader) { + var _this = this; + this._startPerformanceCounter("Unpack Binary"); + // Read magic + version + length + json length + json format + return dataReader.loadAsync(20).then(function () { + var Binary = { + Magic: 0x46546c67, + }; + var magic = dataReader.readUint32(); + if (magic !== Binary.Magic) { + throw new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.RuntimeError("Unexpected magic: " + magic, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.ErrorCodes.GLTFLoaderUnexpectedMagicError); + } + var version = dataReader.readUint32(); + if (_this.loggingEnabled) { + _this._log("Binary version: ".concat(version)); + } + var length = dataReader.readUint32(); + if (!_this.useRangeRequests && length !== dataReader.buffer.byteLength) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Length in header does not match actual data length: ".concat(length, " != ").concat(dataReader.buffer.byteLength)); + } + var unpacked; + switch (version) { + case 1: { + unpacked = _this._unpackBinaryV1Async(dataReader, length); + break; + } + case 2: { + unpacked = _this._unpackBinaryV2Async(dataReader, length); + break; + } + default: { + throw new Error("Unsupported version: " + version); + } + } + _this._endPerformanceCounter("Unpack Binary"); + return unpacked; + }); + }; + GLTFFileLoader.prototype._unpackBinaryV1Async = function (dataReader, length) { + var ContentFormat = { + JSON: 0, + }; + var contentLength = dataReader.readUint32(); + var contentFormat = dataReader.readUint32(); + if (contentFormat !== ContentFormat.JSON) { + throw new Error("Unexpected content format: ".concat(contentFormat)); + } + var bodyLength = length - dataReader.byteOffset; + var data = { json: this._parseJson(dataReader.readString(contentLength)), bin: null }; + if (bodyLength !== 0) { + var startByteOffset_1 = dataReader.byteOffset; + data.bin = { + readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_1 + byteOffset, byteLength); }, + byteLength: bodyLength, + }; + } + return Promise.resolve(data); + }; + GLTFFileLoader.prototype._unpackBinaryV2Async = function (dataReader, length) { + var _this = this; + var ChunkFormat = { + JSON: 0x4e4f534a, + BIN: 0x004e4942, + }; + // Read the JSON chunk header. + var chunkLength = dataReader.readUint32(); + var chunkFormat = dataReader.readUint32(); + if (chunkFormat !== ChunkFormat.JSON) { + throw new Error("First chunk format is not JSON"); + } + // Bail if there are no other chunks. + if (dataReader.byteOffset + chunkLength === length) { + return dataReader.loadAsync(chunkLength).then(function () { + return { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null }; + }); + } + // Read the JSON chunk and the length and type of the next chunk. + return dataReader.loadAsync(chunkLength + 8).then(function () { + var data = { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null }; + var readAsync = function () { + var chunkLength = dataReader.readUint32(); + var chunkFormat = dataReader.readUint32(); + switch (chunkFormat) { + case ChunkFormat.JSON: { + throw new Error("Unexpected JSON chunk"); + } + case ChunkFormat.BIN: { + var startByteOffset_2 = dataReader.byteOffset; + data.bin = { + readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_2 + byteOffset, byteLength); }, + byteLength: chunkLength, + }; + dataReader.skipBytes(chunkLength); + break; + } + default: { + // ignore unrecognized chunkFormat + dataReader.skipBytes(chunkLength); + break; + } + } + if (dataReader.byteOffset !== length) { + return dataReader.loadAsync(8).then(readAsync); + } + return Promise.resolve(data); + }; + return readAsync(); + }); + }; + GLTFFileLoader._parseVersion = function (version) { + if (version === "1.0" || version === "1.0.1") { + return { + major: 1, + minor: 0, + }; + } + var match = (version + "").match(/^(\d+)\.(\d+)/); + if (!match) { + return null; + } + return { + major: parseInt(match[1]), + minor: parseInt(match[2]), + }; + }; + GLTFFileLoader._compareVersion = function (a, b) { + if (a.major > b.major) { + return 1; + } + if (a.major < b.major) { + return -1; + } + if (a.minor > b.minor) { + return 1; + } + if (a.minor < b.minor) { + return -1; + } + return 0; + }; + /** + * @internal + */ + GLTFFileLoader.prototype._logOpen = function (message) { + this._log(message); + this._logIndentLevel++; + }; + /** @internal */ + GLTFFileLoader.prototype._logClose = function () { + --this._logIndentLevel; + }; + GLTFFileLoader.prototype._logEnabled = function (message) { + var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2); + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Log("".concat(spaces).concat(message)); + }; + GLTFFileLoader.prototype._logDisabled = function (message) { }; + GLTFFileLoader.prototype._startPerformanceCounterEnabled = function (counterName) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.StartPerformanceCounter(counterName); + }; + GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) { }; + GLTFFileLoader.prototype._endPerformanceCounterEnabled = function (counterName) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.EndPerformanceCounter(counterName); + }; + GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) { }; + // ---------- + // V1 options + // ---------- + /** + * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders. + * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled. + * Defaults to true. + * @internal + */ + GLTFFileLoader.IncrementalLoading = true; + /** + * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters. + * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates. + * @internal + */ + GLTFFileLoader.HomogeneousCoordinates = false; + GLTFFileLoader._MagicBase64Encoded = "Z2xURg"; // "glTF" base64 encoded (without the quotes!) + GLTFFileLoader._logSpaces = " "; + return GLTFFileLoader; +}()); +if (babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.SceneLoader) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.SceneLoader.RegisterPlugin(new GLTFFileLoader()); +} + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/glTFValidation.ts": +/*!*******************************************************!*\ + !*** ../../../dev/loaders/src/glTF/glTFValidation.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFValidation: () => (/* binding */ GLTFValidation) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__); + +function validateAsync(data, rootUrl, fileName, getExternalResource) { + var options = { + externalResourceFunction: getExternalResource, + }; + if (fileName) { + options.uri = rootUrl === "file:" ? fileName : rootUrl + fileName; + } + return ArrayBuffer.isView(data) ? GLTFValidator.validateBytes(data, options) : GLTFValidator.validateString(data, options); +} +/** + * The worker function that gets converted to a blob url to pass into a worker. + */ +function workerFunc() { + var pendingExternalResources = []; + onmessage = function (message) { + var data = message.data; + switch (data.id) { + case "init": { + importScripts(data.url); + break; + } + case "validate": { + validateAsync(data.data, data.rootUrl, data.fileName, function (uri) { + return new Promise(function (resolve, reject) { + var index = pendingExternalResources.length; + pendingExternalResources.push({ resolve: resolve, reject: reject }); + postMessage({ id: "getExternalResource", index: index, uri: uri }); + }); + }).then(function (value) { + postMessage({ id: "validate.resolve", value: value }); + }, function (reason) { + postMessage({ id: "validate.reject", reason: reason }); + }); + break; + } + case "getExternalResource.resolve": { + pendingExternalResources[data.index].resolve(data.value); + break; + } + case "getExternalResource.reject": { + pendingExternalResources[data.index].reject(data.reason); + break; + } + } + }; +} +/** + * glTF validation + */ +var GLTFValidation = /** @class */ (function () { + function GLTFValidation() { + } + /** + * Validate a glTF asset using the glTF-Validator. + * @param data The JSON of a glTF or the array buffer of a binary glTF + * @param rootUrl The root url for the glTF + * @param fileName The file name for the glTF + * @param getExternalResource The callback to get external resources for the glTF validator + * @returns A promise that resolves with the glTF validation results once complete + */ + GLTFValidation.ValidateAsync = function (data, rootUrl, fileName, getExternalResource) { + var _this = this; + if (typeof Worker === "function") { + return new Promise(function (resolve, reject) { + var workerContent = "".concat(validateAsync, "(").concat(workerFunc, ")()"); + var workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: "application/javascript" })); + var worker = new Worker(workerBlobUrl); + var onError = function (error) { + worker.removeEventListener("error", onError); + worker.removeEventListener("message", onMessage); + reject(error); + }; + var onMessage = function (message) { + var data = message.data; + switch (data.id) { + case "getExternalResource": { + getExternalResource(data.uri).then(function (value) { + worker.postMessage({ id: "getExternalResource.resolve", index: data.index, value: value }, [value]); + }, function (reason) { + worker.postMessage({ id: "getExternalResource.reject", index: data.index, reason: reason }); + }); + break; + } + case "validate.resolve": { + worker.removeEventListener("error", onError); + worker.removeEventListener("message", onMessage); + resolve(data.value); + worker.terminate(); + break; + } + case "validate.reject": { + worker.removeEventListener("error", onError); + worker.removeEventListener("message", onMessage); + reject(data.reason); + worker.terminate(); + } + } + }; + worker.addEventListener("error", onError); + worker.addEventListener("message", onMessage); + worker.postMessage({ id: "init", url: babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.GetBabylonScriptURL(_this.Configuration.url) }); + if (ArrayBuffer.isView(data)) { + // Slice the data to avoid copying the whole array buffer. + var slicedData = data.slice(); + worker.postMessage({ id: "validate", data: slicedData, rootUrl: rootUrl, fileName: fileName }, [slicedData.buffer]); + } + else { + worker.postMessage({ id: "validate", data: data, rootUrl: rootUrl, fileName: fileName }); + } + }); + } + else { + if (!this._LoadScriptPromise) { + this._LoadScriptPromise = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.LoadBabylonScriptAsync(this.Configuration.url); + } + return this._LoadScriptPromise.then(function () { + return validateAsync(data, rootUrl, fileName, getExternalResource); + }); + } + }; + /** + * The configuration. Defaults to `{ url: "https://cdn.babylonjs.com/gltf_validator.js" }`. + */ + GLTFValidation.Configuration = { + url: "".concat(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools._DefaultCdnUrl, "/gltf_validator.js"), + }; + return GLTFValidation; +}()); + + +/***/ }), + +/***/ "../../../lts/loaders/src/legacy/legacy-glTF.ts": +/*!******************************************************!*\ + !*** ../../../lts/loaders/src/legacy/legacy-glTF.ts ***! + \******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFFileLoader: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFFileLoader), +/* harmony export */ GLTFLoaderAnimationStartMode: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderAnimationStartMode), +/* harmony export */ GLTFLoaderCoordinateSystemMode: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderCoordinateSystemMode), +/* harmony export */ GLTFLoaderState: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderState), +/* harmony export */ GLTFValidation: () => (/* reexport safe */ loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__.GLTFValidation) +/* harmony export */ }); +/* harmony import */ var loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/glTF/glTFFileLoader */ "../../../dev/loaders/src/glTF/glTFFileLoader.ts"); +/* harmony import */ var loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! loaders/glTF/glTFValidation */ "../../../dev/loaders/src/glTF/glTFValidation.ts"); + + +/** + * This is the entry point for the UMD module. + * The entry point for a future ESM package should be index.ts + */ +var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined; +if (typeof globalObject !== "undefined") { + globalObject.BABYLON = globalObject.BABYLON || {}; + for (var key in loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__) { + globalObject.BABYLON[key] = loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__[key]; + } + for (var key in loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__) { + globalObject.BABYLON[key] = loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__[key]; + } +} + + + + +/***/ }), + +/***/ "../../../lts/loaders/src/legacy/legacy-glTF2.ts": +/*!*******************************************************!*\ + !*** ../../../lts/loaders/src/legacy/legacy-glTF2.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTF2: () => (/* reexport module object */ loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__) +/* harmony export */ }); +/* harmony import */ var loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/glTF/2.0/Extensions/index */ "../../../dev/loaders/src/glTF/2.0/Extensions/index.ts"); +/* harmony import */ var loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! loaders/glTF/2.0/glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts"); +/* harmony import */ var loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! loaders/glTF/2.0/index */ "../../../dev/loaders/src/glTF/2.0/index.ts"); +/* eslint-disable import/no-internal-modules */ + + + +/** + * This is the entry point for the UMD module. + * The entry point for a future ESM package should be index.ts + */ +var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined; +if (typeof globalObject !== "undefined") { + globalObject.BABYLON = globalObject.BABYLON || {}; + var BABYLON_1 = globalObject.BABYLON; + BABYLON_1.GLTF2 = BABYLON_1.GLTF2 || {}; + BABYLON_1.GLTF2.Loader = BABYLON_1.GLTF2.Loader || {}; + BABYLON_1.GLTF2.Loader.Extensions = BABYLON_1.GLTF2.Loader.Extensions || {}; + var keys = []; + for (var key in loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__) { + BABYLON_1.GLTF2.Loader.Extensions[key] = loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__[key]; + keys.push(key); + } + for (var key in loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__) { + BABYLON_1.GLTF2.Loader[key] = loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__[key]; + keys.push(key); + } + for (var key in loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__) { + // Prevent Reassignment. + if (keys.indexOf(key) > -1) { + continue; + } + BABYLON_1.GLTF2[key] = loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__[key]; + } +} + + + +/***/ }), + +/***/ "../../../lts/loaders/src/legacy/legacy-glTF2FileLoader.ts": +/*!*****************************************************************!*\ + !*** ../../../lts/loaders/src/legacy/legacy-glTF2FileLoader.ts ***! + \*****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTF2: () => (/* reexport safe */ _legacy_glTF2__WEBPACK_IMPORTED_MODULE_1__.GLTF2), +/* harmony export */ GLTFFileLoader: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFFileLoader), +/* harmony export */ GLTFLoaderAnimationStartMode: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderAnimationStartMode), +/* harmony export */ GLTFLoaderCoordinateSystemMode: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderCoordinateSystemMode), +/* harmony export */ GLTFLoaderState: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderState), +/* harmony export */ GLTFValidation: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFValidation) +/* harmony export */ }); +/* harmony import */ var _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./legacy-glTF */ "../../../lts/loaders/src/legacy/legacy-glTF.ts"); +/* harmony import */ var _legacy_glTF2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./legacy-glTF2 */ "../../../lts/loaders/src/legacy/legacy-glTF2.ts"); +// eslint-disable-next-line import/export + + + + +/***/ }), + +/***/ "babylonjs/Misc/observable": +/*!****************************************************************************************************!*\ + !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***! + \****************************************************************************************************/ +/***/ ((module) => { + +module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__; + +/***/ }), + +/***/ "../../../../node_modules/tslib/tslib.es6.mjs": +/*!****************************************************!*\ + !*** ../../../../node_modules/tslib/tslib.es6.mjs ***! + \****************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ __addDisposableResource: () => (/* binding */ __addDisposableResource), +/* harmony export */ __assign: () => (/* binding */ __assign), +/* harmony export */ __asyncDelegator: () => (/* binding */ __asyncDelegator), +/* harmony export */ __asyncGenerator: () => (/* binding */ __asyncGenerator), +/* harmony export */ __asyncValues: () => (/* binding */ __asyncValues), +/* harmony export */ __await: () => (/* binding */ __await), +/* harmony export */ __awaiter: () => (/* binding */ __awaiter), +/* harmony export */ __classPrivateFieldGet: () => (/* binding */ __classPrivateFieldGet), +/* harmony export */ __classPrivateFieldIn: () => (/* binding */ __classPrivateFieldIn), +/* harmony export */ __classPrivateFieldSet: () => (/* binding */ __classPrivateFieldSet), +/* harmony export */ __createBinding: () => (/* binding */ __createBinding), +/* harmony export */ __decorate: () => (/* binding */ __decorate), +/* harmony export */ __disposeResources: () => (/* binding */ __disposeResources), +/* harmony export */ __esDecorate: () => (/* binding */ __esDecorate), +/* harmony export */ __exportStar: () => (/* binding */ __exportStar), +/* harmony export */ __extends: () => (/* binding */ __extends), +/* harmony export */ __generator: () => (/* binding */ __generator), +/* harmony export */ __importDefault: () => (/* binding */ __importDefault), +/* harmony export */ __importStar: () => (/* binding */ __importStar), +/* harmony export */ __makeTemplateObject: () => (/* binding */ __makeTemplateObject), +/* harmony export */ __metadata: () => (/* binding */ __metadata), +/* harmony export */ __param: () => (/* binding */ __param), +/* harmony export */ __propKey: () => (/* binding */ __propKey), +/* harmony export */ __read: () => (/* binding */ __read), +/* harmony export */ __rest: () => (/* binding */ __rest), +/* harmony export */ __runInitializers: () => (/* binding */ __runInitializers), +/* harmony export */ __setFunctionName: () => (/* binding */ __setFunctionName), +/* harmony export */ __spread: () => (/* binding */ __spread), +/* harmony export */ __spreadArray: () => (/* binding */ __spreadArray), +/* harmony export */ __spreadArrays: () => (/* binding */ __spreadArrays), +/* harmony export */ __values: () => (/* binding */ __values), +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise, SuppressedError, Symbol */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + } + return __assign.apply(this, arguments); +} + +function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +} + +function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { + function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } + var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; + var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; + var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); + var _, done = false; + for (var i = decorators.length - 1; i >= 0; i--) { + var context = {}; + for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; + for (var p in contextIn.access) context.access[p] = contextIn.access[p]; + context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; + var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); + if (kind === "accessor") { + if (result === void 0) continue; + if (result === null || typeof result !== "object") throw new TypeError("Object expected"); + if (_ = accept(result.get)) descriptor.get = _; + if (_ = accept(result.set)) descriptor.set = _; + if (_ = accept(result.init)) initializers.unshift(_); + } + else if (_ = accept(result)) { + if (kind === "field") initializers.unshift(_); + else descriptor[key] = _; + } + } + if (target) Object.defineProperty(target, contextIn.name, descriptor); + done = true; +}; + +function __runInitializers(thisArg, initializers, value) { + var useValue = arguments.length > 2; + for (var i = 0; i < initializers.length; i++) { + value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); + } + return useValue ? value : void 0; +}; + +function __propKey(x) { + return typeof x === "symbol" ? x : "".concat(x); +}; + +function __setFunctionName(f, name, prefix) { + if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; + return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); +}; + +function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +var __createBinding = Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +}); + +function __exportStar(m, o) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); +} + +function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +/** @deprecated */ +function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +/** @deprecated */ +function __spreadArrays() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } +} + +function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; + +var __setModuleDefault = Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}; + +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +} + +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { default: mod }; +} + +function __classPrivateFieldGet(receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +} + +function __classPrivateFieldSet(receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +} + +function __classPrivateFieldIn(state, receiver) { + if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); + return typeof state === "function" ? receiver === state : state.has(receiver); +} + +function __addDisposableResource(env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +} + +var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}; + +function __disposeResources(env) { + function fail(e) { + env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ + __extends, + __assign, + __rest, + __decorate, + __param, + __metadata, + __awaiter, + __generator, + __createBinding, + __exportStar, + __values, + __read, + __spread, + __spreadArrays, + __spreadArray, + __await, + __asyncGenerator, + __asyncDelegator, + __asyncValues, + __makeTemplateObject, + __importStar, + __importDefault, + __classPrivateFieldGet, + __classPrivateFieldSet, + __classPrivateFieldIn, + __addDisposableResource, + __disposeResources, +}); + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ (() => { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = (module) => { +/******/ var getter = module && module.__esModule ? +/******/ () => (module['default']) : +/******/ () => (module); +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/global */ +/******/ (() => { +/******/ __webpack_require__.g = (function() { +/******/ if (typeof globalThis === 'object') return globalThis; +/******/ try { +/******/ return this || new Function('return this')(); +/******/ } catch (e) { +/******/ if (typeof window === 'object') return window; +/******/ } +/******/ })(); +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +(() => { +/*!********************************!*\ + !*** ./src/glTF2FileLoader.ts ***! + \********************************/ +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__), +/* harmony export */ loaders: () => (/* reexport module object */ _lts_loaders_legacy_legacy_glTF2FileLoader__WEBPACK_IMPORTED_MODULE_0__) +/* harmony export */ }); +/* harmony import */ var _lts_loaders_legacy_legacy_glTF2FileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @lts/loaders/legacy/legacy-glTF2FileLoader */ "../../../lts/loaders/src/legacy/legacy-glTF2FileLoader.ts"); + + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_lts_loaders_legacy_legacy_glTF2FileLoader__WEBPACK_IMPORTED_MODULE_0__); + +})(); + +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFieWxvbi5nbFRGMkZpbGVMb2FkZX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kudGhlbigodGV4dHVyZSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlci5iYWJ5bG9uU2NlbmUuZW52aXJvbm1lbnRUZXh0dXJlID0gdGV4dHVyZTtcclxuICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICk7XHJcblxyXG4gICAgICAgICAgICB0aGlzLl9sb2FkZXIubG9nQ2xvc2UoKTtcclxuXHJcbiAgICAgICAgICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbigoKSA9PiB7fSk7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfbG9hZExpZ2h0QXN5bmMoY29udGV4dDogc3RyaW5nLCBsaWdodDogSUVYVExpZ2h0c0ltYWdlQmFzZWRfTGlnaHRJbWFnZUJhc2VkKTogUHJvbWlzZTxCYXNlVGV4dHVyZT4ge1xyXG4gICAgICAgIGlmICghbGlnaHQuX2xvYWRlZCkge1xyXG4gICAgICAgICAgICBjb25zdCBwcm9taXNlcyA9IG5ldyBBcnJheTxQcm9taXNlPGFueT4+KCk7XHJcblxyXG4gICAgICAgICAgICB0aGlzLl9sb2FkZXIubG9nT3BlbihgJHtjb250ZXh0fWApO1xyXG5cclxuICAgICAgICAgICAgY29uc3QgaW1hZ2VEYXRhID0gbmV3IEFycmF5PEFycmF5PEFycmF5QnVmZmVyVmlldz4+KGxpZ2h0LnNwZWN1bGFySW1hZ2VzLmxlbmd0aCk7XHJcbiAgICAgICAgICAgIGZvciAobGV0IG1pcG1hcCA9IDA7IG1pcG1hcCA8IGxpZ2h0LnNwZWN1bGFySW1hZ2VzLmxlbmd0aDsgbWlwbWFwKyspIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGZhY2VzID0gbGlnaHQuc3BlY3VsYXJJbWFnZXNbbWlwbWFwXTtcclxuICAgICAgICAgICAgICAgIGltYWdlRGF0YVttaXBtYXBdID0gbmV3IEFycmF5PEFycmF5QnVmZmVyVmlldz4oZmFjZXMubGVuZ3RoKTtcclxuICAgICAgICAgICAgICAgIGZvciAobGV0IGZhY2UgPSAwOyBmYWNlIDwgZmFjZXMubGVuZ3RoOyBmYWNlKyspIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGVjdWxhckltYWdlQ29udGV4dCA9IGAke2NvbnRleHR9L3NwZWN1bGFySW1hZ2VzLyR7bWlwbWFwfS8ke2ZhY2V9YDtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZXIubG9nT3BlbihgJHtzcGVjdWxhckltYWdlQ29udGV4dH1gKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaW5kZXggPSBmYWNlc1tmYWNlXTtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBpbWFnZSA9IEFycmF5SXRlbS5HZXQoc3BlY3VsYXJJbWFnZUNvbnRleHQsIHRoaXMuX2xvYWRlci5nbHRmLmltYWdlcywgaW5kZXgpO1xyXG4gICAgICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2goXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlci5sb2FkSW1hZ2VBc3luYyhgL2ltYWdlcy8ke2luZGV4fWAsIGltYWdlKS50aGVuKChkYXRhKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWFnZURhdGFbbWlwbWFwXVtmYWNlXSA9IGRhdGE7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICAgICAgICAgKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVyLmxvZ0Nsb3NlKCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHRoaXMuX2xvYWRlci5sb2dDbG9zZSgpO1xyXG5cclxuICAgICAgICAgICAgbGlnaHQuX2xvYWRlZCA9IFByb21pc2UuYWxsKHByb21pc2VzKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGJhYnlsb25UZXh0dXJlID0gbmV3IFJhd0N1YmVUZXh0dXJlKHRoaXMuX2xvYWRlci5iYWJ5bG9uU2NlbmUsIG51bGwsIGxpZ2h0LnNwZWN1bGFySW1hZ2VTaXplKTtcclxuICAgICAgICAgICAgICAgIGJhYnlsb25UZXh0dXJlLm5hbWUgPSBsaWdodC5uYW1lIHx8IFwiZW52aXJvbm1lbnRcIjtcclxuICAgICAgICAgICAgICAgIGxpZ2h0Ll9iYWJ5bG9uVGV4dHVyZSA9IGJhYnlsb25UZXh0dXJlO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmIChsaWdodC5pbnRlbnNpdHkgIT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvblRleHR1cmUubGV2ZWwgPSBsaWdodC5pbnRlbnNpdHk7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKGxpZ2h0LnJvdGF0aW9uKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJvdGF0aW9uID0gUXVhdGVybmlvbi5Gcm9tQXJyYXkobGlnaHQucm90YXRpb24pO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAvLyBJbnZlcnQgdGhlIHJvdGF0aW9uIHNvIHRoYXQgcG9zaXRpdmUgcm90YXRpb24gaXMgY291bnRlci1jbG9ja3dpc2UuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9sb2FkZXIuYmFieWxvblNjZW5lLnVzZVJpZ2h0SGFuZGVkU3lzdGVtKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uID0gUXVhdGVybmlvbi5JbnZlcnNlKHJvdGF0aW9uKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIE1hdHJpeC5Gcm9tUXVhd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YWNjZXNzb3IuY291bnQ7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGluc3RhbmNlQ291bnQgIT09IGFjY2Vzc29yLmNvdW50KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGAke2V4dGVuc2lvbkNvbnRleHR9L2F0dHJpYnV0ZXM6IEluc3RhbmNlIGJ1ZmZlciBhY2Nlc3NvcnMgZG8gbm90IGhhdmUgdGhlIHNhbWUgY291bnQuYCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH07XHJcblxyXG4gICAgICAgICAgICBsb2FkQXR0cmlidXRlKFwiVFJBTlNMQVRJT05cIik7XHJcbiAgICAgICAgICAgIGxvYWRBdHRyaWJ1dGUoXCJST1RBVElPTlwiKTtcclxuICAgICAgICAgICAgbG9hZEF0dHJpYnV0ZShcIlNDQUxFXCIpO1xyXG5cclxuICAgICAgICAgICAgcmV0dXJuIHByb21pc2UudGhlbigoYmFieWxvblRyYW5zZm9ybU5vZGUpID0+IHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbigoW3RyYW5zbGF0aW9uQnVmZmVyLCByb3RhdGlvbkJ1ZmZlciwgc2NhbGVCdWZmZXJdKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0cmljZXMgPSBuZXcgRmxvYXQzMkFycmF5KGluc3RhbmNlQ291bnQgKiAxNik7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIFRtcFZlY3RvcnMuVmVjdG9yM1swXS5jb3B5RnJvbUZsb2F0cygwLCAwLCAwKTsgLy8gdHJhbnNsYXRpb25cclxuICAgICAgICAgICAgICAgICAgICBUbXBWZWN0b3JzLlF1YXRlcm5pb25bMF0uY29weUZyb21GbG9hdHMoMCwgMCwgMCwgMSk7IC8vIHJvdGF0aW9uXHJcbiAgICAgICAgICAgICAgICAgICAgVG1wVmVjdG9ycy5WZWN0b3IzWzFdLmNvcHlGcm9tRmxvYXRzKDEsIDEsIDEpOyAvLyBzY2FsZVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGluc3RhbmNlQ291bnQ7ICsraSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2xhdGlvbkJ1ZmZlciAmJiBWZWN0b3IzLkZyb21BcnJheVRvUmVmKHRyYW5zbGF0aW9uQnVmZmVyLCBpICogMywgVG1wVmVjdG9ycy5WZWN0b3IzWzBdKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb25CdWZmZXIgJiYgUXVhdGVybmlvbi5Gcm9tQXJyYXlUb1JlZihyb3RhdGlvbkJ1ZmZlciwgaSAqIDQsIFRtcFZlY3RvcnMuUXVhdGVybmlvblswXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlQnVmZmVyICYmIFZlY3RvcjMuRnJvbUFycmF5VG9SZWYoc2NhbGVCdWZmZXIsIGkgKiAzLCBUbXBWZWN0b3JzLlZlY3RvcjNbMV0pO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgTWF0cml4LkNvbXBvc2VUb1JlZihUbXBWZWN0b3JzLlZlY3RvcjNbMV0sIFRtcFZlY3RvcnMuUXVhdGVybmlvblswXSwgVG1wVmVjdG9ycy5WZWN0b3IzWzBdLCBUbXBWZWN0b3JzLk1hdHJpeFswXSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBUbXBWZWN0b3JzLk1hdHJpeFswXS5jb3B5VG9BcnJheShtYXRyaWNlcywgaSAqIDE2KTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYmFieWxvbk1lc2ggb2Ygbm9kZS5fcHJpbWl0aXZlQmFieWxvbk1lc2hlcyEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgKGJhYnlsb25NZXNoIGFz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ZyxcclxuICAgICAgICBmcHM6IG51bWJlcixcclxuICAgICAgICBrZXlzOiBhbnlbXSxcclxuICAgICAgICBjYWxsYmFjazogKGJhYnlsb25BbmltYXRhYmxlOiBJQW5pbWF0YWJsZSwgYmFieWxvbkFuaW1hdGlvbjogQW5pbWF0aW9uKSA9PiB2b2lkXHJcbiAgICApOiB2b2lkIHtcclxuICAgICAgICBjYWxsYmFjayh0YXJnZXQuX2JhYnlsb25MaWdodCEsIHRoaXMuX2J1aWxkQW5pbWF0aW9uKG5hbWUsIGZwcywga2V5cykpO1xyXG4gICAgfVxyXG59XHJcblxyXG5jb25zdCBub2Rlc1RyZWUgPSB7XHJcbiAgICBfX2FycmF5X186IHtcclxuICAgICAgICBfX3RhcmdldF9fOiB0cnVlLFxyXG4gICAgICAgIC4uLm5vZGVBbmltYXRpb25EYXRhLFxyXG4gICAgfSxcclxufTtcclxuXHJcbmNvbnN0IGNhbWVyYXNUcmVlID0ge1xyXG4gICAgX19hcnJheV9fOiB7XHJcbiAgICAgICAgX190YXJnZXRfXzogdHJ1ZSxcclxuICAgICAgICBvcnRob2dyYXBoaWM6IHtcclxuICAgICAgICAgICAgeG1hZzogW1xyXG4gICAgICAgICAgICAgICAgbmV3IENhbWVyYUFuaW1hdGlvblByb3BlcnR5SW5mbyhBbmltYXRpb24uQU5JTUFUSU9OVFlQRV9GTE9BVCwgXCJvcnRob0xlZnRcIiwgZ2V0TWludXNGbG9hdCwgKCkgPT4gMSksXHJcbiAgICAgICAgICAgICAgICBuZXcgQ2FtZXJhQW5pbWF0aW9uUHJvcGVydHlJbmZvKEFuaW1hdGlvbi5BTklNQVRJT05UWVBFX0ZMT0FULCBcIm9ydGhvUmlnaHRcIiwgZ2V0TmV4dEZsb2F0LCAoKSA9PiAxKSxcclxuICAgICAgICAgICAgXSxcclxuICAgICAgICAgICAgeW1hZzogW1xyXG4gICAgICAgICAgICAgICAgbmV3IENhbWVyYUFuaW1hdGlvblByb3BlcnR5SW5mbyhBbmltYX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gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgYmFieWxvbk1lc2guX2RlbGF5SW5mbyA9IGJhYnlsb25NZXNoLl9kZWxheUluZm8gfHwgW107XHJcbiAgICAgICAgICAgICAgICBpZiAoYmFieWxvbk1lc2guX2RlbGF5SW5mby5pbmRleE9mKGtpbmQpID09PSAtMSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGJhYnlsb25NZXNoLl9kZWxheUluZm8ucHVzaChraW5kKTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBhdHRyaWJ1dGVzW2tpbmRdID0gdW5pcXVlSWQ7XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMudXNlTm9ybWFsaXplZEZsYWdGcm9tQWNjZXNzb3IpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBhY2Nlc3NvciA9IEFycmF5SXRlbS5UcnlHZXQodGhpcy5fbG9hZGVyLmdsdGYuYWNjZXNzb3JzLCBwcmltaXRpdmUuYXR0cmlidXRlc1tuYW1lXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGFjY2Vzc29yKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vcm1hbGl6ZWRba2luZF0gPSBhY2Nlc3Nvci5ub3JtYWxpemVkIHx8IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgIGxvYWRBdHRyaWJ1dGUoXCJQT1NJVElPTlwiLCBWZXJ0ZXhCdWZmZXIuUG9zaXRpb25LaW5kKTtcclxuICAgICAgICAgICAgbG9hZEF0dHJpYnV0ZShcIk5PUk1BTFwiLCBWZXJ0ZXhCdWZmZXIuTm9ybWFsS2luZCk7XHJcbiAgICAgICAgICAgIGxvYWRBdHRyaWJ1dGUoXCJUQU5HRU5UXCIsIFZlcnRleEJ1ZmZlci5UYW5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XcuX2RyYWNvQmFieWxvbkdlb21ldHJ5KSB7XHJcbiAgICAgICAgICAgICAgICBidWZmZXJWaWV3Ll9kcmFjb0JhYnlsb25HZW9tZXRyeSA9IHRoaXMuX2xvYWRlci5sb2FkQnVmZmVyVmlld0FzeW5jKGAvYnVmZmVyVmlld3MvJHtidWZmZXJWaWV3LmluZGV4fWAsIGJ1ZmZlclZpZXcpLnRoZW4oKGRhdGEpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBkcmFjb0NvbXByZXNzaW9uID0gdGhpcy5kcmFjb0NvbXByZXNzaW9uIHx8IERyYWNvQ29tcHJlc3Npb24uRGVmYXVsdDtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZHJhY29Db21wcmVzc2lvbi5fZGVjb2RlTWVzaFRvR2VvbWV0cnlGb3JHbHRmQXN5bmMoYmFieWxvbk1lc2gubmFtZSwgdGhpcy5fbG9hZGVyLmJhYnlsb25TY2VuZSwgZGF0YSwgYXR0cmlidXRlcywgbm9ybWFsaXplZCkuY2F0Y2goKGVycm9yKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgJHtjb250ZXh0fTogJHtlcnJvci5tZXNzYWdlfWApO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHJldHVybiBidWZmZXJWaWV3Ll9kcmFjb0JhYnlsb25HZW9tZXRyeTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxufVxyXG5cclxuR0xURkxvYWRlci5SZWdpc3RlckV4dGVuc2lvbihOQU1FLCAobG9hZGVyKSA9PiBuZXcgS0hSX2RyYWNvX21lc2hfY29tcHJlc3Npb24obG9hZGVyKSk7XHJcbiIsIi8qIGVzbGludC1kaXNhYmxlIEB0eXBlc2NyaXB0LWVzbGludC9uYW1pbmctY29udmVudGlvbiAqL1xyXG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BleHRlbnNpb24ubGlnaHQpO1xyXG4gICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IGxpZ2h0Lm5hbWUgfHwgYmFieWxvbk1lc2gubmFtZTtcclxuXHJcbiAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZXIuYmFieWxvblNjZW5lLl9ibG9ja0VudGl0eUNvbGxlY3Rpb24gPSAhIXRoaXMuX2xvYWRlci5fYXNzZXRDb250YWluZXI7XHJcblxyXG4gICAgICAgICAgICAgICAgc3dpdGNoIChsaWdodC50eXBlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSBLSFJMaWdodHNQdW5jdHVhbF9MaWdodFR5cGUuRElSRUNUSU9OQUw6IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmFieWxvbkRpcmVjdGlvbmFsTGlnaHQgPSBuZXcgRGlyZWN0aW9uYWxMaWdodChuYW1lLCBWZWN0b3IzLkJhY2t3YXJkKCksIHRoaXMuX2xvYWRlci5iYWJ5bG9uU2NlbmUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uRGlyZWN0aW9uYWxMaWdodC5wb3NpdGlvbi5zZXRBbGwoMCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25MaWdodCA9IGJhYnlsb25EaXJlY3Rpb25hbExpZ2h0O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSBLSFJMaWdodHNQdW5jdHVhbF9MaWdodFR5cGUuUE9JTlQ6IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvbkxpZ2h0ID0gbmV3IFBvaW50TGlnaHQobmFtZSwgVmVjdG9yMy5aZXJvKCksIHRoaXMuX2xvYWRlci5iYWJ5bG9uU2NlbmUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSBLSFJMaWdodHNQdW5jdHVhbF9MaWdodFR5cGUuU1BPVDoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiYWJ5bG9uU3BvdExpZ2h0ID0gbmV3IFNwb3RMaWdodChuYW1lLCBWZWN0b3IzLlplcm8oKSwgVmVjdG9yMy5CYWNrd2FyZCgpLCAwLCAxLCB0aGlzLl9sb2FkZXIuYmFieWxvblNjZW5lKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvblNwb3RMaWdodC5hbmdsZSA9ICgobGlnaHQuc3BvdCAmJiBsaWdodC5zcG90Lm91dGVyQ29uZUFuZ2xlKSB8fCBNYXRoLlBJIC8gNCkgKiAyO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uU3BvdExpZ2h0LmlubmVyQW5nbGUgPSAoKGxpZ2h0LnNwb3QgJiYgbGlnaHQuc3BvdC5pbm5lckNvbmVBbmdsZSkgfHwgMCkgKiAyO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uTGlnaHQgPSBiYWJ5bG9uU3BvdExpZ2h0O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZXIuYmFieWxvblNjZW5lLl9ibG9ja0VudGl0eUNvbGxlY3Rpb24gPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGAke2V4dGVuc2lvbkNvbnRleHR9OiBJbnZhbGlkIGxpZ2h0IHR5cGUgKCR7bGlnaHQudHlwZX0pYCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGJhYnlsb25M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0aWVzLmNsZWFyY29hdFJvdWdobmVzc1RleHR1cmUsICh0ZXh0dXJlKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGV4dHVyZS5uYW1lID0gYCR7YmFieWxvbk1hdGVyaWFsLm5hbWV9IChDbGVhckNvYXQgUm91Z2huZXNzKWA7XHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvbk1hdGVyaWFsLmNsZWFyQ29hdC50ZXh0dXJlUm91Z2huZXNzID0gdGV4dHVyZTtcclxuICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAocHJvcGVydGllcy5jbGVhcmNvYXROb3JtYWxUZXh0dXJlKSB7XHJcbiAgICAgICAgICAgIChwcm9wZXJ0aWVzLmNsZWFyY29hdE5vcm1hbFRleHR1cmUgYXMgSVRleHR1cmVJbmZvKS5ub25Db2xvckRhdGEgPSB0cnVlO1xyXG4gICAgICAgICAgICBwcm9taXNlcy5wdXNoKFxyXG4gICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVyLmxvYWRUZXh0dXJlSW5mb0FzeW5jKGAke2NvbnRleHR9L2NsZWFyY29hdE5vcm1hbFRleHR1cmVgLCBwcm9wZXJ0aWVzLmNsZWFyY29hdE5vcm1hbFRleHR1cmUsICh0ZXh0dXJlKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGV4dHVyZS5uYW1lID0gYCR7YmFieWxvbk1hdGVyaWFsLm5hbWV9IChDbGVhckNvYXQgTm9ybWFsKWA7XHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvbk1hdGVyaWFsLmNsZWFyQ29hdC5idW1wVGV4dHVyZSA9IHRleHR1cmU7XHJcbiAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICApO1xyXG5cclxuICAgICAgICAgICAgYmFieWxvbk1hdGVyaWFsLmludmVydE5vcm1hbE1hcFggPSAhYmFieWxvbk1hdGVyaWFsLmdldF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SBzdGF0aWMgcmVhZG9ubHkgX0RFRkFVTFRfSU9SID0gMS41O1xyXG5cclxuICAgIC8qKlxyXG4gICAgICogVGhlIG5hbWUgb2YgdGhpcyBleHRlbnNpb24uXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyByZWFkb25seSBuYW1lID0gTkFNRTtcclxuXHJcbiAgICAvKipcclxuICAgICAqIERlZmluZXMgd2hldGhlciB0aGlzIGV4dGVuc2lvbiBpcyBlbmFibGVkLlxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgZW5hYmxlZDogYm9vbGVhbjtcclxuXHJcbiAgICAvKipcclxuICAgICAqIERlZmluZXMgYSBudW1iZXIgdGhhdCBkZXRlcm1pbmVzIHRoZSBvcmRlciB0aGUgZXh0ZW5zaW9ucyBhcmUgYXBwbGllZC5cclxuICAgICAqL1xyXG4gICAgcHVibGljIG9yZGVyID0gMTgwO1xyXG5cclxuICAgIHByaXZhdGUgX2xvYWRlcjogR0xURkxvYWRlcjtcclxuXHJcbiAgICAvKipcclxuICAgICAqIEBpbnRlcm5hbFxyXG4gICAgICovXHJcbiAgICBjb25zdHJ1Y3Rvcihsb2FkZXI6IEdMVEZMb2FkZXIpIHtcclxuICAgICAgICB0aGlzLl9sb2FkZXIgPSBsb2FkZXI7XHJcbiAgICAgICAgdGhpcy5lbmFibGVkID0gdGhpcy5fbG9hZGVyLmlzRXh0ZW5zaW9uVXNlZChOQU1FKTtcclxuICAgIH1cclxuXHJcbiAgICAvKiogQGludGVybmFsICovXHJcbiAgICBwdWJsaWMgZGlzcG9zZSgpIHtcclxuICAgICAgICAodGhpcy5fbG9hZGVyIGFzIGFueSkgPSBudWxsO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQGludGVybmFsXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBsb2FkTWF0ZXJpYWxQcm9wZXJ0aWVzQXN5bmMoY29udGV4dDogc3RyaW5nLCBtYXRlcmlhbDogSU1hdGVyaWFsLCBi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4gICAgICAgIGJhYnlsb25NYXRlcmlhbC51bmxpdCA9IHRydWU7XHJcblxyXG4gICAgICAgIGNvbnN0IHByb3BlcnRpZXMgPSBtYXRlcmlhbC5wYnJNZXRhbGxpY1JvdWdobmVzcztcclxuICAgICAgICBpZiAocHJvcGVydGllcykge1xyXG4gICAgICAgICAgICBpZiAocHJvcGVydGllcy5iYXNlQ29sb3JGYWN0b3IpIHtcclxuICAgICAgICAgICAgICAgIGJhYnlsb25NYXRlcmlhbC5hbGJlZG9Db2xvciA9IENvbG9yMy5Gcm9tQXJyYXkocHJvcGVydGllcy5iYXNlQ29sb3JGYWN0b3IpO1xyXG4gICAgICAgICAgICAgICAgYmFieWxvbk1hdGVyaWFsLmFscGhhID0gcHJvcGVydGllcy5iYXNlQ29sb3JGYWN0b3JbM107XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBiYWJ5bG9uTWF0ZXJpYWwuYWxiZWRvQ29sb3IgPSBDb2xvcjMuV2hpdGUoKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYgKHByb3BlcnRpZXMuYmFzZUNvbG9yVGV4dHVyZSkge1xyXG4gICAgICAgICAgICAgICAgcHJvbWlzZXMucHVzaChcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZXIubG9hZFRleHR1cmVJbmZvQXN5bmMoYCR7Y29udGV4dH0vYmFzZUNvbG9yVGV4dHVyZWAsIHByb3BlcnRpZXMuYmFzZUNvbG9yVGV4dHVyZSwgKHRleHR1cmUpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dHVyZS5uYW1lID0gYCR7YmFieWxvbk1hdGVyaWFsLm5hbWV9IChCYXNlIENvbG9yKWA7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25NYXRlcmlhbC5hbGJlZG9UZXh0dXJlID0gdGV4dHVyZTtcclxuICAgICAgICAgICAgICAgICAgICB9KVxyXG4gIC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3RyYWN0TWVzaCkgPT4gdm9pZFxyXG4gICAgKTogTnVsbGFibGU8UHJvbWlzZTxBYnN0cmFjdE1lc2g+PiB7XHJcbiAgICAgICAgcmV0dXJuIEdMVEZMb2FkZXIuTG9hZEV4dGVuc2lvbkFzeW5jPElLSFJNYXRlcmlhbFZhcmlhbnRzX01hcHBpbmcsIEFic3RyYWN0TWVzaD4oY29udGV4dCwgcHJpbWl0aXZlLCB0aGlzLm5hbWUsIChleHRlbnNpb25Db250ZXh0LCBleHRlbnNpb24pID0+IHtcclxuICAgICAgICAgICAgY29uc3QgcHJvbWlzZXMgPSBuZXcgQXJyYXk8UHJvbWlzZTxhbnk+PigpO1xyXG4gICAgICAgICAgICBwcm9taXNlcy5wdXNoKFxyXG4gICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVyLl9sb2FkTWVzaFByaW1pdGl2ZUFzeW5jKGNvbnRleHQsIG5hbWUsIG5vZGUsIG1lc2gsIHByaW1pdGl2ZSwgKGJhYnlsb25NZXNoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgYXNzaWduKGJhYnlsb25NZXNoKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGJhYnlsb25NZXNoIGluc3RhbmNlb2YgTWVzaCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiYWJ5bG9uRHJhd01vZGUgPSBHTFRGTG9hZGVyLl9HZXREcmF3TW9kZShjb250ZXh0LCBwcmltaXRpdmUubW9kZSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb290ID0gdGhpcy5fbG9hZGVyLnJvb3RCYWJ5bG9uTWVzaDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWV0YWRhdGEgPSByb290ID8gKHJvb3QuX2ludGVybmFsTWV0YWRhdGEgPSByb290Ll9pbnRlcm5hbE1ldGFkYXRhIHx8IHt9KSA6IHt9O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25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aW5nLm1hdGVyaWFsKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2goXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVyLl9sb2FkTWF0ZXJpYWxBc3luYyhgIy9tYXRlcmlhbHMvJHttYXBwaW5nLm1hdGVyaWFsfWAsIG1hdGVyaWFsLCBiYWJ5bG9uTWVzaCwgYmFieWxvbkRyYXdNb2RlLCAoYmFieWxvbk1hdGVyaWFsKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IG1hcHBpbmdWYXJpYW50SW5kZXggPSAwOyBtYXBwaW5nVmFyaWFudEluZGV4IDwgbWFwcGluZy52YXJpYW50cy5sZW5ndGg7ICsrbWFwcGluZ1ZhcmlhbnRJbmRleCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFyaWFudEluZGV4ID0gbWFwcGluZy52YXJpYW50c1ttYXBwaW5nVmFyaWFudEluZGV4XTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhcmlhbnQgPSBBcnJheUl0ZW0uR2V0KGAvZXh0ZW5zaW9ucy8ke05BTUV9L3ZhcmlhbnRzLyR7dmFyaWFudEluZGV4fWAsIHRoaXMuX3ZhcmlhbnRzLCB2YXJpYW50SW5kZXgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0ZW5zaW9uTWV0YWRhdGEudmFyaWFudHNbdmFyaWFudC5uYW1lXSA9IGV4dGVuc2lvbk1ldGFkYXRhLnZhcmlhbnRzW3ZhcmlhbnQubmFtZV0gfHwgW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRlbnNpb25NZXRhZGF0YS52YXJpYW50c1t2YXJpYW50Lm5hbWVdLnB1c2goe1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc2g6IGJhYnlsb25NZXNoLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hdGVyaWFsOiBiYWJ5bG9uTWF0ZXJpYWwsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBSZXBsYWNlIHRoZSB0YXJnZXQgd2hlbiBvcmlnaW5hbCBtZXNoIGlzIGNsb25lZFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvbk1lc2gub25DbG9uZWRPYnNlcnZhYmxlLmFkZCgobmV3T25lOiBOb2RlKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmV3TWVzaCA9IG5ld09uZSBhcyBNZXNoO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtZXRhZGF0YTogTnVsbGFibGU8SUV4dGVuc2lvbk1ldGFkYXRhPiA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5ld1Jvb3Q6IE51bGxhYmxlPE5vZGU+ID0gbmV3TWVzaDtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gRmluZCByb290IHRvIGdldCBtZWRhdGFcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkbyB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld1Jvb3QgPSBuZXdSb290IS5wYXJlbnQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbmV3Um9vdCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1ldGFkYXRhID0gS0hSX21hdGVyaWFsc192YXJpYW50cy5fR2V0RXh0ZW5zaW9uTWV0YWRhdGEobmV3Um9vdCBhcyBNZXNoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IHdoaWxlIChtZXRhZGF0YSA9PT0gbnVsbCk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIE5lZWQgdG8gY2xvbmUgdGhlIG1ldGFkYXRhIG9uIHRoZSByb290IChmaXJzdCB0aW1lIG9ubHkpXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJvb3QgJiYgbWV0YWRhdGEgPT09IEtIUl9tYXRlcmlhbHNfdmFyaWFudHMuX0dldEV4dGVuc2lvbk1ldGFkYXRhKHJvb3QpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIENvcHkgbWFpbiBtZXRhZGF0YVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdSb290Ll9pbnRlcm5hbE1ldGFkYXRhID0ge307XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qga2V5IGluIHJvb3QuX2ludGVybmFsTWV0YWRhdGEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld1Jvb3QuX2ludGVybmFsTWV0YWRhdGFba2V5XSA9IHJvb3QuX2ludGVybmFsTWV0YWRhdGFba2V5XTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gQ29weSB0aGUgZ2x0ZiBtZXRhZGF0YVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdSb290Ll9pbnRlcm5hbE1ldGFkYXRhLmdsdGYgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBrZXkgaW4gcm9vdC5faW50ZXJuYWxNZXRhZGF0YS5nbHRmKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdSb290Ll9pbnRlcm5hbE1ldGFkYXRhLmdsdGZba2V5XSA9IHJvb3QuX2ludGVybmFsTWV0YWRhdGEuZ2x0ZltrZXldO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBEdXBsaWNhdGUgdGhlIGV4dGVuc2lvbiBzcGVjaWZpYyBtZXRhZGF0YVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdSb290Ll9pbnRlcm5hbE1ldGFkYXRhLmdsdGZbTkFNRV0gPSB7IGxhc3RTZWxlY3RlZDogbnVsbCwgb3JpZ2luYWw6IFtdLCB2YXJpYW50czoge30gfTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvcmlnaW5hbCBvZiBtZXRhZGF0YS5vcmlnaW5hbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Um9vdC5faW50ZXJuYWxNZXRhZGF0YS5nbHRmW05BTUVdLm9yaWdpbmFsLnB1c2goe1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc2g6IG9yaWdpbmFsLm1lc2gsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF0ZXJpYWw6IG9yaWdpbmFsLm1hdGVyaWFsLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBrZXkgaW4gbWV0YWRhdGEudmFyaWFudHMpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwobWV0YWRhdGEudmFyaWFudHMsIGtleSkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdSb290Ll9pbnRlcm5hbE1ldGFkYXRhLmdsdGZbTkFNRV0udmFyaWFudHNba2V5XSA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgdmFyaWFudEVudHJ5IG9mIG1ldGFkYXRhLnZhcmlhbnRzW2tleV0pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Um9vdC5faW50ZXJuYWxNZXRhZGF0YS5nbHRmW05BTUVdLnZhcmlhbnRzW2tleV0ucHVzaCh7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNoOiB2YXJpYW50RW50cnkubWVzaCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hdGVyaWFsOiB2YXJpYW50RW50cnkubWF0ZXJpYWwsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWV0YWRhdGEgPSBuZXdSb290Ll9pbnRlcm5hbE1ldGFkYXRhLmdsdGZbTkFNRV07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBSZWxvY2F0ZVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgdGFyZ2V0IG9mIG1ldGFkYXRhIS5vcmlnaW5hbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGFyZ2V0Lm1lc2ggPT09IGJhYnlsb25NZXNoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQubWVzaCA9IG5ld01lc2g7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCB0YXJnZXQgb2YgbWV0YWRhdGEhLnZhcmlhbnRzW3ZhcmlhbnQubmFtZV0pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldC5tZXNoID09PSBiYWJ5bG9uTWVzaCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0Lm1lc2ggPSBuZXdNZXNoO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbigoW2JhYnlsb25NZXNoXSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGJhYnlsb25NZXNoO1xyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxufVxyXG5cclxuR0xURkxvYWRlci5SZWdpc3RlckV4dGVuc2lvbihOQU1FLCAobG9hZGVyKSA9PiBuZXcgS0hSX21hdGVyaWFsc192YXJpYW50cyhsb2FkZXIpKTt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V0dXJuIEdMVEZMb2FkZXIuTG9hZEV4dGVuc2lvbkFzeW5jPElLSFJUZXh0dXJlVHJhbnNmb3JtLCBCYXNlVGV4dHVyZT4oY29udGV4dCwgdGV4dHVyZUluZm8sIHRoaXMubmFtZSwgKGV4dGVuc2lvbkNvbnRleHQsIGV4dGVuc2lvbikgPT4ge1xyXG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fbG9hZGVyLmxvYWRUZXh0dXJlSW5mb0FzeW5jKGNvbnRleHQsIHRleHR1cmVJbmZvLCAoYmFieWxvblRleHR1cmUpID0+IHtcclxuICAgICAgICAgICAgICAgIGlmICghKGJhYnlsb25UZXh0dXJlIGluc3RhbmNlb2YgVGV4dHVyZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYCR7ZXh0ZW5zaW9uQ29udGV4dH06IFRleHR1cmUgdHlwZSBub3Qgc3VwcG9ydGVkYCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKGV4dGVuc2lvbi5vZmZzZXQpIHtcclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uVGV4dHVyZS51T2Zmc2V0ID0gZXh0ZW5zaW9uLm9mZnNldFswXTtcclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uVGV4dHVyZS52T2Zmc2V0ID0gZXh0ZW5zaW9uLm9mZnNldFsxXTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAvLyBBbHdheXMgcm90YXRlIGFyb3VuZCB0aGUgb3JpZ2luLlxyXG4gICAgICAgICAgICAgICAgYmFieWxvblRleHR1cmUudVJvdGF0aW9uQ2VudGVyID0gMDtcclxuICAgICAgICAgICAgICAgIGJhYnlsb25UZXh0dXJlLnZSb3RhdGlvbkNlbnRlciA9IDA7XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKGV4dGVuc2lvbi5yb3RhdGlvbikge1xyXG4gICAgICAgICAgICAgICAgICAgIGJhYnlsb25UZXh0dXJlLndBbmcgPSAtZXh0ZW5zaW9uLnJvdGF0aW9uO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGlmIChleHRlbnNpb24uc2NhbGUpIHtcclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uVGV4dHVyZS51U2NhbGUgPSBleHRlbnNpb24uc2NhbGVbMF07XHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvblRleHR1cmUudlNjYWxlID0gZXh0ZW5zaW9uLnNjYWxlWzFdO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGlmIChleHRlbnNpb24udGV4Q29vcmQgIT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvblRleHR1cmUuY29vcmRpbmF0ZXNJbmRleCA9IGV4dGVuc2lvbi50ZXhDb29yZDtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBhc3NpZ24oYmFieWxvblRleHR1cmUpO1xyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxufVxyXG5cclxuR0xURkxvYWRlci5SZWdpc3RlckV4dGVuc2lvbihOQU1FLCAobG9hZGVyKSA9PiBuZXcgS0hSX3RleHR1cmVfdHJhbnNmb3JtKGxvYWRlcikpO1xyXG4iLCJpbXBvcnQgdHlwZSB7IElHTFRGTG9hZGVyRXh0ZW5zaW9uIH0gZnJvbSBcIi4uL2dsVEZMb2FkZXJFeHRlbnNpb25cIjtcclxuaW1wb3J0IHsgR0xURkxvYWRlciB9IGZyb20gXCIuLi9nbFRGTG9hZGVyXCI7XHJcbmltcG9ydCB0eXBlIHsgSUtIUlhtcEpzb25MZF9HbHRmLCBJS0hSWG1wSnNvbkxkX05vZGUgfSBmcm9tIFwiYmFieWxvbmpzLWdsdGYyaW50ZXJmYWNlXCI7XHJcblxyXG5jb25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VyLnJlZkRpc3RhbmNlICE9IHVuZGVmaW5lZCB8fFxyXG4gICAgICAgICAgICAgICAgICAgIGVtaXR0ZXIubWF4RGlzdGFuY2UgIT0gdW5kZWZpbmVkIHx8XHJcbiAgICAgICAgICAgICAgICAgICAgZW1pdHRlci5yb2xsb2ZmRmFjdG9yICE9IHVuZGVmaW5lZCB8fFxyXG4gICAgICAgICAgICAgICAgICAgIGVtaXR0ZXIuZGlzdGFuY2VNb2RlbCAhPSB1bmRlZmluZWQgfHxcclxuICAgICAgICAgICAgICAgICAgICBlbWl0dGVyLmlubmVyQW5nbGUgIT0gdW5kZWZpbmVkIHx8XHJcbiAgICAgICAgICAgICAgICAgICAgZW1pdHRlci5vdXRlckFuZ2xlICE9IHVuZGVmaW5lZFxyXG4gICAgICAgICAgICAgICAgKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGAke2V4dGVuc2lvbkNvbnRleHR9OiBEaXJlY3Rpb24gb3IgRGlzdGFuY2UgcHJvcGVydGllcyBhcmUgbm90IGFsbG93ZWQgb24gZW1pdHRlcnMgYXR0YWNoZWQgdG8gYSBzY2VuZWApO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2godGhpcy5fbG9hZEVtaXR0ZXJBc3luYyhgJHtleHRlbnNpb25Db250ZXh0fS9lbWl0dGVycy8ke2VtaXR0ZXIuaW5kZXh9YCwgZW1pdHRlcikpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5hbGwocHJvbWlzZXMpLnRoZW4oKCkgPT4ge30pO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQGludGVybmFsXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBsb2FkTm9kZUFzeW5jKGNvbnRleHQ6IHN0cmluZywgbm9kZTogSU5vZGUsIGFzc2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vZiBlbWl0dGVyLl9iYWJ5bG9uU291bmRzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdW5kLmF0dGFjaFRvTWVzaChiYWJ5bG9uTWVzaCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbWl0dGVyLmlubmVyQW5nbGUgIT0gdW5kZWZpbmVkIHx8IGVtaXR0ZXIub3V0ZXJBbmdsZSAhPSB1bmRlZmluZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdW5kLnNldExvY2FsRGlyZWN0aW9uVG9NZXNoKFZlY3RvcjMuRm9yd2FyZCgpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdW5kLnNldERpcmVjdGlvbmFsQ29uZShcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAyICogVG9vbHMuVG9EZWdyZWVzKGVtaXR0ZXIuaW5uZXJBbmdsZSA9PSB1bmRlZmluZWQgPyBNYXRoLlBJIDogZW1pdHRlci5pbm5lckFuZ2xlKSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAyICogVG9vbHMuVG9EZWdyZWVzKGVtaXR0ZXIub3V0ZXJBbmdsZSA9PSB1bmRlZmluZWQgPyBNYXRoLlBJIDogZW1pdHRlci5vdXRlckFuZ2xlKSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAwXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGFzc2lnbihiYWJ5bG9uTWVzaCk7XHJcbiAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgLnRoZW4oKGJhYnlsb25NZXNoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHByb21pc2VzKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJhYnlsb25NZXNoO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBAaW50ZXJuYWxcclxuICAgICAqL1xyXG4gICAgcHVibGljIGxvYWRBbmltYXRpb25Bc3luYyhjb250ZXh0OiBzdHJpbmcsIGFuaW1hdGlvbjogSUFuaW1hdGlvbik6IE51bGxhYmxlPFByb21pc2U8QW5pbWF0aW9uR3JvdXA+PiB7XHJcbiAgICAgICAgcmV0dXJuIEdMVEZMb2FkZXIuTG9hZEV4dGVuc2lvbkFzeW5jPElMb2FkZXJBbmltYXRpb25FdmVudHMsIEFuaW1hdGlvbkdyb3VwPihjb250ZXh0LCBhbmltYXRpb24sIHRoaXMubmFtZSwgKGV4dGVuc2lvbkNvbnRleHQsIGV4dGVuc2lvbikgPT4ge1xyXG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fbG9hZGVyLmxvYWRBbmltYXRpb25Bc3luYyhjb250ZXh0LCBhbmltYXRpb24pLnRoZW4oKGJhYnlsb25BbmltYXRpb25Hcm91cCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgcHJvbWlzZXMgPSBuZXcgQXJyYXk8UHJvbWlzZTxhbnk+PigpO1xyXG5cclxuICAgICAgICAgICAgICAgIEFycmF5SXRlbS5Bc3NpZ24oZXh0ZW5zaW9uLmV2ZW50cyk7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGV2ZW50IG9mIGV4dGVuc2lvbi5ldmVudHMpIHtcclxuICAgICAgICAgICAgICAgICAgICBwcm9taXNlcy5wdXNoKHRoaXMuX2xvYWRBbmltYXRpb25FdmVudEFzeW5jKGAke2V4dGVuc2lvbkNvbnRleHR9L2V2ZW50cy8ke2V2ZW50LmluZGV4fWAsIGNvbnRleHQsIGFuaW1hdGlvbiwgZXZlbnQsIGJhYnlsb25BbmltYXRpb25Hcm91cCkpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJhYnlsb25BbmltYXRpb25Hcm91cDtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9sb2FkQ2xpcEFzeW5jKGNvbnRleHQ6IHN0cmluZywgY2xpcDogSUxvYWRlckNsaXApOiBQcm9taXNlPHN0cmluZz4ge1xyXG4gICAgICAgIGlmIChjbGlwLl9vYmplY3RVUkwpIHtcclxuICAgICAgICAgICAgcmV0dXJuIGNsaXAuX29iamVjdFVSTDtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGxldCBwcm9taXNlOiBQcm9taXNlPEFycmF5QnVmZmVyVmlldz47XHJcbiAgICAgICAgaWYgKGNsaXAudXJpKSB7XHJcbiAgICAgICAgICAgIHByb21pc2UgPSB0aGlzLl9sb2FkZXIubG9hZFVyaUFzeW5jKGNvbnRleHQsIGNsaXAsIGNsaXAudXJpKTtcclxuICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICBjb25zdCBidWZmZXJWaWV3ID0gQXJyYXlJdGVtLkdldChgJHtjb250ZXh0fS9idWZmZXJWaWV3YCwgdGhpcy5fbG9hZGVyLmdsdGY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UgPT0gdW5kZWZpbmVkID8gMSA6IGVtaXR0ZXIudm9sdW1lLFxyXG4gICAgICAgICAgICB9O1xyXG5cclxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBlbWl0dGVyLmNsaXBzLmxlbmd0aDsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBjbGlwQ29udGV4dCA9IGAvZXh0ZW5zaW9ucy8ke3RoaXMubmFtZX0vY2xpcHNgO1xyXG4gICAgICAgICAgICAgICAgY29uc3QgY2xpcCA9IEFycmF5SXRlbS5HZXQoY2xpcENvbnRleHQsIHRoaXMuX2NsaXBzLCBlbWl0dGVyLmNsaXBzW2ldLmNsaXApO1xyXG4gICAgICAgICAgICAgICAgY2xpcFByb21pc2VzLnB1c2goXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZENsaXBBc3luYyhgJHtjbGlwQ29udGV4dH0vJHtlbWl0dGVyLmNsaXBzW2ldLmNsaXB9YCwgY2xpcCkudGhlbigob2JqZWN0VVJMOiBzdHJpbmcpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc291bmQgPSAoZW1pdHRlci5fYmFieWxvblNvdW5kc1tpXSA9IG5ldyBTb3VuZChuYW1lLCBvYmplY3RVUkwsIHRoaXMuX2xvYWRlci5iYWJ5bG9uU2NlbmUsIG51bGwsIG9wdGlvbnMpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc291bmQucmVmRGlzdGFuY2UgPSBlbWl0dGVyLnJlZkRpc3RhbmNlIHx8IDE7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNvdW5kLm1heERpc3RhbmNlID0gZW1pdHRlci5tYXhEaXN0YW5jZSB8fCAyNTY7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNvdW5kLnJvbGxvZmZGYWN0b3IgPSBlbWl0dGVyLnJvbGxvZmZGYWN0b3IgfHwgMTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc291bmQuZGlzdGFuY2VNb2RlbCA9IGVtaXR0ZXIuZGlzdGFuY2VNb2RlbCB8fCBcImV4cG9uZW50aWFsXCI7XHJcbiAgICAgICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGNvbnN0IHByb21pc2UgPSBQcm9taXNlLmFsbChjbGlwUHJvbWlzZXMpLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgY29uc3Qgd2VpZ2h0cyA9IGVtaXR0ZXIuY2xpcHMubWFwKChjbGlwKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNsaXAud2VpZ2h0IHx8IDE7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIGNvbnN0IHdlaWdodGVkU291bmQgPSBuZXcgV2VpZ2h0ZWRTb3VuZChlbWl0dGVyLmxvb3AgfHwgZmFsc2UsIGVtaXR0ZXIuX2JhYnlsb25Tb3VuZHMsIHdlaWdodHMpO1xyXG4gICAgICAgICAgICAgICAgaWYgKGVtaXR0ZXIuaW5uZXJBbmdsZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHdlaWdodGVkU291bmQuZGlyZWN0aW9uYWxDb25lSW5uZXJBbmdsZSA9IDIgKiBUb29scy5Ub0RlZ3JlZXMoZW1pdHRlci5pbm5lckFuZ2xlKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmIChlbWl0dGVyLm91dGVyQW5nbGUpIHtcclxuICAgICAgICAgICAgICAgICAgICB3ZWlnaHRlZFNvdW5kLmRpcmVjdGlvbmFsQ29uZU91dGVyQW5nbGUgPSAyICogVG9vbHMuVG9EZWdyZWVzKGVtaXR0ZXIub3V0ZXJBbmdsZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoZW1pdHRlci52b2x1bWUpIHtcclxuICAgICAg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AgICAgICAgIHNvdW5kLnBsYXkoZnJhbWVPZmZzZXQpO1xyXG4gICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIElNU0ZUQXVkaW9FbWl0dGVyX0FuaW1hdGlvbkV2ZW50QWN0aW9uLnN0b3A6IHtcclxuICAgICAgICAgICAgICAgIHJldHVybiAoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgc291bmQuc3RvcCgpO1xyXG4gICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIElNU0ZUQXVkaW9FbWl0dGVyX0FuaW1hdGlvbkV2ZW50QWN0aW9uLnBhdXNlOiB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHNvdW5kLnBhdXNlKCk7XHJcbiAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGRlZmF1bHQ6IHtcclxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgJHtjb250ZXh0fTogVW5zdXBwb3J0ZWQgYWN0aW9uICR7YWN0aW9ufWApO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX2xvYWRBbmltYXRpb25FdmVudEFzeW5jKFxyXG4gICAgICAgIGNvbnRleHQ6IHN0cmluZyxcclxuICAgICAgICBhbmltYXRpb25Db250ZXh0OiBzdHJpbmcsXHJcbiAgICAgICAgYW5pbWF0aW9uOiBJQW5pbWF0aW9uLFxyXG4gICAgICAgIGV2ZW50OiBJTG9hZGVyQW5pbWF0aW9uRXZlbnQsXHJcbiAgICAgICAgYmFieWxvbkFuaW1hdGlvbkdyb3VwOiBBbmltYXRpb25Hcm91cFxyXG4gICAgKTogUHJvbWlzZTx2b2lkPiB7XHJcbiAgICAgICAgaWYgKGJhYnlsb25B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gICBwdWJsaWMgb25SZWFkeSgpOiB2b2lkIHtcclxuICAgICAgICBmb3IgKGxldCBpbmRleExPRCA9IDA7IGluZGV4TE9EIDwgdGhpcy5fbm9kZVByb21pc2VMT0RzLmxlbmd0aDsgaW5kZXhMT0QrKykge1xyXG4gICAgICAgICAgICBjb25zdCBwcm9taXNlID0gUHJvbWlzZS5hbGwodGhpcy5fbm9kZVByb21pc2VMT0RzW2luZGV4TE9EXSkudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXhMT0QgIT09IDApIHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZXIuZW5kUGVyZm9ybWFuY2VDb3VudGVyKGBOb2RlIExPRCAke2luZGV4TE9EfWApO1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlci5sb2coYExvYWRlZCBub2RlIExPRCAke2luZGV4TE9EfWApO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIHRoaXMub25Ob2RlTE9Ec0xvYWRlZE9ic2VydmFibGUubm90aWZ5T2JzZXJ2ZXJzKGluZGV4TE9EKTtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXhMT0QgIT09IHRoaXMuX25vZGVQcm9taXNlTE9Ecy5sZW5ndGggLSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVyLnN0YXJ0UGVyZm9ybWFuY2VDb3VudGVyKGBOb2RlIExPRCAke2luZGV4TE9EICsgMX1gKTtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkQnVmZmVyTE9EKHRoaXMuX25vZGVCdWZmZXJMT0RzLCBpbmRleExPRCArIDEpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9ub2RlU2lnbmFsTE9Ec1tpbmRleExPRF0pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbm9kZVNpZ25hbExPRHNbaW5kZXhMT0RdLnJlc29sdmUoKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICAgICAgdGhpcy5fbG9hZGVyLl9jb21wbGV0ZVByb21pc2VzLnB1c2gocHJvbWlzZSk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBmb3IgKGxldCBpbmRleExPRCA9IDA7IGluZGV4TE9EIDwgdGhpcy5fbWF0ZXJpYWxQcm9taXNlTE9Ecy5sZW5ndGg7IGluZGV4TE9EKyspIHtcclxuICAgICAgICAgICAgY29uc3QgcHJvbWlzZSA9IFByb21pc2UuYWxsKHRoaXMuX21hdGVyaWFsUHJvbWlzZUxPRHNbaW5kZXhMT0RdKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgICAgIGlmIChpbmRleExPRCAhPT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlci5lbmRQZXJmb3JtYW5jZUNvdW50ZXIoYE1hdGVyaWFsIExPRCAke2luZGV4TE9EfWApO1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlci5sb2coYExvYWRlZCBtYXRlcmlhbCBMT0QgJHtpbmRleExPRH1gKTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICB0aGlzLm9uTWF0ZXJpYWxMT0RzTG9hZGVkT2JzZXJ2YWJsZS5ub3RpZnlPYnNlcnZlcnMoaW5kZXhMT0QpO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmIChpbmRleExPRCAhPT0gdGhpcy5fbWF0ZXJpYWxQcm9taXNlTE9Ecy5sZW5ndGggLSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVyLnN0YXJ0UGVyZm9ybWFuY2VDb3VudGVyKGBNYXRlcmlhbCBMT0QgJHtpbmRleExPRCArIDF9YCk7XHJcbiAgICAgICAgICAg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ICAgICAgICAgYXNzaWduKGJhYnlsb25UcmFuc2Zvcm1Ob2RlKTtcclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uVHJhbnNmb3JtTm9kZS5zZXRFbmFibGVkKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgIH07XHJcblxyXG4gICAgICAgICAgICAgICAgY29uc3QgcHJvbWlzZSA9IHRoaXMuX2xvYWRlci5sb2FkTm9kZUFzeW5jKGAvbm9kZXMvJHtub2RlTE9ELmluZGV4fWAsIG5vZGVMT0QsIGFzc2lnbldyYXApLnRoZW4oKGJhYnlsb25NZXNoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4TE9EICE9PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFRPRE86IHNob3VsZCBub3QgcmVseSBvbiBfYmFieWxvblRyYW5zZm9ybU5vZGVcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJldmlvdXNOb2RlTE9EID0gbm9kZUxPRHNbaW5kZXhMT0QgLSAxXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHByZXZpb3VzTm9kZUxPRC5fYmFieWxvblRyYW5zZm9ybU5vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc3Bvc2VUcmFuc2Zvcm1Ob2RlKHByZXZpb3VzTm9kZUxPRC5fYmFieWxvblRyYW5zZm9ybU5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHByZXZpb3VzTm9kZUxPRC5fYmFieWxvblRyYW5zZm9ybU5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGJhYnlsb25NZXNoLnNldEVuYWJsZWQodHJ1ZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJhYnlsb25NZXNoO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcblxyXG4gICAgICAgICAgICAgICAgdGhpcy5fbm9kZVByb21pc2VMT0RzW2luZGV4TE9EXSA9IHRoaXMuX25vZGVQcm9taXNlTE9Ec1tpbmRleExPRF0gfHwgW107XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKGluZGV4TE9EID09PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZmlyc3RQcm9taXNlID0gcHJvbWlzZTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbm9kZUluZGV4TE9EID0gbnVsbDtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9ub2RlUHJvbWlzZUxPRHNbaW5kZXhMT0RdLnB1c2gocHJvbWlzZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHRoaXMuX2xvYWRlci5sb2dDbG9zZSgpO1xyXG4gICAgICAgICAgICByZXR1cm4gZmlyc3RQcm9taXNlITtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIEBpbnRlcm5hbFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgX2xvYWRNYXRlcmlhbEFzeW5jKFxyXG4gICAgICAgIGNvbnRleHQ6IHN0cmluZyxcclxuICAgICAgICBtYXRlcmlhbDogSU1hdGVyaWFsLFxyXG4gICAgICAgIGJhYnlsb25NZXNoOiBOdWxsYWJsZTxNZXNoPixcclxuICAgICAgICBiYWJ5bG9uRHJhd01vZGU6IG51bWJlcixcclxuICAgICAgICBhc3NpZ246IChiYWJ5bG9uTWF0ZXJpYWw6IE1hdGVyaWFsKSA9PiB2b2lkXHJcbiAgICApOiBOdWxsYWJsZTxQcm9taXNlPE1hdGVyaWFsPj4ge1xyXG4gICAgICAgIC8vIERvbid0IGxvYWQgbWF0ZXJpYWwgTE9EcyBpZiBhbHJlYWR5IG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YyhgL21hdGVyaWFscy8ke21hdGVyaWFsTE9ELmluZGV4fWAsIG1hdGVyaWFsTE9ELCBiYWJ5bG9uTWVzaCwgYmFieWxvbkRyYXdNb2RlLCAoYmFieWxvbk1hdGVyaWFsKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbmRleExPRCA9PT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXNzaWduKGJhYnlsb25NYXRlcmlhbCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgICAgIC50aGVuKChiYWJ5bG9uTWF0ZXJpYWwpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4TE9EICE9PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhc3NpZ24oYmFieWxvbk1hdGVyaWFsKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBUT0RPOiBzaG91bGQgbm90IHJlbHkgb24gX2RhdGFcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHByZXZpb3VzRGF0YUxPRCA9IG1hdGVyaWFsTE9Ec1tpbmRleExPRCAtIDFdLl9kYXRhITtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwcmV2aW91c0RhdGFMT0RbYmFieWxvbkRyYXdNb2RlXSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc3Bvc2VNYXRlcmlhbHMoW3ByZXZpb3VzRGF0YUxPRFtiYWJ5bG9uRHJhd01vZGVdLmJhYnlsb25NYXRlcmlhbF0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBwcmV2aW91c0RhdGFMT0RbYmFieWxvbkRyYXdNb2RlXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJhYnlsb25NYXRlcmlhbDtcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuXHJcbiAgICAgICAgICAgICAgICB0aGlzLl9tYXRlcmlhbFByb21pc2VMT0RzW2luZGV4TE9EXSA9IHRoaXMuX21hdGVyaWFsUHJvbWlzZUxPRHNbaW5kZXhMT0RdIHx8IFtdO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmIChpbmRleExPRCA9PT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGZpcnN0UHJvbWlzZSA9IHByb21pc2U7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX21hdGVyaWFsSW5kZXhMT0QgPSBudWxsO1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX21hdGVyaWFsUHJvbWlzZUxPRHNbaW5kZXhMT0RdLnB1c2gocHJvbWlzZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHRoaXMuX2xvYWRlci5sb2dDbG9zZSgpO1xyXG4gICAgICAgICAgICByZXR1cm4gZmlyc3RQcm9taXNlITtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIEBpbnRlcm5hbFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgX2xvYWRVcmlBc3luYyhjb250ZXh0OiBzdHJpbmcsIHByb3BlcnR5OiBJUHJvcGVydHksIHVyaTogc3RyaW5nKTogTnVsbGFibGU8UHJvbWlzZTxBcnJheUJ1ZmZlclZpZXc+PiB7XHJcbiAgICAgICAgLy8gRGVmZXIgdGhlIGxvYWRpbmcgb2YgdXJpcyBpZiBsb2FkaW5nIGEgbm9kZSBvciBtYXRlcmlhbCBMT0QuXHJcbiAgICAgICAgaWYgKHRoaXMuX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MT0QpIHtcclxuICAgICAgICAgICAgICAgICAgICBidWZmZXJMT0Quc3RhcnQgPSBNYXRoLm1pbihidWZmZXJMT0Quc3RhcnQsIHN0YXJ0KTtcclxuICAgICAgICAgICAgICAgICAgICBidWZmZXJMT0QuZW5kID0gTWF0aC5tYXgoYnVmZmVyTE9ELmVuZCwgZW5kKTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYnVmZmVyTE9EID0geyBzdGFydDogc3RhcnQsIGVuZDogZW5kLCBsb2FkZWQ6IG5ldyBEZWZlcnJlZCgpIH07XHJcbiAgICAgICAgICAgICAgICAgICAgYnVmZmVyTE9Ec1tpbmRleExPRF0gPSBidWZmZXJMT0Q7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGJ1ZmZlckxPRC5sb2FkZWQucHJvbWlzZS50aGVuKChkYXRhKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBVaW50OEFycmF5KGRhdGEuYnVmZmVyLCBkYXRhLmJ5dGVPZmZzZXQgKyBieXRlT2Zmc2V0IC0gYnVmZmVyTE9ELnN0YXJ0LCBieXRlTGVuZ3RoKTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9O1xyXG5cclxuICAgICAgICAgICAgdGhpcy5fbG9hZGVyLmxvZyhgZGVmZXJyZWRgKTtcclxuXHJcbiAgICAgICAgICAgIGlmICh0aGlzLl9ub2RlSW5kZXhMT0QgIT09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBsb2FkQXN5bmModGhpcy5fbm9kZUJ1ZmZlckxPRHMsIHRoaXMuX25vZGVJbmRleExPRCk7XHJcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5fbWF0ZXJpYWxJbmRleExPRCAhPT0gbnVsbCkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGxvYWRBc3luYyh0aGlzLl9tYXRlcmlhbEJ1ZmZlckxPRHMsIHRoaXMuX21hdGVyaWFsSW5kZXhMT0QpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGxvYWRBc3luYyh0aGlzLl9idWZmZXJMT0RzLCAwKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgcmV0dXJuIG51bGw7XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfbG9hZEJ1ZmZlckxPRChidWZmZXJMT0RzOiBBcnJheTxJQnVmZmVySW5mbz4sIGluZGV4TE9EOiBudW1iZXIpOiB2b2lkIHtcclxuICAgICAgICBjb25zdCBidWZmZXJMT0QgPSBidWZmZXJMT0RzW2luZGV4TE9EXTtcclxuICAgICAgICBpZiAoYnVmZmVyTE9EKSB7XHJcbiAgICAgICAgICAgIHRoaXMuX2xvYWRlci5sb2coYExvYWRpbmcgYnVmZmVyIHJhbmdlIFske2J1ZmZlckxPRC5zdGFydH0tJHtidWZmZXJMT0QuZW5kfV1gKTtcclxuICAgICAgICAgICAgdGhpcy5fbG9hZGVyLmJpbiEucmVhZEFzeW5jKGJ1ZmZlckxPRC5zdGFydCwgYnVmZmVyTE9ELmVuZCAtIGJ1ZmZlckxPRC5zdGFydCArIDEpLnRoZW4oXHJcbiAgICAgICAgICAgICAgICAoZGF0YSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIGJ1ZmZlckxPRC5sb2FkZWQucmVzb2x2ZShkYXRhKTtcclxuICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICAoZXJyb3IpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBidWZmZXJMT0QubG9hZGVkLnJlamVjdChlcnJvcik7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQHJldHVybnMgYW4gYXJyYXkgb2YgTE9EIHByb3BlcnRpZXMgZnJvbSBsb3dlc3QgdG8gaGlnaGVzdC5cclxuICAgICAqIEBwYXJhbSBjb250ZXh0XHJcbiAgICAgKiBAcGFyYW0gcHJvcGVydHlcclxuICAgICAqIEBwYXJhbSBhcnJheVxyXG4gICAgICogQHBhcmFtIGlkc1xyXG4gICAgICovXHJcbiAgICBwcml2YXRlIF9nZXRMT0RzPFQ+KGNvbnRleHQ6IHN0cmluZywgcHJvcGVydHk6IFQsIGFycmF5OiBBcnJheUxpa2U8VD4gfCB1bmRlZmluZWQsIGlkczogbnVtYmVyW10pOiBUW10ge1xyXG4gICAgICAgIGlmICh0aGlzLm1heExPRHNUb0xvYWQgPD0gMCkge1xyXG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJtYXhMT0RzVG9Mb2FkIG11c3QgYmUgZ3JlYXRlciB0aGFuIHplcm9cIik7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBjb25zdCBwcm9wZXJ0aWVzOiBUW10gPSBbXTtcclxuXHJcbiAgICAgICAgZm9yIChsZXQgaSA9IGlkcy5sZW5ndGggLSAxOyBpID49IDA7IGktLSkge1xyXG4gICAgICAgICAgICBwcm9wZXJ0aWVzLnB1c2goQXJyYXlJdGVtLkdldChgJHtjb250ZXh0fS9pZHMvJHtpZHNbaV19YCwgYXJyYXksIGlkc1tpXSkpO1xyXG4gICAgICAgICAgICBpZiAocHJvcGVydGllcy5sZW5ndGggPT09IHRoaXMubWF4TE9Ec1RvTG9hZCkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIHByb3BlcnRpZXM7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHByb3BlcnRpZXMucHVzaChwcm9wZXJ0eSk7XHJcbiAgICAgICAgcmV0dXJuIHByb3BlcnRpZXM7XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfZGlzcG9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hcnRzID0gcGF0aC5zcGxpdChcIi9cIik7XHJcbiAgICAgICAgcGFydHMuc2hpZnQoKTtcclxuXHJcbiAgICAgICAgZm9yIChjb25zdCBwYXJ0IG9mIHBhcnRzKSB7XHJcbiAgICAgICAgICAgIGlmIChpbmZvVHJlZS5fX2FycmF5X18pIHtcclxuICAgICAgICAgICAgICAgIGluZm9UcmVlID0gaW5mb1RyZWUuX19hcnJheV9fO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgaW5mb1RyZWUgPSBpbmZvVHJlZVtwYXJ0XTtcclxuICAgICAgICAgICAgICAgIGlmICghaW5mb1RyZWUpIHtcclxuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYFBhdGggJHtwYXRofSBpcyBpbnZhbGlkYCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKG9iamVjdFRyZWUgPT09IHVuZGVmaW5lZCkge1xyXG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBQYXRoICR7cGF0aH0gaXMgaW52YWxpZGApO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIG9iamVjdFRyZWUgPSBvYmplY3RUcmVlW3BhcnRdO1xyXG5cclxuICAgICAgICAgICAgaWYgKGluZm9UcmVlLl9fdGFyZ2V0X18pIHtcclxuICAgICAgICAgICAgICAgIHRhcmdldCA9IG9iamVjdFRyZWU7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiB7XHJcbiAgICAgICAgICAgIG9iamVjdDogdGFyZ2V0LFxyXG4gICAgICAgICAgICBpbmZvOiBpbmZvVHJlZSxcclxuICAgICAgICB9O1xyXG4gICAgfVxyXG59XHJcbiIsImV4cG9ydCAqIGZyb20gXCIuL0VYVF9saWdodHNfaW1hZ2VfYmFzZWRcIjtcclxuZXhwb3J0ICogZnJvbS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Chjb25zdCBjb25maWdPYmplY3Qgb2YgY29uZmlndXJhdGlvbkxpc3QpIHtcclxuICAgICAgICBpZiAoY29uZmlnT2JqZWN0LmlkID09PSBcImN1c3RvbUV2ZW50XCIpIHtcclxuICAgICAgICAgICAgY29uc3QgY3VzdG9tRXZlbnQgPSBkZWZpbml0aW9uLmN1c3RvbUV2ZW50cyAmJiBkZWZpbml0aW9uLmN1c3RvbUV2ZW50c1tjb25maWdPYmplY3QudmFsdWVdO1xyXG4gICAgICAgICAgICBpZiAoIWN1c3RvbUV2ZW50KSB7XHJcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYC9leHRlbnNpb25zL0tIUl9pbnRlcmFjdGl2aXR5L25vZGVzLyR7aWR9OiBVbmtub3duIGN1c3RvbSBldmVudDogJHtjb25maWdPYmplY3QudmFsdWV9YCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY29udmVydGVkLmV2ZW50SWQgPSBjdXN0b21FdmVudC5pZDtcclxuICAgICAgICAgICAgY29udmVydGVkLmV2ZW50RGF0YSA9IGN1c3RvbUV2ZW50LnZhbHVlcy5tYXAoKHYpID0+IHYuaWQpO1xyXG4gICAgICAgIH0gZWxzZSBpZiAoY29uZmlnT2JqZWN0LmlkID09PSBcInZhcmlhYmxlXCIpIHtcclxuICAgICAgICAgICAgY29uc3QgdmFyaWFibGUgPSBkZWZpbml0aW9uLnZhcmlhYmxlcyAmJiBkZWZpbml0aW9uLnZhcmlhYmxlc1tjb25maWdPYmplY3QudmFsdWVdO1xyXG4gICAgICAgICAgICBpZiAoIXZhcmlhYmxlKSB7XHJcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYC9leHRlbnNpb25zL0tIUl9pbnRlcmFjdGl2aXR5L25vZGVzLyR7aWR9OiBVbmtub3duIHZhcmlhYmxlOiAke2NvbmZpZ09iamVjdC52YWx1ZX1gKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjb252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MgZmxvd1xyXG4gICAgICAgICAgICBjb25zdCBub2RlSW5JZCA9IGZsb3cubm9kZTtcclxuICAgICAgICAgICAgY29uc3Qgbm9kZUluU29ja2V0TmFtZSA9IGZsb3cuc29ja2V0O1xyXG4gICAgICAgICAgICAvLyBmaW5kIHRoZSBjb3JyZXNwb25kaW5nIGZsb3cgZ3JhcGggbm9kZVxyXG4gICAgICAgICAgICBjb25zdCBub2RlSW4gPSBmbG93R3JhcGhKc29uQmxvY2tzW25vZGVJbklkXTtcclxuICAgICAgICAgICAgaWYgKCFub2RlSW4pIHtcclxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcclxuICAgICAgICAgICAgICAgICAgICBgL2V4dGVuc2lvbnMvS0hSX2ludGVyYWN0aXZpdHkvbm9kZXMvJHtpfTogQ291bGQgbm90IGZpbmQgbm9kZSB3aXRoIGlkICR7bm9kZUluSWR9IHRoYXQgY29ubmVjdHMgaXRzIGlucHV0IHdpdGggd2l0aCBub2RlICR7aX0ncyBvdXRwdXQgJHtzb2NrZXRPdXROYW1lfWBcclxuICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgLy8gaW4gYWxsIG9mIHRoZSBmbG93IGdyYXBoIGlucHV0IGNvbm5lY3Rpb25zLCBmaW5kIHRoZSBvbmUgd2l0aCB0aGUgc2FtZSBuYW1lIGFzIHRoZSBzb2NrZXRcclxuICAgICAgICAgICAgbGV0IHNvY2tldEluID0gbm9kZUluLnNpZ25hbElucHV0cy5maW5kKChzKSA9PiBzLm5hbWUgPT09IG5vZGVJblNvY2tldE5hbWUpO1xyXG4gICAgICAgICAgICAvLyBpZiB0aGUgc29ja2V0IGRvZXNuJ3QgZXhpc3QsIGNyZWF0ZSB0aGUgaW5wdXQgc29ja2V0IGZvciB0aGUgY29ubmVjdGlvblxyXG4gICAgICAgICAgICBpZiAoIXNvY2tldEluKSB7XHJcbiAgICAgICAgICAgICAgICBzb2NrZXRJbiA9IHtcclxuICAgICAgICAgICAgICAgICAgICB1bmlxdWVJZDogUmFuZG9tR1VJRCgpLFxyXG4gICAgICAgICAgICAgICAgICAgIG5hbWU6IG5vZGVJblNvY2tldE5hbWUsXHJcbiAgICAgICAgICAgICAgICAgICAgX2Nvbm5lY3Rpb25UeXBlOiBGbG93R3JhcGhDb25uZWN0aW9uVHlwZS5JbnB1dCwgLy8gSW5wdXRcclxuICAgICAgICAgICAgICAgICAgICBjb25uZWN0ZWRQb2ludElkczogW10sXHJcbiAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgbm9kZUluLnNpZ25hbElucHV0cy5wdXNoKHNvY2tldEluKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAvLyBjb25uZWN0IHRoZSBzb2NrZXRzXHJcbiAgICAgICAgICAgIHNvY2tldEluLmNvbm5lY3RlZFBvaW50SWRzLnB1c2goc29ja2V0T3V0LnVuaXF1ZUlkKTtcclxuICAgICAgICAgICAgc29ja2V0T3V0LmNvbm5lY3RlZFBvaW50SWRzLnB1c2goc29ja2V0SW4udW5pcXVlSWQpO1xyXG4gICAgICAgIH1cclxuICAgICAgICAvLyBmb3IgZWFjaCBpbnB1dCB2YWx1ZSBvZiB0aGUgZ2x0ZiBibG9ja1xyXG4gICAgICAgIGNvbnN0IGdsdGZWYWx1ZXMgPSBnbHRmQmxvY2sudmFsdWVzID8/IFtdO1xyXG4gICAgICAgIGZvciAoY29uc3QgdmFsdWUgb2YgZ2x0ZlZhbHVlcykge1xyXG4gICAgICAgICAgICBjb25zdCBzb2NrZXRJbk5hbWUgPSB2YWx1ZS5pZDtcclxuICAgICAgICAgICAgLy8gY3JlYXRlIGFuIGlucHV0IGRhdGEgY29ubmVjdGlvbiBmb3IgdGhlIGZsb3cgZ3JhcGggYmxvY2tcclxuICAgICAgICAgICAgY29uc3Qgc29ja2V0SW46IElTZXJpYWxpemVkRmxvd0dyYXBoQ29ubmVjdGlvbiA9IHtcclxuICAgICAgICAg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ICAgICAgICAgICAgICAgIC8vIGlmIHRoZSB2YWx1ZSBpcyBjb25uZWN0ZWQgd2l0aCB0aGUgb3V0cHV0IGRhdGEgb2YgYW5vdGhlciBzb2NrZXQsIGNvbm5lY3QgdGhlIHR3b1xyXG4gICAgICAgICAgICAgICAgY29uc3Qgbm9kZU91dElkID0gdmFsdWUubm9kZTtcclxuICAgICAgICAgICAgICAgIGNvbnN0IG5vZGVPdXRTb2NrZXROYW1lID0gdmFsdWUuc29ja2V0O1xyXG4gICAgICAgICAgICAgICAgLy8gZmluZCB0aGUgZmxvdyBncmFwaCBub2RlIHRoYXQgb3ducyB0aGF0IG91dHB1dCBzb2NrZXRcclxuICAgICAgICAgICAgICAgIGNvbnN0IG5vZGVPdXQgPSBmbG93R3JhcGhKc29uQmxvY2tzW25vZGVPdXRJZF07XHJcbiAgICAgICAgICAgICAgICBpZiAoIW5vZGVPdXQpIHtcclxuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGAvZXh0ZW5zaW9ucy9LSFJfaW50ZXJhY3Rpdml0eS9ub2Rlcy8ke2l9OiBDb3VsZCBub3QgZmluZCBub2RlIHdpdGggaWQgJHtub2RlT3V0SWR9IHRoYXQgY29ubmVjdHMgaXRzIG91dHB1dCB3aXRoIG5vZGUke2l9J3MgaW5wdXQgJHtzb2NrZXRJbk5hbWV9YFxyXG4gICAgICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBsZXQgc29ja2V0T3V0ID0gbm9kZU91dC5kYXRhT3V0cHV0cy5maW5kKChzKSA9PiBzLm5hbWUgPT09IG5vZGVPdXRTb2NrZXROYW1lKTtcclxuICAgICAgICAgICAgICAgIC8vIGlmIHRoZSBzb2NrZXQgZG9lc24ndCBleGlzdCwgY3JlYXRlIGl0XHJcbiAgICAgICAgICAgICAgICBpZiAoIXNvY2tldE91dCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNvY2tldE91dCA9IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdW5pcXVlSWQ6IFJhbmRvbUdVSUQoKSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZTogbm9kZU91dFNvY2tldE5hbWUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIF9jb25uZWN0aW9uVHlwZTogRmxvd0dyYXBoQ29ubmVjdGlvblR5cGUuT3V0cHV0LFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25uZWN0ZWRQb2ludElkczogW10sXHJcbiAgICAgICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgICAgICAgICBub2RlT3V0LmRhdGFPdXRwdXRzLnB1c2goc29ja2V0T3V0KTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIC8vIGNvbm5lY3QgdGhlIHNvY2tldHNcclxuICAgICAgICAgICAgICAgIHNvY2tldEluLmNvbm5lY3RlZFBvaW50SWRzLnB1c2goc29ja2V0T3V0LnVuaXF1ZUlkKTtcclxuICAgICAgICAgICAgICAgIHNvY2tldE91dC5jb25uZWN0ZWRQb2ludElkcy5wdXNoKHNvY2tldEluLnVuaXF1ZUlkKTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgL2V4dGVuc2lvbnMvS0hSX2ludGVyYWN0aXZpdHkvbm9kZXMvJHtpfTogSW52YWxpZCBzb2NrZXQgJHtzb2NrZXRJbk5hbWV9IGluIG5vZGUgJHtpfWApO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIGNvbnN0IHZhcmlhYmxlcyA9IGdsdGYudmFyaWFibGVzID8/IFtdO1xyXG4gICAgLy8gUGFyc2UgdmFyaWFibGVzXHJcbiAgICBmb3IgKGxldCBpID0gMDsgaSA8IHZhcmlhYmxlcy5sZW5ndGg7IGkrKykge1xy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mV4cG9ydCBjbGFzcyBJbnRlcmFjdGl2aXR5UGF0aFRvT2JqZWN0Q29udmVydGVyIGV4dGVuZHMgR0xURlBhdGhUb09iamVjdENvbnZlcnRlcjxJT2JqZWN0QWNjZXNzb3I+IHtcclxuICAgIHB1YmxpYyBjb25zdHJ1Y3RvcihnbHRmOiBJR0xURikge1xyXG4gICAgICAgIHN1cGVyKGdsdGYsIGdsdGZUcmVlKTtcclxuICAgIH1cclxufVxyXG5cclxuY29uc3Qgbm9kZXNUcmVlID0ge1xyXG4gICAgX19hcnJheV9fOiB7XHJcbiAgICAgICAgX190YXJnZXRfXzogdHJ1ZSxcclxuICAgICAgICB0cmFuc2xhdGlvbjoge1xyXG4gICAgICAgICAgICB0eXBlOiBcIlZlY3RvcjNcIixcclxuICAgICAgICAgICAgZ2V0OiAobm9kZTogSU5vZGUpID0+IHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGJhYnlsb25PYmplY3QgPSBub2RlLl9iYWJ5bG9uVHJhbnNmb3JtTm9kZSBhcyBUcmFuc2Zvcm1Ob2RlO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGJhYnlsb25PYmplY3QucG9zaXRpb247XHJcbiAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgIHNldDogKHZhbHVlOiBhbnksIG5vZGU6IElOb2RlKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBiYWJ5bG9uT2JqZWN0ID0gbm9kZS5fYmFieWxvblRyYW5zZm9ybU5vZGUgYXMgVHJhbnNmb3JtTm9kZTtcclxuICAgICAgICAgICAgICAgIGJhYnlsb25PYmplY3QucG9zaXRpb24gPSB2YWx1ZTtcclxuICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgZ2V0T2JqZWN0KG5vZGU6IElOb2RlKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gbm9kZS5fYmFieWxvblRyYW5zZm9ybU5vZGU7XHJcbiAgICAgICAgICAgIH0sXHJcbiAgICAgICAg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XJyYXkgaXRlbSBvciBudWxsXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBzdGF0aWMgVHJ5R2V0PFQ+KGFycmF5OiBBcnJheUxpa2U8VD4gfCB1bmRlZmluZWQsIGluZGV4OiBudW1iZXIgfCB1bmRlZmluZWQpOiBOdWxsYWJsZTxUPiB7XHJcbiAgICAgICAgaWYgKCFhcnJheSB8fCBpbmRleCA9PSB1bmRlZmluZWQgfHwgIWFycmF5W2luZGV4XSkge1xyXG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBhcnJheVtpbmRleF07XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBBc3NpZ24gYW4gYGluZGV4YCBmaWVsZCB0byBlYWNoIGl0ZW0gb2YgdGhlIGdpdmVuIGFycmF5LlxyXG4gICAgICogQHBhcmFtIGFycmF5IFRoZSBhcnJheSBvZiBpdGVtc1xyXG4gICAgICovXHJcbiAgICBwdWJsaWMgc3RhdGljIEFzc2lnbihhcnJheT86IElBcnJheUl0ZW1bXSk6IHZvaWQge1xyXG4gICAgICAgIGlmIChhcnJheSkge1xyXG4gICAgICAgICAgICBmb3IgKGxldCBpbmRleCA9IDA7IGluZGV4IDwgYXJyYXkubGVuZ3RoOyBpbmRleCsrKSB7XHJcbiAgICAgICAgICAgICAgICBhcnJheVtpbmRleF0uaW5kZXggPSBpbmRleDtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxufVxyXG5cclxuLyoqIEBpbnRlcm5hbCAqL1xyXG5leHBvcnQgaW50ZXJmYWNlIElBbmltYXRpb25UYXJnZXRJbmZvIHtcclxuICAgIC8qKiBAaW50ZXJuYWwgKi9cclxuICAgIHRhcmdldDogYW55O1xyXG5cclxuICAgIC8qKiBAaW50ZXJuYWwgKi9cclxuICAgIHByb3BlcnRpZXM6IEFycmF5PEFuaW1hdGlvblByb3BlcnR5SW5mbz47XH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fYXNzZXRDb250YWluZXIgPSBjb250YWluZXI7XHJcbiAgICAgICAgICAgIHRoaXMuX2xvYWREYXRhKGRhdGEpO1xyXG5cclxuICAgICAgICAgICAgbGV0IG5vZGVzOiBOdWxsYWJsZTxBcnJheTxudW1iZXI+PiA9IG51bGw7XHJcblxyXG4gICAgICAgICAgICBpZiAobWVzaGVzTmFtZXMpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IG5vZGVNYXA6IHsgW25hbWU6IHN0cmluZ106IG51bWJlciB9ID0ge307XHJcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fZ2x0Zi5ub2Rlcykge1xyXG4gICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgbm9kZSBvZiB0aGlzLl9nbHRmLm5vZGVzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChub2RlLm5hbWUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGVNYXBbbm9kZS5uYW1lXSA9IG5vZGUuaW5kZXg7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgY29uc3QgbmFtZXMgPSBtZXNoZXNOYW1lcyBpbnN0YW5jZW9mIEFycmF5ID8gbWVzaGVzTmFtZXMgOiBbbWVzaGVzTmFtZXNdO1xyXG4gICAgICAgICAgICAgICAgbm9kZXMgPSBuYW1lcy5tYXAoKG5hbWUpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBub2RlID0gbm9kZU1hcFtuYW1lXTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAobm9kZSA9PT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgRmFpbGVkIHRvIGZpbmQgbm9kZSAnJHtuYW1lfSdgKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBub2RlO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9sb2FkQXN5bmMocm9vdFVybCwgZmlsZU5hbWUsIG5vZGVzLCAoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xyXG4gICAgICAgICAgICAgICAgICAgIG1lc2hlczogdGhpcy5fZ2V0TWVzaGVzKCksXHJcbiAgICAgICAgICAgICAgICAgICAgcGFydGljbGVTeXN0ZW1zOiBbXSxcclxuICAgICAgICAgICAgICAgICAgICBza2VsZXRvbnM6IHRoaXMuX2dldFNrZWxldG9ucygpLFxyXG4gICAgICAgICAgICAgICAgICAgIGFuaW1hdGlvbkdyb3VwczogdGhpcy5fZ2V0QW5pbWF0aW9uR3JvdXBzKCksXHJcbiAgICAgICAgICAgICAgICAgICAgbGlnaHRzOiB0aGlzLl9iYWJ5bG9uTGlnaHRzLFxyXG4gICAgICAgICAgICAgICAgICAgIHRyYW5zZm9ybU5vZGVzOiB0aGlzLl9nZXRUcmFuc2Zvcm1Ob2RlcygpLFxyXG4gICAgICAgICAgICAgICAgICAgIGdlb21ldHJpZXM6IHRoaXMuX2dldEdlb21ldHJpZXMoKSxcclxuICAgICAgICAgICAgICAgICAgICBzcHJpdGVNYW5hZ2VyczogW10sXHJcbiAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIEBpbnRlcm5hbFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgbG9hZEFzeW5jKHNjZW5lOiBTY2VuZSwgZGF0YTogSUdMVEZMb2FkZXJEYXRhLCByb290VXJsOiBzdHJpbmcsIG9uUHJvZ3Jlc3M/OiAoZXZlbnQ6IElTY2VuZUxvYWRlclByb2dyZXNzRXZlbnQpID0+IHZvaWQsIGZpbGVOYW1lID0gXCJcIik6IFByb21pc2U8dm9pZD4ge1xyXG4gICAgICAgIHJldHVybiBQcm9taXNlLnJlc29sdmUoKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgdGhpcy5fYmFieWxvblNjZW5lID0gc2NlbmU7XHJcbiAgICAgICAgICAgIHRoaXMuX2xvYWREYXRhKGRhdGEpO1xyXG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fbG9hZEFzeW5jKHJvb3RVcmwsIGZpbGVOYW1lLCBudWxsLCAoKSA9PiB1bmRlZmluZWQpO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX2xvYWRBc3luYzxUPihyb290VXJsOiBzdHJpbmcsIGZpbGVOYW1lOiBzdHJpbmcsIG5vZGVzOiBOdWxsYWJsZTxBcnJheTxudW1iZXI+PiwgcmVzdWx0RnVuYzogKCkgPT4gVCk6IFByb21pc2U8VD4ge1xyXG4gICAgICAgIHJldHVybiBQcm9taXNlLnJlc29sdmUoKVxyXG4gICAgICAgICAgICAudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICB0aGlzLl9yb290VXJsID0gcm9vdFVybDtcclxuICAgICAgICAgICAgICAgIHRoaXMuX3VuaXF1ZVJvb3RVcmwgPSAhcm9vdFVybC5zdGFydHNXaXRoKFwiZmlsZTpcIikgJiYgZmlsZU5hbWUgPyByb290VXJsIDogYCR7cm9vdFVybH0ke0RhdGUubm93KCl9L2A7XHJcbiAgICAgICAgICAgICAgICB0aGlzLl9maWxlTmFtZSA9IGZpbGVOYW1lO1xyXG4gICAgICAgICAgICAgICAgdGhpcy5fYWxsTWF0ZXJpYWxzRGlydHlSZXF1aXJlZCA9IGZhbHNlO1xyXG5cclxuICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRFeHRlbnNpb25zKCk7XHJcbiAgICAgICAgICAgICAgICB0aGlzLl9jaGVja0V4dGVuc2lvbnMoKTtcclxuXHJcbiAgICAgICAgICA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ICsrbSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXRlcmlhbCA9IHRoaXMuX2dsdGYubWF0ZXJpYWxzW21dO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb250ZXh0ID0gXCIvbWF0ZXJpYWxzL1wiICsgbTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmFieWxvbkRyYXdNb2RlID0gTWF0ZXJpYWwuVHJpYW5nbGVGaWxsTW9kZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2godGhpcy5fbG9hZE1hdGVyaWFsQXN5bmMoY29udGV4dCwgbWF0ZXJpYWwsIG51bGwsIGJhYnlsb25EcmF3TW9kZSwgKCkgPT4ge30pKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgLy8gUmVzdG9yZSB0aGUgYmxvY2tpbmcgb2YgbWF0ZXJpYWwgZGlydHkuXHJcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fYWxsTWF0ZXJpYWxzRGlydHlSZXF1aXJlZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIC8vIFRoaXMgY2FuIGhhcHBlbiBpZiB3ZSBhZGQgYSBsaWdodCBmb3IgaW5zdGFuY2UgYXMgaXQgd2lsbCBpbXBhY3QgdGhlIHdob2xlIHNjZW5lLlxyXG4gICAgICAgICAgICAgICAgICAgIC8vIFRoaXMgYXV0b21hdGljYWxseSByZXNldHMgZXZlcnl0aGluZyBpZiBuZWVkZWQuXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmFieWxvblNjZW5lLmJsb2NrTWF0ZXJpYWxEaXJ0eU1lY2hhbmlzbSA9IG9sZEJsb2NrTWF0ZXJpYWxEaXJ0eU1lY2hhbmlzbTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgLy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mVudC5jdXN0b21Sb290Tm9kZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yb290QmFieWxvbk1lc2guc2V0RW5hYmxlZCh0cnVlKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2V4dGVuc2lvbnNPblJlYWR5KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFyZW50Ll9zZXRTdGF0ZShHTFRGTG9hZGVyU3RhdGUuUkVBRFkpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdGFydEFuaW1hdGlvbnMoKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdEZ1bmMoKTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHRQcm9taXNlLnRoZW4oKHJlc3VsdCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhcmVudC5fZW5kUGVyZm9ybWFuY2VDb3VudGVyKGxvYWRpbmdUb1JlYWR5Q291bnRlck5hbWUpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBUb29scy5TZXRJbW1lZGlhdGUoKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX2Rpc3Bvc2VkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBQcm9taXNlLmFsbCh0aGlzLl9jb21wbGV0ZVByb21pc2VzKS50aGVuKFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFyZW50Ll9lbmRQZXJmb3JtYW5jZUNvdW50ZXIobG9hZGluZ1RvQ29tcGxldGVDb3VudGVyTmFtZSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXJlbnQuX3NldFN0YXRlKEdMVEZMb2FkZXJTdGF0ZS5DT01QTEVURSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXJlbnQub25Db21wbGV0ZU9ic2VydmFibGUubm90aWZ5T2JzZXJ2ZXJzKHVuZGVmaW5lZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhcmVudC5vbkNvbXBsZXRlT2JzZXJ2YWJsZS5jbGVhcigpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNwb3NlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoZXJyb3IpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFyZW50Lm9uRXJyb3JPYnNlcnZhYmxlLm5vdGlmeU9ic2VydmVycyhlcnJvcik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhcmVudC5vbkVycm9yT2JzZXJ2YWJsZS5jbGVhcigpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNwb3NlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0O1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgIC5jYXRjaCgoZXJyb3IpID0+IHtcclxuICAgICAgICAgICAgICAgIGlmICghdGhpcy5fZGlzcG9z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gICAgICBBcnJheUl0ZW0uQXNzaWduKHRoaXMuX2dsdGYuc2tpbnMpO1xyXG4gICAgICAgIEFycmF5SXRlbS5Bc3NpZ24odGhpcy5fZ2x0Zi50ZXh0dXJlcyk7XHJcblxyXG4gICAgICAgIGlmICh0aGlzLl9nbHRmLm5vZGVzKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IG5vZGVQYXJlbnRzOiB7IFtpbmRleDogbnVtYmVyXTogbnVtYmVyIH0gPSB7fTtcclxuICAgICAgICAgICAgZm9yIChjb25zdCBub2RlIG9mIHRoaXMuX2dsdGYubm9kZXMpIHtcclxuICAgICAgICAgICAgICAgIGlmIChub2RlLmNoaWxkcmVuKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpbmRleCBvZiBub2RlLmNoaWxkcmVuKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGVQYXJlbnRzW2luZGV4XSA9IG5vZGUuaW5kZXg7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBjb25zdCByb290Tm9kZSA9IHRoaXMuX2NyZWF0ZVJvb3ROb2RlKCk7XHJcbiAgICAgICAgICAgIGZvciAoY29uc3Qgbm9kZSBvZiB0aGlzLl9nbHRmLm5vZGVzKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBwYXJlbnRJbmRleCA9IG5vZGVQYXJlbnRzW25vZGUuaW5kZXhdO1xyXG4gICAgICAgICAgICAgICAgbm9kZS5wYXJlbnQgPSBwYXJlbnRJbmRleCA9PT0gdW5kZWZpbmVkID8gcm9vdE5vZGUgOiB0aGlzLl9nbHRmLm5vZGVzW3BhcmVudEluZGV4XTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9sb2FkRXh0ZW5zaW9ucygpOiB2b2lkIHtcclxuICAgIC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9kZS5zY2FsZSA9IFsxLCAxLCAtMV07XHJcbiAgICAgICAgICAgICAgICAgICAgR0xURkxvYWRlci5fTG9hZFRyYW5zZm9ybShyb290Tm9kZSwgdGhpcy5fcm9vdEJhYnlsb25NZXNoKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgR0xURkxvYWRlckNvb3JkaW5hdGVTeXN0ZW1Nb2RlLkZPUkNFX1JJR0hUX0hBTkRFRDoge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5fYmFieWxvblNjZW5lLnVzZVJpZ2h0SGFuZGVkU3lzdGVtID0gdHJ1ZTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGRlZmF1bHQ6IHtcclxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgSW52YWxpZCBjb29yZGluYXRlIHN5c3RlbSBtb2RlICgke3RoaXMuX3BhcmVudC5jb29yZGluYXRlU3lzdGVtTW9kZX0pYCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHRoaXMuX3BhcmVudC5vbk1lc2hMb2FkZWRPYnNlcnZhYmxlLm5vdGlmeU9ic2VydmVycyhyb290TWVzaCk7XHJcbiAgICAgICAgcmV0dXJuIHJvb3ROb2RlO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogTG9hZHMgYSBnbFRGIHNjZW5lLlxyXG4gICAgICogQHBhcmFtIGNvbnRleHQgVGhlIGNvbnRleHQgd2hlbiBsb2FkaW5nIHRoZSBhc3NldFxyXG4gICAgICogQHBhcmFtIHNjZW5lIFRoZSBnbFRGIHNjZW5lIHByb3BlcnR5XHJcbiAgICAgKiBAcmV0dXJucyBBIHByb21pc2UgdGhhdCByZXNvbHZlcyB3aGVuIHRoZSBsb2FkIGlzIGNvbXBsZXRlXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBsb2FkU2NlbmVBc3luYyhjb250ZXh0OiBzdHJpbmcsIHNjZW5lOiBJU2NlbmUpOiBQcm9taXNlPHZvaWQ+IHtcclxuICAgICAgICBjb25zdCBleHRlbnNpb25Qcm9taXNlID0gdGhpcy5fZXh0ZW5zaW9uc0xvYWRTY2VuZUFzeW5jKGNvbnRleHQsIHNjZW5lKTtcclxuICAgICAgICBpZiAoZXh0ZW5zaW9uUHJvbWlzZSkge1xyXG4gICAgICAgICAgICByZXR1cm4gZXh0ZW5zaW9uUHJvbWlzZTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGNvbnN0IHByb21pc2VzID0gbmV3IEFycmF5PFByb21pc2U8YW55Pj4oKTtcclxuXHJcbiAgICAgICAgdGhpcy5sb2dPcGVuKGAke2NvbnRleHR9ICR7c2NlbmUubmFtZSB8fCBcIlwifWApO1xyXG5cclxuICAgICAgICBpZiAoc2NlbmUubm9kZXMpIHtcclxuICAgICAgICAgICAgZm9yIChjb25zdCBpbmRleCBvZiBzY2VuZS5ub2Rlcykge1xyXG4gICAgICAgICAgICAgICAgY29uc3Qgbm9kZSA9IEFycmF5SXRlbS5HZXQoYCR7Y29udGV4dH0vbm9kZXMvJHtpbmRleH1gLCB0aGlzLl9nbHRmLm5vZGVzLCBpbmRleCk7XHJcbiAgICAgICAgICAgICAgICBwcm9taXNlcy5wdXNoKFxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMubG9hZE5vZGVBc3luYyhgL25vZGVzLyR7bm9kZS5pbmRleH1gLCBub2RlLCAoYmFieWxvbk1lc2gpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvbk1lc2gucGFyZW50ID0gdGhpcy5fcm9vdEJhYnlsb25NZXNoO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBmb3IgKGNvbnN0IGFjdGlvbiBvZiB0aGlzLl9wb3N0U2NlbmVMb2FkQWN0aW9ucykge1xyXG4gICAgICAgICAgICBhY3Rpb24oKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHByb21pc2VzLnB1c2godGhpcy5fbG9hZEFuaW1hdGlvbnNBc3luYygpKTtcclxuXHJcbiAgICAgICAgdGhpcy5sb2dDbG9zZSgpO1xyXG5cclxuICAgICAgICByZXR1cm4gUHJvbWlzZS5hbGwocHJvbWlzZXMpLnRoZW4oKCkgPT4ge30pO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX2ZvckVhY2hQcmltaXRpdmUobm9kZTogSU5vZGUsIGNhbGxiYWNrOiAoYmFieWxvbk1lc2g6IEFic3RyYWN0TWVzaCkgPT4gdm9pZCk6IHZvaWQge1xyXG4gICAgICAgIGlmIChub2RlLl9wcmltaXRpdmVCYWJ5bG9uTWVzaGVzKSB7XHJcbiAgICAgICAgICAgIGZvciAoY29uc3QgYmFieWxvbk1lc2ggb2Ygbm9kZS5fcHJpbWl0aXZlQmFieWxvbk1lc2hlcykge1xyXG4gICAgICAgICAgICAgICAgY2FsbGJhY2soYmFieWxvbk1lc2gpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX2dldEdlb21ldHJpZXMoKTogR2VvbWV0cnlbXSB7XHJcbiAgICAgICAgY29uc3QgZ2VvbWV0cmllczogR2VvbWV0cnlbXSA9IFtdO1xyXG5cclxuICAgICAgICBjb25zdCBub2RlcyA9IHRoaXMuX2dsdGYubm9kZXM7XHJcbiAgICAgICAgaWYgKG5vZGVzKSB7XHJcbiAgICAgICAgICAgIGZvciAoY29uc3Qgbm9kZSBvZiBub2Rlcykge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5fZm9yRWFjaFByaW1pdGl2ZShub2RlLCAoYmFieWxvbk1lc2gpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBnZW9tZXRyeSA9IChiYWJ5bG9uTWVzaCBhcyBNZXNoKS5nZW9tZXRyeTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoZ2VvbWV0cnkgJiYgZ2VvbWV0cmllcy5pbmRleE9mKGdlb21ldHJ5KSA9PT0gLTEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZ2VvbWV0cmllcy5wdXNoKGdlb21ldHJ5KTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgcmV0dXJuIGdlb21ldHJpZXM7XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfZ2V0TWVzaGVzKCk6IEFic3RyYWN0TWVzaFtdIHtcclxuICAgICAgICBjb25zdCBtZXNoZXM6IEFic3RyYWN0TWVzaFtdID0gW107XHJcblxyXG4gICAgICAgIC8vIFJvb3QgbWVzaCBpcyBhbHdheXMgZmlyc3QsIGlmIGF2YWlsYWJsZS5cclxuICAgICAgICBpZiAodGhpcy5fcm9vdEJhYnlsb25NZXNoIGluc3RhbmNlb2YgQWJzdHJhY3RNZXNoKSB7XHJcbiAgICAgICAgICAgIG1lc2hlcy5wdXNoKHRoaXMuX3Jvb3RCYWJ5bG9uTWVzaCk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBjb25zdCBub2RlcyA9IHRoaXMuX2dsdGYubm9kZXM7XHJcbiAgICAgICAgaWYgKG5vZGVzKSB7XHJcbiAgICAgICAgICAgIGZvciAoY29uc3Qgbm9kZSBvZiBub2Rlcykge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5fZm9yRWFjaFByaW1pdGl2ZShub2RlLCAoYmFieWxvbk1lc2gpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBtZXNoZXMucHVzaChiYWJ5bG9uTWVzaCk7XHJcbiAgICAgICAgICAg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OiBTa2VsZXRvbltdID0gW107XHJcblxyXG4gICAgICAgIGNvbnN0IHNraW5zID0gdGhpcy5fZ2x0Zi5za2lucztcclxuICAgICAgICBpZiAoc2tpbnMpIHtcclxuICAgICAgICAgICAgZm9yIChjb25zdCBza2luIG9mIHNraW5zKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoc2tpbi5fZGF0YSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNrZWxldG9ucy5wdXNoKHNraW4uX2RhdGEuYmFieWxvblNrZWxldG9uKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgcmV0dXJuIHNrZWxldG9ucztcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9nZXRBbmltYXRpb25Hcm91cHMoKTogQW5pbWF0aW9uR3JvdXBbXSB7XHJcbiAgICAgICAgY29uc3QgYW5pbWF0aW9uR3JvdXBzOiBBbmltYXRpb25Hcm91cFtdID0gW107XHJcblxyXG4gICAgICAgIGNvbnN0IGFuaW1hdGlvbnMgPSB0aGlzLl9nbHRmLmFuaW1hdGlvbnM7XHJcbiAgICAgICAgaWYgKGFuaW1hdGlvbnMpIHtcclxuICAgICAgICAgICAgZm9yIChjb25zdCBhbmltYXRpb24gb2YgYW5pbWF0aW9ucykge1xyXG4gICAgICAgICAgICAgICAgaWYgKGFuaW1hdGlvbi5fYmFieWxvbkFuaW1hdGlvbkdyb3VwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYW5pbWF0aW9uR3JvdXBzLnB1c2goYW5pbWF0aW9uLl9iYWJ5bG9uQW5pbWF0aW9uR3JvdXApO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICByZXR1cm4gYW5pbWF0aW9uR3JvdXBzO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX3N0YXJ0QW5pbWF0aW9ucygpOiB2b2lkIHtcclxuICAgICAgICBzd2l0Y2ggKHRoaXMuX3BhcmVudC5hbmltYXRpb25TdGFydE1vZGUpIHtcclxuICAgICAgICAgICAgY2FzZSBHTFRGTG9hZGVyQW5pbWF0aW9uU3RhcnRNb2RlLk5PTkU6IHtcclxuICAgICAgICAgICAgICAgIC8vIGRvIG5vdGhpbmdcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgR0xURkxvYWRlckFuaW1hdGlvblN0YXJ0TW9kZS5GSVJTVDoge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgYmFieWxvbkFuaW1hdGlvbkdyb3VwcyA9IHRoaXMuX2dldEFuaW1hdGlvbkdyb3VwcygpO1xyXG4gICAgICAgICAgICAgICAgaWYgKGJhYnlsb25BbmltYXRpb25Hcm91cHMubGVuZ3RoICE9PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvbkFuaW1hdGlvbkdyb3Vwc1swXS5zdGFydCh0cnVlKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgR0xURkxvYWRlckFuaW1hdGlvblN0YXJ0TW9kZS5BTEw6IHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGJhYnlsb25BbmltYXRpb25Hcm91cHMgPSB0aGlzLl9nZXRBbmltYXRpb25Hcm91cHMoKTtcclxuICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYmFieWxvbkFuaW1hdGlvbkdyb3VwIG9mIGJhYnlsb25BbmltYXRpb25Hcm91cHMpIHtcclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uQW5pbWF0aW9uR3JvdXAuc3RhcnQodHJ1ZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAg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ICAgICAgICAgIGJhYnlsb25DYW1lcmEucGFyZW50ID0gYmFieWxvblRyYW5zZm9ybU5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmIChub2RlLmNoaWxkcmVuKSB7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGluZGV4IG9mIG5vZGUuY2hpbGRyZW4pIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGlsZE5vZGUgPSBBcnJheUl0ZW0uR2V0KGAke2NvbnRleHR9L2NoaWxkcmVuLyR7aW5kZXh9YCwgdGhpcy5fZ2x0Zi5ub2RlcywgaW5kZXgpO1xyXG4gICAgICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2goXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubG9hZE5vZGVBc3luYyhgL25vZGVzLyR7Y2hpbGROb2RlLmluZGV4fWAsIGNoaWxkTm9kZSwgKGNoaWxkQmFieWxvbk1lc2gpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoaWxkQmFieWxvbk1lc2gucGFyZW50ID0gYmFieWxvblRyYW5zZm9ybU5vZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgYXNzaWduKGJhYnlsb25UcmFuc2Zvcm1Ob2RlKTtcclxuICAgICAgICB9O1xyXG5cclxuICAgICAgICBpZiAobm9kZS5tZXNoID09IHVuZGVmaW5lZCB8fCBub2RlLnNraW4gIT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IG5vZGVOYW1lID0gbm9kZS5uYW1lIHx8IGBub2RlJHtub2RlLmluZGV4fWA7XHJcbiAgICAgICAgICAgIHRoaXM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GVyIGV4dGVuc2lvbiBhZGRlZCBtZXRhZGF0YS5cclxuICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvblRyYW5zZm9ybU5vZGUubWV0YWRhdGEgPSBtZXJnZURlZXAoYmFieWxvblRyYW5zZm9ybU5vZGVGb3JTa2luLm1ldGFkYXRhLCBiYWJ5bG9uVHJhbnNmb3JtTm9kZS5tZXRhZGF0YSB8fCB7fSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBza2luID0gQXJyYXlJdGVtLkdldChgJHtjb250ZXh0fS9za2luYCwgdGhpcy5fZ2x0Zi5za2lucywgbm9kZS5za2luKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcHJvbWlzZXMucHVzaChcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRTa2luQXN5bmMoYC9za2lucy8ke3NraW4uaW5kZXh9YCwgbm9kZSwgc2tpbiwgKGJhYnlsb25Ta2VsZXRvbikgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZvckVhY2hQcmltaXRpdmUobm9kZSwgKGJhYnlsb25NZXNoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25NZXNoLnNrZWxldG9uID0gYmFieWxvblNrZWxldG9uO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBXYWl0IHVudGlsIGFsbCB0aGUgbm9kZXMgYXJlIHBhcmVudGVkIGJlZm9yZSBwYXJlbnRpbmcgdGhlIHNraW5uZWQgbWVzaC5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wb3N0U2NlbmVMb2FkQWN0aW9ucy5wdXNoKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNraW4uc2tlbGV0b24gIT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBQbGFjZSB0aGUgc2tpbm5lZCBtZXNoIG5vZGUgYXMgYSBzaWJsaW5nIG9mIHRoZSBza2VsZXRvbiByb290IG5vZGUuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBIYW5kbGUgc3BlY2lhbCBjYXNlIHdoZW4gdGhlIHBhcmVudCBvZiB0aGUgc2tlbGV0b24gcm9vdCBpcyB0aGUgc2tpbm5lZCBtZXNoLlxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFyZW50Tm9kZSA9IEFycmF5SXRlbS5HZXQoYC9za2lucy8ke3NraW4uaW5kZXh9L3NrZWxldG9uYCwgdGhpcy5fZ2x0Zi5ub2Rlcywgc2tpbi5za2VsZXRvbikucGFyZW50ITtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChub2RlLmluZGV4ID09PSBwYXJlbnROb2RlLmluZGV4KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvblRyYW5zZm9ybU5vZGUucGFyZW50ID0gYmFieWxvblRyYW5zZm9ybU5vZGVGb3JTa2luLnBhcmVudDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvblRyYW5zZm9ybU5vZGUucGFyZW50ID0gcGFyZW50Tm9kZS5fYmFieWxvblRyYW5zZm9ybU5vZGUhO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvblRyYW5zZm9ybU5vZGUucGFyZW50ID0gdGhpcy5fcm9vdEJhYnlsb25NZXNoO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXJlbnQub25Ta2luTG9hZGVkT2JzZXJ2YWJsZS5ub3RpZnlPYnNlcnZlcnMoeyBub2RlOiBiYWJ5bG9uVHJhbnNmb3JtTm9kZUZvclNraW4sIHNraW5uZWROb2RlOiBiYWJ5bG9uVHJhbnNmb3JtTm9kZSB9KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHRoaXMubG9nQ2xvc2UoKTtcclxuXHJcbiAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHByb21pc2VzKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgdGhpcy5fZm9yRWFjaFByaW1pdGl2ZShub2RlLCAoYmFieWxvbk1lc2gpID0+IHtcclxuICAgICAgICAgICAgICAgIGlmICgoYmFieWxvbk1lc2ggYXMgTWVzaCkuZ2VvbWV0cnkgJiYgKGJhYnlsb25NZXNoIGFzIE1lc2gpLmdlb21ldHJ5IS51c2VCb3VuZGluZ0luZm9Gcm9tR2VvbWV0cnkpIHtcclxuICAgICAgICAgICAgICAgICAgICAvLyBzaW1wbHkgYXBwbHkgdGhlIHdvcmxkIG1hdHJpY2VzIHRvIHRoZSBib3VuZGluZyBpbmZvIC0gdGhlIGV4dGVuZHMgYXJlIGFscmVhZHkgb2tcclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uT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XJ0ZXhEYXRhQXN5bmMoY29udGV4dCwgcHJpbWl0aXZlLCBiYWJ5bG9uTWVzaCkudGhlbigoYmFieWxvbkdlb21ldHJ5KSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2xvYWRNb3JwaFRhcmdldHNBc3luYyhjb250ZXh0LCBwcmltaXRpdmUsIGJhYnlsb25NZXNoLCBiYWJ5bG9uR2VvbWV0cnkpLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZGlzcG9zZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmFieWxvblNjZW5lLl9ibG9ja0VudGl0eUNvbGxlY3Rpb24gPSAhIXRoaXMuX2Fzc2V0Q29udGFpbmVyO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uR2VvbWV0cnkuYXBwbHlUb01lc2goYmFieWxvbk1lc2gpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uR2VvbWV0cnkuX3BhcmVudENvbnRhaW5lciA9IHRoaXMuX2Fzc2V0Q29udGFpbmVyO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iYWJ5bG9uU2NlbmUuX2Jsb2NrRW50aXR5Q29sbGVjdGlvbiA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgKTtcclxuXHJcbiAgICAgICAgICAgIGNvbnN0IGJhYnlsb25EcmF3TW9kZSA9IEdMVEZMb2FkZXIuX0dldERyYXdNb2RlKGNvbnRleHQsIHByaW1pdGl2ZS5tb2RlKTtcclxuICAgICAgICAgICAgaWYgKHByaW1pdGl2ZS5tYXRlcmlhbCA9PSB1bmRlZmlu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GJhYnlsb25EcmF3TW9kZSwgKGJhYnlsb25NYXRlcmlhbCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uTWVzaC5tYXRlcmlhbCA9IGJhYnlsb25NYXRlcmlhbDtcclxuICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgcHJvbWlzZSA9IFByb21pc2UuYWxsKHByb21pc2VzKTtcclxuXHJcbiAgICAgICAgICAgIGlmIChzaG91bGRJbnN0YW5jZSkge1xyXG4gICAgICAgICAgICAgICAgcHJpbWl0aXZlLl9pbnN0YW5jZURhdGEgPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvblNvdXJjZU1lc2g6IGJhYnlsb25NZXNoLFxyXG4gICAgICAgICAgICAgICAgICAgIHByb21pc2U6IHByb21pc2UsXHJcbiAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBiYWJ5bG9uQWJzdHJhY3RNZXNoID0gYmFieWxvbk1lc2g7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBHTFRGTG9hZGVyLkFkZFBvaW50ZXJNZXRhZGF0YShiYWJ5bG9uQWJzdHJhY3RNZXNoLCBjb250ZXh0KTtcclxuICAgICAgICB0aGlzLl9wYXJlbnQub25NZXNoTG9hZGVkT2JzZXJ2YWJsZS5ub3RpZnlPYnNlcnZlcnMoYmFieWxvbkFic3RyYWN0TWVzaCk7XHJcbiAgICAgICAgYXNzaWduKGJhYnlsb25BYnN0cmFjdE1lc2gpO1xyXG5cclxuICAgICAgICB0aGlzLmxvZ0Nsb3NlKCk7XHJcblxyXG4gICAgICAgIHJldHVybiBwcm9taXNlLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICByZXR1cm4gYmFieWxvbkFic3RyYWN0TWVzaDtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuX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W50VHlwZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIEFjY2Vzc29yQ29tcG9uZW50VHlwZS5CWVRFOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2aWRlciA9IDEyNy4wO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgQWNjZXNzb3JDb21wb25lbnRUeXBlLlVOU0lHTkVEX0JZVEU6XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXZpZGVyID0gMjU1LjA7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBBY2Nlc3NvckNvbXBvbmVudFR5cGUuU0hPUlQ6XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXZpZGVyID0gMzI3NjcuMDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIEFjY2Vzc29yQ29tcG9uZW50VHlwZS5VTlNJR05FRF9TSE9SVDpcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpdmlkZXIgPSA2NTUzNS4wO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9uZU92ZXJEaXZpZGVyID0gMSAvIGRpdmlkZXI7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluLnNjYWxlSW5QbGFjZShvbmVPdmVyRGl2aWRlcik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4LnNjYWxlSW5QbGFjZShvbmVPdmVyRGl2aWRlcik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uR2VvbWV0cnkuX2JvdW5kaW5nSW5mbyA9IG5ldyBCb3VuZGluZ0luZm8obWluLCBtYXgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvbkdlb21ldHJ5LnVzZUJvdW5kaW5nSW5mb0Zyb21HZW9tZXRyeSA9IHRydWU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvbkdlb21ldHJ5LnNldFZlcnRpY2VzQnVmZmVyKGJhYnlsb25WZXJ0ZXhCdWZmZXIsIGFjY2Vzc29yLmNvdW50KTtcclxuICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICk7XHJcblxyXG4gICAgICAgICAgICBpZiAoa2luZCA9PSBWZXJ0ZXhCdWZmZXIuTWF0cmljZXNJbmRpY2VzRXh0cmFLaW5kKSB7XHJcbiAgICAgICAgICAgICAgICBiYWJ5bG9uTWVzaC5udW1Cb25lSW5mbHVlbmNlcnMgPSA4O1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAoY2FsbGJhY2spIHtcclxuICAgICAgICAgICAgICAgIGNhbGxiYWNrKGFjY2Vzc29yKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH07XHJcblxyXG4gICAgICAgIGxvYWRBdHRyaWJ1dGUoXCJQT1NJVElPTlwiLCBWZXJ0ZXhCdWZmZXIuUG9zaXRpb25LaW5kKTtcclxuICAgICAgICBsb2FkQXR0cmlidXRlKFwiTk9STUFMXCIsIFZlcnRleEJ1ZmZlci5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XG4gICAgICAgICAgICAgICAgaWYgKChpbmRleCArIDEpICUgNCAhPT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHRhbmdlbnRzW2RhdGFJbmRleF0gPSBkYXRhW2RhdGFJbmRleF0gKyB2YWx1ZTtcclxuICAgICAgICAgICAgICAgICAgICBkYXRhSW5kZXgrKztcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIGJhYnlsb25Nb3JwaFRhcmdldC5zZXRUYW5nZW50cyh0YW5nZW50cyk7XHJcbiAgICAgICAgfSk7XHJcblxyXG4gICAgICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbigoKSA9PiB7fSk7XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBzdGF0aWMgX0xvYWRUcmFuc2Zvcm0obm9kZTogSU5vZGUsIGJhYnlsb25Ob2RlOiBUcmFuc2Zvcm1Ob2RlKTogdm9pZCB7XHJcbiAgICAgICAgLy8gSWdub3JlIHRoZSBUUlMgb2Ygc2tpbm5lZCBub2Rlcy5cclxuICAgICAgICAvLyBTZWUgaHR0cHM6Ly9naXRodWIuY29tL0tocm9ub3NHcm91cC9nbFRGL3RyZWUvbWFzdGVyL3NwZWNpZmljYXRpb24vMi4wI3NraW5zIChzZWNvbmQgaW1wbGVtZW50YXRpb24gbm90ZSlcclxuICAgICAgICBpZiAobm9kZS5za2luICE9IHVuZGVmaW5lZCkge1xyXG4gICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBsZXQgcG9zaXRpb24gPSBWZWN0b3IzLlplcm8oKTtcclxuICAgICAgICBsZXQgcm90YXRpb24gPSBRdWF0ZXJuaW9uLklkZW50aXR5KCk7XHJcbiAgICAgICAgbGV0IHNjYWxpbmcgPSBWZWN0b3IzLk9uZSgpO1xyXG5cclxuICAgICAgICBpZiAobm9kZS5tYXRyaXgpIHtcclxuICAgICAgICAgICAgY29uc3QgbWF0cml4ID0gTWF0cml4LkZyb21BcnJheShub2RlLm1hdHJpeCk7XHJcbiAgICAgICAgICAgIG1hdHJpeC5kZWNvbXBvc2Uoc2NhbGluZywgcm90YXRpb24sIHBvc2l0aW9uKTtcclxuICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICBpZiAobm9kZS50cmFuc2xhdGlvbikge1xyXG4gICAgICAgICAgICAgICAgcG9zaXRpb24gPSBWZWN0b3IzLkZyb21BcnJheShub2RlLnRyYW5zbGF0aW9uKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAobm9kZS5yb3RhdGlvbikge1xyXG4gICAgICAgICAgICAgICAgcm90YXRpb24gPSBRdWF0ZXJuaW9uLkZyb21BcnJheShub2RlLnJvdGF0aW9uKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAobm9kZS5zY2FsZSkge1xyXG4gICAgICAgICAgICAgICAgc2NhbGluZyA9IFZlY3RvcjMuRnJvbUFycmF5KG5vZGUuc2NhbGUpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBiYWJ5bG9uTm9kZS5wb3NpdGlvbiA9IHBvc2l0aW9uO1xyXG4gICAgICAgIGJhYnlsb25Ob2RlLnJvdGF0aW9uUXVhdGVybmlvbiA9IHJvdGF0aW9uO1xyXG4gICAgICAgIGJhYnlsb25Ob2RlLnNjYWxpbmcgPSBzY2FsaW5nO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX2xvYWRTa2luQXN5bmMoY29udGV4dDogc3RyaW5nLCBub2RlOiBJTm9kZSwgc2tpbjogSVNraW4sIGFzc2lnbjogKGJhYnlsb25Ta2VsZXRvbjogU2tlbGV0b24pID0+IHZvaWQpOiBQcm9taXNlPHZvaWQ+IHtcclxuICAgICAgICBjb25zdCBleHRlbnNpb25Qcm9taXNlID0gdGhpcy5fZXh0ZW5zaW9uc0xvYWRTa2luQXN5bmMoY29udG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yaWNlcyhiYWJ5bG9uU2tlbGV0b24sIGludmVyc2VCaW5kTWF0cmljZXNEYXRhKTtcclxuICAgICAgICB9KTtcclxuXHJcbiAgICAgICAgc2tpbi5fZGF0YSA9IHtcclxuICAgICAgICAgICAgYmFieWxvblNrZWxldG9uOiBiYWJ5bG9uU2tlbGV0b24sXHJcbiAgICAgICAgICAgIHByb21pc2U6IHByb21pc2UsXHJcbiAgICAgICAgfTtcclxuXHJcbiAgICAgICAgYXNzaWduKGJhYnlsb25Ta2VsZXRvbik7XHJcblxyXG4gICAgICAgIHJldHVybiBwcm9taXNlO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX2xvYWRCb25lcyhjb250ZXh0OiBzdHJpbmcsIHNraW46IElTa2luLCBiYWJ5bG9uU2tlbGV0b246IFNrZWxldG9uKTogdm9pZCB7XHJcbiAgICAgICAgaWYgKHNraW4uc2tlbGV0b24gPT0gdW5kZWZpbmVkIHx8IHRoaXMuX3BhcmVudC5hbHdheXNDb21wdXRlU2tlbGV0b25Sb290Tm9kZSkge1xyXG4gICAgICAgICAgICBjb25zdCByb290Tm9kZSA9IHRoaXMuX2ZpbmRTa2VsZXRvblJvb3ROb2RlKGAke2NvbnRleHR9L2pvaW50c2AsIHNraW4uam9pbnRzKTtcclxuICAgICAgICAgICAgaWYgKHJvb3ROb2RlKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoc2tpbi5za2VsZXRvbiA9PT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2tpbi5za2VsZXRvbiA9IHJvb3ROb2RlLmluZGV4O1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1BhcmVudCA9IChhOiBJTm9kZSwgYjogSU5vZGUpOiBib29sZWFuID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZm9yICg7IGIucGFyZW50OyBiID0gYi5wYXJlbnQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiLnBhcmVudCA9PT0gYSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2tlbGV0b25Ob2RlID0gQXJyYXlJdGVtLkdldChgJHtjb250ZXh0fS9za2VsZXRvbmAsIHRoaXMuX2dsdGYubm9kZXMsIHNraW4uc2tlbGV0b24pO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChza2VsZXRvbk5vZGUgIT09IHJvb3ROb2RlICYmICFpc1BhcmVudChza2VsZXRvbk5vZGUsIHJvb3ROb2RlKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBMb2dnZXIuV2FybihgJHtjb250ZXh0fS9za2VsZXRvbjogT3ZlcnJpZGluZyB3aXRoIG5lYXJlc3QgY29tbW9uIGFuY2VzdG9yIGFzIHNrZWxldG9uIG5vZGUgaXMgbm90IGEgY29tbW9uIHJvb3RgKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2tpbi5za2VsZXRvbiA9IHJvb3ROb2RlLmluZGV4O1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIExvZ2dlci5XYXJuKGAke2NvbnRleHR9OiBGYWlsZWQgdG8gZmluZCBjb21tb24gcm9vdGApO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBjb25zdCBiYWJ5bG9uQm9uZXM6IHsgW2luZGV4OiBudW1iZXJdOiBCb25lIH0gPSB7fTtcclxuICAgICAgICBmb3IgKGNvbnN0IGluZGV4IG9mIHNraW4uam9pbnRzKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IG5vZGUgPSBBcnJheUl0ZW0uR2V0KGAke2NvbnRleHR9L2pvaW50cy8ke2luZGV4fWAsIHRoaXMuX2dsdGYubm9kZXMsIGluZGV4KTtcclxuICAgICAgICAgICAgdGhpcy5fbG9hZEJvbmUobm9kZSwgc2tpbiwgYmFieWxvblNrZWxldG9uLCBiYWJ5bG9uQm9uZXMpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9maW5kU2tlbGV0b25Sb290Tm9kZShjb250ZXh0OiBzdHJpbmcsIGpvaW50czogQXJyYXk8bnVtYmVyPik6IE51bGxhYmxlPElOb2RlPiB7XHJcbiAgICAgICAgaWYgKGpvaW50cy5sZW5ndGggPT09IDApIHtcclxuICAgICAgICAgICAgcmV0dXJuIG51bGw7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBjb25zdCBwYXRoczogeyBbam9pbnQ6IG51bWJlcl06IEFycmF5PElOb2RlPiB9ID0ge307XHJcbiAgICAgICAgZm9yIChjb25zdCBpbmRleCBvZiBqb2ludHMpIHtcclxuICAgICAgICAgICAgY29uc3QgcGF0aDogSU5vZGVbXSA9IFtdO1xyXG4gICAgICAgICAgICBsZXQgbm9kZSA9IEFycmF5SXRlbS5HZXQoYCR7Y29udGV4dH0vJHtpbmRleH1gLCB0aGlzLl9nbHRmLm5vZGVzLCBpbmRleCk7XHJcbiAgICAgICAgICAgIHdoaWxlIChub2RlLmluZGV4ICE9PSAtMSkge1xyXG4gICAgICAgICAgICAgICAgcGF0aC51bnNoaWZ0KG5vZGUpO1xyXG4gICAgICAgICAgICAgICAgbm9kZSA9IG5vZGUucGFyZW50ITtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBwYXRoc1tpbmRleF0gPSBwYXRoO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgbGV0IHJvb3ROb2RlOiBOdWxsYWJsZTxJTm9kZT4gPSBudWxsO1xyXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyA7ICsraSkge1xyXG4gICAgICAgICAgICBsZXQgcGF0aCA9IHBhdGhzW2pvaW50c1swXV07XHJcbiAgICAgICAgICAgIGlmIChpID49IHBhdGgubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gcm9vdE5vZGU7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGNvbnN0IG5vZGUgPSBwYXRoW2ldO1xyXG4gICAgICAgICAgICBmb3IgKGxldCBqID0gMTsgaiA8IGpvaW50cy5sZW5ndGg7ICsraikge1xyXG4gICAgICAgICAgICAgICAgcGF0aCA9IHBhdGhzW2pvaW50c1tqXV07XHJcbiAgICAgICAgICAgICAgICBpZiAoaSA+PSBwYXRoLmxlbmd0aCB8fCBub2RlICE9PSBwYXRoW2ldKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJvb3ROb2RlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICByb290Tm9kZSA9IG5vZGU7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX2xvYWRCb25lKG5vZGU6IElOb2RlLCBza2luOiBJU2tpbiwgYmFieWxvblNrZWxldG9uOiBTa2VsZXRvbiwgYmFieWxvbkJvbmVzOiB7IFtpbmRleDogbnVtYmVyXTogQm9uZSB9KTogQm9uZSB7XHJcbiAgICAgICAgbGV0IGJhYnlsb25Cb25lID0gYmFieWxvbkJvbmVzW25vZGUuaW5kZXhdO1xyXG4gICAgICAgIGlmIChiYWJ5bG9uQm9uZSkge1xyXG4gICAgICAgICAgICByZXR1cm4gYmFieWxvbkJvbmU7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBsZXQgcGFyZW50QmFieWxvbkJvbmU6IE51bGxhYmxlPEJvbm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pbWF0aW9uR3JvdXApID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAvLyBEZWxldGUgdGhlIGFuaW1hdGlvbiBncm91cCBpZiBpdCBlbmRlZCB1cCBub3QgaGF2aW5nIGFueSBhbmltYXRpb25zIGluIGl0LlxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChhbmltYXRpb25Hcm91cC50YXJnZXRlZEFuaW1hdGlvbnMubGVuZ3RoID09PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFuaW1hdGlvbkdyb3VwLmRpc3Bvc2UoKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICApO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHByb21pc2VzKS50aGVuKCgpID0+IHt9KTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIExvYWRzIGEgZ2xURiBhbmltYXRpb24uXHJcbiAgICAgKiBAcGFyYW0gY29udGV4dCBUaGUgY29udGV4dCB3aGVuIGxvYWRpbmcgdGhlIGFzc2V0XHJcbiAgICAgKiBAcGFyYW0gYW5pbWF0aW9uIFRoZSBnbFRGIGFuaW1hdGlvbiBwcm9wZXJ0eVxyXG4gICAgICogQHJldHVybnMgQSBwcm9taXNlIHRoYXQgcmVzb2x2ZXMgd2l0aCB0aGUgbG9hZGVkIEJhYnlsb24gYW5pbWF0aW9uIGdyb3VwIHdoZW4gdGhlIGxvYWQgaXMgY29tcGxldGVcclxuICAgICAqL1xyXG4gICAgcHVibGljIGxvYWRBbmltYXRpb25Bc3luYyhjb250ZXh0OiBzdHJpbmcsIGFuaW1hdGlvbjogSUFuaW1hdGlvbik6IFByb21pc2U8QW5pbWF0aW9uR3JvdXA+IHtcclxuICAgICAgICBjb25zdCBwcm9taXNlID0gdGhpcy5fZXh0ZW5zaW9uc0xvYWRBbmltYXRpb25Bc3luYyhjb250ZXh0LC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aW5kZXh9YCwgY29udGV4dCwgYW5pbWF0aW9uLCBjaGFubmVsLCAoYmFieWxvblRhcmdldCwgYmFieWxvbkFuaW1hdGlvbikgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIGJhYnlsb25UYXJnZXQuYW5pbWF0aW9ucyA9IGJhYnlsb25UYXJnZXQuYW5pbWF0aW9ucyB8fCBbXTtcclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uVGFyZ2V0LmFuaW1hdGlvbnMucHVzaChiYWJ5bG9uQW5pbWF0aW9uKTtcclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uQW5pbWF0aW9uR3JvdXAuYWRkVGFyZ2V0ZWRBbmltYXRpb24oYmFieWxvbkFuaW1hdGlvbiwgYmFieWxvblRhcmdldCk7XHJcbiAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICApO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHByb21pc2VzKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgYmFieWxvbkFuaW1hdGlvbkdyb3VwLm5vcm1hbGl6ZSgwKTtcclxuICAgICAgICAgICAgcmV0dXJuIGJhYnlsb25BbmltYXRpb25Hcm91cDtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIEBoaWRkZW5cclxuICAgICAqIExvYWRzIGEgZ2xURiBhbmltYXRpb24gY2hhbm5lbC5cclxuICAgICAqIEBwYXJhbSBjb250ZXh0IFRoZSBjb250ZXh0IHdoZW4gbG9hZGluZyB0aGUgYXNzZXRcclxuICAgICAqIEBwYXJhbSBhbmltYXRpb25Db250ZXh0IFRoZSBjb250ZXh0IG9mIHRoZSBhbmltYXRpb24gd2hlbiBsb2FkaW5nIHRoZSBhc3NldFxyXG4gICAgICogQHBhcmFtIGFuaW1hdGlvbiBUaGUgZ2xURiBhbmltYXRpb24gcHJvcGVydHlcclxuICAgICAqIEBwYXJ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2V0KGAke2NvbnRleHR9L3RhcmdldC9ub2RlYCwgdGhpcy5fZ2x0Zi5ub2RlcywgY2hhbm5lbC50YXJnZXQubm9kZSk7XHJcblxyXG4gICAgICAgIC8vIElnbm9yZSBhbmltYXRpb25zIHRoYXQgaGF2ZSBubyBhbmltYXRpb24gdGFyZ2V0cy5cclxuICAgICAgICBpZiAoXHJcbiAgICAgICAgICAgIChjaGFubmVsLnRhcmdldC5wYXRoID09PSBBbmltYXRpb25DaGFubmVsVGFyZ2V0UGF0aC5XRUlHSFRTICYmICF0YXJnZXROb2RlLl9udW1Nb3JwaFRhcmdldHMpIHx8XHJcbiAgICAgICAgICAgIChjaGFubmVsLnRhcmdldC5wYXRoICE9PSBBbmltYXRpb25DaGFubmVsVGFyZ2V0UGF0aC5XRUlHSFRTICYmICF0YXJnZXROb2RlLl9iYWJ5bG9uVHJhbnNmb3JtTm9kZSlcclxuICAgICAgICApIHtcclxuICAgICAgICAgICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZSgpO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgbGV0IHByb3BlcnRpZXM6IEFycmF5PEFuaW1hdGlvblByb3BlcnR5SW5mbz47XHJcbiAgICAgICAgc3dpdGNoIChjaGFubmVsLnRhcmdldC5wYXRoKSB7XHJcbiAgICAgICAgICAgIGNhc2UgQW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGguVFJBTlNMQVRJT046IHtcclxuICAgICAgICAgICAgICAgIHByb3BlcnRpZXMgPSBub2RlQW5pbWF0aW9uRGF0YS50cmFuc2xhdGlvbjtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgQW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGguUk9UQVRJT046IHtcclxuICAgICAgICAgICAgICAgIHByb3BlcnRpZXMgPSBub2RlQW5pbWF0aW9uRGF0YS5yb3RhdGlvbjtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgQW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGguU0NBTEU6IHtcclxuICAgICAgICAgICAgICAgIHByb3BlcnRpZXMgPSBub2RlQW5pbWF0aW9uRGF0YS5zY2FsZTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgQW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGguV0VJR0hUUzoge1xyXG4gICAgICAgICAgICAgICAgcHJvcGVydGllcyA9IG5vZGVBbmltYXRpb25EYXRhLndlaWdodHM7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBkZWZhdWx0OiB7XHJcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYCR7Y29udGV4dH0vdGFyZ2V0L3BhdGg6IEludmFsaWQgdmFsdWUgKCR7Y2hhbm5lbC50YXJnZXQucGF0aH0pYCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGNvbnN0IHRhcmdldEluZm86IElPYmplY3RJbmZvPEFuaW1hdGlvblByb3BlcnR5SW5mb1tdPiA9IHtcclxuICAgICAgICAgICAgb2JqZWN0OiB0YXJnZXROb2RlLFxyXG4gICAgICAgICAgICBpbmZvOiBwcm9wZXJ0aWVzLFxyXG4gICAgICAgIH07XHJcblxyXG4gICAgICAgIHJldHVybiB0aGlzLl9sb2FkQW5pbWF0aW9uQ2hhbm5lbEZyb21UYXJnZXRJbmZvQXN5bmMoY29udGV4dCwgYW5pbWF0aW9uQ29udGV4dCwgYW5pbWF0aW9uLCBjaGFubmVsLCB0YXJnZXRJbmZvLCBvbkxvYWQpO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQGhpZGRlblxyXG4gICAgICogTG9hZHMgYSB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4gICAgICAgICAgICBmb3IgKGNvbnN0IHByb3BlcnR5SW5mbyBvZiBwcm9wZXJ0eUluZm9zKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBzdHJpZGUgPSBwcm9wZXJ0eUluZm8uZ2V0U3RyaWRlKHRhcmdldCk7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBpbnB1dCA9IGRhdGEuaW5wdXQ7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBvdXRwdXQgPSBkYXRhLm91dHB1dDtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGtleXMgPSBuZXcgQXJyYXk8SUFuaW1hdGlvbktleT4oaW5wdXQubGVuZ3RoKTtcclxuICAgICAgICAgICAgICAgIGxldCBvdXRwdXRPZmZzZXQgPSAwO1xyXG5cclxuICAgICAgICAgICAgICAgIHN3aXRjaCAoZGF0YS5pbnRlcnBvbGF0aW9uKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSBBbmltYXRpb25TYW1wbGVySW50ZXJwb2xhdGlvbi5TVEVQOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGluZGV4ID0gMDsgaW5kZXggPCBpbnB1dC5sZW5ndGg7IGluZGV4KyspIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gcHJvcGVydHlJbmZvLmdldFZhbHVlKHRhcmdldCwgb3V0cHV0LCBvdXRwdXRPZmZzZXQsIDEpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0T2Zmc2V0ICs9IHN0cmlkZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXlzW2luZGV4XSA9IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcmFtZTogaW5wdXRbaW5kZXhdICogZnBzLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcnBvbGF0aW9uOiBBbmltYXRpb25LZXlJbnRlcnBvbGF0aW9uLlNURVAsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBjYXNlIEFuaW1hdGlvblNhbXBsZXJJbnRlcnBvbGF0aW9uLkNVQklDU1BMSU5FOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGluZGV4ID0gMDsgaW5kZXggPCBpbnB1dC5sZW5ndGg7IGluZGV4KyspIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGluVGFuZ2VudCA9IHByb3BlcnR5SW5mby5nZXRWYWx1ZSh0YXJnZXQsIG91dHB1dCwgb3V0cHV0T2Zmc2V0LCBpbnZmcHMpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0T2Zmc2V0ICs9IHN0cmlkZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gcHJvcGVydHlJbmZvLmdldFZhbHVlKHRhcmdldCwgb3V0cHV0LCBvdXRwdXRPZmZzZXQsIDEpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0T2Zmc2V0ICs9IHN0cmlkZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG91dFRhbmdlbnQgPSBwcm9wZXJ0eUluZm8uZ2V0VmFsdWUodGFyZ2V0LCBvdXRwdXQsIG91dHB1dE9mZnNldCwgaW52ZnBzKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dE9mZnNldCArPSBzdHJpZGU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5c1tpbmRleF0gPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJhbWU6IGlucHV0W2luZGV4XSAqIGZwcyxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpblRhbmdlbnQ6IGluVGFuZ2VudCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0VGFuZ2VudDogb3V0VGFuZ2VudCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgQW5pbWF0aW9uU2FtcGxlckludGVycG9sYXRpb24uTElORUFSOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGluZGV4ID0gMDsgaW5kZXggPCBpbnB1dC5sZW5ndGg7IGluZGV4KyspIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gcHJvcGVydHlJbmZvLmdldFZhbHVlKHRhcmdldCwgb3V0cHV0LCBvdXRwdXRPZmZzZXQsIDEpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0T2Zmc2V0ICs9IHN0cmlkZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXlzW2luZGV4XSA9IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcmFtZTogaW5wdXRbaW5kZXhdICogZnBzLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGlmIChvdXRwdXRPZmZzZXQgPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IGAke2FuaW1hdGlvbi5uYW1lIHx8IGBhbmltYXRpb24ke2FuaW1hdGlvbi5pbmRleH1gfV9jaGFubmVsJHtjaGFubmVsLmluZGV4fV8ke251bUFuaW1hdGlvbnN9YDtcclxuICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0eUluZm8uYnVpbGRBbmltYXRpb25zKHRhcmdldCwgbmFtZSwgZnBzLCBrZXlzLCAoYmFieWxvbkFuaW1hdGFibGUsIGJhYnlsb25BbmltYXRpb24pID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgKytudW1BbmltYXRpb25zO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBvbkxvYWQoYmFieWxvbkFuaW1hdGFibGUsIGJhYnlsb25BbmltYXRpb24pO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfbG9hZEFuaW1hdGlvblNhbXBsZXJBc3luYyhjb250ZXh0OiBzdHJpbmcsIHNhbXBsZXI6IElBbmltYXRpb25TYW1wbGVyKTogUHJvbWlzZTxfSUFuaW1hdGlvblNhbXBsZXJEYXRhPiB7XHJcbiAgICAgICAgaWYgKHNhbXBsZXIuX2RhdGEpIHtcclxuICAgICAgICAgICAgcmV0dXJuIHNhbXBsZXIuX2RhdGE7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBjb25zdCBpbnRlcnBvbGF0aW9uID0gc2FtcGxlci5pbnRlcnBvbGF0aW9uIHx8IEFuaW1hdGlvblNhbXBsZXJJbnRlcnBvbGF0aW9uLkxJTkVBUjtccl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8IGJ5dGVTdHJpZGUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG51bUNvbXBvbmVudHMsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFjY2Vzc29yLmNvbXBvbmVudFR5cGUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGVkQXJyYXkubGVuZ3RoLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBhY2Nlc3Nvci5ub3JtYWxpemVkIHx8IGZhbHNlLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAodmFsdWUsIGluZGV4KSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlZEFycmF5W2luZGV4XSA9IHZhbHVlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHlwZWRBcnJheTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAoYWNjZXNzb3Iuc3BhcnNlKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IHNwYXJzZSA9IGFjY2Vzc29yLnNwYXJzZTtcclxuICAgICAgICAgICAgYWNjZXNzb3IuX2RhdGEgPSBhY2Nlc3Nvci5fZGF0YS50aGVuKChkYXRhKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCB0eXBlZEFycmF5ID0gZGF0YSBhcyBUeXBlZEFycmF5TGlrZTtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGluZGljZXNCdWZmZXJWaWV3ID0gQXJyYXlJdGVtLkdldChgJHtjb250ZXh0fS9zcGFyc2UvaW5kaWNlcy9idWZmZXJWaWV3YCwgdGhpcy5fZ2x0Zi5idWZmZXJWaWV3cywgc3BhcnNlLmluZGljZXMuYnVmZmVyVmlldyk7XHJcbiAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZXNCdWZmZXJWaWV3ID0gQXJyYXlJdGVtLkdldChgJHtjb250ZXh0fS9zcGFyc2UvdmFsdWVzL2J1ZmZlclZpZXdgLCB0aGlzLl9nbHRmLmJ1ZmZlclZpZXdzLCBzcGFyc2UudmFsdWVzLmJ1ZmZlclZpZXcpO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKFtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmxvYWRCdWZmZXJWaWV3QXN5bmMoYC9idWZmZXJWaWV3cy8ke2luZGljZXNCdWZmZXJWaWV3LmluZGV4fWAsIGluZGljZXNCdWZmZXJWaWV3KSxcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmxvYWRCdWZmZXJWaWV3QXN5bmMoYC9idWZmZXJWaWV3cy8ke3ZhbHVlc0J1ZmZlclZpZXcuaW5kZXh9YCwgdmFsdWVzQnVmZmVyVmlldyksXHJcbiAgICAgICAgICAgICAgICBdKS50aGVuKChbaW5kaWNlc0RhdGEsIHZhbHVlc0RhdGFdKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaW5kaWNlcyA9IEdMVEZMb2FkZXIuX0dldFR5cGVkQXJyYXkoXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGAke2NvbnRleHR9L3NwYXJzZS9pbmRpY2VzYCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgc3BhcnNlLmluZGljZXMuY29tcG9uZW50VHlwZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgaW5kaWNlc0RhdGEsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNwYXJzZS5pbmRpY2VzLmJ5dGVPZmZzZXQsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNwYXJzZS5jb3VudFxyXG4gICAgICAgICAgICAgICAgICAgICkgYXMgSW5kaWNlc0FycmF5O1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGFyc2VMZW5ndGggPSBudW1Db21wb25lbnRzICogc3BhcnNl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luZGV4XSA9IHZhbHVlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZXNJbmRleCA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaW5kaWNlc0luZGV4ID0gMDsgaW5kaWNlc0luZGV4IDwgaW5kaWNlcy5sZW5ndGg7IGluZGljZXNJbmRleCsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhSW5kZXggPSBpbmRpY2VzW2luZGljZXNJbmRleF0gKiBudW1Db21wb25lbnRzO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBjb21wb25lbnRJbmRleCA9IDA7IGNvbXBvbmVudEluZGV4IDwgbnVtQ29tcG9uZW50czsgY29tcG9uZW50SW5kZXgrKykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZWRBcnJheVtkYXRhSW5kZXgrK10gPSB2YWx1ZXNbdmFsdWVzSW5kZXgrK107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0eXBlZEFycmF5O1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgcmV0dXJuIGFjY2Vzc29yLl9kYXRhO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQGludGVybmFsXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBfbG9hZEZsb2F0QWNjZXNzb3JBc3luYyhjb250ZXh0OiBzdHJpbmcsIGFjY2Vzc29yOiBJQWNjZXNzb3IpOiBQcm9taXNlPEZsb2F0MzJBcnJheT4ge1xyXG4gICAgICAgIHJldHVybiB0aGlzLl9sb2FkQWNjZXNzb3JB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NjZXNzb3IuX2JhYnlsb25WZXJ0ZXhCdWZmZXJba2luZF0gPSB0aGlzLl9sb2FkRmxvYXRBY2Nlc3NvckFzeW5jKGNvbnRleHQsIGFjY2Vzc29yKS50aGVuKChkYXRhKSA9PiB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFZlcnRleEJ1ZmZlcihlbmdpbmUsIGRhdGEsIGtpbmQsIGZhbHNlKTtcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgY29uc3QgYnVmZmVyVmlldyA9IEFycmF5SXRlbS5HZXQoYCR7Y29udGV4dH0vYnVmZmVyVmlld2AsIHRoaXMuX2dsdGYuYnVmZmVyVmlld3MsIGFjY2Vzc29yLmJ1ZmZlclZpZXcpO1xyXG4gICAgICAgICAgICBhY2Nlc3Nvci5fYmFieWxvblZlcnRleEJ1ZmZlcltraW5kXSA9IHRoaXMuX2xvYWRWZXJ0ZXhCdWZmZXJWaWV3QXN5bmMoYnVmZmVyVmlldykudGhlbigoYmFieWxvbkJ1ZmZlcikgPT4ge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgbnVtQ29tcG9uZW50cyA9IEdMVEZMb2FkZXIuX0dldE51bUNvbXBvbmVudHMoY29udGV4dCwgYWNjZXNzb3IudHlwZSk7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFZlcnRleEJ1ZmZlcihcclxuICAgICAgICAgICAgICAgICAgICBlbmdpbmUsXHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvbkJ1ZmZlcixcclxuICAgICAgICAgICAgICAgICAgICBraW5kLFxyXG4gICAgICAgICAgICAgICAgICAgIGZhbHNlLFxyXG4gICAgICAgICAgICAgICAgICAgIHVuZGVmaW5lZCxcclxuICAgICAgICAgICAgICAgICAgICBidWZmZXJWaWV3LmJ5dGVTdHJpZGUsXHJcbiAgICAgICAgICAgICAgICAgICAgdW5kZWZpbmVkLFxyXG4gICAgICAgICAgICAgICAgICAgIGFjY2Vzc29yLmJ5dGVPZmZzZXQsXHJcbiAgICAgICAgICAgICAgICAgICAgbnVtQ29tcG9uZW50cyxcclxuICAgICAgICAgICAgICAgICAgICBhY2Nlc3Nvci5jb21wb25lbnRUeXBlLFxyXG4gICAgICAgICAgICAgICAgICAgIGFjY2Vzc29yLm5vcm1hbGl6ZWQsXHJcbiAgICAgICAgICAgICAgICAgICAgdHJ1ZSxcclxuICAgICAgICAgICAgICAgICAgICB1bmRlZmluZWQsXHJcbiAgICAgICAgICAgICAgICAgICAgdHJ1ZVxyXG4gICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICByZXR1cm4gYWNjZXNzb3IuX2JhYnlsb25WZXJ0ZXhCdWZmZXJba2luZF07XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfbG9hZE1hdGVyaWFsTWV0YWxsaWNSb3VnaG5lc3NQcm9wZXJ0aWVzQXN5bmMoY29udGV4dDogc3RyaW5nLCBwcm9wZXJ0aWVzOiBJTWF0ZXJpYWxQYnJNZXRhbGxpY1JvdWdobmVzcywgYmFieWxvbk1hdGVyaWFsOiBNYXRlcmlhbCk6IFByb21pc2U8dm9pZD4ge1xyXG4gICAgICAgIGlmICghKGJhYnlsb25NYXRlcmlhbCBpbnN0YW5jZW9mIFBCUk1hdGVyaWFsKSkge1xyXG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYCR7Y29udGV4dH06IE1hdGVyaWFsIHR5cGUgbm90IHN1cHBvcnRlZGApO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgY29uc3QgcHJvbWlzZXMgPSBuZXcgQXJyYXk8UHJvbWlzZTxhbnk+PigpO1xyXG5cclxuICAgICAgICBpZiAocHJvcGVydGllcykge1xyXG4gICAgICAgICAgICBpZiAocHJvcGVydGllcy5iYXNlQ29sb3JGYWN0b3IpIHtcclxuICAgICAgICAgICAgICAgI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cmUgPSB0ZXh0dXJlO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAocHJvcGVydGllcy5tZXRhbGxpY1JvdWdobmVzc1RleHR1cmUpIHtcclxuICAgICAgICAgICAgICAgIHByb3BlcnRpZXMubWV0YWxsaWNSb3VnaG5lc3NUZXh0dXJlLm5vbkNvbG9yRGF0YSA9IHRydWU7XHJcbiAgICAgICAgICAgICAgICBwcm9taXNlcy5wdXNoKFxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMubG9hZFRleHR1cmVJbmZvQXN5bmMoYCR7Y29udGV4dH0vbWV0YWxsaWNSb3VnaG5lc3NUZXh0dXJlYCwgcHJvcGVydGllcy5tZXRhbGxpY1JvdWdobmVzc1RleHR1cmUsICh0ZXh0dXJlKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHR1cmUubmFtZSA9IGAke2JhYnlsb25NYXRlcmlhbC5uYW1lfSAoTWV0YWxsaWMgUm91Z2huZXNzKWA7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25NYXRlcmlhbC5tZXRhbGxpY1RleHR1cmUgPSB0ZXh0dXJlO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICAgICApO1xyXG5cclxuICAgICAgICAgICAgICAgIGJhYnlsb25NYXRlcmlhbC51c2VNZXRhbGxuZXNzRnJvbU1ldGFsbGljVGV4dHVyZUJsdWUgPSB0cnVlO1xyXG4gICAgICAgICAgICAgICAgYmFieWxvbk1hdGVyaWFsLnVzZVJvdWdobmVzc0Zyb21NZXRhbGxpY1RleHR1cmVHcmVlbiA9IHRydWU7XHJcbiAgICAgICAgICAgICAgICBiYWJ5bG9uTWF0ZXJpYWwudXNlUm91Z2huZXNzRnJvbU1ldGFsbGljVGV4dHVyZUFscGhhID0gZmFsc2U7XHJcbiAgICAg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VkID0gbmV3IERlZmVycmVkPHZvaWQ+KCk7XHJcbiAgICAgICAgdGhpcy5fYmFieWxvblNjZW5lLl9ibG9ja0VudGl0eUNvbGxlY3Rpb24gPSAhIXRoaXMuX2Fzc2V0Q29udGFpbmVyO1xyXG4gICAgICAgIGNvbnN0IHRleHR1cmVDcmVhdGlvbk9wdGlvbnM6IElUZXh0dXJlQ3JlYXRpb25PcHRpb25zID0ge1xyXG4gICAgICAgICAgICBub01pcG1hcDogc2FtcGxlckRhdGEubm9NaXBNYXBzLFxyXG4gICAgICAgICAgICBpbnZlcnRZOiBmYWxzZSxcclxuICAgICAgICAgICAgc2FtcGxpbmdNb2RlOiBzYW1wbGVyRGF0YS5zYW1wbGluZ01vZGUsXHJcbiAgICAgICAgICAgIG9uTG9hZDogKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9kaXNwb3NlZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGRlZmVycmVkLnJlc29sdmUoKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgb25FcnJvcjogKG1lc3NhZ2U/OiBzdHJpbmcsIGV4Y2VwdGlvbj86IGFueSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9kaXNwb3NlZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGRlZmVycmVkLnJlamVjdChuZXcgRXJyb3IoYCR7Y29udGV4dH06ICR7ZXhjZXB0aW9uICYmIGV4Y2VwdGlvbi5tZXNzYWdlID8gZXhjZXB0aW9uLm1lc3NhZ2UgOiBtZXNzYWdlIHx8IFwiRmFpbGVkIHRvIGxvYWQgdGV4dHVyZVwifWApKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgbWltZVR5cGU6IGltYWdlLm1pbWVUeXBlLFxyXG4gICAgICAgICAgICBsb2FkZXJPcHRpb25zOiB0ZXh0dXJlTG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ckRhdGEud3JhcFY7XHJcbiAgICAgICAgYXNzaWduKGJhYnlsb25UZXh0dXJlKTtcclxuXHJcbiAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHByb21pc2VzKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgcmV0dXJuIGJhYnlsb25UZXh0dXJlO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX2xvYWRTYW1wbGVyKGNvbnRleHQ6IHN0cmluZywgc2FtcGxlcjogSVNhbXBsZXIpOiBfSVNhbXBsZXJEYXRhIHtcclxuICAgICAgICBpZiAoIXNhbXBsZXIuX2RhdGEpIHtcclxuICAgICAgICAgICAgc2FtcGxlci5fZGF0YSA9IHtcclxuICAgICAgICAgICAgICAgIG5vTWlwTWFwczogc2FtcGxlci5taW5GaWx0ZXIgPT09IFRleHR1cmVNaW5GaWx0ZXIuTkVBUkVTVCB8fCBzYW1wbGVyLm1pbkZpbHRlciA9PT0gVGV4dHVyZU1pbkZpbHRlci5MSU5FQVIsXHJcbiAgICAgICAgICAgICAgICBzYW1wbGluZ01vZGU6IEdMVEZMb2FkZXIuX0dldFRleHR1cmVTYW1wbGluZ01vZGUoY29udGV4dCwgc2FtcGxlciksXHJcbiAgICAgICAgICAgICAgICB3cmFwVTogR0xURkxvYWRlci5fR2V0VGV4dHVyZVdyYXBNb2RlKGAke2NvbnRleHR9L3dyYXBTYCwgc2FtcGxlci53cmFwUyksXHJcbiAgICAgICAgICAgICAgICB3cmFwVjogR0xURkxvYWRlci5fR2V0VGV4dHVyZVdyYXBNb2RlKGAke2NvbnRleHR9L3dyYXBUYCwgc2FtcGxlci53cmFwVCksXHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICByZXR1cm4gc2FtcGxlci5fZGF0YTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIExvYWRzIGEgZ2xURiBpbWFnZS5cclxuICAgICAqIEBwYXJ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bnN0IGRhdGEgPSBuZXcgVWludDhBcnJheShEZWNvZGVCYXNlNjRVcmxUb0JpbmFyeSh1cmkpKTtcclxuICAgICAgICAgICAgdGhpcy5sb2coYCR7Y29udGV4dH06IERlY29kZWQgJHt1cmkuc3Vic3RyKDAsIDY0KX0uLi4gKCR7ZGF0YS5sZW5ndGh9IGJ5dGVzKWApO1xyXG4gICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKGRhdGEpO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgdGhpcy5sb2coYCR7Y29udGV4dH06IExvYWRpbmcgJHt1cml9YCk7XHJcblxyXG4gICAgICAgIHJldHVybiB0aGlzLl9wYXJlbnQucHJlcHJvY2Vzc1VybEFzeW5jKHRoaXMuX3Jvb3RVcmwgKyB1cmkpLnRoZW4oKHVybCkgPT4ge1xyXG4gICAgICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5fcGFyZW50Ll9sb2FkRmlsZShcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9iYWJ5bG9uU2NlbmUsXHJcbiAgICAgICAgICAgICAgICAgICAgdXJsLFxyXG4gICAgICAgICAgICAgICAgICAgIChkYXRhKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fZGlzcG9zZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubG9nKGAke2NvbnRleHR9OiBMb2FkZWQgJHt1cml9ICgkeyhkYXRhIGFzIEFycmF5QnVmZmVyKS5ieXRlTGVuZ3RofSBieXRlcylgKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUobmV3IFVpbnQ4QXJyYXkoZGF0YSBhcyBBcnJheUJ1ZmZlcikpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgICAgICB0cnVlLFxyXG4gICAgICAgICAgICAgICAgICAgIChyZXF1ZXN0KSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChuZXcgTG9hZEZpbGVFcnJvcihgJHtjb250ZXh0fTogRmFpbGVkIHRvIGxvYWQgJyR7dXJpfScke3JlcXVlc3QgPyBcIjogXCIgKyByZXF1ZXN0LnN0YXR1cyArIFwiIFwiICsgcmVxdWVzdC5zdGF0dXNUZXh0IDogXCJcIn1gLCByZXF1ZXN0KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBBZGRzIGEgSlNPTiBwb2ludGVyIHRvIHRoZSBfaW50ZXJuYWxNZXRhZGF0YSBvZiB0aGUgQmFieWxvbiBvYmplY3QgYXQgYDxvYmplY3Q+Ll9pbnRlcm5hbE1ldGFkYXRhLmdsdGYucG9pbnRlcnNgLlxyXG4gICAgICogQHBhcmFtIGJhYnlsb25PYmplY3QgdGhlIEJhYnlsb24gb2JqZWN0IHdpdGggX2ludGVybmFsTWV0YWRhdGFcclxuICAgICAqIEBwYXJhbSBwb2ludGVyIHRoZSBKU09OIHBvaW50ZXJcclxuICAgICAqL1xyXG4gICAgcHVibGljIHN0YXRpYyBBZGRQb2ludGVyTWV0YWRhdGEoYmFieWxvbk9iamVjdDogSVdpdGhNZXRhZGF0YSwgcG9pbnRlcjogc3RyaW5nKTogdm9pZCB7XHJcbiAgICAgICAgYmFieWxvbk9iamVjdC5tZXRhZGF0YSA9IGJhYnlsb25PYmplY3QubWV0YWRhdGEgfHwge307XHJcbiAgICAgICAgY29uc3QgbWV0YWRhdGEgPSAoYmFieWxvbk9iamVjdC5faW50ZXJuYWxNZXRhZGF0YSA9IGJhYnlsb25PYmplY3QuX2ludGVybmFsTWV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ybiBUZXh0dXJlLkxJTkVBUl9ORUFSRVNUX01JUE5FQVJFU1Q7XHJcbiAgICAgICAgICAgICAgICBjYXNlIFRleHR1cmVNaW5GaWx0ZXIuTElORUFSX01JUE1BUF9ORUFSRVNUOlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBUZXh0dXJlLkxJTkVBUl9MSU5FQVJfTUlQTkVBUkVTVDtcclxuICAgICAgICAgICAgICAgIGNhc2UgVGV4dHVyZU1pbkZpbHRlci5ORUFSRVNUX01JUE1BUF9MSU5FQVI6XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFRleHR1cmUuTElORUFSX05FQVJFU1RfTUlQTElORUFSO1xyXG4gICAgICAgICAgICAgICAgY2FzZSBUZXh0dXJlTWluRmlsdGVyLkxJTkVBUl9NSVBNQVBfTElORUFSOlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBUZXh0dXJlLkxJTkVBUl9MSU5FQVJfTUlQTElORUFSO1xyXG4gICAgICAgICAgICAgICAgZGVmYXVsdDpcclxuICAgICAgICAgICAgICAgICAgICBMb2dnZXIuV2FybihgJHtjb250ZXh0fS9taW5GaWx0ZXI6IEludmFsaWQgdmFsdWUgKCR7bWluRmlsdGVyfSlgKTtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gVGV4dHVyZS5MSU5FQVJfTElORUFSX01JUExJTkVBUjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgIGlmIChtYWdGaWx0ZXIgIT09IFRleHR1cmVNYWdGaWx0ZXIuTkVBUkVTVCkge1xyXG4gICAgICAgICAgICAgICAgTG9nZ2VyLldhcm4oYCR7Y29udGV4dH0vbWFnRmlsdGVyOiBJbnZhbGlkIHZhbHVlICgke21hZ0ZpbHRlcn0pYCk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHN3aXRjaCAobWluRmlsdGVyKSB7XHJcbiAgICAgICAgICAgICAgICBjYXNlIFRleHR1cmVNaW5GaWx0ZXIuTkVBUkVTVDpcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gVGV4dHVyZS5ORUFSRVNUX05FQVJFU1Q7XHJcbiAgICAgICAgICAgICAgICBjYXNlIFRleHR1cmVNaW5GaWx0ZXIuTElORUFSOlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBUZXh0dXJlLk5FQVJFU1RfTElORUFSO1xyXG4gICAgICAgICAgICAgICAgY2FzZSBUZXh0dXJlTWluRmlsdGVyLk5FQVJFU1RfTUlQTUFQX05FQVJFU1Q6XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFRleHR1cmUuTkVBUkVTVF9ORUFSRVNUX01JUE5FQVJFU1Q7XHJcbiAgICAgICAgICAgICAgICBjYXNlIFRleHR1cmVNaW5GaWx0ZXIuTElORUFSX01JUE1BUF9ORUFSRVNUOlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBUZXh0dXJlLk5FQVJFU1RfTElORUFSX01JUE5FQVJFU1Q7XHJcbiAgICAgICAgICAgICAgICBjYXNlIFRleHR1cmVNaW5GaWx0ZXIuTkVBUkVTVF9NSVBNQVBfTElORUFSOlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBUZXh0dXJlLk5FQVJFU1RfTkVBUkVTVF9NSVBMSU5FQVI7XHJcbiAgICAgICAgICAgICAgICBjYXNlIFRleHR1cmVNaW5GaWx0ZXIuTElORUFSX01JUE1BUF9MSU5FQVI6XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFRleHR1cmUuTkVBUkVTVF9MSU5FQVJfTUlQTElORUFSO1xyXG4gICAgICAgICAgICAgICAgZGVmYXVsdDpcclxuICAgICAgICAgICAgICAgICAgICBMb2dnZXIuV2FybihgJHtjb250ZXh0fS9taW5GaWx0ZXI6IEludmFsaWQgdmFsdWUgKCR7bWluRmlsdGVyfSlgKTtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gVGV4dHVyZS5ORUFSRVNUX05FQVJFU1RfTUlQTkVBUkVTVDtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIHN0YXRpYyBfR2V0VHlwZWRBcnJheUNvbnN0cnVjdG9yKGNvbnRleHQ6IHN0cmluZywgY29tcG9uZW50VHlwZTogQWNjZXNzb3JDb21wb25lbnRUeXBlKTogVHlwZWRBcnJheUNvbnN0cnVjdG9yIHtcclxuICAgICAgICBzd2l0Y2ggKGNvbXBvbmVudFR5cGUpIHtcclxuICAgICAgICAgICAgY2FzZSBBY2Nlc3NvckNvbXBvbmVudFR5cGUuQllURTpcclxuICAgICAgICAgICAgICAgIHJldHVybiBJbnQ4QXJyYXk7XHJcbiAgICAgICAgICAgIGNhc2UgQWNjZXNzb3JDb21wb25lbnRUeXBlLlVOU0lHTkVEX0JZVEU6XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gVWludDhBcnJheTtcclxuICAgICAgICAgICAgY2FzZSBBY2Nlc3NvckNvbXBvbmVudFR5cGUuU0hPUlQ6XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gSW50MTZBcnJheTtcclxuICAgICAgICAgICAgY2FzZSBBY2Nlc3NvckNvbXBvbmVudFR5cGUuVU5TSUdORURfU0hPUlQ6XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gVWludDE2QXJyYXk7XHJcbiAgICAgICAgICAgIGNhc2UgQWNjZXNzb3JDb21wb25lbnRUeXBlLlVOU0lHTkVEX0lOVDpcclxuICAgICAgICAgICAgICAgIHJldHVybiBVaW50MzJBcnJheTtcclxuICAgICAgICAgICAgY2FzZSBBY2Nlc3NvckNvbXBvbmVudFR5cGUuRkxPQVQ6XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gRmxvYXQzMkFycmF5O1xyXG4gICAgICAgICAgICBkZWZhdWx0OlxyXG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGAke2NvbnRleHR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Lldhcm4oYCR7Y29udGV4dH06IENvcHlpbmcgYnVmZmVyIGFzIGJ5dGUgb2Zmc2V0ICgke2J5dGVPZmZzZXR9KSBpcyBub3QgYSBtdWx0aXBsZSBvZiBjb21wb25lbnQgdHlwZSBieXRlIGxlbmd0aCAoJHtjb21wb25lbnRUeXBlTGVuZ3RofSlgKTtcclxuICAgICAgICAgICAgcmV0dXJuIG5ldyBjb25zdHJ1Y3RvcihidWZmZXIuc2xpY2UoYnl0ZU9mZnNldCwgYnl0ZU9mZnNldCArIGxlbmd0aCAqIGNvbXBvbmVudFR5cGVMZW5ndGgpLCAwKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBuZXcgY29uc3RydWN0b3IoYnVmZmVyLCBieXRlT2Zmc2V0LCBsZW5ndGgpO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgc3RhdGljIF9HZXROdW1Db21wb25lbnRzKGNvbnRleHQ6IHN0cmluZywgdHlwZTogc3RyaW5nKTogbnVtYmVyIHtcclxuICAgICAgICBzd2l0Y2ggKHR5cGUpIHtcclxuICAgICAgICAgICAgY2FzZSBcIlNDQUxBUlwiOlxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIDE7XHJcbiAgICAgICAgICAgIGNhc2UgXCJWRUMyXCI6XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gMjtcclxuICAgICAgICAgICAgY2FzZSBcIlZFQzNcIjpcclxuICAgICAgICAgICAgICAgIHJldHVybiAzO1xyXG4gICAgICAgICAgICBjYXNlIFwiVkVDNFwiOlxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIDQ7XHJcbiAgICAgICAgICAgIGNhc2UgXCJNQVQyXCI6XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gNDtcclxuICAgICAgICAgICAgY2FzZSBcIk1BVDNcIjpcclxuICAgICAgICAgICAgICAgIHJldHVybiA5O1xyXG4gICAgICAgICAgICBjYXNlIFwiTUFUNFwiOlxyXG4gICAgICAgICAg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XJpYWwuX2RhdGEpIHtcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGJhYnlsb25EcmF3TW9kZSBpbiBtYXRlcmlhbC5fZGF0YSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiYWJ5bG9uRGF0YSA9IG1hdGVyaWFsLl9kYXRhW2JhYnlsb25EcmF3TW9kZV07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYmFieWxvbk1lc2ggb2YgYmFieWxvbkRhdGEuYmFieWxvbk1lc2hlcykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gRW5zdXJlIG5vblVuaWZvcm1TY2FsaW5nIGlzIHNldCBpZiBuZWNlc3NhcnkuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uTWVzaC5jb21wdXRlV29ybGRNYXRyaXgodHJ1ZSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmFieWxvbk1hdGVyaWFsID0gYmFieWxvbkRhdGEuYmFieWxvbk1hdGVyaWFsO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvbWlzZXMucHVzaChiYWJ5bG9uTWF0ZXJpYWwuZm9yY2VDb21waWxhdGlvbkFzeW5jKGJhYnlsb25NZXNoKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9taXNlcy5wdXNoKGJhYnlsb25NYXRlcmlhbC5mb3JjZUNvbXBpbGF0aW9uQXN5bmMoYmFieWxvbk1lc2gsIHsgdXNlSW5zdGFuY2VzOiB0cnVlIH0pKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9wYXJlbnQudXNlQ2xpcFBsYW5lKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvbWlzZXMucHVzaChiYWJ5bG9uTWF0ZXJpYWwuZm9yY2VDb21waWxhdGlvbkFzeW5jKGJhYnlsb25NZXNoLCB7IGNsaXBQbGFuZTogdHJ1ZSB9KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvbWlzZXMucHVzaChiYWJ5bG9uTWF0ZXJpYWwuZm9yY2VDb21waWxhdGlvbkFzeW5jKGJhYnlsb25NZXNoLCB7IGNsaXBQbGFuZTogdHJ1ZSwgdXNlSW5zdGFuY2VzOiB0cnVlIH0pKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHByb21pc2VzKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgdGhpcy5fcGFyZW50Ll9lbmRQZXJmb3JtYW5jZUNvdW50ZXIoXCJDb21waWxlIG1hdGVyaWFsc1wiKTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9jb21waWxlU2hhZG93R2VuZXJhdG9yc0FzeW5jKCk6IFByb21pc2U8dm9pZD4ge1xyXG4gICAgICAgIHRoaXMuX3BhcmVudC5fc3RhcnRQZXJmb3JtYW5jZUNvdW50ZXIoXCJDb21waWxlIHNoYWRvdyBnZW5lcmF0b3JzXCIpO1xyXG5cclxuICAgICAgICBjb25zdCBwcm9taXNlcyA9IG5ldyBBcnJheTxQcm9taXNlPGFueT4+KCk7XHJcblxyXG4gICAgICAgIGNvbnN0IGxpZ2h0cyA9IHRoaXMuX2JhYnlsb25TY2VuZS5saWdodHM7XHJcbiAgICAgICAgZm9yIChjb25zdCBsaWdodCBvZiBsaWdodHMpIHtcclxuICAgICAgICAgICAgY29uc3QgZ2VuZXJhdG9yID0gbGlnaHQuZ2V0U2hhZG93R2VuZXJhdG9yKCk7XHJcbiAgICAgICAgICA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dCBpZCA9IGAke2V4dGVuc2lvbi5uYW1lfS4ke2Z1bmN0aW9uTmFtZX1gO1xyXG4gICAgICAgICAgICAgICAgY29uc3QgbG9hZGVyUHJvcGVydHkgPSBwcm9wZXJ0eSBhcyBJTG9hZGVyUHJvcGVydHk7XHJcbiAgICAgICAgICAgICAgICBsb2FkZXJQcm9wZXJ0eS5fYWN0aXZlTG9hZGVyRXh0ZW5zaW9uRnVuY3Rpb25zID0gbG9hZGVyUHJvcGVydHkuX2FjdGl2ZUxvYWRlckV4dGVuc2lvbkZ1bmN0aW9ucyB8fCB7fTtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGFjdGl2ZUxvYWRlckV4dGVuc2lvbkZ1bmN0aW9ucyA9IGxvYWRlclByb3BlcnR5Ll9hY3RpdmVMb2FkZXJFeHRlbnNpb25GdW5jdGlvbnM7XHJcbiAgICAgICAgICAgICAgICBpZiAoIWFjdGl2ZUxvYWRlckV4dGVuc2lvbkZ1bmN0aW9uc1tpZF0pIHtcclxuICAgICAgICAgICAgICAgICAgICBhY3RpdmVMb2FkZXJFeHRlbnNpb25GdW5jdGlvbnNbaWRdID0gdHJ1ZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgdHJ5IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVzdWx0ID0gYWN0aW9uQXN5bmMoZXh0ZW5zaW9uKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH0gZmluYWxseSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBhY3RpdmVMb2FkZXJFeHRlbnNpb25GdW5jdGlvbnNbaWRdO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICA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hbmdlbnQgPyBrZXkuaW5UYW5nZW50W3RhcmdldEluZGV4XSA6IHVuZGVmaW5lZCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGtleS52YWx1ZVt0YXJnZXRJbmRleF0sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG91dFRhbmdlbnQ6IGtleS5vdXRUYW5nZW50ID8ga2V5Lm91dFRhbmdlbnRbdGFyZ2V0SW5kZXhdIDogdW5kZWZpbmVkLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpbnRlcnBvbGF0aW9uOiBrZXkuaW50ZXJwb2xhdGlvbixcclxuICAgICAgICAgICAgICAgICAgICB9KSlcclxuICAgICAgICAgICAgICAgICk7XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKHRhcmdldC5fcHJpbWl0aXZlQmFieWxvbk1lc2hlcykge1xyXG4gICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYmFieWxvbk1lc2ggb2YgdGFyZ2V0Ll9wcmltaXRpdmVCYWJ5bG9uTWVzaGVzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYWJ5bG9uTWVzaC5tb3JwaFRhcmdldE1hbmFnZXIpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1vcnBoVGFyZ2V0ID0gYmFieWxvbk1lc2gubW9ycGhUYXJnZXRNYW5hZ2VyLmdldFRhcmdldCh0YXJnZXRJbmRleCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiYWJ5bG9uQW5pbWF0aW9uQ2xvbmUgPSBiYWJ5bG9uQW5pbWF0aW9uLmNsb25lKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb3JwaFRhcmdldC5hbmltYXRpb25zLnB1c2goYmFieWxvbkFuaW1hdGlvbkNsb25lKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrKG1vcnBoVGFyZ2V0LCBiYWJ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JcbiAgICAgICAgICAgIGlmICh0aGlzLnVzZVJhbmdlUmVxdWVzdHMpIHtcclxuICAgICAgICAgICAgICAgIGlmICh0aGlzLnZhbGlkYXRlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgTG9nZ2VyLldhcm4oXCJnbFRGIHZhbGlkYXRpb24gaXMgbm90IHN1cHBvcnRlZCB3aGVuIHJhbmdlIHJlcXVlc3RzIGFyZSBlbmFibGVkXCIpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGNvbnN0IGZpbGVSZXF1ZXN0OiBJRmlsZVJlcXVlc3QgPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYWJvcnQ6ICgpID0+IHt9LFxyXG4gICAgICAgICAgICAgICAgICAgIG9uQ29tcGxldGVPYnNlcnZhYmxlOiBuZXcgT2JzZXJ2YWJsZTxJRmlsZVJlcXVlc3Q+KCksXHJcbiAgICAgICAgICAgICAgICB9O1xyXG5cclxuICAgICAgICAgICAgICAgIGNvbnN0IGRhdGFCdWZmZXIgPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmVhZEFzeW5jOiAoYnl0ZU9mZnNldDogbnVtYmVyLCBieXRlTGVuZ3RoOiBudW1iZXIpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQcm9taXNlPEFycmF5QnVmZmVyVmlldz4oKHJlc29sdmUsIHJlamVjdCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZEZpbGUoXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NlbmUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlsZU9yVXJsIGFzIEZpbGUgfCBzdHJpbmcsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGRhdGEpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShuZXcgVWludDhBcnJheShkYXRhIGFzIEFycmF5QnVmZmVyKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnVlLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChlcnJvcikgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWplY3QoZXJyb3IpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHdlYlJlcXVlc3QpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2ViUmVxdWVzdC5zZXRSZXF1ZXN0SGVhZGVyKFwiUmFuZ2VcIiwgYGJ5dGVzPSR7Ynl0ZU9mZnNldH0tJHtieXRlT2Zmc2V0ICsgYnl0ZUxlbmd0aCAtIDF9YCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgICAgICBieXRlTGVuZ3RoOiAwLFxyXG4gICAgICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgICAgICB0aGlzLl91bnBhY2tCaW5hcnlBc3luYyhuZXcgRGF0YVJlYWRlcihkYXRhQnVmZmVyKSkudGhlbihcclxuICAgICAgICAgICAgICAgICAgICAobG9hZGVyRGF0YSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBmaWxlUmVxdWVzdC5vbkNvbXBsZXRlT2JzZXJ2YWJsZS5ub3RpZnlPYnNlcnZlcnMoZmlsZVJlcXVlc3QpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBvblN1Y2Nlc3MobG9hZGVyRGF0YSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgICAgICBvbkVycm9yID8gKGVycm9yKSA9PiBvbkVycm9yKHVuZGVmaW5lZCwgZXJyb3IpIDogdW5kZWZpbmVkXHJcbiAgICAgICAgICAgICAgICApO1xyXG5cclxuICAgICAgICAgICAgICAgIHJldHVybiBmaWxlUmVxdWVzdDtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2xvYWRGaWxlKFxyXG4gICAgICAgICAgICAgICAgc2NlbmUsXHJcbiAgICAgICAgICAgICAgICBmaWxlT3JVcmwgYXMgRmlsZSB8IHN0cmluZyxcclxuICAgICAgICAgICAgICAgIChkYXRhKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fdmFsaWRhdGUoc2NlbmUsIG5ldyBVaW50OEFycmF5KGRhdGEgYXMgQXJyYXlCdWZmZXIsIDAsIChkYXRhIGFzIEFycmF5QnVmZmVyKS5ieXRlTGVuZ3RoKSwgcm9vdFVybCwgZmlsZU5hbWUpO1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3VucGFja0JpbmFyeUFzeW5jKFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXcgRGF0YVJlYWRlcih7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkQXN5bmM6IChieXRlT2Zmc2V0LCBieXRlTGVuZ3RoKSA9PiByZWFkQXN5bmMoZGF0YSBhcyBBcnJheUJ1ZmZlciwgYnl0ZU9mZnNldCwgYnl0ZUxlbmd0aCksXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlTGVuZ3RoOiAoZGF0YSBhcyBBcnJheUJ1ZmZlcikuYnl0ZUxlbmd0aCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgICAgICAgICApLnRoZW4oXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIChsb2FkZXJEYXRhKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvblN1Y2Nlc3MobG9hZGVyRGF0YSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG9uRXJyb3IgPyAoZXJyb3IpID0+IG9uRXJyb3IodW5kZWZpbmVkLCBlcnJvcikgOiB1bmRlZmluZWRcclxuICAgICAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgIHRydWUsXHJcbiAgICAgICAgICAgICAgICBvbkVycm9yXHJcbiAgICAgICAgICAgICk7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2xvYWRGaWxlKFxyXG4gICAgICAgICAgICAgICAgc2NlbmUsXHJcbiAgICAgICAgICAgICAgICBmaWxlT3JVcmwsXHJcbiAgICAgICAgICAgICAgICAoZGF0YSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3ZhbGlkYXRlKHNjZW5lLCBkYXRhIGFzIHN0cmluZywgcm9vdFVybCwgZmlsZU5hbWUpO1xyXG4gICAgICAgICAgICAgICAgICAgIG9uU3VjY2Vzcyh7IGpzb246IHRoaXMuX3BhcnNlSnNvbihkYXRhIGFzIHN0cmluZykgfSk7XHJcbiAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgZmFsc2UsXHJcbiAgICAgICAgICAgICAgICBvbkVycm9yXHJcbiAgICAgICAgICAgICk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX2xvYWRCaW5hcnkoXHJcbiAgICAgICAgc2NlbmU6IFNjZW5lLFxyXG4gICAgICAgIGRhdGE6IEFycmF5QnVmZmVyVmlldyxcclxuICAgICAgICByb290VXJsOiBzdHJpbmcsXHJcbiAgICAgICAgb25TdWNjZXNzOiAoZGF0YTogYW55LCByZXNwb25zZVVSTD86IHN0cmluZykgPT4gdm9pZCxcclxuICAgICAgICBvbkVycm9yPzogKHJlcXVlc3Q/OiBXZWJSZXF1ZXN0LCBleGNlcHRpb24/OiBMb2FkRmlsZUVycm9yKSA9PiB2b2lkLFxyXG4gICAgICAgIGZpbGVOYW1lPzogc3RyaW5nXHJcbiAgICApOiB2b2lkIHtcclxuICAgICAgICB0aGlzLl92YWxpZGF0ZShzY2VuZSwgbmV3IFVpbnQ4QXJyYXkoZGF0YS5idWZmZXIsIGRhdGEuYnl0ZU9mZnNldCwgZGF0YS5ieXRlTGVuZ3RoKSwgcm9vdFVybCwgZmlsZU5hbWUpO1xyXG4gICAgICAgIHRoaXMuX3VucGFja0JpbmFyeUFzeW5jKFxyXG4gICAgICAgICAgICBuZXcgRGF0YVJlYWRlcih7XHJcbiAgICAgICAgICAgICAgICByZWFkQXN5bmM6IChieXRlT2Zmc2V0LCBieXRlTGVuZ3RoKSA9PiByZWFkVmlld0FzeW5jKGRhdGEsIGJ5dGVPZmZzZXQsIGJ5dGVMZW5ndGgpLFxyXG4gICAgICAgICAgICAgICAgYnl0ZUxlbmd0aDogZGF0YS5ieXRlTGVuZ3RoLFxyXG4gICAgICAgICAgICB9KVxyXG4gICAgICAgICkudGhlbihcclxuICAgICAgICAgICAgKGxvYWRlckRhdGEpID0+IHtcclxuICAgICAgICAgICAgICAgIG9uU3VjY2Vzcyhsb2FkZXJEYXRhKTtcclxuICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgb25FcnJvciA/IChlcnJvcikgPT4gb25FcnJvcih1bmRlZmluZWQsIGVycm9yKSA6IHVuZGVmaW5lZFxyXG4gICAgICAgICk7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBAaW50ZXJuYWxcclxuICAgICAqL1xyXG4gICAgcHVibGljIGltcG9ydE1lc2hBc3luYyhcclxuICAgICAgICBtZXNoZXNOYW1lczogYW55LFxyXG4gICAgICAgIHNjZW5lOiBTY2VuZSxcclxuIC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uX2dldExvYWRlcihkYXRhKTtcclxuXHJcbiAgICAgICAgICAgIC8vIFByZXBhcmUgdGhlIGFzc2V0IGNvbnRhaW5lci5cclxuICAgICAgICAgICAgY29uc3QgY29udGFpbmVyID0gbmV3IEFzc2V0Q29udGFpbmVyKHNjZW5lKTtcclxuXHJcbiAgICAgICAgICAgIC8vIEdldCBtYXRlcmlhbHMvdGV4dHVyZXMgd2hlbiBsb2FkaW5nIHRvIGFkZCB0byBjb250YWluZXJcclxuICAgICAgICAgICAgY29uc3QgbWF0ZXJpYWxzOiBBcnJheTxNYXRlcmlhbD4gPSBbXTtcclxuICAgICAgICAgICAgdGhpcy5vbk1hdGVyaWFsTG9hZGVkT2JzZXJ2YWJsZS5hZGQoKG1hdGVyaWFsKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBtYXRlcmlhbHMucHVzaChtYXRlcmlhbCk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICBjb25zdCB0ZXh0dXJlczogQXJyYXk8QmFzZVRleHR1cmU+ID0gW107XHJcbiAgICAgICAgICAgIHRoaXMub25UZXh0dXJlTG9hZGVkT2JzZXJ2YWJsZS5hZGQoKHRleHR1cmUpID0+IHtcclxuICAgICAgICAgICAgICAgIHRleHR1cmVzLnB1c2godGV4dHVyZSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICBjb25zdCBjYW1lcmFzOiBBcnJheTxDYW1lcmE+ID0gW107XHJcbiAgICAgICAgICAgIHRoaXMub25DYW1lcmFMb2FkZWRPYnNlcnZhYmxlLmFkZCgoY2FtZXJhKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBjYW1lcmFzLnB1c2goY2FtZXJhKTtcclxuICAgICAgICAgICAgfSk7XHJcblxyXG4gICAgICAgICAgICBjb25zdCBtb3JwaFRhcmdldE1hbmFnZXJzOiBBcnJheTxNb3JwaFRhcmdldE1hbmFnZXI+ID0gW107XHJcbiAgICAgICAgICAgIHRoaXMub25NZXNoTG9hZGVkT2JzZXJ2YWJsZS5hZGQoKG1lc2gpID0+IHtcclxuICAgICAgICAgICAgICAgIGlmIChtZXNoLm1vcnBoVGFyZ2V0TWFuYWdlcikge1xyXG4gICAgICAgICAgICAgICAgICAgIG1vcnBoVGFyZ2V0TWFuYWdlcnMucHVzaChtZXNoLm1vcnBoVGFyZ2V0TWFuYWdlcik7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2xvYWRlci5pbXBvcnRNZXNoQXN5bmMobnVsbCwgc2NlbmUsIGNvbnRhaW5lciwgZGF0YSwgcm9vdFVybCwgb25Qcm9ncmVzcywgZmlsZU5hbWUpLnRoZW4oKHJlc3VsdCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgQXJyYXkucHJvdG90eXBlLnB1c2guYXBwbHkoY29udGFpbmVyLmdlb21ldHJpZXMsIHJlc3VsdC5nZW9tZXRyaWVzKTtcclxuICAgICAgICAgICAgICAgIEFycmF5LnByb3RvdHlwZS5wdXNoLmFwcGx5KGNvbnRhaW5lci5tZXNoZXMsIHJlc3VsdC5tZXNoZXMpO1xyXG4gICAgICAgICAgICAgICAgQXJyYXkucHJvdG90eXBlLnB1c2guYXBwbHkoY29udGFpbmVyLnBhcnRpY2xlU3lzdGVtcywgcmVzdWx0LnBhcnRpY2xlU3lzdGVtcyk7XHJcbiAgICAgICAgICAgICAgICBBcnJheS5wcm90b3R5cGUucHVzaC5hcHBseShjb250YWluZXIuc2tlbGV0b25zLCByZXN1bHQuc2tlbGV0b25zKTtcclxuICAgICAgICAgICAgICAgIEFycmF5LnByb3RvdHlwZS5wdXNoLmFwcGx5KGNvbnRhaW5lci5hbmltYXRpb25Hcm91cHMsIHJlc3VsdC5hbmltYXRpb25Hcm91cHMpO1xyXG4gICAgICAgICAgICAgICAgQXJyYXkucHJvdG90eXBlLnB1c2guYXBwbHkoY29udGFpbmVyLm1hdGVyaWFscywgbWF0ZXJpYWxzKTtcclxuICAgICAgICAgICAgICAgIEFycmF5LnByb3RvdHlwZS5wdXNoLmFwcGx5KGNvbnRhaW5lci50ZXh0dXJlcywgdGV4dHVyZXMpO1xyXG4gICAgICAgICAgICAgICAgQXJyYXkucHJvdG90eXBlLnB1c2guYXBwbHkoY29udGFpbmVyLmxpZ2h0cywgcmVzdWx0LmxpZ2h0cyk7XHJcbiAgICAgICAgICAgICAgICBBcnJheS5wcm90b3R5cGUucHVzaC5hcHBseShjb250YWluZXIudHJhbnNmb3JtTm9kZXMsIHJlc3VsdC50cmFuc2Zvcm1Ob2Rlcyk7XHJcbiAgICAgICAgICAgICAgICBBcnJheS5wcm90b3R5cGUucHVzaC5hcHBseShjb250YWluZXIuY2FtZXJhcywgY2FtZXJhcyk7XHJcbiAgICAgICAgICAgICAgICBBcnJheS5wcm90b3R5cGUucHVzaC5hcHBseShjb250YWluZXIubW9ycGhUYXJnZXRNYW5hZ2VycywgbW9ycGhUYXJnZXRNYW5hZ2Vycyk7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gY29udGFpbmVyO1xyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIEBpbnRlcm5hbFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgY2FuRGlyZWN0TG9hZChkYXRhOiBzdHJpbmcpOiBib29sZWFuIHtcclxuICAgICAgICByZXR1cm4gKFxyXG4gICAgICAgICAgICAoZGF0YS5pbmRleE9mKFwiYXNzZXRcIikgIT09IC0xICYmIGRhdGEuaW5kZXhPZihcInZlcnNpb25cIikgIT09IC0xKSB8fFxyXG4gICAgICAgICAgICBkYXRhLnN0YXJ0c1dpdGgoXCJkYXRhOmJhc2U2NCxcIiArIEdMVEZGaWxlTG9hZGVyLl9NYWdpY0Jhc2U2NEVuY29kZWQpIHx8IC8vIHRoaXMgaXMgdGVjaG5pY2FsbHkgaW5jb3JyZWN0LCBidXQ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XG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQGludGVybmFsXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBfbG9hZEZpbGUoXHJcbiAgICAgICAgc2NlbmU6IFNjZW5lLFxyXG4gICAgICAgIGZpbGVPclVybDogRmlsZSB8IHN0cmluZyxcclxuICAgICAgICBvblN1Y2Nlc3M6IChkYXRhOiBzdHJpbmcgfCBBcnJheUJ1ZmZlcikgPT4gdm9pZCxcclxuICAgICAgICB1c2VBcnJheUJ1ZmZlcj86IGJvb2xlYW4sXHJcbiAgICAgICAgb25FcnJvcj86IChyZXF1ZXN0PzogV2ViUmVxdWVzdCkgPT4gdm9pZCxcclxuICAgICAgICBvbk9wZW5lZD86IChyZXF1ZXN0OiBXZWJSZXF1ZXN0KSA9PiB2b2lkXHJcbiAgICApOiBJRmlsZVJlcXVlc3Qge1xyXG4gICAgICAgIGNvbnN0IHJlcXVlc3QgPSBzY2VuZS5fbG9hZEZpbGUoXHJcbiAgICAgICAgICAgIGZpbGVPclVybCxcclxuICAgICAgICAgICAgb25TdWNjZXNzLFxyXG4gICAgICAgICAgICAoZXZlbnQpID0+IHtcclxuICAgICAgICAgICAgICAgIHRoaXMuX29uUHJvZ3Jlc3MoZXZlbnQsIHJlcXVlc3QpO1xyXG4gICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICB0cnVlLFxyXG4gICAgICAgICAgICB1c2VBcnJheUJ1ZmZlcixcclxuICAgICAgICAgICAgb25FcnJvcixcclxuICAgICAgICAgICAgb25PcGVuZWRcclxuICAgICAgICApIGFzIElGaWxlUmVxdWVzdEluZm87XHJcbiAgICAgICAgcmVxdWVzdC5vbkNvbXBsZXRlT2JzZXJ2YWJsZS5hZGQoKHJlcXVlc3QpID0+IHtcclxuICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMuc3BsaWNlKHRoaXMuX3JlcXVlc3RzLmluZGV4T2YocmVxdWVzdCksIDEpO1xyXG4gICAgICAgIH0pO1xyXG4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Fzc2V0LmdlbmVyYXRvciAmJiB0aGlzLl9sb2coYEFzc2V0IGdlbmVyYXRvcjogJHthc3NldC5nZW5lcmF0b3J9YCk7XHJcblxyXG4gICAgICAgIGNvbnN0IHZlcnNpb24gPSBHTFRGRmlsZUxvYWRlci5fcGFyc2VWZXJzaW9uKGFzc2V0LnZlcnNpb24pO1xyXG4gICAgICAgIGlmICghdmVyc2lvbikge1xyXG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJJbnZhbGlkIHZlcnNpb246IFwiICsgYXNzZXQudmVyc2lvbik7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAoYXNzZXQubWluVmVyc2lvbiAhPT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IG1pblZlcnNpb24gPSBHTFRGRmlsZUxvYWRlci5fcGFyc2VWZXJzaW9uKGFzc2V0Lm1pblZlcnNpb24pO1xyXG4gICAgICAgICAgICBpZiAoIW1pblZlcnNpb24pIHtcclxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIkludmFsaWQgbWluaW11bSB2ZXJzaW9uOiBcIiArIGFzc2V0Lm1pblZlcnNpb24pO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAoR0xURkZpbGVMb2FkZXIuX2NvbXBhcmVWZXJzaW9uKG1pblZlcnNpb24sIHsgbWFqb3I6IDIsIG1pbm9yOiAwIH0pID4gMCkge1xyXG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiSW5jb21wYXRpYmxlIG1pbmltdW0gdmVyc2lvbjogXCIgKyBhc3NldC5taW5WZXJzaW9uKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgY29uc3QgY3JlYXRlTG9hZGVyczogeyBba2V5OiBudW1iZXJdOiAocGFyZW50OiBHTFRGRmlsZUxvYWRlcikgPT4gSUdMVEZMb2FkZXIgfSA9IHtcclx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bmd0aDogJHtsZW5ndGh9ICE9ICR7ZGF0YVJlYWRlci5idWZmZXIuYnl0ZUxlbmd0aH1gKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgbGV0IHVucGFja2VkOiBQcm9taXNlPElHTFRGTG9hZGVyRGF0YT47XHJcbiAgICAgICAgICAgIHN3aXRjaCAodmVyc2lvbikge1xyXG4gICAgICAgICAgICAgICAgY2FzZSAxOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgdW5wYWNrZWQgPSB0aGlzLl91bnBhY2tCaW5hcnlWMUFzeW5jKGRhdGFSZWFkZXIsIGxlbmd0aCk7XHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBjYXNlIDI6IHtcclxuICAgICAgICAgICAgICAgICAgICB1bnBhY2tlZCA9IHRoaXMuX3VucGFja0JpbmFyeVYyQXN5bmMoZGF0YVJlYWRlciwgbGVuZ3RoKTtcclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGRlZmF1bHQ6IHtcclxuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJVbnN1cHBvcnRlZCB2ZXJzaW9uOiBcIiArIHZlcnNpb24pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICB0aGlzLl9lbmRQZXJmb3JtYW5jZUNvdW50ZXIoXCJVbnBhY2sgQmluYXJ5XCIpO1xyXG5cclxuICAgICAgICAgICAgcmV0dXJuIHVucGFja2VkO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX3VucGFja0JpbmFyeVYxQXN5bmMoZGF0YVJlYWRlcjogRGF0YVJlYWRlciwgbGVuZ3RoOiBudW1iZXIpOiBQcm9taXNlPElHTFRGTG9hZGVyRGF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kZXIuYnl0ZU9mZnNldDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YS5iaW4gPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkQXN5bmM6IChieXRlT2Zmc2V0LCBieXRlTGVuZ3RoKSA9PiBkYXRhUmVhZGVyLmJ1ZmZlci5yZWFkQXN5bmMoc3RhcnRCeXRlT2Zmc2V0ICsgYnl0ZU9mZnNldCwgYnl0ZUxlbmd0aCksXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlTGVuZ3RoOiBjaHVua0xlbmd0aCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVJlYWRlci5za2lwQnl0ZXMoY2h1bmtMZW5ndGgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBpZ25vcmUgdW5yZWNvZ25pemVkIGNodW5rRm9ybWF0XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFSZWFkZXIuc2tpcEJ5dGVzKGNodW5rTGVuZ3RoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGlmIChkYXRhUmVhZGVyLmJ5dGVPZmZzZXQgIT09IGxlbmd0aCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBkYXRhUmVhZGVyLmxvYWRBc3luYyg4KS50aGVuKHJlYWRBc3luYyk7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZShkYXRhKTtcclxuICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgIHJldHVybiByZWFkQXN5bmMoKTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIHN0YXRpYyBfcGFyc2VWZXJzaW9uKHZlcnNpb246IHN0cmluZyk6IE51bGxhYmxlPHsgbWFqb3I6IG51bWJlcjsgbWlub3I6IG51bWJlciB9PiB7XHJcbiAgICAgICAgaWYgKHZlcnNpb24gPT09IFwiMS4wXCIgfHwgdmVyc2lvbiA9PT0gXCIxLjAuMVwiKSB7XHJcbiAgICAgICAgICAgIHJldHVybiB7XHJcbiAgICAgICAgICAgICAgICBtYWpvcjogMSxcclxuICAgICAgICAgICAgICAgIG1pbm9yOiAwLFxyXG4gICAgICAgICAgICB9O1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgY29uc3QgbWF0Y2ggPSAodmVyc2lvbiArIFwiXCIpLm1hdGNoKC9eKFxcZCspXFwuKFxcZCspLyk7XHJcbiAgICAgICAgaWYgKCFtYXRjaCkge1xyXG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiB7XHJcbiAgICAgICAgICAgIG1ham9yOiBwYXJzZUludChtYXRjaFsxXSksXHJcbiAgICAgICAgICAgIG1pbm9yOiBwYXJzZUludChtYXRjaFsyXSksXHJcbiAgICAgICAgfTtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIHN0YXRpYyBfY29tcGFyZVZlcnNpb24oYTogeyBtYWpvcjogbnVtYmVyOyBtaW5vcjogbnVtYmVyIH0sIGI6IHsgbWFqb3I6IG51bWJlcjsgbWlub3I6IG51bWJlciB9KTogbnVtYmVyIHtcclxuICAgICAgICBpZiAoYS5tYWpvciA+IGIubWFqb3IpIHtcclxuICAgICAgICAgICAgcmV0dXJuIDE7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmIChhLm1ham9yIDwgYi5tYWpvcikge1xyXG4gICAgICAgICAgICByZXR1cm4gLTE7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmIChhLm1pbm9yID4gYi5taW5vcikge1xyXG4gICAgICAgICAgICByZXR1cm4gMTtcclxuICAgICAgICB9XHJcbiAgICAgICAgaWYgKGEubWlub3IgPCBiLm1pbm9yKSB7XHJcbiAgICAgICAgICAgIHJldHVybiAtMTtcclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIDA7XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBzdGF0aWMgcmVhZG9ubHkgX2xvZ1NwYWNlcyA9IFwiICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIjtcclxuICAgIHByaXZhdGUgX2xvZ0luZGVudExldmVsID0gMDtcclxuICAgIHByaXZhdGUgX2xvZ2dpbmdFbmFibGVkID0gZmFsc2U7XHJcblxyXG4gICAgLyoqIEBpbnRlcm5hbCAqL1xyXG4gICAgcHVibGljIF9sb2cgPSB0aGlzLl9sb2dEaXNhYmxlZDtcclxuXHJcbiAgICAvKipcclxuICAgICAqIEBpbnRlcm5hbFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgX2xvZ09wZW4obWVzc2FnZTogc3RyaW5nKTogdm9pZCB7XHJcbiAgICAgICAgdGhpcy5fbG9nKG1lc3NhZ2UpO1xyXG4gICAgICAgIHRoaXMuX2xvZ0luZGVudExldmVsKys7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqIEBpbnRlcm5hbCAqL1xyXG4gICAgcHVibGljIF9sb2dDbG9zZSgpOiB2b2lkIHtcclxuICAgICAgICAtLXRoaXMuX2xvZ0luZGVudExldmVsO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX2xvZ0VuYWJsZWQobWVzc2FnZTogc3RyaW5nKTogdm9pZCB7XHJcbiAgICAgICAgY29uc3Qgc3BhY2VzID0gR0xURkZpbGVMb2FkZXIuX2xvZ1NwYWNlcy5zdWJzdHIoMCwgdGhpcy5fbG9nSW5kZW50TGV2ZWwgKiAyKTtcclxuICAgIC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5jKFxyXG4gICAgICAgICAgICAgICAgICAgIGRhdGEuZGF0YSxcclxuICAgICAgICAgICAgICAgICAgICBkYXRhLnJvb3RVcmwsXHJcbiAgICAgICAgICAgICAgICAgICAgZGF0YS5maWxlTmFtZSxcclxuICAgICAgICAgICAgICAgICAgICAodXJpKSA9PlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbmRleCA9IHBlbmRpbmdFeHRlcm5hbFJlc291cmNlcy5sZW5ndGg7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZW5kaW5nRXh0ZXJuYWxSZXNvdXJjZXMucHVzaCh7IHJlc29sdmUsIHJlamVjdCB9KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvc3RNZXNzYWdlKHsgaWQ6IFwiZ2V0RXh0ZXJuYWxSZXNvdXJjZVwiLCBpbmRleDogaW5kZXgsIHVyaTogdXJpIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgKS50aGVuKFxyXG4gICAgICAgICAgICAgICAgICAgICh2YWx1ZSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBwb3N0TWVzc2FnZSh7IGlkOiBcInZhbGlkYXRlLnJlc29sdmVcIiwgdmFsdWU6IHZhbHVlIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICAgICAgKHJlYXNvbikgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBwb3N0TWVzc2FnZSh7IGlkOiBcInZhbGlkYXRlLnJlamVjdFwiLCByZWFzb246IHJlYXNvbiB9KTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAg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1xyXG4gICAgICAgIGlmICh0eXBlb2YgV29ya2VyID09PSBcImZ1bmN0aW9uXCIpIHtcclxuICAgICAgICAgICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IHdvcmtlckNvbnRlbnQgPSBgJHt2YWxpZGF0ZUFzeW5jfSgke3dvcmtlckZ1bmN9KSgpYDtcclxuICAgICAgICAgICAgICAgIGNvbnN0IHdvcmtlckJsb2JVcmwgPSBVUkwuY3JlYXRlT2JqZWN0VVJMKG5ldyBCbG9iKFt3b3JrZXJDb250ZW50XSwgeyB0eXBlOiBcImFwcGxpY2F0aW9uL2phdmFzY3JpcHRcIiB9KSk7XHJcbiAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXIgPSBuZXcgV29ya2VyKHdvcmtlckJsb2JVcmwpO1xyXG5cclxuICAgICAgICAgICAgICAgIGNvbnN0IG9uRXJyb3IgPSAoZXJyb3I6IEVycm9yRXZlbnQpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcihcImVycm9yXCIsIG9uRXJyb3IpO1xyXG4gICAgICAgICAgICAgICAgICAgIHdvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKFwibWVzc2FnZVwiLCBvbk1lc3NhZ2UpO1xyXG4gICAgICAgICAgICAgICAgICAgIHJlamVjdChlcnJvcik7XHJcbiAgICAgICAgICAgICAgICB9O1xyXG5cclxuICAgICAgICAgICAgICAgIGNvbnN0IG9uTWVzc2FnZSA9IChtZXNzYWdlOiBNZXNzYWdlRXZlbnQpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gbWVzc2FnZS5kYXRhO1xyXG4gICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZGF0YS5pZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFwiZ2V0RXh0ZXJuYWxSZXNvdXJjZVwiOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXRFeHRlcm5hbFJlc291cmNlKGRhdGEudXJpKS50aGVuKFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICh2YWx1ZSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZDogXCJnZXRFeHRlcm5hbFJlc291cmNlLnJlc29sdmVcIiwgaW5kZXg6IGRhdGEuaW5kZXgsIHZhbHVlOiB2YWx1ZSB9LCBbdmFsdWVdKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChyZWFzb24pID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IFwiZ2V0RXh0ZXJuYWxSZXNvdXJjZS5yZWplY3RcIiwgaW5kZXg6IGRhdGEuaW5kZXgsIHJlYXNvbjogcmVhc29uIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFwidmFsaWRhdGUucmVzb2x2ZVwiOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcihcImVycm9yXCIsIG9uRXJyb3IpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoXCJtZXNzYWdlXCIsIG9uTWVzc2FnZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKGRhdGEudmFsdWUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyLnRlcm1pbmF0ZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcInZhbGlkYXRlLnJlamVjdFwiOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcihcImVycm9yXCIsIG9uRXJyb3IpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoXCJtZXNzYWdlXCIsIG9uTWVzc2FnZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWplY3QoZGF0YS5yZWFzb24pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyLnRlcm1pbmF0ZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgICAgICB3b3JrZXIuYWRkRXZlbnRMaXN0ZW5lcihcImVycm9yXCIsIG9uRXJyb3IpO1xyXG4gICAgICAgICAgICAgICAgd29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoXCJtZXNzYWdlXCIsIG9uTWVzc2FnZSk7XHJcblxyXG4gICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IFwiaW5pdFwiLCB1cmw6IFRvb2xzLkdldEJhYnlsb25TY3JpcHRVUkwodGhpcy5Db25maWd1cmF0aW9uLnVybCkgfSk7XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKEFycmF5QnVmZmVyLmlzVmlldyhkYXRhKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIC8vIFNsaWNlIHRoZSBkYXRh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OiB0cnVlIH0pO1xufTsiLCJpbXBvcnQgKiBhcyBsb2FkZXJzIGZyb20gXCJAbHRzL2xvYWRlcnMvbGVnYWN5L2xlZ2FjeS1nbFRGMkZpbGVMb2FkZXJcIjtcclxuZXhwb3J0IHsgbG9hZGVycyB9O1xyXG5leHBvcnQgZGVmYXVsdCBsb2FkZXJzO1xyXG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0= \ No newline at end of file diff --git a/libs/babylonjs/6.46.0/babylon.glTF2FileLoader.min.js b/libs/babylonjs/6.46.0/babylon.glTF2FileLoader.min.js new file mode 100644 index 00000000..868b03be --- /dev/null +++ b/libs/babylonjs/6.46.0/babylon.glTF2FileLoader.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-loaders",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-loaders"]=t(require("babylonjs")):e.LOADERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={597:t=>{t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{r.d(o,{default:()=>ct});var e={};r.r(e),r.d(e,{GLTFValidation:()=>p});var t={};r.r(t),r.d(t,{GLTFFileLoader:()=>m,GLTFLoaderAnimationStartMode:()=>h,GLTFLoaderCoordinateSystemMode:()=>d,GLTFLoaderState:()=>f});var n={};r.r(n),r.d(n,{EXT_lights_image_based:()=>P,EXT_mesh_gpu_instancing:()=>I,EXT_meshopt_compression:()=>F,EXT_texture_webp:()=>k,ExtrasAsMetadata:()=>ot,KHR_animation_pointer:()=>Ve,KHR_draco_mesh_compression:()=>D,KHR_interactivity:()=>nt,KHR_lights:()=>U,KHR_materials_anisotropy:()=>Q,KHR_materials_clearcoat:()=>W,KHR_materials_dispersion:()=>me,KHR_materials_emissive_strength:()=>$,KHR_materials_ior:()=>ae,KHR_materials_iridescence:()=>X,KHR_materials_pbrSpecularGlossiness:()=>H,KHR_materials_sheen:()=>te,KHR_materials_specular:()=>re,KHR_materials_translucency:()=>he,KHR_materials_transmission:()=>ue,KHR_materials_unlit:()=>q,KHR_materials_variants:()=>se,KHR_materials_volume:()=>pe,KHR_mesh_quantization:()=>be,KHR_texture_basisu:()=>ge,KHR_texture_transform:()=>Te,KHR_xmp_json_ld:()=>we,MSFT_audio_emitter:()=>Ke,MSFT_lod:()=>je,MSFT_minecraftMesh:()=>Ye,MSFT_sRGBFactors:()=>ze});var a={};r.r(a);var i={};r.r(i),r.d(i,{ArrayItem:()=>C,EXT_lights_image_based:()=>P,EXT_mesh_gpu_instancing:()=>I,EXT_meshopt_compression:()=>F,EXT_texture_webp:()=>k,ExtrasAsMetadata:()=>ot,GLTFLoader:()=>L,KHR_animation_pointer:()=>Ve,KHR_draco_mesh_compression:()=>D,KHR_interactivity:()=>nt,KHR_lights:()=>U,KHR_materials_anisotropy:()=>Q,KHR_materials_clearcoat:()=>W,KHR_materials_dispersion:()=>me,KHR_materials_emissive_strength:()=>$,KHR_materials_ior:()=>ae,KHR_materials_iridescence:()=>X,KHR_materials_pbrSpecularGlossiness:()=>H,KHR_materials_sheen:()=>te,KHR_materials_specular:()=>re,KHR_materials_translucency:()=>he,KHR_materials_transmission:()=>ue,KHR_materials_unlit:()=>q,KHR_materials_variants:()=>se,KHR_materials_volume:()=>pe,KHR_mesh_quantization:()=>be,KHR_texture_basisu:()=>ge,KHR_texture_transform:()=>Te,KHR_xmp_json_ld:()=>we,MSFT_audio_emitter:()=>Ke,MSFT_lod:()=>je,MSFT_minecraftMesh:()=>Ye,MSFT_sRGBFactors:()=>ze});var s={};r.r(s),r.d(s,{GLTF2:()=>i,GLTFFileLoader:()=>m,GLTFLoaderAnimationStartMode:()=>h,GLTFLoaderCoordinateSystemMode:()=>d,GLTFLoaderState:()=>f,GLTFValidation:()=>p});var l=r(597);function c(e,t,n,r){var o={externalResourceFunction:r};return n&&(o.uri="file:"===t?n:t+n),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,o):GLTFValidator.validateString(e,o)}function u(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":c(n.data,n.rootUrl,n.fileName,(function(t){return new Promise((function(n,r){var o=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:o,uri:t})}))})).then((function(e){postMessage({id:"validate.resolve",value:e})}),(function(e){postMessage({id:"validate.reject",reason:e})}));break;case"getExternalResource.resolve":e[n.index].resolve(n.value);break;case"getExternalResource.reject":e[n.index].reject(n.reason)}}}var d,h,f,p=function(){function e(){}return e.ValidateAsync=function(e,t,n,r){var o=this;return"function"==typeof Worker?new Promise((function(a,i){var s="".concat(c,"(").concat(u,")()"),d=URL.createObjectURL(new Blob([s],{type:"application/javascript"})),h=new Worker(d),f=function(e){h.removeEventListener("error",f),h.removeEventListener("message",p),i(e)},p=function(e){var t=e.data;switch(t.id){case"getExternalResource":r(t.uri).then((function(e){h.postMessage({id:"getExternalResource.resolve",index:t.index,value:e},[e])}),(function(e){h.postMessage({id:"getExternalResource.reject",index:t.index,reason:e})}));break;case"validate.resolve":h.removeEventListener("error",f),h.removeEventListener("message",p),a(t.value),h.terminate();break;case"validate.reject":h.removeEventListener("error",f),h.removeEventListener("message",p),i(t.reason),h.terminate()}};if(h.addEventListener("error",f),h.addEventListener("message",p),h.postMessage({id:"init",url:l.Tools.GetBabylonScriptURL(o.Configuration.url)}),ArrayBuffer.isView(e)){var _=e.slice();h.postMessage({id:"validate",data:_,rootUrl:t,fileName:n},[_.buffer])}else h.postMessage({id:"validate",data:e,rootUrl:t,fileName:n})})):(this._LoadScriptPromise||(this._LoadScriptPromise=l.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then((function(){return c(e,t,n,r)})))},e.Configuration={url:"".concat(l.Tools._DefaultCdnUrl,"/gltf_validator.js")},e}();function _(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(d||(d={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(h||(h={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(f||(f={}));var m=function(){function e(){this.onParsedObservable=new l.Observable,this.coordinateSystemMode=d.AUTO,this.animationStartMode=h.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this.useRangeRequests=!1,this.createInstances=!0,this.alwaysComputeBoundingBox=!1,this.loadAllMaterials=!1,this.loadOnlyMaterials=!1,this.skipMaterials=!1,this.useSRGBBuffers=!0,this.targetFps=60,this.alwaysComputeSkeletonRootNode=!1,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new l.Observable,this.onSkinLoadedObservable=new l.Observable,this.onTextureLoadedObservable=new l.Observable,this.onMaterialLoadedObservable=new l.Observable,this.onCameraLoadedObservable=new l.Observable,this.onCompleteObservable=new l.Observable,this.onErrorObservable=new l.Observable,this.onDisposeObservable=new l.Observable,this.onExtensionLoadedObservable=new l.Observable,this.validate=!1,this.onValidatedObservable=new l.Observable,this._loader=null,this._state=null,this._requests=new Array,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}},this.onLoaderStateChangedObservable=new l.Observable,this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled}return Object.defineProperty(e.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loggingEnabled",{get:function(){return this._loggingEnabled},set:function(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"capturePerformanceCounters",{get:function(){return this._capturePerformanceCounters},set:function(e){this._capturePerformanceCounters!==e&&(this._capturePerformanceCounters=e,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,t=this._requests;e=e.byteLength)throw new RangeError("Offset is out of range.");if(t+n>e.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,n))}catch(e){return Promise.reject(e)}}(t,e,n)},byteLength:t.byteLength})).then((function(e){r(e)}),o?function(e){return o(void 0,e)}:void 0)},e.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return Promise.resolve().then((function(){return i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n),i._loader.importMeshAsync(e,t,null,n,r,o,a)}))},e.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){return a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t),a._loader.loadAsync(e,t,n,r,o)}))},e.prototype.loadAssetContainerAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t);var i=new l.AssetContainer(e),s=[];a.onMaterialLoadedObservable.add((function(e){s.push(e)}));var c=[];a.onTextureLoadedObservable.add((function(e){c.push(e)}));var u=[];a.onCameraLoadedObservable.add((function(e){u.push(e)}));var d=[];return a.onMeshLoadedObservable.add((function(e){e.morphTargetManager&&d.push(e.morphTargetManager)})),a._loader.importMeshAsync(null,e,i,t,n,r,o).then((function(e){return Array.prototype.push.apply(i.geometries,e.geometries),Array.prototype.push.apply(i.meshes,e.meshes),Array.prototype.push.apply(i.particleSystems,e.particleSystems),Array.prototype.push.apply(i.skeletons,e.skeletons),Array.prototype.push.apply(i.animationGroups,e.animationGroups),Array.prototype.push.apply(i.materials,s),Array.prototype.push.apply(i.textures,c),Array.prototype.push.apply(i.lights,e.lights),Array.prototype.push.apply(i.transformNodes,e.transformNodes),Array.prototype.push.apply(i.cameras,u),Array.prototype.push.apply(i.morphTargetManagers,d),i}))}))},e.prototype.canDirectLoad=function(t){return-1!==t.indexOf("asset")&&-1!==t.indexOf("version")||t.startsWith("data:base64,"+e._MagicBase64Encoded)||t.startsWith("data:;base64,"+e._MagicBase64Encoded)||t.startsWith("data:application/octet-stream;base64,"+e._MagicBase64Encoded)||t.startsWith("data:model/gltf-binary;base64,"+e._MagicBase64Encoded)},e.prototype.directLoad=function(t,n){if(n.startsWith("base64,"+e._MagicBase64Encoded)||n.startsWith(";base64,"+e._MagicBase64Encoded)||n.startsWith("application/octet-stream;base64,"+e._MagicBase64Encoded)||n.startsWith("model/gltf-binary;base64,"+e._MagicBase64Encoded)){var r=(0,l.DecodeBase64UrlToBinary)(n);return this._validate(t,new Uint8Array(r,0,r.byteLength)),this._unpackBinaryAsync(new l.DataReader({readAsync:function(e,t){return _(r,e,t)},byteLength:r.byteLength}))}return this._validate(t,n),Promise.resolve({json:this._parseJson(n)})},e.prototype.createPlugin=function(){return new e},Object.defineProperty(e.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),e.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,n){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){n(e)}))}))},e.prototype._setState=function(e){this._state!==e&&(this._state=e,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(f[this._state]))},e.prototype._loadFile=function(e,t,n,r,o,a){var i=this,s=e._loadFile(t,n,(function(e){i._onProgress(e,s)}),!0,r,o,a);return s.onCompleteObservable.add((function(e){i._requests.splice(i._requests.indexOf(e),1)})),this._requests.push(s),s},e.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a0)throw new Error("Incompatible minimum version: "+n.minVersion)}var a={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[r.major];if(!a)throw new Error("Unsupported version: "+n.version);return a(this)},e.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: ".concat(e.length));var t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t},e.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var n=e.readUint32();if(1179937895!==n)throw new l.RuntimeError("Unexpected magic: "+n,l.ErrorCodes.GLTFLoaderUnexpectedMagicError);var r=e.readUint32();t.loggingEnabled&&t._log("Binary version: ".concat(r));var o,a=e.readUint32();switch(t.useRangeRequests||a===e.buffer.byteLength||l.Logger.Warn("Length in header does not match actual data length: ".concat(a," != ").concat(e.buffer.byteLength)),r){case 1:o=t._unpackBinaryV1Async(e,a);break;case 2:o=t._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+r)}return t._endPerformanceCounter("Unpack Binary"),o}))},e.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: ".concat(r));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},e.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then((function(){return{json:n._parseJson(e.readString(o)),bin:null}})):e.loadAsync(o+8).then((function(){var a={json:n._parseJson(e.readString(o)),bin:null},i=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(i):Promise.resolve(a)};return i()}))},e._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null},e._compareVersion=function(e,t){return e.major>t.major?1:e.majort.minor?1:e.minor ").concat(f[f.READY]),i="".concat(f[f.LOADING]," => ").concat(f[f.COMPLETE]);o._parent._startPerformanceCounter(a),o._parent._startPerformanceCounter(i),o._parent._setState(f.LOADING),o._extensionsOnLoading();var s=new Array,c=o._babylonScene.blockMaterialDirtyMechanism;if(o._babylonScene.blockMaterialDirtyMechanism=!0,!o.parent.loadOnlyMaterials)if(n)s.push(o.loadSceneAsync("/nodes",{nodes:n,index:-1}));else if(null!=o._gltf.scene||o._gltf.scenes&&o._gltf.scenes[0]){var u=C.Get("/scene",o._gltf.scenes,o._gltf.scene||0);s.push(o.loadSceneAsync("/scenes/".concat(u.index),u))}if(!o.parent.skipMaterials&&o.parent.loadAllMaterials&&o._gltf.materials)for(var d=0;de.bin.byteLength)&&l.Logger.Warn("Binary buffer length (".concat(n.byteLength,") from JSON does not match chunk length (").concat(e.bin.byteLength,")")),this._bin=e.bin}else l.Logger.Warn("Unexpected BIN chunk")}},e.prototype._setupData=function(){if(C.Assign(this._gltf.accessors),C.Assign(this._gltf.animations),C.Assign(this._gltf.buffers),C.Assign(this._gltf.bufferViews),C.Assign(this._gltf.cameras),C.Assign(this._gltf.images),C.Assign(this._gltf.materials),C.Assign(this._gltf.meshes),C.Assign(this._gltf.nodes),C.Assign(this._gltf.samplers),C.Assign(this._gltf.scenes),C.Assign(this._gltf.skins),C.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t=(i=n[t[0]]).length)return l;s=i[c];for(var u=1;u=(i=n[t[u]]).length||s!==i[c])return l;l=s}},e.prototype._loadBone=function(e,t,n,r){var o=r[e.index];if(o)return o;var a=null;e.index!==t.skeleton&&(e.parent&&-1!==e.parent.index?a=this._loadBone(e.parent,t,n,r):void 0!==t.skeleton&&l.Logger.Warn("/skins/".concat(t.index,"/skeleton: Skeleton node is not a common root")));var i=t.joints.indexOf(e.index);return o=new l.Bone(e.name||"joint".concat(e.index),n,a,this._getNodeMatrix(e),null,null,i),r[e.index]=o,this._postSceneLoadActions.push((function(){o.linkTransformNode(e._babylonTransformNode)})),o},e.prototype._loadSkinInverseBindMatricesDataAsync=function(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);var n=C.Get("".concat(e,"/inverseBindMatrices"),this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync("/accessors/".concat(n.index),n)},e.prototype._updateBoneMatrices=function(e,t){for(var n=0,r=e.bones;n0){var T="".concat(n.name||"animation".concat(n.index),"_channel").concat(r.index,"_").concat(t);h.buildAnimations(c,T,i,m,(function(e,n){++t,a(e,n)}))}}}))},e.prototype._loadAnimationSamplerAsync=function(e,t){if(t._data)return t._data;var n=t.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error("".concat(e,"/interpolation: Invalid value (").concat(t.interpolation,")"))}var r=C.Get("".concat(e,"/input"),this._gltf.accessors,t.input),o=C.Get("".concat(e,"/output"),this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync("/accessors/".concat(r.index),r),this._loadFloatAccessorAsync("/accessors/".concat(o.index),o)]).then((function(e){var t=e[0],r=e[1];return{input:t,interpolation:n,output:r}})),t._data},e.prototype.loadBufferAsync=function(e,t,n,r){var o=this._extensionsLoadBufferAsync(e,t,n,r);if(o)return o;if(!t._data)if(t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{if(!this._bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then((function(t){try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw new Error("".concat(e,": ").concat(t.message))}}))},e.prototype.loadBufferViewAsync=function(e,t){var n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;var r=C.Get("".concat(e,"/buffer"),this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync("/buffers/".concat(r.index),r,t.byteOffset||0,t.byteLength),t._data},e.prototype._loadAccessorAsync=function(t,n,r){var o=this;if(n._data)return n._data;var a=e._GetNumComponents(t,n.type),i=a*l.VertexBuffer.GetTypeByteLength(n.componentType),s=a*n.count;if(null==n.bufferView)n._data=Promise.resolve(new r(s));else{var c=C.Get("".concat(t,"/bufferView"),this._gltf.bufferViews,n.bufferView);n._data=this.loadBufferViewAsync("/bufferViews/".concat(c.index),c).then((function(o){if(5126!==n.componentType||n.normalized||c.byteStride&&c.byteStride!==i){var u=new r(s);return l.VertexBuffer.ForEach(o,n.byteOffset||0,c.byteStride||i,a,n.componentType,u.length,n.normalized||!1,(function(e,t){u[t]=e})),u}return e._GetTypedArray(t,n.componentType,o,n.byteOffset,s)}))}if(n.sparse){var u=n.sparse;n._data=n._data.then((function(s){var c=s,d=C.Get("".concat(t,"/sparse/indices/bufferView"),o._gltf.bufferViews,u.indices.bufferView),h=C.Get("".concat(t,"/sparse/values/bufferView"),o._gltf.bufferViews,u.values.bufferView);return Promise.all([o.loadBufferViewAsync("/bufferViews/".concat(d.index),d),o.loadBufferViewAsync("/bufferViews/".concat(h.index),h)]).then((function(o){var s,d=o[0],h=o[1],f=e._GetTypedArray("".concat(t,"/sparse/indices"),u.indices.componentType,d,u.indices.byteOffset,u.count),p=a*u.count;if(5126!==n.componentType||n.normalized){var _=e._GetTypedArray("".concat(t,"/sparse/values"),n.componentType,h,u.values.byteOffset,p);s=new r(p),l.VertexBuffer.ForEach(_,0,i,a,n.componentType,s.length,n.normalized||!1,(function(e,t){s[t]=e}))}else s=e._GetTypedArray("".concat(t,"/sparse/values"),n.componentType,h,u.values.byteOffset,p);for(var m=0,y=0;y=6)throw new Error("".concat(t,"/texCoord: Invalid value (").concat(n.texCoord,")"));var i=C.Get("".concat(t,"/index"),this._gltf.textures,n.index);i._textureInfo=n;var s=this._loadTextureAsync("/textures/".concat(n.index),i,(function(a){a.coordinatesIndex=n.texCoord||0,e.AddPointerMetadata(a,t),o._parent.onTextureLoadedObservable.notifyObservers(a),r(a)}));return this.logClose(),s},e.prototype._loadTextureAsync=function(t,n,r){void 0===r&&(r=function(){});var o=this._extensionsLoadTextureAsync(t,n,r);if(o)return o;this.logOpen("".concat(t," ").concat(n.name||""));var a=null==n.sampler?e.DefaultSampler:C.Get("".concat(t,"/sampler"),this._gltf.samplers,n.sampler),i=C.Get("".concat(t,"/source"),this._gltf.images,n.source),s=this._createTextureAsync(t,a,i,r,void 0,!n._textureInfo.nonColorData);return this.logClose(),s},e.prototype._createTextureAsync=function(e,t,n,r,o,a){var i=this;void 0===r&&(r=function(){});var s=this._loadSampler("/samplers/".concat(t.index),t),c=new Array,u=new l.Deferred;this._babylonScene._blockEntityCollection=!!this._assetContainer;var d={noMipmap:s.noMipMaps,invertY:!1,samplingMode:s.samplingMode,onLoad:function(){i._disposed||u.resolve()},onError:function(t,n){i._disposed||u.reject(new Error("".concat(e,": ").concat(n&&n.message?n.message:t||"Failed to load texture")))},mimeType:n.mimeType,loaderOptions:o,useSRGBBuffer:!!a&&this._parent.useSRGBBuffers},h=new l.Texture(null,this._babylonScene,d);return h._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,c.push(u.promise),c.push(this.loadImageAsync("/images/".concat(n.index),n).then((function(e){var t=n.uri||"".concat(i._fileName,"#image").concat(n.index),r="data:".concat(i._uniqueRootUrl).concat(t);h.updateURL(r,e)}))),h.wrapU=s.wrapU,h.wrapV=s.wrapV,r(h),Promise.all(c).then((function(){return h}))},e.prototype._loadSampler=function(t,n){return n._data||(n._data={noMipMaps:9728===n.minFilter||9729===n.minFilter,samplingMode:e._GetTextureSamplingMode(t,n),wrapU:e._GetTextureWrapMode("".concat(t,"/wrapS"),n.wrapS),wrapV:e._GetTextureWrapMode("".concat(t,"/wrapT"),n.wrapT)}),n._data},e.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen("".concat(e," ").concat(t.name||"")),t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{var n=C.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(n.index),n)}this.logClose()}return t._data},e.prototype.loadUriAsync=function(t,n,r){var o=this,a=this._extensionsLoadUriAsync(t,n,r);if(a)return a;if(!e._ValidateUri(r))throw new Error("".concat(t,": '").concat(r,"' is invalid"));if((0,l.IsBase64DataUrl)(r)){var i=new Uint8Array((0,l.DecodeBase64UrlToBinary)(r));return this.log("".concat(t,": Decoded ").concat(r.substr(0,64),"... (").concat(i.length," bytes)")),Promise.resolve(i)}return this.log("".concat(t,": Loading ").concat(r)),this._parent.preprocessUrlAsync(this._rootUrl+r).then((function(e){return new Promise((function(n,a){o._parent._loadFile(o._babylonScene,e,(function(e){o._disposed||(o.log("".concat(t,": Loaded ").concat(r," (").concat(e.byteLength," bytes)")),n(new Uint8Array(e)))}),!0,(function(e){a(new l.LoadFileError("".concat(t,": Failed to load '").concat(r,"'").concat(e?": "+e.status+" "+e.statusText:""),e))}))}))}))},e.AddPointerMetadata=function(e,t){e.metadata=e.metadata||{};var n=e._internalMetadata=e._internalMetadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)},e._GetTextureWrapMode=function(e,t){switch(t=null==t?10497:t){case 33071:return l.Texture.CLAMP_ADDRESSMODE;case 33648:return l.Texture.MIRROR_ADDRESSMODE;case 10497:return l.Texture.WRAP_ADDRESSMODE;default:return l.Logger.Warn("".concat(e,": Invalid value (").concat(t,")")),l.Texture.WRAP_ADDRESSMODE}},e._GetTextureSamplingMode=function(e,t){var n=null==t.magFilter?9729:t.magFilter,r=null==t.minFilter?9987:t.minFilter;if(9729===n)switch(r){case 9728:return l.Texture.LINEAR_NEAREST;case 9729:return l.Texture.LINEAR_LINEAR;case 9984:return l.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return l.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return l.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return l.Texture.LINEAR_LINEAR_MIPLINEAR;default:return l.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(r,")")),l.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==n&&l.Logger.Warn("".concat(e,"/magFilter: Invalid value (").concat(n,")")),r){case 9728:return l.Texture.NEAREST_NEAREST;case 9729:return l.Texture.NEAREST_LINEAR;case 9984:return l.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return l.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return l.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return l.Texture.NEAREST_LINEAR_MIPLINEAR;default:return l.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(r,")")),l.Texture.NEAREST_NEAREST_MIPNEAREST}},e._GetTypedArrayConstructor=function(e,t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error("".concat(e,": Invalid component type ").concat(t))}},e._GetTypedArray=function(t,n,r,o,a){var i=r.buffer;o=r.byteOffset+(o||0);var s=e._GetTypedArrayConstructor("".concat(t,"/componentType"),n),c=l.VertexBuffer.GetTypeByteLength(n);return o%c!=0?(l.Logger.Warn("".concat(t,": Copying buffer as byte offset (").concat(o,") is not a multiple of component type byte length (").concat(c,")")),new s(i.slice(o,o+a*c),0)):new s(i,o,a)},e._GetNumComponents=function(e,t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error("".concat(e,": Invalid type (").concat(t,")"))},e._ValidateUri=function(e){return l.Tools.IsBase64(e)||-1===e.indexOf("..")},e._GetDrawMode=function(e,t){switch(null==t&&(t=4),t){case 0:return l.Material.PointListDrawMode;case 1:return l.Material.LineListDrawMode;case 2:return l.Material.LineLoopDrawMode;case 3:return l.Material.LineStripDrawMode;case 4:return l.Material.TriangleFillMode;case 5:return l.Material.TriangleStripDrawMode;case 6:return l.Material.TriangleFanDrawMode}throw new Error("".concat(e,": Invalid mesh primitive mode (").concat(t,")"))},e.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile materials");var t=new Array;if(this._gltf.materials)for(var n=0,r=this._gltf.materials;n=0;a--)if(o.push(C.Get("".concat(e,"/ids/").concat(r[a]),n,r[a])),o.length===this.maxLODsToLoad)return o;return o.push(t),o},e.prototype._disposeTransformNode=function(e){var t=this,n=[],r=e.material;r&&n.push(r);for(var o=0,a=e.getChildMeshes();o0){var n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}},e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return this._loader.loadNodeAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.loadCameraAsync=function(e,t,n){var r=this;return this._loader.loadCameraAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.createMaterial=function(e,t,n){var r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r},e}();L.RegisterExtension(rt,(function(e){return new ot(e)}));var at=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==at){at.BABYLON=at.BABYLON||{};var it=at.BABYLON;it.GLTF2=it.GLTF2||{},it.GLTF2.Loader=it.GLTF2.Loader||{},it.GLTF2.Loader.Extensions=it.GLTF2.Loader.Extensions||{};var st=[];for(var lt in n)it.GLTF2.Loader.Extensions[lt]=n[lt],st.push(lt);for(var lt in a)it.GLTF2.Loader[lt]=a[lt],st.push(lt);for(var lt in i)st.indexOf(lt)>-1||(it.GLTF2[lt]=i[lt])}const ct=s})(),o.default})())); +//# sourceMappingURL=babylon.glTF2FileLoader.min.js.map \ No newline at end of file diff --git a/libs/babylonjs/6.46.0/babylon.glTF2Serializer.js b/libs/babylonjs/6.46.0/babylon.glTF2Serializer.js new file mode 100644 index 00000000..9e869387 --- /dev/null +++ b/libs/babylonjs/6.46.0/babylon.glTF2Serializer.js @@ -0,0 +1,6339 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("babylonjs")); + else if(typeof define === 'function' && define.amd) + define("babylonjs-serializers", ["babylonjs"], factory); + else if(typeof exports === 'object') + exports["babylonjs-serializers"] = factory(require("babylonjs")); + else + root["SERIALIZERS"] = factory(root["BABYLON"]); +})((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), (__WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math_vector__) => { +return /******/ (() => { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts": +/*!***********************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts ***! + \***********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* binding */ EXT_mesh_gpu_instancing) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Buffers/buffer */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__); + + + + + +var NAME = "EXT_mesh_gpu_instancing"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_mesh_gpu_instancing/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_mesh_gpu_instancing = /** @class */ (function () { + function EXT_mesh_gpu_instancing(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + EXT_mesh_gpu_instancing.prototype.dispose = function () { }; + Object.defineProperty(EXT_mesh_gpu_instancing.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + /** + * After node is exported + * @param context the GLTF context when loading the asset + * @param node the node exported + * @param babylonNode the corresponding babylon node + * @param nodeMap map from babylon node id to node index + * @param binaryWriter binary writer + * @returns nullable promise, resolves with the node + */ + EXT_mesh_gpu_instancing.prototype.postExportNodeAsync = function (context, node, babylonNode, nodeMap, binaryWriter) { + var _this = this; + return new Promise(function (resolve) { + if (node && babylonNode instanceof babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.Mesh) { + if (babylonNode.hasThinInstances && binaryWriter) { + _this._wasUsed = true; + var noTranslation = babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(); + var noRotation = babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.Quaternion.Identity(); + var noScale = babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.Vector3.One(); + // retrieve all the instance world matrix + var matrix = babylonNode.thinInstanceGetWorldMatrices(); + var iwt = babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Vector3[2]; + var iwr = babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Quaternion[1]; + var iws = babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Vector3[3]; + var hasAnyInstanceWorldTranslation = false; + var hasAnyInstanceWorldRotation = false; + var hasAnyInstanceWorldScale = false; + // prepare temp buffers + var translationBuffer = new Float32Array(babylonNode.thinInstanceCount * 3); + var rotationBuffer = new Float32Array(babylonNode.thinInstanceCount * 4); + var scaleBuffer = new Float32Array(babylonNode.thinInstanceCount * 3); + var i = 0; + for (var _i = 0, matrix_1 = matrix; _i < matrix_1.length; _i++) { + var m = matrix_1[_i]; + m.decompose(iws, iwr, iwt); + // fill the temp buffer + translationBuffer.set(iwt.asArray(), i * 3); + rotationBuffer.set(iwr.normalize().asArray(), i * 4); // ensure the quaternion is normalized + scaleBuffer.set(iws.asArray(), i * 3); + // this is where we decide if there is any transformation + hasAnyInstanceWorldTranslation = hasAnyInstanceWorldTranslation || !iwt.equalsWithEpsilon(noTranslation); + hasAnyInstanceWorldRotation = hasAnyInstanceWorldRotation || !iwr.equalsWithEpsilon(noRotation); + hasAnyInstanceWorldScale = hasAnyInstanceWorldScale || !iws.equalsWithEpsilon(noScale); + i++; + } + var extension = { + attributes: {}, + }; + // do we need to write TRANSLATION ? + if (hasAnyInstanceWorldTranslation) { + extension.attributes["TRANSLATION"] = _this._buildAccessor(translationBuffer, "VEC3" /* AccessorType.VEC3 */, babylonNode.thinInstanceCount, binaryWriter, 5126 /* AccessorComponentType.FLOAT */); + } + // do we need to write ROTATION ? + if (hasAnyInstanceWorldRotation) { + var componentType = 5126 /* AccessorComponentType.FLOAT */; // we decided to stay on FLOAT for now see https://github.com/BabylonJS/Babylon.js/pull/12495 + extension.attributes["ROTATION"] = _this._buildAccessor(rotationBuffer, "VEC4" /* AccessorType.VEC4 */, babylonNode.thinInstanceCount, binaryWriter, componentType); + } + // do we need to write SCALE ? + if (hasAnyInstanceWorldScale) { + extension.attributes["SCALE"] = _this._buildAccessor(scaleBuffer, "VEC3" /* AccessorType.VEC3 */, babylonNode.thinInstanceCount, binaryWriter, 5126 /* AccessorComponentType.FLOAT */); + } + /* eslint-enable @typescript-eslint/naming-convention*/ + node.extensions = node.extensions || {}; + node.extensions[NAME] = extension; + } + } + resolve(node); + }); + }; + EXT_mesh_gpu_instancing.prototype._buildAccessor = function (buffer, type, count, binaryWriter, componentType) { + // write the buffer + var bufferOffset = binaryWriter.getByteOffset(); + switch (componentType) { + case 5126 /* AccessorComponentType.FLOAT */: { + for (var i = 0; i != buffer.length; i++) { + binaryWriter.setFloat32(buffer[i]); + } + break; + } + case 5120 /* AccessorComponentType.BYTE */: { + for (var i = 0; i != buffer.length; i++) { + binaryWriter.setByte(buffer[i] * 127); + } + break; + } + case 5122 /* AccessorComponentType.SHORT */: { + for (var i = 0; i != buffer.length; i++) { + binaryWriter.setInt16(buffer[i] * 32767); + } + break; + } + } + // build the buffer view + var bv = { buffer: 0, byteOffset: bufferOffset, byteLength: buffer.length * babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.GetTypeByteLength(componentType) }; + var bufferViewIndex = this._exporter._bufferViews.length; + this._exporter._bufferViews.push(bv); + // finally build the accessor + var accessorIndex = this._exporter._accessors.length; + var accessor = { + bufferView: bufferViewIndex, + componentType: componentType, + count: count, + type: type, + normalized: componentType == 5120 /* AccessorComponentType.BYTE */ || componentType == 5122 /* AccessorComponentType.SHORT */, + }; + this._exporter._accessors.push(accessor); + return accessorIndex; + }; + return EXT_mesh_gpu_instancing; +}()); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new EXT_mesh_gpu_instancing(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_lights_punctual: () => (/* binding */ KHR_lights_punctual) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); + + + + + + +var NAME = "KHR_lights_punctual"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_lights_punctual = /** @class */ (function () { + /** + * @internal + */ + function KHR_lights_punctual(exporter) { + /** The name of this extension. */ + this.name = NAME; + /** Defines whether this extension is enabled. */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._exporter = exporter; + } + /** @internal */ + KHR_lights_punctual.prototype.dispose = function () { + this._lights = null; + }; + Object.defineProperty(KHR_lights_punctual.prototype, "wasUsed", { + /** @internal */ + get: function () { + return !!this._lights; + }, + enumerable: false, + configurable: true + }); + /** @internal */ + KHR_lights_punctual.prototype.onExporting = function () { + this._exporter._glTF.extensions[NAME] = this._lights; + }; + /** + * Define this method to modify the default behavior when exporting a node + * @param context The context when exporting the node + * @param node glTF node + * @param babylonNode BabylonJS node + * @param nodeMap Node mapping of unique id to glTF node index + * @returns nullable INode promise + */ + KHR_lights_punctual.prototype.postExportNodeAsync = function (context, node, babylonNode, nodeMap) { + var _this = this; + return new Promise(function (resolve) { + if (node && babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.ShadowLight) { + var light = void 0; + var lightType = babylonNode.getTypeID() == babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light.LIGHTTYPEID_POINTLIGHT + ? "point" /* KHRLightsPunctual_LightType.POINT */ + : babylonNode.getTypeID() == babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light.LIGHTTYPEID_DIRECTIONALLIGHT + ? "directional" /* KHRLightsPunctual_LightType.DIRECTIONAL */ + : babylonNode.getTypeID() == babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light.LIGHTTYPEID_SPOTLIGHT + ? "spot" /* KHRLightsPunctual_LightType.SPOT */ + : null; + if (lightType == null) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Light ").concat(babylonNode.name, " is not supported in ").concat(NAME)); + } + else { + if (!babylonNode.position.equalsToFloats(0, 0, 0)) { + node.translation = babylonNode.position.asArray(); + } + if (lightType !== "point" /* KHRLightsPunctual_LightType.POINT */) { + var localAxis = babylonNode.direction; + var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2; + var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z); + var pitch = -Math.atan2(localAxis.y, len); + var lightRotationQuaternion = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.RotationYawPitchRoll(yaw + Math.PI, pitch, 0); + if (!babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.IsIdentity(lightRotationQuaternion)) { + node.rotation = lightRotationQuaternion.asArray(); + } + } + if (babylonNode.falloffType !== babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light.FALLOFF_GLTF) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Light falloff for ").concat(babylonNode.name, " does not match the ").concat(NAME, " specification!")); + } + light = { + type: lightType, + }; + if (!babylonNode.diffuse.equals(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White())) { + light.color = babylonNode.diffuse.asArray(); + } + if (babylonNode.intensity !== 1.0) { + light.intensity = babylonNode.intensity; + } + if (babylonNode.range !== Number.MAX_VALUE) { + light.range = babylonNode.range; + } + if (lightType === "spot" /* KHRLightsPunctual_LightType.SPOT */) { + var babylonSpotLight = babylonNode; + if (babylonSpotLight.angle !== Math.PI / 2.0) { + if (light.spot == null) { + light.spot = {}; + } + light.spot.outerConeAngle = babylonSpotLight.angle / 2.0; + } + if (babylonSpotLight.innerAngle !== 0) { + if (light.spot == null) { + light.spot = {}; + } + light.spot.innerConeAngle = babylonSpotLight.innerAngle / 2.0; + } + } + _this._lights || (_this._lights = { + lights: [], + }); + _this._lights.lights.push(light); + var lightReference = { + light: _this._lights.lights.length - 1, + }; + // Avoid duplicating the Light's parent node if possible. + var parentBabylonNode = babylonNode.parent; + if (parentBabylonNode && parentBabylonNode.getChildren().length == 1) { + var parentNode = _this._exporter._nodes[nodeMap[parentBabylonNode.uniqueId]]; + if (parentNode) { + var parentTranslation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(parentNode.translation || [0, 0, 0], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0]); + var parentRotation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArrayToRef(parentNode.rotation || [0, 0, 0, 1], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0]); + var parentScale = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(parentNode.scale || [1, 1, 1], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1]); + var parentMatrix = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Matrix.ComposeToRef(parentScale, parentRotation, parentTranslation, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0]); + var translation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(node.translation || [0, 0, 0], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[2]); + var rotation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArrayToRef(node.rotation || [0, 0, 0, 1], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[1]); + var matrix = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Matrix.ComposeToRef(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.OneReadOnly, rotation, translation, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[1]); + parentMatrix.multiplyToRef(matrix, matrix); + matrix.decompose(parentScale, parentRotation, parentTranslation); + if (parentTranslation.equalsToFloats(0, 0, 0)) { + delete parentNode.translation; + } + else { + parentNode.translation = parentTranslation.asArray(); + } + if (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.IsIdentity(parentRotation)) { + delete parentNode.rotation; + } + else { + parentNode.rotation = parentRotation.asArray(); + } + if (parentScale.equalsToFloats(1, 1, 1)) { + delete parentNode.scale; + } + else { + parentNode.scale = parentScale.asArray(); + } + parentNode.extensions || (parentNode.extensions = {}); + parentNode.extensions[NAME] = lightReference; + // Do not export the original node + resolve(null); + return; + } + } + node.extensions || (node.extensions = {}); + node.extensions[NAME] = lightReference; + } + } + resolve(node); + }); + }; + return KHR_lights_punctual; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_1__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_lights_punctual(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts": +/*!************************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts ***! + \************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_anisotropy: () => (/* binding */ KHR_materials_anisotropy) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrBaseMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_anisotropy"; +/** + * @internal + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_anisotropy = /** @class */ (function () { + function KHR_materials_anisotropy(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + KHR_materials_anisotropy.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_anisotropy.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_anisotropy.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) { + var additionalTextures = []; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRBaseMaterial) { + if (babylonMaterial.anisotropy.isEnabled && !babylonMaterial.anisotropy.legacy) { + if (babylonMaterial.anisotropy.texture) { + additionalTextures.push(babylonMaterial.anisotropy.texture); + } + return additionalTextures; + } + } + return []; + }; + KHR_materials_anisotropy.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRBaseMaterial) { + if (!babylonMaterial.anisotropy.isEnabled || babylonMaterial.anisotropy.legacy) { + resolve(node); + return; + } + _this._wasUsed = true; + node.extensions = node.extensions || {}; + var anisotropyTextureInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.anisotropy.texture); + var anisotropyInfo_1 = { + anisotropyStrength: babylonMaterial.anisotropy.intensity, + anisotropyRotation: babylonMaterial.anisotropy.angle, + anisotropyTexture: anisotropyTextureInfo !== null && anisotropyTextureInfo !== void 0 ? anisotropyTextureInfo : undefined, + hasTextures: function () { + return anisotropyInfo_1.anisotropyTexture !== null; + }, + }; + node.extensions[NAME] = anisotropyInfo_1; + } + resolve(node); + }); + }; + return KHR_materials_anisotropy; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_anisotropy(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts": +/*!***********************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts ***! + \***********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_clearcoat: () => (/* binding */ KHR_materials_clearcoat) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__); + + + +var NAME = "KHR_materials_clearcoat"; +/** + * @internal + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_clearcoat = /** @class */ (function () { + function KHR_materials_clearcoat(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + KHR_materials_clearcoat.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_clearcoat.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_clearcoat.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) { + var additionalTextures = []; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRBaseMaterial) { + if (babylonMaterial.clearCoat.isEnabled) { + if (babylonMaterial.clearCoat.texture) { + additionalTextures.push(babylonMaterial.clearCoat.texture); + } + if (!babylonMaterial.clearCoat.useRoughnessFromMainTexture && babylonMaterial.clearCoat.textureRoughness) { + additionalTextures.push(babylonMaterial.clearCoat.textureRoughness); + } + if (babylonMaterial.clearCoat.bumpTexture) { + additionalTextures.push(babylonMaterial.clearCoat.bumpTexture); + } + return additionalTextures; + } + } + return []; + }; + KHR_materials_clearcoat.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRBaseMaterial) { + if (!babylonMaterial.clearCoat.isEnabled) { + resolve(node); + return; + } + _this._wasUsed = true; + node.extensions = node.extensions || {}; + var clearCoatTextureInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture); + var clearCoatTextureRoughnessInfo = void 0; + if (babylonMaterial.clearCoat.useRoughnessFromMainTexture) { + clearCoatTextureRoughnessInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture); + } + else { + clearCoatTextureRoughnessInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.textureRoughness); + } + if (babylonMaterial.clearCoat.isTintEnabled) { + babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: ".concat(babylonMaterial.name)); + } + if (babylonMaterial.clearCoat.remapF0OnInterfaceChange) { + babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Clear Color F0 remapping is not supported for glTF export. Ignoring for: ".concat(babylonMaterial.name)); + } + var clearCoatNormalTextureInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.bumpTexture); + var clearCoatInfo_1 = { + clearcoatFactor: babylonMaterial.clearCoat.intensity, + clearcoatTexture: clearCoatTextureInfo !== null && clearCoatTextureInfo !== void 0 ? clearCoatTextureInfo : undefined, + clearcoatRoughnessFactor: babylonMaterial.clearCoat.roughness, + clearcoatRoughnessTexture: clearCoatTextureRoughnessInfo !== null && clearCoatTextureRoughnessInfo !== void 0 ? clearCoatTextureRoughnessInfo : undefined, + clearcoatNormalTexture: clearCoatNormalTextureInfo !== null && clearCoatNormalTextureInfo !== void 0 ? clearCoatNormalTextureInfo : undefined, + hasTextures: function () { + return clearCoatInfo_1.clearcoatTexture !== null || clearCoatInfo_1.clearcoatRoughnessTexture !== null || clearCoatInfo_1.clearcoatRoughnessTexture !== null; + }, + }; + node.extensions[NAME] = clearCoatInfo_1; + } + resolve(node); + }); + }; + return KHR_materials_clearcoat; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_clearcoat(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts": +/*!************************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts ***! + \************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_dispersion: () => (/* binding */ KHR_materials_dispersion) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_dispersion"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/87bd64a7f5e23c84b6aef2e6082069583ed0ddb4/extensions/2.0/Khronos/KHR_materials_dispersion/README.md) + * @experimental + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_dispersion = /** @class */ (function () { + /** Constructor */ + function KHR_materials_dispersion() { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + } + /** Dispose */ + KHR_materials_dispersion.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_dispersion.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_dispersion.prototype._isExtensionEnabled = function (mat) { + // This extension must not be used on a material that also uses KHR_materials_unlit + if (mat.unlit) { + return false; + } + var subs = mat.subSurface; + // this extension requires refraction to be enabled. + if (!subs.isRefractionEnabled && !subs.isDispersionEnabled) { + return false; + } + return true; + }; + /** + * After exporting a material + * @param context GLTF context of the material + * @param node exported GLTF node + * @param babylonMaterial corresponding babylon material + * @returns promise, resolves with the material + */ + KHR_materials_dispersion.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial && _this._isExtensionEnabled(babylonMaterial)) { + _this._wasUsed = true; + var subs = babylonMaterial.subSurface; + var dispersion = subs.dispersion; + var dispersionInfo = { + dispersion: dispersion, + }; + node.extensions = node.extensions || {}; + node.extensions[NAME] = dispersionInfo; + } + resolve(node); + }); + }; + return KHR_materials_dispersion; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function () { return new KHR_materials_dispersion(); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts": +/*!*******************************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_emissive_strength: () => (/* binding */ KHR_materials_emissive_strength) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_emissive_strength"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_emissive_strength = /** @class */ (function () { + function KHR_materials_emissive_strength() { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + } + /** Dispose */ + KHR_materials_emissive_strength.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_emissive_strength.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + /** + * After exporting a material + * @param context GLTF context of the material + * @param node exported GLTF node + * @param babylonMaterial corresponding babylon material + * @returns promise, resolves with the material + */ + KHR_materials_emissive_strength.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial)) { + return resolve(node); + } + var emissiveColor = babylonMaterial.emissiveColor.asArray(); + var tempEmissiveStrength = Math.max.apply(Math, emissiveColor); + if (tempEmissiveStrength > 1) { + _this._wasUsed = true; + node.extensions || (node.extensions = {}); + var emissiveStrengthInfo = { + emissiveStrength: tempEmissiveStrength, + }; + // Normalize each value of the emissive factor to have a max value of 1 + var newEmissiveFactor = babylonMaterial.emissiveColor.scale(1 / emissiveStrengthInfo.emissiveStrength); + node.emissiveFactor = newEmissiveFactor.asArray(); + node.extensions[NAME] = emissiveStrengthInfo; + } + return resolve(node); + }); + }; + return KHR_materials_emissive_strength; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_emissive_strength(); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_ior.ts": +/*!*****************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_ior.ts ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_ior: () => (/* binding */ KHR_materials_ior) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_ior"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_ior = /** @class */ (function () { + function KHR_materials_ior() { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + } + /** Dispose */ + KHR_materials_ior.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_ior.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_ior.prototype._isExtensionEnabled = function (mat) { + // This extension must not be used on a material that also uses KHR_materials_unlit + if (mat.unlit) { + return false; + } + return mat.indexOfRefraction != undefined && mat.indexOfRefraction != 1.5; // 1.5 is normative default value. + }; + /** + * After exporting a material + * @param context GLTF context of the material + * @param node exported GLTF node + * @param babylonMaterial corresponding babylon material + * @returns promise, resolves with the material + */ + KHR_materials_ior.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial && _this._isExtensionEnabled(babylonMaterial)) { + _this._wasUsed = true; + var iorInfo = { + ior: babylonMaterial.indexOfRefraction, + }; + node.extensions = node.extensions || {}; + node.extensions[NAME] = iorInfo; + } + resolve(node); + }); + }; + return KHR_materials_ior; +}()); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_ior(); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts": +/*!*************************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts ***! + \*************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_iridescence: () => (/* binding */ KHR_materials_iridescence) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrBaseMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_iridescence"; +/** + * @internal + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_iridescence = /** @class */ (function () { + function KHR_materials_iridescence(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + KHR_materials_iridescence.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_iridescence.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_iridescence.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) { + var additionalTextures = []; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRBaseMaterial) { + if (babylonMaterial.iridescence.isEnabled) { + if (babylonMaterial.iridescence.texture) { + additionalTextures.push(babylonMaterial.iridescence.texture); + } + if (babylonMaterial.iridescence.thicknessTexture && babylonMaterial.iridescence.thicknessTexture !== babylonMaterial.iridescence.texture) { + additionalTextures.push(babylonMaterial.iridescence.thicknessTexture); + } + return additionalTextures; + } + } + return []; + }; + KHR_materials_iridescence.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRBaseMaterial) { + if (!babylonMaterial.iridescence.isEnabled) { + resolve(node); + return; + } + _this._wasUsed = true; + node.extensions = node.extensions || {}; + var iridescenceTextureInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.iridescence.texture); + var iridescenceThicknessTextureInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.iridescence.thicknessTexture); + var iridescenceInfo_1 = { + iridescenceFactor: babylonMaterial.iridescence.intensity, + iridescenceIor: babylonMaterial.iridescence.indexOfRefraction, + iridescenceThicknessMinimum: babylonMaterial.iridescence.minimumThickness, + iridescenceThicknessMaximum: babylonMaterial.iridescence.maximumThickness, + iridescenceTexture: iridescenceTextureInfo !== null && iridescenceTextureInfo !== void 0 ? iridescenceTextureInfo : undefined, + iridescenceThicknessTexture: iridescenceThicknessTextureInfo !== null && iridescenceThicknessTextureInfo !== void 0 ? iridescenceThicknessTextureInfo : undefined, + hasTextures: function () { + return iridescenceInfo_1.iridescenceTexture !== null || iridescenceInfo_1.iridescenceThicknessTexture !== null; + }, + }; + node.extensions[NAME] = iridescenceInfo_1; + } + resolve(node); + }); + }; + return KHR_materials_iridescence; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_iridescence(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_sheen.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_sheen.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_sheen: () => (/* binding */ KHR_materials_sheen) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_sheen"; +/** + * @internal + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_sheen = /** @class */ (function () { + function KHR_materials_sheen(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + KHR_materials_sheen.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_sheen.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_sheen.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) { + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial) { + if (babylonMaterial.sheen.isEnabled && babylonMaterial.sheen.texture) { + return [babylonMaterial.sheen.texture]; + } + } + return []; + }; + KHR_materials_sheen.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + var _a, _b, _c, _d; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial) { + if (!babylonMaterial.sheen.isEnabled) { + resolve(node); + return; + } + _this._wasUsed = true; + if (node.extensions == null) { + node.extensions = {}; + } + var sheenInfo_1 = { + sheenColorFactor: babylonMaterial.sheen.color.asArray(), + sheenRoughnessFactor: (_a = babylonMaterial.sheen.roughness) !== null && _a !== void 0 ? _a : 0, + hasTextures: function () { + return sheenInfo_1.sheenColorTexture !== null || sheenInfo_1.sheenRoughnessTexture !== null; + }, + }; + if (babylonMaterial.sheen.texture) { + sheenInfo_1.sheenColorTexture = (_b = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.sheen.texture)) !== null && _b !== void 0 ? _b : undefined; + } + if (babylonMaterial.sheen.textureRoughness && !babylonMaterial.sheen.useRoughnessFromMainTexture) { + sheenInfo_1.sheenRoughnessTexture = (_c = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.sheen.textureRoughness)) !== null && _c !== void 0 ? _c : undefined; + } + else if (babylonMaterial.sheen.texture && babylonMaterial.sheen.useRoughnessFromMainTexture) { + sheenInfo_1.sheenRoughnessTexture = (_d = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.sheen.texture)) !== null && _d !== void 0 ? _d : undefined; + } + node.extensions[NAME] = sheenInfo_1; + } + resolve(node); + }); + }; + return KHR_materials_sheen; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_sheen(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_specular.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_specular.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_specular: () => (/* binding */ KHR_materials_specular) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_specular"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_specular/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_specular = /** @class */ (function () { + function KHR_materials_specular(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + /** Dispose */ + KHR_materials_specular.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_specular.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + /** + * After exporting a material, deal with the additional textures + * @param context GLTF context of the material + * @param node exported GLTF node + * @param babylonMaterial corresponding babylon material + * @returns array of additional textures to export + */ + KHR_materials_specular.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) { + var additionalTextures = []; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial) { + if (this._isExtensionEnabled(babylonMaterial)) { + if (babylonMaterial.metallicReflectanceTexture) { + additionalTextures.push(babylonMaterial.metallicReflectanceTexture); + } + if (babylonMaterial.reflectanceTexture) { + additionalTextures.push(babylonMaterial.reflectanceTexture); + } + return additionalTextures; + } + } + return additionalTextures; + }; + KHR_materials_specular.prototype._isExtensionEnabled = function (mat) { + // This extension must not be used on a material that also uses KHR_materials_unlit + if (mat.unlit) { + return false; + } + return ((mat.metallicF0Factor != undefined && mat.metallicF0Factor != 1.0) || + (mat.metallicReflectanceColor != undefined && !mat.metallicReflectanceColor.equalsFloats(1.0, 1.0, 1.0)) || + this._hasTexturesExtension(mat)); + }; + KHR_materials_specular.prototype._hasTexturesExtension = function (mat) { + return mat.metallicReflectanceTexture != null || mat.reflectanceTexture != null; + }; + /** + * After exporting a material + * @param context GLTF context of the material + * @param node exported GLTF node + * @param babylonMaterial corresponding babylon material + * @returns promise, resolves with the material + */ + KHR_materials_specular.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + var _a, _b; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial && _this._isExtensionEnabled(babylonMaterial)) { + _this._wasUsed = true; + node.extensions = node.extensions || {}; + var metallicReflectanceTexture = (_a = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.metallicReflectanceTexture)) !== null && _a !== void 0 ? _a : undefined; + var reflectanceTexture = (_b = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.reflectanceTexture)) !== null && _b !== void 0 ? _b : undefined; + var metallicF0Factor = babylonMaterial.metallicF0Factor == 1.0 ? undefined : babylonMaterial.metallicF0Factor; + var metallicReflectanceColor = babylonMaterial.metallicReflectanceColor.equalsFloats(1.0, 1.0, 1.0) + ? undefined + : babylonMaterial.metallicReflectanceColor.asArray(); + var specularInfo = { + specularFactor: metallicF0Factor, + specularTexture: metallicReflectanceTexture, + specularColorFactor: metallicReflectanceColor, + specularColorTexture: reflectanceTexture, + hasTextures: function () { + return _this._hasTexturesExtension(babylonMaterial); + }, + }; + node.extensions[NAME] = specularInfo; + } + resolve(node); + }); + }; + return KHR_materials_specular; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_specular(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_transmission.ts": +/*!**************************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_transmission.ts ***! + \**************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_transmission: () => (/* binding */ KHR_materials_transmission) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_transmission"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_transmission/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_transmission = /** @class */ (function () { + function KHR_materials_transmission(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + /** Dispose */ + KHR_materials_transmission.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_transmission.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + /** + * After exporting a material, deal with additional textures + * @param context GLTF context of the material + * @param node exported GLTF node + * @param babylonMaterial corresponding babylon material + * @returns array of additional textures to export + */ + KHR_materials_transmission.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) { + var additionalTextures = []; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial) { + if (this._isExtensionEnabled(babylonMaterial)) { + if (babylonMaterial.subSurface.thicknessTexture) { + additionalTextures.push(babylonMaterial.subSurface.thicknessTexture); + } + return additionalTextures; + } + } + return additionalTextures; + }; + KHR_materials_transmission.prototype._isExtensionEnabled = function (mat) { + // This extension must not be used on a material that also uses KHR_materials_unlit + if (mat.unlit) { + return false; + } + var subs = mat.subSurface; + return (subs.isRefractionEnabled && subs.refractionIntensity != undefined && subs.refractionIntensity != 0) || this._hasTexturesExtension(mat); + }; + KHR_materials_transmission.prototype._hasTexturesExtension = function (mat) { + return mat.subSurface.refractionIntensityTexture != null; + }; + /** + * After exporting a material + * @param context GLTF context of the material + * @param node exported GLTF node + * @param babylonMaterial corresponding babylon material + * @returns true if successful + */ + KHR_materials_transmission.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + var _a; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial && _this._isExtensionEnabled(babylonMaterial)) { + _this._wasUsed = true; + var subs = babylonMaterial.subSurface; + var transmissionFactor = subs.refractionIntensity === 0 ? undefined : subs.refractionIntensity; + var transmissionTexture = (_a = _this._exporter._glTFMaterialExporter._getTextureInfo(subs.refractionIntensityTexture)) !== null && _a !== void 0 ? _a : undefined; + var volumeInfo = { + transmissionFactor: transmissionFactor, + transmissionTexture: transmissionTexture, + hasTextures: function () { + return _this._hasTexturesExtension(babylonMaterial); + }, + }; + node.extensions = node.extensions || {}; + node.extensions[NAME] = volumeInfo; + } + resolve(node); + }); + }; + return KHR_materials_transmission; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_transmission(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_unlit.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_unlit.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_unlit: () => (/* binding */ KHR_materials_unlit) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + + +var NAME = "KHR_materials_unlit"; +/** + * @internal + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_unlit = /** @class */ (function () { + function KHR_materials_unlit() { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + } + Object.defineProperty(KHR_materials_unlit.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_unlit.prototype.dispose = function () { }; + KHR_materials_unlit.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + var unlitMaterial = false; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial) { + unlitMaterial = babylonMaterial.unlit; + } + else if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.StandardMaterial) { + unlitMaterial = babylonMaterial.disableLighting; + } + if (unlitMaterial) { + _this._wasUsed = true; + if (node.extensions == null) { + node.extensions = {}; + } + node.extensions[NAME] = {}; + } + resolve(node); + }); + }; + return KHR_materials_unlit; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function () { return new KHR_materials_unlit(); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_volume.ts": +/*!********************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_volume.ts ***! + \********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_volume: () => (/* binding */ KHR_materials_volume) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + + +var NAME = "KHR_materials_volume"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_volume/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_volume = /** @class */ (function () { + function KHR_materials_volume(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + KHR_materials_volume.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_volume.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + /** + * After exporting a material, deal with additional textures + * @param context GLTF context of the material + * @param node exported GLTF node + * @param babylonMaterial corresponding babylon material + * @returns array of additional textures to export + */ + KHR_materials_volume.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) { + var additionalTextures = []; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial) { + if (this._isExtensionEnabled(babylonMaterial)) { + if (babylonMaterial.subSurface.thicknessTexture) { + additionalTextures.push(babylonMaterial.subSurface.thicknessTexture); + } + return additionalTextures; + } + } + return additionalTextures; + }; + KHR_materials_volume.prototype._isExtensionEnabled = function (mat) { + // This extension must not be used on a material that also uses KHR_materials_unlit + if (mat.unlit) { + return false; + } + var subs = mat.subSurface; + // this extension requires either the KHR_materials_transmission or KHR_materials_translucency extensions. + if (!subs.isRefractionEnabled && !subs.isTranslucencyEnabled) { + return false; + } + return ((subs.maximumThickness != undefined && subs.maximumThickness != 0) || + (subs.tintColorAtDistance != undefined && subs.tintColorAtDistance != Number.POSITIVE_INFINITY) || + (subs.tintColor != undefined && subs.tintColor != babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.Color3.White()) || + this._hasTexturesExtension(mat)); + }; + KHR_materials_volume.prototype._hasTexturesExtension = function (mat) { + return mat.subSurface.thicknessTexture != null; + }; + /** + * After exporting a material + * @param context GLTF context of the material + * @param node exported GLTF node + * @param babylonMaterial corresponding babylon material + * @returns promise that resolves with the updated node + */ + KHR_materials_volume.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + var _a; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial && _this._isExtensionEnabled(babylonMaterial)) { + _this._wasUsed = true; + var subs = babylonMaterial.subSurface; + var thicknessFactor = subs.maximumThickness == 0 ? undefined : subs.maximumThickness; + var thicknessTexture = (_a = _this._exporter._glTFMaterialExporter._getTextureInfo(subs.thicknessTexture)) !== null && _a !== void 0 ? _a : undefined; + var attenuationDistance = subs.tintColorAtDistance == Number.POSITIVE_INFINITY ? undefined : subs.tintColorAtDistance; + var attenuationColor = subs.tintColor.equalsFloats(1.0, 1.0, 1.0) ? undefined : subs.tintColor.asArray(); + var volumeInfo = { + thicknessFactor: thicknessFactor, + thicknessTexture: thicknessTexture, + attenuationDistance: attenuationDistance, + attenuationColor: attenuationColor, + hasTextures: function () { + return _this._hasTexturesExtension(babylonMaterial); + }, + }; + node.extensions = node.extensions || {}; + node.extensions[NAME] = volumeInfo; + } + resolve(node); + }); + }; + return KHR_materials_volume; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_volume(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_texture_transform.ts": +/*!*********************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_texture_transform.ts ***! + \*********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_texture_transform: () => (/* binding */ KHR_texture_transform) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); + + +var NAME = "KHR_texture_transform"; +/** + * @internal + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_texture_transform = /** @class */ (function () { + function KHR_texture_transform() { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + /** Reference to the glTF exporter */ + this._wasUsed = false; + } + KHR_texture_transform.prototype.dispose = function () { }; + Object.defineProperty(KHR_texture_transform.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_texture_transform.prototype.postExportTexture = function (context, textureInfo, babylonTexture) { + var canUseExtension = babylonTexture && + ((babylonTexture.uAng === 0 && babylonTexture.wAng === 0 && babylonTexture.vAng === 0) || + (babylonTexture.uRotationCenter === 0 && babylonTexture.vRotationCenter === 0)); + if (canUseExtension) { + var textureTransform = {}; + var transformIsRequired = false; + if (babylonTexture.uOffset !== 0 || babylonTexture.vOffset !== 0) { + textureTransform.offset = [babylonTexture.uOffset, babylonTexture.vOffset]; + transformIsRequired = true; + } + if (babylonTexture.uScale !== 1 || babylonTexture.vScale !== 1) { + textureTransform.scale = [babylonTexture.uScale, babylonTexture.vScale]; + transformIsRequired = true; + } + if (babylonTexture.wAng !== 0) { + textureTransform.rotation = -babylonTexture.wAng; + transformIsRequired = true; + } + if (babylonTexture.coordinatesIndex !== 0) { + textureTransform.texCoord = babylonTexture.coordinatesIndex; + transformIsRequired = true; + } + if (!transformIsRequired) { + return; + } + this._wasUsed = true; + if (!textureInfo.extensions) { + textureInfo.extensions = {}; + } + textureInfo.extensions[NAME] = textureTransform; + } + }; + KHR_texture_transform.prototype.preExportTextureAsync = function (context, babylonTexture) { + return new Promise(function (resolve, reject) { + var scene = babylonTexture.getScene(); + if (!scene) { + reject("".concat(context, ": \"scene\" is not defined for Babylon texture ").concat(babylonTexture.name, "!")); + return; + } + /* + * The KHR_texture_transform schema only supports w rotation around the origin. + * See https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform#gltf-schema-updates. + */ + if (babylonTexture.uAng !== 0 || babylonTexture.vAng !== 0) { + babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("".concat(context, ": Texture ").concat(babylonTexture.name, " with rotation in the u or v axis is not supported in glTF.")); + resolve(null); + } + else if (babylonTexture.wAng !== 0 && (babylonTexture.uRotationCenter !== 0 || babylonTexture.vRotationCenter !== 0)) { + babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("".concat(context, ": Texture ").concat(babylonTexture.name, " with rotation not centered at the origin cannot be exported with ").concat(NAME)); + resolve(null); + } + else { + resolve(babylonTexture); + } + }); + }; + return KHR_texture_transform; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_1__._Exporter.RegisterExtension(NAME, function () { return new KHR_texture_transform(); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/index.ts": +/*!*****************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/index.ts ***! + \*****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* reexport safe */ _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_12__.EXT_mesh_gpu_instancing), +/* harmony export */ KHR_lights_punctual: () => (/* reexport safe */ _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_1__.KHR_lights_punctual), +/* harmony export */ KHR_materials_anisotropy: () => (/* reexport safe */ _KHR_materials_anisotropy__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_anisotropy), +/* harmony export */ KHR_materials_clearcoat: () => (/* reexport safe */ _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_2__.KHR_materials_clearcoat), +/* harmony export */ KHR_materials_dispersion: () => (/* reexport safe */ _KHR_materials_dispersion__WEBPACK_IMPORTED_MODULE_10__.KHR_materials_dispersion), +/* harmony export */ KHR_materials_emissive_strength: () => (/* reexport safe */ _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_13__.KHR_materials_emissive_strength), +/* harmony export */ KHR_materials_ior: () => (/* reexport safe */ _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_ior), +/* harmony export */ KHR_materials_iridescence: () => (/* reexport safe */ _KHR_materials_iridescence__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_iridescence), +/* harmony export */ KHR_materials_sheen: () => (/* reexport safe */ _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_5__.KHR_materials_sheen), +/* harmony export */ KHR_materials_specular: () => (/* reexport safe */ _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_8__.KHR_materials_specular), +/* harmony export */ KHR_materials_transmission: () => (/* reexport safe */ _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_11__.KHR_materials_transmission), +/* harmony export */ KHR_materials_unlit: () => (/* reexport safe */ _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_6__.KHR_materials_unlit), +/* harmony export */ KHR_materials_volume: () => (/* reexport safe */ _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_9__.KHR_materials_volume), +/* harmony export */ KHR_texture_transform: () => (/* reexport safe */ _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_0__.KHR_texture_transform) +/* harmony export */ }); +/* harmony import */ var _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./KHR_texture_transform */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_texture_transform.ts"); +/* harmony import */ var _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./KHR_lights_punctual */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"); +/* harmony import */ var _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./KHR_materials_clearcoat */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts"); +/* harmony import */ var _KHR_materials_iridescence__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./KHR_materials_iridescence */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts"); +/* harmony import */ var _KHR_materials_anisotropy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./KHR_materials_anisotropy */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts"); +/* harmony import */ var _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./KHR_materials_sheen */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_sheen.ts"); +/* harmony import */ var _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./KHR_materials_unlit */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_unlit.ts"); +/* harmony import */ var _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./KHR_materials_ior */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_ior.ts"); +/* harmony import */ var _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./KHR_materials_specular */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_specular.ts"); +/* harmony import */ var _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./KHR_materials_volume */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_volume.ts"); +/* harmony import */ var _KHR_materials_dispersion__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./KHR_materials_dispersion */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts"); +/* harmony import */ var _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./KHR_materials_transmission */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"); +/* harmony import */ var _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./EXT_mesh_gpu_instancing */ "../../../dev/serializers/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts"); +/* harmony import */ var _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./KHR_materials_emissive_strength */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts"); + + + + + + + + + + + + + + + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/glTFAnimation.ts": +/*!**************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/glTFAnimation.ts ***! + \**************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ _GLTFAnimation: () => (/* binding */ _GLTFAnimation) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Lights/light */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFUtilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFUtilities */ "../../../dev/serializers/src/glTF/2.0/glTFUtilities.ts"); + + + + + + + + + + +/** + * @internal + * Enum for handling in tangent and out tangent. + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var _TangentType; +(function (_TangentType) { + /** + * Specifies that input tangents are used. + */ + _TangentType[_TangentType["INTANGENT"] = 0] = "INTANGENT"; + /** + * Specifies that output tangents are used. + */ + _TangentType[_TangentType["OUTTANGENT"] = 1] = "OUTTANGENT"; +})(_TangentType || (_TangentType = {})); +/** + * @internal + * Utility class for generating glTF animation data from BabylonJS. + */ +var _GLTFAnimation = /** @class */ (function () { + function _GLTFAnimation() { + } + /** + * Determine if a node is transformable - ie has properties it should be part of animation of transformation. + * @param babylonNode the node to test + * @returns true if can be animated, false otherwise. False if the parameter is null or undefined. + */ + _GLTFAnimation._IsTransformable = function (babylonNode) { + return babylonNode && (babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TransformNode || babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Camera || babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light); + }; + /** + * @ignore + * + * Creates glTF channel animation from BabylonJS animation. + * @param babylonTransformNode - BabylonJS mesh. + * @param animation - animation. + * @param animationChannelTargetPath - The target animation channel. + * @param useQuaternion - Specifies if quaternions are used. + * @returns nullable IAnimationData + */ + _GLTFAnimation._CreateNodeAnimation = function (babylonTransformNode, animation, animationChannelTargetPath, useQuaternion, animationSampleRate) { + if (this._IsTransformable(babylonTransformNode)) { + var inputs = []; + var outputs = []; + var keyFrames = animation.getKeys(); + var minMaxKeyFrames = _GLTFAnimation._CalculateMinMaxKeyFrames(keyFrames); + var interpolationOrBake = _GLTFAnimation._DeduceInterpolation(keyFrames, animationChannelTargetPath, useQuaternion); + var interpolation = interpolationOrBake.interpolationType; + var shouldBakeAnimation = interpolationOrBake.shouldBakeAnimation; + if (shouldBakeAnimation) { + _GLTFAnimation._CreateBakedAnimation(babylonTransformNode, animation, animationChannelTargetPath, minMaxKeyFrames.min, minMaxKeyFrames.max, animation.framePerSecond, animationSampleRate, inputs, outputs, minMaxKeyFrames, useQuaternion); + } + else { + if (interpolation === "LINEAR" /* AnimationSamplerInterpolation.LINEAR */ || interpolation === "STEP" /* AnimationSamplerInterpolation.STEP */) { + _GLTFAnimation._CreateLinearOrStepAnimation(babylonTransformNode, animation, animationChannelTargetPath, inputs, outputs, useQuaternion); + } + else if (interpolation === "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */) { + _GLTFAnimation._CreateCubicSplineAnimation(babylonTransformNode, animation, animationChannelTargetPath, inputs, outputs, useQuaternion); + } + else { + _GLTFAnimation._CreateBakedAnimation(babylonTransformNode, animation, animationChannelTargetPath, minMaxKeyFrames.min, minMaxKeyFrames.max, animation.framePerSecond, animationSampleRate, inputs, outputs, minMaxKeyFrames, useQuaternion); + } + } + if (inputs.length && outputs.length) { + var result = { + inputs: inputs, + outputs: outputs, + samplerInterpolation: interpolation, + inputsMin: shouldBakeAnimation ? minMaxKeyFrames.min : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.FloatRound(minMaxKeyFrames.min / animation.framePerSecond), + inputsMax: shouldBakeAnimation ? minMaxKeyFrames.max : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.FloatRound(minMaxKeyFrames.max / animation.framePerSecond), + }; + return result; + } + } + return null; + }; + _GLTFAnimation._DeduceAnimationInfo = function (animation) { + var animationChannelTargetPath = null; + var dataAccessorType = "VEC3" /* AccessorType.VEC3 */; + var useQuaternion = false; + var property = animation.targetProperty.split("."); + switch (property[0]) { + case "scaling": { + animationChannelTargetPath = "scale" /* AnimationChannelTargetPath.SCALE */; + break; + } + case "position": { + animationChannelTargetPath = "translation" /* AnimationChannelTargetPath.TRANSLATION */; + break; + } + case "rotation": { + dataAccessorType = "VEC4" /* AccessorType.VEC4 */; + animationChannelTargetPath = "rotation" /* AnimationChannelTargetPath.ROTATION */; + break; + } + case "rotationQuaternion": { + dataAccessorType = "VEC4" /* AccessorType.VEC4 */; + useQuaternion = true; + animationChannelTargetPath = "rotation" /* AnimationChannelTargetPath.ROTATION */; + break; + } + case "influence": { + dataAccessorType = "SCALAR" /* AccessorType.SCALAR */; + animationChannelTargetPath = "weights" /* AnimationChannelTargetPath.WEIGHTS */; + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("Unsupported animatable property ".concat(property[0])); + } + } + if (animationChannelTargetPath) { + return { animationChannelTargetPath: animationChannelTargetPath, dataAccessorType: dataAccessorType, useQuaternion: useQuaternion }; + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("animation channel target path and data accessor type could be deduced"); + } + return null; + }; + /** + * @ignore + * Create node animations from the transform node animations + * @param babylonNode + * @param runtimeGLTFAnimation + * @param idleGLTFAnimations + * @param nodeMap + * @param nodes + * @param binaryWriter + * @param bufferViews + * @param accessors + * @param animationSampleRate + */ + _GLTFAnimation._CreateNodeAnimationFromNodeAnimations = function (babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, nodes, binaryWriter, bufferViews, accessors, animationSampleRate, shouldExportAnimation) { + var glTFAnimation; + if (_GLTFAnimation._IsTransformable(babylonNode)) { + if (babylonNode.animations) { + for (var _i = 0, _a = babylonNode.animations; _i < _a.length; _i++) { + var animation = _a[_i]; + if (shouldExportAnimation && !shouldExportAnimation(animation)) { + continue; + } + var animationInfo = _GLTFAnimation._DeduceAnimationInfo(animation); + if (animationInfo) { + glTFAnimation = { + name: animation.name, + samplers: [], + channels: [], + }; + _GLTFAnimation._AddAnimation("".concat(animation.name), animation.hasRunningRuntimeAnimations ? runtimeGLTFAnimation : glTFAnimation, babylonNode, animation, animationInfo.dataAccessorType, animationInfo.animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, animationInfo.useQuaternion, animationSampleRate); + if (glTFAnimation.samplers.length && glTFAnimation.channels.length) { + idleGLTFAnimations.push(glTFAnimation); + } + } + } + } + } + }; + /** + * @ignore + * Create individual morph animations from the mesh's morph target animation tracks + * @param babylonNode + * @param runtimeGLTFAnimation + * @param idleGLTFAnimations + * @param nodeMap + * @param nodes + * @param binaryWriter + * @param bufferViews + * @param accessors + * @param animationSampleRate + */ + _GLTFAnimation._CreateMorphTargetAnimationFromMorphTargetAnimations = function (babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, nodes, binaryWriter, bufferViews, accessors, animationSampleRate, shouldExportAnimation) { + var glTFAnimation; + if (babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh) { + var morphTargetManager = babylonNode.morphTargetManager; + if (morphTargetManager) { + for (var i = 0; i < morphTargetManager.numTargets; ++i) { + var morphTarget = morphTargetManager.getTarget(i); + for (var _i = 0, _a = morphTarget.animations; _i < _a.length; _i++) { + var animation = _a[_i]; + if (shouldExportAnimation && !shouldExportAnimation(animation)) { + continue; + } + var combinedAnimation = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation("".concat(animation.name), "influence", animation.framePerSecond, animation.dataType, animation.loopMode, animation.enableBlending); + var combinedAnimationKeys = []; + var animationKeys = animation.getKeys(); + for (var j = 0; j < animationKeys.length; ++j) { + var animationKey = animationKeys[j]; + for (var k = 0; k < morphTargetManager.numTargets; ++k) { + if (k == i) { + combinedAnimationKeys.push(animationKey); + } + else { + combinedAnimationKeys.push({ frame: animationKey.frame, value: 0 }); + } + } + } + combinedAnimation.setKeys(combinedAnimationKeys); + var animationInfo = _GLTFAnimation._DeduceAnimationInfo(combinedAnimation); + if (animationInfo) { + glTFAnimation = { + name: combinedAnimation.name, + samplers: [], + channels: [], + }; + _GLTFAnimation._AddAnimation(animation.name, animation.hasRunningRuntimeAnimations ? runtimeGLTFAnimation : glTFAnimation, babylonNode, combinedAnimation, animationInfo.dataAccessorType, animationInfo.animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, animationInfo.useQuaternion, animationSampleRate, morphTargetManager.numTargets); + if (glTFAnimation.samplers.length && glTFAnimation.channels.length) { + idleGLTFAnimations.push(glTFAnimation); + } + } + } + } + } + } + }; + /** + * @internal + * Create node and morph animations from the animation groups + * @param babylonScene + * @param glTFAnimations + * @param nodeMap + * @param nodes + * @param binaryWriter + * @param bufferViews + * @param accessors + * @param animationSampleRate + */ + _GLTFAnimation._CreateNodeAndMorphAnimationFromAnimationGroups = function (babylonScene, glTFAnimations, nodeMap, binaryWriter, bufferViews, accessors, animationSampleRate, shouldExportAnimation) { + var _a; + var glTFAnimation; + if (babylonScene.animationGroups) { + var animationGroups = babylonScene.animationGroups; + var _loop_1 = function (animationGroup) { + var morphAnimations = new Map(); + var sampleAnimations = new Map(); + var morphAnimationMeshes = new Set(); + var animationGroupFrameDiff = animationGroup.to - animationGroup.from; + glTFAnimation = { + name: animationGroup.name, + channels: [], + samplers: [], + }; + var _loop_2 = function (i) { + var targetAnimation = animationGroup.targetedAnimations[i]; + var target = targetAnimation.target; + var animation = targetAnimation.animation; + if (shouldExportAnimation && !shouldExportAnimation(animation)) { + return "continue"; + } + if (this_1._IsTransformable(target) || (target.length === 1 && this_1._IsTransformable(target[0]))) { + var animationInfo = _GLTFAnimation._DeduceAnimationInfo(targetAnimation.animation); + if (animationInfo) { + var babylonTransformNode = this_1._IsTransformable(target) ? target : this_1._IsTransformable(target[0]) ? target[0] : null; + if (babylonTransformNode) { + _GLTFAnimation._AddAnimation("".concat(animation.name), glTFAnimation, babylonTransformNode, animation, animationInfo.dataAccessorType, animationInfo.animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, animationInfo.useQuaternion, animationSampleRate); + } + } + } + else if (target instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.MorphTarget || (target.length === 1 && target[0] instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.MorphTarget)) { + var animationInfo = _GLTFAnimation._DeduceAnimationInfo(targetAnimation.animation); + if (animationInfo) { + var babylonMorphTarget_1 = target instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.MorphTarget ? target : target[0]; + if (babylonMorphTarget_1) { + var babylonMorphTargetManager_1 = babylonScene.morphTargetManagers.find(function (morphTargetManager) { + for (var j = 0; j < morphTargetManager.numTargets; ++j) { + if (morphTargetManager.getTarget(j) === babylonMorphTarget_1) { + return true; + } + } + return false; + }); + if (babylonMorphTargetManager_1) { + var babylonMesh = babylonScene.meshes.find(function (mesh) { + return mesh.morphTargetManager === babylonMorphTargetManager_1; + }); + if (babylonMesh) { + if (!morphAnimations.has(babylonMesh)) { + morphAnimations.set(babylonMesh, new Map()); + } + (_a = morphAnimations.get(babylonMesh)) === null || _a === void 0 ? void 0 : _a.set(babylonMorphTarget_1, animation); + morphAnimationMeshes.add(babylonMesh); + sampleAnimations.set(babylonMesh, animation); + } + } + } + } + } + else { + // this is the place for the KHR_animation_pointer. + } + }; + for (var i = 0; i < animationGroup.targetedAnimations.length; ++i) { + _loop_2(i); + } + morphAnimationMeshes.forEach(function (mesh) { + var morphTargetManager = mesh.morphTargetManager; + var combinedAnimationGroup = null; + var animationKeys = []; + var sampleAnimation = sampleAnimations.get(mesh); + var sampleAnimationKeys = sampleAnimation.getKeys(); + var numAnimationKeys = sampleAnimationKeys.length; + /* + Due to how glTF expects morph target animation data to be formatted, we need to rearrange the individual morph target animation tracks, + such that we have a single animation, where a given keyframe input value has successive output values for each morph target belonging to the manager. + See: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations + + We do this via constructing a new Animation track, and interleaving the frames of each morph target animation track in the current Animation Group + We reuse the Babylon Animation data structure for ease of handling export of cubic spline animation keys, and to reuse the + existing _GLTFAnimation.AddAnimation codepath with minimal modification, however the constructed Babylon Animation is NOT intended for use in-engine. + */ + for (var i = 0; i < numAnimationKeys; ++i) { + for (var j = 0; j < morphTargetManager.numTargets; ++j) { + var morphTarget = morphTargetManager.getTarget(j); + var animationsByMorphTarget = morphAnimations.get(mesh); + if (animationsByMorphTarget) { + var morphTargetAnimation = animationsByMorphTarget.get(morphTarget); + if (morphTargetAnimation) { + if (!combinedAnimationGroup) { + combinedAnimationGroup = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation("".concat(animationGroup.name, "_").concat(mesh.name, "_MorphWeightAnimation"), "influence", morphTargetAnimation.framePerSecond, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, morphTargetAnimation.loopMode, morphTargetAnimation.enableBlending); + } + animationKeys.push(morphTargetAnimation.getKeys()[i]); + } + else { + animationKeys.push({ + frame: animationGroup.from + (animationGroupFrameDiff / numAnimationKeys) * i, + value: morphTarget.influence, + inTangent: sampleAnimationKeys[0].inTangent ? 0 : undefined, + outTangent: sampleAnimationKeys[0].outTangent ? 0 : undefined, + }); + } + } + } + } + combinedAnimationGroup.setKeys(animationKeys); + var animationInfo = _GLTFAnimation._DeduceAnimationInfo(combinedAnimationGroup); + if (animationInfo) { + _GLTFAnimation._AddAnimation("".concat(animationGroup.name, "_").concat(mesh.name, "_MorphWeightAnimation"), glTFAnimation, mesh, combinedAnimationGroup, animationInfo.dataAccessorType, animationInfo.animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, animationInfo.useQuaternion, animationSampleRate, morphTargetManager === null || morphTargetManager === void 0 ? void 0 : morphTargetManager.numTargets); + } + }); + if (glTFAnimation.channels.length && glTFAnimation.samplers.length) { + glTFAnimations.push(glTFAnimation); + } + }; + var this_1 = this; + for (var _i = 0, animationGroups_1 = animationGroups; _i < animationGroups_1.length; _i++) { + var animationGroup = animationGroups_1[_i]; + _loop_1(animationGroup); + } + } + }; + _GLTFAnimation._AddAnimation = function (name, glTFAnimation, babylonTransformNode, animation, dataAccessorType, animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, useQuaternion, animationSampleRate, morphAnimationChannels) { + var animationData = _GLTFAnimation._CreateNodeAnimation(babylonTransformNode, animation, animationChannelTargetPath, useQuaternion, animationSampleRate); + var bufferView; + var accessor; + var keyframeAccessorIndex; + var dataAccessorIndex; + var outputLength; + var animationSampler; + var animationChannel; + if (animationData) { + /* + * Now that we have the glTF converted morph target animation data, + * we can remove redundant input data so that we have n input frames, + * and morphAnimationChannels * n output frames + */ + if (morphAnimationChannels) { + var index = 0; + var currentInput = 0; + var newInputs = []; + while (animationData.inputs.length > 0) { + currentInput = animationData.inputs.shift(); + if (index % morphAnimationChannels == 0) { + newInputs.push(currentInput); + } + index++; + } + animationData.inputs = newInputs; + } + var nodeIndex = nodeMap[babylonTransformNode.uniqueId]; + // Creates buffer view and accessor for key frames. + var byteLength = animationData.inputs.length * 4; + bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_1__._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, "".concat(name, " keyframe data view")); + bufferViews.push(bufferView); + animationData.inputs.forEach(function (input) { + binaryWriter.setFloat32(input); + }); + accessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_1__._GLTFUtilities._CreateAccessor(bufferViews.length - 1, "".concat(name, " keyframes"), "SCALAR" /* AccessorType.SCALAR */, 5126 /* AccessorComponentType.FLOAT */, animationData.inputs.length, null, [animationData.inputsMin], [animationData.inputsMax]); + accessors.push(accessor); + keyframeAccessorIndex = accessors.length - 1; + // create bufferview and accessor for keyed values. + outputLength = animationData.outputs.length; + byteLength = _glTFUtilities__WEBPACK_IMPORTED_MODULE_1__._GLTFUtilities._GetDataAccessorElementCount(dataAccessorType) * 4 * animationData.outputs.length; + // check for in and out tangents + bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_1__._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, "".concat(name, " data view")); + bufferViews.push(bufferView); + animationData.outputs.forEach(function (output) { + output.forEach(function (entry) { + binaryWriter.setFloat32(entry); + }); + }); + accessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_1__._GLTFUtilities._CreateAccessor(bufferViews.length - 1, "".concat(name, " data"), dataAccessorType, 5126 /* AccessorComponentType.FLOAT */, outputLength, null, null, null); + accessors.push(accessor); + dataAccessorIndex = accessors.length - 1; + // create sampler + animationSampler = { + interpolation: animationData.samplerInterpolation, + input: keyframeAccessorIndex, + output: dataAccessorIndex, + }; + glTFAnimation.samplers.push(animationSampler); + // create channel + animationChannel = { + sampler: glTFAnimation.samplers.length - 1, + target: { + node: nodeIndex, + path: animationChannelTargetPath, + }, + }; + glTFAnimation.channels.push(animationChannel); + } + }; + /** + * Create a baked animation + * @param babylonTransformNode BabylonJS mesh + * @param animation BabylonJS animation corresponding to the BabylonJS mesh + * @param animationChannelTargetPath animation target channel + * @param minFrame minimum animation frame + * @param maxFrame maximum animation frame + * @param fps frames per second of the animation + * @param sampleRate + * @param inputs input key frames of the animation + * @param outputs output key frame data of the animation + * @param minMaxFrames + * @param minMaxFrames.min + * @param minMaxFrames.max + * @param useQuaternion specifies if quaternions should be used + */ + _GLTFAnimation._CreateBakedAnimation = function (babylonTransformNode, animation, animationChannelTargetPath, minFrame, maxFrame, fps, sampleRate, inputs, outputs, minMaxFrames, useQuaternion) { + var value; + var quaternionCache = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity(); + var previousTime = null; + var time; + var maxUsedFrame = null; + var currKeyFrame = null; + var nextKeyFrame = null; + var prevKeyFrame = null; + var endFrame = null; + minMaxFrames.min = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.FloatRound(minFrame / fps); + var keyFrames = animation.getKeys(); + for (var i = 0, length_1 = keyFrames.length; i < length_1; ++i) { + endFrame = null; + currKeyFrame = keyFrames[i]; + if (i + 1 < length_1) { + nextKeyFrame = keyFrames[i + 1]; + if ((currKeyFrame.value.equals && currKeyFrame.value.equals(nextKeyFrame.value)) || currKeyFrame.value === nextKeyFrame.value) { + if (i === 0) { + // set the first frame to itself + endFrame = currKeyFrame.frame; + } + else { + continue; + } + } + else { + endFrame = nextKeyFrame.frame; + } + } + else { + // at the last key frame + prevKeyFrame = keyFrames[i - 1]; + if ((currKeyFrame.value.equals && currKeyFrame.value.equals(prevKeyFrame.value)) || currKeyFrame.value === prevKeyFrame.value) { + continue; + } + else { + endFrame = maxFrame; + } + } + if (endFrame) { + for (var f = currKeyFrame.frame; f <= endFrame; f += sampleRate) { + time = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.FloatRound(f / fps); + if (time === previousTime) { + continue; + } + previousTime = time; + maxUsedFrame = time; + var state = { + key: 0, + repeatCount: 0, + loopMode: animation.loopMode, + }; + value = animation._interpolate(f, state); + _GLTFAnimation._SetInterpolatedValue(babylonTransformNode, value, time, animation, animationChannelTargetPath, quaternionCache, inputs, outputs, useQuaternion); + } + } + } + if (maxUsedFrame) { + minMaxFrames.max = maxUsedFrame; + } + }; + _GLTFAnimation._ConvertFactorToVector3OrQuaternion = function (factor, babylonTransformNode, animation, animationChannelTargetPath, useQuaternion) { + var basePositionRotationOrScale = _GLTFAnimation._GetBasePositionRotationOrScale(babylonTransformNode, animationChannelTargetPath, useQuaternion); + // handles single component x, y, z or w component animation by using a base property and animating over a component. + var property = animation.targetProperty.split("."); + var componentName = property ? property[1] : ""; // x, y, z, or w component + var value = useQuaternion ? babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(basePositionRotationOrScale).normalize() : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(basePositionRotationOrScale); + switch (componentName) { + case "x": + case "y": + case "z": { + value[componentName] = factor; + break; + } + case "w": { + value.w = factor; + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("glTFAnimation: Unsupported component name \"".concat(componentName, "\"!")); + } + } + return value; + }; + _GLTFAnimation._SetInterpolatedValue = function (babylonTransformNode, value, time, animation, animationChannelTargetPath, quaternionCache, inputs, outputs, useQuaternion) { + var cacheValue; + inputs.push(time); + if (animationChannelTargetPath === "weights" /* AnimationChannelTargetPath.WEIGHTS */) { + outputs.push([value]); + return; + } + if (animation.dataType === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT) { + value = this._ConvertFactorToVector3OrQuaternion(value, babylonTransformNode, animation, animationChannelTargetPath, useQuaternion); + } + if (animationChannelTargetPath === "rotation" /* AnimationChannelTargetPath.ROTATION */) { + if (useQuaternion) { + quaternionCache = value; + } + else { + cacheValue = value; + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.RotationYawPitchRollToRef(cacheValue.y, cacheValue.x, cacheValue.z, quaternionCache); + } + outputs.push(quaternionCache.asArray()); + } + else { + // scaling and position animation + cacheValue = value; + outputs.push(cacheValue.asArray()); + } + }; + /** + * Creates linear animation from the animation key frames + * @param babylonTransformNode BabylonJS mesh + * @param animation BabylonJS animation + * @param animationChannelTargetPath The target animation channel + * @param inputs Array to store the key frame times + * @param outputs Array to store the key frame data + * @param useQuaternion Specifies if quaternions are used in the animation + */ + _GLTFAnimation._CreateLinearOrStepAnimation = function (babylonTransformNode, animation, animationChannelTargetPath, inputs, outputs, useQuaternion) { + for (var _i = 0, _a = animation.getKeys(); _i < _a.length; _i++) { + var keyFrame = _a[_i]; + inputs.push(keyFrame.frame / animation.framePerSecond); // keyframes in seconds. + _GLTFAnimation._AddKeyframeValue(keyFrame, animation, outputs, animationChannelTargetPath, babylonTransformNode, useQuaternion); + } + }; + /** + * Creates cubic spline animation from the animation key frames + * @param babylonTransformNode BabylonJS mesh + * @param animation BabylonJS animation + * @param animationChannelTargetPath The target animation channel + * @param inputs Array to store the key frame times + * @param outputs Array to store the key frame data + * @param useQuaternion Specifies if quaternions are used in the animation + */ + _GLTFAnimation._CreateCubicSplineAnimation = function (babylonTransformNode, animation, animationChannelTargetPath, inputs, outputs, useQuaternion) { + animation.getKeys().forEach(function (keyFrame) { + inputs.push(keyFrame.frame / animation.framePerSecond); // keyframes in seconds. + _GLTFAnimation._AddSplineTangent(_TangentType.INTANGENT, outputs, animationChannelTargetPath, "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */, keyFrame, useQuaternion); + _GLTFAnimation._AddKeyframeValue(keyFrame, animation, outputs, animationChannelTargetPath, babylonTransformNode, useQuaternion); + _GLTFAnimation._AddSplineTangent(_TangentType.OUTTANGENT, outputs, animationChannelTargetPath, "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */, keyFrame, useQuaternion); + }); + }; + _GLTFAnimation._GetBasePositionRotationOrScale = function (babylonTransformNode, animationChannelTargetPath, useQuaternion) { + var basePositionRotationOrScale; + if (animationChannelTargetPath === "rotation" /* AnimationChannelTargetPath.ROTATION */) { + if (useQuaternion) { + var q = babylonTransformNode.rotationQuaternion; + basePositionRotationOrScale = (q !== null && q !== void 0 ? q : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity()).asArray(); + } + else { + var r = babylonTransformNode.rotation; + basePositionRotationOrScale = (r !== null && r !== void 0 ? r : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero()).asArray(); + } + } + else if (animationChannelTargetPath === "translation" /* AnimationChannelTargetPath.TRANSLATION */) { + var p = babylonTransformNode.position; + basePositionRotationOrScale = (p !== null && p !== void 0 ? p : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero()).asArray(); + } + else { + // scale + var s = babylonTransformNode.scaling; + basePositionRotationOrScale = (s !== null && s !== void 0 ? s : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.One()).asArray(); + } + return basePositionRotationOrScale; + }; + /** + * Adds a key frame value + * @param keyFrame + * @param animation + * @param outputs + * @param animationChannelTargetPath + * @param babylonTransformNode + * @param useQuaternion + */ + _GLTFAnimation._AddKeyframeValue = function (keyFrame, animation, outputs, animationChannelTargetPath, babylonTransformNode, useQuaternion) { + var newPositionRotationOrScale; + var animationType = animation.dataType; + if (animationType === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_VECTOR3) { + var value = keyFrame.value.asArray(); + if (animationChannelTargetPath === "rotation" /* AnimationChannelTargetPath.ROTATION */) { + var array = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(value); + var rotationQuaternion = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.RotationYawPitchRoll(array.y, array.x, array.z); + value = rotationQuaternion.asArray(); + } + outputs.push(value); // scale vector. + } + else if (animationType === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT) { + if (animationChannelTargetPath === "weights" /* AnimationChannelTargetPath.WEIGHTS */) { + outputs.push([keyFrame.value]); + } + else { + // handles single component x, y, z or w component animation by using a base property and animating over a component. + newPositionRotationOrScale = this._ConvertFactorToVector3OrQuaternion(keyFrame.value, babylonTransformNode, animation, animationChannelTargetPath, useQuaternion); + if (newPositionRotationOrScale) { + if (animationChannelTargetPath === "rotation" /* AnimationChannelTargetPath.ROTATION */) { + var posRotScale = useQuaternion + ? newPositionRotationOrScale + : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.RotationYawPitchRoll(newPositionRotationOrScale.y, newPositionRotationOrScale.x, newPositionRotationOrScale.z).normalize(); + outputs.push(posRotScale.asArray()); + } + outputs.push(newPositionRotationOrScale.asArray()); + } + } + } + else if (animationType === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_QUATERNION) { + outputs.push(keyFrame.value.normalize().asArray()); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("glTFAnimation: Unsupported key frame values for animation!"); + } + }; + /** + * @internal + * Determine the interpolation based on the key frames + * @param keyFrames + * @param animationChannelTargetPath + * @param useQuaternion + */ + _GLTFAnimation._DeduceInterpolation = function (keyFrames, animationChannelTargetPath, useQuaternion) { + var interpolationType; + var shouldBakeAnimation = false; + var key; + if (animationChannelTargetPath === "rotation" /* AnimationChannelTargetPath.ROTATION */ && !useQuaternion) { + return { interpolationType: "LINEAR" /* AnimationSamplerInterpolation.LINEAR */, shouldBakeAnimation: true }; + } + for (var i = 0, length_2 = keyFrames.length; i < length_2; ++i) { + key = keyFrames[i]; + if (key.inTangent || key.outTangent) { + if (interpolationType) { + if (interpolationType !== "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */) { + interpolationType = "LINEAR" /* AnimationSamplerInterpolation.LINEAR */; + shouldBakeAnimation = true; + break; + } + } + else { + interpolationType = "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */; + } + } + else { + if (interpolationType) { + if (interpolationType === "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */ || + (key.interpolation && key.interpolation === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.AnimationKeyInterpolation.STEP && interpolationType !== "STEP" /* AnimationSamplerInterpolation.STEP */)) { + interpolationType = "LINEAR" /* AnimationSamplerInterpolation.LINEAR */; + shouldBakeAnimation = true; + break; + } + } + else { + if (key.interpolation && key.interpolation === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.AnimationKeyInterpolation.STEP) { + interpolationType = "STEP" /* AnimationSamplerInterpolation.STEP */; + } + else { + interpolationType = "LINEAR" /* AnimationSamplerInterpolation.LINEAR */; + } + } + } + } + if (!interpolationType) { + interpolationType = "LINEAR" /* AnimationSamplerInterpolation.LINEAR */; + } + return { interpolationType: interpolationType, shouldBakeAnimation: shouldBakeAnimation }; + }; + /** + * Adds an input tangent or output tangent to the output data + * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion + * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent) + * @param outputs The animation data by keyframe + * @param animationChannelTargetPath The target animation channel + * @param interpolation The interpolation type + * @param keyFrame The key frame with the animation data + * @param useQuaternion Specifies if quaternions are used + */ + _GLTFAnimation._AddSplineTangent = function (tangentType, outputs, animationChannelTargetPath, interpolation, keyFrame, useQuaternion) { + var tangent; + var tangentValue = tangentType === _TangentType.INTANGENT ? keyFrame.inTangent : keyFrame.outTangent; + if (interpolation === "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */) { + if (animationChannelTargetPath === "rotation" /* AnimationChannelTargetPath.ROTATION */) { + if (tangentValue) { + if (useQuaternion) { + tangent = tangentValue.asArray(); + } + else { + var array = tangentValue; + tangent = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.RotationYawPitchRoll(array.y, array.x, array.z).asArray(); + } + } + else { + tangent = [0, 0, 0, 0]; + } + } + else if (animationChannelTargetPath === "weights" /* AnimationChannelTargetPath.WEIGHTS */) { + if (tangentValue) { + tangent = [tangentValue]; + } + else { + tangent = [0]; + } + } + else { + if (tangentValue) { + tangent = tangentValue.asArray(); + } + else { + tangent = [0, 0, 0]; + } + } + outputs.push(tangent); + } + }; + /** + * Get the minimum and maximum key frames' frame values + * @param keyFrames animation key frames + * @returns the minimum and maximum key frame value + */ + _GLTFAnimation._CalculateMinMaxKeyFrames = function (keyFrames) { + var min = Infinity; + var max = -Infinity; + keyFrames.forEach(function (keyFrame) { + min = Math.min(min, keyFrame.frame); + max = Math.max(max, keyFrame.frame); + }); + return { min: min, max: max }; + }; + return _GLTFAnimation; +}()); + + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/glTFData.ts": +/*!*********************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/glTFData.ts ***! + \*********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFData: () => (/* binding */ GLTFData) +/* harmony export */ }); +/** + * Class for holding and downloading glTF file data + */ +var GLTFData = /** @class */ (function () { + /** + * Initializes the glTF file object + */ + function GLTFData() { + this.glTFFiles = {}; + } + /** + * Downloads the glTF data as files based on their names and data + */ + GLTFData.prototype.downloadFiles = function () { + /** + * Checks for a matching suffix at the end of a string (for ES5 and lower) + * @param str Source string + * @param suffix Suffix to search for in the source string + * @returns Boolean indicating whether the suffix was found (true) or not (false) + */ + function endsWith(str, suffix) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; + } + for (var key in this.glTFFiles) { + var link = document.createElement("a"); + document.body.appendChild(link); + link.setAttribute("type", "hidden"); + link.download = key; + var blob = this.glTFFiles[key]; + var mimeType = void 0; + if (endsWith(key, ".glb")) { + mimeType = { type: "model/gltf-binary" }; + } + else if (endsWith(key, ".bin")) { + mimeType = { type: "application/octet-stream" }; + } + else if (endsWith(key, ".gltf")) { + mimeType = { type: "model/gltf+json" }; + } + else if (endsWith(key, ".jpeg") || endsWith(key, ".jpg")) { + mimeType = { type: "image/jpeg" /* ImageMimeType.JPEG */ }; + } + else if (endsWith(key, ".png")) { + mimeType = { type: "image/png" /* ImageMimeType.PNG */ }; + } + link.href = window.URL.createObjectURL(new Blob([blob], mimeType)); + link.click(); + } + }; + return GLTFData; +}()); + + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts": +/*!*************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/glTFExporter.ts ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ _BinaryWriter: () => (/* binding */ _BinaryWriter), +/* harmony export */ _Exporter: () => (/* binding */ _Exporter) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/multiMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFMaterialExporter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFMaterialExporter */ "../../../dev/serializers/src/glTF/2.0/glTFMaterialExporter.ts"); +/* harmony import */ var _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFUtilities */ "../../../dev/serializers/src/glTF/2.0/glTFUtilities.ts"); +/* harmony import */ var _glTFData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./glTFData */ "../../../dev/serializers/src/glTF/2.0/glTFData.ts"); +/* harmony import */ var _glTFAnimation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./glTFAnimation */ "../../../dev/serializers/src/glTF/2.0/glTFAnimation.ts"); + + + + + + + + + + + + + + + + + + +// Matrix that converts handedness on the X-axis. +var convertHandednessMatrix = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Matrix.Compose(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3(-1, 1, 1), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity(), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero()); +// 180 degrees rotation in Y. +var rotation180Y = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion(0, 1, 0, 0); +function isNoopNode(node, useRightHandedSystem) { + if (!(node instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TransformNode)) { + return false; + } + // Transform + if (useRightHandedSystem) { + var matrix = node.getWorldMatrix(); + if (!matrix.isIdentity()) { + return false; + } + } + else { + var matrix = node.getWorldMatrix().multiplyToRef(convertHandednessMatrix, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0]); + if (!matrix.isIdentity()) { + return false; + } + } + // Geometry + if ((node instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh && node.geometry) || (node instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.InstancedMesh && node.sourceMesh.geometry)) { + return false; + } + return true; +} +function convertNodeHandedness(node) { + var translation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(node.translation || [0, 0, 0], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0]); + var rotation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArrayToRef(node.rotation || [0, 0, 0, 1], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0]); + var scale = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(node.scale || [1, 1, 1], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1]); + var matrix = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Matrix.ComposeToRef(scale, rotation, translation, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0]).multiplyToRef(convertHandednessMatrix, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0]); + matrix.decompose(scale, rotation, translation); + if (translation.equalsToFloats(0, 0, 0)) { + delete node.translation; + } + else { + node.translation = translation.asArray(); + } + if (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.IsIdentity(rotation)) { + delete node.rotation; + } + else { + node.rotation = rotation.asArray(); + } + if (scale.equalsToFloats(1, 1, 1)) { + delete node.scale; + } + else { + node.scale = scale.asArray(); + } +} +/** + * Converts Babylon Scene into glTF 2.0. + * @internal + */ +var _Exporter = /** @class */ (function () { + /** + * Creates a glTF Exporter instance, which can accept optional exporter options + * @param babylonScene Babylon scene object + * @param options Options to modify the behavior of the exporter + */ + function _Exporter(babylonScene, options) { + this._extensions = {}; + this._glTF = { + asset: { generator: "Babylon.js v".concat(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Engine.Version), version: "2.0" }, + }; + babylonScene = babylonScene || babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.EngineStore.LastCreatedScene; + if (!babylonScene) { + return; + } + this._babylonScene = babylonScene; + this._bufferViews = []; + this._accessors = []; + this._meshes = []; + this._scenes = []; + this._cameras = []; + this._nodes = []; + this._images = []; + this._materials = []; + this._materialMap = []; + this._textures = []; + this._samplers = []; + this._skins = []; + this._animations = []; + this._imageData = {}; + this._orderedImageData = []; + this._options = options || {}; + this._animationSampleRate = this._options.animationSampleRate || 1 / 60; + this._glTFMaterialExporter = new _glTFMaterialExporter__WEBPACK_IMPORTED_MODULE_1__._GLTFMaterialExporter(this); + this._loadExtensions(); + } + _Exporter.prototype._applyExtension = function (node, extensions, index, actionAsync) { + var _this = this; + if (index >= extensions.length) { + return Promise.resolve(node); + } + var currentPromise = actionAsync(extensions[index], node); + if (!currentPromise) { + return this._applyExtension(node, extensions, index + 1, actionAsync); + } + return currentPromise.then(function (newNode) { return _this._applyExtension(newNode, extensions, index + 1, actionAsync); }); + }; + _Exporter.prototype._applyExtensions = function (node, actionAsync) { + var extensions = []; + for (var _i = 0, _a = _Exporter._ExtensionNames; _i < _a.length; _i++) { + var name_1 = _a[_i]; + extensions.push(this._extensions[name_1]); + } + return this._applyExtension(node, extensions, 0, actionAsync); + }; + _Exporter.prototype._extensionsPreExportTextureAsync = function (context, babylonTexture, mimeType) { + return this._applyExtensions(babylonTexture, function (extension, node) { return extension.preExportTextureAsync && extension.preExportTextureAsync(context, node, mimeType); }); + }; + _Exporter.prototype._extensionsPostExportMeshPrimitiveAsync = function (context, meshPrimitive, babylonSubMesh, binaryWriter) { + return this._applyExtensions(meshPrimitive, function (extension, node) { return extension.postExportMeshPrimitiveAsync && extension.postExportMeshPrimitiveAsync(context, node, babylonSubMesh, binaryWriter); }); + }; + _Exporter.prototype._extensionsPostExportNodeAsync = function (context, node, babylonNode, nodeMap, binaryWriter) { + return this._applyExtensions(node, function (extension, node) { return extension.postExportNodeAsync && extension.postExportNodeAsync(context, node, babylonNode, nodeMap, binaryWriter); }); + }; + _Exporter.prototype._extensionsPostExportMaterialAsync = function (context, material, babylonMaterial) { + return this._applyExtensions(material, function (extension, node) { return extension.postExportMaterialAsync && extension.postExportMaterialAsync(context, node, babylonMaterial); }); + }; + _Exporter.prototype._extensionsPostExportMaterialAdditionalTextures = function (context, material, babylonMaterial) { + var output = []; + for (var _i = 0, _a = _Exporter._ExtensionNames; _i < _a.length; _i++) { + var name_2 = _a[_i]; + var extension = this._extensions[name_2]; + if (extension.postExportMaterialAdditionalTextures) { + output.push.apply(output, extension.postExportMaterialAdditionalTextures(context, material, babylonMaterial)); + } + } + return output; + }; + _Exporter.prototype._extensionsPostExportTextures = function (context, textureInfo, babylonTexture) { + for (var _i = 0, _a = _Exporter._ExtensionNames; _i < _a.length; _i++) { + var name_3 = _a[_i]; + var extension = this._extensions[name_3]; + if (extension.postExportTexture) { + extension.postExportTexture(context, textureInfo, babylonTexture); + } + } + }; + _Exporter.prototype._forEachExtensions = function (action) { + for (var _i = 0, _a = _Exporter._ExtensionNames; _i < _a.length; _i++) { + var name_4 = _a[_i]; + var extension = this._extensions[name_4]; + if (extension.enabled) { + action(extension); + } + } + }; + _Exporter.prototype._extensionsOnExporting = function () { + var _this = this; + this._forEachExtensions(function (extension) { + if (extension.wasUsed) { + if (_this._glTF.extensionsUsed == null) { + _this._glTF.extensionsUsed = []; + } + if (_this._glTF.extensionsUsed.indexOf(extension.name) === -1) { + _this._glTF.extensionsUsed.push(extension.name); + } + if (extension.required) { + if (_this._glTF.extensionsRequired == null) { + _this._glTF.extensionsRequired = []; + } + if (_this._glTF.extensionsRequired.indexOf(extension.name) === -1) { + _this._glTF.extensionsRequired.push(extension.name); + } + } + if (_this._glTF.extensions == null) { + _this._glTF.extensions = {}; + } + if (extension.onExporting) { + extension.onExporting(); + } + } + }); + }; + /** + * Load glTF serializer extensions + */ + _Exporter.prototype._loadExtensions = function () { + for (var _i = 0, _a = _Exporter._ExtensionNames; _i < _a.length; _i++) { + var name_5 = _a[_i]; + var extension = _Exporter._ExtensionFactories[name_5](this); + this._extensions[name_5] = extension; + } + }; + _Exporter.prototype.dispose = function () { + for (var extensionKey in this._extensions) { + var extension = this._extensions[extensionKey]; + extension.dispose(); + } + }; + Object.defineProperty(_Exporter.prototype, "options", { + get: function () { + return this._options; + }, + enumerable: false, + configurable: true + }); + /** + * Registers a glTF exporter extension + * @param name Name of the extension to export + * @param factory The factory function that creates the exporter extension + */ + _Exporter.RegisterExtension = function (name, factory) { + if (_Exporter.UnregisterExtension(name)) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Extension with the name ".concat(name, " already exists")); + } + _Exporter._ExtensionFactories[name] = factory; + _Exporter._ExtensionNames.push(name); + }; + /** + * Un-registers an exporter extension + * @param name The name fo the exporter extension + * @returns A boolean indicating whether the extension has been un-registered + */ + _Exporter.UnregisterExtension = function (name) { + if (!_Exporter._ExtensionFactories[name]) { + return false; + } + delete _Exporter._ExtensionFactories[name]; + var index = _Exporter._ExtensionNames.indexOf(name); + if (index !== -1) { + _Exporter._ExtensionNames.splice(index, 1); + } + return true; + }; + _Exporter.prototype._reorderIndicesBasedOnPrimitiveMode = function (submesh, primitiveMode, babylonIndices, byteOffset, binaryWriter) { + switch (primitiveMode) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode: { + if (!byteOffset) { + byteOffset = 0; + } + for (var i = submesh.indexStart, length_1 = submesh.indexStart + submesh.indexCount; i < length_1; i = i + 3) { + var index = byteOffset + i * 4; + // swap the second and third indices + var secondIndex = binaryWriter.getUInt32(index + 4); + var thirdIndex = binaryWriter.getUInt32(index + 8); + binaryWriter.setUInt32(thirdIndex, index + 4); + binaryWriter.setUInt32(secondIndex, index + 8); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFanDrawMode: { + for (var i = submesh.indexStart + submesh.indexCount - 1, start = submesh.indexStart; i >= start; --i) { + binaryWriter.setUInt32(babylonIndices[i], byteOffset); + byteOffset += 4; + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleStripDrawMode: { + if (submesh.indexCount >= 3) { + binaryWriter.setUInt32(babylonIndices[submesh.indexStart + 2], byteOffset + 4); + binaryWriter.setUInt32(babylonIndices[submesh.indexStart + 1], byteOffset + 8); + } + break; + } + } + }; + /** + * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is + * clock-wise during export to glTF + * @param submesh BabylonJS submesh + * @param primitiveMode Primitive mode of the mesh + * @param vertexBufferKind The type of vertex attribute + * @param meshAttributeArray The vertex attribute data + * @param byteOffset The offset to the binary data + * @param binaryWriter The binary data for the glTF file + */ + _Exporter.prototype._reorderVertexAttributeDataBasedOnPrimitiveMode = function (submesh, primitiveMode, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter) { + switch (primitiveMode) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode: { + this._reorderTriangleFillMode(submesh, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter); + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleStripDrawMode: { + this._reorderTriangleStripDrawMode(submesh, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter); + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFanDrawMode: { + this._reorderTriangleFanMode(submesh, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter); + break; + } + } + }; + /** + * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is + * clock-wise during export to glTF + * @param submesh BabylonJS submesh + * @param vertexBufferKind The type of vertex attribute + * @param meshAttributeArray The vertex attribute data + * @param byteOffset The offset to the binary data + * @param binaryWriter The binary data for the glTF file + */ + _Exporter.prototype._reorderTriangleFillMode = function (submesh, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter) { + var vertexBuffer = this._getVertexBufferFromMesh(vertexBufferKind, submesh.getMesh()); + if (vertexBuffer) { + var stride = vertexBuffer.byteStride / babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(vertexBuffer.type); + if (submesh.verticesCount % 3 !== 0) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("The submesh vertices for the triangle fill mode is not divisible by 3!"); + } + else { + var vertexData = []; + var index = 0; + switch (vertexBufferKind) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind: { + for (var x = submesh.verticesStart; x < submesh.verticesStart + submesh.verticesCount; x = x + 3) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index + 2 * stride)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index + stride)); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind: { + for (var x = submesh.verticesStart; x < submesh.verticesStart + submesh.verticesCount; x = x + 3) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index + 2 * stride)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index + stride)); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind: { + var size = vertexBuffer.getSize(); + for (var x = submesh.verticesStart; x < submesh.verticesStart + submesh.verticesCount; x = x + size) { + index = x * stride; + if (size === 4) { + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index + 2 * stride)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index + stride)); + } + else { + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index + 2 * stride)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index + stride)); + } + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind: { + for (var x = submesh.verticesStart; x < submesh.verticesStart + submesh.verticesCount; x = x + 3) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2.FromArray(meshAttributeArray, index)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2.FromArray(meshAttributeArray, index + 2 * stride)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2.FromArray(meshAttributeArray, index + stride)); + } + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("Unsupported Vertex Buffer type: ".concat(vertexBufferKind)); + } + } + this._writeVertexAttributeData(vertexData, byteOffset, vertexBufferKind, binaryWriter); + } + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("reorderTriangleFillMode: Vertex Buffer Kind ".concat(vertexBufferKind, " not present!")); + } + }; + /** + * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is + * clock-wise during export to glTF + * @param submesh BabylonJS submesh + * @param vertexBufferKind The type of vertex attribute + * @param meshAttributeArray The vertex attribute data + * @param byteOffset The offset to the binary data + * @param binaryWriter The binary data for the glTF file + */ + _Exporter.prototype._reorderTriangleStripDrawMode = function (submesh, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter) { + var vertexBuffer = this._getVertexBufferFromMesh(vertexBufferKind, submesh.getMesh()); + if (vertexBuffer) { + var stride = vertexBuffer.byteStride / babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(vertexBuffer.type); + var vertexData = []; + var index = 0; + switch (vertexBufferKind) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind: { + index = submesh.verticesStart; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index + 2 * stride)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index + stride)); + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind: { + for (var x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index)); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind: { + for (var x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) { + index = x * stride; + vertexBuffer.getSize() === 4 + ? vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index)) + : vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index)); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind: { + for (var x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2.FromArray(meshAttributeArray, index)); + } + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("Unsupported Vertex Buffer type: ".concat(vertexBufferKind)); + } + } + this._writeVertexAttributeData(vertexData, byteOffset + 12, vertexBufferKind, binaryWriter); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("reorderTriangleStripDrawMode: Vertex buffer kind ".concat(vertexBufferKind, " not present!")); + } + }; + /** + * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is + * clock-wise during export to glTF + * @param submesh BabylonJS submesh + * @param vertexBufferKind The type of vertex attribute + * @param meshAttributeArray The vertex attribute data + * @param byteOffset The offset to the binary data + * @param binaryWriter The binary data for the glTF file + */ + _Exporter.prototype._reorderTriangleFanMode = function (submesh, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter) { + var vertexBuffer = this._getVertexBufferFromMesh(vertexBufferKind, submesh.getMesh()); + if (vertexBuffer) { + var stride = vertexBuffer.byteStride / babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(vertexBuffer.type); + var vertexData = []; + var index = 0; + switch (vertexBufferKind) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind: { + for (var x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index)); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind: { + for (var x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index)); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind: { + for (var x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index)); + vertexBuffer.getSize() === 4 + ? vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index)) + : vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index)); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind: { + for (var x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2.FromArray(meshAttributeArray, index)); + } + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("Unsupported Vertex Buffer type: ".concat(vertexBufferKind)); + } + } + this._writeVertexAttributeData(vertexData, byteOffset, vertexBufferKind, binaryWriter); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("reorderTriangleFanMode: Vertex buffer kind ".concat(vertexBufferKind, " not present!")); + } + }; + /** + * Writes the vertex attribute data to binary + * @param vertices The vertices to write to the binary writer + * @param byteOffset The offset into the binary writer to overwrite binary data + * @param vertexAttributeKind The vertex attribute type + * @param binaryWriter The writer containing the binary data + */ + _Exporter.prototype._writeVertexAttributeData = function (vertices, byteOffset, vertexAttributeKind, binaryWriter) { + for (var _i = 0, vertices_1 = vertices; _i < vertices_1.length; _i++) { + var vertex = vertices_1[_i]; + if (vertexAttributeKind === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind) { + vertex.normalize(); + } + else if (vertexAttributeKind === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind && vertex instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4) { + _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._NormalizeTangentFromRef(vertex); + } + for (var _a = 0, _b = vertex.asArray(); _a < _b.length; _a++) { + var component = _b[_a]; + binaryWriter.setFloat32(component, byteOffset); + byteOffset += 4; + } + } + }; + /** + * Writes mesh attribute data to a data buffer + * Returns the bytelength of the data + * @param vertexBufferKind Indicates what kind of vertex data is being passed in + * @param attributeComponentKind + * @param meshAttributeArray Array containing the attribute data + * @param stride Specifies the space between data + * @param binaryWriter The buffer to write the binary data to + * @param babylonTransformNode + */ + _Exporter.prototype._writeAttributeData = function (vertexBufferKind, attributeComponentKind, meshAttributeArray, stride, binaryWriter, babylonTransformNode) { + var vertexAttributes = []; + var index; + switch (vertexBufferKind) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind: { + for (var k = 0, length_2 = meshAttributeArray.length / stride; k < length_2; ++k) { + index = k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index); + vertexAttributes.push(vertexData.asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind: { + for (var k = 0, length_3 = meshAttributeArray.length / stride; k < length_3; ++k) { + index = k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index); + vertexAttributes.push(vertexData.normalize().asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind: { + for (var k = 0, length_4 = meshAttributeArray.length / stride; k < length_4; ++k) { + index = k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index); + _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._NormalizeTangentFromRef(vertexData); + vertexAttributes.push(vertexData.asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind: { + var meshMaterial = babylonTransformNode.material; + var convertToLinear = meshMaterial ? meshMaterial.getClassName() === "StandardMaterial" : true; + var vertexData = stride === 3 ? new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3() : new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color4(); + var useExactSrgbConversions = this._babylonScene.getEngine().useExactSrgbConversions; + for (var k = 0, length_5 = meshAttributeArray.length / stride; k < length_5; ++k) { + index = k * stride; + if (stride === 3) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArrayToRef(meshAttributeArray, index, vertexData); + if (convertToLinear) { + vertexData.toLinearSpaceToRef(vertexData, useExactSrgbConversions); + } + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color4.FromArrayToRef(meshAttributeArray, index, vertexData); + if (convertToLinear) { + vertexData.toLinearSpaceToRef(vertexData, useExactSrgbConversions); + } + } + vertexAttributes.push(vertexData.asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind: { + for (var k = 0, length_6 = meshAttributeArray.length / stride; k < length_6; ++k) { + index = k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2.FromArray(meshAttributeArray, index); + vertexAttributes.push(vertexData.asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind: { + for (var k = 0, length_7 = meshAttributeArray.length / stride; k < length_7; ++k) { + index = k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index); + vertexAttributes.push(vertexData.asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsExtraKind: { + for (var k = 0, length_8 = meshAttributeArray.length / stride; k < length_8; ++k) { + index = k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index); + vertexAttributes.push(vertexData.asArray()); + } + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Unsupported Vertex Buffer Type: " + vertexBufferKind); + vertexAttributes = []; + } + } + var writeBinaryFunc; + switch (attributeComponentKind) { + case 5121 /* AccessorComponentType.UNSIGNED_BYTE */: { + writeBinaryFunc = binaryWriter.setUInt8.bind(binaryWriter); + break; + } + case 5123 /* AccessorComponentType.UNSIGNED_SHORT */: { + writeBinaryFunc = binaryWriter.setUInt16.bind(binaryWriter); + break; + } + case 5125 /* AccessorComponentType.UNSIGNED_INT */: { + writeBinaryFunc = binaryWriter.setUInt32.bind(binaryWriter); + break; + } + case 5126 /* AccessorComponentType.FLOAT */: { + writeBinaryFunc = binaryWriter.setFloat32.bind(binaryWriter); + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Unsupported Attribute Component kind: " + attributeComponentKind); + return; + } + } + for (var _i = 0, vertexAttributes_1 = vertexAttributes; _i < vertexAttributes_1.length; _i++) { + var vertexAttribute = vertexAttributes_1[_i]; + for (var _a = 0, vertexAttribute_1 = vertexAttribute; _a < vertexAttribute_1.length; _a++) { + var component = vertexAttribute_1[_a]; + writeBinaryFunc(component); + } + } + }; + /** + * Writes mesh attribute data to a data buffer + * Returns the bytelength of the data + * @param vertexBufferKind Indicates what kind of vertex data is being passed in + * @param attributeComponentKind attribute component type + * @param meshPrimitive the mesh primitive + * @param meshAttributeArray Array containing the attribute data + * @param morphTargetAttributeArray + * @param stride Specifies the space between data + * @param binaryWriter The buffer to write the binary data to + * @param minMax + */ + _Exporter.prototype.writeMorphTargetAttributeData = function (vertexBufferKind, attributeComponentKind, meshPrimitive, meshAttributeArray, morphTargetAttributeArray, stride, binaryWriter, minMax) { + var vertexAttributes = []; + var index; + var difference = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3(); + var difference4 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4(0, 0, 0, 0); + switch (vertexBufferKind) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind: { + for (var k = meshPrimitive.verticesStart; k < meshPrimitive.verticesCount; ++k) { + index = meshPrimitive.indexStart + k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index); + var morphData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(morphTargetAttributeArray, index); + difference = morphData.subtractToRef(vertexData, difference); + if (minMax) { + minMax.min.copyFromFloats(Math.min(difference.x, minMax.min.x), Math.min(difference.y, minMax.min.y), Math.min(difference.z, minMax.min.z)); + minMax.max.copyFromFloats(Math.max(difference.x, minMax.max.x), Math.max(difference.y, minMax.max.y), Math.max(difference.z, minMax.max.z)); + } + vertexAttributes.push(difference.asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind: { + for (var k = meshPrimitive.verticesStart; k < meshPrimitive.verticesCount; ++k) { + index = meshPrimitive.indexStart + k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index).normalize(); + var morphData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(morphTargetAttributeArray, index).normalize(); + difference = morphData.subtractToRef(vertexData, difference); + vertexAttributes.push(difference.asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind: { + for (var k = meshPrimitive.verticesStart; k < meshPrimitive.verticesCount; ++k) { + index = meshPrimitive.indexStart + k * (stride + 1); + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index); + _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._NormalizeTangentFromRef(vertexData); + var morphData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(morphTargetAttributeArray, index); + _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._NormalizeTangentFromRef(morphData); + difference4 = morphData.subtractToRef(vertexData, difference4); + vertexAttributes.push([difference4.x, difference4.y, difference4.z]); + } + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Unsupported Vertex Buffer Type: " + vertexBufferKind); + vertexAttributes = []; + } + } + var writeBinaryFunc; + switch (attributeComponentKind) { + case 5121 /* AccessorComponentType.UNSIGNED_BYTE */: { + writeBinaryFunc = binaryWriter.setUInt8.bind(binaryWriter); + break; + } + case 5123 /* AccessorComponentType.UNSIGNED_SHORT */: { + writeBinaryFunc = binaryWriter.setUInt16.bind(binaryWriter); + break; + } + case 5125 /* AccessorComponentType.UNSIGNED_INT */: { + writeBinaryFunc = binaryWriter.setUInt32.bind(binaryWriter); + break; + } + case 5126 /* AccessorComponentType.FLOAT */: { + writeBinaryFunc = binaryWriter.setFloat32.bind(binaryWriter); + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Unsupported Attribute Component kind: " + attributeComponentKind); + return; + } + } + for (var _i = 0, vertexAttributes_2 = vertexAttributes; _i < vertexAttributes_2.length; _i++) { + var vertexAttribute = vertexAttributes_2[_i]; + for (var _a = 0, vertexAttribute_2 = vertexAttribute; _a < vertexAttribute_2.length; _a++) { + var component = vertexAttribute_2[_a]; + writeBinaryFunc(component); + } + } + }; + /** + * Generates glTF json data + * @param shouldUseGlb Indicates whether the json should be written for a glb file + * @param glTFPrefix Text to use when prefixing a glTF file + * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false) + * @returns json data as string + */ + _Exporter.prototype._generateJSON = function (shouldUseGlb, glTFPrefix, prettyPrint) { + var _this = this; + var buffer = { byteLength: this._totalByteLength }; + var imageName; + var imageData; + var bufferView; + var byteOffset = this._totalByteLength; + if (buffer.byteLength) { + this._glTF.buffers = [buffer]; + } + if (this._nodes && this._nodes.length) { + this._glTF.nodes = this._nodes; + } + if (this._meshes && this._meshes.length) { + this._glTF.meshes = this._meshes; + } + if (this._scenes && this._scenes.length) { + this._glTF.scenes = this._scenes; + this._glTF.scene = 0; + } + if (this._cameras && this._cameras.length) { + this._glTF.cameras = this._cameras; + } + if (this._bufferViews && this._bufferViews.length) { + this._glTF.bufferViews = this._bufferViews; + } + if (this._accessors && this._accessors.length) { + this._glTF.accessors = this._accessors; + } + if (this._animations && this._animations.length) { + this._glTF.animations = this._animations; + } + if (this._materials && this._materials.length) { + this._glTF.materials = this._materials; + } + if (this._textures && this._textures.length) { + this._glTF.textures = this._textures; + } + if (this._samplers && this._samplers.length) { + this._glTF.samplers = this._samplers; + } + if (this._skins && this._skins.length) { + this._glTF.skins = this._skins; + } + if (this._images && this._images.length) { + if (!shouldUseGlb) { + this._glTF.images = this._images; + } + else { + this._glTF.images = []; + this._images.forEach(function (image) { + if (image.uri) { + imageData = _this._imageData[image.uri]; + _this._orderedImageData.push(imageData); + imageName = image.uri.split(".")[0] + " image"; + bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateBufferView(0, byteOffset, imageData.data.byteLength, undefined, imageName); + byteOffset += imageData.data.byteLength; + _this._bufferViews.push(bufferView); + image.bufferView = _this._bufferViews.length - 1; + image.name = imageName; + image.mimeType = imageData.mimeType; + image.uri = undefined; + if (!_this._glTF.images) { + _this._glTF.images = []; + } + _this._glTF.images.push(image); + } + }); + // Replace uri with bufferview and mime type for glb + buffer.byteLength = byteOffset; + } + } + if (!shouldUseGlb) { + buffer.uri = glTFPrefix + ".bin"; + } + var jsonText = prettyPrint ? JSON.stringify(this._glTF, null, 2) : JSON.stringify(this._glTF); + return jsonText; + }; + /** + * Generates data for .gltf and .bin files based on the glTF prefix string + * @param glTFPrefix Text to use when prefixing a glTF file + * @param dispose Dispose the exporter + * @returns GLTFData with glTF file data + */ + _Exporter.prototype._generateGLTFAsync = function (glTFPrefix, dispose) { + var _this = this; + if (dispose === void 0) { dispose = true; } + return this._generateBinaryAsync().then(function (binaryBuffer) { + _this._extensionsOnExporting(); + var jsonText = _this._generateJSON(false, glTFPrefix, true); + var bin = new Blob([binaryBuffer], { type: "application/octet-stream" }); + var glTFFileName = glTFPrefix + ".gltf"; + var glTFBinFile = glTFPrefix + ".bin"; + var container = new _glTFData__WEBPACK_IMPORTED_MODULE_3__.GLTFData(); + container.glTFFiles[glTFFileName] = jsonText; + container.glTFFiles[glTFBinFile] = bin; + if (_this._imageData) { + for (var image in _this._imageData) { + container.glTFFiles[image] = new Blob([_this._imageData[image].data], { type: _this._imageData[image].mimeType }); + } + } + if (dispose) { + _this.dispose(); + } + return container; + }); + }; + /** + * Creates a binary buffer for glTF + * @returns array buffer for binary data + */ + _Exporter.prototype._generateBinaryAsync = function () { + var _this = this; + var binaryWriter = new _BinaryWriter(4); + return this._createSceneAsync(binaryWriter).then(function () { + if (_this._localEngine) { + _this._localEngine.dispose(); + } + return binaryWriter.getArrayBuffer(); + }); + }; + /** + * Pads the number to a multiple of 4 + * @param num number to pad + * @returns padded number + */ + _Exporter.prototype._getPadding = function (num) { + var remainder = num % 4; + var padding = remainder === 0 ? remainder : 4 - remainder; + return padding; + }; + /** + * @internal + */ + _Exporter.prototype._generateGLBAsync = function (glTFPrefix, dispose) { + var _this = this; + if (dispose === void 0) { dispose = true; } + return this._generateBinaryAsync().then(function (binaryBuffer) { + _this._extensionsOnExporting(); + var jsonText = _this._generateJSON(true); + var glbFileName = glTFPrefix + ".glb"; + var headerLength = 12; + var chunkLengthPrefix = 8; + var jsonLength = jsonText.length; + var encodedJsonText; + var imageByteLength = 0; + // make use of TextEncoder when available + if (typeof TextEncoder !== "undefined") { + var encoder = new TextEncoder(); + encodedJsonText = encoder.encode(jsonText); + jsonLength = encodedJsonText.length; + } + for (var i = 0; i < _this._orderedImageData.length; ++i) { + imageByteLength += _this._orderedImageData[i].data.byteLength; + } + var jsonPadding = _this._getPadding(jsonLength); + var binPadding = _this._getPadding(binaryBuffer.byteLength); + var imagePadding = _this._getPadding(imageByteLength); + var byteLength = headerLength + 2 * chunkLengthPrefix + jsonLength + jsonPadding + binaryBuffer.byteLength + binPadding + imageByteLength + imagePadding; + //header + var headerBuffer = new ArrayBuffer(headerLength); + var headerBufferView = new DataView(headerBuffer); + headerBufferView.setUint32(0, 0x46546c67, true); //glTF + headerBufferView.setUint32(4, 2, true); // version + headerBufferView.setUint32(8, byteLength, true); // total bytes in file + //json chunk + var jsonChunkBuffer = new ArrayBuffer(chunkLengthPrefix + jsonLength + jsonPadding); + var jsonChunkBufferView = new DataView(jsonChunkBuffer); + jsonChunkBufferView.setUint32(0, jsonLength + jsonPadding, true); + jsonChunkBufferView.setUint32(4, 0x4e4f534a, true); + //json chunk bytes + var jsonData = new Uint8Array(jsonChunkBuffer, chunkLengthPrefix); + // if TextEncoder was available, we can simply copy the encoded array + if (encodedJsonText) { + jsonData.set(encodedJsonText); + } + else { + var blankCharCode = "_".charCodeAt(0); + for (var i = 0; i < jsonLength; ++i) { + var charCode = jsonText.charCodeAt(i); + // if the character doesn't fit into a single UTF-16 code unit, just put a blank character + if (charCode != jsonText.codePointAt(i)) { + jsonData[i] = blankCharCode; + } + else { + jsonData[i] = charCode; + } + } + } + //json padding + var jsonPaddingView = new Uint8Array(jsonChunkBuffer, chunkLengthPrefix + jsonLength); + for (var i = 0; i < jsonPadding; ++i) { + jsonPaddingView[i] = 0x20; + } + //binary chunk + var binaryChunkBuffer = new ArrayBuffer(chunkLengthPrefix); + var binaryChunkBufferView = new DataView(binaryChunkBuffer); + binaryChunkBufferView.setUint32(0, binaryBuffer.byteLength + imageByteLength + imagePadding, true); + binaryChunkBufferView.setUint32(4, 0x004e4942, true); + // binary padding + var binPaddingBuffer = new ArrayBuffer(binPadding); + var binPaddingView = new Uint8Array(binPaddingBuffer); + for (var i = 0; i < binPadding; ++i) { + binPaddingView[i] = 0; + } + var imagePaddingBuffer = new ArrayBuffer(imagePadding); + var imagePaddingView = new Uint8Array(imagePaddingBuffer); + for (var i = 0; i < imagePadding; ++i) { + imagePaddingView[i] = 0; + } + var glbData = [headerBuffer, jsonChunkBuffer, binaryChunkBuffer, binaryBuffer]; + // binary data + for (var i = 0; i < _this._orderedImageData.length; ++i) { + glbData.push(_this._orderedImageData[i].data); + } + glbData.push(binPaddingBuffer); + glbData.push(imagePaddingBuffer); + var glbFile = new Blob(glbData, { type: "application/octet-stream" }); + var container = new _glTFData__WEBPACK_IMPORTED_MODULE_3__.GLTFData(); + container.glTFFiles[glbFileName] = glbFile; + if (_this._localEngine != null) { + _this._localEngine.dispose(); + } + if (dispose) { + _this.dispose(); + } + return container; + }); + }; + /** + * Sets the TRS for each node + * @param node glTF Node for storing the transformation data + * @param babylonTransformNode Babylon mesh used as the source for the transformation data + */ + _Exporter.prototype._setNodeTransformation = function (node, babylonTransformNode) { + if (!babylonTransformNode.getPivotPoint().equalsToFloats(0, 0, 0)) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Pivot points are not supported in the glTF serializer"); + } + if (!babylonTransformNode.position.equalsToFloats(0, 0, 0)) { + node.translation = babylonTransformNode.position.asArray(); + } + if (!babylonTransformNode.scaling.equalsToFloats(1, 1, 1)) { + node.scale = babylonTransformNode.scaling.asArray(); + } + var rotationQuaternion = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromEulerAngles(babylonTransformNode.rotation.x, babylonTransformNode.rotation.y, babylonTransformNode.rotation.z); + if (babylonTransformNode.rotationQuaternion) { + rotationQuaternion.multiplyInPlace(babylonTransformNode.rotationQuaternion); + } + if (!babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.IsIdentity(rotationQuaternion)) { + node.rotation = rotationQuaternion.normalize().asArray(); + } + }; + _Exporter.prototype._setCameraTransformation = function (node, babylonCamera) { + var translation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0]; + var rotation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0]; + babylonCamera.getWorldMatrix().decompose(undefined, rotation, translation); + if (!translation.equalsToFloats(0, 0, 0)) { + node.translation = translation.asArray(); + } + // // Rotation by 180 as glTF has a different convention than Babylon. + rotation.multiplyInPlace(rotation180Y); + if (!babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.IsIdentity(rotation)) { + node.rotation = rotation.asArray(); + } + }; + _Exporter.prototype._getVertexBufferFromMesh = function (attributeKind, bufferMesh) { + if (bufferMesh.isVerticesDataPresent(attributeKind, true)) { + var vertexBuffer = bufferMesh.getVertexBuffer(attributeKind, true); + if (vertexBuffer) { + return vertexBuffer; + } + } + return null; + }; + /** + * Creates a bufferview based on the vertices type for the Babylon mesh + * @param kind Indicates the type of vertices data + * @param attributeComponentKind Indicates the numerical type used to store the data + * @param babylonTransformNode The Babylon mesh to get the vertices data from + * @param binaryWriter The buffer to write the bufferview data to + * @param byteStride + */ + _Exporter.prototype._createBufferViewKind = function (kind, attributeComponentKind, babylonTransformNode, binaryWriter, byteStride) { + var bufferMesh = babylonTransformNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh + ? babylonTransformNode + : babylonTransformNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.InstancedMesh + ? babylonTransformNode.sourceMesh + : null; + if (bufferMesh) { + var vertexBuffer = bufferMesh.getVertexBuffer(kind, true); + var vertexData = bufferMesh.getVerticesData(kind, undefined, undefined, true); + if (vertexBuffer && vertexData) { + var typeByteLength = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(attributeComponentKind); + var byteLength = vertexData.length * typeByteLength; + var bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, byteStride, kind + " - " + bufferMesh.name); + this._bufferViews.push(bufferView); + this._writeAttributeData(kind, attributeComponentKind, vertexData, byteStride / typeByteLength, binaryWriter, babylonTransformNode); + } + } + }; + /** + * Creates a bufferview based on the vertices type for the Babylon mesh + * @param babylonSubMesh The Babylon submesh that the morph target is applied to + * @param meshPrimitive + * @param babylonMorphTarget the morph target to be exported + * @param binaryWriter The buffer to write the bufferview data to + */ + _Exporter.prototype._setMorphTargetAttributes = function (babylonSubMesh, meshPrimitive, babylonMorphTarget, binaryWriter) { + if (babylonMorphTarget) { + if (!meshPrimitive.targets) { + meshPrimitive.targets = []; + } + var target = {}; + var mesh = babylonSubMesh.getMesh(); + if (babylonMorphTarget.hasNormals) { + var vertexNormals = mesh.getVerticesData(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind, undefined, undefined, true); + var morphNormals = babylonMorphTarget.getNormals(); + var count = babylonSubMesh.verticesCount; + var byteStride = 12; // 3 x 4 byte floats + var byteLength = count * byteStride; + var bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, byteStride, babylonMorphTarget.name + "_NORMAL"); + this._bufferViews.push(bufferView); + var bufferViewIndex = this._bufferViews.length - 1; + var accessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateAccessor(bufferViewIndex, babylonMorphTarget.name + " - " + "NORMAL", "VEC3" /* AccessorType.VEC3 */, 5126 /* AccessorComponentType.FLOAT */, count, 0, null, null); + this._accessors.push(accessor); + target.NORMAL = this._accessors.length - 1; + this.writeMorphTargetAttributeData(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind, 5126 /* AccessorComponentType.FLOAT */, babylonSubMesh, vertexNormals, morphNormals, byteStride / 4, binaryWriter); + } + if (babylonMorphTarget.hasPositions) { + var vertexPositions = mesh.getVerticesData(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind, undefined, undefined, true); + var morphPositions = babylonMorphTarget.getPositions(); + var count = babylonSubMesh.verticesCount; + var byteStride = 12; // 3 x 4 byte floats + var byteLength = count * byteStride; + var bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, byteStride, babylonMorphTarget.name + "_POSITION"); + this._bufferViews.push(bufferView); + var bufferViewIndex = this._bufferViews.length - 1; + var minMax = { min: new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3(Infinity, Infinity, Infinity), max: new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3(-Infinity, -Infinity, -Infinity) }; + var accessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateAccessor(bufferViewIndex, babylonMorphTarget.name + " - " + "POSITION", "VEC3" /* AccessorType.VEC3 */, 5126 /* AccessorComponentType.FLOAT */, count, 0, null, null); + this._accessors.push(accessor); + target.POSITION = this._accessors.length - 1; + this.writeMorphTargetAttributeData(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind, 5126 /* AccessorComponentType.FLOAT */, babylonSubMesh, vertexPositions, morphPositions, byteStride / 4, binaryWriter, minMax); + accessor.min = minMax.min.asArray(); + accessor.max = minMax.max.asArray(); + } + if (babylonMorphTarget.hasTangents) { + var vertexTangents = mesh.getVerticesData(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind, undefined, undefined, true); + var morphTangents = babylonMorphTarget.getTangents(); + var count = babylonSubMesh.verticesCount; + var byteStride = 12; // 3 x 4 byte floats + var byteLength = count * byteStride; + var bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, byteStride, babylonMorphTarget.name + "_NORMAL"); + this._bufferViews.push(bufferView); + var bufferViewIndex = this._bufferViews.length - 1; + var accessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateAccessor(bufferViewIndex, babylonMorphTarget.name + " - " + "TANGENT", "VEC3" /* AccessorType.VEC3 */, 5126 /* AccessorComponentType.FLOAT */, count, 0, null, null); + this._accessors.push(accessor); + target.TANGENT = this._accessors.length - 1; + this.writeMorphTargetAttributeData(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind, 5126 /* AccessorComponentType.FLOAT */, babylonSubMesh, vertexTangents, morphTangents, byteStride / 4, binaryWriter); + } + meshPrimitive.targets.push(target); + } + }; + /** + * The primitive mode of the Babylon mesh + * @param babylonMesh The BabylonJS mesh + * @returns Unsigned integer of the primitive mode or null + */ + _Exporter.prototype._getMeshPrimitiveMode = function (babylonMesh) { + if (babylonMesh instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.LinesMesh) { + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.LineListDrawMode; + } + if (babylonMesh instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.InstancedMesh || babylonMesh instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh) { + var baseMesh = babylonMesh instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh ? babylonMesh : babylonMesh.sourceMesh; + if (typeof baseMesh.overrideRenderingFillMode === "number") { + return baseMesh.overrideRenderingFillMode; + } + } + return babylonMesh.material ? babylonMesh.material.fillMode : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode; + }; + /** + * Sets the primitive mode of the glTF mesh primitive + * @param meshPrimitive glTF mesh primitive + * @param primitiveMode The primitive mode + */ + _Exporter.prototype._setPrimitiveMode = function (meshPrimitive, primitiveMode) { + switch (primitiveMode) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode: { + // glTF defaults to using Triangle Mode + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleStripDrawMode: { + meshPrimitive.mode = 5 /* MeshPrimitiveMode.TRIANGLE_STRIP */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFanDrawMode: { + meshPrimitive.mode = 6 /* MeshPrimitiveMode.TRIANGLE_FAN */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.PointListDrawMode: { + meshPrimitive.mode = 0 /* MeshPrimitiveMode.POINTS */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.PointFillMode: { + meshPrimitive.mode = 0 /* MeshPrimitiveMode.POINTS */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.LineLoopDrawMode: { + meshPrimitive.mode = 2 /* MeshPrimitiveMode.LINE_LOOP */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.LineListDrawMode: { + meshPrimitive.mode = 1 /* MeshPrimitiveMode.LINES */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.LineStripDrawMode: { + meshPrimitive.mode = 3 /* MeshPrimitiveMode.LINE_STRIP */; + break; + } + } + }; + /** + * Sets the vertex attribute accessor based of the glTF mesh primitive + * @param meshPrimitive glTF mesh primitive + * @param attributeKind vertex attribute + */ + _Exporter.prototype._setAttributeKind = function (meshPrimitive, attributeKind) { + switch (attributeKind) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind: { + meshPrimitive.attributes.POSITION = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind: { + meshPrimitive.attributes.NORMAL = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind: { + meshPrimitive.attributes.COLOR_0 = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind: { + meshPrimitive.attributes.TANGENT = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind: { + meshPrimitive.attributes.TEXCOORD_0 = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind: { + meshPrimitive.attributes.TEXCOORD_1 = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind: { + meshPrimitive.attributes.JOINTS_0 = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind: { + meshPrimitive.attributes.JOINTS_1 = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind: { + meshPrimitive.attributes.WEIGHTS_0 = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsExtraKind: { + meshPrimitive.attributes.WEIGHTS_1 = this._accessors.length - 1; + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Unsupported Vertex Buffer Type: " + attributeKind); + } + } + }; + /** + * Sets data for the primitive attributes of each submesh + * @param mesh glTF Mesh object to store the primitive attribute information + * @param babylonTransformNode Babylon mesh to get the primitive attribute data from + * @param binaryWriter Buffer to write the attribute data to + * @returns promise that resolves when done setting the primitive attributes + */ + _Exporter.prototype._setPrimitiveAttributesAsync = function (mesh, babylonTransformNode, binaryWriter) { + var promises = []; + var bufferMesh = null; + var bufferView; + var minMax; + if (babylonTransformNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh) { + bufferMesh = babylonTransformNode; + } + else if (babylonTransformNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.InstancedMesh) { + bufferMesh = babylonTransformNode.sourceMesh; + } + var attributeData = [ + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind, accessorType: "VEC3" /* AccessorType.VEC3 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 12 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind, accessorType: "VEC3" /* AccessorType.VEC3 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 12 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind, accessorType: "VEC4" /* AccessorType.VEC4 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 16 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind, accessorType: "VEC4" /* AccessorType.VEC4 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 16 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind, accessorType: "VEC2" /* AccessorType.VEC2 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 8 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind, accessorType: "VEC2" /* AccessorType.VEC2 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 8 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind, accessorType: "VEC4" /* AccessorType.VEC4 */, accessorComponentType: 5123 /* AccessorComponentType.UNSIGNED_SHORT */, byteStride: 8 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind, accessorType: "VEC4" /* AccessorType.VEC4 */, accessorComponentType: 5123 /* AccessorComponentType.UNSIGNED_SHORT */, byteStride: 8 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind, accessorType: "VEC4" /* AccessorType.VEC4 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 16 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsExtraKind, accessorType: "VEC4" /* AccessorType.VEC4 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 16 }, + ]; + if (bufferMesh) { + var indexBufferViewIndex = null; + var primitiveMode = this._getMeshPrimitiveMode(bufferMesh); + var vertexAttributeBufferViews = {}; + var morphTargetManager = bufferMesh.morphTargetManager; + // For each BabylonMesh, create bufferviews for each 'kind' + for (var _i = 0, attributeData_1 = attributeData; _i < attributeData_1.length; _i++) { + var attribute = attributeData_1[_i]; + var attributeKind = attribute.kind; + var attributeComponentKind = attribute.accessorComponentType; + if (bufferMesh.isVerticesDataPresent(attributeKind, true)) { + var vertexBuffer = this._getVertexBufferFromMesh(attributeKind, bufferMesh); + attribute.byteStride = vertexBuffer + ? vertexBuffer.getSize() * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(attribute.accessorComponentType) + : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.DeduceStride(attributeKind) * 4; + if (attribute.byteStride === 12) { + attribute.accessorType = "VEC3" /* AccessorType.VEC3 */; + } + this._createBufferViewKind(attributeKind, attributeComponentKind, babylonTransformNode, binaryWriter, attribute.byteStride); + attribute.bufferViewIndex = this._bufferViews.length - 1; + vertexAttributeBufferViews[attributeKind] = attribute.bufferViewIndex; + } + } + if (bufferMesh.getTotalIndices()) { + var indices = bufferMesh.getIndices(); + if (indices) { + var byteLength = indices.length * 4; + bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, "Indices - " + bufferMesh.name); + this._bufferViews.push(bufferView); + indexBufferViewIndex = this._bufferViews.length - 1; + for (var k = 0, length_9 = indices.length; k < length_9; ++k) { + binaryWriter.setUInt32(indices[k]); + } + } + } + if (bufferMesh.subMeshes) { + // go through all mesh primitives (submeshes) + for (var _a = 0, _b = bufferMesh.subMeshes; _a < _b.length; _a++) { + var submesh = _b[_a]; + var babylonMaterial = submesh.getMaterial() || bufferMesh.getScene().defaultMaterial; + var materialIndex = null; + if (babylonMaterial) { + if (bufferMesh instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.LinesMesh) { + // get the color from the lines mesh and set it in the material + var material = { + name: bufferMesh.name + " material", + }; + if (!bufferMesh.color.equals(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White()) || bufferMesh.alpha < 1) { + material.pbrMetallicRoughness = { + baseColorFactor: bufferMesh.color.asArray().concat([bufferMesh.alpha]), + }; + } + this._materials.push(material); + materialIndex = this._materials.length - 1; + } + else if (babylonMaterial instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.MultiMaterial) { + var subMaterial = babylonMaterial.subMaterials[submesh.materialIndex]; + if (subMaterial) { + babylonMaterial = subMaterial; + materialIndex = this._materialMap[babylonMaterial.uniqueId]; + } + } + else { + materialIndex = this._materialMap[babylonMaterial.uniqueId]; + } + } + var glTFMaterial = materialIndex != null ? this._materials[materialIndex] : null; + var meshPrimitive = { attributes: {} }; + this._setPrimitiveMode(meshPrimitive, primitiveMode); + for (var _c = 0, attributeData_2 = attributeData; _c < attributeData_2.length; _c++) { + var attribute = attributeData_2[_c]; + var attributeKind = attribute.kind; + if ((attributeKind === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind || attributeKind === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind) && !this._options.exportUnusedUVs) { + if (!glTFMaterial || !this._glTFMaterialExporter._hasTexturesPresent(glTFMaterial)) { + continue; + } + } + var vertexData = bufferMesh.getVerticesData(attributeKind, undefined, undefined, true); + if (vertexData) { + var vertexBuffer = this._getVertexBufferFromMesh(attributeKind, bufferMesh); + if (vertexBuffer) { + var stride = vertexBuffer.getSize(); + var bufferViewIndex = attribute.bufferViewIndex; + if (bufferViewIndex != undefined) { + // check to see if bufferviewindex has a numeric value assigned. + minMax = { min: null, max: null }; + if (attributeKind == babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind) { + minMax = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CalculateMinMaxPositions(vertexData, 0, vertexData.length / stride); + } + var accessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateAccessor(bufferViewIndex, attributeKind + " - " + babylonTransformNode.name, attribute.accessorType, attribute.accessorComponentType, vertexData.length / stride, 0, minMax.min, minMax.max); + this._accessors.push(accessor); + this._setAttributeKind(meshPrimitive, attributeKind); + } + } + } + } + if (indexBufferViewIndex) { + // Create accessor + var accessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateAccessor(indexBufferViewIndex, "indices - " + babylonTransformNode.name, "SCALAR" /* AccessorType.SCALAR */, 5125 /* AccessorComponentType.UNSIGNED_INT */, submesh.indexCount, submesh.indexStart * 4, null, null); + this._accessors.push(accessor); + meshPrimitive.indices = this._accessors.length - 1; + } + if (Object.keys(meshPrimitive.attributes).length > 0) { + var sideOrientation = bufferMesh.overrideMaterialSideOrientation !== null ? bufferMesh.overrideMaterialSideOrientation : babylonMaterial.sideOrientation; + if (sideOrientation === (this._babylonScene.useRightHandedSystem ? babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.ClockWiseSideOrientation : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.CounterClockWiseSideOrientation)) { + var byteOffset = indexBufferViewIndex != null ? this._bufferViews[indexBufferViewIndex].byteOffset : null; + if (byteOffset == null) { + byteOffset = 0; + } + var babylonIndices = null; + if (indexBufferViewIndex != null) { + babylonIndices = bufferMesh.getIndices(); + } + if (babylonIndices) { + this._reorderIndicesBasedOnPrimitiveMode(submesh, primitiveMode, babylonIndices, byteOffset, binaryWriter); + } + else { + for (var _d = 0, attributeData_3 = attributeData; _d < attributeData_3.length; _d++) { + var attribute = attributeData_3[_d]; + var vertexData = bufferMesh.getVerticesData(attribute.kind, undefined, undefined, true); + if (vertexData) { + var byteOffset_1 = this._bufferViews[vertexAttributeBufferViews[attribute.kind]].byteOffset || 0; + this._reorderVertexAttributeDataBasedOnPrimitiveMode(submesh, primitiveMode, attribute.kind, vertexData, byteOffset_1, binaryWriter); + } + } + } + } + if (materialIndex != null) { + meshPrimitive.material = materialIndex; + } + } + if (morphTargetManager) { + // By convention, morph target names are stored in the mesh extras. + if (!mesh.extras) { + mesh.extras = {}; + } + mesh.extras.targetNames = []; + for (var i = 0; i < morphTargetManager.numTargets; ++i) { + var target = morphTargetManager.getTarget(i); + this._setMorphTargetAttributes(submesh, meshPrimitive, target, binaryWriter); + mesh.extras.targetNames.push(target.name); + } + } + mesh.primitives.push(meshPrimitive); + this._extensionsPostExportMeshPrimitiveAsync("postExport", meshPrimitive, submesh, binaryWriter); + promises.push(); + } + } + } + return Promise.all(promises).then(function () { + /* do nothing */ + }); + }; + /** + * Creates a glTF scene based on the array of meshes + * Returns the total byte offset + * @param binaryWriter Buffer to write binary data to + * @returns a promise that resolves when done + */ + _Exporter.prototype._createSceneAsync = function (binaryWriter) { + var _a; + var _this = this; + var _b; + var scene = { nodes: [] }; + var glTFNodeIndex; + var glTFNode; + var directDescendents; + var nodes = (0,tslib__WEBPACK_IMPORTED_MODULE_5__.__spreadArray)((0,tslib__WEBPACK_IMPORTED_MODULE_5__.__spreadArray)((0,tslib__WEBPACK_IMPORTED_MODULE_5__.__spreadArray)((0,tslib__WEBPACK_IMPORTED_MODULE_5__.__spreadArray)([], this._babylonScene.transformNodes, true), this._babylonScene.meshes, true), this._babylonScene.lights, true), this._babylonScene.cameras, true); + var removedRootNodes = new Set(); + // Scene metadata + if (this._babylonScene.metadata) { + if (this._options.metadataSelector) { + scene.extras = this._options.metadataSelector(this._babylonScene.metadata); + } + else if (this._babylonScene.metadata.gltf) { + scene.extras = this._babylonScene.metadata.gltf.extras; + } + } + // Remove no-op root nodes + if (((_b = this._options.removeNoopRootNodes) !== null && _b !== void 0 ? _b : true) && !this._options.includeCoordinateSystemConversionNodes) { + for (var _i = 0, _c = this._babylonScene.rootNodes; _i < _c.length; _i++) { + var rootNode = _c[_i]; + if (isNoopNode(rootNode, this._babylonScene.useRightHandedSystem)) { + removedRootNodes.add(rootNode); + // Exclude the node from list of nodes to export + nodes.splice(nodes.indexOf(rootNode), 1); + } + } + } + // Export babylon cameras to glTFCamera + var cameraMap = new Map(); + this._babylonScene.cameras.forEach(function (camera) { + if (_this._options.shouldExportNode && !_this._options.shouldExportNode(camera)) { + return; + } + var glTFCamera = { + type: camera.mode === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Camera.PERSPECTIVE_CAMERA ? "perspective" /* CameraType.PERSPECTIVE */ : "orthographic" /* CameraType.ORTHOGRAPHIC */, + }; + if (camera.name) { + glTFCamera.name = camera.name; + } + if (glTFCamera.type === "perspective" /* CameraType.PERSPECTIVE */) { + glTFCamera.perspective = { + aspectRatio: camera.getEngine().getAspectRatio(camera), + yfov: camera.fovMode === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Camera.FOVMODE_VERTICAL_FIXED ? camera.fov : camera.fov * camera.getEngine().getAspectRatio(camera), + znear: camera.minZ, + zfar: camera.maxZ, + }; + } + else if (glTFCamera.type === "orthographic" /* CameraType.ORTHOGRAPHIC */) { + var halfWidth = camera.orthoLeft && camera.orthoRight ? 0.5 * (camera.orthoRight - camera.orthoLeft) : camera.getEngine().getRenderWidth() * 0.5; + var halfHeight = camera.orthoBottom && camera.orthoTop ? 0.5 * (camera.orthoTop - camera.orthoBottom) : camera.getEngine().getRenderHeight() * 0.5; + glTFCamera.orthographic = { + xmag: halfWidth, + ymag: halfHeight, + znear: camera.minZ, + zfar: camera.maxZ, + }; + } + cameraMap.set(camera, _this._cameras.length); + _this._cameras.push(glTFCamera); + }); + var exportNodes = (_a = this._getExportNodes(nodes), _a[0]), exportMaterials = _a[1]; + return this._glTFMaterialExporter._convertMaterialsToGLTFAsync(exportMaterials, "image/png" /* ImageMimeType.PNG */, true).then(function () { + return _this._createNodeMapAndAnimationsAsync(exportNodes, binaryWriter).then(function (nodeMap) { + return _this._createSkinsAsync(nodeMap, binaryWriter).then(function (skinMap) { + _this._nodeMap = nodeMap; + _this._totalByteLength = binaryWriter.getByteOffset(); + if (_this._totalByteLength == undefined) { + throw new Error("undefined byte length!"); + } + // Build Hierarchy with the node map. + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var babylonNode = nodes_1[_i]; + glTFNodeIndex = _this._nodeMap[babylonNode.uniqueId]; + if (glTFNodeIndex !== undefined) { + glTFNode = _this._nodes[glTFNodeIndex]; + if (babylonNode.metadata) { + if (_this._options.metadataSelector) { + glTFNode.extras = _this._options.metadataSelector(babylonNode.metadata); + } + else if (babylonNode.metadata.gltf) { + glTFNode.extras = babylonNode.metadata.gltf.extras; + } + } + if (babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Camera) { + glTFNode.camera = cameraMap.get(babylonNode); + } + if (_this._options.shouldExportNode && !_this._options.shouldExportNode(babylonNode)) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Log("Omitting " + babylonNode.name + " from scene."); + } + else { + if (!babylonNode.parent && !_this._babylonScene.useRightHandedSystem) { + convertNodeHandedness(glTFNode); + } + if (!babylonNode.parent || removedRootNodes.has(babylonNode.parent)) { + scene.nodes.push(glTFNodeIndex); + } + } + if (babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh) { + if (babylonNode.skeleton) { + glTFNode.skin = skinMap[babylonNode.skeleton.uniqueId]; + } + } + directDescendents = babylonNode.getDescendants(true); + if (!glTFNode.children && directDescendents && directDescendents.length) { + var children = []; + for (var _a = 0, directDescendents_1 = directDescendents; _a < directDescendents_1.length; _a++) { + var descendent = directDescendents_1[_a]; + if (_this._nodeMap[descendent.uniqueId] != null) { + children.push(_this._nodeMap[descendent.uniqueId]); + } + } + if (children.length) { + glTFNode.children = children; + } + } + } + } + if (scene.nodes.length) { + _this._scenes.push(scene); + } + }); + }); + }); + }; + /** + * Getting the nodes and materials that would be exported. + * @param nodes Babylon transform nodes + * @returns Set of materials which would be exported. + */ + _Exporter.prototype._getExportNodes = function (nodes) { + var exportNodes = []; + var exportMaterials = new Set(); + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var babylonNode = nodes_2[_i]; + if (!this._options.shouldExportNode || this._options.shouldExportNode(babylonNode)) { + exportNodes.push(babylonNode); + var babylonMesh = babylonNode; + if (babylonMesh.subMeshes && babylonMesh.subMeshes.length > 0) { + var material = babylonMesh.material || babylonMesh.getScene().defaultMaterial; + if (material instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.MultiMaterial) { + for (var _a = 0, _b = material.subMaterials; _a < _b.length; _a++) { + var subMaterial = _b[_a]; + if (subMaterial) { + exportMaterials.add(subMaterial); + } + } + } + else { + exportMaterials.add(material); + } + } + } + else { + "Excluding node ".concat(babylonNode.name); + } + } + return [exportNodes, exportMaterials]; + }; + /** + * Creates a mapping of Node unique id to node index and handles animations + * @param nodes Babylon transform nodes + * @param binaryWriter Buffer to write binary data to + * @returns Node mapping of unique id to index + */ + _Exporter.prototype._createNodeMapAndAnimationsAsync = function (nodes, binaryWriter) { + var _this = this; + var promiseChain = Promise.resolve(); + var nodeMap = {}; + var nodeIndex; + var runtimeGLTFAnimation = { + name: "runtime animations", + channels: [], + samplers: [], + }; + var idleGLTFAnimations = []; + var _loop_1 = function (babylonNode) { + promiseChain = promiseChain.then(function () { + return _this._createNodeAsync(babylonNode, binaryWriter).then(function (node) { + var promise = _this._extensionsPostExportNodeAsync("createNodeAsync", node, babylonNode, nodeMap, binaryWriter); + if (promise == null) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Not exporting node ".concat(babylonNode.name)); + return Promise.resolve(); + } + else { + return promise.then(function (node) { + if (!node) { + return; + } + _this._nodes.push(node); + nodeIndex = _this._nodes.length - 1; + nodeMap[babylonNode.uniqueId] = nodeIndex; + if (!_this._babylonScene.animationGroups.length) { + _glTFAnimation__WEBPACK_IMPORTED_MODULE_4__._GLTFAnimation._CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, _this._nodes, binaryWriter, _this._bufferViews, _this._accessors, _this._animationSampleRate, _this._options.shouldExportAnimation); + if (babylonNode.animations.length) { + _glTFAnimation__WEBPACK_IMPORTED_MODULE_4__._GLTFAnimation._CreateNodeAnimationFromNodeAnimations(babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, _this._nodes, binaryWriter, _this._bufferViews, _this._accessors, _this._animationSampleRate, _this._options.shouldExportAnimation); + } + } + }); + } + }); + }); + }; + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var babylonNode = nodes_3[_i]; + _loop_1(babylonNode); + } + return promiseChain.then(function () { + if (runtimeGLTFAnimation.channels.length && runtimeGLTFAnimation.samplers.length) { + _this._animations.push(runtimeGLTFAnimation); + } + idleGLTFAnimations.forEach(function (idleGLTFAnimation) { + if (idleGLTFAnimation.channels.length && idleGLTFAnimation.samplers.length) { + _this._animations.push(idleGLTFAnimation); + } + }); + if (_this._babylonScene.animationGroups.length) { + _glTFAnimation__WEBPACK_IMPORTED_MODULE_4__._GLTFAnimation._CreateNodeAndMorphAnimationFromAnimationGroups(_this._babylonScene, _this._animations, nodeMap, binaryWriter, _this._bufferViews, _this._accessors, _this._animationSampleRate, _this._options.shouldExportAnimation); + } + return nodeMap; + }); + }; + /** + * Creates a glTF node from a Babylon mesh + * @param babylonNode Source Babylon mesh + * @param binaryWriter Buffer for storing geometry data + * @returns glTF node + */ + _Exporter.prototype._createNodeAsync = function (babylonNode, binaryWriter) { + var _this = this; + return Promise.resolve().then(function () { + // create node to hold translation/rotation/scale and the mesh + var node = {}; + // create mesh + var mesh = { primitives: [] }; + if (babylonNode.name) { + node.name = babylonNode.name; + } + if (babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TransformNode) { + // Set transformation + _this._setNodeTransformation(node, babylonNode); + if (babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh) { + var morphTargetManager = babylonNode.morphTargetManager; + if (morphTargetManager && morphTargetManager.numTargets > 0) { + mesh.weights = []; + for (var i = 0; i < morphTargetManager.numTargets; ++i) { + mesh.weights.push(morphTargetManager.getTarget(i).influence); + } + } + } + return _this._setPrimitiveAttributesAsync(mesh, babylonNode, binaryWriter).then(function () { + if (mesh.primitives.length) { + _this._meshes.push(mesh); + node.mesh = _this._meshes.length - 1; + } + return node; + }); + } + else if (babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Camera) { + _this._setCameraTransformation(node, babylonNode); + return node; + } + else { + return node; + } + }); + }; + /** + * Creates a glTF skin from a Babylon skeleton + * @param nodeMap Babylon transform nodes + * @param binaryWriter Buffer to write binary data to + * @returns Node mapping of unique id to index + */ + _Exporter.prototype._createSkinsAsync = function (nodeMap, binaryWriter) { + var _a; + var promiseChain = Promise.resolve(); + var skinMap = {}; + for (var _i = 0, _b = this._babylonScene.skeletons; _i < _b.length; _i++) { + var skeleton = _b[_i]; + if (skeleton.bones.length <= 0) { + continue; + } + // create skin + var skin = { joints: [] }; + var inverseBindMatrices = []; + var boneIndexMap = {}; + var maxBoneIndex = -1; + for (var i = 0; i < skeleton.bones.length; ++i) { + var bone = skeleton.bones[i]; + var boneIndex = (_a = bone.getIndex()) !== null && _a !== void 0 ? _a : i; + if (boneIndex !== -1) { + boneIndexMap[boneIndex] = bone; + if (boneIndex > maxBoneIndex) { + maxBoneIndex = boneIndex; + } + } + } + for (var boneIndex = 0; boneIndex <= maxBoneIndex; ++boneIndex) { + var bone = boneIndexMap[boneIndex]; + inverseBindMatrices.push(bone.getInvertedAbsoluteTransform()); + var transformNode = bone.getTransformNode(); + if (transformNode && nodeMap[transformNode.uniqueId] !== null && nodeMap[transformNode.uniqueId] !== undefined) { + skin.joints.push(nodeMap[transformNode.uniqueId]); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Exporting a bone without a linked transform node is currently unsupported"); + } + } + if (skin.joints.length > 0) { + // create buffer view for inverse bind matrices + var byteStride = 64; // 4 x 4 matrix of 32 bit float + var byteLength = inverseBindMatrices.length * byteStride; + var bufferViewOffset = binaryWriter.getByteOffset(); + var bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateBufferView(0, bufferViewOffset, byteLength, undefined, "InverseBindMatrices" + " - " + skeleton.name); + this._bufferViews.push(bufferView); + var bufferViewIndex = this._bufferViews.length - 1; + var bindMatrixAccessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateAccessor(bufferViewIndex, "InverseBindMatrices" + " - " + skeleton.name, "MAT4" /* AccessorType.MAT4 */, 5126 /* AccessorComponentType.FLOAT */, inverseBindMatrices.length, null, null, null); + var inverseBindAccessorIndex = this._accessors.push(bindMatrixAccessor) - 1; + skin.inverseBindMatrices = inverseBindAccessorIndex; + this._skins.push(skin); + skinMap[skeleton.uniqueId] = this._skins.length - 1; + inverseBindMatrices.forEach(function (mat) { + mat.m.forEach(function (cell) { + binaryWriter.setFloat32(cell); + }); + }); + } + } + return promiseChain.then(function () { + return skinMap; + }); + }; + _Exporter._ExtensionNames = new Array(); + _Exporter._ExtensionFactories = {}; + return _Exporter; +}()); +/** + * @internal + * + * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically + */ +var _BinaryWriter = /** @class */ (function () { + /** + * Initialize binary writer with an initial byte length + * @param byteLength Initial byte length of the array buffer + */ + function _BinaryWriter(byteLength) { + this._arrayBuffer = new ArrayBuffer(byteLength); + this._dataView = new DataView(this._arrayBuffer); + this._byteOffset = 0; + } + /** + * Resize the array buffer to the specified byte length + * @param byteLength The new byte length + * @returns The resized array buffer + */ + _BinaryWriter.prototype._resizeBuffer = function (byteLength) { + var newBuffer = new ArrayBuffer(byteLength); + var copyOldBufferSize = Math.min(this._arrayBuffer.byteLength, byteLength); + var oldUint8Array = new Uint8Array(this._arrayBuffer, 0, copyOldBufferSize); + var newUint8Array = new Uint8Array(newBuffer); + newUint8Array.set(oldUint8Array, 0); + this._arrayBuffer = newBuffer; + this._dataView = new DataView(this._arrayBuffer); + return newBuffer; + }; + /** + * Get an array buffer with the length of the byte offset + * @returns ArrayBuffer resized to the byte offset + */ + _BinaryWriter.prototype.getArrayBuffer = function () { + return this._resizeBuffer(this.getByteOffset()); + }; + /** + * Get the byte offset of the array buffer + * @returns byte offset + */ + _BinaryWriter.prototype.getByteOffset = function () { + if (this._byteOffset == undefined) { + throw new Error("Byte offset is undefined!"); + } + return this._byteOffset; + }; + /** + * Stores an UInt8 in the array buffer + * @param entry + * @param byteOffset If defined, specifies where to set the value as an offset. + */ + _BinaryWriter.prototype.setUInt8 = function (entry, byteOffset) { + if (byteOffset != null) { + if (byteOffset < this._byteOffset) { + this._dataView.setUint8(byteOffset, entry); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + } + else { + if (this._byteOffset + 1 > this._arrayBuffer.byteLength) { + this._resizeBuffer(this._arrayBuffer.byteLength * 2); + } + this._dataView.setUint8(this._byteOffset, entry); + this._byteOffset += 1; + } + }; + /** + * Stores an UInt16 in the array buffer + * @param entry + * @param byteOffset If defined, specifies where to set the value as an offset. + */ + _BinaryWriter.prototype.setUInt16 = function (entry, byteOffset) { + if (byteOffset != null) { + if (byteOffset < this._byteOffset) { + this._dataView.setUint16(byteOffset, entry, true); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + } + else { + if (this._byteOffset + 2 > this._arrayBuffer.byteLength) { + this._resizeBuffer(this._arrayBuffer.byteLength * 2); + } + this._dataView.setUint16(this._byteOffset, entry, true); + this._byteOffset += 2; + } + }; + /** + * Gets an UInt32 in the array buffer + * @param byteOffset If defined, specifies where to set the value as an offset. + * @returns entry + */ + _BinaryWriter.prototype.getUInt32 = function (byteOffset) { + if (byteOffset < this._byteOffset) { + return this._dataView.getUint32(byteOffset, true); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + throw new Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + }; + _BinaryWriter.prototype.getVector3Float32FromRef = function (vector3, byteOffset) { + if (byteOffset + 8 > this._byteOffset) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + else { + vector3.x = this._dataView.getFloat32(byteOffset, true); + vector3.y = this._dataView.getFloat32(byteOffset + 4, true); + vector3.z = this._dataView.getFloat32(byteOffset + 8, true); + } + }; + _BinaryWriter.prototype.setVector3Float32FromRef = function (vector3, byteOffset) { + if (byteOffset + 8 > this._byteOffset) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + else { + this._dataView.setFloat32(byteOffset, vector3.x, true); + this._dataView.setFloat32(byteOffset + 4, vector3.y, true); + this._dataView.setFloat32(byteOffset + 8, vector3.z, true); + } + }; + _BinaryWriter.prototype.getVector4Float32FromRef = function (vector4, byteOffset) { + if (byteOffset + 12 > this._byteOffset) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + else { + vector4.x = this._dataView.getFloat32(byteOffset, true); + vector4.y = this._dataView.getFloat32(byteOffset + 4, true); + vector4.z = this._dataView.getFloat32(byteOffset + 8, true); + vector4.w = this._dataView.getFloat32(byteOffset + 12, true); + } + }; + _BinaryWriter.prototype.setVector4Float32FromRef = function (vector4, byteOffset) { + if (byteOffset + 12 > this._byteOffset) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + else { + this._dataView.setFloat32(byteOffset, vector4.x, true); + this._dataView.setFloat32(byteOffset + 4, vector4.y, true); + this._dataView.setFloat32(byteOffset + 8, vector4.z, true); + this._dataView.setFloat32(byteOffset + 12, vector4.w, true); + } + }; + /** + * Stores a Float32 in the array buffer + * @param entry + * @param byteOffset + */ + _BinaryWriter.prototype.setFloat32 = function (entry, byteOffset) { + if (isNaN(entry)) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("Invalid data being written!"); + } + if (byteOffset != null) { + if (byteOffset < this._byteOffset) { + this._dataView.setFloat32(byteOffset, entry, true); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary length!"); + } + } + if (this._byteOffset + 4 > this._arrayBuffer.byteLength) { + this._resizeBuffer(this._arrayBuffer.byteLength * 2); + } + this._dataView.setFloat32(this._byteOffset, entry, true); + this._byteOffset += 4; + }; + /** + * Stores an UInt32 in the array buffer + * @param entry + * @param byteOffset If defined, specifies where to set the value as an offset. + */ + _BinaryWriter.prototype.setUInt32 = function (entry, byteOffset) { + if (byteOffset != null) { + if (byteOffset < this._byteOffset) { + this._dataView.setUint32(byteOffset, entry, true); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + } + else { + if (this._byteOffset + 4 > this._arrayBuffer.byteLength) { + this._resizeBuffer(this._arrayBuffer.byteLength * 2); + } + this._dataView.setUint32(this._byteOffset, entry, true); + this._byteOffset += 4; + } + }; + /** + * Stores an Int16 in the array buffer + * @param entry + * @param byteOffset If defined, specifies where to set the value as an offset. + */ + _BinaryWriter.prototype.setInt16 = function (entry, byteOffset) { + if (byteOffset != null) { + if (byteOffset < this._byteOffset) { + this._dataView.setInt16(byteOffset, entry, true); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + } + else { + if (this._byteOffset + 2 > this._arrayBuffer.byteLength) { + this._resizeBuffer(this._arrayBuffer.byteLength * 2); + } + this._dataView.setInt16(this._byteOffset, entry, true); + this._byteOffset += 2; + } + }; + /** + * Stores a byte in the array buffer + * @param entry + * @param byteOffset If defined, specifies where to set the value as an offset. + */ + _BinaryWriter.prototype.setByte = function (entry, byteOffset) { + if (byteOffset != null) { + if (byteOffset < this._byteOffset) { + this._dataView.setInt8(byteOffset, entry); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + } + else { + if (this._byteOffset + 1 > this._arrayBuffer.byteLength) { + this._resizeBuffer(this._arrayBuffer.byteLength * 2); + } + this._dataView.setInt8(this._byteOffset, entry); + this._byteOffset++; + } + }; + return _BinaryWriter; +}()); + + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/glTFExporterExtension.ts": +/*!**********************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/glTFExporterExtension.ts ***! + \**********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ __IGLTFExporterExtensionV2: () => (/* binding */ __IGLTFExporterExtensionV2) +/* harmony export */ }); +/** @internal */ +// eslint-disable-next-line no-var, @typescript-eslint/naming-convention +var __IGLTFExporterExtensionV2 = 0; // I am here to allow dts to be created + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/glTFMaterialExporter.ts": +/*!*********************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/glTFMaterialExporter.ts ***! + \*********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ _GLTFMaterialExporter: () => (/* binding */ _GLTFMaterialExporter) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/dumpTools */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); + + + + + + + + + + +function getFileExtensionFromMimeType(mimeType) { + switch (mimeType) { + case "image/jpeg" /* ImageMimeType.JPEG */: + return ".jpg"; + case "image/png" /* ImageMimeType.PNG */: + return ".png"; + case "image/webp" /* ImageMimeType.WEBP */: + return ".webp"; + } +} +/** + * Utility methods for working with glTF material conversion properties. This class should only be used internally + * @internal + */ +var _GLTFMaterialExporter = /** @class */ (function () { + function _GLTFMaterialExporter(exporter) { + /** + * Mapping to store textures + */ + this._textureMap = {}; + // Mapping of internal textures to images to avoid exporting duplicate images. + this._internalTextureToImage = {}; + this._textureMap = {}; + this._exporter = exporter; + } + /** + * Specifies if two colors are approximately equal in value + * @param color1 first color to compare to + * @param color2 second color to compare to + * @param epsilon threshold value + * @returns boolean specifying if the colors are approximately equal in value + */ + _GLTFMaterialExporter._FuzzyEquals = function (color1, color2, epsilon) { + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Scalar.WithinEpsilon(color1.r, color2.r, epsilon) && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Scalar.WithinEpsilon(color1.g, color2.g, epsilon) && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Scalar.WithinEpsilon(color1.b, color2.b, epsilon); + }; + /** + * Gets the materials from a Babylon scene and converts them to glTF materials + * @param exportMaterials + * @param mimeType texture mime type + * @param hasTextureCoords specifies if texture coordinates are present on the material + * @returns promise that resolves after all materials have been converted + */ + _GLTFMaterialExporter.prototype._convertMaterialsToGLTFAsync = function (exportMaterials, mimeType, hasTextureCoords) { + var _this = this; + var promises = []; + exportMaterials.forEach(function (material) { + if (material.getClassName() === "StandardMaterial") { + promises.push(_this._convertStandardMaterialAsync(material, mimeType, hasTextureCoords)); + } + else if (material.getClassName().indexOf("PBR") !== -1) { + promises.push(_this._convertPBRMaterialAsync(material, mimeType, hasTextureCoords)); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Unsupported material type: ".concat(material.name)); + } + }); + return Promise.all(promises).then(function () { + /* do nothing */ + }); + }; + /** + * Makes a copy of the glTF material without the texture parameters + * @param originalMaterial original glTF material + * @returns glTF material without texture parameters + */ + _GLTFMaterialExporter.prototype._stripTexturesFromMaterial = function (originalMaterial) { + var newMaterial = {}; + if (originalMaterial) { + newMaterial.name = originalMaterial.name; + newMaterial.doubleSided = originalMaterial.doubleSided; + newMaterial.alphaMode = originalMaterial.alphaMode; + newMaterial.alphaCutoff = originalMaterial.alphaCutoff; + newMaterial.emissiveFactor = originalMaterial.emissiveFactor; + var originalPBRMetallicRoughness = originalMaterial.pbrMetallicRoughness; + if (originalPBRMetallicRoughness) { + newMaterial.pbrMetallicRoughness = {}; + newMaterial.pbrMetallicRoughness.baseColorFactor = originalPBRMetallicRoughness.baseColorFactor; + newMaterial.pbrMetallicRoughness.metallicFactor = originalPBRMetallicRoughness.metallicFactor; + newMaterial.pbrMetallicRoughness.roughnessFactor = originalPBRMetallicRoughness.roughnessFactor; + } + } + return newMaterial; + }; + /** + * Specifies if the material has any texture parameters present + * @param material glTF Material + * @returns boolean specifying if texture parameters are present + */ + _GLTFMaterialExporter.prototype._hasTexturesPresent = function (material) { + var _a; + if (material.emissiveTexture || material.normalTexture || material.occlusionTexture) { + return true; + } + var pbrMat = material.pbrMetallicRoughness; + if (pbrMat) { + if (pbrMat.baseColorTexture || pbrMat.metallicRoughnessTexture) { + return true; + } + } + if (material.extensions) { + for (var extension in material.extensions) { + var extensionObject = material.extensions[extension]; + if (extensionObject) { + return (_a = extensionObject.hasTextures) === null || _a === void 0 ? void 0 : _a.call(extensionObject); + } + } + } + return false; + }; + _GLTFMaterialExporter.prototype._getTextureInfo = function (babylonTexture) { + if (babylonTexture) { + var textureUid = babylonTexture.uid; + if (textureUid in this._textureMap) { + return this._textureMap[textureUid]; + } + } + return null; + }; + /** + * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material + * @param babylonStandardMaterial + * @returns glTF Metallic Roughness Material representation + */ + _GLTFMaterialExporter.prototype._convertToGLTFPBRMetallicRoughness = function (babylonStandardMaterial) { + // Defines a cubic bezier curve where x is specular power and y is roughness + var P0 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2(0, 1); + var P1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2(0, 0.1); + var P2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2(0, 0.1); + var P3 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2(1300, 0.1); + /** + * Given the control points, solve for x based on a given t for a cubic bezier curve + * @param t a value between 0 and 1 + * @param p0 first control point + * @param p1 second control point + * @param p2 third control point + * @param p3 fourth control point + * @returns number result of cubic bezier curve at the specified t + */ + function cubicBezierCurve(t, p0, p1, p2, p3) { + return (1 - t) * (1 - t) * (1 - t) * p0 + 3 * (1 - t) * (1 - t) * t * p1 + 3 * (1 - t) * t * t * p2 + t * t * t * p3; + } + /** + * Evaluates a specified specular power value to determine the appropriate roughness value, + * based on a pre-defined cubic bezier curve with specular on the abscissa axis (x-axis) + * and roughness on the ordinant axis (y-axis) + * @param specularPower specular power of standard material + * @returns Number representing the roughness value + */ + function solveForRoughness(specularPower) { + // Given P0.x = 0, P1.x = 0, P2.x = 0 + // x = t * t * t * P3.x + // t = (x / P3.x)^(1/3) + var t = Math.pow(specularPower / P3.x, 0.333333); + return cubicBezierCurve(t, P0.y, P1.y, P2.y, P3.y); + } + var diffuse = babylonStandardMaterial.diffuseColor.toLinearSpace(babylonStandardMaterial.getScene().getEngine().useExactSrgbConversions).scale(0.5); + var opacity = babylonStandardMaterial.alpha; + var specularPower = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Scalar.Clamp(babylonStandardMaterial.specularPower, 0, _GLTFMaterialExporter._MaxSpecularPower); + var roughness = solveForRoughness(specularPower); + var glTFPbrMetallicRoughness = { + baseColorFactor: [diffuse.r, diffuse.g, diffuse.b, opacity], + metallicFactor: 0, + roughnessFactor: roughness, + }; + return glTFPbrMetallicRoughness; + }; + /** + * Computes the metallic factor + * @param diffuse diffused value + * @param specular specular value + * @param oneMinusSpecularStrength one minus the specular strength + * @returns metallic value + */ + _GLTFMaterialExporter._SolveMetallic = function (diffuse, specular, oneMinusSpecularStrength) { + if (specular < this._DielectricSpecular.r) { + this._DielectricSpecular; + return 0; + } + var a = this._DielectricSpecular.r; + var b = (diffuse * oneMinusSpecularStrength) / (1.0 - this._DielectricSpecular.r) + specular - 2.0 * this._DielectricSpecular.r; + var c = this._DielectricSpecular.r - specular; + var D = b * b - 4.0 * a * c; + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Scalar.Clamp((-b + Math.sqrt(D)) / (2.0 * a), 0, 1); + }; + /** + * Sets the glTF alpha mode to a glTF material from the Babylon Material + * @param glTFMaterial glTF material + * @param babylonMaterial Babylon material + */ + _GLTFMaterialExporter._SetAlphaMode = function (glTFMaterial, babylonMaterial) { + if (babylonMaterial.needAlphaBlending()) { + glTFMaterial.alphaMode = "BLEND" /* MaterialAlphaMode.BLEND */; + } + else if (babylonMaterial.needAlphaTesting()) { + glTFMaterial.alphaMode = "MASK" /* MaterialAlphaMode.MASK */; + glTFMaterial.alphaCutoff = babylonMaterial.alphaCutOff; + } + }; + /** + * Converts a Babylon Standard Material to a glTF Material + * @param babylonStandardMaterial BJS Standard Material + * @param mimeType mime type to use for the textures + * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied + * @returns promise, resolved with the material + */ + _GLTFMaterialExporter.prototype._convertStandardMaterialAsync = function (babylonStandardMaterial, mimeType, hasTextureCoords) { + var materialMap = this._exporter._materialMap; + var materials = this._exporter._materials; + var promises = []; + var pbrMetallicRoughness = this._convertToGLTFPBRMetallicRoughness(babylonStandardMaterial); + var material = { name: babylonStandardMaterial.name }; + if (babylonStandardMaterial.backFaceCulling != null && !babylonStandardMaterial.backFaceCulling) { + if (!babylonStandardMaterial.twoSidedLighting) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn(babylonStandardMaterial.name + ": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."); + } + material.doubleSided = true; + } + if (hasTextureCoords) { + if (babylonStandardMaterial.diffuseTexture) { + promises.push(this._exportTextureAsync(babylonStandardMaterial.diffuseTexture, mimeType).then(function (textureInfo) { + if (textureInfo) { + pbrMetallicRoughness.baseColorTexture = textureInfo; + } + })); + } + var bumpTexture_1 = babylonStandardMaterial.bumpTexture; + if (bumpTexture_1) { + promises.push(this._exportTextureAsync(bumpTexture_1, mimeType).then(function (textureInfo) { + if (textureInfo) { + material.normalTexture = textureInfo; + if (bumpTexture_1.level !== 1) { + material.normalTexture.scale = bumpTexture_1.level; + } + } + })); + } + if (babylonStandardMaterial.emissiveTexture) { + material.emissiveFactor = [1.0, 1.0, 1.0]; + promises.push(this._exportTextureAsync(babylonStandardMaterial.emissiveTexture, mimeType).then(function (textureInfo) { + if (textureInfo) { + material.emissiveTexture = textureInfo; + } + })); + } + if (babylonStandardMaterial.ambientTexture) { + promises.push(this._exportTextureAsync(babylonStandardMaterial.ambientTexture, mimeType).then(function (textureInfo) { + if (textureInfo) { + var occlusionTexture = { + index: textureInfo.index, + }; + material.occlusionTexture = occlusionTexture; + } + })); + } + } + if (babylonStandardMaterial.alpha < 1.0 || babylonStandardMaterial.opacityTexture) { + if (babylonStandardMaterial.alphaMode === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Constants.ALPHA_COMBINE) { + material.alphaMode = "BLEND" /* MaterialAlphaMode.BLEND */; + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn(babylonStandardMaterial.name + ": glTF 2.0 does not support alpha mode: " + babylonStandardMaterial.alphaMode.toString()); + } + } + if (babylonStandardMaterial.emissiveColor && !_GLTFMaterialExporter._FuzzyEquals(babylonStandardMaterial.emissiveColor, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.Black(), _GLTFMaterialExporter._Epsilon)) { + material.emissiveFactor = babylonStandardMaterial.emissiveColor.asArray(); + } + material.pbrMetallicRoughness = pbrMetallicRoughness; + _GLTFMaterialExporter._SetAlphaMode(material, babylonStandardMaterial); + materials.push(material); + materialMap[babylonStandardMaterial.uniqueId] = materials.length - 1; + return this._finishMaterial(promises, material, babylonStandardMaterial, mimeType); + }; + _GLTFMaterialExporter.prototype._finishMaterial = function (promises, glTFMaterial, babylonMaterial, mimeType) { + var _this = this; + return Promise.all(promises).then(function () { + var textures = _this._exporter._extensionsPostExportMaterialAdditionalTextures("exportMaterial", glTFMaterial, babylonMaterial); + var tasks = null; + for (var _i = 0, textures_1 = textures; _i < textures_1.length; _i++) { + var texture = textures_1[_i]; + if (!tasks) { + tasks = []; + } + tasks.push(_this._exportTextureAsync(texture, mimeType)); + } + if (!tasks) { + tasks = [Promise.resolve(null)]; + } + return Promise.all(tasks).then(function () { + var extensionWork = _this._exporter._extensionsPostExportMaterialAsync("exportMaterial", glTFMaterial, babylonMaterial); + if (!extensionWork) { + return glTFMaterial; + } + return extensionWork.then(function () { return glTFMaterial; }); + }); + }); + }; + /** + * Converts an image typed array buffer to a base64 image + * @param buffer typed array buffer + * @param width width of the image + * @param height height of the image + * @param mimeType mimetype of the image + * @returns base64 image string + */ + _GLTFMaterialExporter.prototype._getImageDataAsync = function (buffer, width, height, mimeType) { + return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__awaiter)(this, void 0, void 0, function () { + var textureType, hostingScene, engine, tempTexture, data; + return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__generator)(this, function (_a) { + switch (_a.label) { + case 0: + textureType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Constants.TEXTURETYPE_UNSIGNED_INT; + hostingScene = this._exporter._babylonScene; + engine = hostingScene.getEngine(); + tempTexture = engine.createRawTexture(buffer, width, height, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Constants.TEXTUREFORMAT_RGBA, false, true, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_SAMPLINGMODE, null, textureType); + return [4 /*yield*/, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TextureTools.ApplyPostProcess("pass", tempTexture, hostingScene, textureType, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Constants.TEXTURE_NEAREST_SAMPLINGMODE, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Constants.TEXTUREFORMAT_RGBA)]; + case 1: + _a.sent(); + return [4 /*yield*/, engine._readTexturePixels(tempTexture, width, height)]; + case 2: + data = _a.sent(); + return [4 /*yield*/, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.DumpTools.DumpDataAsync(width, height, data, mimeType, undefined, true, true)]; + case 3: return [2 /*return*/, (_a.sent())]; + } + }); + }); + }; + /** + * Generates a white texture based on the specified width and height + * @param width width of the texture in pixels + * @param height height of the texture in pixels + * @param scene babylonjs scene + * @returns white texture + */ + _GLTFMaterialExporter.prototype._createWhiteTexture = function (width, height, scene) { + var data = new Uint8Array(width * height * 4); + for (var i = 0; i < data.length; i = i + 4) { + data[i] = data[i + 1] = data[i + 2] = data[i + 3] = 0xff; + } + var rawTexture = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.RawTexture.CreateRGBATexture(data, width, height, scene); + return rawTexture; + }; + /** + * Resizes the two source textures to the same dimensions. If a texture is null, a default white texture is generated. If both textures are null, returns null + * @param texture1 first texture to resize + * @param texture2 second texture to resize + * @param scene babylonjs scene + * @returns resized textures or null + */ + _GLTFMaterialExporter.prototype._resizeTexturesToSameDimensions = function (texture1, texture2, scene) { + var texture1Size = texture1 ? texture1.getSize() : { width: 0, height: 0 }; + var texture2Size = texture2 ? texture2.getSize() : { width: 0, height: 0 }; + var resizedTexture1; + var resizedTexture2; + if (texture1Size.width < texture2Size.width) { + if (texture1 && texture1 instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture) { + resizedTexture1 = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TextureTools.CreateResizedCopy(texture1, texture2Size.width, texture2Size.height, true); + } + else { + resizedTexture1 = this._createWhiteTexture(texture2Size.width, texture2Size.height, scene); + } + resizedTexture2 = texture2; + } + else if (texture1Size.width > texture2Size.width) { + if (texture2 && texture2 instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture) { + resizedTexture2 = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TextureTools.CreateResizedCopy(texture2, texture1Size.width, texture1Size.height, true); + } + else { + resizedTexture2 = this._createWhiteTexture(texture1Size.width, texture1Size.height, scene); + } + resizedTexture1 = texture1; + } + else { + resizedTexture1 = texture1; + resizedTexture2 = texture2; + } + return { + texture1: resizedTexture1, + texture2: resizedTexture2, + }; + }; + /** + * Converts an array of pixels to a Float32Array + * Throws an error if the pixel format is not supported + * @param pixels - array buffer containing pixel values + * @returns Float32 of pixels + */ + _GLTFMaterialExporter.prototype._convertPixelArrayToFloat32 = function (pixels) { + if (pixels instanceof Uint8Array) { + var length_1 = pixels.length; + var buffer = new Float32Array(pixels.length); + for (var i = 0; i < length_1; ++i) { + buffer[i] = pixels[i] / 255; + } + return buffer; + } + else if (pixels instanceof Float32Array) { + return pixels; + } + else { + throw new Error("Unsupported pixel format!"); + } + }; + /** + * Convert Specular Glossiness Textures to Metallic Roughness + * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness + * @link https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js + * @param diffuseTexture texture used to store diffuse information + * @param specularGlossinessTexture texture used to store specular and glossiness information + * @param factors specular glossiness material factors + * @param mimeType the mime type to use for the texture + * @returns pbr metallic roughness interface or null + */ + _GLTFMaterialExporter.prototype._convertSpecularGlossinessTexturesToMetallicRoughnessAsync = function (diffuseTexture, specularGlossinessTexture, factors, mimeType) { + var _a; + return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__awaiter)(this, void 0, void 0, function () { + var promises, scene, resizedTextures, diffuseSize, diffuseBuffer, specularGlossinessBuffer, width, height, diffusePixels, specularPixels, byteLength, metallicRoughnessBuffer, baseColorBuffer, strideSize, maxBaseColor, maxMetallic, maxRoughness, h, w, offset, diffuseColor, specularColor, glossiness, specularGlossiness, metallicRoughness, metallicRoughnessFactors_1, writeOutMetallicRoughnessTexture, writeOutBaseColorTexture, h, w, destinationOffset, linearBaseColorPixel, sRGBBaseColorPixel, metallicRoughnessPixel; + return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__generator)(this, function (_b) { + switch (_b.label) { + case 0: + promises = new Array(); + if (!(diffuseTexture || specularGlossinessTexture)) { + return [2 /*return*/, Promise.reject("_ConvertSpecularGlosinessTexturesToMetallicRoughness: diffuse and specular glossiness textures are not defined!")]; + } + scene = diffuseTexture ? diffuseTexture.getScene() : specularGlossinessTexture ? specularGlossinessTexture.getScene() : null; + if (!scene) return [3 /*break*/, 3]; + resizedTextures = this._resizeTexturesToSameDimensions(diffuseTexture, specularGlossinessTexture, scene); + diffuseSize = (_a = resizedTextures.texture1) === null || _a === void 0 ? void 0 : _a.getSize(); + diffuseBuffer = void 0; + specularGlossinessBuffer = void 0; + width = diffuseSize.width; + height = diffuseSize.height; + return [4 /*yield*/, resizedTextures.texture1.readPixels()]; + case 1: + diffusePixels = _b.sent(); + return [4 /*yield*/, resizedTextures.texture2.readPixels()]; + case 2: + specularPixels = _b.sent(); + if (diffusePixels) { + diffuseBuffer = this._convertPixelArrayToFloat32(diffusePixels); + } + else { + return [2 /*return*/, Promise.reject("Failed to retrieve pixels from diffuse texture!")]; + } + if (specularPixels) { + specularGlossinessBuffer = this._convertPixelArrayToFloat32(specularPixels); + } + else { + return [2 /*return*/, Promise.reject("Failed to retrieve pixels from specular glossiness texture!")]; + } + byteLength = specularGlossinessBuffer.byteLength; + metallicRoughnessBuffer = new Uint8Array(byteLength); + baseColorBuffer = new Uint8Array(byteLength); + strideSize = 4; + maxBaseColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.Black(); + maxMetallic = 0; + maxRoughness = 0; + for (h = 0; h < height; ++h) { + for (w = 0; w < width; ++w) { + offset = (width * h + w) * strideSize; + diffuseColor = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3(diffuseBuffer[offset], diffuseBuffer[offset + 1], diffuseBuffer[offset + 2]) + .toLinearSpace(scene.getEngine().useExactSrgbConversions) + .multiply(factors.diffuseColor); + specularColor = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3(specularGlossinessBuffer[offset], specularGlossinessBuffer[offset + 1], specularGlossinessBuffer[offset + 2]) + .toLinearSpace(scene.getEngine().useExactSrgbConversions) + .multiply(factors.specularColor); + glossiness = specularGlossinessBuffer[offset + 3] * factors.glossiness; + specularGlossiness = { + diffuseColor: diffuseColor, + specularColor: specularColor, + glossiness: glossiness, + }; + metallicRoughness = this._convertSpecularGlossinessToMetallicRoughness(specularGlossiness); + maxBaseColor.r = Math.max(maxBaseColor.r, metallicRoughness.baseColor.r); + maxBaseColor.g = Math.max(maxBaseColor.g, metallicRoughness.baseColor.g); + maxBaseColor.b = Math.max(maxBaseColor.b, metallicRoughness.baseColor.b); + maxMetallic = Math.max(maxMetallic, metallicRoughness.metallic); + maxRoughness = Math.max(maxRoughness, metallicRoughness.roughness); + baseColorBuffer[offset] = metallicRoughness.baseColor.r * 255; + baseColorBuffer[offset + 1] = metallicRoughness.baseColor.g * 255; + baseColorBuffer[offset + 2] = metallicRoughness.baseColor.b * 255; + baseColorBuffer[offset + 3] = resizedTextures.texture1.hasAlpha ? diffuseBuffer[offset + 3] * 255 : 255; + metallicRoughnessBuffer[offset] = 0; + metallicRoughnessBuffer[offset + 1] = metallicRoughness.roughness * 255; + metallicRoughnessBuffer[offset + 2] = metallicRoughness.metallic * 255; + metallicRoughnessBuffer[offset + 3] = 255; + } + } + metallicRoughnessFactors_1 = { + baseColor: maxBaseColor, + metallic: maxMetallic, + roughness: maxRoughness, + }; + writeOutMetallicRoughnessTexture = false; + writeOutBaseColorTexture = false; + for (h = 0; h < height; ++h) { + for (w = 0; w < width; ++w) { + destinationOffset = (width * h + w) * strideSize; + baseColorBuffer[destinationOffset] /= metallicRoughnessFactors_1.baseColor.r > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.baseColor.r : 1; + baseColorBuffer[destinationOffset + 1] /= metallicRoughnessFactors_1.baseColor.g > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.baseColor.g : 1; + baseColorBuffer[destinationOffset + 2] /= metallicRoughnessFactors_1.baseColor.b > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.baseColor.b : 1; + linearBaseColorPixel = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.FromInts(baseColorBuffer[destinationOffset], baseColorBuffer[destinationOffset + 1], baseColorBuffer[destinationOffset + 2]); + sRGBBaseColorPixel = linearBaseColorPixel.toGammaSpace(scene.getEngine().useExactSrgbConversions); + baseColorBuffer[destinationOffset] = sRGBBaseColorPixel.r * 255; + baseColorBuffer[destinationOffset + 1] = sRGBBaseColorPixel.g * 255; + baseColorBuffer[destinationOffset + 2] = sRGBBaseColorPixel.b * 255; + if (!_GLTFMaterialExporter._FuzzyEquals(sRGBBaseColorPixel, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White(), _GLTFMaterialExporter._Epsilon)) { + writeOutBaseColorTexture = true; + } + metallicRoughnessBuffer[destinationOffset + 1] /= + metallicRoughnessFactors_1.roughness > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.roughness : 1; + metallicRoughnessBuffer[destinationOffset + 2] /= metallicRoughnessFactors_1.metallic > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.metallic : 1; + metallicRoughnessPixel = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.FromInts(255, metallicRoughnessBuffer[destinationOffset + 1], metallicRoughnessBuffer[destinationOffset + 2]); + if (!_GLTFMaterialExporter._FuzzyEquals(metallicRoughnessPixel, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White(), _GLTFMaterialExporter._Epsilon)) { + writeOutMetallicRoughnessTexture = true; + } + } + } + if (writeOutMetallicRoughnessTexture) { + promises.push(this._getImageDataAsync(metallicRoughnessBuffer, width, height, mimeType).then(function (data) { + metallicRoughnessFactors_1.metallicRoughnessTextureData = data; + })); + } + if (writeOutBaseColorTexture) { + promises.push(this._getImageDataAsync(baseColorBuffer, width, height, mimeType).then(function (data) { + metallicRoughnessFactors_1.baseColorTextureData = data; + })); + } + return [2 /*return*/, Promise.all(promises).then(function () { + return metallicRoughnessFactors_1; + })]; + case 3: return [2 /*return*/, Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")]; + } + }); + }); + }; + /** + * Converts specular glossiness material properties to metallic roughness + * @param specularGlossiness interface with specular glossiness material properties + * @returns interface with metallic roughness material properties + */ + _GLTFMaterialExporter.prototype._convertSpecularGlossinessToMetallicRoughness = function (specularGlossiness) { + var diffusePerceivedBrightness = this._getPerceivedBrightness(specularGlossiness.diffuseColor); + var specularPerceivedBrightness = this._getPerceivedBrightness(specularGlossiness.specularColor); + var oneMinusSpecularStrength = 1 - this._getMaxComponent(specularGlossiness.specularColor); + var metallic = _GLTFMaterialExporter._SolveMetallic(diffusePerceivedBrightness, specularPerceivedBrightness, oneMinusSpecularStrength); + var baseColorFromDiffuse = specularGlossiness.diffuseColor.scale(oneMinusSpecularStrength / (1.0 - _GLTFMaterialExporter._DielectricSpecular.r) / Math.max(1 - metallic, _GLTFMaterialExporter._Epsilon)); + var baseColorFromSpecular = specularGlossiness.specularColor + .subtract(_GLTFMaterialExporter._DielectricSpecular.scale(1 - metallic)) + .scale(1 / Math.max(metallic, _GLTFMaterialExporter._Epsilon)); + var baseColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.Lerp(baseColorFromDiffuse, baseColorFromSpecular, metallic * metallic); + baseColor = baseColor.clampToRef(0, 1, baseColor); + var metallicRoughness = { + baseColor: baseColor, + metallic: metallic, + roughness: 1 - specularGlossiness.glossiness, + }; + return metallicRoughness; + }; + /** + * Calculates the surface reflectance, independent of lighting conditions + * @param color Color source to calculate brightness from + * @returns number representing the perceived brightness, or zero if color is undefined + */ + _GLTFMaterialExporter.prototype._getPerceivedBrightness = function (color) { + if (color) { + return Math.sqrt(0.299 * color.r * color.r + 0.587 * color.g * color.g + 0.114 * color.b * color.b); + } + return 0; + }; + /** + * Returns the maximum color component value + * @param color + * @returns maximum color component value, or zero if color is null or undefined + */ + _GLTFMaterialExporter.prototype._getMaxComponent = function (color) { + if (color) { + return Math.max(color.r, Math.max(color.g, color.b)); + } + return 0; + }; + /** + * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors + * @param babylonPBRMaterial BJS PBR Metallic Roughness Material + * @param mimeType mime type to use for the textures + * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface + * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied + * @returns glTF PBR Metallic Roughness factors + */ + _GLTFMaterialExporter.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync = function (babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords) { + var promises = []; + var baseColor = babylonPBRMaterial._albedoColor; + var metallic = babylonPBRMaterial._metallic; + var roughness = babylonPBRMaterial._roughness; + var metallicRoughness = { + baseColor: baseColor, + metallic: metallic, + roughness: roughness, + }; + if (hasTextureCoords) { + var albedoTexture = babylonPBRMaterial._albedoTexture; + if (albedoTexture) { + promises.push(this._exportTextureAsync(babylonPBRMaterial._albedoTexture, mimeType).then(function (glTFTexture) { + if (glTFTexture) { + glTFPbrMetallicRoughness.baseColorTexture = glTFTexture; + } + })); + } + var metallicTexture = babylonPBRMaterial._metallicTexture; + if (metallicTexture) { + promises.push(this._exportTextureAsync(metallicTexture, mimeType).then(function (glTFTexture) { + if (glTFTexture) { + glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFTexture; + } + })); + } + } + return Promise.all(promises).then(function () { + return metallicRoughness; + }); + }; + _GLTFMaterialExporter.prototype._getTextureSampler = function (texture) { + var sampler = {}; + if (!texture || !(texture instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture)) { + return sampler; + } + var wrapS = this._getGLTFTextureWrapMode(texture.wrapU); + if (wrapS !== 10497 /* TextureWrapMode.REPEAT */) { + sampler.wrapS = wrapS; + } + var wrapT = this._getGLTFTextureWrapMode(texture.wrapV); + if (wrapT !== 10497 /* TextureWrapMode.REPEAT */) { + sampler.wrapT = wrapT; + } + switch (texture.samplingMode) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR: { + sampler.magFilter = 9729 /* TextureMagFilter.LINEAR */; + sampler.minFilter = 9729 /* TextureMinFilter.LINEAR */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST: { + sampler.magFilter = 9729 /* TextureMagFilter.LINEAR */; + sampler.minFilter = 9728 /* TextureMinFilter.NEAREST */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR: { + sampler.magFilter = 9728 /* TextureMagFilter.NEAREST */; + sampler.minFilter = 9729 /* TextureMinFilter.LINEAR */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR_MIPLINEAR: { + sampler.magFilter = 9728 /* TextureMagFilter.NEAREST */; + sampler.minFilter = 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST: { + sampler.magFilter = 9728 /* TextureMagFilter.NEAREST */; + sampler.minFilter = 9728 /* TextureMinFilter.NEAREST */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR_MIPNEAREST: { + sampler.magFilter = 9728 /* TextureMagFilter.NEAREST */; + sampler.minFilter = 9985 /* TextureMinFilter.LINEAR_MIPMAP_NEAREST */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST_MIPNEAREST: { + sampler.magFilter = 9729 /* TextureMagFilter.LINEAR */; + sampler.minFilter = 9984 /* TextureMinFilter.NEAREST_MIPMAP_NEAREST */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST_MIPLINEAR: { + sampler.magFilter = 9729 /* TextureMagFilter.LINEAR */; + sampler.minFilter = 9986 /* TextureMinFilter.NEAREST_MIPMAP_LINEAR */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPLINEAR: { + sampler.magFilter = 9728 /* TextureMagFilter.NEAREST */; + sampler.minFilter = 9986 /* TextureMinFilter.NEAREST_MIPMAP_LINEAR */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPLINEAR: { + sampler.magFilter = 9729 /* TextureMagFilter.LINEAR */; + sampler.minFilter = 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPNEAREST: { + sampler.magFilter = 9729 /* TextureMagFilter.LINEAR */; + sampler.minFilter = 9985 /* TextureMinFilter.LINEAR_MIPMAP_NEAREST */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPNEAREST: { + sampler.magFilter = 9728 /* TextureMagFilter.NEAREST */; + sampler.minFilter = 9984 /* TextureMinFilter.NEAREST_MIPMAP_NEAREST */; + break; + } + } + return sampler; + }; + _GLTFMaterialExporter.prototype._getGLTFTextureWrapMode = function (wrapMode) { + switch (wrapMode) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.WRAP_ADDRESSMODE: { + return 10497 /* TextureWrapMode.REPEAT */; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.CLAMP_ADDRESSMODE: { + return 33071 /* TextureWrapMode.CLAMP_TO_EDGE */; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.MIRROR_ADDRESSMODE: { + return 33648 /* TextureWrapMode.MIRRORED_REPEAT */; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("Unsupported Texture Wrap Mode ".concat(wrapMode, "!")); + return 10497 /* TextureWrapMode.REPEAT */; + } + } + }; + /** + * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors + * @param babylonPBRMaterial BJS PBR Metallic Roughness Material + * @param mimeType mime type to use for the textures + * @param pbrMetallicRoughness glTF PBR Metallic Roughness interface + * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied + * @returns glTF PBR Metallic Roughness factors + */ + _GLTFMaterialExporter.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync = function (babylonPBRMaterial, mimeType, pbrMetallicRoughness, hasTextureCoords) { + var _this = this; + return Promise.resolve().then(function () { + var specGloss = { + diffuseColor: babylonPBRMaterial._albedoColor, + specularColor: babylonPBRMaterial._reflectivityColor, + glossiness: babylonPBRMaterial._microSurface, + }; + var albedoTexture = babylonPBRMaterial._albedoTexture; + var reflectivityTexture = babylonPBRMaterial._reflectivityTexture; + var useMicrosurfaceFromReflectivityMapAlpha = babylonPBRMaterial._useMicroSurfaceFromReflectivityMapAlpha; + if (reflectivityTexture && !useMicrosurfaceFromReflectivityMapAlpha) { + return Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported"); + } + if ((albedoTexture || reflectivityTexture) && hasTextureCoords) { + var samplerIndex_1 = _this._exportTextureSampler(albedoTexture || reflectivityTexture); + return _this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(albedoTexture, reflectivityTexture, specGloss, mimeType).then(function (metallicRoughnessFactors) { + var textures = _this._exporter._textures; + if (metallicRoughnessFactors.baseColorTextureData) { + var imageIndex = _this._exportImage("baseColor".concat(textures.length), mimeType, metallicRoughnessFactors.baseColorTextureData); + pbrMetallicRoughness.baseColorTexture = _this._exportTextureInfo(imageIndex, samplerIndex_1, albedoTexture === null || albedoTexture === void 0 ? void 0 : albedoTexture.coordinatesIndex); + } + if (metallicRoughnessFactors.metallicRoughnessTextureData) { + var imageIndex = _this._exportImage("metallicRoughness".concat(textures.length), mimeType, metallicRoughnessFactors.metallicRoughnessTextureData); + pbrMetallicRoughness.metallicRoughnessTexture = _this._exportTextureInfo(imageIndex, samplerIndex_1, reflectivityTexture === null || reflectivityTexture === void 0 ? void 0 : reflectivityTexture.coordinatesIndex); + } + return metallicRoughnessFactors; + }); + } + else { + return _this._convertSpecularGlossinessToMetallicRoughness(specGloss); + } + }); + }; + /** + * Converts a Babylon PBR Base Material to a glTF Material + * @param babylonPBRMaterial BJS PBR Base Material + * @param mimeType mime type to use for the textures + * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied + * @returns async glTF Material representation + */ + _GLTFMaterialExporter.prototype._convertPBRMaterialAsync = function (babylonPBRMaterial, mimeType, hasTextureCoords) { + var _this = this; + var glTFPbrMetallicRoughness = {}; + var glTFMaterial = { + name: babylonPBRMaterial.name, + }; + var useMetallicRoughness = babylonPBRMaterial.isMetallicWorkflow(); + if (useMetallicRoughness) { + var albedoColor = babylonPBRMaterial._albedoColor; + var alpha = babylonPBRMaterial.alpha; + if (albedoColor) { + glTFPbrMetallicRoughness.baseColorFactor = [albedoColor.r, albedoColor.g, albedoColor.b, alpha]; + } + return this._convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then(function (metallicRoughness) { + return _this._setMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords); + }); + } + else { + return this._convertSpecGlossFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then(function (metallicRoughness) { + return _this._setMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords); + }); + } + }; + _GLTFMaterialExporter.prototype._setMetallicRoughnessPbrMaterial = function (metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords) { + var materialMap = this._exporter._materialMap; + var materials = this._exporter._materials; + var promises = []; + if (metallicRoughness) { + _GLTFMaterialExporter._SetAlphaMode(glTFMaterial, babylonPBRMaterial); + if (!(_GLTFMaterialExporter._FuzzyEquals(metallicRoughness.baseColor, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White(), _GLTFMaterialExporter._Epsilon) && + babylonPBRMaterial.alpha >= _GLTFMaterialExporter._Epsilon)) { + glTFPbrMetallicRoughness.baseColorFactor = [metallicRoughness.baseColor.r, metallicRoughness.baseColor.g, metallicRoughness.baseColor.b, babylonPBRMaterial.alpha]; + } + if (metallicRoughness.metallic != null && metallicRoughness.metallic !== 1) { + glTFPbrMetallicRoughness.metallicFactor = metallicRoughness.metallic; + } + if (metallicRoughness.roughness != null && metallicRoughness.roughness !== 1) { + glTFPbrMetallicRoughness.roughnessFactor = metallicRoughness.roughness; + } + if (babylonPBRMaterial.backFaceCulling != null && !babylonPBRMaterial.backFaceCulling) { + if (!babylonPBRMaterial._twoSidedLighting) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn(babylonPBRMaterial.name + ": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."); + } + glTFMaterial.doubleSided = true; + } + if (hasTextureCoords) { + var bumpTexture_2 = babylonPBRMaterial._bumpTexture; + if (bumpTexture_2) { + var promise = this._exportTextureAsync(bumpTexture_2, mimeType).then(function (glTFTexture) { + if (glTFTexture) { + glTFMaterial.normalTexture = glTFTexture; + if (bumpTexture_2.level !== 1) { + glTFMaterial.normalTexture.scale = bumpTexture_2.level; + } + } + }); + promises.push(promise); + } + var ambientTexture = babylonPBRMaterial._ambientTexture; + if (ambientTexture) { + var promise = this._exportTextureAsync(ambientTexture, mimeType).then(function (glTFTexture) { + if (glTFTexture) { + var occlusionTexture = { + index: glTFTexture.index, + texCoord: glTFTexture.texCoord, + extensions: glTFTexture.extensions, + }; + glTFMaterial.occlusionTexture = occlusionTexture; + var ambientTextureStrength = babylonPBRMaterial._ambientTextureStrength; + if (ambientTextureStrength) { + occlusionTexture.strength = ambientTextureStrength; + } + } + }); + promises.push(promise); + } + var emissiveTexture = babylonPBRMaterial._emissiveTexture; + if (emissiveTexture) { + var promise = this._exportTextureAsync(emissiveTexture, mimeType).then(function (glTFTexture) { + if (glTFTexture) { + glTFMaterial.emissiveTexture = glTFTexture; + } + }); + promises.push(promise); + } + } + var emissiveColor = babylonPBRMaterial._emissiveColor; + if (!_GLTFMaterialExporter._FuzzyEquals(emissiveColor, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.Black(), _GLTFMaterialExporter._Epsilon)) { + glTFMaterial.emissiveFactor = emissiveColor.asArray(); + } + glTFMaterial.pbrMetallicRoughness = glTFPbrMetallicRoughness; + materials.push(glTFMaterial); + materialMap[babylonPBRMaterial.uniqueId] = materials.length - 1; + } + return this._finishMaterial(promises, glTFMaterial, babylonPBRMaterial, mimeType); + }; + _GLTFMaterialExporter.prototype._getPixelsFromTexture = function (babylonTexture) { + var pixels = babylonTexture.textureType === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Constants.TEXTURETYPE_UNSIGNED_INT + ? babylonTexture.readPixels() + : babylonTexture.readPixels(); + return pixels; + }; + /** + * Extracts a texture from a Babylon texture into file data and glTF data + * @param babylonTexture Babylon texture to extract + * @param mimeType Mime Type of the babylonTexture + * @returns glTF texture info, or null if the texture format is not supported + */ + _GLTFMaterialExporter.prototype._exportTextureAsync = function (babylonTexture, mimeType) { + var _this = this; + var extensionPromise = this._exporter._extensionsPreExportTextureAsync("exporter", babylonTexture, mimeType); + if (!extensionPromise) { + return this._exportTextureInfoAsync(babylonTexture, mimeType); + } + return extensionPromise.then(function (texture) { + if (!texture) { + return _this._exportTextureInfoAsync(babylonTexture, mimeType); + } + return _this._exportTextureInfoAsync(texture, mimeType); + }); + }; + _GLTFMaterialExporter.prototype._exportTextureInfoAsync = function (babylonTexture, mimeType) { + return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__awaiter)(this, void 0, void 0, function () { + var textureUid, pixels_1, samplerIndex, textureMimeType, internalTextureToImage, internalTextureUniqueId, imageIndexPromise, size_1, textureInfo, _a; + var _this = this; + return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__generator)(this, function (_b) { + switch (_b.label) { + case 0: + textureUid = babylonTexture.uid; + if (!!(textureUid in this._textureMap)) return [3 /*break*/, 3]; + return [4 /*yield*/, this._getPixelsFromTexture(babylonTexture)]; + case 1: + pixels_1 = _b.sent(); + if (!pixels_1) { + return [2 /*return*/, null]; + } + samplerIndex = this._exportTextureSampler(babylonTexture); + textureMimeType = babylonTexture.mimeType; + if (textureMimeType) { + switch (textureMimeType) { + case "image/jpeg": + case "image/png": + case "image/webp": + mimeType = textureMimeType; + break; + default: + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Unsupported media type: ".concat(textureMimeType)); + break; + } + } + internalTextureToImage = this._internalTextureToImage; + internalTextureUniqueId = babylonTexture.getInternalTexture().uniqueId; + internalTextureToImage[internalTextureUniqueId] || (internalTextureToImage[internalTextureUniqueId] = {}); + imageIndexPromise = internalTextureToImage[internalTextureUniqueId][mimeType]; + if (imageIndexPromise === undefined) { + size_1 = babylonTexture.getSize(); + imageIndexPromise = (function () { return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__awaiter)(_this, void 0, void 0, function () { + var data; + return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__generator)(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this._getImageDataAsync(pixels_1, size_1.width, size_1.height, mimeType)]; + case 1: + data = _a.sent(); + return [2 /*return*/, this._exportImage(babylonTexture.name, mimeType, data)]; + } + }); + }); })(); + internalTextureToImage[internalTextureUniqueId][mimeType] = imageIndexPromise; + } + _a = this._exportTextureInfo; + return [4 /*yield*/, imageIndexPromise]; + case 2: + textureInfo = _a.apply(this, [_b.sent(), samplerIndex, babylonTexture.coordinatesIndex]); + this._textureMap[textureUid] = textureInfo; + this._exporter._extensionsPostExportTextures("exporter", this._textureMap[textureUid], babylonTexture); + _b.label = 3; + case 3: return [2 /*return*/, this._textureMap[textureUid]]; + } + }); + }); + }; + _GLTFMaterialExporter.prototype._exportImage = function (name, mimeType, data) { + var imageData = this._exporter._imageData; + var baseName = name.replace(/\.\/|\/|\.\\|\\/g, "_"); + var extension = getFileExtensionFromMimeType(mimeType); + var fileName = baseName + extension; + if (fileName in imageData) { + fileName = "".concat(baseName, "_").concat(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.RandomId()).concat(extension); + } + imageData[fileName] = { + data: data, + mimeType: mimeType, + }; + var images = this._exporter._images; + images.push({ + name: name, + uri: fileName, + }); + return images.length - 1; + }; + _GLTFMaterialExporter.prototype._exportTextureInfo = function (imageIndex, samplerIndex, coordinatesIndex) { + var textures = this._exporter._textures; + var textureIndex = textures.findIndex(function (t) { return t.sampler == samplerIndex && t.source === imageIndex; }); + if (textureIndex === -1) { + textureIndex = textures.length; + textures.push({ + source: imageIndex, + sampler: samplerIndex, + }); + } + var textureInfo = { index: textureIndex }; + if (coordinatesIndex) { + textureInfo.texCoord = coordinatesIndex; + } + return textureInfo; + }; + _GLTFMaterialExporter.prototype._exportTextureSampler = function (texture) { + var sampler = this._getTextureSampler(texture); + // if a pre-existing sampler with identical parameters exists, then reuse the previous sampler + var samplers = this._exporter._samplers; + var samplerIndex = samplers.findIndex(function (s) { return s.minFilter === sampler.minFilter && s.magFilter === sampler.magFilter && s.wrapS === sampler.wrapS && s.wrapT === sampler.wrapT; }); + if (samplerIndex !== -1) { + return samplerIndex; + } + samplers.push(sampler); + return samplers.length - 1; + }; + /** + * Represents the dielectric specular values for R, G and B + */ + _GLTFMaterialExporter._DielectricSpecular = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3(0.04, 0.04, 0.04); + /** + * Allows the maximum specular power to be defined for material calculations + */ + _GLTFMaterialExporter._MaxSpecularPower = 1024; + /** + * Numeric tolerance value + */ + _GLTFMaterialExporter._Epsilon = 1e-6; + return _GLTFMaterialExporter; +}()); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/glTFSerializer.ts": +/*!***************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/glTFSerializer.ts ***! + \***************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTF2Export: () => (/* binding */ GLTF2Export) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); + +/** + * Class for generating glTF data from a Babylon scene. + */ +var GLTF2Export = /** @class */ (function () { + function GLTF2Export() { + } + /** + * Exports the geometry of the scene to .gltf file format asynchronously + * @param scene Babylon scene with scene hierarchy information + * @param filePrefix File prefix to use when generating the glTF file + * @param options Exporter options + * @returns Returns an object with a .gltf file and associates texture names + * as keys and their data and paths as values + */ + GLTF2Export.GLTFAsync = function (scene, filePrefix, options) { + return scene.whenReadyAsync().then(function () { + var glTFPrefix = filePrefix.replace(/\.[^/.]+$/, ""); + var gltfGenerator = new _glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter(scene, options); + return gltfGenerator._generateGLTFAsync(glTFPrefix); + }); + }; + GLTF2Export._PreExportAsync = function (scene, options) { + return Promise.resolve().then(function () { + if (options && options.exportWithoutWaitingForScene) { + return Promise.resolve(); + } + else { + return scene.whenReadyAsync(); + } + }); + }; + GLTF2Export._PostExportAsync = function (scene, glTFData, options) { + return Promise.resolve().then(function () { + if (options && options.exportWithoutWaitingForScene) { + return glTFData; + } + else { + return glTFData; + } + }); + }; + /** + * Exports the geometry of the scene to .glb file format asychronously + * @param scene Babylon scene with scene hierarchy information + * @param filePrefix File prefix to use when generating glb file + * @param options Exporter options + * @returns Returns an object with a .glb filename as key and data as value + */ + GLTF2Export.GLBAsync = function (scene, filePrefix, options) { + var _this = this; + return this._PreExportAsync(scene, options).then(function () { + var glTFPrefix = filePrefix.replace(/\.[^/.]+$/, ""); + var gltfGenerator = new _glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter(scene, options); + return gltfGenerator._generateGLBAsync(glTFPrefix).then(function (glTFData) { + return _this._PostExportAsync(scene, glTFData, options); + }); + }); + }; + return GLTF2Export; +}()); + + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/glTFUtilities.ts": +/*!**************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/glTFUtilities.ts ***! + \**************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ _GLTFUtilities: () => (/* binding */ _GLTFUtilities) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); + +/** + * @internal + */ +var _GLTFUtilities = /** @class */ (function () { + function _GLTFUtilities() { + } + /** + * Creates a buffer view based on the supplied arguments + * @param bufferIndex index value of the specified buffer + * @param byteOffset byte offset value + * @param byteLength byte length of the bufferView + * @param byteStride byte distance between conequential elements + * @param name name of the buffer view + * @returns bufferView for glTF + */ + _GLTFUtilities._CreateBufferView = function (bufferIndex, byteOffset, byteLength, byteStride, name) { + var bufferview = { buffer: bufferIndex, byteLength: byteLength }; + if (byteOffset) { + bufferview.byteOffset = byteOffset; + } + if (name) { + bufferview.name = name; + } + if (byteStride) { + bufferview.byteStride = byteStride; + } + return bufferview; + }; + /** + * Creates an accessor based on the supplied arguments + * @param bufferviewIndex The index of the bufferview referenced by this accessor + * @param name The name of the accessor + * @param type The type of the accessor + * @param componentType The datatype of components in the attribute + * @param count The number of attributes referenced by this accessor + * @param byteOffset The offset relative to the start of the bufferView in bytes + * @param min Minimum value of each component in this attribute + * @param max Maximum value of each component in this attribute + * @returns accessor for glTF + */ + _GLTFUtilities._CreateAccessor = function (bufferviewIndex, name, type, componentType, count, byteOffset, min, max) { + var accessor = { name: name, bufferView: bufferviewIndex, componentType: componentType, count: count, type: type }; + if (min != null) { + accessor.min = min; + } + if (max != null) { + accessor.max = max; + } + if (byteOffset != null) { + accessor.byteOffset = byteOffset; + } + return accessor; + }; + /** + * Calculates the minimum and maximum values of an array of position floats + * @param positions Positions array of a mesh + * @param vertexStart Starting vertex offset to calculate min and max values + * @param vertexCount Number of vertices to check for min and max values + * @returns min number array and max number array + */ + _GLTFUtilities._CalculateMinMaxPositions = function (positions, vertexStart, vertexCount) { + var min = [Infinity, Infinity, Infinity]; + var max = [-Infinity, -Infinity, -Infinity]; + var positionStrideSize = 3; + var indexOffset; + var position; + var vector; + if (vertexCount) { + for (var i = vertexStart, length_1 = vertexStart + vertexCount; i < length_1; ++i) { + indexOffset = positionStrideSize * i; + position = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(positions, indexOffset); + vector = position.asArray(); + for (var j = 0; j < positionStrideSize; ++j) { + var num = vector[j]; + if (num < min[j]) { + min[j] = num; + } + if (num > max[j]) { + max[j] = num; + } + ++indexOffset; + } + } + } + return { min: min, max: max }; + }; + _GLTFUtilities._NormalizeTangentFromRef = function (tangent) { + var length = Math.sqrt(tangent.x * tangent.x + tangent.y * tangent.y + tangent.z * tangent.z); + if (length > 0) { + tangent.x /= length; + tangent.y /= length; + tangent.z /= length; + } + }; + _GLTFUtilities._GetDataAccessorElementCount = function (accessorType) { + switch (accessorType) { + case "MAT2" /* AccessorType.MAT2 */: + return 4; + case "MAT3" /* AccessorType.MAT3 */: + return 9; + case "MAT4" /* AccessorType.MAT4 */: + return 16; + case "SCALAR" /* AccessorType.SCALAR */: + return 1; + case "VEC2" /* AccessorType.VEC2 */: + return 2; + case "VEC3" /* AccessorType.VEC3 */: + return 3; + case "VEC4" /* AccessorType.VEC4 */: + return 4; + } + }; + return _GLTFUtilities; +}()); + + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/index.ts": +/*!******************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/index.ts ***! + \******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.EXT_mesh_gpu_instancing), +/* harmony export */ GLTF2Export: () => (/* reexport safe */ _glTFSerializer__WEBPACK_IMPORTED_MODULE_5__.GLTF2Export), +/* harmony export */ GLTFData: () => (/* reexport safe */ _glTFData__WEBPACK_IMPORTED_MODULE_1__.GLTFData), +/* harmony export */ KHR_lights_punctual: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_lights_punctual), +/* harmony export */ KHR_materials_anisotropy: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_anisotropy), +/* harmony export */ KHR_materials_clearcoat: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_clearcoat), +/* harmony export */ KHR_materials_dispersion: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_dispersion), +/* harmony export */ KHR_materials_emissive_strength: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_emissive_strength), +/* harmony export */ KHR_materials_ior: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_ior), +/* harmony export */ KHR_materials_iridescence: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_iridescence), +/* harmony export */ KHR_materials_sheen: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_sheen), +/* harmony export */ KHR_materials_specular: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_specular), +/* harmony export */ KHR_materials_transmission: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_transmission), +/* harmony export */ KHR_materials_unlit: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_unlit), +/* harmony export */ KHR_materials_volume: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_volume), +/* harmony export */ KHR_texture_transform: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_texture_transform), +/* harmony export */ _BinaryWriter: () => (/* reexport safe */ _glTFExporter__WEBPACK_IMPORTED_MODULE_2__._BinaryWriter), +/* harmony export */ _Exporter: () => (/* reexport safe */ _glTFExporter__WEBPACK_IMPORTED_MODULE_2__._Exporter), +/* harmony export */ _GLTFAnimation: () => (/* reexport safe */ _glTFAnimation__WEBPACK_IMPORTED_MODULE_0__._GLTFAnimation), +/* harmony export */ _GLTFMaterialExporter: () => (/* reexport safe */ _glTFMaterialExporter__WEBPACK_IMPORTED_MODULE_4__._GLTFMaterialExporter), +/* harmony export */ _GLTFUtilities: () => (/* reexport safe */ _glTFUtilities__WEBPACK_IMPORTED_MODULE_6__._GLTFUtilities), +/* harmony export */ __IGLTFExporterExtensionV2: () => (/* reexport safe */ _glTFExporterExtension__WEBPACK_IMPORTED_MODULE_3__.__IGLTFExporterExtensionV2) +/* harmony export */ }); +/* harmony import */ var _glTFAnimation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFAnimation */ "../../../dev/serializers/src/glTF/2.0/glTFAnimation.ts"); +/* harmony import */ var _glTFData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFData */ "../../../dev/serializers/src/glTF/2.0/glTFData.ts"); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var _glTFExporterExtension__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./glTFExporterExtension */ "../../../dev/serializers/src/glTF/2.0/glTFExporterExtension.ts"); +/* harmony import */ var _glTFMaterialExporter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./glTFMaterialExporter */ "../../../dev/serializers/src/glTF/2.0/glTFMaterialExporter.ts"); +/* harmony import */ var _glTFSerializer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./glTFSerializer */ "../../../dev/serializers/src/glTF/2.0/glTFSerializer.ts"); +/* harmony import */ var _glTFUtilities__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./glTFUtilities */ "../../../dev/serializers/src/glTF/2.0/glTFUtilities.ts"); +/* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Extensions/index */ "../../../dev/serializers/src/glTF/2.0/Extensions/index.ts"); +/* eslint-disable import/no-internal-modules */ + + + + + + + + + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/glTFFileExporter.ts": +/*!*************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/glTFFileExporter.ts ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ __IGLTFExporterExtension: () => (/* binding */ __IGLTFExporterExtension) +/* harmony export */ }); +/** @internal */ +// eslint-disable-next-line no-var, @typescript-eslint/naming-convention +var __IGLTFExporterExtension = 0; // I am here to allow dts to be created + + +/***/ }), + +/***/ "../../../lts/serializers/src/legacy/legacy-glTF2Serializer.ts": +/*!*********************************************************************!*\ + !*** ../../../lts/serializers/src/legacy/legacy-glTF2Serializer.ts ***! + \*********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.EXT_mesh_gpu_instancing), +/* harmony export */ GLTF2Export: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.GLTF2Export), +/* harmony export */ GLTFData: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.GLTFData), +/* harmony export */ KHR_lights_punctual: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_lights_punctual), +/* harmony export */ KHR_materials_anisotropy: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_anisotropy), +/* harmony export */ KHR_materials_clearcoat: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_clearcoat), +/* harmony export */ KHR_materials_dispersion: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_dispersion), +/* harmony export */ KHR_materials_emissive_strength: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_emissive_strength), +/* harmony export */ KHR_materials_ior: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_ior), +/* harmony export */ KHR_materials_iridescence: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_iridescence), +/* harmony export */ KHR_materials_sheen: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_sheen), +/* harmony export */ KHR_materials_specular: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_specular), +/* harmony export */ KHR_materials_transmission: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_transmission), +/* harmony export */ KHR_materials_unlit: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_unlit), +/* harmony export */ KHR_materials_volume: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_volume), +/* harmony export */ KHR_texture_transform: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_texture_transform), +/* harmony export */ _BinaryWriter: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__._BinaryWriter), +/* harmony export */ _Exporter: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__._Exporter), +/* harmony export */ _GLTFAnimation: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__._GLTFAnimation), +/* harmony export */ _GLTFMaterialExporter: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__._GLTFMaterialExporter), +/* harmony export */ _GLTFUtilities: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__._GLTFUtilities), +/* harmony export */ __IGLTFExporterExtension: () => (/* reexport safe */ serializers_glTF_glTFFileExporter__WEBPACK_IMPORTED_MODULE_0__.__IGLTFExporterExtension), +/* harmony export */ __IGLTFExporterExtensionV2: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.__IGLTFExporterExtensionV2) +/* harmony export */ }); +/* harmony import */ var serializers_glTF_glTFFileExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! serializers/glTF/glTFFileExporter */ "../../../dev/serializers/src/glTF/glTFFileExporter.ts"); +/* harmony import */ var serializers_glTF_2_0_glTFData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! serializers/glTF/2.0/glTFData */ "../../../dev/serializers/src/glTF/2.0/glTFData.ts"); +/* harmony import */ var serializers_glTF_2_0_glTFSerializer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! serializers/glTF/2.0/glTFSerializer */ "../../../dev/serializers/src/glTF/2.0/glTFSerializer.ts"); +/* harmony import */ var serializers_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! serializers/glTF/2.0/Extensions/index */ "../../../dev/serializers/src/glTF/2.0/Extensions/index.ts"); +/* harmony import */ var serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! serializers/glTF/2.0/index */ "../../../dev/serializers/src/glTF/2.0/index.ts"); +/* eslint-disable import/no-internal-modules */ + + + + + +/** + * This is the entry point for the UMD module. + * The entry point for a future ESM package should be index.ts + */ +var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined; +if (typeof globalObject !== "undefined") { + globalObject.BABYLON = globalObject.BABYLON || {}; + var BABYLON_1 = globalObject.BABYLON; + BABYLON_1.GLTF2 = BABYLON_1.GLTF2 || {}; + BABYLON_1.GLTF2.Exporter = BABYLON_1.GLTF2.Exporter || {}; + BABYLON_1.GLTF2.Exporter.Extensions = BABYLON_1.GLTF2.Exporter.Extensions || {}; + var keys = []; + for (var key in serializers_glTF_glTFFileExporter__WEBPACK_IMPORTED_MODULE_0__) { + BABYLON_1[key] = serializers_glTF_glTFFileExporter__WEBPACK_IMPORTED_MODULE_0__[key]; + keys.push(key); + } + for (var key in serializers_glTF_2_0_glTFData__WEBPACK_IMPORTED_MODULE_1__) { + BABYLON_1[key] = serializers_glTF_2_0_glTFData__WEBPACK_IMPORTED_MODULE_1__[key]; + keys.push(key); + } + for (var key in serializers_glTF_2_0_glTFSerializer__WEBPACK_IMPORTED_MODULE_2__) { + BABYLON_1[key] = serializers_glTF_2_0_glTFSerializer__WEBPACK_IMPORTED_MODULE_2__[key]; + keys.push(key); + } + for (var key in serializers_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_3__) { + BABYLON_1.GLTF2.Exporter.Extensions[key] = serializers_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_3__[key]; + keys.push(key); + } + for (var key in serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__) { + // Prevent Reassignment. + if (keys.indexOf(key) > -1) { + continue; + } + BABYLON_1.GLTF2.Exporter[key] = serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__[key]; + } +} + + + + +/***/ }), + +/***/ "babylonjs/Maths/math.vector": +/*!****************************************************************************************************!*\ + !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***! + \****************************************************************************************************/ +/***/ ((module) => { + +module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math_vector__; + +/***/ }), + +/***/ "../../../../node_modules/tslib/tslib.es6.mjs": +/*!****************************************************!*\ + !*** ../../../../node_modules/tslib/tslib.es6.mjs ***! + \****************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ __addDisposableResource: () => (/* binding */ __addDisposableResource), +/* harmony export */ __assign: () => (/* binding */ __assign), +/* harmony export */ __asyncDelegator: () => (/* binding */ __asyncDelegator), +/* harmony export */ __asyncGenerator: () => (/* binding */ __asyncGenerator), +/* harmony export */ __asyncValues: () => (/* binding */ __asyncValues), +/* harmony export */ __await: () => (/* binding */ __await), +/* harmony export */ __awaiter: () => (/* binding */ __awaiter), +/* harmony export */ __classPrivateFieldGet: () => (/* binding */ __classPrivateFieldGet), +/* harmony export */ __classPrivateFieldIn: () => (/* binding */ __classPrivateFieldIn), +/* harmony export */ __classPrivateFieldSet: () => (/* binding */ __classPrivateFieldSet), +/* harmony export */ __createBinding: () => (/* binding */ __createBinding), +/* harmony export */ __decorate: () => (/* binding */ __decorate), +/* harmony export */ __disposeResources: () => (/* binding */ __disposeResources), +/* harmony export */ __esDecorate: () => (/* binding */ __esDecorate), +/* harmony export */ __exportStar: () => (/* binding */ __exportStar), +/* harmony export */ __extends: () => (/* binding */ __extends), +/* harmony export */ __generator: () => (/* binding */ __generator), +/* harmony export */ __importDefault: () => (/* binding */ __importDefault), +/* harmony export */ __importStar: () => (/* binding */ __importStar), +/* harmony export */ __makeTemplateObject: () => (/* binding */ __makeTemplateObject), +/* harmony export */ __metadata: () => (/* binding */ __metadata), +/* harmony export */ __param: () => (/* binding */ __param), +/* harmony export */ __propKey: () => (/* binding */ __propKey), +/* harmony export */ __read: () => (/* binding */ __read), +/* harmony export */ __rest: () => (/* binding */ __rest), +/* harmony export */ __runInitializers: () => (/* binding */ __runInitializers), +/* harmony export */ __setFunctionName: () => (/* binding */ __setFunctionName), +/* harmony export */ __spread: () => (/* binding */ __spread), +/* harmony export */ __spreadArray: () => (/* binding */ __spreadArray), +/* harmony export */ __spreadArrays: () => (/* binding */ __spreadArrays), +/* harmony export */ __values: () => (/* binding */ __values), +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise, SuppressedError, Symbol */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + } + return __assign.apply(this, arguments); +} + +function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +} + +function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { + function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } + var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; + var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; + var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); + var _, done = false; + for (var i = decorators.length - 1; i >= 0; i--) { + var context = {}; + for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; + for (var p in contextIn.access) context.access[p] = contextIn.access[p]; + context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; + var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); + if (kind === "accessor") { + if (result === void 0) continue; + if (result === null || typeof result !== "object") throw new TypeError("Object expected"); + if (_ = accept(result.get)) descriptor.get = _; + if (_ = accept(result.set)) descriptor.set = _; + if (_ = accept(result.init)) initializers.unshift(_); + } + else if (_ = accept(result)) { + if (kind === "field") initializers.unshift(_); + else descriptor[key] = _; + } + } + if (target) Object.defineProperty(target, contextIn.name, descriptor); + done = true; +}; + +function __runInitializers(thisArg, initializers, value) { + var useValue = arguments.length > 2; + for (var i = 0; i < initializers.length; i++) { + value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); + } + return useValue ? value : void 0; +}; + +function __propKey(x) { + return typeof x === "symbol" ? x : "".concat(x); +}; + +function __setFunctionName(f, name, prefix) { + if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; + return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); +}; + +function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +var __createBinding = Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +}); + +function __exportStar(m, o) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); +} + +function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +/** @deprecated */ +function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +/** @deprecated */ +function __spreadArrays() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } +} + +function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; + +var __setModuleDefault = Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}; + +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +} + +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { default: mod }; +} + +function __classPrivateFieldGet(receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +} + +function __classPrivateFieldSet(receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +} + +function __classPrivateFieldIn(state, receiver) { + if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); + return typeof state === "function" ? receiver === state : state.has(receiver); +} + +function __addDisposableResource(env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +} + +var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}; + +function __disposeResources(env) { + function fail(e) { + env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ + __extends, + __assign, + __rest, + __decorate, + __param, + __metadata, + __awaiter, + __generator, + __createBinding, + __exportStar, + __values, + __read, + __spread, + __spreadArrays, + __spreadArray, + __await, + __asyncGenerator, + __asyncDelegator, + __asyncValues, + __makeTemplateObject, + __importStar, + __importDefault, + __classPrivateFieldGet, + __classPrivateFieldSet, + __classPrivateFieldIn, + __addDisposableResource, + __disposeResources, +}); + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ (() => { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = (module) => { +/******/ var getter = module && module.__esModule ? +/******/ () => (module['default']) : +/******/ () => (module); +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/global */ +/******/ (() => { +/******/ __webpack_require__.g = (function() { +/******/ if (typeof globalThis === 'object') return globalThis; +/******/ try { +/******/ return this || new Function('return this')(); +/******/ } catch (e) { +/******/ if (typeof window === 'object') return window; +/******/ } +/******/ })(); +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +(() => { +/*!**********************!*\ + !*** ./src/glTF2.ts ***! + \**********************/ +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__), +/* harmony export */ serializers: () => (/* reexport module object */ _lts_serializers_legacy_legacy_glTF2Serializer__WEBPACK_IMPORTED_MODULE_0__) +/* harmony export */ }); +/* harmony import */ var _lts_serializers_legacy_legacy_glTF2Serializer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @lts/serializers/legacy/legacy-glTF2Serializer */ "../../../lts/serializers/src/legacy/legacy-glTF2Serializer.ts"); + + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_lts_serializers_legacy_legacy_glTF2Serializer__WEBPACK_IMPORTED_MODULE_0__); + +})(); + +__webpack_exports__ = __webpack_exports__["default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xJTm9kZT4+IHtcclxuICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUpID0+IHtcclxuICAgICAgICAgICAgaWYgKG5vZGUgJiYgYmFieWxvbk5vZGUgaW5zdGFuY2VvZiBNZXNoKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoYmFieWxvbk5vZGUuaGFzVGhpbkluc3RhbmNlcyAmJiBiaW5hcnlXcml0ZXIpIHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl93YXNVc2VkID0gdHJ1ZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgbm9UcmFuc2xhdGlvbiA9IFZlY3RvcjMuWmVybygpO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vUm90YXRpb24gPSBRdWF0ZXJuaW9uLklkZW50aXR5KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgbm9TY2FsZSA9IFZlY3RvcjMuT25lKCk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIC8vIHJldHJpZXZlIGFsbCB0aGUgaW5zdGFuY2Ugd29ybGQgbWF0cml4XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0cml4ID0gYmFieWxvbk5vZGUudGhpbkluc3RhbmNlR2V0V29ybGRNYXRyaWNlcygpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBpd3QgPSBUbXBWZWN0b3JzLlZlY3RvcjNbMl07XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXdyID0gVG1wVmVjdG9ycy5RdWF0ZXJuaW9uWzFdO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGl3cyA9IFRtcFZlY3RvcnMuVmVjdG9yM1szXTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGhhc0FueUluc3RhbmNlV29ybGRUcmFuc2xhdGlvbiA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCBoYXNBbnlJbnN0YW5jZVdvcmxkUm90YXRpb24gPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgaGFzQW55SW5zdGFuY2VXb3JsZFNjYWxlID0gZmFsc2U7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIC8vIHByZXBhcmUgdGVtcCBidWZmZXJzXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdHJhbnNsYXRpb25CdWZmZXIgPSBuZXcgRmxvYXQzMkFycmF5KGJhYnlsb25Ob2RlLnRoaW5JbnN0YW5jZUNvdW50ICogMyk7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgcm90YXRpb25CdWZmZXIgPSBuZXcgRmxvYXQzMkFycmF5KGJhYnlsb25Ob2RlLnRoaW5JbnN0YW5jZUNvdW50ICogNCk7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVCdWZmZXIgPSBuZXcgRmxvYXQzMkFycmF5KGJhYnlsb25Ob2RlLnRoaW5JbnN0YW5jZUNvdW50ICogMyk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBpID0gMDtcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG0gb2YgbWF0cml4KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG0uZGVjb21wb3NlKGl3cywgaXdyLCBpd3QpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gZmlsbCB0aGUgdGVtcCBidWZmZXJcclxuICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNsYXRpb25CdWZmZXIuc2V0KGl3dC5hc0FycmF5KCksIGkgKiAzKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb25CdWZmZXIuc2V0KGl3ci5ub3JtYWxpemUoKS5hc0FycmF5KCksIGkgKiA0KTsgLy8gZW5zdXJlIHRoZSBxdWF0ZXJuaW9uIGlzIG5vcm1hbGl6ZWRcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVCdWZmZXIuc2V0KGl3cy5hc0FycmF5KCksIGkgKiAzKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIHRoaXMgaXMgd2hlcmUgd2UgZGVjaWRlIGlmIHRoZXJlIGlzIGFueSB0cmFuc2Zvcm1hdGlvblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBoYXNBbnlJbnN0YW5jZVdvcmxkVHJhbnNsYXRpb24gPSBoYXNBbnlJbnN0YW5jZVdvcmxkVHJhbnNsYXRpb24gfHwgIWl3dC5lcXVhbHNXaXRoRXBzaWxvbihub1RyYW5zbGF0aW9uKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaGFzQW55SW5zdGFuY2VXb3JsZFJvdGF0aW9uID0gaGFzQW55SW5zdGFuY2VXb3JsZFJvdGF0aW9uIHx8ICFpd3IuZXF1YWxzV2l0aEVwc2lsb24obm9Sb3RhdGlvbik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGhhc0FueUluc3RhbmNlV29ybGRTY2FsZSA9IGhhc0FueUluc3RhbmNlV29ybGRTY2FsZSB8fCAhaXdzLmVxdWFsc1dpdGhFcHNpbG9uKG5vU2NhbGUpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaSsrO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZXh0ZW5zaW9uOiBJRVhUTWVzaEdwdUluc3RhbmNpbmcgPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGF0dHJpYnV0ZXM6IHt9LFxyXG4gICAgICAgICAgICAgICAgICAgIH07XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIC8vIGRvIHdlIG5lZWQgdG8gd3JpdGUgVFJBTlNMQVRJT04gP1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChoYXNBbnlJbnN0YW5jZVdvcmxkVHJhbnNsYXRpb24pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0ZW5zaW9uLmF0dHJpYnV0ZXNbXCJUUkFOU0xBVElPTlwiXSA9IHRoaXMuX2J1aWxkQWNjZXNzb3IoXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2xhdGlvbkJ1ZmZlcixcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFjY2Vzc29yVHlwZS5WRUMzLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvbk5vZGUudGhpbkluc3RhbmNlQ291bnQsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiaW5hcnlXcml0ZXIsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBY2Nlc3NvckNvbXBvbmVudFR5cGUuRkxPQVRcclxuICAgICAgICAgICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgLy8gZG8gd2UgbmVlZCB0byB3cml0ZSBST1RBVElPTiA/XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGhhc0FueUluc3RhbmNlV29ybGRSb3RhdGlvbikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb21wb25lbnRUeXBlID0gQWNjZXNzb3JDb21wb25lbnRUeXBlLkZMT0FUOyAvLyB3ZSBkZWNpZGVkIHRvIHN0YXkgb24gRkxPQVQgZm9yIG5vdyBzZWUgaHR0cHM6Ly9naXRodWIuY29tL0JhYnlsb25KUy9CYWJ5bG9uLmpzL3B1bGwvMTI0OTVcclxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0ZW5zaW9uLmF0dHJpYnV0ZXNbXCJST1RBVElPTlwiXSA9IHRoaXMuX2J1aWxkQWNjZXNzb3Iocm90YXRpb25CdWZmZXIsIEFjY2Vzc29yVHlwZS5WRUM0LCBiYWJ5bG9uTm9kZS50aGluSW5zdGFuY2VDb3VudCwgYmluYXJ5V3JpdGVyLCBjb21wb25lbnRUeXBlKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgLy8gZG8gd2UgbmVlZCB0byB3cml0ZSBTQ0FMRSA/XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGhhc0FueUluc3RhbmNlV29ybGRTY2FsZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBleHRlbnNpb24uYXR0cmlidXRlc1tcIlNDQUxFXCJdID0gdGhpcy5fYnVpbGRBY2Nlc3NvcihcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlQnVmZmVyLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgQWNjZXNzb3JUeXBlLlZFQzMsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uTm9kZS50aGluSW5zdGFuY2VDb3VudCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJpbmFyeVdyaXRlcixcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFjY2Vzc29yQ29tcG9uZW50VHlwZS5GTE9BVFxyXG4gICAgICAgICAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLyogZXNsaW50LWVuYWJsZSBAdHlwZXNjcmlwdC1lc2xpbnQvbmFtaW5nLWNvbnZlbnRpb24qL1xyXG4gICAgICAgICAgICAgICAgICAgIG5vZGUuZXh0ZW5zaW9ucyA9IG5vZGUuZXh0ZW5zaW9ucyB8fCB7fTtcclxuICAgICAgICAgICAgICAgICAgICBub2RlLmV4dGVuc2lvbnNbTkFNRV0gPSBleHRlbnNpb247XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmVzb2x2ZShub2RlKTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9idWlsZEFjY2Vzc29yKGJ1ZmZlcjogRmxvYXQzMkFycmF5LCB0eXBlOiBBY2Nlc3NvclR5cGUsIGNvdW50OiBudW1iZXIsIGJpbmFyeVdyaXRlcjogX0JpbmFyeVdyaXRlciwgY29tcG9uZW50VHlwZTogQWNjZXNzb3JDb21wb25lbnRUeXBlKTogbnVtYmVyIHtcclxuICAgICAgICAvLyB3cml0ZSB0aGUgYnVmZmVyXHJcbiAgICAgICAgY29uc3QgYnVmZmVyT2Zmc2V0ID0gYmluYXJ5V3JpdGVyLmdldEJ5dGVPZmZzZXQoKTtcclxuICAgICAgICBzd2l0Y2ggKGNvbXBvbmVudFR5cGUpIHtcclxuICAgICAgICAgICAgY2FzZSBBY2Nlc3NvckNvbXBvbmVudFR5cGUuRkxPQVQ6IHtcclxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpICE9IGJ1ZmZlci5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgIGJpbmFyeVdyaXRlci5zZXRGbG9hdDMyKGJ1ZmZlcltpXSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIEFjY2Vzc29yQ29tcG9uZW50VHlwZS5CWVRFOiB7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSAhPSBidWZmZXIubGVuZ3RoOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICBiaW5hcnlXcml0ZXIuc2V0Qnl0ZShidWZmZXJbaV0gKiAxMjcpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY2FzZSBBY2Nlc3NvckNvbXBvbmVudFR5cGUuU0hPUlQ6IHtcclxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpICE9IGJ1ZmZlci5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgIGJpbmFyeVdyaXRlci5zZXRJbn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aWdodC5MSUdIVFRZUEVJRF9ESVJFQ1RJT05BTExJR0hUXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgPyBLSFJMaWdodHNQdW5jdHVhbF9MaWdodFR5cGUuRElSRUNUSU9OQUxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICA6IGJhYnlsb25Ob2RlLmdldFR5cGVJRCgpID09IExpZ2h0LkxJR0hUVFlQRUlEX1NQT1RMSUdIVFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgPyBLSFJMaWdodHNQdW5jdHVhbF9MaWdodFR5cGUuU1BPVFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBudWxsO1xyXG4gICAgICAgICAgICAgICAgaWYgKGxpZ2h0VHlwZSA9PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgTG9nZ2VyLldhcm4oYCR7Y29udGV4dH06IExpZ2h0ICR7YmFieWxvbk5vZGUubmFtZX0gaXMgbm90IHN1cHBvcnRlZCBpbiAke05BTUV9YCk7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICghYmFieWxvbk5vZGUucG9zaXRpb24uZXF1YWxzVG9GbG9hdHMoMCwgMCwgMCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS50cmFuc2xhdGlvbiA9IGJhYnlsb25Ob2RlLnBvc2l0aW9uLmFzQXJyYXkoKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGxpZ2h0VHlwZSAhPT0gS0hSTGlnaHRzUHVuY3R1YWxfTGlnaHRUeXBlLlBPSU5UKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxvY2FsQXhpcyA9IGJhYnlsb25Ob2RlLmRpcmVjdGlvbjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeWF3ID0gLU1hdGguYXRhbjIobG9jYWxBeGlzLnosIGxvY2FsQXhpcy54KSArIE1hdGguUEkgLyAyO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW4gPSBNYXRoLnNxcnQobG9jYWxBeGlzLnggKiBsb2NhbEF4aXMueCArIGxvY2FsQXhpcy56ICogbG9jYWxBeGlzLnopO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwaXRjaCA9IC1NYXRoLmF0YW4yKGxvY2FsQXhpcy55LCBsZW4pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsaWdodFJvdGF0aW9uUXVhdGVybmlvbiA9IFF1YXRlcm5pb24uUm90YXRpb25ZYXdQaXRjaFJvbGwoeWF3ICsgTWF0aC5QSSwgcGl0Y2gsIDApO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIVF1YXRlcm5pb24uSXNJZGVudGl0eShsaWdodFJvdGF0aW9uUXVhdGVybmlvbikpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUucm90YXRpb24gPSBsaWdodFJvdGF0aW9uUXVhdGVybmlvbi5hc0FycmF5KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChiYWJ5bG9uTm9kZS5mYWxsb2ZmVHlwZSAhPT0gTGlnaHQuRkFMTE9GRl9HTFRGKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIExvZ2dlci5XYXJuKGAke2NvbnRleHR9OiBMaWdodCBmYWxsb2ZmIGZvciAke2JhYnlsb25Ob2RlLm5hbWV9IGRvZXMgbm90IG1hdGNoIHRoZSAke05BTUV9IHNwZWNpZmljYXRpb24hYCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGxpZ2h0ID0ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBsaWdodFR5cGUsXHJcbiAgICAgICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoIWJhYnlsb25Ob2RlLmRpZmZ1c2UuZXF1YWxzKENvbG9yMy5XaGl0ZSgpKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBsaWdodC5jb2xvciA9IGJhYnlsb25Ob2RlLmRpZmZ1c2UuYXNBcnJheSgpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBpZiAoYmFieWxvbk5vZGUuaW50ZW5zaXR5ICE9PSAxLjApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGlnaHQuaW50ZW5zaXR5ID0gYmFieWxvbk5vZGUuaW50ZW5zaXR5O1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBpZiAoYmFieWxvbk5vZGUucmFuZ2UgIT09IE51bWJlci5NQVhfVkFMVUUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGlnaHQucmFuZ2UgPSBiYWJ5bG9uTm9kZS5yYW5nZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChsaWdodFR5cGUgPT09IEtIUkxpZ2h0c1B1bmN0dWFsX0xpZ2h0VHlwZS5TUE9UKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJhYnlsb25TcG90TGlnaHQgPSBiYWJ5bG9uTm9kZSBhcyBTcG90TGlnaHQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYWJ5bG9uU3BvdExpZ2h0LmFuZ2xlICE9PSBNYXRoLlBJIC8gMi4wKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobGlnaHQuc3BvdCA9PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlnaHQuc3BvdCA9IHt9O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlnaHQuc3BvdC5vdXRlckNvbmVBbmdsZSA9IGJhYnlsb25TcG90TGlnaHQuYW5nbGUgLyAyLjA7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJhYnlsb25TcG90TGlnaHQuaW5uZXJBbmdsZSAhPT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxpZ2h0LnNwb3QgPT0gbnVsbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpZ2h0LnNwb3QgPSB7fTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpZ2h0LnNwb3QuaW5uZXJDb25lQW5nbGUgPSBiYWJ5bG9uU3BvdExpZ2h0LmlubmVyQW5nbGUgLyAyLjA7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2xpZ2h0cyB8fD0ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBsaWdodHM6IFtdLFxyXG4gICAgICAgICAgICAgICAgICAgIH07XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2xpZ2h0cy5saWdodHMucHVzaChsaWdodCk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpZ2h0UmVmZXJlbmNlOiBJS0hSTGlnaHRzUHVuY3R1YWxfTGlnaHRSZWZlcmVuY2UgPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpZ2h0OiB0aGlzLl9saWdodHMubGlnaHRzLmxlbmd0aCAtIDEsXHJcbiAgICAgICAgICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy8gQXZvaWQgZHVwbGljYXRpbmcgd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RvUmVmKHBhcmVudFNjYWxlLCBwYXJlbnRSb3RhdGlvbiwgcGFyZW50VHJhbnNsYXRpb24sIFRtcFZlY3RvcnMuTWF0cml4WzBdKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc2xhdGlvbiA9IFZlY3RvcjMuRnJvbUFycmF5VG9SZWYobm9kZS50cmFuc2xhdGlvbiB8fCBbMCwgMCwgMF0sIDAsIFRtcFZlY3RvcnMuVmVjdG9yM1syXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb3RhdGlvbiA9IFF1YXRlcm5pb24uRnJvbUFycmF5VG9SZWYobm9kZS5yb3RhdGlvbiB8fCBbMCwgMCwgMCwgMV0sIDAsIFRtcFZlY3RvcnMuUXVhdGVybmlvblsxXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXRyaXggPSBNYXRyaXguQ29tcG9zZVRvUmVmKFZlY3RvcjMuT25lUmVhZE9ubHksIHJvdGF0aW9uLCB0cmFuc2xhdGlvbiwgVG1wVmVjdG9ycy5NYXRyaXhbMV0pO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudE1hdHJpeC5tdWx0aXBseVRvUmVmKG1hdHJpeCwgbWF0cml4KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hdHJpeC5kZWNvbXBvc2UocGFyZW50U2NhbGUsIHBhcmVudFJvdGF0aW9uLCBwYXJlbnRUcmFuc2xhdGlvbik7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmVudFRyYW5zbGF0aW9uLmVxdWFsc1RvRmxvYXRzKDAsIDAsIDApKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHBhcmVudE5vZGUudHJhbnNsYXRpb247XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudE5vZGUudHJhbnNsYXRpb24gPSBwYXJlbnRUcmFuc2xhdGlvbi5hc0FycmF5KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFF1YXRlcm5pb24uSXNJZGVudGl0eShwYXJlbnRSb3RhdGlvbikpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgcGFyZW50Tm9kZS5yb3RhdGlvbjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50Tm9kZS5yb3RhdGlvbiA9IHBhcmVudFJvdGF0aW9uLmFzQXJyYXkoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyZW50U2NhbGUuZXF1YWxzVG9GbG9hdHMoMSwgMSwgMSkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgcGFyZW50Tm9kZS5zY2FsZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50Tm9kZS5zY2FsZSA9IHBhcmVudFNjYWxlLmFzQXJyYXkoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJlbnROb2RlLmV4dGVuc2lvbnMgfHw9IHt9O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50Tm9kZS5leHRlbnNpb25zW05BTUVdID0gbGlnaHRSZWZlcmVuY2U7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gRG8gbm90IGV4cG9yd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cmVzLnB1c2goYmFieWxvbk1hdGVyaWFsLmNsZWFyQ29hdC5idW1wVGV4dHVyZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gYWRkaXRpb25hbFRleHR1cmVzO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICByZXR1cm4gW107XHJcbiAgICB9XHJcblxyXG4gICAgcHVibGljIHBvc3RFeHBvcnRNYXRlcmlhbEFzeW5jPyhjb250ZXh0OiBzdHJpbmcsIG5vZGU6IElNYXRlcmlhbCwgYmFieWxvbk1hdGVyaWFsOiBNYXRlcmlhbCk6IFByb21pc2U8SU1hdGVyaWFsPiB7XHJcbiAgICAgICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlKSA9PiB7XHJcbiAgICAgICAgICAgIGlmIChiYWJ5bG9uTWF0ZXJpYWwgaW5zdGFuY2VvZiBQQlJCYXNlTWF0ZXJpYWwpIHtcclxuICAgICAgICAgICAgICAgIGlmICghYmFieWxvbk1hdGVyaWFsLmNsZWFyQ29hdC5pc0VuYWJsZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICByZXNvbHZlKG5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICB0aGlzLl93YXNVc2VkID0gdHJ1ZTtcclxuXHJcbiAgICAgICAgICAgICAgICBub2RlLmV4dGVuc2lvbnMgPSBub2RlLmV4dGVuc2lvbnMgfHwge307XHJcblxyXG4gICAgICAgICAgICAgICAgY29uc3QgY2xlYXJDb2F0VGV4dHVyZUluZm8gPSB0aGlzLl9leHBvcnRlci5fZ2xURk1hdGVyaWFsRXhwb3J0ZXIuX2dldFRleHR1cmVJbmZvKGJhYnlsb25NYXRlcmlhbC5jbGVhckNvYXQudGV4dHVyZSk7XHJcbiAgICAgICAgICAgICAgICBsZXQgY2xlYXJDb2F0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cclxuICAgICAgICAgICAgICAgICAgICBpcmlkZXNjZW5jZUZhY3RvcjogYmFieWxvbk1hdGVyaWFsLmlyaWRlc2NlbmNlLmludGVuc2l0eSxcclxuICAgICAgICAgICAgICAgICAgICBpcmlkZXNjZW5jZUlvcjogYmFieWxvbk1hdGVyaWFsLmlyaWRlc2NlbmNlLmluZGV4T2ZSZWZyYWN0aW9uLFxyXG4gICAgICAgICAgICAgICAgICAgIGlyaWRlc2NlbmNlVGhpY2tuZXNzTWluaW11bTogYmFieWxvbk1hdGVyaWFsLmlyaWRlc2NlbmNlLm1pbmltdW1UaGlja25lc3MsXHJcbiAgICAgICAgICAgICAgICAgICAgaXJpZGVzY2VuY2VUaGlja25lc3NNYXhpbXVtOiBiYWJ5bG9uTWF0ZXJpYWwuaXJpZGVzY2VuY2UubWF4aW11bVRoaWNrbmVzcyxcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaXJpZGVzY2VuY2VUZXh0dXJlOiBpcmlkZXNjZW5jZVRleHR1cmVJbmZvID8/IHVuZGVmaW5lZCxcclxuICAgICAgICAgICAgICAgICAgICBpcmlkZXNjZW5jZVRoaWNrbmVzc1RleHR1cmU6IGlyaWRlc2NlbmNlVGhpY2tuZXNzVGV4dHVyZUluZm8gPz8gdW5kZWZpbmVkLFxyXG4gICAgICAgICAgICAgICAgICAgIGhhc1RleHR1cmVzOiAoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpcmlkZXNjZW5jZUluZm8uaXJpZGVzY2VuY2VUZXh0dXJlICE9PSBudWxsIHx8IGlyaWRlc2NlbmNlSW5mby5pcmlkZXNjZW5jZVRoaWNrbmVzc1RleHR1cmUgIT09IG51bGw7XHJcbiAgICAgICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgIH07XHJcblxyXG4gICAgICAgICAgICAgICAgbm9kZS5leHRlbnNpb25zW05BTUVdID0gaXJpZGVzY2VuY2VJbmZvO1xyXG4gICAgICAgICAgICB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hdGVyaWFsLnNoZWVuLnRleHR1cmUpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBbYmFieWxvbk1hdGVyaWFsLnNoZWVuLnRleHR1cmVdO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICByZXR1cm4gW107XHJcbiAgICB9XHJcblxyXG4gICAgcHVibGljIHBvc3RFeHBvcnRNYXRlcmlhbEFzeW5jKGNvbnRleHQ6IHN0cmluZywgbm9kZTogSU1hdGVyaWFsLCBiYWJ5bG9uTWF0ZXJpYWw6IE1hdGVyaWFsKTogUHJvbWlzZTxJTWF0ZXJpYWw+IHtcclxuICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUpID0+IHtcclxuICAgICAgICAgICAgaWYgKGJhYnlsb25NYXRlcmlhbCBpbnN0YW5jZW9mIFBCUk1hdGVyaWFsKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoIWJhYnlsb25NYXRlcmlhbC5zaGVlbi5pc0VuYWJsZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICByZXNvbHZlKG5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICB0aGlzLl93YXNVc2VkID0gdHJ1ZTtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAobm9kZS5leHRlbnNpb25zID09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICBub2RlLmV4dGVuc2lvbnMgPSB7fTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGNvbnN0IHNoZWVuSW5mbzogSUtIUk1hdGVyaWFsc1NoZWVuID0ge1xyXG4gICAgICAgICAgICAgICAgICAgIHNoZWVuQ29sb3JGYWN0b3I6IGJhYnlsb25NYXRlcmlhbC5zaGVlbi5jb2xvci5hc0FycmF5KCksXHJcbiAgICAgICAgICAgICAgICAgICAgc2hlZW5Sb3Vna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4gICAgICAgICAgICAgICAgY29uc3QgYXR0ZW51YXRpb25Db2xvciA9IHN1YnMudGludENvbG9yLmVxdWFsc0Zsb2F0cygxLjAsIDEuMCwgMS4wKSA/IHVuZGVmaW5lZCA6IHN1YnMudGludENvbG9yLmFzQXJyYXkoKTtcclxuXHJcbiAgICAgICAgICAgICAgICBjb25zdCB2b2x1bWVJbmZvOiBJS0hSTWF0ZXJpYWxzVm9sdW1lID0ge1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaWNrbmVzc0ZhY3RvcjogdGhpY2tuZXNzRmFjdG9yLFxyXG4gICAgICAgICAgICAgICAgICAgIHRoaWNrbmVzc1RleHR1cmU6IHRoaWNrbmVzc1RleHR1cmUsXHJcbiAgICAgICAgICAgICAgICAgICAgYXR0ZW51YXRpb25EaXN0YW5jZTogYXR0ZW51YXRpb25EaXN0YW5jZSxcclxuICAgICAgICAgICAgICAgICAgICBhdHRlbnVhdGlvbkNvbG9yOiBhdHRlbnVhdGlvbkNvbG9yLFxyXG4gICAgICAgICAgICAgICAgICAgIGhhc1RleHR1cmVzOiAoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9oYXNUZXh0dXJlc0V4dGVuc2lvbihiYWJ5bG9uTWF0ZXJpYWwpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgbm9kZS5leHRlbnNpb25zID0gbm9kZS5leHRlbnNpb25zIHx8IHt9O1xyXG4gICAgICAgICAgICAgICAgbm9kZS5leHRlbnNpb25zW05BTUVdID0gdm9sdW1lSW5mbztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICByZXNvbHZlKG5vZGUpO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG59XHJcblxyXG5fRXhwb3J0ZXIuUmVnaXN0ZXJFeHRlbnNpb24oTkFNRSwgKGV4cG9ydGVyKSA9PiBuZXcgS0hS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yZGluYXRlc0luZGV4O1xyXG4gICAgICAgICAgICAgICAgdHJhbnNmb3JtSXNSZXF1aXJlZCA9IHRydWU7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmICghdHJhbnNmb3JtSXNSZXF1aXJlZCkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICB0aGlzLl93YXNVc2VkID0gdHJ1ZTtcclxuICAgICAgICAgICAgaWYgKCF0ZXh0dXJlSW5mby5leHRlbnNpb25zKSB7XHJcbiAgICAgICAgICAgICAgICB0ZXh0dXJlSW5mby5leHRlbnNpb25zID0ge307XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgdGV4dHVyZUluZm8uZXh0ZW5zaW9uc1tOQU1FXSA9IHRleHR1cmVUcmFuc2Zvcm07XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIHB1YmxpYyBwcmVFeHBvcnRUZXh0dXJlQXN5bmMoY29udGV4dDogc3RyaW5nLCBiYWJ5bG9uVGV4dHVyZTogVGV4dHVyZSk6IFByb21pc2U8TnVsbGFibGU8VGV4dHVyZT4+IHtcclxuICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xyXG4gICAgICAgICAgICBjb25zdCBzY2VuZSA9IGJhYnlsb25UZXh0dXJlLmdldFNjZW5lKCk7XHJcbiAgICAgICAgICAgIGlmICghc2NlbmUpIHtcclxuICAgICAgICAgICAgICAgIHJlamVjdChgJHtjb250ZXh0fTogXCJzY2VuZVwiIGlzIG5vdCBkZWZpbmVkIGZvciBCYWJ5bG9uIHRleHR1cmUgJHtiYWJ5bG9uVGV4dHVyZS5uYW1lfSFgKTtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgLypcclxuICAgICAgICAgICAgICogVGhlIEtIUl90Z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gICAgICAgIGNvbnN0IGlucHV0czogbnVtYmVyW10gPSBbXTtcclxuICAgICAgICAgICAgY29uc3Qgb3V0cHV0czogbnVtYmVyW11bXSA9IFtdO1xyXG4gICAgICAgICAgICBjb25zdCBrZXlGcmFtZXMgPSBhbmltYXRpb24uZ2V0S2V5cygpO1xyXG4gICAgICAgICAgICBjb25zdCBtaW5NYXhLZXlGcmFtZXMgPSBfR0xURkFuaW1hdGlvbi5fQ2FsY3VsYXRlTWluTWF4S2V5RnJhbWVzKGtleUZyYW1lcyk7XHJcbiAgICAgICAgICAgIGNvbnN0IGludGVycG9sYXRpb25PckJha2UgPSBfR0xURkFuaW1hdGlvbi5fRGVkdWNlSW50ZXJwb2xhdGlvbihrZXlGcmFtZXMsIGFuaW1hdGlvbkNoYW5uZWxUYXJnZXRQYXRoLCB1c2VRdWF0ZXJuaW9uKTtcclxuXHJcbiAgICAgICAgICAgIGNvbnN0IGludGVycG9sYXRpb24gPSBpbnRlcnBvbGF0aW9uT3JCYWtlLmludGVycG9sYXRpb25UeXBlO1xyXG4gICAgICAgICAgICBjb25zdCBzaG91bGRCYWtlQW5pbWF0aW9uID0gaW50ZXJwb2xhdGlvbk9yQmFrZS5zaG91bGRCYWtlQW5pbWF0aW9uO1xyXG5cclxuICAgICAgICAgICAgaWYgKHNob3VsZEJha2VBbmltYXRpb24pIHtcclxuICAgICAgICAgICAgICAgIF9HTFRGQW5pbWF0aW9uLl9DcmVhdGVCYWtlZEFuaW1hdGlvbihcclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uVHJhbnNmb3JtTm9kZSxcclxuICAgICAgICAgICAgICAgICAgICBhbmltYXRpb24sXHJcbiAgICAgICAgICAgICAgICAgICAgYW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGgsXHJcbiAgICAgICAgICAgICAgICAgICAgbWluTWF4S2V5RnJhbWVzLm1pbixcclxuICAgICAgICAgICAgICAgICAgICBtaW5NYXhLZXlGcmFtZXMubWF4LFxyXG4gICAgICAgICAgICAgICAgICAgIGFuaW1hdGlvbi5mcmFtZVBlclNlY29uZCxcclxuICAgICAgICAgICAgICAgICAgICBhbmltYXRpb25TYW1wbGVSYXRlLFxyXG4gICAgICAgICAgICAgICAgICAgIGlucHV0cyxcclxuICAgICAgICAgICAgICAgICAgICBvdXRwdXRzLFxyXG4gICAgICAgICAgICAgICAgICAgIG1pbk1heEtleUZyYW1lcyxcclxuICAgICAgICAgICAgICAgICAgICB1c2VRdWF0ZXJuaW9uXHJcbiAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgaWYgKGludGVycG9sYXRpb24gPT09IEFuaW1hdGlvblNhbXBsZXJJbnRlcnBvbGF0aW9uLkxJTkVBUiB8fCBpbnRlcnBvbGF0aW9uID09PSBBbmltYXRpb25TYW1wbGVySW50ZXJwb2xhdGlvbi5TVEVQKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgX0dMVEZBbmltYXRpb24uX0NyZWF0ZUxpbmVhck9yU3RlcEFuaW1hdGlvbihiYWJ5bG9uVHJhbnNmb3JtTm9kZSwgYW5pbWF0aW9uLCBhbmltYXRpb25DaGFubmVsVGFyZ2V0UGF0aCwgaW5wdXRzLCBvdXRwdXRzLCB1c2VRdWF0ZXJuaW9uKTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaW50ZXJwb2xhdGlvbiA9PT0gQW5pbWF0aW9uU2FtcGxlckludGVycG9sYXRpb24uQ1VCSUNTUExJTkUpIHtcclxuICAgICAgICAgICAgICAgICAgICBfR0xURkFuaW1hdGlvbi5fQ3JlYXRlQ3ViaWNTcGxpbmVBbmltYXRpb24oYmFieWxvblRyYW5zZm9ybU5vZGUsIGFuaW1hdGlvbiwgYW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGgsIGlucHV0cywgb3V0cHV0cywgdXNlUXVhdGVybmlvbik7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIF9HTFRGQW5pbWF0aW9uLl9DcmVhdGVCYWtlZEFuaW1hdGlvbihcclxuICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvblRyYW5zZm9ybU5vZGUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFuaW1hdGlvbixcclxuICAgICAgICAgICAgICAgICAgICAgICAgYW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGgsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heEtleUZyYW1lcy5taW4sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heEtleUZyYW1lcy5tYXgsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFuaW1hdGlvbi5mcmFtZVBlclNlY29uZCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgYW5pbWF0aW9uU2FtcGxlUmF0ZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXRzLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRzLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhLZXlGcmFtZXMsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHVzZVF1YXRlcm5pb25cclxuICAgICAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAoaW5wdXRzLmxlbmd0aCAmJiBvdXRwdXRzLmxlbmd0aCkge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgcmVzdWx0OiBfSUFuaW1hdGlvbkRhdGEgPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaW5wdXRzOiBpbnB1dHMsXHJcbiAgICAgICAgICAgICAgICAgICAgb3V0cHV0czogb3V0cHV0cyxcclxuICAgICAgICAgICAgICAgICAgICBzYW1wbGVySW50ZXJwb2xhdGlvbjogaW50ZXJwb2xhdGlvbixcclxuICAgICAgICAgICAgICAgICAgICB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W1hdGlvbkNoYW5uZWxUYXJnZXRQYXRoID0gQW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGguU0NBTEU7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIFwicG9zaXRpb25cIjoge1xyXG4gICAgICAgICAgICAgICAgYW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGggPSBBbmltYXRpb25DaGFubmVsVGFyZ2V0UGF0aC5UUkFOU0xBVElPTjtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgXCJyb3RhdGlvblwiOiB7XHJcbiAgICAgICAgICAgICAgICBkYXRhQWNjZXNzb3JUeXBlID0gQWNjZXNzb3JUeXBlLlZFQzQ7XHJcbiAgICAgICAgICAgICAgICBhbmltYXRpb25DaGFubmVsVGFyZ2V0UGF0aCA9IEFuaW1hdGlvbkNoYW5uZWxUYXJnZXRQYXRoLlJPVEFUSU9OO1xyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY2FzZSBcInJvdGF0aW9uUXVhdGVybmlvblwiOiB7XHJcbiAgICAgICAgICAgICAgICBkYXRhQWNjZXNzb3JUeXBlID0gQWNjZXNzb3JUeXBlLlZFQzQ7XHJcbiAgICAgICAgICAgICAgICB1c2VRdWF0ZXJuaW9uID0gdHJ1ZTtcclxuICAgICAgICAgICAgICAgIGFuaW1hdGlvbkNoYW5uZWxUYXJnZXRQYXRoID0gQW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGguUk9UQVRJT047XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIFwiaW5mbHVlbmNlXCI6IHtcclxuICAgICAgICAgICAgICAgIGRhdGFBY2Nlc3NvclR5cGUgPSBBY2Nlc3NvclR5cGUuU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zKSB7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGFuaW1hdGlvbiBvZiBiYWJ5bG9uTm9kZS5hbmltYXRpb25zKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNob3VsZEV4cG9ydEFuaW1hdGlvbiAmJiAhc2hvdWxkRXhwb3J0QW5pbWF0aW9uKGFuaW1hdGlvbikpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGFuaW1hdGlvbkluZm8gPSBfR0xURkFuaW1hdGlvbi5fRGVkdWNlQW5pbWF0aW9uSW5mbyhhbmltYXRpb24pO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChhbmltYXRpb25JbmZvKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGdsVEZBbmltYXRpb24gPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiBhbmltYXRpb24ubmFtZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhbXBsZXJzOiBbXSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYW5uZWxzOiBbXSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgX0dMVEZBbmltYXRpb24uX0FkZEFuaW1hdGlvbihcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGAke2FuaW1hdGlvbi5uYW1lfWAsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb24uaGFzUnVubmluZ1J1bnRpbWVBbmltYXRpb25zID8gcnVudGltZUdMVEZBbmltYXRpb24gOiBnbFRGQW5pbWF0aW9uLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvbk5vZGUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb24sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb25JbmZvLmRhdGFBY2Nlc3NvclR5cGUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb25JbmZvLmFuaW1hdGlvbkNoYW5uZWxUYXJnZXRQYXRoLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZU1hcCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJpbmFyeVdyaXRlcixcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlclZpZXdzLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYWNjZXNzb3JzLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5pbWF0aW9uSW5mby51c2VRdWF0ZXJuaW9uLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5pbWF0aW9uU2FtcGxlUmF0ZVxyXG4gICAgICAgICAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2xURkFuaW1hdGlvbi5zYW1wbGVycy5sZW5ndGggJiYgZ2xURkFuaW1hdGlvbi5jaGFubmVscy5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkbGVHTFRGQW5pbWF0aW9ucy5wdXNoKGdsVEZBbmltYXRpb24pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQGlnbm9yZVxyXG4gICAgICogQ3JlYXRlIGluZGl2aWR1YWwgbW9ycGggYW5pbWF0aW9ucyBmcm9tIHRoZSBtZXNoJ3MgbW9ycGggdGFyZ2V0IGFuaW1hdGlvbiB0cmFja3NcclxuICAgICAqIEBwYXJhbSBiYWJ5bG9uTm9kZVxyXG4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IE1lc2gpIHtcclxuICAgICAgICAgICAgY29uc3QgbW9ycGhUYXJnZXRNYW5hZ2VyID0gYmFieWxvbk5vZGUubW9ycGhUYXJnZXRNYW5hZ2VyO1xyXG4gICAgICAgICAgICBpZiAobW9ycGhUYXJnZXRNYW5hZ2VyKSB7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG1vcnBoVGFyZ2V0TWFuYWdlci5udW1UYXJnZXRzOyArK2kpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBtb3JwaFRhcmdldCA9IG1vcnBoVGFyZ2V0TWFuYWdlci5nZXRUYXJnZXQoaSk7XHJcbiAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBhbmltYXRpb24gb2YgbW9ycGhUYXJnZXQuYW5pbWF0aW9ucykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2hvdWxkRXhwb3J0QW5pbWF0aW9uICYmICFzaG91bGRFeHBvcnRBbmltYXRpb24oYW5pbWF0aW9uKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29tYmluZWRBbmltYXRpb24gPSBuZXcgQW5pbWF0aW9uKFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYCR7YW5pbWF0aW9uLm5hbWV9YCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwiaW5mbHVlbmNlXCIsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb24uZnJhbWVQZXJTZWNvbmQsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb24uZGF0YVR5cGUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb24ubG9vcE1vZGUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb24uZW5hYmxlQmxlbmRpbmdcclxuICAgICAgICAgICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29tYmluZWRBbmltYXRpb25LZXlzOiBJQW5pbWF0aW9uS2V5W10gPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYW5pbWF0aW9uS2V5cyA9IGFuaW1hdGlvbi5nZXRLZXlzKCk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGFuaW1hdGlvbktleXMubGVuZ3RoOyArK2opIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFuaW1hdGlvbktleSA9IGFuaW1hdGlvbktleXNbal07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IG1vcnBoVGFyZ2V0TWFuYWdlci5udW1UYXJnZXRzOyArK2spIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoayA9PSBpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbWJpbmVkQW5pbWF0aW9uS2V5cy5wdXNoKGFuaW1hdGlvbktleSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tYmluZWRBbmltYXRpb25LZXlzLnB1c2goeyBmcmFtZTogYW5pbWF0aW9uS2V5LmZyYW1lLCB2YWx1ZTogMCB9KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgY29tYmluZWRBbmltYXRpb24uc2V0S2V5cyhjb21iaW5lZEFuaW1hdGlvbktleXMpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhbmltYXRpb25JbmZvID0gX0dMVEZBbmltYXRpb24uX0RlZHVjZUFuaW1hdGlvbkluZm8oY29tYmluZWRBbmltYXRpb24pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoYW5pbWF0aW9uSW5mbykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2xURkFuaW1hdGlvbiA9IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiBjb21iaW5lZEFuaW1hdGlvbi5uYW1lLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhbXBsZXJzOiBbXSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFubmVsczogW10sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgX0dMVEZBbmltYXRpb24uX0FkZEFuaW1hdGlvbihcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb24ubmFtZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb24uaGFzUnVubmluZ1J1bnRpbWVBbmltYXRpb25zID8gcnVudGltZUdMVEZBbmltYXRpb24gOiBnbFRGQW5pbWF0aW9uLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25Ob2RlLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbWJpbmVkQW5pbWF0aW9uLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuaW1hdGlvbkluZm8uZGF0YUFjY2Vzc29yVHlwZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb25JbmZvLmFuaW1hdGlvbkNoYW5uZWxUYXJnZXRQYXRoLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGVNYXAsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmluYXJ5V3JpdGVyLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlclZpZXdzLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjY2Vzc29ycyxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb25JbmZvLnVzZVF1YXRlcm5pb24sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5pbWF0aW9uU2FtcGxlUmF0ZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb3JwaFRhcmdldE1hbmFnZXIubnVtVGFyZ2V0c1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChnbFRGQW5pbWF0aW9uLnNhbXBsZXJzLmxlbmd0aCAmJiBnbFRGQW5pbWF0aW9uLmNoYW5uZWxzLmxlbmd0aCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkbGVHTFRGQW5pbWF0aW9ucy5wdXNoKGdsVEZBbmltYXRpb24pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQGludGVybmFsXHJcbiAgICAgKiBDcmVhdGUgbm9kZSBhbmQgbW9ycGggYW5pbWF0aW9ucyBmcm9tIHRoZSBhbmltYXRpb24gZ3JvdXBzXHJcbiAgICAgKiBAcGFyYW0gYmFieWxvblNjZW5lXHJcbiAgICAgKiBAcGFyYW0gZ2xURkFuaW1hdGlvbnNcclxuICAgICAqIEBwYXJhbSBub2RlTWFwXHJcbiAgICAgKiBAcGFyYW0gbm9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WFwPE1vcnBoVGFyZ2V0LCBBbmltYXRpb24+PiA9IG5ldyBNYXAoKTtcclxuICAgICAgICAgICAgICAgIGNvbnN0IHNhbXBsZUFuaW1hdGlvbnM6IE1hcDxNZXNoLCBBbmltYXRpb24+ID0gbmV3IE1hcCgpO1xyXG4gICAgICAgICAgICAgICAgY29uc3QgbW9ycGhBbmltYXRpb25NZXNoZXM6IFNldDxNZXNoPiA9IG5ldyBTZXQoKTtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGFuaW1hdGlvbkdyb3VwRnJhbWVEaWZmID0gYW5pbWF0aW9uR3JvdXAudG8gLSBhbmltYXRpb25Hcm91cC5mcm9tO1xyXG4gICAgICAgICAgICAgICAgZ2xURkFuaW1hdGlvbiA9IHtcclxuICAgICAgICAgICAgICAgICAgICBuYW1lOiBhbmltYXRpb25Hcm91cC5uYW1lLFxyXG4gICAgICAgICAgICAgICAgICAgIGNoYW5uZWxzOiBbXSxcclxuICAgICAgICAgICAgICAgICAgICBzYW1wbGVyczogW10sXHJcbiAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhbmltYXRpb25Hcm91cC50YXJnZXRlZEFuaW1hdGlvbnMubGVuZ3RoOyArK2kpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCB0YXJnZXRBbmltYXRpb24gPSBhbmltYXRpb25Hcm91cC50YXJnZXRlZEFuaW1hdGlvbnNbaV07XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdGFyZ2V0ID0gdGFyZ2V0QW5pbWF0aW9uLnRhcmdldDtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBhbmltYXRpb24gPSB0YXJnZXRBbmltYXRpb24uYW5pbWF0aW9uO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzaG91bGRFeHBvcnRBbmltYXRpb24gJiYgIXNob3VsZEV4cG9ydEFuaW1hdGlvbihhbmltYXRpb24pKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fSXNUcmFuc2Zvcm1hYmxlKHRhcmdldCkgfHwgKHRhcmdldC5sZW5ndGggPT09IDEgJiYgdGhpcy5fSXNUcmFuc2Zvcm1hYmxlKHRhcmdldFswXSkpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFuaW1hdGlvbkluZm8gPSBfR0xURkFuaW1hdGlvbi5fRGVkdWNlQW5pbWF0aW9uSW5mbyh0YXJnZXRBbmltYXRpb24uYW5pbWF0aW9uKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFuaW1hdGlvbkluZm8pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJhYnlsb25UcmFuc2Zvcm1Ob2RlID0gdGhpcy5fSXNUcmFuc2Zvcm1hYmxlKHRhcmdldCkgPyB0YXJnZXQgOiB0aGlzLl9Jc1RyYW5zZm9ybWFibGUodGFyZ2V0WzBdKSA/IHRhcmdldFswXSA6IG51bGw7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmFieWxvblRyYW5zZm9ybU5vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfR0xURkFuaW1hdGlvbi5fQWRkQW5pbWF0aW9uKFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgJHthbmltYXRpb24ubmFtZX1gLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnbFRGQW5pbWF0aW9uLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uVHJhbnNmb3JtTm9kZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5pbWF0aW9uLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb25JbmZvLmRhdGFBY2Nlc3NvclR5cGUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuaW1hdGlvbkluZm8uYW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGgsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGVNYXAsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJpbmFyeVdyaXRlcixcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyVmlld3MsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjY2Vzc29ycyxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5pbWF0aW9uSW5mby51c2VRdWF0ZXJuaW9uLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb25TYW1wbGVSYXRlXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGFyZ2V0IGluc3RhbmNlb2YgTW9ycGhUYXJnZXQgfHwgKHRhcmdldC5sZW5ndGggPT09IDEgJiYgdGFyZ2V0WzBdIGluc3RhbmNlb2YgTW9ycGhUYXJnZXQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFuaW1hdGlvbkluZm8gPSBfR0xURkFuaW1hdGlvbi5fRGVkdWNlQW5pbWF0aW9uSW5mbyh0YXJnZXRBbmltYXRpb24uYW5pbWF0aW9uKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFuaW1hdGlvbkluZm8pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJhYnlsb25Nb3JwaFRhcmdldCA9IHRhcmdldCBpbnN0YW5jZW9mIE1vcnBoVGFyZ2V0ID8gKHRhcmdldCBhcyBNb3JwaFRhcmdldCkgOiAodGFyZ2V0WzBdIGFzIE1vcnBoVGFyZ2V0KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYWJ5bG9uTW9ycGhUYXJnZXQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiYWJ5bG9uTW9ycGhUYXJnZXRNYW5hZ2VyID0gYmFieWxvblNjZW5lLm1vcnBoVGFyZ2V0TWFuYWdlcnMuZmluZCgobW9ycGhUYXJnZXRNYW5hZ2VyKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgbW9ycGhUYXJnZXRNYW5hZ2VyLm51bVRhcmdldHM7ICsraikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1vcnBoVGFyZ2V0TWFuYWdlci5nZXRUYXJnZXQoaikgPT09IGJhYnlsb25Nb3JwaFRhcmdldCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmFieWxvbk1vcnBoVGFyZ2V0TWFuYWdlcikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiYWJ5bG9uTWVzaCA9IGJhYnlsb25TY2VuZS5tZXNoZXMuZmluZCgobWVzaCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChtZXNoIGFzIE1lc2gpLm1vcnBoVGFyZ2V0TWFuYWdlciA9PT0gYmFieWxvbk1vcnBoVGFyZ2V0TWFuYWdlcjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkgYXMgTWVzaDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJhYnlsb25NZXNoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW1vcnBoQW5pbWF0aW9ucy5oYXMoYmFieWxvbk1lc2gpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9ycGhBbmltYXRpb25zLnNldChiYWJ5bG9uTWVzaCwgbmV3IE1hcCgpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vcnBoQW5pbWF0aW9ucy5nZXQoYmFieWxvbk1lc2gpPy5zZXQoYmFieWxvbk1vcnBoVGFyZ2V0LCBhbmltYXRpb24pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9ycGhBbmltYXRpb25NZXNoZXMuYWRkKGJhYnlsb25NZXNoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhbXBsZUFuaW1hdGlvbnMuc2V0KGJhYnlsb25NZXNoLCBhbmltYXRpb24pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gdGhpcyBpcyB0aGUgcGxhY2UgZm9yIHRoZSBLSFJfYW5pbWF0aW9uX3BvaW50ZXIuXHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgbW9ycGhBbmltYXRpb25NZXNoZXMuZm9yRWFjaCgobWVzaCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IG1vcnBoVGFyZ2V0TWFuYWdlciA9IG1lc2gubW9ycGhUYXJnZXRNYW5hZ2VyITtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgY29tYmluZWRBbmltYXRpb25Hcm91cDogTnVsbGFibGU8QW5pbWF0aW9uPiA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgYW5pbWF0aW9uS2V5czogSUFuaW1hdGlvbktleVtdID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2FtcGxlQW5pbWF0aW9uID0gc2FtcGxlQW5pbWF0aW9ucy5nZXQobWVzaCkhO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHNhbXBsZUFuaW1hdGlvbktleXMgPSBzYW1wbGVBbmltYXRpb24uZ2V0S2V5cygpO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IG51bUFuaW1hdGlvbktleXMgPSBzYW1wbGVBbmltYXRpb25LZXlzLmxlbmd0aDtcclxuICAgICAgICAgICAgICAgICAgICAvKlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBEdWUgdG8gaG93IGdsVEYgZXhwZWN0cyBtb3JwaCB0YXJnZXQgYW5pbWF0aW9uIGRhdGEgdG8gYmUgZm9ybWF0dGVkLCB3ZSBuZWVkIHRvIHJlYXJyYW5nZSB0aGUgaW5kaXZpZHVhbCBtb3JwaCB0YXJnZXQgYW5pbWF0aW9uIHRyYWNrcyxcclxuICAgICAgICAgICAgICAgICAgICAgICAgc3VjaCB0aG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5pbWF0aW9uS2V5czsgKytpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgbW9ycGhUYXJnZXRNYW5hZ2VyLm51bVRhcmdldHM7ICsraikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbW9ycGhUYXJnZXQgPSBtb3JwaFRhcmdldE1hbmFnZXIuZ2V0VGFyZ2V0KGopO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYW5pbWF0aW9uc0J5TW9ycGhUYXJnZXQgPSBtb3JwaEFuaW1hdGlvbnMuZ2V0KG1lc2gpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFuaW1hdGlvbnNCeU1vcnBoVGFyZ2V0KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbW9ycGhUYXJnZXRBbmltYXRpb24gPSBhbmltYXRpb25zQnlNb3JwaFRhcmdldC5nZXQobW9ycGhUYXJnZXQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtb3JwaFRhcmdldEFuaW1hdGlvbikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNvbWJpbmVkQW5pbWF0aW9uR3JvdXApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbWJpbmVkQW5pbWF0aW9uR3JvdXAgPSBuZXcgQW5pbWF0aW9uKFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGAke2FuaW1hdGlvbkdyb3VwLm5hbWV9XyR7bWVzaC5uYW1lfV9Nb3JwaFdlaWdodEFuaW1hdGlvbmAsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXCJpbmZsdWVuY2VcIixcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb3JwaFRhcmdldEFuaW1hdGlvbi5mcmFtZVBlclNlY29uZCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbmltYXRpb24uQU5JTUFUSU9OVFlQRV9GTE9BVCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb3JwaFRhcmdldEFuaW1hdGlvbi5sb29wTW9kZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb3JwaFRhcmdldEFuaW1hdGlvbi5lbmFibGVCbGVuZGluZ1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb25LZXlzLnB1c2gobW9ycGhUYXJnZXRBbmltYXRpb24uZ2V0S2V5cygpW2ldKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb25LZXlzLnB1c2goe1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJhbWU6IGFuaW1hdGlvbkdyb3VwLmZyb20gKyAoYW5pbWF0aW9uR3JvdXBGcmFtZURpZmYgLyBudW1BbmltYXRpb25LZXlzKSAqIGksXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbW9ycGhUYXJnZXQuaW5mbHVlbmNlLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5UYW5nZW50OiBzYW1wbGVBbmltYXRpb25LZXlzWzBdLmluVGFuZ2VudCA/IDAgOiB1bmRlZmluZWQsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRUYW5nZW50OiBzYW1wbGVBbmltYXRpb25LZXlzWzBdLm91dFRhbmdlbnQgPyAwIDogdW5kZWZpbmVkLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgY29tYmluZWRBbmltYXRpb25Hcm91cCEuc2V0S2V5cyhhbmltYXRpb25LZXlzKTtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBhbmltYXRpb25JbmZvID0gX0dMVEZBbmltYXRpb24uX0RlZHVjZUFuaW1hdGlvbkluZm8oY29tYmluZWRBbmltYXRpb25Hcm91cCEpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChhbmltYXRpb25JbmZvKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIF9HTFRGQW5pbWF0aW9uLl9BZGRBbmltYXRpb24oXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBgJHthbmltYXRpb25Hcm91cC5uYW1lfV8ke21lc2gubmFtZX1fTW9ycGhXZWlnaHRBbmltYXRpb25gLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2xURkFuaW1hdGlvbixcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc2gsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21iaW5lZEFuaW1hdGlvbkdyb3VwISxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuaW1hdGlvbkluZm8uZGF0YUFjY2Vzc29yVHlwZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuaW1hdGlvbkluZm8uYW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGgsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlTWFwLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYmluYXJ5V3JpdGVyLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyVmlld3MsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY2Nlc3NvcnMsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb25JbmZvLnVzZVF1YXRlcm5pb24sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb25TYW1wbGVSYXRlLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9ycGhUYXJnZXRNYW5hZ2VyPy5udW1UYXJnZXRzXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICBpZiAoZ2xURkFuaW1hdGlvbi5jaGFubmVscy5sZW5ndGggJiYgZ2xURkFuaW1hdGlvbi5zYW1wbGVycy5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICAgICBnbFRGQW5pbWF0aW9ucy5wdXNoKGdsVEZBbmltYXRpb24pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgc3RhdGljIF9BZGRBbmltYXRpb24oXHJcbiAgICAgICAgbmFtZTogc3RyaW5nLFxyXG4gICAgICAgIGdsVEZBbmltYXRpb246IElBbmltYXRpb24sXHJcbiAgICAgICAgYmFieWxvblRyYW5zZm9ybU5vZGU6IE5vZGUsXHJcbiAgICAgICAgYW5pbWF0aW9uOiBBbmltYXRpb24sXHJcbiAgICAgICAgZGF0YUFjY2Vzc29yVHlwZTogQWNjZXNzb3JUeXBlLFxyXG4gICAgICAgIGFuaW1hdGlvbkNoYW5uZWxUYXJnZXRQYXRoOiBBbmltYXRpb25DaGFubmVsVGFyZ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uICAgICAgICAgICAgICogTm93IHRoYXQgd2UgaGF2ZSB0aGUgZ2xURiBjb252ZXJ0ZWQgbW9ycGggdGFyZ2V0IGFuaW1hdGlvbiBkYXRhLFxyXG4gICAgICAgICAgICAgKiB3ZSBjYW4gcmVtb3ZlIHJlZHVuZGFudCBpbnB1dCBkYXRhIHNvIHRoYXQgd2UgaGF2ZSBuIGlucHV0IGZyYW1lcyxcclxuICAgICAgICAgICAgICogYW5kIG1vcnBoQW5pbWF0aW9uQ2hhbm5lbHMgKiBuIG91dHB1dCBmcmFtZXNcclxuICAgICAgICAgICAgICovXHJcbiAgICAgICAgICAgIGlmIChtb3JwaEFuaW1hdGlvbkNoYW5uZWxzKSB7XHJcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSAwO1xyXG4gICAgICAgICAgICAgICAgbGV0IGN1cnJlbnRJbnB1dDogbnVtYmVyID0gMDtcclxuICAgICAgICAgICAgICAgIGNvbnN0IG5ld0lucHV0czogbnVtYmVyW10gPSBbXTtcclxuICAgICAgICAgICAgICAgIHdoaWxlIChhbmltYXRpb25EYXRhLmlucHV0cy5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudElucHV0ID0gYW5pbWF0aW9uRGF0YS5pbnB1dHMuc2hpZnQoKSE7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4ICUgbW9ycGhBbmltYXRpb25DaGFubmVscyA9PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5ld0lucHV0cy5wdXNoKGN1cnJlbnRJbnB1dCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGluZGV4Kys7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBhbmltYXRpb25EYXRhLmlucHV0cyA9IG5ld0lucHV0cztcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgY29uc3Qgbm9kZUluZGV4ID0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ubWluXHJcbiAgICAgKiBAcGFyYW0gbWluTWF4RnJhbWVzLm1heFxyXG4gICAgICogQHBhcmFtIHVzZVF1YXRlcm5pb24gc3BlY2lmaWVzIGlmIHF1YXRlcm5pb25zIHNob3VsZCBiZSB1c2VkXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgc3RhdGljIF9DcmVhdGVCYWtlZEFuaW1hdGlvbihcclxuICAgICAgICBiYWJ5bG9uVHJhbnNmb3JtTm9kZTogTm9kZSxcclxuICAgICAgICBhbmltYXRpb246IEFuaW1hdGlvbixcclxuICAgICAgICBhbmltYXRpb25DaGFubmVsVGFyZ2V0UGF0aDogQW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGgsXHJcbiAgICAgICAgbWluRnJhbWU6IG51bWJlcixcclxuICAgICAgICBtYXhGcmFtZTogbnVtYmVyLFxyXG4gICAgICAgIGZwczogbnVtYmVyLFxyXG4gICAgICAgIHNhbXBsZVJhdGU6IG51bWJlcixcclxuICAgICAgICBpbnB1dHM6IG51bWJlcltdLFxyXG4gICAgICAgIG91dHB1dHM6IG51bWJlcltdW10sXHJcbiAgICAgICAgbWluTWF4RnJhbWVzOiB7IG1pbjogbnVtYmVyOyBtYXg6IG51bWJlciB9LFxyXG4gICAgICAgIHVzZVF1YXRlcm5pb246IGJvb2xlYW5cclxuICAgICkge1xyXG4gICAgICAgIGxldCB2YWx1ZTogbnVtYmVyIHwgVmVjdG9yMyB8IFF1YXRlcm5pb247XHJcbiAgICAgICAgY29uc3QgcXVhdGVybmlvbkNhY2hlOiBRdWF0ZXJuaW9uID0gUXVhdGVybmlvbi5JZGVudGl0eSgpO1xyXG4gICAgICAgIGxldCBwcmV2aW91c1RpbWU6IE51bGxhYmxlPG51bWJlcj4gPSBudWxsO1xyXG4gICAgICAgIGxldCB0aW1lOiBudW1iZXI7XHJcbiAgICAgICAgbGV0IG1heFVzZWRGcmFtZTogTnVsbGFibGU8bnVtYmVyPiA9IG51bGw7XHJcbiAgICAgICAgb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gICAgICAgICAgICAgIGVuZEZyYW1lID0gY3VycktleUZyYW1lLmZyYW1lO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZW5kRnJhbWUgPSBuZXh0S2V5RnJhbWUuZnJhbWU7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAvLyBhdCB0aGUgbGFzdCBrZXkgZnJhbWVcclxuICAgICAgICAgICAgICAgIHByZXZLZXlGcmFtZSA9IGtleUZyYW1lc1tpIC0gMV07XHJcbiAgICAgICAgICAgICAgICBpZiAoKGN1cnJLZXlGcmFtZS52YWx1ZS5lcXVhbHMgJiYgY3VycktleUZyYW1lLnZhbHVlLmVxdWFscyhwcmV2S2V5RnJhbWUudmFsdWUpKSB8fCBjdXJyS2V5RnJhbWUudmFsdWUgPT09IHByZXZLZXlGcmFtZS52YWx1ZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBlbmRGcmFtZSA9IG1heEZyYW1lO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChlbmRGcmFtZSkge1xyXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgZiA9IGN1cnJLZXlGcmFtZS5mcmFtZTsgZiA8PSBlbmRGcmFtZTsgZiArPSBzYW1wbGVSYXRlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGltZSA9IFRvb2xzLkZsb2F0Um91bmQoZiAvIGZwcyk7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRpbWUgPT09IHByZXZpb3VzVGltZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgcHJldmlvdXNUaW1lID0gdGltZTtcclxuICAgICAgICAgICAgICAgICAgICBtYXhVc2VkRnJhbWUgPSB0aW1lO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0YXRlID0ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBrZXk6IDAsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlcGVhdENvdW50OiAwLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBsb29wTW9kZTogYW5pbWF0aW9uLmxvb3BNb2RlLFxyXG4gICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBhbmltYXRpb24uX2ludGVycG9sYXRlKGYsIHN0YXRlKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgX0dMVEZBbmltYXRpb24uX1NldEludGVycG9sYXRlZFZhbHVlKGJhYnlsb25UcmFuc2Zvcm1Ob2RlLCB2YWx1ZSwgdGltZSwgYW5pbWF0aW9uLCBhbmltYXRpb25DaGFubmVsVGFyZ2V0UGF0aCwgcXVhdGVybmlvbkNhY2hlLCBpbnB1dHMsIG91dHB1dHMsIHVzZVF1YXRlcm5pb24pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmIChtYXhVc2VkRnJhbWUpIHtcclxuICAgICAgICAgICAgbWluTWF4RnJhbWVzLm1heCA9IG1heFVzZWRGcmFtZTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBzdGF0aWMgX0NvbnZlcnRGYWN0b3JUb1ZlY3RvcjNPclF1YXRlcm5pb24oXHJcbiAgICAgICAgZmFjdG9yOiBudW1iZXIsXHJcbiAgICAgICAgYmFieWx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jb21wb25lbnROYW1lKSB7XHJcbiAgICAgICAgICAgIGNhc2UgXCJ4XCI6XHJcbiAgICAgICAgICAgIGNhc2UgXCJ5XCI6XHJcbiAgICAgICAgICAgIGNhc2UgXCJ6XCI6IHtcclxuICAgICAgICAgICAgICAgIHZhbHVlW2NvbXBvbmVudE5hbWVdID0gZmFjdG9yO1xyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY2FzZSBcIndcIjoge1xyXG4gICAgICAgICAgICAgICAgKHZhbHVlIGFzIFF1YXRlcm5pb24pLncgPSBmYWN0b3I7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBkZWZhdWx0OiB7XHJcbiAgICAgICAgICAgICAgICBUb29scy5FcnJvcihgZ2xURkFuaW1hdGlvbjogVW5zdXBwb3J0ZWQgY29tcG9uZW50IG5hbWUgXCIke2NvbXBvbmVudE5hbWV9XCIhYCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiB2YWx1ZTtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIHN0YXRpYyBfU2V0SW50ZXJwb2xhdGVkVmFsdWUoXHJcbiAgICAgICAgYmFieWxvblRyYW5zZm9ybU5vZGU6IE5vZGUsXHJcbiAgICAgICAgdmFsdWU6IG51bWJlciB8IFZlY3RvcjMgfCBRdWF0ZXJuaW9uLFxyXG4gICAgICAgIHRpbWU6IG51bWJlcixcclxuICAgICAgICBhbmltYXRpb246IEFuaW1hdGlvbixcclxuICAgICAgICBhbmltYXRpb25DaGFubmVsVGFyZ2V0UGF0aDogQW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGgsXHJcbiAgICAgICAgcXVhdGVybmlvbkNhY2hlOiBRdWF0ZXJuaW9uLFxyXG4gICAgICAgIGlucHV0czogbnVtYmVyW10sXHJcbiAgICAgICAgb3V0cH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bnZlcnRGYWN0b3JUb1ZlY3RvcjNPclF1YXRlcm5pb24oXHJcbiAgICAgICAgICAgICAgICAgICAga2V5RnJhbWUudmFsdWUgYXMgbnVtYmVyLFxyXG4gICAgICAgICAgICAgICAgICAgIGJhYnlsb25UcmFuc2Zvcm1Ob2RlLFxyXG4gICAgICAgICAgICAgICAgICAgIGFuaW1hdGlvbixcclxuICAgICAgICAgICAgICAgICAgICBhbmltYXRpb25DaGFubmVsVGFyZ2V0UGF0aCxcclxuICAgICAgICAgICAgICAgICAgICB1c2VRdWF0ZXJuaW9uXHJcbiAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICAgICAgaWYgKG5ld1Bvc2l0aW9uUm90YXRpb25PclNjYWxlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGFuaW1hdGlvbkNoYW5uZWxUYXJnZXRQYXRoID09PSBBbmltYXRpb25DaGFubmVsVGFyZ2V0UGF0aC5ST1RBVElPTikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3NSb3RTY2FsZSA9IHVzZVF1YXRlcm5pb25cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgID8gKG5ld1Bvc2l0aW9uUm90YXRpb25PclNjYWxlIGFzIFF1YXRlcm5pb24pXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IFF1YXRlcm5pb24uUm90YXRpb25ZYXdQaXRjaFJvbGwobmV3UG9zaXRpb25Sb3RhdGlvbk9yU2NhbGUueSwgbmV3UG9zaXRpb25Sb3RhdGlvbk9yU2NhbGUueCwgbmV3UG9zaXRpb25Sb3RhdGlvbk9yU2NhbGUueikubm9ybWFsaXplKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dHMucHVzaChwb3NSb3RTY2FsZS5hc0FycmF5KCkpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBvdXRwdXRzLnB1c2gobmV3UG9zaXRpb25Sb3Rh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hdGlvbjogYm9vbGVhbiB9IHtcclxuICAgICAgICBsZXQgaW50ZXJwb2xhdGlvblR5cGU6IEFuaW1hdGlvblNhbXBsZXJJbnRlcnBvbGF0aW9uIHwgdW5kZWZpbmVkO1xyXG4gICAgICAgIGxldCBzaG91bGRCYWtlQW5pbWF0aW9uID0gZmFsc2U7XHJcbiAgICAgICAgbGV0IGtleTogSUFuaW1hdGlvbktleTtcclxuXHJcbiAgICAgICAgaWYgKGFuaW1hdGlvbkNoYW5uZWxUYXJnZXRQYXRoID09PSBBbmltYXRpb25DaGFubmVsVGFyZ2V0UGF0aC5ST1RBVElPTiAmJiAhdXNlUXVhdGVybmlvbikge1xyXG4gICAgICAgICAgICByZXR1cm4geyBpbnRlcnBvbGF0aW9uVHlwZTogQW5pbWF0aW9uU2FtcGxlckludGVycG9sYXRpb24uTElORUFSLCBzaG91bGRCYWtlQW5pbWF0aW9uOiB0cnVlIH07XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuZ3RoID0ga2V5RnJhbWVzLmxlbmd0aDsgaSA8IGxlbmd0aDsgKytpKSB7XHJcbiAgICAgICAgICAgIGtleSA9IGtleUZyYW1lc1tpXTtcclxuICAgICAgICAgICAgaWYgKGtleS5pblRhbmdlbnQgfHwga2V5Lm91dFRhbmdlbnQpIHtcclxuICAgICAgICAgICAgICAgIGlmIChpbnRlcnBvbGF0aW9uVHlwZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChpbnRlcnBvbGF0aW9uVHlwZSAhPT0gQW5pbWF0aW9uU2FtcGxlckludGVycG9sYXRpb24uQ1VCSUNTUExJTkUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaW50ZXJwb2xhdGlvblR5cGUgPSBBbmltYXRpb25TYW1wbGVySW50ZXJwb2xhdGlvbi5MSU5FQVI7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNob3VsZEJha2VBbmltYXRpb24gPSB0cnVlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIGludGVycG9sYXRpb25UeXBlID0gQW5pbWF0aW9uU2FtcGxlckludGVycG9sYXRpb24uQ1VCSUNTUExJTkU7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoaW50ZXJwb2xhdGlvblR5cGUpIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGludGVycG9sYXRpb25UeXBlID09PSBBbmltYXRpb25TYW1wbGVySW50ZXJwb2xhdGlvbi5DVUJJQ1NQTElORSB8fFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAoa2V5LmludGVycG9sYXRpb24gJiYga2V5LmludGVycG9sYXRpb24gPT09IEFuaW1hdGlvbktleUludGVycG9sYXRpb24uU1RFUCAmJiBpbnRlcnBvbGF0aW9uVHlwZSAhPT0gQW5pbWF0aW9uU2FtcGxlckludGVycG9sYXRpb24uU1RFUClcclxuICAgICAgICAgICAgICAgICAgICApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaW50ZXJwb2xhdGlvblR5cGUgPSBBbmltYXRpb25TYW1wbGVySW50ZXJwb2xhdGlvbi5MSU5FQVI7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNob3VsZEJha2VBbmltYXRpb24gPSB0cnVlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChrZXkuaW50ZXJwb2xhdGlvbiAmJiBrZXkuaW50ZXJwb2xhdGlvbiA9PT0gQW5pbWF0aW9uS2V5SW50ZXJwb2xhdGlvbi5TV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hbXBsZXJJbnRlcnBvbGF0aW9uLkNVQklDU1BMSU5FKSB7XHJcbiAgICAgICAgICAgIGlmIChhbmltYXRpb25DaGFubmVsVGFyZ2V0UGF0aCA9PT0gQW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGguUk9UQVRJT04pIHtcclxuICAgICAgICAgICAgICAgIGlmICh0YW5nZW50VmFsdWUpIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAodXNlUXVhdGVybmlvbikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0YW5nZW50ID0gKHRhbmdlbnRWYWx1ZSBhcyBRdWF0ZXJuaW9uKS5hc0FycmF5KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXJyYXkgPSB0YW5nZW50VmFsdWUgYXMgVmVjdG9yMztcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGFuZ2VudCA9IFF1YXRlcm5pb24uUm90YXRpb25ZYXdQaXRjaFJvbGwoYXJyYXkueSwgYXJyYXkueCwgYXJyYXkueikuYXNBcnJheSgpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGFuZ2VudCA9IFswLCAwLCAwLCAwXTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSBlbHNlIGlmIChhbmltYXRpb25DaGFubmVsVGFyZ2V0UGF0aCA9PT0gQW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGguV0VJR0hUUykge1xyXG4gICAgICAgICAgICAgICAgaWYgKHRhbmdlbnRWYWx1ZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHRhbmdlbnQgPSBbdGFuZ2VudFZhbHVlIGFzIG51bWJlcl07XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIHRhbmdlbnQgPSBbMF07XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBpZiAodGFuZ2VudFZhbHVlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGFuZ2VudCA9ICh0YW5nZW50VmFsdWUgYXMgVmVjdG9yMykuYXNBcnJheSgpO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICB0YW5nZW50ID0gWzAsIDAsIDBdO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBvdXRwdXRzLnB1c2godGFuZ2VudCk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogR2V0IHRoZSBtaW5pbXVtIGFuZCBtYXhpbXVtIGtleSBmcmFtZXMnIGZyYW1lIHZhbHVlc1xyXG4gICAgICogQHBhcmFtIGtleUZyYW1lcyBhbmltYXRpb24ga2V5IGZyYW1lc1xyXG4gICAgICogQHJldHVybnMgdGhlIG1pbmltdW0gYW5kIG1heGltdW0ga2V5IGZyYW1lIHZhbHVlXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgc3RhdGljIF9DYWxjdWxhdGVNaW5NYXhLZXlGcmFtZXMoa2V5RnJhbWVzOiBJQW5pbWF0aW9uS2V5W10pOiB7IG1pbjogbnVtYmVyOyBtYXg6IG51bWJlciB9IHtcclxuICAgICAgICBsZXQgbWluOiBudW1iZXIgPSBJbmZpbml0eTtcclxuICAgICAgICBsZXQgbWF4OiBudW1iZXIgPSAtSW5maW5pdHk7XHJcbiAgICAgICAga2V5RnJhbWVzLmZvckVhY2goZnVuY3Rpb24gKGtleUZyYW1lKSB7XHJcbiAgICAgICAgICAgIG1pbiA9IE1hdGgubWluKG1pbiwga2V5RnJhbWUuZnJhbWUpO1xyXG4gICAgICAgICAgICBtYXggPSBNYXRoLm1heChtYXgsIGtleUZyY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XMpIHtcclxuICAgICAgICAgICAgY29uc3QgZXh0ZW5zaW9uID0gdGhpcy5fZXh0ZW5zaW9uc1tuYW1lXTtcclxuICAgICAgICAgICAgaWYgKGV4dGVuc2lvbi5lbmFibGVkKSB7XHJcbiAgICAgICAgICAgICAgICBhY3Rpb24oZXh0ZW5zaW9uKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9leHRlbnNpb25zT25FeHBvcnRpbmcoKTogdm9pZCB7XHJcbiAgICAgICAgdGhpcy5fZm9yRWFjaEV4dGVuc2lvbnMoKGV4dGVuc2lvbikgPT4ge1xyXG4gICAgICAgICAgICBpZiAoZXh0ZW5zaW9uLndhc1VzZWQpIHtcclxuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9nbFRGLmV4dGVuc2lvbnNVc2VkID09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9nbFRGLmV4dGVuc2lvbnNVc2VkID0gW107XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2dsVEYuZXh0ZW5zaW9uc1VzZWQuaW5kZXhPZihleHRlbnNpb24ubmFtZSkgPT09IC0xKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZ2xURi5leHRlbnNpb25zVXNlZC5wdXNoKGV4dGVuc2lvbi5uYW1lKTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoZXh0ZW5zaW9uLnJlcXVpcmVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2dsVEYuZXh0ZW5zaW9uc1JlcXVpcmVkID09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZ2xURi5leHRlbnNpb25zUmVxdWlyZWQgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2dsVEYuZXh0ZW5zaW9uc1JlcXVpcmVkLmluZGV4T2YoZXh0ZW5zaW9uLm5hbWUpID09PSAtMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9nbFRGLmV4dGVuc2lvbnNSZXF1aXJlZC5wdXNoKGV4dGVuc2lvbi5uYW1lKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2dsVEYuZXh0ZW5zaW9ucyA9PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZ2xURi5leHRlbnNpb25zID0ge307XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKGV4dGVuc2lvbi5vbkV4cG9ydGluZykge1xyXG4gICAgICAgICAgICAgICAgICAgIGV4dGVuc2lvbi5vbkV4cG9ydGluZygpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBMb2FkIGdsVEYgc2VyaWFsaXplciBleHRlbnNpb25zXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgX2xvYWRFeHRlbnNpb25zKCk6IHZvaWQge1xyXG4gICAgICAgIGZvciAoY29uc3QgbmFtZSBvZiBfRXhwb3J0ZXIuX0V4dGVuc2lvbk5hbWVzKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IGV4dGVuc2lvbiA9IF9FeHBvcnRlci5fRXh0ZW5zaW9uRmFjdG9yaWVzW25hbWVdKHRoaXMpO1xyXG4gICAgICAgICAgICB0aGlzLl9leHRlbnNpb25zW25hbWVdID0gZXh0ZW5zaW9uO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIENyZWF0ZXMgYSBnbFRGIEV4c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VuZ3RoOyBpID0gaSArIDMpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBpbmRleCA9IGJ5dGVPZmZzZXQgKyBpICogNDtcclxuICAgICAgICAgICAgICAgICAgICAvLyBzd2FwIHRoZSBzZWNvbmQgYW5kIHRoaXJkIGluZGljZXNcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBzZWNvbmRJbmRleCA9IGJpbmFyeVdyaXRlci5nZXRVSW50MzIoaW5kZXggKyA0KTtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCB0aGlyZEluZGV4ID0gYmluYXJ5V3JpdGVyLmdldFVJbnQzMihpbmRleCArIDgpO1xyXG4gICAgICAgICAgICAgICAgICAgIGJpbmFyeVdyaXRlci5zZXRVSW50MzIodGhpcmRJbmRleCwgaW5kZXggKyA0KTtcclxuICAgICAgICAgICAgICAgICAgICBiaW5hcnlXcml0ZXIuc2V0VUludDMyKHNlY29uZEluZGV4LCBpbmRleCArIDgpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY2FzZSBNYXRlcmlhbC5UcmlhbmdsZUZhbkRyYXdNb2RlOiB7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gc3VibWVzaC5pbmRleFN0YXJ0ICsgc3VibWVzaC5pbmRleENvdW50IC0gMSwgc3RhcnQgPSBzdWJtZXNoLmluZGV4U3RhcnQ7IGkgPj0gc3RhcnQ7IC0taSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGJpbmFyeVdyaXRlci5zZXRVSW50MzIoYmFieWxvbkluZGljZXNbaV0sIGJ5dGVPZmZzZXQpO1xyXG4gICAgICAgICAgICAgICAgICAgIGJ5dGVPZmZzZXQgKz0gNDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc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9zaXRpb25LaW5kOlxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgVmVydGV4QnVmZmVyLk5vcm1hbEtpbmQ6IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgeCA9IHN1Ym1lc2gudmVydGljZXNTdGFydDsgeCA8IHN1Ym1lc2gudmVydGljZXNTdGFydCArIHN1Ym1lc2gudmVydGljZXNDb3VudDsgeCA9IHggKyAzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleCA9IHggKiBzdHJpZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAodmVydGV4RGF0YSBhcyBWZWN0b3IzW10pLnB1c2goVmVjdG9yMy5Gcm9tQXJyYXkobWVzaEF0dHJpYnV0ZUFycmF5LCBpbmRleCkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgKHZlcnRleERhdGEgYXMgVmVjdG9yM1tdKS5wdXNoKFZlY3RvcjMuRnJvbUFycmF5KG1lc2hBdHRyaWJ1dGVBcnJheSwgaW5kZXggKyAyICogc3RyaWRlKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAodmVydGV4RGF0YSBhcyBWZWN0b3IzW10pLnB1c2goVmVjdG9yMy5Gcm9tQXJyYXkobWVzaEF0dHJpYnV0ZUFycmF5LCBpbmRleCArIHN0cmlkZSkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBjYXNlIFZlcnRleEJ1ZmZlci5UYW5nZW50S2luZDoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB4ID0gc3VibWVzaC52ZXJ0aWNlc1N0YXJ0OyB4IDwgc3VibWVzaC52ZXJ0aWNlc1N0YXJ0ICsgc3VibWVzaC52ZXJ0aWNlc0NvdW50OyB4ID0geCArIDMpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4ID0geCAqIHN0cmlkZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICh2ZXJ0ZXhEYXRhIGFzIFZlY3RvcjRbXSkucHVzaChWZWN0b3I0LkZyb21BcnJheShtZXNoQXR0cmlidXRlQXJyYXksIGluZGV4KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAodmVydGV4RGF0YSBhcyBWZWN0b3I0W10pLnB1c2goVmVjdG9yNC5Gcm9tQXJyYXkobWVzaEF0dHJpYnV0ZUFycmF5LCBpbmRleCArIDIgKiBzdHJpZGUpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICh2ZXJ0ZXhEYXRhIGFzIFZlY3RvcjRbXSkucHVzaChWZWN0b3I0LkZyb21BcnJheShtZXNoQXR0cmlidXRlQXJyYXksIGluZGV4ICsgc3RyaWRlKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgVmVydGV4QnVmZmVyLkNvbG9yS2luZDoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzaXplID0gdmVydGV4QnVmZmVyLmdldFNpemUoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgeCA9IHN1Ym1lc2gudmVydGljZXNTdGFydDsgeCA8IHN1Ym1lc2gudmVydGljZXNTdGFydCArIHN1Ym1lc2gudmVydGljZXNDb3VudDsgeCA9IHggKyBzaXplKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleCA9IHggKiBzdHJpZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2l6ZSA9PT0gNCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICh2ZXJ0ZXhEYXRhIGFzIFZlY3RvcjRbXSkucHVzaChWZWN0b3I0LkZyb21BcnJheShtZXNoQXR0cmlidXRlQXJyYXksIGluZGV4KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHZlcnRleERhdGEgYXMgVmVjdG9yNFtdKS5wdXNoKFZlY3RvcjQuRnJvbUFycmF5KG1lc2hBdHRyaWJ1dGVBcnJheSwgaW5kZXggKyAyICogc3RyaWRlKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHZlcnRleERhdGEgYXMgVmVjdG9yNFtdKS5wdXNoKFZlY3RvcjQuRnJvbUFycmF5KG1lc2hBdHRyaWJ1dGVBcnJheSwgaW5kZXggKyBzdHJpZGUpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHZlcnRleERhdGEgYXMgVmVjdG9yM1tdKS5wdXNoKFZlY3RvcjMuRnJvbUFycmF5KG1lc2hBdHRyaWJ1dGVBcnJheSwgaW5kZXgpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAodmVydGV4RGF0YSBhcyBWZWN0b3IzW10pLnB1c2goVmVjdG9yMy5Gcm9tQXJyYXkobWVzaEF0dHJpYnV0ZUFycmF5LCBpbmRleCArIDIgKiBzdHJpZGUpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAodmVydGV4RGF0YSBhcyBWZWN0b3IzW10pLnB1c2goVmVjdG9yMy5Gcm9tQXJyYXkobWVzaEF0dHJpYnV0ZUFycmF5LCBpbmRleCArIHN0cmlkZSkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBjYXNlIFZlcnRleEJ1ZmZlci5VVktpbmQ6XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSBWZXJ0ZXhCdWZmZXIuVVYyS2luZDoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB4ID0gc3VibWVzaC52ZXJ0aWNlc1N0YXJ0OyB4IDwgc3VibWVzaC52ZXJ0aWNlc1N0YXJ0ICsgc3VibWVzaC52ZXJ0aWNlc0NvdW50OyB4ID0geCArIDMpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4ID0geCAqIHN0cmlkZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICh2ZXJ0ZXhEYXRhIGFzIFZlY3RvcjJbXSkucHVzaChWZWN0b3IyLkZyb21BcnJheShtZXNoQXR0cmlidXRlQXJyYXksIGluZGV4KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAodmVydGV4RGF0YSBhcyBWZWN0b3IyW10pLnB1c2goVmVjdG9yMi5Gcm9tQXJyYXkobWVzaEF0dHJpYnV0ZUFycmF5LCBpbmRleCArIDIgKiBzdHJpZGUpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICh2ZXJ0ZXhEYXRhIGFzIFZlY3RvcjJbXSkucHVzaChWZWN0b3IyLkZyb21BcnJheShtZXNoQXR0cmlidXRlQXJyYXksIGluZGV4ICsgc3RyaWRlKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgVG9vbHMuRXJyb3IoYFVuc3VwcG9ydGVkIFZlcnRleCBCdWZmZXIgdHlwZTogJHt2ZXJ0ZXhCdWZmZXJLaW5kfWApO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1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TtcclxuICAgICAgICAgICAgICAgICAgICAodmVydGV4RGF0YSBhcyBWZWN0b3IzW10pLnB1c2goVmVjdG9yMy5Gcm9tQXJyYXkobWVzaEF0dHJpYnV0ZUFycmF5LCBpbmRleCArIHN0cmlkZSkpO1xyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgY2FzZSBWZXJ0ZXhCdWZmZXIuVGFuZ2VudEtpbmQ6IHtcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB4ID0gc3VibWVzaC52ZXJ0aWNlc1N0YXJ0ICsgc3VibWVzaC52ZXJ0aWNlc0NvdW50IC0gMTsgeCA+PSBzdWJtZXNoLnZlcnRpY2VzU3RhcnQ7IC0teCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpbmRleCA9IHggKiBzdHJpZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICh2ZXJ0ZXhEYXRhIGFzIFZlY3RvcjRbXSkucHVzaChWZWN0b3I0LkZyb21BcnJheShtZXNoQXR0cmlidXRlQXJyYXksIGluZGV4KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgY2FzZSBWZXJ0ZXhCdWZmZXIuQ29sb3JLaW5kOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgeCA9IHN1Ym1lc2gudmVydGljZXNTdGFydCArIHN1Ym1lc2gudmVydGljZXNDb3VudCAtIDE7IHggPj0gc3VibWVzaC52ZXJ0aWNlc1N0YXJ0OyAtLXgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXggPSB4ICogc3RyaWRlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB2ZXJ0ZXhCdWZmZXIuZ2V0U2l6ZSgpID09PSA0XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICA/ICh2ZXJ0ZXhEYXRhIGFzIFZlY3RvcjRbXSkucHVzaChWZWN0b3I0LkZyb21BcnJheShtZXNoQXR0cmlidXRlQXJyYXksIGluZGV4KSlcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogKHZlcnRleERhdGEgYXMgVmVjdG9yM1tdKS5wdXNoKFZlY3RvcjMuRnJvbUFycmF5KG1lc2hBdHRyaWJ1dGVBcnJheSwgaW5kZXgpKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBjYXNlIFZlcnRleEJ1ZmZlci5VVktpbmQ6XHJcbiAgICAgICAgICAgICAgICBjYXNlIFZlcnRleEJ1ZmZlci5VVjJLaW5kOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgeCA9IHN1Ym1lc2gudmVydGljZXNTdGFydCArIHN1Ym1lc2gudmVydGljZXNDb3VudCAtIDE7IHggPj0gc3VibWVzaC52ZXJ0aWNlc1N0YXJ0OyAtLXgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXggPSB4ICogc3RyaWRlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAodmVydGV4RGF0YSBhcyBWZWN0b3IyW10pLnB1c2goVmVjdG9yMi5Gcm9tQXJyYXkobWVzaEF0dHJpYnV0ZUFycmF5LCBpbmRleCkpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGRlZmF1bHQ6IHtcclxuICAgICAgICAgICAgICAgICAgICBUb29scy5FcnJvcihgVW5zdXBwb3J0ZWQgVmVydGV4IEJ1ZmZlciB0eXBlOiAke3ZlcnRleEJ1ZmZlcktpbmR9YCk7XHJcbiAgICAgICAgICAgICAgICB9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uICAgICAgICAgICAgICAgICAgICAgICAgKHZlcnRleERhdGEgYXMgVmVjdG9yM1tdKS5wdXNoKFZlY3RvcjMuRnJvbUFycmF5KG1lc2hBdHRyaWJ1dGVBcnJheSwgaW5kZXgpKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBjYXNlIFZlcnRleEJ1ZmZlci5UYW5nZW50S2luZDoge1xyXG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IHggPSBzdWJtZXNoLnZlcnRpY2VzU3RhcnQgKyBzdWJtZXNoLnZlcnRpY2VzQ291bnQgLSAxOyB4ID49IHN1Ym1lc2gudmVydGljZXNTdGFydDsgLS14KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4ID0geCAqIHN0cmlkZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgKHZlcnRleERhdGEgYXMgVmVjdG9yNFtdKS5wdXNoKFZlY3RvcjQuRnJvbUFycmF5KG1lc2hBdHRyaWJ1dGVBcnJheSwgaW5kZXgpKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBjYXNlIFZlcnRleEJ1ZmZlci5Db2xvcktpbmQ6IHtcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB4ID0gc3VibWVzaC52ZXJ0aWNlc1N0YXJ0ICsgc3VibWVzaC52ZXJ0aWNlc0NvdW50IC0gMTsgeCA+PSBzdWJtZXNoLnZlcnRpY2VzU3RhcnQ7IC0teCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpbmRleCA9IHggKiBzdHJpZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICh2ZXJ0ZXhEYXRhIGFzIFZlY3RvcjRbXSkucHVzaChWZWN0b3I0LkZyb21BcnJheShtZXNoQXR0cmlidXRlQXJyYXksIGluZGV4KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHZlcnRleEJ1ZmZlci5nZXRTaXplKCkgPT09IDRcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgID8gKHZlcnRleERhdGEgYXMgVmVjdG9yNFtdKS5wdXNoKFZlY3RvcjQuRnJvbUFycmF5KG1lc2hBdHRyaWJ1dGVBcnJheSwgaW5kZXgpKVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgOiAodmVydGV4RGF0YSBhcyBWZWN0b3IzW10pLnB1c2goVmVjdG9yMy5Gcm9tQXJyYXkobWVzaEF0dHJpYnV0ZUFycmF5LCBpbmRleCkpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGNhc2UgVmVydGV4QnVmZmVyLlVWS2luZDpcclxuICAgICAgICAgICAgICAgIGNhc2UgVmVydGV4QnVmZmVyLlVWMktpbmQ6IHtcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB4ID0gc3VibWVzaC52ZXJ0aWNlc1N0YXJ0ICsgc3VibWVzaC52ZXJ0aWNlc0NvdW50IC0gMTsgeCA+PSBzdWJtZXNoLnZlcnRpY2VzU3RhcnQ7IC0teCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpbmRleCA9IHggKiBzdHJpZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICh2ZXJ0ZXhEYXRhIGFzIFZlY3RvcjJbXSkucHVzaChWZWN0b3IyLkZyb21BcnJheShtZXNoQXR0cmlidXRlQXJyYXksIGluZGV4KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgZGVmYXVsdDoge1xy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dHRyaWJ1dGVBcnJheS5sZW5ndGggLyBzdHJpZGU7IGsgPCBsZW5ndGg7ICsraykge1xyXG4gICAgICAgICAgICAgICAgICAgIGluZGV4ID0gayAqIHN0cmlkZTtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCB2ZXJ0ZXhEYXRhID0gVmVjdG9yMy5Gcm9tQXJyYXkobWVzaEF0dHJpYnV0ZUFycmF5LCBpbmRleCk7XHJcbiAgICAgICAgICAgICAgICAgICAgdmVydGV4QXR0cmlidXRlcy5wdXNoKHZlcnRleERhdGEuYXNBcnJheSgpKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgVmVydGV4QnVmZmVyLk5vcm1hbEtpbmQ6IHtcclxuICAgICAgICAgICAgICAgIGZvciAobGV0IGsgPSAwLCBsZW5ndGggPSBtZXNoQXR0cmlidXRlQXJyYXkubGVuZ3RoIC8gc3RyaWRlOyBrIDwgbGVuZ3RoOyArK2spIHtcclxuICAgICAgICAgICAgICAgICAgICBpbmRleCA9IGsgKiBzdHJpZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdmVydGV4RGF0YSA9IFZlY3RvcjMuRnJvbUFycmF5KG1lc2hBdHRyaWJ1dGVBcnJheSwgaW5kZXgpO1xyXG4gICAgICAgICAgICAgICAgICAgIHZlcnRleEF0dHJpYnV0ZXMucHVzaCh2ZXJ0ZXhEYXRhLm5vcm1hbGl6ZSgpLmFzQXJyYXkoKSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIFZlcnRleEJ1ZmZlci5UYW5nZW50S2luZDoge1xyXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgayA9IDAsIGxlbmd0aCA9IG1lc2hBdHRyaWJ1dGVBcnJheS5sZW5ndGggLy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b3IgKGxldCBrID0gMCwgbGVuZ3RoID0gbWVzaEF0dHJpYnV0ZUFycmF5Lmxlbmd0aCAvIHN0cmlkZTsgayA8IGxlbmd0aDsgKytrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaW5kZXggPSBrICogc3RyaWRlO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzdHJpZGUgPT09IDMpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgQ29sb3IzLkZyb21BcnJheVRvUmVmKG1lc2hBdHRyaWJ1dGVBcnJheSwgaW5kZXgsIHZlcnRleERhdGEgYXMgQ29sb3IzKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbnZlcnRUb0xpbmVhcikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgKHZlcnRleERhdGEgYXMgQ29sb3IzKS50b0xpbmVhclNwYWNlVG9SZWYodmVydGV4RGF0YSBhcyBDb2xvcjMsIHVzZUV4YWN0U3JnYkNvbnZlcnNpb25zKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIENvbG9yNC5Gcm9tQXJyYXlUb1JlZihtZXNoQXR0cmlidXRlQXJyYXksIGluZGV4LCB2ZXJ0ZXhEYXRhIGFzIENvbG9yNCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb252ZXJ0VG9MaW5lYXIpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICh2ZXJ0ZXhEYXRhIGFzIENvbG9yNCkudG9MaW5lYXJTcGFjZVRvUmVmKHZlcnRleERhdGEgYXMgQ29sb3I0LCB1c2VFeGFjdFNyZ2JDb252ZXJzaW9ucyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgdmVydGV4QXR0cmlidXRlcy5wdXNoKHZlcnRleERhdGEuYXNBcnJheSgpKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgVmVydGV4QnVmZmVyLlVWS2luZDpcclxuICAgICAgICAgICAgY2FzZSBWZXJ0ZXhCdWZmZXIuVVYyS2luZDoge1xyXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgayA9IDAsIGxlbmd0aCA9IG1lc2hBdHRyaWJ1dGVBcnJheS5sZW5ndGggLyBzdHJpZGU7IGsgPCBsZW5ndGg7ICsraykge1xyXG4gICAgICAgICAgICAgICAgICAgIGluZGV4ID0gayAqIHN0cmlkZTtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCB2ZXJ0ZXhEYXRhID0gVmVjdG9yMi5Gcm9tQXJyYXkobWVzaEF0dHJpYnV0ZUFycmF5LCBpbmRleCk7XHJcbiAgICAgICAgICAgICAgICAgICAgdmVydGV4QXR0cmlidXRlcy5wdXNoKHZlcnRleERhdGEuYXNBcnJheSgpKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgVmVydGV4QnVmZmVyLk1hdHJpY2VzSW5kaWNlc0tpbmQ6XHJcbiAgICAgICAgICAgIGNhc2UgVmVydGV4QnVmZmVyLk1hdHJpY2VzSW5kaWNlc0V4dHJhS2luZDoge1xyXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgayA9IDAsIGxlbmd0aCA9IG1lc2hBdHRyaWJ1dGVBcnJheS5sZW5ndGggLyBzdHJpZGU7IGsgPCBsZW5ndGg7ICsraykge1xyXG4gICAgICAgICAgICAgICAgICAgIGluZGV4ID0gayAqIHN0cmlkZTtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCB2ZXJ0ZXhEYXRhID0gVmVjdG9yNC5Gcm9tQXJyYXkobWVzaEF0dHJpYnV0ZUFycmF5LCBpbmRleCk7XHJcbiAgICAgICAgICAgICAgICAgICAgdmVydGV4QXR0cmlidXRlcy5wdXNoKHZlcnRleERhdGEuYXNBcnJheSgpKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgVmVydGV4QnVmZmVyLk1hdHJpY2VzV2VpZ2h0c0tpbmQ6XHJcbiAgICAgICAgICAgIGNhc2UgVmVydGV4QnVmZmVyLk1hdHJpY2VzV2VpZ2h0c0V4dHJhS2luZDoge1xyXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgayA9IDAsIGxlbmd0aCA9IG1lc2hBdHRyaWJ1dGVBcnJheS5sZW5ndGggLyBzdHJpZGU7IGsgPCBsZW5ndGg7ICsraykge1xyXG4gICAgICAgICAgICAgICAgICAgIGluZGV4ID0gayAqIHN0cmlkZTtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCB2ZXJ0ZXhEYXRhID0gVmVjdG9yNC5Gcm9tQXJyYXkobWVzaEF0dHJpYnV0ZUFycmF5LCBpbmRleCk7XHJcbiAgICAgICAgICAgICAgICAgICAgdmVydGV4QXR0cmlidXRlcy5wdXNoKHZlcnRleERhdGEuYXNBcnJheSgpKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGRlZmF1bHQ6IHtcclxuICAgICAgICAgICAgICAgIFRvb2xzLldhcm4oXCJVbnN1cHBvcnRlZCBWZXJ0ZXggQnVmZmVyIFR5cGU6IFwiICsgdmVydGV4QnVmZmVyS2luZCk7XHJcbiAgICAgICAgICAgICAgICB2ZXJ0ZXhBdHRyaWJ1dGVzID0gW107XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGxldCB3cml0ZUJpbmFyeUZ1bmM7XHJcbiAgICAgICAgc3dpdGNoIChhdHRyaWJ1dGVDb21wb25lbnRLaW5kKSB7XHJcbiAgICAgICAgICAgIGNhc2UgQWNjZXNzb3JDb21wb25lbnRUeXBlLlVOU0lHTkVEX0JZVEU6IHtcclxuICAgICAgICAgICAgICAgIHdyaXRlQmluYXJ5RnVuYyA9IGJpbmFyeVdyaXRlci5zZXRVSW50OC5iaW5kKGJpbmFyeVdyaXRlcik7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIEFjY2Vzc29yQ29tcG9uZW50VHlwZS5VTlNJR05FRF9TSE9SVDoge1xyXG4gICAgICAgICAgICAgICAgd3JpdGVCaW5hcnlGdW5jID0gYmluYXJ5V3JpdGVyLnNldFVJbnQxNi5iaW5kKGJpbmFyeVdyaXRlcik7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIEFjY2Vzc29yQ29tcG9uZW50VHlwZS5VTlNJR05FRF9JTlQ6IHtcclxuICAgICAgICAgICAgICAgIHdyaXRlQmluYXJ5RnVuYyA9IGJpbmFyeVdyaXRlci5zZXRVSW50MzIuYmluZChiaW5hcnlXcml0ZXIpO1xyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY2FzZSBBY2Nlc3NvckNvbXBvbmVudFR5cGUuRkxPQVQ6IHtcclxuICAgICAgICAgICAgICAgIHdyaXRlQmluYXJ5RnVuYyA9IGJpbmFyeVdyaXRlci5zZXRGbG9hdDMyLmJpbmQoYmluYXJ5V3JpdGVyKTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGRlZmF1bHQ6IHtcclxuICAgICAgICAgICAgICAgIFRvb2xzLldhcm4oXCJVbnN1cHBvcnRlZCBBdHRyaWJ1dGUgQ29tc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AgICAgICAgaW5kZXggPSBtZXNoUHJpbWl0aXZlLmluZGV4U3RhcnQgKyBrICogc3RyaWRlO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHZlcnRleERhdGEgPSBWZWN0b3IzLkZyb21BcnJheShtZXNoQXR0cmlidXRlQXJyYXksIGluZGV4KTtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBtb3JwaERhdGEgPSBWZWN0b3IzLkZyb21BcnJheShtb3JwaFRhcmdldEF0dHJpYnV0ZUFycmF5LCBpbmRleCk7XHJcbiAgICAgICAgICAgICAgICAgICAgZGlmZmVyZW5jZSA9IG1vcnBoRGF0YS5zdWJ0cmFjdFRvUmVmKHZlcnRleERhdGEsIGRpZmZlcmVuY2UpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChtaW5NYXgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4Lm1pbi5jb3B5RnJvbUZsb2F0cyhNYXRoLm1pbihkaWZmZXJlbmNlLngsIG1pbk1heC5taW4ueCksIE1hdGgubWluKGRpZmZlcmVuY2UueSwgbWluTWF4Lm1pbi55KSwgTWF0aC5taW4oZGlmZmVyZW5jZS56LCBtaW5NYXgubWluLnopKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4Lm1heC5jb3B5RnJvbUZsb2F0cyhNYXRoLm1heChkaWZmZXJlbmNlLngsIG1pbk1heC5tYXgueCksIE1hdGgubWF4KGRpZmZlcmVuY2UueSwgbWluTWF4Lm1heC55KSwgTWF0aC5tYXgoZGlmZmVyZW5jZS56LCBtaW5NYXgubWF4LnopKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgdmVydGV4QXR0cmlidXRlcy5wdXNoKGRpZmZlcmVuY2UuYXNBcnJheSgpKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgI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dHRyaWJ1dGVDb21wb25lbnRLaW5kKSB7XHJcbiAgICAgICAgICAgIGNhc2UgQWNjZXNzb3JDb21wb25lbnRUeXBlLlVOU0lHTkVEX0JZVEU6IHtcclxuICAgICAgICAgICAgICAgIHdyaXRlQmluYXJ5RnVuYyA9IGJpbmFyeVdyaXRlci5zZXRVSW50OC5iaW5kKGJpbmFyeVdyaXRlcik7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIEFjY2Vzc29yQ29tcG9uZW50VHlwZS5VTlNJR05FRF9TSE9SVDoge1xyXG4gICAgICAgICAgICAgICAgd3JpdGVCaW5hcnlGdW5jID0gYmluYXJ5V3JpdGVyLnNldFVJbnQxNi5iaW5kKGJpbmFyeVdyaXRlcik7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIEFjY2Vzc29yQ29tcG9uZW50VHlwZS5VTlNJR05FRF9JTlQ6IHtcclxuICAgICAgICAgICAgICAgIHdyaXRlQmluYXJ5RnVuYyA9IGJpbmFyeVdyaXRlci5zZXRVSW50MzIuYmluZChiaW5hcnlXcml0ZXIpO1xyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY2FzZSBBY2Nlc3NvckNvbXBvbmVudFR5cGUuRkxPQVQ6IHtcclxuICAgICAgICAgICAgICAgIHdyaXRlQmluYXJ5RnVuYyA9IGJpbmFyeVdyaXRlci5zZXRGbG9hdDMyLmJpbmQoYmluYXJ5V3JpdGVyKTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGRlZmF1bHQ6IHtcclxuICAgICAgICAgICAgICAgIFRvb2xzLldhcm4oXCJVbnN1cHBvcnRlZCBBdHRyaWJ1dGUgQ29tcG9uZW50IGtpbmQ6IFwiICsgYXR0cmlidXRlQ29tcG9uZW50S2luZCk7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGZvciAoY29uc3QgdmVydGV4QXR0cmlidXRlIG9mIHZlcnRleEF0dHJpYnV0ZXMpIHtcclxuICAgICAgICAgICAgZm9yIChjb25zdCBjb21wb25lbnQgb2YgdmVydGV4QXR0cmlidXRlKSB7XHJcbiAgICAgICAgICAgICAgICB3cml0ZUJpbmFyeUZ1bmMoY29tcG9uZW50KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIEdlbmVyYXRlcyBnbFRGIGpzb24gZGF0YVxyXG4gICAgICogQHBhcmFtIHNob3VsZFVzZUdsYiBJbmRpY2F0ZXMgd2hldGhlciB0aGUganNvbiBzaG91bGQgYmUgd3JpdHRlbiBmb3IgYSBnbGIgZmlsZVxyXG4gICAgICogQHBhcmFtIGdsVEZQcmVmaXggVGV4dCB0byB1c2Ugd2hlbiBwcmVmaXhpbmcgYSBnbFRGIGZpbGVcclxuICAgICAqIEBwYXJhbSBwcmV0dHlQcmludCBJbmRpY2F0ZXMgd2hldGhlciB0aGUganNvbiBmaWxlIHNob3VsZCBiZSBwcmV0dHkgcHJpbnRlZCAodHJ1ZSkgb3Igbm90IChmYWxzZSlcclxuICAgICAqIEByZXR1cm5zIGpzb24gZGF0YSBhcyBzdHJpbmdcclxuICAgICAqL1xyXG4gICAgcHJpdmF0ZSBfZ2VuZXJhdGVKU09OKHNob3VsZFVzZUdsYjogYm9vbGVhbiwgZ2xURlByZWZpeD86IHN0cmluZywgcHJldHR5UHJpbnQ/OiBib29sZWFuKTogc3RyaW5nIHtcclxuICAgICAgICBjb25zdCBidWZmZXI6IElCdWZmZXIgPSB7IGJ5dGVMZW5ndGg6IHRoaXMuX3RvdGFsQnl0ZUxlbmd0aCB9O1xyXG4gICAgICAgIGx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2lucztcclxuICAgICAgICB9XHJcbiAgICAgICAgaWYgKHRoaXMuX2ltYWdlcyAmJiB0aGlzLl9pbWFnZXMubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgIGlmICghc2hvdWxkVXNlR2xiKSB7XHJcbiAgICAgICAgICAgICAgICB0aGlzLl9nbFRGLmltYWdlcyA9IHRoaXMuX2ltYWdlcztcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHRoaXMuX2dsVEYuaW1hZ2VzID0gW107XHJcblxyXG4gICAgICAgICAgICAgICAgdGhpcy5faW1hZ2VzLmZvckVhY2goKGltYWdlKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGltYWdlLnVyaSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpbWFnZURhdGEgPSB0aGlzLl9pbWFnZURhdGFbaW1hZ2UudXJpXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb3JkZXJlZEltYWdlRGF0YS5wdXNoKGltYWdlRGF0YSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlTmFtZSA9IGltYWdlLnVyaS5zcGxpdChcIi5cIilbMF0gKyBcIiBpbWFnZVwiO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBidWZmZXJWaWV3ID0gX0dMVEZVdGlsaXRpZXMuX0NyZWF0ZUJ1ZmZlclZpZXcoMCwgYnl0ZU9mZnNldCwgaW1hZ2VEYXRhLmRhdGEuYnl0ZUxlbmd0aCwgdW5kZWZpbmVkLCBpbWFnZU5hbWUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBieXRlT2Zmc2V0ICs9IGltYWdlRGF0YS5kYXRhLmJ5dGVMZW5ndGg7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2J1ZmZlclZpZXdzLnB1c2goYnVmZmVyVmlldyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLmJ1ZmZlclZpZXcgPSB0aGlzLl9idWZmZXJWaWV3cy5sZW5ndGggLSAxO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS5uYW1lID0gaW1hZ2VOYW1lO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS5taW1lVHlwZSA9IGltYWdlRGF0YS5taW1lVHlwZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaW1hZ2UudXJpID0gdW5kZWZpbmVkO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX2dsVEYuaW1hZ2VzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9nbFRGLmltYWdlcyA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2dsVEYuaW1hZ2VzLnB1c2goaW1hZ2UpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgLy8gUmVwbGFjZSB1cmkgd2l0aCBidWZmZXJ2aWV3IGFuZCBtaW1lIHR5cGUgZm9yIGdsYlxyXG4gICAgICAgICAgICAgICAgYnVmZmVyLmJ5dGVMZW5ndGggPSBieXRlT2Zmc2V0O1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAoIXNob3VsZFVzZUdsYikge1xyXG4gICAgICAgICAgICBidWZmZXIudXJpID0gZ2xURlByZWZpeCArIFwiLmJpblwiO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgY29uc3QganNvblRleHQgPSBwcmV0dHlQcmludCA/IEpTT04uc3RyaW5naWZ5KHRoaXMuX2dsVEYsIG51bGwsIDIpIDogSlNPTi5zdHJpbmdpZnkodGhpcy5fZ2xURik7XHJcblxyXG4gICAgICAgIHJldHVybiBqc29uVGV4dDtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIE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mICh0aGlzLl9sb2NhbEVuZ2luZSkge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5fbG9jYWxFbmdpbmUuZGlzcG9zZSgpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHJldHVybiBiaW5hcnlXcml0ZXIuZ2V0QXJyYXlCdWZmZXIoKTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIFBhZHMgdGhlIG51bWJlciB0byBhIG11bHRpcGxlIG9mIDRcclxuICAgICAqIEBwYXJhbSBudW0gbnVtYmVyIHRvIHBhZFxyXG4gICAgICogQHJldHVybnMgcGFkZGVkIG51bWJlclxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIF9nZXRQYWRkaW5nKG51bTogbnVtYmVyKTogbnVtYmVyIHtcclxuICAgICAgICBjb25zdCByZW1haW5kZXIgPSBudW0gJSA0O1xyXG4gICAgICAgIGNvbnN0IHBhZGRpbmcgPSByZW1haW5kZXIgPT09IDAgPyByZW1haW5kZXIgOiA0IC0gcmVtYWluZGVyO1xyXG5cclxuICAgICAgICByZXR1cm4gcGFkZGluZztcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIEBpbnRlcm5hbFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgX2dlbmVyYXRlR0xCQXN5bmMoZ2xURlByZWZpeDogc3RyaW5nLCBkaXNwb3NlID0gdHJ1ZSk6IFByb21pc2U8R0xURkRhdGE+IHtcclxuICAgICAgICByZXR1cm4gdGhpcy5fZ2VuZXJhdGVCaW5hcnlBc3luYygpLnRoZW4oKGJpbmFyeUJ1ZmZlcikgPT4ge1xyXG4gICAgICAgICAgICB0aGlzLl9leHRlbnNpb25zT25FeHBvcnRpbmcoKTtcclxuICAgICAgICAgICAgY29uc3QganNvblRleHQgPSB0aGlzLl9nZW5lcmF0ZUpTT04odHJ1ZSk7XHJcbiAgICAgICAgICAgIGNvbnN0IGdsYkZpbGVOYW1lID0gZ2xURlByZWZpeCArIFwiLmdsYlwiO1xyXG4gICAgICAgICAgICBjb25zdCBoZWFkZXJMZW5ndGggPSAxMjtcclxuICAgICAgICAgICAgY29uc3QgY2h1bmtMZW5ndGhQcmVmaXggPSA4O1xyXG4gICAgICAgICAgICBsZXQganNvbkxlbmd0aCA9IGpzb25UZXh0Lmxlbmd0aDtcclxuICAgICAgICAgICAgbGV0IGVuY29kZWRKc29uVGV4dDtcclxuICAgICAgICAgICAgbGV0IGltYWdlQnl0ZUxlbmd0aCA9IDA7XHJcbiAgICAgICAgICAgIC8vIG1ha2UgdXNlIG9mIFRleHRFbmNvZGVyIHdoZW4gYXZhaWxhYmxlXHJcbiAgICAgICAgICAgIGlmICh0eXBlb2YgVGV4dEVuY29kZXIgIT09IFwidW5kZWZpbmVkXCIpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGVuY29kZXIgPSBuZXcgVGV4dEVuY29kZXIoKTtcclxuICAgICAgICAgICAgICAgIGVuY29kZWRKc29uVGV4dCA9IGVuY29kZXIuZW5jb2RlKGpzb25UZXh0KTtcclxuICAgICAgICAgICAgICAgIGpzb25MZW5ndGggPSBlbmNvZGVkSnNvblRleHQubGVuZ3RoO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdGhpcy5fb3JkZXJlZEltYWdlRGF0YS5sZW5ndGg7ICsraSkge1xyXG4gICAgICAgICAgICAgICAgaW1hZ2VCeXRlTGVuZ3RoICs9IHRoaXMuX29yZGVyZWRJbWFnZURhdGFbaV0uZGF0YS5ieXRlTGVuZ3RoO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNvbnN0IGpzb25QYWRkaW5nID0gdGhpcy5fZ2V0UGFkZGluZyhqc29uTGVuZ3RoKTtcclxuICAgICAgICAgICAgY29uc3QgYmluUGFkZGluZyA9IHRoaXMuX2dldFBhZGRpbmcoYmluYXJ5QnVmZmVyLmJ5dGVMZW5ndGgpO1x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kNodW5rQnVmZmVyKTtcclxuICAgICAgICAgICAganNvbkNodW5rQnVmZmVyVmlldy5zZXRVaW50MzIoMCwganNvbkxlbmd0aCArIGpzb25QYWRkaW5nLCB0cnVlKTtcclxuICAgICAgICAgICAganNvbkNodW5rQnVmZmVyVmlldy5zZXRVaW50MzIoNCwgMHg0ZTRmNTM0YSwgdHJ1ZSk7XHJcblxyXG4gICAgICAgICAgICAvL2pzb24gY2h1bmsgYnl0ZXNcclxuICAgICAgICAgICAgY29uc3QganNvbkRhdGEgPSBuZXcgVWludDhBcnJheShqc29uQ2h1bmtCdWZmZXIsIGNodW5rTGVuZ3RoUHJlZml4KTtcclxuICAgICAgICAgICAgLy8gaWYgVGV4dEVuY29kZXIgd2FzIGF2YWlsYWJsZSwgd2UgY2FuIHNpbXBseSBjb3B5IHRoZSBlbmNvZGVkIGFycmF5XHJcbiAgICAgICAgICAgIGlmIChlbmNvZGVkSnNvblRleHQpIHtcclxuICAgICAgICAgICAgICAgIGpzb25EYXRhLnNldChlbmNvZGVkSnNvblRleHQpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgYmxhbmtDaGFyQ29kZSA9IFwiX1wiLmNoYXJDb2RlQXQoMCk7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGpzb25MZW5ndGg7ICsraSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoYXJDb2RlID0ganNvblRleHQuY2hhckNvZGVBdChpKTtcclxuICAgICAgICAgICAgICAgICAgICAvLyBpZiB0aGUgY2hhcmFjdGVyIGRvZXNuJ3QgZml0IGludG8gYSBzaW5nbGUgVVRGLTE2IGNvZGUgdW5pdCwganVzdCBwdXQgYSBibGFuayBjaGFyYWN0ZXJcclxuICAgICAgICAgICAgICAgICAgICBpZiAoY2hhckNvZGUgIT0ganNvblRleHQuY29kZVBvaW50QXQoaSkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAganNvbkRhdGFbaV0gPSBibGFua0NoYXJDb2RlO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGpzb25EYXRhW2ldID0gY2hhckNvZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvL2pzb24gcGFkZGluZ1xyXG4gICAgICAgICAgICBjb25zdCBqc29uUGFkZGluZ1ZpZXcgPSBuZXcgVWludDhBcnJheShqc29uQ2h1bmtCdWZmZXIsIGNodW5rTGVuZ3RoUHJlZml4ICsganNvbkxlbmd0aCk7XHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwganNvblBhZGRpbmc7ICsraSkge1xyXG4gICAgICAgICAgICAgICAganNvblBhZGRpbmdWaWV3W2ldID0gMHgyMDtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgLy9iaW5hcnkgY2h1bmtcclxuICAgICAgICAgICAgY29uc3QgYmluYXJ5Q2h1bmtCdWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIoY2h1bmtMZW5ndGhQcmVmaXgpO1xyXG4gICAgICAgICAgICBjb25zdCBiaW5hcnlDaHVua0J1ZmZlclZpZXcgPSBuZXcgRGF0YVZpZXcoYmluYXJ5Q2h1bmtCdWZmZXIpO1xyXG4gICAgICAgICAgICBiaW5hcnlDaHVua0J1ZmZlclZpZXcuc2V0VWludDMyKDAsIGJpbmFyeUJ1ZmZlci5ieXRlTGVuZ3RoICsgaW1hZ2VCeXRlTGVuZ3RoICsgaW1hZ2VQYWRkaW5nLCB0cnVlKTtcclxuICAgICAgICAgICAgYmluYXJ5Q2h1bmtCdWZmZXJWaWV3LnNldFVpbnQzMig0LCAweDAwNGU0OTQyLCB0cnVlKTtcclxuXHJcbiAgICAgICAgICAgIC8vIGJpbmFyeSBwYWRkaW5nXHJcb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gICBjb25zdCBieXRlTGVuZ3RoID0gY291bnQgKiBieXRlU3RyaWRlO1xyXG4gICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyVmlldyA9IF9HTFRGVXRpbGl0aWVzLl9DcmVhdGVCdWZmZXJWaWV3KDAsIGJpbmFyeVdyaXRlci5nZXRCeXRlT2Zmc2V0KCksIGJ5dGVMZW5ndGgsIGJ5dGVTdHJpZGUsIGJhYnlsb25Nb3JwaFRhcmdldC5uYW1lICsgXCJfUE9TSVRJT05cIik7XHJcbiAgICAgICAgICAgICAgICB0aGlzLl9idWZmZXJWaWV3cy5wdXNoKGJ1ZmZlclZpZXcpO1xyXG5cclxuICAgICAgICAgICAgICAgIGNvbnN0IGJ1ZmZlclZpZXdJbmRleCA9IHRoaXMuX2J1ZmZlclZpZXdzLmxlbmd0aCAtIDE7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBtaW5NYXggPSB7IG1pbjogbmV3IFZlY3RvcjMoSW5maW5pdHksIEluZmluaXR5LCBJbmZpbml0eSksIG1heDogbmV3IFZlY3RvcjMoLUluZmluaXR5LCAtSW5maW5pdHksIC1JbmZpbml0eSkgfTtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGFjY2Vzc29yID0gX0dMVEZVdGlsaXRpZXMuX0NyZWF0ZUFjY2Vzc29yKFxyXG4gICAgICAgICAgICAgICAgICAgIGJ1ZmZlclZpZXdJbmRleCxcclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uTW9ycGhUYXJnZXQubmFtZSArIFwiIC0gXCIgKyBcIlBPU0lUSU9OXCIsXHJcbiAgICAgICAgICAgICAgICAgICAgQWNjZXNzb3JUeXBlLlZFQzMsXHJcbiAgICAgICAgICAgICAgICAgICAgQWNjZXNzb3JDb21wb25lbnRUeXBlLkZMT0FULFxyXG4gICAgICAgICAgICAgICAgICAgIGNvdW50LFxyXG4gICAgICAgICAgICAgICAgICAgIDAsXHJcbiAgICAgICAgICAgICAgICAgICAgbnVsbCxcclxuICAgICAgICAgICAgICAgICAgICBudWxsXHJcbiAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICAgICAgdGhpcy5fYWNjZXNzb3JzLnB1c2goYWNjZXNzb3IpO1xyXG4gICAgICAgICAgICAgICAgdGFyZ2V0LlBPU0lUSU9OID0gdGhpcy5fYWNjZXNzb3JzLmxlbmd0aCAtIDE7XHJcblxyXG4gICAgICAgICAgICAgICAgdGhpcy53cml0ZU1vcnBoVGFyZ2V0QXR0cmlidXRlRGF0YShcclxuICAgICAgICAgICAgICAgICAgICBWZXJ0ZXhCdWZmZXIuUG9zaXRpb25LaW5kLFxyXG4gICAgICAgICAgICAgICAgICAgIEFjY2Vzc29yQ29tcG9uZW50VHlwZS5GTE9BVCxcclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uU3ViTWVzaCxcclxuICAgICAgICAgICAgICAgICAgICB2ZXJ0ZXhQb3NpdGlvbnMsXHJcbiAgICAgICAgICAgICAgICAgICAgbW9ycGhQb3NpdGlvbnMsXHJcbiAgICAgICAgICAgICAgICAgICAgYnl0ZVN0cmlkZSAvIDQsXHJcbiAgICAgICAgICAgICAgICAgICAgYmluYXJ5V3JpdGVyLFxyXG4gICAgICAgICAgICAgICAgICAgIG1pbk1heFxyXG4gICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgIGFjY2Vzc29yLm1pbiA9IG1pbk1heC5taW4hLmFzQXJyYXkoKTtcclxuICAgICAgICAgICAgICAgIGFjY2Vzc29yLm1heCA9IG1pbk1heC5tYXghLmFzQXJyYXkoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoYmFieWxvbk1vcnBoVGFyZ2V0Lmhhc1RhbmdlbnRzKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCB2ZXJ0ZXhUYW5nZW50cyA9IG1lc2guZ2V0VmVydGljZXNEYXRhKFZlcnRleEJ1ZmZlci5UYW5nZW50S2luZCwgdW5kZWZpbmVkLCB1bmRlZmluZ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9BVCxcclxuICAgICAgICAgICAgICAgICAgICBjb3VudCxcclxuICAgICAgICAgICAgICAgICAgICAwLFxyXG4gICAgICAgICAgICAgICAgICAgIG51bGwsXHJcbiAgICAgICAgICAgICAgICAgICAgbnVsbFxyXG4gICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgIHRoaXMuX2FjY2Vzc29ycy5wdXNoKGFjY2Vzc29yKTtcclxuICAgICAgICAgICAgICAgIHRhcmdldC5UQU5HRU5UID0gdGhpcy5fYWNjZXNzb3JzLmxlbmd0aCAtIDE7XHJcblxyXG4gICAgICAgICAgICAgICAgdGhpcy53cml0ZU1vcnBoVGFyZ2V0QXR0cmlidXRlRGF0YShcclxuICAgICAgICAgICAgICAgICAgICBWZXJ0ZXhCdWZmZXIuVGFuZ2VudEtpbmQsXHJcbiAgICAgICAgICAgICAgICAgICAgQWNjZXNzb3JDb21wb25lbnRUeXBlLkZMT0FULFxyXG4gICAgICAgICAgICAgICAgICAgIGJhYnlsb25TdWJNZXNoLFxyXG4gICAgICAgICAgICAgICAgICAgIHZlcnRleFRhbmdlbnRzLFxyXG4gICAgICAgICAgICAgICAgICAgIG1vcnBoVGFuZ2VudHMsXHJcbiAgICAgICAgICAgICAgICAgICAgYnl0ZVN0cmlkZSAvIDQsXHJcbiAgICAgICAgICAgICAgICAgICAgYmluYXJ5V3JpdGVyXHJcbiAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIG1lc2hQcmltaXRpdmUudGFyZ2V0cy5wdXNoKHRhcmdldCk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogVGhlIHByaW1pdGl2ZSBtb2RlIG9mIHRoZSBCYWJ5bG9uIG1lc2hcclxuICAgICAqIEBwYXJhbSBiYWJ5bG9uTWVzaCBUaGUgQmFieWxvbkpTIG1lc2hcclxuICAgICAqIEByZXR1cm5zIFVuc2lnbmVkIGludGVnZXIgb2Yg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QHBhcmFtIHByaW1pdGl2ZU1vZGUgVGhlIHByaW1pdGl2ZSBtb2RlXHJcbiAgICAgKi9cclxuICAgIHByaXZhdGUgX3NldFByaW1pdGl2ZU1vZGUobWVzaFByaW1pdGl2ZTogSU1lc2hQcmltaXRpdmUsIHByaW1pdGl2ZU1vZGU6IG51bWJlcikge1xyXG4gICAgICAgIHN3aXRjaCAocHJpbWl0aXZlTW9kZSkge1xyXG4gICAgICAgICAgICBjYXNlIE1hdGVyaWFsLlRyaWFuZ2xlRmlsbE1vZGU6IHtcclxuICAgICAgICAgICAgICAgIC8vIGdsVEYgZGVmYXVsdHMgdG8gdXNpbmcgVHJpYW5nbGUgTW9kZVxyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY2FzZSBNYXRlcmlhbC5UcmlhbmdsZVN0cmlwRHJhd01vZGU6IHtcclxuICAgICAgICAgICAgICAgIG1lc2hQcmltaXRpdmUubW9kZSA9IE1lc2hQcmltaXRpdmVNb2RlLlRSSUFOR0xFX1NUUklQO1xyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY2FzZSBNYXRlcmlhbC5UcmlhbmdsZUZhbkRyYXdNb2RlOiB7XHJcbiAgICAgICAgICAgICAgICBtZXNoUHJpbWl0aXZlLm1vZGUgPSBNZXNoUHJpbWl0aXZlTW9kZS5UUklBTkdMRV9GQU47XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIE1hdGVyaWFsLlBvaW50TGlzdERyYXdNb2RlOiB7XHJcbiAgICAgICAgICAgICAgICBtZXNoUHJpbWl0aXZlLm1vZGUgPSBNZXNoUHJpbWl0aXZlTW9kZS5QT0lOVFM7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIE1hdGVyaWFsLlBvaW50RmlsbE1vZGU6IHtcclxuICAgICAgICAgICAgICAgIG1lc2hQcmltaXRpdmUubW9kZSA9IE1lc2hQcmltaXRpdmVNb2RlLlBPSU5UUztcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgTWF0ZXJpYWwuTGluZUxvb3BEcmF3TW9kZToge1xyXG4gICAgICAgICAgICAgICAgbWVzaFByaW1pdGl2ZS5tb2RlID0gTWVzaFByaW1pdGl2ZU1vZGUuTElORV9MT09QO1xyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY2FzZSBNYXRlcmlhbC5MaW5lTGlzdERyYXdNb2RlOiB7XHJcbiAgICAgICAgICAgICAgICBtZXNoUHJpbWl0aXZlLm1vZGUgPSBNZXNoUHJpbWl0aXZlTW9kZS5MSU5FUztcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgTWF0ZXJpYWwuTGluZVN0cmlwRHJhd01vZGU6IHtcclxuICAgICAgICAgICAgICAgIG1lc2hQcmltaXRpdmUubW9kZSA9IE1lc2hQcmltaXRpdmVNb2RlLkxJTkVfU1RSSVA7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIFNldHMgdGhlIHZlcnRleCBhdHRyaWJ1dGUgYWNjZXNzb3IgYmFzZWQgb2YgdGhlIGdsVEYgbWVzaCBwcmltaXRpdmVcclxuICAgICAqIEBwYXJhbSBtZXNoUHJpbWl0aXZlIGdsVEYgbWVzaCBwcmltaXRpdmVcclxuICAgICAqIEBwYXJhbSBhdHRyaWJ1dGVLaW5kIHZlcnRleCBhdHRyaWJ1dGVcclxuICAgICAqL1xyXG4gICAgcHJpdmF0ZSBfc2V0QXR0cmlidXRlS2luZChtZXNoUHJpbWl0aXZlOiBJTWVzaFByaW1pdGl2ZSwgYXR0cmlidXRlS2luZDogc3RyaW5nKTogdm9pZCB7XHJcbiAgICAgICAgc3dpdGNoIChhdHRyaWJ1dGVLaW5kKSB7XHJcbiAgICAgICAgICAgIGNhc2UgVmVydGV4QnVmZmVyLlBvc2l0aW9uS2luZDoge1xyXG4gICAgICAgICAgICAgICAgbWVzaFByaW1pdGl2ZS5hdHRyaWJ1dGVzLlBPU0lUSU9OID0gdGhpcy5fYWNjZXNzb3JzLmxlbmd0aCAtIDE7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIFZlcnRleEJ1ZmZlci5Ob3JtYWxLaW5kOiB7XHJcbiAgICAgICAgICAgICAgICBtZXNoUHJpbWl0aXZlLmF0dHJpYnV0ZXMuTk9STUFMID0gdGhpcy5fYWNjZXNzb3JzLmxlbmd0aCAtIDE7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIFZlcnRleEJ1ZmZlci5Db2xvcktpbmQ6IHtcclxuICAgICAgICAgICAgICAgIG1lc2hQcmltaXRpdmUuYXR0cmlidXRlcy5DT0xPUl8wID0gdGhpcy5fYWNjZXNzb3JzLmxlbmd0aCAtIDE7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIFZlcnRleEJ1ZmZlci5UYW5nZW50S2luZDoge1xyXG4gICAgICAgICAgICAgICAgbWVzaFByaW1pdGl2ZS5hdHRyaWJ1dGVzLlRBTkdFTlQgPSB0aGlzLl9hY2Nlc3NvcnMubGVuZ3RoIC0gMTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgVmVydGV4QnVmZmVyLlVWS2luZDoge1xyXG4gICAgICAgICAgICAgICAgbWVzaFByaW1pdGl2ZS5hdHRyaWJ1dGVzLlRFWENPT1JEXzAgPSB0aGlzLl9hY2Nlc3NvcnMubGVuZ3RoIC0gMTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgVmVydGV4QnVmZmVyLlVWMktpbmQ6IHtcclxuICAgICAgICAgICAgICAgIG1lc2hQcmltaXRpdmUuYXR0cmlidXRlcy5URVhDT09SRF8xID0gdGhpcy5fYWNjZXNzb3JzLmxlbmd0aCAtIDE7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIFZlcnRleEJ1ZmZlci5NYXRyaWNlc0luZGljZXNLaW5kOiB7XHJcbiAgICAgICAgICAgICAgICBtZXNoUHJpbWl0aXZlLmF0dHJpYnV0ZXMuSk9JTlRTXzAgPSB0aGlzLl9hY2Nlc3NvcnMubGVuZ3RoIC0gMTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgVmVydGV4QnVmZmVyLk1hdHJpY2VzSW5kaWNlc0V4dHJhS2luZDoge1xyXG4gICAgICAgICAgICAgICAgbWVzaFByaW1pdGl2ZS5hdHRyaWJ1dGVzLkpPSU5UU18xID0gdGhpcy5fYWNjZXNzb3JzLmxlbmd0aCAtIDE7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIFZlcnRleEJ1ZmZlci5NYXRyaWNlc1dlaWdodHNLaW5kOiB7XHJcbiAgICAgICAgICAgICAgICBtZXNoUHJpbWl0aXZlLmF0dHJpYnV0ZXMuV0VJR0hUU18wID0gdGhpcy5fYWNjZXNzb3JzLmxlbmd0aCAtIDE7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICA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mlidXRlS2luZCkgKiA0O1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChhdHRyaWJ1dGUuYnl0ZVN0cmlkZSA9PT0gMTIpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYXR0cmlidXRlLmFjY2Vzc29yVHlwZSA9IEFjY2Vzc29yVHlwZS5WRUMzO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlQnVmZmVyVmlld0tpbmQoYXR0cmlidXRlS2luZCwgYXR0cmlidXRlQ29tcG9uZW50S2luZCwgYmFieWxvblRyYW5zZm9ybU5vZGUsIGJpbmFyeVdyaXRlciwgYXR0cmlidXRlLmJ5dGVTdHJpZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgIGF0dHJpYnV0ZS5idWZmZXJWaWV3SW5kZXggPSB0aGlzLl9idWZmZXJWaWV3cy5sZW5ndGggLSAxO1xyXG4gICAgICAgICAgICAgICAgICAgIHZlcnRleEF0dHJpYnV0ZUJ1ZmZlclZpZXdzW2F0dHJpYnV0ZUtpbmRdID0gYXR0cmlidXRlLmJ1ZmZlclZpZXdJbmRleDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYgKGJ1ZmZlck1lc2guZ2V0VG90YWxJbmRpY2VzKCkpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGluZGljZXMgPSBidWZmZXJNZXNoLmdldEluZGljZXMoKTtcclxuICAgICAgICAgICAgICAgIGlmIChpbmRpY2VzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgYnl0ZUxlbmd0aCA9IGluZGljZXMubGVuZ3RoICogNDtcclxuICAgICAgICAgICAgICAgICAgICBidWZmZXJWaWV3ID0gX0dMVEZVdGlsaXRpZXMuX0NyZWF0ZUJ1ZmZlclZpZXcoMCwgYmluYXJ5V3JpdGVyLmdldEJ5dGVPZmZzZXQoKSwgYnl0ZUxlbmd0aCwgdW5kZWZpbmVkLCBcIkluZGljZXMgLSBcIiArIGJ1ZmZlck1lc2gubmFtZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fYnVmZmVyVmlld3MucHVzaChidWZmZXJWaWV3KTtcclxuICAgICAgICAgICAgICAgICAgICBpbmRleEJ1ZmZlclZpZXdJbmRleCA9IHRoaXMuX2J1ZmZlclZpZXdzLmxlbmd0aCAtIDE7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGsgPSAwLCBsZW5ndGggPSBpbmRpY2VzLmxlbmd0aDsgayA8IGxlbmd0aDsgKytrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJpbmFyeVdyaXRlci5zZXRVSW50MzIoaW5kaWNlc1trXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAoYnVmZmVyTWVzaC5zdWJNZXNoZXMpIHtcclxuICAgICAgICAgICAgICAgIC8vIGdvIHRocm91Z2ggYWxsIG1lc2ggcHJpbWl0aXZlcyAoc3VibWVzaGVzKVxyXG4gICAgICAgICAgICAgICAgZm9yIChjb25zdCBzdWJtZXNoIG9mIGJ1ZmZlck1lc2guc3ViTWVzaGVzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgbGV0IGJhYnlsb25NYXRlcmlhbCA9IHN1Ym1lc2guZ2V0TWF0ZXJpYWwoKSB8fCBidWZmZXJNZXNoLmdldFNjZW5lKCkuZGVmYXVsdE1hdGVyaWFsO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICBsZXQgbWF0ZXJpYWxJbmRleDogTnVsbGFibGU8bnVtYmVyPiA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGJhYnlsb25NYXRlcmlhbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoYnVmZmVyTWVzaCBpbnN0YW5jZW9mIExpbmVzTWVzaCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gZ2V0IHRoZSBjb2xvciBmcm9tIHRoZSBsaW5lcyBtZXNoIGFuZCBzZXQgaXQgaW4gdGhlIG1hdGVyaWFsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXRlcmlhbDogSU1hdGVyaWFsID0ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IGJ1ZmZlck1lc2gubmFtZSArIFwiIG1hdGVyaWFsXCIsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFidWZmZXJNZXNoLmNvbG9yLmVxdWFscyhDb2xvcjMuV2hpdGUoKSkgfHwgYnVmZmVyTWVzaC5hbHBoYSA8IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXRlcmlhbC5wYnJNZXRhbGxpY1JvdWdobmVzcyA9IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZUNvbG9yRmFjdG9yOiBidWZmZXJNZXNoLmNvbG9yLmFzQXJyYXkoKS5jb25jYXQoW2J1ZmZlck1lc2guYWxwaGFdKSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbWF0ZXJpYWxzLnB1c2gobWF0ZXJpYWwpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF0ZXJpYWxJbmRleCA9IHRoaXMuX21hdGVyaWFscy5sZW5ndGggLSAxO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGJhYnlsb25NYXRlcmlhbCBpbnN0YW5jZW9mIE11bHRpTWF0ZXJpYWwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1Yk1hdGVyaWFsID0gYmFieWxvbk1hdGVyaWFsLnN1Yk1hdGVyaWFsc1tzdWJtZXNoLm1hdGVyaWFsSW5kZXhdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN1Yk1hdGVyaWFsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvbk1hdGVyaWFsID0gc3ViTWF0ZXJpYWw7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF0ZXJpYWxJbmRleCA9IHRoaXMuX21hdGVyaWFsTWFwW2JhYnlsb25NYXRlcmlhbC51bmlxdWVJZF07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXRlcmlhbEluZGV4ID0gdGhpcy5fbWF0ZXJpYWxNYXBbYmFieWxvbk1hdGVyaWFsLnVuaXF1ZUlkXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2xURk1hdGVyaWFsOiBOdWxsYWJsZTxJTWF0ZXJpYWw+ID0gbWF0ZXJpYWxJbmRleCAhPSBudWxsID8gdGhpcy5fbWF0ZXJpYWxzW21hdGVyaWFsSW5kZXhdIDogbnVsbDtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzaFByaW1pdGl2ZTogSU1lc2hQcmltaXRpdmUgPSB7IGF0dHJpYnV0ZXM6IHt9IH07XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UHJpbWl0aXZlTW9kZShtZXNoUHJpbWl0aXZlLCBwcmltaXRpdmVNb2RlKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBhdHRyaWJ1dGUgb2YgYXR0cmlidXRlRGF0YSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdHRyaWJ1dGVLaW5kID0gYXR0cmlidXRlLmtpbmQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoYXR0cmlidXRlS2luZCA9PT0gVmVydGV4QnVmZmVyLlVWS2luZCB8fCBhdHRyaWJ1dGVLaW5kID09PSBWZXJ0ZXhCdWZmZXIuVVYyS2luZCkgJiYgIXRoaXMuX29wdGlvbnMuZXhwb3J0VW51c2VkVVZzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWdsVEZNYXRlcmlhbCB8fCAhdGhpcy5fZ2xURk1hdGVyaWFsRXhwb3J0ZXIuX2hhc1RleHR1cmVzUHJlc2VudChnbFRGTWF0ZXJpYWwpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmVydGV4RGF0YSA9IGJ1ZmZlck1lc2guZ2V0VmVydGljZXNEYXRhKGF0dHJpYnV0ZUtpbmQsIHVuZGVmaW5lZCwgdW5kZWZpbmVkLCB0cnVlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZlcnRleERhdGEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZlcnRleEJ1ZmZlciA9IHRoaXMuX2dldFZlcnRleEJ1ZmZlckZyb21NZXNoKGF0dHJpYnV0ZUtpbmQsIGJ1ZmZlck1lc2gpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZlcnRleEJ1ZmZlcikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0cmlkZSA9IHZlcnRleEJ1ZmZlci5nZXRTaXplKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyVmlld0luZGV4ID0gYXR0cmlidXRlLmJ1ZmZlclZpZXdJbmRleDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYnVmZmVyVmlld0luZGV4ICE9IHVuZGVmaW5lZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBjaGVjayB0byBzZWUgaWYgYnVmZmVydmlld2luZGV4IGhhcyBhIG51bWVyaWMgdmFsdWUgYXNzaWduZWQuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heCA9IHsgbWluOiBudWxsLCBtYXg6IG51bGwgfTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGF0dHJpYnV0ZUtpbmQgPT0gVmVydGV4QnVmZmVyLlBvc2l0aW9uS2luZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4ID0gX0dMVEZVdGlsaXRpZXMuX0NhbGN1bGF0ZU1pbk1heFBvc2l0aW9ucyh2ZXJ0ZXhEYXRhLCAwLCB2ZXJ0ZXhEYXRhLmxlbmd0aCAvIHN0cmlkZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWNjZXNzb3IgPSBfR0xURlV0aWxpdGllcy5fQ3JlYXRlQWNjZXNzb3IoXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXJWaWV3SW5kZXgsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVLaW5kICsgXCIgLSBcIiArIGJhYnlsb25UcmFuc2Zvcm1Ob2RlLm5hbWUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGUuYWNjZXNzb3JUeXBlLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXR0cmlidXRlLmFjY2Vzc29yQ29tcG9uZW50VHlwZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZlcnRleERhdGEubGVuZ3RoIC8gc3RyaWRlLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heC5taW4sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXgubWF4XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2FjY2Vzc29ycy5wdXNoKGFjY2Vzc29yKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0QXR0cmlidXRlS2luZChtZXNoUHJpbWl0aXZlLCBhdHRyaWJ1dGVLaW5kKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChpbmRleEJ1ZmZlclZpZXdJbmRleCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBDcmVhdGUgYWNjZXNzb3JcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWNjZXNzb3IgPSBfR0xURlV0aWxpdGllcy5fQ3JlYXRlQWNjZXNzb3IoXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleEJ1ZmZlclZpZXdJbmRleCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwiaW5kaWNlcyAtIFwiICsgYmFieWxvblRyYW5zZm9ybU5vZGUubmFtZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFjY2Vzc29yVHlwZS5TQ0FMQVIsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBY2Nlc3NvckNvbXBvbmVudFR5cGUuVU5TSUdORURfSU5ULFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VibWVzaC5pbmRleENvdW50LFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VibWVzaC5pbmRleFN0YXJ0ICogNCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG51bGwsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBudWxsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2FjY2Vzc29ycy5wdXNoKGFjY2Vzc29yKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbWVzaFByaW1pdGl2ZS5pbmRpY2VzID0gdGhpcy5fYWNjZXNzb3JzLmxlbmd0aCAtIDE7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBpZiAoT2JqZWN0LmtleXMobWVzaFByaW1pdGl2ZS5hdHRyaWJ1dGVzKS5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNpZGVPcmllbnRhdGlvbiA9IGJ1ZmZlck1lc2gub3ZlcnJpZGVNYXRlcmlhbFNpZGVPcmllbnRhdGlvbiAhPT0gbnVsbCA/IGJ1ZmZlck1lc2gub3ZlcnJpZGVNYXRlcmlhbFNpZGVPcmllbnRhdGlvbiA6IGJhYnlsb25NYXRlcmlhbC5zaWRlT3JpZW50YXRpb247XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2lkZU9yaWVudGF0aW9uID09PSAodGhpcy5fYmFieWxvblNjZW5lLnVzZVJpZ2h0SGFuZGVkU3lzdGVtID8gTWF0ZXJpYWwuQ2xvY2tXaXNlU2lkZU9yaWVudGF0aW9uIDogTWF0ZXJpYWwuQ291bnRlckNsb2NrV2lzZVNpZGVPcmllbnRhdGlvbikpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBieXRlT2Zmc2V0ID0gaW5kZXhCdWZmZXJWaWV3SW5kZXggIT0gbnVsbCA/IHRoaXMuX2J1ZmZlclZpZXdzW2luZGV4QnVmZmVyVmlld0luZGV4XS5ieXRlT2Zmc2V0IDogbnVsbDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChieXRlT2Zmc2V0ID09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlT2Zmc2V0ID0gMDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBiYWJ5bG9uSW5kaWNlczogTnVsbGFibGU8SW5kaWNlc0FycmF5PiA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXhCdWZmZXJWaWV3SW5kZXggIT0gbnVsbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25JbmRpY2VzID0gYnVmZmVyTWVzaC5nZXRJbmRpY2VzKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmFieWxvbkluZGljZXMpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZW9yZGVySW5kaWNlc0Jhc2VkT25QcmltaXRpdmVNb2RlKHN1Ym1lc2gsIHByaW1pdGl2ZU1vZGUsIGJhYnlsb25JbmRpY2VzLCBieXRlT2Zmc2V0LCBiaW5hcnlXcml0ZXIpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGF0dHJpYnV0ZSBvZiBhdHRyaWJ1dGVEYXRhKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZlcnRleERhdGEgPSBidWZmZXJNZXNoLmdldFZlcnRpY2VzRGF0YShhdHRyaWJ1dGUua2luZCwgdW5kZWZpbmVkLCB1bmRlZmluZWQsIHRydWUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmVydGV4RGF0YSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnl0ZU9mZnNldCA9IHRoaXMuX2J1ZmZlclZpZXdzW3ZlcnRleEF0dHJpYnV0ZUJ1ZmZlclZpZXdzW2F0dHJpYnV0ZS5raW5kXV0uYnl0ZU9mZnNldCB8fCAwO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVvcmRlclZlcnRleEF0dHJpYnV0ZURhdGFCYXNlZE9uUHJpbWl0aXZlTW9kZShzdWJtZXNoLCBwcmltaXRpdmVNb2RlLCBhdHRyaWJ1dGUua2luZCwgdmVydGV4RGF0YSwgYnl0ZU9mZnNldCwgYmluYXJ5V3JpdGVyKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1hdGVyaWFsSW5kZXggIT0gbnVsbCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzaFByaW1pdGl2ZS5tYXRlcmlhbCA9IG1hdGVyaWFsSW5kZXg7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKG1vcnBoVGFyZ2V0TWFuYWdlcikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBCeSBjb252ZW50aW9uLCBtb3JwaCB0YXJnZXQgbmFtZXMgYXJlIHN0b3JlZCBpbiB0aGUgbWVzaCBleHRyYXMuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbWVzaC5leHRyYXMpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc2guZXh0cmFzID0ge307XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgbWVzaC5leHRyYXMudGFyZ2V0TmFtZXMgPSBbXTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbW9ycGhUYXJnZXRNYW5hZ2VyLm51bVRhcmdldHM7ICsraSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGFyZ2V0ID0gbW9ycGhUYXJnZXRNYW5hZ2VyLmdldFRhcmdldChpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldE1vcnBoVGFyZ2V0QXR0cmlidXRlcyhzdWJtZXNoLCBtZXNoUHJpbWl0aXZlLCB0YXJnZXQsIGJpbmFyeVdyaXRlcik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNoLmV4dHJhcy50YXJnZXROYW1lcy5wdXNoKHRhcmdldC5uYW1lKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgbWVzaC5wcmltaXRpdmVzLnB1c2gobWVzaFByaW1pdGl2ZSk7XHJcblxyXG4gICAgICAgICAgICAgICA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obm9kZU1hcCwgYmluYXJ5V3JpdGVyKS50aGVuKChza2luTWFwKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbm9kZU1hcCA9IG5vZGVNYXA7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3RvdGFsQnl0ZUxlbmd0aCA9IGJpbmFyeVdyaXRlci5nZXRCeXRlT2Zmc2V0KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3RvdGFsQnl0ZUxlbmd0aCA9PSB1bmRlZmluZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwidW5kZWZpbmVkIGJ5dGUgbGVuZ3RoIVwiKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIC8vIEJ1aWxkIEhpZXJhcmNoeSB3aXRoIHRoZSBub2RlIG1hcC5cclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGJhYnlsb25Ob2RlIG9mIG5vZGVzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGdsVEZOb2RlSW5kZXggPSB0aGlzLl9ub2RlTWFwW2JhYnlsb25Ob2RlLnVuaXF1ZUlkXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdsVEZOb2RlSW5kZXggIT09IHVuZGVmaW5lZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2xURk5vZGUgPSB0aGlzLl9ub2Rlc1tnbFRGTm9kZUluZGV4XTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmFieWxvbk5vZGUubWV0YWRhdGEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fb3B0aW9ucy5tZXRhZGF0YVNlbGVjdG9yKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdsVEZOb2RlLmV4dHJhcyA9IHRoaXMuX29wdGlvbnMubWV0YWRhdGFTZWxlY3RvcihiYWJ5bG9uTm9kZS5tZXRhZGF0YSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChiYWJ5bG9uTm9kZS5tZXRhZGF0YS5nbHRmKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdsVEZOb2RlLmV4dHJhcyA9IGJhYnlsb25Ob2RlLm1ldGFkYXRhLmdsdGYuZXh0cmFzO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmFieWxvbk5vZGUgaW5zdGFuY2VvZiBDYW1lcmEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnbFRGTm9kZS5jYW1lcmEgPSBjYW1lcmFNYXAuZ2V0KGJhYnlsb25Ob2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fb3B0aW9ucy5zaG91bGRFeHBvcnROb2RlICYmICF0aGlzLl9vcHRpb25zLnNob3VsZEV4cG9ydE5vZGUoYmFieWxvbk5vZGUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVG9vbHMuTG9nKFwiT21pdHRpbmcgXCIgKyBiYWJ5bG9uTm9kZS5uYW1lICsgXCIgZnJvbSBzY2VuZS5cIik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghYmFieWxvbk5vZGUucGFyZW50ICYmICF0aGlzLl9iYWJ5bG9uU2NlbmUudXNlUmlnaHRIYW5kZWRTeXN0ZW0pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udmVydE5vZGVIYW5kZWRuZXNzKGdsVEZOb2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghYmFieWxvbk5vZGUucGFyZW50IHx8IHJlbW92ZWRSb290Tm9kZXMuaGFzKGJhYnlsb25Ob2RlLnBhcmVudCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NlbmUubm9kZXMucHVzaChnbFRGTm9kZUluZGV4KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJhYnlsb25Ob2RlIGluc3RhbmNlb2YgTWVzaCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYWJ5bG9uTm9kZS5za2VsZXRvbikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnbFRGTm9kZS5za2luID0gc2tpbk1hcFtiYWJ5bG9uTm9kZS5za2VsZXRvbi51bmlxdWVJZF07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcmVjdERlc2NlbmRlbnRzID0gYmFieWxvbk5vZGUuZ2V0RGVzY2VuZGFudHModHJ1ZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWdsVEZOb2RlLmNoaWxkcmVuICYmIGRpcmVjdERlc2NlbmRlbnRzICYmIGRpcmVjdERlc2NlbmRlbnRzLmxlbmd0aCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkcmVuOiBudW1iZXJbXSA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZGVzY2VuZGVudCBvZiBkaXJlY3REZXNjZW5kZW50cykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fbm9kZU1hcFtkZXNjZW5kZW50LnVuaXF1ZUlkXSAhPSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZHJlbi5wdXNoKHRoaXMuX25vZGVNYXBbZGVzY2VuZGVudC51bmlxdWVJZF0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZHJlbi5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2xURk5vZGUuY2hpbGRyZW4gPSBjaGlsZHJlbjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNjZW5lLm5vZGVzLmxlbmd0aCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zY2VuZXMucHVzaChzY2VuZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogR2V0dGluZyB0aGUgbm9kZXMgYW5kIG1hdGVyaWFscyB0aGF0IHdvdWxkIGJlIGV4cG9ydGVkLlxyXG4gICAgICogQHBhcmFtIG5vZGVzIEJhYnlsb24gdHJh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KGNvbnN0IHN1Yk1hdGVyaWFsIG9mIG1hdGVyaWFsLnN1Yk1hdGVyaWFscykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN1Yk1hdGVyaWFsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhwb3J0TWF0ZXJpYWxzLmFkZChzdWJNYXRlcmlhbCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBleHBvcnRNYXRlcmlhbHMuYWRkKG1hdGVyaWFsKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBgRXhjbHVkaW5nIG5vZGUgJHtiYWJ5bG9uTm9kZS5uYW1lfWA7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBbZXhwb3J0Tm9kZXMsIGV4cG9ydE1hdGVyaWFsc107XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBDcmVhdGVzIGEgbWFwcGluZyBvZiBOb2RlIHVuaXF1ZSBpZCB0byBub2RlIGluZGV4IGFuZCBoYW5kbGVzIGFuaW1hdGlvbnNcclxuICAgICAqIEBwYXJhbSBub2RlcyBCYWJ5bG9uIHRyYW5zZm9ybSBub2Rlc1xyXG4gICAgICogQHBhcmFtIGJpbmFyeVdyaXRlciBCdWZmZXIgdG8gd3JpdGUgYmluYXJ5IGRhdGEgdG9cclxuICAgICAqIEByZXR1cm5zIE5vZGUgbWFwcGluZyBvZiB1bmlxdWUgaWQgdG8gaW5kZXhcclxuICAgICAqL1xyXG4gICAgcHJpdmF0ZSBfY3JlYXRlTm9kZU1hcEFuZEFuaW1hdGlvbnNBc3luYyhub2RlczogTm9kZVtdLCBiaW5hcnlXcml0ZXI6IF9CaW5hcnlXcml0ZXIpOiBQcm9taXNlPHsgW2tleTogbnVtYmVyXTogbnVtYmVyIH0+IHtcclxuICAgICAgICBsZXQgcHJvbWlzZUNoYWluID0gUHJvbWlzZS5yZXNvbHZlKCk7XHJcbiAgICAgICAgY29uc3Qgbm9kZU1hcDogeyBba2V5OiBudW1iZXJdOiBudW1iZXIgfSA9IHt9O1xyXG4gICAgICAgIGxldCBub2RlSW5kZXg6IG51bWJlcjtcclxuICAgICAgICBjb25zdCBydW50aW1lR0xURkFuaW1hdGlvbjogSUFuaW1hdGlvbiA9IHtcclxuICAgICAgICAgICAgbmFtZTogXCJydW50aW1lIGFuaW1hdGlvbnNcIixcclxuICAgICAgICAgICAgY2hhbm5lbHM6IFtdLFxyXG4gICAgICAgICAgICBzYW1wbGVyczogW10sXHJcbiAgICAgICAgfTtcclxuICAgICAgICBjb25zdCBpZGxlR0xURkFuaW1hdGlvbnM6IElBbmltYXRpb25bXSA9IFtdO1xyXG5cclxuICAgICAgICBmb3IgKGNvbnN0IGJhYnlsb25Ob2RlIG9mIG5vZGVzKSB7XHJcbiAgICAgICAgICAgIHByb21pc2VDaGFpbiA9IHByb21pc2VDaGFpbi50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9jcmVhdGVOb2RlQXN5bmMoYmFieWxvbk5vZGUsIGJpbmFyeVdyaXRlcikudGhlbigobm9kZSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHByb21pc2UgPSB0aGlzLl9leHRlbnNpb25zUG9zdEV4cG9ydE5vZGVBc3luYyhcImNyZWF0ZU5vZGVBc3luY1wiLCBub2RlLCBiYWJ5bG9uTm9kZSwgbm9kZU1hcCwgYmluYXJ5V3JpdGVyKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAocHJvbWlzZSA9PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIFRvb2xzLldhcm4oYE5vdCBleHBvcnRpbmcgbm9kZSAke2JhYnlsb25Ob2RlLm5hbWV9YCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlc29sdmUoKTtcclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcHJvbWlzZS50aGVuKChub2RlKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW5vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9ub2Rlcy5wdXNoKG5vZGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZUluZGV4ID0gdGhpcy5fbm9kZXMubGVuZ3RoIC0gMTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGVNYXBbYmFieWxvbk5vZGUudW5pcXVlSWRdID0gbm9kZUluZGV4O1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fYmFieWxvblNjZW5lLmFuaW1hdGlvbkdyb3Vwcy5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfR0xURkFuaW1hdGlvbi5fQ3JlYXRlTW9ycGhUYXJnZXRBbmltYXRpb25Gcm9tTW9ycGhUYXJnZXRBbmltYXRpb25zKFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uTm9kZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVudGltZUdMVEZBbmltYXRpb24sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkbGVHTFRGQW5pbWF0aW9ucyxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZU1hcCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbm9kZXMsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJpbmFyeVdyaXRlcixcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYnVmZmVyVmlld3MsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2FjY2Vzc29ycyxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYW5pbWF0aW9uU2FtcGxlUmF0ZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb3B0aW9ucy5zaG91bGRFeHBvcnRBbmltYXRpb25cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYWJ5bG9uTm9kZS5hbmltYXRpb25zLmxlbmd0aCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfR0xURkFuaW1hdGlvbi5fQ3JlYXRlTm9kZUFuaW1hdGlvbkZyb21Ob2RlQW5pbWF0aW9ucyhcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25Ob2RlLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVudGltZUdMVEZBbmltYXRpb24sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGxlR0xURkFuaW1hdGlvbnMsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlTWFwLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbm9kZXMsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiaW5hcnlXcml0ZXIsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9idWZmZXJWaWV3cyxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2FjY2Vzc29ycyxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2FuaW1hdGlvblNhbXBsZVJhdGUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9vcHRpb25zLnNob3VsZEV4cG9ydEFuaW1hdGlvblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgcmV0dXJuIHByb21pc2VDaGFpbi50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgaWYgKHJ1bnRpbWVHTFRGQW5pbWF0aW9uLmNoYW5uZWxzLmxlbmd0aCAmJiBydW50aW1lR0xURkFuaW1hdGlvbi5zYW1wbGVycy5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgIHRoaXMuX2FuaW1hdGlvbnMucHVzaChydW50aW1lR0xURkFuaW1hdGlvbik7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWRsZUdMVEZBbmltYXRpb25zLmZvckVhY2goKGlkbGVHTFRGQW5pbWF0aW9uKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBpZiAoaWRsZUdMVEZBbmltYXRpb24uY2hhbm5lbHMubGVuZ3RoICYmIGlkbGVHTFRGQW5pbWF0aW9uLnNhbXBsZXJzLmxlbmd0aCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2FuaW1hdGlvbnMucHVzaChpZGxlR0xURkFuaW1hdGlvbik7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICAgICAgaWYgKHRoaXMuX2JhYnlsb25TY2VuZS5hbmltYXRpb25Hcm91cHMubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICBfR0xURkFuaW1hdGlvbi5fQ3JlYXRlTm9kZUFuZE1vcnBoQW5pbWF0aW9uRnJvbUFuaW1hdGlvbkdyb3VwcyhcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9iYWJ5bG9uU2NlbmUsXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fYW5pbWF0aW9ucyxcclxuICAgICAgICAgICAgICAgICAgICBub2RlTWFwLFxyXG4gICAgICAgICAgICAgICAgICAgIGJpbmFyeVdyaXRlcixcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9idWZmZXJWaWV3cyxcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9hY2Nlc3NvcnMsXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fYW5pbWF0aW9uU2FtcGxlUmF0ZSxcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9vcHRpb25zLnNob3VsZEV4cG9ydEFuaW1hdGlvblxyXG4gICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgcmV0dXJuIG5vZGVNYXA7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBDcmVhdGVzIGEgZ2xURiBub2RlIGZyb20gYSBCYWJ5bG9uIG1lc2hcclxuICAgICAqIEBwYXJhbSBiYWJ5bG9uTm9kZSBTb3VyY2UgQmFieWxvbiBtZXNoXHJcbiAgICAgKiBAcGFyYW0gYmluYXJ5V3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hUYXJnZXRNYW5hZ2VyO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChtb3JwaFRhcmdldE1hbmFnZXIgJiYgbW9ycGhUYXJnZXRNYW5hZ2VyLm51bVRhcmdldHMgPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG1lc2gud2VpZ2h0cyA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG1vcnBoVGFyZ2V0TWFuYWdlci5udW1UYXJnZXRzOyArK2kpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc2gud2VpZ2h0cy5wdXNoKG1vcnBoVGFyZ2V0TWFuYWdlci5nZXRUYXJnZXQoaSkuaW5mbHVlbmNlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9zZXRQcmltaXRpdmVBdHRyaWJ1dGVzQXN5bmMobWVzaCwgYmFieWxvbk5vZGUsIGJpbmFyeVdyaXRlcikudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKG1lc2gucHJpbWl0aXZlcy5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbWVzaGVzLnB1c2gobWVzaCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUubWVzaCA9IHRoaXMuX21lc2hlcy5sZW5ndGggLSAxO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gbm9kZTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGJhYnlsb25Ob2RlIGluc3RhbmNlb2YgQ2FtZXJhKSB7XHJcbiAgICAgICAgICAgICAgICB0aGlzLl9zZXRDYW1lcmFUcmFuc2Zvcm1hdGlvbihub2RlLCBiYWJ5bG9uTm9kZSk7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gbm9kZTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBub2RlO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBDcmVhdGVzIGEgZ2xURiBza2luIGZyb20gYSBCYWJ5bG9uIHNrZWxldG9uXHJcbiAgICAgKiBAcGFyYW0gbm9kZU1hcCBCYWJ5bG9uIHRyYW5zZm9ybSBub2Rlc1xyXG4gICAgICogQHBhcmFtIGJpbmFyeVdyaXRlciBCdWZmZXIgdG8gd3JpdGUgYmluYXJ5IGRhdGEgdG9cclxuICAgICAqIEByZXR1cm5zIE5vZGUgbWFwcGluZyBvZiB1bmlxdWUgaWQgdG8gaW5kZXhcclxuICAgICAqL1xyXG4gICAgcHJpdmF0ZSBfY3JlYXRlU2tpbnNBc3luYyhub2RlTWFwOiB7IFtrZXk6IG51bWJlcl06IG51bWJlciB9LCBiaW5hcnlXcml0ZXI6IF9CaW5hcnlXcml0ZXIpOiBQcm9taXNlPHsgW2tleTogbnVtYmVyXTogbnVtYmVyIH0+IHtcclxuICAgICAgICBjb25zdCBwcm9taXNlQ2hhaW4gPSBQcm9taXNlLnJlc29sdmUoKTtcclxuICAgICAgICBjb25zdCBza2luTWFwOiB7IFtrZXk6IG51bWJlcl06IG51bWJlciB9ID0ge307XHJcbiAgICAgICAgZm9yIChjb25zdCBza2VsZXRvbiBvZiB0aGlzLl9iYWJ5bG9uU2NlbmUuc2tlbGV0b25zKSB7XHJcbiAgICAgICAgICAgIGlmIChza2VsZXRvbi5ib25lcy5sZW5ndGggPD0gMCkge1xyXG4gICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgLy8gY3JlYXRlIHNraW5cclxuICAgICAgICAgICAgY29uc3Qgc2tpbjogSVNraW4gPSB7IGpvaW50czogW10gfTtcclxuICAgICAgICAgICAgY29uc3QgaW52ZXJzZUJpbmRNYXRyaWNlczogTWF0cml4W10gPSBbXTtcclxuXHJcbiAgICAgICAgICAgIGNvbnN0IGJvbmVJbmRleE1hcDogeyBbaW5kZXg6IG51bWJlcl06IEJvbmUgfSA9IHt9O1xyXG4gICAgICAgICAgICBsZXQgbWF4Qm9uZUluZGV4ID0gLTE7XHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc2tlbGV0b24uYm9uZXMubGVuZ3RoOyArK2kpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGJvbmUgPSBza2VsZXRvbi5ib25lc1tpXTtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGJvbmVJbmRleCA9IGJvbmUuZ2V0SW5kZXgoKSA/PyBpO1xyXG4gICAgICAgICAgICAgICAgaWYgKGJvbmVJbmRleCAhPT0gLTEpIHtcclxuICAgICAgICAgICAgICAgICAgICBib25lSW5kZXhNYXBbYm9uZUluZGV4XSA9IGJvbmU7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGJvbmVJbmRleCA+IG1heEJvbmVJbmRleCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBtYXhCb25lSW5kZXggPSBib25lSW5kZXg7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBmb3IgKGxldCBib25lSW5kZXggPSAwOyBib25lSW5kZXggPD0gbWF4Qm9uZUluZGV4OyArK2JvbmVJbmRleCkge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgYm9uZSA9IGJvbmVJbmRleE1hcFtib25lSW5kZXhdO1xyXG4gICAgICAgICAgICAgICAgaW52ZXJzZUJpbmRNYXRyaWNlcy5wdXNoKGJvbmUuZ2V0SW52ZXJ0ZWRBYnNvbHV0ZVRyYW5zZm9ybSgpK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VmlldyA9IF9HTFRGVXRpbGl0aWVzLl9DcmVhdGVCdWZmZXJWaWV3KDAsIGJ1ZmZlclZpZXdPZmZzZXQsIGJ5dGVMZW5ndGgsIHVuZGVmaW5lZCwgXCJJbnZlcnNlQmluZE1hdHJpY2VzXCIgKyBcIiAtIFwiICsgc2tlbGV0b24ubmFtZSk7XHJcbiAgICAgICAgICAgICAgICB0aGlzLl9idWZmZXJWaWV3cy5wdXNoKGJ1ZmZlclZpZXcpO1xyXG4gICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyVmlld0luZGV4ID0gdGhpcy5fYnVmZmVyVmlld3MubGVuZ3RoIC0gMTtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGJpbmRNYXRyaXhBY2Nlc3NvciA9IF9HTFRGVXRpbGl0aWVzLl9DcmVhdGVBY2Nlc3NvcihcclxuICAgICAgICAgICAgICAgICAgICBidWZmZXJWaWV3SW5kZXgsXHJcbiAgICAgICAgICAgICAgICAgICAgXCJJbnZlcnNlQmluZE1hdHJpY2VzXCIgKyBcIiAtIFwiICsgc2tlbGV0b24ubmFtZSxcclxuICAgICAgICAgICAgICAgICAgICBBY2Nlc3NvclR5cGUuTUFUNCxcclxuICAgICAgICAgICAgICAgICAgICBBY2Nlc3NvckNvbXBvbmVudFR5cGUuRkxPQVQsXHJcbiAgICAgICAgICAgICAgICAgICAgaW52ZXJzZUJpbmRNYXRyaWNlcy5sZW5ndGgsXHJcbiAgICAgICAgICAgICAgICAgICAgbnVsbCxcclxuICAgICAgICAgICAgICAgICAgICBudWxsLFxyXG4gICAgICAgICAgICAgICAgICAgIG51bGxcclxuICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBpbnZlcnNlQmluZEFjY2Vzc29ySW5kZXggPSB0aGlzLl9hY2Nlc3NvcnMucHVzaChiaW5kTWF0cml4QWNjZXNzb3IpIC0gMTtcclxuICAgICAgICAgICAgICAgIHNraW4uaW52ZXJzZUJpbmRNYXRyaWNlcyA9IGludmVyc2VCaW5kQWNjZXNzb3JJbmRleDtcclxuICAgICAgICAgICAgICAgIHRoaXMuX3NraW5zLnB1c2goc2tpbik7XHJcbiAgICAgICAgICAgICAgICBza2luTWFwW3NrZWxldG9uLnVuaXF1ZUlkXSA9IHRoaXMuX3NraW5zLmxlbmd0aCAtIDE7XHJcblxyXG4gICAgICAgICAgICAgICAgaW52ZXJzZUJpbmRNYXRyaWNlcy5mb3JFYWNoKChtYXQpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBtYXQubS5mb3JFYWNoKChjZWxsOiBudW1iZXIpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYmluYXJ5V3JpdGVyLnNldEZsb2F0MzIoY2VsbCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgICAgICByZXR1cm4gcHJvbWlzZUNoYWluLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICByZXR1cm4gc2tpbk1hcDtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxufVxyXG5cclxuLyoqXHJcbiAqIEBpbnRlcm5hbFxyXG4gKlxyXG4gKiBTdG9yZXMgZ2xURiBiaW5hcnkgZGF0YS4gIElmIHRoZSBhcnJheSBidWZmZXIgYnl0ZSBsZW5ndGggaXMgZXhjZWVkZWQsIGl0IGRvdWJsZXMgaW4gc2l6ZSBkeW5hbWljYWxseVxyXG4gKi9cclxuZXhwb3J0IGNsYXNzIF9CaW5hcnlXcml0ZXIge1xyXG4gICAgLyoqXHJcbiAgICAgKiBBcnJheSBidWZmZXIgd2hpY2ggc3RvcmVzIGFsbCBiaW5hcnkgZGF0YVxyXG4gICAgICovXHJcbiAgICBwcml2YXRlIF9hcnJheUJ1ZmZlcjogQXJyYXlCdWZmZXI7XHJcbiAgICAvKipcclxuICAgICAqIFZpZXcgb2YgdGhlIGFycmF5IGJ1ZmZlclxyX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hY2VDdWxsaW5nICE9IG51bGwgJiYgIWJhYnlsb25TdGFuZGFyZE1hdGVyaWFsLmJhY2tGYWNlQ3VsbGluZykge1xyXG4gICAgICAgICAgICBpZiAoIWJhYnlsb25TdGFuZGFyZE1hdGVyaWFsLnR3b1NpZGVkTGlnaHRpbmcpIHtcclxuICAgICAgICAgICAgICAgIFRvb2xzLldhcm4oYmFieWxvblN0YW5kYXJkTWF0ZXJpYWwubmFtZSArIFwiOiBCYWNrLWZhY2UgY3VsbGluZyBkaXNhYmxlZCBhbmQgdHdvLXNpZGVkIGxpZ2h0aW5nIGRpc2FibGVkIGlzIG5vdCBzdXBwb3J0ZWQgaW4gZ2xURi5cIik7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgbWF0ZXJpYWwuZG91YmxlU2lkZWQgPSB0cnVlO1xyXG4gICAgICAgIH1cclxuICAgICAgICBpZiAoaGFzVGV4dHVyZUNvb3Jkcykge1xyXG4gICAgICAgICAgICBpZiAoYmFieWxvblN0YW5kYXJkTWF0ZXJpYWwuZGlmZnVzZVRleHR1cmUpIHtcclxuICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2goXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZXhwb3J0VGV4dHVyZUFzeW5jKGJhYnlsb25TdGFuZGFyZE1hdGVyaWFsLmRpZmZ1c2VUZXh0dXJlLCBtaW1lVHlwZSkudGhlbigodGV4dHVyZUluZm8pID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRleHR1cmVJbmZvKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYnJNZXRhbGxpY1JvdWdobmVzcy5iYXNlQ29sb3JUZXh0dXJlID0gdGV4dHVyZUluZm87XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjb25zdCBidW1wVGV4dHVyZSA9IGJhYnlsb25TdGFuZGFyZE1hdGVyaWFsLmJ1bXBUZXh0dXJlO1xyXG4gICAgICAgICAgICBpZiAoYnVtcFRleHR1cmUpIHtcclxuICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2goXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZXhwb3J0VGV4dHVyZUFzeW5jKGJ1bXBUZXh0dXJlLCBtaW1lVHlwZSkudGhlbigodGV4dHVyZUluZm8pID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRleHR1cmVJbmZvKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXRlcmlhbC5ub3JtYWxUZXh0dXJlID0gdGV4dHVyZUluZm87XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYnVtcFRleHR1cmUubGV2ZWwgIT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXRlcmlhbC5ub3JtYWxUZXh0dXJlLnNjYWxlID0gYnVtcFRleHR1cmUubGV2ZWw7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoYmFieWxvblN0YW5kYXJkTWF0ZXJpYWwuZW1pc3NpdmVUZXh0dXJlKSB7XHJcbiAgICAgICAgICAgICAgICBtYXRlcmlhbC5lbWlzc2l2ZUZhY3RvciA9IFsxLjAsIDEuMCwgMS4wXTtcclxuXHJcbiAgICAgICAgICAgICAgICBwcm9taXNlcy5wdXNoKFxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2V4cG9ydFRleHR1cmVBc3luYyhiYWJ5bG9uU3RhbmRhcmRNYXRlcmlhbC5lbWlzc2l2ZVRleHR1cmUsIG1pbWVUeXBlKS50aGVuKCh0ZXh0dXJlSW5mbykgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGV4dHVyZUluZm8pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hdGVyaWFsLmVtaXNzaXZlVGV4dHVyZSA9IHRleHR1cmVJbmZvO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKGJhYnlsb25TdGFuZGFyZE1hdGVyaWFsLmFtYmllbnRUZXh0dXJlKSB7XHJcbiAgICAgICAgICAgICAgICBwcm9taXNlcy5wdXNoKFxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2V4cG9ydFRleHR1cmVBc3luYyhiYWJ5bG9uU3RhbmRhcmRNYXRlcmlhbC5hbWJpZW50VGV4dHVyZSwgbWltZVR5cGUpLnRoZW4oKHRleHR1cmVJbmZvKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0dXJlSW5mbykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2NjbHVzaW9uVGV4dHVyZTogSU1hdGVyaWFsT2NjbHVzaW9uVGV4dHVyZUluZm8gPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXg6IHRleHR1cmVJbmZvLmluZGV4LFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hdGVyaWFsLm9jY2x1c2lvblRleHR1cmUgPSBvY2NsdXNpb25UZXh0dXJlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGlmICh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2tzID0gW107XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB0YXNrcy5wdXNoKHRoaXMuX2V4cG9ydFRleHR1cmVBc3luYyh0ZXh0dXJlLCBtaW1lVHlwZSkpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAoIXRhc2tzKSB7XHJcbiAgICAgICAgICAgICAgICB0YXNrcyA9IFtQcm9taXNlLnJlc29sdmUobnVsbCldO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5hbGwodGFza3MpLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgZXh0ZW5zaW9uV29yayA9IHRoaXMuX2V4cG9ydGVyLl9leHRlbnNpb25zUG9zdEV4cG9ydE1hdGVyaWFsQXN5bmMoXCJleHBvcnRNYXRlcmlhbFwiLCBnbFRGTWF0ZXJpYWwsIGJhYnlsb25NYXRlcmlhbCk7XHJcbiAgICAgICAgICAgICAgICBpZiAoIWV4dGVuc2lvbldvcmspIHtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZ2xURk1hdGVyaWFsO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGV4dGVuc2lvbldvcmsudGhlbigoKSA9PiBnbFRGTWF0ZXJpYWwpO1xyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIENvbnZlcnRzIGFuIGltYWdlIHR5cGVkIGFycmF5IGJ1ZmZlciB0byBhIGJhc2U2NCBpbWFnZVxyXG4gICAgICogQHBhcmFtIGJ1ZmZlciB0eXBlZCBhcnJheSBidWZmZXJcclxuICAgICAqIEBwYXJhbSB3aWR0aCB3aWR0aCBvZiB0aGUgaW1hZ2VcclxuICAgICAqIEBwYXJhbSBoZWlnaHQgaGVpZ2h0IG9mIHRoZSBpbWFnZV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wgc3BlY3VsYXJHbG9zc2luZXNzQnVmZmVyW29mZnNldCArIDJdKVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAudG9MaW5lYXJTcGFjZShzY2VuZS5nZXRFbmdpbmUoKS51c2VFeGFjdFNyZ2JDb252ZXJzaW9ucylcclxuICAgICAgICAgICAgICAgICAgICAgICAgLm11bHRpcGx5KGZhY3RvcnMuc3BlY3VsYXJDb2xvcik7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2xvc3NpbmVzcyA9IHNwZWN1bGFyR2xvc3NpbmVzc0J1ZmZlcltvZmZzZXQgKyAzXSAqIGZhY3RvcnMuZ2xvc3NpbmVzcztcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BlY3VsYXJHbG9zc2luZXNzOiBfSVBCUlNwZWN1bGFyR2xvc3NpbmVzcyA9IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZGlmZnVzZUNvbG9yOiBkaWZmdXNlQ29sb3IsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNwZWN1bGFyQ29sb3I6IHNwZWN1bGFyQ29sb3IsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGdsb3NzaW5lc3M6IGdsb3NzaW5lc3MsXHJcbiAgICAgICAgICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbWV0YWxsaWNSb3VnaG5lc3MgPSB0aGlzLl9jb252ZXJ0U3BlY3VsYXJHbG9zc2luZXNzVG9NZXRhbGxpY1JvdWdobmVzcyhzcGVjdWxhckdsb3NzaW5lc3MpO1xyXG4gICAgICAgICAgICAgICAgICAgIG1heEJhc2VDb2xvci5yID0gTWF0aC5tYXgobWF4QmFzZUNvbG9yLnIsIG1ldGFsbGljUm91Z2huZXNzLmJhc2VDb2xvci5yKTtcclxuICAgICAgICAgICAgICAgICAgICBtYXhCYXNlQ29sb3IuZyA9IE1hdGgubWF4KG1heEJhc2VDb2xvci5nLCBtZXR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VR5cGUpLnRoZW4oKGRhdGEpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbWV0YWxsaWNSb3VnaG5lc3NGYWN0b3JzLm1ldGFsbGljUm91Z2huZXNzVGV4dHVyZURhdGEgPSBkYXRhO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmICh3cml0ZU91dEJhc2VDb2xvclRleHR1cmUpIHtcclxuICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2goXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZ2V0SW1hZ2VEYXRhQXN5bmMoYmFzZUNvbG9yQnVmZmVyLCB3aWR0aCwgaGVpZ2h0LCBtaW1lVHlwZSkudGhlbigoZGF0YSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBtZXRhbGxpY1JvdWdobmVzc0ZhY3RvcnMuYmFzZUNvbG9yVGV4dHVyZURhdGEgPSBkYXRhO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5hbGwocHJvbWlzZXMpLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIG1ldGFsbGljUm91Z2huZXNzRmFjdG9ycztcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgcmV0dXJuIFByb21pc2UucmVqZWN0KFwiX0NvbnZlcnRTcGVjdWxhckdsb3NzaW5lc3NUZXh0dXJlc1RvTWV0YWxsaWNSb3VnaG5lc3M6IFNjZW5lIGZyb20gdGV4dHVyZXMgaXMgbWlzc2luZyFcIik7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQ29udmVydHMgc3BlY3VsYXIg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biAgICAgICAgbWltZVR5cGU6IEltYWdlTWltZVR5cGUsXHJcbiAgICAgICAgZ2xURlBick1ldGFsbGljUm91Z2huZXNzOiBJTWF0ZXJpYWxQYnJNZXRhbGxpY1JvdWdobmVzcyxcclxuICAgICAgICBoYXNUZXh0dXJlQ29vcmRzOiBib29sZWFuXHJcbiAgICApOiBQcm9taXNlPF9JUEJSTWV0YWxsaWNSb3VnaG5lc3M+IHtcclxuICAgICAgICBjb25zdCBwcm9taXNlcyA9IFtdO1xyXG4gICAgICAgIGNvbnN0IGJhc2VDb2xvciA9IGJhYnlsb25QQlJNYXRlcmlhbC5fYWxiZWRvQ29sb3I7XHJcbiAgICAgICAgY29uc3QgbWV0YWxsaWMgPSBiYWJ5bG9uUEJSTWF0ZXJpYWwuX21ldGFsbGljO1xyXG4gICAgICAgIGNvbnN0IHJvdWdobmVzcyA9IGJhYnlsb25QQlJNYXRlcmlhbC5fcm91Z2huZXNzO1xyXG4gICAgICAgIGNvbnN0IG1ldGFsbGljUm91Z2huZXNzOiBfSVBCUk1ldGFsbGljUm91Z2huZXNzID0ge1xyXG4gICAgICAgICAgICBiYXNlQ29sb3I6IGJhc2VDb2xvcixcclxuICAgICAgICAgICAgbWV0YWxsaWM6IG1ldGFsbGljLFxyXG4gICAgICAgICAgICByb3VnaG5lc3M6IHJvdWdobmVzcyxcclxuICAgICAgICB9O1xyXG5cclxuICAgICAgICBpZiAoaGFzVGV4dHVyZUNvb3Jkcykge1xyXG4gICAgICAgICAgICBjb25zdCBhbGJlZG9UZXh0dXJlID0gYmFieWxvblBCUk1hdGVyaWFsLl9hbGJlZG9UZXh0dXJlO1xyXG4gICAgICAgICAgICBpZiAoYWxiZWRvVGV4dHVyZSkge1xyXG4gICAgICAgICAgICAgICAgcHJvbWlzZXMucHVzaChcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9leHBvcnRUZXh0dXJlQXN5bmMoYmFieWxvblBCUk1hdGVyaWFsLl9hbGJlZG9UZXh0dXJlISwgbWltZVR5cGUpLnRoZW4oKGdsVEZUZXh0dXJlKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChnbFRGVGV4dHVyZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2xURlBick1ldGFsbGljUm91Z2huZXNzLmJhc2VDb2xvclRleHR1cmUgPSBnbFRGVGV4dHVyZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNvbnN0IG1ldGFsbGljVGV4dHVyZSA9IGJhYnlsb25QQlJNYXRlcmlhbC5fbWV0YWxsaWNUZXh0dXJlO1xyXG4gICAgICAgICAgICBpZiAobWV0YWxsaWNUZXh0dXJlKSB7XHJcbiAgICAgICAgICAgICAgICBwcm9taXNlcy5wdXNoKFxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2V4cG9ydFRleHR1cmVBc3luYyhtZXRhbGxpY1RleHR1cmUsIG1pbWVUeXBlKS50aGVuKChnbFRGVGV4dHVyZSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2xURlRleHR1cmUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdsVEZQYnJNZXRhbGxpY1JvdWdobmVzcy5tZXRhbGxpY1JvdWdobmVzc1RleHR1cmUgPSBnbFRGVGV4dHVyZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgIHJldHVybiBtZXRhbGxpY1JvdWdobmVzcztcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuX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ICAgICAgICAgICBjYXNlIFRleHR1cmUuTElORUFSX05FQVJFU1Q6IHtcclxuICAgICAgICAgICAgICAgIHNhbXBsZXIubWFnRmlsdGVyID0gVGV4dHVyZU1hZ0ZpbHRlci5MSU5FQVI7XHJcbiAgICAgICAgICAgICAgICBzYW1wbGVyLm1pbkZpbHRlciA9IFRleHR1cmVNaW5GaWx0ZXIuTkVBUkVTVDtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgVGV4dHVyZS5ORUFSRVNUX0xJTkVBUjoge1xyXG4gICAgICAgICAgICAgICAgc2FtcGxlci5tYWdGaWx0ZXIgPSBUZXh0dXJlTWFnRmlsdGVyLk5FQVJFU1Q7XHJcbiAgICAgICAgICAgICAgICBzYW1wbGVyLm1pbkZpbHRlciA9IFRleHR1cmVNaW5GaWx0ZXIuTElORUFSO1xyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY2FzZSBUZXh0dXJlLk5FQVJFU1RfTElORUFSX01JUExJTkVBUjoge1xyXG4gICAgICAgICAgICAgICAgc2FtcGxlci5tYWdGaWx0ZXIgPSBUZXh0dXJlTWFnRmlsdGVyLk5FQVJFU1Q7XHJcbiAgICAgICAgICAgICAgICBzYW1wbGVyLm1pbkZpbHRlciA9IFRleHR1cmVNaW5GaWx0ZXIuTElORUFSX01JUE1BUF9MSU5FQVI7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIFRleHR1cmUuTkVBUkVTVF9ORUFSRVNUOiB7XHJcbiAgICAgICAgICAgICAgICBzYW1wbGVyLm1hZ0ZpbHRlciA9IFRleHR1cmVNYWdGaWx0ZXIuTkVBUkVTVDtcclxuICAgICAgICAgICAgICAgIHNhbXBsZXIubWluRmlsdGVyID0gVGV4dHVyZU1pbkZpbHRlci5ORUFSRVNUO1xyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY2FzZSBUZXh0dXJlLk5FQVJFU1RfTElORUFSX01JUE5FQVJFU1Q6IHtcclxuICAgICAgICAgICAgICAgIHNhbXBsZXIubWFnRmlsdGVyID0gVGV4dHVyZU1hZ0ZpbHRlci5ORUFSRVNUO1xyXG4gICAgICAgICAgICAgICAgc2FtcGxlci5taW5GaWx0ZXIgPSBUZXh0dXJlTWluRmlsdGVyLkxJTkVBUl9NSVBNQVBfTkVBUkVTVDtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgVGV4dHVyZS5MSU5FQVJfTkVBUkVTVF9NSVBORUFSRVNUOiB7XHJcbiAgICAgICAgICAgICAgICBzYW1wbGVyLm1hZ0ZpbHRlciA9IFRleHR1cmVNYWdGaWx0ZXIuTElORUFSO1xyXG4gICAgICAgICAgICAgICAgc2FtcGxlci5taW5GaWx0ZXIgPSBUZXh0dXJlTWluRmlsdGVyLk5FQVJFU1RfTUlQTUFQX05FQVJFU1Q7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIFRleHR1cmUuTElORUFSX05FQVJFU1RfTUlQTElORUFSOiB7XHJcbiAgICAgICAgICAgICAgICBzYW1wbGVyLm1hZ0ZpbHRlciA9IFRleHR1cmVNYWdGaWx0ZXIuTElORUFSO1xyXG4gICAgICAgICAgICAgICAgc2FtcGxlci5taW5GaWx0ZXIgPSBUZXh0dXJlTWluRmlsdGVyLk5FQVJFU1RfTUlQTUFQX0xJTkVBUjtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgVGV4dHVyZS5ORUFSRVNUX05FQVJFU1RfTUlQTElORUFSOiB7XHJcbiAgICAgICAgICAgICAgICBzYW1wbGVyLm1hZ0ZpbHRlciA9IFRleHR1cmVNYWdGaWx0ZXIuTkVBUkVTVDtcclxuICAgICAgICAgICAgICAgIHNhbXBsZXIubWluRmlsdGVyID0gVGV4dHVyZU1pbkZpbHRlci5ORUFSRVNUX01JUE1BUF9MSU5FQVI7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIFRleHR1cmUuTElORUFSX0xJTkVBUl9NSVBMSU5FQVI6IHtcclxuICAgICAgICAgICAgICAgIHNhbXBsZXIubWFnRmlsdGVyID0gVGV4dHVyZU1hZ0ZpbHRlci5MSU5FQVI7XHJcbiAgICAgICAgICAgICAgICBzYW1wbGVyLm1pbkZpbHRlciA9IFRleHR1cmVNaW5GaWx0ZXIuTElORUFSX01JUE1BUF9MSU5FQVI7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIFRleHR1cmUuTElORUFSX0xJTkVBUl9NSVBORUFSRVNUOiB7XHJcbiAgICAgICAgICAgICAgICBzYW1wbGVyLm1hZ0ZpbHRlciA9IFRleHR1cmVNYWdGaWx0ZXIuTElORUFSO1xyXG4gICAgICAgICAgICAgICAgc2FtcGxlci5taW5GaWx0ZXIgPSBUZXh0dXJlTWluRmlsdGVyLkxJTkVBUl9NSVBNQVBfTkVBUkVTVDtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgVGV4dHVyZS5ORUFSRVNUX05FQVJFU1RfTUlQTkVBUkVTVDoge1xyXG4gICAgICAgICAgICAgICAgc2FtcGxlci5tYWdGaWx0ZXIgPSBUZXh0dXJlTWFnRmlsdGVyLk5FQVJFU1Q7XHJcbiAgICAgICAgICAgICAgICBzYW1wbGVyLm1pbkZpbHRlciA9IFRleHR1cmVNaW5GaWx0ZXIuTkVBUkVTVF9NSVBNQVBfTkVBUkVTVDtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICByZXR1cm4gc2FtcGxlcjtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9nZXRHTFRGVGV4dHVyZVdyYXBNb2RlKHdyYXBNb2RlOiBudW1iZXIpOiBUZXh0dXJlV3JhcE1vZGUge1xyXG4gICAgICAgIHN3aXRjaCAod3JhcE1vZGUpIHtcclxuICAgICAgICAgICAgY2FzZSBUZXh0dXJlLldSQVBfQUREUkVTU01PREU6IHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBUZXh0dXJlV3JhcE1vZGUuUkVQRUFUO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgVGV4dHVyZS5DTEFNUF9BRERSRVNTTU9ERToge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIFRleHR1cmVXcmFwTW9kZS5DTEFNUF9UT19FREdFO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgVGV4dHVyZS5NSVJST1JfQUREUkVTU01PREU6IHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBUZXh0dXJlV3JhcE1vZGUuTUlSUk9SRURfUkVQRUFUO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGRlZmF1bHQ6IHtcclxuICAgICAgICAgICAgICAgIFRvb2xzLkVycm9yKGBVbnN1cHBvcnRlZCBUZXh0dXJlIFdyYXAgTW9kZSAke3dyYXBNb2RlfSFgKTtcclxuICAgICAgICAgICAgICAgIHJldHVybiBUZXh0dXJlV3JhcE1vZGUuUkVQRUFUO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQ29udmVydCBhIFBCUk1hdGVyaWFsIChTcGVjdWxhci9HbG9zc2luZXNzKSB0byBNZXRhbGxpYyBSb3VnaG5lc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ICBpZiAoYmFieWxvblBCUk1hdGVyaWFsLmJhY2tGYWNlQ3VsbGluZyAhPSBudWxsICYmICFiYWJ5bG9uUEJSTWF0ZXJpYWwuYmFja0ZhY2VDdWxsaW5nKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoIWJhYnlsb25QQlJNYXRlcmlhbC5fdHdvU2lkZWRMaWdodGluZykge1xyXG4gICAgICAgICAgICAgICAgICAgIFRvb2xzLldhcm4oYmFieWxvblBCUk1hdGVyaWFsLm5hbWUgKyBcIjogQmFjay1mYWNlIGN1bGxpbmcgZGlzYWJsZWQgYW5kIHR3by1zaWRlZCBsaWdodGluZyBkaXNhYmxlZCBpcyBub3Qgc3VwcG9ydGVkIGluIGdsVEYuXCIpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgZ2xURk1hdGVyaWFsLmRvdWJsZVNpZGVkID0gdHJ1ZTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYgKGhhc1RleHR1cmVDb29yZHMpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGJ1bXBUZXh0dXJlID0gYmFieWxvblBCUk1hdGVyaWFsLl9idW1wVGV4dHVyZTtcclxuICAgICAgICAgICAgICAgIGlmIChidW1wVGV4dHVyZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHByb21pc2UgPSB0aGlzLl9leHBvcnRUZXh0dXJlQXN5bmMoYnVtcFRleHR1cmUsIG1pbWVUeXBlKS50aGVuKChnbFRGVGV4dHVyZSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2xURlRleHR1cmUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdsVEZNYXRlcmlhbC5ub3JtYWxUZXh0dXJlID0gZ2xURlRleHR1cmU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYnVtcFRleHR1cmUubGV2ZWwgIT09IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnbFRGTWF0ZXJpYWwubm9ybWFsVGV4dHVyZS5zY2FsZSA9IGJ1bXBUZXh0dXJlLmxldmVsO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgcHJvbWlzZXMucHVzaChwcm9taXNlKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGNvbnN0IGFtYmllbnRUZXh0dXJlID0gYmFieWxvblBCUk1hdGVyaWFsLl9hbWJpZW50VGV4dHVyZTtcclxuICAgICAgICAgICAgICAgIGlmIChhbWJpZW50VGV4dHVyZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHByb21pc2UgPSB0aGlzLl9leHBvcnRUZXh0dXJlQXN5bmMoYW1iaWVudFRleHR1cmUsIG1pbWVUeXBlKS50aGVuKChnbFRGVGV4dHVyZSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2xURlRleHR1cmUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9jY2x1c2lvblRleHR1cmU6IElNYXRlcmlhbE9jY2x1c2lvblRleHR1cmVJbmZvID0ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBnbFRGVGV4dHVyZS5pbmRleCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXhDb29yZDogZ2xURlRleHR1cmUudGV4Q29vcmQsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0ZW5zaW9uczogZ2xURlRleHR1cmUuZXh0ZW5zaW9ucyxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2xURk1hdGVyaWFsLm9jY2x1c2lvblRleHR1cmUgPSBvY2NsdXNpb25UZXh0dXJlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYW1iaWVudFRleHR1cmVTdHJlbmd0aCA9IGJhYnlsb25QQlJNYXRlcmlhbC5fYW1iaWVudFRleHR1cmVTdHJlbmd0aDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhbWJpZW50VGV4dHVyZVN0cmVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2NjbHVzaW9uVGV4dHVyZS5zdHJlbmd0aCA9IGFtYmllbnRUZXh0dXJlU3RyZW5ndGg7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICBwcm9taXNlcy5wdXNoKHByb21pc2UpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgY29uc3QgZW1pc3NpdmVUZXh0dXJlID0gYmFieWxvblBCUk1hdGVyaWFsLl9lbWlzc2l2ZVRleHR1cmU7XHJcbiAgICAgICAgICAgICAgICBpZiAoZW1pc3NpdmVUZXh0dXJlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvbWlzZSA9IHRoaXMuX2V4cG9ydFRleHR1cmVBc3luYyhlbWlzc2l2ZVRleHR1cmUsIG1pbWVUeXBlKS50aGVuKChnbFRGVGV4dHVyZSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2xURlRleHR1cmUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdsVEZNYXRlcmlhbC5lbWlzc2l2ZVRleHR1cmUgPSBnbFRGVGV4dHVyZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAg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BzYW1wbGVySW5kZXggPSB0aGlzLl9leHBvcnRUZXh0dXJlU2FtcGxlcihiYWJ5bG9uVGV4dHVyZSk7XHJcblxyXG4gICAgICAgICAgICAvLyBQcmVzZXJ2ZSB0ZXh0dXJlIG1pbWUgdHlwZSBpZiBkZWZpbmVkXHJcbiAgICAgICAgICAgIGNvbnN0IHRleHR1cmVNaW1lVHlwZSA9IChiYWJ5bG9uVGV4dHVyZSBhcyBUZXh0dXJlKS5taW1lVHlwZTtcclxuICAgICAgICAgICAgaWYgKHRleHR1cmVNaW1lVHlwZSkge1xyXG4gICAgICAgICAgICAgICAgc3dpdGNoICh0ZXh0dXJlTWltZVR5cGUpIHtcclxuICAgICAgICAgICAgICAgICAgICBjYXNlIFwiaW1hZ2UvanBlZ1wiOlxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgXCJpbWFnZS9wbmdcIjpcclxuICAgICAgICAgICAgICAgICAgICBjYXNlIFwiaW1hZ2Uvd2VicFwiOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBtaW1lVHlwZSA9IHRleHR1cmVNaW1lVHlwZSBhcyBJbWFnZU1pbWVUeXBlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBUb29scy5XYXJuKGBVbnN1cHBvcnRlZCBtZWRpYSB0eXBlOiAke3RleHR1cmVNaW1lVHlwZX1gKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGNvbnN0IGludGVybmFsVGV4dHVyZVRvSW1hZ2UgPSB0aGlzLl9pbnRlcm5hbFRleHR1cmVUb0ltYWdlO1xyXG4gICAgICAgICAgICBjb25zdCBpbnRlcm5hbFRleHR1cmVVbmlxdWVJZCA9IGJhYnlsb25UZXh0dXJlLmdldEludG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JcbiAgICAgICAgfTtcclxuXHJcbiAgICAgICAgY29uc3QgaW1hZ2VzID0gdGhpcy5fZXhwb3J0ZXIuX2ltYWdlcztcclxuICAgICAgICBpbWFnZXMucHVzaCh7XHJcbiAgICAgICAgICAgIG5hbWU6IG5hbWUsXHJcbiAgICAgICAgICAgIHVyaTogZmlsZU5hbWUsXHJcbiAgICAgICAgfSk7XHJcblxyXG4gICAgICAgIHJldHVybiBpbWFnZXMubGVuZ3RoIC0gMTtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9leHBvcnRUZXh0dXJlSW5mbyhpbWFnZUluZGV4OiBudW1iZXIsIHNhbXBsZXJJbmRleDogbnVtYmVyLCBjb29yZGluYXRlc0luZGV4PzogbnVtYmVyKTogSVRleHR1cmVJbmZvIHtcclxuICAgICAgICBjb25zdCB0ZXh0dXJlcyA9IHRoaXMuX2V4cG9ydGVyLl90ZXh0dXJlcztcclxuICAgICAgICBsZXQgdGV4dHVyZUluZGV4ID0gdGV4dHVyZXMuZmluZEluZGV4KCh0KSA9PiB0LnNhbXBsZXIgPT0gc2FtcGxlckluZGV4ICYmIHQuc291cmNlID09PSBpbWFnZUluZGV4KTtcclxuICAgICAgICBpZiAodGV4dHVyZUluZGV4ID09PSAtMSkge1xyXG4gICAgICAgICAgICB0ZXh0dXJlSW5kZXggPSB0ZXh0dXJlcy5sZW5ndGg7XHJcbiAgICAgICAgICAgIHRleHR1cmVzLnB1c2goe1xyXG4gICAgICAgICAgICAgICAgc291cmNlOiBpbWFnZUluZGV4LFxyXG4gICAgICAgICAgICAgICAgc2FtcGxlcjogc2FtcGxlckluZGV4LFxyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGNvbnN0IHRleHR1cmVJbmZvOiBJVGV4dHVyZUluZm8gPSB7IGluZGV4OiB0ZXh0dXJlSW5kZXggfTtcclxuICAgICAgICBpZiAoY29vcmRpbmF0ZXNJbmRleCkge1xyXG4gICAgICAgICAgIC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ldO1xyXG4gICAgICAgIGNvbnN0IG1heCA9IFstSW5maW5pdHksIC1JbmZpbml0eSwgLUluZmluaXR5XTtcclxuICAgICAgICBjb25zdCBwb3NpdGlvblN0cmlkZVNpemUgPSAzO1xyXG4gICAgICAgIGxldCBpbmRleE9mZnNldDogbnVtYmVyO1xyXG4gICAgICAgIGxldCBwb3NpdGlvbjogVmVjdG9yMztcclxuICAgICAgICBsZXQgdmVjdG9yOiBudW1iZXJbXTtcclxuXHJcbiAgICAgICAgaWYgKHZlcnRleENvdW50KSB7XHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSB2ZXJ0ZXhTdGFydCwgbGVuZ3RoID0gdmVydGV4U3RhcnQgKyB2ZXJ0ZXhDb3VudDsgaSA8IGxlbmd0aDsgKytpKSB7XHJcbiAgICAgICAgICAgICAgICBpbmRleE9mZnNldCA9IHBvc2l0aW9uU3RyaWRlU2l6ZSAqIGk7XHJcblxyXG4gICAgICAgICAgICAgICAgcG9zaXRpb24gPSBWZWN0b3IzLkZyb21BcnJheShwb3NpdGlvbnMsIGluZGV4T2Zmc2V0KTtcclxuICAgICAgICAgICAgICAgIHZlY3RvciA9IHBvc2l0aW9uLmFzQXJyYXkoKTtcclxuXHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IHBvc2l0aW9uU3RyaWRlU2l6ZTsgKytqKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbnVtID0gdmVjdG9yW2pdO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChudW0gPCBtaW5bal0pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbWluW2pdID0gbnVtO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBpZiAobnVtID4gbWF4W2pdKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG1heFtqXSA9IG51bTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgKytpbmRleE9mZnNldDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgICAgICByZXR1cm4geyBtaW4sIG1heCB9O1xyXG4gICAgfVxyXG5cclxuICAgIHB1YmxpYyBzdGF0aWMgX05vcm1hbGl6ZVRhbmdlbnRGcm9tUmVmKHRhbmdlbnQ6IFZlY3RvcjQpIHtcclxuICAgICAgICBjb25zdCBsZW5ndGggPSBNYXRoLnNxcnQodGFuZ2VudC54ICogdGFuZ2VudC54ICsgdGFuZ2VudC55ICogdGFuZ2VudC55ICsgdGFuZ2VudC56ICogdGFuZ2VudC56KTtcclxuICAgICAgICBpZiAobGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICB0YW5nZW50LnggLz0gbGVuZ3RoO1xyXG4gICAgICAgICAgICB0YW5nZW50LnkgLz0gbGVuZ3RoO1xyXG4gICAgICAgICAgICB0YW5nZW50LnogLz0gbGVuZ3RoO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICBwdWJsaWMgc3RhdGljIF9HZXREYXRhQWNjZXNzb3JFbGVtZW50Q291bnQoYWNjZXNzb3JUeXBlOiBBY2Nlc3NvclR5cGUpIHtcclxuICAgICAgICBzd2l0Y2ggKGFjY2Vzc29yVHlwZSkge1xyXG4gICAgICAgICAgICBjYXNlIEFjY2Vzc29yVHlwZS5NQVQyOlxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIDQ7XHJcbiAgICAgICAgICAgIGNhc2UgQWNjZXNzb3JUeXBlLk1BVDM6XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gOTtcclxuICAgICAgICAgICAgY2FzZSBBY2Nlc3NvclR5cGUuTUFUNDpcclxuICAgICAgICAgICAgICAgIHJldHVybiAxNjtcclxuICAgICAgICAgICAgY2FzZSBBY2Nlc3NvclR5cGUuU0NBTEFSOlxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIDE7XHJcbiAgICAgICAgICAgIGNh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ZmF1bHQgc2VyaWFsaXplcnM7XHJcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ== \ No newline at end of file diff --git a/libs/babylonjs/6.46.0/babylon.glTF2Serializer.min.js b/libs/babylonjs/6.46.0/babylon.glTF2Serializer.min.js new file mode 100644 index 00000000..1f5b8f73 --- /dev/null +++ b/libs/babylonjs/6.46.0/babylon.glTF2Serializer.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={597:t=>{t.exports=e}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{n.d(a,{default:()=>ne});var e={};n.r(e),n.d(e,{__IGLTFExporterExtension:()=>u});var t={};n.r(t),n.d(t,{GLTFData:()=>l});var r={};n.r(r),n.d(r,{GLTF2Export:()=>A});var i={};n.r(i),n.d(i,{EXT_mesh_gpu_instancing:()=>Y,KHR_lights_punctual:()=>w,KHR_materials_anisotropy:()=>B,KHR_materials_clearcoat:()=>V,KHR_materials_dispersion:()=>q,KHR_materials_emissive_strength:()=>Z,KHR_materials_ior:()=>k,KHR_materials_iridescence:()=>S,KHR_materials_sheen:()=>N,KHR_materials_specular:()=>D,KHR_materials_transmission:()=>j,KHR_materials_unlit:()=>L,KHR_materials_volume:()=>W,KHR_texture_transform:()=>M});var o={};n.r(o),n.d(o,{EXT_mesh_gpu_instancing:()=>Y,GLTF2Export:()=>A,GLTFData:()=>l,KHR_lights_punctual:()=>w,KHR_materials_anisotropy:()=>B,KHR_materials_clearcoat:()=>V,KHR_materials_dispersion:()=>q,KHR_materials_emissive_strength:()=>Z,KHR_materials_ior:()=>k,KHR_materials_iridescence:()=>S,KHR_materials_sheen:()=>N,KHR_materials_specular:()=>D,KHR_materials_transmission:()=>j,KHR_materials_unlit:()=>L,KHR_materials_volume:()=>W,KHR_texture_transform:()=>M,_BinaryWriter:()=>b,_Exporter:()=>v,_GLTFAnimation:()=>m,_GLTFMaterialExporter:()=>_,_GLTFUtilities:()=>g,__IGLTFExporterExtensionV2:()=>J});var s={};n.r(s),n.d(s,{EXT_mesh_gpu_instancing:()=>Y,GLTF2Export:()=>A,GLTFData:()=>l,KHR_lights_punctual:()=>w,KHR_materials_anisotropy:()=>B,KHR_materials_clearcoat:()=>V,KHR_materials_dispersion:()=>q,KHR_materials_emissive_strength:()=>Z,KHR_materials_ior:()=>k,KHR_materials_iridescence:()=>S,KHR_materials_sheen:()=>N,KHR_materials_specular:()=>D,KHR_materials_transmission:()=>j,KHR_materials_unlit:()=>L,KHR_materials_volume:()=>W,KHR_texture_transform:()=>M,_BinaryWriter:()=>b,_Exporter:()=>v,_GLTFAnimation:()=>m,_GLTFMaterialExporter:()=>_,_GLTFUtilities:()=>g,__IGLTFExporterExtension:()=>u,__IGLTFExporterExtensionV2:()=>J});var u=0,l=function(){function e(){this.glTFFiles={}}return e.prototype.downloadFiles=function(){function e(e,t){return-1!==e.indexOf(t,e.length-t.length)}for(var t in this.glTFFiles){var r=document.createElement("a");document.body.appendChild(r),r.setAttribute("type","hidden"),r.download=t;var n=this.glTFFiles[t],a=void 0;e(t,".glb")?a={type:"model/gltf-binary"}:e(t,".bin")?a={type:"application/octet-stream"}:e(t,".gltf")?a={type:"model/gltf+json"}:e(t,".jpeg")||e(t,".jpg")?a={type:"image/jpeg"}:e(t,".png")&&(a={type:"image/png"}),r.href=window.URL.createObjectURL(new Blob([n],a)),r.click()}},e}();function c(e,t,r,n){return new(r||(r=Promise))((function(a,i){function o(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}u((n=n.apply(e,t||[])).next())}))}function f(e,t){var r,n,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]o.width?(a=t&&t instanceof d.Texture?d.TextureTools.CreateResizedCopy(t,i.width,i.height,!0):this._createWhiteTexture(i.width,i.height,r),n=e):(n=e,a=t),{texture1:n,texture2:a}},e.prototype._convertPixelArrayToFloat32=function(e){if(e instanceof Uint8Array){for(var t=e.length,r=new Float32Array(e.length),n=0;ne._Epsilon?R.baseColor.r:1,T[N+1]/=R.baseColor.g>e._Epsilon?R.baseColor.g:1,T[N+2]/=R.baseColor.b>e._Epsilon?R.baseColor.b:1,O=d.Color3.FromInts(T[N],T[N+1],T[N+2]),L=O.toGammaSpace(s.getEngine().useExactSrgbConversions),T[N]=255*L.r,T[N+1]=255*L.g,T[N+2]=255*L.b,e._FuzzyEquals(L,d.Color3.White(),e._Epsilon)||(I=!0),y[N+1]/=R.roughness>e._Epsilon?R.roughness:1,y[N+2]/=R.metallic>e._Epsilon?R.metallic:1,U=d.Color3.FromInts(255,y[N+1],y[N+2]),e._FuzzyEquals(U,d.Color3.White(),e._Epsilon)||(S=!0);return S&&o.push(this._getImageDataAsync(y,p,_,a).then((function(e){R.metallicRoughnessTextureData=e}))),I&&o.push(this._getImageDataAsync(T,p,_,a).then((function(e){R.baseColorTextureData=e}))),[2,Promise.all(o).then((function(){return R}))];case 3:return[2,Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")]}}))}))},e.prototype._convertSpecularGlossinessToMetallicRoughness=function(t){var r=this._getPerceivedBrightness(t.diffuseColor),n=this._getPerceivedBrightness(t.specularColor),a=1-this._getMaxComponent(t.specularColor),i=e._SolveMetallic(r,n,a),o=t.diffuseColor.scale(a/(1-e._DielectricSpecular.r)/Math.max(1-i,e._Epsilon)),s=t.specularColor.subtract(e._DielectricSpecular.scale(1-i)).scale(1/Math.max(i,e._Epsilon)),u=d.Color3.Lerp(o,s,i*i);return{baseColor:u=u.clampToRef(0,1,u),metallic:i,roughness:1-t.glossiness}},e.prototype._getPerceivedBrightness=function(e){return e?Math.sqrt(.299*e.r*e.r+.587*e.g*e.g+.114*e.b*e.b):0},e.prototype._getMaxComponent=function(e){return e?Math.max(e.r,Math.max(e.g,e.b)):0},e.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync=function(e,t,r,n){var a=[],i={baseColor:e._albedoColor,metallic:e._metallic,roughness:e._roughness};if(n){e._albedoTexture&&a.push(this._exportTextureAsync(e._albedoTexture,t).then((function(e){e&&(r.baseColorTexture=e)})));var o=e._metallicTexture;o&&a.push(this._exportTextureAsync(o,t).then((function(e){e&&(r.metallicRoughnessTexture=e)})))}return Promise.all(a).then((function(){return i}))},e.prototype._getTextureSampler=function(e){var t={};if(!(e&&e instanceof d.Texture))return t;var r=this._getGLTFTextureWrapMode(e.wrapU);10497!==r&&(t.wrapS=r);var n=this._getGLTFTextureWrapMode(e.wrapV);switch(10497!==n&&(t.wrapT=n),e.samplingMode){case d.Texture.LINEAR_LINEAR:t.magFilter=9729,t.minFilter=9729;break;case d.Texture.LINEAR_NEAREST:t.magFilter=9729,t.minFilter=9728;break;case d.Texture.NEAREST_LINEAR:t.magFilter=9728,t.minFilter=9729;break;case d.Texture.NEAREST_LINEAR_MIPLINEAR:t.magFilter=9728,t.minFilter=9987;break;case d.Texture.NEAREST_NEAREST:t.magFilter=9728,t.minFilter=9728;break;case d.Texture.NEAREST_LINEAR_MIPNEAREST:t.magFilter=9728,t.minFilter=9985;break;case d.Texture.LINEAR_NEAREST_MIPNEAREST:t.magFilter=9729,t.minFilter=9984;break;case d.Texture.LINEAR_NEAREST_MIPLINEAR:t.magFilter=9729,t.minFilter=9986;break;case d.Texture.NEAREST_NEAREST_MIPLINEAR:t.magFilter=9728,t.minFilter=9986;break;case d.Texture.LINEAR_LINEAR_MIPLINEAR:t.magFilter=9729,t.minFilter=9987;break;case d.Texture.LINEAR_LINEAR_MIPNEAREST:t.magFilter=9729,t.minFilter=9985;break;case d.Texture.NEAREST_NEAREST_MIPNEAREST:t.magFilter=9728,t.minFilter=9984}return t},e.prototype._getGLTFTextureWrapMode=function(e){switch(e){case d.Texture.WRAP_ADDRESSMODE:return 10497;case d.Texture.CLAMP_ADDRESSMODE:return 33071;case d.Texture.MIRROR_ADDRESSMODE:return 33648;default:return d.Tools.Error("Unsupported Texture Wrap Mode ".concat(e,"!")),10497}},e.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync=function(e,t,r,n){var a=this;return Promise.resolve().then((function(){var i={diffuseColor:e._albedoColor,specularColor:e._reflectivityColor,glossiness:e._microSurface},o=e._albedoTexture,s=e._reflectivityTexture,u=e._useMicroSurfaceFromReflectivityMapAlpha;if(s&&!u)return Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported");if((o||s)&&n){var l=a._exportTextureSampler(o||s);return a._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(o,s,i,t).then((function(e){var n=a._exporter._textures;if(e.baseColorTextureData){var i=a._exportImage("baseColor".concat(n.length),t,e.baseColorTextureData);r.baseColorTexture=a._exportTextureInfo(i,l,null==o?void 0:o.coordinatesIndex)}return e.metallicRoughnessTextureData&&(i=a._exportImage("metallicRoughness".concat(n.length),t,e.metallicRoughnessTextureData),r.metallicRoughnessTexture=a._exportTextureInfo(i,l,null==s?void 0:s.coordinatesIndex)),e}))}return a._convertSpecularGlossinessToMetallicRoughness(i)}))},e.prototype._convertPBRMaterialAsync=function(e,t,r){var n=this,a={},i={name:e.name};if(e.isMetallicWorkflow()){var o=e._albedoColor,s=e.alpha;return o&&(a.baseColorFactor=[o.r,o.g,o.b,s]),this._convertMetalRoughFactorsToMetallicRoughnessAsync(e,t,a,r).then((function(o){return n._setMetallicRoughnessPbrMaterial(o,e,i,a,t,r)}))}return this._convertSpecGlossFactorsToMetallicRoughnessAsync(e,t,a,r).then((function(o){return n._setMetallicRoughnessPbrMaterial(o,e,i,a,t,r)}))},e.prototype._setMetallicRoughnessPbrMaterial=function(t,r,n,a,i,o){var s=this._exporter._materialMap,u=this._exporter._materials,l=[];if(t){if(e._SetAlphaMode(n,r),e._FuzzyEquals(t.baseColor,d.Color3.White(),e._Epsilon)&&r.alpha>=e._Epsilon||(a.baseColorFactor=[t.baseColor.r,t.baseColor.g,t.baseColor.b,r.alpha]),null!=t.metallic&&1!==t.metallic&&(a.metallicFactor=t.metallic),null!=t.roughness&&1!==t.roughness&&(a.roughnessFactor=t.roughness),null==r.backFaceCulling||r.backFaceCulling||(r._twoSidedLighting||d.Tools.Warn(r.name+": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."),n.doubleSided=!0),o){var c=r._bumpTexture;if(c){var f=this._exportTextureAsync(c,i).then((function(e){e&&(n.normalTexture=e,1!==c.level&&(n.normalTexture.scale=c.level))}));l.push(f)}var h=r._ambientTexture;h&&(f=this._exportTextureAsync(h,i).then((function(e){if(e){var t={index:e.index,texCoord:e.texCoord,extensions:e.extensions};n.occlusionTexture=t;var a=r._ambientTextureStrength;a&&(t.strength=a)}})),l.push(f));var p=r._emissiveTexture;p&&(f=this._exportTextureAsync(p,i).then((function(e){e&&(n.emissiveTexture=e)})),l.push(f))}var _=r._emissiveColor;e._FuzzyEquals(_,d.Color3.Black(),e._Epsilon)||(n.emissiveFactor=_.asArray()),n.pbrMetallicRoughness=a,u.push(n),s[r.uniqueId]=u.length-1}return this._finishMaterial(l,n,r,i)},e.prototype._getPixelsFromTexture=function(e){return e.textureType,d.Constants.TEXTURETYPE_UNSIGNED_INT,e.readPixels()},e.prototype._exportTextureAsync=function(e,t){var r=this,n=this._exporter._extensionsPreExportTextureAsync("exporter",e,t);return n?n.then((function(n){return n?r._exportTextureInfoAsync(n,t):r._exportTextureInfoAsync(e,t)})):this._exportTextureInfoAsync(e,t)},e.prototype._exportTextureInfoAsync=function(e,t){return c(this,void 0,void 0,(function(){var r,n,a,i,o,s,u,l,h,p,_=this;return f(this,(function(g){switch(g.label){case 0:return(r=e.uid)in this._textureMap?[3,3]:[4,this._getPixelsFromTexture(e)];case 1:if(!(n=g.sent()))return[2,null];if(a=this._exportTextureSampler(e),i=e.mimeType)switch(i){case"image/jpeg":case"image/png":case"image/webp":t=i;break;default:d.Tools.Warn("Unsupported media type: ".concat(i))}return o=this._internalTextureToImage,s=e.getInternalTexture().uniqueId,o[s]||(o[s]={}),void 0===(u=o[s][t])&&(l=e.getSize(),u=c(_,void 0,void 0,(function(){var r;return f(this,(function(a){switch(a.label){case 0:return[4,this._getImageDataAsync(n,l.width,l.height,t)];case 1:return r=a.sent(),[2,this._exportImage(e.name,t,r)]}}))})),o[s][t]=u),p=this._exportTextureInfo,[4,u];case 2:h=p.apply(this,[g.sent(),a,e.coordinatesIndex]),this._textureMap[r]=h,this._exporter._extensionsPostExportTextures("exporter",this._textureMap[r],e),g.label=3;case 3:return[2,this._textureMap[r]]}}))}))},e.prototype._exportImage=function(e,t,r){var n=this._exporter._imageData,a=e.replace(/\.\/|\/|\.\\|\\/g,"_"),i=function(e){switch(e){case"image/jpeg":return".jpg";case"image/png":return".png";case"image/webp":return".webp"}}(t),o=a+i;o in n&&(o="".concat(a,"_").concat(d.Tools.RandomId()).concat(i)),n[o]={data:r,mimeType:t};var s=this._exporter._images;return s.push({name:e,uri:o}),s.length-1},e.prototype._exportTextureInfo=function(e,t,r){var n=this._exporter._textures,a=n.findIndex((function(r){return r.sampler==t&&r.source===e}));-1===a&&(a=n.length,n.push({source:e,sampler:t}));var i={index:a};return r&&(i.texCoord=r),i},e.prototype._exportTextureSampler=function(e){var t=this._getTextureSampler(e),r=this._exporter._samplers,n=r.findIndex((function(e){return e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.wrapS===t.wrapS&&e.wrapT===t.wrapT}));return-1!==n?n:(r.push(t),r.length-1)},e._DielectricSpecular=new d.Color3(.04,.04,.04),e._MaxSpecularPower=1024,e._Epsilon=1e-6,e}(),g=function(){function e(){}return e._CreateBufferView=function(e,t,r,n,a){var i={buffer:e,byteLength:r};return t&&(i.byteOffset=t),a&&(i.name=a),n&&(i.byteStride=n),i},e._CreateAccessor=function(e,t,r,n,a,i,o,s){var u={name:t,bufferView:e,componentType:n,count:a,type:r};return null!=o&&(u.min=o),null!=s&&(u.max=s),null!=i&&(u.byteOffset=i),u},e._CalculateMinMaxPositions=function(e,t,r){var n,a,i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];if(r)for(var s=t,u=t+r;so[l]&&(o[l]=c),++n}}return{min:i,max:o}},e._NormalizeTangentFromRef=function(e){var t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);t>0&&(e.x/=t,e.y/=t,e.z/=t)},e._GetDataAccessorElementCount=function(e){switch(e){case"MAT2":case"VEC4":return 4;case"MAT3":return 9;case"MAT4":return 16;case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3}},e}();!function(e){e[e.INTANGENT=0]="INTANGENT",e[e.OUTTANGENT=1]="OUTTANGENT"}(p||(p={}));var m=function(){function e(){}return e._IsTransformable=function(e){return e&&(e instanceof d.TransformNode||e instanceof d.Camera||e instanceof d.Light)},e._CreateNodeAnimation=function(t,r,n,a,i){if(this._IsTransformable(t)){var o=[],s=[],u=r.getKeys(),l=e._CalculateMinMaxKeyFrames(u),c=e._DeduceInterpolation(u,n,a),f=c.interpolationType,h=c.shouldBakeAnimation;if(h?e._CreateBakedAnimation(t,r,n,l.min,l.max,r.framePerSecond,i,o,s,l,a):"LINEAR"===f||"STEP"===f?e._CreateLinearOrStepAnimation(t,r,n,o,s,a):"CUBICSPLINE"===f?e._CreateCubicSplineAnimation(t,r,n,o,s,a):e._CreateBakedAnimation(t,r,n,l.min,l.max,r.framePerSecond,i,o,s,l,a),o.length&&s.length)return{inputs:o,outputs:s,samplerInterpolation:f,inputsMin:h?l.min:d.Tools.FloatRound(l.min/r.framePerSecond),inputsMax:h?l.max:d.Tools.FloatRound(l.max/r.framePerSecond)}}return null},e._DeduceAnimationInfo=function(e){var t=null,r="VEC3",n=!1,a=e.targetProperty.split(".");switch(a[0]){case"scaling":t="scale";break;case"position":t="translation";break;case"rotation":r="VEC4",t="rotation";break;case"rotationQuaternion":r="VEC4",n=!0,t="rotation";break;case"influence":r="SCALAR",t="weights";break;default:d.Tools.Error("Unsupported animatable property ".concat(a[0]))}return t?{animationChannelTargetPath:t,dataAccessorType:r,useQuaternion:n}:(d.Tools.Error("animation channel target path and data accessor type could be deduced"),null)},e._CreateNodeAnimationFromNodeAnimations=function(t,r,n,a,i,o,s,u,l,c){var f;if(e._IsTransformable(t)&&t.animations)for(var h=0,p=t.animations;h0;)E=b.inputs.shift(),A%p==0&&M.push(E),A++;b.inputs=M}var F=s[n.uniqueId],w=4*b.inputs.length;d=g._CreateBufferView(0,u.getByteOffset(),w,void 0,"".concat(t," keyframe data view")),l.push(d),b.inputs.forEach((function(e){u.setFloat32(e)})),_=g._CreateAccessor(l.length-1,"".concat(t," keyframes"),"SCALAR",5126,b.inputs.length,null,[b.inputsMin],[b.inputsMax]),c.push(_),m=c.length-1,y=b.outputs.length,w=4*g._GetDataAccessorElementCount(i)*b.outputs.length,d=g._CreateBufferView(0,u.getByteOffset(),w,void 0,"".concat(t," data view")),l.push(d),b.outputs.forEach((function(e){e.forEach((function(e){u.setFloat32(e)}))})),_=g._CreateAccessor(l.length-1,"".concat(t," data"),i,5126,y,null,null,null),c.push(_),x=c.length-1,T={interpolation:b.samplerInterpolation,input:m,output:x},r.samplers.push(T),v={sampler:r.samplers.length-1,target:{node:F,path:o}},r.channels.push(v)}},e._CreateBakedAnimation=function(t,r,n,a,i,o,s,u,l,c,f){var h,p,_=d.Quaternion.Identity(),g=null,m=null,x=null,y=null,T=null,v=null;c.min=d.Tools.FloatRound(a/o);for(var b=r.getKeys(),A=0,E=b.length;A=t.length)return Promise.resolve(e);var i=n(t[r],e);return i?i.then((function(e){return a._applyExtension(e,t,r+1,n)})):this._applyExtension(e,t,r+1,n)},e.prototype._applyExtensions=function(t,r){for(var n=[],a=0,i=e._ExtensionNames;a=c;--i)a.setUInt32(r[i],n),n+=4;break;case d.Material.TriangleStripDrawMode:e.indexCount>=3&&(a.setUInt32(r[e.indexStart+2],n+4),a.setUInt32(r[e.indexStart+1],n+8))}},e.prototype._reorderVertexAttributeDataBasedOnPrimitiveMode=function(e,t,r,n,a,i){switch(t){case d.Material.TriangleFillMode:this._reorderTriangleFillMode(e,r,n,a,i);break;case d.Material.TriangleStripDrawMode:this._reorderTriangleStripDrawMode(e,r,n,a,i);break;case d.Material.TriangleFanDrawMode:this._reorderTriangleFanMode(e,r,n,a,i)}},e.prototype._reorderTriangleFillMode=function(e,t,r,n,a){var i=this._getVertexBufferFromMesh(t,e.getMesh());if(i){var o=i.byteStride/d.VertexBuffer.GetTypeByteLength(i.type);if(e.verticesCount%3!=0)d.Tools.Error("The submesh vertices for the triangle fill mode is not divisible by 3!");else{var s=[],u=0;switch(t){case d.VertexBuffer.PositionKind:case d.VertexBuffer.NormalKind:for(var l=e.verticesStart;l=e.verticesStart;--l)u=l*o,s.push(d.Vector4.FromArray(r,u));break;case d.VertexBuffer.ColorKind:for(l=e.verticesStart+e.verticesCount-1;l>=e.verticesStart;--l)u=l*o,4===i.getSize()?s.push(d.Vector4.FromArray(r,u)):s.push(d.Vector3.FromArray(r,u));break;case d.VertexBuffer.UVKind:case d.VertexBuffer.UV2Kind:for(l=e.verticesStart+e.verticesCount-1;l>=e.verticesStart;--l)u=l*o,s.push(d.Vector2.FromArray(r,u));break;default:d.Tools.Error("Unsupported Vertex Buffer type: ".concat(t))}this._writeVertexAttributeData(s,n+12,t,a)}else d.Tools.Warn("reorderTriangleStripDrawMode: Vertex buffer kind ".concat(t," not present!"))},e.prototype._reorderTriangleFanMode=function(e,t,r,n,a){var i=this._getVertexBufferFromMesh(t,e.getMesh());if(i){var o=i.byteStride/d.VertexBuffer.GetTypeByteLength(i.type),s=[],u=0;switch(t){case d.VertexBuffer.PositionKind:case d.VertexBuffer.NormalKind:for(var l=e.verticesStart+e.verticesCount-1;l>=e.verticesStart;--l)u=l*o,s.push(d.Vector3.FromArray(r,u));break;case d.VertexBuffer.TangentKind:for(l=e.verticesStart+e.verticesCount-1;l>=e.verticesStart;--l)u=l*o,s.push(d.Vector4.FromArray(r,u));break;case d.VertexBuffer.ColorKind:for(l=e.verticesStart+e.verticesCount-1;l>=e.verticesStart;--l)u=l*o,s.push(d.Vector4.FromArray(r,u)),4===i.getSize()?s.push(d.Vector4.FromArray(r,u)):s.push(d.Vector3.FromArray(r,u));break;case d.VertexBuffer.UVKind:case d.VertexBuffer.UV2Kind:for(l=e.verticesStart+e.verticesCount-1;l>=e.verticesStart;--l)u=l*o,s.push(d.Vector2.FromArray(r,u));break;default:d.Tools.Error("Unsupported Vertex Buffer type: ".concat(t))}this._writeVertexAttributeData(s,n,t,a)}else d.Tools.Warn("reorderTriangleFanMode: Vertex buffer kind ".concat(t," not present!"))},e.prototype._writeVertexAttributeData=function(e,t,r,n){for(var a=0,i=e;a0){if((null!==o.overrideMaterialSideOrientation?o.overrideMaterialSideOrientation:F.sideOrientation)===(this._babylonScene.useRightHandedSystem?d.Material.ClockWiseSideOrientation:d.Material.CounterClockWiseSideOrientation)){var L=null!=u?this._bufferViews[u].byteOffset:null;null==L&&(L=0);var U=null;if(null!=u&&(U=o.getIndices()),U)this._reorderIndicesBasedOnPrimitiveMode(M,l,U,L,r);else for(var k=0,K=s;k0){var s=o.material||o.getScene().defaultMaterial;if(s instanceof d.MultiMaterial)for(var u=0,l=s.subMaterials;u0){a.weights=[];for(var o=0;of&&(f=p));for(var p=0;p<=f;++p){var _=c[p];l.push(_.getInvertedAbsoluteTransform());var m=_.getTransformNode();m&&null!==e[m.uniqueId]&&void 0!==e[m.uniqueId]?u.joints.push(e[m.uniqueId]):d.Tools.Warn("Exporting a bone without a linked transform node is currently unsupported")}if(u.joints.length>0){var x=64*l.length,y=t.getByteOffset(),T=g._CreateBufferView(0,y,x,void 0,"InverseBindMatrices - "+s.name);this._bufferViews.push(T);var v=this._bufferViews.length-1,b=g._CreateAccessor(v,"InverseBindMatrices - "+s.name,"MAT4",5126,l.length,null,null,null),A=this._accessors.push(b)-1;u.inverseBindMatrices=A,this._skins.push(u),a[s.uniqueId]=this._skins.length-1,l.forEach((function(e){e.m.forEach((function(e){t.setFloat32(e)}))}))}}}return n.then((function(){return a}))},e._ExtensionNames=new Array,e._ExtensionFactories={},e}(),b=function(){function e(e){this._arrayBuffer=new ArrayBuffer(e),this._dataView=new DataView(this._arrayBuffer),this._byteOffset=0}return e.prototype._resizeBuffer=function(e){var t=new ArrayBuffer(e),r=Math.min(this._arrayBuffer.byteLength,e),n=new Uint8Array(this._arrayBuffer,0,r);return new Uint8Array(t).set(n,0),this._arrayBuffer=t,this._dataView=new DataView(this._arrayBuffer),t},e.prototype.getArrayBuffer=function(){return this._resizeBuffer(this.getByteOffset())},e.prototype.getByteOffset=function(){if(null==this._byteOffset)throw new Error("Byte offset is undefined!");return this._byteOffset},e.prototype.setUInt8=function(e,t){null!=t?tthis._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint8(this._byteOffset,e),this._byteOffset+=1)},e.prototype.setUInt16=function(e,t){null!=t?tthis._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint16(this._byteOffset,e,!0),this._byteOffset+=2)},e.prototype.getUInt32=function(e){if(ethis._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(e.x=this._dataView.getFloat32(t,!0),e.y=this._dataView.getFloat32(t+4,!0),e.z=this._dataView.getFloat32(t+8,!0))},e.prototype.setVector3Float32FromRef=function(e,t){t+8>this._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._dataView.setFloat32(t,e.x,!0),this._dataView.setFloat32(t+4,e.y,!0),this._dataView.setFloat32(t+8,e.z,!0))},e.prototype.getVector4Float32FromRef=function(e,t){t+12>this._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(e.x=this._dataView.getFloat32(t,!0),e.y=this._dataView.getFloat32(t+4,!0),e.z=this._dataView.getFloat32(t+8,!0),e.w=this._dataView.getFloat32(t+12,!0))},e.prototype.setVector4Float32FromRef=function(e,t){t+12>this._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._dataView.setFloat32(t,e.x,!0),this._dataView.setFloat32(t+4,e.y,!0),this._dataView.setFloat32(t+8,e.z,!0),this._dataView.setFloat32(t+12,e.w,!0))},e.prototype.setFloat32=function(e,t){isNaN(e)&&d.Tools.Error("Invalid data being written!"),null!=t&&(tthis._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setFloat32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.setUInt32=function(e,t){null!=t?tthis._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint32(this._byteOffset,e,!0),this._byteOffset+=4)},e.prototype.setInt16=function(e,t){null!=t?tthis._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setInt16(this._byteOffset,e,!0),this._byteOffset+=2)},e.prototype.setByte=function(e,t){null!=t?tthis._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setInt8(this._byteOffset,e),this._byteOffset++)},e}(),A=function(){function e(){}return e.GLTFAsync=function(e,t,r){return e.whenReadyAsync().then((function(){var n=t.replace(/\.[^/.]+$/,"");return new v(e,r)._generateGLTFAsync(n)}))},e._PreExportAsync=function(e,t){return Promise.resolve().then((function(){return t&&t.exportWithoutWaitingForScene?Promise.resolve():e.whenReadyAsync()}))},e._PostExportAsync=function(e,t,r){return Promise.resolve().then((function(){return r&&r.exportWithoutWaitingForScene,t}))},e.GLBAsync=function(e,t,r){var n=this;return this._PreExportAsync(e,r).then((function(){var a=t.replace(/\.[^/.]+$/,"");return new v(e,r)._generateGLBAsync(a).then((function(t){return n._PostExportAsync(e,t,r)}))}))},e}(),E="KHR_texture_transform",M=function(){function e(){this.name=E,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportTexture=function(e,t,r){if(r&&(0===r.uAng&&0===r.wAng&&0===r.vAng||0===r.uRotationCenter&&0===r.vRotationCenter)){var n={},a=!1;if(0===r.uOffset&&0===r.vOffset||(n.offset=[r.uOffset,r.vOffset],a=!0),1===r.uScale&&1===r.vScale||(n.scale=[r.uScale,r.vScale],a=!0),0!==r.wAng&&(n.rotation=-r.wAng,a=!0),0!==r.coordinatesIndex&&(n.texCoord=r.coordinatesIndex,a=!0),!a)return;this._wasUsed=!0,t.extensions||(t.extensions={}),t.extensions[E]=n}},e.prototype.preExportTextureAsync=function(e,t){return new Promise((function(r,n){t.getScene()?0!==t.uAng||0!==t.vAng?(d.Tools.Warn("".concat(e,": Texture ").concat(t.name," with rotation in the u or v axis is not supported in glTF.")),r(null)):0===t.wAng||0===t.uRotationCenter&&0===t.vRotationCenter?r(t):(d.Tools.Warn("".concat(e,": Texture ").concat(t.name," with rotation not centered at the origin cannot be exported with ").concat(E)),r(null)):n("".concat(e,': "scene" is not defined for Babylon texture ').concat(t.name,"!"))}))},e}();v.RegisterExtension(E,(function(){return new M}));var F="KHR_lights_punctual",w=function(){function e(e){this.name=F,this.enabled=!0,this.required=!1,this._exporter=e}return e.prototype.dispose=function(){this._lights=null},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return!!this._lights},enumerable:!1,configurable:!0}),e.prototype.onExporting=function(){this._exporter._glTF.extensions[F]=this._lights},e.prototype.postExportNodeAsync=function(e,t,r,n){var a=this;return new Promise((function(i){if(t&&r instanceof d.ShadowLight){var o=void 0,s=r.getTypeID()==d.Light.LIGHTTYPEID_POINTLIGHT?"point":r.getTypeID()==d.Light.LIGHTTYPEID_DIRECTIONALLIGHT?"directional":r.getTypeID()==d.Light.LIGHTTYPEID_SPOTLIGHT?"spot":null;if(null==s)d.Logger.Warn("".concat(e,": Light ").concat(r.name," is not supported in ").concat(F));else{if(r.position.equalsToFloats(0,0,0)||(t.translation=r.position.asArray()),"point"!==s){var u=r.direction,l=-Math.atan2(u.z,u.x)+Math.PI/2,c=Math.sqrt(u.x*u.x+u.z*u.z),f=-Math.atan2(u.y,c),h=d.Quaternion.RotationYawPitchRoll(l+Math.PI,f,0);d.Quaternion.IsIdentity(h)||(t.rotation=h.asArray())}if(r.falloffType!==d.Light.FALLOFF_GLTF&&d.Logger.Warn("".concat(e,": Light falloff for ").concat(r.name," does not match the ").concat(F," specification!")),o={type:s},r.diffuse.equals(d.Color3.White())||(o.color=r.diffuse.asArray()),1!==r.intensity&&(o.intensity=r.intensity),r.range!==Number.MAX_VALUE&&(o.range=r.range),"spot"===s){var p=r;p.angle!==Math.PI/2&&(null==o.spot&&(o.spot={}),o.spot.outerConeAngle=p.angle/2),0!==p.innerAngle&&(null==o.spot&&(o.spot={}),o.spot.innerConeAngle=p.innerAngle/2)}a._lights||(a._lights={lights:[]}),a._lights.lights.push(o);var _={light:a._lights.lights.length-1},g=r.parent;if(g&&1==g.getChildren().length){var m=a._exporter._nodes[n[g.uniqueId]];if(m){var x=d.Vector3.FromArrayToRef(m.translation||[0,0,0],0,d.TmpVectors.Vector3[0]),y=d.Quaternion.FromArrayToRef(m.rotation||[0,0,0,1],0,d.TmpVectors.Quaternion[0]),T=d.Vector3.FromArrayToRef(m.scale||[1,1,1],0,d.TmpVectors.Vector3[1]),v=d.Matrix.ComposeToRef(T,y,x,d.TmpVectors.Matrix[0]),b=d.Vector3.FromArrayToRef(t.translation||[0,0,0],0,d.TmpVectors.Vector3[2]),A=d.Quaternion.FromArrayToRef(t.rotation||[0,0,0,1],0,d.TmpVectors.Quaternion[1]),E=d.Matrix.ComposeToRef(d.Vector3.OneReadOnly,A,b,d.TmpVectors.Matrix[1]);return v.multiplyToRef(E,E),E.decompose(T,y,x),x.equalsToFloats(0,0,0)?delete m.translation:m.translation=x.asArray(),d.Quaternion.IsIdentity(y)?delete m.rotation:m.rotation=y.asArray(),T.equalsToFloats(1,1,1)?delete m.scale:m.scale=T.asArray(),m.extensions||(m.extensions={}),m.extensions[F]=_,void i(null)}}t.extensions||(t.extensions={}),t.extensions[F]=_}}i(t)}))},e}();v.RegisterExtension(F,(function(e){return new w(e)}));var C="KHR_materials_clearcoat",V=function(){function e(e){this.name=C,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRBaseMaterial&&r.clearCoat.isEnabled?(r.clearCoat.texture&&n.push(r.clearCoat.texture),!r.clearCoat.useRoughnessFromMainTexture&&r.clearCoat.textureRoughness&&n.push(r.clearCoat.textureRoughness),r.clearCoat.bumpTexture&&n.push(r.clearCoat.bumpTexture),n):[]},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){if(r instanceof d.PBRBaseMaterial){if(!r.clearCoat.isEnabled)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var a,i=n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.texture);a=r.clearCoat.useRoughnessFromMainTexture?n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.texture):n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.textureRoughness),r.clearCoat.isTintEnabled&&d.Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: ".concat(r.name)),r.clearCoat.remapF0OnInterfaceChange&&d.Tools.Warn("Clear Color F0 remapping is not supported for glTF export. Ignoring for: ".concat(r.name));var o=n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.bumpTexture),s={clearcoatFactor:r.clearCoat.intensity,clearcoatTexture:null!=i?i:void 0,clearcoatRoughnessFactor:r.clearCoat.roughness,clearcoatRoughnessTexture:null!=a?a:void 0,clearcoatNormalTexture:null!=o?o:void 0,hasTextures:function(){return null!==s.clearcoatTexture||null!==s.clearcoatRoughnessTexture||null!==s.clearcoatRoughnessTexture}};t.extensions[C]=s}e(t)}))},e}();v.RegisterExtension(C,(function(e){return new V(e)}));var R="KHR_materials_iridescence",S=function(){function e(e){this.name=R,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRBaseMaterial&&r.iridescence.isEnabled?(r.iridescence.texture&&n.push(r.iridescence.texture),r.iridescence.thicknessTexture&&r.iridescence.thicknessTexture!==r.iridescence.texture&&n.push(r.iridescence.thicknessTexture),n):[]},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){if(r instanceof d.PBRBaseMaterial){if(!r.iridescence.isEnabled)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var a=n._exporter._glTFMaterialExporter._getTextureInfo(r.iridescence.texture),i=n._exporter._glTFMaterialExporter._getTextureInfo(r.iridescence.thicknessTexture),o={iridescenceFactor:r.iridescence.intensity,iridescenceIor:r.iridescence.indexOfRefraction,iridescenceThicknessMinimum:r.iridescence.minimumThickness,iridescenceThicknessMaximum:r.iridescence.maximumThickness,iridescenceTexture:null!=a?a:void 0,iridescenceThicknessTexture:null!=i?i:void 0,hasTextures:function(){return null!==o.iridescenceTexture||null!==o.iridescenceThicknessTexture}};t.extensions[R]=o}e(t)}))},e}();v.RegisterExtension(R,(function(e){return new S(e)}));var I="KHR_materials_anisotropy",B=function(){function e(e){this.name=I,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRBaseMaterial&&r.anisotropy.isEnabled&&!r.anisotropy.legacy?(r.anisotropy.texture&&n.push(r.anisotropy.texture),n):[]},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){if(r instanceof d.PBRBaseMaterial){if(!r.anisotropy.isEnabled||r.anisotropy.legacy)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var a=n._exporter._glTFMaterialExporter._getTextureInfo(r.anisotropy.texture),i={anisotropyStrength:r.anisotropy.intensity,anisotropyRotation:r.anisotropy.angle,anisotropyTexture:null!=a?a:void 0,hasTextures:function(){return null!==i.anisotropyTexture}};t.extensions[I]=i}e(t)}))},e}();v.RegisterExtension(I,(function(e){return new B(e)}));var P="KHR_materials_sheen",N=function(){function e(e){this.name=P,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){return r instanceof d.PBRMaterial&&r.sheen.isEnabled&&r.sheen.texture?[r.sheen.texture]:[]},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){var a,i,o,s;if(r instanceof d.PBRMaterial){if(!r.sheen.isEnabled)return void e(t);n._wasUsed=!0,null==t.extensions&&(t.extensions={});var u={sheenColorFactor:r.sheen.color.asArray(),sheenRoughnessFactor:null!==(a=r.sheen.roughness)&&void 0!==a?a:0,hasTextures:function(){return null!==u.sheenColorTexture||null!==u.sheenRoughnessTexture}};r.sheen.texture&&(u.sheenColorTexture=null!==(i=n._exporter._glTFMaterialExporter._getTextureInfo(r.sheen.texture))&&void 0!==i?i:void 0),r.sheen.textureRoughness&&!r.sheen.useRoughnessFromMainTexture?u.sheenRoughnessTexture=null!==(o=n._exporter._glTFMaterialExporter._getTextureInfo(r.sheen.textureRoughness))&&void 0!==o?o:void 0:r.sheen.texture&&r.sheen.useRoughnessFromMainTexture&&(u.sheenRoughnessTexture=null!==(s=n._exporter._glTFMaterialExporter._getTextureInfo(r.sheen.texture))&&void 0!==s?s:void 0),t.extensions[P]=u}e(t)}))},e}();v.RegisterExtension(P,(function(e){return new N(e)}));var O="KHR_materials_unlit",L=function(){function e(){this.name=O,this.enabled=!0,this.required=!1,this._wasUsed=!1}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){var a=!1;r instanceof d.PBRMaterial?a=r.unlit:r instanceof d.StandardMaterial&&(a=r.disableLighting),a&&(n._wasUsed=!0,null==t.extensions&&(t.extensions={}),t.extensions[O]={}),e(t)}))},e}();v.RegisterExtension(O,(function(){return new L}));var U="KHR_materials_ior",k=function(){function e(){this.name=U,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype._isExtensionEnabled=function(e){return!e.unlit&&null!=e.indexOfRefraction&&1.5!=e.indexOfRefraction},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){if(r instanceof d.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var a={ior:r.indexOfRefraction};t.extensions=t.extensions||{},t.extensions[U]=a}e(t)}))},e}();v.RegisterExtension(U,(function(e){return new k}));var K="KHR_materials_specular",D=function(){function e(e){this.name=K,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRMaterial&&this._isExtensionEnabled(r)?(r.metallicReflectanceTexture&&n.push(r.metallicReflectanceTexture),r.reflectanceTexture&&n.push(r.reflectanceTexture),n):n},e.prototype._isExtensionEnabled=function(e){return!e.unlit&&(null!=e.metallicF0Factor&&1!=e.metallicF0Factor||null!=e.metallicReflectanceColor&&!e.metallicReflectanceColor.equalsFloats(1,1,1)||this._hasTexturesExtension(e))},e.prototype._hasTexturesExtension=function(e){return null!=e.metallicReflectanceTexture||null!=e.reflectanceTexture},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){var a,i;if(r instanceof d.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0,t.extensions=t.extensions||{};var o=null!==(a=n._exporter._glTFMaterialExporter._getTextureInfo(r.metallicReflectanceTexture))&&void 0!==a?a:void 0,s=null!==(i=n._exporter._glTFMaterialExporter._getTextureInfo(r.reflectanceTexture))&&void 0!==i?i:void 0,u={specularFactor:1==r.metallicF0Factor?void 0:r.metallicF0Factor,specularTexture:o,specularColorFactor:r.metallicReflectanceColor.equalsFloats(1,1,1)?void 0:r.metallicReflectanceColor.asArray(),specularColorTexture:s,hasTextures:function(){return n._hasTexturesExtension(r)}};t.extensions[K]=u}e(t)}))},e}();v.RegisterExtension(K,(function(e){return new D(e)}));var G="KHR_materials_volume",W=function(){function e(e){this.name=G,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRMaterial&&this._isExtensionEnabled(r)?(r.subSurface.thicknessTexture&&n.push(r.subSurface.thicknessTexture),n):n},e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.subSurface;return!(!t.isRefractionEnabled&&!t.isTranslucencyEnabled)&&(null!=t.maximumThickness&&0!=t.maximumThickness||null!=t.tintColorAtDistance&&t.tintColorAtDistance!=Number.POSITIVE_INFINITY||null!=t.tintColor&&t.tintColor!=d.Color3.White()||this._hasTexturesExtension(e))},e.prototype._hasTexturesExtension=function(e){return null!=e.subSurface.thicknessTexture},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){var a;if(r instanceof d.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var i=r.subSurface,o={thicknessFactor:0==i.maximumThickness?void 0:i.maximumThickness,thicknessTexture:null!==(a=n._exporter._glTFMaterialExporter._getTextureInfo(i.thicknessTexture))&&void 0!==a?a:void 0,attenuationDistance:i.tintColorAtDistance==Number.POSITIVE_INFINITY?void 0:i.tintColorAtDistance,attenuationColor:i.tintColor.equalsFloats(1,1,1)?void 0:i.tintColor.asArray(),hasTextures:function(){return n._hasTexturesExtension(r)}};t.extensions=t.extensions||{},t.extensions[G]=o}e(t)}))},e}();v.RegisterExtension(G,(function(e){return new W(e)}));var z="KHR_materials_dispersion",q=function(){function e(){this.name=z,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.subSurface;return!(!t.isRefractionEnabled&&!t.isDispersionEnabled)},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){if(r instanceof d.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var a={dispersion:r.subSurface.dispersion};t.extensions=t.extensions||{},t.extensions[z]=a}e(t)}))},e}();v.RegisterExtension(z,(function(){return new q}));var H="KHR_materials_transmission",j=function(){function e(e){this.name=H,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRMaterial&&this._isExtensionEnabled(r)?(r.subSurface.thicknessTexture&&n.push(r.subSurface.thicknessTexture),n):n},e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.subSurface;return t.isRefractionEnabled&&null!=t.refractionIntensity&&0!=t.refractionIntensity||this._hasTexturesExtension(e)},e.prototype._hasTexturesExtension=function(e){return null!=e.subSurface.refractionIntensityTexture},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){var a;if(r instanceof d.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var i=r.subSurface,o={transmissionFactor:0===i.refractionIntensity?void 0:i.refractionIntensity,transmissionTexture:null!==(a=n._exporter._glTFMaterialExporter._getTextureInfo(i.refractionIntensityTexture))&&void 0!==a?a:void 0,hasTextures:function(){return n._hasTexturesExtension(r)}};t.extensions=t.extensions||{},t.extensions[H]=o}e(t)}))},e}();v.RegisterExtension(H,(function(e){return new j(e)}));var Q="EXT_mesh_gpu_instancing",Y=function(){function e(e){this.name=Q,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportNodeAsync=function(e,t,r,n,a){var i=this;return new Promise((function(e){if(t&&r instanceof d.Mesh&&r.hasThinInstances&&a){i._wasUsed=!0;for(var n=d.Vector3.Zero(),o=d.Quaternion.Identity(),s=d.Vector3.One(),u=r.thinInstanceGetWorldMatrices(),l=d.TmpVectors.Vector3[2],c=d.TmpVectors.Quaternion[1],f=d.TmpVectors.Vector3[3],h=!1,p=!1,_=!1,g=new Float32Array(3*r.thinInstanceCount),m=new Float32Array(4*r.thinInstanceCount),x=new Float32Array(3*r.thinInstanceCount),y=0,T=0,v=u;T1){n._wasUsed=!0,t.extensions||(t.extensions={});var o={emissiveStrength:i},s=r.emissiveColor.scale(1/o.emissiveStrength);t.emissiveFactor=s.asArray(),t.extensions[X]=o}return e(t)}))},e}();v.RegisterExtension(X,(function(e){return new Z}));var J=0,$=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==$){$.BABYLON=$.BABYLON||{};var ee=$.BABYLON;ee.GLTF2=ee.GLTF2||{},ee.GLTF2.Exporter=ee.GLTF2.Exporter||{},ee.GLTF2.Exporter.Extensions=ee.GLTF2.Exporter.Extensions||{};var te=[];for(var re in e)ee[re]=e[re],te.push(re);for(var re in t)ee[re]=t[re],te.push(re);for(var re in r)ee[re]=r[re],te.push(re);for(var re in i)ee.GLTF2.Exporter.Extensions[re]=i[re],te.push(re);for(var re in o)te.indexOf(re)>-1||(ee.GLTF2.Exporter[re]=o[re])}const ne=s})(),a.default})())); +//# sourceMappingURL=babylon.glTF2Serializer.min.js.map \ No newline at end of file diff --git a/libs/babylonjs/6.46.0/babylon.glTFFileLoader.js b/libs/babylonjs/6.46.0/babylon.glTFFileLoader.js new file mode 100644 index 00000000..cec58098 --- /dev/null +++ b/libs/babylonjs/6.46.0/babylon.glTFFileLoader.js @@ -0,0 +1,11147 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("babylonjs")); + else if(typeof define === 'function' && define.amd) + define("babylonjs-loaders", ["babylonjs"], factory); + else if(typeof exports === 'object') + exports["babylonjs-loaders"] = factory(require("babylonjs")); + else + root["LOADERS"] = factory(root["BABYLON"]); +})((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), (__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__) => { +return /******/ (() => { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ "../../../dev/loaders/src/glTF/1.0/glTFBinaryExtension.ts": +/*!****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/1.0/glTFBinaryExtension.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFBinaryExtension: () => (/* binding */ GLTFBinaryExtension) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoader */ "../../../dev/loaders/src/glTF/1.0/glTFLoader.ts"); +/* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoaderUtils */ "../../../dev/loaders/src/glTF/1.0/glTFLoaderUtils.ts"); +/* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts"); + + + + +var BinaryExtensionBufferName = "binary_glTF"; +/** + * @internal + * @deprecated + */ +var GLTFBinaryExtension = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__extends)(GLTFBinaryExtension, _super); + function GLTFBinaryExtension() { + return _super.call(this, "KHR_binary_glTF") || this; + } + GLTFBinaryExtension.prototype.loadRuntimeAsync = function (scene, data, rootUrl, onSuccess) { + var extensionsUsed = data.json.extensionsUsed; + if (!extensionsUsed || extensionsUsed.indexOf(this.name) === -1 || !data.bin) { + return false; + } + this._bin = data.bin; + onSuccess(_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl)); + return true; + }; + GLTFBinaryExtension.prototype.loadBufferAsync = function (gltfRuntime, id, onSuccess, onError) { + if (gltfRuntime.extensionsUsed.indexOf(this.name) === -1) { + return false; + } + if (id !== BinaryExtensionBufferName) { + return false; + } + this._bin.readAsync(0, this._bin.byteLength).then(onSuccess, function (error) { return onError(error.message); }); + return true; + }; + GLTFBinaryExtension.prototype.loadTextureBufferAsync = function (gltfRuntime, id, onSuccess) { + var texture = gltfRuntime.textures[id]; + var source = gltfRuntime.images[texture.source]; + if (!source.extensions || !(this.name in source.extensions)) { + return false; + } + var sourceExt = source.extensions[this.name]; + var bufferView = gltfRuntime.bufferViews[sourceExt.bufferView]; + var buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_1__.GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EComponentType.UNSIGNED_BYTE); + onSuccess(buffer); + return true; + }; + GLTFBinaryExtension.prototype.loadShaderStringAsync = function (gltfRuntime, id, onSuccess) { + var shader = gltfRuntime.shaders[id]; + if (!shader.extensions || !(this.name in shader.extensions)) { + return false; + } + var binaryExtensionShader = shader.extensions[this.name]; + var bufferView = gltfRuntime.bufferViews[binaryExtensionShader.bufferView]; + var shaderBytes = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_1__.GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EComponentType.UNSIGNED_BYTE); + setTimeout(function () { + var shaderString = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_1__.GLTFUtils.DecodeBufferToText(shaderBytes); + onSuccess(shaderString); + }); + return true; + }; + return GLTFBinaryExtension; +}(_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderExtension)); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(new GLTFBinaryExtension()); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/1.0/glTFLoader.ts": +/*!*******************************************************!*\ + !*** ../../../dev/loaders/src/glTF/1.0/glTFLoader.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFLoader: () => (/* binding */ GLTFLoader), +/* harmony export */ GLTFLoaderBase: () => (/* binding */ GLTFLoaderBase), +/* harmony export */ GLTFLoaderExtension: () => (/* binding */ GLTFLoaderExtension) +/* harmony export */ }); +/* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Engines/constants */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderUtils */ "../../../dev/loaders/src/glTF/1.0/glTFLoaderUtils.ts"); +/* harmony import */ var _glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../glTFFileLoader */ "../../../dev/loaders/src/glTF/glTFFileLoader.ts"); + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/** + * Tokenizer. Used for shaders compatibility + * Automatically map world, view, projection, worldViewProjection, attributes and so on + */ +var ETokenType; +(function (ETokenType) { + ETokenType[ETokenType["IDENTIFIER"] = 1] = "IDENTIFIER"; + ETokenType[ETokenType["UNKNOWN"] = 2] = "UNKNOWN"; + ETokenType[ETokenType["END_OF_INPUT"] = 3] = "END_OF_INPUT"; +})(ETokenType || (ETokenType = {})); +var Tokenizer = /** @class */ (function () { + function Tokenizer(toParse) { + this._pos = 0; + this.currentToken = ETokenType.UNKNOWN; + this.currentIdentifier = ""; + this.currentString = ""; + this.isLetterOrDigitPattern = /^[a-zA-Z0-9]+$/; + this._toParse = toParse; + this._maxPos = toParse.length; + } + Tokenizer.prototype.getNextToken = function () { + if (this.isEnd()) { + return ETokenType.END_OF_INPUT; + } + this.currentString = this.read(); + this.currentToken = ETokenType.UNKNOWN; + if (this.currentString === "_" || this.isLetterOrDigitPattern.test(this.currentString)) { + this.currentToken = ETokenType.IDENTIFIER; + this.currentIdentifier = this.currentString; + while (!this.isEnd() && (this.isLetterOrDigitPattern.test((this.currentString = this.peek())) || this.currentString === "_")) { + this.currentIdentifier += this.currentString; + this.forward(); + } + } + return this.currentToken; + }; + Tokenizer.prototype.peek = function () { + return this._toParse[this._pos]; + }; + Tokenizer.prototype.read = function () { + return this._toParse[this._pos++]; + }; + Tokenizer.prototype.forward = function () { + this._pos++; + }; + Tokenizer.prototype.isEnd = function () { + return this._pos >= this._maxPos; + }; + return Tokenizer; +}()); +/** + * Values + */ +var glTFTransforms = ["MODEL", "VIEW", "PROJECTION", "MODELVIEW", "MODELVIEWPROJECTION", "JOINTMATRIX"]; +var babylonTransforms = ["world", "view", "projection", "worldView", "worldViewProjection", "mBones"]; +var glTFAnimationPaths = ["translation", "rotation", "scale"]; +var babylonAnimationPaths = ["position", "rotationQuaternion", "scaling"]; +/** + * Parse + * @param parsedBuffers + * @param gltfRuntime + */ +var parseBuffers = function (parsedBuffers, gltfRuntime) { + for (var buf in parsedBuffers) { + var parsedBuffer = parsedBuffers[buf]; + gltfRuntime.buffers[buf] = parsedBuffer; + gltfRuntime.buffersCount++; + } +}; +var parseShaders = function (parsedShaders, gltfRuntime) { + for (var sha in parsedShaders) { + var parsedShader = parsedShaders[sha]; + gltfRuntime.shaders[sha] = parsedShader; + gltfRuntime.shaderscount++; + } +}; +var parseObject = function (parsedObjects, runtimeProperty, gltfRuntime) { + for (var object in parsedObjects) { + var parsedObject = parsedObjects[object]; + gltfRuntime[runtimeProperty][object] = parsedObject; + } +}; +/** + * Utils + * @param buffer + */ +var normalizeUVs = function (buffer) { + if (!buffer) { + return; + } + for (var i = 0; i < buffer.length / 2; i++) { + buffer[i * 2 + 1] = 1.0 - buffer[i * 2 + 1]; + } +}; +var getAttribute = function (attributeParameter) { + if (attributeParameter.semantic === "NORMAL") { + return "normal"; + } + else if (attributeParameter.semantic === "POSITION") { + return "position"; + } + else if (attributeParameter.semantic === "JOINT") { + return "matricesIndices"; + } + else if (attributeParameter.semantic === "WEIGHT") { + return "matricesWeights"; + } + else if (attributeParameter.semantic === "COLOR") { + return "color"; + } + else if (attributeParameter.semantic && attributeParameter.semantic.indexOf("TEXCOORD_") !== -1) { + var channel = Number(attributeParameter.semantic.split("_")[1]); + return "uv" + (channel === 0 ? "" : channel + 1); + } + return null; +}; +/** + * Loads and creates animations + * @param gltfRuntime + */ +var loadAnimations = function (gltfRuntime) { + for (var anim in gltfRuntime.animations) { + var animation = gltfRuntime.animations[anim]; + if (!animation.channels || !animation.samplers) { + continue; + } + var lastAnimation = null; + for (var i = 0; i < animation.channels.length; i++) { + // Get parameters and load buffers + var channel = animation.channels[i]; + var sampler = animation.samplers[channel.sampler]; + if (!sampler) { + continue; + } + var inputData = null; + var outputData = null; + if (animation.parameters) { + inputData = animation.parameters[sampler.input]; + outputData = animation.parameters[sampler.output]; + } + else { + inputData = sampler.input; + outputData = sampler.output; + } + var bufferInput = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, gltfRuntime.accessors[inputData]); + var bufferOutput = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, gltfRuntime.accessors[outputData]); + var targetId = channel.target.id; + var targetNode = gltfRuntime.scene.getNodeById(targetId); + if (targetNode === null) { + targetNode = gltfRuntime.scene.getNodeByName(targetId); + } + if (targetNode === null) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Creating animation named " + anim + ". But cannot find node named " + targetId + " to attach to"); + continue; + } + var isBone = targetNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone; + // Get target path (position, rotation or scaling) + var targetPath = channel.target.path; + var targetPathIndex = glTFAnimationPaths.indexOf(targetPath); + if (targetPathIndex !== -1) { + targetPath = babylonAnimationPaths[targetPathIndex]; + } + // Determine animation type + var animationType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_MATRIX; + if (!isBone) { + if (targetPath === "rotationQuaternion") { + animationType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_QUATERNION; + targetNode.rotationQuaternion = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion(); + } + else { + animationType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_VECTOR3; + } + } + // Create animation and key frames + var babylonAnimation = null; + var keys = []; + var arrayOffset = 0; + var modifyKey = false; + if (isBone && lastAnimation && lastAnimation.getKeys().length === bufferInput.length) { + babylonAnimation = lastAnimation; + modifyKey = true; + } + if (!modifyKey) { + gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer; + babylonAnimation = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation(anim, isBone ? "_matrix" : targetPath, 1, animationType, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONLOOPMODE_CYCLE); + gltfRuntime.scene._blockEntityCollection = false; + } + // For each frame + for (var j = 0; j < bufferInput.length; j++) { + var value = null; + if (targetPath === "rotationQuaternion") { + // VEC4 + value = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2], bufferOutput[arrayOffset + 3]]); + arrayOffset += 4; + } + else { + // Position and scaling are VEC3 + value = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2]]); + arrayOffset += 3; + } + if (isBone) { + var bone = targetNode; + var translation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(); + var rotationQuaternion = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion(); + var scaling = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(); + // Warning on decompose + var mat = bone.getBaseMatrix(); + if (modifyKey && lastAnimation) { + mat = lastAnimation.getKeys()[j].value; + } + mat.decompose(scaling, rotationQuaternion, translation); + if (targetPath === "position") { + translation = value; + } + else if (targetPath === "rotationQuaternion") { + rotationQuaternion = value; + } + else { + scaling = value; + } + value = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Compose(scaling, rotationQuaternion, translation); + } + if (!modifyKey) { + keys.push({ + frame: bufferInput[j], + value: value, + }); + } + else if (lastAnimation) { + lastAnimation.getKeys()[j].value = value; + } + } + // Finish + if (!modifyKey && babylonAnimation) { + babylonAnimation.setKeys(keys); + targetNode.animations.push(babylonAnimation); + } + lastAnimation = babylonAnimation; + gltfRuntime.scene.stopAnimation(targetNode); + gltfRuntime.scene.beginAnimation(targetNode, 0, bufferInput[bufferInput.length - 1], true, 1.0); + } + } +}; +/** + * @returns the bones transformation matrix + * @param node + */ +var configureBoneTransformation = function (node) { + var mat = null; + if (node.translation || node.rotation || node.scale) { + var scale = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.scale || [1, 1, 1]); + var rotation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray(node.rotation || [0, 0, 0, 1]); + var position = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.translation || [0, 0, 0]); + mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Compose(scale, rotation, position); + } + else { + mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.FromArray(node.matrix); + } + return mat; +}; +/** + * Returns the parent bone + * @param gltfRuntime + * @param skins + * @param jointName + * @param newSkeleton + * @returns the parent bone + */ +var getParentBone = function (gltfRuntime, skins, jointName, newSkeleton) { + // Try to find + for (var i = 0; i < newSkeleton.bones.length; i++) { + if (newSkeleton.bones[i].name === jointName) { + return newSkeleton.bones[i]; + } + } + // Not found, search in gltf nodes + var nodes = gltfRuntime.nodes; + for (var nde in nodes) { + var node = nodes[nde]; + if (!node.jointName) { + continue; + } + var children = node.children; + for (var i = 0; i < children.length; i++) { + var child = gltfRuntime.nodes[children[i]]; + if (!child.jointName) { + continue; + } + if (child.jointName === jointName) { + var mat = configureBoneTransformation(node); + var bone = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone(node.name || "", newSkeleton, getParentBone(gltfRuntime, skins, node.jointName, newSkeleton), mat); + bone.id = nde; + return bone; + } + } + } + return null; +}; +/** + * Returns the appropriate root node + * @param nodesToRoot + * @param id + * @returns the root node + */ +var getNodeToRoot = function (nodesToRoot, id) { + for (var i = 0; i < nodesToRoot.length; i++) { + var nodeToRoot = nodesToRoot[i]; + for (var j = 0; j < nodeToRoot.node.children.length; j++) { + var child = nodeToRoot.node.children[j]; + if (child === id) { + return nodeToRoot.bone; + } + } + } + return null; +}; +/** + * Returns the node with the joint name + * @param gltfRuntime + * @param jointName + * @returns the node with the joint name + */ +var getJointNode = function (gltfRuntime, jointName) { + var nodes = gltfRuntime.nodes; + var node = nodes[jointName]; + if (node) { + return { + node: node, + id: jointName, + }; + } + for (var nde in nodes) { + node = nodes[nde]; + if (node.jointName === jointName) { + return { + node: node, + id: nde, + }; + } + } + return null; +}; +/** + * Checks if a nodes is in joints + * @param skins + * @param id + * @returns true if the node is in joints, else false + */ +var nodeIsInJoints = function (skins, id) { + for (var i = 0; i < skins.jointNames.length; i++) { + if (skins.jointNames[i] === id) { + return true; + } + } + return false; +}; +/** + * Fills the nodes to root for bones and builds hierarchy + * @param gltfRuntime + * @param newSkeleton + * @param skins + * @param nodesToRoot + */ +var getNodesToRoot = function (gltfRuntime, newSkeleton, skins, nodesToRoot) { + // Creates nodes for root + for (var nde in gltfRuntime.nodes) { + var node = gltfRuntime.nodes[nde]; + var id = nde; + if (!node.jointName || nodeIsInJoints(skins, node.jointName)) { + continue; + } + // Create node to root bone + var mat = configureBoneTransformation(node); + var bone = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone(node.name || "", newSkeleton, null, mat); + bone.id = id; + nodesToRoot.push({ bone: bone, node: node, id: id }); + } + // Parenting + for (var i = 0; i < nodesToRoot.length; i++) { + var nodeToRoot = nodesToRoot[i]; + var children = nodeToRoot.node.children; + for (var j = 0; j < children.length; j++) { + var child = null; + for (var k = 0; k < nodesToRoot.length; k++) { + if (nodesToRoot[k].id === children[j]) { + child = nodesToRoot[k]; + break; + } + } + if (child) { + child.bone._parent = nodeToRoot.bone; + nodeToRoot.bone.children.push(child.bone); + } + } + } +}; +/** + * Imports a skeleton + * @param gltfRuntime + * @param skins + * @param mesh + * @param newSkeleton + * @returns the bone name + */ +var importSkeleton = function (gltfRuntime, skins, mesh, newSkeleton) { + if (!newSkeleton) { + newSkeleton = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Skeleton(skins.name || "", "", gltfRuntime.scene); + } + if (!skins.babylonSkeleton) { + return newSkeleton; + } + // Find the root bones + var nodesToRoot = []; + var nodesToRootToAdd = []; + getNodesToRoot(gltfRuntime, newSkeleton, skins, nodesToRoot); + newSkeleton.bones = []; + // Joints + for (var i = 0; i < skins.jointNames.length; i++) { + var jointNode = getJointNode(gltfRuntime, skins.jointNames[i]); + if (!jointNode) { + continue; + } + var node = jointNode.node; + if (!node) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Joint named " + skins.jointNames[i] + " does not exist"); + continue; + } + var id = jointNode.id; + // Optimize, if the bone already exists... + var existingBone = gltfRuntime.scene.getBoneById(id); + if (existingBone) { + newSkeleton.bones.push(existingBone); + continue; + } + // Search for parent bone + var foundBone = false; + var parentBone = null; + for (var j = 0; j < i; j++) { + var jointNode_1 = getJointNode(gltfRuntime, skins.jointNames[j]); + if (!jointNode_1) { + continue; + } + var joint = jointNode_1.node; + if (!joint) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Joint named " + skins.jointNames[j] + " does not exist when looking for parent"); + continue; + } + var children = joint.children; + if (!children) { + continue; + } + foundBone = false; + for (var k = 0; k < children.length; k++) { + if (children[k] === id) { + parentBone = getParentBone(gltfRuntime, skins, skins.jointNames[j], newSkeleton); + foundBone = true; + break; + } + } + if (foundBone) { + break; + } + } + // Create bone + var mat = configureBoneTransformation(node); + if (!parentBone && nodesToRoot.length > 0) { + parentBone = getNodeToRoot(nodesToRoot, id); + if (parentBone) { + if (nodesToRootToAdd.indexOf(parentBone) === -1) { + nodesToRootToAdd.push(parentBone); + } + } + } + var bone = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone(node.jointName || "", newSkeleton, parentBone, mat); + bone.id = id; + } + // Polish + var bones = newSkeleton.bones; + newSkeleton.bones = []; + for (var i = 0; i < skins.jointNames.length; i++) { + var jointNode = getJointNode(gltfRuntime, skins.jointNames[i]); + if (!jointNode) { + continue; + } + for (var j = 0; j < bones.length; j++) { + if (bones[j].id === jointNode.id) { + newSkeleton.bones.push(bones[j]); + break; + } + } + } + newSkeleton.prepare(); + // Finish + for (var i = 0; i < nodesToRootToAdd.length; i++) { + newSkeleton.bones.push(nodesToRootToAdd[i]); + } + return newSkeleton; +}; +/** + * Imports a mesh and its geometries + * @param gltfRuntime + * @param node + * @param meshes + * @param id + * @param newMesh + * @returns the new mesh + */ +var importMesh = function (gltfRuntime, node, meshes, id, newMesh) { + if (!newMesh) { + gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer; + newMesh = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Mesh(node.name || "", gltfRuntime.scene); + newMesh._parentContainer = gltfRuntime.assetContainer; + gltfRuntime.scene._blockEntityCollection = false; + newMesh.id = id; + } + if (!node.babylonNode) { + return newMesh; + } + var subMaterials = []; + var vertexData = null; + var verticesStarts = []; + var verticesCounts = []; + var indexStarts = []; + var indexCounts = []; + for (var meshIndex = 0; meshIndex < meshes.length; meshIndex++) { + var meshId = meshes[meshIndex]; + var mesh = gltfRuntime.meshes[meshId]; + if (!mesh) { + continue; + } + // Positions, normals and UVs + for (var i = 0; i < mesh.primitives.length; i++) { + // Temporary vertex data + var tempVertexData = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexData(); + var primitive = mesh.primitives[i]; + if (primitive.mode !== 4) { + // continue; + } + var attributes = primitive.attributes; + var accessor = null; + var buffer = null; + // Set positions, normal and uvs + for (var semantic in attributes) { + // Link accessor and buffer view + accessor = gltfRuntime.accessors[attributes[semantic]]; + buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, accessor); + if (semantic === "NORMAL") { + tempVertexData.normals = new Float32Array(buffer.length); + tempVertexData.normals.set(buffer); + } + else if (semantic === "POSITION") { + if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.HomogeneousCoordinates) { + tempVertexData.positions = new Float32Array(buffer.length - buffer.length / 4); + for (var j = 0; j < buffer.length; j += 4) { + tempVertexData.positions[j] = buffer[j]; + tempVertexData.positions[j + 1] = buffer[j + 1]; + tempVertexData.positions[j + 2] = buffer[j + 2]; + } + } + else { + tempVertexData.positions = new Float32Array(buffer.length); + tempVertexData.positions.set(buffer); + } + verticesCounts.push(tempVertexData.positions.length); + } + else if (semantic.indexOf("TEXCOORD_") !== -1) { + var channel = Number(semantic.split("_")[1]); + var uvKind = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.UVKind + (channel === 0 ? "" : channel + 1); + var uvs = new Float32Array(buffer.length); + uvs.set(buffer); + normalizeUVs(uvs); + tempVertexData.set(uvs, uvKind); + } + else if (semantic === "JOINT") { + tempVertexData.matricesIndices = new Float32Array(buffer.length); + tempVertexData.matricesIndices.set(buffer); + } + else if (semantic === "WEIGHT") { + tempVertexData.matricesWeights = new Float32Array(buffer.length); + tempVertexData.matricesWeights.set(buffer); + } + else if (semantic === "COLOR") { + tempVertexData.colors = new Float32Array(buffer.length); + tempVertexData.colors.set(buffer); + } + } + // Indices + accessor = gltfRuntime.accessors[primitive.indices]; + if (accessor) { + buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, accessor); + tempVertexData.indices = new Int32Array(buffer.length); + tempVertexData.indices.set(buffer); + indexCounts.push(tempVertexData.indices.length); + } + else { + // Set indices on the fly + var indices = []; + for (var j = 0; j < tempVertexData.positions.length / 3; j++) { + indices.push(j); + } + tempVertexData.indices = new Int32Array(indices); + indexCounts.push(tempVertexData.indices.length); + } + if (!vertexData) { + vertexData = tempVertexData; + } + else { + vertexData.merge(tempVertexData); + } + // Sub material + var material_1 = gltfRuntime.scene.getMaterialById(primitive.material); + subMaterials.push(material_1 === null ? _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetDefaultMaterial(gltfRuntime.scene) : material_1); + // Update vertices start and index start + verticesStarts.push(verticesStarts.length === 0 ? 0 : verticesStarts[verticesStarts.length - 1] + verticesCounts[verticesCounts.length - 2]); + indexStarts.push(indexStarts.length === 0 ? 0 : indexStarts[indexStarts.length - 1] + indexCounts[indexCounts.length - 2]); + } + } + var material; + gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer; + if (subMaterials.length > 1) { + material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.MultiMaterial("multimat" + id, gltfRuntime.scene); + material.subMaterials = subMaterials; + } + else { + material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.StandardMaterial("multimat" + id, gltfRuntime.scene); + } + if (subMaterials.length === 1) { + material = subMaterials[0]; + } + material._parentContainer = gltfRuntime.assetContainer; + if (!newMesh.material) { + newMesh.material = material; + } + // Apply geometry + new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Geometry(id, gltfRuntime.scene, vertexData, false, newMesh); + newMesh.computeWorldMatrix(true); + gltfRuntime.scene._blockEntityCollection = false; + // Apply submeshes + newMesh.subMeshes = []; + var index = 0; + for (var meshIndex = 0; meshIndex < meshes.length; meshIndex++) { + var meshId = meshes[meshIndex]; + var mesh = gltfRuntime.meshes[meshId]; + if (!mesh) { + continue; + } + for (var i = 0; i < mesh.primitives.length; i++) { + if (mesh.primitives[i].mode !== 4) { + //continue; + } + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.SubMesh.AddToMesh(index, verticesStarts[index], verticesCounts[index], indexStarts[index], indexCounts[index], newMesh, newMesh, true); + index++; + } + } + // Finish + return newMesh; +}; +/** + * Configure node transformation from position, rotation and scaling + * @param newNode + * @param position + * @param rotation + * @param scaling + */ +var configureNode = function (newNode, position, rotation, scaling) { + if (newNode.position) { + newNode.position = position; + } + if (newNode.rotationQuaternion || newNode.rotation) { + newNode.rotationQuaternion = rotation; + } + if (newNode.scaling) { + newNode.scaling = scaling; + } +}; +/** + * Configures node from transformation matrix + * @param newNode + * @param node + */ +var configureNodeFromMatrix = function (newNode, node) { + if (node.matrix) { + var position = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0); + var rotation = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion(); + var scaling = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0); + var mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.FromArray(node.matrix); + mat.decompose(scaling, rotation, position); + configureNode(newNode, position, rotation, scaling); + } + else if (node.translation && node.rotation && node.scale) { + configureNode(newNode, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.translation), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray(node.rotation), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.scale)); + } + newNode.computeWorldMatrix(true); +}; +/** + * Imports a node + * @param gltfRuntime + * @param node + * @param id + * @returns the newly imported node + */ +var importNode = function (gltfRuntime, node, id) { + var lastNode = null; + if (gltfRuntime.importOnlyMeshes && (node.skin || node.meshes)) { + if (gltfRuntime.importMeshesNames && gltfRuntime.importMeshesNames.length > 0 && gltfRuntime.importMeshesNames.indexOf(node.name || "") === -1) { + return null; + } + } + // Meshes + if (node.skin) { + if (node.meshes) { + var skin = gltfRuntime.skins[node.skin]; + var newMesh = importMesh(gltfRuntime, node, node.meshes, id, node.babylonNode); + newMesh.skeleton = gltfRuntime.scene.getLastSkeletonById(node.skin); + if (newMesh.skeleton === null) { + newMesh.skeleton = importSkeleton(gltfRuntime, skin, newMesh, skin.babylonSkeleton); + if (!skin.babylonSkeleton) { + skin.babylonSkeleton = newMesh.skeleton; + } + } + lastNode = newMesh; + } + } + else if (node.meshes) { + /** + * Improve meshes property + */ + var newMesh = importMesh(gltfRuntime, node, node.mesh ? [node.mesh] : node.meshes, id, node.babylonNode); + lastNode = newMesh; + } + // Lights + else if (node.light && !node.babylonNode && !gltfRuntime.importOnlyMeshes) { + var light = gltfRuntime.lights[node.light]; + if (light) { + if (light.type === "ambient") { + var ambienLight = light[light.type]; + var hemiLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.HemisphericLight(node.light, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene); + hemiLight.name = node.name || ""; + if (ambienLight.color) { + hemiLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(ambienLight.color); + } + lastNode = hemiLight; + } + else if (light.type === "directional") { + var directionalLight = light[light.type]; + var dirLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.DirectionalLight(node.light, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene); + dirLight.name = node.name || ""; + if (directionalLight.color) { + dirLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(directionalLight.color); + } + lastNode = dirLight; + } + else if (light.type === "point") { + var pointLight = light[light.type]; + var ptLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.PointLight(node.light, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene); + ptLight.name = node.name || ""; + if (pointLight.color) { + ptLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(pointLight.color); + } + lastNode = ptLight; + } + else if (light.type === "spot") { + var spotLight = light[light.type]; + var spLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.SpotLight(node.light, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), 0, 0, gltfRuntime.scene); + spLight.name = node.name || ""; + if (spotLight.color) { + spLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(spotLight.color); + } + if (spotLight.fallOfAngle) { + spLight.angle = spotLight.fallOfAngle; + } + if (spotLight.fallOffExponent) { + spLight.exponent = spotLight.fallOffExponent; + } + lastNode = spLight; + } + } + } + // Cameras + else if (node.camera && !node.babylonNode && !gltfRuntime.importOnlyMeshes) { + var camera = gltfRuntime.cameras[node.camera]; + if (camera) { + gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer; + if (camera.type === "orthographic") { + var orthoCamera = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.FreeCamera(node.camera, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene, false); + orthoCamera.name = node.name || ""; + orthoCamera.mode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Camera.ORTHOGRAPHIC_CAMERA; + orthoCamera.attachControl(); + lastNode = orthoCamera; + orthoCamera._parentContainer = gltfRuntime.assetContainer; + } + else if (camera.type === "perspective") { + var perspectiveCamera = camera[camera.type]; + var persCamera = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.FreeCamera(node.camera, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene, false); + persCamera.name = node.name || ""; + persCamera.attachControl(); + if (!perspectiveCamera.aspectRatio) { + perspectiveCamera.aspectRatio = gltfRuntime.scene.getEngine().getRenderWidth() / gltfRuntime.scene.getEngine().getRenderHeight(); + } + if (perspectiveCamera.znear && perspectiveCamera.zfar) { + persCamera.maxZ = perspectiveCamera.zfar; + persCamera.minZ = perspectiveCamera.znear; + } + lastNode = persCamera; + persCamera._parentContainer = gltfRuntime.assetContainer; + } + gltfRuntime.scene._blockEntityCollection = false; + } + } + // Empty node + if (!node.jointName) { + if (node.babylonNode) { + return node.babylonNode; + } + else if (lastNode === null) { + gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer; + var dummy = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Mesh(node.name || "", gltfRuntime.scene); + dummy._parentContainer = gltfRuntime.assetContainer; + gltfRuntime.scene._blockEntityCollection = false; + node.babylonNode = dummy; + lastNode = dummy; + } + } + if (lastNode !== null) { + if (node.matrix && lastNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Mesh) { + configureNodeFromMatrix(lastNode, node); + } + else { + var translation = node.translation || [0, 0, 0]; + var rotation = node.rotation || [0, 0, 0, 1]; + var scale = node.scale || [1, 1, 1]; + configureNode(lastNode, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(translation), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray(rotation), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(scale)); + } + lastNode.updateCache(true); + node.babylonNode = lastNode; + } + return lastNode; +}; +/** + * Traverses nodes and creates them + * @param gltfRuntime + * @param id + * @param parent + * @param meshIncluded + */ +var traverseNodes = function (gltfRuntime, id, parent, meshIncluded) { + if (meshIncluded === void 0) { meshIncluded = false; } + var node = gltfRuntime.nodes[id]; + var newNode = null; + if (gltfRuntime.importOnlyMeshes && !meshIncluded && gltfRuntime.importMeshesNames) { + if (gltfRuntime.importMeshesNames.indexOf(node.name || "") !== -1 || gltfRuntime.importMeshesNames.length === 0) { + meshIncluded = true; + } + else { + meshIncluded = false; + } + } + else { + meshIncluded = true; + } + if (!node.jointName && meshIncluded) { + newNode = importNode(gltfRuntime, node, id); + if (newNode !== null) { + newNode.id = id; + newNode.parent = parent; + } + } + if (node.children) { + for (var i = 0; i < node.children.length; i++) { + traverseNodes(gltfRuntime, node.children[i], newNode, meshIncluded); + } + } +}; +/** + * do stuff after buffers, shaders are loaded (e.g. hook up materials, load animations, etc.) + * @param gltfRuntime + */ +var postLoad = function (gltfRuntime) { + // Nodes + var currentScene = gltfRuntime.currentScene; + if (currentScene) { + for (var i = 0; i < currentScene.nodes.length; i++) { + traverseNodes(gltfRuntime, currentScene.nodes[i], null); + } + } + else { + for (var thing in gltfRuntime.scenes) { + currentScene = gltfRuntime.scenes[thing]; + for (var i = 0; i < currentScene.nodes.length; i++) { + traverseNodes(gltfRuntime, currentScene.nodes[i], null); + } + } + } + // Set animations + loadAnimations(gltfRuntime); + for (var i = 0; i < gltfRuntime.scene.skeletons.length; i++) { + var skeleton = gltfRuntime.scene.skeletons[i]; + gltfRuntime.scene.beginAnimation(skeleton, 0, Number.MAX_VALUE, true, 1.0); + } +}; +/** + * onBind shaderrs callback to set uniforms and matrices + * @param mesh + * @param gltfRuntime + * @param unTreatedUniforms + * @param shaderMaterial + * @param technique + * @param material + * @param onSuccess + */ +var onBindShaderMaterial = function (mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess) { + var materialValues = material.values || technique.parameters; + for (var unif in unTreatedUniforms) { + var uniform = unTreatedUniforms[unif]; + var type = uniform.type; + if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT2 || type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT3 || type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT4) { + if (uniform.semantic && !uniform.source && !uniform.node) { + _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetMatrix(gltfRuntime.scene, mesh, uniform, unif, shaderMaterial.getEffect()); + } + else if (uniform.semantic && (uniform.source || uniform.node)) { + var source = gltfRuntime.scene.getNodeByName(uniform.source || uniform.node || ""); + if (source === null) { + source = gltfRuntime.scene.getNodeById(uniform.source || uniform.node || ""); + } + if (source === null) { + continue; + } + _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetMatrix(gltfRuntime.scene, source, uniform, unif, shaderMaterial.getEffect()); + } + } + else { + var value = materialValues[technique.uniforms[unif]]; + if (!value) { + continue; + } + if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.SAMPLER_2D) { + var texture = gltfRuntime.textures[material.values ? value : uniform.value].babylonTexture; + if (texture === null || texture === undefined) { + continue; + } + shaderMaterial.getEffect().setTexture(unif, texture); + } + else { + _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetUniform(shaderMaterial.getEffect(), unif, value, type); + } + } + } + onSuccess(shaderMaterial); +}; +/** + * Prepare uniforms to send the only one time + * Loads the appropriate textures + * @param gltfRuntime + * @param shaderMaterial + * @param technique + * @param material + */ +var prepareShaderMaterialUniforms = function (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms) { + var materialValues = material.values || technique.parameters; + var techniqueUniforms = technique.uniforms; + var _loop_1 = function (unif) { + var uniform = unTreatedUniforms[unif]; + var type = uniform.type; + var value = materialValues[techniqueUniforms[unif]]; + if (value === undefined) { + // In case the value is the same for all materials + value = uniform.value; + } + if (!value) { + return "continue"; + } + var onLoadTexture = function (uniformName) { + return function (texture) { + if (uniform.value && uniformName) { + // Static uniform + shaderMaterial.setTexture(uniformName, texture); + delete unTreatedUniforms[uniformName]; + } + }; + }; + // Texture (sampler2D) + if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.SAMPLER_2D) { + GLTFLoaderExtension.LoadTextureAsync(gltfRuntime, material.values ? value : uniform.value, onLoadTexture(unif), function () { return onLoadTexture(null); }); + } + // Others + else { + if (uniform.value && _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetUniform(shaderMaterial, unif, material.values ? value : uniform.value, type)) { + // Static uniform + delete unTreatedUniforms[unif]; + } + } + }; + /** + * Prepare values here (not matrices) + */ + for (var unif in unTreatedUniforms) { + _loop_1(unif); + } +}; +/** + * Shader compilation failed + * @param program + * @param shaderMaterial + * @param onError + * @returns callback when shader is compiled + */ +var onShaderCompileError = function (program, shaderMaterial, onError) { + return function (effect, error) { + shaderMaterial.dispose(true); + onError("Cannot compile program named " + program.name + ". Error: " + error + ". Default material will be applied"); + }; +}; +/** + * Shader compilation success + * @param gltfRuntime + * @param shaderMaterial + * @param technique + * @param material + * @param unTreatedUniforms + * @param onSuccess + * @returns callback when shader is compiled + */ +var onShaderCompileSuccess = function (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess) { + return function (_) { + prepareShaderMaterialUniforms(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms); + shaderMaterial.onBind = function (mesh) { + onBindShaderMaterial(mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess); + }; + }; +}; +/** + * Returns the appropriate uniform if already handled by babylon + * @param tokenizer + * @param technique + * @param unTreatedUniforms + * @returns the name of the uniform handled by babylon + */ +var parseShaderUniforms = function (tokenizer, technique, unTreatedUniforms) { + for (var unif in technique.uniforms) { + var uniform = technique.uniforms[unif]; + var uniformParameter = technique.parameters[uniform]; + if (tokenizer.currentIdentifier === unif) { + if (uniformParameter.semantic && !uniformParameter.source && !uniformParameter.node) { + var transformIndex = glTFTransforms.indexOf(uniformParameter.semantic); + if (transformIndex !== -1) { + delete unTreatedUniforms[unif]; + return babylonTransforms[transformIndex]; + } + } + } + } + return tokenizer.currentIdentifier; +}; +/** + * All shaders loaded. Create materials one by one + * @param gltfRuntime + */ +var importMaterials = function (gltfRuntime) { + // Create materials + for (var mat in gltfRuntime.materials) { + GLTFLoaderExtension.LoadMaterialAsync(gltfRuntime, mat, function () { }, function () { }); + } +}; +/** + * Implementation of the base glTF spec + * @internal + */ +var GLTFLoaderBase = /** @class */ (function () { + function GLTFLoaderBase() { + } + GLTFLoaderBase.CreateRuntime = function (parsedData, scene, rootUrl) { + var gltfRuntime = { + extensions: {}, + accessors: {}, + buffers: {}, + bufferViews: {}, + meshes: {}, + lights: {}, + cameras: {}, + nodes: {}, + images: {}, + textures: {}, + shaders: {}, + programs: {}, + samplers: {}, + techniques: {}, + materials: {}, + animations: {}, + skins: {}, + extensionsUsed: [], + scenes: {}, + buffersCount: 0, + shaderscount: 0, + scene: scene, + rootUrl: rootUrl, + loadedBufferCount: 0, + loadedBufferViews: {}, + loadedShaderCount: 0, + importOnlyMeshes: false, + dummyNodes: [], + assetContainer: null, + }; + // Parse + if (parsedData.extensions) { + parseObject(parsedData.extensions, "extensions", gltfRuntime); + } + if (parsedData.extensionsUsed) { + parseObject(parsedData.extensionsUsed, "extensionsUsed", gltfRuntime); + } + if (parsedData.buffers) { + parseBuffers(parsedData.buffers, gltfRuntime); + } + if (parsedData.bufferViews) { + parseObject(parsedData.bufferViews, "bufferViews", gltfRuntime); + } + if (parsedData.accessors) { + parseObject(parsedData.accessors, "accessors", gltfRuntime); + } + if (parsedData.meshes) { + parseObject(parsedData.meshes, "meshes", gltfRuntime); + } + if (parsedData.lights) { + parseObject(parsedData.lights, "lights", gltfRuntime); + } + if (parsedData.cameras) { + parseObject(parsedData.cameras, "cameras", gltfRuntime); + } + if (parsedData.nodes) { + parseObject(parsedData.nodes, "nodes", gltfRuntime); + } + if (parsedData.images) { + parseObject(parsedData.images, "images", gltfRuntime); + } + if (parsedData.textures) { + parseObject(parsedData.textures, "textures", gltfRuntime); + } + if (parsedData.shaders) { + parseShaders(parsedData.shaders, gltfRuntime); + } + if (parsedData.programs) { + parseObject(parsedData.programs, "programs", gltfRuntime); + } + if (parsedData.samplers) { + parseObject(parsedData.samplers, "samplers", gltfRuntime); + } + if (parsedData.techniques) { + parseObject(parsedData.techniques, "techniques", gltfRuntime); + } + if (parsedData.materials) { + parseObject(parsedData.materials, "materials", gltfRuntime); + } + if (parsedData.animations) { + parseObject(parsedData.animations, "animations", gltfRuntime); + } + if (parsedData.skins) { + parseObject(parsedData.skins, "skins", gltfRuntime); + } + if (parsedData.scenes) { + gltfRuntime.scenes = parsedData.scenes; + } + if (parsedData.scene && parsedData.scenes) { + gltfRuntime.currentScene = parsedData.scenes[parsedData.scene]; + } + return gltfRuntime; + }; + GLTFLoaderBase.LoadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) { + var buffer = gltfRuntime.buffers[id]; + if (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.IsBase64(buffer.uri)) { + setTimeout(function () { return onSuccess(new Uint8Array(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.DecodeBase64(buffer.uri))); }); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.LoadFile(gltfRuntime.rootUrl + buffer.uri, function (data) { return onSuccess(new Uint8Array(data)); }, onProgress, undefined, true, function (request) { + if (request) { + onError(request.status + " " + request.statusText); + } + }); + } + }; + GLTFLoaderBase.LoadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) { + var texture = gltfRuntime.textures[id]; + if (!texture || !texture.source) { + onError(""); + return; + } + if (texture.babylonTexture) { + onSuccess(null); + return; + } + var source = gltfRuntime.images[texture.source]; + if (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.IsBase64(source.uri)) { + setTimeout(function () { return onSuccess(new Uint8Array(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.DecodeBase64(source.uri))); }); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.LoadFile(gltfRuntime.rootUrl + source.uri, function (data) { return onSuccess(new Uint8Array(data)); }, undefined, undefined, true, function (request) { + if (request) { + onError(request.status + " " + request.statusText); + } + }); + } + }; + GLTFLoaderBase.CreateTextureAsync = function (gltfRuntime, id, buffer, onSuccess) { + var texture = gltfRuntime.textures[id]; + if (texture.babylonTexture) { + onSuccess(texture.babylonTexture); + return; + } + var sampler = gltfRuntime.samplers[texture.sampler]; + var createMipMaps = sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST_MIPMAP_NEAREST || + sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST_MIPMAP_LINEAR || + sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_NEAREST || + sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_LINEAR; + var samplingMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.BILINEAR_SAMPLINGMODE; + var blob = buffer == null ? new Blob() : new Blob([buffer]); + var blobURL = URL.createObjectURL(blob); + var revokeBlobURL = function () { return URL.revokeObjectURL(blobURL); }; + var newTexture = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture(blobURL, gltfRuntime.scene, !createMipMaps, true, samplingMode, revokeBlobURL, revokeBlobURL); + if (sampler.wrapS !== undefined) { + newTexture.wrapU = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetWrapMode(sampler.wrapS); + } + if (sampler.wrapT !== undefined) { + newTexture.wrapV = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetWrapMode(sampler.wrapT); + } + newTexture.name = id; + texture.babylonTexture = newTexture; + onSuccess(newTexture); + }; + GLTFLoaderBase.LoadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) { + var shader = gltfRuntime.shaders[id]; + if (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.IsBase64(shader.uri)) { + var shaderString = atob(shader.uri.split(",")[1]); + if (onSuccess) { + onSuccess(shaderString); + } + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.LoadFile(gltfRuntime.rootUrl + shader.uri, onSuccess, undefined, undefined, false, function (request) { + if (request && onError) { + onError(request.status + " " + request.statusText); + } + }); + } + }; + GLTFLoaderBase.LoadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) { + var material = gltfRuntime.materials[id]; + if (!material.technique) { + if (onError) { + onError("No technique found."); + } + return; + } + var technique = gltfRuntime.techniques[material.technique]; + if (!technique) { + gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer; + var defaultMaterial = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.StandardMaterial(id, gltfRuntime.scene); + defaultMaterial._parentContainer = gltfRuntime.assetContainer; + gltfRuntime.scene._blockEntityCollection = false; + defaultMaterial.diffuseColor = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3(0.5, 0.5, 0.5); + defaultMaterial.sideOrientation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Material.CounterClockWiseSideOrientation; + onSuccess(defaultMaterial); + return; + } + var program = gltfRuntime.programs[technique.program]; + var states = technique.states; + var vertexShader = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.vertexShader + "VertexShader"]; + var pixelShader = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.fragmentShader + "PixelShader"]; + var newVertexShader = ""; + var newPixelShader = ""; + var vertexTokenizer = new Tokenizer(vertexShader); + var pixelTokenizer = new Tokenizer(pixelShader); + var unTreatedUniforms = {}; + var uniforms = []; + var attributes = []; + var samplers = []; + // Fill uniform, sampler2D and attributes + for (var unif in technique.uniforms) { + var uniform = technique.uniforms[unif]; + var uniformParameter = technique.parameters[uniform]; + unTreatedUniforms[unif] = uniformParameter; + if (uniformParameter.semantic && !uniformParameter.node && !uniformParameter.source) { + var transformIndex = glTFTransforms.indexOf(uniformParameter.semantic); + if (transformIndex !== -1) { + uniforms.push(babylonTransforms[transformIndex]); + delete unTreatedUniforms[unif]; + } + else { + uniforms.push(unif); + } + } + else if (uniformParameter.type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.SAMPLER_2D) { + samplers.push(unif); + } + else { + uniforms.push(unif); + } + } + for (var attr in technique.attributes) { + var attribute = technique.attributes[attr]; + var attributeParameter = technique.parameters[attribute]; + if (attributeParameter.semantic) { + var name_1 = getAttribute(attributeParameter); + if (name_1) { + attributes.push(name_1); + } + } + } + // Configure vertex shader + while (!vertexTokenizer.isEnd() && vertexTokenizer.getNextToken()) { + var tokenType = vertexTokenizer.currentToken; + if (tokenType !== ETokenType.IDENTIFIER) { + newVertexShader += vertexTokenizer.currentString; + continue; + } + var foundAttribute = false; + for (var attr in technique.attributes) { + var attribute = technique.attributes[attr]; + var attributeParameter = technique.parameters[attribute]; + if (vertexTokenizer.currentIdentifier === attr && attributeParameter.semantic) { + newVertexShader += getAttribute(attributeParameter); + foundAttribute = true; + break; + } + } + if (foundAttribute) { + continue; + } + newVertexShader += parseShaderUniforms(vertexTokenizer, technique, unTreatedUniforms); + } + // Configure pixel shader + while (!pixelTokenizer.isEnd() && pixelTokenizer.getNextToken()) { + var tokenType = pixelTokenizer.currentToken; + if (tokenType !== ETokenType.IDENTIFIER) { + newPixelShader += pixelTokenizer.currentString; + continue; + } + newPixelShader += parseShaderUniforms(pixelTokenizer, technique, unTreatedUniforms); + } + // Create shader material + var shaderPath = { + vertex: program.vertexShader + id, + fragment: program.fragmentShader + id, + }; + var options = { + attributes: attributes, + uniforms: uniforms, + samplers: samplers, + needAlphaBlending: states && states.enable && states.enable.indexOf(3042) !== -1, + }; + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.vertexShader + id + "VertexShader"] = newVertexShader; + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.fragmentShader + id + "PixelShader"] = newPixelShader; + var shaderMaterial = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.ShaderMaterial(id, gltfRuntime.scene, shaderPath, options); + shaderMaterial.onError = onShaderCompileError(program, shaderMaterial, onError); + shaderMaterial.onCompiled = onShaderCompileSuccess(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess); + shaderMaterial.sideOrientation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Material.CounterClockWiseSideOrientation; + if (states && states.functions) { + var functions = states.functions; + if (functions.cullFace && functions.cullFace[0] !== _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ECullingType.BACK) { + shaderMaterial.backFaceCulling = false; + } + var blendFunc = functions.blendFuncSeparate; + if (blendFunc) { + if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.SRC_ALPHA && + blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE_MINUS_SRC_ALPHA && + blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE && + blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) { + shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_COMBINE; + } + else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE && + blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE && + blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO && + blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) { + shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_ONEONE; + } + else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.SRC_ALPHA && + blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE && + blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO && + blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) { + shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_ADD; + } + else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO && + blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE_MINUS_SRC_COLOR && + blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE && + blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) { + shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_SUBTRACT; + } + else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.DST_COLOR && + blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO && + blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE && + blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) { + shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_MULTIPLY; + } + else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.SRC_ALPHA && + blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE_MINUS_SRC_COLOR && + blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE && + blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) { + shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_MAXIMIZED; + } + } + } + }; + return GLTFLoaderBase; +}()); + +/** + * glTF V1 Loader + * @internal + * @deprecated + */ +var GLTFLoader = /** @class */ (function () { + function GLTFLoader() { + } + GLTFLoader.RegisterExtension = function (extension) { + if (GLTFLoader.Extensions[extension.name]) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error('Tool with the same name "' + extension.name + '" already exists'); + return; + } + GLTFLoader.Extensions[extension.name] = extension; + }; + GLTFLoader.prototype.dispose = function () { + // do nothing + }; + GLTFLoader.prototype._importMeshAsync = function (meshesNames, scene, data, rootUrl, assetContainer, onSuccess, onProgress, onError) { + var _this = this; + scene.useRightHandedSystem = true; + GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, function (gltfRuntime) { + gltfRuntime.assetContainer = assetContainer; + gltfRuntime.importOnlyMeshes = true; + if (meshesNames === "") { + gltfRuntime.importMeshesNames = []; + } + else if (typeof meshesNames === "string") { + gltfRuntime.importMeshesNames = [meshesNames]; + } + else if (meshesNames && !(meshesNames instanceof Array)) { + gltfRuntime.importMeshesNames = [meshesNames]; + } + else { + gltfRuntime.importMeshesNames = []; + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Argument meshesNames must be of type string or string[]"); + } + // Create nodes + _this._createNodes(gltfRuntime); + var meshes = []; + var skeletons = []; + // Fill arrays of meshes and skeletons + for (var nde in gltfRuntime.nodes) { + var node = gltfRuntime.nodes[nde]; + if (node.babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.AbstractMesh) { + meshes.push(node.babylonNode); + } + } + for (var skl in gltfRuntime.skins) { + var skin = gltfRuntime.skins[skl]; + if (skin.babylonSkeleton instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Skeleton) { + skeletons.push(skin.babylonSkeleton); + } + } + // Load buffers, shaders, materials, etc. + _this._loadBuffersAsync(gltfRuntime, function () { + _this._loadShadersAsync(gltfRuntime, function () { + importMaterials(gltfRuntime); + postLoad(gltfRuntime); + if (!_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading && onSuccess) { + onSuccess(meshes, skeletons); + } + }); + }); + if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading && onSuccess) { + onSuccess(meshes, skeletons); + } + }, onError); + return true; + }; + /** + * Imports one or more meshes from a loaded gltf file and adds them to the scene + * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file + * @param scene the scene the meshes should be added to + * @param assetContainer defines the asset container to use (can be null) + * @param data gltf data containing information of the meshes in a loaded file + * @param rootUrl root url to load from + * @param onProgress event that fires when loading progress has occured + * @returns a promise containg the loaded meshes, particles, skeletons and animations + */ + GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, assetContainer, data, rootUrl, onProgress) { + var _this = this; + return new Promise(function (resolve, reject) { + _this._importMeshAsync(meshesNames, scene, data, rootUrl, assetContainer, function (meshes, skeletons) { + resolve({ + meshes: meshes, + particleSystems: [], + skeletons: skeletons, + animationGroups: [], + lights: [], + transformNodes: [], + geometries: [], + spriteManagers: [], + }); + }, onProgress, function (message) { + reject(new Error(message)); + }); + }); + }; + GLTFLoader.prototype._loadAsync = function (scene, data, rootUrl, onSuccess, onProgress, onError) { + var _this = this; + scene.useRightHandedSystem = true; + GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, function (gltfRuntime) { + // Load runtime extensios + GLTFLoaderExtension.LoadRuntimeExtensionsAsync(gltfRuntime, function () { + // Create nodes + _this._createNodes(gltfRuntime); + // Load buffers, shaders, materials, etc. + _this._loadBuffersAsync(gltfRuntime, function () { + _this._loadShadersAsync(gltfRuntime, function () { + importMaterials(gltfRuntime); + postLoad(gltfRuntime); + if (!_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading) { + onSuccess(); + } + }); + }); + if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading) { + onSuccess(); + } + }, onError); + }, onError); + }; + /** + * Imports all objects from a loaded gltf file and adds them to the scene + * @param scene the scene the objects should be added to + * @param data gltf data containing information of the meshes in a loaded file + * @param rootUrl root url to load from + * @param onProgress event that fires when loading progress has occured + * @returns a promise which completes when objects have been loaded to the scene + */ + GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress) { + var _this = this; + return new Promise(function (resolve, reject) { + _this._loadAsync(scene, data, rootUrl, function () { + resolve(); + }, onProgress, function (message) { + reject(new Error(message)); + }); + }); + }; + GLTFLoader.prototype._loadShadersAsync = function (gltfRuntime, onload) { + var hasShaders = false; + var processShader = function (sha, shader) { + GLTFLoaderExtension.LoadShaderStringAsync(gltfRuntime, sha, function (shaderString) { + if (shaderString instanceof ArrayBuffer) { + return; + } + gltfRuntime.loadedShaderCount++; + if (shaderString) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[sha + (shader.type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EShaderType.VERTEX ? "VertexShader" : "PixelShader")] = shaderString; + } + if (gltfRuntime.loadedShaderCount === gltfRuntime.shaderscount) { + onload(); + } + }, function () { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("Error when loading shader program named " + sha + " located at " + shader.uri); + }); + }; + for (var sha in gltfRuntime.shaders) { + hasShaders = true; + var shader = gltfRuntime.shaders[sha]; + if (shader) { + processShader.bind(this, sha, shader)(); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("No shader named: " + sha); + } + } + if (!hasShaders) { + onload(); + } + }; + GLTFLoader.prototype._loadBuffersAsync = function (gltfRuntime, onLoad) { + var hasBuffers = false; + var processBuffer = function (buf, buffer) { + GLTFLoaderExtension.LoadBufferAsync(gltfRuntime, buf, function (bufferView) { + gltfRuntime.loadedBufferCount++; + if (bufferView) { + if (bufferView.byteLength != gltfRuntime.buffers[buf].byteLength) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("Buffer named " + buf + " is length " + bufferView.byteLength + ". Expected: " + buffer.byteLength); // Improve error message + } + gltfRuntime.loadedBufferViews[buf] = bufferView; + } + if (gltfRuntime.loadedBufferCount === gltfRuntime.buffersCount) { + onLoad(); + } + }, function () { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("Error when loading buffer named " + buf + " located at " + buffer.uri); + }); + }; + for (var buf in gltfRuntime.buffers) { + hasBuffers = true; + var buffer = gltfRuntime.buffers[buf]; + if (buffer) { + processBuffer.bind(this, buf, buffer)(); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("No buffer named: " + buf); + } + } + if (!hasBuffers) { + onLoad(); + } + }; + GLTFLoader.prototype._createNodes = function (gltfRuntime) { + var currentScene = gltfRuntime.currentScene; + if (currentScene) { + // Only one scene even if multiple scenes are defined + for (var i = 0; i < currentScene.nodes.length; i++) { + traverseNodes(gltfRuntime, currentScene.nodes[i], null); + } + } + else { + // Load all scenes + for (var thing in gltfRuntime.scenes) { + currentScene = gltfRuntime.scenes[thing]; + for (var i = 0; i < currentScene.nodes.length; i++) { + traverseNodes(gltfRuntime, currentScene.nodes[i], null); + } + } + } + }; + GLTFLoader.Extensions = {}; + return GLTFLoader; +}()); +/** @internal */ +var GLTFLoaderExtension = /** @class */ (function () { + function GLTFLoaderExtension(name) { + this._name = name; + } + Object.defineProperty(GLTFLoaderExtension.prototype, "name", { + get: function () { + return this._name; + }, + enumerable: false, + configurable: true + }); + /** + * Defines an override for loading the runtime + * Return true to stop further extensions from loading the runtime + * @param scene + * @param data + * @param rootUrl + * @param onSuccess + * @param onError + * @returns true to stop further extensions from loading the runtime + */ + GLTFLoaderExtension.prototype.loadRuntimeAsync = function (scene, data, rootUrl, onSuccess, onError) { + return false; + }; + /** + * Defines an onverride for creating gltf runtime + * Return true to stop further extensions from creating the runtime + * @param gltfRuntime + * @param onSuccess + * @param onError + * @returns true to stop further extensions from creating the runtime + */ + GLTFLoaderExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) { + return false; + }; + /** + * Defines an override for loading buffers + * Return true to stop further extensions from loading this buffer + * @param gltfRuntime + * @param id + * @param onSuccess + * @param onError + * @param onProgress + * @returns true to stop further extensions from loading this buffer + */ + GLTFLoaderExtension.prototype.loadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) { + return false; + }; + /** + * Defines an override for loading texture buffers + * Return true to stop further extensions from loading this texture data + * @param gltfRuntime + * @param id + * @param onSuccess + * @param onError + * @returns true to stop further extensions from loading this texture data + */ + GLTFLoaderExtension.prototype.loadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) { + return false; + }; + /** + * Defines an override for creating textures + * Return true to stop further extensions from loading this texture + * @param gltfRuntime + * @param id + * @param buffer + * @param onSuccess + * @param onError + * @returns true to stop further extensions from loading this texture + */ + GLTFLoaderExtension.prototype.createTextureAsync = function (gltfRuntime, id, buffer, onSuccess, onError) { + return false; + }; + /** + * Defines an override for loading shader strings + * Return true to stop further extensions from loading this shader data + * @param gltfRuntime + * @param id + * @param onSuccess + * @param onError + * @returns true to stop further extensions from loading this shader data + */ + GLTFLoaderExtension.prototype.loadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) { + return false; + }; + /** + * Defines an override for loading materials + * Return true to stop further extensions from loading this material + * @param gltfRuntime + * @param id + * @param onSuccess + * @param onError + * @returns true to stop further extensions from loading this material + */ + GLTFLoaderExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) { + return false; + }; + // --------- + // Utilities + // --------- + GLTFLoaderExtension.LoadRuntimeAsync = function (scene, data, rootUrl, onSuccess, onError) { + GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) { + return loaderExtension.loadRuntimeAsync(scene, data, rootUrl, onSuccess, onError); + }, function () { + setTimeout(function () { + if (!onSuccess) { + return; + } + onSuccess(GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl)); + }); + }); + }; + GLTFLoaderExtension.LoadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) { + GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) { + return loaderExtension.loadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError); + }, function () { + setTimeout(function () { + onSuccess(); + }); + }); + }; + GLTFLoaderExtension.LoadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) { + GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) { + return loaderExtension.loadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress); + }, function () { + GLTFLoaderBase.LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress); + }); + }; + GLTFLoaderExtension.LoadTextureAsync = function (gltfRuntime, id, onSuccess, onError) { + GLTFLoaderExtension._LoadTextureBufferAsync(gltfRuntime, id, function (buffer) { + if (buffer) { + GLTFLoaderExtension._CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError); + } + }, onError); + }; + GLTFLoaderExtension.LoadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) { + GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) { + return loaderExtension.loadShaderStringAsync(gltfRuntime, id, onSuccess, onError); + }, function () { + GLTFLoaderBase.LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError); + }); + }; + GLTFLoaderExtension.LoadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) { + GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) { + return loaderExtension.loadMaterialAsync(gltfRuntime, id, onSuccess, onError); + }, function () { + GLTFLoaderBase.LoadMaterialAsync(gltfRuntime, id, onSuccess, onError); + }); + }; + GLTFLoaderExtension._LoadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) { + GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) { + return loaderExtension.loadTextureBufferAsync(gltfRuntime, id, onSuccess, onError); + }, function () { + GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError); + }); + }; + GLTFLoaderExtension._CreateTextureAsync = function (gltfRuntime, id, buffer, onSuccess, onError) { + GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) { + return loaderExtension.createTextureAsync(gltfRuntime, id, buffer, onSuccess, onError); + }, function () { + GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, onSuccess); + }); + }; + GLTFLoaderExtension._ApplyExtensions = function (func, defaultFunc) { + for (var extensionName in GLTFLoader.Extensions) { + var loaderExtension = GLTFLoader.Extensions[extensionName]; + if (func(loaderExtension)) { + return; + } + } + defaultFunc(); + }; + return GLTFLoaderExtension; +}()); + +_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader._CreateGLTF1Loader = function () { return new GLTFLoader(); }; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts": +/*!*****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts ***! + \*****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EBlendingFunction: () => (/* binding */ EBlendingFunction), +/* harmony export */ EComponentType: () => (/* binding */ EComponentType), +/* harmony export */ ECullingType: () => (/* binding */ ECullingType), +/* harmony export */ EParameterType: () => (/* binding */ EParameterType), +/* harmony export */ EShaderType: () => (/* binding */ EShaderType), +/* harmony export */ ETextureFilterType: () => (/* binding */ ETextureFilterType), +/* harmony export */ ETextureFormat: () => (/* binding */ ETextureFormat), +/* harmony export */ ETextureWrapMode: () => (/* binding */ ETextureWrapMode) +/* harmony export */ }); +/** + * Enums + * @internal + */ +var EComponentType; +(function (EComponentType) { + EComponentType[EComponentType["BYTE"] = 5120] = "BYTE"; + EComponentType[EComponentType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE"; + EComponentType[EComponentType["SHORT"] = 5122] = "SHORT"; + EComponentType[EComponentType["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT"; + EComponentType[EComponentType["FLOAT"] = 5126] = "FLOAT"; +})(EComponentType || (EComponentType = {})); +/** @internal */ +var EShaderType; +(function (EShaderType) { + EShaderType[EShaderType["FRAGMENT"] = 35632] = "FRAGMENT"; + EShaderType[EShaderType["VERTEX"] = 35633] = "VERTEX"; +})(EShaderType || (EShaderType = {})); +/** @internal */ +var EParameterType; +(function (EParameterType) { + EParameterType[EParameterType["BYTE"] = 5120] = "BYTE"; + EParameterType[EParameterType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE"; + EParameterType[EParameterType["SHORT"] = 5122] = "SHORT"; + EParameterType[EParameterType["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT"; + EParameterType[EParameterType["INT"] = 5124] = "INT"; + EParameterType[EParameterType["UNSIGNED_INT"] = 5125] = "UNSIGNED_INT"; + EParameterType[EParameterType["FLOAT"] = 5126] = "FLOAT"; + EParameterType[EParameterType["FLOAT_VEC2"] = 35664] = "FLOAT_VEC2"; + EParameterType[EParameterType["FLOAT_VEC3"] = 35665] = "FLOAT_VEC3"; + EParameterType[EParameterType["FLOAT_VEC4"] = 35666] = "FLOAT_VEC4"; + EParameterType[EParameterType["INT_VEC2"] = 35667] = "INT_VEC2"; + EParameterType[EParameterType["INT_VEC3"] = 35668] = "INT_VEC3"; + EParameterType[EParameterType["INT_VEC4"] = 35669] = "INT_VEC4"; + EParameterType[EParameterType["BOOL"] = 35670] = "BOOL"; + EParameterType[EParameterType["BOOL_VEC2"] = 35671] = "BOOL_VEC2"; + EParameterType[EParameterType["BOOL_VEC3"] = 35672] = "BOOL_VEC3"; + EParameterType[EParameterType["BOOL_VEC4"] = 35673] = "BOOL_VEC4"; + EParameterType[EParameterType["FLOAT_MAT2"] = 35674] = "FLOAT_MAT2"; + EParameterType[EParameterType["FLOAT_MAT3"] = 35675] = "FLOAT_MAT3"; + EParameterType[EParameterType["FLOAT_MAT4"] = 35676] = "FLOAT_MAT4"; + EParameterType[EParameterType["SAMPLER_2D"] = 35678] = "SAMPLER_2D"; +})(EParameterType || (EParameterType = {})); +/** @internal */ +var ETextureWrapMode; +(function (ETextureWrapMode) { + ETextureWrapMode[ETextureWrapMode["CLAMP_TO_EDGE"] = 33071] = "CLAMP_TO_EDGE"; + ETextureWrapMode[ETextureWrapMode["MIRRORED_REPEAT"] = 33648] = "MIRRORED_REPEAT"; + ETextureWrapMode[ETextureWrapMode["REPEAT"] = 10497] = "REPEAT"; +})(ETextureWrapMode || (ETextureWrapMode = {})); +/** @internal */ +var ETextureFilterType; +(function (ETextureFilterType) { + ETextureFilterType[ETextureFilterType["NEAREST"] = 9728] = "NEAREST"; + ETextureFilterType[ETextureFilterType["LINEAR"] = 9728] = "LINEAR"; + ETextureFilterType[ETextureFilterType["NEAREST_MIPMAP_NEAREST"] = 9984] = "NEAREST_MIPMAP_NEAREST"; + ETextureFilterType[ETextureFilterType["LINEAR_MIPMAP_NEAREST"] = 9985] = "LINEAR_MIPMAP_NEAREST"; + ETextureFilterType[ETextureFilterType["NEAREST_MIPMAP_LINEAR"] = 9986] = "NEAREST_MIPMAP_LINEAR"; + ETextureFilterType[ETextureFilterType["LINEAR_MIPMAP_LINEAR"] = 9987] = "LINEAR_MIPMAP_LINEAR"; +})(ETextureFilterType || (ETextureFilterType = {})); +/** @internal */ +var ETextureFormat; +(function (ETextureFormat) { + ETextureFormat[ETextureFormat["ALPHA"] = 6406] = "ALPHA"; + ETextureFormat[ETextureFormat["RGB"] = 6407] = "RGB"; + ETextureFormat[ETextureFormat["RGBA"] = 6408] = "RGBA"; + ETextureFormat[ETextureFormat["LUMINANCE"] = 6409] = "LUMINANCE"; + ETextureFormat[ETextureFormat["LUMINANCE_ALPHA"] = 6410] = "LUMINANCE_ALPHA"; +})(ETextureFormat || (ETextureFormat = {})); +/** @internal */ +var ECullingType; +(function (ECullingType) { + ECullingType[ECullingType["FRONT"] = 1028] = "FRONT"; + ECullingType[ECullingType["BACK"] = 1029] = "BACK"; + ECullingType[ECullingType["FRONT_AND_BACK"] = 1032] = "FRONT_AND_BACK"; +})(ECullingType || (ECullingType = {})); +/** @internal */ +var EBlendingFunction; +(function (EBlendingFunction) { + EBlendingFunction[EBlendingFunction["ZERO"] = 0] = "ZERO"; + EBlendingFunction[EBlendingFunction["ONE"] = 1] = "ONE"; + EBlendingFunction[EBlendingFunction["SRC_COLOR"] = 768] = "SRC_COLOR"; + EBlendingFunction[EBlendingFunction["ONE_MINUS_SRC_COLOR"] = 769] = "ONE_MINUS_SRC_COLOR"; + EBlendingFunction[EBlendingFunction["DST_COLOR"] = 774] = "DST_COLOR"; + EBlendingFunction[EBlendingFunction["ONE_MINUS_DST_COLOR"] = 775] = "ONE_MINUS_DST_COLOR"; + EBlendingFunction[EBlendingFunction["SRC_ALPHA"] = 770] = "SRC_ALPHA"; + EBlendingFunction[EBlendingFunction["ONE_MINUS_SRC_ALPHA"] = 771] = "ONE_MINUS_SRC_ALPHA"; + EBlendingFunction[EBlendingFunction["DST_ALPHA"] = 772] = "DST_ALPHA"; + EBlendingFunction[EBlendingFunction["ONE_MINUS_DST_ALPHA"] = 773] = "ONE_MINUS_DST_ALPHA"; + EBlendingFunction[EBlendingFunction["CONSTANT_COLOR"] = 32769] = "CONSTANT_COLOR"; + EBlendingFunction[EBlendingFunction["ONE_MINUS_CONSTANT_COLOR"] = 32770] = "ONE_MINUS_CONSTANT_COLOR"; + EBlendingFunction[EBlendingFunction["CONSTANT_ALPHA"] = 32771] = "CONSTANT_ALPHA"; + EBlendingFunction[EBlendingFunction["ONE_MINUS_CONSTANT_ALPHA"] = 32772] = "ONE_MINUS_CONSTANT_ALPHA"; + EBlendingFunction[EBlendingFunction["SRC_ALPHA_SATURATE"] = 776] = "SRC_ALPHA_SATURATE"; +})(EBlendingFunction || (EBlendingFunction = {})); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/1.0/glTFLoaderUtils.ts": +/*!************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/1.0/glTFLoaderUtils.ts ***! + \************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFUtils: () => (/* binding */ GLTFUtils) +/* harmony export */ }); +/* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/Textures/texture */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__); + + + + + + +/** + * Utils functions for GLTF + * @internal + * @deprecated + */ +var GLTFUtils = /** @class */ (function () { + function GLTFUtils() { + } + /** + * Sets the given "parameter" matrix + * @param scene the Scene object + * @param source the source node where to pick the matrix + * @param parameter the GLTF technique parameter + * @param uniformName the name of the shader's uniform + * @param shaderMaterial the shader material + */ + GLTFUtils.SetMatrix = function (scene, source, parameter, uniformName, shaderMaterial) { + var mat = null; + if (parameter.semantic === "MODEL") { + mat = source.getWorldMatrix(); + } + else if (parameter.semantic === "PROJECTION") { + mat = scene.getProjectionMatrix(); + } + else if (parameter.semantic === "VIEW") { + mat = scene.getViewMatrix(); + } + else if (parameter.semantic === "MODELVIEWINVERSETRANSPOSE") { + mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Transpose(source.getWorldMatrix().multiply(scene.getViewMatrix()).invert()); + } + else if (parameter.semantic === "MODELVIEW") { + mat = source.getWorldMatrix().multiply(scene.getViewMatrix()); + } + else if (parameter.semantic === "MODELVIEWPROJECTION") { + mat = source.getWorldMatrix().multiply(scene.getTransformMatrix()); + } + else if (parameter.semantic === "MODELINVERSE") { + mat = source.getWorldMatrix().invert(); + } + else if (parameter.semantic === "VIEWINVERSE") { + mat = scene.getViewMatrix().invert(); + } + else if (parameter.semantic === "PROJECTIONINVERSE") { + mat = scene.getProjectionMatrix().invert(); + } + else if (parameter.semantic === "MODELVIEWINVERSE") { + mat = source.getWorldMatrix().multiply(scene.getViewMatrix()).invert(); + } + else if (parameter.semantic === "MODELVIEWPROJECTIONINVERSE") { + mat = source.getWorldMatrix().multiply(scene.getTransformMatrix()).invert(); + } + else if (parameter.semantic === "MODELINVERSETRANSPOSE") { + mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Transpose(source.getWorldMatrix().invert()); + } + if (mat) { + switch (parameter.type) { + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT2: + shaderMaterial.setMatrix2x2(uniformName, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.GetAsMatrix2x2(mat)); + break; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT3: + shaderMaterial.setMatrix3x3(uniformName, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.GetAsMatrix3x3(mat)); + break; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT4: + shaderMaterial.setMatrix(uniformName, mat); + break; + default: + break; + } + } + }; + /** + * Sets the given "parameter" matrix + * @param shaderMaterial the shader material + * @param uniform the name of the shader's uniform + * @param value the value of the uniform + * @param type the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4) + * @returns true if set, else false + */ + GLTFUtils.SetUniform = function (shaderMaterial, uniform, value, type) { + switch (type) { + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT: + shaderMaterial.setFloat(uniform, value); + return true; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_VEC2: + shaderMaterial.setVector2(uniform, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector2.FromArray(value)); + return true; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_VEC3: + shaderMaterial.setVector3(uniform, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(value)); + return true; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_VEC4: + shaderMaterial.setVector4(uniform, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector4.FromArray(value)); + return true; + default: + return false; + } + }; + /** + * Returns the wrap mode of the texture + * @param mode the mode value + * @returns the wrap mode (TEXTURE_WRAP_ADDRESSMODE, MIRROR_ADDRESSMODE or CLAMP_ADDRESSMODE) + */ + GLTFUtils.GetWrapMode = function (mode) { + switch (mode) { + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureWrapMode.CLAMP_TO_EDGE: + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.CLAMP_ADDRESSMODE; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureWrapMode.MIRRORED_REPEAT: + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.MIRROR_ADDRESSMODE; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureWrapMode.REPEAT: + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.WRAP_ADDRESSMODE; + default: + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.WRAP_ADDRESSMODE; + } + }; + /** + * Returns the byte stride giving an accessor + * @param accessor the GLTF accessor objet + * @returns the byte stride + */ + GLTFUtils.GetByteStrideFromType = function (accessor) { + // Needs this function since "byteStride" isn't requiered in glTF format + var type = accessor.type; + switch (type) { + case "VEC2": + return 2; + case "VEC3": + return 3; + case "VEC4": + return 4; + case "MAT2": + return 4; + case "MAT3": + return 9; + case "MAT4": + return 16; + default: + return 1; + } + }; + /** + * Returns the texture filter mode giving a mode value + * @param mode the filter mode value + * @returns the filter mode (TODO - needs to be a type?) + */ + GLTFUtils.GetTextureFilterMode = function (mode) { + switch (mode) { + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR: + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_NEAREST: + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_LINEAR: + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.TRILINEAR_SAMPLINGMODE; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST: + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST_MIPMAP_NEAREST: + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_SAMPLINGMODE; + default: + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.BILINEAR_SAMPLINGMODE; + } + }; + GLTFUtils.GetBufferFromBufferView = function (gltfRuntime, bufferView, byteOffset, byteLength, componentType) { + byteOffset = bufferView.byteOffset + byteOffset; + var loadedBufferView = gltfRuntime.loadedBufferViews[bufferView.buffer]; + if (byteOffset + byteLength > loadedBufferView.byteLength) { + throw new Error("Buffer access is out of range"); + } + var buffer = loadedBufferView.buffer; + byteOffset += loadedBufferView.byteOffset; + switch (componentType) { + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.BYTE: + return new Int8Array(buffer, byteOffset, byteLength); + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.UNSIGNED_BYTE: + return new Uint8Array(buffer, byteOffset, byteLength); + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.SHORT: + return new Int16Array(buffer, byteOffset, byteLength); + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.UNSIGNED_SHORT: + return new Uint16Array(buffer, byteOffset, byteLength); + default: + return new Float32Array(buffer, byteOffset, byteLength); + } + }; + /** + * Returns a buffer from its accessor + * @param gltfRuntime the GLTF runtime + * @param accessor the GLTF accessor + * @returns an array buffer view + */ + GLTFUtils.GetBufferFromAccessor = function (gltfRuntime, accessor) { + var bufferView = gltfRuntime.bufferViews[accessor.bufferView]; + var byteLength = accessor.count * GLTFUtils.GetByteStrideFromType(accessor); + return GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, accessor.byteOffset, byteLength, accessor.componentType); + }; + /** + * Decodes a buffer view into a string + * @param view the buffer view + * @returns a string + */ + GLTFUtils.DecodeBufferToText = function (view) { + var result = ""; + var length = view.byteLength; + for (var i = 0; i < length; ++i) { + result += String.fromCharCode(view[i]); + } + return result; + }; + /** + * Returns the default material of gltf. Related to + * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material + * @param scene the Babylon.js scene + * @returns the default Babylon material + */ + GLTFUtils.GetDefaultMaterial = function (scene) { + if (!GLTFUtils._DefaultMaterial) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore["GLTFDefaultMaterialVertexShader"] = [ + "precision highp float;", + "", + "uniform mat4 worldView;", + "uniform mat4 projection;", + "", + "attribute vec3 position;", + "", + "void main(void)", + "{", + " gl_Position = projection * worldView * vec4(position, 1.0);", + "}", + ].join("\n"); + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore["GLTFDefaultMaterialPixelShader"] = [ + "precision highp float;", + "", + "uniform vec4 u_emission;", + "", + "void main(void)", + "{", + " gl_FragColor = u_emission;", + "}", + ].join("\n"); + var shaderPath = { + vertex: "GLTFDefaultMaterial", + fragment: "GLTFDefaultMaterial", + }; + var options = { + attributes: ["position"], + uniforms: ["worldView", "projection", "u_emission"], + samplers: new Array(), + needAlphaBlending: false, + }; + GLTFUtils._DefaultMaterial = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.ShaderMaterial("GLTFDefaultMaterial", scene, shaderPath, options); + GLTFUtils._DefaultMaterial.setColor4("u_emission", new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color4(0.5, 0.5, 0.5, 1.0)); + } + return GLTFUtils._DefaultMaterial; + }; + // The GLTF default material + GLTFUtils._DefaultMaterial = null; + return GLTFUtils; +}()); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/1.0/glTFMaterialsCommonExtension.ts": +/*!*************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/1.0/glTFMaterialsCommonExtension.ts ***! + \*************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFMaterialsCommonExtension: () => (/* binding */ GLTFMaterialsCommonExtension) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoader */ "../../../dev/loaders/src/glTF/1.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Lights/spotLight */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__); + + + + + + + + + + + +/** + * @internal + * @deprecated + */ +var GLTFMaterialsCommonExtension = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(GLTFMaterialsCommonExtension, _super); + function GLTFMaterialsCommonExtension() { + return _super.call(this, "KHR_materials_common") || this; + } + GLTFMaterialsCommonExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime) { + if (!gltfRuntime.extensions) { + return false; + } + var extension = gltfRuntime.extensions[this.name]; + if (!extension) { + return false; + } + // Create lights + var lights = extension.lights; + if (lights) { + for (var thing in lights) { + var light = lights[thing]; + switch (light.type) { + case "ambient": { + var ambientLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.HemisphericLight(light.name, new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 1, 0), gltfRuntime.scene); + var ambient = light.ambient; + if (ambient) { + ambientLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(ambient.color || [1, 1, 1]); + } + break; + } + case "point": { + var pointLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.PointLight(light.name, new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(10, 10, 10), gltfRuntime.scene); + var point = light.point; + if (point) { + pointLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(point.color || [1, 1, 1]); + } + break; + } + case "directional": { + var dirLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.DirectionalLight(light.name, new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, -1, 0), gltfRuntime.scene); + var directional = light.directional; + if (directional) { + dirLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(directional.color || [1, 1, 1]); + } + break; + } + case "spot": { + var spot = light.spot; + if (spot) { + var spotLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.SpotLight(light.name, new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 10, 0), new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, -1, 0), spot.fallOffAngle || Math.PI, spot.fallOffExponent || 0.0, gltfRuntime.scene); + spotLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(spot.color || [1, 1, 1]); + } + break; + } + default: + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn('GLTF Material Common extension: light type "' + light.type + "” not supported"); + break; + } + } + } + return false; + }; + GLTFMaterialsCommonExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) { + var material = gltfRuntime.materials[id]; + if (!material || !material.extensions) { + return false; + } + var extension = material.extensions[this.name]; + if (!extension) { + return false; + } + var standardMaterial = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.StandardMaterial(id, gltfRuntime.scene); + standardMaterial.sideOrientation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Material.CounterClockWiseSideOrientation; + if (extension.technique === "CONSTANT") { + standardMaterial.disableLighting = true; + } + standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided; + standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency; + standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess; + // Ambient + if (typeof extension.values.ambient === "string") { + this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, "ambientTexture", onError); + } + else { + standardMaterial.ambientColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(extension.values.ambient || [0, 0, 0]); + } + // Diffuse + if (typeof extension.values.diffuse === "string") { + this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, "diffuseTexture", onError); + } + else { + standardMaterial.diffuseColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(extension.values.diffuse || [0, 0, 0]); + } + // Emission + if (typeof extension.values.emission === "string") { + this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, "emissiveTexture", onError); + } + else { + standardMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(extension.values.emission || [0, 0, 0]); + } + // Specular + if (typeof extension.values.specular === "string") { + this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, "specularTexture", onError); + } + else { + standardMaterial.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(extension.values.specular || [0, 0, 0]); + } + return true; + }; + GLTFMaterialsCommonExtension.prototype._loadTexture = function (gltfRuntime, id, material, propertyPath, onError) { + // Create buffer from texture url + _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, function (buffer) { + // Create texture from buffer + _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, function (texture) { return (material[propertyPath] = texture); }); + }, onError); + }; + return GLTFMaterialsCommonExtension; +}(_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderExtension)); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(new GLTFMaterialsCommonExtension()); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/1.0/index.ts": +/*!**************************************************!*\ + !*** ../../../dev/loaders/src/glTF/1.0/index.ts ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EBlendingFunction: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EBlendingFunction), +/* harmony export */ EComponentType: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EComponentType), +/* harmony export */ ECullingType: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ECullingType), +/* harmony export */ EParameterType: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EParameterType), +/* harmony export */ EShaderType: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EShaderType), +/* harmony export */ ETextureFilterType: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ETextureFilterType), +/* harmony export */ ETextureFormat: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ETextureFormat), +/* harmony export */ ETextureWrapMode: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ETextureWrapMode), +/* harmony export */ GLTFBinaryExtension: () => (/* reexport safe */ _glTFBinaryExtension__WEBPACK_IMPORTED_MODULE_0__.GLTFBinaryExtension), +/* harmony export */ GLTFLoader: () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader), +/* harmony export */ GLTFLoaderBase: () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderBase), +/* harmony export */ GLTFLoaderExtension: () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderExtension), +/* harmony export */ GLTFMaterialsCommonExtension: () => (/* reexport safe */ _glTFMaterialsCommonExtension__WEBPACK_IMPORTED_MODULE_4__.GLTFMaterialsCommonExtension), +/* harmony export */ GLTFUtils: () => (/* reexport safe */ _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_3__.GLTFUtils) +/* harmony export */ }); +/* harmony import */ var _glTFBinaryExtension__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFBinaryExtension */ "../../../dev/loaders/src/glTF/1.0/glTFBinaryExtension.ts"); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoader */ "../../../dev/loaders/src/glTF/1.0/glTFLoader.ts"); +/* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts"); +/* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./glTFLoaderUtils */ "../../../dev/loaders/src/glTF/1.0/glTFLoaderUtils.ts"); +/* harmony import */ var _glTFMaterialsCommonExtension__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./glTFMaterialsCommonExtension */ "../../../dev/loaders/src/glTF/1.0/glTFMaterialsCommonExtension.ts"); + + + + + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts": +/*!******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_lights_image_based: () => (/* binding */ EXT_lights_image_based) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/Textures/rawCubeTexture */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + +var NAME = "EXT_lights_image_based"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_lights_image_based/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_lights_image_based = /** @class */ (function () { + /** + * @internal + */ + function EXT_lights_image_based(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + EXT_lights_image_based.prototype.dispose = function () { + this._loader = null; + delete this._lights; + }; + /** @internal */ + EXT_lights_image_based.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._lights = extension.lights; + } + }; + /** + * @internal + */ + EXT_lights_image_based.prototype.loadSceneAsync = function (context, scene) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) { + _this._loader._allMaterialsDirtyRequired = true; + var promises = new Array(); + promises.push(_this._loader.loadSceneAsync(context, scene)); + _this._loader.logOpen("".concat(extensionContext)); + var light = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/light"), _this._lights, extension.light); + promises.push(_this._loadLightAsync("/extensions/".concat(_this.name, "/lights/").concat(extension.light), light).then(function (texture) { + _this._loader.babylonScene.environmentTexture = texture; + })); + _this._loader.logClose(); + return Promise.all(promises).then(function () { }); + }); + }; + EXT_lights_image_based.prototype._loadLightAsync = function (context, light) { + var _this = this; + if (!light._loaded) { + var promises = new Array(); + this._loader.logOpen("".concat(context)); + var imageData_1 = new Array(light.specularImages.length); + var _loop_1 = function (mipmap) { + var faces = light.specularImages[mipmap]; + imageData_1[mipmap] = new Array(faces.length); + var _loop_2 = function (face) { + var specularImageContext = "".concat(context, "/specularImages/").concat(mipmap, "/").concat(face); + this_1._loader.logOpen("".concat(specularImageContext)); + var index = faces[face]; + var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(specularImageContext, this_1._loader.gltf.images, index); + promises.push(this_1._loader.loadImageAsync("/images/".concat(index), image).then(function (data) { + imageData_1[mipmap][face] = data; + })); + this_1._loader.logClose(); + }; + for (var face = 0; face < faces.length; face++) { + _loop_2(face); + } + }; + var this_1 = this; + for (var mipmap = 0; mipmap < light.specularImages.length; mipmap++) { + _loop_1(mipmap); + } + this._loader.logClose(); + light._loaded = Promise.all(promises).then(function () { + var babylonTexture = new babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.RawCubeTexture(_this._loader.babylonScene, null, light.specularImageSize); + babylonTexture.name = light.name || "environment"; + light._babylonTexture = babylonTexture; + if (light.intensity != undefined) { + babylonTexture.level = light.intensity; + } + if (light.rotation) { + var rotation = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(light.rotation); + // Invert the rotation so that positive rotation is counter-clockwise. + if (!_this._loader.babylonScene.useRightHandedSystem) { + rotation = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Inverse(rotation); + } + babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromQuaternionToRef(rotation, babylonTexture.getReflectionTextureMatrix()); + } + if (!light.irradianceCoefficients) { + throw new Error("".concat(context, ": Irradiance coefficients are missing")); + } + var sphericalHarmonics = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.SphericalHarmonics.FromArray(light.irradianceCoefficients); + sphericalHarmonics.scaleInPlace(light.intensity); + sphericalHarmonics.convertIrradianceToLambertianRadiance(); + var sphericalPolynomial = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.SphericalPolynomial.FromHarmonics(sphericalHarmonics); + // Compute the lod generation scale to fit exactly to the number of levels available. + var lodGenerationScale = (imageData_1.length - 1) / babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Scalar.Log2(light.specularImageSize); + return babylonTexture.updateRGBDAsync(imageData_1, sphericalPolynomial, lodGenerationScale); + }); + } + return light._loaded.then(function () { + return light._babylonTexture; + }); + }; + return EXT_lights_image_based; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_lights_image_based(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* binding */ EXT_mesh_gpu_instancing) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Meshes/thinInstanceMesh */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "EXT_mesh_gpu_instancing"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_mesh_gpu_instancing/README.md) + * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_mesh_gpu_instancing = /** @class */ (function () { + /** + * @internal + */ + function EXT_mesh_gpu_instancing(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + EXT_mesh_gpu_instancing.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + EXT_mesh_gpu_instancing.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + _this._loader._disableInstancedMesh++; + var promise = _this._loader.loadNodeAsync("/nodes/".concat(node.index), node, assign); + _this._loader._disableInstancedMesh--; + if (!node._primitiveBabylonMeshes) { + return promise; + } + var promises = new Array(); + var instanceCount = 0; + var loadAttribute = function (attribute) { + if (extension.attributes[attribute] == undefined) { + promises.push(Promise.resolve(null)); + return; + } + var accessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/attributes/").concat(attribute), _this._loader.gltf.accessors, extension.attributes[attribute]); + promises.push(_this._loader._loadFloatAccessorAsync("/accessors/".concat(accessor.bufferView), accessor)); + if (instanceCount === 0) { + instanceCount = accessor.count; + } + else if (instanceCount !== accessor.count) { + throw new Error("".concat(extensionContext, "/attributes: Instance buffer accessors do not have the same count.")); + } + }; + loadAttribute("TRANSLATION"); + loadAttribute("ROTATION"); + loadAttribute("SCALE"); + return promise.then(function (babylonTransformNode) { + return Promise.all(promises).then(function (_a) { + var translationBuffer = _a[0], rotationBuffer = _a[1], scaleBuffer = _a[2]; + var matrices = new Float32Array(instanceCount * 16); + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0].copyFromFloats(0, 0, 0); // translation + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0].copyFromFloats(0, 0, 0, 1); // rotation + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1].copyFromFloats(1, 1, 1); // scale + for (var i = 0; i < instanceCount; ++i) { + translationBuffer && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(translationBuffer, i * 3, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0]); + rotationBuffer && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArrayToRef(rotationBuffer, i * 4, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0]); + scaleBuffer && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(scaleBuffer, i * 3, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1]); + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Matrix.ComposeToRef(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1], babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0], babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0], babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0]); + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0].copyToArray(matrices, i * 16); + } + for (var _i = 0, _b = node._primitiveBabylonMeshes; _i < _b.length; _i++) { + var babylonMesh = _b[_i]; + babylonMesh.thinInstanceSetBuffer("matrix", matrices, 16, true); + } + return babylonTransformNode; + }); + }); + }); + }; + return EXT_mesh_gpu_instancing; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_mesh_gpu_instancing(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_meshopt_compression: () => (/* binding */ EXT_meshopt_compression) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/Compression/meshoptCompression */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "EXT_meshopt_compression"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_meshopt_compression/README.md) + * + * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js + * @since 5.0.0 + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_meshopt_compression = /** @class */ (function () { + /** + * @internal + */ + function EXT_meshopt_compression(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this.enabled = loader.isExtensionUsed(NAME); + this._loader = loader; + } + /** @internal */ + EXT_meshopt_compression.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + EXT_meshopt_compression.prototype.loadBufferViewAsync = function (context, bufferView) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, bufferView, this.name, function (extensionContext, extension) { + var bufferViewMeshopt = bufferView; + if (bufferViewMeshopt._meshOptData) { + return bufferViewMeshopt._meshOptData; + } + var buffer = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/buffer"), _this._loader.gltf.buffers, extension.buffer); + bufferViewMeshopt._meshOptData = _this._loader.loadBufferAsync("/buffers/".concat(buffer.index), buffer, extension.byteOffset || 0, extension.byteLength).then(function (buffer) { + return babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__.MeshoptCompression.Default.decodeGltfBufferAsync(buffer, extension.count, extension.byteStride, extension.mode, extension.filter); + }); + return bufferViewMeshopt._meshOptData; + }); + }; + return EXT_meshopt_compression; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_meshopt_compression(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts": +/*!************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_texture_webp: () => (/* binding */ EXT_texture_webp) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "EXT_texture_webp"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_texture_webp/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_texture_webp = /** @class */ (function () { + /** + * @internal + */ + function EXT_texture_webp(loader) { + /** The name of this extension. */ + this.name = NAME; + this._loader = loader; + this.enabled = loader.isExtensionUsed(NAME); + } + /** @internal */ + EXT_texture_webp.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + EXT_texture_webp.prototype._loadTextureAsync = function (context, texture, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, texture, this.name, function (extensionContext, extension) { + var sampler = texture.sampler == undefined ? _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.DefaultSampler : _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/sampler"), _this._loader.gltf.samplers, texture.sampler); + var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/source"), _this._loader.gltf.images, extension.source); + return _this._loader._createTextureAsync(context, sampler, image, function (babylonTexture) { + assign(babylonTexture); + }, undefined, !texture._textureInfo.nonColorData); + }); + }; + return EXT_texture_webp; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_texture_webp(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts": +/*!************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ExtrasAsMetadata: () => (/* binding */ ExtrasAsMetadata) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "ExtrasAsMetadata"; +/** + * Store glTF extras (if present) in BJS objects' metadata + */ +var ExtrasAsMetadata = /** @class */ (function () { + /** + * @internal + */ + function ExtrasAsMetadata(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines whether this extension is enabled. + */ + this.enabled = true; + this._loader = loader; + } + ExtrasAsMetadata.prototype._assignExtras = function (babylonObject, gltfProp) { + if (gltfProp.extras && Object.keys(gltfProp.extras).length > 0) { + var metadata = (babylonObject.metadata = babylonObject.metadata || {}); + var gltf = (metadata.gltf = metadata.gltf || {}); + gltf.extras = gltfProp.extras; + } + }; + /** @internal */ + ExtrasAsMetadata.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + ExtrasAsMetadata.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return this._loader.loadNodeAsync(context, node, function (babylonTransformNode) { + _this._assignExtras(babylonTransformNode, node); + assign(babylonTransformNode); + }); + }; + /** + * @internal + */ + ExtrasAsMetadata.prototype.loadCameraAsync = function (context, camera, assign) { + var _this = this; + return this._loader.loadCameraAsync(context, camera, function (babylonCamera) { + _this._assignExtras(babylonCamera, camera); + assign(babylonCamera); + }); + }; + /** + * @internal + */ + ExtrasAsMetadata.prototype.createMaterial = function (context, material, babylonDrawMode) { + var babylonMaterial = this._loader.createMaterial(context, material, babylonDrawMode); + this._assignExtras(babylonMaterial, material); + return babylonMaterial; + }; + return ExtrasAsMetadata; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new ExtrasAsMetadata(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.data.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.data.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ animationPointerTree: () => (/* binding */ animationPointerTree) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoaderAnimation */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts"); +/* eslint-disable @typescript-eslint/naming-convention */ + + + + +function getColor3(_target, source, offset, scale) { + return babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(source, offset).scale(scale); +} +function getAlpha(_target, source, offset, scale) { + return source[offset + 3] * scale; +} +function getFloat(_target, source, offset, scale) { + return source[offset] * scale; +} +function getMinusFloat(_target, source, offset, scale) { + return -source[offset] * scale; +} +function getNextFloat(_target, source, offset, scale) { + return source[offset + 1] * scale; +} +function getFloatBy2(_target, source, offset, scale) { + return source[offset] * scale * 2; +} +function getTextureTransformTree(textureName) { + return { + scale: [ + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".uScale"), getFloat, function () { return 2; }), + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".vScale"), getNextFloat, function () { return 2; }), + ], + offset: [ + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".uOffset"), getFloat, function () { return 2; }), + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".vOffset"), getNextFloat, function () { return 2; }), + ], + rotation: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".wAng"), getMinusFloat, function () { return 1; })], + }; +} +var CameraAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(CameraAnimationPropertyInfo, _super); + function CameraAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + CameraAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + callback(target._babylonCamera, this._buildAnimation(name, fps, keys)); + }; + return CameraAnimationPropertyInfo; +}(_glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.AnimationPropertyInfo)); +var MaterialAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(MaterialAnimationPropertyInfo, _super); + function MaterialAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + MaterialAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + for (var fillMode in target._data) { + callback(target._data[fillMode].babylonMaterial, this._buildAnimation(name, fps, keys)); + } + }; + return MaterialAnimationPropertyInfo; +}(_glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.AnimationPropertyInfo)); +var LightAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(LightAnimationPropertyInfo, _super); + function LightAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + LightAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + callback(target._babylonLight, this._buildAnimation(name, fps, keys)); + }; + return LightAnimationPropertyInfo; +}(_glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.AnimationPropertyInfo)); +var nodesTree = { + __array__: (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({ __target__: true }, _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.nodeAnimationData), +}; +var camerasTree = { + __array__: { + __target__: true, + orthographic: { + xmag: [ + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoLeft", getMinusFloat, function () { return 1; }), + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoRight", getNextFloat, function () { return 1; }), + ], + ymag: [ + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoBottom", getMinusFloat, function () { return 1; }), + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoTop", getNextFloat, function () { return 1; }), + ], + zfar: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "maxZ", getFloat, function () { return 1; })], + znear: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "minZ", getFloat, function () { return 1; })], + }, + perspective: { + yfov: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "fov", getFloat, function () { return 1; })], + zfar: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "maxZ", getFloat, function () { return 1; })], + znear: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "minZ", getFloat, function () { return 1; })], + }, + }, +}; +var materialsTree = { + __array__: { + __target__: true, + pbrMetallicRoughness: { + baseColorFactor: [ + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "albedoColor", getColor3, function () { return 4; }), + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "alpha", getAlpha, function () { return 4; }), + ], + metallicFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "metallic", getFloat, function () { return 1; })], + roughnessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "roughness", getFloat, function () { return 1; })], + baseColorTexture: { + extensions: { + KHR_texture_transform: getTextureTransformTree("albedoTexture"), + }, + }, + }, + emissiveFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "emissiveColor", getColor3, function () { return 3; })], + normalTexture: { + scale: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "bumpTexture.level", getFloat, function () { return 1; })], + }, + occlusionTexture: { + strength: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "ambientTextureStrength", getFloat, function () { return 1; })], + extensions: { + KHR_texture_transform: getTextureTransformTree("ambientTexture"), + }, + }, + emissiveTexture: { + extensions: { + KHR_texture_transform: getTextureTransformTree("emissiveTexture"), + }, + }, + extensions: { + KHR_materials_ior: { + ior: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "indexOfRefraction", getFloat, function () { return 1; })], + }, + KHR_materials_clearcoat: { + clearcoatFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "clearCoat.intensity", getFloat, function () { return 1; })], + clearcoatRoughnessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "clearCoat.roughness", getFloat, function () { return 1; })], + }, + KHR_materials_sheen: { + sheenColorFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "sheen.color", getColor3, function () { return 3; })], + sheenRoughnessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "sheen.roughness", getFloat, function () { return 1; })], + }, + KHR_materials_specular: { + specularFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "metallicF0Factor", getFloat, function () { return 1; })], + specularColorFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "metallicReflectanceColor", getColor3, function () { return 3; })], + }, + KHR_materials_emissive_strength: { + emissiveStrength: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "emissiveIntensity", getFloat, function () { return 1; })], + }, + KHR_materials_transmission: { + transmissionFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.refractionIntensity", getFloat, function () { return 1; })], + }, + KHR_materials_volume: { + attenuationColor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "subSurface.tintColor", getColor3, function () { return 3; })], + attenuationDistance: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.tintColorAtDistance", getFloat, function () { return 1; })], + thicknessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.maximumThickness", getFloat, function () { return 1; })], + }, + KHR_materials_dispersion: { + dispersion: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.dispersion", getFloat, function () { return 1; })], + }, + KHR_materials_iridescence: { + iridescenceFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.intensity", getFloat, function () { return 1; })], + iridescenceIor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.indexOfRefraction", getFloat, function () { return 1; })], + iridescenceThicknessMinimum: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.minimumThickness", getFloat, function () { return 1; })], + iridescenceThicknessMaximum: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.maximumThickness", getFloat, function () { return 1; })], + }, + KHR_materials_anisotropy: { + anisotropyStrength: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "anisotropy.intensity", getFloat, function () { return 1; })], + anisotropyRotation: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "anisotropy.angle", getFloat, function () { return 1; })], + }, + }, + }, +}; +var extensionsTree = { + KHR_lights_punctual: { + lights: { + __array__: { + __target__: true, + color: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "diffuse", getColor3, function () { return 3; })], + intensity: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "intensity", getFloat, function () { return 1; })], + range: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "range", getFloat, function () { return 1; })], + spot: { + innerConeAngle: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "innerAngle", getFloatBy2, function () { return 1; })], + outerConeAngle: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "angle", getFloatBy2, function () { return 1; })], + }, + }, + }, + }, +}; +/** @internal */ +var animationPointerTree = { + nodes: nodesTree, + materials: materialsTree, + cameras: camerasTree, + extensions: extensionsTree, +}; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.ts": +/*!*****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.ts ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_animation_pointer: () => (/* binding */ KHR_animation_pointer) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _KHR_animation_pointer_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./KHR_animation_pointer.data */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.data.ts"); +/* harmony import */ var _gltfPathToObjectConverter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gltfPathToObjectConverter */ "../../../dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts"); + + + + + +var NAME = "KHR_animation_pointer"; +/** + * Class to convert an animation pointer path to a smart object that + * gets data from the animation buffer and creates animations. + */ +var AnimationPointerPathToObjectConverter = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__extends)(AnimationPointerPathToObjectConverter, _super); + function AnimationPointerPathToObjectConverter(gltf) { + return _super.call(this, gltf, _KHR_animation_pointer_data__WEBPACK_IMPORTED_MODULE_2__.animationPointerTree) || this; + } + return AnimationPointerPathToObjectConverter; +}(_gltfPathToObjectConverter__WEBPACK_IMPORTED_MODULE_3__.GLTFPathToObjectConverter)); +/** + * [Specification PR](https://github.com/KhronosGroup/glTF/pull/2147) + * !!! Experimental Extension Subject to Changes !!! + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_animation_pointer = /** @class */ (function () { + /** + * @internal + */ + function KHR_animation_pointer(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this._pathToObjectConverter = new AnimationPointerPathToObjectConverter(this._loader.gltf); + } + Object.defineProperty(KHR_animation_pointer.prototype, "enabled", { + /** + * Defines whether this extension is enabled. + */ + get: function () { + return this._loader.isExtensionUsed(NAME); + }, + enumerable: false, + configurable: true + }); + /** @internal */ + KHR_animation_pointer.prototype.dispose = function () { + this._loader = null; + delete this._pathToObjectConverter; // GC + }; + /** + * Loads a glTF animation channel. + * @param context The context when loading the asset + * @param animationContext The context of the animation when loading the asset + * @param animation The glTF animation property + * @param channel The glTF animation channel property + * @param onLoad Called for each animation loaded + * @returns A void promise that resolves when the load is complete or null if not handled + */ + KHR_animation_pointer.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, onLoad) { + var _a; + var extension = (_a = channel.target.extensions) === null || _a === void 0 ? void 0 : _a.KHR_animation_pointer; + if (!extension || !this._pathToObjectConverter) { + return null; + } + if (channel.target.path !== "pointer" /* AnimationChannelTargetPath.POINTER */) { + babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.Warn("".concat(context, "/target/path: Value (").concat(channel.target.path, ") must be (").concat("pointer" /* AnimationChannelTargetPath.POINTER */, ") when using the ").concat(this.name, " extension")); + } + if (channel.target.node != undefined) { + babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.Warn("".concat(context, "/target/node: Value (").concat(channel.target.node, ") must not be present when using the ").concat(this.name, " extension")); + } + var extensionContext = "".concat(context, "/extensions/").concat(this.name); + var pointer = extension.pointer; + if (!pointer) { + throw new Error("".concat(extensionContext, ": Pointer is missing")); + } + try { + var targetInfo = this._pathToObjectConverter.convert(pointer); + return this._loader._loadAnimationChannelFromTargetInfoAsync(context, animationContext, animation, channel, targetInfo, onLoad); + } + catch (e) { + babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.Warn("".concat(extensionContext, "/pointer: Invalid pointer (").concat(pointer, ") skipped")); + return null; + } + }; + return KHR_animation_pointer; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_animation_pointer(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_draco_mesh_compression: () => (/* binding */ KHR_draco_mesh_compression) +/* harmony export */ }); +/* harmony import */ var babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Buffers/buffer */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_draco_mesh_compression"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_draco_mesh_compression/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_draco_mesh_compression = /** @class */ (function () { + /** + * @internal + */ + function KHR_draco_mesh_compression(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines whether to use the normalized flag from the glTF accessor instead of the Draco data. Defaults to true. + */ + this.useNormalizedFlagFromAccessor = true; + this._loader = loader; + this.enabled = babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_draco_mesh_compression.prototype.dispose = function () { + delete this.dracoCompression; + this._loader = null; + }; + /** + * @internal + */ + KHR_draco_mesh_compression.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) { + if (primitive.mode != undefined) { + if (primitive.mode !== 4 /* MeshPrimitiveMode.TRIANGLES */ && primitive.mode !== 5 /* MeshPrimitiveMode.TRIANGLE_STRIP */) { + throw new Error("".concat(context, ": Unsupported mode ").concat(primitive.mode)); + } + } + var attributes = {}; + var normalized = {}; + var loadAttribute = function (name, kind) { + var uniqueId = extension.attributes[name]; + if (uniqueId == undefined) { + return; + } + babylonMesh._delayInfo = babylonMesh._delayInfo || []; + if (babylonMesh._delayInfo.indexOf(kind) === -1) { + babylonMesh._delayInfo.push(kind); + } + attributes[kind] = uniqueId; + if (_this.useNormalizedFlagFromAccessor) { + var accessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.TryGet(_this._loader.gltf.accessors, primitive.attributes[name]); + if (accessor) { + normalized[kind] = accessor.normalized || false; + } + } + }; + loadAttribute("POSITION", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind); + loadAttribute("NORMAL", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind); + loadAttribute("TANGENT", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind); + loadAttribute("TEXCOORD_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind); + loadAttribute("TEXCOORD_1", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind); + loadAttribute("TEXCOORD_2", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV3Kind); + loadAttribute("TEXCOORD_3", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV4Kind); + loadAttribute("TEXCOORD_4", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV5Kind); + loadAttribute("TEXCOORD_5", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV6Kind); + loadAttribute("JOINTS_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind); + loadAttribute("WEIGHTS_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind); + loadAttribute("COLOR_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind); + var bufferView = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(extensionContext, _this._loader.gltf.bufferViews, extension.bufferView); + if (!bufferView._dracoBabylonGeometry) { + bufferView._dracoBabylonGeometry = _this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) { + var dracoCompression = _this.dracoCompression || babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.Default; + return dracoCompression._decodeMeshToGeometryForGltfAsync(babylonMesh.name, _this._loader.babylonScene, data, attributes, normalized).catch(function (error) { + throw new Error("".concat(context, ": ").concat(error.message)); + }); + }); + } + return bufferView._dracoBabylonGeometry; + }); + }; + return KHR_draco_mesh_compression; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_draco_mesh_compression(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity.ts": +/*!*************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity.ts ***! + \*************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_interactivity: () => (/* binding */ KHR_interactivity) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_FlowGraph_flowGraphCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/FlowGraph/flowGraph */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_FlowGraph_flowGraphCoordinator__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_FlowGraph_flowGraphCoordinator__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _interactivityFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interactivityFunctions */ "../../../dev/loaders/src/glTF/2.0/Extensions/interactivityFunctions.ts"); +/* harmony import */ var _interactivityPathToObjectConverter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./interactivityPathToObjectConverter */ "../../../dev/loaders/src/glTF/2.0/Extensions/interactivityPathToObjectConverter.ts"); + + + + + +var NAME = "KHR_interactivity"; +/** + * Loader extension for KHR_interactivity + */ +var KHR_interactivity = /** @class */ (function () { + /** + * @internal + * @param _loader + */ + function KHR_interactivity(_loader) { + this._loader = _loader; + /** + * The name of this extension. + */ + this.name = NAME; + this.enabled = this._loader.isExtensionUsed(NAME); + this._pathConverter = new _interactivityPathToObjectConverter__WEBPACK_IMPORTED_MODULE_3__.InteractivityPathToObjectConverter(this._loader.gltf); + } + KHR_interactivity.prototype.dispose = function () { + this._loader = null; + delete this._pathConverter; + }; + KHR_interactivity.prototype.onReady = function () { + var _a; + if (!this._loader.babylonScene || !this._pathConverter) { + return; + } + var scene = this._loader.babylonScene; + var interactivityDefinition = (_a = this._loader.gltf.extensions) === null || _a === void 0 ? void 0 : _a.KHR_interactivity; + var json = (0,_interactivityFunctions__WEBPACK_IMPORTED_MODULE_2__.convertGLTFToSerializedFlowGraph)(interactivityDefinition); + var coordinator = new babylonjs_FlowGraph_flowGraphCoordinator__WEBPACK_IMPORTED_MODULE_1__.FlowGraphCoordinator({ scene: scene }); + babylonjs_FlowGraph_flowGraphCoordinator__WEBPACK_IMPORTED_MODULE_1__.FlowGraph.Parse(json, { coordinator: coordinator, pathConverter: this._pathConverter }); + coordinator.start(); + }; + return KHR_interactivity; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_interactivity(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts": +/*!***************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts ***! + \***************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_lights: () => (/* binding */ KHR_lights) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Lights/light */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + + + +var NAME = "KHR_lights_punctual"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_lights_punctual/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_lights = /** @class */ (function () { + /** + * @internal + */ + function KHR_lights(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_lights.prototype.dispose = function () { + this._loader = null; + delete this._lights; + }; + /** @internal */ + KHR_lights.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._lights = extension.lights; + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(this._lights); + } + }; + /** + * @internal + */ + KHR_lights.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + _this._loader._allMaterialsDirtyRequired = true; + return _this._loader.loadNodeAsync(context, node, function (babylonMesh) { + var babylonLight; + var light = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(extensionContext, _this._lights, extension.light); + var name = light.name || babylonMesh.name; + _this._loader.babylonScene._blockEntityCollection = !!_this._loader._assetContainer; + switch (light.type) { + case "directional" /* KHRLightsPunctual_LightType.DIRECTIONAL */: { + var babylonDirectionalLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.DirectionalLight(name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Backward(), _this._loader.babylonScene); + babylonDirectionalLight.position.setAll(0); + babylonLight = babylonDirectionalLight; + break; + } + case "point" /* KHRLightsPunctual_LightType.POINT */: { + babylonLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.PointLight(name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), _this._loader.babylonScene); + break; + } + case "spot" /* KHRLightsPunctual_LightType.SPOT */: { + var babylonSpotLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.SpotLight(name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Backward(), 0, 1, _this._loader.babylonScene); + babylonSpotLight.angle = ((light.spot && light.spot.outerConeAngle) || Math.PI / 4) * 2; + babylonSpotLight.innerAngle = ((light.spot && light.spot.innerConeAngle) || 0) * 2; + babylonLight = babylonSpotLight; + break; + } + default: { + _this._loader.babylonScene._blockEntityCollection = false; + throw new Error("".concat(extensionContext, ": Invalid light type (").concat(light.type, ")")); + } + } + babylonLight._parentContainer = _this._loader._assetContainer; + _this._loader.babylonScene._blockEntityCollection = false; + light._babylonLight = babylonLight; + babylonLight.falloffType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light.FALLOFF_GLTF; + babylonLight.diffuse = light.color ? babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(light.color) : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + babylonLight.intensity = light.intensity == undefined ? 1 : light.intensity; + babylonLight.range = light.range == undefined ? Number.MAX_VALUE : light.range; + babylonLight.parent = babylonMesh; + _this._loader._babylonLights.push(babylonLight); + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.AddPointerMetadata(babylonLight, extensionContext); + assign(babylonMesh); + }); + }); + }; + return KHR_lights; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_lights(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts": +/*!********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts ***! + \********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_anisotropy: () => (/* binding */ KHR_materials_anisotropy) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_anisotropy"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_anisotropy) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_anisotropy = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_anisotropy(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 195; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_anisotropy.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_anisotropy.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_anisotropy.prototype._loadIridescencePropertiesAsync = function (context, properties, babylonMaterial) { + var _a, _b; + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.anisotropy.isEnabled = true; + babylonMaterial.anisotropy.intensity = (_a = properties.anisotropyStrength) !== null && _a !== void 0 ? _a : 0; + babylonMaterial.anisotropy.angle = (_b = properties.anisotropyRotation) !== null && _b !== void 0 ? _b : 0; + if (properties.anisotropyTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/anisotropyTexture"), properties.anisotropyTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Anisotropy Intensity)"); + babylonMaterial.anisotropy.texture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_anisotropy; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_anisotropy(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_clearcoat: () => (/* binding */ KHR_materials_clearcoat) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_clearcoat"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md) + * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_clearcoat = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_clearcoat(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 190; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_clearcoat.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_clearcoat.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadClearCoatPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_clearcoat.prototype._loadClearCoatPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.clearCoat.isEnabled = true; + babylonMaterial.clearCoat.useRoughnessFromMainTexture = false; + babylonMaterial.clearCoat.remapF0OnInterfaceChange = false; + if (properties.clearcoatFactor != undefined) { + babylonMaterial.clearCoat.intensity = properties.clearcoatFactor; + } + else { + babylonMaterial.clearCoat.intensity = 0; + } + if (properties.clearcoatTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatTexture"), properties.clearcoatTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (ClearCoat Intensity)"); + babylonMaterial.clearCoat.texture = texture; + })); + } + if (properties.clearcoatRoughnessFactor != undefined) { + babylonMaterial.clearCoat.roughness = properties.clearcoatRoughnessFactor; + } + else { + babylonMaterial.clearCoat.roughness = 0; + } + if (properties.clearcoatRoughnessTexture) { + properties.clearcoatRoughnessTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatRoughnessTexture"), properties.clearcoatRoughnessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (ClearCoat Roughness)"); + babylonMaterial.clearCoat.textureRoughness = texture; + })); + } + if (properties.clearcoatNormalTexture) { + properties.clearcoatNormalTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatNormalTexture"), properties.clearcoatNormalTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (ClearCoat Normal)"); + babylonMaterial.clearCoat.bumpTexture = texture; + })); + babylonMaterial.invertNormalMapX = !babylonMaterial.getScene().useRightHandedSystem; + babylonMaterial.invertNormalMapY = babylonMaterial.getScene().useRightHandedSystem; + if (properties.clearcoatNormalTexture.scale != undefined) { + babylonMaterial.clearCoat.bumpTexture.level = properties.clearcoatNormalTexture.scale; + } + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_clearcoat; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_clearcoat(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts": +/*!********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts ***! + \********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_dispersion: () => (/* binding */ KHR_materials_dispersion) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_dispersion"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/87bd64a7f5e23c84b6aef2e6082069583ed0ddb4/extensions/2.0/Khronos/KHR_materials_dispersion/README.md) + * @experimental + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_dispersion = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_dispersion(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 174; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_dispersion.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_dispersion.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadDispersionPropertiesAsync(extensionContext, material, babylonMaterial, extension)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_dispersion.prototype._loadDispersionPropertiesAsync = function (context, material, babylonMaterial, extension) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + // If transparency isn't enabled already, this extension shouldn't do anything. + // i.e. it requires either the KHR_materials_transmission or KHR_materials_translucency extensions. + if (!babylonMaterial.subSurface.isRefractionEnabled || !extension.dispersion) { + return Promise.resolve(); + } + babylonMaterial.subSurface.isDispersionEnabled = true; + babylonMaterial.subSurface.dispersion = extension.dispersion; + return Promise.resolve(); + }; + return KHR_materials_dispersion; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_dispersion(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts": +/*!***************************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts ***! + \***************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_emissive_strength: () => (/* binding */ KHR_materials_emissive_strength) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_emissive_strength"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_emissive_strength = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_emissive_strength(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 170; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_emissive_strength.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_emissive_strength.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + return _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial).then(function () { + _this._loadEmissiveProperties(extensionContext, extension, babylonMaterial); + }); + }); + }; + KHR_materials_emissive_strength.prototype._loadEmissiveProperties = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + if (properties.emissiveStrength !== undefined) { + babylonMaterial.emissiveColor.scaleToRef(properties.emissiveStrength, babylonMaterial.emissiveColor); + } + }; + return KHR_materials_emissive_strength; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_emissive_strength(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_ior.ts": +/*!*************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_ior.ts ***! + \*************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_ior: () => (/* binding */ KHR_materials_ior) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_ior"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_ior = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_ior(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 180; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_ior.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_ior.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadIorPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_ior.prototype._loadIorPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + if (properties.ior !== undefined) { + babylonMaterial.indexOfRefraction = properties.ior; + } + else { + babylonMaterial.indexOfRefraction = KHR_materials_ior._DEFAULT_IOR; + } + return Promise.resolve(); + }; + /** + * Default ior Value from the spec. + */ + KHR_materials_ior._DEFAULT_IOR = 1.5; + return KHR_materials_ior; +}()); +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_ior(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts": +/*!*********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts ***! + \*********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_iridescence: () => (/* binding */ KHR_materials_iridescence) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_iridescence"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_iridescence/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_iridescence = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_iridescence(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 195; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_iridescence.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_iridescence.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_iridescence.prototype._loadIridescencePropertiesAsync = function (context, properties, babylonMaterial) { + var _a, _b, _c, _d, _e; + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.iridescence.isEnabled = true; + babylonMaterial.iridescence.intensity = (_a = properties.iridescenceFactor) !== null && _a !== void 0 ? _a : 0; + babylonMaterial.iridescence.indexOfRefraction = (_c = (_b = properties.iridescenceIor) !== null && _b !== void 0 ? _b : properties.iridescenceIOR) !== null && _c !== void 0 ? _c : 1.3; + babylonMaterial.iridescence.minimumThickness = (_d = properties.iridescenceThicknessMinimum) !== null && _d !== void 0 ? _d : 100; + babylonMaterial.iridescence.maximumThickness = (_e = properties.iridescenceThicknessMaximum) !== null && _e !== void 0 ? _e : 400; + if (properties.iridescenceTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/iridescenceTexture"), properties.iridescenceTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Iridescence Intensity)"); + babylonMaterial.iridescence.texture = texture; + })); + } + if (properties.iridescenceThicknessTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/iridescenceThicknessTexture"), properties.iridescenceThicknessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Iridescence Thickness)"); + babylonMaterial.iridescence.thicknessTexture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_iridescence; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_iridescence(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts": +/*!*******************************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_pbrSpecularGlossiness: () => (/* binding */ KHR_materials_pbrSpecularGlossiness) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_pbrSpecularGlossiness"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_pbrSpecularGlossiness = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_pbrSpecularGlossiness(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 200; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_pbrSpecularGlossiness.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_pbrSpecularGlossiness.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadSpecularGlossinessPropertiesAsync(extensionContext, extension, babylonMaterial)); + _this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_pbrSpecularGlossiness.prototype._loadSpecularGlossinessPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.metallic = null; + babylonMaterial.roughness = null; + if (properties.diffuseFactor) { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.diffuseFactor); + babylonMaterial.alpha = properties.diffuseFactor[3]; + } + else { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + } + babylonMaterial.reflectivityColor = properties.specularFactor ? babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.specularFactor) : babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + babylonMaterial.microSurface = properties.glossinessFactor == undefined ? 1 : properties.glossinessFactor; + if (properties.diffuseTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/diffuseTexture"), properties.diffuseTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Diffuse)"); + babylonMaterial.albedoTexture = texture; + })); + } + if (properties.specularGlossinessTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularGlossinessTexture"), properties.specularGlossinessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Specular Glossiness)"); + babylonMaterial.reflectivityTexture = texture; + babylonMaterial.reflectivityTexture.hasAlpha = true; + })); + babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true; + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_pbrSpecularGlossiness; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_pbrSpecularGlossiness(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts": +/*!***************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts ***! + \***************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_sheen: () => (/* binding */ KHR_materials_sheen) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_sheen"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_sheen/README.md) + * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_sheen = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_sheen(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 190; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_sheen.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_sheen.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadSheenPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_sheen.prototype._loadSheenPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.sheen.isEnabled = true; + babylonMaterial.sheen.intensity = 1; + if (properties.sheenColorFactor != undefined) { + babylonMaterial.sheen.color = babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.sheenColorFactor); + } + else { + babylonMaterial.sheen.color = babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.Black(); + } + if (properties.sheenColorTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/sheenColorTexture"), properties.sheenColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Sheen Color)"); + babylonMaterial.sheen.texture = texture; + })); + } + if (properties.sheenRoughnessFactor !== undefined) { + babylonMaterial.sheen.roughness = properties.sheenRoughnessFactor; + } + else { + babylonMaterial.sheen.roughness = 0; + } + if (properties.sheenRoughnessTexture) { + properties.sheenRoughnessTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/sheenRoughnessTexture"), properties.sheenRoughnessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Sheen Roughness)"); + babylonMaterial.sheen.textureRoughness = texture; + })); + } + babylonMaterial.sheen.albedoScaling = true; + babylonMaterial.sheen.useRoughnessFromMainTexture = false; + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_sheen; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_sheen(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts": +/*!******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_specular: () => (/* binding */ KHR_materials_specular) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_specular"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_specular/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_specular = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_specular(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 190; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_specular.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_specular.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_specular.prototype._loadSpecularPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + if (properties.specularFactor !== undefined) { + babylonMaterial.metallicF0Factor = properties.specularFactor; + } + if (properties.specularColorFactor !== undefined) { + babylonMaterial.metallicReflectanceColor = babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.specularColorFactor); + } + if (properties.specularTexture) { + properties.specularTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularTexture"), properties.specularTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Specular F0 Strength)"); + babylonMaterial.metallicReflectanceTexture = texture; + babylonMaterial.useOnlyMetallicFromMetallicReflectanceTexture = true; + })); + } + if (properties.specularColorTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularColorTexture"), properties.specularColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Specular F0 Color)"); + babylonMaterial.reflectanceTexture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_specular; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_specular(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_translucency.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_translucency.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_translucency: () => (/* binding */ KHR_materials_translucency) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_translucency"; +/** + * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825) + * !!! Experimental Extension Subject to Changes !!! + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_translucency = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_translucency(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 174; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + if (this.enabled) { + loader.parent.transparencyAsCoverage = true; + } + } + /** @internal */ + KHR_materials_translucency.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_translucency.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadTranslucentPropertiesAsync(extensionContext, material, babylonMaterial, extension)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_translucency.prototype._loadTranslucentPropertiesAsync = function (context, material, babylonMaterial, extension) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var pbrMaterial = babylonMaterial; + // Enables "translucency" texture which represents diffusely-transmitted light. + pbrMaterial.subSurface.isTranslucencyEnabled = true; + // Since this extension models thin-surface transmission only, we must make the + // internal IOR == 1.0 and set the thickness to 0. + pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0; + pbrMaterial.subSurface.minimumThickness = 0.0; + pbrMaterial.subSurface.maximumThickness = 0.0; + // Albedo colour will tint transmission. + pbrMaterial.subSurface.useAlbedoToTintTranslucency = true; + if (extension.translucencyFactor !== undefined) { + pbrMaterial.subSurface.translucencyIntensity = extension.translucencyFactor; + } + else { + pbrMaterial.subSurface.translucencyIntensity = 0.0; + pbrMaterial.subSurface.isTranslucencyEnabled = false; + return Promise.resolve(); + } + if (extension.translucencyTexture) { + extension.translucencyTexture.nonColorData = true; + return this._loader.loadTextureInfoAsync("".concat(context, "/translucencyTexture"), extension.translucencyTexture).then(function (texture) { + pbrMaterial.subSurface.translucencyIntensityTexture = texture; + }); + } + else { + return Promise.resolve(); + } + }; + return KHR_materials_translucency; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_translucency(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_transmission: () => (/* binding */ KHR_materials_transmission) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + + + +/** + * A class to handle setting up the rendering of opaque objects to be shown through transmissive objects. + */ +var TransmissionHelper = /** @class */ (function () { + /** + * constructor + * @param options Defines the options we want to customize the helper + * @param scene The scene to add the material to + */ + function TransmissionHelper(options, scene) { + var _this = this; + this._opaqueRenderTarget = null; + this._opaqueMeshesCache = []; + this._transparentMeshesCache = []; + this._materialObservers = {}; + this._options = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, TransmissionHelper._GetDefaultOptions()), options); + this._scene = scene; + this._scene._transmissionHelper = this; + this.onErrorObservable = new babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._scene.onDisposeObservable.addOnce(function () { + _this.dispose(); + }); + this._parseScene(); + this._setupRenderTargets(); + } + /** + * Creates the default options for the helper. + * @returns the default options + */ + TransmissionHelper._GetDefaultOptions = function () { + return { + renderSize: 1024, + samples: 4, + lodGenerationScale: 1, + lodGenerationOffset: -4, + renderTargetTextureType: babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Constants.TEXTURETYPE_HALF_FLOAT, + generateMipmaps: true, + }; + }; + /** + * Updates the background according to the new options + * @param options + */ + TransmissionHelper.prototype.updateOptions = function (options) { + var _this = this; + // First check if any options are actually being changed. If not, exit. + var newValues = Object.keys(options).filter(function (key) { return _this._options[key] !== options[key]; }); + if (!newValues.length) { + return; + } + var newOptions = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, this._options), options); + var oldOptions = this._options; + this._options = newOptions; + // If size changes, recreate everything + if (newOptions.renderSize !== oldOptions.renderSize || + newOptions.renderTargetTextureType !== oldOptions.renderTargetTextureType || + newOptions.generateMipmaps !== oldOptions.generateMipmaps || + !this._opaqueRenderTarget) { + this._setupRenderTargets(); + } + else { + this._opaqueRenderTarget.samples = newOptions.samples; + this._opaqueRenderTarget.lodGenerationScale = newOptions.lodGenerationScale; + this._opaqueRenderTarget.lodGenerationOffset = newOptions.lodGenerationOffset; + } + }; + /** + * @returns the opaque render target texture or null if not available. + */ + TransmissionHelper.prototype.getOpaqueTarget = function () { + return this._opaqueRenderTarget; + }; + TransmissionHelper.prototype._shouldRenderAsTransmission = function (material) { + if (!material) { + return false; + } + if (material instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial && material.subSurface.isRefractionEnabled) { + return true; + } + return false; + }; + TransmissionHelper.prototype._addMesh = function (mesh) { + var _this = this; + this._materialObservers[mesh.uniqueId] = mesh.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)); + // we need to defer the processing because _addMesh may be called as part as an instance mesh creation, in which case some + // internal properties are not setup yet, like _sourceMesh (needed when doing mesh.material below) + babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Tools.SetImmediate(function () { + if (_this._shouldRenderAsTransmission(mesh.material)) { + mesh.material.refractionTexture = _this._opaqueRenderTarget; + if (_this._transparentMeshesCache.indexOf(mesh) === -1) { + _this._transparentMeshesCache.push(mesh); + } + } + else { + if (_this._opaqueMeshesCache.indexOf(mesh) === -1) { + _this._opaqueMeshesCache.push(mesh); + } + } + }); + }; + TransmissionHelper.prototype._removeMesh = function (mesh) { + mesh.onMaterialChangedObservable.remove(this._materialObservers[mesh.uniqueId]); + delete this._materialObservers[mesh.uniqueId]; + var idx = this._transparentMeshesCache.indexOf(mesh); + if (idx !== -1) { + this._transparentMeshesCache.splice(idx, 1); + } + idx = this._opaqueMeshesCache.indexOf(mesh); + if (idx !== -1) { + this._opaqueMeshesCache.splice(idx, 1); + } + }; + TransmissionHelper.prototype._parseScene = function () { + this._scene.meshes.forEach(this._addMesh.bind(this)); + // Listen for when a mesh is added to the scene and add it to our cache lists. + this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)); + // Listen for when a mesh is removed from to the scene and remove it from our cache lists. + this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this)); + }; + // When one of the meshes in the scene has its material changed, make sure that it's in the correct cache list. + TransmissionHelper.prototype._onMeshMaterialChanged = function (mesh) { + var transparentIdx = this._transparentMeshesCache.indexOf(mesh); + var opaqueIdx = this._opaqueMeshesCache.indexOf(mesh); + // If the material is transparent, make sure that it's added to the transparent list and removed from the opaque list + var useTransmission = this._shouldRenderAsTransmission(mesh.material); + if (useTransmission) { + if (mesh.material instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial) { + mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget; + } + if (opaqueIdx !== -1) { + this._opaqueMeshesCache.splice(opaqueIdx, 1); + this._transparentMeshesCache.push(mesh); + } + else if (transparentIdx === -1) { + this._transparentMeshesCache.push(mesh); + } + // If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list + } + else { + if (transparentIdx !== -1) { + this._transparentMeshesCache.splice(transparentIdx, 1); + this._opaqueMeshesCache.push(mesh); + } + else if (opaqueIdx === -1) { + this._opaqueMeshesCache.push(mesh); + } + } + }; + /** + * @internal + * Check if the opaque render target has not been disposed and can still be used. + * @returns + */ + TransmissionHelper.prototype._isRenderTargetValid = function () { + var _a; + return ((_a = this._opaqueRenderTarget) === null || _a === void 0 ? void 0 : _a.getInternalTexture()) !== null; + }; + /** + * @internal + * Setup the render targets according to the specified options. + */ + TransmissionHelper.prototype._setupRenderTargets = function () { + var _this = this; + var _a, _b; + if (this._opaqueRenderTarget) { + this._opaqueRenderTarget.dispose(); + } + this._opaqueRenderTarget = new babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.RenderTargetTexture("opaqueSceneTexture", this._options.renderSize, this._scene, this._options.generateMipmaps, undefined, this._options.renderTargetTextureType); + this._opaqueRenderTarget.ignoreCameraViewport = true; + this._opaqueRenderTarget.renderList = this._opaqueMeshesCache; + this._opaqueRenderTarget.clearColor = (_b = (_a = this._options.clearColor) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : this._scene.clearColor.clone(); + this._opaqueRenderTarget.gammaSpace = false; + this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale; + this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset; + this._opaqueRenderTarget.samples = this._options.samples; + this._opaqueRenderTarget.renderSprites = true; + this._opaqueRenderTarget.renderParticles = true; + var sceneImageProcessingapplyByPostProcess; + var saveSceneEnvIntensity; + this._opaqueRenderTarget.onBeforeBindObservable.add(function (opaqueRenderTarget) { + saveSceneEnvIntensity = _this._scene.environmentIntensity; + _this._scene.environmentIntensity = 1.0; + sceneImageProcessingapplyByPostProcess = _this._scene.imageProcessingConfiguration.applyByPostProcess; + if (!_this._options.clearColor) { + _this._scene.clearColor.toLinearSpaceToRef(opaqueRenderTarget.clearColor, _this._scene.getEngine().useExactSrgbConversions); + } + else { + opaqueRenderTarget.clearColor.copyFrom(_this._options.clearColor); + } + // we do not use the applyByPostProcess setter to avoid flagging all the materials as "image processing dirty"! + _this._scene.imageProcessingConfiguration._applyByPostProcess = true; + }); + this._opaqueRenderTarget.onAfterUnbindObservable.add(function () { + _this._scene.environmentIntensity = saveSceneEnvIntensity; + _this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess; + }); + this._transparentMeshesCache.forEach(function (mesh) { + if (_this._shouldRenderAsTransmission(mesh.material)) { + mesh.material.refractionTexture = _this._opaqueRenderTarget; + } + }); + }; + /** + * Dispose all the elements created by the Helper. + */ + TransmissionHelper.prototype.dispose = function () { + this._scene._transmissionHelper = undefined; + if (this._opaqueRenderTarget) { + this._opaqueRenderTarget.dispose(); + this._opaqueRenderTarget = null; + } + this._transparentMeshesCache = []; + this._opaqueMeshesCache = []; + }; + return TransmissionHelper; +}()); +var NAME = "KHR_materials_transmission"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_transmission/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_transmission = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_transmission(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 175; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + if (this.enabled) { + loader.parent.transparencyAsCoverage = true; + } + } + /** @internal */ + KHR_materials_transmission.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_transmission.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadTransparentPropertiesAsync(extensionContext, material, babylonMaterial, extension)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_transmission.prototype._loadTransparentPropertiesAsync = function (context, material, babylonMaterial, extension) { + var _a, _b; + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var pbrMaterial = babylonMaterial; + // Enables "refraction" texture which represents transmitted light. + pbrMaterial.subSurface.isRefractionEnabled = true; + // Since this extension models thin-surface transmission only, we must make IOR = 1.0 + pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0; + // Albedo colour will tint transmission. + pbrMaterial.subSurface.useAlbedoToTintRefraction = true; + if (extension.transmissionFactor !== undefined) { + pbrMaterial.subSurface.refractionIntensity = extension.transmissionFactor; + var scene = pbrMaterial.getScene(); + if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper) { + new TransmissionHelper({}, pbrMaterial.getScene()); + } + else if (pbrMaterial.subSurface.refractionIntensity && !((_a = scene._transmissionHelper) === null || _a === void 0 ? void 0 : _a._isRenderTargetValid())) { + // If the render target is not valid, recreate it. + (_b = scene._transmissionHelper) === null || _b === void 0 ? void 0 : _b._setupRenderTargets(); + } + } + else { + pbrMaterial.subSurface.refractionIntensity = 0.0; + pbrMaterial.subSurface.isRefractionEnabled = false; + return Promise.resolve(); + } + pbrMaterial.subSurface.minimumThickness = 0.0; + pbrMaterial.subSurface.maximumThickness = 0.0; + if (extension.transmissionTexture) { + extension.transmissionTexture.nonColorData = true; + return this._loader.loadTextureInfoAsync("".concat(context, "/transmissionTexture"), extension.transmissionTexture, undefined).then(function (texture) { + pbrMaterial.subSurface.refractionIntensityTexture = texture; + pbrMaterial.subSurface.useGltfStyleTextures = true; + }); + } + else { + return Promise.resolve(); + } + }; + return KHR_materials_transmission; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_transmission(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts": +/*!***************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts ***! + \***************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_unlit: () => (/* binding */ KHR_materials_unlit) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_unlit"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_unlit/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_unlit = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_unlit(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 210; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_unlit.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_unlit.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function () { + return _this._loadUnlitPropertiesAsync(context, material, babylonMaterial); + }); + }; + KHR_materials_unlit.prototype._loadUnlitPropertiesAsync = function (context, material, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.unlit = true; + var properties = material.pbrMetallicRoughness; + if (properties) { + if (properties.baseColorFactor) { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.baseColorFactor); + babylonMaterial.alpha = properties.baseColorFactor[3]; + } + else { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + } + if (properties.baseColorTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/baseColorTexture"), properties.baseColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Base Color)"); + babylonMaterial.albedoTexture = texture; + })); + } + } + if (material.doubleSided) { + babylonMaterial.backFaceCulling = false; + babylonMaterial.twoSidedLighting = true; + } + this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial); + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_unlit; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_unlit(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts": +/*!******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_variants: () => (/* binding */ KHR_materials_variants) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/mesh */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_variants"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_variants/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_variants = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_variants(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_variants.prototype.dispose = function () { + this._loader = null; + }; + /** + * Gets the list of available variant names for this asset. + * @param rootMesh The glTF root mesh + * @returns the list of all the variant names for this model + */ + KHR_materials_variants.GetAvailableVariants = function (rootMesh) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + return []; + } + return Object.keys(extensionMetadata.variants); + }; + /** + * Gets the list of available variant names for this asset. + * @param rootMesh The glTF root mesh + * @returns the list of all the variant names for this model + */ + KHR_materials_variants.prototype.getAvailableVariants = function (rootMesh) { + return KHR_materials_variants.GetAvailableVariants(rootMesh); + }; + /** + * Select a variant given a variant name or a list of variant names. + * @param rootMesh The glTF root mesh + * @param variantName The variant name(s) to select. + */ + KHR_materials_variants.SelectVariant = function (rootMesh, variantName) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + throw new Error("Cannot select variant on a glTF mesh that does not have the ".concat(NAME, " extension")); + } + var select = function (variantName) { + var entries = extensionMetadata.variants[variantName]; + if (entries) { + for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { + var entry = entries_1[_i]; + entry.mesh.material = entry.material; + } + } + }; + if (variantName instanceof Array) { + for (var _i = 0, variantName_1 = variantName; _i < variantName_1.length; _i++) { + var name_1 = variantName_1[_i]; + select(name_1); + } + } + else { + select(variantName); + } + extensionMetadata.lastSelected = variantName; + }; + /** + * Select a variant given a variant name or a list of variant names. + * @param rootMesh The glTF root mesh + * @param variantName The variant name(s) to select. + */ + KHR_materials_variants.prototype.selectVariant = function (rootMesh, variantName) { + KHR_materials_variants.SelectVariant(rootMesh, variantName); + }; + /** + * Reset back to the original before selecting a variant. + * @param rootMesh The glTF root mesh + */ + KHR_materials_variants.Reset = function (rootMesh) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + throw new Error("Cannot reset on a glTF mesh that does not have the ".concat(NAME, " extension")); + } + for (var _i = 0, _a = extensionMetadata.original; _i < _a.length; _i++) { + var entry = _a[_i]; + entry.mesh.material = entry.material; + } + extensionMetadata.lastSelected = null; + }; + /** + * Reset back to the original before selecting a variant. + * @param rootMesh The glTF root mesh + */ + KHR_materials_variants.prototype.reset = function (rootMesh) { + KHR_materials_variants.Reset(rootMesh); + }; + /** + * Gets the last selected variant name(s) or null if original. + * @param rootMesh The glTF root mesh + * @returns The selected variant name(s). + */ + KHR_materials_variants.GetLastSelectedVariant = function (rootMesh) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the ".concat(NAME, " extension")); + } + return extensionMetadata.lastSelected; + }; + /** + * Gets the last selected variant name(s) or null if original. + * @param rootMesh The glTF root mesh + * @returns The selected variant name(s). + */ + KHR_materials_variants.prototype.getLastSelectedVariant = function (rootMesh) { + return KHR_materials_variants.GetLastSelectedVariant(rootMesh); + }; + KHR_materials_variants._GetExtensionMetadata = function (rootMesh) { + var _a, _b; + return ((_b = (_a = rootMesh === null || rootMesh === void 0 ? void 0 : rootMesh._internalMetadata) === null || _a === void 0 ? void 0 : _a.gltf) === null || _b === void 0 ? void 0 : _b[NAME]) || null; + }; + /** @internal */ + KHR_materials_variants.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._variants = extension.variants; + } + }; + /** + * @internal + */ + KHR_materials_variants.prototype._loadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, function (babylonMesh) { + assign(babylonMesh); + if (babylonMesh instanceof babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.Mesh) { + var babylonDrawMode = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader._GetDrawMode(context, primitive.mode); + var root_1 = _this._loader.rootBabylonMesh; + var metadata = root_1 ? (root_1._internalMetadata = root_1._internalMetadata || {}) : {}; + var gltf = (metadata.gltf = metadata.gltf || {}); + var extensionMetadata_1 = (gltf[NAME] = gltf[NAME] || { lastSelected: null, original: [], variants: {} }); + // Store the original material. + extensionMetadata_1.original.push({ mesh: babylonMesh, material: babylonMesh.material }); + var _loop_1 = function (mappingIndex) { + var mapping = extension.mappings[mappingIndex]; + var material = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/mappings/").concat(mappingIndex, "/material"), _this._loader.gltf.materials, mapping.material); + promises.push(_this._loader._loadMaterialAsync("#/materials/".concat(mapping.material), material, babylonMesh, babylonDrawMode, function (babylonMaterial) { + var _loop_2 = function (mappingVariantIndex) { + var variantIndex = mapping.variants[mappingVariantIndex]; + var variant = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("/extensions/".concat(NAME, "/variants/").concat(variantIndex), _this._variants, variantIndex); + extensionMetadata_1.variants[variant.name] = extensionMetadata_1.variants[variant.name] || []; + extensionMetadata_1.variants[variant.name].push({ + mesh: babylonMesh, + material: babylonMaterial, + }); + // Replace the target when original mesh is cloned + babylonMesh.onClonedObservable.add(function (newOne) { + var newMesh = newOne; + var metadata = null; + var newRoot = newMesh; + // Find root to get medata + do { + newRoot = newRoot.parent; + if (!newRoot) { + return; + } + metadata = KHR_materials_variants._GetExtensionMetadata(newRoot); + } while (metadata === null); + // Need to clone the metadata on the root (first time only) + if (root_1 && metadata === KHR_materials_variants._GetExtensionMetadata(root_1)) { + // Copy main metadata + newRoot._internalMetadata = {}; + for (var key in root_1._internalMetadata) { + newRoot._internalMetadata[key] = root_1._internalMetadata[key]; + } + // Copy the gltf metadata + newRoot._internalMetadata.gltf = []; + for (var key in root_1._internalMetadata.gltf) { + newRoot._internalMetadata.gltf[key] = root_1._internalMetadata.gltf[key]; + } + // Duplicate the extension specific metadata + newRoot._internalMetadata.gltf[NAME] = { lastSelected: null, original: [], variants: {} }; + for (var _i = 0, _a = metadata.original; _i < _a.length; _i++) { + var original = _a[_i]; + newRoot._internalMetadata.gltf[NAME].original.push({ + mesh: original.mesh, + material: original.material, + }); + } + for (var key in metadata.variants) { + if (Object.prototype.hasOwnProperty.call(metadata.variants, key)) { + newRoot._internalMetadata.gltf[NAME].variants[key] = []; + for (var _b = 0, _c = metadata.variants[key]; _b < _c.length; _b++) { + var variantEntry = _c[_b]; + newRoot._internalMetadata.gltf[NAME].variants[key].push({ + mesh: variantEntry.mesh, + material: variantEntry.material, + }); + } + } + } + metadata = newRoot._internalMetadata.gltf[NAME]; + } + // Relocate + for (var _d = 0, _e = metadata.original; _d < _e.length; _d++) { + var target = _e[_d]; + if (target.mesh === babylonMesh) { + target.mesh = newMesh; + } + } + for (var _f = 0, _g = metadata.variants[variant.name]; _f < _g.length; _f++) { + var target = _g[_f]; + if (target.mesh === babylonMesh) { + target.mesh = newMesh; + } + } + }); + }; + for (var mappingVariantIndex = 0; mappingVariantIndex < mapping.variants.length; ++mappingVariantIndex) { + _loop_2(mappingVariantIndex); + } + })); + }; + // For each mapping, look at the variants and make a new entry for them. + for (var mappingIndex = 0; mappingIndex < extension.mappings.length; ++mappingIndex) { + _loop_1(mappingIndex); + } + } + })); + return Promise.all(promises).then(function (_a) { + var babylonMesh = _a[0]; + return babylonMesh; + }); + }); + }; + return KHR_materials_variants; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_variants(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts": +/*!****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts ***! + \****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_volume: () => (/* binding */ KHR_materials_volume) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_volume"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_volume/README.md) + * @since 5.0.0 + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_volume = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_volume(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 173; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + if (this.enabled) { + // We need to disable instance usage because the attenuation factor depends on the node scale of each individual mesh + this._loader._disableInstancedMesh++; + } + } + /** @internal */ + KHR_materials_volume.prototype.dispose = function () { + if (this.enabled) { + this._loader._disableInstancedMesh--; + } + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_volume.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadVolumePropertiesAsync(extensionContext, material, babylonMaterial, extension)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_volume.prototype._loadVolumePropertiesAsync = function (context, material, babylonMaterial, extension) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + // If transparency isn't enabled already, this extension shouldn't do anything. + // i.e. it requires either the KHR_materials_transmission or KHR_materials_translucency extensions. + if ((!babylonMaterial.subSurface.isRefractionEnabled && !babylonMaterial.subSurface.isTranslucencyEnabled) || !extension.thicknessFactor) { + return Promise.resolve(); + } + // IOR in this extension only affects interior. + babylonMaterial.subSurface.volumeIndexOfRefraction = babylonMaterial.indexOfRefraction; + var attenuationDistance = extension.attenuationDistance !== undefined ? extension.attenuationDistance : Number.MAX_VALUE; + babylonMaterial.subSurface.tintColorAtDistance = attenuationDistance; + if (extension.attenuationColor !== undefined && extension.attenuationColor.length == 3) { + babylonMaterial.subSurface.tintColor.copyFromFloats(extension.attenuationColor[0], extension.attenuationColor[1], extension.attenuationColor[2]); + } + babylonMaterial.subSurface.minimumThickness = 0.0; + babylonMaterial.subSurface.maximumThickness = extension.thicknessFactor; + babylonMaterial.subSurface.useThicknessAsDepth = true; + if (extension.thicknessTexture) { + extension.thicknessTexture.nonColorData = true; + return this._loader.loadTextureInfoAsync("".concat(context, "/thicknessTexture"), extension.thicknessTexture).then(function (texture) { + babylonMaterial.subSurface.thicknessTexture = texture; + babylonMaterial.subSurface.useGltfStyleTextures = true; + }); + } + else { + return Promise.resolve(); + } + }; + return KHR_materials_volume; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_volume(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts": +/*!*****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_mesh_quantization: () => (/* binding */ KHR_mesh_quantization) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "KHR_mesh_quantization"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_mesh_quantization = /** @class */ (function () { + /** + * @internal + */ + function KHR_mesh_quantization(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this.enabled = loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_mesh_quantization.prototype.dispose = function () { }; + return KHR_mesh_quantization; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_mesh_quantization(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts": +/*!**************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_texture_basisu: () => (/* binding */ KHR_texture_basisu) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "KHR_texture_basisu"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_texture_basisu = /** @class */ (function () { + /** + * @internal + */ + function KHR_texture_basisu(loader) { + /** The name of this extension. */ + this.name = NAME; + this._loader = loader; + this.enabled = loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_texture_basisu.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_texture_basisu.prototype._loadTextureAsync = function (context, texture, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, texture, this.name, function (extensionContext, extension) { + var sampler = texture.sampler == undefined ? _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.DefaultSampler : _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/sampler"), _this._loader.gltf.samplers, texture.sampler); + var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/source"), _this._loader.gltf.images, extension.source); + return _this._loader._createTextureAsync(context, sampler, image, function (babylonTexture) { + assign(babylonTexture); + }, texture._textureInfo.nonColorData ? { useRGBAIfASTCBC7NotAvailableWhenUASTC: true } : undefined, !texture._textureInfo.nonColorData); + }); + }; + return KHR_texture_basisu; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_texture_basisu(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts": +/*!*****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_texture_transform: () => (/* binding */ KHR_texture_transform) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/Textures/texture */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_texture_transform"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_transform/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_texture_transform = /** @class */ (function () { + /** + * @internal + */ + function KHR_texture_transform(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_texture_transform.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_texture_transform.prototype.loadTextureInfoAsync = function (context, textureInfo, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, textureInfo, this.name, function (extensionContext, extension) { + return _this._loader.loadTextureInfoAsync(context, textureInfo, function (babylonTexture) { + if (!(babylonTexture instanceof babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__.Texture)) { + throw new Error("".concat(extensionContext, ": Texture type not supported")); + } + if (extension.offset) { + babylonTexture.uOffset = extension.offset[0]; + babylonTexture.vOffset = extension.offset[1]; + } + // Always rotate around the origin. + babylonTexture.uRotationCenter = 0; + babylonTexture.vRotationCenter = 0; + if (extension.rotation) { + babylonTexture.wAng = -extension.rotation; + } + if (extension.scale) { + babylonTexture.uScale = extension.scale[0]; + babylonTexture.vScale = extension.scale[1]; + } + if (extension.texCoord != undefined) { + babylonTexture.coordinatesIndex = extension.texCoord; + } + assign(babylonTexture); + }); + }); + }; + return KHR_texture_transform; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_texture_transform(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts": +/*!***********************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts ***! + \***********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_xmp_json_ld: () => (/* binding */ KHR_xmp_json_ld) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "KHR_xmp_json_ld"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_xmp_json_ld/README.md) + * @since 5.0.0 + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_xmp_json_ld = /** @class */ (function () { + /** + * @internal + */ + function KHR_xmp_json_ld(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 100; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_xmp_json_ld.prototype.dispose = function () { + this._loader = null; + }; + /** + * Called after the loader state changes to LOADING. + */ + KHR_xmp_json_ld.prototype.onLoading = function () { + var _a, _b, _c; + if (this._loader.rootBabylonMesh === null) { + return; + } + var xmp_gltf = (_a = this._loader.gltf.extensions) === null || _a === void 0 ? void 0 : _a.KHR_xmp_json_ld; + var xmp_node = (_c = (_b = this._loader.gltf.asset) === null || _b === void 0 ? void 0 : _b.extensions) === null || _c === void 0 ? void 0 : _c.KHR_xmp_json_ld; + if (xmp_gltf && xmp_node) { + var packet = +xmp_node.packet; + if (xmp_gltf.packets && packet < xmp_gltf.packets.length) { + this._loader.rootBabylonMesh.metadata = this._loader.rootBabylonMesh.metadata || {}; + this._loader.rootBabylonMesh.metadata.xmp = xmp_gltf.packets[packet]; + } + } + }; + return KHR_xmp_json_ld; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_xmp_json_ld(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts": +/*!**************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_audio_emitter: () => (/* binding */ MSFT_audio_emitter) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Audio/weightedsound */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + + +var NAME = "MSFT_audio_emitter"; +/** + * [Specification](https://github.com/najadojo/glTF/blob/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter/README.md) + * !!! Experimental Extension Subject to Changes !!! + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_audio_emitter = /** @class */ (function () { + /** + * @internal + */ + function MSFT_audio_emitter(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_audio_emitter.prototype.dispose = function () { + this._loader = null; + this._clips = null; + this._emitters = null; + }; + /** @internal */ + MSFT_audio_emitter.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._clips = extension.clips; + this._emitters = extension.emitters; + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(this._clips); + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(this._emitters); + } + }; + /** + * @internal + */ + MSFT_audio_emitter.prototype.loadSceneAsync = function (context, scene) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadSceneAsync(context, scene)); + for (var _i = 0, _a = extension.emitters; _i < _a.length; _i++) { + var emitterIndex = _a[_i]; + var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/emitters"), _this._emitters, emitterIndex); + if (emitter.refDistance != undefined || + emitter.maxDistance != undefined || + emitter.rolloffFactor != undefined || + emitter.distanceModel != undefined || + emitter.innerAngle != undefined || + emitter.outerAngle != undefined) { + throw new Error("".concat(extensionContext, ": Direction or Distance properties are not allowed on emitters attached to a scene")); + } + promises.push(_this._loadEmitterAsync("".concat(extensionContext, "/emitters/").concat(emitter.index), emitter)); + } + return Promise.all(promises).then(function () { }); + }); + }; + /** + * @internal + */ + MSFT_audio_emitter.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + var promises = new Array(); + return _this._loader + .loadNodeAsync(extensionContext, node, function (babylonMesh) { + var _loop_1 = function (emitterIndex) { + var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/emitters"), _this._emitters, emitterIndex); + promises.push(_this._loadEmitterAsync("".concat(extensionContext, "/emitters/").concat(emitter.index), emitter).then(function () { + for (var _i = 0, _a = emitter._babylonSounds; _i < _a.length; _i++) { + var sound = _a[_i]; + sound.attachToMesh(babylonMesh); + if (emitter.innerAngle != undefined || emitter.outerAngle != undefined) { + sound.setLocalDirectionToMesh(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Forward()); + sound.setDirectionalCone(2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.innerAngle == undefined ? Math.PI : emitter.innerAngle), 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.outerAngle == undefined ? Math.PI : emitter.outerAngle), 0); + } + } + })); + }; + for (var _i = 0, _a = extension.emitters; _i < _a.length; _i++) { + var emitterIndex = _a[_i]; + _loop_1(emitterIndex); + } + assign(babylonMesh); + }) + .then(function (babylonMesh) { + return Promise.all(promises).then(function () { + return babylonMesh; + }); + }); + }); + }; + /** + * @internal + */ + MSFT_audio_emitter.prototype.loadAnimationAsync = function (context, animation) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, animation, this.name, function (extensionContext, extension) { + return _this._loader.loadAnimationAsync(context, animation).then(function (babylonAnimationGroup) { + var promises = new Array(); + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(extension.events); + for (var _i = 0, _a = extension.events; _i < _a.length; _i++) { + var event_1 = _a[_i]; + promises.push(_this._loadAnimationEventAsync("".concat(extensionContext, "/events/").concat(event_1.index), context, animation, event_1, babylonAnimationGroup)); + } + return Promise.all(promises).then(function () { + return babylonAnimationGroup; + }); + }); + }); + }; + MSFT_audio_emitter.prototype._loadClipAsync = function (context, clip) { + if (clip._objectURL) { + return clip._objectURL; + } + var promise; + if (clip.uri) { + promise = this._loader.loadUriAsync(context, clip, clip.uri); + } + else { + var bufferView = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(context, "/bufferView"), this._loader.gltf.bufferViews, clip.bufferView); + promise = this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView); + } + clip._objectURL = promise.then(function (data) { + return URL.createObjectURL(new Blob([data], { type: clip.mimeType })); + }); + return clip._objectURL; + }; + MSFT_audio_emitter.prototype._loadEmitterAsync = function (context, emitter) { + var _this = this; + emitter._babylonSounds = emitter._babylonSounds || []; + if (!emitter._babylonData) { + var clipPromises = new Array(); + var name_1 = emitter.name || "emitter".concat(emitter.index); + var options_1 = { + loop: false, + autoplay: false, + volume: emitter.volume == undefined ? 1 : emitter.volume, + }; + var _loop_2 = function (i) { + var clipContext = "/extensions/".concat(this_1.name, "/clips"); + var clip = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(clipContext, this_1._clips, emitter.clips[i].clip); + clipPromises.push(this_1._loadClipAsync("".concat(clipContext, "/").concat(emitter.clips[i].clip), clip).then(function (objectURL) { + var sound = (emitter._babylonSounds[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Sound(name_1, objectURL, _this._loader.babylonScene, null, options_1)); + sound.refDistance = emitter.refDistance || 1; + sound.maxDistance = emitter.maxDistance || 256; + sound.rolloffFactor = emitter.rolloffFactor || 1; + sound.distanceModel = emitter.distanceModel || "exponential"; + })); + }; + var this_1 = this; + for (var i = 0; i < emitter.clips.length; i++) { + _loop_2(i); + } + var promise = Promise.all(clipPromises).then(function () { + var weights = emitter.clips.map(function (clip) { + return clip.weight || 1; + }); + var weightedSound = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.WeightedSound(emitter.loop || false, emitter._babylonSounds, weights); + if (emitter.innerAngle) { + weightedSound.directionalConeInnerAngle = 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.innerAngle); + } + if (emitter.outerAngle) { + weightedSound.directionalConeOuterAngle = 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.outerAngle); + } + if (emitter.volume) { + weightedSound.volume = emitter.volume; + } + emitter._babylonData.sound = weightedSound; + }); + emitter._babylonData = { + loaded: promise, + }; + } + return emitter._babylonData.loaded; + }; + MSFT_audio_emitter.prototype._getEventAction = function (context, sound, action, time, startOffset) { + switch (action) { + case "play" /* IMSFTAudioEmitter_AnimationEventAction.play */: { + return function (currentFrame) { + var frameOffset = (startOffset || 0) + (currentFrame - time); + sound.play(frameOffset); + }; + } + case "stop" /* IMSFTAudioEmitter_AnimationEventAction.stop */: { + return function () { + sound.stop(); + }; + } + case "pause" /* IMSFTAudioEmitter_AnimationEventAction.pause */: { + return function () { + sound.pause(); + }; + } + default: { + throw new Error("".concat(context, ": Unsupported action ").concat(action)); + } + } + }; + MSFT_audio_emitter.prototype._loadAnimationEventAsync = function (context, animationContext, animation, event, babylonAnimationGroup) { + var _this = this; + if (babylonAnimationGroup.targetedAnimations.length == 0) { + return Promise.resolve(); + } + var babylonAnimation = babylonAnimationGroup.targetedAnimations[0]; + var emitterIndex = event.emitter; + var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("/extensions/".concat(this.name, "/emitters"), this._emitters, emitterIndex); + return this._loadEmitterAsync(context, emitter).then(function () { + var sound = emitter._babylonData.sound; + if (sound) { + var babylonAnimationEvent = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.AnimationEvent(event.time, _this._getEventAction(context, sound, event.action, event.time, event.startOffset)); + babylonAnimation.animation.addEvent(babylonAnimationEvent); + // Make sure all started audio stops when this animation is terminated. + babylonAnimationGroup.onAnimationGroupEndObservable.add(function () { + sound.stop(); + }); + babylonAnimationGroup.onAnimationGroupPauseObservable.add(function () { + sound.pause(); + }); + } + }); + }; + return MSFT_audio_emitter; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_audio_emitter(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts": +/*!****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_lod: () => (/* binding */ MSFT_lod) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/deferred */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "MSFT_lod"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/MSFT_lod/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_lod = /** @class */ (function () { + /** + * @internal + */ + function MSFT_lod(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 100; + /** + * Maximum number of LODs to load, starting from the lowest LOD. + */ + this.maxLODsToLoad = 10; + /** + * Observable raised when all node LODs of one level are loaded. + * The event data is the index of the loaded LOD starting from zero. + * Dispose the loader to cancel the loading of the next level of LODs. + */ + this.onNodeLODsLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when all material LODs of one level are loaded. + * The event data is the index of the loaded LOD starting from zero. + * Dispose the loader to cancel the loading of the next level of LODs. + */ + this.onMaterialLODsLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._bufferLODs = new Array(); + this._nodeIndexLOD = null; + this._nodeSignalLODs = new Array(); + this._nodePromiseLODs = new Array(); + this._nodeBufferLODs = new Array(); + this._materialIndexLOD = null; + this._materialSignalLODs = new Array(); + this._materialPromiseLODs = new Array(); + this._materialBufferLODs = new Array(); + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_lod.prototype.dispose = function () { + this._loader = null; + this._nodeIndexLOD = null; + this._nodeSignalLODs.length = 0; + this._nodePromiseLODs.length = 0; + this._nodeBufferLODs.length = 0; + this._materialIndexLOD = null; + this._materialSignalLODs.length = 0; + this._materialPromiseLODs.length = 0; + this._materialBufferLODs.length = 0; + this.onMaterialLODsLoadedObservable.clear(); + this.onNodeLODsLoadedObservable.clear(); + }; + /** @internal */ + MSFT_lod.prototype.onReady = function () { + var _this = this; + var _loop_1 = function (indexLOD) { + var promise = Promise.all(this_1._nodePromiseLODs[indexLOD]).then(function () { + if (indexLOD !== 0) { + _this._loader.endPerformanceCounter("Node LOD ".concat(indexLOD)); + _this._loader.log("Loaded node LOD ".concat(indexLOD)); + } + _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD); + if (indexLOD !== _this._nodePromiseLODs.length - 1) { + _this._loader.startPerformanceCounter("Node LOD ".concat(indexLOD + 1)); + _this._loadBufferLOD(_this._nodeBufferLODs, indexLOD + 1); + if (_this._nodeSignalLODs[indexLOD]) { + _this._nodeSignalLODs[indexLOD].resolve(); + } + } + }); + this_1._loader._completePromises.push(promise); + }; + var this_1 = this; + for (var indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) { + _loop_1(indexLOD); + } + var _loop_2 = function (indexLOD) { + var promise = Promise.all(this_2._materialPromiseLODs[indexLOD]).then(function () { + if (indexLOD !== 0) { + _this._loader.endPerformanceCounter("Material LOD ".concat(indexLOD)); + _this._loader.log("Loaded material LOD ".concat(indexLOD)); + } + _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD); + if (indexLOD !== _this._materialPromiseLODs.length - 1) { + _this._loader.startPerformanceCounter("Material LOD ".concat(indexLOD + 1)); + _this._loadBufferLOD(_this._materialBufferLODs, indexLOD + 1); + if (_this._materialSignalLODs[indexLOD]) { + _this._materialSignalLODs[indexLOD].resolve(); + } + } + }); + this_2._loader._completePromises.push(promise); + }; + var this_2 = this; + for (var indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) { + _loop_2(indexLOD); + } + }; + /** + * @internal + */ + MSFT_lod.prototype.loadSceneAsync = function (context, scene) { + var promise = this._loader.loadSceneAsync(context, scene); + this._loadBufferLOD(this._bufferLODs, 0); + return promise; + }; + /** + * @internal + */ + MSFT_lod.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + var firstPromise; + var nodeLODs = _this._getLODs(extensionContext, node, _this._loader.gltf.nodes, extension.ids); + _this._loader.logOpen("".concat(extensionContext)); + var _loop_3 = function (indexLOD) { + var nodeLOD = nodeLODs[indexLOD]; + if (indexLOD !== 0) { + _this._nodeIndexLOD = indexLOD; + _this._nodeSignalLODs[indexLOD] = _this._nodeSignalLODs[indexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + } + var assignWrap = function (babylonTransformNode) { + assign(babylonTransformNode); + babylonTransformNode.setEnabled(false); + }; + var promise = _this._loader.loadNodeAsync("/nodes/".concat(nodeLOD.index), nodeLOD, assignWrap).then(function (babylonMesh) { + if (indexLOD !== 0) { + // TODO: should not rely on _babylonTransformNode + var previousNodeLOD = nodeLODs[indexLOD - 1]; + if (previousNodeLOD._babylonTransformNode) { + _this._disposeTransformNode(previousNodeLOD._babylonTransformNode); + delete previousNodeLOD._babylonTransformNode; + } + } + babylonMesh.setEnabled(true); + return babylonMesh; + }); + _this._nodePromiseLODs[indexLOD] = _this._nodePromiseLODs[indexLOD] || []; + if (indexLOD === 0) { + firstPromise = promise; + } + else { + _this._nodeIndexLOD = null; + _this._nodePromiseLODs[indexLOD].push(promise); + } + }; + for (var indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) { + _loop_3(indexLOD); + } + _this._loader.logClose(); + return firstPromise; + }); + }; + /** + * @internal + */ + MSFT_lod.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) { + var _this = this; + // Don't load material LODs if already loading a node LOD. + if (this._nodeIndexLOD) { + return null; + } + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var firstPromise; + var materialLODs = _this._getLODs(extensionContext, material, _this._loader.gltf.materials, extension.ids); + _this._loader.logOpen("".concat(extensionContext)); + var _loop_4 = function (indexLOD) { + var materialLOD = materialLODs[indexLOD]; + if (indexLOD !== 0) { + _this._materialIndexLOD = indexLOD; + } + var promise = _this._loader + ._loadMaterialAsync("/materials/".concat(materialLOD.index), materialLOD, babylonMesh, babylonDrawMode, function (babylonMaterial) { + if (indexLOD === 0) { + assign(babylonMaterial); + } + }) + .then(function (babylonMaterial) { + if (indexLOD !== 0) { + assign(babylonMaterial); + // TODO: should not rely on _data + var previousDataLOD = materialLODs[indexLOD - 1]._data; + if (previousDataLOD[babylonDrawMode]) { + _this._disposeMaterials([previousDataLOD[babylonDrawMode].babylonMaterial]); + delete previousDataLOD[babylonDrawMode]; + } + } + return babylonMaterial; + }); + _this._materialPromiseLODs[indexLOD] = _this._materialPromiseLODs[indexLOD] || []; + if (indexLOD === 0) { + firstPromise = promise; + } + else { + _this._materialIndexLOD = null; + _this._materialPromiseLODs[indexLOD].push(promise); + } + }; + for (var indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) { + _loop_4(indexLOD); + } + _this._loader.logClose(); + return firstPromise; + }); + }; + /** + * @internal + */ + MSFT_lod.prototype._loadUriAsync = function (context, property, uri) { + var _this = this; + // Defer the loading of uris if loading a node or material LOD. + if (this._nodeIndexLOD !== null) { + this._loader.log("deferred"); + var previousIndexLOD = this._nodeIndexLOD - 1; + this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(function () { + return _this._loader.loadUriAsync(context, property, uri); + }); + } + else if (this._materialIndexLOD !== null) { + this._loader.log("deferred"); + var previousIndexLOD = this._materialIndexLOD - 1; + this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + return this._materialSignalLODs[previousIndexLOD].promise.then(function () { + return _this._loader.loadUriAsync(context, property, uri); + }); + } + return null; + }; + /** + * @internal + */ + MSFT_lod.prototype.loadBufferAsync = function (context, buffer, byteOffset, byteLength) { + if (this._loader.parent.useRangeRequests && !buffer.uri) { + if (!this._loader.bin) { + throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk")); + } + var loadAsync = function (bufferLODs, indexLOD) { + var start = byteOffset; + var end = start + byteLength - 1; + var bufferLOD = bufferLODs[indexLOD]; + if (bufferLOD) { + bufferLOD.start = Math.min(bufferLOD.start, start); + bufferLOD.end = Math.max(bufferLOD.end, end); + } + else { + bufferLOD = { start: start, end: end, loaded: new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred() }; + bufferLODs[indexLOD] = bufferLOD; + } + return bufferLOD.loaded.promise.then(function (data) { + return new Uint8Array(data.buffer, data.byteOffset + byteOffset - bufferLOD.start, byteLength); + }); + }; + this._loader.log("deferred"); + if (this._nodeIndexLOD !== null) { + return loadAsync(this._nodeBufferLODs, this._nodeIndexLOD); + } + else if (this._materialIndexLOD !== null) { + return loadAsync(this._materialBufferLODs, this._materialIndexLOD); + } + else { + return loadAsync(this._bufferLODs, 0); + } + } + return null; + }; + MSFT_lod.prototype._loadBufferLOD = function (bufferLODs, indexLOD) { + var bufferLOD = bufferLODs[indexLOD]; + if (bufferLOD) { + this._loader.log("Loading buffer range [".concat(bufferLOD.start, "-").concat(bufferLOD.end, "]")); + this._loader.bin.readAsync(bufferLOD.start, bufferLOD.end - bufferLOD.start + 1).then(function (data) { + bufferLOD.loaded.resolve(data); + }, function (error) { + bufferLOD.loaded.reject(error); + }); + } + }; + /** + * @returns an array of LOD properties from lowest to highest. + * @param context + * @param property + * @param array + * @param ids + */ + MSFT_lod.prototype._getLODs = function (context, property, array, ids) { + if (this.maxLODsToLoad <= 0) { + throw new Error("maxLODsToLoad must be greater than zero"); + } + var properties = []; + for (var i = ids.length - 1; i >= 0; i--) { + properties.push(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(context, "/ids/").concat(ids[i]), array, ids[i])); + if (properties.length === this.maxLODsToLoad) { + return properties; + } + } + properties.push(property); + return properties; + }; + MSFT_lod.prototype._disposeTransformNode = function (babylonTransformNode) { + var _this = this; + var babylonMaterials = []; + var babylonMaterial = babylonTransformNode.material; + if (babylonMaterial) { + babylonMaterials.push(babylonMaterial); + } + for (var _i = 0, _a = babylonTransformNode.getChildMeshes(); _i < _a.length; _i++) { + var babylonMesh = _a[_i]; + if (babylonMesh.material) { + babylonMaterials.push(babylonMesh.material); + } + } + babylonTransformNode.dispose(); + var babylonMaterialsToDispose = babylonMaterials.filter(function (babylonMaterial) { return _this._loader.babylonScene.meshes.every(function (mesh) { return mesh.material != babylonMaterial; }); }); + this._disposeMaterials(babylonMaterialsToDispose); + }; + MSFT_lod.prototype._disposeMaterials = function (babylonMaterials) { + var babylonTextures = {}; + for (var _i = 0, babylonMaterials_1 = babylonMaterials; _i < babylonMaterials_1.length; _i++) { + var babylonMaterial = babylonMaterials_1[_i]; + for (var _a = 0, _b = babylonMaterial.getActiveTextures(); _a < _b.length; _a++) { + var babylonTexture = _b[_a]; + babylonTextures[babylonTexture.uniqueId] = babylonTexture; + } + babylonMaterial.dispose(); + } + for (var uniqueId in babylonTextures) { + for (var _c = 0, _d = this._loader.babylonScene.materials; _c < _d.length; _c++) { + var babylonMaterial = _d[_c]; + if (babylonMaterial.hasTexture(babylonTextures[uniqueId])) { + delete babylonTextures[uniqueId]; + } + } + } + for (var uniqueId in babylonTextures) { + babylonTextures[uniqueId].dispose(); + } + }; + return MSFT_lod; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_lod(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts": +/*!**************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_minecraftMesh: () => (/* binding */ MSFT_minecraftMesh) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "MSFT_minecraftMesh"; +/** @internal */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_minecraftMesh = /** @class */ (function () { + /** @internal */ + function MSFT_minecraftMesh(loader) { + /** @internal */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_minecraftMesh.prototype.dispose = function () { + this._loader = null; + }; + /** @internal */ + MSFT_minecraftMesh.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtraAsync(context, material, this.name, function (extraContext, extra) { + if (extra) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(extraContext, ": Material type not supported")); + } + var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial); + if (babylonMaterial.needAlphaBlending()) { + babylonMaterial.forceDepthWrite = true; + babylonMaterial.separateCullingPass = true; + } + babylonMaterial.backFaceCulling = babylonMaterial.forceDepthWrite; + babylonMaterial.twoSidedLighting = true; + return promise; + } + return null; + }); + }; + return MSFT_minecraftMesh; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_minecraftMesh(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts": +/*!************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_sRGBFactors: () => (/* binding */ MSFT_sRGBFactors) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "MSFT_sRGBFactors"; +/** @internal */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_sRGBFactors = /** @class */ (function () { + /** @internal */ + function MSFT_sRGBFactors(loader) { + /** @internal */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_sRGBFactors.prototype.dispose = function () { + this._loader = null; + }; + /** @internal */ + MSFT_sRGBFactors.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtraAsync(context, material, this.name, function (extraContext, extra) { + if (extra) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(extraContext, ": Material type not supported")); + } + var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial); + var useExactSrgbConversions = babylonMaterial.getScene().getEngine().useExactSrgbConversions; + if (!babylonMaterial.albedoTexture) { + babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor, useExactSrgbConversions); + } + if (!babylonMaterial.reflectivityTexture) { + babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor, useExactSrgbConversions); + } + return promise; + } + return null; + }); + }; + return MSFT_sRGBFactors; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_sRGBFactors(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts": +/*!*********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts ***! + \*********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFPathToObjectConverter: () => (/* binding */ GLTFPathToObjectConverter) +/* harmony export */ }); +/** + * A converter that takes a glTF Object Model JSON Pointer + * and transforms it into an ObjectAccessorContainer, allowing + * objects referenced in the glTF to be associated with their + * respective Babylon.js objects. + */ +var GLTFPathToObjectConverter = /** @class */ (function () { + function GLTFPathToObjectConverter(_gltf, _infoTree) { + this._gltf = _gltf; + this._infoTree = _infoTree; + } + /** + * The pointer string is represented by a [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901). + * := /// + * := "nodes" | "materials" | "meshes" | "cameras" | "extensions" + * := | + * := | + * := "extensions"// + * := | / + * := W+ + * := D+ + * + * Examples: + * - "/nodes/0/rotation" + * - "/materials/2/emissiveFactor" + * - "/materials/2/pbrMetallicRoughness/baseColorFactor" + * - "/materials/2/extensions/KHR_materials_emissive_strength/emissiveStrength" + * + * @param path The path to convert + * @returns The object and info associated with the path + */ + GLTFPathToObjectConverter.prototype.convert = function (path) { + var objectTree = this._gltf; + var infoTree = this._infoTree; + var target = undefined; + if (!path.startsWith("/")) { + throw new Error("Path must start with a /"); + } + var parts = path.split("/"); + parts.shift(); + for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { + var part = parts_1[_i]; + if (infoTree.__array__) { + infoTree = infoTree.__array__; + } + else { + infoTree = infoTree[part]; + if (!infoTree) { + throw new Error("Path ".concat(path, " is invalid")); + } + } + if (objectTree === undefined) { + throw new Error("Path ".concat(path, " is invalid")); + } + objectTree = objectTree[part]; + if (infoTree.__target__) { + target = objectTree; + } + } + return { + object: target, + info: infoTree, + }; + }; + return GLTFPathToObjectConverter; +}()); + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/index.ts": +/*!*************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/index.ts ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_lights_image_based: () => (/* reexport safe */ _EXT_lights_image_based__WEBPACK_IMPORTED_MODULE_0__.EXT_lights_image_based), +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* reexport safe */ _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_1__.EXT_mesh_gpu_instancing), +/* harmony export */ EXT_meshopt_compression: () => (/* reexport safe */ _EXT_meshopt_compression__WEBPACK_IMPORTED_MODULE_2__.EXT_meshopt_compression), +/* harmony export */ EXT_texture_webp: () => (/* reexport safe */ _EXT_texture_webp__WEBPACK_IMPORTED_MODULE_3__.EXT_texture_webp), +/* harmony export */ ExtrasAsMetadata: () => (/* reexport safe */ _ExtrasAsMetadata__WEBPACK_IMPORTED_MODULE_30__.ExtrasAsMetadata), +/* harmony export */ KHR_animation_pointer: () => (/* reexport safe */ _KHR_animation_pointer__WEBPACK_IMPORTED_MODULE_24__.KHR_animation_pointer), +/* harmony export */ KHR_draco_mesh_compression: () => (/* reexport safe */ _KHR_draco_mesh_compression__WEBPACK_IMPORTED_MODULE_4__.KHR_draco_mesh_compression), +/* harmony export */ KHR_interactivity: () => (/* reexport safe */ _KHR_interactivity__WEBPACK_IMPORTED_MODULE_29__.KHR_interactivity), +/* harmony export */ KHR_lights: () => (/* reexport safe */ _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_5__.KHR_lights), +/* harmony export */ KHR_materials_anisotropy: () => (/* reexport safe */ _KHR_materials_anisotropy__WEBPACK_IMPORTED_MODULE_10__.KHR_materials_anisotropy), +/* harmony export */ KHR_materials_clearcoat: () => (/* reexport safe */ _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_8__.KHR_materials_clearcoat), +/* harmony export */ KHR_materials_dispersion: () => (/* reexport safe */ _KHR_materials_dispersion__WEBPACK_IMPORTED_MODULE_19__.KHR_materials_dispersion), +/* harmony export */ KHR_materials_emissive_strength: () => (/* reexport safe */ _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_11__.KHR_materials_emissive_strength), +/* harmony export */ KHR_materials_ior: () => (/* reexport safe */ _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_14__.KHR_materials_ior), +/* harmony export */ KHR_materials_iridescence: () => (/* reexport safe */ _KHR_materials_iridescence__WEBPACK_IMPORTED_MODULE_9__.KHR_materials_iridescence), +/* harmony export */ KHR_materials_pbrSpecularGlossiness: () => (/* reexport safe */ _KHR_materials_pbrSpecularGlossiness__WEBPACK_IMPORTED_MODULE_6__.KHR_materials_pbrSpecularGlossiness), +/* harmony export */ KHR_materials_sheen: () => (/* reexport safe */ _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_12__.KHR_materials_sheen), +/* harmony export */ KHR_materials_specular: () => (/* reexport safe */ _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_13__.KHR_materials_specular), +/* harmony export */ KHR_materials_translucency: () => (/* reexport safe */ _KHR_materials_translucency__WEBPACK_IMPORTED_MODULE_17__.KHR_materials_translucency), +/* harmony export */ KHR_materials_transmission: () => (/* reexport safe */ _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_16__.KHR_materials_transmission), +/* harmony export */ KHR_materials_unlit: () => (/* reexport safe */ _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_unlit), +/* harmony export */ KHR_materials_variants: () => (/* reexport safe */ _KHR_materials_variants__WEBPACK_IMPORTED_MODULE_15__.KHR_materials_variants), +/* harmony export */ KHR_materials_volume: () => (/* reexport safe */ _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_18__.KHR_materials_volume), +/* harmony export */ KHR_mesh_quantization: () => (/* reexport safe */ _KHR_mesh_quantization__WEBPACK_IMPORTED_MODULE_20__.KHR_mesh_quantization), +/* harmony export */ KHR_texture_basisu: () => (/* reexport safe */ _KHR_texture_basisu__WEBPACK_IMPORTED_MODULE_21__.KHR_texture_basisu), +/* harmony export */ KHR_texture_transform: () => (/* reexport safe */ _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_22__.KHR_texture_transform), +/* harmony export */ KHR_xmp_json_ld: () => (/* reexport safe */ _KHR_xmp_json_ld__WEBPACK_IMPORTED_MODULE_23__.KHR_xmp_json_ld), +/* harmony export */ MSFT_audio_emitter: () => (/* reexport safe */ _MSFT_audio_emitter__WEBPACK_IMPORTED_MODULE_25__.MSFT_audio_emitter), +/* harmony export */ MSFT_lod: () => (/* reexport safe */ _MSFT_lod__WEBPACK_IMPORTED_MODULE_26__.MSFT_lod), +/* harmony export */ MSFT_minecraftMesh: () => (/* reexport safe */ _MSFT_minecraftMesh__WEBPACK_IMPORTED_MODULE_27__.MSFT_minecraftMesh), +/* harmony export */ MSFT_sRGBFactors: () => (/* reexport safe */ _MSFT_sRGBFactors__WEBPACK_IMPORTED_MODULE_28__.MSFT_sRGBFactors) +/* harmony export */ }); +/* harmony import */ var _EXT_lights_image_based__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EXT_lights_image_based */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts"); +/* harmony import */ var _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EXT_mesh_gpu_instancing */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts"); +/* harmony import */ var _EXT_meshopt_compression__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./EXT_meshopt_compression */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts"); +/* harmony import */ var _EXT_texture_webp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./EXT_texture_webp */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts"); +/* harmony import */ var _KHR_draco_mesh_compression__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./KHR_draco_mesh_compression */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts"); +/* harmony import */ var _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./KHR_lights_punctual */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"); +/* harmony import */ var _KHR_materials_pbrSpecularGlossiness__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./KHR_materials_pbrSpecularGlossiness */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts"); +/* harmony import */ var _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./KHR_materials_unlit */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts"); +/* harmony import */ var _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./KHR_materials_clearcoat */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts"); +/* harmony import */ var _KHR_materials_iridescence__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./KHR_materials_iridescence */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts"); +/* harmony import */ var _KHR_materials_anisotropy__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./KHR_materials_anisotropy */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts"); +/* harmony import */ var _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./KHR_materials_emissive_strength */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts"); +/* harmony import */ var _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./KHR_materials_sheen */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts"); +/* harmony import */ var _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./KHR_materials_specular */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts"); +/* harmony import */ var _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./KHR_materials_ior */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_ior.ts"); +/* harmony import */ var _KHR_materials_variants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./KHR_materials_variants */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts"); +/* harmony import */ var _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./KHR_materials_transmission */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"); +/* harmony import */ var _KHR_materials_translucency__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./KHR_materials_translucency */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_translucency.ts"); +/* harmony import */ var _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./KHR_materials_volume */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts"); +/* harmony import */ var _KHR_materials_dispersion__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./KHR_materials_dispersion */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts"); +/* harmony import */ var _KHR_mesh_quantization__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./KHR_mesh_quantization */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts"); +/* harmony import */ var _KHR_texture_basisu__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./KHR_texture_basisu */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts"); +/* harmony import */ var _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./KHR_texture_transform */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts"); +/* harmony import */ var _KHR_xmp_json_ld__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./KHR_xmp_json_ld */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts"); +/* harmony import */ var _KHR_animation_pointer__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./KHR_animation_pointer */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.ts"); +/* harmony import */ var _MSFT_audio_emitter__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./MSFT_audio_emitter */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts"); +/* harmony import */ var _MSFT_lod__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./MSFT_lod */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts"); +/* harmony import */ var _MSFT_minecraftMesh__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./MSFT_minecraftMesh */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts"); +/* harmony import */ var _MSFT_sRGBFactors__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./MSFT_sRGBFactors */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts"); +/* harmony import */ var _KHR_interactivity__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./KHR_interactivity */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity.ts"); +/* harmony import */ var _ExtrasAsMetadata__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./ExtrasAsMetadata */ "../../../dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts"); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/interactivityFunctions.ts": +/*!******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/interactivityFunctions.ts ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ convertGLTFToSerializedFlowGraph: () => (/* binding */ convertGLTFToSerializedFlowGraph) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/FlowGraph/flowGraphConnection */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _interactivityUtils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./interactivityUtils */ "../../../dev/loaders/src/glTF/2.0/Extensions/interactivityUtils.ts"); + + + +function convertValueWithType(configObject, definition, context) { + if (configObject.type !== undefined) { + // get the type on the gltf definition + var type = definition.types && definition.types[configObject.type]; + if (!type) { + throw new Error("".concat(context, ": Unknown type: ").concat(configObject.type)); + } + var signature = type.signature; + if (!signature) { + throw new Error("".concat(context, ": Type ").concat(configObject.type, " has no signature")); + } + var convertedType = _interactivityUtils__WEBPACK_IMPORTED_MODULE_1__.gltfTypeToBabylonType[signature]; + return { + value: configObject.value, + className: convertedType, + }; + } + else { + return configObject.value; + } +} +function convertConfiguration(gltfBlock, definition, id) { + var _a; + var converted = {}; + var configurationList = (_a = gltfBlock.configuration) !== null && _a !== void 0 ? _a : []; + for (var _i = 0, configurationList_1 = configurationList; _i < configurationList_1.length; _i++) { + var configObject = configurationList_1[_i]; + if (configObject.id === "customEvent") { + var customEvent = definition.customEvents && definition.customEvents[configObject.value]; + if (!customEvent) { + throw new Error("/extensions/KHR_interactivity/nodes/".concat(id, ": Unknown custom event: ").concat(configObject.value)); + } + converted.eventId = customEvent.id; + converted.eventData = customEvent.values.map(function (v) { return v.id; }); + } + else if (configObject.id === "variable") { + var variable = definition.variables && definition.variables[configObject.value]; + if (!variable) { + throw new Error("/extensions/KHR_interactivity/nodes/".concat(id, ": Unknown variable: ").concat(configObject.value)); + } + converted.variableName = variable.id; + } + else if (configObject.id === "path") { + // Convert from a GLTF path to a reference to the Babylon.js object + var pathValue = configObject.value; + converted.path = pathValue; + } + else { + converted[configObject.id] = convertValueWithType(configObject, definition, "/extensions/KHR_interactivity/nodes/".concat(id)); + } + } + return converted; +} +function convertBlock(id, gltfBlock, definition) { + var className = _interactivityUtils__WEBPACK_IMPORTED_MODULE_1__.gltfToFlowGraphTypeMap[gltfBlock.type]; + if (!className) { + throw new Error("/extensions/KHR_interactivity/nodes/".concat(id, ": Unknown block type: ").concat(gltfBlock.type)); + } + var uniqueId = id.toString(); + var config = convertConfiguration(gltfBlock, definition, uniqueId); + var metadata = gltfBlock.metadata; + var dataInputs = []; + var dataOutputs = []; + var signalInputs = []; + var signalOutputs = []; + return { + className: className, + config: config, + uniqueId: uniqueId, + metadata: metadata, + dataInputs: dataInputs, + dataOutputs: dataOutputs, + signalInputs: signalInputs, + signalOutputs: signalOutputs, + }; +} +/** + * @internal + * Converts a glTF Interactivity Extension to a serialized flow graph. + * @param gltf the interactivity data + * @returns a serialized flow graph + */ +function convertGLTFToSerializedFlowGraph(gltf) { + var _a, _b, _c; + // create an empty serialized context to store the values of the connections + var context = { + uniqueId: (0,babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.RandomGUID)(), + _userVariables: {}, + _connectionValues: {}, + }; + var executionContexts = [context]; + // Blocks converted to the flow graph json format + var flowGraphJsonBlocks = []; + for (var i = 0; i < gltf.nodes.length; i++) { + var gltfBlock = gltf.nodes[i]; + var flowGraphJsonBlock = convertBlock(i, gltfBlock, gltf); + flowGraphJsonBlocks.push(flowGraphJsonBlock); + } + // Parse the connections + for (var i = 0; i < gltf.nodes.length; i++) { + var gltfBlock = gltf.nodes[i]; + // get the block that was created in the previous step + var fgBlock = flowGraphJsonBlocks[i]; + var gltfFlows = (_a = gltfBlock.flows) !== null && _a !== void 0 ? _a : []; + var _loop_1 = function (flow) { + var socketOutName = flow.id; + // create an output connection for the flow graph block + var socketOut = { + uniqueId: (0,babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.RandomGUID)(), + name: socketOutName, + _connectionType: babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.FlowGraphConnectionType.Output, + connectedPointIds: [], + }; + fgBlock.signalOutputs.push(socketOut); + // get the input node of this flow + var nodeInId = flow.node; + var nodeInSocketName = flow.socket; + // find the corresponding flow graph node + var nodeIn = flowGraphJsonBlocks[nodeInId]; + if (!nodeIn) { + throw new Error("/extensions/KHR_interactivity/nodes/".concat(i, ": Could not find node with id ").concat(nodeInId, " that connects its input with with node ").concat(i, "'s output ").concat(socketOutName)); + } + // in all of the flow graph input connections, find the one with the same name as the socket + var socketIn = nodeIn.signalInputs.find(function (s) { return s.name === nodeInSocketName; }); + // if the socket doesn't exist, create the input socket for the connection + if (!socketIn) { + socketIn = { + uniqueId: (0,babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.RandomGUID)(), + name: nodeInSocketName, + _connectionType: babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.FlowGraphConnectionType.Input, + connectedPointIds: [], + }; + nodeIn.signalInputs.push(socketIn); + } + // connect the sockets + socketIn.connectedPointIds.push(socketOut.uniqueId); + socketOut.connectedPointIds.push(socketIn.uniqueId); + }; + // for each output flow of the gltf block + for (var _i = 0, gltfFlows_1 = gltfFlows; _i < gltfFlows_1.length; _i++) { + var flow = gltfFlows_1[_i]; + _loop_1(flow); + } + // for each input value of the gltf block + var gltfValues = (_b = gltfBlock.values) !== null && _b !== void 0 ? _b : []; + var _loop_2 = function (value) { + var socketInName = value.id; + // create an input data connection for the flow graph block + var socketIn = { + uniqueId: (0,babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.RandomGUID)(), + name: socketInName, + _connectionType: babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.FlowGraphConnectionType.Input, + connectedPointIds: [], + }; + fgBlock.dataInputs.push(socketIn); + if (value.value !== undefined) { + // if the value is set on the socket itself, store it in the context + var convertedValue = convertValueWithType(value, gltf, "/extensions/KHR_interactivity/nodes/".concat(i)); + // convertBlockInputType(gltfBlock, value, convertedValue, `/extensions/KHR_interactivity/nodes/${i}`); + context._connectionValues[socketIn.uniqueId] = convertedValue; + } + else if (value.node !== undefined && value.socket !== undefined) { + // if the value is connected with the output data of another socket, connect the two + var nodeOutId = value.node; + var nodeOutSocketName_1 = value.socket; + // find the flow graph node that owns that output socket + var nodeOut = flowGraphJsonBlocks[nodeOutId]; + if (!nodeOut) { + throw new Error("/extensions/KHR_interactivity/nodes/".concat(i, ": Could not find node with id ").concat(nodeOutId, " that connects its output with node").concat(i, "'s input ").concat(socketInName)); + } + var socketOut = nodeOut.dataOutputs.find(function (s) { return s.name === nodeOutSocketName_1; }); + // if the socket doesn't exist, create it + if (!socketOut) { + socketOut = { + uniqueId: (0,babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.RandomGUID)(), + name: nodeOutSocketName_1, + _connectionType: babylonjs_Misc_guid__WEBPACK_IMPORTED_MODULE_0__.FlowGraphConnectionType.Output, + connectedPointIds: [], + }; + nodeOut.dataOutputs.push(socketOut); + } + // connect the sockets + socketIn.connectedPointIds.push(socketOut.uniqueId); + socketOut.connectedPointIds.push(socketIn.uniqueId); + } + else { + throw new Error("/extensions/KHR_interactivity/nodes/".concat(i, ": Invalid socket ").concat(socketInName, " in node ").concat(i)); + } + }; + for (var _d = 0, gltfValues_1 = gltfValues; _d < gltfValues_1.length; _d++) { + var value = gltfValues_1[_d]; + _loop_2(value); + } + } + var variables = (_c = gltf.variables) !== null && _c !== void 0 ? _c : []; + // Parse variables + for (var i = 0; i < variables.length; i++) { + var variable = variables[i]; + var variableName = variable.id; + context._userVariables[variableName] = convertValueWithType(variable, gltf, "/extensions/KHR_interactivity/variables/".concat(i)); + } + return { + allBlocks: flowGraphJsonBlocks, + executionContexts: executionContexts, + }; +} + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/interactivityPathToObjectConverter.ts": +/*!******************************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/interactivityPathToObjectConverter.ts ***! + \******************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ InteractivityPathToObjectConverter: () => (/* binding */ InteractivityPathToObjectConverter) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var _gltfPathToObjectConverter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./gltfPathToObjectConverter */ "../../../dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts"); + + +/** + * Class to convert an interactivity pointer path to a smart object + */ +var InteractivityPathToObjectConverter = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__extends)(InteractivityPathToObjectConverter, _super); + function InteractivityPathToObjectConverter(gltf) { + return _super.call(this, gltf, gltfTree) || this; + } + return InteractivityPathToObjectConverter; +}(_gltfPathToObjectConverter__WEBPACK_IMPORTED_MODULE_0__.GLTFPathToObjectConverter)); + +var nodesTree = { + __array__: { + __target__: true, + translation: { + type: "Vector3", + get: function (node) { + var babylonObject = node._babylonTransformNode; + return babylonObject.position; + }, + set: function (value, node) { + var babylonObject = node._babylonTransformNode; + babylonObject.position = value; + }, + getObject: function (node) { + return node._babylonTransformNode; + }, + }, + }, +}; +var gltfTree = { + nodes: nodesTree, +}; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/interactivityUtils.ts": +/*!**************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/interactivityUtils.ts ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ gltfToFlowGraphTypeMap: () => (/* binding */ gltfToFlowGraphTypeMap), +/* harmony export */ gltfTypeToBabylonType: () => (/* binding */ gltfTypeToBabylonType) +/* harmony export */ }); +/* harmony import */ var babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__); +/* eslint-disable @typescript-eslint/naming-convention */ + + + + + + + + + + + + + + +var gltfToFlowGraphTypeMap = { + "lifecycle/onStart": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSceneReadyEventBlock.ClassName, + "lifecycle/onTick": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSceneTickEventBlock.ClassName, + log: babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphConsoleLogBlock.ClassName, + "flow/delay": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphTimerBlock.ClassName, + "customEvent/send": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSendCustomEventBlock.ClassName, + "customEvent/receive": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphReceiveCustomEventBlock.ClassName, + "flow/sequence": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSequenceBlock.ClassName, + "world/get": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphGetPropertyBlock.ClassName, + "world/set": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSetPropertyBlock.ClassName, + "flow/doN": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphDoNBlock.ClassName, + "variable/get": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphGetVariableBlock.ClassName, + "variable/set": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSetVariableBlock.ClassName, + "flow/whileLoop": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphWhileLoopBlock.ClassName, + "math/random": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphRandomBlock.ClassName, + "math/e": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphEBlock.ClassName, + "math/pi": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphPiBlock.ClassName, + "math/inf": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphInfBlock.ClassName, + "math/nan": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphNaNBlock.ClassName, + "math/abs": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAbsBlock.ClassName, + "math/sign": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSignBlock.ClassName, + "math/trunc": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphTruncBlock.ClassName, + "math/floor": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphFloorBlock.ClassName, + "math/ceil": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCeilBlock.ClassName, + "math/fract": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphFractBlock.ClassName, + "math/neg": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphNegBlock.ClassName, + "math/add": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAddBlock.ClassName, + "math/sub": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSubtractBlock.ClassName, + "math/mul": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphMultiplyBlock.ClassName, + "math/div": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphDivideBlock.ClassName, + "math/rem": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphRemainderBlock.ClassName, + "math/min": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphMinBlock.ClassName, + "math/max": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphMaxBlock.ClassName, + "math/clamp": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphClampBlock.ClassName, + "math/saturate": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSaturateBlock.ClassName, + "math/mix": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphInterpolateBlock.ClassName, + "math/eq": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphEqBlock.ClassName, + "math/lt": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphLessThanBlock.ClassName, + "math/le": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphLessThanOrEqualBlock.ClassName, + "math/gt": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphGreaterThanBlock.ClassName, + "math/ge": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphGreaterThanOrEqualBlock.ClassName, + "math/isnan": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphIsNanBlock.ClassName, + "math/isinf": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphIsInfBlock.ClassName, + "math/rad": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphDegToRadBlock.ClassName, + "math/deg": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphRadToDegBlock.ClassName, + "math/sin": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSinBlock.ClassName, + "math/cos": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCosBlock.ClassName, + "math/tan": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphTanBlock.ClassName, + "math/asin": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAsinBlock.ClassName, + "math/acos": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAcosBlock.ClassName, + "math/atan": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAtanBlock.ClassName, + "math/atan2": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAtan2Block.ClassName, + "math/sinh": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSinhBlock.ClassName, + "math/cosh": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCoshBlock.ClassName, + "math/tanh": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphTanhBlock.ClassName, + "math/asinh": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAsinhBlock.ClassName, + "math/acosh": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAcoshBlock.ClassName, + "math/atanh": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphAtanhBlock.ClassName, + "math/exp": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphExpBlock.ClassName, + "math/log": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphLogBlock.ClassName, + "math/log2": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphLog2Block.ClassName, + "math/log10": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphLog10Block.ClassName, + "math/sqrt": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphSqrtBlock.ClassName, + "math/cbrt": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCubeRootBlock.ClassName, + "math/pow": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphPowBlock.ClassName, + "math/length": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphLengthBlock.ClassName, + "math/normalize": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphNormalizeBlock.ClassName, + "math/dot": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphDotBlock.ClassName, + "math/cross": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCrossBlock.ClassName, + "math/rotate2d": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphRotate2DBlock.ClassName, + "math/rotate3d": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphRotate3DBlock.ClassName, + "math/transpose": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphTransposeBlock.ClassName, + "math/determinant": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphDeterminantBlock.ClassName, + "math/inverse": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphInvertMatrixBlock.ClassName, + "math/matmul": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphMatMulBlock.ClassName, + "math/not": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphBitwiseNotBlock.ClassName, + "math/and": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphBitwiseAndBlock.ClassName, + "math/or": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphBitwiseOrBlock.ClassName, + "math/xor": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphBitwiseXorBlock.ClassName, + "math/asr": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphBitwiseRightShiftBlock.ClassName, + "math/lsl": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphBitwiseLeftShiftBlock.ClassName, + "math/clz": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCountLeadingZerosBlock.ClassName, + "math/ctz": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCountTrailingZerosBlock.ClassName, + "math/popcnt": babylonjs_FlowGraph_Blocks_Event_flowGraphSceneReadyEventBlock__WEBPACK_IMPORTED_MODULE_0__.FlowGraphCountOneBitsBlock.ClassName, +}; +var gltfTypeToBabylonType = { + float2: "Vector2", + float3: "Vector3", + float4: "Vector4", + float4x4: "Matrix", + int: "FlowGraphInteger", +}; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts": +/*!*******************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoader.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ArrayItem: () => (/* binding */ ArrayItem), +/* harmony export */ GLTFLoader: () => (/* binding */ GLTFLoader) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Culling/boundingInfo */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFFileLoader */ "../../../dev/loaders/src/glTF/glTFFileLoader.ts"); +/* harmony import */ var _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderAnimation */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts"); + + + + + + + + + + + + + + + + + + + + + + + + + +// https://stackoverflow.com/a/48218209 +function mergeDeep() { + var objects = []; + for (var _i = 0; _i < arguments.length; _i++) { + objects[_i] = arguments[_i]; + } + var isObject = function (obj) { return obj && typeof obj === "object"; }; + return objects.reduce(function (prev, obj) { + Object.keys(obj).forEach(function (key) { + var pVal = prev[key]; + var oVal = obj[key]; + if (Array.isArray(pVal) && Array.isArray(oVal)) { + prev[key] = pVal.concat.apply(pVal, oVal); + } + else if (isObject(pVal) && isObject(oVal)) { + prev[key] = mergeDeep(pVal, oVal); + } + else { + prev[key] = oVal; + } + }); + return prev; + }, {}); +} +/** + * Helper class for working with arrays when loading the glTF asset + */ +var ArrayItem = /** @class */ (function () { + function ArrayItem() { + } + /** + * Gets an item from the given array. + * @param context The context when loading the asset + * @param array The array to get the item from + * @param index The index to the array + * @returns The array item + */ + ArrayItem.Get = function (context, array, index) { + if (!array || index == undefined || !array[index]) { + throw new Error("".concat(context, ": Failed to find index (").concat(index, ")")); + } + return array[index]; + }; + /** + * Gets an item from the given array or returns null if not available. + * @param array The array to get the item from + * @param index The index to the array + * @returns The array item or null + */ + ArrayItem.TryGet = function (array, index) { + if (!array || index == undefined || !array[index]) { + return null; + } + return array[index]; + }; + /** + * Assign an `index` field to each item of the given array. + * @param array The array of items + */ + ArrayItem.Assign = function (array) { + if (array) { + for (var index = 0; index < array.length; index++) { + array[index].index = index; + } + } + }; + return ArrayItem; +}()); + +/** + * The glTF 2.0 loader + */ +var GLTFLoader = /** @class */ (function () { + /** + * @internal + */ + function GLTFLoader(parent) { + /** @internal */ + this._completePromises = new Array(); + /** @internal */ + this._assetContainer = null; + /** Storage */ + this._babylonLights = []; + /** @internal */ + this._disableInstancedMesh = 0; + /** @internal */ + this._allMaterialsDirtyRequired = false; + this._extensions = new Array(); + this._disposed = false; + this._rootUrl = null; + this._fileName = null; + this._uniqueRootUrl = null; + this._bin = null; + this._rootBabylonMesh = null; + this._defaultBabylonMaterialData = {}; + this._postSceneLoadActions = new Array(); + this._parent = parent; + } + /** + * Registers a loader extension. + * @param name The name of the loader extension. + * @param factory The factory function that creates the loader extension. + */ + GLTFLoader.RegisterExtension = function (name, factory) { + if (GLTFLoader.UnregisterExtension(name)) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Extension with the name '".concat(name, "' already exists")); + } + GLTFLoader._RegisteredExtensions[name] = { + factory: factory, + }; + }; + /** + * Unregisters a loader extension. + * @param name The name of the loader extension. + * @returns A boolean indicating whether the extension has been unregistered + */ + GLTFLoader.UnregisterExtension = function (name) { + if (!GLTFLoader._RegisteredExtensions[name]) { + return false; + } + delete GLTFLoader._RegisteredExtensions[name]; + return true; + }; + Object.defineProperty(GLTFLoader.prototype, "gltf", { + /** + * The object that represents the glTF JSON. + */ + get: function () { + if (!this._gltf) { + throw new Error("glTF JSON is not available"); + } + return this._gltf; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "bin", { + /** + * The BIN chunk of a binary glTF. + */ + get: function () { + return this._bin; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "parent", { + /** + * The parent file loader. + */ + get: function () { + return this._parent; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "babylonScene", { + /** + * The Babylon scene when loading the asset. + */ + get: function () { + if (!this._babylonScene) { + throw new Error("Scene is not available"); + } + return this._babylonScene; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "rootBabylonMesh", { + /** + * The root Babylon node when loading the asset. + */ + get: function () { + return this._rootBabylonMesh; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "rootUrl", { + /** + * The root url when loading the asset. + */ + get: function () { + return this._rootUrl; + }, + enumerable: false, + configurable: true + }); + /** @internal */ + GLTFLoader.prototype.dispose = function () { + if (this._disposed) { + return; + } + this._disposed = true; + this._completePromises.length = 0; + this._extensions.forEach(function (extension) { return extension.dispose && extension.dispose(); }); + this._extensions.length = 0; + this._gltf = null; // TODO + this._bin = null; + this._babylonScene = null; // TODO + this._rootBabylonMesh = null; + this._defaultBabylonMaterialData = {}; + this._postSceneLoadActions.length = 0; + this._parent.dispose(); + }; + /** + * @internal + */ + GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, container, data, rootUrl, onProgress, fileName) { + var _this = this; + if (fileName === void 0) { fileName = ""; } + return Promise.resolve().then(function () { + _this._babylonScene = scene; + _this._assetContainer = container; + _this._loadData(data); + var nodes = null; + if (meshesNames) { + var nodeMap_1 = {}; + if (_this._gltf.nodes) { + for (var _i = 0, _a = _this._gltf.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.name) { + nodeMap_1[node.name] = node.index; + } + } + } + var names = meshesNames instanceof Array ? meshesNames : [meshesNames]; + nodes = names.map(function (name) { + var node = nodeMap_1[name]; + if (node === undefined) { + throw new Error("Failed to find node '".concat(name, "'")); + } + return node; + }); + } + return _this._loadAsync(rootUrl, fileName, nodes, function () { + return { + meshes: _this._getMeshes(), + particleSystems: [], + skeletons: _this._getSkeletons(), + animationGroups: _this._getAnimationGroups(), + lights: _this._babylonLights, + transformNodes: _this._getTransformNodes(), + geometries: _this._getGeometries(), + spriteManagers: [], + }; + }); + }); + }; + /** + * @internal + */ + GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) { + var _this = this; + if (fileName === void 0) { fileName = ""; } + return Promise.resolve().then(function () { + _this._babylonScene = scene; + _this._loadData(data); + return _this._loadAsync(rootUrl, fileName, null, function () { return undefined; }); + }); + }; + GLTFLoader.prototype._loadAsync = function (rootUrl, fileName, nodes, resultFunc) { + var _this = this; + return Promise.resolve() + .then(function () { + _this._rootUrl = rootUrl; + _this._uniqueRootUrl = !rootUrl.startsWith("file:") && fileName ? rootUrl : "".concat(rootUrl).concat(Date.now(), "/"); + _this._fileName = fileName; + _this._allMaterialsDirtyRequired = false; + _this._loadExtensions(); + _this._checkExtensions(); + var loadingToReadyCounterName = "".concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING], " => ").concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.READY]); + var loadingToCompleteCounterName = "".concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING], " => ").concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.COMPLETE]); + _this._parent._startPerformanceCounter(loadingToReadyCounterName); + _this._parent._startPerformanceCounter(loadingToCompleteCounterName); + _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING); + _this._extensionsOnLoading(); + var promises = new Array(); + // Block the marking of materials dirty until the scene is loaded. + var oldBlockMaterialDirtyMechanism = _this._babylonScene.blockMaterialDirtyMechanism; + _this._babylonScene.blockMaterialDirtyMechanism = true; + if (!_this.parent.loadOnlyMaterials) { + if (nodes) { + promises.push(_this.loadSceneAsync("/nodes", { nodes: nodes, index: -1 })); + } + else if (_this._gltf.scene != undefined || (_this._gltf.scenes && _this._gltf.scenes[0])) { + var scene = ArrayItem.Get("/scene", _this._gltf.scenes, _this._gltf.scene || 0); + promises.push(_this.loadSceneAsync("/scenes/".concat(scene.index), scene)); + } + } + if (!_this.parent.skipMaterials && _this.parent.loadAllMaterials && _this._gltf.materials) { + for (var m = 0; m < _this._gltf.materials.length; ++m) { + var material = _this._gltf.materials[m]; + var context_1 = "/materials/" + m; + var babylonDrawMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode; + promises.push(_this._loadMaterialAsync(context_1, material, null, babylonDrawMode, function () { })); + } + } + // Restore the blocking of material dirty. + if (_this._allMaterialsDirtyRequired) { + // This can happen if we add a light for instance as it will impact the whole scene. + // This automatically resets everything if needed. + _this._babylonScene.blockMaterialDirtyMechanism = oldBlockMaterialDirtyMechanism; + } + else { + // By default a newly created material is dirty so there is no need to flag the full scene as dirty. + // For perf reasons, we then bypass blockMaterialDirtyMechanism as this would "dirty" the entire scene. + _this._babylonScene._forceBlockMaterialDirtyMechanism(oldBlockMaterialDirtyMechanism); + } + if (_this._parent.compileMaterials) { + promises.push(_this._compileMaterialsAsync()); + } + if (_this._parent.compileShadowGenerators) { + promises.push(_this._compileShadowGeneratorsAsync()); + } + var resultPromise = Promise.all(promises).then(function () { + if (_this._rootBabylonMesh && _this._rootBabylonMesh !== _this._parent.customRootNode) { + _this._rootBabylonMesh.setEnabled(true); + } + _this._extensionsOnReady(); + _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.READY); + _this._startAnimations(); + return resultFunc(); + }); + return resultPromise.then(function (result) { + _this._parent._endPerformanceCounter(loadingToReadyCounterName); + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Tools.SetImmediate(function () { + if (!_this._disposed) { + Promise.all(_this._completePromises).then(function () { + _this._parent._endPerformanceCounter(loadingToCompleteCounterName); + _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.COMPLETE); + _this._parent.onCompleteObservable.notifyObservers(undefined); + _this._parent.onCompleteObservable.clear(); + _this.dispose(); + }, function (error) { + _this._parent.onErrorObservable.notifyObservers(error); + _this._parent.onErrorObservable.clear(); + _this.dispose(); + }); + } + }); + return result; + }); + }) + .catch(function (error) { + if (!_this._disposed) { + _this._parent.onErrorObservable.notifyObservers(error); + _this._parent.onErrorObservable.clear(); + _this.dispose(); + } + throw error; + }); + }; + GLTFLoader.prototype._loadData = function (data) { + this._gltf = data.json; + this._setupData(); + if (data.bin) { + var buffers = this._gltf.buffers; + if (buffers && buffers[0] && !buffers[0].uri) { + var binaryBuffer = buffers[0]; + if (binaryBuffer.byteLength < data.bin.byteLength - 3 || binaryBuffer.byteLength > data.bin.byteLength) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Binary buffer length (".concat(binaryBuffer.byteLength, ") from JSON does not match chunk length (").concat(data.bin.byteLength, ")")); + } + this._bin = data.bin; + } + else { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Unexpected BIN chunk"); + } + } + }; + GLTFLoader.prototype._setupData = function () { + ArrayItem.Assign(this._gltf.accessors); + ArrayItem.Assign(this._gltf.animations); + ArrayItem.Assign(this._gltf.buffers); + ArrayItem.Assign(this._gltf.bufferViews); + ArrayItem.Assign(this._gltf.cameras); + ArrayItem.Assign(this._gltf.images); + ArrayItem.Assign(this._gltf.materials); + ArrayItem.Assign(this._gltf.meshes); + ArrayItem.Assign(this._gltf.nodes); + ArrayItem.Assign(this._gltf.samplers); + ArrayItem.Assign(this._gltf.scenes); + ArrayItem.Assign(this._gltf.skins); + ArrayItem.Assign(this._gltf.textures); + if (this._gltf.nodes) { + var nodeParents = {}; + for (var _i = 0, _a = this._gltf.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.children) { + for (var _b = 0, _c = node.children; _b < _c.length; _b++) { + var index = _c[_b]; + nodeParents[index] = node.index; + } + } + } + var rootNode = this._createRootNode(); + for (var _d = 0, _e = this._gltf.nodes; _d < _e.length; _d++) { + var node = _e[_d]; + var parentIndex = nodeParents[node.index]; + node.parent = parentIndex === undefined ? rootNode : this._gltf.nodes[parentIndex]; + } + } + }; + GLTFLoader.prototype._loadExtensions = function () { + for (var name_1 in GLTFLoader._RegisteredExtensions) { + var extension = GLTFLoader._RegisteredExtensions[name_1].factory(this); + if (extension.name !== name_1) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(extension.name, " !== ").concat(name_1)); + } + this._extensions.push(extension); + this._parent.onExtensionLoadedObservable.notifyObservers(extension); + } + this._extensions.sort(function (a, b) { return (a.order || Number.MAX_VALUE) - (b.order || Number.MAX_VALUE); }); + this._parent.onExtensionLoadedObservable.clear(); + }; + GLTFLoader.prototype._checkExtensions = function () { + if (this._gltf.extensionsRequired) { + var _loop_1 = function (name_2) { + var available = this_1._extensions.some(function (extension) { return extension.name === name_2 && extension.enabled; }); + if (!available) { + throw new Error("Required extension ".concat(name_2, " is not available")); + } + }; + var this_1 = this; + for (var _i = 0, _a = this._gltf.extensionsRequired; _i < _a.length; _i++) { + var name_2 = _a[_i]; + _loop_1(name_2); + } + } + }; + GLTFLoader.prototype._createRootNode = function () { + if (this._parent.customRootNode !== undefined) { + this._rootBabylonMesh = this._parent.customRootNode; + return { + // eslint-disable-next-line @typescript-eslint/naming-convention + _babylonTransformNode: this._rootBabylonMesh === null ? undefined : this._rootBabylonMesh, + index: -1, + }; + } + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var rootMesh = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Mesh("__root__", this._babylonScene); + this._rootBabylonMesh = rootMesh; + this._rootBabylonMesh._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + this._rootBabylonMesh.setEnabled(false); + var rootNode = { + // eslint-disable-next-line @typescript-eslint/naming-convention + _babylonTransformNode: this._rootBabylonMesh, + index: -1, + }; + switch (this._parent.coordinateSystemMode) { + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderCoordinateSystemMode.AUTO: { + if (!this._babylonScene.useRightHandedSystem) { + rootNode.rotation = [0, 1, 0, 0]; + rootNode.scale = [1, 1, -1]; + GLTFLoader._LoadTransform(rootNode, this._rootBabylonMesh); + } + break; + } + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED: { + this._babylonScene.useRightHandedSystem = true; + break; + } + default: { + throw new Error("Invalid coordinate system mode (".concat(this._parent.coordinateSystemMode, ")")); + } + } + this._parent.onMeshLoadedObservable.notifyObservers(rootMesh); + return rootNode; + }; + /** + * Loads a glTF scene. + * @param context The context when loading the asset + * @param scene The glTF scene property + * @returns A promise that resolves when the load is complete + */ + GLTFLoader.prototype.loadSceneAsync = function (context, scene) { + var _this = this; + var extensionPromise = this._extensionsLoadSceneAsync(context, scene); + if (extensionPromise) { + return extensionPromise; + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(scene.name || "")); + if (scene.nodes) { + for (var _i = 0, _a = scene.nodes; _i < _a.length; _i++) { + var index = _a[_i]; + var node = ArrayItem.Get("".concat(context, "/nodes/").concat(index), this._gltf.nodes, index); + promises.push(this.loadNodeAsync("/nodes/".concat(node.index), node, function (babylonMesh) { + babylonMesh.parent = _this._rootBabylonMesh; + })); + } + } + for (var _b = 0, _c = this._postSceneLoadActions; _b < _c.length; _b++) { + var action = _c[_b]; + action(); + } + promises.push(this._loadAnimationsAsync()); + this.logClose(); + return Promise.all(promises).then(function () { }); + }; + GLTFLoader.prototype._forEachPrimitive = function (node, callback) { + if (node._primitiveBabylonMeshes) { + for (var _i = 0, _a = node._primitiveBabylonMeshes; _i < _a.length; _i++) { + var babylonMesh = _a[_i]; + callback(babylonMesh); + } + } + }; + GLTFLoader.prototype._getGeometries = function () { + var geometries = []; + var nodes = this._gltf.nodes; + if (nodes) { + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; + this._forEachPrimitive(node, function (babylonMesh) { + var geometry = babylonMesh.geometry; + if (geometry && geometries.indexOf(geometry) === -1) { + geometries.push(geometry); + } + }); + } + } + return geometries; + }; + GLTFLoader.prototype._getMeshes = function () { + var meshes = []; + // Root mesh is always first, if available. + if (this._rootBabylonMesh instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.AbstractMesh) { + meshes.push(this._rootBabylonMesh); + } + var nodes = this._gltf.nodes; + if (nodes) { + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; + this._forEachPrimitive(node, function (babylonMesh) { + meshes.push(babylonMesh); + }); + } + } + return meshes; + }; + GLTFLoader.prototype._getTransformNodes = function () { + var transformNodes = []; + var nodes = this._gltf.nodes; + if (nodes) { + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var node = nodes_3[_i]; + if (node._babylonTransformNode && node._babylonTransformNode.getClassName() === "TransformNode") { + transformNodes.push(node._babylonTransformNode); + } + if (node._babylonTransformNodeForSkin) { + transformNodes.push(node._babylonTransformNodeForSkin); + } + } + } + return transformNodes; + }; + GLTFLoader.prototype._getSkeletons = function () { + var skeletons = []; + var skins = this._gltf.skins; + if (skins) { + for (var _i = 0, skins_1 = skins; _i < skins_1.length; _i++) { + var skin = skins_1[_i]; + if (skin._data) { + skeletons.push(skin._data.babylonSkeleton); + } + } + } + return skeletons; + }; + GLTFLoader.prototype._getAnimationGroups = function () { + var animationGroups = []; + var animations = this._gltf.animations; + if (animations) { + for (var _i = 0, animations_1 = animations; _i < animations_1.length; _i++) { + var animation = animations_1[_i]; + if (animation._babylonAnimationGroup) { + animationGroups.push(animation._babylonAnimationGroup); + } + } + } + return animationGroups; + }; + GLTFLoader.prototype._startAnimations = function () { + switch (this._parent.animationStartMode) { + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.NONE: { + // do nothing + break; + } + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.FIRST: { + var babylonAnimationGroups = this._getAnimationGroups(); + if (babylonAnimationGroups.length !== 0) { + babylonAnimationGroups[0].start(true); + } + break; + } + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.ALL: { + var babylonAnimationGroups = this._getAnimationGroups(); + for (var _i = 0, babylonAnimationGroups_1 = babylonAnimationGroups; _i < babylonAnimationGroups_1.length; _i++) { + var babylonAnimationGroup = babylonAnimationGroups_1[_i]; + babylonAnimationGroup.start(true); + } + break; + } + default: { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode, ")")); + return; + } + } + }; + /** + * Loads a glTF node. + * @param context The context when loading the asset + * @param node The glTF node property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded Babylon mesh when the load is complete + */ + GLTFLoader.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadNodeAsync(context, node, assign); + if (extensionPromise) { + return extensionPromise; + } + if (node._babylonTransformNode) { + throw new Error("".concat(context, ": Invalid recursive node hierarchy")); + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(node.name || "")); + var loadNode = function (babylonTransformNode) { + GLTFLoader.AddPointerMetadata(babylonTransformNode, context); + GLTFLoader._LoadTransform(node, babylonTransformNode); + if (node.camera != undefined) { + var camera = ArrayItem.Get("".concat(context, "/camera"), _this._gltf.cameras, node.camera); + promises.push(_this.loadCameraAsync("/cameras/".concat(camera.index), camera, function (babylonCamera) { + babylonCamera.parent = babylonTransformNode; + })); + } + if (node.children) { + for (var _i = 0, _a = node.children; _i < _a.length; _i++) { + var index = _a[_i]; + var childNode = ArrayItem.Get("".concat(context, "/children/").concat(index), _this._gltf.nodes, index); + promises.push(_this.loadNodeAsync("/nodes/".concat(childNode.index), childNode, function (childBabylonMesh) { + childBabylonMesh.parent = babylonTransformNode; + })); + } + } + assign(babylonTransformNode); + }; + if (node.mesh == undefined || node.skin != undefined) { + var nodeName = node.name || "node".concat(node.index); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var transformNode = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TransformNode(nodeName, this._babylonScene); + transformNode._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + if (node.mesh == undefined) { + node._babylonTransformNode = transformNode; + } + else { + node._babylonTransformNodeForSkin = transformNode; + } + loadNode(transformNode); + } + if (node.mesh != undefined) { + if (node.skin == undefined) { + var mesh = ArrayItem.Get("".concat(context, "/mesh"), this._gltf.meshes, node.mesh); + promises.push(this._loadMeshAsync("/meshes/".concat(mesh.index), node, mesh, loadNode)); + } + else { + // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note) + // This code path will place the skinned mesh as a sibling of the skeleton root node without loading the + // transform, which effectively ignores the transform of the skinned mesh, as per spec. + var mesh = ArrayItem.Get("".concat(context, "/mesh"), this._gltf.meshes, node.mesh); + promises.push(this._loadMeshAsync("/meshes/".concat(mesh.index), node, mesh, function (babylonTransformNode) { + var babylonTransformNodeForSkin = node._babylonTransformNodeForSkin; + // Merge the metadata from the skin node to the skinned mesh in case a loader extension added metadata. + babylonTransformNode.metadata = mergeDeep(babylonTransformNodeForSkin.metadata, babylonTransformNode.metadata || {}); + var skin = ArrayItem.Get("".concat(context, "/skin"), _this._gltf.skins, node.skin); + promises.push(_this._loadSkinAsync("/skins/".concat(skin.index), node, skin, function (babylonSkeleton) { + _this._forEachPrimitive(node, function (babylonMesh) { + babylonMesh.skeleton = babylonSkeleton; + }); + // Wait until all the nodes are parented before parenting the skinned mesh. + _this._postSceneLoadActions.push(function () { + if (skin.skeleton != undefined) { + // Place the skinned mesh node as a sibling of the skeleton root node. + // Handle special case when the parent of the skeleton root is the skinned mesh. + var parentNode = ArrayItem.Get("/skins/".concat(skin.index, "/skeleton"), _this._gltf.nodes, skin.skeleton).parent; + if (node.index === parentNode.index) { + babylonTransformNode.parent = babylonTransformNodeForSkin.parent; + } + else { + babylonTransformNode.parent = parentNode._babylonTransformNode; + } + } + else { + babylonTransformNode.parent = _this._rootBabylonMesh; + } + _this._parent.onSkinLoadedObservable.notifyObservers({ node: babylonTransformNodeForSkin, skinnedNode: babylonTransformNode }); + }); + })); + })); + } + } + this.logClose(); + return Promise.all(promises).then(function () { + _this._forEachPrimitive(node, function (babylonMesh) { + if (babylonMesh.geometry && babylonMesh.geometry.useBoundingInfoFromGeometry) { + // simply apply the world matrices to the bounding info - the extends are already ok + babylonMesh._updateBoundingInfo(); + } + else { + babylonMesh.refreshBoundingInfo(true); + } + }); + return node._babylonTransformNode; + }); + }; + GLTFLoader.prototype._loadMeshAsync = function (context, node, mesh, assign) { + var primitives = mesh.primitives; + if (!primitives || !primitives.length) { + throw new Error("".concat(context, ": Primitives are missing")); + } + if (primitives[0].index == undefined) { + ArrayItem.Assign(primitives); + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(mesh.name || "")); + var name = node.name || "node".concat(node.index); + if (primitives.length === 1) { + var primitive = mesh.primitives[0]; + promises.push(this._loadMeshPrimitiveAsync("".concat(context, "/primitives/").concat(primitive.index), name, node, mesh, primitive, function (babylonMesh) { + node._babylonTransformNode = babylonMesh; + node._primitiveBabylonMeshes = [babylonMesh]; + })); + } + else { + this._babylonScene._blockEntityCollection = !!this._assetContainer; + node._babylonTransformNode = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TransformNode(name, this._babylonScene); + node._babylonTransformNode._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + node._primitiveBabylonMeshes = []; + for (var _i = 0, primitives_1 = primitives; _i < primitives_1.length; _i++) { + var primitive = primitives_1[_i]; + promises.push(this._loadMeshPrimitiveAsync("".concat(context, "/primitives/").concat(primitive.index), "".concat(name, "_primitive").concat(primitive.index), node, mesh, primitive, function (babylonMesh) { + babylonMesh.parent = node._babylonTransformNode; + node._primitiveBabylonMeshes.push(babylonMesh); + })); + } + } + assign(node._babylonTransformNode); + this.logClose(); + return Promise.all(promises).then(function () { + return node._babylonTransformNode; + }); + }; + /** + * @internal Define this method to modify the default behavior when loading data for mesh primitives. + * @param context The context when loading the asset + * @param name The mesh name when loading the asset + * @param node The glTF node when loading the asset + * @param mesh The glTF mesh when loading the asset + * @param primitive The glTF mesh primitive property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled + */ + GLTFLoader.prototype._loadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) { + var _this = this; + var extensionPromise = this._extensionsLoadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign); + if (extensionPromise) { + return extensionPromise; + } + this.logOpen("".concat(context)); + var shouldInstance = this._disableInstancedMesh === 0 && this._parent.createInstances && node.skin == undefined && !mesh.primitives[0].targets; + var babylonAbstractMesh; + var promise; + if (shouldInstance && primitive._instanceData) { + this._babylonScene._blockEntityCollection = !!this._assetContainer; + babylonAbstractMesh = primitive._instanceData.babylonSourceMesh.createInstance(name); + babylonAbstractMesh._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + promise = primitive._instanceData.promise; + } + else { + var promises = new Array(); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonMesh_1 = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Mesh(name, this._babylonScene); + babylonMesh_1._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + babylonMesh_1.overrideMaterialSideOrientation = this._babylonScene.useRightHandedSystem ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.CounterClockWiseSideOrientation : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.ClockWiseSideOrientation; + this._createMorphTargets(context, node, mesh, primitive, babylonMesh_1); + promises.push(this._loadVertexDataAsync(context, primitive, babylonMesh_1).then(function (babylonGeometry) { + return _this._loadMorphTargetsAsync(context, primitive, babylonMesh_1, babylonGeometry).then(function () { + if (_this._disposed) { + return; + } + _this._babylonScene._blockEntityCollection = !!_this._assetContainer; + babylonGeometry.applyToMesh(babylonMesh_1); + babylonGeometry._parentContainer = _this._assetContainer; + _this._babylonScene._blockEntityCollection = false; + }); + })); + var babylonDrawMode = GLTFLoader._GetDrawMode(context, primitive.mode); + if (primitive.material == undefined) { + var babylonMaterial = this._defaultBabylonMaterialData[babylonDrawMode]; + if (!babylonMaterial) { + babylonMaterial = this._createDefaultMaterial("__GLTFLoader._default", babylonDrawMode); + this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial); + this._defaultBabylonMaterialData[babylonDrawMode] = babylonMaterial; + } + babylonMesh_1.material = babylonMaterial; + } + else if (!this.parent.skipMaterials) { + var material = ArrayItem.Get("".concat(context, "/material"), this._gltf.materials, primitive.material); + promises.push(this._loadMaterialAsync("/materials/".concat(material.index), material, babylonMesh_1, babylonDrawMode, function (babylonMaterial) { + babylonMesh_1.material = babylonMaterial; + })); + } + promise = Promise.all(promises); + if (shouldInstance) { + primitive._instanceData = { + babylonSourceMesh: babylonMesh_1, + promise: promise, + }; + } + babylonAbstractMesh = babylonMesh_1; + } + GLTFLoader.AddPointerMetadata(babylonAbstractMesh, context); + this._parent.onMeshLoadedObservable.notifyObservers(babylonAbstractMesh); + assign(babylonAbstractMesh); + this.logClose(); + return promise.then(function () { + return babylonAbstractMesh; + }); + }; + GLTFLoader.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) { + var _this = this; + var extensionPromise = this._extensionsLoadVertexDataAsync(context, primitive, babylonMesh); + if (extensionPromise) { + return extensionPromise; + } + var attributes = primitive.attributes; + if (!attributes) { + throw new Error("".concat(context, ": Attributes are missing")); + } + var promises = new Array(); + var babylonGeometry = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Geometry(babylonMesh.name, this._babylonScene); + if (primitive.indices == undefined) { + babylonMesh.isUnIndexed = true; + } + else { + var accessor = ArrayItem.Get("".concat(context, "/indices"), this._gltf.accessors, primitive.indices); + promises.push(this._loadIndicesAccessorAsync("/accessors/".concat(accessor.index), accessor).then(function (data) { + babylonGeometry.setIndices(data); + })); + } + var loadAttribute = function (name, kind, callback) { + if (attributes[name] == undefined) { + return; + } + babylonMesh._delayInfo = babylonMesh._delayInfo || []; + if (babylonMesh._delayInfo.indexOf(kind) === -1) { + babylonMesh._delayInfo.push(kind); + } + var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(name), _this._gltf.accessors, attributes[name]); + promises.push(_this._loadVertexAccessorAsync("/accessors/".concat(accessor.index), accessor, kind).then(function (babylonVertexBuffer) { + var _a, _b; + if (babylonVertexBuffer.getKind() === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind && !_this.parent.alwaysComputeBoundingBox && !babylonMesh.skeleton) { + if (accessor.min && accessor.max) { + var min = (_a = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0]).copyFromFloats.apply(_a, accessor.min); + var max = (_b = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1]).copyFromFloats.apply(_b, accessor.max); + if (accessor.normalized && accessor.componentType !== 5126 /* AccessorComponentType.FLOAT */) { + var divider = 1; + switch (accessor.componentType) { + case 5120 /* AccessorComponentType.BYTE */: + divider = 127.0; + break; + case 5121 /* AccessorComponentType.UNSIGNED_BYTE */: + divider = 255.0; + break; + case 5122 /* AccessorComponentType.SHORT */: + divider = 32767.0; + break; + case 5123 /* AccessorComponentType.UNSIGNED_SHORT */: + divider = 65535.0; + break; + } + var oneOverDivider = 1 / divider; + min.scaleInPlace(oneOverDivider); + max.scaleInPlace(oneOverDivider); + } + babylonGeometry._boundingInfo = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.BoundingInfo(min, max); + babylonGeometry.useBoundingInfoFromGeometry = true; + } + } + babylonGeometry.setVerticesBuffer(babylonVertexBuffer, accessor.count); + })); + if (kind == babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind) { + babylonMesh.numBoneInfluencers = 8; + } + if (callback) { + callback(accessor); + } + }; + loadAttribute("POSITION", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind); + loadAttribute("NORMAL", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind); + loadAttribute("TANGENT", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind); + loadAttribute("TEXCOORD_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind); + loadAttribute("TEXCOORD_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind); + loadAttribute("TEXCOORD_2", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV3Kind); + loadAttribute("TEXCOORD_3", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV4Kind); + loadAttribute("TEXCOORD_4", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV5Kind); + loadAttribute("TEXCOORD_5", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV6Kind); + loadAttribute("JOINTS_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind); + loadAttribute("WEIGHTS_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind); + loadAttribute("JOINTS_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind); + loadAttribute("WEIGHTS_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsExtraKind); + loadAttribute("COLOR_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind, function (accessor) { + if (accessor.type === "VEC4" /* AccessorType.VEC4 */) { + babylonMesh.hasVertexAlpha = true; + } + }); + return Promise.all(promises).then(function () { + return babylonGeometry; + }); + }; + GLTFLoader.prototype._createMorphTargets = function (context, node, mesh, primitive, babylonMesh) { + if (!primitive.targets) { + return; + } + if (node._numMorphTargets == undefined) { + node._numMorphTargets = primitive.targets.length; + } + else if (primitive.targets.length !== node._numMorphTargets) { + throw new Error("".concat(context, ": Primitives do not have the same number of targets")); + } + var targetNames = mesh.extras ? mesh.extras.targetNames : null; + this._babylonScene._blockEntityCollection = !!this._assetContainer; + babylonMesh.morphTargetManager = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.MorphTargetManager(this._babylonScene); + babylonMesh.morphTargetManager._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + babylonMesh.morphTargetManager.areUpdatesFrozen = true; + for (var index = 0; index < primitive.targets.length; index++) { + var weight = node.weights ? node.weights[index] : mesh.weights ? mesh.weights[index] : 0; + var name_3 = targetNames ? targetNames[index] : "morphTarget".concat(index); + babylonMesh.morphTargetManager.addTarget(new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.MorphTarget(name_3, weight, babylonMesh.getScene())); + // TODO: tell the target whether it has positions, normals, tangents + } + }; + GLTFLoader.prototype._loadMorphTargetsAsync = function (context, primitive, babylonMesh, babylonGeometry) { + if (!primitive.targets) { + return Promise.resolve(); + } + var promises = new Array(); + var morphTargetManager = babylonMesh.morphTargetManager; + for (var index = 0; index < morphTargetManager.numTargets; index++) { + var babylonMorphTarget = morphTargetManager.getTarget(index); + promises.push(this._loadMorphTargetVertexDataAsync("".concat(context, "/targets/").concat(index), babylonGeometry, primitive.targets[index], babylonMorphTarget)); + } + return Promise.all(promises).then(function () { + morphTargetManager.areUpdatesFrozen = false; + }); + }; + GLTFLoader.prototype._loadMorphTargetVertexDataAsync = function (context, babylonGeometry, attributes, babylonMorphTarget) { + var _this = this; + var promises = new Array(); + var loadAttribute = function (attribute, kind, setData) { + if (attributes[attribute] == undefined) { + return; + } + var babylonVertexBuffer = babylonGeometry.getVertexBuffer(kind); + if (!babylonVertexBuffer) { + return; + } + var accessor = ArrayItem.Get("".concat(context, "/").concat(attribute), _this._gltf.accessors, attributes[attribute]); + promises.push(_this._loadFloatAccessorAsync("/accessors/".concat(accessor.index), accessor).then(function (data) { + setData(babylonVertexBuffer, data); + })); + }; + loadAttribute("POSITION", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind, function (babylonVertexBuffer, data) { + var positions = new Float32Array(data.length); + babylonVertexBuffer.forEach(data.length, function (value, index) { + positions[index] = data[index] + value; + }); + babylonMorphTarget.setPositions(positions); + }); + loadAttribute("NORMAL", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind, function (babylonVertexBuffer, data) { + var normals = new Float32Array(data.length); + babylonVertexBuffer.forEach(normals.length, function (value, index) { + normals[index] = data[index] + value; + }); + babylonMorphTarget.setNormals(normals); + }); + loadAttribute("TANGENT", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind, function (babylonVertexBuffer, data) { + var tangents = new Float32Array((data.length / 3) * 4); + var dataIndex = 0; + babylonVertexBuffer.forEach((data.length / 3) * 4, function (value, index) { + // Tangent data for morph targets is stored as xyz delta. + // The vertexData.tangent is stored as xyzw. + // So we need to skip every fourth vertexData.tangent. + if ((index + 1) % 4 !== 0) { + tangents[dataIndex] = data[dataIndex] + value; + dataIndex++; + } + }); + babylonMorphTarget.setTangents(tangents); + }); + return Promise.all(promises).then(function () { }); + }; + GLTFLoader._LoadTransform = function (node, babylonNode) { + // Ignore the TRS of skinned nodes. + // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note) + if (node.skin != undefined) { + return; + } + var position = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(); + var rotation = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity(); + var scaling = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.One(); + if (node.matrix) { + var matrix = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArray(node.matrix); + matrix.decompose(scaling, rotation, position); + } + else { + if (node.translation) { + position = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.translation); + } + if (node.rotation) { + rotation = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(node.rotation); + } + if (node.scale) { + scaling = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.scale); + } + } + babylonNode.position = position; + babylonNode.rotationQuaternion = rotation; + babylonNode.scaling = scaling; + }; + GLTFLoader.prototype._loadSkinAsync = function (context, node, skin, assign) { + var _this = this; + var extensionPromise = this._extensionsLoadSkinAsync(context, node, skin); + if (extensionPromise) { + return extensionPromise; + } + if (skin._data) { + assign(skin._data.babylonSkeleton); + return skin._data.promise; + } + var skeletonId = "skeleton".concat(skin.index); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonSkeleton = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Skeleton(skin.name || skeletonId, skeletonId, this._babylonScene); + babylonSkeleton._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + this._loadBones(context, skin, babylonSkeleton); + var promise = this._loadSkinInverseBindMatricesDataAsync(context, skin).then(function (inverseBindMatricesData) { + _this._updateBoneMatrices(babylonSkeleton, inverseBindMatricesData); + }); + skin._data = { + babylonSkeleton: babylonSkeleton, + promise: promise, + }; + assign(babylonSkeleton); + return promise; + }; + GLTFLoader.prototype._loadBones = function (context, skin, babylonSkeleton) { + if (skin.skeleton == undefined || this._parent.alwaysComputeSkeletonRootNode) { + var rootNode = this._findSkeletonRootNode("".concat(context, "/joints"), skin.joints); + if (rootNode) { + if (skin.skeleton === undefined) { + skin.skeleton = rootNode.index; + } + else { + var isParent = function (a, b) { + for (; b.parent; b = b.parent) { + if (b.parent === a) { + return true; + } + } + return false; + }; + var skeletonNode = ArrayItem.Get("".concat(context, "/skeleton"), this._gltf.nodes, skin.skeleton); + if (skeletonNode !== rootNode && !isParent(skeletonNode, rootNode)) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root")); + skin.skeleton = rootNode.index; + } + } + } + else { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Failed to find common root")); + } + } + var babylonBones = {}; + for (var _i = 0, _a = skin.joints; _i < _a.length; _i++) { + var index = _a[_i]; + var node = ArrayItem.Get("".concat(context, "/joints/").concat(index), this._gltf.nodes, index); + this._loadBone(node, skin, babylonSkeleton, babylonBones); + } + }; + GLTFLoader.prototype._findSkeletonRootNode = function (context, joints) { + if (joints.length === 0) { + return null; + } + var paths = {}; + for (var _i = 0, joints_1 = joints; _i < joints_1.length; _i++) { + var index = joints_1[_i]; + var path = []; + var node = ArrayItem.Get("".concat(context, "/").concat(index), this._gltf.nodes, index); + while (node.index !== -1) { + path.unshift(node); + node = node.parent; + } + paths[index] = path; + } + var rootNode = null; + for (var i = 0;; ++i) { + var path = paths[joints[0]]; + if (i >= path.length) { + return rootNode; + } + var node = path[i]; + for (var j = 1; j < joints.length; ++j) { + path = paths[joints[j]]; + if (i >= path.length || node !== path[i]) { + return rootNode; + } + } + rootNode = node; + } + }; + GLTFLoader.prototype._loadBone = function (node, skin, babylonSkeleton, babylonBones) { + var babylonBone = babylonBones[node.index]; + if (babylonBone) { + return babylonBone; + } + var parentBabylonBone = null; + if (node.index !== skin.skeleton) { + if (node.parent && node.parent.index !== -1) { + parentBabylonBone = this._loadBone(node.parent, skin, babylonSkeleton, babylonBones); + } + else if (skin.skeleton !== undefined) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("/skins/".concat(skin.index, "/skeleton: Skeleton node is not a common root")); + } + } + var boneIndex = skin.joints.indexOf(node.index); + babylonBone = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Bone(node.name || "joint".concat(node.index), babylonSkeleton, parentBabylonBone, this._getNodeMatrix(node), null, null, boneIndex); + babylonBones[node.index] = babylonBone; + // Wait until the scene is loaded to ensure the transform nodes are loaded. + this._postSceneLoadActions.push(function () { + // Link the Babylon bone with the corresponding Babylon transform node. + // A glTF joint is a pointer to a glTF node in the glTF node hierarchy similar to Unity3D. + babylonBone.linkTransformNode(node._babylonTransformNode); + }); + return babylonBone; + }; + GLTFLoader.prototype._loadSkinInverseBindMatricesDataAsync = function (context, skin) { + if (skin.inverseBindMatrices == undefined) { + return Promise.resolve(null); + } + var accessor = ArrayItem.Get("".concat(context, "/inverseBindMatrices"), this._gltf.accessors, skin.inverseBindMatrices); + return this._loadFloatAccessorAsync("/accessors/".concat(accessor.index), accessor); + }; + GLTFLoader.prototype._updateBoneMatrices = function (babylonSkeleton, inverseBindMatricesData) { + for (var _i = 0, _a = babylonSkeleton.bones; _i < _a.length; _i++) { + var babylonBone = _a[_i]; + var baseMatrix = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.Identity(); + var boneIndex = babylonBone._index; + if (inverseBindMatricesData && boneIndex !== -1) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArrayToRef(inverseBindMatricesData, boneIndex * 16, baseMatrix); + baseMatrix.invertToRef(baseMatrix); + } + var babylonParentBone = babylonBone.getParent(); + if (babylonParentBone) { + baseMatrix.multiplyToRef(babylonParentBone.getAbsoluteInverseBindMatrix(), baseMatrix); + } + babylonBone.updateMatrix(baseMatrix, false, false); + babylonBone._updateAbsoluteBindMatrices(undefined, false); + } + }; + GLTFLoader.prototype._getNodeMatrix = function (node) { + return node.matrix + ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArray(node.matrix) + : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.Compose(node.scale ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.scale) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.One(), node.rotation ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(node.rotation) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity(), node.translation ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.translation) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero()); + }; + /** + * Loads a glTF camera. + * @param context The context when loading the asset + * @param camera The glTF camera property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded Babylon camera when the load is complete + */ + GLTFLoader.prototype.loadCameraAsync = function (context, camera, assign) { + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadCameraAsync(context, camera, assign); + if (extensionPromise) { + return extensionPromise; + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(camera.name || "")); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonCamera = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.FreeCamera(camera.name || "camera".concat(camera.index), babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), this._babylonScene, false); + babylonCamera._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + babylonCamera.ignoreParentScaling = true; + camera._babylonCamera = babylonCamera; + // Rotation by 180 as glTF has a different convention than Babylon. + babylonCamera.rotation.set(0, Math.PI, 0); + switch (camera.type) { + case "perspective" /* CameraType.PERSPECTIVE */: { + var perspective = camera.perspective; + if (!perspective) { + throw new Error("".concat(context, ": Camera perspective properties are missing")); + } + babylonCamera.fov = perspective.yfov; + babylonCamera.minZ = perspective.znear; + babylonCamera.maxZ = perspective.zfar || 0; + break; + } + case "orthographic" /* CameraType.ORTHOGRAPHIC */: { + if (!camera.orthographic) { + throw new Error("".concat(context, ": Camera orthographic properties are missing")); + } + babylonCamera.mode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Camera.ORTHOGRAPHIC_CAMERA; + babylonCamera.orthoLeft = -camera.orthographic.xmag; + babylonCamera.orthoRight = camera.orthographic.xmag; + babylonCamera.orthoBottom = -camera.orthographic.ymag; + babylonCamera.orthoTop = camera.orthographic.ymag; + babylonCamera.minZ = camera.orthographic.znear; + babylonCamera.maxZ = camera.orthographic.zfar; + break; + } + default: { + throw new Error("".concat(context, ": Invalid camera type (").concat(camera.type, ")")); + } + } + GLTFLoader.AddPointerMetadata(babylonCamera, context); + this._parent.onCameraLoadedObservable.notifyObservers(babylonCamera); + assign(babylonCamera); + this.logClose(); + return Promise.all(promises).then(function () { + return babylonCamera; + }); + }; + GLTFLoader.prototype._loadAnimationsAsync = function () { + var animations = this._gltf.animations; + if (!animations) { + return Promise.resolve(); + } + var promises = new Array(); + for (var index = 0; index < animations.length; index++) { + var animation = animations[index]; + promises.push(this.loadAnimationAsync("/animations/".concat(animation.index), animation).then(function (animationGroup) { + // Delete the animation group if it ended up not having any animations in it. + if (animationGroup.targetedAnimations.length === 0) { + animationGroup.dispose(); + } + })); + } + return Promise.all(promises).then(function () { }); + }; + /** + * Loads a glTF animation. + * @param context The context when loading the asset + * @param animation The glTF animation property + * @returns A promise that resolves with the loaded Babylon animation group when the load is complete + */ + GLTFLoader.prototype.loadAnimationAsync = function (context, animation) { + var promise = this._extensionsLoadAnimationAsync(context, animation); + if (promise) { + return promise; + } + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonAnimationGroup = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.AnimationGroup(animation.name || "animation".concat(animation.index), this._babylonScene); + babylonAnimationGroup._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + animation._babylonAnimationGroup = babylonAnimationGroup; + var promises = new Array(); + ArrayItem.Assign(animation.channels); + ArrayItem.Assign(animation.samplers); + for (var _i = 0, _a = animation.channels; _i < _a.length; _i++) { + var channel = _a[_i]; + promises.push(this._loadAnimationChannelAsync("".concat(context, "/channels/").concat(channel.index), context, animation, channel, function (babylonTarget, babylonAnimation) { + babylonTarget.animations = babylonTarget.animations || []; + babylonTarget.animations.push(babylonAnimation); + babylonAnimationGroup.addTargetedAnimation(babylonAnimation, babylonTarget); + })); + } + return Promise.all(promises).then(function () { + babylonAnimationGroup.normalize(0); + return babylonAnimationGroup; + }); + }; + /** + * @hidden + * Loads a glTF animation channel. + * @param context The context when loading the asset + * @param animationContext The context of the animation when loading the asset + * @param animation The glTF animation property + * @param channel The glTF animation channel property + * @param onLoad Called for each animation loaded + * @returns A void promise that resolves when the load is complete + */ + GLTFLoader.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, onLoad) { + var promise = this._extensionsLoadAnimationChannelAsync(context, animationContext, animation, channel, onLoad); + if (promise) { + return promise; + } + if (channel.target.node == undefined) { + return Promise.resolve(); + } + var targetNode = ArrayItem.Get("".concat(context, "/target/node"), this._gltf.nodes, channel.target.node); + // Ignore animations that have no animation targets. + if ((channel.target.path === "weights" /* AnimationChannelTargetPath.WEIGHTS */ && !targetNode._numMorphTargets) || + (channel.target.path !== "weights" /* AnimationChannelTargetPath.WEIGHTS */ && !targetNode._babylonTransformNode)) { + return Promise.resolve(); + } + var properties; + switch (channel.target.path) { + case "translation" /* AnimationChannelTargetPath.TRANSLATION */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.translation; + break; + } + case "rotation" /* AnimationChannelTargetPath.ROTATION */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.rotation; + break; + } + case "scale" /* AnimationChannelTargetPath.SCALE */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.scale; + break; + } + case "weights" /* AnimationChannelTargetPath.WEIGHTS */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.weights; + break; + } + default: { + throw new Error("".concat(context, "/target/path: Invalid value (").concat(channel.target.path, ")")); + } + } + var targetInfo = { + object: targetNode, + info: properties, + }; + return this._loadAnimationChannelFromTargetInfoAsync(context, animationContext, animation, channel, targetInfo, onLoad); + }; + /** + * @hidden + * Loads a glTF animation channel. + * @param context The context when loading the asset + * @param animationContext The context of the animation when loading the asset + * @param animation The glTF animation property + * @param channel The glTF animation channel property + * @param targetInfo The glTF target and properties + * @param onLoad Called for each animation loaded + * @returns A void promise that resolves when the load is complete + */ + GLTFLoader.prototype._loadAnimationChannelFromTargetInfoAsync = function (context, animationContext, animation, channel, targetInfo, onLoad) { + var fps = this.parent.targetFps; + var invfps = 1 / fps; + var sampler = ArrayItem.Get("".concat(context, "/sampler"), animation.samplers, channel.sampler); + return this._loadAnimationSamplerAsync("".concat(animationContext, "/samplers/").concat(channel.sampler), sampler).then(function (data) { + var numAnimations = 0; + var target = targetInfo.object; + var propertyInfos = targetInfo.info; + // Extract the corresponding values from the read value. + // GLTF values may be dispatched to several Babylon properties. + // For example, baseColorFactor [`r`, `g`, `b`, `a`] is dispatched to + // - albedoColor as Color3(`r`, `g`, `b`) + // - alpha as `a` + for (var _i = 0, propertyInfos_1 = propertyInfos; _i < propertyInfos_1.length; _i++) { + var propertyInfo = propertyInfos_1[_i]; + var stride = propertyInfo.getStride(target); + var input = data.input; + var output = data.output; + var keys = new Array(input.length); + var outputOffset = 0; + switch (data.interpolation) { + case "STEP" /* AnimationSamplerInterpolation.STEP */: { + for (var index = 0; index < input.length; index++) { + var value = propertyInfo.getValue(target, output, outputOffset, 1); + outputOffset += stride; + keys[index] = { + frame: input[index] * fps, + value: value, + interpolation: babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.AnimationKeyInterpolation.STEP, + }; + } + break; + } + case "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */: { + for (var index = 0; index < input.length; index++) { + var inTangent = propertyInfo.getValue(target, output, outputOffset, invfps); + outputOffset += stride; + var value = propertyInfo.getValue(target, output, outputOffset, 1); + outputOffset += stride; + var outTangent = propertyInfo.getValue(target, output, outputOffset, invfps); + outputOffset += stride; + keys[index] = { + frame: input[index] * fps, + inTangent: inTangent, + value: value, + outTangent: outTangent, + }; + } + break; + } + case "LINEAR" /* AnimationSamplerInterpolation.LINEAR */: { + for (var index = 0; index < input.length; index++) { + var value = propertyInfo.getValue(target, output, outputOffset, 1); + outputOffset += stride; + keys[index] = { + frame: input[index] * fps, + value: value, + }; + } + break; + } + } + if (outputOffset > 0) { + var name_4 = "".concat(animation.name || "animation".concat(animation.index), "_channel").concat(channel.index, "_").concat(numAnimations); + propertyInfo.buildAnimations(target, name_4, fps, keys, function (babylonAnimatable, babylonAnimation) { + ++numAnimations; + onLoad(babylonAnimatable, babylonAnimation); + }); + } + } + }); + }; + GLTFLoader.prototype._loadAnimationSamplerAsync = function (context, sampler) { + if (sampler._data) { + return sampler._data; + } + var interpolation = sampler.interpolation || "LINEAR" /* AnimationSamplerInterpolation.LINEAR */; + switch (interpolation) { + case "STEP" /* AnimationSamplerInterpolation.STEP */: + case "LINEAR" /* AnimationSamplerInterpolation.LINEAR */: + case "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */: { + break; + } + default: { + throw new Error("".concat(context, "/interpolation: Invalid value (").concat(sampler.interpolation, ")")); + } + } + var inputAccessor = ArrayItem.Get("".concat(context, "/input"), this._gltf.accessors, sampler.input); + var outputAccessor = ArrayItem.Get("".concat(context, "/output"), this._gltf.accessors, sampler.output); + sampler._data = Promise.all([ + this._loadFloatAccessorAsync("/accessors/".concat(inputAccessor.index), inputAccessor), + this._loadFloatAccessorAsync("/accessors/".concat(outputAccessor.index), outputAccessor), + ]).then(function (_a) { + var inputData = _a[0], outputData = _a[1]; + return { + input: inputData, + interpolation: interpolation, + output: outputData, + }; + }); + return sampler._data; + }; + /** + * Loads a glTF buffer. + * @param context The context when loading the asset + * @param buffer The glTF buffer property + * @param byteOffset The byte offset to use + * @param byteLength The byte length to use + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadBufferAsync = function (context, buffer, byteOffset, byteLength) { + var extensionPromise = this._extensionsLoadBufferAsync(context, buffer, byteOffset, byteLength); + if (extensionPromise) { + return extensionPromise; + } + if (!buffer._data) { + if (buffer.uri) { + buffer._data = this.loadUriAsync("".concat(context, "/uri"), buffer, buffer.uri); + } + else { + if (!this._bin) { + throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk")); + } + buffer._data = this._bin.readAsync(0, buffer.byteLength); + } + } + return buffer._data.then(function (data) { + try { + return new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength); + } + catch (e) { + throw new Error("".concat(context, ": ").concat(e.message)); + } + }); + }; + /** + * Loads a glTF buffer view. + * @param context The context when loading the asset + * @param bufferView The glTF buffer view property + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadBufferViewAsync = function (context, bufferView) { + var extensionPromise = this._extensionsLoadBufferViewAsync(context, bufferView); + if (extensionPromise) { + return extensionPromise; + } + if (bufferView._data) { + return bufferView._data; + } + var buffer = ArrayItem.Get("".concat(context, "/buffer"), this._gltf.buffers, bufferView.buffer); + bufferView._data = this.loadBufferAsync("/buffers/".concat(buffer.index), buffer, bufferView.byteOffset || 0, bufferView.byteLength); + return bufferView._data; + }; + GLTFLoader.prototype._loadAccessorAsync = function (context, accessor, constructor) { + var _this = this; + if (accessor._data) { + return accessor._data; + } + var numComponents = GLTFLoader._GetNumComponents(context, accessor.type); + var byteStride = numComponents * babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(accessor.componentType); + var length = numComponents * accessor.count; + if (accessor.bufferView == undefined) { + accessor._data = Promise.resolve(new constructor(length)); + } + else { + var bufferView_1 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView); + accessor._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView_1.index), bufferView_1).then(function (data) { + if (accessor.componentType === 5126 /* AccessorComponentType.FLOAT */ && !accessor.normalized && (!bufferView_1.byteStride || bufferView_1.byteStride === byteStride)) { + return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, length); + } + else { + var typedArray_1 = new constructor(length); + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ForEach(data, accessor.byteOffset || 0, bufferView_1.byteStride || byteStride, numComponents, accessor.componentType, typedArray_1.length, accessor.normalized || false, function (value, index) { + typedArray_1[index] = value; + }); + return typedArray_1; + } + }); + } + if (accessor.sparse) { + var sparse_1 = accessor.sparse; + accessor._data = accessor._data.then(function (data) { + var typedArray = data; + var indicesBufferView = ArrayItem.Get("".concat(context, "/sparse/indices/bufferView"), _this._gltf.bufferViews, sparse_1.indices.bufferView); + var valuesBufferView = ArrayItem.Get("".concat(context, "/sparse/values/bufferView"), _this._gltf.bufferViews, sparse_1.values.bufferView); + return Promise.all([ + _this.loadBufferViewAsync("/bufferViews/".concat(indicesBufferView.index), indicesBufferView), + _this.loadBufferViewAsync("/bufferViews/".concat(valuesBufferView.index), valuesBufferView), + ]).then(function (_a) { + var indicesData = _a[0], valuesData = _a[1]; + var indices = GLTFLoader._GetTypedArray("".concat(context, "/sparse/indices"), sparse_1.indices.componentType, indicesData, sparse_1.indices.byteOffset, sparse_1.count); + var sparseLength = numComponents * sparse_1.count; + var values; + if (accessor.componentType === 5126 /* AccessorComponentType.FLOAT */ && !accessor.normalized) { + values = GLTFLoader._GetTypedArray("".concat(context, "/sparse/values"), accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength); + } + else { + var sparseData = GLTFLoader._GetTypedArray("".concat(context, "/sparse/values"), accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength); + values = new constructor(sparseLength); + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ForEach(sparseData, 0, byteStride, numComponents, accessor.componentType, values.length, accessor.normalized || false, function (value, index) { + values[index] = value; + }); + } + var valuesIndex = 0; + for (var indicesIndex = 0; indicesIndex < indices.length; indicesIndex++) { + var dataIndex = indices[indicesIndex] * numComponents; + for (var componentIndex = 0; componentIndex < numComponents; componentIndex++) { + typedArray[dataIndex++] = values[valuesIndex++]; + } + } + return typedArray; + }); + }); + } + return accessor._data; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadFloatAccessorAsync = function (context, accessor) { + return this._loadAccessorAsync(context, accessor, Float32Array); + }; + /** + * @internal + */ + GLTFLoader.prototype._loadIndicesAccessorAsync = function (context, accessor) { + if (accessor.type !== "SCALAR" /* AccessorType.SCALAR */) { + throw new Error("".concat(context, "/type: Invalid value ").concat(accessor.type)); + } + if (accessor.componentType !== 5121 /* AccessorComponentType.UNSIGNED_BYTE */ && + accessor.componentType !== 5123 /* AccessorComponentType.UNSIGNED_SHORT */ && + accessor.componentType !== 5125 /* AccessorComponentType.UNSIGNED_INT */) { + throw new Error("".concat(context, "/componentType: Invalid value ").concat(accessor.componentType)); + } + if (accessor._data) { + return accessor._data; + } + if (accessor.sparse) { + var constructor = GLTFLoader._GetTypedArrayConstructor("".concat(context, "/componentType"), accessor.componentType); + accessor._data = this._loadAccessorAsync(context, accessor, constructor); + } + else { + var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView); + accessor._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) { + return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, accessor.count); + }); + } + return accessor._data; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadVertexBufferViewAsync = function (bufferView) { + if (bufferView._babylonBuffer) { + return bufferView._babylonBuffer; + } + var engine = this._babylonScene.getEngine(); + bufferView._babylonBuffer = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) { + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Buffer(engine, data, false); + }); + return bufferView._babylonBuffer; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadVertexAccessorAsync = function (context, accessor, kind) { + var _a; + if ((_a = accessor._babylonVertexBuffer) === null || _a === void 0 ? void 0 : _a[kind]) { + return accessor._babylonVertexBuffer[kind]; + } + if (!accessor._babylonVertexBuffer) { + accessor._babylonVertexBuffer = {}; + } + var engine = this._babylonScene.getEngine(); + if (accessor.sparse || accessor.bufferView == undefined) { + accessor._babylonVertexBuffer[kind] = this._loadFloatAccessorAsync(context, accessor).then(function (data) { + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(engine, data, kind, false); + }); + } + // Load joint indices as a float array since the shaders expect float data but glTF uses unsigned byte/short. + // This prevents certain platforms (e.g. D3D) from having to convert the data to float on the fly. + else if (kind === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind || kind === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind) { + accessor._babylonVertexBuffer[kind] = this._loadFloatAccessorAsync(context, accessor).then(function (data) { + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(engine, data, kind, false); + }); + } + else { + var bufferView_2 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView); + accessor._babylonVertexBuffer[kind] = this._loadVertexBufferViewAsync(bufferView_2).then(function (babylonBuffer) { + var numComponents = GLTFLoader._GetNumComponents(context, accessor.type); + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(engine, babylonBuffer, kind, false, undefined, bufferView_2.byteStride, undefined, accessor.byteOffset, numComponents, accessor.componentType, accessor.normalized, true, undefined, true); + }); + } + return accessor._babylonVertexBuffer[kind]; + }; + GLTFLoader.prototype._loadMaterialMetallicRoughnessPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + if (properties) { + if (properties.baseColorFactor) { + babylonMaterial.albedoColor = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.baseColorFactor); + babylonMaterial.alpha = properties.baseColorFactor[3]; + } + else { + babylonMaterial.albedoColor = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + } + babylonMaterial.metallic = properties.metallicFactor == undefined ? 1 : properties.metallicFactor; + babylonMaterial.roughness = properties.roughnessFactor == undefined ? 1 : properties.roughnessFactor; + if (properties.baseColorTexture) { + promises.push(this.loadTextureInfoAsync("".concat(context, "/baseColorTexture"), properties.baseColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Base Color)"); + babylonMaterial.albedoTexture = texture; + })); + } + if (properties.metallicRoughnessTexture) { + properties.metallicRoughnessTexture.nonColorData = true; + promises.push(this.loadTextureInfoAsync("".concat(context, "/metallicRoughnessTexture"), properties.metallicRoughnessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Metallic Roughness)"); + babylonMaterial.metallicTexture = texture; + })); + babylonMaterial.useMetallnessFromMetallicTextureBlue = true; + babylonMaterial.useRoughnessFromMetallicTextureGreen = true; + babylonMaterial.useRoughnessFromMetallicTextureAlpha = false; + } + } + return Promise.all(promises).then(function () { }); + }; + /** + * @internal + */ + GLTFLoader.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) { + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign); + if (extensionPromise) { + return extensionPromise; + } + material._data = material._data || {}; + var babylonData = material._data[babylonDrawMode]; + if (!babylonData) { + this.logOpen("".concat(context, " ").concat(material.name || "")); + var babylonMaterial = this.createMaterial(context, material, babylonDrawMode); + babylonData = { + babylonMaterial: babylonMaterial, + babylonMeshes: [], + promise: this.loadMaterialPropertiesAsync(context, material, babylonMaterial), + }; + material._data[babylonDrawMode] = babylonData; + GLTFLoader.AddPointerMetadata(babylonMaterial, context); + this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial); + this.logClose(); + } + if (babylonMesh) { + babylonData.babylonMeshes.push(babylonMesh); + babylonMesh.onDisposeObservable.addOnce(function () { + var index = babylonData.babylonMeshes.indexOf(babylonMesh); + if (index !== -1) { + babylonData.babylonMeshes.splice(index, 1); + } + }); + } + assign(babylonData.babylonMaterial); + return babylonData.promise.then(function () { + return babylonData.babylonMaterial; + }); + }; + GLTFLoader.prototype._createDefaultMaterial = function (name, babylonDrawMode) { + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonMaterial = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial(name, this._babylonScene); + babylonMaterial._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + // Moved to mesh so user can change materials on gltf meshes: babylonMaterial.sideOrientation = this._babylonScene.useRightHandedSystem ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation; + babylonMaterial.fillMode = babylonDrawMode; + babylonMaterial.enableSpecularAntiAliasing = true; + babylonMaterial.useRadianceOverAlpha = !this._parent.transparencyAsCoverage; + babylonMaterial.useSpecularOverAlpha = !this._parent.transparencyAsCoverage; + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_OPAQUE; + babylonMaterial.metallic = 1; + babylonMaterial.roughness = 1; + return babylonMaterial; + }; + /** + * Creates a Babylon material from a glTF material. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonDrawMode The draw mode for the Babylon material + * @returns The Babylon material + */ + GLTFLoader.prototype.createMaterial = function (context, material, babylonDrawMode) { + var extensionPromise = this._extensionsCreateMaterial(context, material, babylonDrawMode); + if (extensionPromise) { + return extensionPromise; + } + var name = material.name || "material".concat(material.index); + var babylonMaterial = this._createDefaultMaterial(name, babylonDrawMode); + return babylonMaterial; + }; + /** + * Loads properties from a glTF material into a Babylon material. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonMaterial The Babylon material + * @returns A promise that resolves when the load is complete + */ + GLTFLoader.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var extensionPromise = this._extensionsLoadMaterialPropertiesAsync(context, material, babylonMaterial); + if (extensionPromise) { + return extensionPromise; + } + var promises = new Array(); + promises.push(this.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + if (material.pbrMetallicRoughness) { + promises.push(this._loadMaterialMetallicRoughnessPropertiesAsync("".concat(context, "/pbrMetallicRoughness"), material.pbrMetallicRoughness, babylonMaterial)); + } + this.loadMaterialAlphaProperties(context, material, babylonMaterial); + return Promise.all(promises).then(function () { }); + }; + /** + * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonMaterial The Babylon material + * @returns A promise that resolves when the load is complete + */ + GLTFLoader.prototype.loadMaterialBasePropertiesAsync = function (context, material, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.emissiveColor = material.emissiveFactor ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(material.emissiveFactor) : new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3(0, 0, 0); + if (material.doubleSided) { + babylonMaterial.backFaceCulling = false; + babylonMaterial.twoSidedLighting = true; + } + if (material.normalTexture) { + material.normalTexture.nonColorData = true; + promises.push(this.loadTextureInfoAsync("".concat(context, "/normalTexture"), material.normalTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Normal)"); + babylonMaterial.bumpTexture = texture; + })); + babylonMaterial.invertNormalMapX = !this._babylonScene.useRightHandedSystem; + babylonMaterial.invertNormalMapY = this._babylonScene.useRightHandedSystem; + if (material.normalTexture.scale != undefined && babylonMaterial.bumpTexture) { + babylonMaterial.bumpTexture.level = material.normalTexture.scale; + } + babylonMaterial.forceIrradianceInFragment = true; + } + if (material.occlusionTexture) { + material.occlusionTexture.nonColorData = true; + promises.push(this.loadTextureInfoAsync("".concat(context, "/occlusionTexture"), material.occlusionTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Occlusion)"); + babylonMaterial.ambientTexture = texture; + })); + babylonMaterial.useAmbientInGrayScale = true; + if (material.occlusionTexture.strength != undefined) { + babylonMaterial.ambientTextureStrength = material.occlusionTexture.strength; + } + } + if (material.emissiveTexture) { + promises.push(this.loadTextureInfoAsync("".concat(context, "/emissiveTexture"), material.emissiveTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Emissive)"); + babylonMaterial.emissiveTexture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + /** + * Loads the alpha properties from a glTF material into a Babylon material. + * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonMaterial The Babylon material + */ + GLTFLoader.prototype.loadMaterialAlphaProperties = function (context, material, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var alphaMode = material.alphaMode || "OPAQUE" /* MaterialAlphaMode.OPAQUE */; + switch (alphaMode) { + case "OPAQUE" /* MaterialAlphaMode.OPAQUE */: { + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_OPAQUE; + babylonMaterial.alpha = 1.0; // Force alpha to 1.0 for opaque mode. + break; + } + case "MASK" /* MaterialAlphaMode.MASK */: { + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_ALPHATEST; + babylonMaterial.alphaCutOff = material.alphaCutoff == undefined ? 0.5 : material.alphaCutoff; + if (babylonMaterial.albedoTexture) { + babylonMaterial.albedoTexture.hasAlpha = true; + } + break; + } + case "BLEND" /* MaterialAlphaMode.BLEND */: { + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_ALPHABLEND; + if (babylonMaterial.albedoTexture) { + babylonMaterial.albedoTexture.hasAlpha = true; + babylonMaterial.useAlphaFromAlbedoTexture = true; + } + break; + } + default: { + throw new Error("".concat(context, "/alphaMode: Invalid value (").concat(material.alphaMode, ")")); + } + } + }; + /** + * Loads a glTF texture info. + * @param context The context when loading the asset + * @param textureInfo The glTF texture info property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded Babylon texture when the load is complete + */ + GLTFLoader.prototype.loadTextureInfoAsync = function (context, textureInfo, assign) { + var _this = this; + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadTextureInfoAsync(context, textureInfo, assign); + if (extensionPromise) { + return extensionPromise; + } + this.logOpen("".concat(context)); + if (textureInfo.texCoord >= 6) { + throw new Error("".concat(context, "/texCoord: Invalid value (").concat(textureInfo.texCoord, ")")); + } + var texture = ArrayItem.Get("".concat(context, "/index"), this._gltf.textures, textureInfo.index); + texture._textureInfo = textureInfo; + var promise = this._loadTextureAsync("/textures/".concat(textureInfo.index), texture, function (babylonTexture) { + babylonTexture.coordinatesIndex = textureInfo.texCoord || 0; + GLTFLoader.AddPointerMetadata(babylonTexture, context); + _this._parent.onTextureLoadedObservable.notifyObservers(babylonTexture); + assign(babylonTexture); + }); + this.logClose(); + return promise; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadTextureAsync = function (context, texture, assign) { + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadTextureAsync(context, texture, assign); + if (extensionPromise) { + return extensionPromise; + } + this.logOpen("".concat(context, " ").concat(texture.name || "")); + var sampler = texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get("".concat(context, "/sampler"), this._gltf.samplers, texture.sampler); + var image = ArrayItem.Get("".concat(context, "/source"), this._gltf.images, texture.source); + var promise = this._createTextureAsync(context, sampler, image, assign, undefined, !texture._textureInfo.nonColorData); + this.logClose(); + return promise; + }; + /** + * @internal + */ + GLTFLoader.prototype._createTextureAsync = function (context, sampler, image, assign, textureLoaderOptions, useSRGBBuffer) { + var _this = this; + if (assign === void 0) { assign = function () { }; } + var samplerData = this._loadSampler("/samplers/".concat(sampler.index), sampler); + var promises = new Array(); + var deferred = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var textureCreationOptions = { + noMipmap: samplerData.noMipMaps, + invertY: false, + samplingMode: samplerData.samplingMode, + onLoad: function () { + if (!_this._disposed) { + deferred.resolve(); + } + }, + onError: function (message, exception) { + if (!_this._disposed) { + deferred.reject(new Error("".concat(context, ": ").concat(exception && exception.message ? exception.message : message || "Failed to load texture"))); + } + }, + mimeType: image.mimeType, + loaderOptions: textureLoaderOptions, + useSRGBBuffer: !!useSRGBBuffer && this._parent.useSRGBBuffers, + }; + var babylonTexture = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture(null, this._babylonScene, textureCreationOptions); + babylonTexture._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + promises.push(deferred.promise); + promises.push(this.loadImageAsync("/images/".concat(image.index), image).then(function (data) { + var name = image.uri || "".concat(_this._fileName, "#image").concat(image.index); + var dataUrl = "data:".concat(_this._uniqueRootUrl).concat(name); + babylonTexture.updateURL(dataUrl, data); + })); + babylonTexture.wrapU = samplerData.wrapU; + babylonTexture.wrapV = samplerData.wrapV; + assign(babylonTexture); + return Promise.all(promises).then(function () { + return babylonTexture; + }); + }; + GLTFLoader.prototype._loadSampler = function (context, sampler) { + if (!sampler._data) { + sampler._data = { + noMipMaps: sampler.minFilter === 9728 /* TextureMinFilter.NEAREST */ || sampler.minFilter === 9729 /* TextureMinFilter.LINEAR */, + samplingMode: GLTFLoader._GetTextureSamplingMode(context, sampler), + wrapU: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapS"), sampler.wrapS), + wrapV: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapT"), sampler.wrapT), + }; + } + return sampler._data; + }; + /** + * Loads a glTF image. + * @param context The context when loading the asset + * @param image The glTF image property + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadImageAsync = function (context, image) { + if (!image._data) { + this.logOpen("".concat(context, " ").concat(image.name || "")); + if (image.uri) { + image._data = this.loadUriAsync("".concat(context, "/uri"), image, image.uri); + } + else { + var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, image.bufferView); + image._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView); + } + this.logClose(); + } + return image._data; + }; + /** + * Loads a glTF uri. + * @param context The context when loading the asset + * @param property The glTF property associated with the uri + * @param uri The base64 or relative uri + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadUriAsync = function (context, property, uri) { + var _this = this; + var extensionPromise = this._extensionsLoadUriAsync(context, property, uri); + if (extensionPromise) { + return extensionPromise; + } + if (!GLTFLoader._ValidateUri(uri)) { + throw new Error("".concat(context, ": '").concat(uri, "' is invalid")); + } + if ((0,babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.IsBase64DataUrl)(uri)) { + var data = new Uint8Array((0,babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.DecodeBase64UrlToBinary)(uri)); + this.log("".concat(context, ": Decoded ").concat(uri.substr(0, 64), "... (").concat(data.length, " bytes)")); + return Promise.resolve(data); + } + this.log("".concat(context, ": Loading ").concat(uri)); + return this._parent.preprocessUrlAsync(this._rootUrl + uri).then(function (url) { + return new Promise(function (resolve, reject) { + _this._parent._loadFile(_this._babylonScene, url, function (data) { + if (!_this._disposed) { + _this.log("".concat(context, ": Loaded ").concat(uri, " (").concat(data.byteLength, " bytes)")); + resolve(new Uint8Array(data)); + } + }, true, function (request) { + reject(new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.LoadFileError("".concat(context, ": Failed to load '").concat(uri, "'").concat(request ? ": " + request.status + " " + request.statusText : ""), request)); + }); + }); + }); + }; + /** + * Adds a JSON pointer to the _internalMetadata of the Babylon object at `._internalMetadata.gltf.pointers`. + * @param babylonObject the Babylon object with _internalMetadata + * @param pointer the JSON pointer + */ + GLTFLoader.AddPointerMetadata = function (babylonObject, pointer) { + babylonObject.metadata = babylonObject.metadata || {}; + var metadata = (babylonObject._internalMetadata = babylonObject._internalMetadata || {}); + var gltf = (metadata.gltf = metadata.gltf || {}); + var pointers = (gltf.pointers = gltf.pointers || []); + pointers.push(pointer); + }; + GLTFLoader._GetTextureWrapMode = function (context, mode) { + // Set defaults if undefined + mode = mode == undefined ? 10497 /* TextureWrapMode.REPEAT */ : mode; + switch (mode) { + case 33071 /* TextureWrapMode.CLAMP_TO_EDGE */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.CLAMP_ADDRESSMODE; + case 33648 /* TextureWrapMode.MIRRORED_REPEAT */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.MIRROR_ADDRESSMODE; + case 10497 /* TextureWrapMode.REPEAT */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.WRAP_ADDRESSMODE; + default: + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Invalid value (").concat(mode, ")")); + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.WRAP_ADDRESSMODE; + } + }; + GLTFLoader._GetTextureSamplingMode = function (context, sampler) { + // Set defaults if undefined + var magFilter = sampler.magFilter == undefined ? 9729 /* TextureMagFilter.LINEAR */ : sampler.magFilter; + var minFilter = sampler.minFilter == undefined ? 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */ : sampler.minFilter; + if (magFilter === 9729 /* TextureMagFilter.LINEAR */) { + switch (minFilter) { + case 9728 /* TextureMinFilter.NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST; + case 9729 /* TextureMinFilter.LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR; + case 9984 /* TextureMinFilter.NEAREST_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST_MIPNEAREST; + case 9985 /* TextureMinFilter.LINEAR_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPNEAREST; + case 9986 /* TextureMinFilter.NEAREST_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST_MIPLINEAR; + case 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPLINEAR; + default: + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")")); + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPLINEAR; + } + } + else { + if (magFilter !== 9728 /* TextureMagFilter.NEAREST */) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/magFilter: Invalid value (").concat(magFilter, ")")); + } + switch (minFilter) { + case 9728 /* TextureMinFilter.NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST; + case 9729 /* TextureMinFilter.LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR; + case 9984 /* TextureMinFilter.NEAREST_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPNEAREST; + case 9985 /* TextureMinFilter.LINEAR_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR_MIPNEAREST; + case 9986 /* TextureMinFilter.NEAREST_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPLINEAR; + case 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR_MIPLINEAR; + default: + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")")); + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPNEAREST; + } + } + }; + GLTFLoader._GetTypedArrayConstructor = function (context, componentType) { + switch (componentType) { + case 5120 /* AccessorComponentType.BYTE */: + return Int8Array; + case 5121 /* AccessorComponentType.UNSIGNED_BYTE */: + return Uint8Array; + case 5122 /* AccessorComponentType.SHORT */: + return Int16Array; + case 5123 /* AccessorComponentType.UNSIGNED_SHORT */: + return Uint16Array; + case 5125 /* AccessorComponentType.UNSIGNED_INT */: + return Uint32Array; + case 5126 /* AccessorComponentType.FLOAT */: + return Float32Array; + default: + throw new Error("".concat(context, ": Invalid component type ").concat(componentType)); + } + }; + GLTFLoader._GetTypedArray = function (context, componentType, bufferView, byteOffset, length) { + var buffer = bufferView.buffer; + byteOffset = bufferView.byteOffset + (byteOffset || 0); + var constructor = GLTFLoader._GetTypedArrayConstructor("".concat(context, "/componentType"), componentType); + var componentTypeLength = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(componentType); + if (byteOffset % componentTypeLength !== 0) { + // HACK: Copy the buffer if byte offset is not a multiple of component type byte length. + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Copying buffer as byte offset (").concat(byteOffset, ") is not a multiple of component type byte length (").concat(componentTypeLength, ")")); + return new constructor(buffer.slice(byteOffset, byteOffset + length * componentTypeLength), 0); + } + return new constructor(buffer, byteOffset, length); + }; + GLTFLoader._GetNumComponents = function (context, type) { + switch (type) { + case "SCALAR": + return 1; + case "VEC2": + return 2; + case "VEC3": + return 3; + case "VEC4": + return 4; + case "MAT2": + return 4; + case "MAT3": + return 9; + case "MAT4": + return 16; + } + throw new Error("".concat(context, ": Invalid type (").concat(type, ")")); + }; + GLTFLoader._ValidateUri = function (uri) { + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Tools.IsBase64(uri) || uri.indexOf("..") === -1; + }; + /** + * @internal + */ + GLTFLoader._GetDrawMode = function (context, mode) { + if (mode == undefined) { + mode = 4 /* MeshPrimitiveMode.TRIANGLES */; + } + switch (mode) { + case 0 /* MeshPrimitiveMode.POINTS */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.PointListDrawMode; + case 1 /* MeshPrimitiveMode.LINES */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineListDrawMode; + case 2 /* MeshPrimitiveMode.LINE_LOOP */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineLoopDrawMode; + case 3 /* MeshPrimitiveMode.LINE_STRIP */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineStripDrawMode; + case 4 /* MeshPrimitiveMode.TRIANGLES */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode; + case 5 /* MeshPrimitiveMode.TRIANGLE_STRIP */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleStripDrawMode; + case 6 /* MeshPrimitiveMode.TRIANGLE_FAN */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFanDrawMode; + } + throw new Error("".concat(context, ": Invalid mesh primitive mode (").concat(mode, ")")); + }; + GLTFLoader.prototype._compileMaterialsAsync = function () { + var _this = this; + this._parent._startPerformanceCounter("Compile materials"); + var promises = new Array(); + if (this._gltf.materials) { + for (var _i = 0, _a = this._gltf.materials; _i < _a.length; _i++) { + var material = _a[_i]; + if (material._data) { + for (var babylonDrawMode in material._data) { + var babylonData = material._data[babylonDrawMode]; + for (var _b = 0, _c = babylonData.babylonMeshes; _b < _c.length; _b++) { + var babylonMesh = _c[_b]; + // Ensure nonUniformScaling is set if necessary. + babylonMesh.computeWorldMatrix(true); + var babylonMaterial = babylonData.babylonMaterial; + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh)); + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { useInstances: true })); + if (this._parent.useClipPlane) { + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { clipPlane: true })); + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { clipPlane: true, useInstances: true })); + } + } + } + } + } + } + return Promise.all(promises).then(function () { + _this._parent._endPerformanceCounter("Compile materials"); + }); + }; + GLTFLoader.prototype._compileShadowGeneratorsAsync = function () { + var _this = this; + this._parent._startPerformanceCounter("Compile shadow generators"); + var promises = new Array(); + var lights = this._babylonScene.lights; + for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) { + var light = lights_1[_i]; + var generator = light.getShadowGenerator(); + if (generator) { + promises.push(generator.forceCompilationAsync()); + } + } + return Promise.all(promises).then(function () { + _this._parent._endPerformanceCounter("Compile shadow generators"); + }); + }; + GLTFLoader.prototype._forEachExtensions = function (action) { + for (var _i = 0, _a = this._extensions; _i < _a.length; _i++) { + var extension = _a[_i]; + if (extension.enabled) { + action(extension); + } + } + }; + GLTFLoader.prototype._applyExtensions = function (property, functionName, actionAsync) { + for (var _i = 0, _a = this._extensions; _i < _a.length; _i++) { + var extension = _a[_i]; + if (extension.enabled) { + var id = "".concat(extension.name, ".").concat(functionName); + var loaderProperty = property; + loaderProperty._activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions || {}; + var activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions; + if (!activeLoaderExtensionFunctions[id]) { + activeLoaderExtensionFunctions[id] = true; + try { + var result = actionAsync(extension); + if (result) { + return result; + } + } + finally { + delete activeLoaderExtensionFunctions[id]; + } + } + } + } + return null; + }; + GLTFLoader.prototype._extensionsOnLoading = function () { + this._forEachExtensions(function (extension) { return extension.onLoading && extension.onLoading(); }); + }; + GLTFLoader.prototype._extensionsOnReady = function () { + this._forEachExtensions(function (extension) { return extension.onReady && extension.onReady(); }); + }; + GLTFLoader.prototype._extensionsLoadSceneAsync = function (context, scene) { + return this._applyExtensions(scene, "loadScene", function (extension) { return extension.loadSceneAsync && extension.loadSceneAsync(context, scene); }); + }; + GLTFLoader.prototype._extensionsLoadNodeAsync = function (context, node, assign) { + return this._applyExtensions(node, "loadNode", function (extension) { return extension.loadNodeAsync && extension.loadNodeAsync(context, node, assign); }); + }; + GLTFLoader.prototype._extensionsLoadCameraAsync = function (context, camera, assign) { + return this._applyExtensions(camera, "loadCamera", function (extension) { return extension.loadCameraAsync && extension.loadCameraAsync(context, camera, assign); }); + }; + GLTFLoader.prototype._extensionsLoadVertexDataAsync = function (context, primitive, babylonMesh) { + return this._applyExtensions(primitive, "loadVertexData", function (extension) { return extension._loadVertexDataAsync && extension._loadVertexDataAsync(context, primitive, babylonMesh); }); + }; + GLTFLoader.prototype._extensionsLoadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) { + return this._applyExtensions(primitive, "loadMeshPrimitive", function (extension) { return extension._loadMeshPrimitiveAsync && extension._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign); }); + }; + GLTFLoader.prototype._extensionsLoadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) { + return this._applyExtensions(material, "loadMaterial", function (extension) { return extension._loadMaterialAsync && extension._loadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign); }); + }; + GLTFLoader.prototype._extensionsCreateMaterial = function (context, material, babylonDrawMode) { + return this._applyExtensions(material, "createMaterial", function (extension) { return extension.createMaterial && extension.createMaterial(context, material, babylonDrawMode); }); + }; + GLTFLoader.prototype._extensionsLoadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + return this._applyExtensions(material, "loadMaterialProperties", function (extension) { return extension.loadMaterialPropertiesAsync && extension.loadMaterialPropertiesAsync(context, material, babylonMaterial); }); + }; + GLTFLoader.prototype._extensionsLoadTextureInfoAsync = function (context, textureInfo, assign) { + return this._applyExtensions(textureInfo, "loadTextureInfo", function (extension) { return extension.loadTextureInfoAsync && extension.loadTextureInfoAsync(context, textureInfo, assign); }); + }; + GLTFLoader.prototype._extensionsLoadTextureAsync = function (context, texture, assign) { + return this._applyExtensions(texture, "loadTexture", function (extension) { return extension._loadTextureAsync && extension._loadTextureAsync(context, texture, assign); }); + }; + GLTFLoader.prototype._extensionsLoadAnimationAsync = function (context, animation) { + return this._applyExtensions(animation, "loadAnimation", function (extension) { return extension.loadAnimationAsync && extension.loadAnimationAsync(context, animation); }); + }; + GLTFLoader.prototype._extensionsLoadAnimationChannelAsync = function (context, animationContext, animation, channel, onLoad) { + return this._applyExtensions(animation, "loadAnimationChannel", function (extension) { return extension._loadAnimationChannelAsync && extension._loadAnimationChannelAsync(context, animationContext, animation, channel, onLoad); }); + }; + GLTFLoader.prototype._extensionsLoadSkinAsync = function (context, node, skin) { + return this._applyExtensions(skin, "loadSkin", function (extension) { return extension._loadSkinAsync && extension._loadSkinAsync(context, node, skin); }); + }; + GLTFLoader.prototype._extensionsLoadUriAsync = function (context, property, uri) { + return this._applyExtensions(property, "loadUri", function (extension) { return extension._loadUriAsync && extension._loadUriAsync(context, property, uri); }); + }; + GLTFLoader.prototype._extensionsLoadBufferViewAsync = function (context, bufferView) { + return this._applyExtensions(bufferView, "loadBufferView", function (extension) { return extension.loadBufferViewAsync && extension.loadBufferViewAsync(context, bufferView); }); + }; + GLTFLoader.prototype._extensionsLoadBufferAsync = function (context, buffer, byteOffset, byteLength) { + return this._applyExtensions(buffer, "loadBuffer", function (extension) { return extension.loadBufferAsync && extension.loadBufferAsync(context, buffer, byteOffset, byteLength); }); + }; + /** + * Helper method called by a loader extension to load an glTF extension. + * @param context The context when loading the asset + * @param property The glTF property to load the extension from + * @param extensionName The name of the extension to load + * @param actionAsync The action to run + * @returns The promise returned by actionAsync or null if the extension does not exist + */ + GLTFLoader.LoadExtensionAsync = function (context, property, extensionName, actionAsync) { + if (!property.extensions) { + return null; + } + var extensions = property.extensions; + var extension = extensions[extensionName]; + if (!extension) { + return null; + } + return actionAsync("".concat(context, "/extensions/").concat(extensionName), extension); + }; + /** + * Helper method called by a loader extension to load a glTF extra. + * @param context The context when loading the asset + * @param property The glTF property to load the extra from + * @param extensionName The name of the extension to load + * @param actionAsync The action to run + * @returns The promise returned by actionAsync or null if the extra does not exist + */ + GLTFLoader.LoadExtraAsync = function (context, property, extensionName, actionAsync) { + if (!property.extras) { + return null; + } + var extras = property.extras; + var extra = extras[extensionName]; + if (!extra) { + return null; + } + return actionAsync("".concat(context, "/extras/").concat(extensionName), extra); + }; + /** + * Checks for presence of an extension. + * @param name The name of the extension to check + * @returns A boolean indicating the presence of the given extension name in `extensionsUsed` + */ + GLTFLoader.prototype.isExtensionUsed = function (name) { + return !!this._gltf.extensionsUsed && this._gltf.extensionsUsed.indexOf(name) !== -1; + }; + /** + * Increments the indentation level and logs a message. + * @param message The message to log + */ + GLTFLoader.prototype.logOpen = function (message) { + this._parent._logOpen(message); + }; + /** + * Decrements the indentation level. + */ + GLTFLoader.prototype.logClose = function () { + this._parent._logClose(); + }; + /** + * Logs a message + * @param message The message to log + */ + GLTFLoader.prototype.log = function (message) { + this._parent._log(message); + }; + /** + * Starts a performance counter. + * @param counterName The name of the performance counter + */ + GLTFLoader.prototype.startPerformanceCounter = function (counterName) { + this._parent._startPerformanceCounter(counterName); + }; + /** + * Ends a performance counter. + * @param counterName The name of the performance counter + */ + GLTFLoader.prototype.endPerformanceCounter = function (counterName) { + this._parent._endPerformanceCounter(counterName); + }; + GLTFLoader._RegisteredExtensions = {}; + /** + * The default glTF sampler. + */ + GLTFLoader.DefaultSampler = { index: -1 }; + return GLTFLoader; +}()); +_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFFileLoader._CreateGLTF2Loader = function (parent) { return new GLTFLoader(parent); }; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts": +/*!****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ AnimationPropertyInfo: () => (/* binding */ AnimationPropertyInfo), +/* harmony export */ TransformNodeAnimationPropertyInfo: () => (/* binding */ TransformNodeAnimationPropertyInfo), +/* harmony export */ WeightAnimationPropertyInfo: () => (/* binding */ WeightAnimationPropertyInfo), +/* harmony export */ getQuaternion: () => (/* binding */ getQuaternion), +/* harmony export */ getVector3: () => (/* binding */ getVector3), +/* harmony export */ getWeights: () => (/* binding */ getWeights), +/* harmony export */ nodeAnimationData: () => (/* binding */ nodeAnimationData) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__); + + + +/** @internal */ +function getVector3(_target, source, offset, scale) { + return babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(source, offset).scaleInPlace(scale); +} +/** @internal */ +function getQuaternion(_target, source, offset, scale) { + return babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(source, offset).scaleInPlace(scale); +} +/** @internal */ +function getWeights(target, source, offset, scale) { + var value = new Array(target._numMorphTargets); + for (var i = 0; i < value.length; i++) { + value[i] = source[offset++] * scale; + } + return value; +} +/** @internal */ +var AnimationPropertyInfo = /** @class */ (function () { + /** @internal */ + function AnimationPropertyInfo(type, name, getValue, getStride) { + this.type = type; + this.name = name; + this.getValue = getValue; + this.getStride = getStride; + } + AnimationPropertyInfo.prototype._buildAnimation = function (name, fps, keys) { + var babylonAnimation = new babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation(name, this.name, fps, this.type); + babylonAnimation.setKeys(keys); + return babylonAnimation; + }; + return AnimationPropertyInfo; +}()); + +/** @internal */ +var TransformNodeAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__extends)(TransformNodeAnimationPropertyInfo, _super); + function TransformNodeAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + TransformNodeAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + callback(target._babylonTransformNode, this._buildAnimation(name, fps, keys)); + }; + return TransformNodeAnimationPropertyInfo; +}(AnimationPropertyInfo)); + +/** @internal */ +var WeightAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__extends)(WeightAnimationPropertyInfo, _super); + function WeightAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + WeightAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + if (target._numMorphTargets) { + var _loop_1 = function (targetIndex) { + var babylonAnimation = new babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation("".concat(name, "_").concat(targetIndex), this_1.name, fps, this_1.type); + babylonAnimation.setKeys(keys.map(function (key) { return ({ + frame: key.frame, + inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined, + value: key.value[targetIndex], + outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined, + interpolation: key.interpolation, + }); })); + if (target._primitiveBabylonMeshes) { + for (var _i = 0, _a = target._primitiveBabylonMeshes; _i < _a.length; _i++) { + var babylonMesh = _a[_i]; + if (babylonMesh.morphTargetManager) { + var morphTarget = babylonMesh.morphTargetManager.getTarget(targetIndex); + var babylonAnimationClone = babylonAnimation.clone(); + morphTarget.animations.push(babylonAnimationClone); + callback(morphTarget, babylonAnimationClone); + } + } + } + }; + var this_1 = this; + for (var targetIndex = 0; targetIndex < target._numMorphTargets; targetIndex++) { + _loop_1(targetIndex); + } + } + }; + return WeightAnimationPropertyInfo; +}(AnimationPropertyInfo)); + +/** @internal */ +var nodeAnimationData = { + translation: [new TransformNodeAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_VECTOR3, "position", getVector3, function () { return 3; })], + rotation: [new TransformNodeAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_QUATERNION, "rotationQuaternion", getQuaternion, function () { return 4; })], + scale: [new TransformNodeAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_VECTOR3, "scaling", getVector3, function () { return 3; })], + weights: [new WeightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "influence", getWeights, function (target) { return target._numMorphTargets; })], +}; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoaderExtension.ts": +/*!****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoaderExtension.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts": +/*!*****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts ***! + \*****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/index.ts": +/*!**************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/index.ts ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ArrayItem: () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem), +/* harmony export */ EXT_lights_image_based: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_lights_image_based), +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_mesh_gpu_instancing), +/* harmony export */ EXT_meshopt_compression: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_meshopt_compression), +/* harmony export */ EXT_texture_webp: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_texture_webp), +/* harmony export */ ExtrasAsMetadata: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.ExtrasAsMetadata), +/* harmony export */ GLTFLoader: () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader), +/* harmony export */ KHR_animation_pointer: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_animation_pointer), +/* harmony export */ KHR_draco_mesh_compression: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_draco_mesh_compression), +/* harmony export */ KHR_interactivity: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_interactivity), +/* harmony export */ KHR_lights: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_lights), +/* harmony export */ KHR_materials_anisotropy: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_anisotropy), +/* harmony export */ KHR_materials_clearcoat: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_clearcoat), +/* harmony export */ KHR_materials_dispersion: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_dispersion), +/* harmony export */ KHR_materials_emissive_strength: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_emissive_strength), +/* harmony export */ KHR_materials_ior: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_ior), +/* harmony export */ KHR_materials_iridescence: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_iridescence), +/* harmony export */ KHR_materials_pbrSpecularGlossiness: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_pbrSpecularGlossiness), +/* harmony export */ KHR_materials_sheen: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_sheen), +/* harmony export */ KHR_materials_specular: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_specular), +/* harmony export */ KHR_materials_translucency: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_translucency), +/* harmony export */ KHR_materials_transmission: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_transmission), +/* harmony export */ KHR_materials_unlit: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_unlit), +/* harmony export */ KHR_materials_variants: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_variants), +/* harmony export */ KHR_materials_volume: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_volume), +/* harmony export */ KHR_mesh_quantization: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_mesh_quantization), +/* harmony export */ KHR_texture_basisu: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_texture_basisu), +/* harmony export */ KHR_texture_transform: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_texture_transform), +/* harmony export */ KHR_xmp_json_ld: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_xmp_json_ld), +/* harmony export */ MSFT_audio_emitter: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_audio_emitter), +/* harmony export */ MSFT_lod: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_lod), +/* harmony export */ MSFT_minecraftMesh: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_minecraftMesh), +/* harmony export */ MSFT_sRGBFactors: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_sRGBFactors) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var _glTFLoaderExtension__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoaderExtension */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderExtension.ts"); +/* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts"); +/* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Extensions/index */ "../../../dev/loaders/src/glTF/2.0/Extensions/index.ts"); +/* eslint-disable import/no-internal-modules */ + + + + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/glTFFileLoader.ts": +/*!*******************************************************!*\ + !*** ../../../dev/loaders/src/glTF/glTFFileLoader.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFFileLoader: () => (/* binding */ GLTFFileLoader), +/* harmony export */ GLTFLoaderAnimationStartMode: () => (/* binding */ GLTFLoaderAnimationStartMode), +/* harmony export */ GLTFLoaderCoordinateSystemMode: () => (/* binding */ GLTFLoaderCoordinateSystemMode), +/* harmony export */ GLTFLoaderState: () => (/* binding */ GLTFLoaderState) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/error */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFValidation */ "../../../dev/loaders/src/glTF/glTFValidation.ts"); + + + + + + + + + +function readAsync(arrayBuffer, byteOffset, byteLength) { + try { + return Promise.resolve(new Uint8Array(arrayBuffer, byteOffset, byteLength)); + } + catch (e) { + return Promise.reject(e); + } +} +function readViewAsync(arrayBufferView, byteOffset, byteLength) { + try { + if (byteOffset < 0 || byteOffset >= arrayBufferView.byteLength) { + throw new RangeError("Offset is out of range."); + } + if (byteOffset + byteLength > arrayBufferView.byteLength) { + throw new RangeError("Length is out of range."); + } + return Promise.resolve(new Uint8Array(arrayBufferView.buffer, arrayBufferView.byteOffset + byteOffset, byteLength)); + } + catch (e) { + return Promise.reject(e); + } +} +/** + * Mode that determines the coordinate system to use. + */ +var GLTFLoaderCoordinateSystemMode; +(function (GLTFLoaderCoordinateSystemMode) { + /** + * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene. + */ + GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["AUTO"] = 0] = "AUTO"; + /** + * Sets the useRightHandedSystem flag on the scene. + */ + GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["FORCE_RIGHT_HANDED"] = 1] = "FORCE_RIGHT_HANDED"; +})(GLTFLoaderCoordinateSystemMode || (GLTFLoaderCoordinateSystemMode = {})); +/** + * Mode that determines what animations will start. + */ +var GLTFLoaderAnimationStartMode; +(function (GLTFLoaderAnimationStartMode) { + /** + * No animation will start. + */ + GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["NONE"] = 0] = "NONE"; + /** + * The first animation will start. + */ + GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["FIRST"] = 1] = "FIRST"; + /** + * All animations will start. + */ + GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["ALL"] = 2] = "ALL"; +})(GLTFLoaderAnimationStartMode || (GLTFLoaderAnimationStartMode = {})); +/** + * Loader state. + */ +var GLTFLoaderState; +(function (GLTFLoaderState) { + /** + * The asset is loading. + */ + GLTFLoaderState[GLTFLoaderState["LOADING"] = 0] = "LOADING"; + /** + * The asset is ready for rendering. + */ + GLTFLoaderState[GLTFLoaderState["READY"] = 1] = "READY"; + /** + * The asset is completely loaded. + */ + GLTFLoaderState[GLTFLoaderState["COMPLETE"] = 2] = "COMPLETE"; +})(GLTFLoaderState || (GLTFLoaderState = {})); +/** + * File loader for loading glTF files into a scene. + */ +var GLTFFileLoader = /** @class */ (function () { + function GLTFFileLoader() { + // -------------- + // Common options + // -------------- + /** + * Raised when the asset has been parsed + */ + this.onParsedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + // ---------- + // V2 options + // ---------- + /** + * The coordinate system mode. Defaults to AUTO. + */ + this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO; + /** + * The animation start mode. Defaults to FIRST. + */ + this.animationStartMode = GLTFLoaderAnimationStartMode.FIRST; + /** + * Defines if the loader should compile materials before raising the success callback. Defaults to false. + */ + this.compileMaterials = false; + /** + * Defines if the loader should also compile materials with clip planes. Defaults to false. + */ + this.useClipPlane = false; + /** + * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false. + */ + this.compileShadowGenerators = false; + /** + * Defines if the Alpha blended materials are only applied as coverage. + * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials. + * If true, no extra effects are applied to transparent pixels. + */ + this.transparencyAsCoverage = false; + /** + * Defines if the loader should use range requests when load binary glTF files from HTTP. + * Enabling will disable offline support and glTF validator. + * Defaults to false. + */ + this.useRangeRequests = false; + /** + * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true. + */ + this.createInstances = true; + /** + * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false. + */ + this.alwaysComputeBoundingBox = false; + /** + * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false. + */ + this.loadAllMaterials = false; + /** + * If true, load only the materials defined in the file. Defaults to false. + */ + this.loadOnlyMaterials = false; + /** + * If true, do not load any materials defined in the file. Defaults to false. + */ + this.skipMaterials = false; + /** + * If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true. + */ + this.useSRGBBuffers = true; + /** + * When loading glTF animations, which are defined in seconds, target them to this FPS. Defaults to 60. + */ + this.targetFps = 60; + /** + * Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using `skin.skeleton`. Defaults to false. + * Set this to true if loading assets with invalid `skin.skeleton` values. + */ + this.alwaysComputeSkeletonRootNode = false; + /** + * Function called before loading a url referenced by the asset. + * @param url url referenced by the asset + * @returns Async url to load + */ + this.preprocessUrlAsync = function (url) { return Promise.resolve(url); }; + /** + * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh. + * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...) + */ + this.onMeshLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Callback raised when the loader creates a skin after parsing the glTF properties of the skin node. + * @see https://doc.babylonjs.com/features/featuresDeepDive/importers/glTF/glTFSkinning#ignoring-the-transform-of-the-skinned-mesh + * @param node - the transform node that corresponds to the original glTF skin node used for animations + * @param skinnedNode - the transform node that is the skinned mesh itself or the parent of the skinned meshes + */ + this.onSkinLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the loader creates a texture after parsing the glTF properties of the texture. + */ + this.onTextureLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the loader creates a material after parsing the glTF properties of the material. + */ + this.onMaterialLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the loader creates a camera after parsing the glTF properties of the camera. + */ + this.onCameraLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the asset is completely loaded, immediately before the loader is disposed. + * For assets with LODs, raised when all of the LODs are complete. + * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise. + */ + this.onCompleteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when an error occurs. + */ + this.onErrorObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised after the loader is disposed. + */ + this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised after a loader extension is created. + * Set additional options for a loader extension in this event. + */ + this.onExtensionLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Defines if the loader should validate the asset. + */ + this.validate = false; + /** + * Observable raised after validation when validate is set to true. The event data is the result of the validation. + */ + this.onValidatedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._loader = null; + this._state = null; + this._requests = new Array(); + /** + * Name of the loader ("gltf") + */ + this.name = "gltf"; + /** @internal */ + this.extensions = { + ".gltf": { isBinary: false }, + ".glb": { isBinary: true }, + }; + /** + * Observable raised when the loader state changes. + */ + this.onLoaderStateChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._logIndentLevel = 0; + this._loggingEnabled = false; + /** @internal */ + this._log = this._logDisabled; + this._capturePerformanceCounters = false; + /** @internal */ + this._startPerformanceCounter = this._startPerformanceCounterDisabled; + /** @internal */ + this._endPerformanceCounter = this._endPerformanceCounterDisabled; + } + Object.defineProperty(GLTFFileLoader.prototype, "onParsed", { + /** + * Raised when the asset has been parsed + */ + set: function (callback) { + if (this._onParsedObserver) { + this.onParsedObservable.remove(this._onParsedObserver); + } + this._onParsedObserver = this.onParsedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onMeshLoaded", { + /** + * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh. + * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...) + */ + set: function (callback) { + if (this._onMeshLoadedObserver) { + this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver); + } + this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onTextureLoaded", { + /** + * Callback raised when the loader creates a texture after parsing the glTF properties of the texture. + */ + set: function (callback) { + if (this._onTextureLoadedObserver) { + this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver); + } + this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onMaterialLoaded", { + /** + * Callback raised when the loader creates a material after parsing the glTF properties of the material. + */ + set: function (callback) { + if (this._onMaterialLoadedObserver) { + this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver); + } + this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onCameraLoaded", { + /** + * Callback raised when the loader creates a camera after parsing the glTF properties of the camera. + */ + set: function (callback) { + if (this._onCameraLoadedObserver) { + this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver); + } + this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onComplete", { + /** + * Callback raised when the asset is completely loaded, immediately before the loader is disposed. + * For assets with LODs, raised when all of the LODs are complete. + * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise. + */ + set: function (callback) { + if (this._onCompleteObserver) { + this.onCompleteObservable.remove(this._onCompleteObserver); + } + this._onCompleteObserver = this.onCompleteObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onError", { + /** + * Callback raised when an error occurs. + */ + set: function (callback) { + if (this._onErrorObserver) { + this.onErrorObservable.remove(this._onErrorObserver); + } + this._onErrorObserver = this.onErrorObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onDispose", { + /** + * Callback raised after the loader is disposed. + */ + set: function (callback) { + if (this._onDisposeObserver) { + this.onDisposeObservable.remove(this._onDisposeObserver); + } + this._onDisposeObserver = this.onDisposeObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onExtensionLoaded", { + /** + * Callback raised after a loader extension is created. + */ + set: function (callback) { + if (this._onExtensionLoadedObserver) { + this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver); + } + this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "loggingEnabled", { + /** + * Defines if the loader logging is enabled. + */ + get: function () { + return this._loggingEnabled; + }, + set: function (value) { + if (this._loggingEnabled === value) { + return; + } + this._loggingEnabled = value; + if (this._loggingEnabled) { + this._log = this._logEnabled; + } + else { + this._log = this._logDisabled; + } + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "capturePerformanceCounters", { + /** + * Defines if the loader should capture performance counters. + */ + get: function () { + return this._capturePerformanceCounters; + }, + set: function (value) { + if (this._capturePerformanceCounters === value) { + return; + } + this._capturePerformanceCounters = value; + if (this._capturePerformanceCounters) { + this._startPerformanceCounter = this._startPerformanceCounterEnabled; + this._endPerformanceCounter = this._endPerformanceCounterEnabled; + } + else { + this._startPerformanceCounter = this._startPerformanceCounterDisabled; + this._endPerformanceCounter = this._endPerformanceCounterDisabled; + } + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onValidated", { + /** + * Callback raised after a loader extension is created. + */ + set: function (callback) { + if (this._onValidatedObserver) { + this.onValidatedObservable.remove(this._onValidatedObserver); + } + this._onValidatedObserver = this.onValidatedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + /** + * Disposes the loader, releases resources during load, and cancels any outstanding requests. + */ + GLTFFileLoader.prototype.dispose = function () { + if (this._loader) { + this._loader.dispose(); + this._loader = null; + } + for (var _i = 0, _a = this._requests; _i < _a.length; _i++) { + var request = _a[_i]; + request.abort(); + } + this._requests.length = 0; + delete this._progressCallback; + this.preprocessUrlAsync = function (url) { return Promise.resolve(url); }; + this.onMeshLoadedObservable.clear(); + this.onSkinLoadedObservable.clear(); + this.onTextureLoadedObservable.clear(); + this.onMaterialLoadedObservable.clear(); + this.onCameraLoadedObservable.clear(); + this.onCompleteObservable.clear(); + this.onExtensionLoadedObservable.clear(); + this.onDisposeObservable.notifyObservers(undefined); + this.onDisposeObservable.clear(); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.loadFile = function (scene, fileOrUrl, rootUrl, onSuccess, onProgress, useArrayBuffer, onError, name) { + var _this = this; + if (ArrayBuffer.isView(fileOrUrl)) { + this._loadBinary(scene, fileOrUrl, rootUrl, onSuccess, onError, name); + return null; + } + this._progressCallback = onProgress; + var fileName = fileOrUrl.name || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.GetFilename(fileOrUrl); + if (useArrayBuffer) { + if (this.useRangeRequests) { + if (this.validate) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("glTF validation is not supported when range requests are enabled"); + } + var fileRequest_1 = { + abort: function () { }, + onCompleteObservable: new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(), + }; + var dataBuffer = { + readAsync: function (byteOffset, byteLength) { + return new Promise(function (resolve, reject) { + _this._loadFile(scene, fileOrUrl, function (data) { + resolve(new Uint8Array(data)); + }, true, function (error) { + reject(error); + }, function (webRequest) { + webRequest.setRequestHeader("Range", "bytes=".concat(byteOffset, "-").concat(byteOffset + byteLength - 1)); + }); + }); + }, + byteLength: 0, + }; + this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader(dataBuffer)).then(function (loaderData) { + fileRequest_1.onCompleteObservable.notifyObservers(fileRequest_1); + onSuccess(loaderData); + }, onError ? function (error) { return onError(undefined, error); } : undefined); + return fileRequest_1; + } + return this._loadFile(scene, fileOrUrl, function (data) { + _this._validate(scene, new Uint8Array(data, 0, data.byteLength), rootUrl, fileName); + _this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({ + readAsync: function (byteOffset, byteLength) { return readAsync(data, byteOffset, byteLength); }, + byteLength: data.byteLength, + })).then(function (loaderData) { + onSuccess(loaderData); + }, onError ? function (error) { return onError(undefined, error); } : undefined); + }, true, onError); + } + else { + return this._loadFile(scene, fileOrUrl, function (data) { + _this._validate(scene, data, rootUrl, fileName); + onSuccess({ json: _this._parseJson(data) }); + }, false, onError); + } + }; + GLTFFileLoader.prototype._loadBinary = function (scene, data, rootUrl, onSuccess, onError, fileName) { + this._validate(scene, new Uint8Array(data.buffer, data.byteOffset, data.byteLength), rootUrl, fileName); + this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({ + readAsync: function (byteOffset, byteLength) { return readViewAsync(data, byteOffset, byteLength); }, + byteLength: data.byteLength, + })).then(function (loaderData) { + onSuccess(loaderData); + }, onError ? function (error) { return onError(undefined, error); } : undefined); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fileName) { + var _this = this; + return Promise.resolve().then(function () { + _this.onParsedObservable.notifyObservers(data); + _this.onParsedObservable.clear(); + _this._log("Loading ".concat(fileName || "")); + _this._loader = _this._getLoader(data); + return _this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) { + var _this = this; + return Promise.resolve().then(function () { + _this.onParsedObservable.notifyObservers(data); + _this.onParsedObservable.clear(); + _this._log("Loading ".concat(fileName || "")); + _this._loader = _this._getLoader(data); + return _this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress, fileName) { + var _this = this; + return Promise.resolve().then(function () { + _this.onParsedObservable.notifyObservers(data); + _this.onParsedObservable.clear(); + _this._log("Loading ".concat(fileName || "")); + _this._loader = _this._getLoader(data); + // Prepare the asset container. + var container = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.AssetContainer(scene); + // Get materials/textures when loading to add to container + var materials = []; + _this.onMaterialLoadedObservable.add(function (material) { + materials.push(material); + }); + var textures = []; + _this.onTextureLoadedObservable.add(function (texture) { + textures.push(texture); + }); + var cameras = []; + _this.onCameraLoadedObservable.add(function (camera) { + cameras.push(camera); + }); + var morphTargetManagers = []; + _this.onMeshLoadedObservable.add(function (mesh) { + if (mesh.morphTargetManager) { + morphTargetManagers.push(mesh.morphTargetManager); + } + }); + return _this._loader.importMeshAsync(null, scene, container, data, rootUrl, onProgress, fileName).then(function (result) { + Array.prototype.push.apply(container.geometries, result.geometries); + Array.prototype.push.apply(container.meshes, result.meshes); + Array.prototype.push.apply(container.particleSystems, result.particleSystems); + Array.prototype.push.apply(container.skeletons, result.skeletons); + Array.prototype.push.apply(container.animationGroups, result.animationGroups); + Array.prototype.push.apply(container.materials, materials); + Array.prototype.push.apply(container.textures, textures); + Array.prototype.push.apply(container.lights, result.lights); + Array.prototype.push.apply(container.transformNodes, result.transformNodes); + Array.prototype.push.apply(container.cameras, cameras); + Array.prototype.push.apply(container.morphTargetManagers, morphTargetManagers); + return container; + }); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.canDirectLoad = function (data) { + return ((data.indexOf("asset") !== -1 && data.indexOf("version") !== -1) || + data.startsWith("data:base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat. + data.startsWith("data:;base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("data:application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("data:model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded)); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.directLoad = function (scene, data) { + if (data.startsWith("base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat. + data.startsWith(";base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded)) { + var arrayBuffer_1 = (0,babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DecodeBase64UrlToBinary)(data); + this._validate(scene, new Uint8Array(arrayBuffer_1, 0, arrayBuffer_1.byteLength)); + return this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({ + readAsync: function (byteOffset, byteLength) { return readAsync(arrayBuffer_1, byteOffset, byteLength); }, + byteLength: arrayBuffer_1.byteLength, + })); + } + this._validate(scene, data); + return Promise.resolve({ json: this._parseJson(data) }); + }; + /** @internal */ + GLTFFileLoader.prototype.createPlugin = function () { + return new GLTFFileLoader(); + }; + Object.defineProperty(GLTFFileLoader.prototype, "loaderState", { + /** + * The loader state or null if the loader is not active. + */ + get: function () { + return this._state; + }, + enumerable: false, + configurable: true + }); + /** + * Returns a promise that resolves when the asset is completely loaded. + * @returns a promise that resolves when the asset is completely loaded. + */ + GLTFFileLoader.prototype.whenCompleteAsync = function () { + var _this = this; + return new Promise(function (resolve, reject) { + _this.onCompleteObservable.addOnce(function () { + resolve(); + }); + _this.onErrorObservable.addOnce(function (reason) { + reject(reason); + }); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype._setState = function (state) { + if (this._state === state) { + return; + } + this._state = state; + this.onLoaderStateChangedObservable.notifyObservers(this._state); + this._log(GLTFLoaderState[this._state]); + }; + /** + * @internal + */ + GLTFFileLoader.prototype._loadFile = function (scene, fileOrUrl, onSuccess, useArrayBuffer, onError, onOpened) { + var _this = this; + var request = scene._loadFile(fileOrUrl, onSuccess, function (event) { + _this._onProgress(event, request); + }, true, useArrayBuffer, onError, onOpened); + request.onCompleteObservable.add(function (request) { + _this._requests.splice(_this._requests.indexOf(request), 1); + }); + this._requests.push(request); + return request; + }; + GLTFFileLoader.prototype._onProgress = function (event, request) { + if (!this._progressCallback) { + return; + } + request._lengthComputable = event.lengthComputable; + request._loaded = event.loaded; + request._total = event.total; + var lengthComputable = true; + var loaded = 0; + var total = 0; + for (var _i = 0, _a = this._requests; _i < _a.length; _i++) { + var request_1 = _a[_i]; + if (request_1._lengthComputable === undefined || request_1._loaded === undefined || request_1._total === undefined) { + return; + } + lengthComputable = lengthComputable && request_1._lengthComputable; + loaded += request_1._loaded; + total += request_1._total; + } + this._progressCallback({ + lengthComputable: lengthComputable, + loaded: loaded, + total: lengthComputable ? total : 0, + }); + }; + GLTFFileLoader.prototype._validate = function (scene, data, rootUrl, fileName) { + var _this = this; + if (rootUrl === void 0) { rootUrl = ""; } + if (fileName === void 0) { fileName = ""; } + if (!this.validate) { + return; + } + this._startPerformanceCounter("Validate JSON"); + _glTFValidation__WEBPACK_IMPORTED_MODULE_1__.GLTFValidation.ValidateAsync(data, rootUrl, fileName, function (uri) { + return _this.preprocessUrlAsync(rootUrl + uri).then(function (url) { + return scene._loadFileAsync(url, undefined, true, true).then(function (data) { + return new Uint8Array(data, 0, data.byteLength); + }); + }); + }).then(function (result) { + _this._endPerformanceCounter("Validate JSON"); + _this.onValidatedObservable.notifyObservers(result); + _this.onValidatedObservable.clear(); + }, function (reason) { + _this._endPerformanceCounter("Validate JSON"); + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Failed to validate: ".concat(reason.message)); + _this.onValidatedObservable.clear(); + }); + }; + GLTFFileLoader.prototype._getLoader = function (loaderData) { + var asset = loaderData.json.asset || {}; + this._log("Asset version: ".concat(asset.version)); + asset.minVersion && this._log("Asset minimum version: ".concat(asset.minVersion)); + asset.generator && this._log("Asset generator: ".concat(asset.generator)); + var version = GLTFFileLoader._parseVersion(asset.version); + if (!version) { + throw new Error("Invalid version: " + asset.version); + } + if (asset.minVersion !== undefined) { + var minVersion = GLTFFileLoader._parseVersion(asset.minVersion); + if (!minVersion) { + throw new Error("Invalid minimum version: " + asset.minVersion); + } + if (GLTFFileLoader._compareVersion(minVersion, { major: 2, minor: 0 }) > 0) { + throw new Error("Incompatible minimum version: " + asset.minVersion); + } + } + var createLoaders = { + 1: GLTFFileLoader._CreateGLTF1Loader, + 2: GLTFFileLoader._CreateGLTF2Loader, + }; + var createLoader = createLoaders[version.major]; + if (!createLoader) { + throw new Error("Unsupported version: " + asset.version); + } + return createLoader(this); + }; + GLTFFileLoader.prototype._parseJson = function (json) { + this._startPerformanceCounter("Parse JSON"); + this._log("JSON length: ".concat(json.length)); + var parsed = JSON.parse(json); + this._endPerformanceCounter("Parse JSON"); + return parsed; + }; + GLTFFileLoader.prototype._unpackBinaryAsync = function (dataReader) { + var _this = this; + this._startPerformanceCounter("Unpack Binary"); + // Read magic + version + length + json length + json format + return dataReader.loadAsync(20).then(function () { + var Binary = { + Magic: 0x46546c67, + }; + var magic = dataReader.readUint32(); + if (magic !== Binary.Magic) { + throw new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.RuntimeError("Unexpected magic: " + magic, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.ErrorCodes.GLTFLoaderUnexpectedMagicError); + } + var version = dataReader.readUint32(); + if (_this.loggingEnabled) { + _this._log("Binary version: ".concat(version)); + } + var length = dataReader.readUint32(); + if (!_this.useRangeRequests && length !== dataReader.buffer.byteLength) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Length in header does not match actual data length: ".concat(length, " != ").concat(dataReader.buffer.byteLength)); + } + var unpacked; + switch (version) { + case 1: { + unpacked = _this._unpackBinaryV1Async(dataReader, length); + break; + } + case 2: { + unpacked = _this._unpackBinaryV2Async(dataReader, length); + break; + } + default: { + throw new Error("Unsupported version: " + version); + } + } + _this._endPerformanceCounter("Unpack Binary"); + return unpacked; + }); + }; + GLTFFileLoader.prototype._unpackBinaryV1Async = function (dataReader, length) { + var ContentFormat = { + JSON: 0, + }; + var contentLength = dataReader.readUint32(); + var contentFormat = dataReader.readUint32(); + if (contentFormat !== ContentFormat.JSON) { + throw new Error("Unexpected content format: ".concat(contentFormat)); + } + var bodyLength = length - dataReader.byteOffset; + var data = { json: this._parseJson(dataReader.readString(contentLength)), bin: null }; + if (bodyLength !== 0) { + var startByteOffset_1 = dataReader.byteOffset; + data.bin = { + readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_1 + byteOffset, byteLength); }, + byteLength: bodyLength, + }; + } + return Promise.resolve(data); + }; + GLTFFileLoader.prototype._unpackBinaryV2Async = function (dataReader, length) { + var _this = this; + var ChunkFormat = { + JSON: 0x4e4f534a, + BIN: 0x004e4942, + }; + // Read the JSON chunk header. + var chunkLength = dataReader.readUint32(); + var chunkFormat = dataReader.readUint32(); + if (chunkFormat !== ChunkFormat.JSON) { + throw new Error("First chunk format is not JSON"); + } + // Bail if there are no other chunks. + if (dataReader.byteOffset + chunkLength === length) { + return dataReader.loadAsync(chunkLength).then(function () { + return { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null }; + }); + } + // Read the JSON chunk and the length and type of the next chunk. + return dataReader.loadAsync(chunkLength + 8).then(function () { + var data = { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null }; + var readAsync = function () { + var chunkLength = dataReader.readUint32(); + var chunkFormat = dataReader.readUint32(); + switch (chunkFormat) { + case ChunkFormat.JSON: { + throw new Error("Unexpected JSON chunk"); + } + case ChunkFormat.BIN: { + var startByteOffset_2 = dataReader.byteOffset; + data.bin = { + readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_2 + byteOffset, byteLength); }, + byteLength: chunkLength, + }; + dataReader.skipBytes(chunkLength); + break; + } + default: { + // ignore unrecognized chunkFormat + dataReader.skipBytes(chunkLength); + break; + } + } + if (dataReader.byteOffset !== length) { + return dataReader.loadAsync(8).then(readAsync); + } + return Promise.resolve(data); + }; + return readAsync(); + }); + }; + GLTFFileLoader._parseVersion = function (version) { + if (version === "1.0" || version === "1.0.1") { + return { + major: 1, + minor: 0, + }; + } + var match = (version + "").match(/^(\d+)\.(\d+)/); + if (!match) { + return null; + } + return { + major: parseInt(match[1]), + minor: parseInt(match[2]), + }; + }; + GLTFFileLoader._compareVersion = function (a, b) { + if (a.major > b.major) { + return 1; + } + if (a.major < b.major) { + return -1; + } + if (a.minor > b.minor) { + return 1; + } + if (a.minor < b.minor) { + return -1; + } + return 0; + }; + /** + * @internal + */ + GLTFFileLoader.prototype._logOpen = function (message) { + this._log(message); + this._logIndentLevel++; + }; + /** @internal */ + GLTFFileLoader.prototype._logClose = function () { + --this._logIndentLevel; + }; + GLTFFileLoader.prototype._logEnabled = function (message) { + var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2); + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Log("".concat(spaces).concat(message)); + }; + GLTFFileLoader.prototype._logDisabled = function (message) { }; + GLTFFileLoader.prototype._startPerformanceCounterEnabled = function (counterName) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.StartPerformanceCounter(counterName); + }; + GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) { }; + GLTFFileLoader.prototype._endPerformanceCounterEnabled = function (counterName) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.EndPerformanceCounter(counterName); + }; + GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) { }; + // ---------- + // V1 options + // ---------- + /** + * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders. + * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled. + * Defaults to true. + * @internal + */ + GLTFFileLoader.IncrementalLoading = true; + /** + * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters. + * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates. + * @internal + */ + GLTFFileLoader.HomogeneousCoordinates = false; + GLTFFileLoader._MagicBase64Encoded = "Z2xURg"; // "glTF" base64 encoded (without the quotes!) + GLTFFileLoader._logSpaces = " "; + return GLTFFileLoader; +}()); +if (babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.SceneLoader) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.SceneLoader.RegisterPlugin(new GLTFFileLoader()); +} + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/glTFValidation.ts": +/*!*******************************************************!*\ + !*** ../../../dev/loaders/src/glTF/glTFValidation.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFValidation: () => (/* binding */ GLTFValidation) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__); + +function validateAsync(data, rootUrl, fileName, getExternalResource) { + var options = { + externalResourceFunction: getExternalResource, + }; + if (fileName) { + options.uri = rootUrl === "file:" ? fileName : rootUrl + fileName; + } + return ArrayBuffer.isView(data) ? GLTFValidator.validateBytes(data, options) : GLTFValidator.validateString(data, options); +} +/** + * The worker function that gets converted to a blob url to pass into a worker. + */ +function workerFunc() { + var pendingExternalResources = []; + onmessage = function (message) { + var data = message.data; + switch (data.id) { + case "init": { + importScripts(data.url); + break; + } + case "validate": { + validateAsync(data.data, data.rootUrl, data.fileName, function (uri) { + return new Promise(function (resolve, reject) { + var index = pendingExternalResources.length; + pendingExternalResources.push({ resolve: resolve, reject: reject }); + postMessage({ id: "getExternalResource", index: index, uri: uri }); + }); + }).then(function (value) { + postMessage({ id: "validate.resolve", value: value }); + }, function (reason) { + postMessage({ id: "validate.reject", reason: reason }); + }); + break; + } + case "getExternalResource.resolve": { + pendingExternalResources[data.index].resolve(data.value); + break; + } + case "getExternalResource.reject": { + pendingExternalResources[data.index].reject(data.reason); + break; + } + } + }; +} +/** + * glTF validation + */ +var GLTFValidation = /** @class */ (function () { + function GLTFValidation() { + } + /** + * Validate a glTF asset using the glTF-Validator. + * @param data The JSON of a glTF or the array buffer of a binary glTF + * @param rootUrl The root url for the glTF + * @param fileName The file name for the glTF + * @param getExternalResource The callback to get external resources for the glTF validator + * @returns A promise that resolves with the glTF validation results once complete + */ + GLTFValidation.ValidateAsync = function (data, rootUrl, fileName, getExternalResource) { + var _this = this; + if (typeof Worker === "function") { + return new Promise(function (resolve, reject) { + var workerContent = "".concat(validateAsync, "(").concat(workerFunc, ")()"); + var workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: "application/javascript" })); + var worker = new Worker(workerBlobUrl); + var onError = function (error) { + worker.removeEventListener("error", onError); + worker.removeEventListener("message", onMessage); + reject(error); + }; + var onMessage = function (message) { + var data = message.data; + switch (data.id) { + case "getExternalResource": { + getExternalResource(data.uri).then(function (value) { + worker.postMessage({ id: "getExternalResource.resolve", index: data.index, value: value }, [value]); + }, function (reason) { + worker.postMessage({ id: "getExternalResource.reject", index: data.index, reason: reason }); + }); + break; + } + case "validate.resolve": { + worker.removeEventListener("error", onError); + worker.removeEventListener("message", onMessage); + resolve(data.value); + worker.terminate(); + break; + } + case "validate.reject": { + worker.removeEventListener("error", onError); + worker.removeEventListener("message", onMessage); + reject(data.reason); + worker.terminate(); + } + } + }; + worker.addEventListener("error", onError); + worker.addEventListener("message", onMessage); + worker.postMessage({ id: "init", url: babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.GetBabylonScriptURL(_this.Configuration.url) }); + if (ArrayBuffer.isView(data)) { + // Slice the data to avoid copying the whole array buffer. + var slicedData = data.slice(); + worker.postMessage({ id: "validate", data: slicedData, rootUrl: rootUrl, fileName: fileName }, [slicedData.buffer]); + } + else { + worker.postMessage({ id: "validate", data: data, rootUrl: rootUrl, fileName: fileName }); + } + }); + } + else { + if (!this._LoadScriptPromise) { + this._LoadScriptPromise = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.LoadBabylonScriptAsync(this.Configuration.url); + } + return this._LoadScriptPromise.then(function () { + return validateAsync(data, rootUrl, fileName, getExternalResource); + }); + } + }; + /** + * The configuration. Defaults to `{ url: "https://cdn.babylonjs.com/gltf_validator.js" }`. + */ + GLTFValidation.Configuration = { + url: "".concat(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools._DefaultCdnUrl, "/gltf_validator.js"), + }; + return GLTFValidation; +}()); + + +/***/ }), + +/***/ "../../../lts/loaders/src/legacy/legacy-glTF.ts": +/*!******************************************************!*\ + !*** ../../../lts/loaders/src/legacy/legacy-glTF.ts ***! + \******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFFileLoader: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFFileLoader), +/* harmony export */ GLTFLoaderAnimationStartMode: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderAnimationStartMode), +/* harmony export */ GLTFLoaderCoordinateSystemMode: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderCoordinateSystemMode), +/* harmony export */ GLTFLoaderState: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderState), +/* harmony export */ GLTFValidation: () => (/* reexport safe */ loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__.GLTFValidation) +/* harmony export */ }); +/* harmony import */ var loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/glTF/glTFFileLoader */ "../../../dev/loaders/src/glTF/glTFFileLoader.ts"); +/* harmony import */ var loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! loaders/glTF/glTFValidation */ "../../../dev/loaders/src/glTF/glTFValidation.ts"); + + +/** + * This is the entry point for the UMD module. + * The entry point for a future ESM package should be index.ts + */ +var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined; +if (typeof globalObject !== "undefined") { + globalObject.BABYLON = globalObject.BABYLON || {}; + for (var key in loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__) { + globalObject.BABYLON[key] = loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__[key]; + } + for (var key in loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__) { + globalObject.BABYLON[key] = loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__[key]; + } +} + + + + +/***/ }), + +/***/ "../../../lts/loaders/src/legacy/legacy-glTF1.ts": +/*!*******************************************************!*\ + !*** ../../../lts/loaders/src/legacy/legacy-glTF1.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTF1: () => (/* reexport module object */ loaders_glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__) +/* harmony export */ }); +/* harmony import */ var loaders_glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/glTF/1.0/index */ "../../../dev/loaders/src/glTF/1.0/index.ts"); +/* eslint-disable import/no-internal-modules */ + +/** + * This is the entry point for the UMD module. + * The entry point for a future ESM package should be index.ts + */ +var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined; +if (typeof globalObject !== "undefined") { + globalObject.BABYLON = globalObject.BABYLON || {}; + globalObject.BABYLON.GLTF1 = globalObject.BABYLON.GLTF1 || {}; + for (var key in loaders_glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__) { + globalObject.BABYLON.GLTF1[key] = loaders_glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__[key]; + } +} + + + +/***/ }), + +/***/ "../../../lts/loaders/src/legacy/legacy-glTF2.ts": +/*!*******************************************************!*\ + !*** ../../../lts/loaders/src/legacy/legacy-glTF2.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTF2: () => (/* reexport module object */ loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__) +/* harmony export */ }); +/* harmony import */ var loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/glTF/2.0/Extensions/index */ "../../../dev/loaders/src/glTF/2.0/Extensions/index.ts"); +/* harmony import */ var loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! loaders/glTF/2.0/glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts"); +/* harmony import */ var loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! loaders/glTF/2.0/index */ "../../../dev/loaders/src/glTF/2.0/index.ts"); +/* eslint-disable import/no-internal-modules */ + + + +/** + * This is the entry point for the UMD module. + * The entry point for a future ESM package should be index.ts + */ +var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined; +if (typeof globalObject !== "undefined") { + globalObject.BABYLON = globalObject.BABYLON || {}; + var BABYLON_1 = globalObject.BABYLON; + BABYLON_1.GLTF2 = BABYLON_1.GLTF2 || {}; + BABYLON_1.GLTF2.Loader = BABYLON_1.GLTF2.Loader || {}; + BABYLON_1.GLTF2.Loader.Extensions = BABYLON_1.GLTF2.Loader.Extensions || {}; + var keys = []; + for (var key in loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__) { + BABYLON_1.GLTF2.Loader.Extensions[key] = loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__[key]; + keys.push(key); + } + for (var key in loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__) { + BABYLON_1.GLTF2.Loader[key] = loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__[key]; + keys.push(key); + } + for (var key in loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__) { + // Prevent Reassignment. + if (keys.indexOf(key) > -1) { + continue; + } + BABYLON_1.GLTF2[key] = loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__[key]; + } +} + + + +/***/ }), + +/***/ "../../../lts/loaders/src/legacy/legacy-glTFFileLoader.ts": +/*!****************************************************************!*\ + !*** ../../../lts/loaders/src/legacy/legacy-glTFFileLoader.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTF1: () => (/* reexport safe */ _legacy_glTF1__WEBPACK_IMPORTED_MODULE_1__.GLTF1), +/* harmony export */ GLTF2: () => (/* reexport safe */ _legacy_glTF2__WEBPACK_IMPORTED_MODULE_2__.GLTF2), +/* harmony export */ GLTFFileLoader: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFFileLoader), +/* harmony export */ GLTFLoaderAnimationStartMode: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderAnimationStartMode), +/* harmony export */ GLTFLoaderCoordinateSystemMode: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderCoordinateSystemMode), +/* harmony export */ GLTFLoaderState: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderState), +/* harmony export */ GLTFValidation: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFValidation) +/* harmony export */ }); +/* harmony import */ var _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./legacy-glTF */ "../../../lts/loaders/src/legacy/legacy-glTF.ts"); +/* harmony import */ var _legacy_glTF1__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./legacy-glTF1 */ "../../../lts/loaders/src/legacy/legacy-glTF1.ts"); +/* harmony import */ var _legacy_glTF2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./legacy-glTF2 */ "../../../lts/loaders/src/legacy/legacy-glTF2.ts"); +// eslint-disable-next-line import/export + + + + + +/***/ }), + +/***/ "babylonjs/Misc/observable": +/*!****************************************************************************************************!*\ + !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***! + \****************************************************************************************************/ +/***/ ((module) => { + +module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__; + +/***/ }), + +/***/ "../../../../node_modules/tslib/tslib.es6.mjs": +/*!****************************************************!*\ + !*** ../../../../node_modules/tslib/tslib.es6.mjs ***! + \****************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ __addDisposableResource: () => (/* binding */ __addDisposableResource), +/* harmony export */ __assign: () => (/* binding */ __assign), +/* harmony export */ __asyncDelegator: () => (/* binding */ __asyncDelegator), +/* harmony export */ __asyncGenerator: () => (/* binding */ __asyncGenerator), +/* harmony export */ __asyncValues: () => (/* binding */ __asyncValues), +/* harmony export */ __await: () => (/* binding */ __await), +/* harmony export */ __awaiter: () => (/* binding */ __awaiter), +/* harmony export */ __classPrivateFieldGet: () => (/* binding */ __classPrivateFieldGet), +/* harmony export */ __classPrivateFieldIn: () => (/* binding */ __classPrivateFieldIn), +/* harmony export */ __classPrivateFieldSet: () => (/* binding */ __classPrivateFieldSet), +/* harmony export */ __createBinding: () => (/* binding */ __createBinding), +/* harmony export */ __decorate: () => (/* binding */ __decorate), +/* harmony export */ __disposeResources: () => (/* binding */ __disposeResources), +/* harmony export */ __esDecorate: () => (/* binding */ __esDecorate), +/* harmony export */ __exportStar: () => (/* binding */ __exportStar), +/* harmony export */ __extends: () => (/* binding */ __extends), +/* harmony export */ __generator: () => (/* binding */ __generator), +/* harmony export */ __importDefault: () => (/* binding */ __importDefault), +/* harmony export */ __importStar: () => (/* binding */ __importStar), +/* harmony export */ __makeTemplateObject: () => (/* binding */ __makeTemplateObject), +/* harmony export */ __metadata: () => (/* binding */ __metadata), +/* harmony export */ __param: () => (/* binding */ __param), +/* harmony export */ __propKey: () => (/* binding */ __propKey), +/* harmony export */ __read: () => (/* binding */ __read), +/* harmony export */ __rest: () => (/* binding */ __rest), +/* harmony export */ __runInitializers: () => (/* binding */ __runInitializers), +/* harmony export */ __setFunctionName: () => (/* binding */ __setFunctionName), +/* harmony export */ __spread: () => (/* binding */ __spread), +/* harmony export */ __spreadArray: () => (/* binding */ __spreadArray), +/* harmony export */ __spreadArrays: () => (/* binding */ __spreadArrays), +/* harmony export */ __values: () => (/* binding */ __values), +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise, SuppressedError, Symbol */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + } + return __assign.apply(this, arguments); +} + +function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +} + +function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { + function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } + var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; + var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; + var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); + var _, done = false; + for (var i = decorators.length - 1; i >= 0; i--) { + var context = {}; + for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; + for (var p in contextIn.access) context.access[p] = contextIn.access[p]; + context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; + var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); + if (kind === "accessor") { + if (result === void 0) continue; + if (result === null || typeof result !== "object") throw new TypeError("Object expected"); + if (_ = accept(result.get)) descriptor.get = _; + if (_ = accept(result.set)) descriptor.set = _; + if (_ = accept(result.init)) initializers.unshift(_); + } + else if (_ = accept(result)) { + if (kind === "field") initializers.unshift(_); + else descriptor[key] = _; + } + } + if (target) Object.defineProperty(target, contextIn.name, descriptor); + done = true; +}; + +function __runInitializers(thisArg, initializers, value) { + var useValue = arguments.length > 2; + for (var i = 0; i < initializers.length; i++) { + value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); + } + return useValue ? value : void 0; +}; + +function __propKey(x) { + return typeof x === "symbol" ? x : "".concat(x); +}; + +function __setFunctionName(f, name, prefix) { + if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; + return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); +}; + +function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +var __createBinding = Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +}); + +function __exportStar(m, o) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); +} + +function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +/** @deprecated */ +function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +/** @deprecated */ +function __spreadArrays() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } +} + +function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; + +var __setModuleDefault = Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}; + +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +} + +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { default: mod }; +} + +function __classPrivateFieldGet(receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +} + +function __classPrivateFieldSet(receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +} + +function __classPrivateFieldIn(state, receiver) { + if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); + return typeof state === "function" ? receiver === state : state.has(receiver); +} + +function __addDisposableResource(env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +} + +var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}; + +function __disposeResources(env) { + function fail(e) { + env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ + __extends, + __assign, + __rest, + __decorate, + __param, + __metadata, + __awaiter, + __generator, + __createBinding, + __exportStar, + __values, + __read, + __spread, + __spreadArrays, + __spreadArray, + __await, + __asyncGenerator, + __asyncDelegator, + __asyncValues, + __makeTemplateObject, + __importStar, + __importDefault, + __classPrivateFieldGet, + __classPrivateFieldSet, + __classPrivateFieldIn, + __addDisposableResource, + __disposeResources, +}); + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ (() => { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = (module) => { +/******/ var getter = module && module.__esModule ? +/******/ () => (module['default']) : +/******/ () => (module); +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/global */ +/******/ (() => { +/******/ __webpack_require__.g = (function() { +/******/ if (typeof globalThis === 'object') return globalThis; +/******/ try { +/******/ return this || new Function('return this')(); +/******/ } catch (e) { +/******/ if (typeof window === 'object') return window; +/******/ } +/******/ })(); +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +(() => { +/*!*******************************!*\ + !*** ./src/glTFFileLoader.ts ***! + \*******************************/ +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__), +/* harmony export */ loaders: () => (/* reexport module object */ _lts_loaders_legacy_legacy_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__) +/* harmony export */ }); +/* harmony import */ var _lts_loaders_legacy_legacy_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @lts/loaders/legacy/legacy-glTFFileLoader */ "../../../lts/loaders/src/legacy/legacy-glTFFileLoader.ts"); + + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_lts_loaders_legacy_legacy_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__); + +})(); + +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFieWxvbi5nbFRGRmlsZUxvYWRlci5qcyIsIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOzs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FDVkE7QUFDQTtBQUlBO0FBSUE7QUFhQTs7O0FBR0E7QUFDQTtBQUFBO0FBR0E7QUFDQTtBQUNBO0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBRUE7QUFDQTtBQUNBO0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFBQTs7QUFFQTs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQzVEQTtBQUdBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUlBO0FBRUE7QUFDQTtBQUdBOzs7QU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mltYXRpb24uY2hhbm5lbHMgfHwgIWFuaW1hdGlvbi5zYW1wbGVycykge1xyXG4gICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGxldCBsYXN0QW5pbWF0aW9uOiBOdWxsYWJsZTxBbmltYXRpb24+ID0gbnVsbDtcclxuXHJcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhbmltYXRpb24uY2hhbm5lbHMubGVuZ3RoOyBpKyspIHtcclxuICAgICAgICAgICAgLy8gR2V0IHBhcmFtZXRlcnMgYW5kIGxvYWQgYnVmZmVyc1xyXG4gICAgICAgICAgICBjb25zdCBjaGFubmVsID0gYW5pbWF0aW9uLmNoYW5uZWxzW2ldO1xyXG4gICAgICAgICAgICBjb25zdCBzYW1wbGVyOiBJR0xURkFuaW1hdGlvblNhbXBsZXIgPSBhbmltYXRpb24uc2FtcGxlcnNbY2hhbm5lbC5zYW1wbGVyXTtcclxuXHJcbiAgICAgICAgICAgIGlmICghc2FtcGxlcikge1xyXG4gICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGxldCBpbnB1dERhdGE6IE51bGxhYmxlPHN0cmluZz4gPSBudWxsO1xyXG4gICAgICAgICAgICBsZXQgb3V0cHV0RGF0YTogTnVsbGFibGU8c3RyaW5nPiA9IG51bGw7XHJcblxyXG4gICAgICAgICAgICBpZiAoYW5pbWF0aW9uLnBhcmFtZXRlcnMpIHtcclxuICAgICAgICAgICAgICAgIGlucHV0RGF0YSA9IGFuaW1hdGlvbi5wYXJhbWV0ZXJzW3NhbXBsZXIuaW5wdXRdO1xyXG4gICAgICAgICAgICAgICAgb3V0cHV0RGF0YSA9IGFuaW1hdGlvbi5wYXJhbWV0ZXJzW3NhbXBsZXIub3V0cHV0XTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGlucHV0RGF0YSA9IHNhbXBsZXIuaW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A9IHRhcmdldE5vZGUgaW5zdGFuY2VvZiBCb25lO1xyXG5cclxuICAgICAgICAgICAgLy8gR2V0IHRhcmdldCBwYXRoIChwb3NpdGlvbiwgcm90YXRpb24gb3Igc2NhbGluZylcclxuICAgICAgICAgICAgbGV0IHRhcmdldFBhdGggPSBjaGFubmVsLnRhcmdldC5wYXRoO1xyXG4gICAgICAgICAgICBjb25zdCB0YXJnZXRQYXRoSW5kZXggPSBnbFRGQW5pbWF0aW9uUGF0aHMuaW5kZXhPZih0YXJnZXRQYXRoKTtcclxuXHJcbiAgICAgICAgICAgIGlmICh0YXJnZXRQYXRoSW5kZXggIT09IC0xKSB7XHJcbiAgICAgICAgICAgICAgICB0YXJnZXRQYXRoID0gYmFieWxvbkFuaW1hdGlvblBhdGhzW3RhcmdldFBhdGhJbmRleF07XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIC8vIERldGVybWluZSBhbmltYXRpb24gdHlwZVxyXG4gICAgICAgICAgICBsZXQgYW5pbWF0aW9uVHlwZSA9IEFuaW1hdGlvbi5BTklNQVRJT05UWVBFX01BVFJJWDtcclxuXHJcbiAgICAgICAgICAgIGlmICghaXNCb25lKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAodGFyZ2V0UGF0aCA9PT0gXCJyb3RhdGlvblF1YXRlcm5pb25cIikge1xyXG4gICAgICAgICAgICAgICAgICAgIGFuaW1hdGlvblR5cGUgPSBBbmltYXRpb24uQU5JTUFUSU9OVFlQRV9RVUFURVJOSU9OO1xyXG4gICAgICAgICAgICAgICAgICAgIHRhcmdldE5vZGUucm90YXRpb25RdWF0ZXJuaW9uID0gbmV3IFF1YXRlcm5pb24oKTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYW5pbWF0aW9uVHlwZSA9IEFuaW1hdGlvbi5BTklNQVRJT05UWVBFX1ZFQ1RPUjM7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAg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1lXHJcbiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgYnVmZmVySW5wdXQubGVuZ3RoOyBqKyspIHtcclxuICAgICAgICAgICAgICAgIGxldCB2YWx1ZTogYW55ID0gbnVsbDtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAodGFyZ2V0UGF0aCA9PT0gXCJyb3RhdGlvblF1YXRlcm5pb25cIikge1xyXG4gICAgICAgICAgICAgICAgICAgIC8vIFZFQzRcclxuICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IFF1YXRlcm5pb24uRnJvbUFycmF5KFtidWZmZXJPdXRwdXRbYXJyYXlPZmZzZXRdLCBidWZmZXJPdXRwdXRbYXJyYXlPZmZzZXQgKyAxXSwgYnVmZmVyT3V0cHV0W2FycmF5T2Zmc2V0ICsgMl0sIGJ1ZmZlck91dHB1dFthcnJheU9mZnNldCArIDNdXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgYXJyYXlPZmZzZXQgKz0gNDtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgLy8gUG9zaXRpb24gYW5kIHNjYWxpbmcgYXJlIFZFQzNcclxuICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IFZlY3RvcjMuRnJvbUFycmF5KFtidWZmZXJPdXRwdXRbYXJyYXlPZmZzZXRdLCBidWZmZXJPdXRwdXRbYXJyYXlPZmZzZXQgKyAxXSwgYnVmZmVyT3V0cHV0W2FycmF5T2Zmc2V0ICsgMl1dKTtcclxuICAgICAgICAgICAgICAgICAgICBhcnJheU9mZnNldCArPSAzO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGlmIChpc0JvbmUpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBib25lID0gPEJvbmU+dGFyZ2V0Tm9kZTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgdHJhbnNsYXRpb24gPSBWZWN0b3IzLlplcm8oKTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgcm90YXRpb25RdWF0ZXJuaW9uID0gbmV3IFF1YXRlcm5pb24oKTtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgc2NhbGluZyA9IFZlY3RvcjMuWmVybygpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAvLyBXYXJuaW5nIG9uIGRlY29tcG9zZVxyXG4gICAgICAgICAgICAgICAgICAgIGxldCBtYXQgPSBib25lLmdldEJhc2VNYXRyaXgoKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKG1vZGlmeUtleSAmJiBsYXN0QW5pbWF0aW9uKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hdCA9IGxhc3RBbmltYXRpb24uZ2V0S2V5cygpW2pdLnZhbHVlO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgbWF0LmRlY29tcG9zZShzY2FsaW5nLCByb3RhdGlvblF1YXRlcm5pb24sIHRyYW5zbGF0aW9uKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldFBhdGggPT09IFwicG9zaXRpb25cIikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2xhdGlvbiA9IHZhbHVlO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGFyZ2V0UGF0aCA9PT0gXCJyb3RhdGlvblF1YXRlcm5pb25cIikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvblF1YXRlcm5pb24gPSB2YWx1ZTtcclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzY2FsaW5nID0gdmFsdWU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IE1hdHJpeC5Db21wb3NlKHNjYWxpbmcsIHJvdGF0aW9uUXVhdGVybmlvbiwgdHJhbnNsYXRpb24pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGlmICghbW9kaWZ5S2V5KSB7XHJcbiAgICAgICAgICAgICAgICAgICAga2V5cy5wdXNoKHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZnJhbWU6IGJ1ZmZlcklucHV0W2pdLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsXHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGxhc3RBbmltYXRpb24pIHtcclxuICAgICAgICAgICAgICAgICAgICBsYXN0QW5pbWF0aW9uLmdldEtleXMoKVtqXS52YWx1ZSA9IHZhbHVlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvLyBGaW5pc2hcclxuICAgICAgICAgICAgaWYgKCFtb2RpZnlLZXkgJiYgYmFieWxvbkFuaW1hdGlvbikge1xyXG4gICAgICAgICAgICAgICAgYmFieWxvbkFuaW1hdGlvbi5zZXRLZXlzKGtleXMpO1xyXG4gICAgICAgICAgICAgICAgdGFyZ2V0Tm9kZS5hbmltYXRpb25zLnB1c2goYmFieWxvbkFuaW1hdGlvbik7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGxhc3RBbmltYXRpb24gPSBiYWJ5bG9uQW5pbWF0aW9uO1xyXG5cclxuICAgICAgICAgICAgZ2x0ZlJ1bnRpbWUuc2NlbmUuc3RvcEFuaW1hdGlvbih0YXJnZXROb2RlKTtcclxuICAgICAgICAgICAgZ2x0ZlJ1bnRpbWUuc2NlbmUuYmVnaW5BbmltYXRpb24odGFyZ2V0Tm9kZSwgMCwgYnVmZmVySW5wdXRbYnVmZmVySW5wdXQubGVuZ3RoIC0gMV0sIHRydWUsIDEuMCk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG59O1xyXG5cclx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XJlbnRCb25lID0gKGdsdGZSdW50aW1lOiBJR0xURlJ1bnRpbWUsIHNraW5zOiBJR0xURlNraW5zLCBqb2ludE5hbWU6IHN0cmluZywgbmV3U2tlbGV0b246IFNrZWxldG9uKTogTnVsbGFibGU8Qm9uZT4gPT4ge1xyXG4gICAgLy8gVHJ5IHRvIGZpbmRcclxuICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbmV3U2tlbGV0b24uYm9uZXMubGVuZ3RoOyBpKyspIHtcclxuICAgICAgICBpZiAobmV3U2tlbGV0b24uYm9uZXNbaV0ubmFtZSA9PT0gam9pbnROYW1lKSB7XHJcbiAgICAgICAgICAgIHJldHVybiBuZXdTa2VsZXRvbi5ib25lc1tpXTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgLy8gTm90IGZvdW5kLCBzZWFyY2ggaW4gZ2x0ZiBub2Rlc1xyXG4gICAgY29uc3Qgbm9kZXMgPSBnbHRmUnVudGltZS5ub2RlcztcclxuICAgIGZvciAoY29uc3QgbmRlIGluIG5vZGVzKSB7XHJcbiAgICAgICAgY29uc3Qgbm9kZTogSUdMVEZOb2RlID0gbm9kZXNbbmRlXTtcclxuXHJcbiAgICAgICAgaWYgKCFub2RlLmpvaW50TmFtZSkge1xyXG4gICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGNvbnN0IGNoaWxkcmVuID0gbm9kZS5jaGlsZHJlbjtcclxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNoaWxkcmVuLmxlbmd0aDsgaSsrKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IGNoaWxkOiBJR0xURk5vZGUgPSBnbHRmUnVudGltZS5ub2Rlc1tjaGlsZHJlbltpXV07XHJcbiAgICAgICAgICAgIGlmICghY2hpbGQuam9pbnROYW1lKSB7XHJcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaW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gIGlmIChjaGlsZCA9PT0gaWQpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBub2RlVG9Sb290LmJvbmU7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgcmV0dXJuIG51bGw7XHJcbn07XHJcblxyXG4vKipcclxuICogUmV0dXJucyB0aGUgbm9kZSB3aXRoIHRoZSBqb2ludCBuYW1lXHJcbiAqIEBwYXJhbSBnbHRmUnVudGltZVxyXG4gKiBAcGFyYW0gam9pbnROYW1lXHJcbiAqIEByZXR1cm5zIHRoZSBub2RlIHdpdGggdGhlIGpvaW50IG5hbWVcclxuICovXHJcbmNvbnN0IGdldEpvaW50Tm9kZSA9IChnbHRmUnVudGltZTogSUdMVEZSdW50aW1lLCBqb2ludE5hbWU6IHN0cmluZyk6IE51bGxhYmxlPElKb2ludE5vZGU+ID0+IHtcclxuICAgIGNvbnN0IG5vZGVzID0gZ2x0ZlJ1bnRpbWUubm9kZXM7XHJcbiAgICBsZXQgbm9kZTogSUdMVEZOb2RlID0gbm9kZXNbam9pbnROYW1lXTtcclxuICAgIGlmIChub2RlKSB7XHJcbiAgICAgICAgcmV0dXJuIHtcclxuICAgICAgICAgICAgbm9kZTogbm9kZSxcclxuICAgICAgICAgICAgaWQ6IGpvaW50TmFtZSxcclxuICAgICAgICB9O1xyXG4gICAgfVxyXG5cclxuICAgIGZvciAoY29uc3QgbmRlIGluIG5vZGVzKSB7XHJcbiAgICAgICAgbm9kZSA9IG5vZGVzW25kZV07XHJcbiAgICAgICAgaWYgKG5vZGUuam9pbnROYW1lID09PSBqb2ludE5hbWUpIHtcclxuICAgICAgICAgICAgcmV0dXJuIHtcclxuICAgICAgICAgICAgICAgIG5vZGU6IG5vZGUsXHJcbiAgICAgICAgICAgICAgICBpZDogbmRlLFxyXG4gICAgICAgICAgICB9O1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICByZXR1cm4gbnVsbDtcclxufTtcclxuXH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IGNoaWxkcmVuW2pdKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY2hpbGQgPSBub2Rlc1RvUm9vdFtrXTtcclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYgKGNoaWxkKSB7XHJcbiAgICAgICAgICAgICAgICAoPGFueT5jaGlsZC5ib25lKS5fcGFyZW50ID0gbm9kZVRvUm9vdC5ib25lO1xyXG4gICAgICAgICAgICAgICAgbm9kZVRvUm9vdC5ib25lLmNoaWxkcmVuLnB1c2goY2hpbGQuYm9uZSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICB9XHJcbn07XHJcblxyXG4vKipcclxuICogSW1wb3J0cyBhIHNrZWxldG9uXHJcbiAqIEBwYXJhbSBnbHRmUnVudGltZVxyXG4gKiBAcGFyYW0gc2tpbnNcclxuICogQHBhcmFtIG1lc2hcclxuICogQHBhcmFtIG5ld1NrZWxldG9uXHJcbiAqIEByZXR1cm5zIHRoZSBib25lIG5hbWVcclxuICovXHJcbmNvbnN0IGltcG9ydFNrZWxldG9uID0gKGdsdGZSdW50aW1lOiBJR0xURlJ1bnRpbWUsIHNraW5zOiBJR0xURlNraW5zLCBtZXNoOiBNZXNoLCBuZXdTa2VsZXRvbjogU2tlbGV0b24gfCB1bmRlZmluZWQpOiBTa2VsZXRvbiA9PiB7XHJcbiAgICBpZiAoIW5ld1NrZWxldG9uKSB7XHJcbiAgICAgICAgbmV3U2tlbGV0b24gPSBuZXcgU2tlbGV0b24oc2tpbnMubmFtZSB8fCBcIlwiLCBcIlwiLCBnbHRmUnVudGltZS5zY2VuZSk7XHJcbiAgICB9XHJcblxyXG4gICAgaWYgKCFza2lucy5iYWJ5bG9uU2tlbGV0b24pIHtcclxuICAgICAgICByZXR1cm4gbmV3U2tlbGV0b247XHJcbiAgICB9XHJcblxyXG4gICAgLy8gRmluZCB0aGUgc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ICAgbmV3U2tlbGV0b24uYm9uZXMucHVzaChleGlzdGluZ0JvbmUpO1xyXG4gICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIC8vIFNlYXJjaCBmb3IgcGFyZW50IGJvbmVcclxuICAgICAgICBsZXQgZm91bmRCb25lID0gZmFsc2U7XHJcbiAgICAgICAgbGV0IHBhcmVudEJvbmU6IE51bGxhYmxlPEJvbmU+ID0gbnVsbDtcclxuXHJcbiAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBpOyBqKyspIHtcclxuICAgICAgICAgICAgY29uc3Qgam9pbnROb2RlID0gZ2V0Sm9pbnROb2RlKGdsdGZSdW50aW1lLCBza2lucy5qb2ludE5hbWVzW2pdKTtcclxuXHJcbiAgICAgICAgICAgIGlmICgham9pbnROb2RlKSB7XHJcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgY29uc3Qgam9pbnQ6IElHTFRGTm9kZSA9IGpvaW50Tm9kZS5ub2RlO1xyXG5cclxuICAgICAgICAgICAgaWYgKCFqb2ludCkge1xyXG4gICAgICAgICAgICAgICAgVG9vbHMuV2FybihcIkpvaW50IG5hbWVkIFwiICsgc2tpbnMuam9pbnROYW1lc1tqXSArIFwiIGRvZXMgbm90IGV4aXN0IHdoZW4gbG9va2luZyBmb3IgcGFyZW50XCIpO1xyXG4gICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGNvbnN0IGNoaWxkcmVuID0gam9pbnQuY2hpbGRyZW47XHJcbiAgICAgICAgICAgIGlmICghY2hpbGRyZW4pIHtcclxuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGZvdW5kQm9uZSA9IGZhbHNlO1xyXG5cclxuICAgICAgICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCBjaGlsZHJlbi5sZW5ndGg7IGsrKykge1xyXG4gICAgICAgICAgICAgICAgaWYgKGNoaWxkcmVuW2tdID09PSBpZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHBhcmVudEJvbmUgPSBnZXRQYXJlbnRCb25lKGdsdGZSdW50aW1lLCBza2lucywgc2tpbnMuam9pbnROYW1lc1tqXSwgbmV3U2tlbGV0b24pO1xyXG4gICAgICAgICAgICAgICAgICAgIGZvdW5kQm9uZSA9IHRydWU7XHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmIChmb3VuZEJvbmUpIHtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICAvLyBDcmVhdGUgYm9uZVxyXG4gICAgICAgIGNvbnN0IG1hdCA9IGNvbmZpZ3VyZUJvbmVUcmFuc2Zvcm1hdGlvbihub2RlKTtcclxuXHJcbiAgICAgICAgaWYgKCFwYXJlbnRCb25lICYmIG5vZGVzVG9Sb290Lmxlbmd0aCA+IDApIHtcclxuICAgICAgICAgICAgcGFyZW50Qm9uZSA9IGdldE5vZGVUb1Jvb3Qobm9kZXNUb1Jvb3QsIGlkKTtcclxuXHJcbiAgICAgICAgICAgIGlmIChwYXJlbnRCb25lKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAobm9kZXNUb1Jvb3RUb0FkZC5pbmRleE9mKHBhcmVudEJvbmUpID09PSAtMSkge1xyXG4gICAgICAgICAgICAgICAgICAgIG5vZGVzVG9Sb290VG9BZGQucHVzaChwYXJlbnRCb25lKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgY29uc3QgYm9uZSA9IG5ldyBCb25lKG5vZGUuam9pbnROYW1lIHx8IFwiXCIsIG5ld1NrZWxldG9uLCBwYXJlbnRCb25lLCBtYXQpO1xyXG4gICAgICAgIGJvbmUuaWQgPSBpZDtcclxuICAgIH1cclxuXHJcbiAgICAvLyBQb2xpc2hcclxuICAgIGNvbnN0IGJvbmVzID0gbmV3U2tlbGV0b24uYm9uZXM7XHJcbiAgICBuZXdTa2VsZXRvbi5ib25lcyA9IFtdO1xyXG5cclxuICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc2tpbnMuam9pbnROYW1lcy5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgIGNvbnN0IGpvaW50Tm9kZSA9IGdldEpvaW50Tm9kZShnbHRmUnVudGltZSwgc2tpbnMuam9pbnROYW1lc1tpXSk7XHJcblxyXG4gICAgICAgIGlmICgham9pbnROb2RlKSB7XHJcbiAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBib25lcy5sZW5ndGg7IGorKykge1xyXG4gICAgICAgICAgICBpZiAoYm9uZXNbal0uaWQgPT09IGpvaW50Tm9kZS5pZCkge1xyXG4gICAgICAgICAgICAgICAgbmV3U2tlbGV0b24uYm9uZXMucHVzaChib25lc1tqXSk7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICBuZXdTa2VsZXRvbi5wcmVwYXJlKCk7XHJcblxyXG4gICAgLy8gRmluaXNoXHJcbiAgICBmb3IgKGxldCBpID0gMDsgaSA8IG5vZGVzVG9Sb290VG9BZGQubGVuZ3RoOyBpKyspIHtcclxuICAgICAgICBuZXdTa2VsZXRvbi5ib25lcy5wdXNoKG5vZGVzVG9Sb290VG9BZGRbaV0pO1xyXG4gICAgfVxyXG5cclxuICAgIHJldHVybiBuZXdTa2VsZXRvbjtcclxufTtcclxuXHJcbi8qKlxyXG4gKiBJbXBvcnRzIGEgbWVzaCBhbmQgaXRzIGdlb21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xyXG4gICAgY29uc3QgdmVydGljZXNDb3VudHM6IG51bWJlcltdID0gW107XHJcbiAgICBjb25zdCBpbmRleFN0YXJ0czogbnVtYmVyW10gPSBbXTtcclxuICAgIGNvbnN0IGluZGV4Q291bnRzOiBudW1iZXJbXSA9IFtdO1xyXG5cclxuICAgIGZvciAobGV0IG1lc2hJbmRleCA9IDA7IG1lc2hJbmRleCA8IG1lc2hlcy5sZW5ndGg7IG1lc2hJbmRleCsrKSB7XHJcbiAgICAgICAgY29uc3QgbWVzaElkID0gbWVzaGVzW21lc2hJbmRleF07XHJcbiAgICAgICAgY29uc3QgbWVzaDogSUdMVEZNZXNoID0gZ2x0ZlJ1bnRpbWUubWVzaGVzW21lc2hJZF07XHJcblxyXG4gICAgICAgIGlmICghbWVzaCkge1xyXG4gICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIC8vIFBvc2l0aW9ucywgbm9ybWFscyBhbmQgVVZzXHJcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBtZXNoLnByaW1pdGl2ZXMubGVuZ3RoOyBpKyspIHtcclxuICAgICAgICAgICAgLy8gVGVtcG9yYXJ5IHZlcnRleCBkYXRhXHJcbiAgICAgICAgICAgIGNvbnN0IHRlbXBWZXJ0ZXhEYXRhID0gbmV3IFZlcnRleERhdGEoKTtcclxuXHJcbiAgICAgICAgICAgIGNvbnN0IHByaW1pdGl2ZSA9IG1lc2gucHJpbWl0aXZlc1tpXTtcclxuICAgICAgICAgICAgaWYgKHByaW1pdGl2ZS5tb2RlICE9PSA0KSB7XHJcbiAgICAgICAgICAgICAgICAvLyBjb250aW51ZTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgY29uc3QgYXR0cmlidXRlcyA9IHByaW1pdGl2ZS5hdHRyaWJ1dGVzO1xyXG4gICAgICAgICAgICBsZXQgYWNjZXNzb3I6IE51bGxhYmxlPElHTFRGQWNjZXNzb3I+ID0gbnVsbDt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PSAwOyBqIDwgYnVmZmVyLmxlbmd0aDsgaiArPSA0KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZW1wVmVydGV4RGF0YS5wb3NpdGlvbnNbal0gPSBidWZmZXJbal07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZW1wVmVydGV4RGF0YS5wb3NpdGlvbnNbaiArIDFdID0gYnVmZmVyW2ogKyAxXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXBWZXJ0ZXhEYXRhLnBvc2l0aW9uc1tqICsgMl0gPSBidWZmZXJbaiArIDJdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGVtcFZlcnRleERhdGEucG9zaXRpb25zID0gbmV3IEZsb2F0MzJBcnJheShidWZmZXIubGVuZ3RoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgKDxGbG9hdDMyQXJyYXk+dGVtcFZlcnRleERhdGEucG9zaXRpb25zKS5zZXQoYnVmZmVyKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHZlcnRpY2VzQ291bnRzLnB1c2godGVtcFZlcnRleERhdGEucG9zaXRpb25zLmxlbmd0aCk7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNlbWFudGljLmluZGV4T2YoXCJURVhDT09SRF9cIikgIT09IC0xKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhbm5lbCA9IE51bWJlcihzZW1hbnRpYy5zcGxpdChcIl9cIilbMV0pO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHV2S2luZCA9IFZlcnRleEJ1ZmZlci5VVktpbmQgKyAoY2hhbm5lbCA9PT0gMCA/IFwiXCIgOiBjaGFubmVsICsgMSk7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdXZzID0gbmV3IEZsb2F0MzJBcnJheShidWZmZXIubGVuZ3RoKTtcclxuICAgICAgICAgICAgICAgICAgICAoPEZsb2F0MzJBcnJheT51dnMpLnNldChidWZmZXIpO1xyXG4gICAgICAgICAgICAgICAgICAgIG5vcm1hbGl6ZVVWcyh1dnMpO1xyXG4gICAgICAgICAgICAgICAgICAgIHRlbXBWZXJ0ZXhEYXRhLnNldCh1dnMsIHV2S2luZCk7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNlbWFudGljID09PSBcIkpPSU5UXCIpIHtcclxuICAgICAgICAgICAgICAgICAgICB0ZW1wVmVydGV4RGF0YS5tYXRyaWNlc0luZGljZXMgPSBuZXcgRmxvYXQzMkFycmF5KGJ1ZmZlci5sZW5ndGgpO1xyXG4gICAgICAgICAgICAgICAgICAgICg8RmxvYXQzMkFycmF5PnRlbXBWZXJ0ZXhEYXRhLm1hdHJpY2VzSW5kaWNlcykuc2V0KGJ1ZmZlcik7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNlbWFudGljID09PSBcIldFSUdIVFwiKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGVtcFZlcnRleERhdGEubWF0cmljZXNXZWlnaHRzID0gbmV3IEZsb2F0MzJBcnJheShidWZmZXIubGVuZ3RoKTtcclxuICAgICAgICAgICAgICAgICAgICAoPEZsb2F0MzJBcnJheT50ZW1wVmVydGV4RGF0YS5tYXRyaWNlc1dlaWdodHMpLnNldChidWZmZXIpO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzZW1hbnRpYyA9PT0gXCJDT0xPUlwiKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGVtcFZlcnRleERhdGEuY29sb3JzID0gbmV3IEZsb2F0MzJBcnJheShidWZmZXIubGVuZ3RoKTtcclxuICAgICAgICAgICAgICAgICAgICAoPEZsb2F0MzJBcnJheT50ZW1wVmVydGV4RGF0YS5jb2xvcnMpLnNldChidWZmZXIpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvLyBJbmRpY2VzXHJcbiAgICAgICAgICAgIGFjY2Vzc29yID0gZ2x0ZlJ1bnRpbWUuYWNjZXNzb3JzW3ByaW1pdGl2ZS5pbmRpY2VzXTtcclxuICAgICAgICAgICAgaWYgKGFjY2Vzc29yKSB7XHJcbiAgICAgICAgICAgICAgICBidWZmZXIgPSBHTFRGVXRpbHMuR2V0QnVmZmVyRnJvbUFjY2Vzc29yKGdsdGZSdW50aW1lLCBhY2Nlc3Nvcik7XHJcblxyXG4gICAgICAgICAgICAgICAgdGVtcFZlcnRleERhdGEuaW5kaWNlcyA9IG5ldyBJbnQzMkFycmF5KGJ1ZmZlci5sZW5ndGgpO1xyXG4gICAgICAgICAgICAgICAgdGVtcFZlcnRleERhdGEuaW5kaWNlcy5zZXQoYnVmZmVyKTtcclxuICAgICAgICAgICAgICAgIGluZGV4Q291bnRzLnB1c2godGVtcFZlcnRleERhdGEuaW5kaWNlcy5sZW5ndGgpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgLy8gU2V0IGluZGljZXMgb24gdGhlIGZseVxyXG4gICAgICAgICAgICAgICAgY29uc3QgaW5kaWNlczogbnVtYmVyW10gPSBbXTtcclxuICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgKDxGbG9hdEFycmF5PnRlbXBWZXJ0ZXhEYXRhLnBvc2l0aW9ucykubGVuZ3RoIC8gMzsgaisrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaW5kaWNlcy5wdXNoKGopO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIHRlbXBWZXJ0ZXhEYXRhLmluZGljZXMgPSBuZXcgSW50MzJBcnJheShpbmRpY2VzKTtcclxuICAgICAgICAgICAgICAgIGluZGV4Q291bnRzLnB1c2godGVtcFZlcnRleERhdGEuaW5kaWNlcy5sZW5ndGgpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAoIXZlcnRleERhdGEpIHtcclxuICAgICAgICAgICAgICAgIHZlcnRleERhdGEgPSB0ZW1wVmVydGV4RGF0YTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHZlcnRleERhdGEubWVyZ2UodGVtcFZlcnRleERhdGEpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAvLyBTdWIgbWF0ZXJpYWxcclxuICAgICAgICAgICAgY29uc3QgbWF0ZXJpYWwgPSBnbHRmUnVudGltZS5zY2VuZS5nZXRNYXRlcmlhbEJ5SWQocHJpbWl0aXZlLm1hdGVyaWFsKTtcclxuXHJcbiAgICAgICAgICAgIHN1Yk1hdGVyaWFscy5wdXNoKG1hdGVyaWFsID09PSBudWxsID8gR0xURlV0aWxzLkdldERlZmF1bHRNYXRlcmlhbChnbHRmUnVudGltZS5zY2VuZSkgOiBtYXRlcmlhbCk7XHJcblxyXG4gICAgICAgICAgICAvLyBVcGRhdGUgdmVydGljZXMgc3RhcnQgYW5kIGluZGV4IHN0YXJ0XHJcbiAgICAgICAgICAgIHZlcnRpY2VzU3RhcnRzLnB1c2godmVydGljZXNTdGFydHMubGVuZ3RoID09PSAwID8gMCA6IHZlcnRpY2VzU3RhcnRzW3ZlcnRpY2VzU3RhcnRzLmxlbmd0aCAtIDFdICsgdmVydGljZXNDb3VudHNbdmVydGljZXNDb3VudHMubGVuZ3RoIC0gMl0pO1xyXG4gICAgICAgICAgICBpbmRleFN0YXJ0cy5wdXNoKGluZGV4U3RhcnRzLmxlbmd0aCA9PT0gMCA/IDAgOiBpbmRleFN0YXJ0c1tpbmRleFN0YXJ0cy5sZW5ndGggLSAxXSArIGluZGV4Q291bnRzW2luZGV4Q291bnRzLmxlbmd0aCAtIDJdKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcbiAgICBsZXQgbWF0ZXJpYW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sbDtcclxuXHJcbiAgICBpZiAoZ2x0ZlJ1bnRpbWUuaW1wb3J0T25seU1lc2hlcyAmJiAobm9kZS5za2luIHx8IG5vZGUubWVzaGVzKSkge1xyXG4gICAgICAgIGlmIChnbHRmUnVudGltZS5pbXBvcnRNZXNoZXNOYW1lcyAmJiBnbHRmUnVudGltZS5pbXBvcnRNZXNoZXNOYW1lcy5sZW5ndGggPiAwICYmIGdsdGZSdW50aW1lLmltcG9ydE1lc2hlc05hbWVzLmluZGV4T2Yobm9kZS5uYW1lIHx8IFwiXCIpID09PSAtMSkge1xyXG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgLy8gTWVzaGVzXHJcbiAgICBpZiAobm9kZS5za2luKSB7XHJcbiAgICAgICAgaWYgKG5vZGUubWVzaGVzKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IHNraW46IElHTFRGU2tpbnMgPSBnbHRmUnVudGltZS5za2luc1tub2RlLnNraW5dO1xyXG5cclxuICAgICAgICAgICAgY29uc3QgbmV3TWVzaCA9IGltcG9ydE1lc2goZ2x0ZlJ1bnRpbWUsIG5vZGUsIG5vZGUubWVzaGVzLCBpZCwgPE1lc2g+bm9kZS5iYWJ5bG9uTm9kZSk7XHJcbiAgICAgICAgICAgIG5ld01lc2guc2tlbGV0b24gPSBnbHRmUnVudGltZS5zY2VuZS5nZXRMYXN0U2tlbGV0b25CeUlkKG5vZGUuc2tpbik7XHJcblxyXG4gICAgICAgICAgICBpZiAobmV3TWVzaC5za2VsZXRvbiA9PT0gbnVsbCkge1xyXG4gICAgICAgICAgICAgICAgbmV3TWVzaC5za2VsZXRvbiA9IGltcG9ydFNrZWxldG9uKGdsdGZSdW50aW1lLCBza2luLCBuZXdNZXNoLCBza2luLmJhYnlsb25Ta2VsZXRvbik7XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKCFza2luLmJhYnlsb25Ta2VsZXRvbikge1xyXG4gICAgICAgIC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TtcclxuICAgICAgICAgICAgICAgIGhlbWlMaWdodC5uYW1lID0gbm9kZS5uYW1lIHx8IFwiXCI7XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKGFtYmllbkxpZ2h0LmNvbG9yKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaGVtaUxpZ2h0LmRpZmZ1c2UgPSBDb2xvcjMuRnJvbUFycmF5KGFtYmllbkxpZ2h0LmNvbG9yKTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBsYXN0Tm9kZSA9IGhlbWlMaWdodDtcclxuICAgICAgICAgICAgfSBlbHNlIGlmIChsaWdodC50eXBlID09PSBcImRpcmVjdGlvbmFsXCIpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGRpcmVjdGlvbmFsTGlnaHQ6IElHTFRGRGlyZWN0aW9uYWxMaWdodCA9ICg8YW55PmxpZ2h0KVtsaWdodC50eXBlXTtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGRpckxpZ2h0ID0gbmV3IERpcmVjdGlvbmFsTGlnaHQobm9kZS5saWdodCwgVmVjdG9yMy5aZXJvKCksIGdsdGZSdW50aW1lLnNjZW5lKTtcclxuICAgICAgICAgICAgICAgIGRpckxpZ2h0Lm5hbWUgPSBub2RlLm5hbWUgfHwgXCJcIjtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoZGlyZWN0aW9uYWxMaWdodC5jb2xvcikge1xyXG4gICAgICAgICAgICAgICAgICAgIGRpckxpZ2h0LmRpZmZ1c2UgPSBDb2xvcjMuRnJvbUFycmF5KGRpcmVjdGlvbmFsTGlnaHQuY29sb3IpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGxhc3ROb2RlID0gZGlyTGlnaHQ7XHJcbiAgICAgICAgICAgIH0gZWxzZSBpZiAobGlnaHQudHlwZSA9PT0gXCJwb2ludFwiKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBwb2ludExpZ2h0OiBJR0xURlBvaW50TGlnaHQgPSAoPGFueT5saWdodClbbGlnaHQudHlwZV07XHJcbiAgICAgICAgICAgICAgICBjb25zdCBwdExpZ2h0ID0gbmV3IFBvaW50TGlnaHQobm9kZS5saWdodCwgVmVjdG9yMy5aZXJvKCksIGdsdGZSdW50aW1lLnNjZW5lKTtcclxuICAgICAgICAgICAgICAgIHB0TGlnaHQubmFtZSA9IG5vZGUubmFtZSB8fCBcIlwiO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmIChwb2ludExpZ2h0LmNvbG9yKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcHRMaWdodC5kaWZmdXNlID0gQ29sb3IzLkZyb21BcnJheShwb2ludExpZ2h0LmNvbG9yKTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBsYXN0Tm9kZSA9IHB0TGlnaHQ7XHJcbiAgICAgICAgICAgIH0gZWxzZSBpZiAobGlnaHQudHlwZSA9PT0gXCJzcG90XCIpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IHNwb3RMaWdodDogSUdMVEZTcG90TGlnaHQgPSAoPGFueT5saWdodClbbGlnaHQudHlwZV07XHJcbiAgICAgICAgICAgICAgICBjb25zdCBzcExpZ2h0ID0gbmV3IFNwb3RMaWdodChub2RlLmxpZ2h0LCBWZWN0b3IzLlplcm8oKSwgVmVjdG9yMy5aZXJvKCksIDAsIDAsIGdsdGZSdW50aW1lLnNjZW5lKTtcclxuICAgICAgICAgICAgICAgIHNwTGlnaHQubmFtZSA9IG5vZGUubmFtZSB8fCBcIlwiO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmIChzcG90TGlnaHQuY29sb3IpIHtcclxuICAgICAgICAgICAgICAgICAgICBzcExpZ2h0LmRpZmZ1c2UgPSBDb2xvcjMuRnJvbUFycmF5KHNwb3RMaWdodC5jb2xvcik7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKH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HJcbn07XHJcblxyXG4vKipcclxuICogSW1wbGVtZW50YXRpb24gb2YgdGhlIGJhc2UgZ2xURiBzcGVjXHJcbiAqIEBpbnRlcm5hbFxyXG4gKi9cclxuZXhwb3J0IGNsYXNzIEdMVEZMb2FkZXJCYXNlIHtcclxuICAgIHB1YmxpYyBzdGF0aWMgQ3JlYXRlUnVudGltZShwYXJzZWREYXRhOiBhbnksIHNjZW5lOiBTY2VuZSwgcm9vdFVybDogc3RyaW5nKTogSUdMVEZSdW50aW1lIHtcclxuICAgICAgICBjb25zdCBnbHRmUnVudGltZTogSUdMVEZSdW50aW1lID0ge1xyXG4gICAgICAgICAgICBleHRlbnNpb25zOiB7fSxcclxuICAgICAgICAgICAgYWNjZXNzb3JzOiB7fSxcclxuICAgICAgICAgICAgYnVmZmVyczoge30sXHJcbiAgICAgICAgICAgIGJ1ZmZlclZpZXdzOiB7fSxcclxuICAgICAgICAgICAgbWVzaGVzOiB7fSxcclxuICAgICAgICAgICAgbGlnaHRzOiB7fSxcclxuICAgICAgICAgICAgY2FtZXJhczoge30sXHJcbiAgICAgICAgICAgIG5vZGVzOiB7fSxcclxuICAgICAgICAgICAgaW1hZ2VzOiB7fSxcclxuICAgICAgICAgICAgdGV4dHVyZXM6IHt9LFxyXG4gICAgICAgICAgICBzaGFkZXJzOiB7fSxcclxuICAgICAgICAgICAgcHJvZ3JhbXM6IHt9LFxyXG4gICAgICAgICAgICBzYW1wbGVyczoge30sXHJcbiAgICAgICAgICAgIHRlY2huaXF1ZXM6IHt9LFxyXG4gICAgICAgICAgICBtYXRlcmlhbHM6IHt9LFxyXG4gICAgICAgICAgICBhbmltYXRpb25zOiB7fSxcclxuICAgICAgICAgICAgc2tpbnM6IHt9LFxyXG4gICAgICAgICAgICBleHRlbnNpb25zVXNlZDogW10sXHJcblxyXG4gICAgICAgICAgICBzY2VuZXM6IHt9LFxyXG5cclxuICAgICAgICAgICAgYnVmZmVyc0NvdW50OiAwLFxyXG4gICAgICAgICAgICBzaGFkZXJzY291bnQ6IDAsXHJcblxyXG4gICAgICAgICAgICBzY2VuZTogc2NlbmUsXHJcbiAgICAgICAgICAgIHJvb3RVcmw6IHJvb3RVcmwsXHJcblxyXG4gICAgICAgICAgICBsb2FkZWRCdWZmZXJDb3VudDogMCxcclxuICAgICAgICAgICAgbG9hZGVkQnVmZmVyVmlld3M6IHt9LFxyXG5cclxuICAgICAgICAgICAgbG9hZGVkU2hhZGVyQ291bnQ6IDAsXHJcblxyXG4gICAgICAgICAgICBpbXBvcnRPbmx5TWVzaGVzOiBmYWxzZSxcclxuXHJcbiAgICAgICAgICAgIGR1bW15Tm9kZXM6IFtdLFxyXG5cclxuICAgICAgICAgICAgYXNzZXRDb250YWluZXI6IG51bGwsXHJcbiAgICAgICAgfTtcclxuXHJcbiAgICAgICAgLy8gUGFyc2VcclxuICAgICAgICBpZiAocGFyc2VkRGF0YS5leHRlbnNpb25zKSB7XHJcbiAgICAgICAgICAgIHBhcnNlT2JqZWN0KHBhcnNlZERhdGEuZXh0ZW5zaW9ucywgXCJleHRlbnNpb25zXCIsIGdsdGZSdW50aW1lKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGlmIChwYXJzZWREYXRhLmV4dGVuc2lvbnNVc2VkKSB7XHJcbiAgICAgICAgICAgIHBhcnNlT2JqZWN0KHBhcnNlZERhdGEuZXh0ZW5zaW9uc1VzZWQsIFwiZXh0ZW5zaW9uc1VzZWRcIiwgZ2x0ZlJ1bnRpbWUpO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgaWYgKHBhcnNlZERhdGEuYnVmZmVycykge1xyXG4gICAgICAgICAgICBwYXJzZUJ1ZmZlcnMocGFyc2VkRGF0YS5idWZmZXJzLCBnbHRmUnVudGltZSk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAocGFyc2VkRGF0YS5idWZmZXJWaWV3cykge1xyXG4gICAgICAgICAgICBwYXJzZU9iamVjdChwYXJzZWREYXRhLmJ1ZmZlclZpZXdzLCBcImJ1ZmZlclZpZXdzXCIsIGdsdGZSdW50aW1lKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGlmIChwYXJzZWREYXRhLmFjY2Vzc29ycykge1xyXG4gICAgICAgICAgICBwYXJzZU9iamVjdChwYXJzZWREYXRhLmFjY2Vzc29ycywgXCJhY2Nlc3NvcnNcIiwgZ2x0ZlJ1bnRpbWUpO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgaWYgKHBhcnNlZERhdGEubWVzaGVzKSB7XHJcbiAgICAgICAgICAgIHBhcnNlT2JqZWN0KHBhcnNlZERhdGEubWVzaGVzLCBcIm1lc2hlc1wiLCBnbHRmUnVudGltZSk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAocGFyc2VkRGF0YS5saWdodHMpIHtcclxuICAgICAgICAgICAgcGFyc2VPYmplY3QocGFyc2VkRGF0YS5saWdodHMsIFwibGlnaHRzXCIsIGdsdGZSdW50aW1lKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGlmIChwYXJzZWREYXRhLmNhbWVyYXMpIHtcclxuICAgICAgICAgICAgcGFyc2VPYmplY3QocGFyc2VkRGF0YS5jYW1lcmFzLCBcImNhbWVyYXNcIiwgZ2x0ZlJ1bnRpbWUpO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgaWYgKHBhcnNlZERhdGEubm9kZXMpIHtcclxuICAgICAgICAgICAgcGFyc2VPYmplY3QocGFyc2VkRGF0YS5ub2RlcywgXCJub2Rlc1wiLCBnbHRmUnVudGltZSk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAocGFyc2VkRGF0YS5pbWFnZXMpIHtcclxuICAgICAgICAgICAgcGFyc2VPYmplY3QocGFyc2VkRGF0YS5pbWFnZXMsIFwiaW1hZ2VzXCIsIGdsdGZSdW50aW1lKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGlmIChwYXJzZWREYXRhLnRleHR1cmVzKSB7XHJcbiAgICAgICAgICAgIHBhcnNlT2JqZWN0KHBhcnNlZERhdGEudGV4dHVyZXMsIFwidGV4dHVyZXNcIiwgZ2x0ZlJ1bnRpbWUpO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgaWYgKHBhcnNlZERhdGEuc2hhZGVycykge1xyXG4gICAgICAgICAgICBwYXJzZVNoYWRlcnMocGFyc2VkRGF0YS5zaGFkZXJzLCBnbHRmUnVudGltZSk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAocGFyc2VkRGF0YS5wcm9ncmFtcykge1xyXG4gICAgICAgICAgICBwYXJzZU9iamVjdChwYXJzZWREYXRhLnByb2dyYW1zLCBcInByb2dyYW1zXCIsIGdsdGZSdW50aW1lKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGlmIChwYXJzZWREYXRhLnNhbXBsZXJzKSB7XHJcbiAgICAgICAgICAgIHBhcnNlT2JqZWN0KHBhcnNlZERhdGEuc2FtcGxlcnMsIFwic2FtcGxlcnNcIiwgZ2x0ZlJ1bnRpbWUpO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgaWYgKHBhcnNlZERhdGEudGVjaG5pcXVlcykge1xyXG4gICAgICAgICAgICBwYXJzZU9iamVjdChwYXJzZWREYXRhLnRlY2huaXF1ZXMsIFwidGVjaG5pcXVlc1wiLCBnbHRmUnVudGltZSk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAocGFyc2VkRGF0YS5tYXRlcmlhbHMpIHtcclxuICAgICAgICAgICAgcGFyc2VPYmplY3QocGFyc2VkRGF0YS5tYXRlcmlhbHMsIFwibWF0ZXJpYWxzXCIsIGdsdGZSdW50aW1lKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGlmIChwYXJzZWREYXRhLmFuaW1hdGlvbnMpIHtcclxuICAgICAgICAgICAgcGFyc2VPYmplY3QocGFyc2VkRGF0YS5hbmltYXRpb25zLCBcImFuaW1hdGlvbnNcIiwgZ2x0ZlJ1bnRpbWUpO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgaWYgKHBhcnNlZERhdGEuc2tpbnMpIHtcclxuICAgICAgICAgICAgcGFyc2VPYmplY3QocGFyc2VkRGF0YS5za2lucywgXCJza2luc1wiLCBnbHRmUnVudGltZSk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAocGFyc2VkRGF0YS5zY2VuZXMpIHtcclxuICAgICAgICAgICAgZ2x0ZlJ1bnRpbWUuc2NlbmVzID0gcGFyc2VkRGF0YS5zY2VuZXM7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAocGFyc2VkRGF0YS5zY2VuZSAmJiBwYXJzZWREYXRhLnNjZW5lcykge1xyXG4gICAgICAgICAgICBnbHRmUnVudGltZS5jdXJyZW50U2NlbmUgPSBwYXJzZWREYXRhLnNjZW5lc1twYXJzZWREYXRhLnNjZW5lXTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBnbHRmUnVudGltZTtcclxuICAgIH1cclxuXHJcbiAgICBwdWJsaWMgc3RhdGljIExvYWRCdWZmZXJBc3luYyhcclxuICAgICAgICBnbHRmUnVudGltZTogSUdMVEZSdW50aW1lLFxyXG4gICAgICAgIGlkOiBzdHJpbmcsXHJcbiAgICAgICAgb25TdWNjZXNzOiAoYnVmZmVyOiBBcnJheUJ1ZmZlclZpZXcpID0+IHZvaWQsXHJcbiAgICAgICAgb25FcnJvcjogKG1lc3NhZ2U6IHN0cmluZykgPT4gdm9pZCxcclxuICAgICAgICBvblByb2dyZXNzPzogKCkgPT4gdm9pZFxyXG4gICAgKTogdm9pZCB7XHJcbiAgICAgICAgY29uc3QgYnVmZmVyOiBJR0xURkJ1ZmZlciA9IGdsdGZSdW50aW1lLmJ1ZmZlcnNbaWRdO1xyXG5cclxuICAgICAgICBpZiAoVG9vbHMuSXNCYXNlNjQoYnVmZmVyLnVyaSkpIHtcclxuICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiBvblN1Y2Nlc3MobmV3IFVpbnQ4QXJyYXkoVG9vbHMuRGVjb2RlQmFzZTY0KGJ1ZmZlci51cmkpKSkpO1xyXG4gICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgIFRvb2xzLkxvYWRGaWxlKFxyXG4gICAgICAgICAgICAgICAgZ2x0ZlJ1bnRpbWUucm9vdFVybCArIGJ1ZmZlci51cmksXHJcbiAgICAgICAgICAgICAgICAoZGF0YSkgPT4gb25TdWNjZXNzKG5ldyBVaW50OEFycmF5KGRhdGEgYXMgQXJyYXlCdWZmZXIpKSxcclxuICAgICAgICAgICAgICAgIG9uUHJvZ3Jlc3MsXHJcbiAgICAgICAgICAgICAgICB1bmRlZmluZWQsXHJcbiAgICAgICAgICAgICAgICB0cnVlLFxyXG4gICAgICAgICAgICAgICAgKHJlcXVlc3QpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAocmVxdWVzdCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBvbkVycm9yKHJlcXVlc3Quc3RhdHVzICsgXCIgXCIgKyByZXF1ZXN0LnN0YXR1c1RleHQpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgcHVibGljIHN0YXRpYyBMb2FkVGV4dHVyZUJ1ZmZlckFzeW5jKGdsdGZSdW50aW1lOiBJR0xURlJ1bnRpbWUsIGlkOiBzdHJpbmcsIG9uU3VjY2VzczogKGJ1ZmZlcjogTnVsbGFibGU8QXJyYXlCdWZmZXJWaWV3PikgPT4gdm9pZCwgb25FcnJvcjogKG1lc3NhZ2U6IHN0cmluZykgPT4gdm9pZCk6IHZvaWQge1xyXG4gICAgICAgIGNvbnN0IHRleHR1cmU6IElHTFRGVGV4dHVyZSA9IGdsdGZSdW50aW1lLnRleHR1cmVzW2lkXTtcclxuXHJcbiAgICAgICAgaWYgKCF0ZXh0dXJlIHx8ICF0ZXh0dXJlLnNvdXJjZSkge1xyXG4gICAgICAgICAgICBvbkVycm9yKFwiXCIpO1xyXG4gICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAodGV4dHVyZS5iYWJ5bG9uVGV4dHVyZSkge1xyXG4gICAgICAgICAgICBvblN1Y2Nlc3MobnVsbCk7XHJcbiAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGNvbnN0IHNvdXJjZTogSUdMVEZJbWFnZSA9IGdsdGZSdW50aW1lLmltYWdlc1t0ZXh0dXJlLnNvdXJjZV07XHJcblxyXG4gICAgICAgIGlmIChUb29scy5Jc0Jhc2U2NChzb3VyY2UudXJpKSkge1xyXG4gICAgICAgICAgICBzZXRUaW1lb3V0KCgpID0+IG9uU3VjY2VzcyhuZXcgVWludDhBcnJheShUb29scy5EZWNvZGVCYXNlNjQoc291cmNlLnVyaSkpKSk7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgVG9vbHMuTG9hZEZpbGUoXHJcbiAgICAgICAgICAgICAgICBnbHRmUnVudGltZS5yb290VXJsICsgc291cmNlLnVyaSxcclxuICAgICAgICAgICAgICAgIChkYXRhKSA9PiBvblN1Y2Nlc3MobmV3IFVpbnQ4QXJyYXkoZGF0YSBhcyBBcnJheUJ1ZmZlcikpLFxyXG4gICAgICAgICAgICAgICAgdW5kZWZpbmVkLFxyXG4gICAgICAgICAgICAgICAgdW5kZWZpbmVkLFxyXG4gICAgICAgICAgICAgICAgdHJ1ZSxcclxuICAgICAgICAgICAgICAgIChyZXF1ZXN0KSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHJlcXVlc3QpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgb25FcnJvcihyZXF1ZXN0LnN0YXR1cyArIFwiIFwiICsgcmVxdWVzdC5zdGF0dXNUZXh0KTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIHB1YmxpYyBzdGF0aWMgQ3JlYXRlVGV4dHVyZUFzeW5jKGdsdGZSdW50aW1lOiBJR0xURlJ1bnRpbWUsIGlkOiBzdHJpbmcsIGJ1ZmZlcjogTnVsbGFibGU8QXJyYXlCdWZmZXJWaWV3Piwgb25TdWNjZXNzOiAodGV4dHVyZTogVGV4dHVyZSkgPT4gdm9pZCk6IHZvaWQge1xyXG4gICAgICAgIGNvbnN0IHRleHR1cmU6IElHTFRGVGV4dHVyZSA9IGdsdGZSdW50aW1lLnRleHR1cmVzW2lkXTtcclxuXHJcbiAgICAgICAgaWYgKHRleHR1cmUuYmFieWxvblRleHR1cmUpIHtcclxuICAgICAgICAgICAgb25TdWNjZXNzKHRleHR1cmUuYmFieWxvblRleHR1cmUpO1xyXG4gICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBjb25zdCBzYW1wbGVyOiBJR0xURlNhbXBsZXIgPSBnbHRmUnVudGltZS5zYW1wbGVyc1t0ZXh0dXJlLnNhbXBsZXJdO1xyXG5cclxuICAgICAgICBjb25zdCBjcmVhdGVNaXBNYXBzID1cclxuICAgICAgICAgICAgc2FtcGxlci5taW5GaWx0ZXIgPT09IEVUZXh0dXJlRmlsdGVyVHlwZS5ORUFSRVNUX01JUE1BUF9ORUFSRVNUIHx8XHJcbiAgICAgICAgICAgIHNhbXBsZXIubWluRmlsdGVyID09PSBFVGV4dHVyZUZpbHRlclR5cGUuTkVBUkVTVF9NSVBNQVBfTElORUFSIHx8XHJcbiAgICAgICAgICAgIHNhbXBsZXIubWluRmlsdGVyID09PSBFVGV4dHVyZUZpbHRlclR5cGUuTElORUFSX01JUE1BUF9ORUFSRVNUIHx8XHJcbiAgICAgICAgICAgIHNhbXBsZXIubWluRml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vcm1JbmRleF0pO1xyXG4gICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB1blRyZWF0ZWRVbmlmb3Jtc1t1bmlmXTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdW5pZm9ybXMucHVzaCh1bmlmKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSBlbHNlIGlmICh1bmlmb3JtUGFyYW1ldGVyLnR5cGUgPT09IEVQYXJhbWV0ZXJUeXBlLlNBTVBMRVJfMkQpIHtcclxuICAgICAgICAgICAgICAgIHNhbXBsZXJzLnB1c2godW5pZik7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICB1bmlmb3Jtcy5wdXNoKHVuaWYpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBmb3IgKGNvbnN0IGF0dHIgaW4gdGVjaG5pcXVlLmF0dHJpYnV0ZXMpIHtcclxuICAgICAgICAgICAgY29uc3QgYXR0cmlidXRlID0gdGVjaG5pcXVlLmF0dHJpYnV0ZXNbYXR0cl07XHJcbiAgICAgICAgICAgIGNvbnN0IGF0dHJpYnV0ZVBhcmFtZXRlcjogSUdMVEZUZWNobmlxdWVQYXJhbWV0ZXIgPSB0ZWNobmlxdWUucGFyYW1ldGVyc1thdHRyaWJ1dGVdO1xyXG5cclxuICAgICAgICAgICAgaWYgKGF0dHJpYnV0ZVBhcmFtZXRlci5zZW1hbnRpYykge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IGdldEF0dHJpYnV0ZShhdHRyaWJ1dGVQYXJhbWV0ZXIpO1xyXG4gICAgICAgICAgICAgICAgaWYgKG5hbWUpIHtcclxuICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVzLnB1c2gobmFtZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxy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gIGZvdW5kQXR0cmlidXRlID0gdHJ1ZTtcclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYgKGZvdW5kQXR0cmlidXRlKSB7XHJcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgbmV3VmVydGV4U2hhZGVyICs9IHBhcnNlU2hhZGVyVW5pZm9ybXModmVydGV4VG9rZW5pemVyLCB0ZWNobmlxdWUsIHVuVHJlYXRlZFVuaWZvcm1zKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIC8vIENvbmZpZ3VyZSBwaXhlbCBzaGFkZXJcclxuICAgICAgICB3aGlsZSAoIXBpeGVsVG9rZW5pemVyLmlzRW5kKCkgJiYgcGl4ZWxUb2tlbml6ZXIuZ2V0TmV4dFRva2VuKCkpIHtcclxuICAgICAgICAgICAgY29uc3QgdG9rZW5UeXBlID0gcGl4ZWxUb2tlbml6ZXIuY3VycmVudFRva2VuO1xyXG5cclxuICAgICAgICAgICAgaWYgKHRva2VuVHlwZSAhPT0gRVRva2VuVHlwZS5JREVOVElGSUVSKSB7XHJcbiAgICAgICAgICAgICAgICBuZXdQaXhlbFNoYWRlciArPSBwaXhlbFRva2VuaXplci5jdXJyZW50U3RyaW5nO1xyXG4gICAgICAgICAgICAgICAgY29udGludWU7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIG5ld1BpeGVsU2hhZGVyICs9IHBhcnNlU2hhZGVyVW5pZm9ybXMocGl4ZWxUb2tlbml6ZXIsIHRlY2huaXF1ZSwgdW5UcmVhdGVkVW5pZm9ybXMpO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgLy8gQ3JlYXRlIHNoYWRlciBtYXRlcmlhbFxyXG4gICAgICAgIGNvbnN0IHNoYWRlclBhdGggPSB7XHJcbiAgICAgICAgIC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ICAgICAgICAgICAgICkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNoYWRlck1hdGVyaWFsLmFscGhhTW9kZSA9IENvbnN0YW50cy5BTFBIQV9DT01CSU5FO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChcclxuICAgICAgICAgICAgICAgICAgICBibGVuZEZ1bmNbMF0gPT09IEVCbGVuZGluZ0Z1bmN0aW9uLk9ORSAmJlxyXG4gICAgICAgICAgICAgICAgICAgIGJsZW5kRnVuY1sxXSA9PT0gRUJsZW5kaW5nRnVuY3Rpb24uT05FICYmXHJcbiAgICAgICAgICAgICAgICAgICAgYmxlbmRGdW5jWzJdID09PSBFQmxlbmRpbmdGdW5jdGlvbi5aRVJPICYmXHJcbiAgICAgICAgICAgICAgICAgICAgYmxlbmRGdW5jWzNdID09PSBFQmxlbmRpbmdGdW5jdGlvbi5PTkVcclxuICAgICAgICAgICAgICAgICkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNoYWRlck1hdGVyaWFsLmFscGhhTW9kZSA9IENvbnN0YW50cy5BTFBIQV9PTkVPTkU7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKFxyXG4gICAgICAgICAgICAgICAgICAgIGJsZW5kRnVuY1swXSA9PT0gRUJsZW5kaW5nRnVuY3Rpb24uU1JDX0FMUEhBICYmXHJcbiAgICAgICAgICAgICAgICAgICAgYmxlbmRGdW5jWzFdID09PSBFQmxlbmRpbmdGdW5jdGlvbi5PTkUgJiZcclxuICAgICAgICAgICAgICAgICAgICBibGVuZEZ1bmNbMl0gPT09IEVCbGVuZGluZ0Z1bmN0aW9uLlpFUk8gJiZcclxuICAgICAgICAgICAgICAgICAgICBibGVuZEZ1bmNbM10gPT09IEVCbGVuZGluZ0Z1bmN0aW9uLk9ORVxyXG4gICAgICAgICAgICAgICAgKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2hhZGVyTWF0ZXJpYWwuYWxwaGFNb2RlID0gQ29uc3RhbnRzLkFMUEhBX0FERDtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoXHJcbiAgICAgICAgICAgICAgICAgICAgYmxlbmRGdW5jWzBdID09PSBFQmxlbmRpbmdGdW5jdGlvbi5aRVJPICYmXHJcbiAgICAgICAgICAgICAgICAgICAgYmxlbmRGdW5jWzFdID09PSBFQmxlbmRpbmdGdW5jdGlvbi5PTkVfTUlOVVNfU1JDX0NPTE9SICYmXHJcbiAgICAgICAgICAgICAgICAgICAgYmxlbmRGdW5jWzJdID09PSBFQmxlbmRpbmdGdW5jdGlvbi5PTkUgJiZcclxuICAgICAgICAgICAgICAgICAgICBibGVuZEZ1bmNbM10gPT09IEVCbGVuZGluZ0Z1bmN0aW9uLk9ORVxyXG4gICAgICAgICAgICAgICAgKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2hhZGVyTWF0ZXJpYWwuYWxwaGFNb2RlID0gQ29uc3RhbnRzLkFMUEhBX1NVQlRSQUNUO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChcclxuICAgICAgICAgICAgICAgICAgICBibGVuZEZ1bmNbMF0gPT09IEVCbGVuZGluZ0Z1bmN0aW9uLkRTVF9DT0xPUiAmJlxyXG4gICAgICAgICAgICAgICAgICAgIGJsZW5kRnVuY1sxXSA9PT0gRUJsZW5kaW5nRnVuY3Rpb24uWkVSTyAmJlxyXG4gICAgICAgICAgICAgICAgICAgIGJsZW5kRnVuY1syXSA9PT0gRUJsZW5kaW5nRnVuY3Rpb24uT05FICYmXHJcbiAgICAgICAgICAgICAgICAgICAgYmxlbmRGdW5jWzNdID09PSBFQmxlbmRpbmdGdW5jdGlvbi5PTkVcclxuICAgICAgICAgICAgICAgICkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNoYWRlck1hdGVyaWFsLmFscGhhTW9kZSA9IENvbnN0YW50cy5BTFBIQV9NVUxUSVBMWTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoXHJcbiAgICAgICAgICAgICAgICAgICAgYmxlbmRGdW5jWzBdID09PSBFQmxlbmRpbmdGdW5jdGlvbi5TUkNfQUxQSEEgJiZcclxuICAgICAgICAgICAgICAgICAgICBibGVuZEZ1bmNbMV0gPT09IEVCbGVuZGluZ0Z1bmN0aW9uLk9ORV9NSU5VU19TUkNfQ09MT1IgJiZcclxuICAgICAgICAgICAgICAgICAgICBibGVuZEZ1bmNbMl0gPT09IEVCbGVuZGluZ0Z1bmN0aW9uLk9ORSAmJlxyXG4gICAgICAgICAgICAgICAgICAgIGJsZW5kRnVuY1szXSA9PT0gRUJsZW5kaW5nRnVuY3Rpb24uT05FXHJcbiAgICAgICAgICAgICAgICApIHtcclxuICAgICAgICAgICAgICAgICAgICBzaGFkZXJNYXRlcmlhbC5hbHBoYU1vZGUgPSBDb25zdGFudHMuQUxQSEFfTUFYSU1JWkVEO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG59XHJcblxyXG4vKipcclxuICogZ2xURiBWMSBMb2FkZXJcclxuICogQGludGVybmFsXHJcbiAqIEBkZXByZWNhdGVkXHJcbiAqL1xyXG5leHBvcnQgY2xhc3MgR0xURkxvYWRlciBpbXBsZW1lbnRzIElHTFRGTG9hZGVyIHtcclxuICAgIHB1YmxpYyBzdGF0aWMgRXh0ZW5zaW9uczogeyBbbmFtZTogc3RyaW5nXTogR0xURkxvYWRlckV4dGVuc2lvbiB9ID0ge307XHJcblxyXG4gICAgcHVibGljIHN0YXRpYyBSZWdpc3RlckV4dGVuc2lvbihleHRlbnNpb246IEdMVEZMb2FkZXJFeHRlbnNpb24pOiB2b2lkIHtcclxuICAgICAgICBpZiAoR0xURkxvYWRlci5FeHRlbnNpb25zW2V4dGVuc2lvbi5uYW1lXSkge1xyXG4gICAgICAgICAgICBUb29scy5FcnJvcignVG9vbCB3aXRoIHRoZSBzYW1lIG5hbWUgXCInICsgZXh0ZW5zaW9uLm5hbWUgKyAnXCIgYWxyZWF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mFzc2V0Q29udGFpbmVyID0gYXNzZXRDb250YWluZXI7XHJcbiAgICAgICAgICAgICAgICBnbHRmUnVudGltZS5pbXBvcnRPbmx5TWVzaGVzID0gdHJ1ZTtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAobWVzaGVzTmFtZXMgPT09IFwiXCIpIHtcclxuICAgICAgICAgICAgICAgICAgICBnbHRmUnVudGltZS5pbXBvcnRNZXNoZXNOYW1lcyA9IFtdO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgbWVzaGVzTmFtZXMgPT09IFwic3RyaW5nXCIpIHtcclxuICAgICAgICAgICAgICAgICAgICBnbHRmUnVudGltZS5pbXBvcnRNZXNoZXNOYW1lcyA9IFttZXNoZXNOYW1lc107XHJcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG1lc2hlc05hbWVzICYmICEobWVzaGVzTmFtZXMgaW5zdGFuY2VvZiBBcnJheSkpIHtcclxuICAgICAgICAgICAgICAgICAgICBnbHRmUnVudGltZS5pbXBvcnRNZXNoZXNOYW1lcyA9IFttZXNoZXNOYW1lc107XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIGdsdGZSdW50aW1lLmltcG9ydE1lc2hlc05hbWVzID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgVG9vbHMuV2FybihcIkFyZ3VtZW50IG1lc2hlc05hbWVzIG11c3QgYmUgb2YgdHlwZSBzdHJpbmcgb3Igc3RyaW5nW11cIik7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgLy8gQ3JlYXRlIG5vZGVzXHJcbiAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVOb2RlcyhnbHRmUnVudGltZSk7XHJcblxyXG4gICAgICAgICAgICAgICAgY29uc3QgbWVzaGVzOiBBYnN0cmFjdE1lc2hbXSA9IFtdO1xyXG4gICAgICAgICAgICAgICAgY29uc3Qgc2tlbGV0b25zOiBTa2VsZXRvbltdID0gW107XHJcblxyXG4gICAgICAgICAgICAgICAgLy8gRmlsbCBhcnJheXMgb2YgbWVzaGVzIGFuZCBza2VsZXRvbnNcclxuICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbmRlIGluIGdsdGZSdW50aW1lLm5vZGVzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgbm9kZTogSUdMVEZOb2RlID0gZ2x0ZlJ1bnRpbWUubm9kZXNbbmRlXTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKG5vZGUuYmFieWxvbk5vZGUgaW5zdGFuY2VvZiBBYnN0cmFjdE1lc2gpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbWVzaGVzLnB1c2goPEFic3RyYWN0TWVzaD5ub2RlLmJhYnlsb25Ob2RlKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgZm9yIChjb25zdCBza2wgaW4gZ2x0ZlJ1bnRpbWUuc2tpbnMpIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBza2luOiBJR0xURlNraW5zID0gZ2x0ZlJ1bnRpbWUuc2tpbnNbc2tsXTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNraW4uYmFieWxvblNrZWxldG9uIGluc3RhbmNlb2YgU2tlbGV0b24pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2tlbGV0b25zLnB1c2goc2tpbi5iYWJ5bG9uU2tlbGV0b24pO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAvLyBMb2FkIGJ1ZmZlcnMsIHNoYWRlcnMsIG1hdGVyaWFscywgZXRjLlxyXG4gICAgICAgICAgICAgICAgdGhpcy5fbG9hZEJ1ZmZlcnNBc3luYyhnbHRmUnVudGltZSwgKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRTaGFkZXJzQXN5bmMoZ2x0ZlJ1bnRpbWUsICgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaW1wb3J0TWF0ZXJpYWxzKGdsdGZSdW50aW1lKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcG9zdExvYWQoZ2x0ZlJ1bnRpbWUpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFHTFRGRmlsZUxvYWRlci5JbmNyZW1lbnRhbExvYWRpbmcgJiYgb25TdWNjZXNzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvblN1Y2Nlc3MobWVzaGVzLCBza2VsZXRvbnMpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoR0xURkZpbGVMb2FkZXIuSW5jcmVtZW50YWxMb2FkaW5nICYmIG9uU3VjY2Vzcykge1xyXG4gICAgICAgICAgICAgICAgICAgIG9uU3VjY2VzcyhtZXNoZXMsIHNrZWxldG9ucyk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgIG9uRXJyb3JcclxuICAgICAgICApO1xyXG5cclxuICAgICAgICByZXR1cm4gdHJ1ZTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIEltcG9ydHMgb25lIG9yIG1vcmUgbWVzaGVzIGZyb20gYSBsb2FkZWQgZ2x0ZiBmaWxlIGFuZCBhZGRzIHRoZW0gdG8gdGhlIHNjZW5lXHJcbiAgICAgKiBAcGFyYW0gbWVzaGVzTmFtZXMgYSBzdHJpbmcgb3IgYXJyYXkgb2Ygc3RyaW5ncyBvZiB0aGUgbWVzaCBuYW1lcyB0aGF0IHNob3VsZCBiZSBsb2FkZWQgZnJvbSB0aGUgZm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G4gICAgICAgICAgICB0aGlzLl9pbXBvcnRNZXNoQXN5bmMoXHJcbiAgICAgICAgICAgICAgICBtZXNoZXNOYW1lcyxcclxuICAgICAgICAgICAgICAgIHNjZW5lLFxyXG4gICAgICAgICAgICAgICAgZGF0YSxcclxuICAgICAgICAgICAgICAgIHJvb3RVcmwsXHJcbiAgICAgICAgICAgICAgICBhc3NldENvbnRhaW5lcixcclxuICAgICAgICAgICAgICAgIChtZXNoZXMsIHNrZWxldG9ucykgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHJlc29sdmUoe1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBtZXNoZXM6IG1lc2hlcyxcclxuICAgICAgICAgICAgICAgICAgICAgICAgcGFydGljbGVTeXN0ZW1zOiBbXSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2tlbGV0b25zOiBza2VsZXRvbnMsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFuaW1hdGlvbkdyb3VwczogW10sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpZ2h0czogW10sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZm9ybU5vZGVzOiBbXSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgZ2VvbWV0cmllczogW10sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNwcml0ZU1hbmFnZXJzOiBbXSxcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICBvblByb2dyZXNzLFxyXG4gICAgICAgICAgICAgICAgKG1lc3NhZ2UpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICByZWplY3QobmV3IEVycm9yKG1lc3NhZ2UpKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgKTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9sb2FkQXN5bmMoXHJcbiAgICAgICAgc2NlbmU6IFNjZW5lLFxyXG4gICAgICAgIGRhdGE6IElHTFRGTG9hZGVyRGF0YSxcclxuICAgICAgICByb290VXJsOiBzdHJpbmcsXHJcbiAgICAgICAgb25TdWNjZXNzOiAoKSA9PiB2b2lkLFxyXG4gICAgICAgIG9uUHJvZ3Jlc3M/OiAoZXZlbnQ6IElTY2VuZUxvYWRlclByb2dyZXNzRXZlbnQpID0+IHZvaWQsXHJcbiAgICAgICAgb25FcnJvcj86IChtZXNzYWdlOiBzdHJpbmcpID0+IHZvaWRcclxuICAgICk6IHZvaWQge1xyXG4gICAgICAgIHNjZW5lLnVzZVJpZ2h0SGFuZGVkU3lzdGVtID0gdHJ1ZTtcclxuXHJcbiAgICAgICAgR0xURkxvYWRlckV4dGVuc2lvbi5Mb2FkUnVudGltZUFzeW5jKFxyXG4gICAgICAgICAgICBzY2VuZSxcclxuICAgICAgICAgICAgZGF0YSxcclxuICAgICAgICAgICAgcm9vdFVybCxcclxuICAgICAgICAgICAgKGdsdGZSdW50aW1lKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAvLyBMb2FkIHJ1bnRpbWUgZXh0ZW5zaW9zXHJcbiAgICAgICAgICAgICAgICBHTFRGTG9hZGVyRXh0ZW5zaW9uLkxvYWRSdW50aW1lRXh0ZW5zaW9uc0FzeW5jKFxyXG4gICAgICAgICAgICAgICAgICAgIGdsdGZSdW50aW1lLFxyXG4gICAgICAgICAgICAgICAgICAgICgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gQ3JlYXRlIG5vZGVzXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZU5vZGVzKGdsdGZSdW50aW1lKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIExvYWQgYnVmZmVycywgc2hhZGVycywgbWF0ZXJpYWxzLCBldGMuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRCdWZmZXJzQXN5bmMoZ2x0ZlJ1bnRpbWUsICgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRTaGFkZXJzQXN5bmMoZ2x0ZlJ1bnRpbWUsICgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbXBvcnRNYXRlcmlhbHMoZ2x0ZlJ1bnRpbWUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvc3RMb2FkKGdsdGZSdW50aW1lKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFHTFRGRmlsZUxvYWRlci5JbmNyZW1lbnRhbExvYWRpbmcpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb25TdWNjZXNzKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEdMVEZGaWxlTG9hZGVyLkluY3JlbWVudGFsTG9hZGluZykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgb25TdWNjZXNzKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgICAgIG9uRXJyb3JcclxuICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgIG9uRXJyb3JcclxuICAgICAgICApO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogSW1wb3J0cyBhbGwgb2JqZWN0cyBmcm9tIGEgbG9hZGVkIGdsdGYgZmlsZSBhbmQgYWRkcyB0aGVtIHRvIHRoZSBzY2VuZVxyXG4gICAgICogQHBhcmFtIHNjZW5lIHRoZSBzY2VuZSB0aGUgb2JqZWN0cyBzaG91bGQgYmUgYWRkZWQgdG9cclxuICAgICAqIEBwYXJhbSBkYXRhIGdsdGYgZGF0YSBjb250YWluaW5nIGluZm9ybWF0aW9uIG9mIHRoZSBtZXNoZXMgaW4gYSBsb2FkZWQgZmlsZVxyXG4gICAgICogQHBhcmFtIHJvb3RVcmwgcm9vdCB1cmwgdG8gbG9hZCBmcm9tXHJcbiAgICAgKiBAcGFyYW0gb25Qcm9ncmVzcyBldmVudCB0aGF0IGZpcmVzIHdoZW4gbG9hZGluZyBwcm9ncmVzcyBoYXMgb2NjdXJlZFxyXG4gICAgICogQHJldHVybnMgYSBwcm9taXNlIHdoaWNoIGNvbXBsZXRlcyB3aGVuIG9iamVjdHMgaGF2ZSBiZWVuIGxvYWRlZCB0byB0aGUgc2NlbmVcclxuICAgICAqL1xyXG4gICAgcHVibGljIGxvYWRBc3luYyhzY2VuZTogU2NlbmUsIGRhdGE6IElHTFRGTG9hZGVyRGF0YSwgcm9vdFVybDogc3RyaW5nLCBvblByb2dyZXNzPzogKGV2ZW50OiBJU2NlbmVMb2FkZXJQcm9ncmVzc0V2ZW50KSA9PiB2b2lkKTogUHJvbWlzZTx2b2lkPiB7XHJcbiAgICAgICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcclxuICAgICAgICAgICAgdGhpcy5fbG9hZEFzeW5jKFxyXG4gICAgICAgICAgICAgICAgc2NlbmUsXHJcbiAgICAgICAgICAgICAgICBkYXRhLFxyXG4gICAgICAgICAgICAgICAgcm9vdFVybCxcclxuICAgICAgICAgICAgICAgICgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICByZXNvbHZlKCk7XHJcbiAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgb25Qcm9ncmVzcyxcclxuICAgICAgICAgICAgICAgIChtZXNzYWdlKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmVqZWN0KG5ldyBFcnJvcihtZXNzYWdlKSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICk7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfbG9hZFNoYWRlcnNBc3luYyhnbHRmUnVudGltZTogSUdMVEZSdW50aW1lLCBvbmxvYWQ6ICgpID0+IHZvaWQpOiB2b2lkIHtcclxuICAgICAgICBsZXQgaGFzU2hhZGVycyA9IGZhbHNlO1xyXG5cclxuICAgICAgICBjb25zdCBwcm9jZXNzU2hhZGVyID0gKHNoYTogc3RyaW5nLCBzaGFkZXI6IElHTFRGU2hhZGVyKSA9PiB7XHJcbiAgICAgICAgICAgIEdMVEZMb2FkZXJFeHRlbnNpb24uTG9hZFNoYWRlclN0cmluZ0FzeW5jKFxyXG4gICAgICAgICAgICAgICAgZ2x0ZlJ1bnRpbWUsXHJcbiAgICAgICAgICAgICAgICBzaGEsXHJcbiAgICAgICAgICAgICAgICAoc2hhZGVyU3RyaW5nKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNoYWRlclN0cmluZyBpbnN0YW5jZW9mIEFycmF5QnVmZmVyKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGdsdGZSdW50aW1lLmxvYWRlZFNoYWRlckNvdW50Kys7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzaGFkZXJTdHJpbmcpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgRWZmZWN0LlNoYWRlcnNTdG9yZVtzaGEgKyAoc2hhZGVyLnR5cGUgPT09IEVTaGFkZXJUeXBlLlZFUlRFWCA/IFwiVmVydGV4U2hhZGVyXCIgOiBcIlBpeGVsU2hhZGVyXCIpXSA9IHNoYWRlclN0cmluZztcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChnbHRmUnVudGltZS5sb2FkZWRTaGFkZXJDb3VudCA9PT0gZ2x0ZlJ1bnRpbWUuc2hhZGVyc2NvdW50KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG9ubG9hZCgpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICAoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgVG9vbHMuRXJyb3IoXCJFcnJvciB3aGVuIGxvYWRpbmcgc2hhZGVyIHByb2dyYW0gbmFtZWQgXCIgKyBzaGEgKyBcIiBsb2NhdGVkIGF0IFwiICsgc2hhZGVyLnVyaSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICk7XHJcbiAgICAgICAgfTtcclxuXHJcbiAgICAgICAgZm9yIChjb25zdCBzaGEgaW4gZ2x0ZlJ1bnRpbWUuc2hhZGVycykge1xyXG4gICAgICAgICAgICBoYXNTaGFkZXJzID0gdHJ1ZTtcclxuXHJcbiAgICAgICAgICAgIGNvbnN0IHNoYWRlcjogSUdMVEZTaGFkZXIgPSBnbHRmUnVudGltZS5zaGFkZXJzW3NoYV07XHJcbiAgICAgICAgICAgIGlmIChzaGFkZXIpIHtcclxuICAgICAgICAgICAgICAgIHByb2Nlc3NTaGFkZXIuYmluZCh0aGlzLCBzaGEsIHNoYWRlcikoKTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIFRvb2xzLkVycm9yKFwiTm8gc2hhZGVyIG5hbWVkOiBcIiArIHNoYSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGlmICghaGFzU2hhZGVycykge1xyXG4gICAgICAgICAgICBvbmxvYWQoKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfbG9hZEJ1ZmZlcnNBc3luYyhnbHRmUnVudGltZTogSUdMVEZSdW50aW1lLCBvbkxvYWQ6ICgpID0+IHZvaWQpO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nVudGltZS5idWZmZXJzQ291bnQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgb25Mb2FkKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgICgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBUb29scy5FcnJvcihcIkVycm9yIHdoZW4gbG9hZGluZyBidWZmZXIgbmFtZWQgXCIgKyBidWYgKyBcIiBsb2NhdGVkIGF0IFwiICsgYnVmZmVyLnVyaSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICk7XHJcbiAgICAgICAgfTtcclxuXHJcbiAgICAgICAgZm9yIChjb25zdCBidWYgaW4gZ2x0ZlJ1bnRpbWUuYnVmZmVycykge1xyXG4gICAgICAgICAgICBoYXNCdWZmZXJzID0gdHJ1ZTtcclxuXHJcbiAgICAgICAgICAgIGNvbnN0IGJ1ZmZlcjogSUdMVEZCdWZmZXIgPSBnbHRmUnVudGltZS5idWZmZXJzW2J1Zl07XHJcbiAgICAgICAgICAgIGlmIChidWZmZXIpIHtcclxuICAgICAgICAgICAgICAgIHByb2Nlc3NCdWZmZXIuYmluZCh0aGlzLCBidWYsIGJ1ZmZlcikoKTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIFRvb2xzLkVycm9yKFwiTm8gYnVmZmVyIG5hbWVkOiBcIiArIGJ1Zik7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGlmICghaGFzQnVmZmVycykge1xyXG4gICAgICAgICAgICBvbkxvYWQoKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfY3JlYXRlTm9kZXMoZ2x0ZlJ1bnRpbWU6IElHTFRGUnVudGltZSk6IHZvaWQge1xyXG4gICAgICAgIGxldCBjdXJyZW50U2NlbmUgPSA8SUdMVEZTY2VuZT5nbHRmUnVudGltZS5jdXJyZW50U2NlbmU7XHJcblxyXG4gICAgICAgIGlmIChjdXJyZW50U2NlbmUpIHtcclxuICAgICAgICAgICAgLy8gT25seSBvbmUgc2NlbmUgZXZlbiBpZiBtdWx0aXBsZSBzY2VuZXMgYXJlIGRlZmluZWRcclxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjdXJyZW50U2NlbmUubm9kZXMubGVuZ3RoOyBpKyspIHtcclxuICAgICAgICAgICAgICAgIHRyYXZlcnNlTm9kZXMoZ2x0ZlJ1bnRpbWUsIGN1cnJlbnRTY2VuZS5ub2Rlc1tpXSwgbnVsbCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAvLyBMb2FkIGFsbCBzY2VuZXNcclxuICAgICAgICAgICAgZm9yIChjb25zdCB0aGluZyBpbiBnbHRmUnVudGltZS5zY2VuZXMpIHtcclxuICAgICAgICAgICAgICAgIGN1cnJlbnRTY2VuZSA9IDxJR0xURlNjZW5lPmdsdGZSdW50aW1lLnNjZW5lc1t0aGluZ107XHJcblxyXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjdXJyZW50U2NlbmUubm9kZXMubGVuZ3RoOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICB0cmF2ZXJzZU5vZGVzKGdsdGZSdW50aW1lLCBjdXJyZW50U2NlbmUubm9kZXNbaV0sIG51bGwpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG59XHJcblxyXG4vKiogQGludGVybmFsICovXHJcbmV4cG9ydCBhYnN0cmFjdCBjbGFzcyBHTFRGTG9hZGVyRXh0ZW5zaW9uIHtcclxuICAgIHByaXZhdGUgX25hbWU6IHN0cmluZztcclxuXHJcbiAgICBwdWJsaWMgY29uc3RydWN0b3IobmFtZTogc3RyaW5nKSB7XHJcbiAgICAgICAgdGhpc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gICAgICBzY2VuZTogU2NlbmUsXHJcbiAgICAgICAgZGF0YTogSUdMVEZMb2FkZXJEYXRhLFxyXG4gICAgICAgIHJvb3RVcmw6IHN0cmluZyxcclxuICAgICAgICBvblN1Y2Nlc3M/OiAoZ2x0ZlJ1bnRpbWU6IElHTFRGUnVudGltZSkgPT4gdm9pZCxcclxuICAgICAgICBvbkVycm9yPzogKG1lc3NhZ2U6IHN0cmluZykgPT4gdm9pZFxyXG4gICAgKTogdm9pZCB7XHJcbiAgICAgICAgR0xURkxvYWRlckV4dGVuc2lvbi5fQXBwbHlFeHRlbnNpb25zKFxyXG4gICAgICAgICAgICAobG9hZGVyRXh0ZW5zaW9uKSA9PiB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gbG9hZGVyRXh0ZW5zaW9uLmxvYWRSdW50aW1lQXN5bmMoc2NlbmUsIGRhdGEsIHJvb3RVcmwsIG9uU3VjY2Vzcywgb25FcnJvcik7XHJcbiAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICgpID0+IHtcclxuICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICghb25TdWNjZXNzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgb25TdWNjZXNzKEdMVEZMb2FkZXJCYXNlLkNyZWF0ZVJ1bnRpbWUoZGF0YS5qc29uLCBzY2VuZSwgcm9vdFVybCkpO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICApO1xyXG4gICAgfVxyXG5cclxuICAgIHB1YmxpYyBzdGF0aWMgTG9hZFJ1bnRpbWVFeHRlbnNpb25zQXN5bmMoZ2x0ZlJ1bnRpbWU6IElHTFRGUnVudGltZSwgb25TdWNjZXNzOiAoKSA9PiB2b2lkLCBvbkVycm9yPzogKG1lc3NhZ2U6IHN0cmluZykgPT4gdm9pZCk6IHZvaWQge1xyXG4gICAgICAgIEdMVEZMb2FkZXJFeHRlbnNpb24uX0FwcGx5RXh0ZW5zaW9ucyhcclxuICAgICAgICAgICAgKGxvYWRlckV4dGVuc2lvbikgPT4ge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGxvYWRlckV4dGVuc2lvbi5sb2FkUnVudGltZUV4dGVuc2lvbnNBc3luYyhnbHRmUnVudGltZSwgb25TdWNjZXNzLCBvbkVycm9yKTtcclxuICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgb25TdWNjZXNzKCk7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICk7XHJcbiAgICB9XHJcblxyXG4gICAgcHVibGljIHN0YXRpYyBMb2FkQnVmZmVyQXN5bmMoXHJcbiAgICAgICAgZ2x0ZlJ1bnRpbWU6IElHTFRGUnVudGltZSxcclxuICAgICAgICBpZDogc3RyaW5nLFxyXG4gICAgICAgIG9uU3VjY2VzczogKGJ1ZmZlclZpZXc6IEFycmF5QnVmZmVyVmlldykgPT4gdm9pZCxcclxuICAgICAgICBvbkVycm9yOiAobWVzc2FnZTogc3RyaW5nKSA9PiB2b2lkLFxyXG4gICAgICAgIG9uUHJvZ3Jlc3M/OiAoKSA9PiB2b2lkXHJcbiAgICApOiB2b2lkIHtcclxuICAgICAgICBHTFRGTG9hZGVyRXh0ZW5zaW9uLl9BcHBseUV4dGVuc2lvbnMoXHJcbiAgICAgICAgICAgIChsb2FkZXJFeHRlbnNpb24pID0+IHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBsb2FkZXJFeHRlbnNpb24ubG9hZEJ1ZmZlckFzeW5jKGdsdGZSdW50aW1lLCBpZCwgb25TdWNjZXNzLCBvbkVycm9yLCBvblByb2dyZXN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ICAgICAgIGlmICghR0xURlV0aWxzLl9EZWZhdWx0TWF0ZXJpYWwpIHtcclxuICAgICAgICAgICAgRWZmZWN0LlNoYWRlcnNTdG9yZVtcIkdMVEZEZWZhdWx0TWF0ZXJpYWxWZXJ0ZXhTaGFkZXJcIl0gPSBbXHJcbiAgICAgICAgICAgICAgICBcInByZWNpc2lvbiBoaWdocCBmbG9hdDtcIixcclxuICAgICAgICAgICAgICAgIFwiXCIsXHJcbiAgICAgICAgICAgICAgICBcInVuaWZvcm0gbWF0NCB3b3JsZFZpZXc7XCIsXHJcbiAgICAgICAgICAgICAgICBcInVuaWZvcm0gbWF0NCBwcm9qZWN0aW9uO1wiLFxyXG4gICAgICAgICAgICAgICAgXCJcIixcclxuICAgICAgICAgICAgICAgIFwiYXR0cmlidXRlIHZlYzMgcG9zaXRpb247XCIsXHJcbiAgICAgICAgICAgICAgICBcIlwiLFxyXG4gICAgICAgICAgICAgICAgXCJ2b2lkIG1haW4odm9pZClcIixcclxuICAgICAgICAgICAgICAgIFwie1wiLFxyXG4gICAgICAgICAgICAgICAgXCIgICAgZ2xfUG9zaXRpb24gPSBwcm9qZWN0aW9uICogd29ybGRWaWV3ICogdmVjNChwb3NpdGlvbiwgMS4wKTtcIixcclxuICAgICAgICAgICAgICAgIFwifVwiLFxyXG4gICAgICAgICAgICBdLmpvaW4oXCJcXG5cIik7XHJcblxyXG4gICAgICAgICAgICBFZmZlY3QuU2hhZGVyc1N0b3JlW1wiR0xURkRlZmF1bHRNYXRlcmlhbFBpeGVsU2hhZGVyXCJdID0gW1xyXG4gICAgICAgICAgICAgICAgXCJwcmVjaXNpb24gaGlnaHAgZmxvYXQ7XCIsXHJcbiAgICAgICAgICAgICAgICBcIlwiLFxyXG4gICAgICAgICAgICAgICAgXCJ1bmlmb3JtIHZlYzQgdV9lbWlzc2lvbjtcIixcclxuICAgICAgICAgICAgICAgIFwiXCIsXHJcbiAgICAgICAgICAgICAgICBcInZvaWQgbWFpbih2b2lkKVwiLFx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gICAgICAgICAgICAgICAgICAgICBjb25zdCBhbWJpZW50ID0gbGlnaHQuYW1iaWVudDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFtYmllbnQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFtYmllbnRMaWdodC5kaWZmdXNlID0gQ29sb3IzLkZyb21BcnJheShhbWJpZW50LmNvbG9yIHx8IFsxLCAxLCAxXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgXCJwb2ludFwiOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvaW50TGlnaHQgPSBuZXcgUG9pbnRMaWdodChsaWdodC5uYW1lLCBuZXcgVmVjdG9yMygxMCwgMTAsIDEwKSwgZ2x0ZlJ1bnRpbWUuc2NlbmUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb2ludCA9IGxpZ2h0LnBvaW50O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocG9pbnQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50TGlnaHQuZGlmZnVzZSA9IENvbG9yMy5Gcm9tQXJyYXkocG9pbnQuY29sb3IgfHwgWzEsIDEsIDFdKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSBcImRpcmVjdGlvbmFsXCI6IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGlyTGlnaHQgPSBuZXcgRGlyZWN0aW9uYWxMaWdodChsaWdodC5uYW1lLCBuZXcgVmVjdG9yMygwLCAtMSwgMCksIGdsdGZSdW50aW1lLnNjZW5lKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGlyZWN0aW9uYWwgPSBsaWdodC5kaXJlY3Rpb25hbDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRpcmVjdGlvbmFsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXJMaWdodC5kaWZmdXNlID0gQ29sb3IzLkZyb21BcnJheShkaXJlY3Rpb25hbC5jb2xvciB8fCBbMSwgMSwgMV0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBjYXNlIFwic3BvdFwiOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwb3QgPSBsaWdodC5zcG90O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3BvdCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BvdExpZ2h0ID0gbmV3IFNwb3RMaWdodChcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaWdodC5uYW1lLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBWZWN0b3IzKDAsIDEwLCAwKSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXcgVmVjdG9yMygwLCAtMSwgMCksXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BvdC5mYWxsT2ZmQW5nbGUgfHwgTWF0aC5QSSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcG90LmZhbGxPZmZFeHBvbmVudCB8fCAwLjAsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2x0ZlJ1bnRpbWUuc2NlbmVcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcG90TGlnaHQuZGlmZnVzZSA9IENvbG9yMy5Gcm9tQXJyYXkoc3BvdC5jb2xvciB8fCBbMSwgMSwgMV0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OlxyXG4gICAgICAgICAgICAgICAgICAgICAgICBUb29scy5XYXJuKCdHTFRGIE1hdGVyaWFsIENvbW1vbiBleHRlbnNpb246IGxpZ2h0IHR5cGUgXCInICsgbGlnaHQudHlwZSArIFwi4oCdIG5vdCBzdXBwb3J0ZWRcIik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICB9XHJcblxyXG4gICAgcHVibGljIGxvYWRNYXRlcmlhbEFzeW5jKGdsdGZSdW50aW1lOiBJR0xURlJ1bnRpbWUsIGlkOiBzdHJpbmcsIG9uU3VjY2VzczogKG1hdGVyaWFsOiBNYXRlcmlhbCkgPT4gdm9pZCwgb25FcnJvcjogKG1lc3NhZ2U6IHN0cmluZykgPT4gdm9pZCk6IGJvb2xlYW4ge1xyXG4gICAgICAgIGNvbnN0IG1hdGVyaWFsOiBJR0xURk1hdGVyaWFsID0gZ2x0ZlJ1bnRpbWUubWF0ZXJpYWxzW2lkXTtcclxuICAgICAgICBpZiAoIW1hdGVyaWFsIHx8ICFtYXRlcmlhbC5leHRlbnNpb25zKSB7XHJcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGNvbnN0IGV4dGVuc2lvbjogSUdMVEZNYXRlcmlhbHNDb21tb25FeHRlbnNpb24gPSBtYXRlcmlhbC5leHRlbnNpb25zW3RoaXMub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aW1hZ2UgPSBBcnJheUl0ZW0uR2V0KHNwZWN1bGFySW1hZ2VDb250ZXh0LCB0aGlzLl9sb2FkZXIuZ2x0Zi5pbWFnZXMsIGluZGV4KTtcclxuICAgICAgICAgICAgICAgICAgICBwcm9taXNlcy5wdXNoKFxyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZXIubG9hZEltYWdlQXN5bmMoYC9pbWFnZXMvJHtpbmRleH1gLCBpbWFnZSkudGhlbigoZGF0YSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1hZ2VEYXRhW21pcG1hcF1bZmFjZV0gPSBkYXRhO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgICAgICk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlci5sb2dDbG9zZSgpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICB0aGlzLl9sb2FkZXIubG9nQ2xvc2UoKTtcclxuXHJcbiAgICAgICAgICAgIGxpZ2h0Ll9sb2FkZWQgPSBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBiYWJ5bG9uVGV4dHVyZSA9IG5ldyBSYXdDdWJlVGV4dHVyZSh0aGlzLl9sb2FkZXIuYmFieWxvblNjZW5lLCBudWxsLCBsaWdodC5zcGVjdWxhckltYWdlU2l6ZSk7XHJcbiAgICAgICAgICAgICAgICBiYWJ5bG9uVGV4dHVyZS5uYW1lID0gbGlnaHQubmFtZSB8fCBcImVudmlyb25tZW50XCI7XHJcbiAgICAgICAgICAgICAgICBsaWdodC5fYmFieWxvblRleHR1cmUgPSBiYWJ5bG9uVGV4dHVyZTtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAobGlnaHQuaW50ZW5zaXR5ICE9IHVuZGVmaW5lZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGJhYnlsb25UZXh0dXJlLmxldmVsID0gbGlnaHQuaW50ZW5zaXR5O1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGlmIChsaWdodC5yb3RhdGlvbikge1xyXG4gICAgICAgICAgICAgICAgICAgIGxldCByb3RhdGlvbiA9IFF1YXRlcm5pb24uRnJvbUFycmF5KGxpZ2h0LnJvdGF0aW9uKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgLy8gSW52ZXJ0IHRoZSByb3RhdGlvbiBzbyB0aGF0IHBvc2l0aXZlIHJvdGF0aW9uIGlzIGNvdW50ZXItY2xvY2t3aXNlLlxyXG4gICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fbG9hZGVyLmJhYnlsb25TY2VuZS51c2VSaWdodEhhbmRlZFN5c3RlbSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbiA9IFF1YXRlcm5pb24uSW52ZXJzZShyb3RhdGlvbik7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBNYXRyaXguRnJvbVF1YXRlcm5pb25Ub1JlZihyb3RhdGlvbiwgYmFieWxvblRleHR1cmUuZ2V0UmVmbGVjdGlvblRleHR1cmVNYXRyaXgoKSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKCFsaWdodC5pcnJhZGlhbmNlQ29lZmZpY2llbnRzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGAke2NvbnRleHR9OiBJcnJhZGlhbmNlIGNvZWZmaWNpZW50cyBhcmUgbWlzc2luZ2ApO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGNvbnN0IHNwaGVyaWNhbEhhcm1vbmljcyA9IFNwaGVyaWNhbEhhcm1vbmljcy5Gcm9tQXJyYXkobGlnaHQu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HVuZGVmaW5lZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2goUHJvbWlzZS5yZXNvbHZlKG51bGwpKTtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgY29uc3QgYWNjZXNzb3IgPSBBcnJheUl0ZW0uR2V0KGAke2V4dGVuc2lvbkNvbnRleHR9L2F0dHJpYnV0ZXMvJHthdHRyaWJ1dGV9YCwgdGhpcy5fbG9hZGVyLmdsdGYuYWNjZXNzb3JzLCBleHRlbnNpb24uYXR0cmlidXRlc1thdHRyaWJ1dGVdKTtcclxuICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2godGhpcy5fbG9hZGVyLl9sb2FkRmxvYXRBY2Nlc3NvckFzeW5jKGAvYWNjZXNzb3JzLyR7YWNjZXNzb3IuYnVmZmVyVmlld31gLCBhY2Nlc3NvcikpO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmIChpbnN0YW5jZUNvdW50ID09PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaW5zdGFuY2VDb3VudCA9IGFjY2Vzc29yLmNvdW50O1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpbnN0YW5jZUNvdW50ICE9PSBhY2Nlc3Nvci5jb3VudCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgJHtleHRlbnNpb25Db250ZXh0fS9hdHRyaWJ1dGVzOiBJbnN0YW5jZSBidWZmZXIgYWNjZXNzb3JzIGRvIG5vdCBoYXZlIHRoZSBzYW1lIGNvdW50LmApO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9O1xyXG5cclxuICAgICAgICAgICAgbG9hZEF0dHJpYnV0ZShcIlRSQU5TTEFUSU9OXCIpO1xyXG4gICAgICAgICAgICBsb2FkQXR0cmlidXRlKFwiUk9UQVRJT05cIik7XHJcbiAgICA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BWZWN0b3JzLlF1YXRlcm5pb25bMF0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzY2FsZUJ1ZmZlciAmJiBWZWN0b3IzLkZyb21BcnJheVRvUmVmKHNjYWxlQnVmZmVyLCBpICogMywgVG1wVmVjdG9ycy5WZWN0b3IzWzFdKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIE1hdHJpeC5Db21wb3NlVG9SZWYoVG1wVmVjdG9ycy5WZWN0b3IzWzFdLCBUbXBWZWN0b3JzLlF1YXRlcm5pb25bMF0sIFRtcFZlY3RvcnMuVmVjdG9yM1swXSwgVG1wVmVjdG9ycy5NYXRyaXhbMF0pO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgVG1wVmVjdG9ycy5NYXRyaXhbMF0uY29weVRvQXJyYXkobWF0cmljZXMsIGkgKiAxNik7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGJhYnlsb25NZXNoIG9mIG5vZGUuX3ByaW1pdGl2ZUJhYnlsb25NZXNoZXMhKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIChiYWJ5bG9uTWVzaCBhcyBNZXNoKS50aGluSW5zdGFuY2VTZXRCdWZmZXIoXCJtYXRyaXhcIiwgbWF0cmljZXMsIDE2LCB0cnVlKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBiYWJ5bG9uVHJhbnNmb3JtTm9kZTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxufVxyXG5cclxuR0xURkxvYWRlci5SZWdpc3RlckV4dGVuc2lvbihOQU1FLCAobG9hZGVyKSA9PiBuZXcgRVhUX21lc2hfZ3B1X2luc3RhbmNpbmcobG9hZGVyKSk7XHJcbiIsImltcG9ydCB0eXBlIHsgTnVsbGFibG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b2FkZXIuTG9hZEV4dGVuc2lvbkFzeW5jPElFWFRUZXh0dXJlV2ViUCwgQmFzZVRleHR1cmU+KGNvbnRleHQsIHRleHR1cmUsIHRoaXMubmFtZSwgKGV4dGVuc2lvbkNvbnRleHQsIGV4dGVuc2lvbikgPT4ge1xyXG4gICAgICAgICAgICBjb25zdCBzYW1wbGVyID0gdGV4dHVyZS5zYW1wbGVyID09IHVuZGVmaW5lZCA/IEdMVEZMb2FkZXIuRGVmYXVsdFNhbXBsZXIgOiBBcnJheUl0ZW0uR2V0KGAke2NvbnRleHR9L3NhbXBsZXJgLCB0aGlzLl9sb2FkZXIuZ2x0Zi5zYW1wbGVycywgdGV4dHVyZS5zYW1wbGVyKTtcclxuICAgICAgICAgICAgY29uc3QgaW1hZ2UgPSBBcnJheUl0ZW0uR2V0KGAke2V4dGVuc2lvbkNvbnRleHR9L3NvdXJjZWAsIHRoaXMuX2xvYWRlci5nbHRmLmltYWdlcywgZXh0ZW5zaW9uLnNvdXJjZSk7XHJcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9sb2FkZXIuX2NyZWF0ZVRleHR1cmVBc3luYyhcclxuICAgICAgICAgICAgICAgIGNvbnRleHQsXHJcbiAgICAgICAgICAgICAgICBzYW1wbGVyLFxyXG4gICAgICAgICAgICAgICAgaW1hZ2UsXHJcbiAgICAgICAgICAgICAgICAoYmFieWxvblRleHR1cmUpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBhc3NpZ24oYmFieWxvblRleHR1cmUpO1xyXG4gICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgIHVuZGVmaW5lZCxcclxuICAgICAgICAgICAgICAgICF0ZXh0dXJlLl90ZXh0dXJlSW5mby5ub25Db2xvckRhdGFcclxuICAgICAgICAgICAgKTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxufVxyXG5cclxuR0xURkxvYWRlci5SZWdpc3RlckV4dGVuc2lvbihOQU1FLCAobG9hZGVyKSA9PiBuZXcgRVh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Z2V0RmxvYXQsICgpID0+IDEpXSxcclxuICAgICAgICB9LFxyXG4gICAgICAgIG9jY2x1c2lvblRleHR1cmU6IHtcclxuICAgICAgICAgICAgc3RyZW5ndGg6IFtuZXcgTWF0ZXJpYWxBbmltYXRpb25Qcm9wZXJ0eUluZm8oQW5pbWF0aW9uLkFOSU1BVElPTlRZUEVfRkxPQVQsIFwiYW1iaWVudFRleHR1cmVTdHJlbmd0aFwiLCBnZXRGbG9hdCwgKCkgPT4gMSldLFxyXG4gICAgICAgICAgICBleHRlbnNpb25zOiB7XHJcbiAgICAgICAgICAgICAgICBLSFJfdGV4dHVyZV90cmFuc2Zvcm06IGdldFRleHR1cmVUcmFuc2Zvcm1UcmVlKFwiYW1iaWVudFRleHR1cmVcIiksXHJcbiAgICAgICAgICAgIH0sXHJcbiAgICAgICAgfSxcclxuICAgICAgICBlbWlzc2l2ZVRleHR1cmU6IHtcclxuICAgICAgICAgICAgZXh0ZW5zaW9uczoge1xyXG4gICAgICAgICAgICAgICAgS0hSX3RleHR1cmVfdHJhbnNmb3JtOiBnZXRUZXh0dXJlVHJhbnNmb3JtVHJlZShcImVtaXNzaXZlVGV4dHVyZVwiKSxcclxuICAgICAgICAgICAgfSxcclxuICAgICAgICB9LFxyXG4gICAgICAgIGV4dGVuc2lvbnM6IHtcclxuICAgICAgICAgICAgS0hSX21hdGVyaWFsc19pb3I6IHtcclxuICAgICAgICAgICAgICAgIGlvcjogW25ldyBNYXRlcmlhbEFuaW1hdGlvblByb3BlcnR5SW5mbyhBbmltYXRpb24uQU5JTUFUSU9OVFlQRV9GTE9BVCwgXCJpbmRleE9mUmVmcmFjdGlvblwiLCBnZXRGbG9hdCwgKCkgPT4gMSldLFxyXG4gICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICBLSFJfbWF0ZXJpYWxzX2NsZWFyY29hdDoge1xyXG4gICAgICAgICAgICAgICAgY2xlYXJjb2F0RmFjdG9yOiBbbmV3IE1hdGVyaWFsQW5pbWF0aW9u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RSSVApIHtcclxuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYCR7Y29udGV4dH06IFVuc3VwcG9ydGVkIG1vZGUgJHtwcmltaXRpdmUubW9kZX1gKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgY29uc3QgYXR0cmlidXRlczogeyBba2luZDogc3RyaW5nXTogbnVtYmVyIH0gPSB7fTtcclxuICAgICAgICAgICAgY29uc3Qgbm9ybWFsaXplZDogeyBba2luZDogc3RyaW5nXTogYm9vbGVhbiB9ID0ge307XHJcbiAgICAgICAgICAgIGNvbnN0IGxvYWRBdHRyaWJ1dGUgPSAobmFtZTogc3RyaW5nLCBraW5kOiBzdHJpbmcpID0+IHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IHVuaXF1ZUlkID0gZXh0ZW5zaW9uLmF0dHJpYnV0ZXNbbmFtZV07XHJcbiAgICAgICAgICAgICAgICBpZiAodW5pcXVlSWQgPT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGJhYnlsb25NZXNoLl9kZWxheUluZm8gPSBiYWJ5bG9uTWVzaC5fZGVsYXlJbmZvIHx8IFtdO1xyXG4gICAgICAgICAgICAgICAgaWYgKGJhYnlsb25NZXNoLl9kZWxheUluZm8uaW5kZXhPZihraW5kKSA9PT0gLTEpIHtcclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uTWVzaC5fZGVsYXlJbmZvLnB1c2goa2luZCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgYXR0cmlidXRlc1traW5kXSA9IHVuaXF1ZUlkO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmICh0aGlzLnVzZU5vcm1hbGl6ZWRGbGFnRnJvbUFjY2Vzc29yKSB7XHJcbiAgICAgICAg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VDVElPTkFMOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJhYnlsb25EaXJlY3Rpb25hbExpZ2h0ID0gbmV3IERpcmVjdGlvbmFsTGlnaHQobmFtZSwgVmVjdG9yMy5CYWNrd2FyZCgpLCB0aGlzLl9sb2FkZXIuYmFieWxvblNjZW5lKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvbkRpcmVjdGlvbmFsTGlnaHQucG9zaXRpb24uc2V0QWxsKDApO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uTGlnaHQgPSBiYWJ5bG9uRGlyZWN0aW9uYWxMaWdodDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgS0hSTGlnaHRzUHVuY3R1YWxfTGlnaHRUeXBlLlBPSU5UOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25MaWdodCA9IG5ldyBQb2ludExpZ2h0KG5hbWUsIFZlY3RvcjMuWmVybygpLCB0aGlzLl9sb2FkZXIuYmFieWxvblNjZW5lKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgS0hSTGlnaHRzUHVuY3R1YWxfTGlnaHRUeXBlLlNQT1Q6IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmFieWxvblNwb3RMaWdodCA9IG5ldyBTcG90TGlnaHQobmFtZSwgVmVjdG9yMy5aZXJvKCksIFZlY3RvcjMuQmFja3dhcmQoKSwgMCwgMSwgdGhpcy5fbG9hZGVyLmJhYnlsb25TY2VuZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25TcG90TGlnaHQuYW5nbGUgPSAoKGxpZ2h0LnNwb3QgJiYgbGlnaHQuc3BvdC5vdXRlckNvbmVBbmdsZSkgfHwgTWF0aC5QSSAvIDQpICogMjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvblNwb3RMaWdodC5pbm5lckFuZ2xlID0gKChsaWdodC5zcG90ICYmIGxpZ2h0LnNwb3QuaW5uZXJDb25lQW5nbGUpIHx8IDApICogMjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvbkxpZ2h0ID0gYmFieWxvblNwb3RMaWdodDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVyLmJhYnlsb25TY2VuZS5fYmxvY2tFbnRpdHlDb2xsZWN0aW9uID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgJHtleHRlbnNpb25Db250ZXh0fTogSW52YWxpZCBsaWdodCB0eXBlICgke2xpZ2h0LnR5cGV9KWApO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBiYWJ5bG9uTGlnaHQuX3BhcmVudENvbnRhaW5lciA9IHRoaXMuX2xvYWRlci5fYXNzZXRDb250YWluZXI7XHJcbiAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZXIuYmFieWxvblNjZW5lLl9ibG9ja0VudGl0eUNvbGxlY3Rpb24gPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgIGxpZ2h0Ll9iYWJ5bG9uTGlnaHQgPSBiYWJ5bG9uTGlnaHQ7XHJcblxyXG4gICAgICAgICAgICAgICAgYmFieWxvbkxpZ2h0LmZhbGxvZmZUeXBlID0gTGlnaHQuRkFMTE9GRl9HTFRGO1xyXG4gICAgICAgICAgICAgICAgYmFieWxvbkxpZ2h0LmRpZmZ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ICAgICk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAocHJvcGVydGllcy5jbGVhcmNvYXRSb3VnaG5lc3NGYWN0b3IgIT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgIGJhYnlsb25NYXRlcmlhbC5jbGVhckNvYXQucm91Z2huZXNzID0gcHJvcGVydGllcy5jbGVhcmNvYXRSb3VnaG5lc3NGYWN0b3I7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgYmFieWxvbk1hdGVyaWFsLmNsZWFyQ29hdC5yb3VnaG5lc3MgPSAwO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgaWYgKHByb3BlcnRpZXMuY2xlYXJjb2F0Um91Z2huZXNzVGV4dHVyZSkge1xyXG4gICAgICAgICAgICAocHJvcGVydGllcy5jbGVhcmNvYXRSb3VnaG5lc3NUZXh0dXJlIGFzIElUZXh0dXJlSW5mbykubm9uQ29sb3JEYXRhID0gdHJ1ZTtcclxuICAgICAgICAgICAgcHJvbWlzZXMucHVzaChcclxuICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlci5sb2FkVGV4dHVyZUluZm9Bc3luYyhgJHtjb250ZXh0fS9jbGVhcmNvYXRSb3VnaG5lc3NUZXh0dXJlYCwgcHJvcGVydGllcy5jbGVhcmNvYXRSb3VnaG5lc3NUZXh0dXJlLCAodGV4dHVyZSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHRleHR1cmUubmFtZSA9IGAke2JhYnlsb25NYXRlcmlhbC5uYW1lfSAoQ2xlYXJDb2F0IFJvdWdobmVzcylgO1xyXG4gICAgICAgICAgICAgICAgICAgIGJhYnlsb25NYXRlcmlhbC5jbGVhckNvYXQudGV4dHVyZVJvdWdobmVzcyA9IHRleHR1cmU7XHJcbiAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICApO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgaWYgKHByb3BlcnRpZXMuY2x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xyXG5leHBvcnQgY2xhc3MgS0hSX21hdGVyaWFsc19zcGVjdWxhciBpbXBsZW1lbnRzIElHTFRGTG9hZGVyRXh0ZW5zaW9uIHtcclxuICAgIC8qKlxyXG4gICAgICogVGhlIG5hbWUgb2YgdGhpcyBleHRlbnNpb24uXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyByZWFkb25seSBuYW1lID0gTkFNRTtcclxuXHJcbiAgICAvKipcclxuICAgICAqIERlZmluZXMgd2hldGhlciB0aGlzIGV4dGVuc2lvbiBpcyBlbmFibGVkLlxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgZW5hYmxlZDogYm9vbGVhbjtcclxuXHJcbiAgICAvKipcclxuICAgICAqIERlZmluZXMgYSBudW1iZXIgdGhhdCBkZXRlcm1pbmVzIHRoZSBvcmRlciB0aGUgZXh0ZW5zaW9ucyBhcmUgYXBwbGllZC5cclxuICAgICAqL1xyXG4gICAgcHVibGljIG9yZGVyID0gMTkwO1xyXG5cclxuICAgIHByaXZhdGUgX2xvYWRlcjogR0xURkxvYWRlcjtcclxuXHJcbiAgICAvKipcclxuICAgICAqIEBpbnRlcm5hbFxyXG4gICAgICovXHJcbiAgICBjb25zdHJ1Y3Rvcihsb2FkZXI6IEdMVEZMb2FkZXIpIHtcclxuICAgICAgICB0aGlzLl9sb2FkZXIgPSBsb2FkZXI7XHJcbiAgICAgICAgdGhpcy5lbmFibGVkID0gdGhpcy5fbG9hZGVyLmlzRXh0ZW5zaW9uVXNlZChOQU1FKTtcclxuICAgIH1cclxuXHJcbiAgICAvKiogQGludGVybmFsICovXHJcbiAgICBwdWJsaWMgZGlzcG9zZSgpIHtcclxuICAgICAgICAodGhpcy5fbG9hZGVyIGFzIGFueSkgPSBudWxsO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQGludGVybmFsXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBsb2FkTWF0ZXJpYWxQcm9wZXJ0aWVzQXN5bmMoY29udGV4d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gICAgICAgICAgICAgICAgIGJhYnlsb25NYXRlcmlhbC5tZXRhbGxpY1JlZmxlY3RhbmNlVGV4dHVyZSA9IHRleHR1cmU7XHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvbk1hdGVyaWFsLnVzZU9ubHlNZXRhbGxpY0Zyb21NZXRhbGxpY1JlZmxlY3RhbmNlVGV4dHVyZSA9IHRydWU7XHJcbiAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICApO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgaWYgKHByb3BlcnRpZXMuc3BlY3VsYXJDb2xvclRleHR1cmUpIHtcclxuICAgICAgICAgICAgcHJvbWlzZXMucHVzaChcclxuICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlci5sb2FkVGV4dHVyZUluZm9Bc3luYyhgJHtjb250ZXh0fS9zcGVjdWxhckNvbG9yVGV4dHVyZWAsIHByb3BlcnRpZXMuc3BlY3VsYXJDb2xvclRleHR1cmUsICh0ZXh0dXJlKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGV4dHVyZS5uYW1lID0gYCR7YmFieWxvbk1hdGVyaWFsLm5hbWV9IChTcGVjdWxhciBGMCBDb2xvcilgO1xyXG4gICAgICAgICAgICAgICAgICAgIGJhYnlsb25NYXRlcmlhbC5yZWZsZWN0YW5jZVRleHR1cmUgPSB0ZXh0dXJlO1xyXG4gICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbigoKSA9PiB7fSk7XHJcbiAgICB9XHJcbn1cclxuXHJcbkdMVEZMb2FkZXIuUmVnaXN0ZXJFeHRlbnNpb24oTkFNRSwgKGxvYWRlcikgPT4gbmV3IEtIUl9tYXRlcmlhbHNfc3BlY3VsYXIobG9hZGVyKSk7XHJcbiIsImltcG9ydCB0eXBlIHsgTnVsbGFibGUgfSBmcm9tIF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UaGUgZ2xURiByb290IG1lc2hcclxuICAgICAqIEBwYXJhbSB2YXJpYW50TmFtZSBUaGUgdmFyaWFudCBuYW1lKHMpIHRvIHNlbGVjdC5cclxuICAgICAqL1xyXG4gICAgcHVibGljIHN0YXRpYyBTZWxlY3RWYXJpYW50KHJvb3RNZXNoOiBNZXNoLCB2YXJpYW50TmFtZTogc3RyaW5nIHwgc3RyaW5nW10pOiB2b2lkIHtcclxuICAgICAgICBjb25zdCBleHRlbnNpb25NZXRhZGF0YSA9IHRoaXMuX0dldEV4dGVuc2lvbk1ldGFkYXRhKHJvb3RNZXNoKTtcclxuICAgICAgICBpZiAoIWV4dGVuc2lvbk1ldGFkYXRhKSB7XHJcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgQ2Fubm90IHNlbGVjdCB2YXJpYW50IG9uIGEgZ2xURiBtZXNoIHRoYXQgZG9lcyBub3QgaGF2ZSB0aGUgJHtOQU1FfSBleHRlbnNpb25gKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGNvbnN0IHNlbGVjdCA9ICh2YXJpYW50TmFtZTogc3RyaW5nKTogdm9pZCA9PiB7XHJcbiAgICAgICAgICAgIGNvbnN0IGVudHJpZXMgPSBleHRlbnNpb25NZXRhZGF0YS52YXJpYW50c1t2YXJpYW50TmFtZV07XHJcbiAgICAgICAgICAgIGlmIChlbnRyaWVzKSB7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIGVudHJpZXMpIHtcclxuICAgICAgICAgICAgICAgICAgICBlbnRyeS5tZXNoLm1hdGVyaWFsID0gZW50cnkubWF0ZXJpYWw7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9O1xyXG5cclxuICAgICAgICBpZiAodmFyaWFudE5hbWUgaW5zdGFuY2VvZiBBcnJheSkge1xyXG4gICAgICAgICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgdmFyaWFudE5hbWUpIHt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lhbH1gLCBtYXRlcmlhbCwgYmFieWxvbk1lc2gsIGJhYnlsb25EcmF3TW9kZSwgKGJhYnlsb25NYXRlcmlhbCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBtYXBwaW5nVmFyaWFudEluZGV4ID0gMDsgbWFwcGluZ1ZhcmlhbnRJbmRleCA8IG1hcHBpbmcudmFyaWFudHMubGVuZ3RoOyArK21hcHBpbmdWYXJpYW50SW5kZXgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhcmlhbnRJbmRleCA9IG1hcHBpbmcudmFyaWFudHNbbWFwcGluZ1ZhcmlhbnRJbmRleF07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YXJpYW50ID0gQXJyYXlJdGVtLkdldChgL2V4dGVuc2lvbnMvJHtOQU1FfS92YXJpYW50cy8ke3ZhcmlhbnRJbmRleH1gLCB0aGlzLl92YXJpYW50cywgdmFyaWFudEluZGV4KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4dGVuc2lvbk1ldGFkYXRhLnZhcmlhbnRzW3ZhcmlhbnQubmFtZV0gPSBleHRlbnNpb25NZXRhZGF0YS52YXJpYW50c1t2YXJpYW50Lm5hbWVdIHx8IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0ZW5zaW9uTWV0YWRhdGEudmFyaWFudHNbdmFyaWFudC5uYW1lXS5wdXNoKHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNoOiBiYWJ5bG9uTWVzaCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXRlcmlhbDogYmFieWxvbk1hdGVyaWFsLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gUmVwbGFjZSB0aGUgdGFyZ2V0IHdoZW4gb3JpZ2luYWwgbWVzaCBpcyBjbG9uZWRcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25NZXNoLm9uQ2xvbmVkT2JzZXJ2YWJsZS5hZGQoKG5ld09uZTogTm9kZSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5ld01lc2ggPSBuZXdPbmUgYXMgTWVzaDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbWV0YWRhdGE6IE51bGxhYmxlPElFeHRlbnNpb25NZXRhZGF0YT4gPSBudWxsO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBuZXdSb290OiBOdWxsYWJsZTxOb2RlPiA9IG5ld01lc2g7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIEZpbmQgcm9vdCB0byBnZXQgbWVkYXRhXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG8ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdSb290ID0gbmV3Um9vdCEucGFyZW50O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW5ld1Jvb3QpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXRhZGF0YSA9IEtIUl9tYXRlcmlhbHNfdmFyaWFudHMuX0dldEV4dGVuc2lvbk1ldGFkYXRhKG5ld1Jvb3QgYXMgTWVzaCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAobWV0YWRhdGEgPT09IG51bGwpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBOZWVkIHRvIGNsb25lIHRoZSBtZXRhZGF0YSBvbiB0aGUgcm9vdCAoZmlyc3QgdGltZSBvbmx5KVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyb290ICYmIG1ldGFkYXRhID09PSBLSFJfbWF0ZXJpYWxzX3ZhcmlhbnRzLl9HZXRFeHRlbnNpb25NZXRhZGF0YShyb290KSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBDb3B5IG1haW4gbWV0YWRhdGFcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Um9vdC5faW50ZXJuYWxNZXRhZGF0YSA9IHt9O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGtleSBpbiByb290Ll9pbnRlcm5hbE1ldGFkYXRhKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdSb290Ll9pbnRlcm5hbE1ldGFkYXRhW2tleV0gPSByb290Ll9pbnRlcm5hbE1ldGFkYXRhW2tleV07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIENvcHkgdGhlIGdsdGYgbWV0YWRhdGFcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Um9vdC5faW50ZXJuYWxNZXRhZGF0YS5nbHRmID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qga2V5IGluIHJvb3QuX2ludGVybmFsTWV0YWRhdGEuZ2x0Zikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Um9vdC5faW50ZXJuYWxNZXRhZGF0YS5nbHRmW2tleV0gPSByb290Ll9pbnRlcm5hbE1ldGFkYXRhLmdsdGZba2V5XTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gRHVwbGljYXRlIHRoZSBleHRlbnNpb24gc3BlY2lmaWMgbWV0YWRhdGFcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Um9vdC5faW50ZXJuYWxNZXRhZGF0YS5nbHRmW05BTUVdID0geyBsYXN0U2VsZWN0ZWQ6IG51bGwsIG9yaWdpbmFsOiBbXSwgdmFyaWFudHM6IHt9IH07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb3JpZ2luYWwgb2YgbWV0YWRhdGEub3JpZ2luYWwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld1Jvb3QuX2ludGVybmFsTWV0YWRhdGEuZ2x0ZltOQU1FXS5vcmlnaW5hbC5wdXNoKHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNoOiBvcmlnaW5hbC5tZXNoLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hdGVyaWFsOiBvcmlnaW5hbC5tYXRlcmlhbCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qga2V5IGluIG1ldGFkYXRhLnZhcmlhbnRzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKG1ldGFkYXRhLnZhcmlhbnRzLCBrZXkpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3Um9vdC5faW50ZXJuYWxNZXRhZGF0YS5nbHRmW05BTUVdLnZhcmlhbnRzW2tleV0gPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHZhcmlhbnRFbnRyeSBvZiBtZXRhZGF0YS52YXJpYW50c1trZXldKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld1Jvb3QuX2ludGVybmFsTWV0YWRhdGEuZ2x0ZltOQU1FXS52YXJpYW50c1trZXldLnB1c2goe1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzaDogdmFyaWFudEVudHJ5Lm1lc2gsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXRlcmlhbDogdmFyaWFudEVudHJ5Lm1hdGVyaWFsLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1ldGFkYXRhID0gbmV3Um9vdC5faW50ZXJuYWxNZXRhZGF0YS5nbHRmW05BTUVdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gUmVsb2NhdGVcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHRhcmdldCBvZiBtZXRhZGF0YSEub3JpZ2luYWwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldC5tZXNoID09PSBiYWJ5bG9uTWVzaCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0Lm1lc2ggPSBuZXdNZXNoO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgdGFyZ2V0IG9mIG1ldGFkYXRhIS52YXJpYW50c1t2YXJpYW50Lm5hbWVdKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0YXJnZXQubWVzaCA9PT0gYmFieWxvbk1lc2gpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldC5tZXNoID0gbmV3TWVzaDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICApO1xyXG4gICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5hbGwocHJvbWlzZXMpLnRoZW4oKFtiYWJ5bG9uTWVzaF0pID0+IHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBiYWJ5bG9uTWVzaDtcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcbn1cclxuXHJcbkdMVEZMb2FkZXIuUmVnaXN0ZXJFeHRlbnNpb24oTkFNRSwgKGxvYWRlcikgPT4gbmV3IEtIUl9tYXRlcmlhbHNfdmFyaWFudHMobG9hZGVyKSk7XHJcbiIsIi8qIGVzbGludC1kaXNhYmxlIEB0eXBlc2NyaXB0LWVzbGludC9uYW1pbmctY29udmVudGlvbiAqL1xyXG5pbXBvcnQgdHlwZSB7IE51bGxhYmxlIH0gZnJvbSBcImNvcmUvdHlwZXNcIjtcclxuaW1wb3J0IHsgUEJSTWF0ZXJpYWwgf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cGxlciA9IHRleHR1cmUuc2FtcGxlciA9PSB1bmRlZmluZWQgPyBHTFRGTG9hZGVyLkRlZmF1bHRTYW1wbGVyIDogQXJyYXlJdGVtLkdldChgJHtjb250ZXh0fS9zYW1wbGVyYCwgdGhpcy5fbG9hZGVyLmdsdGYuc2FtcGxlcnMsIHRleHR1cmUuc2FtcGxlcik7XHJcbiAgICAgICAgICAgIGNvbnN0IGltYWdlID0gQXJyYXlJdGVtLkdldChgJHtleHRlbnNpb25Db250ZXh0fS9zb3VyY2VgLCB0aGlzLl9sb2FkZXIuZ2x0Zi5pbWFnZXMsIGV4dGVuc2lvbi5zb3VyY2UpO1xyXG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fbG9hZGVyLl9jcmVhdGVUZXh0dXJlQXN5bmMoXHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LFxyXG4gICAgICAgICAgICAgICAgc2FtcGxlcixcclxuICAgICAgICAgICAgICAgIGltYWdlLFxyXG4gICAgICAgICAgICAgICAgKGJhYnlsb25UZXh0dXJlKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgYXNzaWduKGJhYnlsb25UZXh0dXJlKTtcclxuICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICB0ZXh0dXJlLl90ZXh0dXJlSW5mby5ub25Db2xvckRhdGEgPyB7IHVzZVJHQkFJZkFTVENCQzdOb3RBdmFpbGFibGVXaGVuVUFTVEM6IHRydWUgfSA6IHVuZGVmaW5lZCxcclxuICAgICAgICAgICAgICAgICF0ZXh0dXJlLl90ZXh0dXJlSW5mby5ub25Db2xvckRhdGFcclxuICAgICAgICAgICAgKTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxufVxyXG5cclxuR0xURkxvYWRlci5SZWdpc3RlckV4dGVuc2lvbihOQU1FLCAobG9hZGVyKSA9PiBuZXcgS0hSX3RleHR1cmVfYmFzaXN1KGxvYWRlcikpO1xyXG4iLCJpbXBvcnQgdHlwZSB7IE51bGxhYmx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RlbnNpb25Db250ZXh0LCBleHRlbnNpb24pID0+IHtcclxuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2xvYWRlci5sb2FkVGV4dHVyZUluZm9Bc3luYyhjb250ZXh0LCB0ZXh0dXJlSW5mbywgKGJhYnlsb25UZXh0dXJlKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBpZiAoIShiYWJ5bG9uVGV4dHVyZSBpbnN0YW5jZW9mIFRleHR1cmUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGAke2V4dGVuc2lvbkNvbnRleHR9OiBUZXh0dXJlIHR5cGUgbm90IHN1cHBvcnRlZGApO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGlmIChleHRlbnNpb24ub2Zmc2V0KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvblRleHR1cmUudU9mZnNldCA9IGV4dGVuc2lvbi5vZmZzZXRbMF07XHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvblRleHR1cmUudk9mZnNldCA9IGV4dGVuc2lvbi5vZmZzZXRbMV07XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgLy8gQWx3YXlzIHJvdGF0ZSBhcm91bmQgdGhlIG9yaWdpbi5cclxuICAgICAgICAgICAgICAgIGJhYnlsb25UZXh0dXJlLnVSb3RhdGlvbkNlbnRlciA9IDA7XHJcbiAgICAgICAgICAgICAgICBiYWJ5bG9uVGV4dHVyZS52Um90YXRpb25DZW50ZXIgPSAwO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmIChleHRlbnNpb24ucm90YXRpb24pIHtcclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uVGV4dHVyZS53QW5nID0gLWV4dGVuc2lvbi5yb3RhdGlvbjtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoZXh0ZW5zaW9uLnNjYWxlKSB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pdHRlcnNSZWZlcmVuY2UsIFRyYW5zZm9ybU5vZGU+KGNvbnRleHQsIG5vZGUsIHRoaXMubmFtZSwgKGV4dGVuc2lvbkNvbnRleHQsIGV4dGVuc2lvbikgPT4ge1xyXG4gICAgICAgICAgICBjb25zdCBwcm9taXNlcyA9IG5ldyBBcnJheTxQcm9taXNlPGFueT4+KCk7XHJcblxyXG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fbG9hZGVyXHJcbiAgICAgICAgICAgICAgICAubG9hZE5vZGVBc3luYyhleHRlbnNpb25Db250ZXh0LCBub2RlLCAoYmFieWxvbk1lc2gpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVtaXR0ZXJJbmRleCBvZiBleHRlbnNpb24uZW1pdHRlcnMpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZW1pdHRlciA9IEFycmF5SXRlbS5HZXQoYCR7ZXh0ZW5zaW9uQ29udGV4dH0vZW1pdHRlcnNgLCB0aGlzLl9lbWl0dGVycywgZW1pdHRlckluZGV4KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcHJvbWlzZXMucHVzaChcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRFbWl0dGVyQXN5bmMoYCR7ZXh0ZW5zaW9uQ29udGV4dH0vZW1pdHRlcnMvJHtlbWl0dGVyLmluZGV4fWAsIGVtaXR0ZXIpLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgc291bmQgb2YgZW1pdHRlci5fYmFieWxvblNvdW5kcykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VuZC5hdHRhY2hUb01lc2goYmFieWxvbk1lc2gpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW1pdHRlci5pbm5lckFuZ2xlICE9IHVuZGVmaW5lZCB8fCBlbWl0dGVyLm91dGVyQW5nbGUgIT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VuZC5zZXRMb2NhbERpcmVjdGlvblRvTWVzaChWZWN0b3IzLkZvcndhcmQoKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VuZC5zZXREaXJlY3Rpb25hbENvbmUoXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMiAqIFRvb2xzLlRvRGVncmVlcyhlbWl0dGVyLmlubmVyQW5nbGUgPT0gdW5kZWZpbmVkID8gTWF0aC5QSSA6IGVtaXR0ZXIuaW5uZXJBbmdsZSksXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMiAqIFRvb2xzLlRvRGVncmVlcyhlbWl0dGVyLm91dGVyQW5nbGUgPT0gdW5kZWZpbmVkID8gTWF0aC5QSSA6IGVtaXR0ZXIub3V0ZXJBbmdsZSksXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBhc3NpZ24oYmFieWxvbk1lc2gpO1xyXG4gICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgICAgIC50aGVuKChiYWJ5bG9uTWVzaCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBiYWJ5bG9uTWVzaDtcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQGludGVybmFsXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBsb2FkQW5pbWF0aW9uQXN5bmMoY29udGV4dDogc3RyaW5nLCBhbmltYXRpb246IElBbmltYXRpb24pOiBOdWxsYWJsZTxQcm9taXNlPEFuaW1hdGlvbkdyb3VwPj4ge1xyXG4gICAgICAgIHJldHVybiBHTFRGTG9hZGVyLkxvYWRFeHRlbnNpb25Bc3luYzxJTG9hZGVyQW5pbWF0aW9uRXZlbnRzLCBBbmltYXRpb25Hcm91cD4oY29udGV4dCwgYW5pbWF0aW9uLCB0aGlzLm5hbWUsIChleHRlbnNpb25Db250ZXh0LCBleHRlbnNpb24pID0+IHtcclxuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2xvYWRlci5sb2FkQW5pbWF0aW9uQXN5bmMoY29udGV4dCwgYW5pbWF0aW9uKS50aGVuKChiYWJ5bG9uQW5pbWF0aW9uR3JvdXApID0+IHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IHByb21pc2VzID0gbmV3IEFycmF5PFByb21pc2U8YW55Pj4oKTtcclxuXHJcbiAgICAgICAgICAgICAgICBBcnJheUl0ZW0uQXNzaWduKGV4dGVuc2lvbi5ldmVudHMpO1xyXG4gICAgICAgICAgICAgICAgZm9yIChjb25zdCBldmVudCBvZiBleHRlbnNpb24uZXZlbnRzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcHJvbWlzZXMucHVzaCh0aGlzLl9sb2FkQW5pbWF0aW9uRXZlbnRBc3luYyhgJHtleHRlbnNpb25Db250ZXh0fS9ldmVudHMvJHtldmVudC5pbmRleH1gLCBjb250ZXh0LCBhbmltYXRpb24sIGV2ZW50LCBiY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jbGlwLl9vYmplY3RVUkwgPSBwcm9taXNlLnRoZW4oKGRhdGEpID0+IHtcclxuICAgICAgICAgICAgcmV0dXJuIFVSTC5jcmVhdGVPYmplY3RVUkwobmV3IEJsb2IoW2RhdGFdLCB7IHR5cGU6IGNsaXAubWltZVR5cGUgfSkpO1xyXG4gICAgICAgIH0pO1xyXG5cclxuICAgICAgICByZXR1cm4gY2xpcC5fb2JqZWN0VVJMO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX2xvYWRFbWl0dGVyQXN5bmMoY29udGV4dDogc3RyaW5nLCBlbWl0dGVyOiBJTG9hZGVyRW1pdHRlcik6IFByb21pc2U8dm9pZD4ge1xyXG4gICAgICAgIGVtaXR0ZXIuX2JhYnlsb25Tb3VuZHMgPSBlbWl0dGVyLl9iYWJ5bG9uU291bmRzIHx8IFtdO1xyXG4gICAgICAgIGlmICghZW1pdHRlci5fYmFieWxvbkRhdGEpIHtcclxuICAgICAgICAgICAgY29uc3QgY2xpcFByb21pc2VzID0gbmV3IEFycmF5PFByb21pc2U8YW55Pj4oKTtcclxuICAgICAgICAgICAgY29uc3QgbmFtZSA9IGVtaXR0ZXIubmFtZSB8fCBgZW1pdHRlciR7ZW1pdHRlci5pbmRleH1gO1xyXG4gICAgICAgICAgICBjb25zdCBvcHRpb25zID0ge1xyXG4gICAgICAgICAgICAgICAgbG9vcDogZmFsc2UsXHJcbiAgICAgICAgICAgICAgICBhdXRvcGxheTogZmFsc2UsXHJcbiAgICAgICAgICAgICAgICB2b2x1bWU6IGVtaXR0ZXIudm9sdW1lID09IHVuZGVmaW5lZCA/IDEgOiBlbWl0dGVyLnZvbHVtZSxcclxuICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZW1pdHRlci5jbGlwcy5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgY2xpcENvbnRleHQgPSBgL2V4dGVuc2lvbnMvJHt0a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oY2xpcFByb21pc2VzKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IHdlaWdodHMgPSBlbWl0dGVyLmNsaXBzLm1hcCgoY2xpcCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBjbGlwLndlaWdodCB8fCAxO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICBjb25zdCB3ZWlnaHRlZFNvdW5kID0gbmV3IFdlaWdodGVkU291bmQoZW1pdHRlci5sb29wIHx8IGZhbHNlLCBlbWl0dGVyLl9iYWJ5bG9uU291bmRzLCB3ZWlnaHRzKTtcclxuICAgICAgICAgICAgICAgIGlmIChlbWl0dGVyLmlubmVyQW5nbGUpIHtcclxuICAgICAgICAgICAgICAgICAgICB3ZWlnaHRlZFNvdW5kLmRpcmVjdGlvbmFsQ29uZUlubmVyQW5nbGUgPSAyICogVG9vbHMuVG9EZWdyZWVzKGVtaXR0ZXIuaW5uZXJBbmdsZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoZW1pdHRlci5vdXRlckFuZ2xlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgd2VpZ2h0ZWRTb3VuZC5kaXJlY3Rpb25hbENvbmVPdXRlckFuZ2xlID0gMiAqIFRvb2xzLlRvRGVncmVlcyhlbWl0dGVyLm91dGVyQW5nbGUpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKGVtaXR0ZXIudm9sdW1lKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgd2VpZ2h0ZWRTb3VuZC52b2x1bWUgPSBlbWl0dGVyLnZvbHVtZTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGVtaXR0ZXIuX2JhYnlsb25EYXRhIS5zb3VuZCA9IHdlaWdodGVkU291bmQ7XHJcbiAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICAgICAgZW1pdHRlci5fYmFieWxvbkRhdGEgPSB7XHJcbiAgICAgICAgICAgICAgICBsb2FkZWQ6IHByb21pc2UsXHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICByZXR1cm4gZW1pdHRlci5fYmFieWxvbkRhdGEubG9hZGVkO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX2dldEV2ZW50QWN0aW9uKFxyXG4gICAgICAgIGNvbnRleHQ6IHN0cmluZyxcclxuICAgICAgICBzb3VuZDogV2VpZ2h0ZWRTb3VuZCxcclxuICAgICAgICBhY3Rpb246IElNU0ZUQXVkaW9FbWl0dGVyX0FuaW1hdGlvbkV2ZW50QWN0aW9uLFxyXG4gICAgICAgIHRpbWU6IG51bWJlcixcclxuICAgICAgICBzdGFydE9mZnNldD86IG51bWJlclxyXG4gICAgKTogKGN1cnJlbnRGcmFtZTogbnVtYmVyKSA9PiB2b2lkIHtcclxuICAgICAgICBzd2l0Y2ggKGFjdGlvbikge1xyXG4gICAgICAgICAgICBjYXNlIElNU0ZUQXVkaW9FbWl0dGVyX0FuaW1hdGlvbkV2ZW50QWN0aW9uLnBsYXk6IHtcclxuICAgICAgICAgICAgICAgIHJldHVybiAoY3VycmVudEZyYW1lOiBudW1iZXIpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCBmcmFtZU9mZnNldCA9IChzdGFydE9mZnNldCB8fCAwKSArIChjdXJyZW50RnJhbWUgLSB0aW1lKTtcclxuICAgICAgICAgICAgICAgICAgICBzb3VuZC5wbGF5KGZyYW1lT2Zmc2V0KTtcclxuICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY2FzZSBJTVNGVEF1ZGlvRW1pdHRlcl9BbmltYXRpb25FdmVudEFjdGlvbi5zdG9wOiB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHNvdW5kLnN0b3AoKTtcclxuICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY2FzZSBJTVNGVEF1ZGlvRW1pdHRlcl9BbmltYXRpb25FdmVudEFjdGlvbi5wYXVzZToge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuICgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICBzb3VuZC5wYXVzZSgpO1xyXG4gICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBkZWZhdWx0OiB7XHJcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYCR7Y29udGV4dH06IFVuc3VwcG9ydGVkIGFjdGlvbiAke2FjdGlvbn1gKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9sb2FkQW5pbWF0aW9uRXZlbnRBc3luYyhcclxuICAgICAgICBjb250ZXh0OiBzdHJpbmcsXHJcbiAgICAgICAgYW5pbWF0aW9uQ29udGV4dDogc3RyaW5nLFxyXG4gICAgICAgIGFuaW1hdGlvbjogSUFuaW1hdGlvbixcclxuICAgICAgICBldmVudDogSUxvYWRlckFuaW1hdGlvbkV2ZW50LFxyXG4gICAgICAgIGJhYnlsb25BbmltYXRpb25Hcm91cDogQW5pbWF0aW9uR3JvdXBcclxuICAgICk6IFByb21pc2U8dm9pZD4ge1xyXG4gICAgICAgIGlmIChiYWJ5bG9uQW5pbWF0aW9uR3JvdXAudGFyZ2V0ZWRBbmltYXRpb25zLmxlbmd0aCA9PSAwKSB7XHJcbiAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlc29sdmUoKTtcclxuICAgICAgICB9XHJcbiAgICAgICAgY29uc3QgYmFieWxvbkFuaW1hdGlvbiA9IGJhYnlsb25BbmltYXRpb25Hcm91cC50YXJnZXRlZEFuaW1hdGlvbnNbMF07XHJcbiAgICAgICAgY29uc3QgZW1pdHRlckluZGV4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luZGV4TE9EICE9PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVyLmVuZFBlcmZvcm1hbmNlQ291bnRlcihgTm9kZSBMT0QgJHtpbmRleExPRH1gKTtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZXIubG9nKGBMb2FkZWQgbm9kZSBMT0QgJHtpbmRleExPRH1gKTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICB0aGlzLm9uTm9kZUxPRHNMb2FkZWRPYnNlcnZhYmxlLm5vdGlmeU9ic2VydmVycyhpbmRleExPRCk7XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKGluZGV4TE9EICE9PSB0aGlzLl9ub2RlUHJvbWlzZUxPRHMubGVuZ3RoIC0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlci5zdGFydFBlcmZvcm1hbmNlQ291bnRlcihgTm9kZSBMT0QgJHtpbmRleExPRCArIDF9YCk7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZEJ1ZmZlckxPRCh0aGlzLl9ub2RlQnVmZmVyTE9EcywgaW5kZXhMT0QgKyAxKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fbm9kZVNpZ25hbExPRHNbaW5kZXhMT0RdKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX25vZGVTaWduYWxMT0RzW2luZGV4TE9EXS5yZXNvbHZlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9KTtcclxuXHJcbiAgICAgICAgICAgIHRoaXMuX2xvYWRlci5fY29tcGxldGVQcm9taXNlcy5wdXNoKHByb21pc2UpO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgZm9yIChsZXQgaW5kZXhMT0QgPSAwOyBpbmRleExPRCA8IHRoaXMuX21hdGVyaWFsUHJ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ICBjb25zdCBub2RlTE9EcyA9IHRoaXMuX2dldExPRHMoZXh0ZW5zaW9uQ29udGV4dCwgbm9kZSwgdGhpcy5fbG9hZGVyLmdsdGYubm9kZXMsIGV4dGVuc2lvbi5pZHMpO1xyXG4gICAgICAgICAgICB0aGlzLl9sb2FkZXIubG9nT3BlbihgJHtleHRlbnNpb25Db250ZXh0fWApO1xyXG5cclxuICAgICAgICAgICAgZm9yIChsZXQgaW5kZXhMT0QgPSAwOyBpbmRleExPRCA8IG5vZGVMT0RzLmxlbmd0aDsgaW5kZXhMT0QrKykge1xyXG4gICAgICAgICAgICAgICAgY29uc3Qgbm9kZUxPRCA9IG5vZGVMT0RzW2luZGV4TE9EXTtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXhMT0QgIT09IDApIHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9ub2RlSW5kZXhMT0QgPSBpbmRleExPRDtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9ub2RlU2lnbmFsTE9Ec1tpbmRleExPRF0gPSB0aGlzLl9ub2RlU2lnbmFsTE9Ec1tpbmRleExPRF0gfHwgbmV3IERlZmVycmVkKCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgY29uc3QgYXNzaWduV3JhcCA9IChiYWJ5bG9uVHJhbnNmb3JtTm9kZTogVHJhbnNmb3JtTm9kZSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIGFzc2lnbihiYWJ5bG9uVHJhbnNmb3JtTm9kZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvblRyYW5zZm9ybU5vZGUuc2V0RW5hYmxlZChmYWxzZSk7XHJcbiAgICAgICAgICAgICAgICB9O1xyXG5cclxuICAgICAgICAgICAgICAgIGNvbnN0IHByb21pc2UgPSB0aGlzLl9sb2FkZXIubG9hZE5vZGVBc3luYyhgL25vZGVzLyR7bm9kZUxPRC5pbmRleH1gLCBub2RlTE9ELCBhc3NpZ25XcmFwKS50aGVuKChiYWJ5bG9uTWVzaCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChpbmRleExPRCAhPT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBUT0RPOiBzaG91bGQgbm90IHJlbHkgb24gX2JhYnlsb25UcmFuc2Zvcm1Ob2RlXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHByZXZpb3VzTm9kZUxPRCA9IG5vZGVMT0RzW2luZGV4TE9EIC0gMV07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwcmV2aW91c05vZGVMT0QuX2JhYnlsb25UcmFuc2Zvcm1Ob2RlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kaXNwb3NlVHJhbnNmb3JtTm9kZShwcmV2aW91c05vZGVMT0QuX2JhYnlsb25UcmFuc2Zvcm1Ob2RlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBwcmV2aW91c05vZGVMT0QuX2JhYnlsb25UcmFuc2Zvcm1Ob2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uTWVzaC5zZXRFbmFibGVkKHRydWUpO1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBiYWJ5bG9uTWVzaDtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICAgICAgICAgIHRoaXMuX25vZGVQcm9taXNlTE9Ec1tpbmRleExPRF0gPSB0aGlzLl9ub2RlUHJvbWlzZUxPRHNbaW5kZXhMT0RdIHx8IFtdO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmIChpbmRleExPRCA9PT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGZpcnN0UHJvbWlzZSA9IHByb21pc2U7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX25vZGVJbmRleExPRCA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbm9kZVByb21pc2VMT0RzW2luZGV4TE9EXS5wdXNoKHByb21pc2UpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICB0aGlzLl9sb2FkZXIubG9nQ2xvc2UoKTtcclxuICAgICAgICAgICAgcmV0dXJuIGZpcnN0UHJvbWlzZSE7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBAaW50ZXJuYWxcclxuICAgICAqL1xyXG4gICAgcHVibGljIF9sb2FkTWF0ZXJpYWxBc3luYyhcclxuICAgICAgICBjb250ZXh0OiBzdHJpbmcsXHJcbiAgICAgICAgbWF0ZXJpYWw6IElNYXRlcmlhbCxcclxuICAgICAgICBiYWJ5bG9uTWVzaDogTnVsbGFibGU8TWVzaD4sXHJcbiAgICAgICAgYmFieWxvbkRyYXdNb2RlOiBudW1iZXIsXHJcbiAgICAgICAgYXNzaWduOiAoYmFieWxvbk1hdGVyaWFsOiBNYXRlcmlhbCkgPT4gdm9pZFxyXG4gICAgKTogTnVsbGFibGU8UHJvbWlzZTxNYXRlcmlhbD4+IHtcclxuICAgICAgICAvLyBEb24ndCBsb2FkIG1hdGVyaWFsIExPRHMgaWYgYWxyZWFkeSBsb2FkaW5nIGEgbm9kZSBMT0QuXHJcbiAgICAgICAgaWYgKHRoaXMuX25vZGVJbmRleExPRCkge1xyXG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBHTFRGTG9hZGVyLkxvYWRFeHRlbnNpb25Bc3luYzxJTVNGVExPRCwgTWF0ZXJpYWw+KGNvbnRleHQsIG1hdGVyaWFsLCB0aGlzLm5hbWUsIChleHRlbnNpb25Db250ZXh0LCBleHRlbnNpb24pID0+IHtcclxuICAgICAgICAgICAgbGV0IGZpcnN0UHJvbWlzZTogUHJvbWlzZTxNYXRlcmlhbD47XHJcblxyXG4gICAgICAgICAgICBjb25zdCBtYXRlcmlhbExPRHMgPSB0aGlzLl9nZXRMT0RzKGV4dGVuc2lvbkNvbnRleHQsIG1hdGVyaWFsLCB0aGlzLl9sb2FkZXIuZ2x0Zi5tYXRlcmlhbHMsIGV4dGVuc2lvbi5pZHMpO1xyXG4gICAgICAgICAgICB0aGlzLl9sb2FkZXIubG9nT3BlbihgJHtleHRlbnNpb25Db250ZXh0fWApO1xyXG5cclxuICAgICAgICAgICAgZm9yIChsZXQgaW5kZXhMT0QgPSAwOyBpbmRleExPRCA8IG1hdGVyaWFsTE9Ecy5sZW5ndGg7IGluZGV4TE9EKyspIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IG1hdGVyaWFsTE9EID0gbWF0ZXJpYWxMT0RzW2luZGV4TE9EXTtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXhMT0QgIT09IDApIHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYXRlcmlhbEluZGV4TE9EID0gaW5kZXhMT0Q7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgY29uc3QgcHJvbWlzZSA9IHRoaXMuX2xvYWRlclxyXG4gICAgICAgICAgICAgICAgICAgIC5fbG9hZE1hdGVyaWFsQXN5bmMoYC9tYXRlcmlhbHMvJHttYXRlcmlhbExPRC5pbmRleH1gLCBtYXRlcmlhbExPRCwgYmFieWxvbk1lc2gsIGJhYnlsb25EcmF3TW9kZSwgKGJhYnlsb25NYXRlcmlhbCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXhMT0QgPT09IDApIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFzc2lnbihiYWJ5bG9uTWF0ZXJpYWwpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgICAgICAgICAudGhlbigoYmFieWxvbk1hdGVyaWFsKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbmRleExPRCAhPT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYXNzaWduKGJhYnlsb25NYXRlcmlhbCk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gVE9ETzogc2hvdWxkIG5vdCByZWx5IG9uIF9kYXRhXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwcmV2aW91c0RhdGFMT0QgPSBtYXRlcmlhbExPRHNbaW5kZXhMT0QgLSAxXS5fZGF0YSE7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldmlvdXNEYXRhTE9EW2JhYnlsb25EcmF3TW9kZV0pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kaXNwb3NlTWF0ZXJpYWxzKFtwcmV2aW91c0RhdGFMT0RbYmFieWxvbkRyYXdNb2RlXS5iYWJ5bG9uTWF0ZXJpYWxdKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgcHJldmlvdXNEYXRhTE9EW2JhYnlsb25EcmF3TW9kZV07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBiYWJ5bG9uTWF0ZXJpYWw7XHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcblxyXG4gICAgICAgICAgICAgICAgdGhpcy5fbWF0ZXJpYWxQcm9taXNlTE9Ec1tpbmRleExPRF0gPSB0aGlzLl9tYXRlcmlhbFByb21pc2VMT0RzW2luZGV4TE9EXSB8fCBbXTtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXhMT0QgPT09IDApIHtcclxuICAgICAgICAgICAgICAgICAgICBmaXJzdFByb21pc2UgPSBwcm9taXNlO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYXRlcmlhbEluZGV4TE9EID0gbnVsbDtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYXRlcmlhbFByb21pc2VMT0RzW2luZGV4TE9EXS5wdXNoKHByb21pc2UpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICB0aGlzLl9sb2FkZXIubG9nQ2xvc2UoKTtcclxuICAgICAgICAgICAgcmV0dXJuIGZpcnN0UHJvbWlzZSE7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBAaW50ZXJuYWxcclxuICAgICAqL1xyXG4gICAgcHVibGljIF9sb2FkVXJpQXN5bmMoY29udGV4dDogc3RyaW5nLCBwcm9wZXJ0eTogSVByb3BlcnR5LCB1cmk6IHN0cmluZyk6IE51bGxhYmxlPFByb21pc2U8QXJyYXlCdWZmZXJWaWV3Pj4ge1xyXG4gICAgICAgIC8vIERlZmVyIHRoZSBsb2FkaW5nIG9mIHVyaXMgaWYgbG9hZGluZyBhIG5vZGUgb3IgbWF0ZXJpYWwgTE9ELlxyXG4gICAgICAgIGlmICh0aGlzLl9ub2RlSW5kZXhMT0QgIT09IG51bGwpIHtcclxuICAgICAgICAgICAgdGhpcy5fbG9hZGVyLmxvZyhgZGVmZXJyZWRgKTtcclxuICAgICAgICAgICAgY29uc3QgcHJldmlvdXNJbmRleExPRCA9IHRoaXMuX25vZGVJbmRleExPRCAtIDE7XHJcbiAgICAgICAgICAgIHRoaXMuX25vZGVTaWduYWxMT0RzW3ByZXZpb3VzSW5kZXhMT0RdID0gdGhpcy5fbm9kZVNpZ25hbExPRHNbcHJldmlvdXNJbmRleEx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Q6IHN0YXJ0LCBlbmQ6IGVuZCwgbG9hZGVkOiBuZXcgRGVmZXJyZWQoKSB9O1xyXG4gICAgICAgICAgICAgICAgICAgIGJ1ZmZlckxPRHNbaW5kZXhMT0RdID0gYnVmZmVyTE9EO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIHJldHVybiBidWZmZXJMT0QubG9hZGVkLnByb21pc2UudGhlbigoZGF0YSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgVWludDhBcnJheShkYXRhLmJ1ZmZlciwgZGF0YS5ieXRlT2Zmc2V0ICsgYnl0ZU9mZnNldCAtIGJ1ZmZlckxPRC5zdGFydCwgYnl0ZUxlbmd0aCk7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgIHRoaXMuX2xvYWRlci5sb2coYGRlZmVycmVkYCk7XHJcblxyXG4gICAgICAgICAgICBpZiAodGhpcy5fbm9kZUluZGV4TE9EICE9PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gbG9hZEFzeW5jKHRoaXMuX25vZGVCdWZmZXJMT0RzLCB0aGlzLl9ub2RlSW5kZXhMT0QpO1xyXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX21hdGVyaWFsSW5kZXhMT0QgIT09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBsb2FkQXN5bmModGhpcy5fbWF0ZXJpYWxCdWZmZXJMT0RzLCB0aGlzLl9tYXRlcmlhbEluZGV4TE9EKTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBsb2FkQXN5bmModGhpcy5fYnVmZmVyTE9EcywgMCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBudWxsO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUg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WFscykge1xyXG4gICAgICAgICAgICBmb3IgKGNvbnN0IGJhYnlsb25UZXh0dXJlIG9mIGJhYnlsb25NYXRlcmlhbC5nZXRBY3RpdmVUZXh0dXJlcygpKSB7XHJcbiAgICAgICAgICAgICAgICBiYWJ5bG9uVGV4dHVyZXNbYmFieWxvblRleHR1cmUudW5pcXVlSWRdID0gYmFieWxvblRleHR1cmU7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGJhYnlsb25NYXRlcmlhbC5kaXNwb3NlKCk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBmb3IgKGNvbnN0IHVuaXF1ZUlkIGluIGJhYnlsb25UZXh0dXJlcykge1xyXG4gICAgICAgICAgICBmb3IgKGNvbnN0IGJhYnlsb25NYXRlcmlhbCBvZiB0aGlzLl9sb2FkZXIuYmFieWxvblNjZW5lLm1hdGVyaWFscykge1xyXG4gICAgICAgICAgICAgICAgaWYgKGJhYnlsb25NYXRlcmlhbC5oYXNUZXh0dXJlKGJhYnlsb25UZXh0dXJlc1t1bmlxdWVJZF0pKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlIGJhYnlsb25UZXh0dXJlc1t1bmlxdWVJZF07XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGZvciAoY29uc3QgdW5pcXVlSWQgaW4gYmFieWxvblRleHR1cmVzKSB7XHJcbiAgICAgICAgICAgIGJhYnlsb25UZXh0dXJlc1t1bmlxdWVJZF0uZGlzcG9zZSgpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxufVxyXG5cclxuR0xURkxvYWRlci5SZWdpc3RlckV4dGVuc2lvbihOQU1FLCAobG9hZGVyKSA9PiBuZXcgTVNGVF9sb2QobG9hZGVyKSk7XHJcbiIsImltcG9ydCB0eXBlIHsgTnVsbGFibGUgfSBmcm9tIFwiY29yZS90eXBlc1wiO1xyXG5pbXBvcnQ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FwiL21hdGVyaWFscy8yL3Bick1ldGFsbGljUm91Z2huZXNzL2Jhc2VDb2xvckZhY3RvclwiXHJcbiAgICAgKiAgLSBcIi9tYXRlcmlhbHMvMi9leHRlbnNpb25zL0tIUl9tYXRlcmlhbHNfZW1pc3NpdmVfc3RyZW5ndGgvZW1pc3NpdmVTdHJlbmd0aFwiXHJcbiAgICAgKlxyXG4gICAgICogQHBhcmFtIHBhdGggVGhlIHBhdGggdG8gY29udmVydFxyXG4gICAgICogQHJldHVybnMgVGhlIG9iamVjdCBhbmQgaW5mbyBhc3NvY2lhdGVkIHdpdGggdGhlIHBhdGhcclxuICAgICAqL1xyXG4gICAgcHVibGljIGNvbnZlcnQocGF0aDogc3RyaW5nKTogSU9iamVjdEluZm88VD4ge1xyXG4gICAgICAgIGxldCBvYmplY3RUcmVlOiBhbnkgPSB0aGlzLl9nbHRmO1xyXG4gICAgICAgIGxldCBpbmZvVHJlZTogYW55ID0gdGhpcy5faW5mb1RyZWU7XHJcbiAgICAgICAgbGV0IHRhcmdldDogYW55ID0gdW5kZWZpbmVkO1xyXG5cclxuICAgICAgICBpZiAoIXBhdGguc3RhcnRzV2l0aChcIi9cIikpIHtcclxuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiUGF0aCBtdXN0IHN0YXJ0IHdpdGggYSAvXCIpO1xyXG4gICAgICAgIH1cclxuICAgICAgICBjb25zdCBwYXJ0cyA9IHBhdGguc3BsaXQoXCIvXCIpO1xyXG4gICAgICAgIHBhcnRzLnNoaWZ0KCk7XHJcblxyXG4gICAgICAgIGZvciAoY29uc3QgcGFydCBvZiBwYXJ0cykge1xyXG4gICAgICAgICAgICBpZiAoaW5mb1RyZWUuX19hcnJheV9fKSB7XHJcbiAgICAgICAgICAgICAgICBpbmZvVHJlZSA9IGluZm9UcmVlLl9fYXJyYXlfXztcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGluZm9UcmVlID0gaW5mb1RyZWVbcGFydF07XHJcbiAgICAgICAgICAgICAgICBpZiAoIWluZm9UcmVlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBQYXRoICR7cGF0aH0gaXMgaW52YWxpZGApO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChvYmplY3RUcmVlID09PSB1bmRlZmluZWQpIHtcclxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgUGF0aCAke3BhdGh9IGlzIGludmFsaWRgKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBvYmplY3RUcmVlID0gb2JqZWN0VHJlZVtwYXJ0XTtcclxuXHJcbiAgICAgICAgICAgIGlmIChpbmZvVHJlZS5fX3RhcmdldF9fKSB7XHJcbiAgICAgICAgICAgICAgICB0YXJnZXQgPSBvYmplY3RUcmVlO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICByZXR1cm4ge1xyXG4gICAgICAgICAgICBvYmplY3Q6IHRhcmdldCxcclxuICAgICAgICAgICAgaW5mbzogaW5mb1RyZWUsXHJcbiAgICAgICAgfTtcclxuICAgIH1cclxufVxyXG4iLCJleHBvcnQgKiBmcm9tIFwiLi9FWFRfbGlnaHRzX2ltYWdlX2Jhc2VkXCI7XHJcbmV4cG9ydCAqIGZyb20gXCIuL0VYVF9tZXNoX2dwdV9pbnN0YW5jaW5nXCI7XHJcbmV4cG9ydCAqIGZyb20gXCIuL0VYVF9tZXNob3B0X2NvbXByZXNzaW9uXCI7XHJcbmV4cG9ydCAqIGZyb20gXCIuL0VYVF90ZXh0dXJlX3dlYnBcIjtcclxuZXhwb3J0ICogZnJvbSBcIi4vS0hSX2RyYWNvX21lc2hfY29tcHJlc3Npb25cIjtcclxuZXhwb3J0ICogZnJvbSBcIi4vS0hSX2xpZ2h0c19wdW5jdHVhbFwiO1xyXG5leHBvcnQgKiBmcm9tIFwiL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Zmxvd3MgPz8gW107XHJcbiAgICAgICAgLy8gZm9yIGVhY2ggb3V0cHV0IGZsb3cgb2YgdGhlIGdsdGYgYmxvY2tcclxuICAgICAgICBmb3IgKGNvbnN0IGZsb3cgb2YgZ2x0ZkZsb3dzKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IHNvY2tldE91dE5hbWUgPSBmbG93LmlkO1xyXG4gICAgICAgICAgICAvLyBjcmVhdGUgYW4gb3V0cHV0IGNvbm5lY3Rpb24gZm9yIHRoZSBmbG93IGdyYXBoIGJsb2NrXHJcbiAgICAgICAgICAgIGNvbnN0IHNvY2tldE91dDogSVNlcmlhbGl6ZWRGbG93R3JhcGhDb25uZWN0aW9uID0ge1xyXG4gICAgICAgICAgICAgICAgdW5pcXVlSWQ6IFJhbmRvbUdVSUQoKSxcclxuICAgICAgICAgICAgICAgIG5hbWU6IHNvY2tldE91dE5hbWUsXHJcbiAgICAgICAgICAgICAgICBfY29ubmVjdGlvblR5cGU6IEZsb3dHcmFwaENvbm5lY3Rpb25UeXBlLk91dHB1dCwgLy8gT3V0cHV0XHJcbiAgICAgICAgICAgICAgICBjb25uZWN0ZWRQb2ludElkczogW10sXHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIGZnQmxvY2suc2lnbmFsT3V0cHV0cy5wdXNoKHNvY2tldE91dCk7XHJcbiAgICAgICAgICAgIC8vIGdldCB0aGUgaW5wdXQgbm9kZSBvZiB0aGlzIGZsb3dcclxuICAgICAgICAgICAgY29uc3Qgbm9kZUluSWQgPSBmbG93Lm5vZGU7XHJcbiAgICAgICAgICAgIGNvbnN0IG5vZGVJblNvY2tldE5hbWUgPSBmbG93LnNvY2tldDtcclxuICAgICAgICAgICAgLy8gZmluZCB0aGUgY29ycmVzcG9uZGluZyBmbG93IGdyYXBoIG5vZGVcclxuICAgICAgICAgICAgY29uc3Qgbm9kZUluID0gZmxvd0dyYXBoSnNvbkJsb2Nrc1tub2RlSW5JZF07XHJcbiAgICAgICAgICAgIGlmICghbm9kZUluKSB7XHJcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXHJcbiAgICAgICAgICAgICAgICAgICAgYC9leHRlbnNpb25zL0tIUl9pbnRlcmFjdGl2aXR5L25vZGVzLyR7aX06IENvdWxkIG5vdCBmaW5kIG5vZGUgd2l0aCBpZCAke25vZGVJbklkfSB0aGF0IGNvbm5lY3RzIGl0cyBpbnB1dCB3aXRoIHdpdGggbm9kZSAke2l9J3Mgb3V0cHV0ICR7c29ja2V0T3V0TmFtZX1gXHJcbiAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIC8vIGluIGFsbCBvZiB0aGUgZmxvdyBncmFwaCBpbnB1dCBjb25uZWN0aW9ucywgZmluZCB0aGUgb25lIHdpdGggdGhlIHNhbWUgbmFtZSBhcyB0aGUgc29ja2V0XHJcbiAgICAgICAgICAgIGxldCBzb2NrZXRJbiA9IG5vZGVJbi5zaWduYWxJbnB1dHMuZmluZCgocykgPT4gcy5uYW1lID09PSBub2RlSW5Tb2NrZXROYW1lKTtcclxuICAgICAgICAgICAgLy8gaWYgdGhlIHNvY2tldCBkb2Vzbid0IGV4aXN0LCBjcmVhdGUgdGhlIGlucHV0IHNvY2tldCBmb3IgdGhlIGNvbm5lY3Rpb25cclxuICAgICAgICAgICAgaWYgKCFzb2NrZXRJbikge1xyXG4gICAgICAgICAgICAgICAgc29ja2V0SW4gPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdW5pcXVlSWQ6IFJhbmRvbUdVSUQoKSxcclxuICAgICAgICAgICAgICAgICAgICBuYW1lOiBub2RlSW5Tb2NrZXROYW1lLFxyXG4gICAgICAgICAgICAgICAgICAgIF9jb25uZWN0aW9uVHlwZTogRmxvd0dyYXBoQ29ubmVjdGlvblR5cGUuSW5wdXQsIC8vIElucHV0XHJcbiAgICAgICAgICAgICAgICAgICAgY29ubmVjdGVkUG9pbnRJZHM6IFtdLFxyXG4gICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgICAgIG5vZGVJbi5zaWduYWxJbnB1dHMucHVzaChzb2NrZXRJbik7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgLy8gY29ubmVjdCB0aGUgc29ja2V0c1xyXG4gICAgICAgICAgICBzb2NrZXRJbi5jb25uZWN0ZWRQb2ludElkcy5wdXNoKHNvY2tldE91dC51bmlxdWVJZCk7XHJcbiAgICAgICAgICAgIHNvY2tldE91dC5jb25uZWN0ZWRQb2ludElkcy5wdXNoKHNvY2tldEluLnVuaXF1ZUlkKTtcclxuICAgICAgICB9XHJcbiAgICAgICAgLy8gZm9yIGVhY2ggaW5wdXQgdmFsdWUgb2YgdGhlIGdsdGYgYmxvY2tcclxuICAgICAgICBjb25zdCBnbHRmVmFsdWVzID0gZ2x0ZkJsb2NrLnZhbHVlcyA/PyBbXTtcclxuICAgICAgICBmb3IgKGNvbnN0IHZhbHVlIG9mIGdsdGZWYWx1ZXMpIHtcclxuICAgICAgICAgICAgY29uc3Qgc29ja2V0SW5OYW1lID0gdmFsdWUuaWQ7XHJcbiAgICAgICAgICAgIC8vIGNyZWF0ZSBhbiBpbnB1dCBkYXRhIGNvbm5lY3Rpb24gZm9yIHRoZSBmbG93IGdyYXBoIGJsb2NrXHJcbiAgICAgICAgICAgIGNvbnN0IHNvY2tldEluOiBJU2VyaWFsaXplZEZsb3dHcmFwaENvbm5lY3Rpb24gPSB7XHJcbiAgICAgICAgICAgICAgICB1bmlxdWVJZDogUmFuZG9tR1VJRCgpLFxyXG4gICAgICAgICAgICAgICAgbmFtZTogc29ja2V0SW5OYW1lLFxyXG4gICAgICAgICAgICAgICAgX2Nvbm5lY3Rpb25UeXBlOiBGbG93R3JhcGhDb25uZWN0aW9uVHlwZS5JbnB1dCxcclxuICAgICAgICAgICAgICAgIGNvbm5lY3RlZFBvaW50SWRzOiBbXSxcclxuICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgZmdCbG9jay5kYXRh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GZpbmQgdGhlIGZsb3cgZ3JhcGggbm9kZSB0aGF0IG93bnMgdGhhdCBvdXRwdXQgc29ja2V0XHJcbiAgICAgICAgICAgICAgICBjb25zdCBub2RlT3V0ID0gZmxvd0dyYXBoSnNvbkJsb2Nrc1tub2RlT3V0SWRdO1xyXG4gICAgICAgICAgICAgICAgaWYgKCFub2RlT3V0KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBgL2V4dGVuc2lvbnMvS0hSX2ludGVyYWN0aXZpdHkvbm9kZXMvJHtpfTogQ291bGQgbm90IGZpbmQgbm9kZSB3aXRoIGlkICR7bm9kZU91dElkfSB0aGF0IGNvbm5lY3RzIGl0cyBvdXRwdXQgd2l0aCBub2RlJHtpfSdzIGlucHV0ICR7c29ja2V0SW5OYW1lfWBcclxuICAgICAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgbGV0IHNvY2tldE91dCA9IG5vZGVPdXQuZGF0YU91dHB1dHMuZmluZCgocykgPT4gcy5uYW1lID09PSBub2RlT3V0U29ja2V0TmFtZSk7XHJcbiAgICAgICAgICAgICAgICAvLyBpZiB0aGUgc29ja2V0IGRvZXNuJ3QgZXhpc3QsIGNyZWF0ZSBpdFxyXG4gICAgICAgICAgICAgICAgaWYgKCFzb2NrZXRPdXQpIHtcclxuICAgICAgICAgICAgICAgICAgICBzb2NrZXRPdXQgPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHVuaXF1ZUlkOiBSYW5kb21HVUlEKCksXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IG5vZGVPdXRTb2NrZXROYW1lLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBfY29ubmVjdGlvblR5cGU6IEZsb3dHcmFwaENvbm5lY3Rpb25UeXBlLk91dHB1dCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29ubmVjdGVkUG9pbnRJZHM6IFtdLFxyXG4gICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICAgICAgbm9kZU91dC5kYXRhT3V0cHV0cy5wdXNoKHNvY2tldE91dCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAvLyBjb25uZWN0IHRoZSBzb2NrZXRzXHJcbiAgICAgICAgICAgICAgICBzb2NrZXRJbi5jb25uZWN0ZWRQb2ludElkcy5wdXNoKHNvY2tldE91dC51bmlxdWVJZCk7XHJcbiAgICAgICAgICAgICAgICBzb2NrZXRPdXQuY29ubmVjdGVkUG9pbnRJZHMucHVzaChzb2NrZXRJbi51bmlxdWVJZCk7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYC9leHRlbnNpb25zL0tIUl9pbnRlcmFjdGl2aXR5L25vZGVzLyR7aX06IEludmFsaWQgc29ja2V0ICR7c29ja2V0SW5OYW1lfSBpbiBub2RlICR7aX1gKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICBjb25zdCB2YXJpYWJsZXMgPSBnbHRmLnZhcmlhYmxlcyA/PyBbXTtcclxuICAgIC8vIFBhcnNlIHZhcmlhYmxlc1xyXG4gICAgZm9yIChsZXQgaSA9IDA7IGkgPCB2YXJpYWJsZXMubGVuZ3RoOyBpKyspIHtcclxuICAgICAgICBjb25zdCB2YXJpYWJsZTogSUtIUkludGVyYWN0aXZpdHlfVmFyaWFibGUgPSB2YXJpYWJsZXNbaV07XHJcbiAgICAgICAgY29uc3QgdmFyaWFibGVOYW1lID0gdmFyaWFibGUuaWQ7XHJcbiAgICAgICAgY29udGV4dC5fdXNlclZhcmlhYmxlc1t2YXJpYWJsZU5hbWVdID0gY29udmVydFZhbHVlV2l0aFR5cGUodmFyaWFibGUgYXMgSUtIUkludGVyYWN0aXZpdHlfQ29uZm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VjdHMucmVkdWNlKChwcmV2LCBvYmopID0+IHtcclxuICAgICAgICBPYmplY3Qua2V5cyhvYmopLmZvckVhY2goKGtleSkgPT4ge1xyXG4gICAgICAgICAgICBjb25zdCBwVmFsID0gcHJldltrZXldO1xyXG4gICAgICAgICAgICBjb25zdCBvVmFsID0gb2JqW2tleV07XHJcblxyXG4gICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShwVmFsKSAmJiBBcnJheS5pc0FycmF5KG9WYWwpKSB7XHJcbiAgICAgICAgICAgICAgICBwcmV2W2tleV0gPSBwVmFsLmNvbmNhdCguLi5vVmFsKTtcclxuICAgICAgICAgICAgfSBlbHNlIGlmIChpc09iamVjdChwVmFsKSAmJiBpc09iamVjdChvVmFsKSkge1xyXG4gICAgICAgICAgICAgICAgcHJldltrZXldID0gbWVyZ2VEZWVwKHBWYWwsIG9WYWwpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgcHJldltrZXldID0gb1ZhbDtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0pO1xyXG5cclxuICAgICAgICByZXR1cm4gcHJldjtcclxuICAgIH0sIHt9KTtcclxufVxyXG5cclxuLyoqXHJcbiAqIEhlbHBlciBjbGFzcyBmb3Igd29ya2luZyB3aXRoIGFycmF5cyB3aGVuIGxvYWRpbmcgdGhlIGdsVEYgYXNzZXRcclxuICovXHJcbmV4cG9ydCBjbGFzcyBBcnJheUl0ZW0ge1xyXG4gICAgLyoqXHJcbiAgICAgKiBHZXRzIGFuIGl0ZW0gZnJvbSB0aGUgZ2l2ZW4gYXJyYXkuXHJcbiAgICAgKiBAcGFyYW0gY29udGV4dCBUaGUgY29udGV4dCB3aGVuIGxvYWRpbmcgdGhlIGFzc2V0XHJcbiAgICAgKiBAcGFyYW0gYXJyYXkgVGhlIGFycmF5IHRvIGdldCB0aGUgaXRlbSBmcm9tXHJcbiAgICAgKiBAcGFyYW0gaW5kZXggVGhlIGluZGV4IHRv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fTtcclxuICAgICAgICB0aGlzLl9wb3N0U2NlbmVMb2FkQWN0aW9ucy5sZW5ndGggPSAwO1xyXG5cclxuICAgICAgICB0aGlzLl9wYXJlbnQuZGlzcG9zZSgpO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQGludGVybmFsXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBpbXBvcnRNZXNoQXN5bmMoXHJcbiAgICAgICAgbWVzaGVzTmFtZXM6IGFueSxcclxuICAgICAgICBzY2VuZTogU2NlbmUsXHJcbiAgICAgICAgY29udGFpbmVyOiBOdWxsYWJsZTxBc3NldENvbnRhaW5lcj4sXHJcbiAgICAgICAgZGF0YTogSUdMVEZMb2FkZXJEYXRhLFxyXG4gICAgICAgIHJvb3RVcmw6IHN0cmluZyxcclxuICAgICAgICBvblByb2dyZXNzPzogKGV2ZW50OiBJU2NlbmVMb2FkZXJQcm9ncmVzc0V2ZW50KSA9PiB2b2lkLFxyXG4gICAgICAgIGZpbGVOYW1lID0gXCJcIlxyXG4gICAgKTogUHJvbWlzZTxJU2NlbmVMb2FkZXJBc3luY1Jlc3VsdD4ge1xyXG4gICAgICAgIHJldHVybiBQcm9taXNlLnJlc29sdmUoKS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgdGhpcy5fYmFieWxvblNjZW5lID0gc2NlbmU7XHJcbiAgICAgICAgICAgIHRoaXMuX2Fzc2V0Q29udGFpbmVyID0gY29udGFpbmVyO1xyXG4gICAgICAgICAgICB0aGlzLl9sb2FkRGF0YShkYXRhKTtcclxuXHJcbiAgICAgICAgICAgIGxldCBub2RlczogTnVsbGFibGU8QXJyYXk8bnVtYmVyPj4gPSBudWxsO1xyXG5cclxuICAgICAgICAgICAgaWYgKG1lc2hlc05hbWVzKSB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBub2RlTWFwOiB7IFtuYW1lOiBzdHJpbmddOiBudW1iZXIgfSA9IHt9O1xyXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2dsdGYubm9kZXMpIHtcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG5vZGUgb2YgdGhpcy5fZ2x0Zi5ub2Rlcykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobm9kZS5uYW1lKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlTWFwW25vZGUubmFtZV0gPSBub2RlLmluZGV4O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGNvbnN0IG5hbWVzID0gbWVzaGVzTmFtZXMgaW5zdGFuY2VvZiBBcnJheSA/IG1lc2hlc05hbWVzIDogW21lc2hlc05hbWVzXTtcclxuICAgICAgICAgICAgICAgIG5vZGVzID0gbmFtZXMubWFwKChuYW1lKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgbm9kZSA9IG5vZGVNYXBbbmFtZV07XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKG5vZGUgPT09IHVuZGVmaW5lZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYEZhaWxlZCB0byBmaW5kIG5vZGUgJyR7bmFtZX0nYCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gbm9kZTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fbG9hZEFzeW5jKHJvb3RVcmwsIGZpbGVOYW1lLCBub2RlcywgKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcclxuICAgICAgICAgICAgICAgICAgICBtZXNoZXM6IHRoaXMuX2dldE1lc2hlcygpLFxyXG4gICAgICAgICAgICAgICAgICAgIHBhcnRpY2xlU3lzdGVtczogW10sXHJcbiAgICAgICAgICAgICAgICAgICAgc2tlbGV0b25zOiB0aGlzLl9nZXRTa2VsZXRvbnMoKSxcclxuICAgICAgICAgICAgICAgICAgICBhbmltYXRpb25Hcm91cHM6IHRoaXMuX2dldEFuaW1hdGlvbkdyb3VwcygpLFxyXG4gICAgICAgICAgICAgICAgICAgIGxpZ2h0czogdGhpcy5fYmFieWxvbkxpZ2h0cyxcclxuICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm1Ob2RlczogdGhpcy5fZ2V0VHJhbnNmb3JtTm9kZXMoKSxcclxuICAgICAgICAgICAgICAgICAgICBnZW9tZXRyaWVzOiB0aGlzLl9nZXRHZW9tZXRyaWVzKCksXHJcbiAgICAgICAgICAgICAgICAgICAgc3ByaXRlTWFuYWdlcnM6IFtdLFxyXG4gICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgLyoqXHJcbiAgICAgKiBAaW50ZXJuYWxcclxuICAgICAqL1xyXG4gICAgcHVibGljIGxvYWRBc3luYyhzY2VuZTogU2NlbmUsIGRhdGE6IElHTFRGTG9hZGVyRGF0YSwgcm9vdFVybDogc3RyaW5nLCBvblByb2dyZXNzPzogKGV2ZW50OiBJU2NlbmVMb2FkZXJQcm9ncmVzc0V2ZW50KSA9PiB2b2lkLCBmaWxlTmFtZSA9IFwiXCIpOiBQcm9taXNlPHZvaWQ+IHtcclxuICAgICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKCkudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgIHRoaXMuX2JhYnlsb25TY2VuZSA9IHNjZW5lO1xyXG4gICAgICAgICAgICB0aGlzLl9sb2FkRGF0YShkYXRhKTtcclxuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2xvYWRBc3luYyhyb290VXJsLCBmaWxlTmFtZSwgbnVsbCwgKCkgPT4gdW5kZWZpbmVkKTtcclxuIC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iL25vZGVzXCIsIHsgbm9kZXM6IG5vZGVzLCBpbmRleDogLTEgfSkpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5fZ2x0Zi5zY2VuZSAhPSB1bmRlZmluZWQgfHwgKHRoaXMuX2dsdGYuc2NlbmVzICYmIHRoaXMuX2dsdGYuc2NlbmVzWzBdKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2VuZSA9IEFycmF5SXRlbS5HZXQoYC9zY2VuZWAsIHRoaXMuX2dsdGYuc2NlbmVzLCB0aGlzLl9nbHRmLnNjZW5lIHx8IDApO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBwcm9taXNlcy5wdXNoKHRoaXMubG9hZFNjZW5lQXN5bmMoYC9zY2VuZXMvJHtzY2VuZS5pbmRleH1gLCBzY2VuZSkpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoIXRoaXMucGFyZW50LnNraXBNYXRlcmlhbHMgJiYgdGhpcy5wYXJlbnQubG9hZEFsbE1hdGVyaWFscyAmJiB0aGlzLl9nbHRmLm1hdGVyaWFscykge1xyXG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IG0gPSAwOyBtIDwgdGhpcy5fZ2x0Zi5tYXRlcmlhbHMubGVuZ3RoOyArK20pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0ZXJpYWwgPSB0aGlzLl9nbHRmLm1hdGVyaWFsc1ttXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29udGV4dCA9IFwiL21hdGVyaWFscy9cIiArIG07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJhYnlsb25EcmF3TW9kZSA9IE1hdGVyaWFsLlRyaWFuZ2xlRmlsbE1vZGU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBwcm9taXNlcy5w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ICAgICAgICAgICB0aGlzLl9iYWJ5bG9uU2NlbmUuX2ZvcmNlQmxvY2tNYXRlcmlhbERpcnR5TWVjaGFuaXNtKG9sZEJsb2NrTWF0ZXJpYWxEaXJ0eU1lY2hhbmlzbSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3BhcmVudC5jb21waWxlTWF0ZXJpYWxzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcHJvbWlzZXMucHVzaCh0aGlzLl9jb21waWxlTWF0ZXJpYWxzQXN5bmMoKSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3BhcmVudC5jb21waWxlU2hhZG93R2VuZXJhdG9ycykge1xyXG4gICAgICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2godGhpcy5fY29tcGlsZVNoYWRvd0dlbmVyYXRvcnNBc3luYygpKTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBjb25zdCByZXN1bHRQcm9taXNlID0gUHJvbWlzZS5hbGwocHJvbWlzZXMpLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yb290QmFieWxvbk1lc2ggJiYgdGhpcy5fcm9vdEJhYnlsb25NZXNoICE9PSB0aGlzLl9wYXJlbnQuY3VzdG9tUm9vdE5vZGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcm9vdEJhYnlsb25NZXNoLnNldEVuYWJsZWQodHJ1ZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9leHRlbnNpb25zT25SZWFkeSgpO1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhcmVudC5fc2V0U3RhdGUoR0xURkxvYWRlclN0YXRlLlJFQURZKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RhcnRBbmltYXRpb25zKCk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHRGdW5jKCk7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuXHJcbiAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0UHJvbWlzZS50aGVuKChyZXN1bHQpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXJlbnQuX2VuZFBlcmZvcm1hbmNlQ291bnRlcihsb2FkaW5nVG9SZWFkeUNvdW50ZXJOYW1lKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgVG9vbHMuU2V0SW1tZWRpYXRlKCgpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9kaXNwb3NlZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgUHJvbWlzZS5hbGwodGhpcy5fY29tcGxldGVQcm9taXNlcykudGhlbihcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhcmVudC5fZW5kUGVyZm9ybWFuY2VDb3VudGVyKGxvYWRpbmdUb0NvbXBsZXRlQ291bnRlck5hbWUpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFyZW50Ll9zZXRTdGF0ZShHTFRGTG9hZGVyU3RhdGUuQ09NUExFVEUpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFyZW50Lm9uQ29tcGxldGVPYnNlcnZhYmxlLm5vdGlmeU9ic2VydmVycyh1bmRlZmluZWQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXJlbnQub25Db21wbGV0ZU9ic2VydmFibGUuY2xlYXIoKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzcG9zZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGVycm9yKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhcmVudC5vbkVycm9yT2JzZXJ2YWJsZS5ub3RpZnlPYnNlcnZlcnMoZXJyb3IpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXJlbnQub25FcnJvck9ic2VydmFibGUuY2xlYXIoKTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzcG9zZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAuY2F0Y2goKGVycm9yKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX2Rpc3Bvc2VkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFyZW50Lm9uRXJyb3JPYnNlcnZhYmxlLm5vdGlmeU9ic2VydmVycyhlcnJvcik7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFyZW50Lm9uRXJyb3JPYnNlcnZhYmxlLmNsZWFyKCk7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzcG9zZSgpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIHRocm93IGVycm9yO1xyXG4gICAgICAgICAgICB9K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AgICAgICBpZiAobm9kZS5jaGlsZHJlbikge1xyXG4gICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW5kZXggb2Ygbm9kZS5jaGlsZHJlbikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBub2RlUGFyZW50c1tpbmRleF0gPSBub2RlLmluZGV4O1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgY29uc3Qgcm9vdE5vZGUgPSB0aGlzLl9jcmVhdGVSb290Tm9kZSgpO1xyXG4gICAgICAgICAgICBmb3IgKGNvbnN0IG5vZGUgb2YgdGhpcy5fZ2x0Zi5ub2Rlcykge1xyXG4gICAgICAgICAgICAgICAgY29uc3QgcGFyZW50SW5kZXggPSBub2RlUGFyZW50c1tub2RlLmluZGV4XTtcclxuICAgICAgICAgICAgICAgIG5vZGUucGFyZW50ID0gcGFyZW50SW5kZXggPT09IHVuZGVmaW5lZCA/IHJvb3ROb2RlIDogdGhpcy5fZ2x0Zi5ub2Rlc1twYXJlbnRJbmRleF07XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfbG9hZEV4dGVuc2lvbnMoKTogdm9pZCB7XHJcbiAgICAgICAgZm9yIChjb25zdCBuYW1lIGluIEdMVEZMb2FkZXIuX1JlZ2lzdGVyZWRFeHRlbnNpb25zKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IGV4dGVuc2lvbiA9IEdMVEZMb2FkZXIuX1JlZ2lzdGVyZWRFeHRlbnNpb25zW25hbWVdLmZhY3RvcnkodGhpcyk7XHJcbiAgICAgICAgICAgIGlmIChleHRlbnNpb24ubmFtZSAhPT0gbmFtZSkge1xyXG4gICAgICAgICAgICAgICAgTG9nZ2VyLldhcm4oYFRoZSBuYW1lIG9mIHRoZSBnbFRGIGxvYWRlciBleHRlbnNpb24gaW5zdGFuY2U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gPSBmYWxzZTtcclxuICAgICAgICB0aGlzLl9yb290QmFieWxvbk1lc2guc2V0RW5hYmxlZChmYWxzZSk7XHJcblxyXG4gICAgICAgIGNvbnN0IHJvb3ROb2RlOiBJTm9kZSA9IHtcclxuICAgICAgICAgICAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIEB0eXBlc2NyaXB0LWVzbGludC9uYW1pbmctY29udmVudGlvblxyXG4gICAgICAgICAgICBfYmFieWxvblRyYW5zZm9ybU5vZGU6IHRoaXMuX3Jvb3RCYWJ5bG9uTWVzaCxcclxuICAgICAgICAgICAgaW5kZXg6IC0xLFxyXG4gICAgICAgIH07XHJcblxyXG4gICAgICAgIHN3aXRjaCAodGhpcy5fcGFyZW50LmNvb3JkaW5hdGVTeXN0ZW1Nb2RlKSB7XHJcbiAgICAgICAgICAgIGNhc2UgR0xURkxvYWRlckNvb3JkaW5hdGVTeXN0ZW1Nb2RlLkFVVE86IHtcclxuICAgICAgICAgICAgICAgIGlmICghdGhpcy5fYmFieWxvblNjZW5lLnVzZVJpZ2h0SGFuZGVkU3lzdGVtKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcm9vdE5vZGUucm90YXRpb24gPSBbMCwgMSwgMCwgMF07XHJcbiAgICAgICAgICAgICAgICAgICAgcm9vdE5vZGUuc2NhbGUgPSBbMSwgMSwgLTFdO1xyXG4gICAgICAgICAgICAgICAgICAgIEdMVEZMb2FkZXIuX0xvYWRUcmFuc2Zvcm0ocm9vdE5vZGUsIHRoaXMuX3Jvb3RCYWJ5bG9uTWVzaCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIEdMVEZMb2FkZXJDb29yZGluYXRlU3lzdGVtTW9kZS5GT1JDRV9SSUdIVF9IQU5ERUQ6IHtcclxuICAgICAgICAgICAgICAgIHRoaXMuX2JhYnlsb25TY2VuZS51c2VSaWdodEhh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b25zdCBwcm9taXNlcyA9IG5ldyBBcnJheTxQcm9taXNlPGFueT4+KCk7XHJcblxyXG4gICAgICAgIHRoaXMubG9nT3BlbihgJHtjb250ZXh0fSAke3NjZW5lLm5hbWUgfHwgXCJcIn1gKTtcclxuXHJcbiAgICAgICAgaWYgKHNjZW5lLm5vZGVzKSB7XHJcbiAgICAgICAgICAgIGZvciAoY29uc3QgaW5kZXggb2Ygc2NlbmUubm9kZXMpIHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IG5vZGUgPSBBcnJheUl0ZW0uR2V0KGAke2NvbnRleHR9L25vZGVzLyR7aW5kZXh9YCwgdGhpcy5fZ2x0Zi5ub2RlcywgaW5kZXgpO1xyXG4gICAgICAgICAgICAgICAgcHJvbWlzZXMucHVzaChcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLmxvYWROb2RlQXN5bmMoYC9ub2Rlcy8ke25vZGUuaW5kZXh9YCwgbm9kZSwgKGJhYnlsb25NZXNoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25NZXNoLnBhcmVudCA9IHRoaXMuX3Jvb3RCYWJ5bG9uTWVzaDtcclxuICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgZm9yIChjb25zdCBhY3Rpb24gb2YgdGhpcy5fcG9zdFNjZW5lTG9hZEFjdGlvbnMpIHtcclxuICAgICAgICAgICAgYWN0aW9uKCk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBwcm9taXNlcy5wdXNoKHRoaXMuX2xvYWRBbmltYXRpb25zQXN5bmMoKSk7XHJcblxyXG4gICAgICAgIHRoaXMubG9nQ2xvc2UoKTtcclxuXHJcbiAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHByb21pc2VzKS50aGVuKCgpID0+IHt9KTtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9mb3JFYWNoUHJpbWl0aXZlKG5vZGU6IElOb2RlLCBjYWxsYmFjazogKGJhYnlsb25NZXNoOiBBYnN0cmFjdE1lc2gpID0+IHZvaWQpOiB2b2lkIHtcclxuICAgICAgICBpZiAobm9kZS5fcHJpbWl0aXZlQmFieWxvbk1lc2hlcykge1xyXG4gICAgICAgICAgICBmb3IgKGNvbnN0IGJhYnlsb25NZXNoIG9mIG5vZGUuX3ByaW1pdGl2ZUJhYnlsb25NZXNoZXMpIHtcclxuICAgICAgICAgICAgICAgIGNhbGxiYWNrKGJhYnlsb25NZXNoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9nZXRHZW9tZXRyaWVzKCk6IEdlb21ldHJ5W10ge1xyXG4gICAgICAgIGNvbnN0IGdlb21ldHJpZXM6IEdlb21ldHJ5W10gPSBbXTtcclxuXHJcbiAgICAgICAgY29uc3Qgbm9kZXMgPSB0aGlzLl9nbHRmLm5vZGVzO1xyXG4gICAgICAgIGlmIChub2Rlcykge1xyXG4gICAgICAgICAgICBmb3IgKGNvbnN0IG5vZGUgb2Ygbm9kZXMpIHtcclxuICAgICAgICAgICAgICAgIHRoaXMuX2ZvckVhY2hQcmltaXRpdmUobm9kZSwgKGJhYnlsb25NZXNoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2VvbWV0cnkgPSAoYmFieWxvbk1lc2ggYXMgTWVzaCkuZ2VvbWV0cnk7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGdlb21ldHJ5ICYmIGdlb21ldHJpZXMuaW5kZXhPZihnZW9tZXRyeSkgPT09IC0xKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGdlb21ldHJpZXMucHVzaChnZW9tZXRyeSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XH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AgICAgZm9yIChjb25zdCBub2RlIG9mIG5vZGVzKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAobm9kZS5fYmFieWxvblRyYW5zZm9ybU5vZGUgJiYgbm9kZS5fYmFieWxvblRyYW5zZm9ybU5vZGUuZ2V0Q2xhc3NOYW1lKCkgPT09IFwiVHJhbnNmb3JtTm9kZVwiKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtTm9kZXMucHVzaChub2RlLl9iYWJ5bG9uVHJhbnNmb3JtTm9kZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAobm9kZS5fYmFieWxvblRyYW5zZm9ybU5vZGVGb3JTa2luKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtTm9kZXMucHVzaChub2RlLl9iYWJ5bG9uVHJhbnNmb3JtTm9kZUZvclNraW4pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICByZXR1cm4gdHJhbnNmb3JtTm9kZXM7XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfZ2V0U2tlbGV0b25zKCk6IFNrZWxldG9uW10ge1xyXG4gICAgICAgIGNvbnN0IHNrZWxldG9uczogU2tlbGV0b25bXSA9IFtdO1xyXG5cclxuICAgICAgICBjb25zdCBza2lucyA9IHRoaXMuX2dsdGYuc2tpbnM7XHJcbiAgICAgICAgaWYgKHNraW5zKSB7XHJcbiAgICAgICAgICAgIGZvciAoY29uc3Qgc2tpbiBvZiBza2lucykge1xyXG4gICAgICAgICAgICAgICAgaWYgKHNraW4uX2RhdGEpIHtcclxuICAgICAgICAgICAgICAgICAgICBza2VsZXRvbnMucHVzaChza2luLl9kYXRhLmJhYnlsb25Ta2VsZXRvbik7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBza2VsZXRvbnM7XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfZ2V0QW5pbWF0aW9uR3JvdXBzKCk6IEFuaW1hdGlvbkdyb3VwW10ge1xyXG4gICAgICAgIGNvbnN0IGFuaW1hdGlvbkdyb3VwczogQW5pbWF0aW9uR3JvdXBbXSA9IFtdO1xyXG5cclxuICAgICAgICBjb25zdCBhbmltYXRpb25zID0gdGhpcy5fZ2x0Zi5hbmltYXRpb25zO1xyXG4gICAgICAgIGlmIChhbmltYXRpb25zKSB7XHJcbiAgICAgICAgICAgIGZvciAoY29uc3QgYW5pbWF0aW9uIG9mIGFuaW1hdGlvbnMpIHtcclxuICAgICAgICAgICAgICAgIGlmIChhbmltYXRpb24uX2JhYnlsb25BbmltYXRpb25Hcm91cCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGFuaW1hdGlvbkdyb3Vwcy5wdXNoKGFuaW1hdGlvbi5fYmFieWxvbkFuaW1hdGlvbkdyb3VwKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgcmV0dXJuIGFuaW1hdGlvbkdyb3VwcztcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9zdGFydEFuaW1hdGlvbnMoKTogdm9pZCB7XHJcbiAgICAgICAgc3dpdGNoICh0aGlzLl9wYXJlbnQuYW5pbWF0aW9uU3RhcnRNb2RlKSB7XHJcbiAgICAgICAgICAgIGNhc2UgR0xURkxvYWRlckFuaW1hdGlvblN0YXJ0TW9kZS5OT05FOiB7XHJcbiAgICAgICAgICAgICAgICAvLyBkbyBub3RoaW5nXHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIEdMVEZMb2FkZXJBbmltYXRpb25TdGFydE1vZGUuRklSU1Q6IHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGJhYnlsb25BbmltYXRpb25Hcm91cHMgPSB0aGlzLl9nZXRBbmltYXRpb25Hcm91cHMoKTtcclxuICAgICAgICAgICAgICAgIGlmIChiYWJ5bG9uQW5pbWF0aW9uR3JvdXBzLmxlbmd0aCAhPT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGJhYnlsb25BbmltYXRpb25Hcm91cHNbMF0uc3RhcnQodHJ1ZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIEdMVEZMb2FkZXJBbmltYXRpb25TdGFydE1vZGUuQUxMOiB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBiYWJ5bG9uQW5pbWF0aW9uR3JvdXBzID0gdGhpcy5fZ2V0QW5pbWF0aW9uR3JvdXBzKCk7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGJhYnlsb25BbmltYXRpb25Hcm91cCBvZiBiYWJ5bG9uQW5pbWF0aW9uR3JvdXBzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvbkFuaW1hdGlvbkdyb3VwLnN0YXJ0KHRydWUpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgZGVmYXVsdDoge1xyXG4gICAgICAgICAgICAgICAgTG9nZ2VyLkVycm9yKGBJbnZhbGlkIGFuaW1hdGlvbiBzdGFydCBtb2RlICgke3RoaXMuX3BhcmVudC5hbmltYXRpb25TdGFydE1vZGV9KWApO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogTG9hZHMgYSBnbFRGIG5vZGUuXHJcbiAgICAgKiBAcGFyYW0gY29udGV4dCBUaGUgY29udGV4dCB3aGVuIGxvYWRpbmcgdGhlI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WAsIHRoaXMuX2dsdGYubm9kZXMsIGluZGV4KTtcclxuICAgICAgICAgICAgICAgICAgICBwcm9taXNlcy5wdXNoKFxyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxvYWROb2RlQXN5bmMoYC9ub2Rlcy8ke2NoaWxkTm9kZS5pbmRleH1gLCBjaGlsZE5vZGUsIChjaGlsZEJhYnlsb25NZXNoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZEJhYnlsb25NZXNoLnBhcmVudCA9IGJhYnlsb25UcmFuc2Zvcm1Ob2RlO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGFzc2lnbihiYWJ5bG9uVHJhbnNmb3JtTm9kZSk7XHJcbiAgICAgICAgfTtcclxuXHJcbiAgICAgICAgaWYgKG5vZGUubWVzaCA9PSB1bmRlZmluZWQgfHwgbm9kZS5za2luICE9IHVuZGVmaW5lZCkge1xyXG4gICAgICAgICAgICBjb25zdCBub2RlTmFtZSA9IG5vZGUubmFtZSB8fCBgbm9kZSR7bm9kZS5pbmRleH1gO1xyXG4gICAgICAgICAgICB0aGlzLl9iYWJ5bG9uU2NlbmUuX2Jsb2NrRW50aXR5Q29sbGVjdGlvbiA9ICEhdGhpcy5fYXNzZXRDb250YWluZXI7XHJcbiAgICAgICAgICAgIGNvbnN0IHRyYW5zZm9ybU5vZGUgPSBuZXcgVHJhbnNmb3JtTm9kZShub2RlTmFtZSwgdGhpcy5fYmFieWxvblNjZW5lKTtcclxuICAgICAgICAgICAgdHJhbnNmb3JtTm9kZS5fcGFyZW50Q29udGFpbmVyID0gdGhpcy5fYXNzZXRDb250YWluZXI7XHJcbiAgICAgICAgICAgIHRoaXMuX2JhYnlsb25TY2VuZS5fYmxvY2tFbnRpdHlDb2xsZWN0aW9uID0g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MsIG5vZGUuc2tpbik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2goXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkU2tpbkFzeW5jKGAvc2tpbnMvJHtza2luLmluZGV4fWAsIG5vZGUsIHNraW4sIChiYWJ5bG9uU2tlbGV0b24pID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mb3JFYWNoUHJpbWl0aXZlKG5vZGUsIChiYWJ5bG9uTWVzaCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uTWVzaC5za2VsZXRvbiA9IGJhYnlsb25Ta2VsZXRvbjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gV2FpdCB1bnRpbCBhbGwgdGhlIG5vZGVzIGFyZSBwYXJlbnRlZCBiZWZvcmUgcGFyZW50aW5nIHRoZSBza2lubmVkIG1lc2guXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcG9zdFNjZW5lTG9hZEFjdGlvbnMucHVzaCgoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChza2luLnNrZWxldG9uICE9IHVuZGVmaW5lZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gUGxhY2UgdGhlIHNraW5uZWQgbWVzaCBub2RlIGFzIGEgc2libGluZyBvZiB0aGUgc2tlbGV0b24gcm9vdCBub2RlLlxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gSGFuZGxlIHNwZWNpYWwgY2FzZSB3aGVuIHRoZSBwYXJlbnQgb2YgdGhlIHNrZWxldG9uIHJvb3QgaXMgdGhlIHNraW5uZWQgbWVzaC5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhcmVudE5vZGUgPSBBcnJheUl0ZW0uR2V0KGAvc2tpbnMvJHtza2luLmluZGV4fS9za2VsZXRvbmAsIHRoaXMuX2dsdGYubm9kZXMsIHNraW4uc2tlbGV0b24pLnBhcmVudCE7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobm9kZS5pbmRleCA9PT0gcGFyZW50Tm9kZS5pbmRleCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25UcmFuc2Zvcm1Ob2RlLnBhcmVudCA9IGJhYnlsb25UcmFuc2Zvcm1Ob2RlRm9yU2tpbi5wYXJlbnQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25UcmFuc2Zvcm1Ob2RlLnBhcmVudCA9IHBhcmVudE5vZGUuX2JhYnlsb25UcmFuc2Zvcm1Ob2RlITtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25UcmFuc2Zvcm1Ob2RlLnBhcmVudCA9IHRoaXMuX3Jvb3RCYWJ5bG9uTWVzaDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFyZW50Lm9uU2tpbkxvYWRlZE9ic2VydmFibGUubm90aWZ5T2JzZXJ2ZXJzKHsgbm9kZTogYmFieWxvblRyYW5zZm9ybU5vZGVGb3JTa2luLCBza2lubmVkTm9kZTogYmFieWxvblRyYW5zZm9ybU5vZGUgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICB0aGlzLmxvZ0Nsb3NlKCk7XHJcblxyXG4gICAgICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgIHRoaXMuX2ZvckVhY2hQcmltaXRpdmUobm9kZSwgKGJhYnlsb25NZXNoKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBpZiAoKGJhYnlsb25NZXNoIGFzIE1lc2gpLmdlb21ldHJ5ICYmIChiYWJ5bG9uTWVzaCBhcyBNZXNoKS5nZW9tZXRyeSEudXNlQm91bmRpbmdJbmZvRnJvbUdlb21ldHJ5KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgLy8gc2ltcGx5IGFwcGx5IHRoZSB3b3JsZCBtYXRyaWNlcyB0byB0aGUgYm91bmRpbmcgaW5mbyAtIHRoZSBleHRlbmRzIGFyZSBhbHJlYWR5IG9rXHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvbk1lc2guX3VwZGF0ZUJvdW5kaW5nSW5mbygpO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBiYWJ5bG9uTWVzaC5yZWZyZXNoQm91bmRpbmdJbmZvKHRydWUpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9KTtcclxuXHJcbiAgICAgICAgICAgIHJldHVybiBub2RlLl9iYWJ5bG9uVHJhbnNmb3JtTm9kZSE7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgc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cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2JhYnlsb25TY2VuZS5fYmxvY2tFbnRpdHlDb2xsZWN0aW9uID0gISF0aGlzLl9hc3NldENvbnRhaW5lcjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvbkdlb21ldHJ5LmFwcGx5VG9NZXNoKGJhYnlsb25NZXNoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvbkdlb21ldHJ5Ll9wYXJlbnRDb250YWluZXIgPSB0aGlzLl9hc3NldENvbnRhaW5lcjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmFieWxvblNjZW5lLl9ibG9ja0VudGl0eUNvbGxlY3Rpb24gPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICk7XHJcblxyXG4gICAgICAgICAgICBjb25zdCBiYWJ5bG9uRHJhd01vZGUgPSBHTFRGTG9hZGVyLl9HZXREcmF3TW9kZShjb250ZXh0LCBwcmltaXRpdmUubW9kZSk7XHJcbiAgICAgICAgICAgIGlmIChwcmltaXRpdmUubWF0ZXJpYWwgPT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgICAgICBsZXQgYmFieWxvbk1hdGVyaWFsID0gdGhpcy5fZGVmYXVsdEJhYnlsb25NYXRlcmlhbERhdGFbYmFieWxvbkRyYXdNb2RlXTtcclxuICAgICAgICAgICAgICAgIGlmICghYmFieWxvbk1hdGVyaWFsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYmFieWxvbk1hdGVyaWFsID0gdGhpcy5fY3JlYXRlRGVmYXVsdE1hdGVyaWFsKFwiX19HTFRGTG9hZGVyLl9kZWZhdWx0XCIsIGJhYnlsb25EcmF3TW9kZSk7XHJcbiAgICA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Y2UpIHtcclxuICAgICAgICAgICAgICAgIHByaW1pdGl2ZS5faW5zdGFuY2VEYXRhID0ge1xyXG4gICAgICAgICAgICAgICAgICAgIGJhYnlsb25Tb3VyY2VNZXNoOiBiYWJ5bG9uTWVzaCxcclxuICAgICAgICAgICAgICAgICAgICBwcm9taXNlOiBwcm9taXNlLFxyXG4gICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgYmFieWxvbkFic3RyYWN0TWVzaCA9IGJhYnlsb25NZXNoO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgR0xURkxvYWRlci5BZGRQb2ludGVyTWV0YWRhdGEoYmFieWxvbkFic3RyYWN0TWVzaCwgY29udGV4dCk7XHJcbiAgICAgICAgdGhpcy5fcGFyZW50Lm9uTWVzaExvYWRlZE9ic2VydmFibGUubm90aWZ5T2JzZXJ2ZXJzKGJhYnlsb25BYnN0cmFjdE1lc2gpO1xyXG4gICAgICAgIGFzc2lnbihiYWJ5bG9uQWJzdHJhY3RNZXNoKTtcclxuXHJcbiAgICAgICAgdGhpcy5sb2dDbG9zZSgpO1xyXG5cclxuICAgICAgICByZXR1cm4gcHJvbWlzZS50aGVuKCgpID0+IHtcclxuICAgICAgICAgICAgcmV0dXJuIGJhYnlsb25BYnN0cmFjdE1lc2g7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfbG9hZFZlcnRleERhdGFBc3luYyhjb250ZXh0OiBzdHJpbmcsIHByaW1pdGl2ZTogSU1lc2hQcmltaXRpdmUsIGJhYnlsb25NZXNoOiBNZXNoKTogUHJvbWlzZTxHZW9tZXRyeT4ge1xyXG4gICAgICAgIGNvbnN0IGV4dGVuc2lvblByb21pc2UgPSB0aGlzLl9leHRlbnNpb25zTG9hZFZlcnRleERhdGFBc3luYyhjb250ZXh0LCBwcmltaXRpdmUsIGJhYnlsb25NZXNoKTtcclxuICAgICAgICBpZiAoZXh0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JlbnQuYWx3YXlzQ29tcHV0ZUJvdW5kaW5nQm94ICYmICFiYWJ5bG9uTWVzaC5za2VsZXRvbikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWNjZXNzb3IubWluICYmIGFjY2Vzc29yLm1heCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWluID0gVG1wVmVjdG9ycy5WZWN0b3IzWzBdLmNvcHlGcm9tRmxvYXRzKC4uLihhY2Nlc3Nvci5taW4gYXMgW251bWJlciwgbnVtYmVyLCBudW1iZXJdKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXggPSBUbXBWZWN0b3JzLlZlY3RvcjNbMV0uY29weUZyb21GbG9hdHMoLi4uKGFjY2Vzc29yLm1heCBhcyBbbnVtYmVyLCBudW1iZXIsIG51bWJlcl0pKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhY2Nlc3Nvci5ub3JtYWxpemVkICYmIGFjY2Vzc29yLmNvbXBvbmVudFR5cGUgIT09IEFjY2Vzc29yQ29tcG9uZW50VHlwZS5GTE9BVCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkaXZpZGVyID0gMTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGFjY2Vzc29yLmNvbXBvbmVudFR5cGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBBY2Nlc3NvckNvbXBvbmVudFR5cGUuQllURTpcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpdmlkZXIgPSAxMjcuMDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIEFjY2Vzc29yQ29tcG9uZW50VHlwZS5VTlNJR05FRF9CWVRFOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2aWRlciA9IDI1NS4wO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgQWNjZXNzb3JDb21wb25lbnRUeXBlLlNIT1JUOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2aWRlciA9IDMyNzY3LjA7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBBY2Nlc3NvckNvbXBvbmVudFR5cGUuVU5TSUdORURfU0hPUlQ6XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXZpZGVyID0gNjU1MzUuMDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvbmVPdmVyRGl2aWRlciA9IDEgLyBkaXZpZGVyO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbi5zY2FsZUluUGxhY2Uob25lT3ZlckRpdmlkZXIpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heC5zY2FsZUluUGxhY2Uob25lT3ZlckRpdmlkZXIpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvbkdlb21ldHJ5Ll9ib3VuZGluZ0luZm8gPSBuZXcgQm91bmRpbmdJbmZvKG1pbiwgbWF4KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25HZW9tZXRyeS51c2VCb3VuZGlu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AgICAgaWYgKG5vZGUucm90YXRpb24pIHtcclxuICAgICAgICAgICAgICAgIHJvdGF0aW9uID0gUXVhdGVybmlvbi5Gcm9tQXJyYXkobm9kZS5yb3RhdGlvbik7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKG5vZGUuc2NhbGUpIHtcclxuICAgICAgICAgICAgICAgIHNjYWxpbmcgPSBWZWN0b3IzLkZyb21BcnJheShub2RlLnNjYWxlKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgYmFieWxvbk5vZGUucG9zaXRpb24gPSBwb3NpdGlvbjtcclxuICAgICAgICBiYWJ5bG9uTm9kZS5yb3RhdGlvblF1YXRlcm5pb24gPSByb3RhdGlvbjtcclxuICAgICAgICBiYWJ5bG9uTm9kZS5zY2FsaW5nID0gc2NhbGluZztcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9sb2FkU2tpbkFzeW5jKGNvbnRleHQ6IHN0cmluZywgbm9kZTogSU5vZGUsIHNraW46IElTa2luLCBhc3NpZ246IChiYWJ5bG9uU2tlbGV0b246IFNrZWxldG9uKSA9PiB2b2lkKTogUHJvbWlzZTx2b2lkPiB7XHJcbiAgICAgICAgY29uc3QgZXh0ZW5zaW9uUHJvbWlzZSA9IHRoaXMuX2V4dGVuc2lvbnNMb2FkU2tpbkFzeW5jKGNvbnRleHQsIG5vZGUsIHNraW4pO1xyXG4gICAgICAgIGlmIChleHRlbnNpb25Qcm9taXNlKSB7XHJcbiAgICAgICAgICAgIHJldHVybiBleHRlbnNpb25Qcm9taXNlO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgaWYgKHNraW4uX2RhdGEpIHtcclxuICAgICAgICAgICAgYXNzaWduKHNraW4uX2RhdGEuYmFieWxvblNrZWxldG9uKTtcclxuICAgICAgICAgICAgcmV0dXJuIHNraW4uX2RhdGEucHJvbWlzZTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGNvb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uICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9sb2FkQm9uZXMoY29udGV4dDogc3RyaW5nLCBza2luOiBJU2tpbiwgYmFieWxvblNrZWxldG9uOiBTa2VsZXRvbik6IHZvaWQge1xyXG4gICAgICAgIGlmIChza2luLnNrZWxldG9uID09IHVuZGVmaW5lZCB8fCB0aGlzLl9wYXJlbnQuYWx3YXlzQ29tcHV0ZVNrZWxldG9uUm9vdE5vZGUpIHtcclxuICAgICAgICAgICAgY29uc3Qgcm9vdE5vZGUgPSB0aGlzLl9maW5kU2tlbGV0b25Sb290Tm9kZShgJHtjb250ZXh0fS9qb2ludHNgLCBza2luLmpvaW50cyk7XHJcbiAgICAgICAgICAgIGlmIChyb290Tm9kZSkge1xyXG4gICAgICAgICAgICAgICAgaWYgKHNraW4uc2tlbGV0b24gPT09IHVuZGVmaW5lZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNraW4uc2tlbGV0b24gPSByb290Tm9kZS5pbmRleDtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNQYXJlbnQgPSAoYTogSU5vZGUsIGI6IElOb2RlKTogYm9vbGVhbiA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoOyBiLnBhcmVudDsgYiA9IGIucGFyZW50KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYi5wYXJlbnQgPT09IGEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgICAgIH07XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHNrZWxldG9uTm9kZSA9IEFycmF5SXRlbS5HZXQoYCR7Y29udGV4dH0vc2tlbGV0b25gLCB0aGlzLl9nbHRmLm5vZGVzLCBza2luLnNrZWxldG9uKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoc2tlbGV0b25Ob2RlICE9PSByb290Tm9kZSAmJiAhaXNQYXJlbnQoc2tlbGV0b25Ob2RlLCByb290Tm9kZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgTG9nZ2VyLldhcm4oYCR7Y29udGV4dH0vc2tlbGV0b246IE92ZXJyaWRpbmcgd2l0aCBuZWFyZXN0IGNvbW1vbiBhbmNlc3RvciBhcyBza2VsZXRvbiBub2RlIGlzIG5vdCBhIGNvbW1vbiByb290YCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNraW4uc2tlbGV0b24gPSByb290Tm9kZS5pbmRleDtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBMb2dnZXIuV2FybihgJHtjb250ZXh0fTogRmFpbGVkIHRvIGZpbmQgY29tbW9uIHJvb3RgKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgY29uc3QgYmFieWxvbkJvbmVzOiB7IFtpbmRleDogbnVtYmVyXTogQm9uZSB9ID0ge307XHJcbiAgICAgICAgZm9yIChjb25zdCBpbmRleCBvZiBza2luLmpvaW50cykge1xyXG4gICAgICAgICAgICBjb25zdCBub2RlID0gQXJyYXlJdGVtLkdldChgJHtjb250ZXh0fS9qb2ludHMvJHtpbmRleH1gLCB0aGlzLl9nbHRmLm5vZGVzLCBpbmRleCk7XHJcbiAgICAgICAgICAgIHRoaXMuX2xvYWRCb25lKG5vZGUsIHNraW4sIGJhYnlsb25Ta2VsZXRvbiwgYmFieWxvbkJvbmVzKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfZmluZFNrZWxldG9uUm9vdE5vZGUoY29udGV4dDogc3RyaW5nLCBqb2ludHM6IEFycmF5PG51bWJlcj4pOiBOdWxsYWJsZTxJTm9kZT4ge1xyXG4gICAgICAgIGlmIChqb2ludHMubGVuZ3RoID09PSAwKSB7XHJcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgY29uc3QgcGF0aHM6IHsgW2pvaW50OiBudW1iZXJdOiBBcnJheTxJTm9kZT4gfSA9IHt9O1xyXG4gICAgICAgIGZvciAoY29uc3QgaW5kZXggb2Ygam9pbnRzKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IHBhdGg6IElOb2RlW10gPSBbXTtcclxuICAgICAgICAgICAgbGV0IG5vZGUgPSBBcnJheUl0ZW0uR2V0KGAke2NvbnRleHR9LyR7aW5kZXh9YCwgdGhpcy5fZ2x0Zi5ub2RlcywgaW5kZXgpO1xyXG4gICAgICAgICAgICB3aGlsZSAobm9kZS5pbmRleCAhPT0gLTEpIHtcclxuICAgICAgICAgICAgICAgIHBhdGgudW5zaGlmdChub2RlKTtcclxuICAgICAgICAgICAgICAgIG5vZGUgPSBub2RlLnBhcmVudCE7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcGF0aHNbaW5kZXhdID0gcGF0aDtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGxldCByb290Tm9kZTogTnVsbGFibGU8SU5vZGU+ID0gbnVsbDtcclxuICAgICAgICBmb3IgKGxldCBpID0gMDsgOyArK2kpIHtcclxuICAgICAgICAgICAgbGV0IHBhdGggPSBwYXRoc1tqb2ludHNbMF1dO1xyXG4gICAgICAgICAgICBpZiAoaSA+PSBwYXRoLmxlbmd0aCkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIHJvb3ROb2RlO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBjb25zdCBub2RlID0gcGF0aFtpXTtcclxuICAgICAgICAgICAgZm9yIChsZXQgaiA9IDE7IGogPCBqb2ludHMubGVuZ3RoOyArK2opIHtcclxuICAgICAgICAgICAgICAgIHBhdGggPSBwYXRoc1tqb2ludHNbal1dO1xyXG4gICAgICAgICAgICAgICAgaWYgKGkgPj0gcGF0aC5sZW5ndGggfHwgbm9kZSAhPT0gcGF0aFtpXSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiByb290Tm9kZTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgcm9vdE5vZGUgPSBub2RlO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9sb2FkQm9uZShub2RlOiBJTm9kZSwgc2tpbjogSVNraW4sIGJhYnlsb25Ta2VsZXRvbjogU2tlbGV0b24sIGJhYnlsb25Cb25lczogeyBbaW5kZXg6IG51bWJlcl06IEJvbmUgfSk6IEJvbmUge1xyXG4gICAgICAgIGxldCBiYWJ5bG9uQm9uZSA9IGJhYnlsb25Cb25lc1tub2RlLmluZGV4XTtcclxuICAgICAgICBpZiAoYmFieWxvbkJvbmUpIHtcclxuICAgICAgICAgICAgcmV0dXJuIGJhYnlsb25Cb25lO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgbGV0IHBhcmVudEJhYnlsb25Cb25lOiBOdWxsYWJsZTxCb25lPiA9IG51bGw7XHJcbiAgICAgICAgaWYgKG5vZGUuaW5kZXggIT09IHNraW4uc2tlbGV0b24pIHtcclxuICAgICAgICAgICAgaWYgKG5vZGUucGFyZW50ICYmIG5vZGUucGFyZW50LmluZGV4ICE9PSAtMSkge1xyXG4gICAgICAgICAgICAgICAgcGFyZW50QmFieWxvbkJvbmUgPSB0aGlzLl9sb2FkQm9uZShub2RlLnBhcmVudCwgc2tpbiwgYmFieWxvblNrZWxldG9uLCBiYWJ5bG9uQm9uZXMpO1xyXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHNraW4uc2tlbGV0b24gIT09IHVu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pZiAoaW52ZXJzZUJpbmRNYXRyaWNlc0RhdGEgJiYgYm9uZUluZGV4ICE9PSAtMSkge1xyXG4gICAgICAgICAgICAgICAgTWF0cml4LkZyb21BcnJheVRvUmVmKGludmVyc2VCaW5kTWF0cmljZXNEYXRhLCBib25lSW5kZXggKiAxNiwgYmFzZU1hdHJpeCk7XHJcbiAgICAgICAgICAgICAgICBiYXNlTWF0cml4LmludmVydFRvUmVmKGJhc2VNYXRyaXgpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBjb25zdCBiYWJ5bG9uUGFyZW50Qm9uZSA9IGJhYnlsb25Cb25lLmdldFBhcmVudCgpO1xyXG4gICAgICAgICAgICBpZiAoYmFieWxvblBhcmVudEJvbmUpIHtcclxuICAgICAgICAgICAgICAgIGJhc2VNYXRyaXgubXVsdGlwbHlUb1JlZihiYWJ5bG9uUGFyZW50Qm9uZS5nZXRBYnNvbHV0ZUludmVyc2VCaW5kTWF0cml4KCksIGJhc2VNYXRyaXgpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBiYWJ5bG9uQm9uZS51cGRhdGVNYXRyaXgoYmFzZU1hdHJpeCwgZmFsc2UsIGZhbHNlKTtcclxuICAgICAgICAgICAgYmFieWxvbkJvbmUuX3VwZGF0ZUFic29sdXRlQmluZE1hdHJpY2VzKHVuZGVmaW5lZCwgZmFsc2UpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9nZXROb2RlTWF0cml4KG5vZGU6IElOb2RlKTogTWF0cml4IHtcclxuICAgICAgICByZXR1cm4gbm9kZS5tYXRyaXhcclxuICAgICAgICAgICAgPyBNYXRyaXguRnJvbUFycmF5KG5vZGUubWF0cml4KVxyXG4gICAgICAgICAgICA6IE1hdHJpeC5Db21wb3NlKFxyXG4gICAgICAgICAgICAgICAgICBub2RlLnNjYWxlID8gVmVjdG9yMy5Gcm9tQXJyYXkobm9kZS5zY2FsZSkgO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5cGUpIHtcclxuICAgICAgICAgICAgY2FzZSBDYW1lcmFUeXBlLlBFUlNQRUNUSVZFOiB7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBwZXJzcGVjdGl2ZSA9IGNhbWVyYS5wZXJzcGVjdGl2ZTtcclxuICAgICAgICAgICAgICAgIGlmICghcGVyc3BlY3RpdmUpIHtcclxuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYCR7Y29udGV4dH06IENhbWVyYSBwZXJzcGVjdGl2ZSBwcm9wZXJ0aWVzIGFyZSBtaXNzaW5nYCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgYmFieWxvbkNhbWVyYS5mb3YgPSBwZXJzcGVjdGl2ZS55Zm92O1xyXG4gICAgICAgICAgICAgICAgYmFieWxvbkNhbWVyYS5taW5aID0gcGVyc3BlY3RpdmUuem5lYXI7XHJcbiAgICAgICAgICAgICAgICBiYWJ5bG9uQ2FtZXJhLm1heFogPSBwZXJzcGVjdGl2ZS56ZmFyIHx8IDA7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIENhbWVyYVR5cGUuT1JUSE9HUkFQSElDOiB7XHJcbiAgICAgICAgICAgICAgICBpZiAoIWNhbWVyYS5vcnRob2dyYXBoaWMpIHtcclxuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYCR7Y29udGV4dH06IENhbWVyYSBvcnRob2dyYXBoaWMgcHJvcGVydGllcyBhcmUgbWlzc2luZ2ApO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIGJhYnlsb25DYW1lcmEubW9kZSA9IENhbWVyYS5PUlRIT0dSQVBISUNfQ0FNRVJBO1xyXG4gICAgICAgICAgICAgICAgYmFieWxvbkNhbWVyYS5vcnRob0xlZnQgPSAtY2FtZXJhLm9ydGhvZ3JhcGhpYy54bWFnO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NhbWVyYTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9sb2FkQW5pbWF0aW9uc0FzeW5jKCk6IFByb21pc2U8dm9pZD4ge1xyXG4gICAgICAgIGNvbnN0IGFuaW1hdGlvbnMgPSB0aGlzLl9nbHRmLmFuaW1hdGlvbnM7XHJcbiAgICAgICAgaWYgKCFhbmltYXRpb25zKSB7XHJcbiAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlc29sdmUoKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGNvbnN0IHByb21pc2VzID0gbmV3IEFycmF5PFByb21pc2U8dm9pZD4+KCk7XHJcblxyXG4gICAgICAgIGZvciAobGV0IGluZGV4ID0gMDsgaW5kZXggPCBhbmltYXRpb25zLmxlbmd0aDsgaW5kZXgrKykge1xyXG4gICAgICAgICAgICBjb25zdCBhbmltYXRpb24gPSBhbmltYXRpb25zW2luZGV4XTtcclxuICAgICAgICAgICAgcHJvbWlzZXMucHVzaChcclxuICAgICAgICAgICAgICAgIHRoaXMubG9hZEFuaW1hdGlvbkFzeW5jKGAvYW5pbWF0aW9ucy8ke2FuaW1hdGlvbi5pbmRleH1gLCBhbmltYXRpb24pLnRoZW4oKGFuaW1hdGlvbkdyb3VwKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgLy8gRGVsZXRlIHRoZSBhbmltYXRpb24gZ3JvdXAgaWYgaXQgZW5kZWQgdXAgbm90IGhhdmluZyBhbnkgYW5pbWF0aW9ucyBpbiBpdC5cclxuICAgICAgICAgICAgICAgICAgICBpZiAoYW5pbWF0aW9uR3JvdXAudGFyZ2V0ZWRBbmltYXRpb25zLmxlbmd0aCA9PT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBhbmltYXRpb25Hcm91cC5kaXNwb3NlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgKTtcclxuICAg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bC50YXJnZXQucGF0aCAhPT0gQW5pbWF0aW9uQ2hhbm5lbFRhcmdldFBhdGguV0VJR0hUUyAmJiAhdGFyZ2V0Tm9kZS5fYmFieWxvblRyYW5zZm9ybU5vZGUpXHJcbiAgICAgICAgKSB7XHJcbiAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlc29sdmUoKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGxldCBwcm9wZXJ0aWVzOiBBcnJheTxBbmltYXRpb25Qcm9wZXJ0eUluZm8+O1xyXG4gICAgICAgIHN3aXRjaCAoY2hhbm5lbC50YXJnZXQucGF0aCkge1xyXG4gICAgICAgICAgICBjYXNlIEFuaW1hdGlvbkNoYW5uZWxUYXJnZXRQYXRoLlRSQU5TTEFUSU9OOiB7XHJcbiAgICAgICAgICAgICAgICBwcm9wZXJ0aWVzID0gbm9kZUFuaW1hdGlvbkRhdGEudHJhbnNsYXRpb247XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIEFuaW1hdGlvbkNoYW5uZWxUYXJnZXRQYXRoLlJPVEFUSU9OOiB7XHJcbiAgICAgICAgICAgICAgICBwcm9wZXJ0aWVzID0gbm9kZUFuaW1hdGlvbkRhdGEucm90YXRpb247XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIEFuaW1hdGlvbkNoYW5uZWxUYXJnZXRQYXRoLlNDQUxFOiB7XHJcbiAgICAgICAgICAgICAgICBwcm9wZXJ0aWVzID0gbm9kZUFuaW1hdGlvbkRhdGEuc2NhbGU7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIEFuaW1hdGlvbkNoYW5uZWxUYXJnZXRQYXRoLldFSUdIVFM6IHtcclxuICAgICAgICAgICAgICAgIHByb3BlcnRpZXMgPSBub2RlQW5pbWF0a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cbiAgICAgICAgICAgICAgICBsZXQgb3V0cHV0T2Zmc2V0ID0gMDtcclxuXHJcbiAgICAgICAgICAgICAgICBzd2l0Y2ggKGRhdGEuaW50ZXJwb2xhdGlvbikge1xyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgQW5pbWF0aW9uU2FtcGxlckludGVycG9sYXRpb24uU1RFUDoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpbmRleCA9IDA7IGluZGV4IDwgaW5wdXQubGVuZ3RoOyBpbmRleCsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IHByb3BlcnR5SW5mby5nZXRWYWx1ZSh0YXJnZXQsIG91dHB1dCwgb3V0cHV0T2Zmc2V0LCAxKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dE9mZnNldCArPSBzdHJpZGU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5c1tpbmRleF0gPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJhbWU6IGlucHV0W2luZGV4XSAqIGZwcyxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZXJwb2xhdGlvbjogQW5pbWF0aW9uS2V5SW50ZXJwb2xhdGlvbi5TVEVQLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSBBbmltYXRpb25TYW1wbGVySW50ZXJwb2xhdGlvbi5DVUJJQ1NQTElORToge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpbmRleCA9IDA7IGluZGV4IDwgaW5wdXQubGVuZ3RoOyBpbmRleCsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpblRhbmdlbnQgPSBwcm9wZXJ0eUluZm8uZ2V0VmFsdWUodGFyZ2V0LCBvdXRwdXQsIG91dHB1dE9mZnNldCwgaW52ZnBzKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dE9mZnNldCArPSBzdHJpZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IHByb3BlcnR5SW5mby5nZXRWYWx1ZSh0YXJnZXQsIG91dHB1dCwgb3V0cHV0T2Zmc2V0LCAxKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dE9mZnNldCArPSBzdHJpZGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvdXRUYW5nZW50ID0gcHJvcGVydHlJbmZvLmdldFZhbHVlKHRhcmdldCwgb3V0cHV0LCBvdXRwdXRPZmZzZXQsIGludmZwcyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRPZmZzZXQgKz0gc3RyaWRlO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleXNbaW5kZXhdID0ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyYW1lOiBpbnB1dFtpbmRleF0gKiBmcHMsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5UYW5nZW50OiBpblRhbmdlbnQsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZhbHVlLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dFRhbmdlbnQ6IG91dFRhbmdlbnQsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBjYXNlIEFuaW1hdGlvblNhbXBsZXJJbnRlcnBvbGF0aW9uLkxJTkVBUjoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpbmRleCA9IDA7IGluZGV4IDwgaW5wdXQubGVuZ3RoOyBpbmRleCsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IHByb3BlcnR5SW5mby5nZXRWYWx1ZSh0YXJnZXQsIG91dHB1dCwgb3V0cHV0T2Zmc2V0LCAxKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dE9mZnNldCArPSBzdHJpZGU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5c1tpbmRleF0gPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJhbWU6IGlucHV0W2luZGV4XSAqIGZwcyxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBpZiAob3V0cHV0T2Zmc2V0ID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IG5hbWUgPSBgJHthbmltYXRpb24ubmFtZSB8fCBgYW5pbWF0aW9uJHthbmltYXRpb24uaW5kZXh9YH1fY2hhbm5lbCR7Y2hhbm5lbC5pbmRleH1fJHtudW1BbmltYXRpb25zfWA7XHJcbiAgICAgICAgICAgICAgICAgICAgcHJvcGVydHlJbmZvLmJ1aWxkQW5pbWF0aW9ucyh0YXJnZXQsIG5hbWUsIGZwcywga2V5cywgKGJhYnlsb25BbmltYXRhYmxlLCBiYWJ5bG9uQW5pbWF0aW9uKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICsrbnVtQW5pbWF0aW9ucztcclxuICAgICAgICAgICAgICAgICAgICAgICAgb25Mb2FkKGJhYnlsb25BbmltYXRhYmxlLCBiYWJ5bG9uQW5pbWF0aW9uKTtcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX2xvYWRBbmltYXRpb25TYW1wbGVyQXN5bmMoY29udGV4dDogc3RyaW5nLCBzYW1wbGVyOiBJQW5pbWF0aW9uU2FtcGxlcik6IFByb21pc2U8X0lBbmltYXRpb25TYW1wbGVyRGF0YT4ge1xyXG4gICAgICAgIGlmIChzYW1wbGVyLl9kYXRhKSB7XHJcbiAgICAgICAgICAgIHJldHVybiBzYW1wbGVyLl9kYXRhO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgY29uc3QgaW50ZXJwb2xhdGlvbiA9IHNhbXBsZXIuaW50ZXJwb2xhdGlvbiB8fCBBbmltYXRpb25TYW1wbGVySW50ZXJwb2xhdGlvbi5MSU5FQVI7XHJcbiAgICAgICAgc3dpdGNoIChpbnRlcnBvbGF0aW9uKSB7XHJcbiAgICAgICAgICAgIGNhc2UgQW5pbWF0aW9uU2FtcGxlckludGVycG9sYXRpb24uU1RFUDpcclxuICAgICAgICAgICAgY2FzZSBBbmltYXRpb25TYW1wbGVySW50ZXJwb2xhdGlvbi5MSU5FQVI6XHJcbiAgICAgICAgICAgIGNhc2UgQW5pbWF0aW9uU2FtcGxlckludGVycG9sYXRpb24uQ1VCSUNTUExJTkU6IHtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGRlZmF1bHQ6IHtcclxuICAg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2FkVXJpQXN5bmMoYCR7Y29udGV4dH0vdXJpYCwgYnVmZmVyLCBidWZmZXIudXJpKTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGlmICghdGhpcy5fYmluKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGAke2NvbnRleHR9OiBVcmkgaXMgbWlzc2luZyBvciB0aGUgYmluYXJ5IGdsVEYgaXMgbWlzc2luZyBpdHMgYmluYXJ5IGNodW5rYCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgYnVmZmVyLl9kYXRhID0gdGhpcy5fYmluLnJlYWRBc3luYygwLCBidWZmZXIuYnl0ZUxlbmd0aCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBidWZmZXIuX2RhdGEudGhlbigoZGF0YSkgPT4ge1xyXG4gICAgICAgICAgICB0cnkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBVaW50OEFycmF5KGRhdGEuYnVmZmVyLCBkYXRhLmJ5dGVPZmZzZXQgKyBieXRlT2Zmc2V0LCBieXRlTGVuZ3RoKTtcclxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xyXG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGAke2NvbnRleHR9OiAke2UubWVzc2FnZX1gKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogTG9hZHMgYSBnbFRGIGJ1ZmZlciB2aWV3LlxyXG4gICAgICogQHBhcmFtIGNvbnRleHQgVGhlIGNvbnRleHQgd2hlbiBsb2FkaW5nIHRoZSBhc3NldFxyXG4gICAgICogQHBhcmFtIGJ1ZmZlclZpZXcgVGhlIGdsVEYgYnVmZmVyIHZpZXcgcHJvcGVydHlcclxuICAgICAqIEByZXR1cm5zI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gICAgICAgaWYgKGFjY2Vzc29yLmNvbXBvbmVudFR5cGUgPT09IEFjY2Vzc29yQ29tcG9uZW50VHlwZS5GTE9BVCAmJiAhYWNjZXNzb3Iubm9ybWFsaXplZCAmJiAoIWJ1ZmZlclZpZXcuYnl0ZVN0cmlkZSB8fCBidWZmZXJWaWV3LmJ5dGVTdHJpZGUgPT09IGJ5dGVTdHJpZGUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEdMVEZMb2FkZXIuX0dldFR5cGVkQXJyYXkoY29udGV4dCwgYWNjZXNzb3IuY29tcG9uZW50VHlwZSwgZGF0YSwgYWNjZXNzb3IuYnl0ZU9mZnNldCwgbGVuZ3RoKTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdHlwZWRBcnJheSA9IG5ldyBjb25zdHJ1Y3RvcihsZW5ndGgpO1xyXG4gICAgICAgICAgICAgICAgICAgIFZlcnRleEJ1ZmZlci5Gb3JFYWNoKFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBhY2Nlc3Nvci5ieXRlT2Zmc2V0IHx8IDAsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlclZpZXcuYnl0ZVN0cmlkZSB8fCBieXRlU3RyaWRlLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBudW1Db21wb25lbnRzLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBhY2Nlc3Nvci5jb21wb25lbnRUeXBlLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlZEFycmF5Lmxlbmd0aCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgYWNjZXNzb3Iubm9ybWFsaXplZCB8fCBmYWxzZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgKHZhbHVlLCBpbmRleCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgd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ICAgICAgICAgICAgICAgICAgdGhpcy5sb2FkQnVmZmVyVmlld0FzeW5jKGAvYnVmZmVyVmlld3MvJHt2YWx1ZXNCdWZmZXJWaWV3LmluZGV4fWAsIHZhbHVlc0J1ZmZlclZpZXcpLFxyXG4gICAgICAgICAgICAgICAgXSkudGhlbigoW2luZGljZXNEYXRhLCB2YWx1ZXNEYXRhXSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGluZGljZXMgPSBHTFRGTG9hZGVyLl9HZXRUeXBlZEFycmF5KFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBgJHtjb250ZXh0fS9zcGFyc2UvaW5kaWNlc2AsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNwYXJzZS5pbmRpY2VzLmNvbXBvbmVudFR5cGUsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGluZGljZXNEYXRhLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBzcGFyc2UuaW5kaWNlcy5ieXRlT2Zmc2V0LFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBzcGFyc2UuY291bnRcclxuICAgICAgICAgICAgICAgICAgICApIGFzIEluZGljZXNBcnJheTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BhcnNlTGVuZ3RoID0gbnVtQ29tcG9uZW50cyAqIHNwYXJzZS5jb3VudDtcclxuICAgICAgICAgICAgICAgICAgICBsZXQgdmFsdWVzOiBUeXBlZEFycmF5TGlrZTtcclxuXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGFjY2Vzc29yLmNvbXBvbmVudFR5cGUgPT09IEFjY2Vzc29yQ29tcG9uZW50VHlwZS5GTE9BVCAmJiAhYWNjZXNzb3Iubm9ybWFsaXplZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZXMgPSBHTFRGTG9hZGVyLl9HZXRUeXBlZEFycmF5KGAke2NvbnRleHR9L3NwYXJzZS92YWx1ZXNgLCBhY2Nlc3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SW5kZXhdICogbnVtQ29tcG9uZW50cztcclxuICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgY29tcG9uZW50SW5kZXggPSAwOyBjb21wb25lbnRJbmRleCA8IG51bUNvbXBvbmVudHM7IGNvbXBvbmVudEluZGV4KyspIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGVkQXJyYXlbZGF0YUluZGV4KytdID0gdmFsdWVzW3ZhbHVlc0luZGV4KytdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHlwZWRBcnJheTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBhY2Nlc3Nvci5fZGF0YTtcclxuICAgIH1cclxuXHJcbiAgICAvKipcclxuICAgICAqIEBpbnRlcm5hbFxyXG4gICAgICovXHJcbiAgICBwdWJsaWMgX2xvYWRGbG9hdEFjY2Vzc29yQXN5bmMoY29udGV4dDogc3RyaW5nLCBhY2Nlc3NvcjogSUFjY2Vzc29yKTogUHJvbWlzZTxGbG9hdDMyQXJyYXk+IHtcclxuICAgICAgICByZXR1cm4gdGhpcy5fbG9hZEFjY2Vzc29yQXN5bmMoY29udGV4dCwgYWNjZXNzb3IsIEZsb2F0MzJBcnJheSkgYXMgUHJvbWlzZTxGbG9hdDMyQXJyYXk+O1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQGludGVybmFsXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBfbG9hZEluZGljZXNBY2Nlc3NvckFzeW5jKGNvbnRleHQ6IHN0cmluZywgYWNjZXNzb3I6IElBY2Nlc3Nvcik6IFByb21pc2U8SW5kaWNlc0FycmF5PiB7XHJcbiAgICAgICAgaWYgKGFjY2Vzc29yLnR5cGUgIT09IEFjY2Vzc29yVHl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uR2V0KGAke2NvbnRleHR9L2J1ZmZlclZpZXdgLCB0aGlzLl9nbHRmLmJ1ZmZlclZpZXdzLCBhY2Nlc3Nvci5idWZmZXJWaWV3KTtcclxuICAgICAgICAgICAgYWNjZXNzb3IuX2JhYnlsb25WZXJ0ZXhCdWZmZXJba2luZF0gPSB0aGlzLl9sb2FkVmVydGV4QnVmZmVyVmlld0FzeW5jKGJ1ZmZlclZpZXcpLnRoZW4oKGJhYnlsb25CdWZmZXIpID0+IHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IG51bUNvbXBvbmVudHMgPSBHTFRGTG9hZGVyLl9HZXROdW1Db21wb25lbnRzKGNvbnRleHQsIGFjY2Vzc29yLnR5cGUpO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBWZXJ0ZXhCdWZmZXIoXHJcbiAgICAgICAgICAgICAgICAgICAgZW5naW5lLFxyXG4gICAgICAgICAgICAgICAgICAgIGJhYnlsb25CdWZmZXIsXHJcbiAgICAgICAgICAgICAgICAgICAga2luZCxcclxuICAgICAgICAgICAgICAgICAgICBmYWxzZSxcclxuICAgICAgICAgICAgICAgICAgICB1bmRlZmluZWQsXHJcbiAgICAgICAgICAgICAgICAgICAgYnVmZmVyVmlldy5ieXRlU3RyaWRlLFxyXG4gICAgICAgICAgICAgICAgICAgIHVuZGVmaW5lZCxcclxuICAgICAgICAgICAgICAgICAgICBhY2Nlc3Nvci5ieXRlT2Zmc2V0LFxyXG4gICAgICAgICAgICAgICAgICAgIG51bUNvbXBvbmVudHMsXHJcbiAgICAgICAgICAgICAgICAgICAgYWNjZXNzb3IuY29tcG9uZW50VHlwZSxcclxuICAgICAgICAgICAgICAgICAgICBhY2Nlc3Nvci5ub3JtYWxpemVkLFxyXG4gICAgICAgICAgICAgICAgICAgIHRydWUsXHJcbiAgICAgICAgICAgICAgICAgICAgdW5kZWZpbmVkLFxyXG4gICAgICAgICAgICAgICAgICAgIHRydWVcclxuICAgICAgICAgICAgICAgICk7XHJcb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xuXHJcbiAgICAgICAgICAgIGJhYnlsb25NYXRlcmlhbC5tZXRhbGxpYyA9IHByb3BlcnRpZXMubWV0YWxsaWNGYWN0b3IgPT0gdW5kZWZpbmVkID8gMSA6IHByb3BlcnRpZXMubWV0YWxsaWNGYWN0b3I7XHJcbiAgICAgICAgICAgIGJhYnlsb25NYXRlcmlhbC5yb3VnaG5lc3MgPSBwcm9wZXJ0aWVzLnJvdWdobmVzc0ZhY3RvciA9PSB1bmRlZmluZWQgPyAxIDogcHJvcGVydGllcy5yb3VnaG5lc3NGYWN0b3I7XHJcblxyXG4gICAgICAgICAgICBpZiAocHJvcGVydGllcy5iYXNlQ29sb3JUZXh0dXJlKSB7XHJcbiAgICAgICAgICAgICAgICBwcm9taXNlcy5wdXNoKFxyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMubG9hZFRleHR1cmVJbmZvQXN5bmMoYCR7Y29udGV4dH0vYmFzZUNvbG9yVGV4dHVyZWAsIHByb3BlcnRpZXMuYmFzZUNvbG9yVGV4dHVyZSwgKHRleHR1cmUpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dHVyZS5uYW1lID0gYCR7YmFieWxvbk1hdGVyaWFsLm5hbWV9IChCYXNlIENvbG9yKWA7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJhYnlsb25NYXRlcmlhbC5hbGJlZG9UZXh0dXJlID0gdGV4dHVyZTtcclxuICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYgKHByb3BlcnRpZXMubWV0YWxsaWNSb3VnaG5lc3NUZXh0dXJlKSB7XHJcbiAgICAgICAgICAgICAgICBwcm9wZXJ0aWVzLm1ldGFsbGljUm91Z2huZXNzVGV4dHVyZS5ub25Db2xvckRhdGEgPSB0cnVlO1xyXG4gICAgICAgICAgICAgICAgcHJvbWlzZXMucHVzaChcclxuICAgICAgICAgICAgICAgIC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ZShkYXRhKTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHRoaXMubG9nKGAke2NvbnRleHR9OiBMb2FkaW5nICR7dXJpfWApO1xyXG5cclxuICAgICAgICByZXR1cm4gdGhpcy5fcGFyZW50LnByZXByb2Nlc3NVcmxBc3luYyh0aGlzLl9yb290VXJsICsgdXJpKS50aGVuKCh1cmwpID0+IHtcclxuICAgICAgICAgICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcclxuICAgICAgICAgICAgICAgIHRoaXMuX3BhcmVudC5fbG9hZEZpbGUoXHJcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmFieWxvblNjZW5lLFxyXG4gICAgICAgICAgICAgICAgICAgIHVybCxcclxuICAgICAgICAgICAgICAgICAgICAoZGF0YSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX2Rpc3Bvc2VkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxvZyhgJHtjb250ZXh0fTogTG9hZGVkICR7dXJpfSAoJHsoZGF0YSBhcyBBcnJheUJ1ZmZlcikuYnl0ZUxlbmd0aH0gYnl0ZXMpYCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKG5ldyBVaW50OEFycmF5KGRhdGEgYXMgQXJyYXlCdWZmZXIpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICAgICAgdHJ1ZSxcclxuICAgICAgICAgICAgICAgICAgICAocmVxdWVzdCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZWplY3QobmV3IExvYWRGaWxlRXJyb3IoYCR7Y29udGV4dH06IEZhaWxlZCB0byBsb2FkICcke3VyaX0nJHtyZXF1ZXN0ID8gXCI6IFwiICsgcmVxdWVzdC5zdGF0dXMgKyBcIiBcIiArIHJ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HR1cmVNaW5GaWx0ZXIuTkVBUkVTVF9NSVBNQVBfTElORUFSOlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBUZXh0dXJlLkxJTkVBUl9ORUFSRVNUX01JUExJTkVBUjtcclxuICAgICAgICAgICAgICAgIGNhc2UgVGV4dHVyZU1pbkZpbHRlci5MSU5FQVJfTUlQTUFQX0xJTkVBUjpcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gVGV4dHVyZS5MSU5FQVJfTElORUFSX01JUExJTkVBUjtcclxuICAgICAgICAgICAgICAgIGRlZmF1bHQ6XHJcbiAgICAgICAgICAgICAgICAgICAgTG9nZ2VyLldhcm4oYCR7Y29udGV4dH0vbWluRmlsdGVyOiBJbnZhbGlkIHZhbHVlICgke21pbkZpbHRlcn0pYCk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFRleHR1cmUuTElORUFSX0xJTkVBUl9NSVBMSU5FQVI7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICBpZiAobWFnRmlsdGVyICE9PSBUZXh0dXJlTWFnRmlsdGVyLk5FQVJFU1QpIHtcclxuICAgICAgICAgICAgICAgIExvZ2dlci5XYXJuKGAke2NvbnRleHR9L21hZ0ZpbHRlcjogSW52YWxpZCB2YWx1ZSAoJHttYWdGaWx0ZXJ9KWApO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBzd2l0Y2ggKG1pbkZpbHRlcikge1xyXG4gICAgICAgICAgICAgICAgY2FzZSBUZXh0dXJlTWluRmlsdGVyLk5FQVJFU1Q6XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFRleHR1cmUuTkVBUkVTVF9ORUFSRVNUO1xyXG4gICAgICAgICAgICAgICAgY2FzZSBUZXh0dXJlTWluRmlsdGVyLkxJTkVBUjpcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gVGV4dHVyZS5ORUFSRVNUX0xJTkVBUjtcclxuICAgICAgICAgICAgICAgIGNhc2UgVGV4dHVyZU1pbkZpbHRlci5ORUFSRVNUX01JUE1BUF9ORUFSRVNUOlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBUZXh0dXJlLk5FQVJFU1RfTkVBUkVTVF9NSVBORUFSRVNUO1xyXG4gICAgICAgICAgICAgICAgY2FzZSBUZXh0dXJlTWluRmlsdGVyLkxJTkVBUl9NSVBNQVBfTkVBUkVTVDpcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gVGV4dHVyZS5ORUFSRVNUX0xJTkVBUl9NSVBORUFSRVNUO1xyXG4gICAgICAgICAgICAgICAgY2FzZSBUZXh0dXJlTWluRmlsdGVyLk5FQVJFU1RfTUlQTUFQX0xJTkVBUjpcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gVGV4dHVyZS5ORUFSRVNUX05FQVJFU1RfTUlQTElORUFSO1xyXG4gICAgICAgICAgICAgICAgY2FzZSBUZXh0dXJlTWluRmlsdGVyLkxJTkVBUl9NSVBNQVBfTElORUFSOlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBUZXh0dXJlLk5FQVJFU1RfTElORUFSX01JUExJTkVBUjtcclxuICAgICAgICAgICAgICAgIGRlZmF1bHQ6XHJcbiAgICAgICAgICAgICAgICAgICAgTG9nZ2VyLldhcm4oYCR7Y29udGV4dH0vbWluRmlsdGVyOiBJbnZhbGlkIHZhbHVlICgke21pbkZpbHRlcn0pYCk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFRleHR1cmUuTkVBUkVTVF9ORUFSRVNUX01JUE5FQVJFU1Q7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBzdGF0aWMgX0dldFR5cGVkQXJyYXlDb25zdHJ1Y3Rvcihjb250ZXh0OiBzdHJpbmcsIGNvbXBvbmVudFR5cGU6IEFjY2Vzc29yQ29tcG9uZW50VHlwZSk6IFR5cGVkQXJyYXlDb25zdHJ1Y3RvciB7XHJcbiAgICAgICAgc3dpdGNoIChjb21wb25lbnRUeXBlKSB7XHJcbiAgICAgICAgICAgIGNhc2UgQWNjZXNzb3JDb21wb25lbnRUeXBlLkJZVEU6XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gSW50OEFycmF5O1xyXG4gICAgICAgICAgICBjYXNlIEFjY2Vzc29yQ29tcG9uZW50VHlwZS5VTlNJR05FRF9CWVRFOlxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIFVpbnQ4QXJyYXk7XHJcbiAgICAgICAgICAgIGNhc2UgQWNjZXNzb3JDb21wb25lbnRUeXBlLlNIT1JUOlxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIEludDE2QXJyYXk7XHJcbiAgICAgICAgICAgIGNhc2UgQWNjZXNzb3JDb21wb25lbnRUeXBlLlVOU0lHTkVEX1NIT1JUOlxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIFVpbnQxNkFycmF5O1xyXG4gICAgICAgICAgICBjYXNlIEFjY2Vzc29yQ29tcG9uZW50VHlwZS5VTlNJR05FRF9JTlQ6XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gVWludDMyQXJyYXk7XHJcbiAgICAgICAgICAgIGNhc2UgQWNjZXNzb3JDb21wb25lbnRUeXBlLkZMT0FUOlxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIEZsb2F0MzJBcnJheTtcclxuICAgICAgICAgICAgZGVmYXVsdDpcclxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgJHtjb250ZXh0fTogSW52YWxpZCBjb21wb25lbnQgdHlwZSAke2NvbXBvbmVudFR5cGV9YCk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgc3RhdGljIF9HZXRUeXBlZEFycmF5KFxyXG4gICAgICAgIGNvbnRleHQ6IHN0cmluZyxcclxuICAgICAgICBjb21wb25lbnRUeXBlOiBBY2Nlc3NvckN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uc3RydWN0b3IoYnVmZmVyLnNsaWNlKGJ5dGVPZmZzZXQsIGJ5dGVPZmZzZXQgKyBsZW5ndGggKiBjb21wb25lbnRUeXBlTGVuZ3RoKSwgMCk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICByZXR1cm4gbmV3IGNvbnN0cnVjdG9yKGJ1ZmZlciwgYnl0ZU9mZnNldCwgbGVuZ3RoKTtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIHN0YXRpYyBfR2V0TnVtQ29tcG9uZW50cyhjb250ZXh0OiBzdHJpbmcsIHR5cGU6IHN0cmluZyk6IG51bWJlciB7XHJcbiAgICAgICAgc3dpdGNoICh0eXBlKSB7XHJcbiAgICAgICAgICAgIGNhc2UgXCJTQ0FMQVJcIjpcclxuICAgICAgICAgICAgICAgIHJldHVybiAxO1xyXG4gICAgICAgICAgICBjYXNlIFwiVkVDMlwiOlxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIDI7XHJcbiAgICAgICAgICAgIGNhc2UgXCJWRUMzXCI6XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gMztcclxuICAgICAgICAgICAgY2FzZSBcIlZFQzRcIjpcclxuICAgICAgICAgICAgICAgIHJldHVybiA0O1xyXG4gICAgICAgICAgICBjYXNlIFwiTUFUMlwiOlxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIDQ7XHJcbiAgICAgICAgICAgIGNhc2UgXCJNQVQzXCI6XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gOTtcclxuICAgICAgICAgICAgY2FzZSBcIk1BVDRcIjpcclxuICAgICAgICAgICAgICAgIHJldHVybiAxNjtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHRocm93IG5ldyBFcnJvcihgJHtjb250ZXh0fTogSW52YWxpZCB0eXBlICgke3R5cGV9KWApO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgc3RhdGljIF9WYWxpZGF0ZVVyaSh1cmk6IHN0cmluZyk6IGJvb2xlYW4ge1xyXG4gICAgICAgIHJldHVybiBUb29scy5Jc0Jhc2U2NCh1cmkpIHx8IHVyaS5pbmRleE9mKFwiLi5cIikgPT09IC0xO1xyXG4gICAgfVxyXG5cclxuICAgIC8qKlxyXG4gICAgICogQGludGVybmFsXHJcbiAgICAgKi9cclxuICAgIHB1YmxpYyBzdGF0aWMgX0dldERyYXdNb2RlKGNvbnRleHQ6IHN0cmluZywgbW9kZTogbnVtYmVyIHwgdW5kZWZpbmVkKTogbnVtYmVyIHtcclxuICAgICAgICBpZiAobW9kZSA9PSB1bmRlZmluZWQpIHtcclxuICAgICAgICAgICAgbW9kZSA9IE1lc2hQcmltaXRpdmVNb2RlLlRSSUFOR0xFUztcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHN3aXRjaCAobW9kZSkge1xyXG4gICAgICAgICAgICBjYXNlIE1lc2hQcmltaXRpdmVNb2RlLlBPSU5UUzpcclxuICAgICAgICAgICAgICAgIHJldHVybiBNYXRlcmlhbC5Qb2ludExpc3REcmF3TW9kZTtcclxuICAgICAgICAgICAgY2FzZSBNZXNoUHJpbWl0aXZlTW9kZS5MSU5FUzpcclxuICAgICAgICAgICAgICAgIHJldHVybiBNYXRlcmlhbC5MaW5lTGlzdERyYXdNb2RlO1xyXG4gICAgICAgICAgICBjYXNlIE1lc2hQcmltaXRpdmVNb2RlLkxJTkVfTE9PUDpcclxuICAgICAgICAgICAgICAgIHJldHVybiBNYXRlcmlhbC5MaW5lTG9vcERyYXdNb2RlO1xyXG4gICAgICAgICAgICBjYXNlIE1lc2hQcmltaXRpdmVNb2RlLkxJTkVfU1RSSVA6XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gTWF0ZXJpYWwuTGluZVN0cmlwRHJhd01vZGU7XHJcbiAgICAgICAgICAgIGNhc2UgTWVzaFByaW1pdGl2ZU1vZGUuVFJJQU5HTEVTOlxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIE1hdGVyaWFsLlRyaWFuZ2xlRmlsbE1vZGU7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gICAgICAgICAgICAgICBmb3IgKGNvbnN0IGJhYnlsb25NZXNoIG9mIGJhYnlsb25EYXRhLmJhYnlsb25NZXNoZXMpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIEVuc3VyZSBub25Vbmlmb3JtU2NhbGluZyBpcyBzZXQgaWYgbmVjZXNzYXJ5LlxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFieWxvbk1lc2guY29tcHV0ZVdvcmxkTWF0cml4KHRydWUpO1xyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJhYnlsb25NYXRlcmlhbCA9IGJhYnlsb25EYXRhLmJhYnlsb25NYXRlcmlhbDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2goYmFieWxvbk1hdGVyaWFsLmZvcmNlQ29tcGlsYXRpb25Bc3luYyhiYWJ5bG9uTWVzaCkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvbWlzZXMucHVzaChiYWJ5bG9uTWF0ZXJpYWwuZm9yY2VDb21waWxhdGlvbkFzeW5jKGJhYnlsb25NZXNoLCB7IHVzZUluc3RhbmNlczogdHJ1ZSB9KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcGFyZW50LnVzZUNsaXBQbGFuZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2goYmFieWxvbk1hdGVyaWFsLmZvcmNlQ29tcGlsYXRpb25Bc3luYyhiYWJ5bG9uTWVzaCwgeyBjbGlwUGxhbmU6IHRydWUgfSkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb21pc2VzLnB1c2goYmFieWxvbk1hdGVyaWFsLmZvcmNlQ29tcGlsYXRpb25Bc3luYyhiYWJ5bG9uTWVzaCwgeyBjbGlwUGxhbmU6IHRydWUsIHVzZUluc3RhbmNlczogdHJ1ZSB9KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbigoKSA9PiB7XHJcbiAgICAgICAgICAgIHRoaXMuX3BhcmVudC5fZW5kUGVyZm9ybWFuY2VDb3VudGVyKFwiQ29tcGlsZSBtYXRlcmlhbHNcIik7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBfY29tcGlsZVNoYWRvd0dlbmVyYXRvcnNBc3luYygpOiBQcm9taXNlPHZvaWQ+IHtcclxuICAgICAgICB0aGlzLl9wYXJlbnQuX3N0YXJ0UGVyZm9ybWFuY2VDb3VudGVyKFwiQ29tcGlsZSBzaGFkb3cgZ2VuZXJhdG9yc1wiKTtcclxuXHJcbiAgICAgICAgY29uc3QgcHJvbWlzZXMgPSBuZXcgQXJyYXk8UHJvbWlzZTxhbnk+PigpO1xyXG5cclxuICAgICAgICBjb25zdCBsaWdodHMgPSB0aGlzLl9iYWJ5bG9uU2NlbmUubGlnaHRzO1xyXG4gICAgICAgIGZvciAoY29uc3QgbGlnaHQgb2YgbGlnaHRzKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IGdlbmVyYXRvciA9IGxpZ2h0LmdldFNoYWRvd0dlbmVyYXRvcigpO1xyXG4gICAgICAgICAgICBpZiAoZ2VuZXJhdG9yKSB7XHJcbiAgICAgICAgICAgICAgICBwcm9taXNlcy5wdXNoKGdlbmVyYXRvci5mb3JjZUNvbXBpbGF0aW9uQXN5bmMoKSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbigoKSA9PiB7X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Z1bmN0aW9ucyA9IGxvYWRlclByb3BlcnR5Ll9hY3RpdmVMb2FkZXJFeHRlbnNpb25GdW5jdGlvbnMgfHwge307XHJcbiAgICAgICAgICAgICAgICBjb25zdCBhY3RpdmVMb2FkZXJFeHRlbnNpb25GdW5jdGlvbnMgPSBsb2FkZXJQcm9wZXJ0eS5fYWN0aXZlTG9hZGVyRXh0ZW5zaW9uRnVuY3Rpb25zO1xyXG4gICAgICAgICAgICAgICAgaWYgKCFhY3RpdmVMb2FkZXJFeHRlbnNpb25GdW5jdGlvbnNbaWRdKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYWN0aXZlTG9hZGVyRXh0ZW5zaW9uRnVuY3Rpb25zW2lkXSA9IHRydWU7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIHRyeSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlc3VsdCA9IGFjdGlvbkFzeW5jKGV4dGVuc2lvbik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9IGZpbmFsbHkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgYWN0aXZlTG9hZGVyRXh0ZW5zaW9uRnVuY3Rpb25zW2lkXTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBudWxsO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX2V4dGVuc2lvbnNPbkxvYWRpbmcoKTogdm9pZCB7XHJcbiAgICAgICAgdGhpcy5fZm9yRWFjaEV4dGVuc2lvbnMoKGV4dGVuc2lvbikgPT4gZXh0ZW5zaW9uLm9uTG9hZGluZyAm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Xkub3V0VGFuZ2VudCA/IGtleS5vdXRUYW5nZW50W3RhcmdldEluZGV4XSA6IHVuZGVmaW5lZCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgaW50ZXJwb2xhdGlvbjoga2V5LmludGVycG9sYXRpb24sXHJcbiAgICAgICAgICAgICAgICAgICAgfSkpXHJcbiAgICAgICAgICAgICAgICApO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmICh0YXJnZXQuX3ByaW1pdGl2ZUJhYnlsb25NZXNoZXMpIHtcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGJhYnlsb25NZXNoIG9mIHRhcmdldC5fcHJpbWl0aXZlQmFieWxvbk1lc2hlcykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmFieWxvbk1lc2gubW9ycGhUYXJnZXRNYW5hZ2VyKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtb3JwaFRhcmdldCA9IGJhYnlsb25NZXNoLm1vcnBoVGFyZ2V0TWFuYWdlci5nZXRUYXJnZXQodGFyZ2V0SW5kZXgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmFieWxvbkFuaW1hdGlvbkNsb25lID0gYmFieWxvbkFuaW1hdGlvbi5jbG9uZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9ycGhUYXJnZXQuYW5pbWF0aW9ucy5wdXNoKGJhYnlsb25BbmltYXRpb25DbG9uZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayhtb3JwaFRhcmdldCwgYmFieWxvbkFuaW1hdGlvbkNsb25lKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxufVxyXG5cclxuLyoqIEBpbnRlcm5hbCAqL1xyXG5leH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G5vdCBzdXBwb3J0ZWQgd2hlbiByYW5nZSByZXF1ZXN0cyBhcmUgZW5hYmxlZFwiKTtcclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBjb25zdCBmaWxlUmVxdWVzdDogSUZpbGVSZXF1ZXN0ID0ge1xyXG4gICAgICAgICAgICAgICAgICAgIGFib3J0OiAoKSA9PiB7fSxcclxuICAgICAgICAgICAgICAgICAgICBvbkNvbXBsZXRlT2JzZXJ2YWJsZTogbmV3IE9ic2VydmFibGU8SUZpbGVSZXF1ZXN0PigpLFxyXG4gICAgICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgICAgICBjb25zdCBkYXRhQnVmZmVyID0ge1xyXG4gICAgICAgICAgICAgICAgICAgIHJlYWRBc3luYzogKGJ5dGVPZmZzZXQ6IG51bWJlciwgYnl0ZUxlbmd0aDogbnVtYmVyKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZTxBcnJheUJ1ZmZlclZpZXc+KChyZXNvbHZlLCByZWplY3QpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRGaWxlKFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjZW5lLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVPclVybCBhcyBGaWxlIHwgc3RyaW5nLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChkYXRhKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUobmV3IFVpbnQ4QXJyYXkoZGF0YSBhcyBBcnJheUJ1ZmZlcikpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ1ZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoZXJyb3IpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVqZWN0KGVycm9yKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICh3ZWJSZXF1ZXN0KSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdlYlJlcXVlc3Quc2V0UmVxdWVzdEhlYWRlcihcIlJhbmdlXCIsIGBieXRlcz0ke2J5dGVPZmZzZXR9LSR7Ynl0ZU9mZnNldCArIGJ5dGVMZW5ndGggLSAxfWApO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICAgICAgYnl0ZUxlbmd0aDogMCxcclxuICAgICAgICAgICAgICAgIH07XHJcblxyXG4gICAgICAgICAgICAgICAgdGhpcy5fdW5wYWNrQmluYXJ5QXN5bmMobmV3IERhdGFSZWFkZXIoZGF0YUJ1ZmZlcikpLnRoZW4oXHJcbiAgICAgICAgICAgICAgICAgICAgKGxvYWRlckRhdGEpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZmlsZVJlcXVlc3Qub25Db21wbGV0ZU9ic2VydmFibGUubm90aWZ5T2JzZXJ2ZXJzKGZpbGVSZXF1ZXN0KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgb25TdWNjZXNzKGxvYWRlckRhdGEpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICAgICAgb25FcnJvciA/IChlcnJvcikgPT4gb25FcnJvcih1bmRlZmluZWQsIGVycm9yKSA6IHVuZGVmaW5lZFxyXG4gICAgICAgICAgICAgICAgKTtcclxuXHJcbiAgICAgICAgICAgICAgICByZXR1cm4gZmlsZVJlcXVlc3Q7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9sb2FkRmlsZShcclxuICAgICAgICAgICAgICAgIHNjZW5lLFxyXG4gICAgICAgICAgICAgICAgZmlsZU9yVXJsIGFzIEZpbGUgfCBzdHJpbmcsXHJcbiAgICAgICAgICAgICAgICAoZGF0YSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3ZhbGlkYXRlKHNjZW5lLCBuZXcgVWludDhBcnJheShkYXRhIGFzIEFycmF5QnVmZmVyLCAwLCAoZGF0YSBhcyBBcnJheUJ1ZmZlcikuYnl0ZUxlbmd0aCksIHJvb3RVcmwsIGZpbGVOYW1lKTtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl91bnBhY2tCaW5hcnlBc3luYyhcclxuICAgICAgICAgICAgICAgICAgICAgICAgbmV3IERhdGFSZWFkZXIoe1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZEFzeW5jOiAoYnl0ZU9mZnNldCwgYnl0ZUxlbmd0aCkgPT4gcmVhZEFzeW5jKGRhdGEgYXMgQXJyYXlCdWZmZXIsIGJ5dGVPZmZzZXQsIGJ5dGVMZW5ndGgpLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZUxlbmd0aDogKGRhdGEgYXMgQXJyYXlCdWZmZXIpLmJ5dGVMZW5ndGgsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgICAgICAgICAgKS50aGVuKFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAobG9hZGVyRGF0YSkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgb25TdWNjZXNzKGxvYWRlckRhdGEpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBvbkVycm9yID8gKGVycm9yKSA9PiBvbkVycm9yKHVuZGVmaW5lZCwgZXJyb3IpIDogdW5kZWZpbmVkXHJcbiAgICAgICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICB0cnVlLFxyXG4gICAgICAgICAgICAgICAgb25FcnJvclxyXG4gICAgICAgICAgICApO1xyXG4gICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9sb2FkRmlsZShcclxuICAgICAgICAgICAgICAgIHNjZW5lLFxyXG4gICAgICAgICAgICAgICAgZmlsZU9yVXJsLFxyXG4gICAgICAgICAgICAgICAgKGRhdGEpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICB0aGlzLl92YWxpZGF0ZShzY2VuZSwgZGF0YSBhcyBzdHJpbmcsIHJvb3RVcmwsIGZpbGVOYW1lKTtcclxuICAgICAgICAgICAgICAgICAgICBvblN1Y2Nlc3MoeyBqc29uOiB0aGlzLl9wYXJzZUpzb24oZGF0YSBhcyBzdHJpbmcpIH0pO1xyXG4gICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgIGZhbHNlLFxyXG4gICAgICAgICAgICAgICAgb25FcnJvclxyXG4gICAgICAgICAgICApO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF9sb2FkQmluYXJ5KFxyXG4gICAgICAgIHNjZW5lOiBTY2VuZSxcclxuICAgICAgICBkYXRhOiBBcnJheUJ1ZmZlclZpZXcsXHJcbiAgICAgICAgcm9vdFVybDogc3RyaW5nLFxyXG4gICAgICAgIG9uU3VjY2VzczogKGRhdGE6IGFueSwgcmVzcG9uc2VVUkw/OiBzdHJpbmcpID0+IHZvaWQsXHJcbiAgICAgICAgb25FcnJvcj86IChyZXF1ZXN0PzogV2ViUmVxdWVzdCwgZXhjZXB0aW9uPzogTG9hZEZpbGVFcnJvcikgPT4gdm9pZCxcclxuICAgICAgICBmaWxlTmFtZT86IHN0cmluZ1xyXG4gIC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gICBtb3JwaFRhcmdldE1hbmFnZXJzLnB1c2gobWVzaC5tb3JwaFRhcmdldE1hbmFnZXIpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9KTtcclxuXHJcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9sb2FkZXIuaW1wb3J0TWVzaEFzeW5jKG51bGwsIHNjZW5lLCBjb250YWluZXIsIGRhdGEsIHJvb3RVcmwsIG9uUHJvZ3Jlc3MsIGZpbGVOYW1lKS50aGVuKChyZXN1bHQpID0+IHtcclxuICAgICAgICAgICAgICAgIEFycmF5LnByb3RvdHlwZS5wdXNoLmFwcGx5KGNvbnRhaW5lci5nZW9tZXRyaWVzLCByZXN1bHQuZ2VvbWV0cmllcyk7XHJcbiAgICAgICAgICAgICAgICBBcnJheS5wcm90b3R5cGUucHVzaC5hcHBseShjb250YWluZXIubWVzaGVzLCByZXN1bHQubWVzaGVzKTtcclxuICAgICAgICAgICAgICAgIEFycmF5LnByb3RvdHlwZS5wdXNoLmFwcGx5KGNvbnRhaW5lci5wYXJ0aWNsZVN5c3RlbXMsIHJlc3VsdC5wYXJ0aWNsZVN5c3RlbXMpO1xyXG4gICAgICAgICAgICAgICAgQXJyYXkucHJvdG90eXBlLnB1c2guYXBwbHkoY29udGFpbmVyLnNrZWxldG9ucywgcmVzdWx0LnNrZWxldG9ucyk7XHJcbiAgICAgICAgICAgICAgICBBcnJheS5wcm90b3R5cGUucHVzaC5hcHBseShjb250YWluZXIuYW5pbWF0aW9uR3JvdXBzLCByZXN1bHQuYW5pbWF0aW9uR3JvdXBzKTtcclxuICAgICAgICAgICAgICAgIEFycmF5LnByb3RvdHlwZS5wdXNoLmFwcGx5KGNvbnRhaW5lci5tYXRlcmlhbHMsIG1hdGVyaWFscyk7XHJcbiAgICAgICAgICAgICAgICBBcnJheS5wcm90b3R5cGUucHVzaC5hcHBseShjb250YWluZXIudGV4dHVyZXMsIHRleHR1cmVzKTtcclxuICAgICAgICAgICAgICAgIE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AgICAgICAgICAgbGVuZ3RoQ29tcHV0YWJsZTogbGVuZ3RoQ29tcHV0YWJsZSxcclxuICAgICAgICAgICAgbG9hZGVkOiBsb2FkZWQsXHJcbiAgICAgICAgICAgIHRvdGFsOiBsZW5ndGhDb21wdXRhYmxlID8gdG90YWwgOiAwLFxyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG5cclxuICAgIHByaXZhdGUgX3ZhbGlkYXRlKHNjZW5lOiBTY2VuZSwgZGF0YTogc3RyaW5nIHwgVWludDhBcnJheSwgcm9vdFVybCA9IFwiXCIsIGZpbGVOYW1lID0gXCJcIik6IHZvaWQge1xyXG4gICAgICAgIGlmICghdGhpcy52YWxpZGF0ZSkge1xyXG4gICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICB0aGlzLl9zdGFydFBlcmZvcm1hbmNlQ291bnRlcihcIlZhbGlkYXRlIEpTT05cIik7XHJcbiAgICAgICAgR0xURlZhbGlkYXRpb24uVmFsaWRhdGVBc3luYyhkYXRhLCByb290VXJsLCBmaWxlTmFtZSwgKHVyaSkgPT4ge1xyXG4gICAgICAgICAgICByZXR1cm4gdGhpcy5wcmVwcm9jZXNzVXJsQXN5bmMocm9vdFVybCArIHVyaSkudGhlbigodXJsKSA9PiB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gc2NlbmUuX2xvYWRGaWxlQXN5bmModXJsLCB1bmRlZmluZWQsIHRydWUsIHRydWUpLnRoZW4oKGRhdGEpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFVpbnQ4QXJyYXkoZGF0YSwgMCwgZGF0YS5ieXRlTGVuZ3RoKTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9KS50aGVuKFxyXG4gICAgICAgICAgICAocmVzdWx0KSA9PiB7XHJcbiAgICAgICAgICAgICAgICB0aGlzLl9lbmRQZXJmb3JtYW5jZUNvdW50Z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3BhcnNlVmVyc2lvbihhc3NldC52ZXJzaW9uKTtcclxuICAgICAgICBpZiAoIXZlcnNpb24pIHtcclxuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiSW52YWxpZCB2ZXJzaW9uOiBcIiArIGFzc2V0LnZlcnNpb24pO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgaWYgKGFzc2V0Lm1pblZlcnNpb24gIT09IHVuZGVmaW5lZCkge1xyXG4gICAgICAgICAgICBjb25zdCBtaW5WZXJzaW9uID0gR0xURkZpbGVMb2FkZXIuX3BhcnNlVmVyc2lvbihhc3NldC5taW5WZXJzaW9uKTtcclxuICAgICAgICAgICAgaWYgKCFtaW5WZXJzaW9uKSB7XHJcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJJbnZhbGlkIG1pbmltdW0gdmVyc2lvbjogXCIgKyBhc3NldC5taW5WZXJzaW9uKTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYgKEdMVEZGaWxlTG9hZGVyLl9jb21wYXJlVmVyc2lvbihtaW5WZXJzaW9uLCB7IG1ham9yOiAyLCBtaW5vcjogMCB9KSA+IDApIHtcclxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIkluY29tcGF0aWJsZSBtaW5pbXVtIHZlcnNpb246IFwiICsgYXNzZXQubWluVmVyc2lvbik7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGNvbnN0IGNyZWF0ZUxvYWRlcnM6IHsgW2tleTogbnVtYmVyXTogKHBhcmVudDogR0xURkZpbGVMb2FkZXIpID0+IElHTFRGTG9hZGVyIH0gPSB7XHJcbiAgICAgICAgICAgIDE6IEdMVEZGaWxlTG9hZGVyLl9DcmVhdGVHTFRGMUxvYWRlcixcclxuICAgICAgICAgICAgMjogR0xURkZpbGVMb2FkZXIuX0NyZWF0ZUdMVEYyTG9hZGVyLFxyXG4gICAgICAgIH07XH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bWlzZTxJR0xURkxvYWRlckRhdGE+O1xyXG4gICAgICAgICAgICBzd2l0Y2ggKHZlcnNpb24pIHtcclxuICAgICAgICAgICAgICAgIGNhc2UgMToge1xyXG4gICAgICAgICAgICAgICAgICAgIHVucGFja2VkID0gdGhpcy5fdW5wYWNrQmluYXJ5VjFBc3luYyhkYXRhUmVhZGVyLCBsZW5ndGgpO1xyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgY2FzZSAyOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgdW5wYWNrZWQgPSB0aGlzLl91bnBhY2tCaW5hcnlWMkFzeW5jKGRhdGFSZWFkZXIsIGxlbmd0aCk7XHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBkZWZhdWx0OiB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiVW5zdXBwb3J0ZWQgdmVyc2lvbjogXCIgKyB2ZXJzaW9uKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgdGhpcy5fZW5kUGVyZm9ybWFuY2VDb3VudGVyKFwiVW5wYWNrIEJpbmFyeVwiKTtcclxuXHJcbiAgICAgICAgICAgIHJldHVybiB1bnBhY2tlZDtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICBwcml2YXRlIF91bnBhY2tCaW5hcnlWMUFzeW5jKGRhdGFSZWFkZXI6IERhdGFSZWFkZXIsIGxlbmd0aDogbnVtYmVyKTogUHJvbWlzZTxJR0xURkxvYWRlckRhdGE+IHtcclxuICAgICAgICBjb25zdCBDb250ZW50Rm9ybWF0ID0ge1xyXG4gICAgICAgICAgICBKU09OOiAwLFxyXG4gICAgICAgIH07XHJcblxyXG4gICAgICAgIGNvbnN0IGNvbnRlbnRM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ZCB0aGUgbGVuZ3RoIGFuZCB0eXBlIG9mIHRoZSBuZXh0IGNodW5rLlxyXG4gICAgICAgIHJldHVybiBkYXRhUmVhZGVyLmxvYWRBc3luYyhjaHVua0xlbmd0aCArIDgpLnRoZW4oKCkgPT4ge1xyXG4gICAgICAgICAgICBjb25zdCBkYXRhOiBJR0xURkxvYWRlckRhdGEgPSB7IGpzb246IHRoaXMuX3BhcnNlSnNvbihkYXRhUmVhZGVyLnJlYWRTdHJpbmcoY2h1bmtMZW5ndGgpKSwgYmluOiBudWxsIH07XHJcblxyXG4gICAgICAgICAgICBjb25zdCByZWFkQXN5bmMgPSAoKTogUHJvbWlzZTxJR0xURkxvYWRlckRhdGE+ID0+IHtcclxuICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rTGVuZ3RoID0gZGF0YVJlYWRlci5yZWFkVWludDMyKCk7XHJcbiAgICAgICAgICAgICAgICBjb25zdCBjaHVua0Zvcm1hdCA9IGRhdGFSZWFkZXIucmVhZFVpbnQzMigpO1xyXG5cclxuICAgICAgICAgICAgICAgIHN3aXRjaCAoY2h1bmtGb3JtYXQpIHtcclxuICAgICAgICAgICAgICAgICAgICBjYXNlIENodW5rRm9ybWF0LkpTT046IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiVW5leHBlY3RlZCBKU09OIGNodW5rXCIpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBjYXNlIENodW5rRm9ybWF0LkJJTjoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGFydEJ5dGVPZmZzZXQgPSBkYXRhUmVhZGVyLmJ5dGVPZmZzZXQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEuYmluID0ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZEFzeW5jOiAoYnl0ZU9mZnNldCwgYnl0ZUxlbmd0aCkgPT4gZGF0YVJlYWRlci5idWZmZXIucmVhZEFzeW5jKHN0YXJ0Qnl0ZU9mZnNldCArIGJ5dGVPZmZzZXQsIGJ5dGVMZW5ndGgpLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZUxlbmd0aDogY2h1bmtMZW5ndGgsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFSZWFkZXIuc2tpcEJ5dGVzKGNodW5rTGVuZ3RoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gaWdub3JlIHVucmVjb2duaXplZCBjaHVua0Zvcm1hdFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhUmVhZGVyLnNraXBCeXRlcyhjaHVua0xlbmd0aCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoZGF0YVJlYWRlci5ieXRlT2Zmc2V0ICE9PSBsZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGF0YVJlYWRlci5sb2FkQXN5bmMoOCkudGhlbihyZWFkQXN5bmMpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlc29sdmUoZGF0YSk7XHJcbiAgICAgICAgICAgIH07XHJcblxyXG4gICAgICAgICAgICByZXR1cm4gcmVhZEFzeW5jKCk7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBzdGF0aWMgX3BhcnNlVmVyc2lvbih2ZXJzaW9uOiBzdHJpbmcpOiBOdWxsYWJsZTx7IG1ham9yOiBudW1iZXI7IG1pbm9yOiBudW1iZXIgfT4ge1xyXG4gICAgICAgIGlmICh2ZXJzaW9uID09PSBcIjEuMFwiIHx8IHZlcnNpb24gPT09IFwiMS4wLjFcIikge1xyXG4gICAgICAgICAgICByZXR1cm4ge1xyXG4gICAgICAgICAgICAgICAgbWFqb3I6IDEsXHJcbiAgICAgICAgICAgICAgICBtaW5vcjogMCxcclxuICAgICAgICAgICAgfTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGNvbnN0IG1hdGNoID0gKHZlcnNpb24gKyBcIlwiKS5tYXRjaCgvXihcXGQrKVxcLihcXGQrKS8pO1xyXG4gICAgICAgIGlmICghbWF0Y2gpIHtcclxuICAgICAgICAgICAgcmV0dXJuIG51bGw7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICByZXR1cm4ge1xyXG4gICAgICAgICAgICBtYWpvcjogcGFyc2VJbnQobWF0Y2hbMV0pLFxyXG4gICAgICAgICAgICBtaW5vcjogcGFyc2VJbnQobWF0Y2hbMl0pLFxyXG4gICAgICAgIH07XHJcbiAgICB9XHJcblxyXG4gICAgcHJpdmF0ZSBzdGF0aWMgX2NvbXBhcmVWZXJzaW9uKGE6IHsgbWFqb3I6IG51bWJlcjsgbWlub3I6IG51bWJlciB9LCBiOiB7IG1ham9yOiBudW1iZXI7IG1pbm9yOiBudW1iZXIgfSk6IG51bWJlciB7XHJcbiAgICAgICAgaWYgKGEubWFqb3IgPiBiLm1ham9yKSB7XHJcbiAgICAgICAgICAgIHJldHVybiAxO1xyXG4gICAgICAgIH1cclxuICAgICAgICBpZiAoYS5tYWpvciA8IGIubWFqb3IpIHtcclxuICAgICAgICAgICAgcmV0dXJuIC0xO1xyXG4gICAgICAgIH1cclxuICAgICAgICBpZiAoYS5taW5vciA+IGIubWlub3IpIHtcclxuICAgICAgICAgICAgcmV0dXJuIDE7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmIChhLm1pbm9yIDwgYi5taW5vcikge1xy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W1lIDogcm9vdFVybCArIGZpbGVOYW1lO1xyXG4gICAgfVxyXG5cclxuICAgIHJldHVybiBBcnJheUJ1ZmZlci5pc1ZpZXcoZGF0YSkgPyBHTFRGVmFsaWRhdG9yLnZhbGlkYXRlQnl0ZXMoZGF0YSwgb3B0aW9ucykgOiBHTFRGVmFsaWRhdG9yLnZhbGlkYXRlU3RyaW5nKGRhdGEsIG9wdGlvbnMpO1xyXG59XHJcblxyXG4vKipcclxuICogVGhlIHdvcmtlciBmdW5jdGlvbiB0aGF0IGdldHMgY29udmVydGVkIHRvIGEgYmxvYiB1cmwgdG8gcGFzcyBpbnRvIGEgd29ya2VyLlxyXG4gKi9cclxuZnVuY3Rpb24gd29ya2VyRnVuYygpOiB2b2lkIHtcclxuICAgIGNvbnN0IHBlbmRpbmdFeHRlcm5hbFJlc291cmNlczogQXJyYXk8eyByZXNvbHZlOiAoZGF0YTogYW55KSA9PiB2b2lkOyByZWplY3Q6IChyZWFzb246IGFueSkgPT4gdm9pZCB9PiA9IFtdO1xyXG5cclxuICAgIG9ubWVzc2FnZSA9IChtZXNzYWdlKSA9PiB7XHJcbiAgICAgICAgY29uc3QgZGF0YSA9IG1lc3NhZ2UuZGF0YTtcclxuICAgICAgICBzd2l0Y2ggKGRhdGEuaWQpIHtcclxuICAgICAgICAgICAgY2FzZSBcImluaXRcIjoge1xyXG4gICAgICAgICAgICAgICAgaW1wb3J0U2NyaXB0cyhkYXRhLnVybCk7XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXNlIFwidmFsaWRhdGVcIjoge1xyXG4gICAgICAgICAgICAgICAgdmFsaWRhdGVBc3luYyhcclxuICAgICAgICAgICAgICAgICAgICBkYXRhLmRhdGEsXHJcbiAgICAgICAgICAgICAgICAgICAgZGF0YS5yb290VXJsLFxyXG4gICAgICAgICAgICAgICAgICAgIGRhdGEuZmlsZU5hbWUsXHJcbiAgICAgICAgICAgICAgICAgICAgKHVyaSkgPT5cclxuICAgICAgICAgICAgICAgICAgICAgICAgbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW5kZXggPSBwZW5kaW5nRXh0ZXJuYWxSZXNvdXJjZXMubGVuZ3RoO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ0V4dGVybmFsUmVzb3VyY2VzLnB1c2goeyByZXNvbHZlLCByZWplY3QgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3N0TWVzc2FnZSh7IGlkOiBcImdldEV4dGVybmFsUmVzb3VyY2VcIiwgaW5kZXg6IGluZGV4LCB1cmk6IHVyaSB9KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgICAgICkudGhlbihcclxuICAgICAgICAgICAgICAgICAgICAodmFsdWUpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcG9zdE1lc3NhZ2UoeyBpZDogXCJ2YWxpZGF0ZS5yZXNvbHZlXCIsIHZhbHVlOiB2YWx1ZSB9KTtcclxuICAgICAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgICAgIChyZWFzb24pID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcG9zdE1lc3NhZ2UoeyBpZDogXCJ2YWxpZGF0ZS5yZWplY3RcIiwgcmVhc29uOiByZWFzb24gfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgKTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGNhc2UgXCJnZXRFeHRlcm5hbFJlc291cmNlLnJlc29sdmVcIjoge1xyXG4gICAgICAgICAgICAgICAgcGVuZGluZ0V4dGVybmFsUmVzb3VyY2VzW2RhdGEuaW5kZXhdLnJlc29sdmUoZGF0YS52YWx1ZS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7XHJcbiAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXJDb250ZW50ID0gYCR7dmFsaWRhdGVBc3luY30oJHt3b3JrZXJGdW5jfSkoKWA7XHJcbiAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXJCbG9iVXJsID0gVVJMLmNyZWF0ZU9iamVjdFVSTChuZXcgQmxvYihbd29ya2VyQ29udGVudF0sIHsgdHlwZTogXCJhcHBsaWNhdGlvbi9qYXZhc2NyaXB0XCIgfSkpO1xyXG4gICAgICAgICAgICAgICAgY29uc3Qgd29ya2VyID0gbmV3IFdvcmtlcih3b3JrZXJCbG9iVXJsKTtcclxuXHJcbiAgICAgICAgICAgICAgICBjb25zdCBvbkVycm9yID0gKGVycm9yOiBFcnJvckV2ZW50KSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgd29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoXCJlcnJvclwiLCBvbkVycm9yKTtcclxuICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcihcIm1lc3NhZ2VcIiwgb25NZXNzYWdlKTtcclxuICAgICAgICAgICAgICAgICAgICByZWplY3QoZXJyb3IpO1xyXG4gICAgICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgICAgICBjb25zdCBvbk1lc3NhZ2UgPSAobWVzc2FnZTogTWVzc2FnZUV2ZW50KSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IG1lc3NhZ2UuZGF0YTtcclxuICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGRhdGEuaWQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcImdldEV4dGVybmFsUmVzb3VyY2VcIjoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0RXh0ZXJuYWxSZXNvdXJjZShkYXRhLnVyaSkudGhlbihcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAodmFsdWUpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IFwiZ2V0RXh0ZXJuYWxSZXNvdXJjZS5yZXNvbHZlXCIsIGluZGV4OiBkYXRhLmluZGV4LCB2YWx1ZTogdmFsdWUgfSwgW3ZhbHVlXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAocmVhc29uKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkOiBcImdldEV4dGVybmFsUmVzb3VyY2UucmVqZWN0XCIsIGluZGV4OiBkYXRhLmluZGV4LCByZWFzb246IHJlYXNvbiB9KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICApO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcInZhbGlkYXRlLnJlc29sdmVcIjoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoXCJlcnJvclwiLCBvbkVycm9yKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKFwibWVzc2FnZVwiLCBvbk1lc3NhZ2UpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShkYXRhLnZhbHVlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdvcmtlci50ZXJtaW5hdGUoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXCJ2YWxpZGF0ZS5yZWplY3RcIjoge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoXCJlcnJvclwiLCBvbkVycm9yKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKFwibWVzc2FnZVwiLCBvbk1lc3NhZ2UpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVqZWN0KGRhdGEucmVhc29uKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdvcmtlci50ZXJtaW5hdGUoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH07XHJcblxyXG4gICAgICAgICAgICAgICAgd29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoXCJlcnJvclwiLCBvbkVycm9yKTtcclxuICAgICAgICAgICAgICAgIHdvcmtlci5hZGRFdmVudExpc3RlbmVyKFwibWVzc2FnZVwiLCBvbk1lc3NhZ2UpO1xyXG5cclxuICAgICAgICAgICAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkOiBcImluaXRcIiwgdXJsOiBUb29scy5HZXRCYWJ5bG9uU2NyaXB0VVJMKHRoaXMuQ29uZmlndXJhdGlvbi51cmwpIH0pO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmIChBcnJheUJ1ZmZlci5pc1ZpZXcoZGF0YSkpIHtcclxuICAgICAgICAgICAgICAgICAgICAvLyBTbGljZSB0aGUgZGF0YSB0byBhdm9pZCBjb3B5aW5nIHRoZSB3aG9sZSBhcnJheSBidWZmZXIuXHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2xpY2VkRGF0YSA9IGRhdGEuc2xpY2UoKTtcclxuICAgICAgICAgICAgICAgICAgICB3b3JrZXI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bnN0IGtleSBpbiBJbnRlcmZhY2VzKSB7XHJcbiAgICAgICAgQkFCWUxPTi5HTFRGMi5Mb2FkZXJba2V5XSA9ICg8YW55PkludGVyZmFjZXMpW2tleV07XHJcbiAgICAgICAga2V5cy5wdXNoKGtleSk7XHJcbiAgICB9XHJcblxyXG4gICAgZm9yIChjb25zdCBrZXkgaW4gR0xURjIpIHtcclxuICAgICAgICAvLyBQcmV2ZW50IFJlYXNzaWdubWVudC5cclxuICAgICAgICBpZiAoa2V5cy5pbmRleE9mKGtleSkgPiAtMSkge1xyXG4gICAgICAgICAgICBjb250aW51ZTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIEJBQllMT04uR0xURjJba2V5XSA9ICg8YW55PkdMVEYyKVtrZXldO1xyXG4gICAgfVxyXG59XHJcblxyXG5leHBvcnQgeyBHTFRGMiB9O1xyXG4iLCIvLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgaW1wb3J0L2V4cG9ydFxyXG5leHBvcnQgKiBmcm9tIFwiLi9sZWdhY3ktZ2xURlwiO1xyXG5leHBvcnQgKiBmcm9tIFwiLi9sZWdhY3ktZ2xURjFcIjtcclxuZXhwb3J0ICogZnJvbSBcIi4vbGVnYWN5LWdsVEYyXCI7XHJcbiIsIm1vZHVsZS5leHBvcnRzID0gX19XRUJQQUNLX0VYVEVSTkFMX01PRFVMRV9iYWJ5bG9uanNfTWlzY19vYnNlcnZhYmxlX187IiwiLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKlxuQ29weXJpZ2h0IChjKSBNaWNyb3NvZnQgQ29ycG9yYXRpb24uXG5cblBlcm1pc3Npb24gdG8gdXNlLCBjb3B5LCBtb2RpZnksIGFuZC9vciBkaXN0cmlidXRlIHRoaXMgc29mdHdhcmUgZm9yIGFueVxucHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmF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ykgcmV0dXJuIGdsb2JhbFRoaXM7XG5cdHRyeSB7XG5cdFx0cmV0dXJuIHRoaXMgfHwgbmV3IEZ1bmN0aW9uKCdyZXR1cm4gdGhpcycpKCk7XG5cdH0gY2F0Y2ggKGUpIHtcblx0XHRpZiAodHlwZW9mIHdpbmRvdyA9PT0gJ29iamVjdCcpIHJldHVybiB3aW5kb3c7XG5cdH1cbn0pKCk7IiwiX193ZWJwYWNrX3JlcXVpcmVfXy5vID0gKG9iaiwgcHJvcCkgPT4gKE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChvYmosIHByb3ApKSIsIi8vIGRlZmluZSBfX2VzTW9kdWxlIG9uIGV4cG9ydHNcbl9fd2VicGFja19yZXF1aXJlX18uciA9IChleHBvcnRzKSA9PiB7XG5cdGlmKHR5cGVvZiBTeW1ib2wgIT09ICd1bmRlZmluZWQnICYmIFN5bWJvbC50b1N0cmluZ1RhZykge1xuXHRcdE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCBTeW1ib2wudG9TdHJpbmdUYWcsIHsgdmFsdWU6ICdNb2R1bGUnIH0pO1xuXHR9XG5cdE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAnX19lc01vZHVsZScsIHsgdmFsdWU6IHRydWUgfSk7XG59OyIsImltcG9ydCAqIGFzIGxvYWRlcnMgZnJvbSBcIkBsdHMvbG9hZGVycy9sZWdhY3kvbGVnYWN5LWdsVEZGaWxlTG9hZGVyXCI7XHJcbmV4cG9ydCB7IGxvYWRlcnMgfTtcclxuZXhwb3J0IGRlZmF1bHQgbG9hZGVycztcclxuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9 \ No newline at end of file diff --git a/libs/babylonjs/6.46.0/babylon.glTFFileLoader.min.js b/libs/babylonjs/6.46.0/babylon.glTFFileLoader.min.js new file mode 100644 index 00000000..7b0fec51 --- /dev/null +++ b/libs/babylonjs/6.46.0/babylon.glTFFileLoader.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-loaders",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-loaders"]=t(require("babylonjs")):e.LOADERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={597:t=>{t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{r.d(o,{default:()=>Yt});var e={};r.r(e),r.d(e,{GLTFValidation:()=>_});var t={};r.r(t),r.d(t,{GLTFFileLoader:()=>y,GLTFLoaderAnimationStartMode:()=>h,GLTFLoaderCoordinateSystemMode:()=>f,GLTFLoaderState:()=>p});var n={};r.r(n),r.d(n,{EBlendingFunction:()=>L,EComponentType:()=>T,ECullingType:()=>C,EParameterType:()=>E,EShaderType:()=>x,ETextureFilterType:()=>M,ETextureFormat:()=>w,ETextureWrapMode:()=>O,GLTFBinaryExtension:()=>ne,GLTFLoader:()=>ee,GLTFLoaderBase:()=>$,GLTFLoaderExtension:()=>te,GLTFMaterialsCommonExtension:()=>re,GLTFUtils:()=>S});var a={};r.r(a),r.d(a,{EXT_lights_image_based:()=>_e,EXT_mesh_gpu_instancing:()=>ye,EXT_meshopt_compression:()=>ge,EXT_texture_webp:()=>Ae,ExtrasAsMetadata:()=>Ht,KHR_animation_pointer:()=>Et,KHR_draco_mesh_compression:()=>xe,KHR_interactivity:()=>Gt,KHR_lights:()=>Oe,KHR_materials_anisotropy:()=>Fe,KHR_materials_clearcoat:()=>Re,KHR_materials_dispersion:()=>et,KHR_materials_emissive_strength:()=>De,KHR_materials_ior:()=>Ke,KHR_materials_iridescence:()=>Ie,KHR_materials_pbrSpecularGlossiness:()=>we,KHR_materials_sheen:()=>Ve,KHR_materials_specular:()=>Ue,KHR_materials_translucency:()=>Ze,KHR_materials_transmission:()=>Xe,KHR_materials_unlit:()=>Le,KHR_materials_variants:()=>qe,KHR_materials_volume:()=>Je,KHR_mesh_quantization:()=>nt,KHR_texture_basisu:()=>ot,KHR_texture_transform:()=>it,KHR_xmp_json_ld:()=>lt,MSFT_audio_emitter:()=>Mt,MSFT_lod:()=>Ct,MSFT_minecraftMesh:()=>Nt,MSFT_sRGBFactors:()=>St});var i={};r.r(i);var s={};r.r(s),r.d(s,{ArrayItem:()=>fe,EXT_lights_image_based:()=>_e,EXT_mesh_gpu_instancing:()=>ye,EXT_meshopt_compression:()=>ge,EXT_texture_webp:()=>Ae,ExtrasAsMetadata:()=>Ht,GLTFLoader:()=>he,KHR_animation_pointer:()=>Et,KHR_draco_mesh_compression:()=>xe,KHR_interactivity:()=>Gt,KHR_lights:()=>Oe,KHR_materials_anisotropy:()=>Fe,KHR_materials_clearcoat:()=>Re,KHR_materials_dispersion:()=>et,KHR_materials_emissive_strength:()=>De,KHR_materials_ior:()=>Ke,KHR_materials_iridescence:()=>Ie,KHR_materials_pbrSpecularGlossiness:()=>we,KHR_materials_sheen:()=>Ve,KHR_materials_specular:()=>Ue,KHR_materials_translucency:()=>Ze,KHR_materials_transmission:()=>Xe,KHR_materials_unlit:()=>Le,KHR_materials_variants:()=>qe,KHR_materials_volume:()=>Je,KHR_mesh_quantization:()=>nt,KHR_texture_basisu:()=>ot,KHR_texture_transform:()=>it,KHR_xmp_json_ld:()=>lt,MSFT_audio_emitter:()=>Mt,MSFT_lod:()=>Ct,MSFT_minecraftMesh:()=>Nt,MSFT_sRGBFactors:()=>St});var l={};r.r(l),r.d(l,{GLTF1:()=>n,GLTF2:()=>s,GLTFFileLoader:()=>y,GLTFLoaderAnimationStartMode:()=>h,GLTFLoaderCoordinateSystemMode:()=>f,GLTFLoaderState:()=>p,GLTFValidation:()=>_});var c=r(597);function u(e,t,n,r){var o={externalResourceFunction:r};return n&&(o.uri="file:"===t?n:t+n),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,o):GLTFValidator.validateString(e,o)}function d(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":u(n.data,n.rootUrl,n.fileName,(function(t){return new Promise((function(n,r){var o=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:o,uri:t})}))})).then((function(e){postMessage({id:"validate.resolve",value:e})}),(function(e){postMessage({id:"validate.reject",reason:e})}));break;case"getExternalResource.resolve":e[n.index].resolve(n.value);break;case"getExternalResource.reject":e[n.index].reject(n.reason)}}}var f,h,p,_=function(){function e(){}return e.ValidateAsync=function(e,t,n,r){var o=this;return"function"==typeof Worker?new Promise((function(a,i){var s="".concat(u,"(").concat(d,")()"),l=URL.createObjectURL(new Blob([s],{type:"application/javascript"})),f=new Worker(l),h=function(e){f.removeEventListener("error",h),f.removeEventListener("message",p),i(e)},p=function(e){var t=e.data;switch(t.id){case"getExternalResource":r(t.uri).then((function(e){f.postMessage({id:"getExternalResource.resolve",index:t.index,value:e},[e])}),(function(e){f.postMessage({id:"getExternalResource.reject",index:t.index,reason:e})}));break;case"validate.resolve":f.removeEventListener("error",h),f.removeEventListener("message",p),a(t.value),f.terminate();break;case"validate.reject":f.removeEventListener("error",h),f.removeEventListener("message",p),i(t.reason),f.terminate()}};if(f.addEventListener("error",h),f.addEventListener("message",p),f.postMessage({id:"init",url:c.Tools.GetBabylonScriptURL(o.Configuration.url)}),ArrayBuffer.isView(e)){var _=e.slice();f.postMessage({id:"validate",data:_,rootUrl:t,fileName:n},[_.buffer])}else f.postMessage({id:"validate",data:e,rootUrl:t,fileName:n})})):(this._LoadScriptPromise||(this._LoadScriptPromise=c.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then((function(){return u(e,t,n,r)})))},e.Configuration={url:"".concat(c.Tools._DefaultCdnUrl,"/gltf_validator.js")},e}();function m(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(f||(f={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(h||(h={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(p||(p={}));var y=function(){function e(){this.onParsedObservable=new c.Observable,this.coordinateSystemMode=f.AUTO,this.animationStartMode=h.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this.useRangeRequests=!1,this.createInstances=!0,this.alwaysComputeBoundingBox=!1,this.loadAllMaterials=!1,this.loadOnlyMaterials=!1,this.skipMaterials=!1,this.useSRGBBuffers=!0,this.targetFps=60,this.alwaysComputeSkeletonRootNode=!1,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new c.Observable,this.onSkinLoadedObservable=new c.Observable,this.onTextureLoadedObservable=new c.Observable,this.onMaterialLoadedObservable=new c.Observable,this.onCameraLoadedObservable=new c.Observable,this.onCompleteObservable=new c.Observable,this.onErrorObservable=new c.Observable,this.onDisposeObservable=new c.Observable,this.onExtensionLoadedObservable=new c.Observable,this.validate=!1,this.onValidatedObservable=new c.Observable,this._loader=null,this._state=null,this._requests=new Array,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}},this.onLoaderStateChangedObservable=new c.Observable,this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled}return Object.defineProperty(e.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loggingEnabled",{get:function(){return this._loggingEnabled},set:function(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"capturePerformanceCounters",{get:function(){return this._capturePerformanceCounters},set:function(e){this._capturePerformanceCounters!==e&&(this._capturePerformanceCounters=e,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,t=this._requests;e=e.byteLength)throw new RangeError("Offset is out of range.");if(t+n>e.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,n))}catch(e){return Promise.reject(e)}}(t,e,n)},byteLength:t.byteLength})).then((function(e){r(e)}),o?function(e){return o(void 0,e)}:void 0)},e.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return Promise.resolve().then((function(){return i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n),i._loader.importMeshAsync(e,t,null,n,r,o,a)}))},e.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){return a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t),a._loader.loadAsync(e,t,n,r,o)}))},e.prototype.loadAssetContainerAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t);var i=new c.AssetContainer(e),s=[];a.onMaterialLoadedObservable.add((function(e){s.push(e)}));var l=[];a.onTextureLoadedObservable.add((function(e){l.push(e)}));var u=[];a.onCameraLoadedObservable.add((function(e){u.push(e)}));var d=[];return a.onMeshLoadedObservable.add((function(e){e.morphTargetManager&&d.push(e.morphTargetManager)})),a._loader.importMeshAsync(null,e,i,t,n,r,o).then((function(e){return Array.prototype.push.apply(i.geometries,e.geometries),Array.prototype.push.apply(i.meshes,e.meshes),Array.prototype.push.apply(i.particleSystems,e.particleSystems),Array.prototype.push.apply(i.skeletons,e.skeletons),Array.prototype.push.apply(i.animationGroups,e.animationGroups),Array.prototype.push.apply(i.materials,s),Array.prototype.push.apply(i.textures,l),Array.prototype.push.apply(i.lights,e.lights),Array.prototype.push.apply(i.transformNodes,e.transformNodes),Array.prototype.push.apply(i.cameras,u),Array.prototype.push.apply(i.morphTargetManagers,d),i}))}))},e.prototype.canDirectLoad=function(t){return-1!==t.indexOf("asset")&&-1!==t.indexOf("version")||t.startsWith("data:base64,"+e._MagicBase64Encoded)||t.startsWith("data:;base64,"+e._MagicBase64Encoded)||t.startsWith("data:application/octet-stream;base64,"+e._MagicBase64Encoded)||t.startsWith("data:model/gltf-binary;base64,"+e._MagicBase64Encoded)},e.prototype.directLoad=function(t,n){if(n.startsWith("base64,"+e._MagicBase64Encoded)||n.startsWith(";base64,"+e._MagicBase64Encoded)||n.startsWith("application/octet-stream;base64,"+e._MagicBase64Encoded)||n.startsWith("model/gltf-binary;base64,"+e._MagicBase64Encoded)){var r=(0,c.DecodeBase64UrlToBinary)(n);return this._validate(t,new Uint8Array(r,0,r.byteLength)),this._unpackBinaryAsync(new c.DataReader({readAsync:function(e,t){return m(r,e,t)},byteLength:r.byteLength}))}return this._validate(t,n),Promise.resolve({json:this._parseJson(n)})},e.prototype.createPlugin=function(){return new e},Object.defineProperty(e.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),e.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,n){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){n(e)}))}))},e.prototype._setState=function(e){this._state!==e&&(this._state=e,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(p[this._state]))},e.prototype._loadFile=function(e,t,n,r,o,a){var i=this,s=e._loadFile(t,n,(function(e){i._onProgress(e,s)}),!0,r,o,a);return s.onCompleteObservable.add((function(e){i._requests.splice(i._requests.indexOf(e),1)})),this._requests.push(s),s},e.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a0)throw new Error("Incompatible minimum version: "+n.minVersion)}var a={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[r.major];if(!a)throw new Error("Unsupported version: "+n.version);return a(this)},e.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: ".concat(e.length));var t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t},e.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var n=e.readUint32();if(1179937895!==n)throw new c.RuntimeError("Unexpected magic: "+n,c.ErrorCodes.GLTFLoaderUnexpectedMagicError);var r=e.readUint32();t.loggingEnabled&&t._log("Binary version: ".concat(r));var o,a=e.readUint32();switch(t.useRangeRequests||a===e.buffer.byteLength||c.Logger.Warn("Length in header does not match actual data length: ".concat(a," != ").concat(e.buffer.byteLength)),r){case 1:o=t._unpackBinaryV1Async(e,a);break;case 2:o=t._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+r)}return t._endPerformanceCounter("Unpack Binary"),o}))},e.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: ".concat(r));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},e.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then((function(){return{json:n._parseJson(e.readString(o)),bin:null}})):e.loadAsync(o+8).then((function(){var a={json:n._parseJson(e.readString(o)),bin:null},i=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(i):Promise.resolve(a)};return i()}))},e._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null},e._compareVersion=function(e,t){return e.major>t.major?1:e.majort.minor?1:e.minora.byteLength)throw new Error("Buffer access is out of range");var i=a.buffer;switch(n+=a.byteOffset,o){case T.BYTE:return new Int8Array(i,n,r);case T.UNSIGNED_BYTE:return new Uint8Array(i,n,r);case T.SHORT:return new Int16Array(i,n,r);case T.UNSIGNED_SHORT:return new Uint16Array(i,n,r);default:return new Float32Array(i,n,r)}},e.GetBufferFromAccessor=function(t,n){var r=t.bufferViews[n.bufferView],o=n.count*e.GetByteStrideFromType(n);return e.GetBufferFromBufferView(t,r,n.byteOffset,o,n.componentType)},e.DecodeBufferToText=function(e){for(var t="",n=e.byteLength,r=0;r=this._maxPos},e}(),P=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],F=["world","view","projection","worldView","worldViewProjection","mBones"],B=["translation","rotation","scale"],D=["position","rotationQuaternion","scaling"],k=function(e,t,n){for(var r in e){var o=e[r];n[t][r]=o}},V=function(e){if(e)for(var t=0;t1?(a=new c.MultiMaterial("multimat"+r,e.scene)).subMaterials=i:a=new c.StandardMaterial("multimat"+r,e.scene),1===i.length&&(a=i[0]),a._parentContainer=e.assetContainer,o.material||(o.material=a),new c.Geometry(r,e.scene,s,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];var L=0;for(h=0;h0&&-1===e.importMeshesNames.indexOf(t.name||""))return null;if(t.skin){if(t.meshes){var o=e.skins[t.skin];(a=W(e,t,t.meshes,n,t.babylonNode)).skeleton=e.scene.getLastSkeletonById(t.skin),null===a.skeleton&&(a.skeleton=function(e,t,n,r){if(r||(r=new c.Skeleton(t.name||"","",e.scene)),!t.babylonSkeleton)return r;var o=[],a=[];!function(e,t,n,r){for(var o in e.nodes){var a=e.nodes[o],i=o;if(a.jointName&&!q(n,a.jointName)){var s=U(a),l=new c.Bone(a.name||"",t,null,s);l.id=i,r.push({bone:l,node:a,id:i})}}for(var u=0;u0&&(f=K(o,l))&&-1===a.indexOf(f)&&a.push(f),new c.Bone(s.jointName||"",r,f,v).id=l}}else c.Tools.Warn("Joint named "+t.jointNames[i]+" does not exist")}var g=r.bones;for(r.bones=[],i=0;i ").concat(p[p.READY]),i="".concat(p[p.LOADING]," => ").concat(p[p.COMPLETE]);o._parent._startPerformanceCounter(a),o._parent._startPerformanceCounter(i),o._parent._setState(p.LOADING),o._extensionsOnLoading();var s=new Array,l=o._babylonScene.blockMaterialDirtyMechanism;if(o._babylonScene.blockMaterialDirtyMechanism=!0,!o.parent.loadOnlyMaterials)if(n)s.push(o.loadSceneAsync("/nodes",{nodes:n,index:-1}));else if(null!=o._gltf.scene||o._gltf.scenes&&o._gltf.scenes[0]){var u=fe.Get("/scene",o._gltf.scenes,o._gltf.scene||0);s.push(o.loadSceneAsync("/scenes/".concat(u.index),u))}if(!o.parent.skipMaterials&&o.parent.loadAllMaterials&&o._gltf.materials)for(var d=0;de.bin.byteLength)&&c.Logger.Warn("Binary buffer length (".concat(n.byteLength,") from JSON does not match chunk length (").concat(e.bin.byteLength,")")),this._bin=e.bin}else c.Logger.Warn("Unexpected BIN chunk")}},e.prototype._setupData=function(){if(fe.Assign(this._gltf.accessors),fe.Assign(this._gltf.animations),fe.Assign(this._gltf.buffers),fe.Assign(this._gltf.bufferViews),fe.Assign(this._gltf.cameras),fe.Assign(this._gltf.images),fe.Assign(this._gltf.materials),fe.Assign(this._gltf.meshes),fe.Assign(this._gltf.nodes),fe.Assign(this._gltf.samplers),fe.Assign(this._gltf.scenes),fe.Assign(this._gltf.skins),fe.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t=(i=n[t[0]]).length)return l;s=i[c];for(var u=1;u=(i=n[t[u]]).length||s!==i[c])return l;l=s}},e.prototype._loadBone=function(e,t,n,r){var o=r[e.index];if(o)return o;var a=null;e.index!==t.skeleton&&(e.parent&&-1!==e.parent.index?a=this._loadBone(e.parent,t,n,r):void 0!==t.skeleton&&c.Logger.Warn("/skins/".concat(t.index,"/skeleton: Skeleton node is not a common root")));var i=t.joints.indexOf(e.index);return o=new c.Bone(e.name||"joint".concat(e.index),n,a,this._getNodeMatrix(e),null,null,i),r[e.index]=o,this._postSceneLoadActions.push((function(){o.linkTransformNode(e._babylonTransformNode)})),o},e.prototype._loadSkinInverseBindMatricesDataAsync=function(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);var n=fe.Get("".concat(e,"/inverseBindMatrices"),this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync("/accessors/".concat(n.index),n)},e.prototype._updateBoneMatrices=function(e,t){for(var n=0,r=e.bones;n0){var T="".concat(n.name||"animation".concat(n.index),"_channel").concat(r.index,"_").concat(t);f.buildAnimations(l,T,i,m,(function(e,n){++t,a(e,n)}))}}}))},e.prototype._loadAnimationSamplerAsync=function(e,t){if(t._data)return t._data;var n=t.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error("".concat(e,"/interpolation: Invalid value (").concat(t.interpolation,")"))}var r=fe.Get("".concat(e,"/input"),this._gltf.accessors,t.input),o=fe.Get("".concat(e,"/output"),this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync("/accessors/".concat(r.index),r),this._loadFloatAccessorAsync("/accessors/".concat(o.index),o)]).then((function(e){var t=e[0],r=e[1];return{input:t,interpolation:n,output:r}})),t._data},e.prototype.loadBufferAsync=function(e,t,n,r){var o=this._extensionsLoadBufferAsync(e,t,n,r);if(o)return o;if(!t._data)if(t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{if(!this._bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then((function(t){try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw new Error("".concat(e,": ").concat(t.message))}}))},e.prototype.loadBufferViewAsync=function(e,t){var n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;var r=fe.Get("".concat(e,"/buffer"),this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync("/buffers/".concat(r.index),r,t.byteOffset||0,t.byteLength),t._data},e.prototype._loadAccessorAsync=function(t,n,r){var o=this;if(n._data)return n._data;var a=e._GetNumComponents(t,n.type),i=a*c.VertexBuffer.GetTypeByteLength(n.componentType),s=a*n.count;if(null==n.bufferView)n._data=Promise.resolve(new r(s));else{var l=fe.Get("".concat(t,"/bufferView"),this._gltf.bufferViews,n.bufferView);n._data=this.loadBufferViewAsync("/bufferViews/".concat(l.index),l).then((function(o){if(5126!==n.componentType||n.normalized||l.byteStride&&l.byteStride!==i){var u=new r(s);return c.VertexBuffer.ForEach(o,n.byteOffset||0,l.byteStride||i,a,n.componentType,u.length,n.normalized||!1,(function(e,t){u[t]=e})),u}return e._GetTypedArray(t,n.componentType,o,n.byteOffset,s)}))}if(n.sparse){var u=n.sparse;n._data=n._data.then((function(s){var l=s,d=fe.Get("".concat(t,"/sparse/indices/bufferView"),o._gltf.bufferViews,u.indices.bufferView),f=fe.Get("".concat(t,"/sparse/values/bufferView"),o._gltf.bufferViews,u.values.bufferView);return Promise.all([o.loadBufferViewAsync("/bufferViews/".concat(d.index),d),o.loadBufferViewAsync("/bufferViews/".concat(f.index),f)]).then((function(o){var s,d=o[0],f=o[1],h=e._GetTypedArray("".concat(t,"/sparse/indices"),u.indices.componentType,d,u.indices.byteOffset,u.count),p=a*u.count;if(5126!==n.componentType||n.normalized){var _=e._GetTypedArray("".concat(t,"/sparse/values"),n.componentType,f,u.values.byteOffset,p);s=new r(p),c.VertexBuffer.ForEach(_,0,i,a,n.componentType,s.length,n.normalized||!1,(function(e,t){s[t]=e}))}else s=e._GetTypedArray("".concat(t,"/sparse/values"),n.componentType,f,u.values.byteOffset,p);for(var m=0,y=0;y=6)throw new Error("".concat(t,"/texCoord: Invalid value (").concat(n.texCoord,")"));var i=fe.Get("".concat(t,"/index"),this._gltf.textures,n.index);i._textureInfo=n;var s=this._loadTextureAsync("/textures/".concat(n.index),i,(function(a){a.coordinatesIndex=n.texCoord||0,e.AddPointerMetadata(a,t),o._parent.onTextureLoadedObservable.notifyObservers(a),r(a)}));return this.logClose(),s},e.prototype._loadTextureAsync=function(t,n,r){void 0===r&&(r=function(){});var o=this._extensionsLoadTextureAsync(t,n,r);if(o)return o;this.logOpen("".concat(t," ").concat(n.name||""));var a=null==n.sampler?e.DefaultSampler:fe.Get("".concat(t,"/sampler"),this._gltf.samplers,n.sampler),i=fe.Get("".concat(t,"/source"),this._gltf.images,n.source),s=this._createTextureAsync(t,a,i,r,void 0,!n._textureInfo.nonColorData);return this.logClose(),s},e.prototype._createTextureAsync=function(e,t,n,r,o,a){var i=this;void 0===r&&(r=function(){});var s=this._loadSampler("/samplers/".concat(t.index),t),l=new Array,u=new c.Deferred;this._babylonScene._blockEntityCollection=!!this._assetContainer;var d={noMipmap:s.noMipMaps,invertY:!1,samplingMode:s.samplingMode,onLoad:function(){i._disposed||u.resolve()},onError:function(t,n){i._disposed||u.reject(new Error("".concat(e,": ").concat(n&&n.message?n.message:t||"Failed to load texture")))},mimeType:n.mimeType,loaderOptions:o,useSRGBBuffer:!!a&&this._parent.useSRGBBuffers},f=new c.Texture(null,this._babylonScene,d);return f._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,l.push(u.promise),l.push(this.loadImageAsync("/images/".concat(n.index),n).then((function(e){var t=n.uri||"".concat(i._fileName,"#image").concat(n.index),r="data:".concat(i._uniqueRootUrl).concat(t);f.updateURL(r,e)}))),f.wrapU=s.wrapU,f.wrapV=s.wrapV,r(f),Promise.all(l).then((function(){return f}))},e.prototype._loadSampler=function(t,n){return n._data||(n._data={noMipMaps:9728===n.minFilter||9729===n.minFilter,samplingMode:e._GetTextureSamplingMode(t,n),wrapU:e._GetTextureWrapMode("".concat(t,"/wrapS"),n.wrapS),wrapV:e._GetTextureWrapMode("".concat(t,"/wrapT"),n.wrapT)}),n._data},e.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen("".concat(e," ").concat(t.name||"")),t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{var n=fe.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(n.index),n)}this.logClose()}return t._data},e.prototype.loadUriAsync=function(t,n,r){var o=this,a=this._extensionsLoadUriAsync(t,n,r);if(a)return a;if(!e._ValidateUri(r))throw new Error("".concat(t,": '").concat(r,"' is invalid"));if((0,c.IsBase64DataUrl)(r)){var i=new Uint8Array((0,c.DecodeBase64UrlToBinary)(r));return this.log("".concat(t,": Decoded ").concat(r.substr(0,64),"... (").concat(i.length," bytes)")),Promise.resolve(i)}return this.log("".concat(t,": Loading ").concat(r)),this._parent.preprocessUrlAsync(this._rootUrl+r).then((function(e){return new Promise((function(n,a){o._parent._loadFile(o._babylonScene,e,(function(e){o._disposed||(o.log("".concat(t,": Loaded ").concat(r," (").concat(e.byteLength," bytes)")),n(new Uint8Array(e)))}),!0,(function(e){a(new c.LoadFileError("".concat(t,": Failed to load '").concat(r,"'").concat(e?": "+e.status+" "+e.statusText:""),e))}))}))}))},e.AddPointerMetadata=function(e,t){e.metadata=e.metadata||{};var n=e._internalMetadata=e._internalMetadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)},e._GetTextureWrapMode=function(e,t){switch(t=null==t?10497:t){case 33071:return c.Texture.CLAMP_ADDRESSMODE;case 33648:return c.Texture.MIRROR_ADDRESSMODE;case 10497:return c.Texture.WRAP_ADDRESSMODE;default:return c.Logger.Warn("".concat(e,": Invalid value (").concat(t,")")),c.Texture.WRAP_ADDRESSMODE}},e._GetTextureSamplingMode=function(e,t){var n=null==t.magFilter?9729:t.magFilter,r=null==t.minFilter?9987:t.minFilter;if(9729===n)switch(r){case 9728:return c.Texture.LINEAR_NEAREST;case 9729:return c.Texture.LINEAR_LINEAR;case 9984:return c.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return c.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return c.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return c.Texture.LINEAR_LINEAR_MIPLINEAR;default:return c.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(r,")")),c.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==n&&c.Logger.Warn("".concat(e,"/magFilter: Invalid value (").concat(n,")")),r){case 9728:return c.Texture.NEAREST_NEAREST;case 9729:return c.Texture.NEAREST_LINEAR;case 9984:return c.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return c.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return c.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return c.Texture.NEAREST_LINEAR_MIPLINEAR;default:return c.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(r,")")),c.Texture.NEAREST_NEAREST_MIPNEAREST}},e._GetTypedArrayConstructor=function(e,t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error("".concat(e,": Invalid component type ").concat(t))}},e._GetTypedArray=function(t,n,r,o,a){var i=r.buffer;o=r.byteOffset+(o||0);var s=e._GetTypedArrayConstructor("".concat(t,"/componentType"),n),l=c.VertexBuffer.GetTypeByteLength(n);return o%l!=0?(c.Logger.Warn("".concat(t,": Copying buffer as byte offset (").concat(o,") is not a multiple of component type byte length (").concat(l,")")),new s(i.slice(o,o+a*l),0)):new s(i,o,a)},e._GetNumComponents=function(e,t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error("".concat(e,": Invalid type (").concat(t,")"))},e._ValidateUri=function(e){return c.Tools.IsBase64(e)||-1===e.indexOf("..")},e._GetDrawMode=function(e,t){switch(null==t&&(t=4),t){case 0:return c.Material.PointListDrawMode;case 1:return c.Material.LineListDrawMode;case 2:return c.Material.LineLoopDrawMode;case 3:return c.Material.LineStripDrawMode;case 4:return c.Material.TriangleFillMode;case 5:return c.Material.TriangleStripDrawMode;case 6:return c.Material.TriangleFanDrawMode}throw new Error("".concat(e,": Invalid mesh primitive mode (").concat(t,")"))},e.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile materials");var t=new Array;if(this._gltf.materials)for(var n=0,r=this._gltf.materials;n=0;a--)if(o.push(fe.Get("".concat(e,"/ids/").concat(r[a]),n,r[a])),o.length===this.maxLODsToLoad)return o;return o.push(t),o},e.prototype._disposeTransformNode=function(e){var t=this,n=[],r=e.material;r&&n.push(r);for(var o=0,a=e.getChildMeshes();o0){var n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}},e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return this._loader.loadNodeAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.loadCameraAsync=function(e,t,n){var r=this;return this._loader.loadCameraAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.createMaterial=function(e,t,n){var r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r},e}();he.RegisterExtension(Ut,(function(e){return new Ht(e)}));var Kt=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==Kt){Kt.BABYLON=Kt.BABYLON||{};var jt=Kt.BABYLON;jt.GLTF2=jt.GLTF2||{},jt.GLTF2.Loader=jt.GLTF2.Loader||{},jt.GLTF2.Loader.Extensions=jt.GLTF2.Loader.Extensions||{};var qt=[];for(var Wt in a)jt.GLTF2.Loader.Extensions[Wt]=a[Wt],qt.push(Wt);for(var Wt in i)jt.GLTF2.Loader[Wt]=i[Wt],qt.push(Wt);for(var Wt in s)qt.indexOf(Wt)>-1||(jt.GLTF2[Wt]=s[Wt])}const Yt=l})(),o.default})())); +//# sourceMappingURL=babylon.glTFFileLoader.min.js.map \ No newline at end of file diff --git a/libs/babylonjs/6.46.0/babylon.inspector.bundle.js b/libs/babylonjs/6.46.0/babylon.inspector.bundle.js new file mode 100644 index 00000000..6f08d418 --- /dev/null +++ b/libs/babylonjs/6.46.0/babylon.inspector.bundle.js @@ -0,0 +1,3 @@ +/*! For license information please see babylon.inspector.bundle.js.LICENSE.txt */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs"),require("babylonjs-materials"),require("babylonjs"),require("babylonjs-gui"),require("babylonjs-gui-editor"),require("babylonjs-loaders"),require("babylonjs-serializers")):"function"==typeof define&&define.amd?define("babylonjs-inspector",["babylonjs","babylonjs-materials","babylonjs","babylonjs-gui","babylonjs-gui-editor","babylonjs-loaders","babylonjs-serializers"],t):"object"==typeof exports?exports["babylonjs-inspector"]=t(require("babylonjs"),require("babylonjs-materials"),require("babylonjs"),require("babylonjs-gui"),require("babylonjs-gui-editor"),require("babylonjs-loaders"),require("babylonjs-serializers")):e.INSPECTOR=t(e.BABYLON,e.BABYLON,e.BABYLON.Debug,e.BABYLON.GUI,e.BABYLON,e.BABYLON,e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,((e,t,r,n,o,s,a)=>(()=>{var i={729:(e,t,r)=>{"use strict";r.d(t,{A:()=>h});var n=r(3234),o=r.n(n),s=r(7474),a=r.n(s),i=r(1721),l=r.n(i),p=new URL(r(4149),r.b),c=a()(o()),d=l()(p);c.push([e.id,`#inspector-host{position:absolute;right:0px;top:0px;bottom:0px}#__resizable_base__{display:none}#actionTabs{background:#333;height:100%;margin:0;padding:0;display:grid;grid-template-rows:auto 1fr;font:14px "Arial";overflow:hidden}#actionTabs .hoverIcon:hover{opacity:.8}#actionTabs #header{height:30px;font-size:16px;color:#fff;background:#222;grid-row:1;text-align:center;display:grid;grid-template-columns:30px 1fr 50px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#actionTabs #header #logo{grid-column:1;width:24px;height:24px;display:flex;align-self:center;justify-self:center}#actionTabs #header #back{grid-column:1;display:grid;align-self:center;justify-self:center;cursor:pointer}#actionTabs #header #title{grid-column:2;display:grid;align-items:center;text-align:center}#actionTabs #header #commands{grid-column:3;display:grid;align-items:center;grid-template-columns:1fr 1fr}#actionTabs #header #commands .expand{grid-column:1;display:grid;align-items:center;justify-items:center;cursor:pointer}#actionTabs #header #commands .close{grid-column:2;display:grid;align-items:center;justify-items:center;cursor:pointer}#actionTabs .tabsMenu{display:grid;grid-row:2;grid-template-rows:40px 1fr;font:14px "Arial";overflow:hidden}#actionTabs .tabsMenu .labels{grid-row:1;display:flex;align-items:center;justify-items:center;border-bottom:1px solid #fff;margin:0;padding:0}#actionTabs .tabsMenu .labels .label{font-size:24px;color:#fff;width:40px;display:flex;align-content:center;justify-content:center;border:1px solid rgba(0,0,0,0);border-bottom:none;background:#333;padding:5px;height:28px;cursor:pointer}#actionTabs .tabsMenu .labels .label.active{border-color:#fff;border-bottom:2px solid rgba(0,0,0,0);margin-bottom:-2px}#actionTabs .tabsMenu .panes{grid-row:2;display:grid;grid-template-rows:100%;overflow:hidden}#actionTabs .tabsMenu .panes .infoMessage{opacity:.5;color:#fff;margin:15px 5px 0px 5px}#actionTabs .tabsMenu .panes .gradient-step{display:grid;grid-template-rows:100%;grid-template-columns:20px 30px 40px auto 20px 30px;padding-top:5px;padding-left:5px;padding-bottom:5px;align-items:center}#actionTabs .tabsMenu .panes .gradient-step .step{grid-row:1;grid-column:1}#actionTabs .tabsMenu .panes .gradient-step .color1{height:100%}#actionTabs .tabsMenu .panes .gradient-step .color2{height:100%;padding-left:5px}#actionTabs .tabsMenu .panes .gradient-step .factor1{grid-row:1;grid-column:2;cursor:pointer}#actionTabs .tabsMenu .panes .gradient-step .factor2{padding-left:5px;grid-row:1;grid-column:3;cursor:pointer}#actionTabs .tabsMenu .panes .gradient-step .factor2 .grayed{background:gray;border-color:gray}#actionTabs .tabsMenu .panes .gradient-step .numeric-input{width:calc(100% - 5px)}#actionTabs .tabsMenu .panes .gradient-step .icon{cursor:pointer}#actionTabs .tabsMenu .panes .gradient-step .step-value{margin-left:5px;grid-row:1;grid-column:3;text-align:right;margin-right:5px}#actionTabs .tabsMenu .panes .gradient-step .step-slider{grid-row:1;grid-column:4;display:grid;justify-content:stretch;align-content:center;margin-right:12px}#actionTabs .tabsMenu .panes .gradient-step .step-slider input{width:100%}#actionTabs .tabsMenu .panes .gradient-step .step-slider .range:hover{opacity:1}#actionTabs .tabsMenu .panes .gradient-step .step-slider .range{-webkit-appearance:none;height:6px;background:#d3d3d3;border-radius:5px;outline:none;opacity:.7;-webkit-transition:.2s;transition:opacity .2s}#actionTabs .tabsMenu .panes .gradient-step .step-slider .range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:#337ab7;cursor:pointer}#actionTabs .tabsMenu .panes .gradient-step .step-slider .range::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:#337ab7;cursor:pointer}#actionTabs .tabsMenu .panes .gradient-step .gradient-copy{grid-row:1;grid-column:5;display:grid;align-content:center;justify-content:center}#actionTabs .tabsMenu .panes .gradient-step .gradient-copy .img{height:20px;width:20px}#actionTabs .tabsMenu .panes .gradient-step .gradient-copy .img:hover{cursor:pointer}#actionTabs .tabsMenu .panes .gradient-step .gradient-delete{grid-row:1;grid-column:6;display:grid;align-content:center;justify-content:center}#actionTabs .tabsMenu .panes .gradient-step .gradient-delete .img{height:20px;width:20px}#actionTabs .tabsMenu .panes .gradient-step .gradient-delete .img:hover{cursor:pointer}#actionTabs .tabsMenu .panes .pane{color:#fff;overflow-x:hidden;overflow-y:auto;height:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#actionTabs .tabsMenu .panes .pane .animation-info{border-left:#adff2f 3px solid;margin-left:5px;padding-left:5px !important}#actionTabs .tabsMenu .panes .pane .underline{border-bottom:.5px solid rgba(255,255,255,.5)}#actionTabs .tabsMenu .panes .pane .textureLinkLine{display:grid;grid-template-columns:auto 1fr}#actionTabs .tabsMenu .panes .pane .textureLinkLine .debug{grid-column:1;margin-left:5px;margin-right:5px;display:block;align-items:center;justify-items:center;cursor:pointer;opacity:.5}#actionTabs .tabsMenu .panes .pane .textureLinkLine .debug.selected{opacity:1}#actionTabs .tabsMenu .panes .pane .textureLinkLine .textLine{grid-column:2}#actionTabs .tabsMenu .panes .pane .textureLinkLine .actionIcon{display:inline-block;margin-top:6px;margin-right:4px}#actionTabs .tabsMenu .panes .pane .messageLine{text-align:center;font-size:12px;font-style:italic;opacity:.6}#actionTabs .tabsMenu .panes .pane .iconMessageLine{padding-left:2px;height:30px;display:grid;grid-template-columns:30px 1fr}#actionTabs .tabsMenu .panes .pane .iconMessageLine .icon{grid-column:1;display:grid;align-items:center;justify-items:center}#actionTabs .tabsMenu .panes .pane .iconMessageLine .value{grid-column:2;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .color-picker{height:calc(100% - 8px);margin:4px;width:100%}#actionTabs .tabsMenu .panes .pane .color-picker .color-rect{height:calc(100% - 4px);border:2px #fff solid;cursor:pointer;min-height:18px}#actionTabs .tabsMenu .panes .pane .color-picker .color-picker-cover{position:fixed;top:0px;right:0px;bottom:0px;left:0px;z-index:100}#actionTabs .tabsMenu .panes .pane .color-picker .color-picker-float{position:absolute}#actionTabs .tabsMenu .panes .pane .linkButtonLine{padding-left:2px;height:30px;display:grid;grid-template-columns:1fr auto 20px}#actionTabs .tabsMenu .panes .pane .linkButtonLine .link{grid-column:1;display:flex;align-items:center;text-decoration:underline;cursor:pointer}#actionTabs .tabsMenu .panes .pane .linkButtonLine .link-button{grid-column:2}#actionTabs .tabsMenu .panes .pane .linkButtonLine .link-button button{background:#222;border:1px solid #337ab7;margin:5px 10px 5px 10px;color:#fff;padding:4px 5px;opacity:.9;cursor:pointer}#actionTabs .tabsMenu .panes .pane .linkButtonLine .link-button button:hover{opacity:1}#actionTabs .tabsMenu .panes .pane .linkButtonLine .link-button button:active{background:#282828}#actionTabs .tabsMenu .panes .pane .linkButtonLine .link-button button:focus{border:1px solid #337ab7;outline:0px}#actionTabs .tabsMenu .panes .pane .linkButtonLine .link-icon{grid-column:3;display:grid;align-content:center}#actionTabs .tabsMenu .panes .pane .textLine{padding-left:2px;height:30px;display:grid;grid-template-columns:1fr auto}#actionTabs .tabsMenu .panes .pane .textLine.indented{grid-template-columns:100%}#actionTabs .tabsMenu .panes .pane .textLine.indented .link-value{grid-column:1;text-align:start;margin-left:20px;opacity:.6;max-width:unset}#actionTabs .tabsMenu .panes .pane .textLine.indented .value{grid-column:1;text-align:start;margin-left:20px;opacity:.6;max-width:unset}#actionTabs .tabsMenu .panes .pane .textLine.reduced-opacity{opacity:.6;padding-left:25px}#actionTabs .tabsMenu .panes .pane .textLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .textLine .link-value{grid-column:2;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-align:end;opacity:.8;margin:5px;margin-top:7px;max-width:140px;text-decoration:underline;cursor:pointer}#actionTabs .tabsMenu .panes .pane .textLine .value{grid-column:2;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-align:end;opacity:.8;margin:5px;margin-top:7px;max-width:200px;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text}#actionTabs .tabsMenu .panes .pane .textLine .value.check{color:green}#actionTabs .tabsMenu .panes .pane .textLine .value.uncheck{color:red}#actionTabs .tabsMenu .panes .pane .gradient-container{margin-top:3px}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-label{height:30px;display:grid;align-content:center}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step{display:grid;grid-template-rows:100%;grid-template-columns:25px 50px 55px 40px auto 20px 5px;padding-top:5px;padding-left:5px;padding-bottom:5px;align-items:center;border-left:orange 3px solid}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .step{grid-row:1;grid-column:1}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .color1{height:100%}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .color2{height:100%;padding-left:5px}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .factor1{grid-row:1;grid-column:2;cursor:pointer}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .factor2{padding-left:5px;grid-row:1;grid-column:3;cursor:pointer}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .factor2 .grayed{background:gray;border-color:gray}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .numeric-input{width:calc(100% - 5px)}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .step-value{margin-left:5px;grid-row:1;grid-column:4;text-align:right;margin-right:5px}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .step-slider{grid-row:1;grid-column:5;display:grid;justify-content:stretch;align-content:center;margin-right:5px}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .step-slider input{width:100%}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .gradient-delete{grid-row:1;grid-column:6;display:grid;align-content:center;justify-content:center}#actionTabs .tabsMenu .panes .pane .textInputLine{padding-left:2px;height:30px;display:grid;grid-template-columns:1fr 120px}#actionTabs .tabsMenu .panes .pane .textInputLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .textInputLine .value{display:flex;align-items:center;grid-column:2}#actionTabs .tabsMenu .panes .pane .textInputLine .value input{width:110px}#actionTabs .tabsMenu .panes .pane .buttonLine{height:30px;display:grid;align-items:center;justify-items:stretch}#actionTabs .tabsMenu .panes .pane .buttonLine input[type=file]{display:none}#actionTabs .tabsMenu .panes .pane .buttonLine .file-upload{background:#222;border:1px solid #337ab7;margin:5px 10px 5px 10px;color:#fff;padding:4px 5px;font-size:13px;opacity:.9;cursor:pointer;text-align:center}#actionTabs .tabsMenu .panes .pane .buttonLine .file-upload:hover{opacity:1}#actionTabs .tabsMenu .panes .pane .buttonLine .file-upload:active{transform:scale(0.98);transform-origin:.5 .5}#actionTabs .tabsMenu .panes .pane .buttonLine button{background:#222;border:1px solid #337ab7;margin:5px 10px 5px 10px;color:#fff;padding:4px 5px;opacity:.9;cursor:pointer}#actionTabs .tabsMenu .panes .pane .buttonLine button:hover{opacity:1}#actionTabs .tabsMenu .panes .pane .buttonLine button:active{background:#282828}#actionTabs .tabsMenu .panes .pane .buttonLine button:focus{border:1px solid #337ab7;outline:0px}#actionTabs .tabsMenu .panes .pane .radioLine{padding-left:2px;height:30px;display:grid;grid-template-columns:1fr 24px}#actionTabs .tabsMenu .panes .pane .radioLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer{display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .radio{grid-column:2;display:none}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .radio:checked+label:before{border-color:#337ab7}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .radio:checked+label:after{transform:scale(1)}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .labelForRadio{display:inline-block;height:14px;position:relative;padding:0 24px;margin-bottom:0;cursor:pointer;vertical-align:bottom}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .labelForRadio:before,#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .labelForRadio:after{position:absolute;content:"";border-radius:50%;transition:all .3s ease;transition-property:transform,border-color}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .labelForRadio:before{left:0px;top:0;width:16px;height:16px;border:2px solid #fff}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .labelForRadio:after{top:6px;left:6px;width:8px;height:8px;transform:scale(0);background:#337ab7}#actionTabs .tabsMenu .panes .pane .vector3Line{padding-left:2px;display:grid}#actionTabs .tabsMenu .panes .pane .vector3Line .firstLine{display:grid;grid-template-columns:1fr auto 20px;height:30px}#actionTabs .tabsMenu .panes .pane .vector3Line .firstLine .label{grid-column:1;display:flex;align-items:center;white-space:nowrap;overflow:hidden}#actionTabs .tabsMenu .panes .pane .vector3Line .firstLine .vector{grid-column:2;display:flex;align-items:center;text-align:right;opacity:.8;padding-left:5px}#actionTabs .tabsMenu .panes .pane .vector3Line .firstLine .expand{grid-column:3;display:grid;align-items:center;justify-items:center;cursor:pointer}#actionTabs .tabsMenu .panes .pane .vector3Line .secondLine{display:grid;padding-right:5px;border-left:1px solid #337ab7}#actionTabs .tabsMenu .panes .pane .vector3Line .secondLine .numeric{display:grid;grid-template-columns:1fr auto}#actionTabs .tabsMenu .panes .pane .vector3Line .secondLine .numeric-label{text-align:right;grid-column:1;display:flex;align-items:center;justify-self:right;margin-right:10px}#actionTabs .tabsMenu .panes .pane .vector3Line .secondLine .numeric-value{width:120px;grid-column:2;display:flex;align-items:center;border:1px solid #337ab7}#actionTabs .tabsMenu .panes .pane .checkBoxLine{padding-left:2px;height:30px;display:grid;grid-template-columns:1fr auto}#actionTabs .tabsMenu .panes .pane .checkBoxLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox{grid-column:2;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .lbl{position:relative;display:block;height:14px;width:34px;margin-right:5px;background:#898989;border-radius:100px;cursor:pointer;transition:all .3s ease}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .lbl.checked{background:#337ab7}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .lbl:after{position:absolute;left:3px;top:2px;display:block;width:10px;height:10px;border-radius:100px;background:#fff;box-shadow:0px 3px 3px rgba(0,0,0,.05);content:"";transition:all .15s ease}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .lbl:after.checked{left:20px;background:#164975}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .lbl.checked:after{position:absolute;top:2px;display:block;width:10px;height:10px;border-radius:100px;background:#fff;box-shadow:0px 3px 3px rgba(0,0,0,.05);content:"";transition:all .15s ease;left:20px;background:#164975}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .lbl:active:after{transform:scale(1.15, 0.85)}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .hidden{display:none}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .icon{display:none}#actionTabs .tabsMenu .panes .pane .textureLine{display:grid;grid-template-rows:30px auto}#actionTabs .tabsMenu .panes .pane .textureLine .control{margin-top:2px;grid-row:1;display:grid;grid-template-columns:1fr 40px 40px 40px 40px 40px 1fr}#actionTabs .tabsMenu .panes .pane .textureLine .control .red{grid-column:2}#actionTabs .tabsMenu .panes .pane .textureLine .control .green{grid-column:3}#actionTabs .tabsMenu .panes .pane .textureLine .control .blue{grid-column:4}#actionTabs .tabsMenu .panes .pane .textureLine .control .alpha{grid-column:5}#actionTabs .tabsMenu .panes .pane .textureLine .control .all{grid-column:6}#actionTabs .tabsMenu .panes .pane .textureLine .control3D{margin-top:2px;grid-row:1;display:grid;grid-template-columns:1fr 40px 40px 40px 40px 40px 40px 1fr}#actionTabs .tabsMenu .panes .pane .textureLine .control3D .px{grid-column:2}#actionTabs .tabsMenu .panes .pane .textureLine .control3D .nx{grid-column:3}#actionTabs .tabsMenu .panes .pane .textureLine .control3D .py{grid-column:4}#actionTabs .tabsMenu .panes .pane .textureLine .control3D .ny{grid-column:5}#actionTabs .tabsMenu .panes .pane .textureLine .control3D .pz{grid-column:6}#actionTabs .tabsMenu .panes .pane .textureLine .control3D .nz{grid-column:7}#actionTabs .tabsMenu .panes .pane .textureLine .command{border:1px solid rgba(0,0,0,0);background:rgba(0,0,0,0);color:#fff}#actionTabs .tabsMenu .panes .pane .textureLine .selected{border:1px solid #337ab7}#actionTabs .tabsMenu .panes .pane .textureLine .preview{grid-row:2;display:grid;align-self:center;justify-self:center;height:256px;width:256px;margin-top:5px;margin-bottom:5px;border:1px solid #fff;background-size:32px 32px;background-color:#fff;background-image:url(${d})}#actionTabs .tabsMenu .panes .pane .gltf-extension-property{margin-left:30px;border-left:1px solid #337ab7}#actionTabs .tabsMenu .panes .pane .floatLine{padding-left:2px;height:30px;display:grid;grid-template-columns:1fr 120px}#actionTabs .tabsMenu .panes .pane .floatLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .floatLine .value{grid-column:2;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .floatLine .value input{width:110px}#actionTabs .tabsMenu .panes .pane .sliderLine{padding-left:2px;height:30px;display:grid;grid-template-rows:100%;grid-template-columns:1fr 50px auto}#actionTabs .tabsMenu .panes .pane .sliderLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .sliderLine .withMargins{margin-left:5px}#actionTabs .tabsMenu .panes .pane .sliderLine .floatLine{padding-left:2px}#actionTabs .tabsMenu .panes .pane .sliderLine .floatLine .short{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .sliderLine .floatLine .short input{width:35px}#actionTabs .tabsMenu .panes .pane .sliderLine .floatLine .short input::-webkit-outer-spin-button,#actionTabs .tabsMenu .panes .pane .sliderLine .floatLine .short input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}#actionTabs .tabsMenu .panes .pane .sliderLine .floatLine .short input[type=number]{-moz-appearance:textfield}#actionTabs .tabsMenu .panes .pane .sliderLine .slider{grid-column:3;grid-row:1;margin-right:5px;width:90%;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .sliderLine .slider .range{-webkit-appearance:none;width:100%;height:6px;background:#d3d3d3;border-radius:5px;outline:none;opacity:.7;-webkit-transition:.2s;transition:opacity .2s}#actionTabs .tabsMenu .panes .pane .sliderLine .slider .range:hover{opacity:1}#actionTabs .tabsMenu .panes .pane .sliderLine .slider .range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:#337ab7;cursor:pointer}#actionTabs .tabsMenu .panes .pane .sliderLine .slider .range::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:#337ab7;cursor:pointer}#actionTabs .tabsMenu .panes .pane .color3Line{padding-left:2px;display:grid}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine{height:30px;display:grid;grid-template-columns:1fr auto 20px 20px}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .color3{grid-column:2;width:50px;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .color3 input[type=color]{-webkit-appearance:none;border:1px solid rgba(255,255,255,.5);padding:0;width:30px;height:20px}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .color3 input[type=color]::-webkit-color-swatch-wrapper{padding:0}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .color3 input[type=color]::-webkit-color-swatch{border:none}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .color3 input{margin-right:5px}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .copy{grid-column:3;display:grid;align-items:center;justify-items:center;cursor:pointer}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .copy img{height:100%}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .expand{grid-column:4;display:grid;align-items:center;justify-items:center;cursor:pointer}#actionTabs .tabsMenu .panes .pane .color3Line .secondLine{display:grid;padding-right:5px;border-left:1px solid #337ab7}#actionTabs .tabsMenu .panes .pane .color3Line .secondLine .numeric{display:grid;grid-template-columns:1fr auto}#actionTabs .tabsMenu .panes .pane .color3Line .secondLine .numeric-label{text-align:right;grid-column:1;display:flex;align-items:center;justify-self:right;margin-right:10px}#actionTabs .tabsMenu .panes .pane .color3Line .secondLine .numeric-value{width:120px;grid-column:2;display:flex;align-items:center;border:1px solid #337ab7}#actionTabs .tabsMenu .panes .pane .listLine{padding-left:2px;height:30px;display:grid;grid-template-columns:1fr auto}#actionTabs .tabsMenu .panes .pane .listLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .listLine .options{grid-column:2;display:flex;align-items:center;margin-right:5px}#actionTabs .tabsMenu .panes .pane .listLine .options select{width:115px}#actionTabs .tabsMenu .panes .pane .paneContainer{margin-top:3px;display:grid;grid-template-rows:100%;grid-template-columns:100%}#actionTabs .tabsMenu .panes .pane .paneContainer .paneList{border-left:3px solid rgba(0,0,0,0)}#actionTabs .tabsMenu .panes .pane .paneContainer:hover .paneList{border-left:3px solid rgba(51,122,183,.8)}#actionTabs .tabsMenu .panes .pane .paneContainer:hover .paneContainer-content .header .title{border-left:3px solid #337ab7}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-highlight-border{grid-row:1;grid-column:1;opacity:1;border:3px solid red;margin-bottom:-5px;z-index:100;transition:opacity 250ms;pointer-events:none}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-highlight-border.transparent{opacity:0}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-content{grid-row:1;grid-column:1}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-content .header{display:grid;grid-template-columns:1fr auto;background:#555;height:30px;padding-right:5px;cursor:pointer}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-content .header .title{border-left:3px solid rgba(0,0,0,0);padding-left:5px;grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-content .header .collapse{grid-column:2;display:flex;align-items:center;justify-items:center;transform-origin:center}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-content .header .collapse.closed{transform:rotate(180deg)}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-content .paneList>div:not(:last-child){border-bottom:.5px solid rgba(255,255,255,.1)}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-content .fragment>div:not(:last-child){border-bottom:.5px solid rgba(255,255,255,.1)}`,"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/actionTabs.scss"],names:[],mappings:"AAEA,gBACI,iBAAA,CACA,SAAA,CACA,OAAA,CACA,UAAA,CAGJ,oBACI,YAAA,CAGJ,YACI,eAAA,CACA,WAAA,CACA,QAAA,CACA,SAAA,CACA,YAAA,CACA,2BAAA,CACA,iBAAA,CACA,eAAA,CAEA,6BACI,UAAA,CAGJ,oBACI,WAAA,CACA,cAAA,CACA,UAAA,CACA,eAAA,CACA,UAAA,CACA,iBAAA,CACA,YAAA,CACA,mCAAA,CACA,wBAAA,CACA,qBAAA,CACA,oBAAA,CACA,gBAAA,CAEA,0BACI,aAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,iBAAA,CACA,mBAAA,CAGJ,0BACI,aAAA,CACA,YAAA,CACA,iBAAA,CACA,mBAAA,CACA,cAAA,CAGJ,2BACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,iBAAA,CAGJ,8BACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,6BAAA,CAEA,sCACI,aAAA,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AAA,CAGJ,2FACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,uBAAA,CAEA,kGACI,wBAAA,CAKZ,wGACI,6CAAA,CAGJ,wGACI,6CAAA",sourcesContent:['$line-padding-left: 2px;\r\n\r\n#inspector-host {\r\n position: absolute;\r\n right: 0px;\r\n top: 0px;\r\n bottom: 0px;\r\n}\r\n\r\n#__resizable_base__ {\r\n display: none;\r\n}\r\n\r\n#actionTabs {\r\n background: #333333;\r\n height: 100%;\r\n margin: 0;\r\n padding: 0;\r\n display: grid;\r\n grid-template-rows: auto 1fr;\r\n font: 14px "Arial";\r\n overflow: hidden;\r\n\r\n .hoverIcon:hover {\r\n opacity: 0.8;\r\n }\r\n\r\n #header {\r\n height: 30px;\r\n font-size: 16px;\r\n color: white;\r\n background: #222222;\r\n grid-row: 1;\r\n text-align: center;\r\n display: grid;\r\n grid-template-columns: 30px 1fr 50px;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n\r\n #logo {\r\n grid-column: 1;\r\n width: 24px;\r\n height: 24px;\r\n display: flex;\r\n align-self: center;\r\n justify-self: center;\r\n }\r\n\r\n #back {\r\n grid-column: 1;\r\n display: grid;\r\n align-self: center;\r\n justify-self: center;\r\n cursor: pointer;\r\n }\r\n\r\n #title {\r\n grid-column: 2;\r\n display: grid;\r\n align-items: center;\r\n text-align: center;\r\n }\r\n\r\n #commands {\r\n grid-column: 3;\r\n display: grid;\r\n align-items: center;\r\n grid-template-columns: 1fr 1fr;\r\n\r\n .expand {\r\n grid-column: 1;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n\r\n .close {\r\n grid-column: 2;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n }\r\n }\r\n\r\n .tabsMenu {\r\n display: grid;\r\n grid-row: 2;\r\n grid-template-rows: 40px 1fr;\r\n font: 14px "Arial";\r\n overflow: hidden;\r\n\r\n .labels {\r\n grid-row: 1;\r\n display: flex;\r\n align-items: center;\r\n justify-items: center;\r\n border-bottom: 1px solid #ffffff;\r\n margin: 0;\r\n padding: 0;\r\n\r\n .label {\r\n font-size: 24px;\r\n color: white;\r\n width: 40px;\r\n display: flex;\r\n align-content: center;\r\n justify-content: center;\r\n border: 1px solid transparent;\r\n border-bottom: none;\r\n background: #333333;\r\n padding: 5px;\r\n height: 28px;\r\n cursor: pointer;\r\n\r\n &.active {\r\n border-color: #ffffff;\r\n border-bottom: 2px solid transparent;\r\n margin-bottom: -2px;\r\n }\r\n }\r\n }\r\n\r\n .panes {\r\n grid-row: 2;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n\r\n overflow: hidden;\r\n\r\n .infoMessage {\r\n opacity: 0.5;\r\n color: white;\r\n margin: 15px 5px 0px 5px;\r\n }\r\n\r\n .gradient-step {\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 20px 30px 40px auto 20px 30px;\r\n padding-top: 5px;\r\n padding-left: 5px;\r\n padding-bottom: 5px;\r\n align-items: center;\r\n\r\n .step {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n .color1 {\r\n height: 100%;\r\n }\r\n\r\n .color2 {\r\n height: 100%;\r\n padding-left: 5px;\r\n }\r\n\r\n .factor1 {\r\n grid-row: 1;\r\n grid-column: 2;\r\n cursor: pointer;\r\n }\r\n\r\n .factor2 {\r\n padding-left: 5px;\r\n grid-row: 1;\r\n grid-column: 3;\r\n cursor: pointer;\r\n\r\n .grayed {\r\n background: gray;\r\n border-color: gray;\r\n }\r\n }\r\n\r\n .numeric-input {\r\n width: calc(100% - 5px);\r\n }\r\n\r\n .icon {\r\n cursor: pointer;\r\n }\r\n\r\n .step-value {\r\n margin-left: 5px;\r\n grid-row: 1;\r\n grid-column: 3;\r\n text-align: right;\r\n margin-right: 5px;\r\n }\r\n\r\n .step-slider {\r\n grid-row: 1;\r\n grid-column: 4;\r\n display: grid;\r\n justify-content: stretch;\r\n align-content: center;\r\n margin-right: 12px;\r\n\r\n input {\r\n width: 100%;\r\n }\r\n .range:hover {\r\n opacity: 1;\r\n }\r\n\r\n .range {\r\n -webkit-appearance: none;\r\n height: 6px;\r\n background: #d3d3d3;\r\n border-radius: 5px;\r\n outline: none;\r\n opacity: 0.7;\r\n -webkit-transition: 0.2s;\r\n transition: opacity 0.2s;\r\n }\r\n .range::-webkit-slider-thumb {\r\n -webkit-appearance: none;\r\n appearance: none;\r\n width: 14px;\r\n height: 14px;\r\n border-radius: 50%;\r\n background: rgb(51, 122, 183);\r\n cursor: pointer;\r\n }\r\n\r\n .range::-moz-range-thumb {\r\n width: 14px;\r\n height: 14px;\r\n border-radius: 50%;\r\n background: rgb(51, 122, 183);\r\n cursor: pointer;\r\n }\r\n }\r\n\r\n .gradient-copy {\r\n grid-row: 1;\r\n grid-column: 5;\r\n display: grid;\r\n align-content: center;\r\n justify-content: center;\r\n\r\n .img {\r\n height: 20px;\r\n width: 20px;\r\n }\r\n .img:hover {\r\n cursor: pointer;\r\n }\r\n }\r\n .gradient-delete {\r\n grid-row: 1;\r\n grid-column: 6;\r\n display: grid;\r\n align-content: center;\r\n justify-content: center;\r\n .img {\r\n height: 20px;\r\n width: 20px;\r\n }\r\n .img:hover {\r\n cursor: pointer;\r\n }\r\n }\r\n }\r\n\r\n .pane {\r\n color: white;\r\n\r\n overflow-x: hidden;\r\n overflow-y: auto;\r\n height: 100%;\r\n\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n\r\n .animation-info {\r\n border-left: greenyellow 3px solid;\r\n margin-left: 5px;\r\n padding-left: 5px !important;\r\n }\r\n\r\n .underline {\r\n border-bottom: 0.5px solid rgba(255, 255, 255, 0.5);\r\n }\r\n\r\n .textureLinkLine {\r\n display: grid;\r\n grid-template-columns: auto 1fr;\r\n\r\n .debug {\r\n grid-column: 1;\r\n margin-left: 5px;\r\n margin-right: 5px;\r\n display: block;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n opacity: 0.5;\r\n\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .textLine {\r\n grid-column: 2;\r\n }\r\n\r\n .actionIcon {\r\n display: inline-block;\r\n margin-top: 6px;\r\n margin-right: 4px;\r\n }\r\n }\r\n\r\n .messageLine {\r\n text-align: center;\r\n font-size: 12px;\r\n font-style: italic;\r\n opacity: 0.6;\r\n }\r\n\r\n .iconMessageLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 30px 1fr;\r\n\r\n .icon {\r\n grid-column: 1;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n }\r\n\r\n .value {\r\n grid-column: 2;\r\n display: flex;\r\n align-items: center;\r\n }\r\n }\r\n\r\n .color-picker {\r\n height: calc(100% - 8px);\r\n margin: 4px;\r\n width: 100%;\r\n\r\n .color-rect {\r\n height: calc(100% - 4px);\r\n border: 2px white solid;\r\n cursor: pointer;\r\n min-height: 18px;\r\n }\r\n\r\n .color-picker-cover {\r\n position: fixed;\r\n top: 0px;\r\n right: 0px;\r\n bottom: 0px;\r\n left: 0px;\r\n z-index: 100;\r\n }\r\n\r\n .color-picker-float {\r\n position: absolute;\r\n }\r\n }\r\n\r\n .linkButtonLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr auto 20px;\r\n\r\n .link {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n text-decoration: underline;\r\n cursor: pointer;\r\n }\r\n\r\n .link-button {\r\n grid-column: 2;\r\n\r\n button {\r\n background: #222222;\r\n border: 1px solid rgb(51, 122, 183);\r\n margin: 5px 10px 5px 10px;\r\n color: white;\r\n padding: 4px 5px;\r\n opacity: 0.9;\r\n cursor: pointer;\r\n }\r\n\r\n button:hover {\r\n opacity: 1;\r\n }\r\n\r\n button:active {\r\n background: #282828;\r\n }\r\n\r\n button:focus {\r\n border: 1px solid rgb(51, 122, 183);\r\n outline: 0px;\r\n }\r\n }\r\n\r\n .link-icon {\r\n grid-column: 3;\r\n display: grid;\r\n align-content: center;\r\n }\r\n }\r\n\r\n .textLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr auto;\r\n\r\n &.indented {\r\n grid-template-columns: 100%;\r\n\r\n .link-value {\r\n grid-column: 1;\r\n text-align: start;\r\n margin-left: 20px;\r\n opacity: 0.6;\r\n max-width: unset;\r\n }\r\n\r\n .value {\r\n grid-column: 1;\r\n text-align: start;\r\n margin-left: 20px;\r\n opacity: 0.6;\r\n max-width: unset;\r\n }\r\n }\r\n\r\n &.reduced-opacity {\r\n opacity: 0.6;\r\n padding-left: 25px;\r\n }\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .link-value {\r\n grid-column: 2;\r\n white-space: nowrap;\r\n text-overflow: ellipsis;\r\n overflow: hidden;\r\n text-align: end;\r\n opacity: 0.8;\r\n margin: 5px;\r\n margin-top: 7px;\r\n max-width: 140px;\r\n text-decoration: underline;\r\n cursor: pointer;\r\n }\r\n\r\n .value {\r\n grid-column: 2;\r\n white-space: nowrap;\r\n text-overflow: ellipsis;\r\n overflow: hidden;\r\n text-align: end;\r\n opacity: 0.8;\r\n margin: 5px;\r\n margin-top: 7px;\r\n max-width: 200px;\r\n -webkit-user-select: text;\r\n -moz-user-select: text;\r\n -ms-user-select: text;\r\n user-select: text;\r\n\r\n &.check {\r\n color: green;\r\n }\r\n\r\n &.uncheck {\r\n color: red;\r\n }\r\n }\r\n }\r\n\r\n .gradient-container {\r\n margin-top: 3px;\r\n\r\n .gradient-label {\r\n height: 30px;\r\n display: grid;\r\n align-content: center;\r\n }\r\n\r\n .gradient-step {\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 25px 50px 55px 40px auto 20px 5px;\r\n padding-top: 5px;\r\n padding-left: 5px;\r\n padding-bottom: 5px;\r\n align-items: center;\r\n border-left: orange 3px solid;\r\n\r\n .step {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n .color1 {\r\n height: 100%;\r\n }\r\n\r\n .color2 {\r\n height: 100%;\r\n padding-left: 5px;\r\n }\r\n\r\n .factor1 {\r\n grid-row: 1;\r\n grid-column: 2;\r\n cursor: pointer;\r\n }\r\n\r\n .factor2 {\r\n padding-left: 5px;\r\n grid-row: 1;\r\n grid-column: 3;\r\n cursor: pointer;\r\n\r\n .grayed {\r\n background: gray;\r\n border-color: gray;\r\n }\r\n }\r\n\r\n .numeric-input {\r\n width: calc(100% - 5px);\r\n }\r\n\r\n .step-value {\r\n margin-left: 5px;\r\n grid-row: 1;\r\n grid-column: 4;\r\n text-align: right;\r\n margin-right: 5px;\r\n }\r\n\r\n .step-slider {\r\n grid-row: 1;\r\n grid-column: 5;\r\n display: grid;\r\n justify-content: stretch;\r\n align-content: center;\r\n margin-right: 5px;\r\n\r\n input {\r\n width: 100%;\r\n }\r\n }\r\n\r\n .gradient-delete {\r\n grid-row: 1;\r\n grid-column: 6;\r\n display: grid;\r\n align-content: center;\r\n justify-content: center;\r\n }\r\n }\r\n }\r\n\r\n .textInputLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr 120px;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .value {\r\n display: flex;\r\n align-items: center;\r\n grid-column: 2;\r\n\r\n input {\r\n width: 110px;\r\n }\r\n }\r\n }\r\n\r\n .buttonLine {\r\n height: 30px;\r\n display: grid;\r\n align-items: center;\r\n justify-items: stretch;\r\n\r\n input[type="file"] {\r\n display: none;\r\n }\r\n\r\n .file-upload {\r\n background: #222222;\r\n border: 1px solid rgb(51, 122, 183);\r\n margin: 5px 10px 5px 10px;\r\n color: white;\r\n padding: 4px 5px;\r\n font-size: 13px;\r\n opacity: 0.9;\r\n cursor: pointer;\r\n text-align: center;\r\n }\r\n\r\n .file-upload:hover {\r\n opacity: 1;\r\n }\r\n\r\n .file-upload:active {\r\n transform: scale(0.98);\r\n transform-origin: 0.5 0.5;\r\n }\r\n\r\n button {\r\n background: #222222;\r\n border: 1px solid rgb(51, 122, 183);\r\n margin: 5px 10px 5px 10px;\r\n color: white;\r\n padding: 4px 5px;\r\n opacity: 0.9;\r\n cursor: pointer;\r\n }\r\n\r\n button:hover {\r\n opacity: 1;\r\n }\r\n\r\n button:active {\r\n background: #282828;\r\n }\r\n\r\n button:focus {\r\n border: 1px solid rgb(51, 122, 183);\r\n outline: 0px;\r\n }\r\n }\r\n\r\n .radioLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr 24px;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .radioContainer {\r\n display: flex;\r\n align-items: center;\r\n\r\n .radio {\r\n grid-column: 2;\r\n display: none;\r\n\r\n &:checked + label:before {\r\n border-color: rgb(51, 122, 183);\r\n }\r\n &:checked + label:after {\r\n transform: scale(1);\r\n }\r\n }\r\n\r\n .labelForRadio {\r\n display: inline-block;\r\n height: 14px;\r\n position: relative;\r\n padding: 0 24px;\r\n margin-bottom: 0;\r\n cursor: pointer;\r\n vertical-align: bottom;\r\n &:before,\r\n &:after {\r\n position: absolute;\r\n content: "";\r\n border-radius: 50%;\r\n transition: all 0.3s ease;\r\n transition-property: transform, border-color;\r\n }\r\n &:before {\r\n left: 0px;\r\n top: 0;\r\n width: 16px;\r\n height: 16px;\r\n border: 2px solid white;\r\n }\r\n &:after {\r\n top: 6px;\r\n left: 6px;\r\n width: 8px;\r\n height: 8px;\r\n transform: scale(0);\r\n background: rgb(51, 122, 183);\r\n }\r\n }\r\n }\r\n }\r\n\r\n .vector3Line {\r\n padding-left: $line-padding-left;\r\n display: grid;\r\n\r\n .firstLine {\r\n display: grid;\r\n grid-template-columns: 1fr auto 20px;\r\n height: 30px;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n }\r\n\r\n .vector {\r\n grid-column: 2;\r\n display: flex;\r\n align-items: center;\r\n text-align: right;\r\n opacity: 0.8;\r\n padding-left: 5px;\r\n }\r\n\r\n .expand {\r\n grid-column: 3;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n }\r\n\r\n .secondLine {\r\n display: grid;\r\n padding-right: 5px;\r\n border-left: 1px solid rgb(51, 122, 183);\r\n\r\n .numeric {\r\n display: grid;\r\n grid-template-columns: 1fr auto;\r\n }\r\n\r\n .numeric-label {\r\n text-align: right;\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n justify-self: right;\r\n margin-right: 10px;\r\n }\r\n\r\n .numeric-value {\r\n width: 120px;\r\n grid-column: 2;\r\n display: flex;\r\n align-items: center;\r\n border: 1px solid rgb(51, 122, 183);\r\n }\r\n }\r\n }\r\n\r\n .checkBoxLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr auto;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .checkBox {\r\n grid-column: 2;\r\n\r\n display: flex;\r\n align-items: center;\r\n\r\n .lbl {\r\n position: relative;\r\n display: block;\r\n height: 14px;\r\n width: 34px;\r\n margin-right: 5px;\r\n background: #898989;\r\n border-radius: 100px;\r\n cursor: pointer;\r\n transition: all 0.3s ease;\r\n\r\n &.checked {\r\n background: rgb(51, 122, 183);\r\n }\r\n }\r\n\r\n .lbl:after {\r\n position: absolute;\r\n left: 3px;\r\n top: 2px;\r\n display: block;\r\n width: 10px;\r\n height: 10px;\r\n border-radius: 100px;\r\n background: #fff;\r\n box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.05);\r\n content: "";\r\n transition: all 0.15s ease;\r\n\r\n &.checked {\r\n left: 20px;\r\n background: rgb(22, 73, 117);\r\n }\r\n }\r\n\r\n .lbl.checked:after {\r\n position: absolute;\r\n top: 2px;\r\n display: block;\r\n width: 10px;\r\n height: 10px;\r\n border-radius: 100px;\r\n background: #fff;\r\n box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.05);\r\n content: "";\r\n transition: all 0.15s ease;\r\n left: 20px;\r\n background: rgb(22, 73, 117);\r\n }\r\n\r\n .lbl:active:after {\r\n transform: scale(1.15, 0.85);\r\n }\r\n\r\n .hidden {\r\n display: none;\r\n }\r\n\r\n .icon {\r\n display: none;\r\n }\r\n }\r\n }\r\n\r\n .textureLine {\r\n display: grid;\r\n grid-template-rows: 30px auto;\r\n\r\n .control {\r\n margin-top: 2px;\r\n grid-row: 1;\r\n display: grid;\r\n grid-template-columns: 1fr 40px 40px 40px 40px 40px 1fr;\r\n\r\n .red {\r\n grid-column: 2;\r\n }\r\n\r\n .green {\r\n grid-column: 3;\r\n }\r\n\r\n .blue {\r\n grid-column: 4;\r\n }\r\n\r\n .alpha {\r\n grid-column: 5;\r\n }\r\n\r\n .all {\r\n grid-column: 6;\r\n }\r\n }\r\n\r\n .control3D {\r\n margin-top: 2px;\r\n grid-row: 1;\r\n display: grid;\r\n grid-template-columns: 1fr 40px 40px 40px 40px 40px 40px 1fr;\r\n\r\n .px {\r\n grid-column: 2;\r\n }\r\n\r\n .nx {\r\n grid-column: 3;\r\n }\r\n\r\n .py {\r\n grid-column: 4;\r\n }\r\n\r\n .ny {\r\n grid-column: 5;\r\n }\r\n\r\n .pz {\r\n grid-column: 6;\r\n }\r\n\r\n .nz {\r\n grid-column: 7;\r\n }\r\n }\r\n\r\n .command {\r\n border: 1px solid transparent;\r\n background: transparent;\r\n color: white;\r\n }\r\n\r\n .selected {\r\n border: 1px solid rgb(51, 122, 183);\r\n }\r\n\r\n .preview {\r\n grid-row: 2;\r\n display: grid;\r\n align-self: center;\r\n justify-self: center;\r\n height: 256px;\r\n width: 256px;\r\n margin-top: 5px;\r\n margin-bottom: 5px;\r\n border: 1px solid white;\r\n background-size: 32px 32px;\r\n background-color: white;\r\n background-image: url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 2 2\'%3E%3Cpath fill=\'rgba(1.0,1.0,1.0,0.3)\' fill-rule=\'evenodd\' d=\'M0 0h1v1H0V0zm1 1h1v1H1V1z\'/%3E%3C/svg%3E");\r\n }\r\n }\r\n\r\n .gltf-extension-property {\r\n margin-left: 30px;\r\n border-left: 1px solid rgb(51, 122, 183);\r\n }\r\n\r\n .floatLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr 120px;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .value {\r\n grid-column: 2;\r\n\r\n display: flex;\r\n align-items: center;\r\n\r\n input {\r\n width: 110px;\r\n }\r\n }\r\n }\r\n\r\n .sliderLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 1fr 50px auto;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .withMargins {\r\n margin-left: 5px;\r\n }\r\n\r\n .floatLine {\r\n padding-left: $line-padding-left;\r\n\r\n .short {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n\r\n input {\r\n width: 35px;\r\n }\r\n\r\n input::-webkit-outer-spin-button,\r\n input::-webkit-inner-spin-button {\r\n -webkit-appearance: none;\r\n margin: 0;\r\n }\r\n\r\n input[type="number"] {\r\n -moz-appearance: textfield;\r\n }\r\n }\r\n }\r\n\r\n .slider {\r\n grid-column: 3;\r\n grid-row: 1;\r\n margin-right: 5px;\r\n width: 90%;\r\n display: flex;\r\n align-items: center;\r\n\r\n .range {\r\n -webkit-appearance: none;\r\n width: 100%;\r\n height: 6px;\r\n background: #d3d3d3;\r\n border-radius: 5px;\r\n outline: none;\r\n opacity: 0.7;\r\n -webkit-transition: 0.2s;\r\n transition: opacity 0.2s;\r\n }\r\n\r\n .range:hover {\r\n opacity: 1;\r\n }\r\n\r\n .range::-webkit-slider-thumb {\r\n -webkit-appearance: none;\r\n appearance: none;\r\n width: 14px;\r\n height: 14px;\r\n border-radius: 50%;\r\n background: rgb(51, 122, 183);\r\n cursor: pointer;\r\n }\r\n\r\n .range::-moz-range-thumb {\r\n width: 14px;\r\n height: 14px;\r\n border-radius: 50%;\r\n background: rgb(51, 122, 183);\r\n cursor: pointer;\r\n }\r\n }\r\n }\r\n\r\n .color3Line {\r\n padding-left: $line-padding-left;\r\n display: grid;\r\n\r\n .firstLine {\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr auto 20px 20px;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .color3 {\r\n grid-column: 2;\r\n width: 50px;\r\n\r\n display: flex;\r\n align-items: center;\r\n\r\n input[type="color"] {\r\n -webkit-appearance: none;\r\n border: 1px solid rgba(255, 255, 255, 0.5);\r\n padding: 0;\r\n width: 30px;\r\n height: 20px;\r\n }\r\n input[type="color"]::-webkit-color-swatch-wrapper {\r\n padding: 0;\r\n }\r\n input[type="color"]::-webkit-color-swatch {\r\n border: none;\r\n }\r\n\r\n input {\r\n margin-right: 5px;\r\n }\r\n }\r\n\r\n .copy {\r\n grid-column: 3;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n img {\r\n height: 100%;\r\n }\r\n }\r\n\r\n .expand {\r\n grid-column: 4;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n }\r\n\r\n .secondLine {\r\n display: grid;\r\n padding-right: 5px;\r\n border-left: 1px solid rgb(51, 122, 183);\r\n\r\n .numeric {\r\n display: grid;\r\n grid-template-columns: 1fr auto;\r\n }\r\n\r\n .numeric-label {\r\n text-align: right;\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n justify-self: right;\r\n margin-right: 10px;\r\n }\r\n\r\n .numeric-value {\r\n width: 120px;\r\n grid-column: 2;\r\n display: flex;\r\n align-items: center;\r\n border: 1px solid rgb(51, 122, 183);\r\n }\r\n }\r\n }\r\n\r\n .listLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr auto;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .options {\r\n grid-column: 2;\r\n\r\n display: flex;\r\n align-items: center;\r\n margin-right: 5px;\r\n\r\n select {\r\n width: 115px;\r\n }\r\n }\r\n }\r\n\r\n .paneContainer {\r\n margin-top: 3px;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 100%;\r\n\r\n .paneList {\r\n border-left: 3px solid transparent;\r\n }\r\n\r\n &:hover {\r\n .paneList {\r\n border-left: 3px solid rgba(51, 122, 183, 0.8);\r\n }\r\n\r\n .paneContainer-content {\r\n .header {\r\n .title {\r\n border-left: 3px solid rgb(51, 122, 183);\r\n }\r\n }\r\n }\r\n }\r\n\r\n .paneContainer-highlight-border {\r\n grid-row: 1;\r\n grid-column: 1;\r\n opacity: 1;\r\n border: 3px solid red;\r\n margin-bottom: -5px;\r\n z-index: 100;\r\n transition: opacity 250ms;\r\n pointer-events: none;\r\n\r\n &.transparent {\r\n opacity: 0;\r\n }\r\n }\r\n\r\n .paneContainer-content {\r\n grid-row: 1;\r\n grid-column: 1;\r\n\r\n .header {\r\n display: grid;\r\n grid-template-columns: 1fr auto;\r\n background: #555555;\r\n height: 30px;\r\n padding-right: 5px;\r\n cursor: pointer;\r\n\r\n .title {\r\n border-left: 3px solid transparent;\r\n padding-left: 5px;\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .collapse {\r\n grid-column: 2;\r\n display: flex;\r\n align-items: center;\r\n justify-items: center;\r\n transform-origin: center;\r\n\r\n &.closed {\r\n transform: rotate(180deg);\r\n }\r\n }\r\n }\r\n\r\n .paneList > div:not(:last-child) {\r\n border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);\r\n }\r\n\r\n .fragment > div:not(:last-child) {\r\n border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),c.locals={};const h=c},5030:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(3234),o=r.n(n),s=r(7474),a=r.n(s)()(o());a.push([e.id,'#performance-viewer{display:grid;height:100%;width:100%;grid-template-columns:300px 1fr;font-family:"acumin-pro"}#performance-viewer .performancePlayheadButton{grid-area:liveButton;height:30px;width:100px;justify-self:right;background-color:#dcdfe1;color:#2e3f47;outline:2px #2e3f47;margin:5px;position:absolute;top:10px;right:10px}#performance-viewer #performance-viewer-sidebar{display:flex;flex-direction:column;overflow-y:scroll;border:2px solid gray}#performance-viewer #performance-viewer-sidebar .sidebar-item{display:grid;width:100%;height:30px;font-size:14px;padding:2.5px 0px;align-items:center}#performance-viewer #performance-viewer-sidebar .header{color:#fff;grid-template-columns:10px 9fr 1fr 10px}#performance-viewer #performance-viewer-sidebar .header .category{grid-column:2}#performance-viewer #performance-viewer-sidebar .header .value{grid-column:3}#performance-viewer #performance-viewer-sidebar .version-header{background-color:#2e3f47;color:#fff;grid-template-columns:10px 1fr 1fr 10px;font-size:14px;height:35px}#performance-viewer #performance-viewer-sidebar .version-header .category{grid-column:2}#performance-viewer #performance-viewer-sidebar .version-header .value{grid-column:3;display:flex;justify-content:end}#performance-viewer #performance-viewer-sidebar .category-header{background-color:#4a5960;text-transform:uppercase;font-size:14px;height:30px}#performance-viewer #performance-viewer-sidebar .category-header .checkBoxLine{color:#dcdfe1}#performance-viewer #performance-viewer-sidebar .measure{color:#000;grid-template-columns:18px 6fr 1fr;font-family:"acumin-pro-condensed"}#performance-viewer #performance-viewer-sidebar .measure .category{display:grid;grid-template-columns:18px 7px 18px 10px 1fr;grid-column:2;align-items:center}#performance-viewer #performance-viewer-sidebar .measure .category .color-picker{grid-column:3}#performance-viewer #performance-viewer-sidebar .measure .category .sidebar-item-label{grid-column:5}#performance-viewer #performance-viewer-sidebar .measure .value{grid-column:3}#performance-viewer #performance-viewer-sidebar .measure:nth-child(odd){background-color:#dcdfe1}#performance-viewer #performance-viewer-sidebar .measure:nth-child(even){background-color:#ebedee}#performance-viewer #performance-viewer-sidebar .checkBoxLine{color:#4a5960;width:100%;height:100%;display:flex;justify-content:center;align-items:center}#performance-viewer #performance-viewer-sidebar .checkBoxLine .disabled{color:#d3d3d3}#performance-viewer #performance-viewer-sidebar .color-picker{width:100%}#performance-viewer #performance-viewer-sidebar .color-picker .color-rect{height:18px;width:18px;cursor:pointer}#performance-viewer #performance-viewer-sidebar .color-picker .color-picker-cover{position:fixed;top:0px;right:0px;bottom:0px;left:0px;z-index:100}#performance-viewer #performance-viewer-sidebar .color-picker .color-picker-float{position:absolute}#performance-viewer #performance-viewer-sidebar .color-picker .color-picker-float .color-picker-container{width:200px}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/performanceViewer/scss/performanceViewer.scss"],names:[],mappings:"AAGA,oBACI,YAAA,CACA,WAAA,CACA,UAAA,CACA,+BAAA,CACA,wBAAA,CAEA,+CACI,oBAAA,CACA,WAZO,CAaP,WAAA,CACA,kBAAA,CACA,wBAAA,CACA,aAAA,CACA,mBAAA,CACA,UAAA,CACA,iBAAA,CACA,QAAA,CACA,UAAA,CAGJ,gDACI,YAAA,CACA,qBAAA,CACA,iBAAA,CAEA,qBAAA,CAEA,8DACI,YAAA,CACA,UAAA,CACA,WAAA,CACA,cAAA,CACA,iBAAA,CACA,kBAAA,CAGJ,wDACI,UAAA,CACA,uCAAA,CAEA,kEACI,aAAA,CAGJ,+DACI,aAAA,CAIR,gEACI,wBAAA,CACA,UAAA,CACA,uCAAA,CACA,cAAA,CACA,WAAA,CAEA,0EACI,aAAA,CAGJ,uEACI,aAAA,CACA,YAAA,CACA,mBAAA,CAKR,iEACI,wBAAA,CACA,wBAAA,CACA,cAAA,CACA,WAAA,CAEA,+EACI,aAAA,CAIR,yDACI,UAAA,CACA,kCAAA,CACA,kCAAA,CAEA,mEACI,YAAA,CACA,4CAAA,CACA,aAAA,CACA,kBAAA,CAEA,iFACI,aAAA,CAGJ,uFACI,aAAA,CAIR,gEACI,aAAA,CAKR,wEACI,wBAAA,CAIJ,yEACI,wBAAA,CAGJ,8DACI,aAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,sBAAA,CACA,kBAAA,CACA,wEACI,aAAA,CAIR,8DACI,UAAA,CAEA,0EACI,WArIH,CAsIG,UAtIH,CAuIG,cAAA,CAGJ,kFACI,cAAA,CACA,OAAA,CACA,SAAA,CACA,UAAA,CACA,QAAA,CACA,WAAA,CAGJ,kFACI,iBAAA,CAEA,0GACI,WAAA",sourcesContent:['$buttonHeight: 30px;\r\n$squareSize: 18px;\r\n\r\n#performance-viewer {\r\n display: grid;\r\n height: 100%;\r\n width: 100%;\r\n grid-template-columns: 300px 1fr;\r\n font-family: "acumin-pro";\r\n\r\n .performancePlayheadButton {\r\n grid-area: liveButton;\r\n height: $buttonHeight;\r\n width: 100px;\r\n justify-self: right;\r\n background-color: #dcdfe1;\r\n color: #2e3f47;\r\n outline: 2px #2e3f47;\r\n margin: 5px;\r\n position: absolute;\r\n top: 10px;\r\n right: 10px;\r\n }\r\n\r\n #performance-viewer-sidebar {\r\n display: flex;\r\n flex-direction: column;\r\n overflow-y: scroll;\r\n\r\n border: 2px solid gray;\r\n\r\n .sidebar-item {\r\n display: grid;\r\n width: 100%;\r\n height: 30px;\r\n font-size: 14px;\r\n padding: 2.5px 0px;\r\n align-items: center;\r\n }\r\n\r\n .header {\r\n color: white;\r\n grid-template-columns: 10px 9fr 1fr 10px;\r\n\r\n .category {\r\n grid-column: 2;\r\n }\r\n\r\n .value {\r\n grid-column: 3;\r\n }\r\n }\r\n\r\n .version-header {\r\n background-color: #2e3f47;\r\n color: white;\r\n grid-template-columns: 10px 1fr 1fr 10px;\r\n font-size: 14px;\r\n height: 35px; // with padding, we get 40px\r\n\r\n .category {\r\n grid-column: 2;\r\n }\r\n\r\n .value {\r\n grid-column: 3;\r\n display: flex;\r\n justify-content: end;\r\n }\r\n }\r\n\r\n // mid-dark color\r\n .category-header {\r\n background-color: #4a5960;\r\n text-transform: uppercase;\r\n font-size: 14px;\r\n height: 30px;\r\n\r\n .checkBoxLine {\r\n color: #dcdfe1;\r\n }\r\n }\r\n\r\n .measure {\r\n color: black;\r\n grid-template-columns: $squareSize 6fr 1fr;\r\n font-family: "acumin-pro-condensed";\r\n\r\n .category {\r\n display: grid;\r\n grid-template-columns: $squareSize 7px $squareSize 10px 1fr;\r\n grid-column: 2;\r\n align-items: center;\r\n\r\n .color-picker {\r\n grid-column: 3;\r\n }\r\n\r\n .sidebar-item-label {\r\n grid-column: 5;\r\n }\r\n }\r\n\r\n .value {\r\n grid-column: 3;\r\n }\r\n }\r\n\r\n //darker color\r\n .measure:nth-child(odd) {\r\n background-color: #dcdfe1;\r\n }\r\n\r\n // lighter color\r\n .measure:nth-child(even) {\r\n background-color: #ebedee;\r\n }\r\n\r\n .checkBoxLine {\r\n color: #4a5960;\r\n width: 100%;\r\n height: 100%;\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n .disabled {\r\n color: lightgray;\r\n }\r\n }\r\n\r\n .color-picker {\r\n width: 100%;\r\n\r\n .color-rect {\r\n height: $squareSize;\r\n width: $squareSize;\r\n cursor: pointer;\r\n }\r\n\r\n .color-picker-cover {\r\n position: fixed;\r\n top: 0px;\r\n right: 0px;\r\n bottom: 0px;\r\n left: 0px;\r\n z-index: 100;\r\n }\r\n\r\n .color-picker-float {\r\n position: absolute;\r\n\r\n .color-picker-container {\r\n width: 200px;\r\n }\r\n }\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},2685:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(3234),o=r.n(n),s=r(7474),a=r.n(s)()(o());a.push([e.id,'#bottom-bar{display:grid;grid-template-rows:100%;grid-template-columns:10px 210px 10px 1fr 10px 61px 10px}#bottom-bar #bottom-bar-total{grid-row:1;grid-column:6;color:#fff;background:#222;height:25px;align-self:center;font-size:12pt}#bottom-bar #bottom-bar-total #clip-range{width:100%}#bottom-bar .control-button .control-button-image{display:unset}#bottom-bar .control-button .control-button-hover-image{display:none}#bottom-bar .control-button:hover{cursor:pointer}#bottom-bar .control-button:hover .control-button-image{display:none}#bottom-bar .control-button:hover .control-button-hover-image{display:unset}#bottom-bar .control-button:active{transform-origin:50% 50%;transform:scale(0.96)}#bottom-bar #media-player{grid-row:1;grid-column:2;display:grid;align-self:center;justify-self:center;grid-template-rows:100%;grid-template-columns:23px 23px 23px 23px 23px 23px 23px}#bottom-bar #media-player #start-key{grid-row:1;grid-column:1}#bottom-bar #media-player #prev-frame{grid-row:1;grid-column:2}#bottom-bar #media-player #first-key{grid-row:1;grid-column:3}#bottom-bar #media-player #rev-key{grid-row:1;grid-column:4}#bottom-bar #media-player #fwd-key{grid-row:1;grid-column:5}#bottom-bar #media-player #next-key{grid-row:1;grid-column:6}#bottom-bar #media-player #next-frame{grid-row:1;grid-column:7}#bottom-bar #media-player #end-key{grid-row:1;grid-column:8}#bottom-bar #range-selector{grid-row:1;grid-column:4;background:#222;width:100%;height:calc(100% - 20px);margin:10px 0;position:relative}#bottom-bar #range-selector #range-scrollbar{position:absolute;left:2px;top:2px;right:2px;bottom:2px;background:#666;display:grid;grid-template-rows:100%;grid-template-columns:20px auto 1fr auto 20px;color:#222;font-family:"acumin-pro-condensed";font-size:14px;min-width:70px}#bottom-bar #range-selector #range-scrollbar #left-handle{grid-row:1;grid-column:1}#bottom-bar #range-selector #range-scrollbar #right-handle{grid-row:1;grid-column:5}#bottom-bar #range-selector #range-scrollbar #from-key{grid-row:1;grid-column:2;align-self:center;justify-self:center;user-select:none;pointer-events:none}#bottom-bar #range-selector #range-scrollbar #to-key{grid-row:1;grid-column:4;align-self:center;justify-self:center;user-select:none;pointer-events:none}#bottom-bar #range-selector #range-scrollbar .handle{width:20px;align-self:center;justify-self:center;cursor:pointer;user-select:none}#bottom-bar #range-selector #range-scrollbar .handle img{pointer-events:none}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/propertyGrids/animations/curveEditor/scss/bottomBar.scss"],names:[],mappings:"AAAA,YACI,YAAA,CACA,uBAAA,CACA,wDAAA,CAEA,8BACI,UAAA,CACA,aAAA,CACA,UAAA,CACA,eAAA,CACA,WAAA,CACA,iBAAA,CACA,cAAA,CAEA,0CACI,UAAA,CAKJ,kDACI,aAAA,CAGJ,wDACI,YAAA,CAGJ,kCACI,cAAA,CAEA,wDACI,YAAA,CAGJ,8DACI,aAAA,CAIR,mCACI,wBAAA,CACA,qBAAA,CAIR,0BACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,iBAAA,CACA,mBAAA,CACA,uBAAA,CACA,wDAAA,CAEA,qCACI,UAAA,CACA,aAAA,CAGJ,sCACI,UAAA,CACA,aAAA,CAGJ,qCACI,UAAA,CACA,aAAA,CAGJ,mCACI,UAAA,CACA,aAAA,CAGJ,mCACI,UAAA,CACA,aAAA,CAGJ,oCACI,UAAA,CACA,aAAA,CAGJ,sCACI,UAAA,CACA,aAAA,CAGJ,mCACI,UAAA,CACA,aAAA,CAIR,4BACI,UAAA,CACA,aAAA,CACA,eAAA,CACA,UAAA,CACA,wBAAA,CACA,aAAA,CACA,iBAAA,CAEA,6CACI,iBAAA,CACA,QAAA,CACA,OAAA,CACA,SAAA,CACA,UAAA,CACA,eAAA,CACA,YAAA,CACA,uBAAA,CACA,6CAAA,CACA,UAAA,CACA,kCAAA,CACA,cAAA,CACA,cAAA,CAEA,0DACI,UAAA,CACA,aAAA,CAGJ,2DACI,UAAA,CACA,aAAA,CAGJ,uDACI,UAAA,CACA,aAAA,CACA,iBAAA,CACA,mBAAA,CACA,gBAAA,CACA,mBAAA,CAGJ,qDACI,UAAA,CACA,aAAA,CACA,iBAAA,CACA,mBAAA,CACA,gBAAA,CACA,mBAAA,CAGJ,qDACI,UAAA,CACA,iBAAA,CACA,mBAAA,CACA,cAAA,CACA,gBAAA,CAEA,yDACI,mBAAA",sourcesContent:['#bottom-bar {\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 10px 210px 10px 1fr 10px 61px 10px;\r\n\r\n #bottom-bar-total {\r\n grid-row: 1;\r\n grid-column: 6;\r\n color: white;\r\n background: #222222;\r\n height: 25px;\r\n align-self: center;\r\n font-size: 12pt;\r\n\r\n #clip-range {\r\n width: 100%;\r\n }\r\n }\r\n\r\n .control-button {\r\n .control-button-image {\r\n display: unset;\r\n }\r\n\r\n .control-button-hover-image {\r\n display: none;\r\n }\r\n\r\n &:hover {\r\n cursor: pointer;\r\n\r\n .control-button-image {\r\n display: none;\r\n }\r\n\r\n .control-button-hover-image {\r\n display: unset;\r\n }\r\n }\r\n\r\n &:active {\r\n transform-origin: 50% 50%;\r\n transform: scale(0.96);\r\n }\r\n }\r\n\r\n #media-player {\r\n grid-row: 1;\r\n grid-column: 2;\r\n display: grid;\r\n align-self: center;\r\n justify-self: center;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 23px 23px 23px 23px 23px 23px 23px;\r\n\r\n #start-key {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n #prev-frame {\r\n grid-row: 1;\r\n grid-column: 2;\r\n }\r\n\r\n #first-key {\r\n grid-row: 1;\r\n grid-column: 3;\r\n }\r\n\r\n #rev-key {\r\n grid-row: 1;\r\n grid-column: 4;\r\n }\r\n\r\n #fwd-key {\r\n grid-row: 1;\r\n grid-column: 5;\r\n }\r\n\r\n #next-key {\r\n grid-row: 1;\r\n grid-column: 6;\r\n }\r\n\r\n #next-frame {\r\n grid-row: 1;\r\n grid-column: 7;\r\n }\r\n\r\n #end-key {\r\n grid-row: 1;\r\n grid-column: 8;\r\n }\r\n }\r\n\r\n #range-selector {\r\n grid-row: 1;\r\n grid-column: 4;\r\n background: #222222;\r\n width: 100%;\r\n height: calc(100% - 20px);\r\n margin: 10px 0;\r\n position: relative;\r\n\r\n #range-scrollbar {\r\n position: absolute;\r\n left: 2px;\r\n top: 2px;\r\n right: 2px;\r\n bottom: 2px;\r\n background: #666666;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 20px auto 1fr auto 20px;\r\n color: #222222;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 14px;\r\n min-width: 70px;\r\n\r\n #left-handle {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n #right-handle {\r\n grid-row: 1;\r\n grid-column: 5;\r\n }\r\n\r\n #from-key {\r\n grid-row: 1;\r\n grid-column: 2;\r\n align-self: center;\r\n justify-self: center;\r\n user-select: none;\r\n pointer-events: none;\r\n }\r\n\r\n #to-key {\r\n grid-row: 1;\r\n grid-column: 4;\r\n align-self: center;\r\n justify-self: center;\r\n user-select: none;\r\n pointer-events: none;\r\n }\r\n\r\n .handle {\r\n width: 20px;\r\n align-self: center;\r\n justify-self: center;\r\n cursor: pointer;\r\n user-select: none;\r\n\r\n img {\r\n pointer-events: none;\r\n }\r\n }\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},7159:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(3234),o=r.n(n),s=r(7474),a=r.n(s)()(o());a.push([e.id,'#canvas-zone{display:grid;grid-template-columns:100%;grid-template-rows:30px 1fr 10px 40px;overflow:hidden;position:relative}#canvas-zone #graph{grid-column:1;grid-row:2;width:100%;height:100%;background:#222;display:grid;grid-template-columns:100%;grid-template-rows:100%;overflow:hidden;position:relative}#canvas-zone #graph #svg-graph-grid{grid-column:1;grid-row:1;width:100%;height:100%;pointer-events:none;z-index:1}#canvas-zone #graph #svg-graph-grid:focus{outline:none}#canvas-zone #graph #svg-graph-horizontal{grid-column:1;grid-row:1;margin-left:40px;width:calc(100% - 40px);height:100%;pointer-events:none;z-index:1}#canvas-zone #graph #svg-graph-horizontal:focus{outline:none}#canvas-zone #graph #dark-rectangle{grid-column:1;grid-row:1;margin-left:40px;width:calc(100% - 40px);height:100%;background:#111;opacity:.2;pointer-events:none;position:absolute}#canvas-zone #graph #block-rectangle{grid-column:1;grid-row:1;width:40px;height:100%;background:#222;z-index:1}#canvas-zone #graph #svg-graph-curves{grid-column:1;grid-row:1;margin-left:40px;width:calc(100% - 40px);height:100%;z-index:2}#canvas-zone #graph #svg-graph-curves:focus{outline:none}#canvas-zone #graph #selection-rectangle{grid-column:1;grid-row:1;width:calc(100% - 40px);height:100%;pointer-events:none;position:absolute;left:40px;visibility:hidden;border:1px dashed #fff}#canvas-zone #range-frame-bar{grid-column:1;grid-row:4;width:100%;height:100%;background:#222;pointer-events:none;display:grid;grid-template-rows:100%;grid-template-columns:100%;pointer-events:none;user-select:none}#canvas-zone #range-frame-bar #svg-range-frames{grid-column:1;grid-row:1;width:100%;height:100%}#canvas-zone #frame-bar{grid-column:1;grid-row:1;width:100%;height:100%;background:#222;pointer-events:none;display:grid;grid-template-rows:100%;grid-template-columns:40px 1fr}#canvas-zone #frame-bar #angle-unit{grid-column:1;grid-row:1;background:#111}#canvas-zone #frame-bar #frames{grid-column:1/3;grid-row:1;width:100%;height:100%;display:grid;grid-template-rows:100%;grid-template-columns:100%}#canvas-zone #frame-bar #frames #svg-frames{margin-left:40px;grid-column:1;grid-row:1;width:calc(100% - 40px);height:100%}#canvas-zone #play-head-control{grid-column:1;grid-row:1;position:absolute;height:30px;left:40px;width:calc(100% - 40px)}#canvas-zone #play-head-control-2{grid-column:1;grid-row:4;position:absolute;height:30px;left:0px;width:100%}#canvas-zone #play-head{grid-column:1;grid-row:1/3;position:absolute;top:0;height:calc(100% - 5px);width:22px;margin-left:40px;display:grid;grid-template-columns:100%;grid-template-rows:22px 1fr;transform:translateX(-50%);pointer-events:none;z-index:3}#canvas-zone #play-head #play-head-bar{grid-row:2;grid-column:1;justify-self:center;width:1.5px;background:#fff;height:100%;pointer-events:none}#canvas-zone #play-head #play-head-circle{grid-row:1;grid-column:1;width:22px;height:22px;border-radius:50%;background:#fff;font-family:"acumin-pro-condensed";font-size:8pt;display:grid;align-content:center;justify-content:center;color:#555;cursor:pointer}#canvas-zone #angle-mode{grid-column:1;grid-row:1;width:40px;height:100%;z-index:1;background:#222}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/propertyGrids/animations/curveEditor/scss/canvas.scss"],names:[],mappings:"AAAA,aACI,YAAA,CACA,0BAAA,CACA,qCAAA,CACA,eAAA,CACA,iBAAA,CAEA,oBACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CACA,eAAA,CACA,YAAA,CACA,0BAAA,CACA,uBAAA,CACA,eAAA,CACA,iBAAA,CAEA,oCACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CACA,mBAAA,CAKA,SAAA,CAHA,0CACI,YAAA,CAKR,0CACI,aAAA,CACA,UAAA,CACA,gBAAA,CACA,uBAAA,CACA,WAAA,CACA,mBAAA,CAKA,SAAA,CAHA,gDACI,YAAA,CAKR,oCACI,aAAA,CACA,UAAA,CACA,gBAAA,CACA,uBAAA,CACA,WAAA,CACA,eAAA,CACA,UAAA,CACA,mBAAA,CACA,iBAAA,CAGJ,qCACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CACA,eAAA,CACA,SAAA,CAGJ,sCACI,aAAA,CACA,UAAA,CACA,gBAAA,CACA,uBAAA,CACA,WAAA,CACA,SAAA,CAEA,4CACI,YAAA,CAIR,yCACI,aAAA,CACA,UAAA,CACA,uBAAA,CACA,WAAA,CACA,mBAAA,CACA,iBAAA,CACA,SAAA,CACA,iBAAA,CAEA,sBAAA,CAIR,8BACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CACA,eAAA,CACA,mBAAA,CACA,YAAA,CACA,uBAAA,CACA,0BAAA,CACA,mBAAA,CACA,gBAAA,CAEA,gDACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CAIR,wBACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CACA,eAAA,CACA,mBAAA,CAEA,YAAA,CACA,uBAAA,CACA,8BAAA,CAEA,oCACI,aAAA,CACA,UAAA,CACA,eAAA,CAGJ,gCACI,eAAA,CAEA,UAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,uBAAA,CACA,0BAAA,CAEA,4CACI,gBAAA,CACA,aAAA,CACA,UAAA,CACA,uBAAA,CACA,WAAA,CAKZ,gCACI,aAAA,CACA,UAAA,CACA,iBAAA,CACA,WAAA,CACA,SAAA,CACA,uBAAA,CAGJ,kCACI,aAAA,CACA,UAAA,CACA,iBAAA,CACA,WAAA,CACA,QAAA,CACA,UAAA,CAGJ,wBACI,aAAA,CACA,YAAA,CACA,iBAAA,CACA,KAAA,CACA,uBAAA,CACA,UAAA,CACA,gBAAA,CACA,YAAA,CACA,0BAAA,CACA,2BAAA,CACA,0BAAA,CACA,mBAAA,CACA,SAAA,CAEA,uCACI,UAAA,CACA,aAAA,CACA,mBAAA,CACA,WAAA,CACA,eAAA,CACA,WAAA,CACA,mBAAA,CAGJ,0CACI,UAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CACA,iBAAA,CACA,eAAA,CACA,kCAAA,CACA,aAAA,CACA,YAAA,CACA,oBAAA,CACA,sBAAA,CACA,UAAA,CACA,cAAA,CAIR,yBACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CACA,SAAA,CACA,eAAA",sourcesContent:['#canvas-zone {\r\n display: grid;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 30px 1fr 10px 40px;\r\n overflow: hidden;\r\n position: relative;\r\n\r\n #graph {\r\n grid-column: 1;\r\n grid-row: 2;\r\n width: 100%;\r\n height: 100%;\r\n background: #222222;\r\n display: grid;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 100%;\r\n overflow: hidden;\r\n position: relative;\r\n\r\n #svg-graph-grid {\r\n grid-column: 1;\r\n grid-row: 1;\r\n width: 100%;\r\n height: 100%;\r\n pointer-events: none;\r\n\r\n &:focus {\r\n outline: none;\r\n }\r\n z-index: 1;\r\n }\r\n\r\n #svg-graph-horizontal {\r\n grid-column: 1;\r\n grid-row: 1;\r\n margin-left: 40px;\r\n width: calc(100% - 40px);\r\n height: 100%;\r\n pointer-events: none;\r\n\r\n &:focus {\r\n outline: none;\r\n }\r\n z-index: 1;\r\n }\r\n\r\n #dark-rectangle {\r\n grid-column: 1;\r\n grid-row: 1;\r\n margin-left: 40px;\r\n width: calc(100% - 40px);\r\n height: 100%;\r\n background: #111111;\r\n opacity: 0.2;\r\n pointer-events: none;\r\n position: absolute;\r\n }\r\n\r\n #block-rectangle {\r\n grid-column: 1;\r\n grid-row: 1;\r\n width: 40px;\r\n height: 100%;\r\n background: #222222;\r\n z-index: 1;\r\n }\r\n\r\n #svg-graph-curves {\r\n grid-column: 1;\r\n grid-row: 1;\r\n margin-left: 40px;\r\n width: calc(100% - 40px);\r\n height: 100%;\r\n z-index: 2;\r\n\r\n &:focus {\r\n outline: none;\r\n }\r\n }\r\n\r\n #selection-rectangle {\r\n grid-column: 1;\r\n grid-row: 1;\r\n width: calc(100% - 40px);\r\n height: 100%;\r\n pointer-events: none;\r\n position: absolute;\r\n left: 40px;\r\n visibility: hidden;\r\n\r\n border: 1px dashed white;\r\n }\r\n }\r\n\r\n #range-frame-bar {\r\n grid-column: 1;\r\n grid-row: 4;\r\n width: 100%;\r\n height: 100%;\r\n background: #222222;\r\n pointer-events: none;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 100%;\r\n pointer-events: none;\r\n user-select: none;\r\n\r\n #svg-range-frames {\r\n grid-column: 1;\r\n grid-row: 1;\r\n width: 100%;\r\n height: 100%;\r\n }\r\n }\r\n\r\n #frame-bar {\r\n grid-column: 1;\r\n grid-row: 1;\r\n width: 100%;\r\n height: 100%;\r\n background: #222222;\r\n pointer-events: none;\r\n\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 40px 1fr;\r\n\r\n #angle-unit {\r\n grid-column: 1;\r\n grid-row: 1;\r\n background: #111111;\r\n }\r\n\r\n #frames {\r\n grid-column: 1 / 3;\r\n\r\n grid-row: 1;\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 100%;\r\n\r\n #svg-frames {\r\n margin-left: 40px;\r\n grid-column: 1;\r\n grid-row: 1;\r\n width: calc(100% - 40px);\r\n height: 100%;\r\n }\r\n }\r\n }\r\n\r\n #play-head-control {\r\n grid-column: 1;\r\n grid-row: 1;\r\n position: absolute;\r\n height: 30px;\r\n left: 40px;\r\n width: calc(100% - 40px);\r\n }\r\n\r\n #play-head-control-2 {\r\n grid-column: 1;\r\n grid-row: 4;\r\n position: absolute;\r\n height: 30px;\r\n left: 0px;\r\n width: 100%;\r\n }\r\n\r\n #play-head {\r\n grid-column: 1;\r\n grid-row: 1 / 3;\r\n position: absolute;\r\n top: 0;\r\n height: calc(100% - 5px);\r\n width: 22px;\r\n margin-left: 40px;\r\n display: grid;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 22px 1fr;\r\n transform: translateX(-50%);\r\n pointer-events: none;\r\n z-index: 3;\r\n\r\n #play-head-bar {\r\n grid-row: 2;\r\n grid-column: 1;\r\n justify-self: center;\r\n width: 1.5px;\r\n background: #ffffff;\r\n height: 100%;\r\n pointer-events: none;\r\n }\r\n\r\n #play-head-circle {\r\n grid-row: 1;\r\n grid-column: 1;\r\n width: 22px;\r\n height: 22px;\r\n border-radius: 50%;\r\n background: #ffffff;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 8pt;\r\n display: grid;\r\n align-content: center;\r\n justify-content: center;\r\n color: #555555;\r\n cursor: pointer;\r\n }\r\n }\r\n\r\n #angle-mode {\r\n grid-column: 1;\r\n grid-row: 1;\r\n width: 40px;\r\n height: 100%;\r\n z-index: 1;\r\n background: #222222;\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},2667:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(3234),o=r.n(n),s=r(7474),a=r.n(s)()(o());a.push([e.id,'#curve-editor{background:#333;width:100%;height:100%;display:grid;grid-template-rows:40px calc(100% - 85px) 45px;grid-template-columns:10px 210px 10px 1fr 10px}#curve-editor #top-bar{background:#333;grid-row:1;grid-column:1/6;width:100%;height:100%}#curve-editor #bottom-bar{background:#333;grid-row:3;grid-column:1/6;width:100%;height:100%}#curve-editor #canvas-zone{grid-row:2;grid-column:4;width:100%;height:100%;background:#333}#curve-editor #sidebar{grid-row:2;grid-column:2;width:100%;height:100%;background:#111}#curve-editor .action-button:hover{background:#666;color:#fff;cursor:pointer}#curve-editor .action-button.active{background:#111}#curve-editor .action-button:active{transform-origin:50% 50%;transform:scale(0.96)}#curve-editor .push-button{cursor:pointer}#curve-editor .push-button.active{background:#666}#curve-editor .text-input{color:#fff;background:#000;font-family:"acumin-pro-condensed";font-size:11pt;border:0;margin:3px 1px;text-align:end;padding-right:4px}#curve-editor .text-input:focus{outline:none}#curve-editor .text-input:disabled{background:#444;border:#555 solid 1px}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/propertyGrids/animations/curveEditor/scss/curveEditor.scss"],names:[],mappings:"AAAA,cACI,eAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,8CAAA,CACA,8CAAA,CAEA,uBACI,eAAA,CACA,UAAA,CACA,eAAA,CACA,UAAA,CACA,WAAA,CAGJ,0BACI,eAAA,CACA,UAAA,CACA,eAAA,CACA,UAAA,CACA,WAAA,CAGJ,2BACI,UAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CACA,eAAA,CAGJ,uBACI,UAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CACA,eAAA,CAIA,mCACI,eAAA,CACA,UAAA,CACA,cAAA,CAGJ,oCACI,eAAA,CAGJ,oCACI,wBAAA,CACA,qBAAA,CAIR,2BACI,cAAA,CACA,kCACI,eAAA,CAIR,0BACI,UAAA,CACA,eAAA,CACA,kCAAA,CACA,cAAA,CACA,QAAA,CACA,cAAA,CACA,cAAA,CACA,iBAAA,CAEA,gCACI,YAAA,CAGJ,mCACI,eAAA,CACA,qBAAA",sourcesContent:['#curve-editor {\r\n background: #333333;\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-rows: 40px calc(100% - 85px) 45px;\r\n grid-template-columns: 10px 210px 10px 1fr 10px;\r\n\r\n #top-bar {\r\n background: #333333;\r\n grid-row: 1;\r\n grid-column: 1 / 6;\r\n width: 100%;\r\n height: 100%;\r\n }\r\n\r\n #bottom-bar {\r\n background: #333333;\r\n grid-row: 3;\r\n grid-column: 1 / 6;\r\n width: 100%;\r\n height: 100%;\r\n }\r\n\r\n #canvas-zone {\r\n grid-row: 2;\r\n grid-column: 4;\r\n width: 100%;\r\n height: 100%;\r\n background: #333333;\r\n }\r\n\r\n #sidebar {\r\n grid-row: 2;\r\n grid-column: 2;\r\n width: 100%;\r\n height: 100%;\r\n background: #111111;\r\n }\r\n\r\n .action-button {\r\n &:hover {\r\n background: #666666;\r\n color: white;\r\n cursor: pointer;\r\n }\r\n\r\n &.active {\r\n background: #111111;\r\n }\r\n\r\n &:active {\r\n transform-origin: 50% 50%;\r\n transform: scale(0.96);\r\n }\r\n }\r\n\r\n .push-button {\r\n cursor: pointer;\r\n &.active {\r\n background: #666666;\r\n }\r\n }\r\n\r\n .text-input {\r\n color: white;\r\n background: #000000;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 11pt;\r\n border: 0;\r\n margin: 3px 1px;\r\n text-align: end;\r\n padding-right: 4px;\r\n\r\n &:focus {\r\n outline: none;\r\n }\r\n\r\n &:disabled {\r\n background: #444444;\r\n border: #555555 solid 1px;\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},9465:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(3234),o=r.n(n),s=r(7474),a=r.n(s)()(o());a.push([e.id,'#sideBar{display:grid;grid-template-columns:100%;grid-template-rows:30px 1fr}#sideBar #menu-bar{background:#252525;grid-row:1;grid-column:1;width:100%;height:100%;display:grid;grid-template-rows:100%;grid-template-columns:30px 30px 30px 30px 1fr 52px 3px}#sideBar #menu-bar.small{grid-template-columns:0px 0px 30px 30px 1fr 52px 3px}#sideBar #menu-bar #add-animation{grid-row:1;grid-column:1}#sideBar #menu-bar #load-animation{grid-row:1;grid-column:2}#sideBar #menu-bar #save-animation{grid-row:1;grid-column:3}#sideBar #menu-bar #edit-animation{grid-row:1;grid-column:4}#sideBar #menu-bar #framerate-animation{grid-row:1;grid-column:6}#sideBar .simple-button{width:80px;height:20px;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt;background:#444;border:0;line-height:12px;cursor:pointer;align-self:center;justify-self:center;border-radius:0}#sideBar .simple-button:active{transform-origin:center;transform:scale(0.95)}#sideBar #save-animation-pane{width:100%;height:100%;display:grid;grid-template-columns:100%;grid-template-rows:1fr 40px auto}#sideBar #save-animation-pane #save-animation-list{grid-row:1;grid-column:1;width:100%;height:100%;display:flex;flex-direction:column;padding-top:5px}#sideBar #save-animation-pane #save-animation-list .save-animation-list-entry{height:20px;margin-left:10px;display:flex;align-content:center;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt;line-height:15px}#sideBar #save-animation-pane #save-animation-buttons{grid-row:2;grid-column:1;width:100%;height:100%;display:grid;grid-template-rows:100%;grid-template-columns:10px 1fr 10px 1fr 10px;align-items:center}#sideBar #save-animation-pane #save-animation-buttons #save-snippet{grid-row:1;grid-column:2}#sideBar #save-animation-pane #save-animation-buttons #save-file{grid-row:1;grid-column:4}#sideBar #save-animation-pane #save-animation-snippet{grid-row:3;grid-column:1;width:calc(100% - 31px);height:20px;align-content:center;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt;padding-left:31px;background:#252525}#sideBar #load-animation-pane{width:100%;height:100%;display:grid;grid-template-columns:75px 1fr;grid-template-rows:10px 20px 10px 20px 10px 20px 1fr auto;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt}#sideBar #load-animation-pane #load-animation-snippet-id-label{grid-row:2;grid-column:1;justify-self:end;margin-right:10px}#sideBar #load-animation-pane #load-animation-local-file-label{grid-row:6;grid-column:1;justify-self:end;margin-right:10px}#sideBar #load-animation-pane #load-snippet-id{grid-row:2;grid-column:2;margin-right:10px;border:0;background:#252525;width:127px;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt}#sideBar #load-animation-pane #load-snippet{grid-row:4;grid-column:2;width:60px;justify-self:left}#sideBar #load-animation-pane input[type=file]{display:none}#sideBar #load-animation-pane #file-snippet-label{grid-row:6;grid-column:2;width:60px;justify-self:left;text-align:center;line-height:18px}#sideBar #load-animation-pane #load-animation-snippet{grid-row:8;grid-column:1/3;width:calc(100% - 31px);height:20px;align-content:center;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt;padding-left:31px;background:#252525}#sideBar #add-animation-pane{grid-column:1;grid-row:2;width:100%;height:100%;display:grid;grid-template-columns:75px 1fr;grid-template-rows:10px 20px 10px 20px 10px 20px 10px 20px 10px 20px 10px 20px 1fr;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt}#sideBar #add-animation-pane .input-text{border:0;background:#252525;width:127px;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt}#sideBar #add-animation-pane .option{background:#252525;color:#fff;border:0}#sideBar #add-animation-pane #add-animation-display-name-label{grid-row:2;grid-column:1;justify-self:end;margin-right:10px}#sideBar #add-animation-pane #add-animation-mode-label{grid-row:4;grid-column:1;justify-self:end;margin-right:10px}#sideBar #add-animation-pane #add-animation-property-label{grid-row:6;grid-column:1;justify-self:end;margin-right:10px}#sideBar #add-animation-pane #add-animation-type-label{grid-row:8;grid-column:1;justify-self:end;margin-right:10px}#sideBar #add-animation-pane #add-animation-loop-mode-label{grid-row:10;grid-column:1;justify-self:end;margin-right:10px}#sideBar #add-animation-pane #add-animation-name{grid-row:2;grid-column:2;margin-right:10px}#sideBar #add-animation-pane #add-animation-mode{grid-row:4;grid-column:2;margin-right:10px;width:calc(100% - 10px)}#sideBar #add-animation-pane #add-animation-property{grid-row:6;grid-column:2;margin-right:10px;width:calc(100% - 10px)}#sideBar #add-animation-pane #add-animation-type{grid-row:8;grid-column:2;margin-right:10px}#sideBar #add-animation-pane #add-animation-loop-mode{grid-row:10;grid-column:2;margin-right:10px}#sideBar #add-animation-pane #add-animation{grid-row:12;grid-column:2;justify-self:left}#sideBar #edit-animation-pane{grid-column:1;grid-row:2;width:100%;height:100%;display:grid;grid-template-columns:75px 1fr;grid-template-rows:10px 20px 10px 20px 10px 20px 10px 20px 1fr;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt;background:#111}#sideBar #edit-animation-pane .input-text{border:0;background:#252525;width:127px;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt}#sideBar #edit-animation-pane .option{background:#252525;color:#fff;border:0}#sideBar #edit-animation-pane #edit-animation-display-name-label{grid-row:2;grid-column:1;justify-self:end;margin-right:10px}#sideBar #edit-animation-pane #edit-animation-property-label{grid-row:4;grid-column:1;justify-self:end;margin-right:10px}#sideBar #edit-animation-pane #edit-animation-loop-mode-label{grid-row:6;grid-column:1;justify-self:end;margin-right:10px}#sideBar #edit-animation-pane #edit-animation-name{grid-row:2;grid-column:2;margin-right:10px}#sideBar #edit-animation-pane #edit-animation-property{grid-row:4;grid-column:2;margin-right:10px}#sideBar #edit-animation-pane #edit-animation-loop-mode{grid-row:6;grid-column:2;margin-right:10px}#sideBar #edit-animation-pane #edit-animation{grid-row:8;grid-column:1/3;display:grid;grid-template-columns:50% 50%;grid-template-rows:100%}#sideBar #edit-animation-pane #edit-animation #edit-animation-ok{grid-row:1;grid-column:1}#sideBar #edit-animation-pane #edit-animation #edit-animation-cancel{grid-row:1;grid-column:2}#sideBar #animation-list{background:#111;grid-row:2;grid-column:1;width:100%;height:100%}#sideBar #animation-list .animation-entry{height:20px;display:grid;grid-template-columns:20px 10px 1fr 20px 20px;grid-template-rows:100%}#sideBar #animation-list .animation-entry.isActive{background:#444}#sideBar #animation-list .animation-entry .animation-active-indicator{grid-row:1;grid-column:1;display:grid;margin:5px;padding-top:2px}#sideBar #animation-list .animation-entry .animation-chevron{grid-row:1;grid-column:2;display:grid;align-content:center;padding-top:5px;cursor:pointer}#sideBar #animation-list .animation-entry .animation-chevron .animation-chevron-image.collapsed{transform-origin:50% 50%;transform:rotateZ(-90deg)}#sideBar #animation-list .animation-entry .animation-name{cursor:pointer;grid-row:1;grid-column:3;font-family:"acumin-pro-condensed";font-size:10.5pt;color:#fff;display:grid;align-self:center;margin-left:5px;user-select:none}#sideBar #animation-list .animation-entry .animation-options{grid-row:1;grid-column:4}#sideBar #animation-list .animation-entry .animation-delete{grid-row:1;grid-column:5}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/propertyGrids/animations/curveEditor/scss/sideBar.scss"],names:[],mappings:"AAAA,SACI,YAAA,CACA,0BAAA,CACA,2BAAA,CAEA,mBACI,kBAAA,CACA,UAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,uBAAA,CACA,sDAAA,CAEA,yBACI,oDAAA,CAGJ,kCACI,UAAA,CACA,aAAA,CAGJ,mCACI,UAAA,CACA,aAAA,CAGJ,mCACI,UAAA,CACA,aAAA,CAGJ,mCACI,UAAA,CACA,aAAA,CAGJ,wCACI,UAAA,CACA,aAAA,CAIR,wBACI,UAAA,CACA,WAAA,CACA,UAAA,CACA,kCAAA,CACA,cAAA,CACA,eAAA,CACA,QAAA,CACA,gBAAA,CACA,cAAA,CACA,iBAAA,CACA,mBAAA,CACA,eAAA,CAEA,+BACI,uBAAA,CACA,qBAAA,CAIR,8BACI,UAAA,CACA,WAAA,CACA,YAAA,CACA,0BAAA,CACA,gCAAA,CAEA,mDACI,UAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,C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UAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CAEA,0CACI,WAAA,CACA,YAAA,CACA,6CAAA,CACA,uBAAA,CAEA,mDACI,eAAA,CAGJ,sEACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,UAAA,CACA,eAAA,CAGJ,6DACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,oBAAA,CACA,eAAA,CACA,cAAA,CAGI,gGACI,wBAAA,CACA,yBAAA,CAKZ,0DACI,cAAA,CACA,UAAA,CACA,aAAA,CACA,kCAAA,CACA,gBAAA,CACA,UAAA,CACA,YAAA,CACA,iBAAA,CACA,eAAA,CACA,gBAAA,CAGJ,6DACI,UAAA,CACA,aAAA,CAGJ,4DACI,UAAA,CACA,aAAA",sourcesContent:['#sideBar {\r\n display: grid;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 30px 1fr;\r\n\r\n #menu-bar {\r\n background: #252525;\r\n grid-row: 1;\r\n grid-column: 1;\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 30px 30px 30px 30px 1fr 52px 3px;\r\n\r\n &.small {\r\n grid-template-columns: 0px 0px 30px 30px 1fr 52px 3px;\r\n }\r\n\r\n #add-animation {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n #load-animation {\r\n grid-row: 1;\r\n grid-column: 2;\r\n }\r\n\r\n #save-animation {\r\n grid-row: 1;\r\n grid-column: 3;\r\n }\r\n\r\n #edit-animation {\r\n grid-row: 1;\r\n grid-column: 4;\r\n }\r\n\r\n #framerate-animation {\r\n grid-row: 1;\r\n grid-column: 6;\r\n }\r\n }\r\n\r\n .simple-button {\r\n width: 80px;\r\n height: 20px;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n background: #444444;\r\n border: 0;\r\n line-height: 12px;\r\n cursor: pointer;\r\n align-self: center;\r\n justify-self: center;\r\n border-radius: 0;\r\n\r\n &:active {\r\n transform-origin: center;\r\n transform: scale(0.95);\r\n }\r\n }\r\n\r\n #save-animation-pane {\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 1fr 40px auto;\r\n\r\n #save-animation-list {\r\n grid-row: 1;\r\n grid-column: 1;\r\n width: 100%;\r\n height: 100%;\r\n display: flex;\r\n flex-direction: column;\r\n padding-top: 5px;\r\n\r\n .save-animation-list-entry {\r\n height: 20px;\r\n margin-left: 10px;\r\n display: flex;\r\n align-content: center;\r\n color: white;\r\n\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n line-height: 15px;\r\n }\r\n }\r\n\r\n #save-animation-buttons {\r\n grid-row: 2;\r\n grid-column: 1;\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 10px 1fr 10px 1fr 10px;\r\n align-items: center;\r\n\r\n #save-snippet {\r\n grid-row: 1;\r\n grid-column: 2;\r\n }\r\n\r\n #save-file {\r\n grid-row: 1;\r\n grid-column: 4;\r\n }\r\n }\r\n\r\n #save-animation-snippet {\r\n grid-row: 3;\r\n grid-column: 1;\r\n width: calc(100% - 31px);\r\n height: 20px;\r\n align-content: center;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n padding-left: 31px;\r\n background: #252525;\r\n }\r\n }\r\n\r\n #load-animation-pane {\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-columns: 75px 1fr;\r\n grid-template-rows: 10px 20px 10px 20px 10px 20px 1fr auto;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n\r\n #load-animation-snippet-id-label {\r\n grid-row: 2;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #load-animation-local-file-label {\r\n grid-row: 6;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #load-snippet-id {\r\n grid-row: 2;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n border: 0;\r\n background: #252525;\r\n width: 127px;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n }\r\n\r\n #load-snippet {\r\n grid-row: 4;\r\n grid-column: 2;\r\n width: 60px;\r\n justify-self: left;\r\n }\r\n\r\n input[type="file"] {\r\n display: none;\r\n }\r\n\r\n #file-snippet-label {\r\n grid-row: 6;\r\n grid-column: 2;\r\n width: 60px;\r\n justify-self: left;\r\n text-align: center;\r\n line-height: 18px;\r\n }\r\n\r\n #load-animation-snippet {\r\n grid-row: 8;\r\n grid-column: 1 / 3;\r\n width: calc(100% - 31px);\r\n height: 20px;\r\n align-content: center;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n padding-left: 31px;\r\n background: #252525;\r\n }\r\n }\r\n\r\n #add-animation-pane {\r\n grid-column: 1;\r\n grid-row: 2;\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-columns: 75px 1fr;\r\n grid-template-rows: 10px 20px 10px 20px 10px 20px 10px 20px 10px 20px 10px 20px 1fr;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n\r\n .input-text {\r\n border: 0;\r\n background: #252525;\r\n width: 127px;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n }\r\n\r\n .option {\r\n background: #252525;\r\n color: white;\r\n border: 0;\r\n }\r\n\r\n #add-animation-display-name-label {\r\n grid-row: 2;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation-mode-label {\r\n grid-row: 4;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation-property-label {\r\n grid-row: 6;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation-type-label {\r\n grid-row: 8;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation-loop-mode-label {\r\n grid-row: 10;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation-name {\r\n grid-row: 2;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation-mode {\r\n grid-row: 4;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n width: calc(100% - 10px);\r\n }\r\n\r\n #add-animation-property {\r\n grid-row: 6;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n width: calc(100% - 10px);\r\n }\r\n\r\n #add-animation-type {\r\n grid-row: 8;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation-loop-mode {\r\n grid-row: 10;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation {\r\n grid-row: 12;\r\n grid-column: 2;\r\n justify-self: left;\r\n }\r\n }\r\n\r\n #edit-animation-pane {\r\n grid-column: 1;\r\n grid-row: 2;\r\n\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-columns: 75px 1fr;\r\n grid-template-rows: 10px 20px 10px 20px 10px 20px 10px 20px 1fr;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n background: #111111;\r\n\r\n .input-text {\r\n border: 0;\r\n background: #252525;\r\n width: 127px;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n }\r\n\r\n .option {\r\n background: #252525;\r\n color: white;\r\n border: 0;\r\n }\r\n\r\n #edit-animation-display-name-label {\r\n grid-row: 2;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #edit-animation-property-label {\r\n grid-row: 4;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #edit-animation-loop-mode-label {\r\n grid-row: 6;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #edit-animation-name {\r\n grid-row: 2;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n }\r\n\r\n #edit-animation-property {\r\n grid-row: 4;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n }\r\n\r\n #edit-animation-loop-mode {\r\n grid-row: 6;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n }\r\n\r\n #edit-animation {\r\n grid-row: 8;\r\n grid-column: 1 / 3;\r\n display: grid;\r\n grid-template-columns: 50% 50%;\r\n grid-template-rows: 100%;\r\n\r\n #edit-animation-ok {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n #edit-animation-cancel {\r\n grid-row: 1;\r\n grid-column: 2;\r\n }\r\n }\r\n }\r\n\r\n #animation-list {\r\n background: #111111;\r\n grid-row: 2;\r\n grid-column: 1;\r\n width: 100%;\r\n height: 100%;\r\n\r\n .animation-entry {\r\n height: 20px;\r\n display: grid;\r\n grid-template-columns: 20px 10px 1fr 20px 20px;\r\n grid-template-rows: 100%;\r\n\r\n &.isActive {\r\n background: #444444;\r\n }\r\n\r\n .animation-active-indicator {\r\n grid-row: 1;\r\n grid-column: 1;\r\n display: grid;\r\n margin: 5px;\r\n padding-top: 2px;\r\n }\r\n\r\n .animation-chevron {\r\n grid-row: 1;\r\n grid-column: 2;\r\n display: grid;\r\n align-content: center;\r\n padding-top: 5px;\r\n cursor: pointer;\r\n\r\n .animation-chevron-image {\r\n &.collapsed {\r\n transform-origin: 50% 50%;\r\n transform: rotateZ(-90deg);\r\n }\r\n }\r\n }\r\n\r\n .animation-name {\r\n cursor: pointer;\r\n grid-row: 1;\r\n grid-column: 3;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10.5pt;\r\n color: white;\r\n display: grid;\r\n align-self: center;\r\n margin-left: 5px;\r\n user-select: none;\r\n }\r\n\r\n .animation-options {\r\n grid-row: 1;\r\n grid-column: 4;\r\n }\r\n\r\n .animation-delete {\r\n grid-row: 1;\r\n grid-column: 5;\r\n }\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},2063:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(3234),o=r.n(n),s=r(7474),a=r.n(s)()(o());a.push([e.id,'#top-bar{display:grid;grid-template-columns:40px 200px 75px 8px 75px 8px 40px 40px 40px 40px 40px 40px 40px 40px 1fr 40px;grid-template-rows:100%}#top-bar .disabled{opacity:20%;pointer-events:none}#top-bar #top-bar-logo{grid-row:1;grid-column:1}#top-bar #top-bar-parent-name{grid-row:1;grid-column:2;font-family:"acumin-pro-condensed";font-size:15pt;color:#fff;display:grid;align-content:center;padding-bottom:5px}#top-bar #key-frame{grid-row:1;grid-column:3;height:24px;display:grid;align-self:center}#top-bar #key-value{grid-row:1;grid-column:5;height:24px;display:grid;align-self:center}#top-bar #new-key{grid-row:1;grid-column:7}#top-bar #frame-canvas{grid-row:1;grid-column:8}#top-bar #flatten-tangent{grid-row:1;grid-column:9}#top-bar #linear-tangent{grid-row:1;grid-column:10}#top-bar #break-tangent{grid-row:1;grid-column:11}#top-bar #unify-tangent{grid-row:1;grid-column:12}#top-bar #step-tangent{grid-row:1;grid-column:13}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/propertyGrids/animations/curveEditor/scss/topBar.scss"],names:[],mappings:"AAAA,SACI,YAAA,CACA,mGAAA,CACA,uBAAA,CAEA,mBACI,WAAA,CACA,mBAAA,CAGJ,uBACI,UAAA,CACA,aAAA,CAGJ,8BACI,UAAA,CACA,aAAA,CACA,kCAAA,CACA,cAAA,CACA,UAAA,CACA,YAAA,CACA,oBAAA,CACA,kBAAA,CAGJ,oBACI,UAAA,CACA,aAAA,CACA,WAAA,CACA,YAAA,CACA,iBAAA,CAGJ,oBACI,UAAA,CACA,aAAA,CACA,WAAA,CACA,YAAA,CACA,iBAAA,CAGJ,kBACI,UAAA,CACA,aAAA,CAGJ,uBACI,UAAA,CACA,aAAA,CAGJ,0BACI,UAAA,CACA,aAAA,CAGJ,yBACI,UAAA,CACA,cAAA,CAGJ,wBACI,UAAA,CACA,cAAA,CAGJ,wBACI,UAAA,CACA,cAAA,CAGJ,uBACI,UAAA,CACA,cAAA",sourcesContent:['#top-bar {\r\n display: grid;\r\n grid-template-columns: 40px 200px 75px 8px 75px 8px 40px 40px 40px 40px 40px 40px 40px 40px 1fr 40px;\r\n grid-template-rows: 100%;\r\n\r\n .disabled {\r\n opacity: 20%;\r\n pointer-events: none;\r\n }\r\n\r\n #top-bar-logo {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n #top-bar-parent-name {\r\n grid-row: 1;\r\n grid-column: 2;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 15pt;\r\n color: white;\r\n display: grid;\r\n align-content: center;\r\n padding-bottom: 5px;\r\n }\r\n\r\n #key-frame {\r\n grid-row: 1;\r\n grid-column: 3;\r\n height: 24px;\r\n display: grid;\r\n align-self: center;\r\n }\r\n\r\n #key-value {\r\n grid-row: 1;\r\n grid-column: 5;\r\n height: 24px;\r\n display: grid;\r\n align-self: center;\r\n }\r\n\r\n #new-key {\r\n grid-row: 1;\r\n grid-column: 7;\r\n }\r\n\r\n #frame-canvas {\r\n grid-row: 1;\r\n grid-column: 8;\r\n }\r\n\r\n #flatten-tangent {\r\n grid-row: 1;\r\n grid-column: 9;\r\n }\r\n\r\n #linear-tangent {\r\n grid-row: 1;\r\n grid-column: 10;\r\n }\r\n\r\n #break-tangent {\r\n grid-row: 1;\r\n grid-column: 11;\r\n }\r\n\r\n #unify-tangent {\r\n grid-row: 1;\r\n grid-column: 12;\r\n }\r\n\r\n #step-tangent {\r\n grid-row: 1;\r\n grid-column: 13;\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},2181:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(3234),o=r.n(n),s=r(7474),a=r.n(s)()(o());a.push([e.id,'#texture-editor{height:100%;width:100%;color:#fff;background-color:#1e1e1e;font-family:"acumin-pro-condensed"}#texture-editor .icon{width:40px;height:40px}#texture-editor .icon.button{background-color:#333}#texture-editor .icon.button:hover{background-color:#4a4a4a;cursor:pointer}#texture-editor .icon.button.active{background-color:#666}#texture-editor .icon.button:active{background-color:#837c7c}#texture-editor .has-tooltip{display:inline-block}#texture-editor .has-tooltip .tooltip{visibility:hidden;background-color:#fff;z-index:1;position:absolute;opacity:0;transition:opacity .5s;line-height:normal;font-size:14px;padding:0px 5px;color:#000}#texture-editor .has-tooltip:hover .tooltip{visibility:visible;opacity:1}#texture-editor #properties{width:100%;height:40px;display:flex;align-items:center;font-size:12px;color:#fff;user-select:none;background-color:#333}#texture-editor #properties .tab{display:inline-flex;line-height:40px;height:40px;flex-shrink:0;flex-grow:0;border-right:2px solid #1e1e1e;background-color:#333}#texture-editor #properties #left{overflow:hidden;height:40px;flex-grow:1;flex-shrink:1;display:flex;flex-wrap:wrap}#texture-editor #properties #left #dimensions-tab form{display:flex}#texture-editor #properties #left #dimensions-tab label{margin-left:15px;font-size:15px;color:#afafaf}#texture-editor #properties #left #dimensions-tab label input{width:40px;height:24px;background-color:#000;color:#fff;border:0;font-size:12px;text-align:"left";font-family:"acumin-pro-condensed";font-size:15px;padding-left:8px}#texture-editor #properties #left #dimensions-tab label:last-of-type{margin-right:8px}#texture-editor #properties #right-tab{margin-right:0;flex-grow:0;flex-shrink:0}#texture-editor #properties #right-tab input[type=file]{display:none}#texture-editor #properties .pixel-data{width:45px;color:#afafaf;display:flex;justify-content:space-between;font-size:15px}#texture-editor #properties .pixel-data:first-of-type{margin-left:15px}#texture-editor #properties .pixel-data:last-of-type{padding-right:15px}#texture-editor #properties .pixel-data .value{display:inline-block;width:30px;color:#fff}#texture-editor #toolbar{position:absolute;top:60px;left:0;width:40px;display:flex;flex-direction:column;justify-content:left}#texture-editor #toolbar #tools{display:flex;flex-direction:column}#texture-editor #toolbar #add-tool{position:relative}#texture-editor #toolbar #add-tool #add-tool-popup{background-color:#333;width:348px;margin-left:40px;position:absolute;top:0px;height:40px;padding-left:4px;line-height:40px;user-select:none}#texture-editor #toolbar #add-tool #add-tool-popup button{background:#222;border:1px solid #337ab7;margin:5px 10px 5px 10px;color:#fff;padding:4px 5px;opacity:.9;cursor:pointer}#texture-editor #toolbar #color{margin-top:8px}#texture-editor #toolbar #color #active-color-bg{border-radius:50%;width:20px;height:20px;margin:10px;position:relative;background-image:linear-gradient(45deg, #808080 25%, transparent 25%),linear-gradient(-45deg, #808080 25%, transparent 25%),linear-gradient(45deg, transparent 75%, #808080 75%),linear-gradient(-45deg, transparent 75%, #808080 75%);background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0px}#texture-editor #toolbar #color #active-color{width:20px;height:20px;position:absolute;top:0;left:0;border-radius:50%}#texture-editor #toolbar #color-picker{position:absolute;margin-left:40px}#texture-editor #channels-bar{position:absolute;top:60px;right:0;width:80px;background:#666;user-select:none}#texture-editor #channels-bar .channel{color:#fff;border-bottom:2px solid #232323;width:80px;height:40px;font-size:16px;display:flex;align-items:center}#texture-editor #channels-bar .channel.uneditable{background:#333}#texture-editor #channels-bar .channel:hover{cursor:pointer}#texture-editor #channels-bar .channel:last-of-type{border-bottom:none}#texture-editor #canvas-ui{width:100%;height:calc(100% - 70px);outline:none}#texture-editor #tool-ui{background-color:#333;position:absolute;right:0;bottom:30px}#texture-editor #tool-ui label{display:flex;flex-direction:column;align-items:center}#texture-editor #tool-ui input[type=range]{background:#d3d3d3}#texture-editor #bottom-bar{height:30px;width:100%;background-color:#333;font-size:14px;user-select:none;line-height:30px;position:relative}#texture-editor #bottom-bar #file-url{left:30px;position:absolute}#texture-editor #bottom-bar #mip-level{right:30px;position:absolute}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/propertyGrids/materials/textures/textureEditor.scss"],names:[],mappings:"AAAA,gBACI,WAAA,CACA,UAAA,CACA,UAAA,CACA,wBAAA,CACA,kCAAA,CAEA,sBACI,UAAA,CACA,WAAA,CACA,6BACI,qBAAA,CACA,mCACI,wBAAA,CACA,cAAA,CAG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iDACI,iBAAA,CACA,UAAA,CACA,WAAA,CACA,WAAA,CACA,iBAAA,CACA,sOAAA,CAEA,yBAAA,CACA,mDACI,CAKR,8CACI,UAAA,CACA,WAAA,CACA,iBAAA,CACA,KAAA,CACA,MAAA,CACA,iBAAA,CAGR,uCACI,iBAAA,CACA,gBAAA,CAIR,8BACI,iBAAA,CACA,QAAA,CACA,OAAA,CACA,UAAA,CACA,eAAA,CAsBA,gBAAA,CArBA,uCACI,UAAA,CACA,+BAAA,CACA,UAAA,CACA,WAAA,CACA,cAAA,CACA,YAAA,CACA,kBAAA,CAEA,kDACI,eAAA,CAGJ,6CACI,cAAA,CAGJ,oDACI,kBAAA,CAMZ,2BACI,UAAA,CACA,wBAAA,CACA,YAAA,CAGJ,yBACI,qBAAA,CACA,iBAAA,CACA,OAAA,CACA,WAAA,CAEA,+BACI,YAAA,CACA,qBAAA,CACA,kBAAA,CAGJ,2CACI,kBAAA,CAIR,4BACI,WAAA,CACA,UAAA,CACA,qBAAA,CACA,cAAA,CACA,gBAAA,CACA,gBAAA,CACA,iBAAA,CACA,sCACI,SAAA,CACA,iBAAA,CAEJ,uCACI,UAAA,CACA,iBAAA",sourcesContent:['#texture-editor {\r\n height: 100%;\r\n width: 100%;\r\n color: white;\r\n background-color: #1e1e1e;\r\n font-family: "acumin-pro-condensed";\r\n\r\n .icon {\r\n width: 40px;\r\n height: 40px;\r\n &.button {\r\n background-color: #333333;\r\n &:hover {\r\n background-color: #4a4a4a;\r\n cursor: pointer;\r\n }\r\n // When the button is selected - className=\'active\'\r\n &.active {\r\n background-color: #666666;\r\n }\r\n // When the button is clicked\r\n &:active {\r\n background-color: #837c7c;\r\n }\r\n }\r\n }\r\n\r\n .has-tooltip {\r\n display: inline-block;\r\n .tooltip {\r\n visibility: hidden;\r\n background-color: rgb(255, 255, 255);\r\n z-index: 1;\r\n position: absolute;\r\n opacity: 0;\r\n transition: opacity 0.5s;\r\n line-height: normal;\r\n font-size: 14px;\r\n padding: 0px 5px;\r\n color: black;\r\n }\r\n\r\n &:hover .tooltip {\r\n visibility: visible;\r\n opacity: 1;\r\n }\r\n }\r\n\r\n #properties {\r\n width: 100%;\r\n height: 40px;\r\n\r\n display: flex;\r\n align-items: center;\r\n font-size: 12px;\r\n color: white;\r\n user-select: none;\r\n background-color: #333333;\r\n\r\n .tab {\r\n display: inline-flex;\r\n line-height: 40px;\r\n height: 40px;\r\n flex-shrink: 0;\r\n flex-grow: 0;\r\n border-right: 2px solid #1e1e1e;\r\n background-color: #333333;\r\n }\r\n #left {\r\n overflow: hidden;\r\n height: 40px;\r\n flex-grow: 1;\r\n flex-shrink: 1;\r\n display: flex;\r\n flex-wrap: wrap;\r\n #dimensions-tab {\r\n form {\r\n display: flex;\r\n }\r\n label {\r\n margin-left: 15px;\r\n font-size: 15px;\r\n color: #afafaf;\r\n input {\r\n width: 40px;\r\n height: 24px;\r\n background-color: #000000;\r\n color: #ffffff;\r\n border: 0;\r\n font-size: 12px;\r\n text-align: "left";\r\n font-family: "acumin-pro-condensed";\r\n font-size: 15px;\r\n padding-left: 8px;\r\n }\r\n\r\n &:last-of-type {\r\n margin-right: 8px;\r\n }\r\n }\r\n }\r\n }\r\n #right-tab {\r\n margin-right: 0;\r\n flex-grow: 0;\r\n flex-shrink: 0;\r\n\r\n input[type="file"] {\r\n display: none;\r\n }\r\n }\r\n\r\n .pixel-data {\r\n &:first-of-type {\r\n margin-left: 15px;\r\n }\r\n &:last-of-type {\r\n padding-right: 15px;\r\n }\r\n width: 45px;\r\n color: #afafaf;\r\n display: flex;\r\n justify-content: space-between;\r\n .value {\r\n display: inline-block;\r\n width: 30px;\r\n color: white;\r\n }\r\n font-size: 15px;\r\n }\r\n }\r\n\r\n #toolbar {\r\n position: absolute;\r\n top: 60px;\r\n left: 0;\r\n width: 40px;\r\n display: flex;\r\n flex-direction: column;\r\n justify-content: left;\r\n\r\n #tools {\r\n display: flex;\r\n flex-direction: column;\r\n }\r\n\r\n #add-tool {\r\n position: relative;\r\n #add-tool-popup {\r\n background-color: #333333;\r\n width: 348px;\r\n margin-left: 40px;\r\n position: absolute;\r\n top: 0px;\r\n height: 40px;\r\n padding-left: 4px;\r\n line-height: 40px;\r\n user-select: none;\r\n button {\r\n background: #222222;\r\n border: 1px solid rgb(51, 122, 183);\r\n margin: 5px 10px 5px 10px;\r\n color: white;\r\n padding: 4px 5px;\r\n opacity: 0.9;\r\n cursor: pointer;\r\n }\r\n }\r\n }\r\n\r\n #color {\r\n margin-top: 8px;\r\n #active-color-bg {\r\n border-radius: 50%;\r\n width: 20px;\r\n height: 20px;\r\n margin: 10px;\r\n position: relative;\r\n background-image: linear-gradient(45deg, #808080 25%, transparent 25%), linear-gradient(-45deg, #808080 25%, transparent 25%),\r\n linear-gradient(45deg, transparent 75%, #808080 75%), linear-gradient(-45deg, transparent 75%, #808080 75%);\r\n background-size: 20px 20px;\r\n background-position:\r\n 0 0,\r\n 0 10px,\r\n 10px -10px,\r\n -10px 0px;\r\n }\r\n #active-color {\r\n width: 20px;\r\n height: 20px;\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n border-radius: 50%;\r\n }\r\n }\r\n #color-picker {\r\n position: absolute;\r\n margin-left: 40px;\r\n }\r\n }\r\n\r\n #channels-bar {\r\n position: absolute;\r\n top: 60px;\r\n right: 0;\r\n width: 80px;\r\n background: #666666;\r\n .channel {\r\n color: white;\r\n border-bottom: 2px solid #232323;\r\n width: 80px;\r\n height: 40px;\r\n font-size: 16px;\r\n display: flex;\r\n align-items: center;\r\n\r\n &.uneditable {\r\n background: #333333;\r\n }\r\n\r\n &:hover {\r\n cursor: pointer;\r\n }\r\n\r\n &:last-of-type {\r\n border-bottom: none;\r\n }\r\n }\r\n user-select: none;\r\n }\r\n\r\n #canvas-ui {\r\n width: 100%;\r\n height: calc(100% - 70px);\r\n outline: none;\r\n }\r\n\r\n #tool-ui {\r\n background-color: #333;\r\n position: absolute;\r\n right: 0;\r\n bottom: 30px;\r\n\r\n label {\r\n display: flex;\r\n flex-direction: column;\r\n align-items: center;\r\n }\r\n\r\n input[type="range"] {\r\n background: #d3d3d3;\r\n }\r\n }\r\n\r\n #bottom-bar {\r\n height: 30px;\r\n width: 100%;\r\n background-color: #333333;\r\n font-size: 14px;\r\n user-select: none;\r\n line-height: 30px;\r\n position: relative;\r\n #file-url {\r\n left: 30px;\r\n position: absolute;\r\n }\r\n #mip-level {\r\n right: 30px;\r\n position: absolute;\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},8335:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(3234),o=r.n(n),s=r(7474),a=r.n(s)()(o());a.push([e.id,"#metadata-container textarea{display:block;margin:4px;width:calc(100% - 14px);min-height:100px;max-height:500px;resize:vertical}.meta-string textarea{background:#fe9}.meta-json textarea{background:#9df}.meta-object textarea{background:#d9f}.meta-object-protect textarea{background:#b0b0b0}.buttonLine.disabled{opacity:20%;pointer-events:none}.copy-root{display:grid;justify-content:end;height:30px}.copy-container{height:30px;width:30px;cursor:pointer}.hoverIcon:hover{opacity:.8}.type-status{padding:5px 15px}","",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/propertyGrids/metadata/metadataPropertyGrid.scss"],names:[],mappings:"AACI,6BACI,aAAA,CACA,UAAA,CACA,uBAAA,CACA,gBAAA,CACA,gBAAA,CACA,eAAA,CAKJ,sBACI,eAAA,CAKJ,oBACI,eAAA,CAKJ,sBACI,eAAA,CAKJ,8BACI,kBAAA,CAKJ,qBACI,WAAA,CACA,mBAAA,CAIR,WACI,YAAA,CACA,mBAAA,CACA,WAAA,CAGJ,gBACI,WAAA,CACA,UAAA,CACA,cAAA,CAGJ,iBACI,UAAA,CAGJ,aACI,gBAAA",sourcesContent:["#metadata-container {\r\n textarea {\r\n display: block;\r\n margin: 4px;\r\n width: calc(100% - 14px);\r\n min-height: 100px;\r\n max-height: 500px;\r\n resize: vertical;\r\n }\r\n}\r\n\r\n.meta-string {\r\n textarea {\r\n background: #ffee99;\r\n }\r\n}\r\n\r\n.meta-json {\r\n textarea {\r\n background: #99ddff;\r\n }\r\n}\r\n\r\n.meta-object {\r\n textarea {\r\n background: #dd99ff;\r\n }\r\n}\r\n\r\n.meta-object-protect {\r\n textarea {\r\n background: #b0b0b0;\r\n }\r\n}\r\n\r\n.buttonLine {\r\n &.disabled {\r\n opacity: 20%;\r\n pointer-events: none;\r\n }\r\n}\r\n\r\n.copy-root {\r\n display: grid;\r\n justify-content: end;\r\n height: 30px;\r\n}\r\n\r\n.copy-container {\r\n height: 30px;\r\n width: 30px;\r\n cursor: pointer;\r\n}\r\n\r\n.hoverIcon:hover {\r\n opacity: 0.8;\r\n}\r\n\r\n.type-status {\r\n padding: 5px 15px;\r\n}\r\n"],sourceRoot:""}]),a.locals={};const i=a},8555:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(3234),o=r.n(n),s=r(7474),a=r.n(s)()(o());a.push([e.id,'#embed-host{position:absolute;right:0px;top:0px;bottom:0px;z-index:10}#__resizable_base__{display:none}#embed{background:#333;height:100%;margin:0;padding:0;display:grid;grid-template-rows:30px 1fr;font:14px "Arial";overflow:hidden}#embed #header{font-size:16px;color:#fff;background:#222;grid-row:1;text-align:center;display:grid;grid-template-columns:30px 1fr 50px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#embed #header #logo{grid-column:1;width:24px;height:24px;display:flex;align-self:center;justify-self:center}#embed #header #back{grid-column:1;display:grid;align-self:center;justify-self:center;cursor:pointer}#embed #header #title{grid-column:2;display:grid;align-items:center;text-align:center}#embed #header #commands{grid-column:3;display:grid;align-items:center;grid-template-columns:1fr 1fr}#embed #header #commands .expand{grid-column:1;display:grid;align-items:center;justify-items:center;cursor:pointer}#embed #header #commands .close{grid-column:2;display:grid;align-items:center;justify-items:center;cursor:pointer}#embed #split{grid-row:2;overflow:hidden}#embed #split.splitPopup{display:grid;grid-template-rows:300px 2px 1fr}#embed #split.splitPopup .panes{margin-bottom:1px}#embed #split #topPart{grid-row:1;overflow:hidden;display:grid;grid-auto-rows:100%}#embed #split #separator{grid-row:2;background:#fff;opacity:.1}#embed #split #bottomPart{overflow:hidden;grid-row:3;display:grid;grid-auto-rows:100%}#embed #split .gutter.gutter-vertical{background-image:none;background:#444;cursor:row-resize}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/embedHost/embedHost.scss"],names:[],mappings:"AAAA,YACI,iBAAA,CACA,SAAA,CACA,OAAA,CACA,UAAA,CACA,UAAA,CAGJ,oBACI,YAAA,CAGJ,OACI,eAAA,CACA,WAAA,CACA,QAAA,CACA,SAAA,CACA,YAAA,CACA,2BAAA,CACA,iBAAA,CACA,eAAA,CAEA,eACI,cAAA,CACA,UAAA,CACA,eAAA,CACA,UAAA,CACA,iBAAA,CACA,YAAA,CACA,mCAAA,CACA,wBAAA,CACA,qBAAA,CACA,oBAAA,CACA,gBAAA,CAEA,qBACI,aAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,iBAAA,CACA,mBAAA,CAGJ,qBACI,aAAA,CACA,YAAA,CACA,iBAAA,CACA,mBAAA,CACA,cAAA,CAGJ,sBACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,iBAAA,CAGJ,yBACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,6BAAA,CAEA,iCACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAGJ,gCACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAKZ,cACI,UAAA,CACA,eAAA,CAEA,yBACI,YAAA,CACA,gCAAA,CAEA,gCACI,iBAAA,CAIR,uBACI,UAAA,CACA,eAAA,CACA,YAAA,CACA,mBAAA,CAGJ,yBACI,UAAA,CACA,eAAA,CACA,UAAA,CAGJ,0BACI,eAAA,CACA,UAAA,CACA,YAAA,CACA,mBAAA,CAGJ,sCACI,qBAAA,CACA,eAAA,CACA,iBAAA",sourcesContent:['#embed-host {\r\n position: absolute;\r\n right: 0px;\r\n top: 0px;\r\n bottom: 0px;\r\n z-index: 10;\r\n}\r\n\r\n#__resizable_base__ {\r\n display: none;\r\n}\r\n\r\n#embed {\r\n background: #333333;\r\n height: 100%;\r\n margin: 0;\r\n padding: 0;\r\n display: grid;\r\n grid-template-rows: 30px 1fr;\r\n font: 14px "Arial";\r\n overflow: hidden;\r\n\r\n #header {\r\n font-size: 16px;\r\n color: white;\r\n background: #222222;\r\n grid-row: 1;\r\n text-align: center;\r\n display: grid;\r\n grid-template-columns: 30px 1fr 50px;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n\r\n #logo {\r\n grid-column: 1;\r\n width: 24px;\r\n height: 24px;\r\n display: flex;\r\n align-self: center;\r\n justify-self: center;\r\n }\r\n\r\n #back {\r\n grid-column: 1;\r\n display: grid;\r\n align-self: center;\r\n justify-self: center;\r\n cursor: pointer;\r\n }\r\n\r\n #title {\r\n grid-column: 2;\r\n display: grid;\r\n align-items: center;\r\n text-align: center;\r\n }\r\n\r\n #commands {\r\n grid-column: 3;\r\n display: grid;\r\n align-items: center;\r\n grid-template-columns: 1fr 1fr;\r\n\r\n .expand {\r\n grid-column: 1;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n\r\n .close {\r\n grid-column: 2;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n }\r\n }\r\n\r\n #split {\r\n grid-row: 2;\r\n overflow: hidden;\r\n\r\n &.splitPopup {\r\n display: grid;\r\n grid-template-rows: 300px 2px 1fr;\r\n\r\n .panes {\r\n margin-bottom: 1px;\r\n }\r\n }\r\n\r\n #topPart {\r\n grid-row: 1;\r\n overflow: hidden;\r\n display: grid;\r\n grid-auto-rows: 100%;\r\n }\r\n\r\n #separator {\r\n grid-row: 2;\r\n background: white;\r\n opacity: 0.1;\r\n }\r\n\r\n #bottomPart {\r\n overflow: hidden;\r\n grid-row: 3;\r\n display: grid;\r\n grid-auto-rows: 100%;\r\n }\r\n\r\n .gutter.gutter-vertical {\r\n background-image: none;\r\n background: #444444;\r\n cursor: row-resize;\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},6771:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(3234),o=r.n(n),s=r(7474),a=r.n(s)()(o());a.push([e.id,'#scene-explorer-host{position:absolute;left:0px;top:0px;bottom:0px}#scene-explorer-host:focus{outline:none}#__resizable_base__{display:none}.context-menu{background:#222}.context-menu .react-contextmenu-item{padding:10px;cursor:pointer}.context-menu .react-contextmenu-item:hover{background:#555}.react-contextmenu.context-menu.react-contextmenu--visible{z-index:99;transform:scale(1)}#sceneExplorer{background:#333;height:100%;margin:0;padding:0;display:grid;grid-template-rows:auto 1fr;font:14px "Arial"}#sceneExplorer:focus{outline:none}#sceneExplorer #header{height:30px;font-size:16px;color:#fff;background:#222;grid-row:1;text-align:center;display:grid;grid-template-columns:30px 1fr 50px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#sceneExplorer #header #logo{position:relative;grid-column:1;width:24px;height:24px;left:0;display:flex;align-self:center;justify-self:center}#sceneExplorer #header #title{grid-column:2;display:grid;align-items:center;text-align:center}#sceneExplorer #header #commands{grid-column:3;display:grid;align-items:center;grid-template-columns:1fr 1fr}#sceneExplorer #header #commands .expand{grid-column:1;display:grid;align-items:center;justify-items:center;cursor:pointer}#sceneExplorer #header #commands .close{grid-column:2;display:grid;align-items:center;justify-items:center;cursor:pointer}#sceneExplorer #tree{grid-row:2;overflow-x:hidden;overflow-y:auto}#sceneExplorer .filter{display:flex;align-items:stretch}#sceneExplorer .filter input{width:100%;margin:10px 40px 5px 40px;display:block;border:none;padding:0;border-bottom:solid 1px #337ab7;background:linear-gradient(to bottom, rgba(255, 255, 255, 0) 96%, rgb(51, 122, 183) 4%);background-position:-1000px 0;background-size:1000px 100%;background-repeat:no-repeat;color:#fff}#sceneExplorer .filter input::placeholder{color:#d3d3d3}#sceneExplorer .filter input:focus{box-shadow:none;outline:none;background-position:0 0}#sceneExplorer .groupContainer{margin-left:0px;color:#fff;margin-top:0px;margin-bottom:0px;height:24px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;align-self:center;display:grid;align-items:center}#sceneExplorer .groupContainer:hover{background:#444}#sceneExplorer .groupContainer .expandableHeader{display:grid;grid-template-columns:1fr 20px}#sceneExplorer .groupContainer .expandableHeader .text{grid-column:1;display:grid;grid-template-columns:20px 1fr}#sceneExplorer .groupContainer .expandableHeader .text .arrow{grid-column:1;margin-left:0px;color:#fff;cursor:pointer;display:inline-block;margin-right:6px;opacity:.5}#sceneExplorer .groupContainer .expandableHeader .text .text-value{grid-column:2;display:flex;align-items:center}#sceneExplorer .groupContainer .expandableHeader .expandAll{opacity:.5;grid-column:2;margin-right:10px}#sceneExplorer .icon{display:grid;align-items:center;justify-items:center;cursor:pointer}#sceneExplorer .itemContainer{margin-left:0px;color:#fff;margin-top:0px;margin-bottom:0px;height:24px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:grid;grid-template-columns:20px 1fr}#sceneExplorer .itemContainer:hover{background:#444}#sceneExplorer .itemContainer.selected{background:#bbb;color:#000}#sceneExplorer .itemContainer .isNotActive{opacity:.3}#sceneExplorer .itemContainer .arrow{grid-column:1;color:#fff;opacity:.6}#sceneExplorer .itemContainer .popup{width:200px;visibility:hidden;background-color:#444;color:#fff;border:1px solid rgba(255,255,255,.5);position:absolute;z-index:1;margin-left:-180px;box-sizing:border-box}#sceneExplorer .itemContainer .popup.show{visibility:visible}#sceneExplorer .itemContainer .popup:focus{outline:none}#sceneExplorer .itemContainer .popup .popupMenu{padding:6px 5px 5px 10px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;height:18px}#sceneExplorer .itemContainer .popup .popupMenu:hover{background:#fff;color:#333}#sceneExplorer .itemContainer .sceneNode{grid-column:2;margin-left:-10px;display:grid;grid-template-columns:1fr 20px 20px 20px 20px 10px 20px 20px auto 5px;align-items:center;cursor:pointer}#sceneExplorer .itemContainer .sceneNode .sceneTitle{grid-column:1;margin-right:5px;display:flex;align-items:center;height:24px}#sceneExplorer .itemContainer .sceneNode .translation{grid-column:2;opacity:.6}#sceneExplorer .itemContainer .sceneNode .translation.selected{opacity:1}#sceneExplorer .itemContainer .sceneNode .rotation{grid-column:3;opacity:.6}#sceneExplorer .itemContainer .sceneNode .rotation.selected{opacity:1}#sceneExplorer .itemContainer .sceneNode .scaling{grid-column:4;opacity:.6}#sceneExplorer .itemContainer .sceneNode .scaling.selected{opacity:1}#sceneExplorer .itemContainer .sceneNode .bounding{grid-column:5;opacity:.6}#sceneExplorer .itemContainer .sceneNode .bounding.selected{opacity:1}#sceneExplorer .itemContainer .sceneNode .separator{grid-column:6;margin-left:5px;width:5px;display:flex;align-items:center;height:18px;border-left:solid 1px #337ab7}#sceneExplorer .itemContainer .sceneNode .pickingMode{grid-column:7;opacity:.6}#sceneExplorer .itemContainer .sceneNode .pickingMode.selected{opacity:1}#sceneExplorer .itemContainer .sceneNode .coordinates{grid-column:8;opacity:.6}#sceneExplorer .itemContainer .sceneNode .coordinates.selected{opacity:1}#sceneExplorer .itemContainer .sceneNode .refresh{grid-column:9}#sceneExplorer .itemContainer .sceneNode .extensions{width:20px;grid-column:10}#sceneExplorer .itemContainer .targetedAnimationTools{grid-column:2;width:100%;display:grid;grid-template-columns:1fr auto 5px;align-items:center;min-width:0}#sceneExplorer .itemContainer .targetedAnimationTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .animationGroupTools{grid-column:2;width:100%;display:grid;grid-template-columns:1fr auto 5px;align-items:center;min-width:0}#sceneExplorer .itemContainer .animationGroupTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .soundTools{grid-column:2;width:100%;display:grid;grid-template-columns:1fr auto 5px;align-items:center;min-width:0}#sceneExplorer .itemContainer .soundTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .meshTools{grid-column:2;width:100%;display:grid;grid-template-columns:1fr 20px 20px auto 5px;align-items:center;min-width:0}#sceneExplorer .itemContainer .meshTools .bounding-box{grid-column:2;opacity:.5}#sceneExplorer .itemContainer .meshTools .bounding-box.selected{opacity:1}#sceneExplorer .itemContainer .meshTools .visibility{grid-column:3}#sceneExplorer .itemContainer .meshTools .extensions{width:20px;grid-column:4}#sceneExplorer .itemContainer .cameraTools{grid-column:2;display:grid;grid-template-columns:1fr 20px 20px auto 5px;align-items:center}#sceneExplorer .itemContainer .cameraTools .activeCamera{grid-column:2}#sceneExplorer .itemContainer .cameraTools .enableGizmo{grid-column:3}#sceneExplorer .itemContainer .cameraTools .extensions{width:20px;grid-column:4}#sceneExplorer .itemContainer .lightTools{grid-column:2;display:grid;grid-template-columns:1fr 20px 20px auto 5px;align-items:center}#sceneExplorer .itemContainer .lightTools .visibility{grid-column:2}#sceneExplorer .itemContainer .lightTools .enableGizmo{grid-column:3}#sceneExplorer .itemContainer .lightTools .extensions{width:20px;grid-column:4}#sceneExplorer .itemContainer .spriteTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .spriteTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .spriteManagerTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .spriteManagerTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .materialTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .materialTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .materialTools .icon{display:grid;align-items:center;justify-items:center;cursor:pointer}#sceneExplorer .itemContainer .particleSystemTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .particleSystemTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .effectLayerTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .effectLayerTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .postProcessTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .postProcessTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .renderingPipelineTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .renderingPipelineTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .textureTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .textureTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .adtextureTools{grid-column:2;display:grid;grid-template-columns:1fr 20px 20px auto 5px;align-items:center}#sceneExplorer .itemContainer .adtextureTools .edit{grid-column:2}#sceneExplorer .itemContainer .adtextureTools .pickingMode{grid-column:3;opacity:.6}#sceneExplorer .itemContainer .adtextureTools .pickingMode.selected{opacity:1}#sceneExplorer .itemContainer .adtextureTools .extensions{width:20px;grid-column:3}#sceneExplorer .itemContainer .controlTools{grid-column:2;display:grid;grid-template-columns:1fr 20px 20px auto 5px;align-items:center}#sceneExplorer .itemContainer .controlTools .highlight{grid-column:2}#sceneExplorer .itemContainer .controlTools .visibility{grid-column:3}#sceneExplorer .itemContainer .controlTools .extensions{width:20px;grid-column:4}#sceneExplorer .itemContainer .transformNodeTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .transformNodeTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .skeletonTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .skeletonTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .title{grid-column:1;background:rgba(0,0,0,0);white-space:nowrap;overflow:hidden;min-width:0;margin-right:5px;display:grid;align-items:center;grid-template-columns:25px 1fr;height:24px;cursor:pointer}#sceneExplorer .itemContainer .title .titleIcon{grid-column:1;display:grid;align-items:center;justify-items:center}#sceneExplorer .itemContainer .title .titleText{grid-column:2;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/sceneExplorer/sceneExplorer.scss"],names:[],mappings:"AAAA,qBACI,iBAAA,CACA,QAAA,CACA,OAAA,CACA,UAAA,CAEA,2BACI,YAAA,CAIR,oBACI,YAAA,CAGJ,cACI,eAAA,CAEA,sCACI,YAAA,CACA,cAAA,CAEA,4CACI,eAAA,CAKZ,2DACI,UAAA,CACA,kBAAA,CAGJ,eACI,eAAA,CACA,WAAA,CACA,QAAA,CACA,SAAA,CACA,YAAA,CACA,2BAAA,CACA,iBAAA,CAEA,qBACI,YAAA,CAGJ,uBACI,WAAA,CACA,cAAA,CACA,UAAA,CACA,eAAA,CACA,UAAA,CACA,iBAAA,CACA,YAAA,CACA,mCAAA,CACA,wBAAA,CACA,qBAAA,CACA,oBAAA,CACA,gBAAA,CAEA,6BACI,iBAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CACA,MAAA,CACA,YAAA,CACA,iBAAA,CACA,mBAAA,CAGJ,8BACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,iBAAA,CAGJ,iCACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,6BAAA,CAEA,yCACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAGJ,wCACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAKZ,qBACI,UAAA,CAEA,iBAAA,CACA,eAAA,CAGJ,uBACI,YAAA,CACA,mBAAA,CAEA,6BACI,UAAA,CACA,yBAAA,CACA,aAAA,CACA,WAAA,CACA,SAAA,CACA,+BAAA,CACA,uFAAA,CACA,6BAAA,CACA,2BAAA,CACA,2BAAA,CACA,UAAA,CAGJ,0CACI,aAAA,CAGJ,mCACI,eAAA,CACA,YAAA,CACA,uBAAA,CAIR,+BACI,eAAA,CACA,UAAA,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ACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAIR,mDACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,+DACI,UAAA,CACA,aAAA,CAIR,gDACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,4DACI,UAAA,CACA,aAAA,CAIR,gDACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,4DACI,UAAA,CACA,aAAA,CAIR,sDACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,kEACI,UAAA,CACA,aAAA,CAIR,4CACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,wDACI,UAAA,CACA,aAAA,CAIR,8CACI,aAAA,CACA,YAAA,CACA,4CAAA,CACA,kBAAA,CAEA,oDACI,aAAA,CAGJ,2DACI,aAAA,CACA,UAAA,CAEA,oEACI,SAAA,CAIR,0DACI,UAAA,CACA,aAAA,CAIR,4CACI,aAAA,CACA,YAAA,CACA,4CAAA,CACA,kBAAA,CAEA,uDACI,aAAA,CAGJ,wDACI,aAAA,CAGJ,wDACI,UAAA,CACA,aAAA,CAIR,kDACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,8DACI,UAAA,CACA,aAAA,CAIR,6CACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,yDACI,UAAA,CACA,aAAA,CAIR,qCACI,aAAA,CACA,wBAAA,CACA,kBAAA,CACA,eAAA,CACA,WAAA,CACA,gBAAA,CACA,YAAA,CACA,kBAAA,CACA,8BAAA,CACA,WAAA,CACA,cAAA,CAEA,gDACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CAGJ,gDACI,aAAA,CACA,kBAAA,CACA,sBAAA,CACA,eAAA",sourcesContent:['#scene-explorer-host {\r\n position: absolute;\r\n left: 0px;\r\n top: 0px;\r\n bottom: 0px;\r\n\r\n &:focus {\r\n outline: none;\r\n }\r\n}\r\n\r\n#__resizable_base__ {\r\n display: none;\r\n}\r\n\r\n.context-menu {\r\n background: #222222;\r\n\r\n .react-contextmenu-item {\r\n padding: 10px;\r\n cursor: pointer;\r\n\r\n &:hover {\r\n background: #555555;\r\n }\r\n }\r\n}\r\n\r\n.react-contextmenu.context-menu.react-contextmenu--visible {\r\n z-index: 99;\r\n transform: scale(1);\r\n}\r\n\r\n#sceneExplorer {\r\n background: #333333;\r\n height: 100%;\r\n margin: 0;\r\n padding: 0;\r\n display: grid;\r\n grid-template-rows: auto 1fr;\r\n font: 14px "Arial";\r\n\r\n &:focus {\r\n outline: none;\r\n }\r\n\r\n #header {\r\n height: 30px;\r\n font-size: 16px;\r\n color: white;\r\n background: #222222;\r\n grid-row: 1;\r\n text-align: center;\r\n display: grid;\r\n grid-template-columns: 30px 1fr 50px;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n\r\n #logo {\r\n position: relative;\r\n grid-column: 1;\r\n width: 24px;\r\n height: 24px;\r\n left: 0;\r\n display: flex;\r\n align-self: center;\r\n justify-self: center;\r\n }\r\n\r\n #title {\r\n grid-column: 2;\r\n display: grid;\r\n align-items: center;\r\n text-align: center;\r\n }\r\n\r\n #commands {\r\n grid-column: 3;\r\n display: grid;\r\n align-items: center;\r\n grid-template-columns: 1fr 1fr;\r\n\r\n .expand {\r\n grid-column: 1;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n\r\n .close {\r\n grid-column: 2;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n }\r\n }\r\n\r\n #tree {\r\n grid-row: 2;\r\n\r\n overflow-x: hidden;\r\n overflow-y: auto;\r\n }\r\n\r\n .filter {\r\n display: flex;\r\n align-items: stretch;\r\n\r\n input {\r\n width: 100%;\r\n margin: 10px 40px 5px 40px;\r\n display: block;\r\n border: none;\r\n padding: 0;\r\n border-bottom: solid 1px rgb(51, 122, 183);\r\n background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 96%, rgb(51, 122, 183) 4%);\r\n background-position: -1000px 0;\r\n background-size: 1000px 100%;\r\n background-repeat: no-repeat;\r\n color: white;\r\n }\r\n\r\n input::placeholder {\r\n color: lightgray;\r\n }\r\n\r\n input:focus {\r\n box-shadow: none;\r\n outline: none;\r\n background-position: 0 0;\r\n }\r\n }\r\n\r\n .groupContainer {\r\n margin-left: 0px;\r\n color: white;\r\n margin-top: 0px;\r\n margin-bottom: 0px;\r\n height: 24px;\r\n\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n\r\n align-self: center;\r\n display: grid;\r\n align-items: center;\r\n\r\n &:hover {\r\n background: #444444;\r\n }\r\n\r\n .expandableHeader {\r\n display: grid;\r\n grid-template-columns: 1fr 20px;\r\n\r\n .text {\r\n grid-column: 1;\r\n display: grid;\r\n grid-template-columns: 20px 1fr;\r\n\r\n .arrow {\r\n grid-column: 1;\r\n margin-left: 0px;\r\n color: white;\r\n cursor: pointer;\r\n display: inline-block;\r\n margin-right: 6px;\r\n opacity: 0.5;\r\n }\r\n\r\n .text-value {\r\n grid-column: 2;\r\n display: flex;\r\n align-items: center;\r\n }\r\n }\r\n\r\n .expandAll {\r\n opacity: 0.5;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n }\r\n }\r\n }\r\n\r\n .icon {\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n\r\n .itemContainer {\r\n margin-left: 0px;\r\n color: white;\r\n margin-top: 0px;\r\n margin-bottom: 0px;\r\n height: 24px;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n display: grid;\r\n grid-template-columns: 20px 1fr;\r\n\r\n &:hover {\r\n background: #444444;\r\n }\r\n\r\n &.selected {\r\n background: #bbbbbb;\r\n color: black;\r\n }\r\n\r\n .isNotActive {\r\n opacity: 0.3;\r\n }\r\n\r\n .arrow {\r\n grid-column: 1;\r\n color: white;\r\n opacity: 0.6;\r\n }\r\n\r\n .popup {\r\n width: 200px;\r\n visibility: hidden;\r\n background-color: #444444;\r\n color: #fff;\r\n border: 1px solid rgba(255, 255, 255, 0.5);\r\n position: absolute;\r\n z-index: 1;\r\n margin-left: -180px;\r\n box-sizing: border-box;\r\n\r\n &.show {\r\n visibility: visible;\r\n }\r\n\r\n &:focus {\r\n outline: none;\r\n }\r\n\r\n .popupMenu {\r\n padding: 6px 5px 5px 10px;\r\n overflow: hidden;\r\n white-space: nowrap;\r\n text-overflow: ellipsis;\r\n height: 18px;\r\n\r\n &:hover {\r\n background: white;\r\n color: #333333;\r\n }\r\n }\r\n }\r\n\r\n .sceneNode {\r\n grid-column: 2;\r\n margin-left: -10px;\r\n display: grid;\r\n grid-template-columns: 1fr 20px 20px 20px 20px 10px 20px 20px auto 5px;\r\n align-items: center;\r\n cursor: pointer;\r\n\r\n .sceneTitle {\r\n grid-column: 1;\r\n margin-right: 5px;\r\n display: flex;\r\n align-items: center;\r\n height: 24px;\r\n }\r\n\r\n .translation {\r\n grid-column: 2;\r\n opacity: 0.6;\r\n\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .rotation {\r\n grid-column: 3;\r\n opacity: 0.6;\r\n\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .scaling {\r\n grid-column: 4;\r\n opacity: 0.6;\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .bounding {\r\n grid-column: 5;\r\n opacity: 0.6;\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .separator {\r\n grid-column: 6;\r\n margin-left: 5px;\r\n width: 5px;\r\n display: flex;\r\n align-items: center;\r\n height: 18px;\r\n border-left: solid 1px rgb(51, 122, 183);\r\n }\r\n\r\n .pickingMode {\r\n grid-column: 7;\r\n opacity: 0.6;\r\n\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .coordinates {\r\n grid-column: 8;\r\n opacity: 0.6;\r\n\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .refresh {\r\n grid-column: 9;\r\n }\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 10;\r\n }\r\n }\r\n\r\n .targetedAnimationTools {\r\n grid-column: 2;\r\n width: 100%;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n min-width: 0;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .animationGroupTools {\r\n grid-column: 2;\r\n width: 100%;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n min-width: 0;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .soundTools {\r\n grid-column: 2;\r\n width: 100%;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n min-width: 0;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .meshTools {\r\n grid-column: 2;\r\n width: 100%;\r\n display: grid;\r\n grid-template-columns: 1fr 20px 20px auto 5px;\r\n align-items: center;\r\n min-width: 0;\r\n\r\n .bounding-box {\r\n grid-column: 2;\r\n opacity: 0.5;\r\n\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .visibility {\r\n grid-column: 3;\r\n }\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 4;\r\n }\r\n }\r\n\r\n .cameraTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr 20px 20px auto 5px;\r\n align-items: center;\r\n\r\n .activeCamera {\r\n grid-column: 2;\r\n }\r\n\r\n .enableGizmo {\r\n grid-column: 3;\r\n }\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 4;\r\n }\r\n }\r\n\r\n .lightTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr 20px 20px auto 5px;\r\n align-items: center;\r\n\r\n .visibility {\r\n grid-column: 2;\r\n }\r\n\r\n .enableGizmo {\r\n grid-column: 3;\r\n }\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 4;\r\n }\r\n }\r\n\r\n .spriteTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .spriteManagerTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .materialTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n\r\n .icon {\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n }\r\n\r\n .particleSystemTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .effectLayerTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .postProcessTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .renderingPipelineTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .textureTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .adtextureTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr 20px 20px auto 5px;\r\n align-items: center;\r\n\r\n .edit {\r\n grid-column: 2;\r\n }\r\n\r\n .pickingMode {\r\n grid-column: 3;\r\n opacity: 0.6;\r\n\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 3;\r\n }\r\n }\r\n\r\n .controlTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr 20px 20px auto 5px;\r\n align-items: center;\r\n\r\n .highlight {\r\n grid-column: 2;\r\n }\r\n\r\n .visibility {\r\n grid-column: 3;\r\n }\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 4;\r\n }\r\n }\r\n\r\n .transformNodeTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .skeletonTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .title {\r\n grid-column: 1;\r\n background: transparent;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n min-width: 0;\r\n margin-right: 5px;\r\n display: grid;\r\n align-items: center;\r\n grid-template-columns: 25px 1fr;\r\n height: 24px;\r\n cursor: pointer;\r\n\r\n .titleIcon {\r\n grid-column: 1;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n }\r\n\r\n .titleText {\r\n grid-column: 2;\r\n white-space: nowrap;\r\n text-overflow: ellipsis;\r\n overflow: hidden;\r\n }\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},5228:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(3234),o=r.n(n),s=r(7474),a=r.n(s)()(o());a.push([e.id,'.color-picker-container{width:320px;height:300px;background-color:#fff;display:grid;grid-template-columns:100%;grid-template-rows:50% 50px 60px 40px 1fr auto;font-family:"acumin-pro-condensed";font-weight:normal;font-size:14px}.color-picker-container.with-hints{height:380px}.color-picker-container .color-picker-saturation{grid-row:1;grid-column:1;display:grid;grid-template-columns:100%;grid-template-rows:100%;position:relative;cursor:pointer}.color-picker-container .color-picker-saturation .color-picker-saturation-white{grid-row:1;grid-column:1;background:-webkit-linear-gradient(to right, #fff, rgba(255, 255, 255, 0));background:linear-gradient(to right, #fff, rgba(255, 255, 255, 0))}.color-picker-container .color-picker-saturation .color-picker-saturation-black{grid-row:1;grid-column:1;background:-webkit-linear-gradient(to top, #000, rgba(0, 0, 0, 0));background:linear-gradient(to top, #000, rgba(0, 0, 0, 0))}.color-picker-container .color-picker-saturation .color-picker-saturation-cursor{pointer-events:none;width:4px;height:4px;box-shadow:0 0 0 1.5px #fff,inset 0 0 1px 1px rgba(0,0,0,.3),0 0 1px 2px rgba(0,0,0,.4);border-radius:50%;transform:translate(-2px, -2px);position:absolute}.color-picker-container .color-picker-hue{grid-row:2;grid-column:1;display:grid;margin:10px;grid-template-columns:24% 76%;grid-template-rows:100%}.color-picker-container .color-picker-hue .color-picker-hue-color{grid-row:1;grid-column:1;align-self:center;justify-self:center;width:30px;height:30px;border-radius:15px;border:1px solid #000}.color-picker-container .color-picker-hue .color-picker-hue-slider{grid-row:1;grid-column:2;align-self:center;height:16px;position:relative;cursor:pointer;background:linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);background:-webkit-linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)}.color-picker-container .color-picker-hue .color-picker-hue-slider .color-picker-hue-cursor{pointer-events:none;width:8px;height:18px;transform:translate(-4px, -2px);background-color:#f8f8f8;box-shadow:0 1px 4px 0 rgba(0,0,0,.37);position:absolute}.color-picker-container .color-picker-component{display:grid;margin:5px;grid-template-columns:100%;grid-template-rows:50% 50%}.color-picker-container .color-picker-component .color-picker-component-value{justify-self:center;align-self:center;grid-row:1;grid-column:1;margin-bottom:4px}.color-picker-container .color-picker-component .color-picker-component-value input{width:50px}.color-picker-container .color-picker-component .color-picker-component-label{justify-self:center;align-self:center;grid-row:2;grid-column:1;color:#000}.color-picker-container .color-picker-rgb{grid-row:3;grid-column:1;display:grid;margin:10px;grid-template-columns:20% 6.66% 20% 6.66% 20% 6.66% 20%;grid-template-rows:100%}.color-picker-container .red{grid-row:1;grid-column:1}.color-picker-container .green{grid-row:1;grid-column:3}.color-picker-container .blue{grid-row:1;grid-column:5}.color-picker-container .alpha{grid-row:1;grid-column:7}.color-picker-container .alpha.grayed{opacity:.5}.color-picker-container .color-picker-hex{grid-row:4;grid-column:1;display:grid;grid-template-columns:20% 80%;grid-template-rows:100%}.color-picker-container .color-picker-hex .color-picker-hex-label{justify-self:center;align-self:center;grid-row:1;grid-column:1;margin-left:10px;color:#000}.color-picker-container .color-picker-hex .color-picker-hex-value{justify-self:left;align-self:center;grid-row:1;grid-column:2;margin-left:10px;margin-right:10px}.color-picker-container .color-picker-hex .color-picker-hex-value input{width:70px}.color-picker-container .color-picker-warning{color:#000;font-size:11px;padding:4px;justify-self:left;align-self:center;grid-row:6;grid-column:1}',"",{version:3,sources:["webpack://./../../../dev/sharedUiComponents/dist/colorPicker/colorPicker.scss"],names:[],mappings:"AAAA,wBACI,WAAA,CACA,YAAA,CACA,qBAAA,CACA,YAAA,CACA,0BAAA,CACA,8CAAA,CACA,kCAAA,CACA,kBAAA,CACA,cAAA,CAEA,mCACI,YAAA,CAGJ,iDACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,0BAAA,CACA,uBAAA,CACA,iBAAA,CACA,cAAA,CAEA,gF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AA,CACA,WAAA,CACA,iBAAA,CACA,iBAAA,CACA,UAAA,CACA,aAAA",sourcesContent:['.color-picker-container {\r\n width: 320px;\r\n height: 300px;\r\n background-color: white;\r\n display: grid;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 50% 50px 60px 40px 1fr auto;\r\n font-family: "acumin-pro-condensed";\r\n font-weight: normal;\r\n font-size: 14px;\r\n\r\n &.with-hints {\r\n height: 380px;\r\n }\r\n\r\n .color-picker-saturation {\r\n grid-row: 1;\r\n grid-column: 1;\r\n display: grid;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 100%;\r\n position: relative;\r\n cursor: pointer;\r\n\r\n .color-picker-saturation-white {\r\n grid-row: 1;\r\n grid-column: 1;\r\n\r\n background: -webkit-linear-gradient(to right, #fff, rgba(255, 255, 255, 0));\r\n background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0));\r\n }\r\n\r\n .color-picker-saturation-black {\r\n grid-row: 1;\r\n grid-column: 1;\r\n\r\n background: -webkit-linear-gradient(to top, #000, rgba(0, 0, 0, 0));\r\n background: linear-gradient(to top, #000, rgba(0, 0, 0, 0));\r\n }\r\n\r\n .color-picker-saturation-cursor {\r\n pointer-events: none;\r\n width: 4px;\r\n height: 4px;\r\n box-shadow:\r\n 0 0 0 1.5px #fff,\r\n inset 0 0 1px 1px rgba(0, 0, 0, 0.3),\r\n 0 0 1px 2px rgba(0, 0, 0, 0.4);\r\n border-radius: 50%;\r\n transform: translate(-2px, -2px);\r\n position: absolute;\r\n }\r\n }\r\n\r\n .color-picker-hue {\r\n grid-row: 2;\r\n grid-column: 1;\r\n display: grid;\r\n margin: 10px;\r\n grid-template-columns: 24% 76%;\r\n grid-template-rows: 100%;\r\n\r\n .color-picker-hue-color {\r\n grid-row: 1;\r\n grid-column: 1;\r\n align-self: center;\r\n justify-self: center;\r\n width: 30px;\r\n height: 30px;\r\n border-radius: 15px;\r\n border: 1px solid black;\r\n }\r\n\r\n .color-picker-hue-slider {\r\n grid-row: 1;\r\n grid-column: 2;\r\n align-self: center;\r\n height: 16px;\r\n position: relative;\r\n cursor: pointer;\r\n\r\n background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);\r\n background: -webkit-linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);\r\n\r\n .color-picker-hue-cursor {\r\n pointer-events: none;\r\n width: 8px;\r\n height: 18px;\r\n transform: translate(-4px, -2px);\r\n background-color: rgb(248, 248, 248);\r\n box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.37);\r\n position: absolute;\r\n }\r\n }\r\n }\r\n\r\n .color-picker-component {\r\n display: grid;\r\n margin: 5px;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 50% 50%;\r\n\r\n .color-picker-component-value {\r\n justify-self: center;\r\n align-self: center;\r\n grid-row: 1;\r\n grid-column: 1;\r\n margin-bottom: 4px;\r\n\r\n input {\r\n width: 50px;\r\n }\r\n }\r\n\r\n .color-picker-component-label {\r\n justify-self: center;\r\n align-self: center;\r\n grid-row: 2;\r\n grid-column: 1;\r\n color: black;\r\n }\r\n }\r\n\r\n .color-picker-rgb {\r\n grid-row: 3;\r\n grid-column: 1;\r\n display: grid;\r\n margin: 10px;\r\n grid-template-columns: 20% 6.66% 20% 6.66% 20% 6.66% 20%;\r\n grid-template-rows: 100%;\r\n }\r\n\r\n .red {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n .green {\r\n grid-row: 1;\r\n grid-column: 3;\r\n }\r\n\r\n .blue {\r\n grid-row: 1;\r\n grid-column: 5;\r\n }\r\n\r\n .alpha {\r\n grid-row: 1;\r\n grid-column: 7;\r\n\r\n &.grayed {\r\n opacity: 0.5;\r\n }\r\n }\r\n\r\n .color-picker-hex {\r\n grid-row: 4;\r\n grid-column: 1;\r\n display: grid;\r\n grid-template-columns: 20% 80%;\r\n grid-template-rows: 100%;\r\n\r\n .color-picker-hex-label {\r\n justify-self: center;\r\n align-self: center;\r\n grid-row: 1;\r\n grid-column: 1;\r\n margin-left: 10px;\r\n color: black;\r\n }\r\n\r\n .color-picker-hex-value {\r\n justify-self: left;\r\n align-self: center;\r\n grid-row: 1;\r\n grid-column: 2;\r\n margin-left: 10px;\r\n margin-right: 10px;\r\n\r\n input {\r\n width: 70px;\r\n }\r\n }\r\n }\r\n\r\n .color-picker-warning {\r\n color: black;\r\n font-size: 11px;\r\n padding: 4px;\r\n justify-self: left;\r\n align-self: center;\r\n grid-row: 6;\r\n grid-column: 1;\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},7474:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var r="",n=void 0!==t[5];return t[4]&&(r+="@supports (".concat(t[4],") {")),t[2]&&(r+="@media ".concat(t[2]," {")),n&&(r+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),r+=e(t),n&&(r+="}"),t[2]&&(r+="}"),t[4]&&(r+="}"),r})).join("")},t.i=function(e,r,n,o,s){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(n)for(var i=0;i0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=s),r&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=r):c[2]=r),o&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=o):c[4]="".concat(o)),t.push(c))}},t}},1721:e=>{"use strict";e.exports=function(e,t){return t||(t={}),e?(e=String(e.__esModule?e.default:e),/^['"].*['"]$/.test(e)&&(e=e.slice(1,-1)),t.hash&&(e+=t.hash),/["'() \t\n]|(%20)/.test(e)||t.needQuotes?'"'.concat(e.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"'):e):e}},3234:e=>{"use strict";e.exports=function(e){var t=e[1],r=e[3];if(!r)return t;if("function"==typeof btoa){var n=btoa(unescape(encodeURIComponent(JSON.stringify(r)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),s="/*# ".concat(o," */");return[t].concat([s]).join("\n")}return[t].join("\n")}},1684:function(e){e.exports=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){var n,o,s={}.hasOwnProperty,a=[].indexOf||function(e){for(var t=0,r=this.length;t0&&r.data&&(this.groups.has(r.data)?this.groups.get(r.data).push(o):this.groups.set(r.data,[o])),this.frames.push(r)},t.prototype.render=function(){var e,t,r;if(this.running)throw new Error("Already running");if(null==this.options.width||null==this.options.height)throw new Error("Width and height must be set prior to rendering");if(this.running=!0,this.nextFrame=0,this.finishedFrames=0,this.imageParts=function(){var e,t,r;for(r=[],e=0,t=this.frames.length;0<=t?et;0<=t?++e:--e)r.push(null);return r}.call(this),t=this.spawnWorkers(),!0===this.options.globalPalette)this.renderNextFrame();else for(e=0,r=t;0<=r?er;0<=r?++e:--e)this.renderNextFrame();return this.emit("start"),this.emit("progress",0)},t.prototype.abort=function(){for(var e;null!=(e=this.activeWorkers.shift());)this.log("killing active worker"),e.terminate();return this.running=!1,this.emit("abort")},t.prototype.spawnWorkers=function(){var e,t,r;return e=Math.min(this.options.workers,this.frames.length),function(){r=[];for(var n=t=this.freeWorkers.length;t<=e?ne;t<=e?n++:n--)r.push(n);return r}.apply(this).forEach(function(e){return function(t){var r;return e.log("spawning worker "+t),(r=new Worker(e.options.workerScript)).onmessage=function(t){return e.activeWorkers.splice(e.activeWorkers.indexOf(r),1),e.freeWorkers.push(r),e.frameFinished(t.data,!1)},e.freeWorkers.push(r)}}(this)),e},t.prototype.frameFinished=function(e,t){var r,n,o,s;if(this.finishedFrames++,t?(r=this.frames.indexOf(e),n=this.groups.get(e.data)[0],this.log("frame "+(r+1)+" is duplicate of "+n+" - "+this.activeWorkers.length+" active"),this.imageParts[r]={indexOfFirstInGroup:n}):(this.log("frame "+(e.index+1)+" finished - "+this.activeWorkers.length+" active"),this.emit("progress",this.finishedFrames/this.frames.length),this.imageParts[e.index]=e),!0===this.options.globalPalette&&!t&&(this.options.globalPalette=e.globalPalette,this.log("global palette analyzed"),this.frames.length>2))for(o=1,s=this.freeWorkers.length;1<=s?os;1<=s?++o:--o)this.renderNextFrame();return a.call(this.imageParts,null)>=0?this.renderNextFrame():this.finishRendering()},t.prototype.finishRendering=function(){var e,t,r,n,o,s,a,i,l,p,c,d,h,u,b,g,m,A,C,f;for(o=s=0,p=(m=this.imageParts).length;s=this.frames.length))return e=this.frames[this.nextFrame++],(t=this.frames.indexOf(e))>0&&this.groups.has(e.data)&&this.groups.get(e.data)[0]!==t?void setTimeout(function(t){return function(){return t.frameFinished(e,!0)}}(this),0):(n=this.freeWorkers.shift(),r=this.getTask(e),this.log("starting frame "+(r.index+1)+" of "+this.frames.length),this.activeWorkers.push(n),n.postMessage(r))},t.prototype.getContextData=function(e){return e.getImageData(0,0,this.options.width,this.options.height).data},t.prototype.getImageData=function(e){var t;return null==this._canvas&&(this._canvas=document.createElement("canvas"),this._canvas.width=this.options.width,this._canvas.height=this.options.height),(t=this._canvas.getContext("2d")).setFill=this.options.background,t.fillRect(0,0,this.options.width,this.options.height),t.drawImage(e,0,0),this.getContextData(t)},t.prototype.getTask=function(e){var t,r;if(r={index:t=this.frames.indexOf(e),last:t===this.frames.length-1,delay:e.delay,transparent:e.transparent,width:this.options.width,height:this.options.height,quality:this.options.quality,dither:this.options.dither,globalPalette:this.options.globalPalette,repeat:this.options.repeat,canTransfer:!0},null!=e.data)r.data=e.data;else if(null!=e.context)r.data=this.getContextData(e.context);else{if(null==e.image)throw new Error("Invalid frame");r.data=this.getImageData(e.image)}return r},t.prototype.log=function(e){if(this.options.debug)return console.log(e)},t}(n),e.exports=o},function(e,t){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(e){return"function"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!function(e){return"number"==typeof e}(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,r,a,i,l,p;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}if(s(r=this._events[e]))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(o(r))for(i=Array.prototype.slice.call(arguments,1),a=(p=r.slice()).length,l=0;l0&&this._events[e].length>a&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function r(){this.removeListener(e,r),o||(o=!0,t.apply(this,arguments))}if(!n(t))throw TypeError("listener must be a function");var o=!1;return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var r,s,a,i;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(r=this._events[e]).length,s=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(i=a;i-- >0;)if(r[i]===t||r[i].listener&&r[i].listener===t){s=i;break}if(s<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(s,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t){var r,n,o,s,a;a=navigator.userAgent.toLowerCase(),s=navigator.platform.toLowerCase(),o="ie"===(r=a.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/)||[null,"unknown",0])[1]&&document.documentMode,(n={name:"version"===r[1]?r[3]:r[1],version:o||parseFloat("opera"===r[1]&&r[4]?r[4]:r[2]),platform:{name:a.match(/ip(?:ad|od|hone)/)?"ios":(a.match(/(?:webos|android)/)||s.match(/mac|win|linux/)||["other"])[0]}})[n.name]=!0,n[n.name+parseInt(n.version,10)]=!0,n.platform[n.platform.name]=!0,e.exports=n}])},772:e=>{"use strict";var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,o){for(var s,a,i=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),l=1;l{"use strict";var n=r(8565);function o(){}function s(){}s.resetWarningCache=o,e.exports=function(){function e(e,t,r,o,s,a){if(a!==n){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:s,resetWarningCache:o};return r.PropTypes=r,r}},764:(e,t,r)=>{e.exports=r(878)()},8565:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},315:(e,t,r)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var r=l(t);if(r&&r.has(e))return r.get(e);var o={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var i=s?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(o,a,i):o[a]=e[a]}return o.default=e,r&&r.set(e,o),o}(r(7460)),s=i(r(764)),a=i(r(1122));function i(e){return e&&e.__esModule?e:{default:e}}function l(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(l=function(e){return e?r:t})(e)}function p(e,t){return p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},p(e,t)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var u=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(l,e);var t,r,s,i=(r=l,s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=d(r);if(s){var o=d(this).constructor;e=Reflect.construct(t,arguments,o)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return c(e)}(this,e)});function l(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),h(c(t=i.call(this,e)),"handleKeyNavigation",(function(e){if(!1!==t.state.isVisible)switch(e.keyCode){case 37:case 27:e.preventDefault(),t.hideMenu(e);break;case 38:e.preventDefault(),t.selectChildren(!0);break;case 40:e.preventDefault(),t.selectChildren(!1);break;case 39:t.tryToOpenSubMenu(e);break;case 13:e.preventDefault(),t.tryToOpenSubMenu(e);var r=t.seletedItemRef&&t.seletedItemRef.props&&t.seletedItemRef.props.disabled;t.seletedItemRef&&t.seletedItemRef.ref instanceof HTMLElement&&!r?t.seletedItemRef.ref.click():t.hideMenu(e)}})),h(c(t),"handleForceClose",(function(){t.setState({forceSubMenuOpen:!1})})),h(c(t),"tryToOpenSubMenu",(function(e){t.state.selectedItem&&t.state.selectedItem.type===t.getSubMenuType()&&(e.preventDefault(),t.setState({forceSubMenuOpen:!0}))})),h(c(t),"selectChildren",(function(e){var r=t.state.selectedItem,n=[],s=0,i={};if(o.default.Children.forEach(t.props.children,(function e(r,l){r&&([a.default,t.getSubMenuType()].indexOf(r.type)<0?o.default.Children.forEach(r.props.children,e):r.props.divider||(r.props.disabled&&(++s,i[l]=!0),n.push(r)))})),s!==n.length){var l=function(t){var r=t;do{e?--r:++r,r<0?r=n.length-1:r>=n.length&&(r=0)}while(r!==t&&i[r]);return r===t?null:r}(n.indexOf(r));null!==l&&t.setState({selectedItem:n[l],forceSubMenuOpen:!1})}})),h(c(t),"onChildMouseMove",(function(e){t.state.selectedItem!==e&&t.setState({selectedItem:e,forceSubMenuOpen:!1})})),h(c(t),"onChildMouseLeave",(function(){t.setState({selectedItem:null,forceSubMenuOpen:!1})})),h(c(t),"renderChildren",(function(e){return o.default.Children.map(e,(function(e){var r={};return o.default.isValidElement(e)?[a.default,t.getSubMenuType()].indexOf(e.type)<0?(r.children=t.renderChildren(e.props.children),o.default.cloneElement(e,r)):(r.onMouseLeave=t.onChildMouseLeave.bind(c(t)),e.type===t.getSubMenuType()&&(r.forceOpen=t.state.forceSubMenuOpen&&t.state.selectedItem===e,r.forceClose=t.handleForceClose,r.parentKeyNavigationHandler=t.handleKeyNavigation),e.props.divider||t.state.selectedItem!==e?(r.onMouseMove=function(){return t.onChildMouseMove(e)},o.default.cloneElement(e,r)):(r.selected=!0,r.ref=function(e){t.seletedItemRef=e},o.default.cloneElement(e,r))):e}))})),t.seletedItemRef=null,t.state={selectedItem:null,forceSubMenuOpen:!1},t}return t=l,Object.defineProperty(t,"prototype",{writable:!1}),t}(o.Component);t.default=u,h(u,"propTypes",{children:s.default.node.isRequired})},6824:(e,t,r)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=u(r(7460)),s=u(r(764)),a=u(r(3368)),i=u(r(772)),l=u(r(9225)),p=u(r(315)),c=u(r(2349)),d=r(5451),h=r(3645);function u(e){return e&&e.__esModule?e:{default:e}}function b(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n={top:r,left:e};if(!t.menu)return n;var o=window,s=o.innerWidth,a=o.innerHeight,i=t.menu.getBoundingClientRect();return r+i.height>a&&(n.top-=i.height),e+i.width>s&&(n.left-=i.width),n.top<0&&(n.top=i.height0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n={top:r,left:e};if(!t.menu)return n;var o=window,s=o.innerWidth,a=o.innerHeight,i=t.menu.getBoundingClientRect();return n.left=e-i.width,r+i.height>a&&(n.top-=i.height),n.left<0&&(n.left+=i.width),n.top<0&&(n.top=i.heights&&(n.left=i.width{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var r=d(t);if(r&&r.has(e))return r.get(e);var o={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var i=s?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(o,a,i):o[a]=e[a]}return o.default=e,r&&r.set(e,o),o}(r(7460)),s=c(r(764)),a=c(r(3368)),i=c(r(772)),l=r(5451),p=r(3645);function c(e){return e&&e.__esModule?e:{default:e}}function d(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(d=function(e){return e?r:t})(e)}function h(e,t){for(var r=0;r=0&&0===t.button&&(t.persist(),t.stopPropagation(),e.mouseDownTimeoutId=setTimeout((function(){return e.handleContextClick(t)}),e.props.holdToDisplay)),(0,p.callIfExists)(e.props.attributes.onMouseDown,t)})),m(b(e),"handleMouseUp",(function(t){0===t.button&&clearTimeout(e.mouseDownTimeoutId),(0,p.callIfExists)(e.props.attributes.onMouseUp,t)})),m(b(e),"handleMouseOut",(function(t){0===t.button&&clearTimeout(e.mouseDownTimeoutId),(0,p.callIfExists)(e.props.attributes.onMouseOut,t)})),m(b(e),"handleTouchstart",(function(t){e.touchHandled=!1,e.props.holdToDisplay>=0&&(t.persist(),t.stopPropagation(),e.touchstartTimeoutId=setTimeout((function(){e.handleContextClick(t),e.touchHandled=!0}),e.props.holdToDisplay)),(0,p.callIfExists)(e.props.attributes.onTouchStart,t)})),m(b(e),"handleTouchEnd",(function(t){e.touchHandled&&t.preventDefault(),clearTimeout(e.touchstartTimeoutId),(0,p.callIfExists)(e.props.attributes.onTouchEnd,t)})),m(b(e),"handleContextMenu",(function(t){t.button===e.props.mouseButton&&e.handleContextClick(t),(0,p.callIfExists)(e.props.attributes.onContextMenu,t)})),m(b(e),"handleMouseClick",(function(t){t.button===e.props.mouseButton&&e.handleContextClick(t),(0,p.callIfExists)(e.props.attributes.onClick,t)})),m(b(e),"handleContextClick",(function(t){if(!(e.props.disable||e.props.disableIfShiftIsPressed&&t.shiftKey)){t.preventDefault(),t.stopPropagation();var r=t.clientX||t.touches&&t.touches[0].pageX,n=t.clientY||t.touches&&t.touches[0].pageY;e.props.posX&&(r-=e.props.posX),e.props.posY&&(n-=e.props.posY),(0,l.hideMenu)();var o=(0,p.callIfExists)(e.props.collect,e.props),s={position:{x:r,y:n},target:e.elem,id:e.props.id};o&&"function"==typeof o.then?o.then((function(e){s.data=(0,i.default)({},e,{target:t.target}),(0,l.showMenu)(s)})):(s.data=(0,i.default)({},o,{target:t.target}),(0,l.showMenu)(s))}})),m(b(e),"elemRef",(function(t){e.elem=t})),e}return t=A,(r=[{key:"render",value:function(){var e=this.props,t=e.renderTag,r=e.attributes,n=e.children,s=(0,i.default)({},r,{className:(0,a.default)(p.cssClasses.menuWrapper,r.className),onContextMenu:this.handleContextMenu,onClick:this.handleMouseClick,onMouseDown:this.handleMouseDown,onMouseUp:this.handleMouseUp,onTouchStart:this.handleTouchstart,onTouchEnd:this.handleTouchEnd,onMouseOut:this.handleMouseOut,ref:this.elemRef});return o.default.createElement(t,s,n)}}])&&h(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),A}(o.Component);t.default=A,m(A,"propTypes",{id:s.default.string.isRequired,children:s.default.node.isRequired,attributes:s.default.object,collect:s.default.func,disable:s.default.bool,holdToDisplay:s.default.number,posX:s.default.number,posY:s.default.number,renderTag:s.default.elementType,mouseButton:s.default.number,disableIfShiftIsPressed:s.default.bool}),m(A,"defaultProps",{attributes:{},collect:function(){return null},disable:!1,holdToDisplay:1e3,renderTag:"div",posX:0,posY:0,mouseButton:2,disableIfShiftIsPressed:!1})},1122:(e,t,r)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var r=d(t);if(r&&r.has(e))return r.get(e);var o={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var i=s?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(o,a,i):o[a]=e[a]}return o.default=e,r&&r.set(e,o),o}(r(7460)),s=c(r(764)),a=c(r(3368)),i=c(r(772)),l=r(5451),p=r(3645);function c(e){return e&&e.__esModule?e:{default:e}}function d(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(d=function(e){return e?r:t})(e)}function h(){return h=Object.assign||function(e){for(var t=1;t{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=h(r(7460)),s=h(r(764)),a=h(r(3368)),i=h(r(772)),l=r(5451),p=h(r(315)),c=r(3645),d=h(r(9225));function h(e){return e&&e.__esModule?e:{default:e}}function u(){return u=Object.assign||function(e){for(var t=1;tn?s.bottom=0:s.top=0,o.righte?n.bottom=0:n.top=0,r.left<0?n.left="100%":n.right="100%",n})),C(m(t),"hideMenu",(function(e){e.preventDefault(),t.hideSubMenu(e)})),C(m(t),"hideSubMenu",(function(e){e.detail&&e.detail.id&&t.menu&&e.detail.id!==t.menu.id||(t.props.forceOpen&&t.props.forceClose(),t.setState({visible:!1,selectedItem:null}),t.unregisterHandlers())})),C(m(t),"handleClick",(function(e){e.preventDefault(),t.props.disabled||((0,c.callIfExists)(t.props.onClick,e,(0,i.default)({},t.props.data,c.store.data),c.store.target),t.props.onClick&&!t.props.preventCloseOnClick&&(0,l.hideMenu)())})),C(m(t),"handleMouseEnter",(function(){t.closetimer&&clearTimeout(t.closetimer),t.props.disabled||t.state.visible||(t.opentimer=setTimeout((function(){return t.setState({visible:!0,selectedItem:null})}),t.props.hoverDelay))})),C(m(t),"handleMouseLeave",(function(){t.opentimer&&clearTimeout(t.opentimer),t.state.visible&&(t.closetimer=setTimeout((function(){return t.setState({visible:!1,selectedItem:null})}),t.props.hoverDelay))})),C(m(t),"menuRef",(function(e){t.menu=e})),C(m(t),"subMenuRef",(function(e){t.subMenu=e})),C(m(t),"registerHandlers",(function(){document.removeEventListener("keydown",t.props.parentKeyNavigationHandler),document.addEventListener("keydown",t.handleKeyNavigation)})),C(m(t),"unregisterHandlers",(function(e){document.removeEventListener("keydown",t.handleKeyNavigation),e||document.addEventListener("keydown",t.props.parentKeyNavigationHandler)})),t.state=(0,i.default)({},t.state,{visible:!1}),t}return t=f,(r=[{key:"componentDidMount",value:function(){this.listenId=d.default.register((function(){}),this.hideSubMenu)}},{key:"getSubMenuType",value:function(){return f}},{key:"shouldComponentUpdate",value:function(e,t){return this.isVisibilityChange=!(this.state.visible===t.visible&&this.props.forceOpen===e.forceOpen||this.state.visible&&e.forceOpen||this.props.forceOpen&&t.visible),!0}},{key:"componentDidUpdate",value:function(){var e=this;this.isVisibilityChange&&(this.props.forceOpen||this.state.visible?(window.requestAnimationFrame||setTimeout)((function(){var t=e.props.rtl?e.getRTLMenuPosition():e.getMenuPosition();e.subMenu.style.removeProperty("top"),e.subMenu.style.removeProperty("bottom"),e.subMenu.style.removeProperty("left"),e.subMenu.style.removeProperty("right"),(0,c.hasOwnProp)(t,"top")&&(e.subMenu.style.top=t.top),(0,c.hasOwnProp)(t,"left")&&(e.subMenu.style.left=t.left),(0,c.hasOwnProp)(t,"bottom")&&(e.subMenu.style.bottom=t.bottom),(0,c.hasOwnProp)(t,"right")&&(e.subMenu.style.right=t.right),e.subMenu.classList.add(c.cssClasses.menuVisible),e.registerHandlers(),e.setState({selectedItem:null})})):(this.subMenu.addEventListener("transitionend",(function t(){e.subMenu.removeEventListener("transitionend",t),e.subMenu.style.removeProperty("bottom"),e.subMenu.style.removeProperty("right"),e.subMenu.style.top=0,e.subMenu.style.left="100%",e.unregisterHandlers()})),this.subMenu.classList.remove(c.cssClasses.menuVisible)))}},{key:"componentWillUnmount",value:function(){this.listenId&&d.default.unregister(this.listenId),this.opentimer&&clearTimeout(this.opentimer),this.closetimer&&clearTimeout(this.closetimer),this.unregisterHandlers(!0)}},{key:"render",value:function(){var e,t=this.props,r=t.children,n=t.attributes,s=t.disabled,i=t.title,l=t.selected,p=this.state.visible,d={ref:this.menuRef,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,className:(0,a.default)(c.cssClasses.menuItem,c.cssClasses.subMenu,n.listClassName),style:{position:"relative"}},h={className:(0,a.default)(c.cssClasses.menuItem,n.className,(e={},C(e,(0,a.default)(c.cssClasses.menuItemDisabled,n.disabledClassName),s),C(e,(0,a.default)(c.cssClasses.menuItemActive,n.visibleClassName),p),C(e,(0,a.default)(c.cssClasses.menuItemSelected,n.selectedClassName),l),e)),onMouseMove:this.props.onMouseMove,onMouseOut:this.props.onMouseOut,onClick:this.handleClick},b={ref:this.subMenuRef,style:{position:"absolute",transition:"opacity 1ms",top:0,left:"100%"},className:(0,a.default)(c.cssClasses.menu,this.props.className)};return o.default.createElement("nav",u({},d,{role:"menuitem",tabIndex:"-1","aria-haspopup":"true"}),o.default.createElement("div",u({},n,h),i),o.default.createElement("nav",u({},b,{role:"menu",tabIndex:"-1"}),this.renderChildren(r)))}}])&&b(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),f}(p.default);t.default=f,C(f,"propTypes",{children:s.default.node.isRequired,attributes:s.default.object,title:s.default.node.isRequired,className:s.default.string,disabled:s.default.bool,hoverDelay:s.default.number,rtl:s.default.bool,selected:s.default.bool,onMouseMove:s.default.func,onMouseOut:s.default.func,forceOpen:s.default.bool,forceClose:s.default.func,parentKeyNavigationHandler:s.default.func}),C(f,"defaultProps",{disabled:!1,hoverDelay:500,attributes:{},className:"",rtl:!1,selected:!1,onMouseMove:function(){return null},onMouseOut:function(){return null},forceOpen:!1,forceClose:function(){return null},parentKeyNavigationHandler:function(){return null}})},5451:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MENU_SHOW=t.MENU_HIDE=void 0,t.dispatchGlobalEvent=l,t.hideMenu=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;l(i,(0,o.default)({},e,{type:i}),t)},t.showMenu=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;l(a,(0,o.default)({},e,{type:a}),t)};var n,o=(n=r(772))&&n.__esModule?n:{default:n},s=r(3645),a="REACT_CONTEXTMENU_SHOW";t.MENU_SHOW=a;var i="REACT_CONTEXTMENU_HIDE";function l(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window;"function"==typeof window.CustomEvent?r=new window.CustomEvent(e,{detail:t}):(r=document.createEvent("CustomEvent")).initCustomEvent(e,!1,!0,t),n&&(n.dispatchEvent(r),(0,o.default)(s.store,t))}t.MENU_HIDE=i},857:(e,t,r)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t){return function(r){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}(C,r);var s,i,l,g,m=(s=C,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=u(s);if(i){var r=u(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}(this,e)});function C(t){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,C),b(h(r=m.call(this,t)),"handleShow",(function(t){if(t.detail.id===e){var n=t.detail.data,o={};for(var s in n)A.includes(s)||(o[s]=n[s]);r.setState({trigger:o})}})),b(h(r),"handleHide",(function(){r.setState({trigger:null})})),r.state={trigger:null},r}return l=C,(g=[{key:"componentDidMount",value:function(){this.listenId=a.default.register(this.handleShow,this.handleHide)}},{key:"componentWillUnmount",value:function(){this.listenId&&a.default.unregister(this.listenId)}},{key:"render",value:function(){return o.default.createElement(t,p({},this.props,{id:e,trigger:this.state.trigger}))}}])&&c(l.prototype,g),Object.defineProperty(l,"prototype",{writable:!1}),C}(o.Component)}};var o=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var r=l(t);if(r&&r.has(e))return r.get(e);var o={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var i=s?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(o,a,i):o[a]=e[a]}return o.default=e,r&&r.set(e,o),o}(r(7460)),s=i(r(774)),a=i(r(9225));function i(e){return e&&e.__esModule?e:{default:e}}function l(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(l=function(e){return e?r:t})(e)}function p(){return p=Object.assign||function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r(5451),o=r(3645);function s(e,t){for(var r=0;r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.callIfExists=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{"use strict";Object.defineProperty(t,"tz",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(t,"Rc",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(t,"Dr",{enumerable:!0,get:function(){return s.default}});var n=a(r(6824)),o=a(r(774)),s=a(r(1122));a(r(2349)),a(r(857)),r(5451);function a(e){return e&&e.__esModule?e:{default:e}}},3903:(e,t,r)=>{"use strict";var n=r(7460),o=r(772),s=r(9798);function a(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r