1"use strict";(self["vic.app.globalLoadingChunk"]=self["vic.app.globalLoadingChunk"]||[]).push([[56655],{25520(t,e,i){var r,s,a,n,l,o,h,u,c,g=i(43439),p=i.n(g),d=i(59649),y=i.n(d),f=(i(52301),i(54767)),m=i(88045),b=i(13263),v=i(54714),F=i(72420),R=i(69592),w=i(51010),B=i(492);let x=(r=(0,f.hq)(".vic-m-product-catalogue__search-input"),s=(0,f.hq)(".vic-m-product-catalogue__filter-bar"),a=(0,f.hq)(".vic-m-product-catalogue__results"),n=(0,f.rF)("filterBar",R.kx),l=(0,f.rF)("searchInput",R.eS),o=class extends f.uA{constructor(...t){super(...t),this.initialContentCleared=!1,p()(this,"searchInput",h,this),p()(this,"filterBar",u,this),p()(this,"resultBox",c,this),this._numberResults=0,this.pagination=void 0,this.paginationLocked=!1}afterComponentRender(){this.triggerInitialSearch()}async triggerInitialSearch(){const t=b.tJ.get("q");null!==t&&(await(0,m.db)(this.searchInput),this.searchInput.currentValue=t),this.searchItems({newQueryString:!0,isInitialSearch:!0})}getInitialFilters(){const t=[...new Set(b.tJ.getAllKeys().filter(t=>t.startsWith("filter_")))],e=[];return t.forEach(t=>{(b.tJ.getAll(t)||[]).forEach(i=>{const r=t.replace("filter_","");e.push({categoryKey:r,name:i,iconId:"",tag:i})})}),e.filter(t=>""!==t.name)}get activeFilters(){return Array.from(this.filterBar.activeFilters.values()).map(t=>({groupKey:t.categoryKey,tagKey:t.tag}))}async handleFilterChange(){await Promise.all([this.searchItems(),this.scrollToTop()])}async scrollToTop(){!1!==this.filterBar.flyoutOpen&&await B.A.scrollToElement(this)}get pageSize(){return 12}get currentPage(){return this.pagination?.activeItem||0}get isInitialPage(){return 0===this.currentPage}get queryString(){return this.searchInput.currentValue}get searchUrl(){return this.getAttribute("search-url")||""}get numberResults(){return this._numberResults}set numberResults(t){this._numberResults!==t&&(this._numberResults=t,(0,m.p1)(this.pagination||null,F.F4,t<=this.pageSize))}handleSearchInputSubmit(){b.tJ.set("q",this.queryString),this.searchItems({newQueryString:!0})}handlePaginationChanged(){if(this.paginationLocked)return;const t=this.pagination?.activeItem;void 0!==t&&this.loadPage(t)}async searchItems({newQueryString:t=!1,isInitialSearch:e=!1}={}){if(""!==this.searchUrl){t&&(await(0,m.db)(this.filterBar),this.filterBar.resetFilterList(),(0,m.vy)(this.filterBar,F.S2)),this.filterBar.flyout.isLoading=!0,await this.renderPlaceholders(this.pageSize);try{const i=await w.A.getEnrichedResultsFor({endpointUrl:this.searchUrl,includeMeta:e||t,size:this.pageSize,filter_tags:new Set(this.activeFilters),rangeFilters:this.filterBar.activeRangeFilters,queryString:this.queryString});if(null===i)throw new Error("api not responding");this.numberResults=i.results.numberResults,this.filterBar.flyout.numberResults=i.results.numberResults,this.filterBar.flyout.isLoading=!1,this.updatePagination(),t&&(this.updateFilters(i),(0,m.iQ)(this.filterBar,F.S2)),e?this.filterBar.setActiveFilters(this.getInitialFilters()):await this.renderItems(i.results.items)}catch(t){b.bD.error("ProductCatalog: ",t)}}}async loadPage(t){const e=this.numberResults-t*this.pageSize,i=e>=this.pageSize?this.pageSize:e;await this.renderPlaceholders(i),window.scrollTo({top:this.offsetTop,behavior:"smooth"});try{const e=await w.A.getResultsFor({endpointUrl:this.searchUrl,includeMeta:!1,size:this.pageSize,offset:t*this.pageSize,filter_tags:new Set(this.activeFilters),rangeFilters:this.filterBar.activeRangeFilters,queryString:this.queryString});if(null===e)throw new Error("api not responding");await this.renderItems(e.results.items)}catch(t){b.bD.error("ProductCatalog: ",t)}}async renderItems(t){if(0===t.length)return void await this.renderNoResultMessage();const e=await this.loadResultListTemplate();(0,v.XX)(e(t),this.resultBox)}async renderNoResultMessage(){const t=await this.loadNoResultTemplate();(0,v.XX)(await t(this),this.resultBox)}async loadNoResultTemplate(){const{noResultMessageTemplate:t}=await i.e(23503).then(i.bind(i,23503));return t}async loadResultListTemplate(){const{renderResultList:t}=await i.e(23503).then(i.bind(i,23503));return t}async renderPlaceholders(t){const e=await this.loadPlaceholderTemplate();!1===this.initialContentCleared&&(this.resultBox.innerHTML="",this.initialContentCleared=!0),(0,v.XX)(e(t),this.resultBox)}async loadPlaceholderTemplate(){const{renderPlaceholders:t}=await i.e(23503).then(i.bind(i,23503));return t}initPagination(){if(void 0!==this.pagination)return;const t=Math.ceil(this.numberResults/this.pageSize),e=document.createElement("vic-m-pagination");(0,m.iQ)(e,"vic-m-pagination","vic-m-product-catalogue__pagination"),e.setAttribute("page-count",t.toString()),this.pagination=e,(0,m.MR)(this.pagination,R.i$,this.handlePaginationChanged,this),this.numberResults<=this.pageSize&&(0,m.iQ)(this.pagination,F.F4),this.appendChild(e)}updatePagination(){if(this.paginationLocked=!0,void 0===this.pagination)return this.initPagination(),void(this.paginationLocked=!1);const t=Math.ceil(this.numberResults/this.pageSize);this.pagination?.resetActiveItem(),this.pagination?.setAttribute("page-count",t.toString()),this.paginationLocked=!1}updateFilters(t){const e=t.meta.categories.PRODUCT;this.filterBar.updateFilterList(e),(0,m.p1)(this.filterBar,F.RG,0===t.results.numberResults)}resetFilters(t=!0){this.filterBar.resetFilters(t)}},h=y()(o.prototype,"searchInput",[r],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),u=y()(o.prototype,"filterBar",[s],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),c=y()(o.prototype,"resultBox",[a],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),y()(o.prototype,"handleFilterChange",[n],Object.getOwnPropertyDescriptor(o.prototype,"handleFilterChange"),o.prototype),y()(o.prototype,"handleSearchInputSubmit",[l],Object.getOwnPropertyDescriptor(o.prototype,"handleSearchInputSubmit"),o.prototype),o);customElements.define("vic-m-product-catalogue",x);var S,T,C,A,P,I,O,_,z,k,E,L,j,q=i(13750),Q=i(14634);let M=(S=(0,f.hq)(".vic-m-product-catalogue-filter-bar__top-box"),T=(0,f.hq)(".vic-m-product-catalogue-filter-bar__flyout-toggles"),C=(0,f.hq)(".vic-m-product-catalogue-filter-bar__nav-btn--prev"),A=(0,f.hq)(".vic-m-product-catalogue-filter-bar__nav-btn--next"),P=(0,f.rF)("window","resize"),I=(0,q.nF)(100),O=(0,f.rF)("flyoutToggleBox","scroll"),_=(0,q.nF)(100),z=class extends f.uA{get numberResultsPrefix(){return this.getAttribute("i18n-prefix")||""}constructor(){super({asyncRendering:!0}),this._flyout=void 0,this.priorityCategories=[],this.priorityRangeFilters=[],p()(this,"topBox",k,this),p()(this,"flyoutToggleBox",E,this),p()(this,"prevBtn",L,this),p()(this,"nextBtn",j,this)}get flyout(){if(void 0!==this._flyout)return this._flyout;const t=document.createElement("vic-m-filter-flyout");return(0,m.iQ)(t,"vic-m-filter-flyout"),t.setAttribute("id","vic-filter-flyout"),t.setAttribute("i18n-prefix",this.numberResultsPrefix),this._flyout=t,document.body.appendChild(t),t}get flyoutOpen(){return void 0!==this._flyout&&this.flyout.isOpen}get activeFilters(){return this.flyout.activeFilters}get relevantRangeFilterCategories(){return(0,Q.C)(this,"range-filter-category-").map(t=>t.value)}get activeRangeFilters(){return this.flyout.activeRangeFilters}get templateArgs(){return{activeFilters:this.activeFilters,component:this,priorityCategories:this.priorityCategories,priorityRangeFilters:this.priorityRangeFilters}}async renderAsync(){const t=await this.loadTemplate();(0,v.XX)(await t(this.templateArgs),this)}async loadTemplate(){const{productCatalogueFilterBarTemplate:t}=await i.e(95915).then(i.bind(i,95915));return t}afterComponentRender(){this.updateOverflowIndicators(),this.initEvents(),this.initViewportObserver()}initEvents(){(0,m.MR)(this.flyout,R.kx,this.handleActiveFilterChanged,this),(0,m.MR)(this.flyout,R.s5,this.handleFlyoutReset,this)}initViewportObserver(){new IntersectionObserver(t=>{0===t[0].intersectionRatio?this.addStickyClass():1===t[0].intersectionRatio&&(0,m.vy)(this,F.Ag)},{threshold:[0,1]}).observe(this.topBox)}async addStickyClass(){(0,m.nB)(document.body,F.DM)?((0,m.iQ)(this,F.Ag,F.ZB),await(0,m.fm)(300),(0,m.vy)(this,F.ZB)):(0,m.iQ)(this,F.Ag)}resetFilterList(){this.flyout.categoryData=void 0}setActiveFilters(t){this.flyout.setActiveFilters(t)}async updatePriorityCategories(t){const e=t.filters||{};this.priorityCategories=Object.keys(e).filter(t=>!0===e[t].priorityFilter).map(t=>({name:e[t].name,key:t}));const i=t.rangeFilters||{};this.priorityRangeFilters=Object.keys(i).filter(t=>this.relevantRangeFilterCategories.includes(t)&&!0===i[t].priorityFilter).map(t=>({name:i[t].name,key:t})),await this.renderAsync(),this.updateOverflowIndicators()}updateFilterList(t){this.flyout.categoryData={...t,rangeFilters:this.getRelevantRangeFilters(t)},this.updatePriorityCategories(t);const e=Object.keys(t.filters||{}).length>0,i=Object.keys(t.rangeFilters||{}).length>0;(0,m.p1)(this,F.RG,!e&&!i)}handleActiveFilterChanged(){this.renderAsync(),this.dispatchEvent(new CustomEvent(R.kx,{bubbles:!1}))}handleFlyoutReset(){this.renderAsync()}async resetFilters(t=!0){await this.flyout.resetAllFilters(t),this.renderAsync()}removeFilter(t){this.flyout.removeFilter(t)}removeFilterRange(t){this.flyout.removeRangeFilter(t)}openFlyout(t){this.flyout.open(t)}handleResize(){this.updateOverflowIndicators()}handleFlyoutToggleBoxScroll(){this.updateOverflowIndicators()}handlePrevBtnClick(){this.flyoutToggleBox.scrollTo({left:this.flyoutToggleBox.scrollLeft-this.flyoutToggleBox.offsetWidth/2,behavior:"smooth"})}handleNextBtnClick(){this.flyoutToggleBox.scrollTo({left:this.flyoutToggleBox.scrollLeft+this.flyoutToggleBox.offsetWidth/2,behavior:"smooth"})}updateOverflowIndicators(){const t=this.flyoutToggleBox.offsetWidth<this.flyoutToggleBox.scrollWidth;(0,m.p1)(this.flyoutToggleBox,F.DQ,t),(0,m.p1)(this.prevBtn,F.f9,t),(0,m.p1)(this.nextBtn,F.f9,t);const e=this.flyoutToggleBox.scrollLeft>0;(0,m.p1)(this.flyoutToggleBox,F.zh,e),this.prevBtn.toggleAttribute("disabled",!e);const i=this.flyoutToggleBox.scrollLeft+this.flyoutToggleBox.offsetWidth<this.flyoutToggleBox.scrollWidth;(0,m.p1)(this.flyoutToggleBox,F.Wb,i),this.nextBtn.toggleAttribute("disabled",!i)}getRelevantRangeFilters(t){const e=t.rangeFilters;if(void 0===e)return;const i=this.relevantRangeFilterCategories;if(0===i.length)return;const r={};
1return i.forEach(t=>{e[t]&&(r[t]=e[t])}),r}},k=y()(z.prototype,"topBox",[S],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),E=y()(z.prototype,"flyoutToggleBox",[T],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),L=y()(z.prototype,"prevBtn",[C],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),j=y()(z.prototype,"nextBtn",[A],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),y()(z.prototype,"handleResize",[P,I],Object.getOwnPropertyDescriptor(z.prototype,"handleResize"),z.prototype),y()(z.prototype,"handleFlyoutToggleBoxScroll",[O,_],Object.getOwnPropertyDescriptor(z.prototype,"handleFlyoutToggleBoxScroll"),z.prototype),z);customElements.define("vic-m-product-catalogue-filter-bar",M)},14634(t,e,i){var r=i(91242);i.d(e,["C",0,(t,e)=>Array.from(t.attributes).filter(t=>t.name.startsWith(e)).map(t=>({key:(0,r.Cb)(t.name.replace(e,"")),value:t.value}))])},51010(t,e,i){var r=i(8748),s=i(97203);class a extends r.S{getQueryParams(t){const e=super.getQueryParams(t);return void 0!==t.category&&e.append("category",t.category),!0===t.isPopular&&e.append("isPopular","true"),void 0!==t.rangeFilters&&t.rangeFilters.forEach(t=>{const i=this.getQueryParamsObjectForFilterRange(t);Object.entries(i).forEach(([t,i])=>{e.append(t,i)})}),e}async getEnrichedResultsFor(t){const e=await super.getResultsFor(t);return null===e?null:await this.enrichApiResponse(e)}async enrichApiResponse(t){const e=Object.entries(t.meta.categories),i=await Promise.all(e.map(async([t,e])=>{const i=e.rangeFilters,r=await this.enrichRangeFilters(i);return[t,{...e,rangeFilters:r}]}));return{...t,meta:{...t.meta,categories:Object.fromEntries(i)}}}async enrichRangeFilters(t){if(void 0===t)return;const e=await Promise.all(Object.entries(t).map(async([t,e])=>[t,await this.enrichRangeFilter(t,e)]));return Object.fromEntries(e)}async enrichRangeFilter(t,e){return{...e,name:await s.A.getValueOrDefault(`viessmann.corporate.search.pageSearch.rangeFilter.${t}.label`,t)}}getQueryParamsObjectForFilterRange(t){const e=new Map;return void 0!==t.min&&e.set(`min${t.name}`,t.min.toString()),void 0!==t.max&&e.set(`max${t.name}`,t.max.toString()),Object.fromEntries(e)}}const n=new a;i.d(e,["A",0,n])},85822(){}},t=>{var e=e=>t(t.s=e);e(25520),e(85822)}]); 2//# sourceMappingURL=vic.productCatalogue.js.map
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.