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L,EACK,2GAMF,gJAOT,cAAA,CAAe,EAAa,GAC1B,IAAK,EACH,OAAO,EAGT,IAAI,EAAc,EAAS,KAAK,MAChC,OAAO,EAAQ,YAAY,EAAa,EAC5C,EAEE,QAAA,GACE,GAA8B,mBAAnB,KAAK,UACd,OAAO,KAAK,YACP,CAKL,IAAI,EACA,EAAU,KACd,GACG,EAAM,EAAQ,KAAO,WACf,EAAQ,QAAU,EAAQ,OAAO,SAAW,EAAU,EAAQ,SAEvE,OAAO,CACb,CACA,G","file":"/npm/ember-fetch@8.1.2/index.js/+esm","sourceRoot":"","sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.\n * Original file: /npm/ember-fetch@8.1.2/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","'use strict';\n\nconst caniuse = require('caniuse-api');\nconst path = require('path');\n// We use a few different Broccoli plugins to build our trees:\n//\n// broccoli-templater: renders the contents of a file inside a template.\n// Used to wrap the browser polyfill in a shim that prevents it from exporting\n// a global.\n//\n// broccoli-merge-trees: merge several broccoli trees (folders) to a single tree\n//\n// broccoli-concat: concatenate input files to single output file\n//\n// broccoli-stew: super useful library of Broccoli utilities. We use:\n//\n//   * find - finds files in a tree based on a glob pattern\n//   * map - map content of files in a tree\n//\n// broccoli-rollup: rollup dependencies to expected module format\n//\nconst stew = require('broccoli-stew');\nconst Template = require('broccoli-templater');\nconst MergeTrees = require('broccoli-merge-trees');\nconst concat = require('broccoli-concat');\nconst map = stew.map;\nconst Rollup = require('broccoli-rollup');\nconst BroccoliDebug = require('broccoli-debug');\nconst calculateCacheKeyForTree = require('calculate-cache-key-for-tree');\nconst VersionChecker = require('ember-cli-version-checker');\n\nconst debug = BroccoliDebug.buildDebugCallback('ember-fetch');\n\n// Path to the template that contains the shim wrapper around the browser polyfill\nconst TEMPLATE_PATH = path.resolve(__dirname + '/assets/browser-fetch.js.t');\n\n/*\n * The `index.js` file is the main entry point for all Ember CLI addons.  The\n * object we export from this file is turned into an Addon class\n * (https://github.com/ember-cli/ember-cli/blob/master/lib/models/addon.js) by\n * Ember CLI.\n *\n * This addon is relatively simple: it includes both `node-fetch` and\n * `whatwg-fetch` as npm dependencies, and swaps the correct version in\n * depending on whether the Ember app is being built for FastBoot or the\n * browser.\n *\n * At a high-level, the flow for this addon is:\n *\n * 1. When a build starts and the addon is included, tell Ember CLI to import\n *    `vendor/fetch.js` into the vendor.js file. `vendor/fetch.js` doesn't\n *    actually exist yet; we'll create it later.\n * 2. When Ember CLI asks for the addon's vendor tree, we'll return a Broccoli\n *    tree that contains the correct fetch() version.\n * 3. In the case of the browser polyfill, we wrap it in a shim that that makes\n *    it compatible with Ember's module system. (Normally the polyfill exports a\n *    global, but we can rely on the fact that Ember users are using modules.)\n */\nmodule.exports = {\n  name: 'ember-fetch',\n\n  /*\n   * The `included` hook is invoked at the very beginning of the build process.\n   * It gets passed the `EmberApp` model\n   * (https://github.com/ember-cli/ember-cli/blob/master/lib/broccoli/ember-app.js),\n   * which allows us to use the `import()` method to tell it to include a file\n   * from our `vendor` tree into the final built app.\n   */\n  included: function() {\n    this._super.included.apply(this, arguments);\n\n    let isApp = !this.project.isEmberCLIAddon();\n\n    let hasEmberFetch = !!this.project.findAddonByName('ember-fetch');\n    let hasEmberCliFastboot = !!this.project.findAddonByName('ember-cli-fastboot');\n\n    let emberSource = new VersionChecker(this.project).for('ember-source');\n    let hasEmberSourceModules = emberSource.exists() && emberSource.gte('3.27.0');\n\n    if(isApp && hasEmberCliFastboot && !hasEmberFetch) {\n      throw new Error(`Ember fetch is not installed as top-level dependency of the application using fastboot. Add ember-fetch as dependecy in application's package.json.\n      For details check here - https://github.com/ember-cli/ember-fetch#top-level-addon`);\n    }\n\n    let app = this._findApp();\n    let importTarget = app;\n\n    if (typeof this.import === 'function') {\n      importTarget = this;\n    }\n\n    app._fetchBuildConfig = Object.assign({\n      preferNative: false,\n      nativePromise: false,\n      alwaysIncludePolyfill: false,\n      hasEmberSourceModules,\n      browsers: this.project.targets && this.project.targets.browsers\n    }, app.options['ember-fetch']);\n\n    importTarget.import('vendor/ember-fetch.js', {\n      exports: {\n        default: [\n          'default',\n          'Headers',\n          'Request',\n          'Response',\n          'AbortController'\n        ]\n      }\n    });\n  },\n\n  /*\n   * Returns a Broccoli tree for the addon's `vendor` directory. The `vendor`\n   * directory is kind of a junk drawer; nothing we put in it is used unless we\n   * explicitly `import()` a file (which we do in the `included` hook, above).\n   *\n   * To build our tree, we first pass in option flags and detect whether we're\n   * in a FastBoot build or not. Based on that, we return a tree that contains\n   * the correct version of the polyfill at the `vendor/ember-fetch.js` path.\n   */\n  treeForVendor() {\n    let babelAddon = this.addons.find(addon => addon.name === 'ember-cli-babel');\n\n    const app = this._findApp();\n    const options = app._fetchBuildConfig;\n\n    let browserTree = this.treeForBrowserFetch(options);\n    if (babelAddon) {\n      browserTree = debug(babelAddon.transpileTree(browserTree, {\n        'ember-cli-babel': {\n          compileModules: false,\n        },\n      }), 'after-babel');\n\n    } else {\n      this.ui.writeWarnLine('[ember-fetch] Could not find `ember-cli-babel` addon, opting out of transpilation!')\n    }\n\n    const preferNative = options.preferNative;\n\n    return debug(map(browserTree, (content) => `if (typeof FastBoot === 'undefined') {\n      var preferNative = ${preferNative};\n      ${content}\n    }`), 'wrapped');\n  },\n\n  // Only include public/fetch-fastboot.js if top level addon\n  treeForPublic() {\n    const fastbootEnabled = process.env.FASTBOOT_DISABLED !== 'true'\n      && !!this.project.findAddonByName('ember-cli-fastboot');\n    return !this.parent.parent && fastbootEnabled\n      ? this._super.treeForPublic.apply(this, arguments) : null;\n  },\n\n  cacheKeyForTree(treeType) {\n    if (treeType === 'public') {\n      return calculateCacheKeyForTree('public', this, [!this.parent.parent]);\n    } else {\n      // make sure results of other treeFor* methods won't get opt-out of cache\n      // including the \"treeForVendor\"\n      return calculateCacheKeyForTree(treeType, this);\n    }\n  },\n\n  // Add node version of fetch.js into fastboot package.json manifest vendorFiles array\n  updateFastBootManifest(manifest) {\n    manifest.vendorFiles.push('ember-fetch/fetch-fastboot.js');\n    return manifest;\n  },\n\n  // Returns a tree containing the browser polyfill (from `whatwg-fetch` and `abortcontroller-polyfill`),\n  // wrapped in a shim that stops it from exporting a global and instead turns it into a module\n  // that can be used by the Ember app.\n  treeForBrowserFetch(options) {\n    const browsers = options.browsers;\n    // To skip including the polyfill, `preferNative` needs to be `true` AND `alwaysIncludePolyfill` needs to be `false` (default)\n    const alwaysIncludePolyfill = !options.preferNative || options.alwaysIncludePolyfill;\n    const needsFetchPolyfill = alwaysIncludePolyfill || !this._checkSupports('fetch', browsers);\n    const needsAbortControllerPolyfill = alwaysIncludePolyfill || !this._checkSupports('abortcontroller', browsers);\n\n    const inputNodes = [];\n    const inputFiles = [];\n\n    if (needsAbortControllerPolyfill) {\n      const abortcontrollerNode = debug(new Rollup(path.dirname(path.dirname(require.resolve('abortcontroller-polyfill'))), {\n        rollup: {\n          input: 'src/abortcontroller-polyfill.js',\n          output: {\n            file: 'abortcontroller.js',\n            // abortcontroller is polyfill only, the name is only required by rollup iife\n            name: 'AbortController',\n            format: 'iife'\n          }\n        }\n      }), 'abortcontroller');\n\n      inputNodes.push(abortcontrollerNode);\n      inputFiles.push('abortcontroller.js');\n    }\n\n    if (needsFetchPolyfill) {\n      const fetchNode = debug(new Rollup(path.dirname(path.dirname(require.resolve('whatwg-fetch'))), {\n        rollup: {\n          input: 'fetch.js',\n          output: {\n            file: 'fetch.js',\n            name: 'WHATWGFetch',\n            format: 'iife'\n          }\n        }\n      }), 'whatwg-fetch');\n\n      inputNodes.push(fetchNode);\n      inputFiles.push('fetch.js');\n    }\n\n    const polyfillNode = debug(concat(new MergeTrees(inputNodes), {\n      inputFiles,\n      allowNone: true,\n      outputFile: 'ember-fetch.js',\n      sourceMapConfig: { enabled: false }\n    }), 'after-concat');\n\n    const moduleHeader = this._getModuleHeader(options);\n\n    return debug(\n      new Template(polyfillNode, TEMPLATE_PATH, function (content) {\n        return {\n          moduleHeader,\n          moduleBody: content,\n        };\n      }),\n      \"browser-fetch\"\n    );\n  },\n\n  _getModuleHeader({ hasEmberSourceModules, nativePromise }) {\n    if (hasEmberSourceModules && nativePromise) {\n      return `\ndefine('fetch', ['exports', 'ember'], function(exports, Ember__module) {\n  'use strict';\n  var Ember = 'default' in Ember__module ? Ember__module['default'] : Ember__module;`;\n    }\n\n    if (hasEmberSourceModules) {\n      return `\ndefine('fetch', ['exports', 'ember', 'rsvp'], function(exports, Ember__module, RSVP__module) {\n  'use strict';\n  var Ember = 'default' in Ember__module ? Ember__module['default'] : Ember__module;\n  var RSVP = 'default' in RSVP__module ? RSVP__module['default'] : RSVP__module;\n  var Promise = RSVP.Promise;`;\n    }\n\n    if (nativePromise) {\n      return `\ndefine('fetch', ['exports'], function(exports) {\n  'use strict';\n  var Ember = originalGlobal.Ember;`;\n    }\n\n    return `\ndefine('fetch', ['exports'], function(exports) {\n  'use strict';\n  var Ember = originalGlobal.Ember;\n  var Promise = Ember.RSVP.Promise;`;\n  },\n\n  _checkSupports(featureName, browsers) {\n    if (!browsers) {\n      return false;\n    }\n\n    let browserList = browsers.join(', ');\n    return caniuse.isSupported(featureName, browserList);\n  },\n\n  _findApp() {\n    if (typeof this._findHost === 'function') {\n      return this._findHost();\n    } else {\n      // Otherwise, we'll use this implementation borrowed from the _findHost()\n      // method in ember-cli.\n      // Keep iterating upward until we don't have a grandparent.\n      // Has to do this grandparent check because at some point we hit the project.\n      let app;\n      let current = this;\n      do {\n         app = current.app || this;\n      } while (current.parent && current.parent.parent && (current = current.parent));\n\n      return app;\n    }\n  },\n};\n"]}