<commit_before>module Carto
  module Api
    module InfowindowMigrator
      MUSTACHE_ROOT_PATH = 'lib/assets/javascripts/cartodb3/mustache-templates'.freeze

      def migrate_builder_infowindow(templated_element, mustache_dir: 'infowindows')
        return nil if templated_element.nil?

        template = templated_element['template']
        return templated_element if template.present?

        templated_sym = templated_element.deep_symbolize_keys

        old_template_name = templated_sym[:template_name]

        if MIGRATED_TEMPLATES.include?(old_template_name)
          new_template_name = 'infowindow_color'

          fixed_color = extract_color_from_old_template(old_template_name)

          template_content_path = "#{MUSTACHE_ROOT_PATH}/#{mustache_dir}/infowindow_color.jst.mustache"

          templated_element[:template] = get_template(
            new_template_name,
            templated_sym[:template],
            template_content_path).gsub('#35AAE5', fixed_color)

          templated_element[:headerColor] = {
            color: {
              opacity: 1,
              fixed: fixed_color
            }
          }
        else<commit_msg>Avoid migrating none template fixes #8223<commit_after>module Carto
  module Api
    module InfowindowMigrator
      MUSTACHE_ROOT_PATH = 'lib/assets/javascripts/cartodb3/mustache-templates'.freeze

      def migrate_builder_infowindow(templated_element, mustache_dir: 'infowindows')
        return nil if templated_element.nil?

        template = templated_element['template']
        return templated_element if template.present?

        templated_sym = templated_element.deep_symbolize_keys

        old_template_name = templated_sym[:template_name]
        return templated_element if old_template_name == 'none'

        if MIGRATED_TEMPLATES.include?(old_template_name)
          new_template_name = 'infowindow_color'

          fixed_color = extract_color_from_old_template(old_template_name)

          template_content_path = "#{MUSTACHE_ROOT_PATH}/#{mustache_dir}/infowindow_color.jst.mustache"

          templated_element[:template] = get_template(
            new_template_name,
            templated_sym[:template],
            template_content_path).gsub('#35AAE5', fixed_color)

          templated_element[:headerColor] = {
            color: {
              opacity: 1,
              fixed: fixed_color
            }
          }
        else
{'fraction_non_alphanumeric': 0.0727796052631579, 'fraction_numerical': 0.005756578947368421, 'mean_word_length': 2.861904761904762, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6021282', 'n_tokens_mistral': 726, 'n_tokens_neox': 720, 'n_words': 103}