1import{r as o,z,j as e,B as O,e as L,C as D,d as V}from"./chunk-CjkYRJu7.js";import{O as F}from"./chunk-gvM9JHW_.js";import{g as W}from"./chunk-BN4jtO5Y.js";/* empty css */import{C as l}from"./chunk-BbE8-ozs.js";import{O as q,T as U}from"./chunk-BmyCpzM0.js";const X=({product:s,productIndex:i,activeProductTab:P,actionLabel:x,onAction:g})=>{const[f,c]=o.useState({}),[y,j]=o.useState({}),[d,C]=o.useState({}),r=`${P==="lancamentos"?"":"best-"}${s.categoryName}-${s.subcategoryName}-${s.name}-${i}`,n=s.image||W(s,s.categoryName,s.subcategoryName),u=y[r]||n,N="https://placehold.co/200x200?text=Imagem+do+Produto",a=s.productLink!==void 0?s.productLink:s.link||z(s),t=a&&a!=="/"?a:null,b=!!(x&&g),k=s.status||s.details?.Status||s.details?.status||"",m=String(k).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),S=m.includes("lancamento")?"product-status-launch":m.includes("em linha")?"product-status-in-line":m.includes("fora de linha")?"product-status-discontinued":"",M=()=>{if(!n){c(h=>({...h,[r]:!0}));return}if(f[r])return;const p=[n.replace(/\.webp$/i,".png"),n.replace(/\.webp$/i,".jpg"),n.replace(/\.png$/i,".jpg"),n.replace(/\.jpg$/i,".png")],A=d[r]||0;if(A<p.length){const h=p[A];C(T=>({...T,[r]:A+1})),j(T=>({...T,[r]:h}))}else c(h=>({...h,[r]:!0}))},R=p=>{p.preventDefault(),p.stopPropagation(),g(s)},v=e.jsxs(e.Fragment,{children:[s.bestseller===!0&&e.jsx("span",{className:"product-bestseller-icon",title:"Mais vendido","aria-label":"Mais vendido",children:e.jsx("i",{className:"fas fa-fire","aria-hidden":"true"})}),e.jsx(l.Title,{as:"h3",className:"product-card-title",children:s.name}),e.jsx(l.Subtitle,{className:"product-card-subtitle text-muted",children:s.subcategoryName}),e.jsx("img",{src:!f[r]&&u?u:N,alt:s.name,className:"card-img-top product-card-image",onError:M,loading:"lazy"}),e.jsx(l.Body,{className:"product-card-body",children:s.description&&e.jsx(l.Text,{className:"product-card-description",children:s.description.length>180?s.description.substring(0,180)+"...":s.description})})]}),E=t?e.jsx("a",{href:t,className:"product-card-link",children:v}):e.jsx("div",{className:"product-card-link product-card-link--static",children:v}),I=b?e.jsxs(l,{className:`product-card landing-product-card h-100 ${S}`,children:[E,e.jsx(l.Footer,{className:"product-card-action",children:e.jsx(O,{type:"button",size:"small",icon:"fas fa-envelope",onClick:R,children:x})})]}):t?e.jsx("a",{href:t,className:"product-card-link",children:e.jsx(l,{className:`product-card landing-product-card h-100 ${S}`,children:v})}):e.jsx(l,{className:`product-card landing-product-card h-100 ${S}`,children:v}),B=s.tooltip?e.jsx(q,{placement:"bottom",overlay:e.jsx(U,{id:`product-card-tooltip-${i}`,children:s.tooltip}),children:e.jsx("div",{className:"product-card-tooltip-wrapper",children:I})}):I;return e.jsx(L,{className:"product-carousel-card d-flex justify-content-center",children:B})},w=30,Y=({initialProductHighlights:s,products:i,ariaLabel:P="Selecionar produtos em destaque",heading:x="Produtos em Destaque",cardActionLabel:g,onCardAction:f})=>{const[c,y]=o.useState("lancamentos"),j=o.useRef(null),d=o.useMemo(()=>s||{},[s]),C=o.useMemo(()=>i||[],[i]),$=Array.isArray(i),r=o.useMemo(()=>(d.launchProducts||[]).slice(0,w),[d]),n=o.useMemo(()=>(d.bestsellerProducts||[]).slice(0,w),[d]),u=$?C.slice(0,w):c==="lancamentos"?r:n,N=a=>{const t=j.current;if(!t)return;const b=t.scrollWidth-t.clientWidth,k=t.scrollLeft<=1,m=t.scrollLeft>=b-1;if(a<0&&k){t.scrollTo({left:b,behavior:"smooth"});return}if(a>0&&m){t.scrollTo({left:0,behavior:"smooth"});return}t.scrollBy({left:a*t.clientWidth,behavior:"smooth"})};return e.jsx("section",{className:"featured-products-section py-5",children:e.jsxs(D,{children:[e.jsx("h2",{className:"section-title visually-hidden",children:x}),!$&&e.jsxs("div",{className:"product-tabs-container",children:[e.jsx(F,{ariaLabel:P,activeValue:c,onChange:y,options:[{value:"lancamentos",label:"Lançamentos",icon:"fas fa-rocket"},{value:"maisVendidos",label:"Mais Vendidos",icon:"fas fa-fire"}]}),e.jsx("p",{className:"section-subtitle mt-3",children:c==="lancamentos"?"Conheça nossos produtos mais recentes":"Confira nossos produtos mais populares"})]}),u.length>0?e.jsxs("div",{className:"launch-products-carousel",children:[e.jsx("button",{type:"button",className:"carousel-control-prev",onClick:()=>N(-1),"aria-label":"Produtos anteriores",children:e.jsx("span",{className:"carousel-control-prev-icon","aria-hidden":"true"})}
1),e.jsx("div",{ref:j,className:"product-carousel-viewport",children:e.jsx("div",{className:"product-carousel-track",children:u.map((a,t)=>e.jsx(X,{product:a,productIndex:t,activeProductTab:c,actionLabel:g,onAction:f},`${a.categoryName}-${a.subcategoryName}-${a.name}-${t}`))})}),e.jsx("button",{type:"button",className:"carousel-control-next",onClick:()=>N(1),"aria-label":"Próximos produtos",children:e.jsx("span",{className:"carousel-control-next-icon","aria-hidden":"true"})})]},c):e.jsx(V,{children:e.jsx(L,{className:"text-center py-5",children:e.jsx("p",{className:"text-muted",children:"Nenhum produto disponÃvel no momento."})})})]})})};export{Y as P};
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.