{
  "version": 3,
  "sources": ["/cdn/shop/t/2/assets/search-page-input.js?x=676287672"],
  "sourcesContent": ["import { Component } from '@theme/component';\nimport { debounce } from '@theme/utilities';\n\n/**\n * A custom element that allows the user to clean a search input.\n *\n * @typedef {object} Refs\n * @property {HTMLInputElement} searchPageInput - The search input element.\n * @extends {Component<Refs>}\n */\nclass SearchPageInputComponent extends Component {\n  requiredRefs = ['searchPageInput'];\n\n  /**\n   * Handles the keydown event on the search input and resets the search when\n   * empty and Escape is pressed.\n   *\n   * @param {KeyboardEvent} event - The keyboard event.\n   */\n  handleKeyDown = debounce((event) => {\n    const value = this.refs.searchPageInput.value.trim();\n\n    if (event.key === 'Escape' && value === '') {\n      this.#submitEmptySearch();\n    }\n  }, 100);\n\n  #submitEmptySearch() {\n    const searchInput = this.refs.searchPageInput;\n\n    searchInput.focus();\n    searchInput.value = '';\n\n    if (this.#isEmptyState()) return;\n\n    searchInput.form?.submit();\n  }\n\n  #isEmptyState = () => {\n    const url = new URL(window.location.href);\n    const queryParam = url.searchParams.get('q') ?? '';\n\n    return queryParam.trim() === '';\n  };\n}\n\nif (!customElements.get('search-page-input-component')) {\n  customElements.define('search-page-input-component', SearchPageInputComponent);\n}\n"],
  "mappings": "AAAA,OAAS,cAAiB,mBAC1B,OAAS,aAAgB,mBASzB,MAAM,iCAAiC,SAAU,CAC/C,aAAe,CAAC,iBAAiB,EAQjC,cAAgB,SAAU,OAAU,CAClC,MAAM,MAAQ,KAAK,KAAK,gBAAgB,MAAM,KAAK,EAE/C,MAAM,MAAQ,UAAY,QAAU,IACtC,KAAK,mBAAmB,CAE5B,EAAG,GAAG,EAEN,oBAAqB,CACnB,MAAM,YAAc,KAAK,KAAK,gBAE9B,YAAY,MAAM,EAClB,YAAY,MAAQ,GAEhB,MAAK,cAAc,GAEvB,YAAY,MAAM,OAAO,CAC3B,CAEA,cAAgB,KACF,IAAI,IAAI,OAAO,SAAS,IAAI,EACjB,aAAa,IAAI,GAAG,GAAK,IAE9B,KAAK,IAAM,EAEjC,CAEK,eAAe,IAAI,6BAA6B,GACnD,eAAe,OAAO,8BAA+B,wBAAwB",
  "names": []
}
