"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.configRuntimeResourceCleanup = configRuntimeResourceCleanup;

var _modeUtils = require("../common/modeUtils");

var _RuntimeResourceCleanup = _interopRequireDefault(require("../custom_plugins/RuntimeResourceCleanup"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function configRuntimeResourceCleanup(options) {
  const chunkLoadingGlobal = (0, _modeUtils.getGlobalCacheStorageName)(options);
  const {
    resourceCleanup: runtimeResourceCleanupEnabled,
    hasEFC: efcEnabled
  } = options.efc;
  const {
    customAttributes = {}
  } = options;

  if (efcEnabled && runtimeResourceCleanupEnabled) {
    return new _RuntimeResourceCleanup.default({ ...customAttributes,
      chunkLoadingGlobal
    });
  }

  return null;
}