<commit_before>// Inlines assets as data: urls
//
//   If the url of the image has an 'inline' GET parameter, it is inlined if the parameter has a true (or no) value, eg.: foo.png?inline or foo.png?inline=true
//   Otherwise the image will be inlined if the size of the image is less than or equal to 'options.sizeThreshold' AND the Css asset only has that one relation to the image

const AssetGraph = require('../AssetGraph');

const defaultQueryObj = {
  isInline: false,
  query: { inline: value => value !== undefined }
};

module.exports = (queryObj, { minimumIeVersion = Infinity } = {}) => {
  if (queryObj) {
    queryObj = AssetGraph.query.and(queryObj, defaultQueryObj);
  } else {
    queryObj = defaultQueryObj;
  }

  return function inlineAssetsPerQueryString(assetGraph) {
    const minimumIeVersionByAsset = new Map(); // Asset => minimumIeVersion
    function getMinimumIeVersionUsage(asset, stack = []) {
      if (asset.type === 'Html') {
        return 1;
      }
      if (minimumIeVersionByAsset.has(asset)) {
        return minimumIeVersionByAsset.get(asset);
      }
      stack.push(asset);
      const minimumIeVersion = Math.min(
        ...asset.incomingRelations
          .filter(incomingRelation => !stack.includes(incomingRelation.from))
          .map(incomingRelation => {
            let matchCondition;
            if (incomingRelation.type === 'HtmlConditionalComment') {
              matchCondition = incomingRelation.condition.match(
                /^(gte?|lte?)\s+IE\s+(\d+)$/i
              );<commit_msg>Fix an occurrence of the old query syntax<commit_after>// Inlines assets as data: urls
//
//   If the url of the image has an 'inline' GET parameter, it is inlined if the parameter has a true (or no) value, eg.: foo.png?inline or foo.png?inline=true
//   Otherwise the image will be inlined if the size of the image is less than or equal to 'options.sizeThreshold' AND the Css asset only has that one relation to the image

const defaultQueryObj = {
  isInline: false,
  query: { inline: value => value !== undefined }
};

module.exports = (queryObj, { minimumIeVersion = Infinity } = {}) => {
  if (queryObj) {
    queryObj = { $and: [queryObj, defaultQueryObj] };
  } else {
    queryObj = defaultQueryObj;
  }

  return function inlineAssetsPerQueryString(assetGraph) {
    const minimumIeVersionByAsset = new Map(); // Asset => minimumIeVersion
    function getMinimumIeVersionUsage(asset, stack = []) {
      if (asset.type === 'Html') {
        return 1;
      }
      if (minimumIeVersionByAsset.has(asset)) {
        return minimumIeVersionByAsset.get(asset);
      }
      stack.push(asset);
      const minimumIeVersion = Math.min(
        ...asset.incomingRelations
          .filter(incomingRelation => !stack.includes(incomingRelation.from))
          .map(incomingRelation => {
            let matchCondition;
            if (incomingRelation.type === 'HtmlConditionalComment') {
              matchCondition = incomingRelation.condition.match(
                /^(gte?|lte?)\s+IE\s+(\d+)$/i
              );
{'fraction_non_alphanumeric': 0.11498371335504887, 'fraction_numerical': 0.0006514657980456026, 'mean_word_length': 2.8922686945500633, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4219757', 'n_tokens_mistral': 906, 'n_tokens_neox': 892, 'n_words': 255}