<commit_before>/* eslint-disable import/default */

import { action } from 'dev-novel';
import instantsearch from '../../../index.js';
import item from './item.html';
import empty from './no-results.html';

export const wrapWithHits = (
  initWidget,
  instantSearchConfig = {}
) => container => {
  const {
    appId = 'latency',
    apiKey = '6be0576ff61c053d5f9a3225e2a90f76',
    indexName = 'instant_search',
    searchParameters = {},
    ...otherInstantSearchConfig
  } = instantSearchConfig;

  const urlLogger = action('[URL sync] pushstate: query string');
  window.search = instantsearch({
    appId,
    apiKey,
    indexName,
    searchParameters: {
      hitsPerPage: 3,
      ...searchParameters,
    },
    urlSync: {
      urlUtils: {
        onpopstate() {},
        pushState(qs) {
          urlLogger(this.createURL(qs));
        },
        createURL(qs) {
          return qs;
        },
        readUrl() {
          return '';
        },
      },
    },
    ...otherInstantSearchConfig,
  });

  container.innerHTML = `
    <div id="widget-display"></div>
    <div id="results-display">
      <div id="results-search-box-container"></div>
      <div id="results-hits-container"></div>
      <div id="results-pagination-container"></div>
    </div>
  `;
<commit_msg>docs(dev-novel): use the router for logging state (#3039)<commit_after>/* eslint-disable import/default */

import { action } from 'dev-novel';
import instantsearch from '../../../index.js';
import item from './item.html';
import empty from './no-results.html';

export const wrapWithHits = (
  initWidget,
  instantSearchConfig = {}
) => container => {
  const {
    appId = 'latency',
    apiKey = '6be0576ff61c053d5f9a3225e2a90f76',
    indexName = 'instant_search',
    searchParameters = {},
    ...otherInstantSearchConfig
  } = instantSearchConfig;

  const urlLogger = action('Routing state');
  window.search = instantsearch({
    appId,
    apiKey,
    indexName,
    searchParameters: {
      hitsPerPage: 3,
      ...searchParameters,
    },
    routing: {
      router: {
        write: routeState => {
          urlLogger(JSON.stringify(routeState, null, 2));
        },
        read: () => ({}),
        createURL: () => '',
        onUpdate: () => {},
      },
    },
    ...otherInstantSearchConfig,
  });

  container.innerHTML = `
    <div id="widget-display"></div>
    <div id="results-display">
      <div id="results-search-box-container"></div>
      <div id="results-hits-container"></div>
      <div id="results-pagination-container"></div>
    </div>
  `;

{'fraction_non_alphanumeric': 0.161804745235317, 'fraction_numerical': 0.019058732010890703, 'mean_word_length': 2.552486187845304, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 31, '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': '2245520', 'n_tokens_mistral': 835, 'n_tokens_neox': 808, 'n_words': 152}