1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-P0N1Je5T.js","assets/index-Hb747z0V.css"])))=>i.map(i=>d[i]); 2import{p as zr,G as ht,s as Y,r as s,j as e,E as Mr,a as ye,B as q,C as Xt,h as Or,i as $r,o as Jt,l as Qt,aP as gt,f as Et,a1 as Zt,I as lt,y as we,a7 as Xe,aQ as Gr,aR as Vr,A as er,aG as tr,aS as Ct,q as ft,n as Ur,J as at,t as He,P as ot,R as qr,X as rr,aj as sr,K as kt,g as nr,ab as xe,D as Br,b as Wr,d as Hr,e as Yr,m as Kr,aT as st,aU as Xr,N as Jr}from"./index-P0N1Je5T.js";import{u as Qr}from"./useTemplateCustomization-BeD0aLqa.js";import{b as Pt,a as Lt,u as ar,L as Tt,S as Rt,c as or}from"./useVideoPlaybackLogger-tNk5b0nL.js";import{C as it,a as ir}from"./CleanLightFooter-BtUoMxpU.js";import{g as lr}from"./useFanSession-CbNndObm.js";import{P as Zr}from"./phone-BEElgfE1.js";import{g as It,f as es}from"./internationalization-ClDqWLdo.js";import{C as ct}from"./calendar-D19SFwpy.js";import{M as cr}from"./map-pin-vvbH8j3Q.js";import{U as ts}from"./users-BWumBODg.js";import{D as rs}from"./dollar-sign-CqQMCX2l.js";import{A as ss}from"./arrow-right-DPBZU1JC.js";import{g as dt}from"./coverUrls-CgXMhAXv.js";import{S as ee}from"./skeleton-CeSviFvH.js";import{u as ns}from"./useInfiniteQuery-sM8iYSC7.js";import{a as as,u as os}from"./useViewport-C9YSnTxU.js";import{D as ut}from"./download-JbV5bimG.js";import{F as qt}from"./file-text-CCIhddT1.js";import{V as dr}from"./video-Cc9sN0SY.js";import{M as is}from"./music-S9wJf2WC.js";import{U as ur}from"./upload-kDtOV4MB.js";import{M as ls}from"./react-masonry-css.module-Dmt9rLSk.js";import{C as cs}from"./circle-alert-CrhXFnHf.js";import{s as ds,b as us,d as ms}from"./motionConfig-C2xmfZcV.js";import{I as vt}from"./instagram-CPlm1Z3D.js";import{F as hs}from"./index-ByRs6DhW.js";import{C as mr}from"./chevron-left-Cjx7fP8f.js";import{S as mt}from"./share-2-D2yJBwlq.js";import{A as hr}from"./index-DAgt0Pin.js";import{m as Ge}from"./proxy-D6BoR0p8.js";import{P as gs}from"./play-B168p-g_.js";import{I as fs}from"./image-off-CV_s2Uwh.js";import{a as gr}from"./index-fl9140bc.js";import"./label-CoHN_xq2.js";import"./input-1tKBwIjz.js";import{u as xs}from"./useCompanySlugAlias-CyJEsqsy.js";import"./useMutation-DJI0oEf-.js";import"./checkbox-wSZ1kz90.js";import"./user-CvuxPiRQ.js";import"./eye-BxqX1t91.js";import"./iconBase-BMvTZryz.js";import"./shotgun-icon-transparent-DGyBNJFr.js";import"./globe-Dl8HrUsL.js";import"./frame-D7tGqiwN.js";/** 3 * @license lucide-react v0.462.0 - ISC 4 * 5 * This source code is licensed under the ISC license. 6 * See the LICENSE file in the root directory of this source tree. 7 */const Bt=zr("Share",[["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["polyline",{points:"16 6 12 2 8 6",key:"m901s6"}],["line",{x1:"12",x2:"12",y1:"2",y2:"15",key:"1p0rca"}]]),nt={hidden:!0,theme:{},links:[],related:[],show_related:!1,show_upload_cta:!1};function ps(t){return ht({queryKey:["gallery-end-block",t],enabled:!!t,staleTime:6e4,retry:1,queryFn:async()=>{if(!t)return nt;const{data:n,error:a}=await Y.rpc("get_gallery_end_block",{p_gallery_id:t});if(a)return console.warn("[gallery-end-block] RPC failed, hiding block",a.message),nt;const u=n??nt;return{...nt,...u,theme:u.theme||{},links:Array.isArray(u.links)?u.links:[],related:Array.isArray(u.related)?u.related:[]}}})}function bs(){return{track:s.useCallback(async({companyId:n,galleryId:a,linkType:u,linkUrl:m})=>{try{await Y.functions.invoke("track-external-click",{body:{companyId:n,linkType:u,linkUrl:m,userSessionId:lr(),galleryId:a}})}catch(c){console.warn("[gallery-end-block] click tracking failed",c)}},[])}}function vs(t){const n=t||{},a={};return n.accent&&(a["--geb-accent"]=n.accent),n.accentForeground&&(a["--geb-accent-foreground"]=n.accentForeground),n.surface&&(a["--geb-surface"]=n.surface),n.text&&(a["--geb-text"]=n.text),n.muted&&(a["--geb-muted"]=n.muted),n.border&&(a["--geb-border"]=n.border),n.radius&&(a["--geb-radius"]=n.radius),n.fontFamily&&(a["--geb-font"]=n.fontFamily),a}function ws({galleries:t,heading:n,companySlug:a,onSelect:u}){const{t:m,locale:c}=gr();if(t.length===0)return null;const x=d=>{if(!d)return null;try{return new Date(d).toLocaleDateString(c==="en"?"en-GB":c,{day:"2-digit",month:"short",year:"numeric"})}catch{return null}};return e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",style:{color:"var(--geb-text, hsl(var(--foreground)))"},children:n}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:t.map(d=>
7{const b=dt(d.cover_image_url),k=`/${a}/highlights/${d.slug}`,N=x(d.date);return e.jsxs("a",{href:k,onClick:y=>{y.preventDefault(),u(d,k)},className:"group block overflow-hidden border transition-colors",style:{borderColor:"var(--geb-border, hsl(var(--border)))",borderRadius:"var(--geb-radius, 0px)",backgroundColor:"var(--geb-surface, transparent)"},children:[e.jsx("div",{className:"aspect-[4/3] w-full overflow-hidden bg-muted",children:e.jsx("img",{src:b.thumbnail,alt:d.title,loading:"lazy",decoding:"async",className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.03]"})}),e.jsxs("div",{className:"p-3 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",style:{color:"var(--geb-text, hsl(var(--foreground)))"},children:d.title}),e.jsx("p",{className:"text-xs truncate",style:{color:"var(--geb-muted, hsl(var(--muted-foreground)))"},children:[N,d.location,d.item_count===1?m("oneItem"):m("items",{count:d.item_count})].filter(Boolean).join(" ⢠")})]})]},d.id)})})]})}function ys({links:t,onSelect:n}){return t.length===0?null:e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(a=>e.jsxs("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>n(a),className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium transition-opacity hover:opacity-90",style:{backgroundColor:"var(--geb-accent, hsl(var(--primary)))",color:"var(--geb-accent-foreground, hsl(var(--primary-foreground)))",borderRadius:"var(--geb-radius, 0px)"},children:[e.jsx("span",{className:"truncate max-w-[16rem]",children:a.label}),e.jsx(Mr,{className:"h-4 w-4 flex-shrink-0"})]},a.id))})}function js({galleryId:t,companyId:n,companyName:a,companySlug:u,gallerySlug:m,fanUploadEnabled:c=!1,className:x}){var R,E;const{data:d,isLoading:b}=ps(t),{track:k}=bs(),{t:N}=gr();if(b||!d||d.hidden)return null;const y=((E=(R=d.theme)==null?void 0:R.partnerLabel)==null?void 0:E.trim())||a,l=d.show_related&&d.related.length>0,o=d.links.length>0,f=d.show_upload_cta&&c&&!!m;if(!l&&!o&&!f)return null;const S=m?`/${u}/highlights/${m}/upload`:null;return e.jsx("section",{"data-module":"gallery-end-block",className:x,style:{...vs(d.theme),fontFamily:"var(--geb-font, inherit)",backgroundColor:"var(--geb-surface, transparent)"},children:e.jsxs("div",{className:"border-t pt-8 mt-10 space-y-8",style:{borderColor:"var(--geb-border, hsl(var(--border)))"},children:[l&&e.jsx(ws,{galleries:d.related,companySlug:u,heading:N("moreFrom",{partner:y}),onSelect:(G,V)=>{k({companyId:n,galleryId:t||void 0,linkType:"gallery_end_related",linkUrl:V}),window.location.href=V}}),f&&S&&e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 border p-5",style:{borderColor:"var(--geb-border, hsl(var(--border)))",borderRadius:"var(--geb-radius, 0px)"},children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-base font-semibold",style:{color:"var(--geb-text, hsl(var(--foreground)))"},children:N("uploadCta")}),e.jsx("p",{className:"text-sm",style:{color:"var(--geb-muted, hsl(var(--muted-foreground)))"},children:N("uploadCtaDescription")})]}),e.jsxs("a",{href:S,className:"inline-flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium transition-opacity hover:opacity-90",style:{backgroundColor:"var(--geb-accent, hsl(var(--primary)))",color:"var(--geb-accent-foreground, hsl(var(--primary-foreground)))",borderRadius:"var(--geb-radius, 0px)"},children:[e.jsx(ur,{className:"h-4 w-4"}),N("upload")]})]}),o&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",style:{color:"var(--geb-text, hsl(var(--foreground)))"},children:N("links")}),e.jsx(ys,{links:d.links,onSelect:G=>void k({companyId:n,galleryId:t||void 0,linkType:"gallery_end_cta",linkUrl:G.url})})]})]})})}const fr=()=>({trackExternalClick:s.useCallback(async n=>{try{const a=n.userSessionId||lr();console.log("ð Tracking external link click:",{type:n.linkType,url:n.linkUrl,company:n.companyId});const{data:u,error:m}=await Y.functions.invoke("track-external-click",{body:{companyId:n.companyId,linkType:n.linkType,linkUrl:n.linkUrl,userSessionId:a,galleryId:n.galleryId,galleryItemId:n.galleryItemId}});return m?(console.error("â Error tracking external link click:",m),!1):(console.log("â
External link click tracked successfully:",u),!0)}catch(a){return console.error("ð¥ Fatal error in trackExternalClick:",a),!1}},[])}),_s=({company:t})=>{var d,b,k,N;const{t:n,language:a}=ye(),{trackExternalClick:u}=fr(),m=((d=t.promotion_url)==null?void 0:d.trim())&&((b=t.promotion_button_title)==null?void 0:b.trim()),c=((k=t.calendar_url)==null?void 0:k.trim())&&((N=t.calendar_button_title)==null?void 0:N.trim()),x=async(y,l)=>{await u({companyId:t.id,linkType:y,linkUrl:l})};return e.jsxs("section",{className:"text-center pt-8",children:[t.logo_url&&e.jsx("div",{className:"mb-8",children:e.jsx("img",{src:t.logo_url,alt:t.name,className:"h-36 w-auto object-contain mx-auto"})}),(t.landing_page_description||t.description)&&e.jsx("p",{className:"text-base text-muted-foreground max-w-2xl mx-auto mb-8 leading-relaxed px-[5px] sm:px-0",children:(()=>
7{if(typeof t.landing_page_description=="object"&&t.landing_page_description){const y=t.landing_page_description;return y[a]||y.en||t.description||""}return t.landing_page_description||t.description||""})()}),m||c?e.jsxs("div",{className:"flex flex-col sm:flex-row justify-center gap-4 mb-6",children:[m&&e.jsx(q,{size:"lg",variant:"outline",className:"w-full sm:w-64 px-5 bg-transparent border-black hover:bg-black hover:text-white",asChild:!0,children:e.jsx("a",{href:t.promotion_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>x("promotion_url",t.promotion_url),children:t.promotion_button_title})}),c&&e.jsx(q,{size:"lg",variant:"outline",className:"w-full sm:w-64 px-5 bg-transparent border-black hover:bg-black hover:text-white",asChild:!0,children:e.jsx("a",{href:t.calendar_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>x("calendar",t.calendar_url),children:t.calendar_button_title})})]}):null,e.jsx("div",{className:"flex flex-wrap justify-center gap-4 mt-6",children:t.whatsapp_url&&e.jsx(q,{size:"lg",className:"bg-green-600 hover:bg-green-700 text-white",asChild:!0,children:e.jsxs("a",{href:t.whatsapp_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>x("whatsapp",t.whatsapp_url),children:[e.jsx(Zr,{className:"mr-2 h-4 w-4"}),n("landingPage.contact.whatsapp")]})})})]})},Ns=({events:t,companySlug:n})=>{const{t:a,language:u}=ye(),m=d=>{if(!d)return"";const b=It(u);return new Date(d).toLocaleDateString(b,{day:"2-digit",month:"long",year:"numeric"})},c=d=>d?es(d,u,"BRL"):a("landingPage.events.free"),x=d=>{d.slug&&(window.location.href=`/${n}/evento/${d.slug}`)};return t.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(ct,{className:"h-16 w-16 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:a("landingPage.events.noEvents")}),e.jsx("p",{className:"text-muted-foreground",children:a("landingPage.events.noEvents")})]}):e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-3xl font-bold mb-4",children:a("landingPage.events.title")}),e.jsx("p",{className:"text-muted-foreground max-w-2xl mx-auto",children:a("landingPage.events.subtitle")})]}),e.jsx("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:t.map(d=>e.jsxs(Xt,{className:"overflow-hidden hover:shadow-lg transition-shadow",children:[d.banner_url&&e.jsx("div",{className:"aspect-video overflow-hidden",children:e.jsx("img",{src:d.banner_url,alt:d.name,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})}),e.jsxs(Or,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx($r,{className:"text-xl leading-tight",children:d.name}),e.jsx(Jt,{variant:"default",children:a("landingPage.events.active")})]}),d.description&&e.jsx("p",{className:"text-muted-foreground text-sm line-clamp-2",children:d.description})]}),e.jsxs(Qt,{className:"space-y-4",children:[d.event_date&&e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(ct,{className:"h-4 w-4 mr-2"}),e.jsx("span",{children:m(d.event_date)})]}),d.location&&e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(cr,{className:"h-4 w-4 mr-2"}),e.jsx("span",{children:d.location})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[d.max_participants&&e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(ts,{className:"h-4 w-4 mr-1"}),e.jsxs("span",{children:[d.max_participants," ",a("landingPage.events.spots")]})]}),e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(rs,{className:"h-4 w-4 mr-1"}),e.jsx("span",{children:c(d.price)})]})]}),e.jsxs(q,{onClick:()=>x(d),className:"w-full",size:"lg",children:[a("landingPage.events.viewEvent"),e.jsx(ss,{className:"h-4 w-4 ml-2"})]})]})]},d.id))})]})},Ie=["thumbnail","medium","large","original"],ks=({galleries:t,companySlug:n,hasMore:a=!0,loadingMore:u=!1,onLoadMore:m})=>{const{t:c,language:x}=ye(),[d,b]=s.useState({}),[k,N]=s.useState({}),[y,l]=s.useState(()=>{const i=new Set;
7return t.slice(0,6).forEach(_=>i.add(_.id)),i}),o=s.useRef(!1),f=s.useRef(null),S=s.useRef(new Map),R=s.useRef(null),E=s.useRef(new Set),G=s.useRef(new Set),V=gt(),oe=s.useCallback(i=>_=>{_&&(S.current.set(i,_),f.current&&f.current.observe(_))},[]);s.useEffect(()=>{const i=new IntersectionObserver(_=>{_.forEach($=>{if($.isIntersecting){const T=$.target.getAttribute("data-gallery-id");T&&(l(W=>new Set([...W,T])),i.unobserve($.target))}})},{rootMargin:"600px",threshold:0});return f.current=i,S.current.forEach(_=>{i.observe(_)}),V&&console.log(`[GalleryGrid] ðï¸ Observer created, observing ${S.current.size} pre-mounted elements`),()=>i.disconnect()},[]),s.useEffect(()=>{if(t.length>0&&y.size===0){const i=new Set;t.slice(0,6).forEach(_=>i.add(_.id)),l(i),V&&console.log(`[GalleryGrid] ð Pre-marked ${i.size} galleries as visible (fail-safe)`)}},[t,V]),s.useEffect(()=>{if(!a||!m)return;const i=R.current;if(!i)return;const _=new IntersectionObserver($=>{$[0].isIntersecting&&!u&&(V&&console.log("[InfiniteScroll] Sentinel triggered, loading more..."),m())},{rootMargin:"400px"});return _.observe(i),()=>_.disconnect()},[a,u,m]);const O=Et(),L=Zt(),Q=s.useRef(new Set),re=s.useCallback(i=>{!(i!=null&&i.id)||Q.current.has(i.id)||(Q.current.add(i.id),L.prefetchQuery({queryKey:["gallery-items",i.id],staleTime:6e4,queryFn:async()=>{const{data:_,error:$}=await Y.from("gallery_items").select("*").eq("gallery_id",i.id).order("sort_order",{ascending:!0});if($)throw $;return _||[]}}))},[L]),C=i=>{i.slug&&(L.setQueryData(["gallery",i.company_id,i.slug],i),re(i),O(`/${n}/highlights/${i.slug}`))},F=i=>i?new Date(i).toLocaleDateString(It(x),{year:"numeric",month:"long",day:"numeric"}):"",H=i=>{const _=dt(i.cover_image_url),$=d[i.id]??0;if($>=Ie.length)return"/placeholder.svg";const T=Ie[$],W=_[T];return $===0&&V&&!E.current.has(i.id)&&(E.current.add(i.id),console.log(`[GalleryGrid] ð¼ï¸ Loading "${i.title}" (${i.id.slice(0,8)}...)`,` 8 â Requesting: ${T}`,` 9 â URL: ...${W.slice(-60)}`)),W==="/placeholder.svg"&&$<Ie.length-1?_[Ie[$+1]]||"/placeholder.svg":W},M=async(i,_,$,T)=>{if(!G.current.has(i.id)){G.current.add(i.id);try{let W=sessionStorage.getItem("fallbackSessionId");W||(W=crypto.randomUUID(),sessionStorage.setItem("fallbackSessionId",W));const{getEnvironmentForLogging:te}=await Xe(async()=>{const{getEnvironmentForLogging:se}=await import("./index-P0N1Je5T.js").then(je=>je.c3);return{getEnvironmentForLogging:se}},__vite__mapDeps([0,1]));await Y.from("image_fallback_logs").insert({failed_url:dt(i.cover_image_url).thumbnail||null,failed_version:_,successful_version:$,company_id:i.company_id,gallery_id:i.id,gallery_title:i.title,fallback_count:T,environment:te()})}catch(W){V&&console.warn("[FallbackLog] Failed to log:",W)}}},K=i=>{const _=d[i.id]??0,$=Ie[_]||"thumbnail";if(N(T=>({...T,[i.id]:$})),_>0){const T=Ie[0];M(i,T,$,_)}V&&console.log(`[GalleryGrid] ${_===0?"â ":"ð"} Loaded "${i.title}":`,`version=${$}`,_>0?`(after ${_} fallback${_>1?"s":""})`:"(first try)")},B=(i,_)=>{const $=d[i]??0,T=$+1;if(V){const W=t.find(te=>te.id===i);console.warn(`[GalleryGrid] â Failed "${(W==null?void 0:W.title)||i}":`,` 10 â Failed version: ${Ie[$]}`,` 11 â Failed URL: ...${_.slice(-80)}`,T<Ie.length?` 12 â Next attempt: ${Ie[T]}`:` 13 â â ï¸ All versions exhausted, using placeholder`)}b(W=>({...W,[i]:T}))};s.useEffect(()=>{const i=t.filter(T=>T.cover_image_url),_=Object.keys(k).length,$=i.length;if(_===$&&!o.current&&_>0){o.current=!0;const T=Object.values(k).reduce((te,se)=>(te[se]=(te[se]||0)+1,te),{}),W=Object.keys(d).length;V&&console.log("[GalleryGrid] ð Loading Summary:",` 14 â Total galleries: ${_}`,` 15 â Versions used:`,T,W>0?` 16 â Fallbacks triggered: ${W} (${(W/_*100).toFixed(1)}%)`:` 17 â No fallbacks needed â¨`)}},[k,t,d,V]);const ie=()=>e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-muted/50 to-muted flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(lt,{className:"h-12 w-12 text-muted-foreground mx-auto mb-2"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Galeria"})]})});if(t.length===0)return e.jsxs("div",{className:"text-center py-16",children:[e.jsx(lt,{className:"h-16 w-16 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:c("landingPage.galleries.noGalleries")}),e.jsx("p",{className:"text-muted-foreground",children:c("landingPage.galleries.noGalleriesDesc")})]});const ne=t.length===1,ge=t.length===2,D=ne?"grid gap-8":ge?"grid gap-8 md:grid-cols-2":"grid gap-8 md:grid-cols-2 lg:grid-cols-3";return e.jsxs("div",{className:"space-y-8 mb-20",children:[e.jsx("div",{className:"text-center"}),e.jsx("div",{className:D,children:t.map((i,_)=>{const $=y.has(i.id),T=$?H(i):"",W=T==="/placeholder.svg",te=!!k[i.id];return e.jsxs("div",{className:we("group cursor-pointer",ne&&"mx-auto w-full max-w-[760px]"),onClick:()=>C(i),onMouseEnter:()=>re(i),onTouchStart:()=>re(i),children:[e.jsx("div",{ref:oe(i.id),"data-gallery-id":i.id,className:"relative aspect-[3/2] mb-4 rounded overflow-hidden",children:$?W?ie():e.jsxs(e.Fragment,{children:[e.jsx("img",{src:T,alt:i.title,className:we("w-full h-full object-cover transition-opacity duration-300",te?"opacity-100":"opacity-0"),loading:_<4?"eager":"lazy",fetchPriority:_<4?"high":"auto",decoding:"async",onLoad:()=>K(i),onError:se=>B(i.id,se.target.src)}),!te&&e.jsx("div",{className:we("absolute inset-0 animate-pulse bg-gradient-to-br",_%3===0?"from-zinc-800 to-zinc-900":_%3===1?"from-slate-800 to-slate-900":"from-neutral-800 to-neutral-900")}),e.jsx("div",{className:"absolute inset-0 bg-white/0 group-hover:bg-white/20 transition-colors duration-300"})]}):e.jsx("div",{className:we("w-full h-full animate-pulse bg-gradient-to-br",_%3===0?"from-zinc-800 to-zinc-900":_%3===1?"from-slate-800 to-slate-900":"from-neutral-800 to-neutral-900")})}),e.jsxs("div",{className:"text-center space-y-0.5",children:[e.jsx("h3",{className:"text-lg md:text-xl font-semibold group-hover:text-primary transition-colors",children:i.title}),(i.location||i.date)&&e.jsx("div",{className:"text-sm text-muted-foreground",children:i.location&&i.date?e.jsxs("span",{children:[i.location," ⢠",F(i.date)]}):i.location?e.jsx("span",{children:i.location}):e.jsx("span",{children:F(i.date)})})]})]},i.id)})}),a&&e.jsx("div",{ref:R,className:"h-1","aria-hidden":"true"}),u&&e.jsx("div",{className:"grid gap-8 md:grid-cols-2 lg:grid-cols-3",children:[...Array(6)].map((i,_)=>e.jsxs("div",{className:"space-y-4",children:[e.jsx(ee,{className:"aspect-[3/2] w-full rounded"}),e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx(ee,{className:"h-6 w-3/4"}),e.jsx(ee,{className:"h-4 w-1/2"})]})]},`skeleton-${_}`))})]})};let We=null,Wt=!1;const Dt=()=>{if(We)return We;const t=Gr(),n=Vr();return Wt||(console.log(`ðï¸ [CACHE CONFIG] Environment: ${n}, Aggressive cache: ${t}`),Wt=!0),t?(We={company:{staleTime:5*60*1e3,gcTime:30*60*1e3},galleries:{staleTime:2*60*1e3,gcTime:10*60*1e3},customization:{staleTime:5*60*1e3,gcTime:15*60*1e3}},We):(We={company:{staleTime:0,gcTime:6e4},galleries:{staleTime:0,gcTime:6e4},customization:{staleTime:0,gcTime:6e4}},We)},Ss=({companyId:t,sortOrder:n="created_desc",itemsPerPage:a=12,enabled:u=!0})=>{const m=Dt();let c="created_at",x=!1;return n==="gallery_date"||n==="event_date"?(c="date",x=!1):n==="created_asc"&&(c="created_at",x=!0),ns({queryKey:["galleries-public",t,n],queryFn:async({pageParam:d=1})=>{if(!t)return{galleries:[],total:0,page:1,hasMore:!1};const b=(d-1)*a;let k=0;if(d===1){const{count:o}=await Y.from("galleries").select("*",{count:"exact",head:!0}).eq("company_id",t).eq("status","published").eq("visibility","public");k=o||0}const{data:N,error:y}=await Y.from("galleries").select("*").eq("company_id",t).eq("status","published").eq("visibility","public").order(c,{ascending:x,nullsFirst:!1}).range(b,b+a-1);if(y)throw y;const l=N||[];return b+l.length,{galleries:l,total:d===1?k:0,page:d,hasMore:l.length===a}},getNextPageParam:d=>d.hasMore?d.page+1:void 0,initialPageParam:1,enabled:u&&!!t,...m.galleries})},Es=t=>{if(!t||!Array.isArray(t))return[];try{return t.flatMap(n=>!n||!Array.isArray(n.galleries)?[]:n.galleries)}catch(n){return console.error("[flattenGalleries] Error:",n),[]}},Cs=t=>{var n;if(!t||!Array.isArray(t)||t.length===0)return 0;try{return((n=t[0])==null?void 0:n.total)??0}catch(a){return console.error("[getTotalGalleries] Error:",a),0}},Ps=({company:t,customization:n})=>{console.log("[CleanLightTemplate] Rendering with company:",t==null?void 0:t.id);const{t:a}=ye(),[u,m]=s.useState([]),[c,x]=s.useState(!1),[d,b]=s.useState(!1),{applyCustomization:k}=Qr(t.id),{trackPageView:N}=Pt(),y=t.id,l=t.landing_page_display_mode||"galleries",o=t.gallery_sort_order||"gallery_date",f=t.google_analytics_id,S=t.analytics_enabled,R=t.slug,{data:E,isLoading:G,fetchNextPage:V,hasNextPage:oe,isFetchingNextPage:O,error:L}=Ss({companyId:y,sortOrder:o,enabled:l!=="events"});s.useEffect(()=>{L&&console.error("[CleanLightTemplate] Galleries query error:",L)},[L]);const Q=s.useMemo(()=>{try{return E!=null&&E.pages?Es(E.pages):[]}catch(M){return console.error("[CleanLightTemplate] Error processing galleries:",M),[]}},[E==null?void 0:E.pages]);s.useMemo(()=>{try{return E!=null&&E.pages?Cs(E.pages):0}catch(M){return console.error("[CleanLightTemplate] Error getting total:",M),0}},[E==null?void 0:E.pages]);const re=async()=>{try{x(!0),console.log("Fetching events for company:",t.id);const{data:M,error:K}=await Y.from("events").select("id, name, description, banner_url, slug, event_date, location, max_participants, price").eq("company_id",t.id).eq("status","published").eq("allow_public_access",!0).order("event_date",{ascending:!0});if(K){console.error("Error fetching events:",K);return}console.log("Events fetched:",(M==null?void 0:M.length)||0);const B=(M==null?void 0:M.map(ne=>({...ne,content:[]})))||[],{data:ie}=await Y.from("content").select("id").eq("company_id",t.id).is("event_id",null).eq("status","published").limit(1);ie&&ie.length>0&&B.unshift({id:"general",name:a("landingPage.events.generalResources")||"General Resources",description:a("landingPage.events.generalResourcesDesc")||"Company materials and content",slug:"recursos-gerais",content:[]}),m(B)}catch(M){console.error("Error fetching events:",M)}finally{x(!1)}},C=()=>{oe&&!O&&V()};s.useEffect(()=>{l==="events"&&re(),N(y).catch(M=>{console.error("[PAGE VIEW] Track error:",M)})},[y,l]),s.useEffect(()=>{n&&k(n)},[n]),s.useEffect(()=>{if(!y)return;const M=()=>{const B=(()=>{try{const ie=localStorage.getItem("cookie-preferences");if(ie)return JSON.parse(ie).analytics===!0}catch{return!1}return!1})();Ct({companyGaId:f,companyAnalyticsEnabled:S,landingPageName:R}).then(()=>{B&&window.__forcePageView&&window.__forcePageView()}).catch(ie=>{console.error("[CleanLightTemplate] Failed to initialize analytics:",ie)})};"requestIdleCallback"in window?window.requestIdleCallback(M,{timeout:2e3}
17):setTimeout(M,100)},[y,f,S,R]);const F=l==="events"?c:G;if(s.useEffect(()=>{if(!F||Q.length>0||u.length>0){b(!1);return}const M=setTimeout(()=>{console.warn("[CleanLightTemplate] Loading timeout (5s) - forcing render"),b(!0)},5e3);return()=>clearTimeout(M)},[F,Q.length,u.length]),F&&!d&&Q.length===0&&u.length===0)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center",children:[e.jsx(er,{size:48,className:"mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:a("landingPage.loading")})]})});const H=t.slug||"empresa";return e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-background via-background to-muted/20 template-clean-light",children:[e.jsx(it,{company:t}),e.jsxs("main",{className:"container mx-auto px-4 py-8",children:[e.jsx(_s,{company:t}),e.jsx("div",{className:"flex justify-center mt-[30px] mb-16",children:e.jsx(tr,{className:"w-24 bg-muted-foreground/30"})}),e.jsx("div",{children:l==="events"?e.jsx(Ns,{events:u,companySlug:H}):e.jsx(ks,{galleries:Q,companySlug:H,hasMore:!!oe,loadingMore:O,onLoadMore:C})})]}),e.jsx(ir,{companyName:t.name,companySlug:H,companyId:t.id})]})},xr=(t={})=>{const{delay:n=1e3,maxCalls:a=3,windowMs:u=3e4}=t,[m,c]=s.useState({}),x=s.useRef({}),d=s.useCallback(l=>{const o=Date.now(),f=m[l];if(!f)return!0;if(f.isDownloading){const R=n+5e3;return o-f.lastDownloadTime>R?(c(E=>{const G=E[l];return G?{...E,[l]:{...G,isDownloading:!1}}:E}),!0):(console.log("Download already in progress for:",l),!1)}if(f.blockedUntil>o)return console.log("Download blocked until:",new Date(f.blockedUntil).toLocaleTimeString()),!1;const S=o-u;return f.lastDownloadTime>S&&f.downloadCount>=a?(console.log("Rate limit exceeded for:",l),!1):!0},[m,a,u]),b=s.useCallback((l,o)=>{const f=Date.now();return d(l)?(x.current[l]&&clearTimeout(x.current[l]),c(S=>{const R=S[l]||{isDownloading:!1,downloadCount:0,lastDownloadTime:0,blockedUntil:0},E=f-u,G=R.lastDownloadTime>E?R.downloadCount+1:1;return{...S,[l]:{isDownloading:!0,downloadCount:G,lastDownloadTime:f,blockedUntil:G>=a?f+u:0}}}),new Promise((S,R)=>{x.current[l]=setTimeout(async()=>{try{await o(),S()}catch(E){R(E)}finally{c(E=>({...E,[l]:{...E[l],isDownloading:!1}})),delete x.current[l]}},n)})):Promise.reject(new Error("Download not allowed - rate limited or in progress"))},[n,d,a,u]),k=s.useCallback(l=>m[l]||{isDownloading:!1,downloadCount:0,lastDownloadTime:0,blockedUntil:0},[m]),N=s.useCallback(l=>{x.current[l]&&(clearTimeout(x.current[l]),delete x.current[l]),c(o=>{const f={...o};return delete f[l],f})},[]),y=s.useCallback(()=>{Object.values(x.current).forEach(l=>{clearTimeout(l)}),x.current={}},[]);return{debouncedDownload:b,isDownloadAllowed:d,getDownloadState:k,resetDownloadState:N,cleanup:y}},Ls=({content:t,companyId:n,eventId:a,companyLandingPageName:u})=>{var ne,ge;const[m,c]=s.useState(!1),[x,d]=s.useState(!1),[b,k]=s.useState(!1),{company:N}=ft(),{session:y,saveSession:l,isSessionValid:o}=Lt(n),{debouncedDownload:f,isDownloadAllowed:S,getDownloadState:R}=xr({delay:1e3,maxCalls:3,windowMs:3e4}),{toast:E}=Ur(),{invalidateDownloads:G}=ar(),V=Et(),oe=as(),{t:O}=ye(),L=()=>{var D,i;return((D=t.file_type)==null?void 0:D.startsWith("image/"))||((i=t.file_type)==null?void 0:i.startsWith("video/"))},Q=()=>"share"in navigator,C=t.file_type?t.file_type.startsWith("image/")?lt:t.file_type.startsWith("video/")?dr:t.file_type.startsWith("audio/")?is:qt:qt,F=async D=>{if(D&&(D.preventDefault(),D.stopPropagation()),!!t.file_url){if(!S(t.id)){R(t.id).isDownloading?E({title:"Download em andamento",description:"Aguarde o download atual terminar antes de iniciar outro.",variant:"destructive"}):E({title:"Muitos downloads",description:"Aguarde um pouco antes de baixar novamente.",variant:"destructive"});return}try{await f(t.id,async()=>{!t.require_lead||o()?await H():c(!0)})}catch(i){console.error("Download debounce error:",i)}}},H=async D=>{k(!0);try{const i=D||y&&{email:y.email,first_name:y.first_name,last_name:y.last_name,marketing_consent:y.marketing_consent},_={contentId:t.id,companyId:n,eventId:a||null,email:(i==null?void 0:i.email)||"[email protected]",first_name:i==null?void 0:i.first_name,last_name:i==null?void 0:i.last_name,consent_given:D?!!D.consent_given:void 0,privacy_policy_accepted:D?!!D.privacy_policy_accepted:void 0,marketing_consent:D?!!D.marketing_consent:i==null?void 0:i.marketing_consent,fan_session_id:(()=>{try{const W=localStorage.getItem("fan_session");return W?JSON.parse(W).id:null}catch{return null}})()},{data:$,error:T}=await Y.functions.invoke("capture-lead",{body:_});if(T)throw console.error("Error calling capture-lead function:",T),T;if(!$.success)throw new Error($.error||"Erro na captura de lead");D&&l(D.email,{first_name:D.first_name,last_name:D.last_name,marketing_consent:!!D.marketing_consent}),$.accessToken?await M($.accessToken):await M()}catch(i){console.error("Error processing download:",i),E({title:O("download.generalError"),description:O("download.generalErrorDesc"),variant:"destructive"})}finally{k(!1)}},M=async D=>{try{if(!t.file_url)throw new Error("URL do arquivo não disponÃvel");const{data:i,error:_}=await Y.functions.invoke("download-file",{body:{contentId:t.id,companyId:n,accessToken:D||null}});if(_||!(i!=null&&i.downloadUrl))throw new Error((_==null?void 0:_.message)||"Failed to get download URL");window.location.href=i.downloadUrl,G(),E({title:O("download.started"),description:O("download.success").replace("{title}",t.title||"file")})}catch(i){throw console.error("Direct download failed:",i),E({title:O("download.generalError"),description:O("download.generalErrorDesc"),variant:"destructive"}),i}},K=()=>{var D;
17t.file_url&&((D=t.file_type)!=null&&D.startsWith("video/")?V(`/player/${t.id}`):window.open(t.file_url,"_blank"))},B=D=>{D.preventDefault(),D.stopPropagation(),d(!0)},ie=()=>window.location.href;return e.jsx(Xt,{className:"group hover:shadow-lg transition-all duration-300 hover:-translate-y-1 bg-card border-border/50 cursor-pointer",onClick:K,children:e.jsxs(Qt,{className:"p-0",children:[e.jsxs("div",{className:"aspect-video bg-muted rounded-t-lg flex items-center justify-center overflow-hidden relative",children:[t.thumbnail_url?e.jsx("img",{src:t.thumbnail_url,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",loading:"lazy"}):t.file_url&&((ne=t.file_type)!=null&&ne.startsWith("image/"))?e.jsx("img",{src:t.file_url,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",loading:"lazy"}):e.jsx(C,{size:48,className:"text-muted-foreground"}),((ge=t.file_type)==null?void 0:ge.startsWith("video/"))&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:e.jsx(q,{size:"icon",variant:"secondary",className:"h-12 w-12 bg-black/60 hover:bg-black/80 border-0 backdrop-blur-sm rounded-full pointer-events-auto",onClick:D=>{D.stopPropagation(),K()},disabled:!t.file_url,children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",className:"text-white ml-1",children:e.jsx("polygon",{points:"5,3 19,12 5,21",fill:"currentColor"})})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-foreground mb-2 line-clamp-2",children:t.title}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-4 line-clamp-2",children:t.description}),t.category&&e.jsx("div",{className:"mb-4",children:e.jsx("span",{className:"inline-block px-2 py-1 text-xs font-medium bg-primary/10 text-primary rounded-full",children:t.category})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(q,{size:"sm",className:"flex-1",onClick:F,disabled:!t.file_url||b||!S(t.id),children:b?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),O("contentCard.processing")]}):e.jsxs(e.Fragment,{children:[oe&&L()&&Q()?e.jsx(Bt,{size:16,className:"mr-2"}):e.jsx(ut,{size:16,className:"mr-2"}),oe&&L()?Q()?O("contentCard.saveToGallery"):O("contentCard.saveMedia"):(t.require_lead&&!o(),O("contentCard.download"))]})}),e.jsx(q,{size:"sm",variant:"outline",onClick:B,className:"px-3",children:e.jsx(Bt,{size:16})})]}),e.jsx(Tt,{isOpen:m,onClose:()=>c(!1),contentTitle:t.title,onSubmit:async D=>{await H(D),c(!1)},isLoading:b,companyName:N==null?void 0:N.name,companySlug:N==null?void 0:N.slug}),e.jsx(Rt,{isOpen:x,onClose:()=>d(!1),url:ie(),title:`Share: ${t.title}`,description:"Copy the link to share this content with others",contentId:t.id,companyId:n,galleryId:t.gallery_id})]})]})})},Ts=({company:t,eventSlug:n,companySlug:a})=>{const{t:u,language:m}=ye(),[c,x]=s.useState(null),[d,b]=s.useState([]),[k,N]=s.useState(!0);Et(),s.useEffect(()=>{y()},[n,t.id]),s.useEffect(()=>{t&&Ct({companyGaId:t.google_analytics_id,companyAnalyticsEnabled:t.analytics_enabled,landingPageName:t.slug}).catch(f=>{console.error("[CleanLightEventPage] Failed to initialize analytics:",f)})},[t,t.google_analytics_id,t.slug,t.analytics_enabled]);const y=async()=>{try{if(n==="recursos-gerais"){const{data:G,error:V}=await Y.from("content").select("*").eq("company_id",t.id).is("event_id",null).eq("status","published").order("created_at",{ascending:!1});if(V){console.error("Error fetching general content:",V),at.error(u("landingPage.eventPage.contentNotFoundDesc"));return}x({id:"general",name:u("landingPage.events.generalResources"),description:u("landingPage.events.generalResourcesDesc"),event_date:new Date().toISOString().split("T")[0],status:"published",slug:"recursos-gerais"}),b(G||[]),N(!1);return}const{data:f,error:S}=await Y.from("events").select("*").eq("slug",n).eq("company_id",t.id).eq("status","published").eq("allow_public_access",!0).maybeSingle();if(S){console.error("Error fetching event:",S),at.error(u("landingPage.eventPage.eventNotFoundDesc"));return}if(!f){at.error(u("landingPage.eventPage.eventNotFoundDesc"));return}x(f);const{data:R,error:E}=await Y.from("content").select("*").eq("event_id",f.id).eq("status","published").order("created_at",{ascending:!1});E?console.error("Error fetching content:",E):b(R||[])}catch(f){console.error("Error:",f)}finally{N(!1)}},l=f=>{const S={pt:"pt-BR",en:"en-US",es:"es-ES",fr:"fr-FR"};return new Date(f).toLocaleDateString(S[m]||"pt-BR",{day:"2-digit",month:"long",year:"numeric"})},o=()=>{window.location.href=`/${a}`};return k?e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-background via-background to-muted/20",children:[e.jsx(it,{company:t}),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(er,{size:48})})})]}):c?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(it,{company:t}),e.jsxs("div",{className:"relative w-full h-screen flex items-center justify-center overflow-hidden",children:[c.banner_url?e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("img",{src:c.banner_url,alt:c.name,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/40"})]}):e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-primary/20 via-primary/10 to-background"}),e.jsxs("div",{className:"relative z-10 text-center text-white px-4",children:[e.jsx("h1",{className:"text-4xl md:text-6xl lg:text-7xl font-bold mb-4 tracking-wider",children:c.name.toUpperCase()}),c.id!=="general"&&e.jsxs("div",{className:"space-y-2 mb-8",children:[e.jsx("p",{className:"text-lg md:text-xl font-medium tracking-wide",children:l(c.event_date)}),c.location&&e.jsx("p",{className:"text-base md:text-lg opacity-90",children:c.location})]}),e.jsx(q,{variant:"outline",size:"lg",className:"bg-white/10 text-white border-white/20 hover:bg-white/20 backdrop-blur-sm",onClick:()=>{const f=document.getElementById("content-section");f==null||f.scrollIntoView({behavior:"smooth"})},children:u("landingPage.eventPage.viewGallery")})]}),e.jsxs(q,{variant:"ghost",onClick:o,className:"absolute top-20 left-4 text-white hover:bg-white/10 z-20",children:[e.jsx(He,{className:"h-4 w-4 mr-2"}),u("landingPage.eventPage.back")]})]}),e.jsxs("div",{id:"content-section",className:"container mx-auto px-4 py-16",children:[d.length>0&&e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-3xl font-bold mb-2",children:c.id==="general"?u("landingPage.eventPage.availableContent"):u("landingPage.eventPage.eventGallery")}),e.jsx("p",{className:"text-muted-foreground",children:u("landingPage.eventPage.exploreE
17xclusiveContent")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[e.jsx(q,{variant:"default",size:"sm",children:u("landingPage.eventPage.filters.all")}),e.jsx(q,{variant:"outline",size:"sm",children:u("landingPage.eventPage.filters.photos")}),e.jsx(q,{variant:"outline",size:"sm",children:u("landingPage.eventPage.filters.videos")}),e.jsx(q,{variant:"outline",size:"sm",children:u("landingPage.eventPage.filters.audios")})]}),e.jsx("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:d.map(f=>e.jsx(Ls,{content:f,companyId:t.id,eventId:(c==null?void 0:c.id)==="general"||c==null?void 0:c.id},f.id))})]}),d.length===0&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx(ct,{className:"h-16 w-16 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:u("landingPage.eventPage.noContentAvailable")}),e.jsx("p",{className:"text-muted-foreground",children:c.id==="general"?u("landingPage.eventPage.generalContentNotPublished"):u("landingPage.eventPage.eventContentNotPublished")})]})]})]}):e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-background via-background to-muted/20",children:[e.jsx(it,{company:t}),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("h1",{className:"text-2xl font-bold mb-4",children:u("landingPage.eventPage.eventNotFound")}),e.jsx("p",{className:"text-muted-foreground mb-6",children:u("landingPage.eventPage.eventNotFoundDesc")}),e.jsxs(q,{onClick:o,children:[e.jsx(He,{className:"h-4 w-4 mr-2"}),u("landingPage.eventPage.backToHome")]})]})})]})},Ht=({activeTab:t,onTabChange:n,itemCounts:a,fanUploadEnabled:u=!1,companySlug:m,gallerySlug:c})=>{const{t:x}=ye();gt()&&console.log("[GALLERY TABS] Rendering with counts:",a,"fanUploadEnabled:",u);const d=[{id:"photos",label:x("landingPage.galleries.tabs.photos"),icon:lt,count:a.photos},{id:"videos",label:x("landingPage.galleries.tabs.videos"),icon:dr,count:a.videos}].filter(y=>y.count>0),b=u&&!!m&&!!c;if(d.length===0&&!b)return null;const k=b?e.jsx(ot,{to:`/fan-upload/${m}/${c}`,className:"w-full lg:w-auto",children:e.jsxs(q,{variant:"default",className:` 18 w-full lg:w-auto 19 flex items-center justify-center gap-2 20 rounded-none lg:rounded 21 h-12 lg:h-10 22 bg-primary text-primary-foreground hover:bg-primary/90 border border-primary 23 `,children:[e.jsx(ur,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm lg:text-sm font-medium",children:x("landingPage.galleries.tabs.submitYours")})]})}):null,N=d.map(y=>{const l=y.icon,o=t===y.id;return e.jsxs(q,{variant:o?"default":"outline",onClick:()=>n(y.id),className:` 24 flex-1 lg:flex-initial 25 flex items-center justify-center gap-2 26 rounded-none lg:rounded 27 h-11 lg:h-10 28 ${o?"bg-black text-white border border-black lg:bg-primary lg:text-primary-foreground lg:border-transparent":"bg-white text-black border border-border lg:bg-background lg:hover:bg-accent lg:hover:text-accent-foreground"} 29 `,disabled:y.count===0,children:[e.jsx(l,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm lg:text-sm font-medium",children:y.label}),e.jsx(Jt,{variant:o?"secondary":"outline",className:`ml-1 ${o?"bg-white text-black lg:bg-secondary lg:text-secondary-foreground":"bg-black text-white lg:bg-background lg:text-foreground"}`,children:y.count})]},y.id)});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-2 lg:hidden bg-transparent px-3 py-3",children:[k,N.length>0&&e.jsx("div",{className:"flex flex-nowrap gap-2",children:N})]}),e.jsxs("div",{className:"hidden lg:flex flex-nowrap justify-end gap-2 pt-4 pb-4 px-4 pr-0 bg-transparent",children:[k,N]})]})},Rs=50*1024*1024,pr=({src:t,poster:n,fileName:a,fileType:u,fileSize:m,width:c,height:x,autoPlay:d=!1,showControls:b=!0,muted:k,onMutedChange:N,onEnded:y,onTimeUpdate:l,className:o="",style:f={}})=>{const{t:S}=ye(),R=s.useRef(null),{logPlaybackError:E,logPlaybackSuccess:G,checkVideoSupport:V,getBrowserInfo:oe}=or();oe();const[O,L]=s.useState("loading"),[Q,re]=s.useState(0),[C,F]=s.useState(""),[H,M]=s.useState(!1),[K,B]=s.useState(!1),[ie,ne]=s.useState(0),ge=3,D=m&&m>Rs;s.useEffect(()=>{if(L("loading"),re(0),F(""),M(!1),B(!1),ne(0),R.current){try{R.current.pause()}catch{}try{R.current.load()}catch{}}},[t]),s.useEffect(()=>{const P=setTimeout(()=>{L(X=>X==="ready"||X==="error"?X:"ready")},1500);return()=>clearTimeout(P)},[t]),s.useEffect(()=>{u&&a&&V(u,a,t)},[u,a,t,V]),s.useEffect(()=>{const P=R.current;if(!P||!N)return;const X=()=>{N(P.muted)};return P.addEventListener("volumechange",X),()=>P.removeEventListener("volumechange",X)},[N]),s.useEffect(()=>{const P=R.current;!P||k===void 0||(P.muted=k)},[k]);const i=s.useRef(!1);s.useEffect(()=>{i.current=!1},[t]),s.useEffect(()=>{const P=R.current;if(!P||!d)return;const X=async()=>
29{if(!i.current){i.current=!0,P.muted=k??!0;try{await P.play()}catch(v){console.log("AutoPlay bloqueado, tentando muted:",v),P.muted=!0;try{await P.play(),k===!1&&N&&N(!0)}catch(le){console.log("AutoPlay muted também falhou:",le),M(!0)}}}};if(P.readyState>=1)X();else{const v=()=>X();return P.addEventListener("loadedmetadata",v,{once:!0}),()=>P.removeEventListener("loadedmetadata",v)}},[d,t,k,N]);const _=s.useCallback(()=>{if(!(Q>=ge)&&(re(P=>P+1),L("loading"),F(""),B(!1),ne(0),R.current)){const P=R.current.src;R.current.src="",R.current.load(),setTimeout(()=>{if(R.current){const X=P.includes("?")?"&":"?";R.current.src=`${t}${X}_retry=${Date.now()}`,R.current.load()}},500)}},[Q,t]);s.useEffect(()=>{if(O==="error"&&Q<ge){const P=setTimeout(()=>{_()},2e3*(Q+1));return()=>clearTimeout(P)}},[O,Q,_]);const $=()=>{L("loading")},T=()=>{const P=R.current;P&&P.readyState>=2&&(B(!0),L("ready"))},W=()=>{L("ready"),G(a,u)},te=()=>{L("ready")},se=()=>{O==="ready"&&L("loading")},je=()=>{B(!0),L("ready")},de=()=>{const P=R.current;
29if(!(!P||!P.duration||!isFinite(P.duration)))try{if(P.buffered.length>0){const X=P.buffered.end(P.buffered.length-1),v=Math.min(100,Math.round(X/P.duration*100));ne(v)}}catch{}},Ee=()=>{L("stalled")},ke=P=>{const X=P.currentTarget,v=X.error;let le=S("videoPlayer.genericError")||"Erro ao carregar vÃdeo";if(v){switch(v.code){case MediaError.MEDIA_ERR_ABORTED:le=S("videoPlayer.errorAborted")||"Reprodução interrompida";break;case MediaError.MEDIA_ERR_NETWORK:le=D?S("videoPlayer.errorNetworkLarge")||"Erro de rede. VÃdeo grande pode demorar para carregar.":S("videoPlayer.errorNetwork")||"Erro de rede. Verifique sua conexão.";break;case MediaError.MEDIA_ERR_DECODE:le=S("videoPlayer.errorDecode")||"Formato de vÃdeo incompatÃvel com este navegador.";break;case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED:le=S("videoPlayer.errorNotSupported")||"Formato de vÃdeo não suportado.";break}E({code:v.code,message:v.message||le,fileName:a,fileType:u},X)}F(le),L("error")},Se={width:"100%",height:"100%",...f};return e.jsxs("div",{className:"relative flex items-center justify-center mx-auto",style:Se,children:[n&&!K&&e.jsx("img",{src:n,alt:"",draggable:!1,ref:P=>{P&&P.complete&&P.naturalWidth>0&&(P.style.opacity="1")},className:`absolute inset-0 w-full h-full object-contain z-[1] transition-opacity duration-300 ${o}`}),e.jsx("video",{ref:R,controls:b,controlsList:"nodownload noremoteplayback noplaybackrate",disablePictureInPicture:!0,playsInline:!0,muted:k??!0,preload:D?"metadata":"auto",poster:n,src:t,className:`w-full h-full object-contain ${o}`,onLoadStart:$,onLoadedData:T,onCanPlay:W,onCanPlayThrough:te,onWaiting:se,onPlaying:je,onProgress:de,onStalled:Ee,onError:ke,onEnded:y,onTimeUpdate:l?P=>{const X=P.currentTarget;X.duration&&l(X.currentTime,X.duration)}:void 0,children:"Your browser does not support the video tag."}),H&&O!=="error"&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10 cursor-pointer bg-black/30",onClick:()=>{const P=R.current;P&&(P.muted=!0,P.play().then(()=>{M(!1)}).catch(()=>{}))},children:e.jsx("div",{className:"bg-white/20 backdrop-blur-sm rounded-full p-4",children:e.jsx("svg",{className:"h-10 w-10 text-white",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M8 5v14l11-7z"})})})}),O==="error"&&Q>=ge&&e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/80 backdrop-blur-sm z-10",children:[e.jsx(cs,{className:"h-12 w-12 text-red-400 mb-4"}),e.jsx("p",{className:"text-white text-sm font-medium text-center px-4 max-w-md mb-2",children:C}),e.jsxs(q,{variant:"secondary",size:"sm",onClick:()=>{re(0),_()},className:"mt-2",children:[e.jsx(qr,{className:"h-4 w-4 mr-2"}),S("videoPlayer.tryAgain")||"Tentar novamente"]})]})]})},wt="downloadedItems",Is=()=>{const[t,n]=s.useState(new Set);s.useEffect(()=>{try{const c=localStorage.getItem(wt);if(c){const x=JSON.parse(c);Array.isArray(x)&&n(new Set(x))}}catch(c){console.error("Error loading downloaded items:",c)}},[]),s.useEffect(()=>{try{localStorage.setItem(wt,JSON.stringify([...t]))}catch(c){console.error("Error saving downloaded items:",c)}},[t]);const a=s.useCallback(c=>{n(x=>new Set(x).add(c))},[]),u=s.useCallback(c=>t.has(c),[t]),m=s.useCallback(()=>{n(new Set),localStorage.removeItem(wt)},[]);return{downloadedItems:t,markAsDownloaded:a,isDownloaded:u,clearDownloaded:m}},Ds=["medium_thumbnail_url","thumbnail_url","fullscreen_thumbnail_url","file_url"],As=["thumbnail_url","grid_thumbnail_url","medium_thumbnail_url"],br=({items:t,currentIndex:n,enabled:a=!0,preloadCount:u=2,photoOrder:m=Ds,videoOrder:c=As,preloadVideoFiles:x=!1,maxVideoPreloads:d=1})=>{const b=s.useRef(new Set),k=s.useRef(new Set),N=s.useRef([]),y=gt(),l=typeof navigator<"u"&&(/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1),o=typeof navigator<"u"&&((navigator.deviceMemory??8)<=4||l),f=o?Math.min(u,1):u,S=o?["grid_thumbnail_url","thumbnail_url","medium_thumbnail_url","fullscreen_thumbnail_url"]:m;return s.useEffect(()=>{var re;if(!a||t.length===0)return;const R=o?3:8,E=new Set;for(let C=Math.max(0,n-R);C<=Math.min(t.length-1,n+R);C++){const F=t[C];if(F)for(const H of S){const M=F[H];M&&E.add(M)}}b.current.forEach(C=>{E.has(C)||b.current.delete(C)}),y&&console.log(`[Preload] ð Active for index ${n}. Preloading +${f}/-${Math.min(f,1)} (lowMem=${o})`);const G=C=>{var M;const H=((M=C.file_type)==null?void 0:M.startsWith("video/"))?c:S;for(const K of H){const B=C[K];if(B&&!k.current.has(B))return B}return null},V=(C,F)=>{if(b.current.has(C))return;const H=new Image;H.onload=()=>{b.current.add(C),y&&console.log(`[Preload] â
Image: ...${C.slice(-50)}`)},H.onerror=()=>{k.current.add(C),y&&console.warn(`[Preload] â Failed: ...${C.slice(-50)}`);const M=t.find(K=>K.id===F);if(M){const K=G(M);K&&K!==C&&V(K,F)}},H.src=C},oe=typeof navigator<"u"&&(/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1),O=C=>{if(b.current.has(C)||k.current.has(C))return;if(oe){y&&console.log("[Preload] âï¸ iOS detected â skipping video file preload");return}const F=document.createElement("video");
29F.src=C,F.preload="auto",F.muted=!0,F.playsInline=!0,F.setAttribute("playsinline",""),F.setAttribute("webkit-playsinline",""),F.setAttribute("aria-hidden","true"),F.style.cssText="position:fixed;top:-9999px;left:-9999px;width:1px;height:1px;opacity:0;pointer-events:none;",F.addEventListener("loadeddata",()=>{b.current.add(C),y&&console.log(`[Preload] ð¬ Video ready: ...${C.slice(-50)}`)},{once:!0}),F.addEventListener("error",()=>{k.current.add(C),y&&console.warn(`[Preload] â Video failed: ...${C.slice(-50)}`)},{once:!0}),document.body.appendChild(F),N.current.push(F)};let L=0;for(let C=1;C<=f;C++){const F=n+C;if(F<t.length){const H=t[F],M=(re=H.file_type)==null?void 0:re.startsWith("video/"),K=G(H);if(K&&V(K,H.id),x&&M&&L<d){const B=H.file_url;B&&(O(B),L++)}}}const Q=n-1;if(Q>=0){const C=t[Q],F=G(C);F&&V(F,C.id)}return()=>{N.current.forEach(C=>{C.parentNode&&C.parentNode.removeChild(C)}),N.current=[]}},[t,n,a,f,S,c,x,d,y,o]),{preloadedCount:b.current.size,isActive:a&&t.length>0}},vr=t=>ht({queryKey:["gallery-fan-credits",t],enabled:!!t,staleTime:5*60*1e3,queryFn:async()=>{const{data:n,error:a}=await Y.rpc("get_fan_credits_for_gallery",{p_gallery_id:t});if(a)return console.warn("[useGalleryFanCredits] RPC error:",a),new Map;const u=new Map;return(n||[]).forEach(m=>{if(!(m!=null&&m.gallery_item_id))return;const c=(m.full_name??"").toString().trim()||null,x=(m.instagram_handle??"").toString().trim()||null;!c&&!x||u.set(m.gallery_item_id,{fullName:c,instagram:x})}),u}}),St=({credit:t,variant:n,className:a})=>{if(!t)return null;const{fullName:u,instagram:m}=t;if(!u&&!m)return null;const c=m?`https://instagram.com/${m}`:null,x=d=>d.stopPropagation();return n==="badge"?e.jsxs("div",{className:we("pointer-events-auto inline-flex items-center gap-1.5 rounded-full bg-black/55 px-2 py-0.5 text-[10px] font-medium text-white backdrop-blur-sm shadow-sm max-w-full",a),onClick:x,children:[u&&e.jsx("span",{className:"truncate max-w-[140px]",children:u}),u&&m&&e.jsx("span",{className:"opacity-60",children:"|"}),c&&e.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer nofollow","aria-label":`Instagram @${m}`,className:"inline-flex items-center gap-1 hover:underline",onClick:x,children:[e.jsx(vt,{className:"h-3 w-3"}),e.jsxs("span",{className:"truncate max-w-[120px]",children:["@",m]})]})]}):n==="inline"?e.jsxs("div",{className:we("flex items-center gap-2 text-sm text-gray-700",a),children:[u&&e.jsx("span",{className:"font-medium",children:u}),u&&m&&e.jsx("span",{className:"text-gray-300",children:"|"}),c&&e.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer nofollow","aria-label":`Instagram @${m}`,className:"inline-flex items-center gap-1 text-gray-900 hover:underline",children:[e.jsx(vt,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:["@",m]})]})]}):e.jsxs("div",{className:we("pointer-events-auto inline-flex items-center gap-2 rounded-full bg-black/45 px-3 py-1 text-xs text-white backdrop-blur-sm shadow-md max-w-full",a),onClick:x,onPointerDown:x,onTouchStart:x,children:[u&&e.jsx("span",{className:"font-medium truncate max-w-[180px]",children:u}),u&&m&&e.jsx("span",{className:"opacity-60",children:"|"}),c&&e.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer nofollow","aria-label":`Instagram @${m}`,className:"inline-flex items-center gap-1 hover:underline",onClick:x,children:[e.jsx(vt,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"truncate max-w-[160px]",children:["@",m]})]})]})},wr=({url:t,title:n,artist:a,companyId:u,galleryId:m,galleryItemId:c,className:x="",variant:d="filled"})=>{const{t:b}=ye(),{trackExternalClick:k}=fr(),N=n?`${n}${a?` â ${a}`:""}`:b("gallery.spotify.listen")||"Listen on Spotify",y=()=>{k({companyId:u,linkType:"spotify",linkUrl:t,galleryId:m,galleryItemId:c})},l=d==="outline";return e.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",onClick:y,"aria-label":`${b("gallery.spotify.listen")||"Listen on Spotify"}: ${N}`,className:`inline-flex items-center gap-2 rounded-full px-4 py-2 text-sm font-medium transition-transform hover:scale-[1.02] active:scale-[0.98] ${l?"bg-transparent border shadow-sm hover:bg-white/5":"shadow-sm"} ${x}
29`,style:{backgroundColor:l?"transparent":"hsl(var(--spotify))",color:l?"#ffffff":"hsl(var(--spotify-foreground))",borderColor:l?"hsl(var(--spotify))":void 0,borderWidth:l?"1.5px":void 0},children:[e.jsx(hs,{className:"h-4 w-4 shrink-0",style:{color:l?"hsl(var(--spotify))":void 0}}),e.jsx("span",{className:"truncate max-w-[60vw] sm:max-w-sm",children:N})]})},yt=["fullscreen_thumbnail_url","medium_thumbnail_url","thumbnail_url","file_url"],jt=["thumbnail_url","medium_thumbnail_url","grid_thumbnail_url"],Fs={enter:t=>({x:t>0?"100%":"-100%",opacity:0}),center:{x:0,opacity:1},exit:t=>({x:t<0?"100%":"-100%",opacity:0})},zs={type:"tween",duration:.25,ease:[.25,.1,.25,1]},Ms=({items:t,selectedIndex:n,gallery:a,companyId:u,company:m,onClose:c,onNavigate:x,onDownload:d,onShare:b,downloadingItems:k,isDownloaded:N,isDownloadAllowed:y})=>{ye();const{isMobile:l}=os(),{company:o}=ft(),f=m||o,{data:S}=vr(a==null?void 0:a.id),R=p=>(p||"").replace(/-+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,A=>A.toUpperCase()),E=R(f==null?void 0:f.name)||R(f==null?void 0:f.slug)||"",G=R(a==null?void 0:a.title),V=f==null?void 0:f.light_logo_url,oe=f==null?void 0:f.logo_url,O=V||oe,L=!V&&!!oe,Q=f!=null&&f.slug?`/${f.slug}`:"#",re=f!=null&&f.slug&&(a!=null&&a.slug)?`/${f.slug}/${a.slug}`:"#",[C,F]=s.useState(0),[H,M]=s.useState(null),[K,B]=s.useState(null),[ie,ne]=s.useState(l),ge=15e3,[D,i]=s.useState(0),[_,$]=s.useState(!1),T=s.useRef(null),W=s.useRef(0),te=s.useRef(0),se=s.useRef(0),[je,de]=s.useState(new Set),[Ee,ke]=s.useState({}),[Se,P]=s.useState(new Set),X=s.useRef(new Set),v=t[n];br({items:t,currentIndex:n,enabled:!0,preloadCount:3,photoOrder:yt,videoOrder:jt,preloadVideoFiles:!0,maxVideoPreloads:1});const le=p=>{var A;return(A=p.file_type)==null?void 0:A.startsWith("video/")},fe=s.useCallback(()=>{n<t.length-1?(F(1),i(0),se.current=0,te.current=0,x(n+1)):c()},[n,t.length,x,c]),Ce=s.useCallback(()=>{n>0&&(F(-1),i(0),se.current=0,te.current=0,x(n-1))},[n,x]);s.useEffect(()=>{const p=window.scrollY,A=document.body.style.overflow,j=document.body.style.position,z=document.body.style.top,U=document.body.style.width;return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${p}px`,document.body.style.width="100%",()=>{document.body.style.overflow=A,document.body.style.position=j,document.body.style.top=z,document.body.style.width=U,window.scrollTo(0,p)}},[]),s.useEffect(()=>{const p=A=>{A.key==="ArrowRight"&&fe(),A.key==="ArrowLeft"&&Ce(),A.key==="Escape"&&c(),A.key.toLowerCase()==="d"&&v&&(A.preventDefault(),d(v)),A.key.toLowerCase()==="s"&&v&&(A.preventDefault(),b(v))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[fe,Ce,c,v,d,b]);const De=v?k.has(v.id):!1,Ae=v?je.has(v.id):!1;s.useEffect(()=>{if(!v||le(v)||_||De||!Ae){T.current&&(te.current=se.current,clearInterval(T.current),T.current=null);return}const p=te.current;W.current=Date.now()-ge*p;const A=50;return T.current=setInterval(()=>{const j=Date.now()-W.current,z=Math.min(j/ge,1);se.current=z,i(z),z>=1&&(T.current&&(clearInterval(T.current),T.current=null),fe())},A),()=>{T.current&&(te.current=se.current,clearInterval(T.current),T.current=null)}},[v,_,De,Ae,fe]);const Fe=s.useCallback(()=>{fe()},[fe]),pe=s.useCallback((p,A)=>{A>0&&i(p/A)},[]),ze=s.useCallback(()=>{v&&!le(v)&&(te.current=D,$(!0))},[v,D]),Te=s.useCallback(()=>{_&&$(!1)},[_]),be=p=>{B(null),M({x:p.targetTouches[0].clientX,y:p.targetTouches[0].clientY})},_e=p=>{B({x:p.targetTouches[0].clientX,y:p.targetTouches[0].clientY})},Ve=()=>{if(_&&$(!1),!H||!K)return;const p=H.x-K.x,A=Math.abs(H.y-K.y);Math.abs(p)>A&&Math.abs(p)>50&&(p>0?fe():Ce())},Ue=s.useCallback(p=>{var U;const j=((U=p.file_type)==null?void 0:U.startsWith("video/"))?jt:yt,z=Ee[p.id]??0;if(z>=j.length)return"/placeholder.svg";for(let J=z;J<j.length;J++){const ce=p[j[J]];if(ce)return ce}return"/placeholder.svg"},[Ee]),Pe=s.useCallback(p=>{P(A=>{const j=new Set(A);return j.delete(p),j}),de(A=>{if(A.has(p))return A;const j=new Set(A);return j.add(p),j})},[]),Ne=s.useCallback((p,A)=>{var ue;const j=t.find(me=>me.id===p),z=(ue=j==null?void 0:j.file_type)==null?void 0:ue.startsWith("video/"),U=z?jt:yt,J=Ee[p]??0,ce=J+1;gt()&&console.warn(`[ReelsViewer] â Failed (${z?"video":"photo"}):`,` 30 â Version: ${U[J]}`,` 31 â URL: ...${A.slice(-60)}`,ce<U.length?` 32 â Next: ${U[ce]}`:` 33 â â ï¸ All versions exhausted`),J>0&&!X.current.has(p)&&(X.current.add(p),Xe(async()=>{const{getEnvironmentForLogging:me}=await import("./index-P0N1Je5T.js").then(ae=>ae.c3);return{getEnvironmentForLogging:me}},__vite__mapDeps([0,1])).then(({getEnvironmentForLogging:me})=>{Y.from("image_fallback_logs").insert({failed_url:String((j==null?void 0:j[U[0]])||""),failed_version:String(U[0]),successful_version:String(U[J]),company_id:u,gallery_id:a.id,gallery_title:a.title,environment:me()})})),P(me=>new Set(me).add(p)),ke(me=>({...me,[p]:ce}))},[Ee,t,a.id,a.title,u]);return v?e.jsxs("div",{className:"fixed z-50 bg-black overflow-hidden touch-none",style:{isolation:"isolate",inset:0,marginTop:"calc(-1 * env(safe-area-inset-top, 0px))",marginLeft:"calc(-1 * env(safe-area-inset-left, 0px))",marginRight:"calc(-1 * env(safe-area-inset-right, 0px))",marginBottom:"calc(-1 * env(safe-area-inset-bottom, 0px))",paddingTop:"env(safe-area-inset-top, 0px)",paddingLeft:"env(safe-area-inset-left, 0px)",paddingRight:"env(safe-area-inset-right, 0px)",paddingBottom:"env(safe-area-inset-bottom, 0px)"},onTouchStart:be,onTouchMove:_e,onTouchEnd:Ve,onPointerDown:ze,onPointerUp:Te,onPointerLeave:Te,children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 z-50 px-2 pt-2 flex gap-1",
33style:{paddingTop:"max(0.5rem, calc(env(safe-area-inset-top, 0.5rem) + 0.25rem))",paddingLeft:"max(0.5rem, env(safe-area-inset-left, 0.5rem))",paddingRight:"max(0.5rem, env(safe-area-inset-right, 0.5rem))"},children:t.map((p,A)=>e.jsx("div",{className:"flex-1 h-0.5 rounded-full overflow-hidden bg-white/30",children:e.jsx("div",{className:"h-full rounded-full bg-white",style:{width:A<n?"100%":A===n?`${D*100}%`:"0%",transition:A===n?"none":"width 0.3s ease"}})},A))}),e.jsx(q,{variant:"ghost",size:"sm",className:"absolute z-50 bg-black/40 text-white hover:bg-black/70 hover:text-white backdrop-blur-sm rounded-full h-10 w-10 p-0",onClick:c,style:{top:"max(1.5rem, calc(env(safe-area-inset-top, 1.5rem) + 0.75rem))",left:"max(0.75rem, env(safe-area-inset-left, 0.75rem))"},children:e.jsx(rr,{className:"h-5 w-5"})}),t.length>1&&e.jsxs(e.Fragment,{children:[n>0&&e.jsx(q,{variant:"ghost",size:"lg",className:"absolute left-2 sm:left-4 top-1/2 -translate-y-1/2 z-50 bg-black/30 sm:bg-black/40 text-white hover:bg-black/70 hover:text-white backdrop-blur-sm h-10 w-10 sm:h-14 sm:w-14 p-0 flex rounded-full",onClick:Ce,children:e.jsx(mr,{className:"h-6 w-6 sm:h-8 sm:w-8"})}),n<t.length-1&&e.jsx(q,{variant:"ghost",size:"lg",className:"absolute right-2 sm:right-4 top-1/2 -translate-y-1/2 z-50 bg-black/30 sm:bg-black/40 text-white hover:bg-black/70 hover:text-white backdrop-blur-sm h-10 w-10 sm:h-14 sm:w-14 p-0 flex rounded-full",onClick:fe,children:e.jsx(sr,{className:"h-6 w-6 sm:h-8 sm:w-8"})})]}),e.jsxs("div",{className:"absolute right-4 z-50 flex flex-col gap-4 items-center",style:{bottom:"max(1.625rem, calc(env(safe-area-inset-bottom, 0px) + 1.625rem))"},children:[e.jsx(q,{onClick:()=>b(v),className:"bg-black/50 text-white hover:bg-black/50 hover:text-white backdrop-blur-md h-12 w-12 p-0 rounded-full border border-white/40 hover:border-white shadow-lg transition-colors",variant:"ghost",children:e.jsx(mt,{className:"h-5 w-5"})}),e.jsx(q,{onClick:()=>d(v),className:"apple-intelligence-button-circle text-white h-12 w-12 p-0 !rounded-full !border-0",variant:"default",disabled:k.has(v.id)||!y(v.id),children:k.has(v.id)?e.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-white"}):N(v.id)?e.jsx(kt,{className:"h-5 w-5 text-green-500"}):e.jsx(ut,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"absolute z-40 pointer-events-none flex flex-col items-start gap-1.5 text-left max-w-[70%] sm:max-w-md",style:{left:"max(1rem, calc(env(safe-area-inset-left, 0px) + 1rem))",bottom:"max(1.625rem, calc(env(safe-area-inset-bottom, 0px) + 1.625rem))"},children:[(E||O||G)&&e.jsxs("div",{className:"flex items-center gap-2",children:[O&&e.jsx(ot,{to:Q,className:"pointer-events-auto shrink-0",onClick:p=>p.stopPropagation(),onPointerDown:p=>p.stopPropagation(),onTouchStart:p=>p.stopPropagation(),children:e.jsx("img",{src:O,alt:E||"logo",className:`h-9 w-auto object-contain drop-shadow-md ${L?"filter brightness-0 invert":""}`})}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[G&&e.jsx("div",{className:"flex items-center gap-2 max-w-full",children:e.jsx(ot,{to:re,className:"pointer-events-auto text-white text-sm font-semibold drop-shadow-md hover:underline truncate leading-tight",onClick:p=>p.stopPropagation(),onPointerDown:p=>p.stopPropagation(),onTouchStart:p=>p.stopPropagation(),children:G})}),E&&e.jsx(ot,{to:Q,className:"pointer-events-auto text-white/80 text-xs font-medium drop-shadow-md hover:underline truncate max-w-full leading-tight",onClick:p=>p.stopPropagation(),onPointerDown:p=>p.stopPropagation(),onTouchStart:p=>p.stopPropagation(),children:E})]})]}),(v==null?void 0:v.title)&&e.jsx("p",{className:"text-white/80 text-xs leading-snug drop-shadow-md line-clamp-2 max-w-full",children:v.title}),(S==null?void 0:S.get(v==null?void 0:v.id))&&e.jsx(St,{credit:S.get(v.id),variant:"overlay",className:"mt-1"}),(v==null?void 0:v.spotify_url)&&e.jsx("div",{className:"mt-2 self-start",onClick:p=>p.stopPropagation(),onPointerDown:p=>p.stopPropagation(),onTouchStart:p=>p.stopPropagation(),children:e.jsx(wr,{url:v.spotify_url,title:v.spotify_title,artist:v.spotify_artist,companyId:u,galleryId:a.id,galleryItemId:v.id,className:"pointer-events-auto",variant:"outline"})})]}),le(v)&&e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-black",style:{paddingBottom:"env(safe-area-inset-bottom, 0px)"},onClick:p=>{const A=p.currentTarget.querySelector("video");A&&(A.paused?A.play().catch(()=>{}):A.pause())},children:e.jsx(pr,{src:v.file_url,poster:Ue(v),fileName:v.file_name||void 0,fileType:v.file_type,fileSize:v.file_size||void 0,width:v.width||void 0,height:v.height||void 0,autoPlay:!0,showControls:!1,muted:ie,onMutedChange:ne,onEnded:Fe,onTimeUpdate:pe,style:{maxWidth:"100%",maxHeight:"calc(100vh - env(safe-area-inset-bottom, 0px))"}})}),!le(v)&&e.jsx(hr,{initial:!1,custom:C,mode:"wait",children:e.jsx(Ge.div,{custom:C,variants:Fs,initial:"enter",animate:"center",exit:"exit",transition:zs,className:"absolute inset-0 z-10 flex flex-col justify-center bg-black",style:{paddingTop:0,paddingBottom:"env(safe-area-inset-bottom, 0px)"},children:e.jsxs("div",{className:"flex justify-center w-full relative",children:[Se.has(v.id)&&!le(v)&&e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-md animate-pulse z-10"}),!le(v)&&e.jsx("img",{src:Ue(v),alt:v.title||"",draggable:!1,decoding:"async",onLoad:()=>Pe(v.id),onError:p=>Ne(v.id,p.currentTarget.src),className:`object-contain transition-opacity duration-300 ${Se.has(v.id)?"opacity-0":"opacity-100"}`,style:{maxWidth:"100%",maxHeight:"calc(100vh - env(safe-area-inset-bottom, 0px))"}})]})},v.id)})]}):null},Os={default:4,1280:4,1024:3,768:2,480:1},$s={default:5,1280:4,1024:2,640:1,0:1},_t=["thumbnail_url","medium_thumbnail_url","fullscreen_thumbnail_url","file_url"],Nt=["grid_thumbnail_url","thumbnail_url","medium_thumbnail_url","fullscreen_thumbnail_url"],Yt=()=>window.location.hostname==="localhost",Gs=({items:t,gallery:n,companyId:a,companyViewMode:u,company:m})=>{const{t:c}=ye(),{company:x}=ft(),d=m||x,b=u??(d==null?void 0:d.gallery_view_mode)??"reels",{data:k}=vr(n==null?void 0:n.id),[N,y]=nr(),[l,o]=s.useState(null),[f,S]=s.useState(0),[R,E]=s.useState(0),[G,V]=s.useState({width:0,height:0}),[oe,O]=s.useState(!0),[L,Q]=s.useState(null),[re,C]=s.useState(null),[F,H]=s.useState(!1),[M,K]=s.useState(!1),[B,ie]=s.useState(null),[ne,ge]=s.useState(!1),[D,i]=s.useState(new Set),[_,$]=s.useState(!1),[T,W]=s.useState(null),te=s.useRef([]);s.useEffect(()=>{if(_){const g=Array.from(document.querySelectorAll("video")).filter(h=>!h.paused&&!h.ended);g.forEach(h=>h.pause()),te.current=g;return}const r=te.current;te.current=[],r.forEach(g=>{g.isConnected&&g.play().catch(()=>{})})},[_]);const[se,je]=s.useState({}),[de,Ee]=s.useState({}),ke=s.useRef(new Set),[Se,P]=s.useState({}),[X,v]=s.useState(new Set),le=1e4,fe=50,[Ce,De]=s.useState(0),Ae=s.useRef(0),Fe=s.useRef(0),pe=s.useRef(null),ze=s.useRef(new Set),Te=["fullscreen_thumbnail_url","medium_thumbnail_url","thumbnail_url","file_url"],be=["thumbnail_url","medium_thumbnail_url","grid_thumbnail_url"],{session:_e,saveSession:Ve,isSessionValid:Ue}=Lt(a),{debouncedDownload:Pe,isDownloadAllowed:Ne,getDownloadState:p,resetDownloadState:A}=xr({delay:1e3,maxCalls:5,windowMs:6e4}),{trackView:j}=Pt(),{invalidateDownloads:z}=ar(),{logPlaybackError:U,logPlaybackSuccess:J,checkVideoSupport:ce}=or(),{markAsDownloaded:ue,isDownloaded:me}=Is(),ae=s.useCallback(r=>{var g;return(g=r.file_type)==null?void 0:g.startsWith("video/")},[]),qe=30,Me=30,Oe=8,Ye=t.length>60,[Je,At]=s.useState(Ye?qe:t.length);s.useEffect(()=>{At(t.length>60?qe:t.length)},[t]);const[yr,jr]=s.useState(()=>{const r=new Set;return t.slice(0,Oe).forEach(g=>r.add(g.id)),r}),Qe=s.useRef(new Map),Ke=s.useRef(null),Ft=s.useRef(null),_r=s.useCallback(r=>g=>
33{if(g)Qe.current.set(r,g),Ke.current&&Ke.current.observe(g);else{const h=Qe.current.get(r);h&&Ke.current&&Ke.current.unobserve(h),Qe.current.delete(r)}},[]);s.useEffect(()=>{const r=new IntersectionObserver(g=>{const h=[];g.forEach(w=>{if(w.isIntersecting){const I=w.target.dataset.itemId;I&&(h.push(I),r.unobserve(w.target))}}),h.length>0&&jr(w=>{const I=new Set(w);return h.forEach(Z=>I.add(Z)),I})},{rootMargin:"800px",threshold:0});return Ke.current=r,Qe.current.forEach(g=>r.observe(g)),()=>r.disconnect()},[]),s.useEffect(()=>{if(!Ye)return;const r=Ft.current;if(!r||Je>=t.length)return;const g=new IntersectionObserver(h=>{h[0].isIntersecting&&At(w=>Math.min(t.length,w+Me))},{rootMargin:"600px"});return g.observe(r),()=>g.disconnect()},[Ye,Je,t.length]),br({items:t,currentIndex:f,enabled:!!l,preloadCount:2}),s.useEffect(()=>{const r=()=>{V({width:window.innerWidth,height:window.innerHeight})};return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),s.useEffect(()=>{const r=N.get("item"),g=N.get("index");if(r&&t.length>0){const h=t.find(w=>w.id===r);if(h){const w=g?parseInt(g,10):t.findIndex(I=>I.id===r);if(w>=0&&w<t.length){o(h),S(w),O(!1);const I=ae(h)?"video":"photo";j(h.id,a,I)}}}},[N,t,a,j]);const $e=s.useCallback(()=>{pe.current&&(clearInterval(pe.current),pe.current=null),Ae.current=0,Fe.current=0,De(0)},[]),Nr=r=>{const g=t.findIndex(I=>I.id===r.id);$e(),o(r),S(g),O(!0);const h=new URLSearchParams(N);h.set("item",r.id),h.set("index",g.toString()),y(h,{replace:!0});const w=ae(r)?"video":"photo";j(r.id,a,w)},Ze=()=>{$e();const r=document.querySelector("video");r&&(r.pause(),r.currentTime=0),E(1);const g=(f+1)%t.length,h=t[g];o(h),S(g),O(!1);const w=new URLSearchParams(N);w.set("item",h.id),w.set("index",g.toString()),y(w,{replace:!0})},xt=()=>{$e();const r=document.querySelector("video");r&&(r.pause(),r.currentTime=0),E(-1);const g=(f-1+t.length)%t.length,h=t[g];o(h),S(g),O(!1);const w=new URLSearchParams(N);w.set("item",h.id),w.set("index",g.toString()),y(w,{replace:!0})};s.useEffect(()=>{var g;if(!(b==="lightbox"&&!!l&&t.length>1&&G.width>=640&&!ae(l)&&!(typeof window<"u"&&((g=window.matchMedia)!=null&&g.call(window,"(prefers-reduced-motion: reduce)").matches)))){$e();return}return $e(),Fe.current=Date.now(),pe.current=setInterval(()=>{const h=Date.now()-Fe.current,w=Math.min(h/le,1);Ae.current=w,De(w),w>=1&&(pe.current&&(clearInterval(pe.current),pe.current=null),Ze())},fe),()=>{pe.current&&(clearInterval(pe.current),pe.current=null)}},[b,l==null?void 0:l.id,f,t.length,G.width,ae,$e]);const et=()=>{$e(),o(null);const r=new URLSearchParams(N);r.delete("item"),r.delete("index"),y(r,{replace:!0})},kr=s.useCallback(r=>{r.key==="ArrowRight"&&Ze(),r.key==="ArrowLeft"&&xt(),r.key==="Escape"&&et(),r.key.toLowerCase()==="d"&&l&&(r.preventDefault(),tt(l)),r.key.toLowerCase()==="s"&&l&&(r.preventDefault(),pt(l))},[l]),Sr=r=>{C(null),Q({x:r.targetTouches[0].clientX,y:r.targetTouches[0].clientY})},Er=r=>{C({x:r.targetTouches[0].clientX,y:r.targetTouches[0].clientY})},Cr=()=>{if(!L||!re)return;const r=L.x-re.x,g=Math.abs(L.y-re.y);Math.abs(r)>g&&Math.abs(r)>50&&t.length>1&&(H(!0),r>0?Ze():xt(),setTimeout(()=>H(!1),100))},tt=async r=>{i(g=>new Set(g).add(r.id));try{if(n.require_lead)if(Ue()){if(!Ne(r.id)){p(r.id).isDownloading?xe({title:"Download em andamento",description:"Aguarde o download atual terminar antes de iniciar outro.",variant:"destructive"}):xe({title:"Muitos downloads",description:"Aguarde um pouco antes de baixar novamente.",variant:"destructive"});return}await Pe(r.id,async()=>{await Lr(r)})}else A(r.id),ie(r),K(!0);else{if(!Ne(r.id)){p(r.id).isDownloading?xe({title:"Download em andamento",description:"Aguarde o download atual terminar antes de iniciar outro.",variant:"destructive"}):xe({title:"Muitos downloads",description:"Aguarde um pouco antes de baixar novamente.",variant:"destructive"});return}await Pe(r.id,async()=>{await Pr(r)})}}catch(g){console.error("Download error:",g)}finally{i(g=>{const h=new Set(g);return h.delete(r.id),h})}},Pr=async r=>{try{const{data:g,error:h}=await Y.functions.invoke("download-file",{body:{contentId:r.id,companyId:a,accessToken:null}});if(h||!(g!=null&&g.downloadUrl))throw new Error((h==null?void 0:h.message)||"Failed to get download URL");window.location.href=g.downloadUrl,z(),ue(r.id),xe({title:c("download.started"),description:c("download.success").replace("{title}",r.title||r.file_name||"arquivo")})}catch(g){throw console.error("Direct download error:",g),xe({title:c("download.error"),description:c("download.errorDesc"),variant:"destructive"}),g}},zt=async(r,g)=>{try{const{data:h,error:w}=await Y.functions.invoke("download-file",{body:{contentId:r.id,companyId:a,accessToken:g||null}});if(w||!(h!=null&&h.downloadUrl))throw new Error((w==null?void 0:w.message)||"Erro no download do arquivo");window.location.href=h.downloadUrl,z(),ue(r.id),xe({title:c("download.started"),description:c("download.success").replace("{title}",r.title||r.file_name||"arquivo")})}catch(h){console.error("Erro no download seguro:",h),xe({title:c("download.error"),description:c("download.errorDesc"),variant:"destructive"})}},Lr=async r=>{if(_e)try{const g={contentId:r.id,companyId:a,email:_e.email,first_name:_e.first_name,last_name:_e.last_name,consent_given:!0,privacy_policy_accepted:!0,marketing_consent:_e.marketing_consent??!1,website:"",url:"",s
33ource:"gallery_download",fan_session_id:(()=>{try{const I=localStorage.getItem("fan_session");return I?JSON.parse(I).id:null}catch{return null}})()},{data:h,error:w}=await Y.functions.invoke("capture-lead",{body:g});if(w){console.error("Erro ao gerar token:",w),xe({title:c("download.error"),description:c("download.errorDesc"),variant:"destructive"});return}h!=null&&h.success&&(h!=null&&h.accessToken)?await zt(r,h.accessToken):xe({title:c("download.error"),description:c("download.errorDesc"),variant:"destructive"})}catch(g){console.error("Erro ao gerar token e fazer download:",g),xe({title:c("download.error"),description:c("download.errorDesc"),variant:"destructive"})}},Tr=async r=>{if(B){ge(!0);try{const g={contentId:B.id,companyId:a,email:r.email,first_name:r.first_name,last_name:r.last_name,consent_given:!!r.consent_given,privacy_policy_accepted:!!r.privacy_policy_accepted,marketing_consent:!!r.marketing_consent,website:"",url:"",source:"gallery_download",fan_session_id:(()=>{try{const I=localStorage.getItem("fan_session");return I?JSON.parse(I).id:null}catch{return null}})()},{data:h,error:w}=await Y.functions.invoke("capture-lead",{body:g});if(w){console.error("Erro na função capture-lead:",w),xe({title:c("download.generalError"),description:c("download.generalErrorDesc"),variant:"destructive"});return}h!=null&&h.success&&(h!=null&&h.accessToken)?(Ve(r.email,{first_name:r.first_name,last_name:r.last_name,marketing_consent:!!r.marketing_consent}),K(!1),ie(null),await zt(B,h.accessToken),xe({title:c("download.thankYou"),description:c("download.thankYouDesc")})):xe({title:c("download.generalError"),description:c("download.generalErrorDesc"),variant:"destructive"})}catch(g){console.error("Erro ao processar lead:",g),xe({title:c("download.generalError"),description:c("download.generalErrorDesc"),variant:"destructive"})}finally{ge(!1)}}},Rr=()=>{K(!1),ie(null),B&&A(B.id),xe({title:c("download.cancelled"),description:c("download.cancelledDesc")})},pt=r=>{W(r),$(!0)},Mt=s.useCallback(r=>{const g=ae(r)?Nt:_t,h=se[r.id]??0;if(h>=g.length)return"/placeholder.svg";const w=g[h],I=r[w];if(!I){for(let Z=h+1;Z<g.length;Z++){const he=r[g[Z]];if(he)return he}return"/placeholder.svg"}return I},[se,ae]),Ot=s.useCallback((r,g,h)=>{const w=h?Nt:_t,I=se[r]??0,Z=I+1;if(Yt()){const he=t.find(ve=>ve.id===r);console.warn(`[MediaGrid] â Failed "${(he==null?void 0:he.title)||r}":`,` 34 â Failed version: ${w[I]}`,` 35 â Failed URL: ...${g.slice(-60)}`,Z<w.length?` 36 â Next: ${w[Z]}`:` 37 â â ï¸ All versions exhausted`)}je(he=>({...he,[r]:Z}))},[se,t]),Be=s.useCallback(r=>{const g=ae(r)?Nt:_t,h=se[r.id]??0,w=g[h]||"thumbnail_url";Ee(I=>({...I,[r.id]:w})),h>0&&!ke.current.has(r.id)&&(ke.current.add(r.id),Xe(async()=>{const{getEnvironmentForLogging:I}=await import("./index-P0N1Je5T.js").then(Z=>Z.c3);return{getEnvironmentForLogging:I}},__vite__mapDeps([0,1])).then(({getEnvironmentForLogging:I})=>{Y.from("image_fallback_logs").insert({failed_url:String(r[g[0]]||""),failed_version:String(g[0]),successful_version:String(w),company_id:a,gallery_id:n.id,gallery_title:n.title,environment:I()})}))},[se,ae,n.id,n.title,a]),$t=s.useCallback(r=>{var I;const h=((I=r.file_type)==null?void 0:I.startsWith("video/"))?be:Te,w=Se[r.id]??0;if(w>=h.length)return"/placeholder.svg";for(let Z=w;Z<h.length;Z++){const he=r[h[Z]];if(he)return he}return"/placeholder.svg"},[Se,Te,be]),Ir=s.useCallback(r=>{v(g=>{const h=new Set(g);return h.delete(r),h})},[]),Dr=s.useCallback((r,g)=>{var ve;const h=t.find(Le=>Le.id===r),w=(ve=h==null?void 0:h.file_type)==null?void 0:ve.startsWith("video/"),I=w?be:Te,Z=Se[r]??0,he=Z+1;Yt()&&console.warn(`[Lightbox] â Failed (${w?"video":"photo"}):`,` 38 â Version: ${I[Z]}`,` 39 â URL: ...${g.slice(-60)}`,he<I.length?` 40 â Next: ${I[he]}`:` 41 â â ï¸ All versions exhausted`),Z>0&&!ze.current.has(r)&&(ze.current.add(r),Xe(async()=>{const{getEnvironmentForLogging:Le}=await import("./index-P0N1Je5T.js").then(Re=>Re.c3);return{getEnvironmentForLogging:Le}},__vite__mapDeps([0,1])).then(({getEnvironmentForLogging:Le})=>{Y.from("image_fallback_logs").insert({failed_url:String((h==null?void 0:h[I[0]])||""),failed_version:String(I[0]),successful_version:String(I[Z]),company_id:a,gallery_id:n.id,gallery_title:n.title,environment:Le()})})),v(Le=>
41new Set(Le).add(r)),P(Le=>({...Le,[r]:he}))},[Se,Te,be,t,n.id,n.title,a]);if(t.length===0)return null;const rt=t.length>0&&t.every(r=>ae(r)),Gt=rt?[...t].sort((r,g)=>{const h=(r.width||16)/(r.height||9),w=(g.width||16)/(g.height||9);return h<1&&w>=1?-1:h>=1&&w<1?1:h<=1.5&&w>1.5?-1:h>1.5&&w<=1.5?1:0}):t,Ar=Ye?Gt.slice(0,Je):Gt,Fr=r=>{if(!rt)return{};const g=r.width||16,h=r.height||9;return g/h<1?{maxHeight:"400px"}:{}};return e.jsxs(e.Fragment,{children:[e.jsx(ls,{breakpointCols:rt?$s:Os,className:"flex -ml-3 w-auto",columnClassName:"pl-3 bg-clip-padding",children:Ar.map((r,g)=>{const h=r.width&&r.height?r.width/r.height:1,w=g<6,I=g%3,Z=!!de[r.id],he=w||yr.has(r.id);return e.jsxs("div",{ref:_r(r.id),"data-item-id":r.id,className:"mb-3 relative group cursor-pointer overflow-hidden bg-muted",style:{borderRadius:"2px",aspectRatio:h,...rt?{...Fr(r),maxHeight:"1080px"}:{}},onClick:()=>Nr(r),children:[he?ae(r)?e.jsxs("div",{className:"relative w-full h-full",children:[!Z&&e.jsx("div",{className:we("absolute inset-0 animate-pulse bg-gradient-to-br",I===0?"from-zinc-800 to-zinc-900":I===1?"from-slate-800 to-slate-900":"from-neutral-800 to-neutral-900")}),(()=>{const ve=Mt(r);return ve==="/placeholder.svg"?e.jsx("video",{src:r.file_url,className:"absolute inset-0 w-full h-full object-cover",muted:!0,playsInline:!0,preload:"metadata",onLoadedMetadata:()=>Be(r),onLoadedData:()=>Be(r),onError:Re=>{var Vt,Ut;const bt=Re.currentTarget;U({code:((Vt=bt.error)==null?void 0:Vt.code)||0,message:((Ut=bt.error)==null?void 0:Ut.message)||"Unknown video error",fileName:r.file_name,fileType:r.file_type},bt)}}):e.jsx("img",{src:ve,alt:r.title||"Video thumbnail",className:we("absolute inset-0 w-full h-full object-cover transition-opacity duration-300",Z?"opacity-100":"opacity-0"),loading:w?"eager":"lazy",fetchPriority:w?"high":"auto",decoding:w?"sync":"async",ref:Re=>{Re&&Re.complete&&Re.naturalWidth>0&&!de[r.id]&&Be(r)},onLoad:()=>Be(r),onError:Re=>{Ot(r.id,Re.currentTarget.src,!0)}})})(),e.jsx("div",{className:"absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 pointer-events-none z-10",children:e.jsx("div",{className:"bg-black/60 rounded-full p-3 backdrop-blur-sm",children:e.jsx(gs,{className:"h-8 w-8 text-white fill-white"})})})]}):e.jsxs("div",{className:"relative w-full h-full",children:[!Z&&e.jsx("div",{className:we("absolute inset-0 animate-pulse bg-gradient-to-br",I===0?"from-zinc-800 to-zinc-900":I===1?"from-slate-800 to-slate-900":"from-neutral-800 to-neutral-900")}),e.jsx("img",{src:Mt(r),alt:r.title||"",className:we("absolute inset-0 w-full h-full object-cover transition-opacity duration-300",Z?"opacity-100":"opacity-0"),loading:w?"eager":"lazy",fetchPriority:w?"high":"auto",decoding:w?"sync":"async",ref:ve=>{ve&&ve.complete&&ve.naturalWidth>0&&!de[r.id]&&Be(r)},onLoad:()=>Be(r),onError:ve=>Ot(r.id,ve.currentTarget.src,!1)})]}):e.jsx("div",{className:we("absolute inset-0 animate-pulse bg-gradient-to-br",I===0?"from-zinc-800 to-zinc-900":I===1?"from-slate-800 to-slate-900":"from-neutral-800 to-neutral-900")}),e.jsxs("div",{className:"absolute inset-0 bg-transparent transition-colors duration-200 flex items-center justify-center z-10",children:[e.jsx("div",{className:"absolute top-2 right-2 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity duration-200",children:e.jsx(q,{size:"sm",variant:"ghost",className:"apple-intelligence-button-circle !border-0 h-10 w-10 p-0 text-white hover:!bg-transparent !rounded-full [&_svg]:text-white",disabled:D.has(r.id)||!Ne(r.id),onClick:ve=>{ve.stopPropagation(),tt(r)},children:D.has(r.id)?e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}):me(r.id)?e.jsx(kt,{className:"h-4 w-4 text-green-400"}):e.jsx(ut,{className:"h-4 w-4"})})}),(k==null?void 0:k.get(r.id))&&e.jsx("div",{className:"absolute bottom-2 left-2 z-20 max-w-[calc(100%-1rem)]",children:e.jsx(St,{credit:k.get(r.id),variant:"badge"})})]})]},r.id)})}),Ye&&Je<t.length&&e.jsx("div",{ref:Ft,className:"h-1 w-full","aria-hidden":"true"}),b==="reels"&&l&&e.jsx(Ms,{items:t,selectedIndex:f,gallery:n,companyId:a,company:d,onClose:et,onNavigate:r=>{const g=t[r];o(g),S(r);const h=new URLSearchParams(N);h.set("item",g.id),h.set("index",r.toString()),y(h,{replace:!0})},onDownload:tt,onShare:pt,downloadingItems:D,isDownloaded:me,isDownloadAllowed:Ne}),b==="lightbox"&&e.jsx(Br,{open:!!l,onOpenChange:et,children:e.jsxs(Wr,{className:"fixed inset-0 w-screen h-screen max-w-none translate-x-0 translate-y-0 sm:rounded-none z-50 p-0 border-0 bg-white overflow-hidden [&>button]:hidden",onKeyDown:kr,children:[e.jsx(Hr,{className:"sr-only",children:(l==null?void 0:l.title)||"Gallery Media"}),e.jsxs(Yr,{className:"sr-only",children:[l&&ae(l)?"Video player":"Image viewer"," - Use arrow keys or swipe to navigate. Press Escape to close."]}),l&&e.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",onTouchStart:Sr,onTouchMove:Er,onTouchEnd:Cr,children:[e.jsx(q,{variant:"ghost",size:"sm",className:"absolute top-8 left-4 ml-[15px] z-30 bg-gray-100 text-gray-900 hover:bg-gray-200 hover:text-gray-900 border border-gray-300 shadow-md safe-area-top px-2.5 !rounded-[6px]",onClick:et,style:{to
41p:"max(2rem, env(safe-area-inset-top, 2rem))"},children:e.jsx(rr,{className:"h-5 w-5"})}),t.length>1&&e.jsxs("div",{className:"absolute left-1/2 -translate-x-1/2 z-30 flex w-[min(28rem,70vw)] flex-col items-center gap-2",style:{top:"max(2rem, env(safe-area-inset-top, 2rem))"},children:[e.jsxs("div",{className:"bg-black/50 backdrop-blur-sm text-white text-sm px-3 py-1.5 rounded-full font-medium",children:[f+1," / ",t.length]}),!ae(l)&&G.width>=640&&e.jsx("div",{className:"flex w-full gap-1","aria-hidden":"true",children:t.map((r,g)=>e.jsx("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-black/20 backdrop-blur-sm",children:e.jsx("div",{className:"h-full rounded-full bg-black/70",style:{width:g<f?"100%":g===f?`${Ce*100}%`:"0%",transition:g===f?"none":"width 0.2s ease"}})},g))})]}),e.jsxs("div",{className:"absolute top-8 right-4 mr-[15px] z-30 gap-3 items-center justify-center flex",style:{top:"max(2rem, env(safe-area-inset-top, 2rem))"},children:[e.jsx(q,{onClick:()=>pt(l),className:"bg-gray-100 text-gray-900 hover:bg-gray-200 hover:text-gray-900 border border-gray-300 shadow-md h-10 w-10 p-0 !rounded-[6px]",variant:"outline",children:e.jsx(mt,{className:"h-4 w-4"})}),e.jsx(q,{onClick:()=>tt(l),className:"apple-intelligence-button-circle text-white h-10 w-10 p-0 !border-0 !rounded-full",variant:"default",disabled:D.has(l.id),children:D.has(l.id)?e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}):me(l.id)?e.jsx(kt,{className:"h-4 w-4 text-green-500"}):e.jsx(ut,{className:"h-4 w-4"})})]}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(q,{variant:"ghost",size:"lg",className:"absolute left-6 top-1/2 -translate-y-1/2 z-30 bg-gray-100 text-gray-900 hover:bg-gray-200 hover:text-gray-900 border border-gray-300 shadow-lg h-16 w-16 p-0 hidden sm:flex !rounded-[6px]",onClick:xt,children:e.jsx(mr,{className:"h-8 w-8"})}),e.jsx(q,{variant:"ghost",size:"lg",className:"absolute right-6 top-1/2 -translate-y-1/2 z-30 bg-gray-100 text-gray-900 hover:bg-gray-200 hover:text-gray-900 border border-gray-300 shadow-lg h-16 w-16 p-0 hidden sm:flex !rounded-[6px]",onClick:Ze,children:e.jsx(sr,{className:"h-8 w-8"})})]}),(l.title||l.spotify_url||(k==null?void 0:k.get(l.id)))&&e.jsxs("div",{className:"absolute left-1/2 -translate-x-1/2 z-30 flex flex-col items-center gap-2 max-w-[90%]",style:{bottom:"max(1.5rem, calc(env(safe-area-inset-bottom, 0px) + 1rem))"},children:[l.title&&e.jsx("p",{className:"text-gray-900 text-sm leading-snug text-center line-clamp-2 max-w-full bg-white/95 backdrop-blur-sm border border-gray-200 rounded-2xl px-3 py-1.5 shadow-sm",children:l.title}),l.spotify_url&&e.jsx(wr,{url:l.spotify_url,title:l.spotify_title,artist:l.spotify_artist,companyId:a,galleryId:n.id,galleryItemId:l.id,variant:"outline"}),(k==null?void 0:k.get(l.id))&&e.jsx("div",{className:"bg-white/95 backdrop-blur-sm border border-gray-200 rounded-full px-3 py-1.5 shadow-sm",children:e.jsx(St,{credit:k.get(l.id),variant:"inline"})})]}),e.jsxs("div",{className:"w-full h-full flex items-center justify-center overflow-hidden relative",children:[X.has(l.id)&&e.jsx("div",{className:"absolute inset-0 bg-muted/50 backdrop-blur-md animate-pulse z-10 flex items-center justify-center"}),e.jsx(hr,{initial:!1,custom:R,mode:"wait",children:e.jsx(Ge.div,{custom:R,variants:ds,initial:"enter",animate:"center",exit:"exit",transition:F?us:ms,className:"flex flex-col items-center justify-center h-full w-full px-0 sm:px-8",style:{paddingTop:"max(1rem, env(safe-area-inset-top, 1rem))",paddingBottom:"max(1rem, env(safe-area-inset-bottom, 1rem))"},children:ae(l)?e.jsx(pr,{src:l.file_url,poster:$t(l),fileName:l.file_name||void 0,fileType:l.file_type,fileSize:l.file_size||void 0,width:l.width||void 0,height:l.height||void 0,autoPlay:!0,className:"object-contain w-full h-full",style:(()=>{const r=l.width&&l.height?l.width/l.height:1.7777777777777777;if(G.width<640)return{maxWidth:"100vw",maxHeight:"calc(100dvh - 2rem)"};const h=G.width*.9,w=G.height*.85;let I,Z;return r>1?(I=Math.min(h,w*r),Z=I/r):(Z=Math.min(w,h/r),I=Z*r),{width:`${I}px`,height:`${Z}px`}})()},l.id):e.jsx("img",{src:$t(l),alt:l.title||"",onLoad:()=>Ir(l.id),onError:r=>Dr(l.id,r.currentTarget.src),className:`object-contain w-full h-full transition-opacity duration-300 ${X.has(l.id)?"opacity-0":"opacity-100"}`,style:{maxWidth:G.width<640?"100vw":`${G.width*.9}px`,maxHeight:G.width<640?"calc(100dvh - 2rem)":`${G.height*.85}px`}})},l.id)})]})]})]})}),e.jsx(Tt,{isOpen:M,onClose:Rr,contentTitle:(B==null?void 0:B.title)||"arquivo",onSubmit:Tr,isLoading:ne,companyName:d==null?void 0:d.name,companySlug:d==null?void 0:d.slug}),e.jsx(Rt,{isOpen:_,onClose:()=>$(!1),url:window.location.href,title:`Share: ${(T==null?void 0:T.title)||"Gallery Item"}`,description:"Copy the link to share this content with others",contentId:T==null?void 0:T.id,companyId:a,galleryId:n.id})]})},Vs=({onBackClick:t})=>{const{t:n}=ye(),a={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.5,when:"beforeChildren",staggerChildren:.15}}},u={hidden:{scale:0,rotate:-180},visible:{scale:1,rotate:0,transition:{type:"spring",stiffness:260,damping:20,delay:.1}}},m={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4}}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-background via-background to-muted/20 px-4",children:e.jsxs(Ge.div,{variants:a,initial:"hidden",animate:"visible",className:"text-center max-w-md",children:[e.jsx(Ge.div,{variants:u,className:"mb-8 inl
41ine-flex items-center justify-center w-24 h-24 rounded-full bg-gradient-to-br from-muted to-muted/50 backdrop-blur-sm border border-border",children:e.jsx(fs,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx(Ge.h1,{variants:m,className:"text-4xl font-bold text-foreground mb-4",children:n("errors.galleryNotFound")}),e.jsx(Ge.p,{variants:m,className:"text-lg text-muted-foreground mb-8",children:n("errors.galleryNotFoundDesc")}),e.jsx(Ge.div,{variants:m,whileHover:{scale:1.05},whileTap:{scale:.95},children:e.jsx(q,{onClick:t,size:"lg",className:"shadow-lg hover:shadow-xl transition-shadow duration-300",children:n("errors.backToGalleries")})})]})})},Kt="mm_telemetry_visit",Us=3e4,qs=()=>{var t;try{return((t=performance.getEntriesByType("navigation")[0])==null?void 0:t.type)??null}catch{return null}},Bs=t=>{if(typeof window>"u")return;const{galleryId:n,companyId:a,itemCount:u}=t,m=Date.now();try{const c=sessionStorage.getItem(Kt);if(c){const x=JSON.parse(c),d=qs(),b=m-x.startedAt;if(x.galleryId===n&&d==="reload"&&b<Us){const y=navigator.deviceMemory??null;(async()=>{try{await Y.rpc("log_mobile_reload_event",{p_gallery_id:x.galleryId,p_company_id:x.companyId,p_item_count:x.itemCount,p_user_agent:navigator.userAgent,p_device_memory:y,p_metadata:{time_to_reload_ms:b,viewport_width:window.innerWidth,viewport_height:window.innerHeight,dpr:window.devicePixelRatio,navigation_type:d}})}catch{}})()}}}catch{}try{const c={galleryId:n,startedAt:m,itemCount:u,companyId:a};sessionStorage.setItem(Kt,JSON.stringify(c))}catch{}},Ws=({company:t,customization:n,gallerySlug:a,companySlug:u})=>{const{t:m,language:c}=ye(),{trackGalleryView:x}=Pt(),{profile:d,isAdmin:b,isManager:k}=ft(),N=Zt(),y=N.getQueryData(["gallery",t.id,a])||null,l=y&&N.getQueryData(["gallery-items",y.id])||null,[o,f]=s.useState(y),[S,R]=s.useState(l||[]),[E,G]=s.useState(!y),[V,oe]=s.useState(!l),[O,L]=s.useState("photos"),[Q,re]=s.useState(!1),[C,F]=s.useState(!1),[H,M]=s.useState(!1),K=s.useRef(null),B=s.useRef(null),ie=s.useRef(null),ne=s.useRef(null),{session:ge,saveSession:D,isSessionValid:i,isLoading:_}=Lt(t==null?void 0:t.id),[$,T]=s.useState(!1),[W,te]=s.useState(!1),se=s.useRef(!1),je=s.useRef(!0),[de,Ee]=s.useState(0),[ke,Se]=s.useState(!1),P=s.useRef(!1),X=["large","medium","thumbnail","original"];s.useEffect(()=>{if(je.current){je.current=!1;return}let j=0;const z=()=>{const U=window.matchMedia("(min-width: 1024px)").matches,J=U?B.current||K.current:K.current||B.current,ce=ie.current;if(!ce)return;const ue=ce.getBoundingClientRect().top+window.scrollY,me=window.matchMedia("(min-width: 768px) and (max-width: 1024px)").matches,ae=U?8:me?12:16,qe=((J==null?void 0:J.offsetHeight)??0)+ae,Me=Math.max(0,ue-qe);window.scrollTo({top:Me,behavior:"smooth"}),j<6&&(j+=1,ne.current&&clearTimeout(ne.current),ne.current=window.setTimeout(()=>{requestAnimationFrame(()=>requestAnimationFrame(z))},120))};return requestAnimationFrame(()=>requestAnimationFrame(z)),()=>{ne.current&&(clearTimeout(ne.current),ne.current=null)}},[O]),s.useEffect(()=>{(async()=>{try{const z=(b||k)&&(d==null?void 0:d.company_id)===t.id;let U=Y.from("galleries").select("*").eq("company_id",t.id).eq("slug",a);z||(U=U.eq("status","published"));const{data:J,error:ce}=await U.single();if(ce){console.error("Error fetching gallery:",ce);return}if(!J){console.error("Gallery not found");return}f(J),J.status==="draft"&&z&&F(!0);const{data:ue,error:me}=await Y.from("gallery_items").select("*").eq("gallery_id",J.id).order("sort_order",{ascending:!0});if(me){console.error("Error fetching gallery items:",me);return}if(console.log("[LANDING PAGE DEBUG] Gallery items loaded:",ue==null?void 0:ue.length),R(ue||[]),N.setQueryData(["gallery",t.id,a],J),N.setQueryData(["gallery-items",J.id],ue||[]),Y.from("gallery_fan_upload_settings").select("enabled").eq("gallery_id",J.id).maybeSingle().then(({data:ae})=>M(!!(ae!=null&&ae.enabled))),ue&&ue.length>0){const ae=ue.some(Me=>{var Oe;return(Oe=Me.file_type)==null?void 0:Oe.startsWith("image/")}),qe=ue.some(Me=>{var Oe;return(Oe=Me.file_type)==null?void 0:Oe.startsWith("video/")});
41!ae&&qe&&(console.log("[GALLERY DEBUG] No photos found but videos exist, switching to videos tab"),je.current=!0,L("videos"))}}catch(z){console.error("Error fetching gallery data:",z)}finally{G(!1),oe(!1)}})()},[a,t.id]),s.useEffect(()=>{t&&(console.log("[CleanLightGalleryPage] Initializing analytics for company:",t.id),Ct({companyGaId:t.google_analytics_id,companyAnalyticsEnabled:t.analytics_enabled,landingPageName:t.slug}).catch(j=>{console.error("[CleanLightGalleryPage] Failed to initialize analytics:",j)}))},[t,t.google_analytics_id,t.slug,t.analytics_enabled]);const v=(b||k)&&(d==null?void 0:d.company_id)===t.id,le=!!(o!=null&&o.require_lead_on_open)&&!v&&!C,fe=le&&!_&&!i(),Ce=s.useRef(!1);s.useEffect(()=>{fe?Ce.current||T(!0):(T(!1),Ce.current=!1)},[fe]);const De=s.useRef(!1);s.useEffect(()=>{!(o!=null&&o.id)||De.current||V||(De.current=!0,Bs({galleryId:o.id,companyId:(t==null?void 0:t.id)??null,itemCount:S.length}))},[o==null?void 0:o.id,V,S.length,t==null?void 0:t.id]);const Ae=s.useCallback(()=>{try{const j=!!document.referrer&&new URL(document.referrer).origin===window.location.origin;if(window.history.length>1&&j){window.history.back();return}}catch{}window.location.href=`/${u}`},[u]);s.useEffect(()=>{!o||E||le&&!i()||se.current||(se.current=!0,console.log("[GALLERY VIEW] Tracking gallery view for company:",t.id),x(t.id).catch(j=>{console.error("[GALLERY VIEW] Track error:",j)}))},[o,E,le,ge,t.id,x]);const Fe=async j=>{if(o){te(!0);try{const z=(()=>{try{const ce=localStorage.getItem("fan_session");return ce?JSON.parse(ce).id:null}catch{return null}})(),{data:U,error:J}=await Y.functions.invoke("capture-gallery-lead",{body:{galleryId:o.id,companyId:t.id,email:j.email,first_name:j.first_name,last_name:j.last_name,consent_given:j.consent_given,privacy_policy_accepted:j.privacy_policy_accepted,marketing_consent:j.marketing_consent,website:j.website??"",url:j.url??"",fan_session_id:z}});if(J||!(U!=null&&U.success))throw console.error("capture-gallery-lead error:",J,U),at.error(m("download.leadCapture.errorDesc")),new Error("capture-gallery-lead failed");D(j.email),T(!1)}finally{te(!1)}}},[pe]=nr(),ze=s.useRef(null);s.useEffect(()=>{var U,J;const j=pe.get("item");if(!j||S.length===0||ze.current===j)return;const z=S.find(ce=>ce.id===j);z&&((U=z.file_type)!=null&&U.startsWith("video/")?L("videos"):(J=z.file_type)!=null&&J.startsWith("image/")&&L("photos"),ze.current=j)},[pe,S]);const Te=s.useMemo(()=>{const j=S.filter(z=>{var U,J;return O==="photos"?(U=z.file_type)==null?void 0:U.startsWith("image/"):O==="videos"?(J=z.file_type)==null?void 0:J.startsWith("video/"):!1});return console.log(`[GALLERY] Tab: ${O} | Items: ${S.length} â ${j.length}`),j},[S,O]),be=o!=null&&o.cover_image_url?dt(o.cover_image_url):null,_e=s.useCallback(()=>{if(!be||de>=X.length)return null;const j=X[de];return be[j]},[be,de]),Ve=s.useCallback(()=>{const j=X[de];console.warn(`[Hero] Failed to load ${j}, trying next...`),de<X.length-1&&Ee(z=>z+1)},[de]),Ue=s.useCallback(async()=>{if(Se(!0),de>0&&o&&!P.current){P.current=!0;const j=X[0],z=X[de];console.log(`[Hero] Loaded ${z} after ${de} fallback(s)`);try{let U=sessionStorage.getItem("fallbackSessionId");U||(U=crypto.randomUUID(),sessionStorage.setItem("fallbackSessionId",U));const{getEnvironmentForLogging:J}=await Xe(async()=>{const{getEnvironmentForLogging:ce}=await import("./index-P0N1Je5T.js").then(ue=>ue.c3);return{getEnvironmentForLogging:ce}},__vite__mapDeps([0,1]));await Y.from("image_fallback_logs").insert({failed_url:(be==null?void 0:be.large)||null,failed_version:j,successful_version:z,company_id:t.id,gallery_id:o.id,gallery_title:o.title,fallback_count:de,environment:J()}),console.log("[Hero] Fallback event logged to dashboard")}catch(U){console.warn("[Hero] Failed to log fallback event:",U)}}},[de,o,t.id]),Pe=S.filter(j=>{var z;return(z=j.file_type)==null?void 0:z.startsWith("image/")}).length,Ne=S.filter(j=>{var z;return(z=j.file_type)==null?void 0:z.startsWith("video/")}).length;if(s.useEffect(()=>{!E&&S.length>0&&(Pe===0&&Ne>0?(je.current=!0,L("videos")):Ne===0&&Pe>0&&(je.current=!0,L("photos")))},[E,Pe,Ne,S.length]),!E&&!o)return e.jsx(Vs,{onBackClick:()=>window.location.href=`/${u}`});if(!o)return e.jsx("div",{className:"min-h-screen bg-background template-clean-light",children:e.jsxs("section",{className:"relative h-screen overflow-hidden bg-muted/30",children:[e.jsx(ee,{className:"absolute inset-0"}),e.jsx("div",{className:"absolute top-8 left-8 z-20",children:e.jsx(q,{variant:"ghost",onClick:()=>window.location.href=`/${u}`,className:"bg-black/20 backdrop-blur-sm border border-white/30 text-white hover:bg-white/20 w-12 h-12 p-0",children:e.jsx(He,{className:"h-5 w-5"})})})]})});const p=j=>j?new Date(j).toLocaleDateString(It(c),{year:"numeric",month:"long",day:"numeric"}):"",A=()=>!o.location&&!o.date?null:o.location&&o.date?`${o.location} ⢠${p(o.date)}`:o.location||p(o.date);return e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-background via-background to-muted/20 template-clean-light",children:[C&&e.jsx("div",{className:"bg-yellow-500 text-yellow-900 px-4 py-2 text-center font-medium text-sm",children:"ð PREVIEW MODE - This gallery is not currently visible to your audience"}),be&&_e()&&e.jsxs("section",{className:"relative h-screen overflow-hidden",children:[!ke&&e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-zinc-800 via-zinc-900 to-black",children:e.jsx("div",{className:"absolute inset-0 overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/5 to-transparent animate-shimmer"})})}),e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("img",{src:_e(),alt:o.title,fetchPriority:"high",decoding:"async",className:we("w-full h-full object-cover transition-opacity duration-500",ke?"opacity-100":"opacity-0"),onLoad:Ue,onError:Ve}),e.jsx("div",{className:we("absolute inset-0 bg-black/30 transition-opacity duration-500",ke?"opacity-100":"opacity-0")})]}),e.jsxs("div",{className:we("relative z-10 h-full flex flex-col items-center justify-center transition-opacity duration-500",ke?"opacity-100":"opacity-0"),children:[e.jsxs("div",{className:"text-center text-white px-4 max-w-5xl",children:[e.jsx("h1",{className:"text-4xl md:text-[3rem] md:leading-[3.2rem] lg:text-[3rem] lg:leading-[3.2rem] font-semibold mb-6 tracking-wide uppercase break-words overflow-wrap-anywhere text-center",children:o.title}),e.jsx("div",{className:"mb-12",children:(o.location||o.date)&&e.jsx("p",{className:"text-xl md:text-2xl font-light tracking-normal",children:o.location&&o.date?e.jsxs("span",{style:{fontSize:"1.3rem"},children:[o.location," ",e.jsx("span",{style:{fontSize:"1.3rem"},children:"|"})," ",p(o.date)]}):o.location?e.jsx("span",{children:o.location}):e.jsx("span",{children:p(o.date)})})}),e.jsx("div",{className:"mb-16",children:e.jsx(q,{onClick:()=>{const j=document.getElementById("gallery-content");j&&j.scrollIntoView({behavior:"smooth"})},className:"bg-transparent border border-white text-white hover:bg-white hover:text-black px-8 py-3 text-xs font-medium tracking-wider up
41percase transition-all duration-300 rounded-[2px]",children:m("landingPage.galleries.viewGallery")||"VIEW GALLERY"})})]}),(t.light_logo_url||t.logo_url)&&e.jsx("div",{className:"absolute bottom-12 left-1/2 transform -translate-x-1/2",children:e.jsx("img",{src:t.light_logo_url||t.logo_url,alt:t.name,className:`h-11 md:h-14 opacity-100 ${t.light_logo_url?"":"filter brightness-0 invert"}`})})]}),e.jsx("div",{className:"absolute top-8 left-8 z-20",children:e.jsx(q,{variant:"ghost",onClick:()=>window.location.href=`/${u}`,className:"bg-black/20 backdrop-blur-sm border border-white/30 text-white hover:bg-white/20 w-12 h-12 p-0",children:e.jsx(He,{className:"h-5 w-5"})})})]}),e.jsxs("main",{id:"gallery-content",className:"container mx-auto px-4 lg:px-8 pt-4 lg:pt-0 pb-12",children:[!o.cover_image_url&&e.jsxs("div",{className:"mb-12",children:[e.jsxs(q,{variant:"ghost",onClick:()=>window.location.href=`/${u}`,className:"mb-8",children:[e.jsx(He,{className:"h-4 w-4 mr-2"}),m("common.back")]}),e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-6",children:o.title}),o.description&&e.jsx("p",{className:"text-xl text-muted-foreground mb-8 max-w-3xl mx-auto",children:o.description}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-8 text-muted-foreground",children:[o.location&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-5 w-5"}),e.jsx("span",{className:"text-lg",children:o.location})]}),o.date&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ct,{className:"h-5 w-5"}),e.jsx("span",{className:"text-lg",children:p(o.date)})]})]})]})]}),o.cover_image_url&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"lg:hidden sticky top-0 h-4 -mt-4 bg-background z-20 pointer-events-none","aria-hidden":"true"}),e.jsxs("div",{ref:K,className:"lg:hidden sticky top-4 z-20 bg-background pb-3",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-lg font-bold truncate",children:o.title}),e.jsxs("p",{className:"text-sm text-muted-foreground truncate",children:[t.name,A()&&` ⢠${A()}`]})]}),e.jsx(q,{variant:"default",size:"sm",onClick:()=>re(!0),className:"h-10 w-10 p-0 bg-black hover:bg-black/90 text-white flex-shrink-0",children:e.jsx(mt,{className:"h-4 w-4"})})]})}),e.jsx("div",{className:"mt-3",children:e.jsx(Ht,{activeTab:O,onTabChange:L,itemCounts:{photos:Pe,videos:Ne},fanUploadEnabled:H,companySlug:u,gallerySlug:a})})]}),e.jsx("div",{ref:B,className:"hidden lg:block sticky top-0 z-20 bg-background mb-2",children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-6 lg:mb-3 lg:mt-1.5",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[t.logo_url?e.jsx("img",{src:t.logo_url,alt:t.name,className:"h-16 w-auto object-contain"}):e.jsx("div",{className:"h-16 w-16 bg-muted border-2 border-border flex items-center justify-center",children:e.jsx("span",{className:"text-xl font-bold text-muted-foreground",children:t.name.charAt(0).toUpperCase()})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-[1.2rem] md:text-2xl font-bold",children:o.title}),e.jsx(q,{variant:"ghost",size:"sm",onClick:()=>re(!0),className:"h-8 w-8 p-0 hover:bg-muted",children:e.jsx(mt,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-muted-foreground",children:[t.name,A()&&e.jsxs("span",{className:"ml-2",children:["⢠",A()]})]}),o.description&&e.jsx("p",{className:"text-muted-foreground mt-2 max-w-2xl",children:o.description})]})]}),e.jsx("div",{children:e.jsx(Ht,{activeTab:O,onTabChange:L,itemCounts:{photos:Pe,videos:Ne},fanUploadEnabled:H,companySlug:u,gallerySlug:a})})]})})]}),e.jsxs("div",{ref:ie,className:"space-y-6 lg:space-y-3",children:[fe?e.jsxs("div",{className:"py-24 text-center text-muted-foreground flex flex-col items-center gap-4",children:[e.jsx("p",{className:"text-base",children:m("gallery.leadCapture.gatedDescription")}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[e.jsx(q,{variant:"default",onClick:()=>{Ce.current=!1,T(!0)},children:m("gallery.leadCapture.cta")}),e.jsxs(q,{variant:"outline",onClick:Ae,children:[e.jsx(He,{className:"h-4 w-4 mr-2"}),m("gallery.leadCapture.goBack")]})]})]}):V&&S.length===0?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2 md:gap-3 py-4",children:[...Array(8)].map((j,z)=>e.jsx(ee,{className:"aspect-square w-full rounded"},z))}):e.jsx(Gs,{items:Te,gallery:o,companyId:t.id,companyViewMode:t.gallery_view_mode,company:t}),!fe&&o&&e.jsx(js,{galleryId:o.id,companyId:t.id,companyName:t.name,companySlug:u,gallerySlug:o.slug,fanUploadEnabled:H})]})]}),e.jsx(ir,{companyName:t.name,companySlug:u,companyId:t.id}),e.jsx(Rt,{isOpen:Q,onClose:()=>
41re(!1),url:window.location.href,title:o==null?void 0:o.title,description:o==null?void 0:o.description,galleryId:o==null?void 0:o.id,companyId:t.id}),fe&&be&&_e()&&e.jsxs("div",{className:"fixed inset-0 z-50 pointer-events-none overflow-hidden",children:[e.jsx("img",{src:_e(),alt:"","aria-hidden":"true",className:"w-full h-full object-cover",onError:Ve}),e.jsx("div",{className:"absolute inset-0 bg-black/30"})]}),o&&e.jsx(Tt,{isOpen:$,onClose:Ae,contentTitle:o.title,onSubmit:Fe,isLoading:W,mode:"gallery_open",dismissible:!0,companyName:t.name,companySlug:u})]})},Hs=()=>e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-background via-background to-muted/20",children:[e.jsx("header",{className:"border-b border-border/50 bg-background/80 backdrop-blur-sm",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ee,{className:"h-10 w-32 rounded-md"}),e.jsxs("div",{className:"hidden md:flex items-center gap-6",children:[e.jsx(ee,{className:"h-4 w-16"}),e.jsx(ee,{className:"h-4 w-20"}),e.jsx(ee,{className:"h-4 w-16"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ee,{className:"h-8 w-8 rounded-full"}),e.jsx(ee,{className:"h-8 w-8 rounded-full"}),e.jsx(ee,{className:"h-8 w-8 rounded-full"})]})]})})}),e.jsxs("main",{className:"container mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(ee,{className:"h-24 w-24 rounded-full"})}),e.jsx(ee,{className:"h-10 w-64 mx-auto mb-4"}),e.jsxs("div",{className:"max-w-2xl mx-auto space-y-2",children:[e.jsx(ee,{className:"h-4 w-full"}),e.jsx(ee,{className:"h-4 w-4/5 mx-auto"}),e.jsx(ee,{className:"h-4 w-3/5 mx-auto"})]}),e.jsxs("div",{className:"flex justify-center gap-4 mt-6",children:[e.jsx(ee,{className:"h-10 w-32 rounded-md"}),e.jsx(ee,{className:"h-10 w-32 rounded-md"})]})]}),e.jsx("div",{className:"flex justify-center mt-[30px] mb-16",children:e.jsx(tr,{className:"w-24 bg-muted-foreground/30"})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:Array.from({length:8}).map((t,n)=>e.jsx(Ys,{index:n},n))})]}),e.jsx("footer",{className:"border-t border-border/50 bg-muted/30 mt-16",children:e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsx(ee,{className:"h-4 w-48"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ee,{className:"h-4 w-24"}),e.jsx(ee,{className:"h-4 w-24"})]})]})})})]}),Ys=({index:t})=>{const n=`${t*75}ms`;return e.jsxs("div",{className:"group relative overflow-hidden rounded-xl border border-border/50 bg-card animate-pulse",style:{animationDelay:n},children:[e.jsx("div",{className:"aspect-[4/3] relative",children:e.jsx(ee,{className:"absolute inset-0 rounded-t-xl"})}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(ee,{className:"h-5 w-3/4"}),e.jsx(ee,{className:"h-3 w-1/2"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ee,{className:"h-3 w-full"}),e.jsx(ee,{className:"h-3 w-2/3"})]})]})]})},Ks=()=>e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-zinc-800 via-zinc-900 to-black relative",children:e.jsx("div",{className:"absolute inset-0 overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/5 to-transparent animate-shimmer"})})}),Xs=({identifier:t,source:n,enabled:a=!0})=>{const u=Dt();return ht({queryKey:["company-public",t,n],queryFn:async()=>{if(!t)return null;console.log("[useCompanyPublicData] Fetching:",t,"source:",n);let m=null;if(n==="subdirectory")try{const c=await Y.rpc("get_company_public_data",{p_slug:t}).maybeSingle();m=c.data,!m&&!c.error&&(m=(await Y.rpc("get_company_public_data",{p_subdomain:t}).maybeSingle()).data)}catch{const{data:x,error:d}=await Y.from("companies").select("*").eq("slug",t).maybeSingle();d||(m=x)}else try{m=(await Y.rpc("get_company_public_data",{p_subdomain:t}).maybeSingle()).data}catch{const{data:x,error:d}=await Y.from("companies").select("*").eq("slug",t).maybeSingle();d||(m=x)}return m||null},enabled:a&&!!t,...u.company,retry:2})},Js=(t,n="clean_light")=>{const a=Dt();return ht({queryKey:["company-customization",t,n],queryFn:async()=>
41{if(!t)return null;const{data:u,error:m}=await Y.from("landing_page_customizations").select("*").eq("company_id",t).eq("template_type",n).maybeSingle();if(m)throw m;return u},enabled:!!t,...a.customization})},Qs=["drophighlight.com","www.drophighlight.com"],Zs=({subdomain:t,source:n="subdomain"})=>{const a=Kr(),{t:u}=ye(),m=window.location.pathname.split("/").filter(Boolean),c=n==="subdirectory"?m[0]:void 0,x=(()=>{const L=m.indexOf("highlights");if(L!==-1&&m[L+1])return m[L+1]})(),d=(()=>{const L=m.indexOf("evento");if(L!==-1&&m[L+1])return m[L+1]})(),b=n==="subdirectory"?window.location.pathname.startsWith("/demo")?"demo":a.clientSlug||c:t,k=a.eventSlug||d,N=a.gallerySlug||x,y=b&&st.includes(b.toLowerCase()),l=b&&!y,{data:o,isLoading:f,error:S}=Xs({identifier:b,source:n,enabled:l}),{data:R}=Js(o==null?void 0:o.id,(o==null?void 0:o.template_type)||"clean_light");if(Xr(void 0,o||void 0),s.useEffect(()=>{const L=window.location.hostname,C=window.location.pathname.split("/").filter(Boolean)[0];if(C&&!st.includes(C.toLowerCase())){console.log("[PersonalizedLandingPage] Path válido na URL, não redirecionar:",C);return}if(b&&!st.includes(b.toLowerCase())){console.log("[PersonalizedLandingPage] identifier válido encontrado:",b);return}if(Qs.includes(L)&&!b){console.log("[PersonalizedLandingPage] DomÃnio raiz sem identifier, redirecionando para /en"),window.location.replace("/en");return}if(b&&st.includes(b.toLowerCase())){console.log("[PersonalizedLandingPage] Rota reservada:",b,"- redirecionando para /en"),window.location.replace("/en");return}},[b,t]),y)return null;const E=!f&&!o&&!!b&&n==="subdirectory",{loading:G,currentSlug:V}=xs(E?b:void 0,E);if(f||G)return N?e.jsx(Ks,{}):e.jsx(Hs,{});if(!o&&V){const L=window.location.pathname.split("/").filter(Boolean).slice(1).join("/"),Q=`/${V}${L?"/"+L:""}${window.location.search}${window.location.hash}`;return e.jsx(Jr,{to:Q,replace:!0})}if(S||!o){const L=S instanceof Error?S.message:u("landingPage.companyNotFound");return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-6xl mb-4",children:"ð"}),e.jsx("h1",{className:"text-4xl font-bold text-foreground mb-4",children:u("errors.notFound")}),e.jsx("p",{className:"text-muted-foreground",children:L})]})})}const oe=o.template_type||"clean_light",O=o.slug||"";if(k)switch(oe){case"clean_light":default:return e.jsx(Ts,{company:o,eventSlug:k,companySlug:O})}if(N)switch(oe){case"clean_light":default:return e.jsx(Ws,{company:o,gallerySlug:N,companySlug:O})}switch(oe){case"clean_light":default:return e.jsx(Ps,{company:o,customization:R})}},Bn=t=>e.jsx(Zs,{...t});export{Bn as PersonalizedLandingPage};
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.