"use strict";const PATH_TO_PREFIX_MAP = {
  Types: 'definition',
  Queries: 'query',
  Mutations: 'mutation',
  Subscriptions: 'subscription'
};

module.exports = function interpolateReferences(value, options) {
  if (typeof value !== 'string') {
    return value;
  }

  return value.replace(/{{(.*?)}}/g, (match, value) => {
    const [path, name] = value.split('.');
    const prefix = PATH_TO_PREFIX_MAP[path];
    if (!prefix) {var _options$data, _options$data$root, _options$data$root$al, _options$data$root$al2, _options$data$root$al3;
      const msg = `Unsupported interpolation encountered: "${match}"`;
      if (
      (options === null || options === void 0 ? void 0 : (_options$data = options.data) === null || _options$data === void 0 ? void 0 : (_options$data$root = _options$data.root) === null || _options$data$root === void 0 ? void 0 : (_options$data$root$al = _options$data$root.allOptions) === null || _options$data$root$al === void 0 ? void 0 : (_options$data$root$al2 = _options$data$root$al.specData) === null || _options$data$root$al2 === void 0 ? void 0 : (_options$data$root$al3 = _options$data$root$al2.spectaql) === null || _options$data$root$al3 === void 0 ? void 0 : _options$data$root$al3.
      errorOnInterpolationReferenceNotFound) !== false)
      {
        throw new Error(
          msg +
          '. You can change this to be a warning via the "errorOnInterpolationReferenceNotFound" option'
        );
      } else {
        console.warn('WARNING: ' + msg);
        return match;
      }
    }

    return `#${prefix}-${name}`;
  });
};