<commit_before><template>
<div style="position: relative"
  v-bind:class="{'open':showDropdown}"
  >
  <input type="text" class="form-control"
    :placeholder="placeholder"
    autocomplete="off"
    v-model="query"
    @input="update"
    @keydown.up="up"
    @keydown.down="down"
    @keydown.enter= "hit"
    @keydown.esc="reset"
    @blur="showDropdown = false"
  />
  <ul class="dropdown-menu" v-el:dropdown>
    <li v-for="item in items" v-bind:class="{'active': isActive($index)}">
      <a @mousedown.prevent="hit" @mousemove="setActive($index)">
        <partial :name="templateName"></partial>
      </a>
    </li>
  </ul>
</div>

</template>

<script>
import callAjax from './utils/callAjax.js'
import coerceBoolean from './utils/coerceBoolean.js'

const typeahead = {
    created() {
      this.items = this.primitiveData
    },
    partials: {
      'default': '<span v-html="item | highlight query"></span>',
    },
    props: {
      data: {
        type: Array
      },
      limit: {
        type: Number,
        default: 8
      },
      async: {
        type: String
      },
      template: {
        type:String
      },
      templateName: {
        type:String,
        default: 'default'
      },
      key: {
        type: String
      },
      matchCase: {
        type: Boolean,
        coerce: coerceBoolean,
        default: false
      },
      onHit: {
        type: Function,
        default(items) {
          this.reset()
          this.query = items
        }
      },
      placeholder: {
        type: String
      }
    },
    data() {
      return {
        query: '',
        showDropdown: false,
        noResults: true,
        current: 0,
        items: [],
      }
    },
    computed: {
      primitiveData() {
        if (this.data) {
          return this.data.filter(value=> {
            value = this.matchCase ? value : value.toLowerCase();
            var query = this.matchCase ? this.query : this.query.toLowerCase();
            return value.indexOf(query) !== -1;
          }).slice(0, this.limit)
        }
      }
    },
    ready() {
      // register a partial:
      if (this.templateName && this.templateName!=='default')
      {
        Vue.partial(this.templateName, this.template)
      }
    },
    methods: {<commit_msg>Protect var from unintended transformation<commit_after><template>
<div style="position: relative"
  v-bind:class="{'open':showDropdown}"
  >
  <input type="text" class="form-control"
    :placeholder="placeholder"
    autocomplete="off"
    v-model="query"
    @input="update"
    @keydown.up="up"
    @keydown.down="down"
    @keydown.enter= "hit"
    @keydown.esc="reset"
    @blur="showDropdown = false"
  />
  <ul class="dropdown-menu" v-el:dropdown>
    <li v-for="item in items" v-bind:class="{'active': isActive($index)}">
      <a @mousedown.prevent="hit" @mousemove="setActive($index)">
        <partial :name="templateName"></partial>
      </a>
    </li>
  </ul>
</div>

</template>

<script>
import callAjax from './utils/callAjax.js'
import coerceBoolean from './utils/coerceBoolean.js'

const typeahead = {
    created() {
      this.items = this.primitiveData
    },
    partials: {
      'default': '<span v-html="item | highlight query"></span>',
    },
    props: {
      data: {
        type: Array
      },
      limit: {
        type: Number,
        default: 8
      },
      async: {
        type: String
      },
      template: {
        type:String
      },
      templateName: {
        type:String,
        default: 'default'
      },
      key: {
        type: String
      },
      matchCase: {
        type: Boolean,
        coerce: coerceBoolean,
        default: false
      },
      onHit: {
        type: Function,
        default(items) {
          this.reset()
          this.query = items
        }
      },
      placeholder: {
        type: String
      }
    },
    data() {
      return {
        query: '',
        showDropdown: false,
        noResults: true,
        current: 0,
        items: [],
      }
    },
    computed: {
      primitiveData() {
        var _this = this;
        
        if (this.data) {
          return this.data.filter(value=> {
            value = this.matchCase ? value : value.toLowerCase();
            var query = this.matchCase ? _this.query : _this.query.toLowerCase();
            return value.indexOf(query) !== -1;
          }).slice(0, this.limit)
        }
      }
    },
    ready() {
      // register a partial:
      if (this.templateName && this.templateName!=='default')
      {
        Vue.partial(this.templateName, this.template)
      }
    },
    methods: {
{'fraction_non_alphanumeric': 0.15122791900043084, 'fraction_numerical': 0.0017233950883239983, 'mean_word_length': 1.8276492082825821, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 37, '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': '1631031', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1453, 'n_words': 279}