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AiB,IAAI,MACzD,CAEA,OAAO,QAAU","file":"/npm/gltf-loader@1.0.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/gltf-loader@1.0.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const path = require(\"path\");\nconst loaderUtils = require(\"loader-utils\");\n\nconst isObject = (value) => typeof value === \"object\" && value !== null;\nconst isDataURI = (value) => /^data:/i.test(value);\n\n/**\n * A utility function that allows mapping the value for a given key in an object\n * [in place](https://en.wikipedia.org/wiki/In-place_algorithm).\n *\n * @remarks\n * This function recursively iterates through every key in the object.\n * Once a key strictly equal to the given key is found, the callback function\n * is invoked, and its return value (or resolved value) is then set as the new value\n * for that entry.\n *\n * @param {unknown} obj - The object to mutate.\n * @param {string} key - The key to match against.\n * @param {(value: unknown) => Promise<any>} callback\n * The callback that either returns the mapped value, or returns a Promise\n * that resolves to the new value.\n */\nasync function mapDeep(obj, key, callback) {\n  if (Array.isArray(obj)) {\n    for (const item of obj) {\n      await mapDeep(item, key, callback);\n    }\n  } else if (isObject(obj)) {\n    for (const [k, v] of Object.entries(obj)) {\n      if (k === key) {\n        obj[k] = await callback(v);\n      } else {\n        await mapDeep(v, key, callback);\n      }\n    }\n  }\n}\n\n/**\n * @typedef {import(\".\").GLTFLoaderDefinition} GLTFLoader\n * @this {ThisParameterType<GLTFLoader>}\n * @type {GLTFLoader}\n */\nasync function gltfLoader(content) {\n  // Destructure loader options and set default values:\n  const {\n    inline = false,\n    useRelativePaths = true,\n    uriResolver = (module) => String(module.default ?? module),\n    fileName = \"[name].[hash:8].[ext]\",\n    filePath = \"/static/media\",\n    publicPath = this._compilation?.outputOptions.publicPath ?? \"/\",\n    context = this.context,\n  } = this.getOptions();\n  // Parse the glTF data:\n  const data = JSON.parse(content);\n  // Iterate over the object and map any URIs:\n  await mapDeep(data, \"uri\", async (uri) => {\n    // Resolve early if the URI cannot be imported as a module:\n    if (!loaderUtils.isUrlRequest(uri)) return uri;\n    // If the URI is a data URI, print a warning and resolve with the original value:\n    if (isDataURI(uri)) {\n      this.emitWarning(\n        // prettier-ignore\n        new Error(\n            \"Detected a data URI attempting to load a glTF file.\\n\\n\" +\n            \"Prefer using local or remote URIs instead for better performance on the web. \" +\n            \"If you want to use self-contained files, consider using the `.glb` format.\"\n          ),\n      );\n      return uri;\n    }\n    // Get the asset's path as a relative module path:\n    const request = loaderUtils.urlToRequest(uri, context);\n    // Import the asset as a module (this ensures the files are loaded by their respective loaders):\n    const module = await this.importModule(request);\n    // Get the updated asset URI:\n    const updatedUri = uriResolver(module);\n    // If not using relative paths, return the resolved URI as-is:\n    if (!useRelativePaths) return updatedUri;\n    // Otherwise, return the URI relative to the path where this file will be emitted:\n    const assetPath = path.join(publicPath, filePath);\n    return path.relative(assetPath, updatedUri);\n  });\n  // Stringify the updated data:\n  const updatedContent = JSON.stringify(data);\n  // Interpolate any file name tokens:\n  const interpolatedName = loaderUtils.interpolateName(this, fileName, { content: updatedContent });\n  // Join the file path and interpolated name:\n  const interpolatedPath = path.join(filePath, interpolatedName);\n  // Emit the file:\n  this.emitFile(interpolatedPath, updatedContent, null);\n  // Join all paths together:\n  const fullPath = path.join(publicPath, interpolatedPath);\n  // Lastly, resolve with either the JSON data or the full output path:\n  return `export default ${inline ? updatedContent : `\"${fullPath}\"`}`;\n}\n\nmodule.exports = gltfLoader;\n"]}