https://www.ksiegarnianowabasn.com/application/assets/storefront/chunk-search_initializer.Dhxjg4s.js
1import{W as he}from"./chunk-webapi_http_api.C3s8IQv.js";import{B as le}from"./chunk-base_http_api_url.H743YfZ.js";import{L as m,f as n,g as de,h as S,R as ue,b as U,G as pe,i as _e,s as f,w as l,j as B,k as $,c as D,v,l as Se,m as R,n as c,o as me,T as ge,e as Y,p as ye,S as fe,q as be,H as ve,C as Pe,r as Ee}from"./storefrontApp.CsApItsi.min.js";import{C as we,P as Ae,a as Oe,b as Ie}from"./chunk-producer_mapper.CMRXClb.js";import{I as K,P as Me}from"./chunk-price_mapper.RARQykB.js";import{P as Ce}from"./chunk-product_code_mapper.uZ5tufp.js";import{C as F,$ as u,U as Be,e as p,t as z}from"./chunk-vendor-lit.NvY0u02.js";import{S as P}from"./chunk-storefront_base_lit_element.lX23Jvc.js";import{s as $e,g as Re,c as Fe,e as Le,d as ke,w as Te}from"./chunk-index.esm.BJO8Gf1.js";import{d as L,c as k,f as T,s as b}from"./chunk-vendor-rxjs.Dp7kflo.js";import{S as W}from"./chunk-storefront_settings_constants.DIF02Gz.js";import{B as He}from"./chunk-behavior_subject.BGn-8a7.js";import{W as H,C as Ne}from"./chunk-context_provider_controller.CCbkLM7.js";import{t as h}from"./chunk-translations_directive.DWSzkd6.js";import"./chunk-vendor-di.Bh23gdA.js";import"./chunk-vendor-lodash.CWHFt7Z.js";import"./chunk-vendor-phoenix.cdKS79L.js";import"./chunk-subject.nuVoBpB.js";class xe extends le{constructor(e,t){super(e,t)}getSuggestionsUrl(e){return`${this.webapiUrl}/search/suggest?text=${e}`}getSearchResultsBasedOnSuggestionsUrl(e,t){return`${this.webapiUrl}/search/short-list?text=${e}&org=${t}`}getSearchProductsUrl(e,t){return`${this.webapiUrl}/search/short-list/products?text=${e}&page=${t}`}getSearchProducersUrl(e,t){return`${this.webapiUrl}/search/short-list/producers?text=${e}&page=${t}`}getSearchCategoriesUrl(e,t){return`${this.webapiUrl}/search/short-list/categories?text=${e}&page=${t}`}}var N,x;class E extends(x=we,N=m,x){constructor({id:e,name:t,img:s,score:r,url:i}){super({id:Number(e),name:t}),this[N]=!0;const o=new K;this.image=o.toModel({imagePath:s??void 0}),this.score=r,this.url=i}static create(e){return new E(e)}}class Ve{toModel(e){return E.create(e)}}var V,q;class w extends(q=Ae,V=m,q){constructor({id:e,name:t,url:s,imagePath:r,score:i}){super({id:e,name:t,url:s,imagePath:r}),this[V]=!0,this.score=i}static create(e){return new w(e)}}class qe{toModel(e){return w.create({...e,imagePath:e.img||void 0})}}var G;G=m;const Ue=class j{constructor({active:e,attributes:t,availabilities:s,category:r,id:i,img:o,name:ee,options_stock:te,price:A,product_code:O,product_codes:se,promotion_price:I,rate:re,score:ae,url:ie}){this[G]=!0;const oe=new Ie,g=new Ce,M=new Me,ne=new Oe,ce=new K;this.productId=parseInt(i,10),this.name=ee,this.isActive=e,this.isBuyable=s.can_buy,this.producer=ne.toModel({id:NaN,name:t.producer_name}),this.stock=t.stock,this.availabilityLabel=s.label,this.category=oe.toModel(r),this.image=ce.toModel({imagePath:o}),this.isStock=te,this.prices={basic:M.toModel({text:A,float:F.toNumber(A)}),promotion:M.toModel({text:I??"",float:F.toNumber(I??"")??NaN})},this.codes={code:g.toModel({name:"code",value:O}),sku:g.toModel({name:"sku",value:O})},se.reduce((C,y)=>(C[y.label]=g.toModel({name:y.label,value:y.value}),C),this.codes),this.rate=parseFloat(re),this.score=ae,this.url=ie}static create(e){return new j(e)}};let De=Ue;class Ye{toModel(e){return De.create(e)}}class Ke extends he{constructor({httpApi:e,settingsApi:t,localeOptions:s}){super(e),this.moduleName=n.httpApi,this.#s=new Ye,this.#t=new qe,this.#r=new Ve,this.#e=new xe(t,s)}#e;#s;#t;#r;getSuggestions(e){return this.fetch({url:this.#e.getSuggestionsUrl(e),...this._getSearchRequestOptions()})}search(e,t){return this.fetch({url:this.#e.getSearchResultsBasedOnSuggestionsUrl(e,t),...this._getSearchRequestOptions()},{callback:s=>({...s,data:{products:{...s.data.products,list:this._mapProductsToModel(s.data.products?.list)},producers:{...s.data.producers,list:this._mapProducersToModel(s.data.producers?.list)},categories:{...s.data.categories,list:this._mapCategoriesToModel(s.data.categories?.list)}}})})}searchForProducts(e,t){return this.fetch({url:this.#e.getSearchProductsUrl(e,t),...this._getSearchRequestOptions()},{callback:s=>({...s,data:{...s.data,list:this._mapProductsToModel(s.data.list)}})})}searchForProducers(e,t){return this.fetch({url:this.#e.getSearchProducersUrl(e,t),...this._getSearchRequestOptions()},{callback:s=>({...s,data:{...s.data,list:this._mapProducersToModel(s.data.list)}})})}searchForCategories(e,t){return this.fetch({url:this.#e.getSearchCategoriesUrl(e,t),...this._getSearchRequestOptions()},{callback:s=>({...s,data:{...s.data,list:this._mapCategoriesToModel(s.data.list)}})})}_getSearchRequestOptions(){return{method:ue.get,repeatOptions:{maxAttempts:3,attemptDelayInMs:1e3,repeatRequestOnStatusCodes:[S.requestTimeout,S.internalServerError,S.badGateway,S.gatewayTimeout]},sanitizeOptions:{disable:!0},cacheOptions:{type:de.memory,ttlInMs:3e4}}}_mapProductsToModel(e=[]){return e.map(t=>this.#s.toModel(t))}_mapProducersToModel(e=[]){return e.map(t=>this.#t.toModel(t))}_mapCategoriesToModel(e=[]){return e.map(t=>this.#r.toModel(t))}}class ze extends U{constructor({httpApi:e,settingsApi:t,localeOptions:s,flashMessengerApi:r}){super(),this.moduleName=n.service,this.#e=new Ke({httpApi:e,settingsApi:t,localeOptions:s}),this.#s=r}#e;#s;async getSuggestions(e){try{const{data:t}=await this.#e.getSuggestions(e).response;return t}catch(t){const{_flash_messenger:s}=t.response.data;return this._displayFlashMessages(s),null}}async search(e,t){try{const{data:s}=await this.#e.search(e,t).response;return s}catch(s){const{_flash_messenger:r}=s.response.data;return this._displayFlashMessages(r),null}}async searchForProducts(e,t){try{const{data:s}=await this.#e.searchForProducts(e,t).response;return s}catch(s){const{_flash_messenger:r}=s.response.data;return this._displayFlashMessages(r),null}}async searchForProducers(e,t){try{const{data:s}=await this.#e.searchForProducers(e,t).response;return s}catch(s){const{_flash_messenger:r}=s.response.data;return this._displayFlashMessages(r),null}}async searchForCategories(e,t){try{const{data:s}=await this.#e.searchForCategories(e,t).response;return s}catch(s){const{_flash_messenger:r}=s.response.data;return this._displayFlashMessages(r),null}}_displayFlashMessages(e){e&&this.#s.parseAndAddFlashMessages(e,pe)}}
1class We extends _e{constructor(e){super(),this.moduleName=n.api,this.#e=e}#e;async getSuggestions(e){return this.#e.getSuggestions(e)}async search(e,t){return this.#e.search(e,t)}async searchForProducts(e,t){return this.#e.searchForProducts(e,t)}async searchForProducers(e,t){return this.#e.searchForProducers(e,t)}async searchForCategories(e,t){return this.#e.searchForCategories(e,t)}}class Ge{#e;constructor(e){this.#e=e}select$(){return this.#e.pipe($e())}get(){return this.#e.query(Re())}set(e){this.#e.update(Fe(e))}add(e){this.#e.update(Le(e))}delete(e){this.#e.update(ke(e))}}class je{#e;constructor(e){this.#e=e}selectSearchPhrase$(){return this.#e.pipe(f(e=>e.searchPhrase))}selectSuggestions$(){return this.#e.pipe(f(e=>e.suggestions))}selectResults$(){return this.#e.pipe(f(e=>({products:e.products,producers:e.producers,categories:e.categories,productsPagesCount:e.productsPagesCount,isRequestPending:e.isRequestPending})))}updatePendingStatus(e){this.#e.update(l(t=>{t.isRequestPending=e}))}updateSearchPhrase(e){this.#e.update(l(t=>{t.searchPhrase=e}))}updateSuggestions(e){this.#e.update(l(t=>{t.suggestions=e}))}addSuggestion(e){this.#e.update(l(t=>{t.suggestions.push(e)}))}updateResults(e){this.#e.update(l(t=>{t.products=e.products.list,t.producers=e.producers.list,t.categories=e.categories.list,t.productsPagesCount=e.products.pages||0}))}updateProducts(e){this.#e.update(l(t=>{t.products=[...t.products,...e.list]}))}getValue(){return this.#e.getValue()}}class Qe extends U{constructor({searchHistoryRepository:e,searchResultsRepository:t,storeFactoryApi:s,searchInstanceId:r,searchApi:i,settings:o}){super(),this.moduleName=n.viewService,this.#s=e,this.#t=t,this.#e=i,this.#r=s,this.#i=this._getLocalStore(),this.#a=o,this.#o=r,this._setupHistoryFromLocalStore(),this._setupSearchActions(),this._setupHistorySubscriber()}#e;#s;#t;#r;#i;#a;#o;_getLocalStore(){const e=this.#r.getStore(n.historyStore);return e||this.#r.createStore("local",n.historyStore)}_setupHistoryFromLocalStore(){const e=this.#i.getObject(B);e&&this.#s.set(e)}_setupSearchActions(){const e=this.#a.isSearchInCategoriesEnabled||this.#a.isSearchInProducersEnabled||this.#a.isSearchInProductsEnabled;this.#a.isPhraseSuggestionsEnabled&&this._setupSearchSuggestions(e),e&&this._setupSearchResults()}_setupSearchSuggestions(e){this.#t.selectSearchPhrase$().pipe(L(),k(300),T(t=>t?t.length>=$:!1),b(t=>(this.#t.updatePendingStatus(!0),this.#e.getSuggestions(t)))).subscribe(t=>{t&&(e||this.#t.updatePendingStatus(!1),this.#t.updateSuggestions(t),this.#t.updatePendingStatus(!1))})}_setupSearchResults(){let e;this.#a.isPhraseSuggestionsEnabled?e=this.#t.selectSuggestions$().pipe(b(t=>{const s=t[0]!==void 0||this.#t.getValue().searchPhrase!=="",r=t[0]||this.#t.getValue().searchPhrase,i={pages:0,page:0,count:0,list:[],max_score:0,suggests:[]};return s?this.#e.search(r,this.#t.getValue().searchPhrase):Promise.resolve({products:i,producers:i,categories:i})})):e=this.#t.selectSearchPhrase$().pipe(L(),k(300),T(t=>t?t.length>=$:!1),b(t=>(this.#t.updatePendingStatus(!0),this.#e.search(t)))),e.subscribe(t=>{t&&(this.#t.updateResults(t),this.#t.updatePendingStatus(!1))})}_setupHistorySubscriber(){this.#s.select$().subscribe(()=>this._updateLocalStore())}_updateLocalStore(){const e=this.#s.get();this.#i.setObject(B,e)}addHistoryItem(e){this.#s.add(e)}deleteHistoryItem(e){this.#s.delete(e)}updateSearchPhrase(e){this.#t.updateSearchPhrase(e)}getHistory(){return this.#s.get()}selectHistory$(){return this.#s.select$()}selectSearchPhrase$(){return this.#t.selectSearchPhrase$()}selectSuggestions$(){return this.#t.selectSuggestions$()}selectResults$(){return this.#t.selectResults$()}async loadMoreProducts(e,t){const s=await this.#e.searchForProducts(e,t);s&&this.#t.updateProducts(s)}}const Xe=()=>D({name:`${n.historyStore}-${v()}`},Te()),Ze=()=>D({name:`${n.resultsStore}-${v()}`},Se({searchPhrase:"",suggestions:[],products:[],producers:[],categories:[],productsPagesCount:0,isRequestPending:!1}));var Q;Q=m;const Je=class X{constructor({id:e,label:t}){this[Q]=!0,this.id=e,this.label=t}static create(e){return new X(e)}};let et=Je;class tt{constructor(e){this.component=e}render(){return u`${this.component.getSlot("form")}`}}class st{constructor(e){this.component=e}render(){return u` 2 <search-popup-form module-instance-id="${this.component.moduleInstanceId}"> 3 <div slot="form">${this.component.getSlot("form")}</div> 4 </search-popup-form> 5 `}}class rt{constructor(e){this.component=e}render(){return u` 6 <search-sidebar-form module-instance-id="${this.component.moduleInstanceId}"> 7 <div slot="form">${this.component.getSlot("form")}</div> 8 </search-sidebar-form> 9 `}}class at{constructor(e){this._search=e}submit(e){const t=this._search.querySelector('input[type="search"]');if(!t)return;t.value=e,this._search.querySelector("form")?.submit()}}class it{constructor(e){this._search=e}submit(e){const s=document.querySelector(`h-search[module-instance-id="${this._search.moduleInstanceId}"]`)?.closest("form"),r=s?.querySelector('input[type="search"]');r&&(r.value=e,s?.submit())}}
9class ot{constructor(e){this._search=e}submit(e){const s=document.querySelector(`h-search[module-instance-id="${this._search.moduleInstanceId}"]`)?.closest("form"),r=s?.querySelector('input[type="search"]');r&&(r.value=e,s?.submit())}}var nt=Object.defineProperty,_=(a,e,t,s)=>{for(var r=void 0,i=a.length-1,o;i>=0;i--)(o=a[i])&&(r=o(e,t,r)||r);return r&&nt(e,t,r),r};class d extends P{constructor(){super(),this._searchContextProvider=null,this._scrollYBeforeOpen=0,this._isBodyScrollLocked=!1,this._handleSearchBarOpenerClick=()=>this.openSearchBar(),this._handleSearchBarOpenerKeydown=e=>this.openSearchBarWithKeyboard(e),this.displayMode="dropdown",this._isOverlayActive=!1,this._searchState=new He({searchPhrase:"",history:[],results:{suggestions:[],products:[],producers:[],categories:[],productsPagesCount:0,isRequestPending:!1},translations:{}}),this._selectSearchPhraseSubscription$=null,this._selectSuggestionsSubscription$=null,this._selectResultsSubscription$=null,this._selectHistorySubscription$=null,this._isDropdown=!0,this._isPopup=!1,this._isSidebar=!1,this._createTranslations=()=>({searchHistory:this._translationApi.translate("Search history"),enterSearchPraseOrChooseFromHistory:this._translationApi.translate("Enter a search phrase or repeat one of the searches below."),enterSearchPrase:this._translationApi.translate("Enter a search phrase."),emptySearchPhraseFlashMessage:this._translationApi.translate("The search f
9ield cannot be blank"),suggestions:this._translationApi.translate("Suggestions"),products:this._translationApi.translate("Products"),producers:this._translationApi.translate("Producers"),loadMore:this._translationApi.translate("Load more"),goToProductsFor:this._translationApi.translate("Go to products for"),category:this._translationApi.translate("category"),inTheCategory:this._translationApi.translate("in the category"),searchInStore:this._translationApi.translate("search in store"),availability:this._translationApi.translate("Availability"),priceForTheBaseModel:this._translationApi.translate("Price for the base model. Variants may have a different price."),search:this._translationApi.translate("Search"),regularPrice:this._translationApi.translate("Regular price")}),this._updateSearchPhraseOnPhraseSubmit=e=>{if(!e.detail)return;if((e.detail?.searchPhrase.trim()).length<2){this._flashMessengerApi.addFlashMessage({type:"error",content:this._translationApi.translate("The search field must have at least 2 characters")}),this._searchViewService.updateSearchPhrase(e.detail.searchPhrase);return}this.settings?.isSearchSuggestLayerEnabled&&(this._isModuleInstanceIdValid(e.detail.moduleInstanceId)&&this._searchViewService.updateSearchPhrase(e.detail.searchPhrase),this._customerPrivacyApi?.onFunctionalConsentGranted(()=>this._updateHistory(e.detail?.searchPhrase))),this._isModuleInstanceIdValid(e.detail.moduleInstanceId)&&this._getSubmissionStrategyInstance().submit(e.detail.searchPhrase)},this._updateSearchPhrase=e=>{!e.detail||!this._isModuleInstanceIdValid(e.detail.moduleInstanceId)||this._searchState.getValue()?.searchPhrase===e.detail.searchPhrase||this._searchViewService.updateSearchPhrase(e.detail.searchPhrase)},this._removeHistoryItem=e=>{e.detail&&this._searchViewService.deleteHistoryItem(e.detail.id)},this._loadMoreProducts=e=>{!e.detail||!this._isModuleInstanceIdValid(e.detail.moduleInstanceId)||this._searchViewService.loadMoreProducts(e.detail.searchPhrase,e.detail.page)},this._updateOverlayState=()=>{const e=this.querySelector('[aria-haspopup="dialog"]')?.getAttribute("name"),t=e?this.querySelector(`[hidden][id="${e}"]`):null;window.innerWidth<R.sm?(this._isOverlayActive=!1,t?.opened&&document.body.dispatchEvent(new CustomEvent(c.searchOpenMobileView)),this._settingsApi.isFeatureEnabled("dev_search_close_aria_hidden_fix")&&window.requestAnimationFrame(()=>this._setupSearchBarOpener())):this._isDropdown||(this._isOverlayActive=!0,this._hSearch?.classList.contains("search_mobile-opened")&&(t?.open(),this._hSearch?.classList.remove("search_mobile-opened"),this._settingsApi.isFeatureEnabled("dev_search_focus_trap_fix")&&this._hSearch?.mobileFocusTrapController.deactivate(),this._unpinFlashMessengers()),this._settingsApi.isFeatureEnabled("dev_search_close_aria_hidden_fix")&&window.requestAnimationFrame(()=>this._setupSearchBarOpener()))},this._handleDocumentContextRequest=e=>{const t=e,s=t.detail.key;s===this.moduleInstanceId&&(t.detail[s]=this._searchState,e.stopPropagation())},this._handleVisualViewportResize=()=>{this._isBodyScrollLocked&&window.scrollY!==0&&window.scrollTo(0,0)},this._handleSearchClose=()=>{this.closeSearchBar()},this._closeSearchBarOnEsc=e=>{if(!this._hSearch||!this._hSearch.classList.contains("search_mobile-opened"))return;const t=this._hSearch.querySelector('input[type="search"]');if(!t)return;const s=t.value.length===0;[e.key==="Escape",e.key!=="Enter",e.ctrlKey===!1,e.shiftKey===!1,e.altKey===!1,s].every(o=>o)&&(e.preventDefault(),this.closeSearchBar())},this._closeSearchBarOnClickOutside=e=>{if(!this._hSearch||!this._hSearch.classList.contains("search_mobile-opened")||this._searchBarOpener?.contains(e.target))return;!this._hSearch.contains(e.target)&&(e.preventDefault(),this.closeSearchBar())},this._searchApi=this.getApiSync(n.api),this._settingsApi=this.getApiSync(W.api),this.getApi(me).then(e=>{this._customerPrivacyApi=e}),this.getApi(ge.api).then(e=>{this._translationApi=e,this._setupTranslationsInState(),this._translationApi.subscribeOnLanguageChange(()=>{this._setupTranslationsInState()})}),this._flashMessengerApi=this.getApiSync(Y.api)}static{this.moduleName=n.component}connectedCallback(){super.connectedCallback(),this._setupDisplayModeStates(),window.innerWidth>=R.sm&&(this._isOverlayActive=!this._isDropdown),this._isDropdown||document.addEventListener(H.valueRequested,this._handleDocumentContextRequest),this._setupContext(),this._setupListeners(),this.addEventListener("close",this._handleSearchClose,{capture:!0});const e=this.querySelector("form");e?.classList.remove("hidden-xs-only","hidden-sm-only"),e?.removeAttribute("hidden"),this._settingsApi.isFeatureEnabled("dev_search_close_aria_hidden_fix")?window.requestAnimationFrame(()=>this._setupSearchBarOpener()):window.requestAnimationFrame(()=>{this._hSearch=this.querySelector("h-search")||void 0,this._searchBar=this.querySelector(".search__bar")||void 0,this._searchBarOpener=this.querySelector(".search__icon")||void 0,this._searchBarClose=this.querySelector(".search__close")||void 0,this._searchBarOpener&&(this._searchBarOpener.addEventListener("click",()=>this.openSearchBar()),this._searchBarOpener.addEventListener("keydown",t=>this.openSearchBarWithKeyboard(t)))}),this.settings?.isSearchSuggestLayerEnabled&&(this._setupSearchViewService(),this._setupSubscribers())}disconnectedCallback(){super.disconnectedCallback(),this._unlockBodyScroll(),this._selectSearchPhraseSubscription$?.unsubscribe(),this._selectSuggestionsSubscription$?.unsubscribe(),this._selectResultsSubscription$?.unsubscribe(),this._selectHistorySubscription$?.unsubscribe(),this._isDropdown||document.removeEventListener(H.valueRequested,this._handleDocumentContextRequest),document.removeEventListener(c.searchPhraseSubmitted,this._updateSearchPhraseOnPhraseSubmit),this.removeEventListener("close",this._handleSearchClose,{capture:!0}),this._isDropdown||window.removeEventListener("resize",this._updateOverlayState),this._searchBarOpener&&(this._settingsApi.isFeatureEnabled("dev_search_close_aria_hidden_fix")?(this._searchBarOpener.removeEventListener("click",this._handleSearchBarOpenerClick),this._searchBarOpener.removeEventListener("keydown",this._handleSearchBarOpenerKeydown)):(this._searchBarOpener.removeEventListener("click",()=>this.openSearchBar()),this._searchBarOpener.removeEventListener("keydown",e=>this.openSearchBarWithKeyboard(e)))),this.settings?.isSearchSuggestLayerEnabled&&(document.removeEventListener(c.searchPhraseUpdated,this._updateSearchPhrase),document.removeEventListener(c.removeHistoryItem,this._removeHistoryItem),document.removeEventListener(c.loadMoreProducts,this._loadMoreProducts))}_setupTranslationsInState(){const e=this._searchState.getValue(),t=this._createTranslations();this._searchState.notify({...e,translations:t})}_setupDisplayModeStates(){this._isDropdown=this.displayMode==="dropdown",this._isPopup=this.displayMode==="popup",this._isSidebar=this.displayMode==="sidebar"}_setupContext(){this._searchContextProvider=new Ne(this),this._searchContextProvider.provide(this.moduleInstanceId,this._searchState)}_setupListeners(){document.addEventListener(c.searchPhraseSubmitted,this._updateSearchPhraseOnPhraseSubmit),this._isDropdown||window.addEventListener("resize",this._updateOverlayState),this.settings?.isSearchSuggestLayerEnabled&&(document.addEventListener(c.searchPhraseUpdated,this._updateSearchPhrase),document.addEventListener(c.removeHistoryItem,this._removeHistoryItem),document.addEventListener(c.loadMoreProducts,this._loadMoreProducts))}_getSubmissionStrategyInstance(){return this._isOverlayActive&&this._isPopup?new it(this):this._isOverlayActive&&this._isSidebar?new ot(this):new at(this)}_isModuleInstanceIdValid(e){return e===this.moduleInstanceId}_updateHistory(e){const t=this._searchViewService.getHistory(),s=t.findIndex(i=>i.label===e);s!==-1&&this._searchViewService.deleteHistoryItem(t[s].id),this._searchViewService.addHistoryItem(et.create({label:e,id:v()}))}_setupSearchViewService(){const e=this.getApiSync(ye),t=Ze(),s=new je(t),r=Xe(),i=new Ge(r);this._searchViewService=new Qe({searchResultsRepository:s,searchHistoryRepository:i,storeFactoryApi:e,searchApi:this._searchApi,searchInstanceId:this.moduleInstanceId,settings:this.settings})}_setupSubscribers(){this._selectSearchPhraseSubscription$=this._searchViewService.selectSearchPhrase$().subscribe(e=>{const t=this._searchState.getValue();this._searchState.notify({...t,searchPhrase:e})}),this._selectSuggestionsSubscription$=this._searchViewService.selectSuggestions$().subscribe(e=>{const t=this._searchState.getValue();this._searchState.notify({...t,results:{...t.results,suggestions:e}})}),this._selectResultsSubscription$=this._searchViewService.selectResults$().subscribe(e=>{const t=this._searchState.getValue();this._searchState.notify({...t,results:{...t.results,...e}})}),this._selectHistorySubscription$=this._searchViewService.selectHistory$
9().subscribe(e=>{const t=this._searchState.getValue();this._searchState.notify({...t,history:e.reverse()})})}_setupSearchBarOpener(){this._searchBarOpener&&(this._searchBarOpener.removeEventListener("click",this._handleSearchBarOpenerClick),this._searchBarOpener.removeEventListener("keydown",this._handleSearchBarOpenerKeydown)),this._hSearch=this.querySelector("h-search")||void 0,this._searchBar=this.querySelector(".search__bar")||void 0,this._searchBarOpener=this.querySelector(".search__icon")||void 0,this._searchBarClose=this.querySelector(".search__close")||void 0,this._searchBarOpener&&(this._searchBarOpener.addEventListener("click",this._handleSearchBarOpenerClick),this._searchBarOpener.addEventListener("keydown",this._handleSearchBarOpenerKeydown))}_manageFocus(e){const t=s=>{Be.keepFocusWithinContainer(e,s)};document.addEventListener("keydown",t),this._searchBarClose?.addEventListener("click",()=>{document.removeEventListener("keydown",t),document.removeEventListener("keydown",t)})}_pinFlashMessengers(){document.querySelectorAll(".flash-messenger_fixed").forEach(e=>{e.classList.add("flash-messenger_bottom")})}_unpinFlashMessengers(){document.querySelectorAll(".flash-messenger_fixed").forEach(e=>{e.classList.remove("flash-messenger_bottom")})}_lockBodyScroll(){this._isBodyScrollLocked||(this._isBodyScrollLocked=!0,this._scrollYBeforeOpen=window.scrollY,document.body.style.top=`-${this._scrollYBeforeOpen}px`,document.body.classList.add("search_scroll-locked"),window.visualViewport?.addEventListener("resize",this._handleVisualViewportResize))}_unlockBodyScroll(){this._isBodyScrollLocked&&(this._isBodyScrollLocked=!1,window.visualViewport?.removeEventListener("resize",this._handleVisualViewportResize),document.body.classList.remove("search_scroll-locked"),document.body.style.top="",window.scrollTo(0,this._scrollYBeforeOpen))}openSearchBar(){this._hSearch&&(this._searchBarClose?.setAttribute("tabindex","0"),this._searchBarClose?.setAttribute("aria-hidden","false"),this._pinFlashMessengers(),this._lockBodyScroll(),this._settingsApi.isFeatureEnabled("dev_mobile_search_layer")&&this._searchBar&&this._manageFocus(this._searchBar),document.addEventListener("keydown",this._closeSearchBarOnEsc),document.addEventListener("click",this._closeSearchBarOnClickOutside))}closeSearchBar(){!this._hSearch||!this._hSearch.classList.contains("search_mobile-opened")||(this._hSearch.classList.remove("search_mobile-opened"),this._settingsApi.isFeatureEnabled("dev_search_focus_trap_fix")&&this._hSearch?.mobileFocusTrapController.deactivate(),this._searchBarClose?.setAttribute("tabindex","-1"),this._searchBarClose?.setAttribute("aria-hidden","true"),this._searchBarOpener?.focus(),this._settingsApi.isFeatureEnabled("dev_search_fixes")&&this._hSearch.dispatchEvent(new CustomEvent(c.searchClose,{bubbles:!0,composed:!0})),this._unpinFlashMessengers(),this._unlockBodyScroll(),document.removeEventListener("keydown",this._closeSearchBarOnEsc),document.removeEventListener("click",this._closeSearchBarOnClickOutside))}openSearchBarWithKeyboard(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.openSearchBar())}_getRenderStrategyInstance(){return this._isOverlayActive&&this._isPopup?new st(this):this._isOverlayActive&&this._isSidebar?new rt(this):new tt(this)}render(){return super.render(),this._getRenderStrategyInstance().render()}}_([p({type:String,attribute:"display-mode"})],d.prototype,"displayMode");_([p({type:String,attribute:"module-instance-id"})],d.prototype,"moduleInstanceId");_([z()],d.prototype,"_isOverlayActive");_([z()],d.prototype,"_searchState");_([p({type:Object})],d.prototype,"settings");var ct=Object.defineProperty,ht=(a,e,t,s)=>{for(var r=void 0,i=a.length-1,o;i>=0;i--)(o=a[i])&&(r=o(e,t,r)||r);return r&&ct(e,t,r),r};class Z extends P{static{this.moduleName="search-popup-form"}render(){return super.render(),u` 10 <h-modal-opener 11 name="modal-${this.moduleInstanceId}" 12 class="search__icon labeled-icon search__popup-opener" 13 > 14 <span class="sr-only"> ${h("Open search engine")} </span> 15 16 <h-icon 17 icon-name="icon-search" 18 size="l" 19 aria-hidden="true" 20 ></h-icon> 21 <div 22 class="labeled-icon__signature" 23 aria-hidden="true" 24 > 25 ${h("Search")} 26 </div> 27 </h-modal-opener> 28 29 <h-modal 30 id="modal-${this.moduleInstanceId}" 31 class="search__popup" 32 hidden 33 > 34 <h-modal-header> 35 <h2 class="font_semibold">${h("Search")}</h2> 36 <h-modal-close class="btn btn_icon">
37 <span class="sr-only"> ${h("Close window")} </span> 38 <h-icon 39 icon-name="icon-x" 40 aria-hidden="true" 41 ></h-icon> 42 </h-modal-close> 43 </h-modal-header> 44 <h-modal-body> ${this.getSlot("form")} </h-modal-body> 45 </h-modal> 46 `}}ht([p({type:String,attribute:"module-instance-id"})],Z.prototype,"moduleInstanceId");var lt=Object.defineProperty,dt=(a,e,t,s)=>{for(var r=void 0,i=a.length-1,o;i>=0;i--)(o=a[i])&&(r=o(e,t,r)||r);return r&<(e,t,r),r};class J extends P{static{this.moduleName="search-sidebar-form"}render(){return super.render(),u` 47 <h-sheet-opener 48 name="sidebar-${this.moduleInstanceId}" 49 class="search__icon labeled-icon search__sidebar-opener" 50 > 51 <span class="sr-only"> ${h("Open search engine")} </span> 52 53 <h-icon 54 icon-name="icon-search" 55 size="l" 56 ></h-icon> 57 <div 58 class="labeled-icon__signature" 59 aria-hidden="true" 60 > 61 ${h("Search")} 62 </div> 63 </h-sheet-opener> 64 65 <h-sheet 66 id="sidebar-${this.moduleInstanceId}" 67 class="search__sidebar" 68 hidden 69 > 70 <h-sheet-header> 71 <h2 class="font_semibold">${h("Search")}</h2> 72 <h-sheet-close class="btn btn_icon"> 73 <span class="sr-only">${h("Close window")}</span> 74 <h-icon 75 icon-name="icon-x" 76 aria-hidden="true" 77 ></h-icon> 78 </h-sheet-close> 79 </h-sheet-header> 80 <h-sheet-body>
80 ${this.getSlot("form")} </h-sheet-body> 81 </h-sheet> 82 `}}dt([p({type:String,attribute:"module-instance-id"})],J.prototype,"moduleInstanceId");class Bt extends fe{static{this.featureName=n.feature}static{this.dependencies=[be]}init(){const e=this.getApiSync(ve),t=this.getApiSync(W.api),s=this.getApiSync(Y.api),r=new ze({httpApi:e,settingsApi:t,flashMessengerApi:s});return{cores:[{type:Pe,instance:[Z,J,d]},{type:Ee.api,instance:new We(r)}]}}}export{Bt as SearchInitializer};
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.