1import{u as _,j as t}from"./vendor-query-CO_QYTkO.js";import{r as u,b as I}from"./vendor-react-DJfEFaqw.js";import{c as M,s as R}from"./index-BuBFkYNO.js";import{L as q}from"./vendor-router-CkFJCvFZ.js";import"./vendor-ui-CCUQhf4y.js";import"./vendor-supabase-MEHSyf2E.js";import"./vendor-icons-BmcpZVdY.js";import"./vendor-helmet-Cc4zoVvE.js";import"./vendor-sanitize-D9RiKzGB.js";import"./vendor-codemirror-kF8_xaBD.js";import"./vendor-dnd-Ds4KDHQQ.js";import"./vendor-carousel-DpjaRhUe.js";const D=({title:x="Fotos",titleFontFamily:g,titleFontSize:p="3.5rem",count:c=12,categories:m=["lazer","gastronomia","acomodacoes","ambientes"],layout:d="grid",columns:h=4})=>{const[n,l]=u.useState(null),{data:r,isLoading:f}=_({queryKey:["random-gallery",m,c],queryFn:async()=>{const e=Math.ceil(c/m.length),s=[];for(const a of m){const{data:i}=await R.from("gallery_images").select("id, url, alt_text").eq("is_enabled",!0).eq("category",a).limit(e);i&&s.push(...i)}return s.sort(()=>Math.random()-.5).slice(0,c)}}),v=u.useMemo(()=>({2:"grid-cols-1 sm:grid-cols-2",3:"grid-cols-2 md:grid-cols-3",4:"grid-cols-2 md:grid-cols-4",5:"grid-cols-2 md:grid-cols-3 lg:grid-cols-5"})[h]||"grid-cols-2 md:grid-cols-4",[h]),j=u.useMemo(()=>{if(d!=="justified"||!r)return[];const e=280,s=[];let o=[],a=0;const i=1200;for(const C of r){const k=e*1.3333333333333333;o.push(C),a+=k,a>=i&&o.length>=2&&(s.push([...o]),o=[],a=0)}return o.length>0&&s.push(o),s},[r,d]);if(f||!r||r.length===0)return null;const w=(e,s,o="aspect-square")=>t.jsx("div",{className:`${o} cursor-pointer overflow-hidden rounded-card group`,onClick:()=>l(s),children:t.jsx("img",{src:e.url,alt:e.alt_text||"",className:"w-full h-full object-cover transition-transform duration-700 ease-out group-hover:scale-[1.03]",loading:"lazy",decoding:"async",sizes:"(max-width: 640px) 50vw, (max-width: 1024px) 33vw, 25vw"})},e.id),y=()=>t.jsx("div",{className:`grid ${v} gap-2`,children:r.map((e,s)=>w(e,s))}),b=()=>t.jsx("div",{className:"columns-2 md:columns-3 lg:columns-4 gap-2",children:r.map((e,s)=>t.jsx("div",{className:"mb-2 break-inside-avoid cursor-pointer overflow-hidden rounded-card group",onClick:()=>l(s),children:t.jsx("img",{src:e.url,alt:e.alt_text||"",className:"w-full h-auto object-cover transition-transform duration-700 ease-out group-hover:scale-[1.03]",loading:"lazy",decoding:"async",sizes:"(max-width: 640px) 50vw, (max-width: 1024px) 33vw, 25vw"})},e.id))}),N=()=>{let e=0;return t.jsx("div",{className:"space-y-2",children:j.map((s,o)=>t.jsx("div",{className:"flex gap-2",children:s.map(a=>{const i=e++;return t.jsx("div",{className:"flex-1 cursor-pointer overflow-hidden rounded-card group",style:{height:"280px"},onClick:()=>l(i),children:t.jsx("img",{src:a.url,alt:a.alt_text||"",className:"w-full h-full object-cover transition-transform duration-700 ease-out group-hover:scale-[1.03]",loading:"lazy",decoding:"async",sizes:"(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 33vw"})},a.id)})},o))})},z=()=>d==="masonry"?b():d==="justified"?N():y();return t.jsxs("div",{children:[x&&t.jsx("div",{className:"text-center mb-8",children:t.jsx("h2",{className:"font-display text-3xl md:text-4xl lg:text-5xl text-foreground",style:{fontFamily:g,fontSize:p},children:x})}),z(),t.jsx("div",{className:"flex justify-center mt-8",children:t.jsx(M,{asChild:!0,variant:"hotel",size:"lg",children:t.jsx(q,{to:"/galeria/",children:"Ver Mais"})})}),n!==null&&I.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[99999999] flex items-center justify-center",style:{backgroundColor:"#002d41"},onClick:()=>l(null),children:[t.jsx("button",{className:"absolute top-4 right-4 text-white text-3xl z-50",onClick:()=>l(null),children:"â"}),t.jsx("button",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-white text-4xl z-50",onClick:e=>{e.stopPropagation(),l((n-1+r.length)%r.length)},children:"â¹"}),t.jsx("img",{src:r[n].url,alt:r[n].alt_text||"",className:"max-h-[90vh] max-w-[90vw] object-contain rounded-feature",onClick:e=>e.stopPropagation()}),t.jsx("button",{className:"absolute right-4 top-1/2 -translate-y-1/2 text-white text-4xl z-50",onClick:e=>{e.stopPropagation(),l((n+1)%r.length)},children:"âº"})]}),document.body)]})};export{D 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.