import{_ as K}from"./WebSearchField-Riu7XFZZ.mjs";import{_ as B}from"./WebSearchFilterCount-DfRlmA_G.mjs";import{_ as k,o as i,c as m,F as L,x as M,a as o,q as N,t as q,d as f,y as w,G as $,s as S,b as p,l as d,h as I,p as P,ai as R,Q as A,R as H,k as j}from"./BDipKYNj.js";import{V as E}from"./vue-select-CqDP9j-G.mjs";import{_ as z}from"./WebSearchSort-HWMeh32L.mjs";import{_ as G}from"./WebViewToggle-CK4XYDoW.mjs";import{a as Q,_ as Z}from"./WebContentListNew-BgdZ5dgN.mjs";import{_ as J}from"./WebPager-FdWmPsqK.mjs";import{u as D}from"./useContentSearch-DxxFtNhd.mjs";import"./WebContentItem-Bpw6xJnG.mjs";import"./WebImage-CIpNTik-.mjs";import"./nuxt-link-BWzEhDJx.mjs";import"./useImageUrl-1XbeiwSF.mjs";import"./Pager-CQd4UNKT.mjs";import"./index-CT5P7xjO.mjs";import"./useStringUtils-B4L5WUsu.mjs";const X={props:{field:{type:String},options:{type:Array},values:{type:[Boolean,Array]},columns:{type:Number,default:1}},emits:["update"]},Y=["value","checked"];function ee(e,t,s,h,n,a){const c=B;return i(),m("div",{class:w(["checkbox-filter","columns-"+s.columns])},[(i(!0),m(L,null,M(s.options,r=>(i(),m("div",{key:r.value,class:"checkbox"},[o("label",null,[o("input",{type:"checkbox",name:"contentType",value:r.value,checked:s.values.length?s.values.indexOf(r.value)>=0:!1,onInput:t[0]||(t[0]=l=>{e.$emit("update",s.field,l.target.value)})},null,40,Y),N(" "+q(r.label.replace(/([A-Z])/g," $1"))+" ",1),f(c,{count:r.count},null,8,["count"])])]))),128))],2)}const te=k(X,[["render",ee]]),se={components:{VueSelect:E},props:{field:{type:String},options:{type:Array},values:{type:Array},required:{type:Boolean,default:!1}},emits:["update"],data(){return{localVal:this.values}},watch:{localVal(e){this.localVal=e,this.$emit("update",this.field,e)}}},ne={class:"select-filter"},oe={class:"option"},ie=["innerHTML"],le={class:"option"},ae=["innerHTML"];function re(e,t,s,h,n,a){const c=B,r=$("VueSelect");return i(),m("div",ne,[f(r,{modelValue:n.localVal,"onUpdate:modelValue":t[0]||(t[0]=l=>n.localVal=l),placeholder:"Select...",class:"select",options:s.options,reduce:l=>l.value,label:"label",clearable:!s.required,multiple:!0},{option:S(l=>[o("div",oe,[o("div",{innerHTML:l.label},null,8,ie),l.count?(i(),p(c,{key:0,count:l.count},null,8,["count"])):d("",!0)])]),"selected-option":S(l=>[o("div",le,[o("div",{innerHTML:l.label},null,8,ae),l.count?(i(),p(c,{key:0,alternate:!0,count:l.count},null,8,["count"])):d("",!0)])]),_:1},8,["modelValue","options","reduce","clearable"])])}const ce=k(se,[["render",re]]),ue={props:{facetOptions:{type:Object,required:!0},filters:{type:Object},layout:{type:String,default:"stacked"}},emits:["updateFilters"],methods:{toggleCheckboxFilter(e,t){const s={...this.filters};s[e].value.length===0?s[e].value.push(t):s[e].value=[],this.$emit("updateFilters",s)},updateFilter(e,t){const s={...this.filters};s[e].value=t,this.$emit("updateFilters",s)}}},pe={key:0,class:"filter content-type checkboxes"},me={key:1,class:"filter"};function de(e,t,s,h,n,a){var l,_,y,g,v,b;const c=te,r=ce;return i(),m("div",{class:w(["web-search-filters",s.layout])},[(_=(l=s.facetOptions)==null?void 0:l.contentType)!=null&&_.length?(i(),m("div",pe,[t[0]||(t[0]=o("label",null,"Type",-1)),f(c,{field:"type",options:s.facetOptions.contentType,values:((g=(y=s.filters)==null?void 0:y.type)==null?void 0:g.value)??[],onUpdate:a.toggleCheckboxFilter},null,8,["options","values","onUpdate"])])):d("",!0),(b=(v=s.facetOptions)==null?void 0:v.websiteSchedule)!=null&&b.length?(i(),m("div",me,[t[1]||(t[1]=o("label",null,"Section",-1)),f(r,{field:"websiteSchedule",options:s.facetOptions.websiteSchedule,values:s.filters.websiteSchedule.value,onUpdate:a.updateFilter},null,8,["options","values","onUpdate"])])):d("",!0)],2)}const he=k(ue,[["render",de],["__scopeId","data-v-d11f33a9"]]),fe={props:{imagePosition:{type:String,default:"above"},dateFormat:{type:String},itemMask:{type:Boolean,default:!1},syncWithUrl:{type:Boolean,default:!1},cutoffDate:{type:Number},imageShaping:{type:String}},emits:["item-click","updateFilters"],data(){return{viewType:"grid",userHasToggled:!1,selectedItems:[],searchRan:!1,tenantKey:this.$ss.tenant,facetOptions:{contentType:[],websiteSchedule:[]},index:null,results:{items:[],totalCount:0},filters:{text:"",type:{value:[]},websiteSchedule:{value:[]},page:1},sort:"published",changeSortOnSearch:!0,searchOnFilterChange:!1,filterKey:Math.random()}},watch:{"$route.query":{immediate:!0,handler(){var e,t;window&&(this.syncWithUrl&&(this.filters={...this.filters,...D().getFiltersFromUrl()},this.sort=((t=(e=I())==null?void 0:e.query)==null?void 0:t.sort)??"published"),this.filterKey=Math.random(),this.search())}}},methods:{updateFilter(e,t){this.changeSortOnSearch&&(this.sort="score",this.changeSortOnSearch=!1);const s={...this.filters};s[e]=t,this.filters[e]=t,this.$emit("updateFilters",s),this.search()},updateFilters(e){this.filters={...this.filters,...e},this.filters.page=1,this.search()},getPage(e){this.results.page=e,this.filters.page=e,this.search()},updateSort(e){this.sort=e,this.filters.page=1,this.search()},async search(){const{search:e,clearEmptyFilters:t}=D(),s=await e(this.syncWithUrl,this.cutoffDate,t({...this.filters,tenant:[this.tenantKey],status:["1"],impliedSchedules:!0}),this.filters.page,"public-search",this.sort,20,["Promotion","Contact"]);console.log("response",s),this.facetOptions=s.facetOptions;const h=await this.$gql.queryStream("getContentStream",{includeContentIds:s.results.items.map(a=>a.id),limit:1e3}),n=[];s.results.items.forEach(a=>{const c=h.data.items.find(r=>r.id===a.id);n.push(c)}),this.results={totalCount:s.results.totalCount,items:[...n]},this.searchOnFilterChange=!0,this.searchRan=!0}}},_e={class:"search-field-wrapper"},ye={class:"field"},ge={class:"stats"},ve={key:0,class:"count"},be={class:"columns"},Se={key:0,class:"sponsored-search",style:{marginBottom:"15px"}},ke=["src"],we={class:"results"},Fe={class:"topbar"},Ce={class:"sort"},xe={class:"view"},Te={key:3,class:"no-results"};function Oe(e,t,s,h,n,a){const c=K,r=he,l=z,_=G,y=Q,g=Z,v=J,b=A;return i(),p(b,null,{default:S(()=>{var F,C,x,T,O,V,U,W;return[o("div",{class:w(["search-new",(F=e.$ss)!=null&&F.useNewDesign?"new-design":""])},[o("div",_e,[o("div",ye,[(i(),p(c,{key:n.filterKey,value:n.filters.text,onUpdate:t[0]||(t[0]=u=>{a.updateFilter("text",u)})},null,8,["value"])),o("div",ge,[o("div",null,[n.results?(i(),m("span",ve,q(n.results.totalCount),1)):d("",!0),t[5]||(t[5]=N(" results "))])])])]),o("div",be,[o("div",{class:"filters",style:P({paddingRight:"25px",fontFamily:e.$ss.primaryFontFamily})},[(x=(C=e.$ss)==null?void 0:C.sponsoredSearch)!=null&&x.enabled?(i(),m("div",Se,[t[6]||(t[6]=o("div",{class:"sponsored-search-text"}," Search sponsored by ",-1)),(i(),p(R((O=(T=e.$ss)==null?void 0:T.sponsoredSearch)!=null&&O.clickUrl?"a":"span"),{href:(U=(V=e.$ss)==null?void 0:V.sponsoredSearch)==null?void 0:U.clickUrl,target:"_blank"},{default:S(()=>{var u;return[o("img",{src:`${((u=e.$ss.sponsoredSearch)!=null&&u.searchPageLogo?e.$ss.sponsoredSearch.searchPageLogo:e.$ss.sponsoredSearch.logo).split("?")[0]}?auto=format,compress&height=50`,alt:"Sponsored search logo",height:"35",class:"sponsored-search-logo"},null,8,ke)]}),_:1},8,["href"]))])):d("",!0),f(r,{"facet-options":n.facetOptions,filters:n.filters,onUpdateFilters:a.updateFilters},null,8,["facet-options","filters","onUpdateFilters"])],4),o("div",we,[o("div",Fe,[o("div",Ce,[(i(),p(l,{key:n.sort,value:n.sort,"sort-options":["score","published","name_asc","name_desc"],style:{display:"flex"},onUpdateSort:a.updateSort},null,8,["value","onUpdateSort"]))]),o("div",xe,[f(_,{value:n.viewType,style:{display:"flex"},onSetViewType:t[1]||(t[1]=u=>{n.viewType=u})},null,8,["value"])])]),(W=e.$ss)!=null&&W.useNewDesign?(i(),p(y,{key:`${n.viewType}new`,"image-position":n.viewType==="list"?"left":"above","image-shaping":s.imageShaping,"number-of-columns":n.viewType==="list"?1:4,"show-summary":!0,data:{items:n.results.items},"item-mask":s.itemMask,onItemClick:t[2]||(t[2]=u=>{e.$emit("item-click",{...u,tenantKey:n.tenantKey})})},null,8,["image-position","image-shaping","number-of-columns","data","item-mask"])):(i(),p(g,{key:n.viewType,"image-position":n.viewType==="list"?"left":"above","image-shaping":s.imageShaping,"number-of-columns":n.viewType==="list"?1:4,"show-summary":!0,data:{items:n.results.items},"item-mask":s.itemMask,onItemClick:t[3]||(t[3]=u=>{e.$emit("item-click",{...u,tenantKey:n.tenantKey})})},null,8,["image-position","image-shaping","number-of-columns","data","item-mask"])),n.results.totalCount>20?(i(),p(v,{key:2,"active-page":n.filters.page,"total-count":n.results.totalCount,"items-per-page":20,onChangeValue:t[4]||(t[4]=u=>a.getPage(u))},null,8,["active-page","total-count"])):d("",!0),n.results.totalCount===0&&n.searchRan?(i(),m("div",Te," There were no results that matched your criteria. ")):d("",!0)])])],2)]}),_:1})}const Ve=k(fe,[["render",Oe],["__scopeId","data-v-2872fe90"]]),Ee={__name:"SearchBlock",props:{page:{type:Object,required:!0,validator(e){return["pageData"].every(t=>t in e)}}},setup(e){const t=e,s=H(new Date().getTime());function h(){return t.page.pageData.type==="Company"?t.page.pageData.name??"":""}return(n,a)=>{const c=Ve;return i(),p(c,{"image-shaping":"fill","page-company-name":h(),"cutoff-date":j(s),"sync-with-url":!0},null,8,["page-company-name","cutoff-date"])}}};export{Ee as default};