import{d as Fe,c as we,$ as De,a as Oe,b as Re,r as u,P as d,w as k,v as U,g as Ne,a0 as Be,a1 as He,e as V,o as ke,a2 as be,a3 as Ue,h as I,l as m,m as he,C as W,i as l,T as Ve,k as S,j as xe,p as Me,q as We,a4 as ye,_ as je,t as qe,x as y,O as Ae,A as Ke,y as Qe}from"./D1QozqMg.js";import{_ as Ye}from"./C5LCsqGt.js";import{C as ze,P as Je,_ as Xe,a as Ze,b as et}from"./NYj3_b7p.js";import"./DSjuBfzT.js";import"./DhFW1opL.js";import"./DslTMqll.js";import"./BHP1V-5W.js";import"./CXnv8yYB.js";const tt=Me(Ye),at=Me(Ze),st={class:"max-w-screen-xl mx-auto"},lt={key:0,class:"text-center heading h1"},nt=["innerHTML"],ot={key:0,class:"w-full text-center min-h-screen"},gt=Fe({__name:"[slug]",async setup(ut){var ee,te,ae,se,le,ne,oe,ue,re,ie,ce,pe,de,me,ve,_e;let r,v;const{locale:a,t:Pe}=we(),$=De(),C=Oe(),_=Re(),c=We(),j=ye,A=u(0),g=u(!0),M=u(!0),f=u([]),F=u([]),q=u([]),Se=u([]),n=u(null),s=u(null),w=u({mainFacets:{},drawerFacets:{}}),p=u({productGroup:[],mountingOptions:[],mainMaterial:[],enStandard:[],constructionAssessment:[],ageGroup:[],isInclusive:!1,isExpress:!1,fallHeightMin:0,fallHeightMax:0,impactAreaMin:0,impactAreaMax:0,priceRangeMin:0,priceRangeMax:0}),E=u({sort:"variants.attributes.product-priority%20asc",label:null}),D=u({}),K=(ee=C.params)==null?void 0:ee.slug;let O=C.path.split(`${a.value}/${d.pageCatalog[a.value]}/`)[1]||C.path.split(`${d.pageCatalog[a.value]}/`)[1];O=O.split("/")[0];let Q="";c.public.PREVIEW=="true"&&(Q="&preview=true");const{data:Y}=([r,v]=k(()=>U("catalog-index",()=>$fetch(`content-type/${K}?locale=${a.value}&contentType=pageCatalog${Q}`,{method:"GET",baseURL:`${c.public.AWS_API_ENDPOINT}/${c.public.AWS_API_ENV}/`}))),r=await r,v(),r),z={"nn-NO":"en-GB","da-DK":"en-GB","es-ES":"en-GB"},i=z[a.value]||a.value;try{const{data:t}=([r,v]=k(()=>U("catalog-maincategory",()=>$fetch(`product-maincategories?locale=${i}`,{method:"GET",baseURL:`${c.public.AWS_API_ENDPOINT}/${c.public.AWS_API_ENV}/`}))),r=await r,v(),r);if((((te=t.value)==null?void 0:te.results)||[]).sort((e,o)=>e.name[i].localeCompare(o.name[i])),(((ae=t.value)==null?void 0:ae.results)||[]).length>0){for(const e in t.value.results)if(Object.values(t.value.results[e].slug).includes(O)){n.value=t.value.results[e];break}t.value||_.push($(`/${d.pageCatalog[a.value]}/`))}}catch(t){n.value=null,console.error(t),_.push($(`/${d.pageCatalog[a.value]}/`))}try{const{data:t}=([r,v]=k(()=>U("product-subcategory",()=>{var e;return $fetch(`product-subcategories/${(e=n==null?void 0:n.value)==null?void 0:e.id}?locale=${i}&limit=50`,{method:"GET",baseURL:`${c.public.AWS_API_ENDPOINT}/${c.public.AWS_API_ENV}/`})})),r=await r,v(),r);if((((se=t.value)==null?void 0:se.results)||[]).sort((e,o)=>e.name[i].localeCompare(o.name[i])),t.value&&(((le=t.value)==null?void 0:le.results)||[]).length){for(const e in t.value.results)if(z[a.value]){const h=t.value.results[e].slug[i].split("/").pop();if(t.value.results[e].slug[i]===h){s.value=t.value.results[e];break}}else if(Object.values(t.value.results[e].slug).includes(K)){s.value=t.value.results[e];break}s.value||_.push($(`/${d.pageCatalog[a.value]}/`))}}catch(t){s.value=null,console.error(t),_.push($(`/${d.pageCatalog[a.value]}/`))}const $e=u((oe=(ne=s.value)==null?void 0:ne.name)==null?void 0:oe[a.value]),Ce=u((re=(ue=s.value)==null?void 0:ue.description)==null?void 0:re[a.value]);Ne({title:`${$e.value||Be} ${Pe("| Lappset Group | The world of playgrounds and sports")}`,meta:[{name:"description",content:Ce.value||He}]});const Ee=[{slug:"pageCatalog",name:"pageCatalog"},{slug:`${d.pageCatalog[a.value]}/${(ie=n==null?void 0:n.value)==null?void 0:ie.slug[a.value]}`||"pageCatalog",name:((pe=(ce=n==null?void 0:n.value)==null?void 0:ce.name)==null?void 0:pe[a.value])||((me=(de=n==null?void 0:n.value)==null?void 0:de.name)==null?void 0:me[i])||""},{name:((ve=s==null?void 0:s.value)==null?void 0:ve.name[a.value])||((_e=s==null?void 0:s.value)==null?void 0:_e.name[i])||""}];q.value=Ee;const J=V(()=>{const e={"nn-NO":"en-GB","da-DK":"en-GB","es-ES":"en-GB"}[a.value]||a.value,o=[`variants.attributes.product-groups.label.${e} as productGroup`,`variants.attributes.product-mounting-options.label.${e} as mountingOptions`,`variants.attributes.product-main-material.label.${e} as mainMaterial`,`variants.attributes.product-en-standard.label.${e} as enStandard`,`variants.attributes.product-age-group.label.${e} as ageGroup`,"variants.attributes.product-is-inclusive as isInclusive","variants.attributes.product-is-express as isExpress","variants.attributes.product-max-free-fall-height:range (0 to 5000) as fallHeight","variants.attributes.product-impact-area:range (0 to 500) as impactArea"];return a.value==="sv-SE"&&o.push("variants.attributes.product-construction-assessment as constructionAssessment"),o}),R=V(()=>{var t,e;return s.value?((t=s.value.name)==null?void 0:t[a.value])||((e=s.value.name)==null?void 0:e[Ae[a.value]]):null}),X=V(()=>{var t,e;return s.value?((t=s.value.description)==null?void 0:t[a.value])||((e=s.value.description)==null?void 0:e[Ae[a.value]]):null});let b,N;ke(async()=>{p.value={productGroup:[],mountingOptions:[],mainMaterial:[],enStandard:[],constructionAssessment:[],ageGroup:[],isInclusive:!1,isExpress:!1,fallHeightMin:0,fallHeightMax:0,impactAreaMin:0,impactAreaMax:0,priceRangeMin:0,priceRangeMax:0},b=new ze(p.value,E.value,C,_),N=new Je(a.value,c),b.turnQueryParamsIntoFilters(),await Le(b.defaultFilters)}),be(p,t=>{B(t,!1,E.value.sort)},{deep:!0}),be(E,t=>{B(p.value,!1,t.sort)},{deep:!0});async function Le(t){var e;try{const{facets:o}=await N.fetchProductsNonReactive(t,M.value,J.value,j,A.value,(e=s==null?void 0:s.value)==null?void 0:e.id);Z(o)}catch(o){console.error(o)}}async function B(t,e=!1,o="variants.attributes.product-priority%20asc"){var h;g.value=!0,e||(A.value=0,f.value=[]);try{const{results:x,rest:L,error:T}=await N.fetchProductsData(t,M.value,J.value,j,A.value,(h=s==null?void 0:s.value)==null?void 0:h.id,o);T&&(console.error(T),g.value=!1),M.value&&(Z(w),M.value=!1),e?f.value=f.value.concat(x):f.value=x,D.value=L,g.value=!1,f.value.forEach((G,H)=>{F.value.push({item_id:G.key,item_name:G.name[a.value],affiliation:`Lappset.com/${a.value}`,index:H,item_list_id:"All Products",item_list_name:"All Products",quantity:"1"})})}catch(x){console.error(x),g.value=!1}}function Z(t){b.setupFacets(t,w)}function Te(){A.value=A.value+ye,B(p.value,!0)}function Ge(){Object.assign(p.value,{productGroup:[],mountingOptions:[],mainMaterial:[],enStandard:[],constructionAssessment:[],ageGroup:[],isInclusive:!1,isExpress:!1,fallHeightMin:0,fallHeightMax:0,impactAreaMin:0,impactAreaMax:0,priceRangeMin:0,priceRangeMax:0}),_.push({query:{}})}return Ue(()=>{p.value={productGroup:[],mountingOptions:[],mainMaterial:[],enStandard:[],constructionAssessment:[],ageGroup:[],isInclusive:!1,isExpress:!1,fallHeightMin:0,fallHeightMax:0,impactAreaMin:0,impactAreaMax:0,priceRangeMin:0,priceRangeMax:0}}),(t,e)=>{var ge,fe;const o=Ke,h=tt,x=at,L=je,T=Xe,G=et,H=Qe,Ie=qe;return y(),I("div",null,[m(L,null,{default:he(()=>[m(o,{"breadcrumbs-list":l(q)},null,8,["breadcrumbs-list"]),l(F).length?(y(),xe(h,{key:0,data:{event:"view_item_list",ecommerce:{items:l(F)}}},null,8,["data"])):S("",!0),m(x,{data:l(s)??[],"category-type":"sub"},null,8,["data"])]),_:1}),W("div",null,[W("div",st,[l(R)?(y(),I("h1",lt,Ve(l(R)),1)):S("",!0),l(X)?(y(),I("div",{key:1,class:"text-center",innerHTML:l(X)},null,8,nt)):S("",!0),m(T,{"main-category":l(n),categories:l(Se),facets:l(w),"selected-filters":l(p),"selected-sorting":l(E),"loading-facets":l(M),"category-type":"sub-category",metadata:l(D),locale:l(a),onSetSelectedFilter:e[0]||(e[0]=P=>l(b).setSelectedFilter(P)),onSortProductsDisplayed:e[1]||(e[1]=P=>l(b).setSelectedSorting(P)),onClearFilters:e[2]||(e[2]=P=>Ge())},null,8,["main-category","categories","facets","selected-filters","selected-sorting","loading-facets","metadata","locale"])]),W("div",null,[m(L,null,{default:he(()=>[m(G,{loading:l(g),products:l(f),metadata:l(D),"current-category":l(R),onLoadmore:e[3]||(e[3]=P=>Te())},null,8,["loading","products","metadata","current-category"])]),_:1})]),l(g)?(y(),I("div",ot,[m(H,{class:"my-10"})])):S("",!0),(ge=l(Y))!=null&&ge.fields.descriptionBottom?(y(),xe(Ie,{key:1,content:(fe=l(Y))==null?void 0:fe.fields.descriptionBottom,class:"px-5 my-3 text-center"},null,8,["content"])):S("",!0)])])}}});export{gt as default};