1import{r as d,j as e,a4 as V,a6 as K,a7 as P,a8 as M,a9 as T,aa as L,ab as O,L as Q,b as H}from"./vendor-react-core-_0sZDOLQ.js";import{B as g,a as j,l as J,c as $,b as G}from"./index-j07E1qHv.js";import{I as U}from"./input-rti45mgP.js";import{T as X,a as W,b as Y}from"./tabs-BUF6w8PE.js";import{C as Z,a as ee}from"./card-DHmBnTdH.js";import{B as p}from"./badge-BXqwvh8U.js";import{D as ae,b as se,c as te,d as le}from"./dialog-C9ty4md6.js";import{S as ie,a as re,b as ne,c as oe,d as ce}from"./select-DHshRvNJ.js";import{J as k,x as S,X as de,e as y,be as me,a0 as xe,a1 as he,a2 as ge,al as ue,i as fe}from"./vendor-lucide-Ddz0eB7N.js";import{f as q}from"./publicProducts-BGVf2oJm.js";import{C as pe}from"./CleanHero-B9_2ARuE.js";import{m as je}from"./vendor-framer-motion-C1oRD-X5.js";import"./vendor-radix-CFmJ1img.js";import"./vendor-utils-BRu4i-LD.js";import"./vendor-supabase-Ca6cp8v2.js";const A={camisolas:"Camisola",equipamento:"Equipamento",acessorios:"Acessório",outros:"Outro"};function be({product:a,onAddToCart:i}){const[l,x]=d.useState(!1),[m,u]=d.useState(""),n=Number(a.stock??a.stock_quantity??0),s=Array.isArray(a.sizes)?a.sizes:[],o=()=>{if(s.length>0&&!m){x(!0);return}i({...a,stock:n},m||"Ãnico"),u("")};return e.jsxs(e.Fragment,{children:[e.jsxs(Z,{className:"overflow-hidden hover:shadow-xl transition-shadow group cursor-pointer",onClick:()=>x(!0),children:[e.jsxs("div",{className:"relative aspect-square bg-gray-100 overflow-hidden",children:[a.image_url?e.jsx("img",{src:a.image_url,alt:a.name,loading:"lazy",className:"w-full h-full object-cover group-hover:scale-110 transition-transform"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(k,{className:"w-20 h-20 text-gray-300"})}),a.featured&&e.jsx(p,{className:"absolute top-3 right-3 bg-yellow-500 text-black",children:"Destaque"}),n===0&&e.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center",children:e.jsx(p,{variant:"destructive",children:"Esgotado"})})]}),e.jsxs(ee,{className:"p-4",children:[e.jsx(p,{variant:"outline",className:"mb-2",children:A[a.category]}),e.jsx("h3",{className:"font-bold text-gray-900 mb-2 line-clamp-2",children:a.name}),e.jsx("p",{className:"text-sm text-gray-600 mb-3 line-clamp-2",children:a.description}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-2xl font-bold text-green-600",children:[a.price.toLocaleString("pt-AO")," Kz"]}),e.jsxs(g,{size:"sm",onClick:c=>{c.stopPropagation(),o()},disabled:n===0,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(S,{className:"w-4 h-4 mr-2"}),"Adicionar"]})]})]})]}),e.jsx(ae,{open:l,onOpenChange:x,children:e.jsxs(se,{className:"max-w-3xl",children:[e.jsx(te,{children:e.jsx(le,{children:a.name})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsx("div",{className:"aspect-square bg-gray-100 rounded-lg overflow-hidden",children:a.image_url?e.jsx("img",{src:a.image_url,alt:a.name,loading:"lazy",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(k,{className:"w-32 h-32 text-gray-300"})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{children:e.jsx(p,{variant:"outline",children:A[a.category]})}),e.jsx("p",{className:"text-gray-600",children:a.description}),e.jsxs("div",{className:"text-3xl font-bold text-green-600",children:[a.price.toLocaleString("pt-AO")," Kz"]}),s.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Tamanho"}),e.jsxs(ie,{value:m,onValueChange:u,children:[e.jsx(re,{children:e.jsx(ne,{placeholder:"Selecione o tamanho"})}),e.jsx(oe,{children:s.map(c=>e.jsx(ce,{value:c,children:c},c))})]})]}),e.jsxs("div",{className:"text-sm text-gray-600",children:["Stock: ",e.jsxs("span",{className:"font-bold",children:[n," unidades"]})]}),e.jsxs(g,{onClick:()=>{s.length>0&&!m||(i({...a,stock:n},m||"Ãnico"),x(!1),u(""))},disabled:n===0||s.length>0&&!m,className:"w-full bg-green-600 hover:bg-green-700",children:[e.jsx(S,{className:"w-4 h-4 mr-2"}),"Adicionar ao Carrinho"]})]})]})]})})]})}const Ne=V,ye=K,_=d.forwardRef(({className:a,...i},l)=>e.jsx(L,{className:j("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...i,ref:l}));_.displayName=L.displayName;const ve=J("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),D=d.forwardRef(({side:a="right",className:i,children:l,...x},m)=>e.jsxs(ye,{children:[e.jsx(_,{}),e.jsxs(P,{ref:m,className:j(ve({side:a}),i),...x,children:[e.jsxs(M,{className:"absolute right-4 top-4 roun
1ded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[e.jsx(de,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),l]})]}));D.displayName=P.displayName;const E=({className:a,...i})=>e.jsx("div",{className:j("flex flex-col space-y-2 text-center sm:text-left",a),...i});E.displayName="SheetHeader";const I=d.forwardRef(({className:a,...i},l)=>e.jsx(T,{ref:l,className:j("text-lg font-semibold text-foreground",a),...i}));I.displayName=T.displayName;const we=d.forwardRef(({className:a,...i},l)=>e.jsx(O,{ref:l,className:j("text-sm text-muted-foreground",a),...i}));we.displayName=O.displayName;function Ce({open:a,onClose:i,cart:l,setCart:x}){const m=(s,o,c)=>{x(l.map(f=>{if(f.id===s&&f.size===o){const b=f.quantity+c;return b>0?{...f,quantity:b}:null}return f}).filter(Boolean))},u=(s,o)=>{x(l.filter(c=>!(c.id===s&&c.size===o)))},n=l.reduce((s,o)=>s+o.price*o.quantity,0);return e.jsx(Ne,{open:a,onOpenChange:i,children:e.jsxs(D,{className:"w-full sm:max-w-lg flex flex-col",children:[e.jsx(E,{children:e.jsx(I,{children:"Carrinho de Compras"})}),l.length===0?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center py-12",children:[e.jsx(y,{className:"w-20 h-20 text-gray-300 mb-4"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-2",children:"Carrinho vazio"}),e.jsx("p",{className:"text-gray-600 mb-6",children:"Adicione produtos para começar"}),e.jsx(g,{onClick:i,className:"bg-red-600 hover:bg-red-700",children:"Continuar a comprar"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-y-auto py-6 space-y-4",children:l.map(s=>e.jsxs("div",{className:"flex gap-4 border-b pb-4",children:[e.jsx("div",{className:"w-20 h-20 bg-gray-100 rounded-lg overflow-hidden flex-shrink-0",children:s.image_url?e.jsx("img",{src:s.image_url,alt:s.name,loading:"lazy",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(y,{className:"w-8 h-8 text-gray-300"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-gray-900 mb-1",children:s.name}),e.jsxs("p",{className:"text-sm text-gray-600 mb-2",children:["Tamanho: ",s.size]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 rounded-lg",children:[e.jsx(g,{size:"icon",variant:"ghost",onClick:()=>m(s.id,s.size,-1),className:"h-8 w-8",children:e.jsx(me,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-semibold w-8 text-center",children:s.quantity}),e.jsx(g,{size:"icon",variant:"ghost",onClick:()=>m(s.id,s.size,1),disabled:s.quantity>=s.stock,className:"h-8 w-8",children:e.jsx(xe,{className:"w-4 h-4"})})]}),e.jsxs("span",{className:"font-bold text-red-600",children:[(s.price*s.quantity).toLocaleString("pt-AO")," Kz"]})]})]}),e.jsx(g,{size:"icon",variant:"ghost",onClick:()=>u(s.id,s.size),className:"text-red-600 hover:bg-red-50",children:e.jsx(he,{className:"w-4 h-4"})})]},`${s.id}-${s.size}`))}),e.jsxs("div",{className:"border-t pt-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-lg font-bold",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{className:"text-red-600",children:[n.toLocaleString("pt-AO")," Kz"]})]}),e.jsx(Q,{to:$("Checkout"),onClick:i,children:e.jsx(g,{className:"w-full bg-red-600 hover:bg-red-700",size:"lg",children:"Finalizar Compra"})})]})]})]})})}const Se=[{value:"all",label:"Todos"},{value:"camisolas",label:"Camisolas"},{value:"equipamento",label:"Equipamento"},{value:"acessorios",label:"Acessórios"},{value:"outros",label:"Outros"}],C=12;function Ve(){const[a,i]=d.useState(""),[l,x]=d.useState("all"),[m,u]=d.useState(!1),[n,s]=d.useState([]),[o,c]=d.use
1State(1),{data:f,isLoading:b}=H({queryKey:["products"],queryFn:()=>G.entities.Product.filter({active:!0}),initialData:[]}),F=q(f);d.useEffect(()=>{const t=localStorage.getItem("faf_cart");if(t)try{s(q(JSON.parse(t)))}catch{localStorage.removeItem("faf_cart")}},[]),d.useEffect(()=>{localStorage.setItem("faf_cart",JSON.stringify(n))},[n]);const v=F.filter(t=>{var h;const r=t.name.toLowerCase().includes(a.toLowerCase())||((h=t.description)==null?void 0:h.toLowerCase().includes(a.toLowerCase())),w=l==="all"||t.category===l;return r&&w}),N=Math.ceil(v.length/C),R=v.slice((o-1)*C,o*C);d.useEffect(()=>{c(1)},[a,l]);const B=(t,r)=>{const w=n.find(h=>h.id===t.id&&h.size===r);s(w?n.map(h=>h.id===t.id&&h.size===r?{...h,quantity:h.quantity+1}:h):[...n,{...t,size:r,quantity:1}]),u(!0)},z=n.reduce((t,r)=>t+r.quantity,0);return e.jsxs("main",{className:"min-h-screen bg-gray-50",children:[e.jsx(pe,{eyebrow:"Vista as cores de Angola. Viva a paixão pelo futebol.",title:"Loja Oficial",description:"Bem-vindo à Loja Oficial da Federação Angolana de Futebol. Aqui encontra produtos oficiais das Seleções Nacionais e da FAF, desenvolvidos para todos os adeptos que vivem e apoiam o futebol angolano. Ao adquirir produtos oficiais, está a contribuir para o desenvolvimento do futebol em Angola e a representar com orgulho as cores nacionais.",icon:y}),e.jsx("section",{className:"py-8 bg-white border-b sticky top-20 z-30",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 items-center justify-between",children:[e.jsx(X,{value:l,onValueChange:x,children:e.jsx(W,{className:"bg-gray-100",children:Se.map(t=>e.jsx(Y,{value:t.value,children:t.label},t.value))})}),e.jsxs("div",{className:"flex gap-3 w-full md:w-auto",children:[e.jsxs("div",{className:"relative flex-1 md:w-64",children:[e.jsx(ge,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx(U,{placeholder:"Pesquisar produtos...",value:a,onChange:t=>i(t.target.value),className:"pl-10"})]}),e.jsxs(g,{onClick:()=>u(!0),className:"bg-red-600 hover:bg-red-700 relative",children:[e.jsx(S,{className:"w-5 h-5"}),z>0&&e.jsx(p,{className:"absolute -top-2 -right-2 bg-yellow-500 text-black",children:z})]})]})]})})}),e.jsx("section",{className:"py-12",children:e.jsx("div",{className:"container mx-auto px-4",children:b?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-6",children:[...Array(8)].map((t,r)=>e.jsx("div",{className:"bg-white rounded-xl h-96 animate-pulse"},r))}):v.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-6",children:R.map((t,r)=>e.jsx(je.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:r*.05},children:e.jsx(be,{product:t,onAddToCart:B})},t.id))}),N>1&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-8",children:[e.jsx(g,{variant:"outline",size:"icon",onClick:()=>c(t=>Math.max(1,t-1)),disabled:o===1,children:e.jsx(ue,{className:"w-4 h-4"})}),e.jsx("div",{className:"flex items-center gap-2",children:[...Array(N)].map((t,r)=>e.jsx(g,{variant:o===r+1?"default":"outline",size:"sm",onClick:()=>c(r+1),className:o===r+1?"bg-red-600 hover:bg-red-700":"",children:r+1},r))}),e.jsx(g,{variant:"outline",size:"icon",onClick:()=>c(t=>Math.min(N,t+1)),disabled:o===N,children:e.jsx(fe,{className:"w-4 h-4"})})]})]}):e.jsxs("div",{className:"text-center py-20",children:[e.jsx(y,{className:"w-20 h-20 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-bold text-gray-900 mb-2",children:"Nenhum produto encontrado"}),e.jsx("p",{className:"text-gray-600",children:"Tente ajustar os filtros de pesquisa"})]})})}),e.jsx(Ce,{open:m,onClose:()=>u(!1),cart:n,setCart:s})]})}export{Ve as default};
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.