1import{H as h,j as e,Q as j,i as X,a3 as Y,g as Z,s as B,a4 as ee,a5 as se,a6 as ae,X as te,n as ne,r as b,P as re,a0 as F,t as ie,u as le,v as ce,w as oe,B as de,G as me,U as xe,z as he,J as N,I as ue,K as M}from"./ui-ig8E5hwA.js";import{f as ge,b as pe,r as c}from"./vendor-lj6cluqn.js";import{u as fe,d as T,O as g,l as v,m as je}from"./index-CxnQOnkr.js";import{R as be}from"./ReportButton-BTHNdfOW.js";import"./firebase-OpcZ-Tii.js";import"./firestore-Mpy8fa92.js";import"./reportService-D6yT3kGh.js";const Le=()=>{var A;const{id:l}=ge(),r=pe(),[s,y]=c.useState(null),[U,w]=c.useState(!0),[C,z]=c.useState([]),{user:o,isAdmin:V,isModerator:q}=fe(),[k,I]=c.useState(!1),O=T("click"),G=T("navigation"),[n,u]=c.useState(null),p=c.useRef(null);c.useEffect(()=>{(async()=>{if(l){w(!0);try{const t=await v.getListings({}),i=t.find(d=>d.id===l);if(i){if(y(i),p.current!==l){const m=`viewed_listing_${l}`;if(sessionStorage.getItem(m))p.current=l;else{try{await v.incrementViews(l),y(x=>x?{...x,views:x.views+1}:null),sessionStorage.setItem(m,"true")}catch(x){console.error("Failed to increment views:",x)}p.current=l}}const d=t.filter(m=>m.type===i.type&&m.id!==i.id).slice(0,3);z(d)}else r("/listings")}catch(t){console.error("Failed to load listing:",t)}finally{w(!1)}}})()},[l,r]);const S=async()=>{if(O(),!o){window.confirm("Você precisa estar logado para enviar uma mensagem. Deseja fazer login agora?")&&r("/login");return}if(s){if(o.uid===s.userId){alert("Você não pode enviar mensagem para seu próprio anúncio.");return}try{const a=await je.findOrCreateListingConversation(o.uid,s.userId,s.id,s.title,s.price,s.images[0]);r(`/messages/${a}`)}catch(a){console.error("Failed to start chat:",a),alert("Erro ao iniciar conversa. Tente novamente.")}}},L=()=>{s&&r(`/profile/${s.userId}`)},E=a=>{u(a)},f=()=>{u(null)},R=a=>{if(a&&a.stopPropagation(),n===null||!s)return;const t=n>0?n-1:s.images.length-1;u(t)},$=a=>{if(a&&a.stopPropagation(),n===null||!s)return;const t=n<s.images.length-1?n+1:0;u(t)};c.useEffect(()=>{const a=t=>{n===null||!s||(t.key==="Escape"?f():t.key==="ArrowLeft"?R():t.key==="ArrowRight"&&$())};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[n,s]);const D=(a,t)=>new Intl.NumberFormat("pt-BR",{style:"currency",currency:t==="BRL"?"BRL":"USD"}).format(a),P=a=>{const t=s==null?void 0:s.mainCategory;if(a==="generic"&&t)switch(t){case"housing":return h;case"cars":return M;case"services":return N;case"documents":return ue;case"jobs":return N;case"education":return he;case"community":return xe;case"saude":return B;case"tecnologia":return me;case"negocios":return de;case"furniture":return oe;case"electronics":return ce;case"fashion":return le;case"others":return ie;default:return h}switch(a){case"property":return h;case"car":return M;case"service":return N;default:return h}},H=a=>{switch(a){case"property":return"Imóvel";case"car":return"Carro";case"service":return"Serviço";case"generic":{const t=s==null?void 0:s.mainCategory;return t?{housing:"Imóvel",cars:"Carro",services:"Serviço",documents:"Documentos",jobs:"Empregos",education:"Educação",community:"Comunidade",saude:"Saúde",tecnologia:"Tecnologia",negocios:"Negócios",furniture:"Móveis",electronics:"Eletrônicos",fashion:"Moda",others:"Outros"}[t]||t:"Outros"}default:return a}},K=s?P(s.type):h,Q=(s==null?void 0:s.type)==="property",W=(s==null?void 0:s.type)==="car",_=(s==null?void 0:s.type)==="service",J=async()=>{if(s&&window.confirm("Tem certeza que deseja excluir este anúncio?")){I(!0);try{await v.deleteListing(s.id,o==null?void 0:o.uid),r("/listings")}catch(a){console.error("Error deleting listing:",a),alert("Não foi possÃvel excluir o anúncio.")}finally{I(!1)}}};return e.jsx("div",{className:"max-w-7xl mx-auto px-6 py-8 flex-grow",children:U?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-noe-brand"})}):s?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{G(),r("/listings")},className:"flex items-center gap-2 text-noe-400 hover:text-noe-brand transition-colors mb-6",children:[e.jsx(j,{className:"w-5 h-5"}),"Voltar para listagens"]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-8",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx("div",{className:`p-3 rounded-xl ${s.type==="property"?"bg-emerald-500/20 text-emerald-400":s.type==="car"?"bg-blue-500/20 text-blue-400":"bg-amber-500/20 text-amber-400"}`,children:e.jsx(K,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-3xl font-bold",children:s.title}),e.jsx("span",{className:"px-3 py-1 bg-noe-brand/20 text-noe-brand rounded-full text-sm font-medium",children:H(s.type)})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-noe-500",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"w-4 h-4"}),e.jsx("span",{children:s.location})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4"}),e.jsxs("span",{children:["Publicado em ",new Date(s.createdAt).toLocaleDateString("pt-BR")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4"}),e.jsxs("span",{children:[s.views," visualizações"]})]})]})]})]})}),e.jsxs("div",{className:"bg-noe-900/30 border border-noe-800 rounded-2xl p-4 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center justify-end gap-4 mb-4",children:[e.jsxs("button",{className:"flex items-center gap-2 text-noe-400 hover:text-noe-brand transition-colors",children:[e.jsx(B,{className:"w-5 h-5"}),"Favoritar"]}),e.jsxs("button",{className:"flex items-center gap-2 text-noe-400 hover:text-noe-brand transition-colors",children:[e.jsx(ee,{className:"w-5 h-5"}),"Compartilhar"]}),e.jsx(be,{targetType:"listing",targetId:s.id,targetTitle:s.title,targetUserId:s.userId,size:"sm"}),(V||q)&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>r(`/listings/${s.id}/edit`),className:"flex items-center gap-2 text-noe-400 hover:text-noe-brand transition-colors",title:"Editar anúncio",children:[e.jsx(se,{className:"w-5 h-5"}),"Editar"]}),e.jsxs("button",{onClick:J,disabled:k,className:"flex items-center gap-2 text-noe-400 hover:text-red-400 transition-colors disabled:opacity-50",title:"Excluir anúncio",children:[e.jsx(ae,{className:"w-5 h-5"}),k?"Excluindo...":"Excluir"]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:s.images.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"md:col-span-2",onClick:()=>E(0),children:e.jsx("div",{className:"aspect-video rounded-xl overflow-hidden bg-noe-800/50",children:e.jsx(g,{src:s.images[0],alt:s.title,className:"w-full h-full object-cover cursor-pointer",width:800,height:450,fallbackSrc:`https://via.placeholder.com/800x450/bfa757/ffffff?text=${encodeURIComponent(s.title)}`})})}),s.images.slice(1,3).map((a,t)=>{const i=t+1,d=i===2&&s.images.length>3;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-noe-800/30 border border-noe-800",onClick:()=>E(i),children:[e.jsx(g,{src:a,alt:`${s.title} - ${i+1}`,className:"w-full h-full object-cover cursor-pointer",width:400,height:400,fallbackSrc:`https://via.placeholder.com/400x400/bfa757/ffffff?text=${encodeURIComponent(s.title)}`}),d&&e.jsx("div",{className:"absolute inset-0 bg-black/70 flex items-center justify-center cursor-pointer",children:e.jsxs("div",{className:"text-white text-2xl font-bold",children:["+",s.images.length-3]})})]},i)}),s.images.length===2&&e.jsx("div",{className:"aspect-square rounded-lg bg-noe-800/30 border border-noe-800 flex items-center justify-center",children:e.jsx("span",{className:"text-noe-500",children:"Sem imagem adicional"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-video rounded-xl bg-noe-800/50 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-6xl mb-4",children:s.type==="property"?"ð ":s.type==="car"?"ð":"ð§°"}),e.jsx("p",{className:"text-noe-400",children:"Imagem principal da listagem"})]})})}),[1,2,3].map(a=>e.jsx("div",{className:"aspect-square rounded-lg bg-noe-800/30 border border-noe-800 flex items-center justify-center",children:e.jsxs("span",{className:"text-noe-500",children:["Imagem ",a]})},a))]})})]}),n!==null&&s&&e.jsx("div",{className:"fixed inset-0 bg-black/90 z-50 flex items-center justify-center p-4",onClick:f,children:e.jsxs("div",{className:"relative max-w-5xl max-h-[90vh] w-full",onClick:a=>a.stopPropagation(),children:[e.jsx("button",{onClick:f,className:"absolute -top-12 right-0 text-white hover:text-gray-300 transition-colors z-10 bg-black/50 rounded-full p-2",children:e.jsx(te,{className:"w-6 h-6"})}),s.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:R,className:"absolute left-4 top-1/2 -translate-y-1/2 text-white hover:text-gray-300 transition-colors z-10 bg-black/50 rounded-full p-3",children:e.jsx(j,{className:"w-6 h-6"})}),e.jsx("button",{onClick:$,className:"absolute right-4 top-1/2 -translate-y-1/2 text-white hover:text-gray-300 transition-colors z-10 bg-black/50 rounded-full p-3",children:e.jsx(j,{className:"w-6 h-6 transform rotate-180"})})]}),e.jsx("div",{className:"rounded-lg overflow-hidden",children:e.jsx(g,{src:s.images[n],alt:`${s.title} - ${n+1}`,className:"w-full h-auto max-h-[80vh] object-contain",width:1200,height:800,fallbackSrc:`https://via.placeholder.com/1200x800/bfa757/ffffff?text=${encodeURIComponent(s.title)}`})}),e.jsxs("div",{className:"text-white text-center mt-4",children:[n+1," / ",s.images.length]})]})}),e.jsxs("div",{className:"bg-noe-900/30 border border-noe-800 rounded-2xl p-6 backdrop-blur-sm",children:[e.jsx("h2",{className:"text-xl font-bold mb-6",children:"Detalhes"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Descrição"}),e.jsx("p",{className:"text-noe-300",children:s.description})]}),Q&&"bedrooms"in s&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"CaracterÃsticas do Imóvel"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-noe-500",children:"Quartos:"}),e.jsx("span",{className:"font-medium",children:s.bedrooms})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-noe-500",children:"Banheiros:"}),e.jsx("span",{className:"font-medium",children:s.bathrooms})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-noe-500",children:"Ãrea:"}),e.jsxs("span",{className:"font-medium",children:[s.area," m²"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-noe-500",children:"Mobiliado:"}),e.jsx("span",{className:"font-medium",children:(A=s.amenities)!=null&&A.includes("mobiliado")?"Sim":"Não"})]})]})]}),W&&"year"in s&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Especificações do Carro"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-noe-500",children:"Ano:"}),e.jsx("span",{className:"font-medium",children:s.year})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-noe-500",children:"Marca:"}),e.jsx("span",{className:"font-medium",children:s.make})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-noe-500",children:"Modelo:"}),e.jsx("span",{className:"font-medium",children:s.model})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-noe-500",children:"Qu
1ilometragem:"}),e.jsxs("span",{className:"font-medium",children:[s.mileage.toLocaleString("pt-BR")," km"]})]})]})]}),_&&"category"in s&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Informações do Serviço"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-noe-500",children:"Categoria:"}),e.jsx("span",{className:"font-medium",children:s.category})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-noe-500",children:"Experiência:"}),e.jsxs("span",{className:"font-medium",children:[s.providerExperience," anos"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-noe-500",children:"Disponibilidade:"}),e.jsx("span",{className:"font-medium",children:s.availability})]})]})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-noe-800/30 border border-noe-700 rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:D(s.price,s.priceUnit)}),e.jsxs("div",{className:"text-noe-500 text-sm",children:[s.type==="property"&&"por mês",s.type==="car"&&"à vista",s.type==="service"&&s.priceUnit]})]}),e.jsx("div",{className:"text-emerald-400",children:e.jsx(ne,{className:"w-6 h-6"})})]}),e.jsxs("button",{onClick:S,className:"w-full py-3 bg-noe-brand text-white rounded-lg font-medium hover:bg-noe-brand/80 transition-colors flex items-center justify-center gap-2",children:[e.jsx(b,{className:"w-5 h-5"}),"Enviar mensagem"]})]}),e.jsxs("div",{className:"bg-noe-800/30 border border-noe-700 rounded-xl p-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Anunciante"}),e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[s.userAvatar?e.jsx("button",{onClick:L,className:"w-12 h-12 rounded-full overflow-hidden bg-noe-brand/20 focus:outline-none focus:ring-2 focus:ring-noe-brand",children:e.jsx(g,{src:s.userAvatar,alt:s.userName,className:"w-full h-full object-cover",width:48,height:48,fallbackSrc:`https://ui-avatars.com/api/?name=${encodeURIComponent(s.userName)}&background=bfa757&color=000000`})}):e.jsx("button",{onClick:L,className:"w-12 h-12 rounded-full bg-noe-brand/20 flex items-center justify-center text-noe-brand font-bold text-xl focus:outline-none focus:ring-2 focus:ring-noe-brand",children:s.userName.charAt(0)}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.userName}),e.jsx("div",{className:"text-sm text-noe-500",children:"Membro desde 2023"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(re,{className:"w-4 h-4 text-noe-500"}),e.jsx("span",{className:"text-noe-300",children:s.contactPhone})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(b,{className:"w-4 h-4 text-noe-500"}),e.jsx("span",{className:"text-noe-300",children:s.contactWhatsApp})]})]}),e.jsxs("button",{onClick:S,className:"w-full mt-4 py-2.5 bg-noe-brand/20 text-noe-brand rounded-lg font-medium hover:bg-noe-brand/30 transition-colors flex items-center justify-center gap-2",children:[e.jsx(b,{className:"w-4 h-4"}),"Enviar mensagem"]}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 text-sm text-noe-500",children:[e.jsx(F,{className:"w-4 h-4"}),e.jsx("span",{children:"Verificado pelo Grupo Noé"})]})]})]})]})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-noe-900/30 border border-noe-800 rounded-2xl p-6 backdrop-blur-sm",children:[e.jsx("h2",{className:"text-xl font-bold mb-6",children:"Listagens Similares"}),e.jsx("div",{className:"space-y-4",children:C.length>0?C.map(a=>{const t=P(a.type);return e.jsx("div",{className:"p-4 bg-noe-800/30 rounded-xl border border-noe-800 hover:border-noe-brand/30 transition-all cursor-pointer",onClick:()=>r(`/listings/${a.id}`),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg ${a.type==="property"?"bg-emerald-500/20 text-emerald-400":a.type==="car"?"bg-blue-500/20 text-blue-400":"bg-amber-500/20 text-amber-400"}`,children:e.jsx(t,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:a.title}),e.jsx("div",{className:"text-sm text-noe-500",children:a.location}),e.jsx("div",{className:"text-noe-brand font-bold mt-2",children:D(a.price,a.priceUnit)})]})]})},a.id)}):e.jsx("div",{className:"text-center text-noe-500 py-4",children:"Nenhuma listagem similar encontrada"})})]}),e.jsxs("div",{className:"bg-noe-900/30 border border-noe-800 rounded-2xl p-6 backdrop-blur-sm",children:[e.jsxs("h2",{className:"text-xl font-bold mb-4 flex items-center gap-2",children:[e.jsx(F,{className:"w-5 h-5 text-noe-brand"}),"Dicas de Segurança"]}),e.jsxs("ul",{className:"space-y-3 text-sm",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-noe-brand mt-1.5"}),e.jsx("span",{children:"Combine encontros em locais públicos e seguros"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-noe-brand mt-1.5"}),e.jsx("span",{children:"Verifique a identidade do anunciante"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-noe-brand mt-1.5"}),e.jsx("span",{children:"Desconfie de preços muito abaixo do mercado"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-noe-brand mt-1.5"}),e.jsx("span",{children:"Nunca transfira dinheiro antes de verificar o produto"})]})]})]})]})]})]}):e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Listagem não encontrada"}),e.jsx("button",{onClick:()=>r("/listings"),className:"mt-4 px-4 py-2 bg-noe-brand text-white rounded-lg hover:bg-noe-brand/80 transition-colors",children:"Voltar ao Marketplace"})]})})};export{Le as default}; 2//# sourceMappingURL=ListingDetailPage-BFoX_Vuw.js.map
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.