1"use strict";(self.webpackChunkcrownpeak_opus2=self.webpackChunkcrownpeak_opus2||[]).push([["blog-loader"],{"./src/js/opus2/blog/blog-list.ts"(e,t,a){a.d(t,{BlogList:()=>d});var o=a(/*! tslib */"./node_modules/tslib/tslib.es6.mjs"),n=a(/*! moment */"./node_modules/moment/moment.js"),s=a.n(n),r=a(/*! ../api/apiRequest */"./src/js/opus2/api/apiRequest.ts"),l=a(/*! ../util/loader */"./src/js/opus2/util/loader.ts"),i=a(/*! ../util/share */"./src/js/opus2/util/share.ts"),c=a(/*! ../util/blogPageLocation */"./src/js/opus2/util/blogPageLocation.ts");class d{constructor(){this.itemsPerPage=10,this.currentPage=1,this.data=[],document.addEventListener("DOMContentLoaded",()=>(0,o.__awaiter)(this,void 0,void 0,function*(){var e;const t=null===(e=document.getElementById("conceptCode"))||void 0===e?void 0:e.value,a=yield(0,i.getBrandDetailsFromBrandJson)(t);this.brandDetail=a;(null===document||void 0===document?void 0:document.querySelector(".blog-list"))&&((null==a?void 0:a.enable_fte)||this.getData(null))}));const e=document.querySelector(".blog-search-form");null==e||e.addEventListener("submit",e=>{var t;e.preventDefault();const a=(null===(t=document.getElementById("search-blog"))||void 0===t?void 0:t.value)||"";""!==(null==a?void 0:a.trim())?this.updateURLParams():window.location.reload()});const t=document.getElementById("filter-blog");null==t||t.addEventListener("change",e=>{e.preventDefault(),this.updateURLParams()});const a=document.getElementById("a_share_link_blogs");null==a||a.addEventListener("click",e=>{e.preventDefault();let t=decodeURIComponent(window.location.href);this.copyToClipboard(t)})}copyToClipboard(e){const t=t=>{t.clipboardData.setData("text/plain",e),t.preventDefault()};document.addEventListener("copy",t),document.execCommand("copy"),alert(`${e}\n Copied to Clipboard`),document.removeEventListener("copy",t)}updateURLParams(){var e,t,a;if(null===(e=this.brandDetail)||void 0===e?void 0:e.enable_fte)this.updateBlogURLParams();else{const e="1",o=(null===(t=document.getElementById("search-blog"))||void 0===t?void 0:t.value)||"",n=(null===(a=document.getElementById("filter-blog"))||void 0===a?void 0:a.value)||"",s=new URL(window.location.href);s.searchParams.set("page",e),s.searchParams.set("search",o),s.searchParams.set("categories","--Select--"!=n?n:""),window.location.href=s.href}}updateBlogURLParams(){return(0,o.__awaiter)(this,void 0,void 0,function*(){var e;const t=this.getSearchTerm(),a=new URL(window.location.href);let o=this.formatSearchTerm(t);sessionStorage.setItem("blog_search",o),(null===(e=this.brandDetail)||void 0===e?void 0:e.includeTrailingSlash)&&(o+="/");const n=localStorage.getItem("dbaName"),s=this.getLocalBlogUrlName(),r=window.location.pathname;this.isDbaNameInSearch(n,a)?this.updateUrlForDbaName(n,s,o,a):this.updateUrlForNonDbaName(r,o,a),window.location.href=a.href})}getSearchTerm(){var e,t;return(null===(t=null===(e=document.getElementById("search-blog"))||void 0===e?void 0:e.value)||void 0===t?void 0:t.trim())||""}formatSearchTerm(e){return null==e?void 0:e.replace(/\s+/g,"-")}getLocalBlogUrlName(){var e;const t=localStorage.getItem("brandDetails"),a=window.location.pathname;try{return t?null===(e=JSON.parse(t))||void 0===e?void 0:e.brand_local_blog_url_name:a}catch(e){return a}}isDbaNameInSearch(e,t){var a;return e&&(null===(a=null==t?void 0:t.toString())||void 0===a?void 0:a.includes(e))}updateUrlForDbaName(e,t,a,o){const n=(0,c.blogPageLocationURL)(e);o.pathname="error"!==n?`/${n}/${t}/search/${a}`:`/${e}/${t}/search/${a}`}updateUrlForNonDbaName(e,t,a){let o=e;o=(null==o?void 0:o.includes("/category"))&&t?e.split("/category")[0]:null==o?void 0:o.split("/search/")[0],a.pathname=`${o}/search/${t}`,a.pathname=a.pathname.replace(/\/+/g,"/")}getData(e){e&&e.preventDefault();const t=new URLSearchParams(window.location.search),a=t.get("page"),o=t.get("search"),n=t.get("categories");a&&(this.currentPage=Number.parseInt(a,10));const s=document.getElementById("brandName"),i=document.getElementById("dbaName"),c={method:"GET",url:`https://searchg2.crownpeak.net/NEI-Blogs-Prod/select?q=custom_s_brand:${null==s?void 0:s.value}&rows=1000&sort=custom_dt_created%20desc&echoParams=explicit&fl=*,score&defType=edismax&wt=json&fq=custom_s_local_dba:${(null==i?void 0:i.value)?i.value:"none"}`};(0,l.startLoader)(),(0,r.default)(c).then(e=>{var t;const{docs:a=[]}=null!==(t=null==e?void 0:e.response)&&void 0!==t?t:{},{currentPageItems:s,filterArray:r}=this.pagination(a,this.currentPage,this.itemsPerPage,o,n),i=s.map(e=>this.createBlogList(e)).join(""),c=document.querySelector(".blog-list");c&&c.insertAdjacentHTML("afterbegin",i),this.data=r;const d=document.getElementById("search-blog");document.querySelector(".pagination-wrapper")&&d&&this.renderPageNumbers(o,n);const u=n||o,g=null==r?void 0:r.length,m=document.getElementById("search-blog"),p=document.getElementById("filter-blog");o&&m&&(m.value=o),p&&n&&(p.value=n);const h=u?`<h2 class="blog-list-heading">Showing ${g} Results for ${o?`<span>"${o}"</span>`:""} ${n&&o?"and":""} ${n?`<span>${n}</span>`:""}</h2>
1`:'<h2 class="blog-list-heading">All Blog</h2>';null==c||c.insertAdjacentHTML("afterbegin",h),(0,l.stopLoader)()}).catch(e=>{(0,l.stopLoader)(),console.error(e)})}pagination(e,t,a,o,n){let s=e;o&&(s=s.filter(e=>String(e.custom_s_template_lable).toLocaleLowerCase().includes(String(o).toLocaleLowerCase())||String(e.custom_s_heading).toLocaleLowerCase().includes(String(o).toLocaleLowerCase())||String(e.custom_t_content_summary_Desc).toLocaleLowerCase().includes(String(o).toLocaleLowerCase()))),n&&(s=s.filter(e=>String(e.custom_s_category).toLocaleLowerCase()==String(n).toLocaleLowerCase()));const r=(t-1)*a,l=r+a;return{currentPageItems:s.slice(r,l),filterArray:s}}capitalizeEachWord(e){return e.replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()})}createBlogList(e){const{custom_dt_modified:t,custom_s_local_url:a,custom_s_heading:o,custom_s_template_lable:n,custom_t_content_summary_Desc:r,custom_s_article_summary_Image_url:l,custom_t_content_summary_Image_url_alt:i,custom_s_category:c,custom_dt_created:d}=e,u=l?`<div class="media-wrapper">\n <div class="media-container">\n <a href="${a}">\n <picture>\n <img src=${l} alt="${i}" width="579" height="339">\n </picture>\n </a>\n </div>\n </div>`:"";return`<article class="blog-card section-50-50">\n <div class="image-content-warpper left-image-content">\n <div class="text-wrapper">\n <p class="blog-topic"><a href="${a}">${this.capitalizeEachWord(c)}</a></p>\n <div class="blog-heading"><a href="${a}">${o}</a></div>\n <span class="blog-date">${s()(d).format("MMM DD YYYY")}</span>\n <p class="blog-text">${r}</p>\n <a href="${a}" class="blog-more-link" title="click to learn more">\n Learn more\n <svg aria-hidden="true">\n <use xlink:href="/brand/_assets/images/icons/hero-icon-sprite.svg#chevron-right-primary "></use>\n </svg>\n </a>\n </div>\n ${u}\n </div>\n </article>`}renderPageNumbers(e,t){const a=document.querySelector(".pagination-wrapper");a.innerHTML="";const o=Math.ceil(this.data.length/this.itemsPerPage),n=`${window.location.pathname}?page=${this.currentPage>1?this.currentPage-1:this.currentPage}&search=${e||""}&categories=${t||""}`,s=`${window.location.pathname}?page=${this.currentPage<o?this.currentPage+1:this.currentPage}&search=${e||""}&categories=${t||""}`,r=`${window.location.pathname}?page=${o}&search=${e||""}&categories=${t||""}`,l=`<li class="page-list">\n <a href="${n}" class="prev-btn">\n <span class="sr-only">Previous</span>\n <svg aria-hidden="true" >\n <use xlink:href="/brand/_assets/images/icons/hero-icon-sprite.svg#chevron-left-g500 "></use>\n </svg>\n </a>\n </li>`,i=`<li class="page-list">\n <a href="${s}" class="next-btn">\n <span class="sr-only">Next</span>\n <svg aria-hidden="true" >\n <use xlink:href="/brand/_assets/images/icons/hero-icon-sprite.svg#chevron-right-g500 "></use>\n </svg>\n </a>\n </li>`;o<=1&&a.classList.add("hidden"),o>1&&(null==a||a.insertAdjacentHTML("afterbegin",l));const c=o-this.currentPage>3?this.currentPage+2:o-1;for(let o=this.currentPage;o<=c;o++){const n=document.createElement("li");n.className="page-list";const s=document.createElement("a");s.href=`${window.location.pathname}?page=${o}&search=${e||""}&categories=${t||""}`,s.className="page-number",s.textContent=o.toString(),o===this.currentPage&&(s.classList.add("current-page"),s.setAttribute("aria-current","page")),s.addEventListener("click",()=>{this.currentPage=o,this.updateURLParams()}),n.appendChild(s),a.appendChild(n)}if(this.currentPage==o&&o>3){let n=o-2,s=document.createElement("li");s.className="page-list";let r=document.createElement("a");r.href=`${window.location.pathname}?page=${n}&search=${e||""}&categories=${t||""}`,r.className="page-number",r.textContent=n.toString(),s.appendChild(r),a.appendChild(s),n=o-1,s=document.createElement("li"),s.className="page-list",r=document.createElement("a"),r.href=`${window.location.pathname}?page=${n}&search=${e||""}&categories=${t||""}`,r.className="page-number",r.textContent=n.toString(),s.appendChild(r),a.appendChild(s)}if(o>3){null==a||a.insertAdjacentHTML("beforeend",'<li class="page-list">\n <a href="#" class="page-number">...</a>\n </li>');let e="page-number",t="";this.currentPage==o&&(e="current-page page-number",t='aria-current="page"'),null==a||a.insertAdjacentHTML("beforeend",`<li class="page-list"><a href="${r}" ${t} class="${e}">${o}</a></li>`)}o>1&&(null==a||a.insertAdjacentHTML("beforeend",i))}}new d},"./src/js/opus2/blog/index.ts"(e,t,a){a.r(t),a.d(t,{BlogAiSummary:()=>s.BlogAiSummary,BlogList:()=>
1o.BlogList,NextPrev:()=>n.NextPrev,initBlogAiSummary:()=>s.initBlogAiSummary});var o=a(/*! ./blog-list */"./src/js/opus2/blog/blog-list.ts"),n=a(/*! ./next-prev */"./src/js/opus2/blog/next-prev.ts"),s=a(/*! ./ai-summary */"./src/js/opus2/blog/ai-summary.ts")},"./src/js/opus2/blog/next-prev.ts"(e,t,a){a.d(t,{NextPrev:()=>l});var o=a(/*! tslib */"./node_modules/tslib/tslib.es6.mjs"),n=a(/*! ../api/apiRequest */"./src/js/opus2/api/apiRequest.ts"),s=a(/*! ../config/apiConfig */"./src/js/opus2/config/apiConfig.ts"),r=a(/*! ../util/share */"./src/js/opus2/util/share.ts");class l{static init(){return(0,o.__awaiter)(this,void 0,void 0,function*(){var e;const t=null===(e=document.getElementById("conceptCode"))||void 0===e?void 0:e.value,a=yield(0,r.getBrandDetailsFromBrandJson)(t);(new l).setNextPrev(a)})}setNextPrev(e){return(0,o.__awaiter)(this,void 0,void 0,function*(){var t,a,o,n;const s=Array.from(document.querySelectorAll(".pagination-link"));let r=window.location.pathname;const l=(null===(t=document.getElementById("brandName"))||void 0===t?void 0:t.value)||"",i=(null===(a=document.getElementById("dbaName"))||void 0===a?void 0:a.value)||"none",c=null===(o=document.getElementById("countryCode"))||void 0===o?void 0:o.value,d=(null==e?void 0:e.display_blog_authordate)?"&sort=custom_dt_created desc":"&sort=custom_dt_modified desc",u=null!==(n=sessionStorage.getItem("blog_search"))&&void 0!==n?n:this.blogSearchTerm(),g=sessionStorage.getItem("blog_category");let m=this.buildBaseUrl(l,i,d);if((null==e?void 0:e.enable_fte)&&(m=this.appendBrandFilters(m,c,g,u),this.handleBlogSearchPersistence(),null===window||void 0===window?void 0:window.g2Data)){const e=this.initBlogArticlePage();sessionStorage.setItem("blog_category",e)}if(!(s.length<2))try{const t=yield this.getBlogDocs(m);(null==e?void 0:e.includeTrailingSlash)&&(r=r.replace(/\/$/,"")),this.updatePaginationButtons(s,t,r)}catch(e){console.error(e)}})}buildBaseUrl(e,t,a){return`${s.apiConfig.BLOG_URL}NEI-Blogs-Prod/select?q=custom_s_brand:${e}&rows=1000${a}&echoParams=explicit&fl=*,score&defType=edismax&wt=json&fq=custom_s_opus_version:2&fq=custom_s_local_dba:${t}&fq=custom_s_type:blog&fq=custom_s_status:Active`}appendBrandFilters(e,t,a,o){var n;const s=window.location.href,r=(null===(n=document.getElementById("conceptCode"))||void 0===n?void 0:n.value)||"";if("CORP"===r.toUpperCase()?s.includes("/press-center/")?e+="&fq=custom_s_corp_blogs:press-center":e+="&fq=custom_s_corp_blogs:blog":"PLGC"===r.toUpperCase()&&(s.includes("/case-studies/")?e+="&fq=custom_s_plg_commercial_blogs:case-studies":e+="&fq=custom_s_plg_commercial_blogs:blog"),t&&(e+=`&fq=custom_s_country:${t}`),a&&"none"!==a&&(e+=`&fq=custom_ss_category:(*${a}*)`,sessionStorage.removeItem("blog_search")),"none"===a&&o){let t=o.split("-");e+=`&fq=content:${o=t.join(" ")}${1==t.length?"*":""}`}return e}handleBlogSearchPersistence(){var e;const t=new URL(window.location.href),a=localStorage.getItem("brandDetails");let o="blog";try{a&&(o=(null===(e=JSON.parse(a))||void 0===e?void 0:e.brand_local_blog_url_name)||"blog")}catch(e){o="blog"}t.pathname.replace(/\//g,"")===o.replace(/\//g,"")&&sessionStorage.removeItem("blog_search")}getBlogDocs(e){return(0,o.__awaiter)(this,void 0,void 0,function*(){var t;const a=yield(0,n.default)({method:"GET",url:e}),{docs:o=[]}=null!==(t=null==a?void 0:a.response)&&void 0!==t?t:{};return o})}updatePaginationButtons(e,t,a){const o=a.replace(/\/$/,"").split("#")[0],n=t.findIndex(e=>{var t;return(null===(t=e.custom_s_context_url)||void 0===t?void 0:t.replace(/\/$/,"").split("#")[0])===o});-1!==n&&this.setPrevNextButton(e,t,n)}setPrevNextButton(e,t,a){-1!==a&&(a>0&&(e[0].href=t[a-1].custom_s_context_url),0==a&&(e[0].disabled=!0,e[0].style.opacity="0.3"),a<t.length-1&&(e[1].href=t[a+1].custom_s_context_url),a==t.length-1&&(e[1].disabled=!0,e[1].style.opacity="0.3"))}blogSearchTerm(){const e=window.location.href,t=new URL(e).pathname.split("/"),a=t.indexOf("search");let o=null;return-1!==a&&t[a+1]&&(o=t[a+1],sessionStorage.setItem("blog_search",o)),o}initBlogArticlePage(){return(window.location.href.match(/\/category\/[\s\-a-zA-Z0-9]+\/?/gim)||["/category/none"])[0].split("/category/")[1].replace("/","")}}document.addEventListener("DOMContentLoaded",function(){l.init()})},"./src/js/opus2/util/blogPageLocation.ts"(e,t,a){function o(e){const t=localStorage.getItem("brandDetails");if("undefined"!==t&&null!==t){const a=JSON.parse(t),o=null==a?void 0:a.weblocationUrlPath_blog,n=a.weblocation_path_group,s=a.include_statename&&a.include_statename_blog,r=function(){const e=window.crownpeakWeblocationsByIdDetail;if(!e)return console.error("Error while getting weblocationInfo"),null;return e}();
1return o&&n&&!s?`${a.weblocation_path_group}/${e}`:o&&n&&s&&(null==r?void 0:r.stateName)?`${a.weblocation_path_group}/${r.stateName}/${e}`:o&&!n&&s&&(null==r?void 0:r.stateName)?`${r.stateName}/${e}`:`${e}`}return console.error("Error while setting a localized blog URL"),"error"}a.d(t,{blogPageLocationURL:()=>o})}}]); 2//# sourceMappingURL=opus2.blog-loader.4c8a44bca6550c82845d.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.