import{j as e,a3 as G,L as Q,ak as $,R as A,u as J,al as q}from"./main-5057ff34.js";import{r as g}from"./chunk-react-162a731f.js";import{H as K,a as V,F as Y,b as U}from"./chunk-index-e56c01f9.js";import{m as v,C as P,G as c,e as C,f as X,ag as Z,ah as D,H as w,L as ee,i as _,ai as re,o as se,B as oe,J as ne,M as te,aj as ie}from"./chunk-material-ui-eb5bb5f8.js";import{B as pe,a as ce}from"./chunk-index-1e6d64bd.js";import{P as de,D as me}from"./chunk-index-0da27f0d.js";import{H as le}from"./chunk-Helmet-930b1405.js";import{C as xe,F as ue,a as he,b as ae}from"./chunk-index-ec903dbb.js";import{Page404 as je}from"./chunk-index-182dbea3.js";import"./chunk-lodash-6114c6d4.js";import"./chunk-index-730d0e8a.js";import"./chunk-index-89b7ba38.js";import"./chunk-index-4d24fc93.js";import"./chunk-index-a7d53221.js";import"./chunk-ListItemButton-a29ddd25.js";import"./chunk-generateUtilityClasses-54aa0b46.js";import"./chunk-index-72204a8f.js";import"./chunk-index-9e8b2b74.js";import"./chunk-index-a1788cfb.js";import"./chunk-index-9f909ab3.js";import"./chunk-index-3462efa3.js";import"./chunk-index-b4f9c953.js";import"./chunk-index-827e676e.js";import"./chunk-createSvgIcon-76c2431e.js";import"./chunk-index-e791da15.js";import"./chunk-index-4b8e5f08.js";import"./chunk-effect-fade-17bfa8f3.js";import"./chunk-index-69f914a0.js";import"./chunk-pagination-780a19ab.js";const ye=v(s=>({pageHeaderWrapper:{backgroundColor:s.color.black20},pageHeaderContainer:{"@media (min-width: 1280px)":{paddingTop:"24px",paddingBottom:"24px"}}}),{name:"PageHeader"});function fe({children:s}){const o=ye();return e.jsx(P,{disableGutters:!0,maxWidth:!1,className:o.pageHeaderWrapper,children:e.jsx(P,{fixed:!0,maxWidth:"xl",classes:{root:o.pageHeaderContainer},children:e.jsx(c,{container:!0,spacing:3,children:s})})})}const ge=v(s=>({mainBlock:{padding:9,"@media (max-width: 1280px)":{paddingBlockStart:0}},headerRoot:{"@media (min-width: 1280px)":{paddingTop:s.spacing(2)}},headerText:{"@media (min-width: 390px)":{fontSize:s.typography.pxToRem(37),lineHeight:s.typography.pxToRem(37)},"@media (max-width: 360px)":{fontSize:s.typography.pxToRem(31),lineHeight:s.typography.pxToRem(31)}},categoryBtn:{padding:0},textLink:{"&:not(:last-child)":{paddingBottom:6}}}),{name:"CatalogHeader"}),be=({categoryName:s,subCategoryLinks:o,seoBlock:p={}})=>{const i=ge(),r=p==null?void 0:p.h1,t=p==null?void 0:p.seo_popular_query,d=G(t),[m,h]=g.useState(!1),{meta_desc:l,meta_title:x}=p;return e.jsxs(e.Fragment,{children:[e.jsxs(le,{children:[e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:title",content:x}),e.jsx("meta",{property:"og:description",content:l}),e.jsx("meta",{property:"og:image",content:location.origin+"/local/traektoria_ta/build/img/logo_traektoria.svg"}),e.jsx("meta",{property:"og:url",content:location.href}),e.jsx("meta",{property:"og:site_name",content:"Траектория"})]}),e.jsxs(c,{xs:12,classes:{root:i.mainBlock},children:[e.jsxs(c,{container:!0,item:!0,alignItems:"baseline",classes:{root:i.headerRoot},spacing:3,children:[e.jsx(c,{item:!0,xs:"auto",children:e.jsx(C,{variant:"h1",classes:{root:i.headerText},children:r||s})}),Array.isArray(o)&&!!o.length&&e.jsx(c,{item:!0,xs:"auto",children:e.jsx(X,{classes:{root:i.categoryBtn},variant:"text",color:"default",onClick:()=>h(!m),endIcon:m?e.jsx(D,{}):e.jsx(Z,{}),children:"категории"})}),m&&e.jsx(w,{mdDown:!0,children:e.jsx(c,{item:!0,xs:12,children:e.jsx(c,{style:{maxHeight:90},container:!0,item:!0,direction:"column",justifyContent:"space-between",children:o&&o.map(a=>e.jsx(c,{classes:{root:i.textLink},item:!0,xs:"auto",children:e.jsx(C,{variant:"body1",children:e.jsx(ee,{underline:"none",component:Q,to:a.url,children:a.name})})},a.id))})})})]}),Array.isArray(d)&&e.jsx(de,{popularQuerySeoArray:d})]})]})},B=v(s=>({headerPopular:{"@media (max-width: 1024px)":{height:41}},chipRoot:{background:"#FFFFFF",borderRadius:"10px",fontSize:"0.85rem",lineHeight:"20px",color:"#5D6871"},chipIcon:{color:s.color.black60,"&:hover":{color:s.color.black60}},chipSkeleton:{width:200,height:32,backgroundColor:s.color.black40,borderRadius:10}}));function Se({items:s}){const o=B();return g.useMemo(()=>e.jsx(e.Fragment,{children:s.map((p,i)=>e.jsx(c,{item:!0,xs:"auto",sm:"auto",md:"auto",lg:"auto",xl:"auto",children:e.jsx(se,{variant:"rect",classes:{root:o.chipSkeleton},animation:"wave"})},i))}),[s])}function Pe({popularTags:s}){const o=B(),p=$(8),i=()=>{console.info("You clicked the delete icon.")};return s?e.jsx(w,{mdDown:!0,children:e.jsxs(c,{item:!0,spacing:3,container:!0,alignItems:"center",justifyContent:"flex-start",className:o.headerPopular,children:[s.map((r,t)=>e.jsx(c,{item:!0,xs:"auto",sm:"auto",md:"auto",lg:"auto",xl:"auto",children:e.jsx(_,{classes:{root:o.chipRoot},label:r.title},t)},t)),e.jsx(c,{item:!0,xs:"auto",sm:"auto",md:"auto",lg:"auto",xl:"auto",children:e.jsx(_,{classes:{root:o.chipRoot,deleteIcon:o.chipIcon},onClick:i,onDelete:i,label:"еще",deleteIcon:e.jsx(re,{color:"primary"})})})]})}):e.jsx(w,{mdDown:!0,children:e.jsx(c,{container:!0,spacing:3,alignItems:"center",justifyContent:"flex-start",className:o.headerPopular,children:e.jsx(Se,{items:p})})})}const ve=v(s=>({catalogWrapper:{backgroundColor:"#FFFFFF",position:"relative"},blogWrapper:{backgroundColor:"#3A474E",padding:"80px 0"},blogHeaderText:{"@media (max-width: 479px)":{fontSize:s.typography.pxToRem(20)}},blogSectionHeader:{paddingBottom:40},Backdrop:{zIndex:s.zIndex.drawer,position:"absolute",backgroundColor:"rgba(255, 255, 255, 0.5)"},loader:{position:"absolute",top:300},errorText:{fontSize:s.typography.pxToRem(33),lineHeight:s.typography.pxToRem(40),fontFamily:"TTFirsNeue-Medium, sans-serif","@media (max-width: 960px)":{textAlign:"center",fontSize:s.typography.pxToRem(27)}},errorGrid:{marginBlockStart:60}}),{name:"CatalogPage"}),Ie=({headerContent:s,page:o,isLoading:p,setPage:i,catalogData:r,error:t})=>{var k,F,H,T,R;const d=ve(),[m,h]=g.useState(),l=(k=r==null?void 0:r.products)==null?void 0:k.length,x=(H=(F=t==null?void 0:t.MAIN)==null?void 0:F[0])==null?void 0:H.message,a=!!l||x,j=s==null?void 0:s.SEO_BLOCK,b=r==null?void 0:r.breadcrumb,E=!!(b!=null&&b.length),N="Catalog",y=(T=r==null?void 0:r.products)==null?void 0:T.filter(n=>n.colors_list.length),z=n=>y.find(({product_id:u})=>u==n),W=n=>y.findIndex(({product_id:u})=>u==n),[M]=A(),L=n=>{const u=n.map(f=>{var S;return{id:f,price:(S=z(f))==null?void 0:S.colors_list[0].retail_price,index:W(f)}});M({type:"showProducts",products:JSON.stringify(u)})},O=g.useMemo(()=>{try{new IntersectionObserver((n,u)=>{if(r!=null&&r.products){const f=n.map(S=>S.target.dataset.id);L(f)}},{threshold:.5})}catch{}},[r==null?void 0:r.products]),I=!(r!=null&&r.sorts.filter(({code:n})=>n!=="sort").some(({is_active:n})=>n))&&(r==null?void 0:r.name)==="Одежда"?[...y].sort((n,u)=>u.badges.length-n.badges.length):y;return((R=t==null?void 0:t[0])==null?void 0:R.code)==="404"?e.jsx(je,{}):e.jsxs(e.Fragment,{children:[p?e.jsx(P,{fixed:!0,maxWidth:"xl",children:e.jsx(c,{container:!0,spacing:4,children:e.jsx(xe,{count:12})})}):a&&e.jsxs(oe,{className:d.catalogWrapper,children:[e.jsxs(fe,{children:[E&&e.jsx(pe,{items:b,children:e.jsx(ce,{})}),e.jsx(be,{subCategoryLinks:r==null?void 0:r.subsections,categoryName:r==null?void 0:r.name,seoBlock:j}),Array.isArray(r==null?void 0:r.popular_tags)&&!!(r!=null&&r.popular_tags.length)&&e.jsx(c,{item:!0,xs:12,children:e.jsx(Pe,{popularTags:r==null?void 0:r.popular_tags})})]}),e.jsxs(P,{fixed:!0,maxWidth:"xl",children:[e.jsx(ue,{headerContent:s,page:o,filterData:r}),e.jsx(c,{container:!0,spacing:4,itemProp:"hasOfferCatalog",itemScope:!0,itemType:"http://schema.org/OfferCatalog",children:y&&(I==null?void 0:I.map((n,u)=>e.jsx(he,{product:n,pageName:N,catalogName:r==null?void 0:r.name,productPosition:u+1,setShowDisplayProductSizes:h,showDisplayProductSiazes:m===(n==null?void 0:n.product_id),observer:O},n.product_id)))}),x&&e.jsx(c,{spacing:4,classes:{root:d.errorGrid},children:e.jsx(C,{variant:"body1",classes:{root:d.errorText},children:x})}),e.jsx(ae,{headerContent:s,items:r==null?void 0:r.navigation,sumProducs:l}),e.jsx(me,{seoBlock:j})]})]}),e.jsx(ne,{classes:{root:d.Backdrop},invisible:p,open:p??!1,children:e.jsx(te,{classes:{root:d.loader},color:"primary"})})]})},Ce=({data:s,isFetching:o,aditionalEventData:p})=>{var m,h,l,x;const i=(m=s==null?void 0:s.data)==null?void 0:m.HEADER,r=(l=(h=s==null?void 0:s.data)==null?void 0:h.MAIN)==null?void 0:l.content,t=(x=s==null?void 0:s.data)==null?void 0:x.FOOTER,d=s==null?void 0:s.errors;return e.jsxs(e.Fragment,{children:[e.jsx(K,{content:i,aditionalEventData:p,children:e.jsx(V,{isFetching:o})}),e.jsx(Ie,{isLoading:o,headerContent:i,catalogData:r,error:d}),e.jsx(Y,{content:t,children:e.jsx(ie,{container:document.getElementById("footer"),children:e.jsx(U,{isLoading:o})})})]})},sr=s=>{var m,h;const o=J(),[p]=A(),{data:i,isFetching:r}=q({pathname:o.pathname,params:o.search}),t=(h=(m=i==null?void 0:i.data)==null?void 0:m.MAIN)==null?void 0:h.content;g.useEffect(()=>{t&&p({type:"viewCategory",section_id:t.id})},[t]);const d=t==null?void 0:t.products.filter(l=>l.colors_list.length).reduce((l,x,a)=>{var j;return{...l,[`contentIds[${a}][ID]`]:x.product_id,[`contentIds[${a}][PRICE]`]:(j=x.colors_list[0])==null?void 0:j.retail_price}},{});return e.jsx(Ce,{data:i,isFetching:r,aditionalEventData:d})};export{sr as Catalog,Ce as Page};