import{j as e,a4 as G,L as Q,al as $,S as A,u as J,am as q}from"./main-ac2fa4b1.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-cb596e09.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 R,ai as re,o as se,B as oe,J as ne,M as te,aj as ie}from"./chunk-material-ui-42c43899.js";import{B as pe,a as ce}from"./chunk-index-06e3c389.js";import{P as de,D as me}from"./chunk-index-dbde51c6.js";import{H as le}from"./chunk-Helmet-b4541bbd.js";import{C as xe,F as ue,a as he,b as ae}from"./chunk-index-a37e06c2.js";import{Page404 as je}from"./chunk-index-db85048a.js";import"./chunk-lodash-6114c6d4.js";import"./chunk-index-a4bfef69.js";import"./chunk-index-89b7ba38.js";import"./chunk-index-2ed2285e.js";import"./chunk-index-c479aaf2.js";import"./chunk-index-60bb7016.js";import"./chunk-index-815ed3d5.js";import"./chunk-index-52e322f4.js";import"./chunk-index-9d37c6bf.js";import"./chunk-index-965fe2b4.js";import"./chunk-index-36abcaa9.js";import"./chunk-index-9bb58e99.js";import"./chunk-styled-bfd8e494.js";import"./chunk-createSvgIcon-288b305d.js";import"./chunk-index-e94d2725.js";import"./chunk-index-4b8e5f08.js";import"./chunk-effect-fade-17bfa8f3.js";import"./chunk-index-ba13af53.js";import"./chunk-pagination-4aa3111e.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"}),Se=({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 be({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(R,{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(R,{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(be,{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 F,H,T,k,_;const d=ve(),[m,h]=g.useState(),l=(F=r==null?void 0:r.products)==null?void 0:F.length,x=(T=(H=t==null?void 0:t.MAIN)==null?void 0:H[0])==null?void 0:T.message,a=!!l||x,j=s==null?void 0:s.SEO_BLOCK,S=r==null?void 0:r.breadcrumb,E=!!(S!=null&&S.length),N="Catalog",y=(k=r==null?void 0:r.products)==null?void 0:k.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 b;return{id:f,price:(b=z(f))==null?void 0:b.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(b=>b.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((_=t==null?void 0:t[0])==null?void 0:_.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:S,children:e.jsx(ce,{})}),e.jsx(Se,{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})})})]})},rr=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{rr as Catalog,Ce as Page};