1import{_ as i,a as r}from"./chunk-vendor-di.Bh23gdA.js";import{P as _,e as o,t as m,E as u,$ as h,V as Q,b as O,F as M,d as R,U as F}from"./chunk-vendor-lit.NvY0u02.js";import{p as y}from"./chunk-phoenix_custom_element.-3oJuZO.js";import{O as B}from"./chunk-observer.oe4_irb.js";import{C as N}from"./chunk-context_consumer_controller.DQ84A7A.js";import{B as W}from"./chunk-behavior_subject.BGn-8a7.js";import{C as X}from"./chunk-context_provider_controller.CCbkLM7.js";import{B as G,D as Z}from"./chunk-relative_position_controller_constants.D8T_ePx.js";import{v as x}from"./chunk-v4.FWzwXvE.js";import{M as J}from"./chunk-modal_constants.RvL-5Lb.js";import{S as ee}from"./chunk-sheet_constants.BGkaDhX.js";import{F as te,a as se}from"./chunk-focus_trap_controller.DPCVDzb.js";import{a,S as l,b as g,E as ie,c as K,d as re,D as ae,e as k,f}from"./chunk-search_constants.BTyTVBH.js";import{B as L}from"./chunk-btn_controller.BPcEEeZ.js";import{d as q,r as U,q as ne}from"./chunk-vendor-lodash.CWHFt7Z.js";import{c as oe}from"./chunk-icon_constants.BVm6Vwv.js";import"./chunk-subject.nuVoBpB.js";import"./chunk-keystrokes_controller.BSiCZ0Y.js";let P=class extends _{constructor(){super(...arguments),this.isSearchFocusTrapFixEnabled=!1,this.isSearchFixesFlagEnabled=!1,this._isSearchPhraseCleared=!1,this._setupAttributes=()=>{var e,t,s,n;(e=this.input)===null||e===void 0||e.setAttribute("role","combobox"),(t=this.input)===null||t===void 0||t.setAttribute("aria-autocomplete","none"),(s=this.input)===null||s===void 0||s.setAttribute("aria-haspopup","grid"),(n=this.input)===null||n===void 0||n.setAttribute("aria-activedescendant",""),requestAnimationFrame(()=>{var d,c;const A=(d=this.closest("h-search"))===null||d===void 0?void 0:d.querySelector(`.${a.container}`);(c=this.input)===null||c===void 0||c.setAttribute("aria-controls",A?.id||"")})}}connectedCallback(){if(super.connectedCallback(),this.input=this.querySelector('input[type="search"]'),!this.input)throw new Error("Search input not found");this._setupListeners(),this._setupAttributes()}firstUpdated(e){super.firstUpdated(e),this.isSearchFixesFlagEnabled||this._setupInitialValue()}_setupInitialValue(){const t=/\/searchquery\/([^/]{1,})/.exec(window.location.pathname);if(!t)return;const s=t[1].replace(/\+/g," ");this.input.value=decodeURIComponent(this._deserializeInputPhrase(s))}_deserializeInputPhrase(e){return e.indexOf("%2f")!==-1&&(e=e.replace(/%2f/g,"/")),e.indexOf("%2523")!==-1&&(e=e.replace(/%2523/g,"#")),e.indexOf("%252f")!==-1&&(e=e.replace(/%252f/g,"/")),e.indexOf("%23")!==-1&&(e=e.replace(/%23/g,"#")),e}_setupListeners(){this.input.addEventListener("focusin",e=>{this.emitCustomEvent(l.focusin,{detail:{searchPhrase:e.target.value,relatedTarget:e.relatedTarget}})}),this.isSearchFocusTrapFixEnabled||this.isSearchFixesFlagEnabled?(this.input.addEventListener("keydown",e=>{if(!(e.key!=="Enter"||e.repeat)){if(this._isSearchPhraseCleared){this._isSearchPhraseCleared=!1;return}this.emitCustomEvent(l.submit,{detail:{searchPhrase:e.target.value}})}}),this.input.addEventListener("keyup",q(e=>{e.key==="ArrowUp"||e.key==="ArrowDown"||e.key==="Escape"||e.key==="Enter"||this.emitCustomEvent(l.keyup,{detail:{searchPhrase:e.target.value}})},200))):(this.input.addEventListener("keyup",e=>{if(!(e.key==="ArrowUp"||e.key==="ArrowDown"||e.key==="Escape")){if(e.key!=="Enter"){this.emitCustomEvent(l.keyup,{detail:{searchPhrase:e.target.value}});return}if(this._isSearchPhraseCleared){this._isSearchPhraseCleared=!1;return}this.emitCustomEvent(l.submit,{detail:{searchPhrase:e.target.value}})}}),this.input.addEventListener("keyup",q(e=>{e.key==="ArrowUp"||e.key==="ArrowDown"||e.key==="Escape"||e.key==="Enter"||this.emitCustomEvent(l.keyup,{detail:{searchPhrase:e.target.value}})},200))),this.input.addEventListener("search",e=>{this.input.value===""&&this.emitCustomEvent(l.search,{detail:{searchPhrase:e.target.value}})}),document.addEventListener(l.clear,e=>{!e.detail||e.detail.moduleInstanceId!==this.moduleInstanceId||(this._isSearchPhraseCleared=!0,this.input.value="",this.input.focus())}),document.addEventListener(l.updateSearchPhrase,e=>{!e.detail||e.detail.moduleInstanceId!==this.moduleInstanceId||(this.input.value=e.detail.searchPhrase,this.emitCustomEvent(l.keyup,{detail:{searchPhrase:e.detail.searchPhrase}}))})}};i([o({type:String,attribute:"module-instance-id"}),r("design:type",String)],P.prototype,"moduleInstanceId",void 0);i([o({type:Boolean,attribute:"is-search-focus-trap-fix-enabled"}),r("design:type",Boolean)],P.prototype,"isSearchFocusTrapFixEnabled",void 0);i([o({type:Boolean,attribute:"is-search-fixes-flag-enabled"}),r("design:type",Boolean)],P.prototype,"isSearchFixesFlagEnabled",void 0);i([m(),r("design:type",Boolean)],P.prototype,"_isSearchPhraseCleared",void 0);P=i([y(g.searchInput)],P);let S=class extends _{constructor(){super(...arguments),this._loadMoreButtonId=x(),this._goToProductsForButtonId=x(),this.searchPhrase="",this.translations={},this._productPage=1,this._getInitialItemsIds=()=>{const e=this.results.suggestions.length,t=this._isProductInTheCategory()?e+1:e,s=t+this.results.categories.length,n=s+this.results.products.length;return{suggestionInCategory:e,categories:t,products:s,producers:n}}}_isProductInTheCategory(){return this.results.products.length&&this.results.suggestions.length}_areSearchResultsNotEmpty(){return!U(this.results,ie)}_areMoreProductsAvailable(){return this._productPage<this.results.productsPagesCount}_getSearchPhrase(){return this.results.suggestions.length?this.results.suggestions[0]:this.searchPhrase}handleGoToProductsFor(){this.emitCustomEvent(l.searchPhraseSubmitted,{detail:{searchPhrase:this._getSearchPhrase(),moduleInstanceId:this.moduleInstanceId}})}handleLoadMoreProducts(){this._productPage++,this.emitCustomEvent(l.loadMoreProducts,{detail:{searchPhrase:this._getSearchPhrase(),page:this._productPage,moduleInstanceId:this.moduleInstanceId}})}render(){return u(this._areSearchResultsNotEmpty(),()=>{var e,t,s,n;return h` 2 ${u(((e=this.results.suggestions)===null||e===void 0?void 0:e.length)||((t=this.results.categories)===null||t===void 0?void 0:t.length),()=>h` <h-search-suggestion-content 3 class="${a.section}" 4 active-item-id="${this.activeItemId}" 5 search-id="${this.searchId}" 6 .initialItemIds="${this._getInitialItemsIds()}" 7 .translations="${this.translations}" 8 locale="${this.locale}" 9 view="${this.view}" 10 module-instance-id="${this.moduleInstanceId}" 11 .suggestionAriaLabel=${this.settings.suggesterItemAriaLabel} 12 > 13 </h-search-suggestion-content>`)} 14 ${u((s=this.results.products)===null||s===void 0?void 0:s.length,()=>h` 15 <div class="${a.section}"> 16 <h-search-product-content 17 .products="${this.results.products}" 18 .settings="${this.settings}" 19 active-item-id="${this.activeItemId}" 20 search-id="${this.searchId}" 21 .initialItemIds="${this._getInitialItemsIds()}" 22 .translations="${this.translations}" 23 .productAriaLabel=${this.settings.suggesterProductItemAriaLabel} 24 ></h-search-product-content> 25 26 ${u(this.settings.isLoadingMoreSearchResultsEnabled,()=>u(this._areMoreProductsAvailable(),()=>h`<button 27 class="${a.productButton}" 28 @click="${this.handleLoadMoreProducts}" 29 type="button" 30 data-search-item-id="${this.searchId}${this._loadMoreButtonId}" 31 > 32 ${this.translations.loadMore} 33 </button>`),()=>u(this._getSearchPhrase().length>1,()=>h`<button 34 class="${a.productButton}" 35 @click="${this.handleGoToProductsFor}" 36 type="button" 37 data-search-item-id="${this.searchId}${this._goToProductsForButtonId}" 38 > 39 ${this.translations.goToProductsFor}: <strong>${this._getSearchPhrase()}</strong> 40 </button>`))} 41 </div> 42 `)} 43 ${u((n=this.results.producers)===null||n===void 0?void 0:n.length,()=>h` <h-search-producer-content 44 class="${a.section}" 45 .producers="${this.results.producers}" 46 active-item-id="${this.activeItemId}" 47 search-id="${this.searchId}" 48 .initialItemIds="${this._getInitialItemsIds()}" 49 .translations="${this.translations}" 50 search-phrase="${this.searchPhrase}" 51 .producerAriaLabel=${this.settings.suggesterProducerItemAriaLabel} 52 ></h-search-producer-content>`)} 53 `})}};i([o({type:Object,attribute:"result-data"}),r("design:type",Object)],S.prototype,"results",void 0);i([o({type:String,attribute:"search-phrase"}),r("design:type",Object)],S.prototype,"searchPhrase",void 0);i([o({type:Object}),r("design:type",Object)],S.prototype,"settings",void 0);i([o({type:String}),r("design:type",String)],S.prototype,"view",void 0);i([o({type:String}),r("design:type",String)],S.prototype,"locale",void 0);i([o({type:String,attribute:"active-item-id"}),r("design:type",String)],S.prototype,"activeItemId",void 0);i([o({type:String,attribute:"search-id"}),r("design:type",String)],S.prototype,"searchId",void 0);i([o({type:Object}),r("design:type",Object)],S.prototype,"translations",void 0);i([o({type:String,attribute:"module-instance-id"}),r("design:type",String)],S.prototype,"moduleInstanceId",void 0);i([m(),r("design:type",Number)],S.prototype,"_productPage",void 0);S=i([y(g.searchResults)],S);let D=class extends _{constructor(){super(),this._dispatchHistoryLoadMoreEvent=()=>{this.emitCustomEvent(l.loadMoreHistoryItems)},this._btnController=new L(this,this._dispatchHistoryLoadMoreEvent),this._visibilityController=new Q(this)}hide(){this._visibilityController.hide()}show(){this._visibilityController.show()}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatchHistoryLoadMoreEvent)}};D=i([y(g.historyLoadMoreButton),r("design:paramtypes",[])],D);let C=class extends _{constructor(){super(...arguments),this.buttonRef=O(),this.history=[],this.translations={}}async connectedCallback(){super.connectedCallback();try{this._historyContextConsumer=new N(this),this._historyContext$=await this._historyContextConsumer.consumeAsync(K.historyContext),this._historyContextObserver=new B(e=>{this.requestUpdate();const t=this.buttonRef.value;t&&(e.showLoadMore?t.show():t.hide())}),this._historyContext$.subscribe(this._historyContextObserver)}catch{console.error("Search context is not provided")}}render(){var e;return u((e=this.history)===null||e===void 0?void 0:e.length,()=>h`<h3 class="${a.headline}">${this.translations.searchHistory}</h3> 54 55 <ul> 56 ${M(this.history,(t,s)=>h` 57 <li 58 class=" 59 ${a.item} 60 ${`${this.searchId}${s}`===this.activeItemId?a.itemActive:""} 61 " 62 role="row" 63 > 64 <h-search-history-select 65 item-label="${t.label}" 66 class="${a.historySelect}" 67 data-suggested-value="${t.label}" 68 data-search-item-id="${this.searchId}${s}" 69 module-instance-id="${this.moduleInstanceId}" 70 aria-label=${this.translations.historyAriaLabel?`${this.translations.historyAriaLabel} ${t.label}`:void 0} 71 role="gridcell" 72 > 73 <h-icon icon-name="icon-clock"></h-icon> 74
75 <span class="${a.historyItemValue}">${t.label}</span> 76 </h-search-history-select> 77 78 <h-search-history-remove 79 data-search-item-id="${this.searchId}${s}-remove" 80 data-search-grid-item 81 item-id="${t.id}" 82 role="gridcell" 83 > 84 <h-icon 85 icon-name="icon-x" 86 clickable=${!0} 87 size=${oe.l} 88 css-classes="${a.historyRemoveIcon}" 89 ></h-icon> 90 </h-search-history-remove> 91 </li>`)} 92 </ul> 93 94 <h-search-history-load-more 95 class="${a.historyLoadMore}" 96 data-search-item-id="${this.searchId}-loadmore" 97 ${R(this.buttonRef)} 98 > 99 ${this.translations.loadMore} 100 </h-search-history-load-more>`)}};i([o({type:Array}),r("design:type",Array)],C.prototype,"history",void 0);i([o({type:String,attribute:"active-item-id"}),r("design:type",String)],C.prototype,"activeItemId",void 0);i([o({type:String,attribute:"search-id"}),r("design:type",String)],C.prototype,"searchId",void 0);i([o({type:Object}),r("design:type",Object)],C.prototype,"translations",void 0);i([o({type:String,attribute:"module-instance-id"}),r("design:type",String)],C.prototype,"moduleInstanceId",void 0);C=i([y(g.searchHistory)],C);let w=class extends _{constructor(){super(),this.isSearchFixesFlagEnabled=!1,this._shouldShow=!1,this._isRequestPending=!1,this._$searchInput=null,this._handleClearButtonOnPhraseEnter=e=>{this._updateClearButtonVisibility(e.detail.searchPhrase)},this._updateClearButtonVisibility=e=>{this._shouldShow=e!==""},this._handleSearchClear=()=>{var e;this._dispatchClearEvent(),this.isSearchFixesFlagEnabled&&(this._updateClearButtonVisibility(""),(e=this._$searchInput)===null||e===void 0||e.focus())},this._dispatchClearEvent=()=>{this.emitCustomEvent(l.clear,{detail:{moduleInstanceId:this.moduleInstanceId}})},this._btnController=new L(this,this._handleSearchClear)}connectedCallback(){var e,t,s;super.connectedCallback(),this._searchContextSetup();const n=this.closest(g.search);this._$searchInput=(e=n?.querySelector('input[type="search"]'))!==null&&e!==void 0?e:null,this.isSearchFixesFlagEnabled&&this._updateClearButtonVisibility((s=(t=this._$searchInput)===null||t===void 0?void 0:t.value)!==null&&s!==void 0?s:""),this.addEventListener("click",this._handleSearchClear),document.addEventListener(l.keyup,this._handleClearButtonOnPhraseEnter)}updated(e){super.updated(e),this._shouldShow?(this.setAttribute("tabindex","0"),this.removeAttribute("aria-hidden"),this.setAttribute("role","button")):(this.setAttribute("tabindex","-1"),this.setAttribute("aria-hidden","true"),this.removeAttribute("role"))}async _searchContextSetup(){try{this._searchContextConsumer=new N(this),this._searchContext$=await this._searchContextConsumer.consumeAsync(this.moduleInstanceId),this._searchContextObserver=new B(e=>{var t;this._shouldShow=((t=e.searchPhrase)===null||t===void 0?void 0:t.length)!==0,this._isRequestPending=e.results.isRequestPending}),this._searchContext$.subscribe(this._searchContextObserver)}catch{console.error("Search context is not provided")}}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(l.keyup,this._handleClearButtonOnPhraseEnter)}render(){return h` ${u(this._shouldShow,()=>h` 101 ${u(this._isRequestPending,()=>h`<div class="${a.loader}"> 102 <div class="${a.loaderSpinner} ${a.loaderSpinnerXs}"></div> 103 </div>`,()=>this.getSlot(re.clearButton))} 104 `)}`}};i([o({type:String,attribute:"module-instance-id"}),r("design:type",String)],w.prototype,"moduleInstanceId",void 0);i([o({type:Boolean,attribute:"is-search-fixes-flag-enabled"}),r("design:type",Boolean)],w.prototype,"isSearchFixesFlagEnabled",void 0);i([m(),r("design:type",Boolean)],w.prototype,"_shouldShow",void 0);i([m(),r("design:type",Boolean)],w.prototype,"_isRequestPending",void 0);w=i([y(g.clearButton),r("design:paramtypes",[])],w);let E=class extends _{constructor(){super(...arguments),this.searchPhrase="",this.history=[],this.translations={},this._searchButtonId=x()}_createEmptyResults(){return{suggestions:[],products:[],producers:[],categories:[],productsPagesCount:0,isRequestPending:!1}}_isNoResultsForSearchPhrase(){return this.searchPhrase&&U(this.results,this._createEmptyResults())}_hasHistoryAndEmptyPhrase(){return this.searchPhrase===""&&this.history.length>0}_hasNoHistoryAndEmptyPhrase(){return this.searchPhrase===""&&this.history.length===0}handleGoToResults(){this.emitCustomEvent(l.searchPhraseSubmitted,{detail:{searchPhrase:this.searchPhrase,moduleInstanceId:this.moduleInstanceId}})}render(){return h` 105 ${u(this._isNoResultsForSearchPhrase(),()=>h`<p class="${a.messageNoResults}"> 106 ${this.searchPhrase} - 107 <button 108 class="${a.messageText}" 109 @click="${this.handleGoToResults}" 110 type="button" 111 data-search-item-id="${this._searchButtonId}" 112 > 113 ${this.translations.searchInStore} 114 </button> 115 </p>`,()=>h`${u(this._hasHistoryAndEmptyPhrase(),()=>h`<p class="${a.message} ${a.messageWithHistory}"> 116 ${this.translations.enterSearchPraseOrChooseFromHistory} 117 </p>`)} 118 ${u(this._hasNoHistoryAndEmptyPhrase(),()=>h`<p class="${a.message}">${this.translations.enterSearchPrase}</p>`)} `)} 119 `}};i([o({type:String,attribute:"search-phrase"}),r("design:type",Object)],E.prototype,"searchPhrase",void 0);i([o({type:Object,attribute:"result-data"}),r("design:type",Object)],E.prototype,"results",void 0);i([o({type:Array}),r("design:type",Array)],E.prototype,"history",void 0);i([o({type:Object}),r("design:type",Object)],E.prototype,"translations",void 0);i([o({type:String,attribute:"module-instance-id"}),r("design:type",String)],E.prototype,"moduleInstanceId",void 0);E=i([y(g.searchMessage)],E);let p=class extends _{constructor(){super(...arguments),this.view=ae,this.isSearchFocusTrapFixEnabled=!1,this.displayMode="dropdown",this._togglerElement=null,this._mobileDialogOpener=null,this._id=x(),this._openSearchButtonAriaLabelId=`${this._id}-open-search-button-aria-label`,this._searchContentContainerId=x(),this.mobileFocusTrapController=new te(this,{mode:se.cyclic,getContainer:()=>this}),this._searchResultsRef=O(),this._searchHistoryRef=O(),this._searchMessageRef=O(),this._openSearchButtonLabelRef=O(),this._shouldShowHistory=!1,this._shouldShowResults=!1,this._shouldShowMessage=!1,this._searchHistory=[],this._searchPhrase="",this._historyLimitedContent=[],this._historyContext=new W({showLoadMore:!1}),this._activeItemId=`${this._id}-1`,this._translations={},this._containerRole="grid",this._handleSubmitForm=()=>{if(this._activeItemId!==`${this._id}-1`)return;if(this._inputField.value.trim()===""){this._updateSearchView(this._inputField.value,!0);return}const t=this._inputField.value.trim().replace(/\s+/g," ");this._inputField.value=t,this._submitSearchPhrase(t)},this._bindKeys=e=>{this.displayMode!=="dropdown"?this._bindOverlayKeys(e):this._bindDropdownKeys(e)},this._bindDropdownKeys=e=>{switch(e.key){case"ArrowDown":e.preventDefault(),this._handleForwardListFocus();break;case"ArrowUp":this._handleBackwardListFocus(e);break;case"ArrowLeft":this._containerRole==="grid"&&(e.preventDefault(),this._handleBackwardGridFocus()),this._containerRole==="listbox"&&this._handleMoveToInputField();break;case"ArrowRight":this._containerRole==="grid"&&(e.preventDefault(),this._handleForwardGridFocus()),this._containerRole==="listbox"&&this._handleMoveToInputField();break;case"Enter":if(e.preventDefault(),this._activeItemId===`${this._id}-1`||!this._shouldShowResults)return;this._handleChooseSearchItem();break;case"Escape":e.preventDefault(),this.emitCustomEvent(l.close),this._shouldShowHistory||this._shouldShowHistory||this._shouldShowResults?(this._inputField.focus(),this._shouldShowMessage=!1,this._hideHistorySuggestionsAndResults()):this._inputField.value="";break;case"End":e.preventDefault(),this._handleFocusOnInputWithCaretEnd();break;case"Home":e.preventDefault(),this._handleFocusOnInputWithCaretStart();break;case"Backspace":this._handleMoveToInputField();break;case"Tab":document.activeElement===this._inputField||e.preventDefault();break;default:e.key.length===1&&this._handleWriteableCharacter(e);break}},this._bindOverlayKeys=e=>{var t;switch(e.key){case"Enter":e.preventDefault();const s=(t=document.activeElement)===null||t===void 0?void 0:t.closest("[data-search-item-id]");if(!s)return;this._handleChooseSearchItem(s);break;case"Escape":e.preventDefault();const n=this.displayMode==="popup"?J.close:ee.close;this.emitCustomEvent(n);const d=document.querySelector(`h-storefront-search[module-instance-id="${this.moduleInstanceId}"]`),c=d&&d.querySelector('[aria-haspopup="dialog"]');
119c?.focus(),this._shouldShowMessage=!1,this._hideHistorySuggestionsAndResults();break}},this._handleSearchTabNavigation=e=>{if(e.key!=="Tab")return;const t=document.activeElement===this._inputField;if(e.shiftKey&&!t){this._focusOnPreviousElementBeforeSearchInput(e);return}if(!t){const s=this.querySelector(`.${a.searchBar}`);s?.classList.remove(a.outline),this._resetSearchView(),this._removeSearchKeyboardNavigation(),this._focusOnNextElementAfterSearchInput(e)}},this._focusOnPreviousElementBeforeSearchInput=async e=>{e.preventDefault();const t=this.querySelector(`.${a.searchBar}`);t?.classList.remove(a.outline),this._resetSearchView(),this._removeSearchKeyboardNavigation(),F.getPreviousFocusableElement(this._inputField).focus()},this._focusOnNextElementAfterSearchInput=async e=>{e.preventDefault(),F.getNextFocusableElement(this._inputField).focus()},this._preventScrollingOnSearchContentBrowsing=e=>{var t;const s=e.key==="ArrowUp"||e.key==="ArrowDown",n=e.key==="Home"||e.key==="End",d=!!(!((t=document.activeElement)===null||t===void 0)&&t.closest(".search__container"));(s||n)&&d&&e.preventDefault()},this._handleForwardListFocus=()=>{var e,t;const s=this._findSearchItemsContainer();if(!s)return;const d=!!(!((e=document.activeElement)===null||e===void 0)&&e.getAttribute("data-search-item-id"))&&!!(!((t=document.activeElement)===null||t===void 0)&&t.getAttribute("data-search-grid-item")),c=this._findListSearchItems(s,d);this._handleForwardFocus(c)},this._handleForwardGridFocus=()=>{const e=this._findSearchItemsContainer();if(!e)return;const t=F.getFocusableElements(e).filter(s=>!!s.getAttribute("data-search-item-id"));this._handleForwardFocus(t)},this._handleForwardFocus=e=>{var t;const s=document.activeElement,n=e.indexOf(s),d=n===e.length-1?0:n+1,c=e[d];c.focus(),this._setActiveItemId((t=c.getAttribute("data-search-item-id"))!==null&&t!==void 0?t:`${this._id}-1`)},this._handleMoveToInputField=()=>{document.activeElement!==this._inputField&&this._inputField.focus()},this._handleBackwardListFocus=e=>{var t,s;const n=document.activeElement===this._inputField,d=this._shouldShowHistory||this._shouldShowHistory||this._shouldShowResults;if(n||!d)return;e.preventDefault();const c=this._findSearchItemsContainer();if(!c)return;const z=!!(!((t=document.activeElement)===null||t===void 0)&&t.getAttribute("data-search-item-id"))&&!!(!((s=document.activeElement)===null||s===void 0)&&s.getAttribute("data-search-grid-item")),Y=this._findListSearchItems(c,z);this._handleBackwardFocus(Y)},this._findListSearchItems=(e,t)=>F.getFocusableElements(e).filter(s=>{const n=s.getAttribute("data-search-item-id"),d=!!n&&!s.getAttribute("data-search-grid-item"),c=!!n&&s.getAttribute("data-search-grid-item");return t?c:d}),this._handleBackwardGridFocus=()=>{const e=this._findSearchItemsContainer();if(!e)return;const t=F.getFocusableElements(e).filter(s=>!!s.getAttribute("data-search-item-id"));this._handleBackwardFocus(t)},this._findSearchItemsContainer=()=>[this._searchHistoryRef.value,this._searchResultsRef.value,this._searchMessageRef.value].find(t=>t&&!F.isElementEmpty(t)),this._handleBackwardFocus=e=>{var t;const s=document.activeElement,n=e.indexOf(s),d=n===0?e.length-1:n-1,c=e[d];c.focus(),this._setActiveItemId((t=c.getAttribute("data-search-item-id"))!==null&&t!==void 0?t:`${this._id}-1`)},this._setActiveItemId=e=>{this._activeItemId=e,document.activeElement!==this._inputField&&this._inputField.setAttribute("aria-activedescendant",this._activeItemId)},this._removeSearchKeyboardNavigation=()=>{document.body.removeEventListener("keydown",this._bindKeys),document.removeEventListener("keyup",this._handleSearchTabNavigation)},this._handleFocusOnInputWithCaretEnd=()=>{if(document.activeElement===this._inputField)return;this._inputField.focus();const t=this._inputField.value.length;this._inputField.setSelectionRange(t,t)},this._handleFocusOnInputWithCaretStart=()=>{this._inputField.focus(),this._inputField.setSelectionRange(0,0)},this._handleWriteableCharacter=e=>{if(document.activeElement===this._inputField)return;this._inputField.focus();const s=e.key.match(/\P{C}/u);(e.key.length!==1||!s)&&e.preventDefault()},this._hideSuggesterOnClickOutside=e=>{typeof e.composedPath=="function"&&!e.composedPath().includes(this)&&(this._resetSearchView(),this._removeSearchKeyboardNavigation())},this._switchTypeOfSearchView=()=>{var e;if(!(!this._isSuggesterLayerVisible()&&this.displayMode==="dropdown"))if(window.innerWidth>G.sm){const t=this.classList.contains(a.mobileOpened);if(this.classList.remove(a.mobileOpened),this.isSearchFocusTrapFixEnabled&&this._deactivateMobileDialog(),t&&this.displayMode!=="dropdown"){const s=document.querySelector(`h-storefront-search[module-instance-id="${this.moduleInstanceId}"]`),n=(e=s?.querySelector('[aria-haspopup="dialog"]'))===null||e===void 0?void 0:e.getAttribute("name"),d=this.querySelector(`[hidden][id="${n}"]`);if(!n||!d)return;d?.open()}}else this.displayMode==="dropdown"&&this._openMobileView()},this._openMobileView=()=>{this.classList.add(a.mobileOpened),this.isSearchFocusTrapFixEnabled&&this._activateMobileDialog()},this._isSuggesterLayerVisible=()=>{var e;return((e=this.settings)===null||e===void 0?void 0:e.isSearchSuggestLayerEnabled)&&(this._shouldShowHistory||this._shouldShowResults||this._shouldShowMessage)},this._preventSubmitOnSearchClear=e=>{const t=this.querySelector(g.clearButton);e.key==="Enter"&&e.target===t&&e.preventDefault()},this._resetSearchOnFocusOutside=e=>{const t=e.target;this===t||this.contains(t)||(this._resetSearchView(),this._removeSearchKeyboardNavigation(),document.removeEventListener("focusin",this._resetSearchOnFocusOutside))},this._activateMobileDialog=()=>{this._mobileDialogOpener=document.activeElement,this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this.mobileFocusTrapController.activate()},this._deactivateMobileDialog=()=>{this.removeAttribute("role"),this.removeAttribute("aria-modal"),this.mobileFocusTrapController.deactivate()},this._handleOpenSearch=()=>{this.classList.add(a.mobileOpened),this.isSearchFocusTrapFixEnabled&&this._activateMobileDialog();const e=this._searchPhrase!=="";this._updateSearchView(this._searchPhrase,e,!1);const t=this.querySelector(` 120 ${g.searchInput} input[type="search"] 121 `);t?.focus()},this._handleOpenSearchWithKeyboard=e=>{const t=this.isSearchFocusTrapFixEnabled?e.repeat:!1;e.code!=="Enter"||t||(e.preventDefault(),this._handleOpenSearch())}}async connectedCallback(){super.connectedCallback(),this._setupContext(),this._searchInput=this.querySelector(g.searchInput),this.isSearchFocusTrapFixEnabled&&(this._setupInitialSearchPhrase(),this._setupListeners(),this._setupToggler());try{this._searchContextConsumer=new N(this),this._searchContext$=await this._searchContextConsumer.consumeAsync(this.moduleInstanceId);const e={historyGuideAriaLabel:this.settings.historyGuideAriaLabel,suggesterGuideAriaLabel:this.settings.suggesterGuideAriaLabel,historyItemAriaLabel:this.settings.historyItemAriaLabel,suggesterItemAriaLabel:this.settings.suggesterItemAriaLabel,suggesterProductItemAriaLabel:this.settings.suggesterProductItemAriaLabel,suggesterProducerItemAriaLabel:this.settings.suggesterProducerItemAriaLabel,openSearchButtonAriaLabel:this.settings.openSearchButtonAriaLabel};this._searchContextObserver=new B(t=>{this._searchResults=t.results,this._searchHistory=t.history,this._translations={...t.translations,...e},this._searchPhrase=t.searchPhrase,this._historyContext.notify({showLoadMore:this._searchHistory.length>k.historyContentLimit}),this._historyLimitedContent=this._searchHistory.slice(0,k.historyContentLimit)}),this._searchContext$.subscribe(this._searchContextObserver)}catch{console.error("Search context is not provided")}this.isSearchFocusTrapFixEnabled||(this._searchInput=this.querySelector(g.searchInput),this._setupInitialSearchPhrase(),this._setupListeners(),this._setupToggler())}disconnectedCallback(){var e;super.disconnectedCallback(),document.removeEventListener("click",this._hideSuggesterOnClickOutside),document.removeEventListener("keydown",this._preventScrollingOnSearchContentBrowsing),document.removeEventListener("focusin",this._resetSearchOnFocusOutside),window.removeEventListener("resize",this._switchTypeOfSearchView),(e=this._searchForm)===null||e===void 0||e.removeEventListener("keydown",this._preventSubmitOnSearchClear),this._teardownToggler()}_setupContext(){this._historyContextProvider=new X(this),this._historyContextProvider.provide(K.historyContext,this._historyContext)}_setupInitialSearchPhrase(){var e;const t=this.querySelector('input[type="search"]'),s=this.closest("form");t&&(this._inputField=t),s&&(this._searchForm=s),!((e=this._inputField)===null||e===void 0)&&e.value&&(this._searchPhrase=this._inputField.value,this._updateSearchPhrase(this._inputField.value))}_updateSearchPhrase(e){this._dispatchEventWithSearchPhrase(l.searchPhraseUpdated,e)}_dispatchEventWithSearchPhrase(e,t){this.emitCustomEvent(e,{detail:{searchPhrase:t,moduleInstanceId:this.moduleInstanceId}})}
121_setupListeners(){this.addEventListener(l.focusin,e=>{var t,s,n;const d=(t=e.detail)===null||t===void 0?void 0:t.relatedTarget;if(d?.closest(`[id="${this._searchContentContainerId}"]`))return;const c=this.querySelector(`.${a.searchBar}`);c?.classList.add(a.outline);const A=((s=e.detail)===null||s===void 0?void 0:s.searchPhrase)!=="";this._updateSearchView(((n=e.detail)===null||n===void 0?void 0:n.searchPhrase)||"",A,!1),this.displayMode==="dropdown"&&document.addEventListener("keyup",this._handleSearchTabNavigation),document.body.addEventListener("keydown",this._bindKeys),document.addEventListener("keydown",this._preventScrollingOnSearchContentBrowsing),document.addEventListener("focusin",this._resetSearchOnFocusOutside),document.body.addEventListener("searchOpenMobileView",this._openMobileView)}),this.addEventListener(l.keyup,e=>{const t=e.detail.searchPhrase!=="";this._updateSearchView(e.detail.searchPhrase,t)}),this.addEventListener(l.search,e=>this._updateSearchView(e.detail.searchPhrase,!1)),this.addEventListener(l.clear,e=>{e.stopImmediatePropagation(),this._inputField.value="",this._updateSearchView("",!1)}),this.addEventListener(l.submit,this._handleSubmitForm),this.addEventListener(l.close,()=>{this.classList.remove(a.mobileOpened),this.isSearchFocusTrapFixEnabled&&this._deactivateMobileDialog(),this._resetSearchView(),this._removeSearchKeyboardNavigation(),this.isSearchFocusTrapFixEnabled&&requestAnimationFrame(()=>{var e;return(e=this._mobileDialogOpener)===null||e===void 0?void 0:e.focus()})}),this.addEventListener(l.loadMoreHistoryItems,()=>{const e=this._searchHistory.length,t=this._historyLimitedContent.length;t<e&&(this._historyLimitedContent=this._searchHistory.slice(0,t+k.historyContentLimit)),this._historyContext.notify({showLoadMore:this._historyLimitedContent.length<e})}),document.addEventListener("click",this._hideSuggesterOnClickOutside),window.addEventListener("resize",this._switchTypeOfSearchView),this._searchForm.addEventListener("keydown",this._preventSubmitOnSearchClear)}_updateSearchView(e,t,s=!0){this._shouldShowMessage=t,this._setActiveItemId(`${this._id}-1`),this._inputField.setAttribute("aria-activedescendant",""),this._displaySuggester(e),s&&this._updateSearchPhrase(e)}_displaySuggester(e){e===""&&this._searchHistory.length!==0&&this._displayHistorySuggestions(),e===""&&this._searchHistory.length===0&&this._hideHistorySuggestionsAndResults(),e!==""&&this._displayResults()}_displayHistorySuggestions(){this._handleToggleHistoryAndResults({shouldShowHistory:!0,shouldShowResults:!1})}_hideHistorySuggestionsAndResults(){this._handleToggleHistoryAndResults({shouldShowHistory:!1,shouldShowResults:!1})}_displayResults(){this._handleToggleHistoryAndResults({shouldShowHistory:!1,shouldShowResults:!0})}_handleToggleHistoryAndResults({shouldShowHistory:e,shouldShowResults:t}){this._shouldShowHistory=e,this._shouldShowResults=t,this._toggleSearchInputAttributes(e,t),this._toggleSearchContainerAttributes(e,t)}_toggleSearchInputAttributes(e,t){var s;const n=(s=this._searchInput)===null||s===void 0?void 0:s.input;if(n){if(!e&&!t){n.removeAttribute("aria-label"),n.setAttribute("aria-activedescendant","");return}n.setAttribute("aria-expanded","true"),e&&(n.setAttribute("aria-label",this.settings.historyGuideAriaLabel),n.setAttribute("aria-haspopup","grid")),t&&(n.setAttribute("aria-label",this.settings.suggesterGuideAriaLabel),this._inputField.removeAttribute("aria-haspopup"))}}_toggleSearchContainerAttributes(e,t){e&&(this._containerRole="grid"),t&&(this._containerRole="listbox")}_handleChooseSearchItem(e){const t=this.displayMode==="dropdown"?this.querySelector(`[data-search-item-id="${this._activeItemId}"]`):document.activeElement;if(!t)return;const s=t.querySelector("a"),n=s||t,d=t.dataset.suggestedValue?n:s;d?d.click():t.click()}_resetSearchView(){this._shouldShowMessage=!1,this._setActiveItemId(`${this._id}-1`);const e=this.querySelector(`.${a.searchBar}`);e?.classList.remove(a.outline),this.displayMode==="dropdown"&&(this.classList.contains(a.mobileOpened)?this._displaySuggester(this._searchPhrase):this._hideHistorySuggestionsAndResults())}_submitSearchPhrase(e){this._dispatchEventWithSearchPhrase(l.searchPhraseSubmitted,e)}_setupToggler(){this._togglerElement=this.querySelector(".js-search-toggler"),this._togglerElement&&(this._togglerElement.addEventListener("click",this._handleOpenSearch),this.isSearchFocusTrapFixEnabled?this._togglerElement.addEventListener("keydown",this._handleOpenSearchWithKeyboard):this._togglerElement.addEventListener("keyup",this._handleOpenSearchWithKeyboard))}_teardownToggler(){this._togglerElement&&(this._togglerElement.removeEventListener("click",this._handleOpenSearch),this.isSearchFocusTrapFixEnabled?this._togglerElement.removeEventListener("keydown",this._handleOpenSearchWithKeyboard):this._togglerElement.removeEventListener("keyup",this._handleOpenSearchWithKeyboard))}render(){return super.render(),h` 122 ${u(this._isSuggesterLayerVisible(),()=>h` 123 <div class="${a.container}" id="${this._searchContentContainerId}" role="${this._containerRole}"> 124 ${u(this._shouldShowMessage,()=>h`<h-search-message 125 ${R(this._searchMessageRef)} 126 .history="${this._historyLimitedContent}" 127 .results="${this._searchResults}" 128 .translations="${this._translations}" 129 search-phrase="${this._searchPhrase}" 130 module-instance-id="${this.moduleInstanceId}" 131 ></h-search-message>`)} 132 ${u(this._shouldShowHistory,()=>h`<h-search-history 133 ${R(this._searchHistoryRef)} 134 .history="${this._historyLimitedContent}" 135 .translations="${this._translations}" 136 active-item-id="${this._activeItemId}" 137 search-id="${this._id}" 138 module-instance-id="${this.moduleInstanceId}" 139 ></h-search-history>`)} 140 ${u(this._shouldShowResults,()=>h`<h-search-results 141 ${R(this._searchResultsRef)} 142 .results="${this._searchResults}" 143 search-phrase="${this._searchPhrase}" 144 .settings="${this.settings}" 145 locale="${this.locale}" 146 view="${this.view}" 147 .translations="${this._translations}" 148 active-item-id="${this._activeItemId}" 149 search-id="${this._id}" 150 module-instance-id="${this.moduleInstanceId}" 151 ></h-search-results>`)} 152 </div> 153 `,()=>h` <div 154 class="${a.container}" 155 id="${this._searchContentContainerId}" 156 role="${this._containerRole}" 157 hidden 158 ></div>`)} 159 `}};i([o({type:Object}),r("design:type",Object)],p.prototype,"settings",void 0);i([o({type:String}),r("design:type",String)],p.prototype,"view",void 0);i([o({type:String}),r("design:type",String)],p.prototype,"locale",void 0);i([o({type:Boolean,attribute:"is-search-focus-trap-fix-enabled"}),r("design:type",Boolean)],p.prototype,"isSearchFocusTrapFixEnabled",void 0);i([o({type:String,attribute:"display-mode"}),r("design:type",String)],p.prototype,"displayMode",void 0);i([o({type:String,attribute:"module-instance-id"}),r("design:type",String)],p.prototype,"moduleInstanceId",void 0);i([m(),r("design:type",Boolean)],p.prototype,"_shouldShowHistory",void 0);i([m(),r("design:type",Boolean)],p.prototype,"_shouldShowResults",void 0);i([m(),r("design:type",Boolean)],p.prototype,"_shouldShowMessage",void 0);i([m(),r("design:type",Object)],p.prototype,"_searchResults",void 0);i([m(),r("design:type",Array)],p.prototype,"_searchHistory",void 0);i([m(),r("design:type",String)],p.prototype,"_searchPhrase",void 0);i([m(),r("design:type",Array)],p.prototype,"_historyLimitedContent",void 0);i([m(),r("design:type",W)],p.prototype,"_historyContext",void 0);i([m(),r("design:type",String)],p.prototype,"_activeItemId",void 0);i([m(),r("design:type",Object)],p.prototype,"_translations",void 0);i([m(),r("design:type",String)],p.prototype,"_containerRole",void 0);p=i([y(g.search)],p);let V=class extends _{constructor(){super(),this._dispatchSubmitEvent=()=>{this.emitCustomEvent(l.submit)},this._btnController=new L(this,this._dispatchSubmitEvent)}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatchSubmitEvent)}};V=i([y(g.submitButton),r("design:paramtypes",[])],V);let j=class extends _{constructor(){super(),this._dispatchCloseEvent=()=>{this.emitCustomEvent(l.close)},this._throttledToggleSearchCloseAria=ne(()=>{this._toggleSearchCloseAria()},Z),this._toggleSearchCloseAria=()=>
159{if(window.innerWidth<G.sm){this.setAttribute("tabindex","0"),this.removeAttribute("aria-hidden"),this.setAttribute("role","button");return}this.setAttribute("tabindex","-1"),this.setAttribute("aria-hidden","true"),this.removeAttribute("role")},this._btnController=new L(this,this._dispatchCloseEvent)}connectedCallback(){super.connectedCallback(),this._toggleSearchCloseAria(),this.addEventListener("click",this._dispatchCloseEvent),window.addEventListener("resize",this._throttledToggleSearchCloseAria)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._throttledToggleSearchCloseAria)}};j=i([y(g.closeButton),r("design:paramtypes",[])],j);let T=class extends _{constructor(){super(),this._dispatchRemoveHistoryItemEvent=e=>{e.stopPropagation(),this.emitCustomEvent(l.removeHistoryItem,{detail:{id:this.historyItemId}})},this._btnController=new L(this,this._dispatchRemoveHistoryItemEvent)}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatchRemoveHistoryItemEvent)}};i([o({type:String,attribute:"item-id"}),r("design:type",String)],T.prototype,"historyItemId",void 0);T=i([y(g.historyRemoveButton),r("design:paramtypes",[])],T);let H=class extends _{constructor(){super(),this._dispatchHistorySelectEvent=()=>{this.emitCustomEvent(l.searchPhraseSubmitted,{detail:{searchPhrase:this.historyItemLabel,moduleInstanceId:this.moduleInstanceId}})},this._btnController=new L(this,this._dispatchHistorySelectEvent)}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatchHistorySelectEvent)}};i([o({type:String,attribute:"item-label"}),r("design:type",String)],H.prototype,"historyItemLabel",void 0);i([o({type:String,attribute:"module-instance-id"}),r("design:type",String)],H.prototype,"moduleInstanceId",void 0);H=i([y(g.historySelectButton),r("design:paramtypes",[])],H);let b=class extends _{constructor(){super(...arguments),this.initialItemIds={},this.translations={},this._searchPhrase="",this._suggestionsData=[],this._updateSearchPhrase=(e,t)=>{e.stopPropagation(),this._dispatchEventWithSearchPhrase(l.updateSearchPhrase,t)}}async connectedCallback(){super.connectedCallback();try{this._searchContextConsumer=new N(this),this._searchContext$=await this._searchContextConsumer.consumeAsync(this.moduleInstanceId),this._searchContextObserver=new B(e=>{this._searchPhrase=e.searchPhrase,this._setupSuggestionData(e.results)}),this._searchContext$.subscribe(this._searchContextObserver)}catch{console.error("Search context is not provided")}}_setupSuggestionData(e){let t=[];e.suggestions.length?e.suggestions.forEach((s,n)=>{if(t.push({suggestionName:s,type:f.suggestion}),n)return;if(e.products.length){const c=this.locale.split("_")[0];t.push({suggestionName:s,categoryName:e.products[0].category.breadcrumbs,type:f.suggestionInCategory,url:`/${c}/c/${e.products[0].category.name}/${e.products[0].category.categoryId}/1/${this.view}/1/searchquery/${s}`})}e.categories.length&&(t=[...t,...e.categories.map(c=>({categoryName:c.name,url:c.url,type:f.category}))])}):e.categories.length&&(t=[...e.categories.map(s=>({categoryName:s.name,url:s.url,type:f.category}))]),this._suggestionsData=t}_handleSuggestion(e,t){t===f.suggestion&&this._dispatchEventWithSearchPhrase(l.searchPhraseSubmitted,e)}_dispatchEventWithSearchPhrase(e,t){this.emitCustomEvent(e,{detail:{searchPhrase:t,moduleInstanceId:this.moduleInstanceId}})}_getMatchedPhrase(e){if(!e.toLowerCase().includes(this._searchPhrase))return h`${e}`;const s=e.toLowerCase().indexOf(this._searchPhrase)+this._searchPhrase.length;return h`${e.substring(0,s)}<strong>${e.substring(s)}</strong>`}render(){return u(this._suggestionsData.length,()=>h` 160 <h3 class="${a.headline}">${this.translations.suggestions}</h3> 161 162 <ul> 163 ${M(this._suggestionsData,(e,t)=>{const s=this.closest('.search_mobile-opened, [display-mode="dropdown"]')||e.type===f.suggestion?"0":void 0;return h`<li 164 @click=${()=>this._handleSuggestion(e.suggestionName,e.type)} 165 class="${a.item} ${a.itemHoverable} ${String(t)===this.activeItemId?a.itemActive:""}" 166 data-suggested-value="${e.suggestionName}" 167 data-search-item-id="${this.searchId}${t}" 168 aria-label="${this.suggestionAriaLabel?`${this.suggestionAriaLabel} ${e.suggestionName||e.categoryName}`:""}" 169 tabindex=${s} 170 role="option" 171 > 172 ${u(e.type===f.suggestion,()=>h` <span> ${this._getMatchedPhrase(e.suggestionName)}
172 </span> 173 <h-icon 174 icon-name="icon-arrow-up-left" 175 clickable=${!0} 176 @click=${n=>this._updateSearchPhrase(n,e.suggestionName)} 177 ></h-icon>`)} 178 ${u(e.type===f.suggestionInCategory,()=>h` <a class="${a.link}" href=${e.url}> 179 <span> ${this._getMatchedPhrase(e.suggestionName)} </span> 180 <span class="${a.categoryTitle}"> ${this.translations.inTheCategory} </span> 181 <span> ${e.categoryName} </span> 182 </a>`)} 183 ${u(e.type===f.category,()=>h` <a class="${a.link}" href="${e.url}"> 184 <span> ${this._getMatchedPhrase(e.categoryName)} </span> 185 <span class="${a.categoryTitle}"> ${this.translations.category} </span> 186 </a>`)} 187 </li>`})} 188 </ul> 189 `)}};i([o({type:String,attribute:"active-item-id"}),r("design:type",String)],b.prototype,"activeItemId",void 0);i([o({type:String,attribute:"search-id"}),r("design:type",String)],b.prototype,"searchId",void 0);i([o({type:Object,reflect:!0}),r("design:type",Object)],b.prototype,"initialItemIds",void 0);i([o({type:Object}),r("design:type",Object)],b.prototype,"translations",void 0);i([o({type:String}),r("design:type",String)],b.prototype,"view",void 0);i([o({type:String}),r("design:type",String)],b.prototype,"locale",void 0);i([o({type:String,attribute:"module-instance-id"}),r("design:type",String)],b.prototype,"moduleInstanceId",void 0);i([o({type:String}),r("design:type",String)],b.prototype,"suggestionAriaLabel",void 0);i([m(),r("design:type",String)],b.prototype,"_searchPhrase",void 0);i([m(),r("design:type",Array)],b.prototype,"_suggestionsData",void 0);b=i([y(g.searchSuggestionContent)],b);let I=class extends _{constructor(){super(...arguments),this.initialItemIds={},this.translations={},this.getProductRateHtml=e=>h` 190 <div class="${a.starScore}"> 191 ${[1,2,3,4,5].map(t=>{const s=t-.4,n=t-.81;return e>=t||e>=s?h` <h-icon icon-name="icon-star" css-classes=${a.productIconFilled} aria-hidden="true" noStroke=${!0}></h-icon>`:e>n?h`<h-icon icon-name="icon-half-filled" css-classes="${a.productIconFilled}" aria-hidden="true" noStroke=${!0}></h-icon>`:h` <h-icon icon-name="icon-star" css-classes=${a.productIconEmpty} aria-hidden="true" noStroke=${!0}></h-icon>`})} 192 </div> 193 `}_getShortenProductName(e){return e.length>k.maxCharactersInProductName?e.substring(0,k.maxCharactersInProductName)+"...":e}_getPercentPromotion(e){return`-${Math.round((e.basic.float-e.promotion.float)/e.basic.float*100)}%`}render(){return h` 194 <h3 class="${a.headline}">${this.translations.products}</h3> 195 196 <ul> 197 ${M(this.products,(e,t)=>{var s,n;const d=this.closest('.search_mobile-opened, [display-mode="dropdown"]')?"0":void 0;return h` <li 198 class="${a.item} ${a.itemHoverable} ${String(this.initialItemIds.products+t)===this.activeItemId?a.itemActive:""}" 199 data-search-item-id="${this.searchId}${this.initialItemIds.products+t}" 200 aria-label=${this.productAriaLabel?`${this.productAriaLabel} ${e.name}`:void 0} 201 tabindex=${d} 202 role="option" 203 > 204 <a 205 href="${e.url}" 206 class="${!((s=e.image)===null||s===void 0)&&s.imagePath?a.linkWithImage:a.link}" 207 > 208 ${u((n=e.image)===null||n===void 0?void 0:n.imagePath,()=>{var c;return h`<img src="${(c=e.image)===null||c===void 0?void 0:c.imagePath}" alt="" />`})} 209 210 <div> 211 ${u(this.settings.showProductRate&&e.rate,()=>this.getProductRateHtml(e.rate))} 212 213 <div>${this.settings.isNamesShorteningEnabled?this._getShortenProductName(e.name):e.name}</div> 214 215 ${u(this.settings.showProductPrice,()=>h` 216 ${u(e.prices.promotion.text.length,()=>h` 217 <div class="${a.productPricePromotion}">
218 <span class="${a.productPricePromotionIcon}"><h-icon icon-name="icon-percent"></h-icon></span> <span>${e.prices.promotion.text}</span> 219 </div> 220 221 <div class="${a.productPriceRegular}"> 222 <span>${this.translations.regularPrice}:</span> 223 <span class="${a.productPriceBasic}">${e.prices.basic.text}</span> 224 <span class="${a.productPercentPromotion}">${this._getPercentPromotion(e.prices)}</span> 225 </div> 226 </div>`,()=>h`<div class="${a.productText}">${e.prices.basic.text}</div>`)} 227 ${u(e.isStock,()=>h`<div class="${a.productPriceInfo}"> 228 ${this.translations.priceForTheBaseModel} 229 </div>`)} 230 `)} 231 ${u(this.settings.showProductAvailability,()=>h`<div class="${a.productAvailability}"> 232 ${this.translations.availability}: <span class="${a.productText}">${e.availabilityLabel}<span> 233 </div>`)} 234 </div> 235 </a> 236 </li>`})} 237 </ul> 238 `}};i([o({type:Object,reflect:!0}),r("design:type",Array)],I.prototype,"products",void 0);i([o({type:Object}),r("design:type",Object)],I.prototype,"settings",void 0);i([o({type:String,attribute:"active-item-id"}),r("design:type",String)],I.prototype,"activeItemId",void 0);i([o({type:String,attribute:"search-id"}),r("design:type",String)],I.prototype,"searchId",void 0);i([o({type:Object,reflect:!0}),r("design:type",Object)],I.prototype,"initialItemIds",void 0);i([o({type:Object}),r("design:type",Object)],I.prototype,"translations",void 0);i([o({type:String}),r("design:type",String)],I.prototype,"productAriaLabel",void 0);I=i([y(g.searchProductContent)],I);let $=class extends _{constructor(){super(...arguments),this.initialItemIds={},this.translations={},this.searchPhrase=""}_getMatchedPhrase(e){return e.toLowerCase().startsWith(this.searchPhrase)?h`${e.substring(0,this.searchPhrase.length)}<strong>${e.substring(this.searchPhrase.length)}</strong>`:h`${e}`}render(){return h` 239 <h3 class="${a.headline}">${this.translations.producers}</h3> 240 241 <ul> 242 ${M(this.producers,(e,t)=>{var s,n;const d=this.closest('.search_mobile-opened, [display-mode="dropdown"]')?"0":void 0;return h`<li 243 class="${a.item} ${a.itemHoverable} ${String(this.initialItemIds.producers+t)===this.activeItemId?a.itemActive:""}" 244 data-search-item-id="${this.searchId}${this.initialItemIds.producers+t}" 245 aria-label=${this.producerAriaLabel?`${this.producerAriaLabel} ${e.name}`:void 0} 246 tabindex=${d} 247 role="option" 248 > 249 <a 250 href="${e.url}" 251 class="${!((s=e.image)===null||s===void 0)&&s.imagePath?a.linkWithImage:a.link}" 252 > 253 ${u((n=e.image)===null||n===void 0?void 0:n.imagePath,()=>{var c;return h`<img src="${(c=e.image)===null||c===void 0?void 0:c.imagePath}" alt="" />`})} 254 255 <span>${this._getMatchedPhrase(e.name)}</span> 256 </a> 257 </li>`})} 258 </ul> 259 `}};i([o({type:Object,reflect:!0}),r("design:type",Array)],$.prototype,"producers",void 0);i([o({type:String,attribute:"active-item-id"}),r("design:type",String)],$.prototype,"activeItemId",void 0);i([o({type:String,attribute:"search-id"}),r("design:type",String)],$.prototype,"searchId",void 0);i([o({type:Object,reflect:!0}),r("design:type",Object)],$.prototype,"initialItemIds",void 0);i([o({type:Object}),r("design:type",Object)],$.prototype,"translations",void 0);i([o({type:String,attribute:"search-phrase"}),r("design:type",String)],$.prototype,"searchPhrase",void 0);i([o({type:String}),r("design:type",String)],$.prototype,"producerAriaLabel",void 0);$=i([y(g.searchProducerContent)],$);requestAnimationFrame(()=>{});
259globalThis.__phoenix_wc__=[p,w,j,C,D,T,H,P,E,$,I,S,V,b];
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.