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I,EAAQ,KAAO,EAAQ,IAAK,CAS9B,IAFwC,IAAtC,EAAS,QAAQ,gBAEoB,CACrC,MAAM,EAAY,gBAClB,EAAU,QAAU,EAAiB,OAAO,EAAU,SACtD,EAAS,IAAI,KAAW,EAC1B,CACF,CAEA,MAAO,IACF,KACA,EAEP,CAEA,MAAM,UAAiD,EACrD,WACA,UACA,MACA,cAEA,MAAM,EAAgB,QAAQ,IAAI,UAClC,QAAQ,IAAI,UAAY,EAAQ,IAC5B,cACA,QAAQ,IAAI,WAAa,aAE7B,IACE,MAAM,EAAsC,CAE1C,WAAY,iBACT,iBAAiB,EAAU,EAAS,GACvC,OAAQ,CAAC,KAAM,QAAS,QAAS,QAAS,SAAU,EAAQ,UAC5D,KAAK,EAML,eAAe,GAEX,EACJ,mBAAmB,IACnB,YAAY,KACX,EAAQ,aACL,UAAU,EAAK,GAEf,QAAQ,iBAAiB,MAAM,EAAK,CAClC,OAAO,EACP,mBAAoB,KACpB,WAAY,EAAY,aAG1B,EACJ,qBAAqB,EAAW,EAAK,GAGvC,OAAK,EAME,CAAC,IAAK,WAAW,EAAO,KAAM,SAAU,EAAO,UAH7C,CAAC,IAAK,KAIjB,CAAE,QACI,IACF,QAAQ,IAAI,UAAY,EAE5B,GAGF,SAAS,cACP,IAAI,EAAM,OAAO,WAAW,OAE5B,OADA,cAAc,SAAQ,GAAQ,EAAI,OAAO,KAClC,EAAI,OAAO,MACpB,CAEA,MAAM,iBAA2C,CAC/C,oBACA,yBAGF,OAAO,QAAU","file":"/npm/@react-native/metro-babel-transformer@0.82.1/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@react-native/metro-babel-transformer@0.82.1/src/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","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n * @format\n */\n\n// This file uses Flow comment syntax so that it may be used from source as a\n// transformer without itself requiring transformation, such as in\n// facebook/react-native's own tests.\n\n'use strict';\n\n/*::\nimport type {BabelCoreOptions, Plugins, TransformResult} from '@babel/core';\nimport type {\n  BabelTransformer,\n  MetroBabelFileMetadata,\n} from 'metro-babel-transformer';\n*/\n\nconst {parseSync, transformFromAstSync} = require('@babel/core');\nconst makeHMRConfig = require('@react-native/babel-preset/src/configs/hmr');\nconst crypto = require('crypto');\nconst fs = require('fs');\nconst nullthrows = require('nullthrows');\nconst path = require('path');\n\nconst cacheKeyParts = [fs.readFileSync(__filename)];\n\n// TS detection conditions copied from @react-native/babel-preset\nfunction isTypeScriptSource(fileName /*: string */) {\n  return !!fileName && fileName.endsWith('.ts');\n}\n\nfunction isTSXSource(fileName /*: string */) {\n  return !!fileName && fileName.endsWith('.tsx');\n}\n\n/**\n * Return a memoized function that checks for the existence of a\n * project level .babelrc file, and if it doesn't exist, reads the\n * default RN babelrc file and uses that.\n */\nconst getBabelRC = (function () {\n  let babelRC /*: ?BabelCoreOptions */ = null;\n\n  /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's\n   * LTI update could not be added via codemod */\n  return function _getBabelRC({\n    projectRoot,\n    extendsBabelConfigPath,\n    ...options\n  }) {\n    if (babelRC != null) {\n      return babelRC;\n    }\n\n    babelRC = {\n      plugins: [],\n      extends: extendsBabelConfigPath,\n    };\n\n    if (extendsBabelConfigPath) {\n      return babelRC;\n    }\n\n    // Let's look for a babel config file in the project root.\n    let projectBabelRCPath;\n\n    // .babelrc\n    if (projectRoot) {\n      projectBabelRCPath = path.resolve(projectRoot, '.babelrc');\n    }\n\n    if (projectBabelRCPath) {\n      // .babelrc.js\n      if (!fs.existsSync(projectBabelRCPath)) {\n        projectBabelRCPath = path.resolve(projectRoot, '.babelrc.js');\n      }\n\n      // babel.config.js\n      if (!fs.existsSync(projectBabelRCPath)) {\n        projectBabelRCPath = path.resolve(projectRoot, 'babel.config.js');\n      }\n\n      // If we found a babel config file, extend our config off of it\n      // otherwise the default config will be used\n      if (fs.existsSync(projectBabelRCPath)) {\n        // $FlowFixMe[incompatible-use] `extends` is missing in null or undefined.\n        babelRC.extends = projectBabelRCPath;\n      }\n    }\n\n    // If a babel config file doesn't exist in the project then\n    // the default preset for react-native will be used instead.\n    // $FlowFixMe[incompatible-use] `extends` is missing in null or undefined.\n    // $FlowFixMe[incompatible-type] `extends` is missing in null or undefined.\n    if (!babelRC.extends) {\n      const {experimentalImportSupport, ...presetOptions} = options;\n\n      // $FlowFixMe[incompatible-use] `presets` is missing in null or undefined.\n      babelRC.presets = [\n        [\n          require('@react-native/babel-preset'),\n          {\n            projectRoot,\n            ...presetOptions,\n            disableImportExportTransform: experimentalImportSupport,\n            enableBabelRuntime: options.enableBabelRuntime,\n          },\n        ],\n      ];\n    }\n\n    return babelRC;\n  };\n})();\n\n/**\n * Given a filename and options, build a Babel\n * config object with the appropriate plugins.\n */\nfunction buildBabelConfig(\n  filename /*: string */,\n  /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's\n   * LTI update could not be added via codemod */\n  options,\n  plugins /*:: ?: Plugins*/ = [],\n) /*: BabelCoreOptions*/ {\n  const babelRC = getBabelRC(options);\n\n  const extraConfig /*: BabelCoreOptions */ = {\n    babelrc:\n      typeof options.enableBabelRCLookup === 'boolean'\n        ? options.enableBabelRCLookup\n        : true,\n    code: false,\n    cwd: options.projectRoot,\n    filename,\n    highlightCode: true,\n  };\n\n  let config /*: BabelCoreOptions */ = {\n    ...babelRC,\n    ...extraConfig,\n  };\n\n  const withExtraPlugins = (config.plugins = [\n    ...(config.plugins ?? []),\n    ...plugins,\n  ]);\n\n  if (options.dev && options.hot) {\n    // Note: this intentionally doesn't include the path separator because\n    // I'm not sure which one it should use on Windows, and false positives\n    // are unlikely anyway. If you later decide to include the separator,\n    // don't forget that the string usually *starts* with \"node_modules\" so\n    // the first one often won't be there.\n    const mayContainEditableReactComponents =\n      filename.indexOf('node_modules') === -1;\n\n    if (mayContainEditableReactComponents) {\n      const hmrConfig = makeHMRConfig();\n      hmrConfig.plugins = withExtraPlugins.concat(hmrConfig.plugins);\n      config = {...config, ...hmrConfig};\n    }\n  }\n\n  return {\n    ...babelRC,\n    ...config,\n  };\n}\n\nconst transform /*: BabelTransformer['transform'] */ = ({\n  filename,\n  options,\n  src,\n  plugins,\n}) => {\n  const OLD_BABEL_ENV = process.env.BABEL_ENV;\n  process.env.BABEL_ENV = options.dev\n    ? 'development'\n    : process.env.BABEL_ENV || 'production';\n\n  try {\n    const babelConfig /*: BabelCoreOptions */ = {\n      // ES modules require sourceType='module' but OSS may not always want that\n      sourceType: 'unambiguous',\n      ...buildBabelConfig(filename, options, plugins),\n      caller: {name: 'metro', bundler: 'metro', platform: options.platform},\n      ast: true,\n\n      // NOTE(EvanBacon): We split the parse/transform steps up to accommodate\n      // Hermes parsing, but this defaults to cloning the AST which increases\n      // the transformation time by a fair amount.\n      // You get this behavior by default when using Babel's `transform` method directly.\n      cloneInputAst: false,\n    };\n    const sourceAst /*: BabelNodeFile */ =\n      isTypeScriptSource(filename) ||\n      isTSXSource(filename) ||\n      !options.hermesParser\n        ? parseSync(src, babelConfig)\n        : // $FlowFixMe[incompatible-exact]\n          require('hermes-parser').parse(src, {\n            babel: true,\n            reactRuntimeTarget: '19',\n            sourceType: babelConfig.sourceType,\n          });\n\n    const result /*: TransformResult<MetroBabelFileMetadata> */ =\n      transformFromAstSync(sourceAst, src, babelConfig);\n\n    // The result from `transformFromAstSync` can be null (if the file is ignored)\n    if (!result) {\n      /* $FlowFixMe[incompatible-type] BabelTransformer specifies that the `ast` can never be null but\n       * the function returns here. Discovered when typing `BabelNode`. */\n      return {ast: null};\n    }\n\n    return {ast: nullthrows(result.ast), metadata: result.metadata};\n  } finally {\n    if (OLD_BABEL_ENV) {\n      process.env.BABEL_ENV = OLD_BABEL_ENV;\n    }\n  }\n};\n\nfunction getCacheKey() {\n  var key = crypto.createHash('md5');\n  cacheKeyParts.forEach(part => key.update(part));\n  return key.digest('hex');\n}\n\nconst babelTransformer /*: BabelTransformer */ = {\n  transform,\n  getCacheKey,\n};\n\nmodule.exports = babelTransformer;\n"]}