<commit_before><template>
  <!-- eslint-disable vue/attribute-hyphenation  -->
  <v-menu
    v-model="menuModel"
    max-height="75vh"
    offset-y
    readonly
    @input="resetSearch"
  >
    <template #activator="{ attrs }">
      <v-text-field
        ref="searchInput"
        v-model="searchString"
        v-bind="attrs"
        :background-color="(!theme.isDark && !isFocused) ? 'grey lighten-3' : undefined"
        :class="isSearching ? 'rounded-b-0' : ' rounded-lg'"
        :flat="!isFocused && !isSearching"
        :placeholder="placeholder"
        autocomplete="off"
        class="mx-2 mx-md-4"
        dense
        hide-details
        solo
        style="max-width: 450px;"
        @focus="onFocus"
      >
        <template #prepend-inner>
          <v-icon
            :color="!isFocused ? 'grey' : undefined"
            class="ml-1 mr-2"
          >
            $mdiMagnify
          </v-icon>
        </template>
      </v-text-field>
    </template>

    <v-card>
      <ais-instant-search
        :search-client="searchClient"
        :search-function="searchFunction"
        index-name="vuetifyjs"
      >
        <ais-configure
          :facetFilters="[`language:${locale}`]"
          :query="searchString"
        />

        <ais-hits v-slot="{ items }">
          <search-results :groups="transformItems(items)" />
        </ais-hits>
      </ais-instant-search>

      <ais-powered-by />
    </v-card>
  </v-menu>
</template>

<script>
  // Utilities
  import { get } from 'vuex-pathify'
  import { groupItems, sortItems } from 'vuetify/lib/util/helpers'
  import algoliasearch from 'algoliasearch'
  import SearchResults from './SearchResults'

  // Globals
  import { IN_BROWSER } from '@/util/globals'

  // This behavior should be easier to do with solo fields
  // TODO: Review this for v3
  export default {
    name: 'DefaultSearch',

    components: { SearchResults },

    inject: ['theme'],

    data: () => ({
      isFocused: false,
      menuModel: false,
      searchClient: algoliasearch(
        'BH4D9OD16A', // docsearch app ID
        '259d4615e283a1bbaa3313b4eff7881c' // vuetify API key
      ),
      searchString: '',
    }),

    computed: {
      locale: get('route/params@locale'),
      search: get('route/query@search'),
      isSearching () {
        return this.searchString && this.searchString.length > 0
      },
      placeholder () {
        let placeholder = this.$t('search.placeholder')

        if (!this.$vuetify.breakpoint.mobile) {
          placeholder += ' ' + this.$t('search.key-hint')
        }

        return placeholder
      },
    },

    watch: {
      isSearching (val) {
        val
          ? this.menuModel = true
          : this.resetSearch()
      },
    },

    mounted () {
      if (!IN_BROWSER) return

      document.addEventListener('keydown', this.onDocumentKeydown)<commit_msg>docs(search): pass search query to searchbar<commit_after><template>
  <!-- eslint-disable vue/attribute-hyphenation  -->
  <v-menu
    v-model="menuModel"
    max-height="75vh"
    offset-y
    readonly
    @input="resetSearch"
  >
    <template #activator="{ attrs }">
      <v-text-field
        ref="searchInput"
        v-model="searchString"
        v-bind="attrs"
        :background-color="(!theme.isDark && !isFocused) ? 'grey lighten-3' : undefined"
        :class="isSearching ? 'rounded-b-0' : ' rounded-lg'"
        :flat="!isFocused && !isSearching"
        :placeholder="placeholder"
        autocomplete="off"
        class="mx-2 mx-md-4"
        dense
        hide-details
        solo
        style="max-width: 450px;"
        @focus="onFocus"
      >
        <template #prepend-inner>
          <v-icon
            :color="!isFocused ? 'grey' : undefined"
            class="ml-1 mr-2"
          >
            $mdiMagnify
          </v-icon>
        </template>
      </v-text-field>
    </template>

    <v-card>
      <ais-instant-search
        :search-client="searchClient"
        :search-function="searchFunction"
        index-name="vuetifyjs"
      >
        <ais-configure
          :facetFilters="[`language:${locale}`]"
          :query="searchString"
        />

        <ais-hits v-slot="{ items }">
          <search-results :groups="transformItems(items)" />
        </ais-hits>
      </ais-instant-search>

      <ais-powered-by />
    </v-card>
  </v-menu>
</template>

<script>
  // Utilities
  import { get } from 'vuex-pathify'
  import { groupItems, sortItems } from 'vuetify/lib/util/helpers'
  import algoliasearch from 'algoliasearch'
  import SearchResults from './SearchResults'

  // Globals
  import { IN_BROWSER } from '@/util/globals'

  // This behavior should be easier to do with solo fields
  // TODO: Review this for v3
  export default {
    name: 'DefaultSearch',

    components: { SearchResults },

    inject: ['theme'],

    data: () => ({
      isFocused: false,
      menuModel: false,
      searchClient: algoliasearch(
        'BH4D9OD16A', // docsearch app ID
        '259d4615e283a1bbaa3313b4eff7881c' // vuetify API key
      ),
      searchString: '',
    }),

    computed: {
      locale: get('route/params@locale'),
      search: get('route/query@search'),
      isSearching () {
        return this.searchString && this.searchString.length > 0
      },
      placeholder () {
        let placeholder = this.$t('search.placeholder')

        if (!this.$vuetify.breakpoint.mobile) {
          placeholder += ' ' + this.$t('search.key-hint')
        }

        return placeholder
      },
    },

    watch: {
      isSearching (val) {
        val
          ? this.menuModel = true
          : this.resetSearch()
      },
    },

    mounted () {
      if (!IN_BROWSER) return
      if (this.search) {
        this.$nextTick(() => {
          this.searchString = this.search
          this.$refs.searchInput.focus()
        })
      }

      document.addEventListener('keydown', this.onDocumentKeydown)
{'fraction_non_alphanumeric': 0.14429699311271627, 'fraction_numerical': 0.01243070720645053, 'mean_word_length': 2.0025214321734746, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 54, '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': '4882558', 'n_tokens_mistral': 1946, 'n_tokens_neox': 1861, 'n_words': 338}