1import{j as e,r as l}from"./vendor-react-De19kUq8.js";import{B as _,$ as ve,H as je,x as A,X as W,bj as ue,a as U,G as ye,s as le,h as q,Z as we,L as ne,b4 as Ne,E as Ce,w as ae,P as ke,al as me,D as Se,m as Ee,k as Re,n as Ie,p as Le,cv as _e,ax as K,C as fe,j as Oe,a5 as ee,aB as ze,ar as Ve,ai as Me,ah as Pe,aj as Ae,cm as De}from"./index-BNqnZmmX.js";import{c as he,L as re,g as Fe}from"./vendor-app-DH33cvx6.js";import{u as Te,a as $e,b as Be}from"./useVenuesWithCoords-CV6FvyeG.js";import{c as Ue}from"./index-BZM8LO45.js";import{F as xe}from"./filter-BTtr7B1B.js";import{m as ie}from"./vendor-map-Bc-sylbD.js";import{a as We,P as pe,A as ge,S as He,C as Ge,b as Ye,M as Qe,D as qe,c as Xe}from"./mapConfig-DsGDalZO.js";import{L as X}from"./label-BdtRRvBI.js";import{n as Ze,b as Je}from"./search-CzucOSHG.js";import{R as oe}from"./rotate-ccw-B64IHgT4.js";import{D as Ke,a as es,b as ss,c as ts,e as ns}from"./drawer-CZ0aB8qe.js";import"./vendor-ui-pO556hdz.js";import"./vendor-supabase-Bm92Y2YK.js";const Z=Ue(n=>({selectedRegions:[],searchQuery:"",showOnlyWithEvents:!1,showOnlyVerified:!1,showEvents:!1,selectedVenueId:null,isSidebarOpen:!1,mapBounds:null,toggleRegion:o=>n(c=>({selectedRegions:c.selectedRegions.includes(o)?c.selectedRegions.filter(i=>i!==o):[...c.selectedRegions,o]})),setSelectedRegions:o=>n({selectedRegions:o}),setSearchQuery:o=>n({searchQuery:o}),setShowOnlyWithEvents:o=>n({showOnlyWithEvents:o}),setShowOnlyVerified:o=>n({showOnlyVerified:o}),setShowEvents:o=>n({showEvents:o}),setSelectedVenueId:o=>n({selectedVenueId:o}),setIsSidebarOpen:o=>n({isSidebarOpen:o}),setMapBounds:o=>n({mapBounds:o}),resetFilters:()=>n({selectedRegions:[],searchQuery:"",showOnlyWithEvents:!1,showOnlyVerified:!1,showEvents:!1})}));function rs({venueCount:n,totalVenueCount:o,activeRegionName:c,onClearRegion:i}){const{isSidebarOpen:f,setIsSidebarOpen:g,selectedRegions:t,showOnlyWithEvents:j,showOnlyVerified:N,showEvents:m}=Z(),v=he(),x=(t.length>0?1:0)+(j?1:0)+(N?1:0)+(m?1:0);return e.jsxs("header",{className:"h-14 bg-card/95 backdrop-blur-md border-b border-border/50 flex items-center px-3 sm:px-4 gap-2 sm:gap-3 z-50",children:[e.jsx(_,{variant:"ghost",size:"sm",className:"sm:hidden h-8 w-8 p-0",onClick:()=>v("/"),"aria-label":"Retour à l'accueil",children:e.jsx(ve,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"ghost",size:"sm",className:"hidden sm:flex h-8 gap-2",onClick:()=>v("/"),children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Accueil"})]}),e.jsx("div",{className:"h-6 w-px bg-border/50 hidden sm:block"}),e.jsxs(re,{to:"/",className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(A,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-display font-bold text-lg hidden md:inline",children:"Sortir"})]}),e.jsx("div",{className:"h-6 w-px bg-border/50 hidden md:block"}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground hidden md:block",children:"Carte des lieux"}),c&&t.length===1&&i&&e.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-primary/10 text-primary text-xs font-medium hover:bg-primary/20 transition-colors",children:[c,e.jsx(W,{className:"h-3 w-3"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground ml-auto sm:ml-0",children:[n," lieu",n!==1?"x":"",o!=null&&o!==n&&e.jsxs("span",{className:"hidden sm:inline",children:[" / ",o]})]}),e.jsx("div",{className:"flex-1"}),e.jsx(re,{to:"/lieux",children:e.jsxs(_,{variant:"default",size:"sm",className:"h-8",children:[e.jsx(ue,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Liste"})]})}),e.jsxs(_,{variant:f?"secondary":"outline",size:"sm",className:"h-8 relative",onClick:()=>g(!f),children:[e.jsx(xe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Filtres"}),x>0&&e.jsx(U,{variant:"default",className:"absolute -top-1.5 -right-1.5 h-4 w-4 p-0 flex items-center justify-center text-[10px]",children:x})]})]})}function as(n){const{isVerified:o,eventCount:c,isSelected:i}=n,f=108,g=document.createElement("canvas");g.width=f,g.height=f;const t=g.getContext("2d"),j=f/2,N=f/2,m=f/2-8;if(t.shadowColor="rgba(0, 0, 0, 0.35)",t.shadowBlur=12,t.shadowOffsetY=3,t.beginPath(),t.arc(j,N,m,0,Math.PI*2),t.fillStyle=i?We:pe,t.fill(),t.shadowColor="transparent",t.strokeStyle=i?"#ffffff"
1:"rgba(255, 255, 255, 0.9)",t.lineWidth=i?5:4,t.stroke(),t.fillStyle="#ffffff",t.font=`${f*.38}px "Segoe UI Emoji", "Apple Color Emoji", sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText("ð",j,N),o){const v=f-20,x=20;t.beginPath(),t.arc(v,x,14,0,Math.PI*2),t.fillStyle=ge,t.fill(),t.strokeStyle="#ffffff",t.lineWidth=2.5,t.stroke(),t.fillStyle="#ffffff",t.font="bold 14px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("â",v,x)}if(c>0){const v=f-20,x=f-20;t.beginPath(),t.arc(v,x,14,0,Math.PI*2),t.fillStyle=He,t.fill(),t.strokeStyle="#ffffff",t.lineWidth=2.5,t.stroke(),t.fillStyle="#ffffff",t.font="bold 12px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(c>9?"9+":String(c),v,x)}return t.getImageData(0,0,f,f)}function se(n){return`venue-icon-${n.isVerified?"v":"n"}-${n.eventCount}-${n.isSelected?"s":"u"}`}function ls(n){const c=document.createElement("canvas");c.width=80,c.height=80;const i=c.getContext("2d"),f=80/2,g=80/2,t=80/2-6;return i.shadowColor="rgba(0, 0, 0, 0.3)",i.shadowBlur=8,i.shadowOffsetY=2,i.beginPath(),i.arc(f,g,t,0,Math.PI*2),i.fillStyle=n?"#b8900e":ge,i.fill(),i.shadowColor="transparent",i.strokeStyle=n?"#ffffff":"rgba(255,255,255,0.9)",i.lineWidth=n?4:3,i.stroke(),i.fillStyle="#ffffff",i.font=`${80*.35}px "Segoe UI Emoji", "Apple Color Emoji", sans-serif`,i.textAlign="center",i.textBaseline="middle",i.fillText("ð",f,g),i.getImageData(0,0,80,80)}function is(n){return`event-icon-${n?"s":"u"}`}const te={small:pe,medium:"#1e3a5f",large:"#0f1f3a"},be=l.forwardRef(({venues:n,onVenueSelect:o,initialCenter:c,initialZoom:i=10},f)=>{const g=l.useRef(null),t=l.useRef(null),j=l.useRef(new Set),N=l.useRef(n),[m,v]=l.useState(!1),x=l.useRef(!1),{selectedVenueId:C,setSelectedVenueId:V,showEvents:S}=Z();l.useImperativeHandle(f,()=>({flyTo:(s,u,h=12)=>{t.current&&t.current.flyTo({center:[u,s],zoom:h,duration:1500})}})),l.useEffect(()=>{N.current=n},[n]);const L=n,R=l.useCallback(()=>({type:"FeatureCollection",features:L.map(s=>({type:"Feature",geometry:{type:"Point",coordinates:[s.longitude,s.latitude]},properties:{id:s.id,name:s.name,isVerified:s.is_verified,eventCount:s.event_count,isSelected:s.id===C,iconId:se({isVerified:s.is_verified,eventCount:s.event_count,isSelected:s.id===C})}}))}),[L,C]),O=l.useCallback(()=>({type:"FeatureCollection",features:[]}),[]),E=l.useCallback(s=>{const u=[];L.forEach(h=>{const y={isVerified:h.is_verified,eventCount:h.event_count,isSelected:!1},w=se(y);j.current.has(w)||u.push({id:w,options:y});const k={isVerified:h.is_verified,eventCount:h.event_count,isSelected:!0},d=se(k);j.current.has(d)||u.push({id:d,options:k})}),u.forEach(({id:h,options:y})=>{if(!s.hasImage(h)){const w=as(y);s.addImage(h,w,{pixelRatio:2}),j.current.add(h)}})},[L]),I=l.useCallback(s=>{s.getLayer("venues-icons")&&s.removeLayer("venues-icons"),s.getLayer("clusters-count")&&s.removeLayer("clusters-count"),s.getLayer("clusters-circles")&&s.removeLayer("clusters-circles"),s.getSource("venues-source")&&s.removeSource("venues-source"),E(s),s.addSource("venues-source",{type:"geojson",data:R(),cluster:!0,clusterMaxZoom:Ge,clusterRadius:Ye}),s.addLayer({id:"clusters-circles",type:"circle",source:"venues-source",filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],te.small,10,te.medium,50,te.large],"circle-radius":["step",["get","point_count"],24,10,32,50,40],"circle-stroke-width":3,"circle-stroke-color":"#ffffff"}}),s.addLayer({id:"clusters-count",type:"symbol",source:"venues-source",filter:["has","point_count"],layout:{"text-field":["get","point_count_abbreviated"],"text-size":14},paint:{"text-color":"#ffffff"}}),s.addLayer({id:"venues-icons",type:"symbol",source:"venues-source",filter:["!",["has","point_count"]],layout:{"icon-image":["get","iconId"],"icon-size":.65,"icon-allow-overlap":!0,"icon-ignore-placement":!0}})},[R,E]),M=l.useCallback(s=>{s.getLayer("events-icons")&&s.removeLayer("events-icons"),s.getSource("events-source")&&s.removeSource("events-source"),["s","u"].forEach(u=>{const h=u==="s",y=is(h);s.hasImage(y)||s.addImage(y,ls(h),{pixelRatio:2})}),s.addSource("events-source",{type:"geojson",data:O()}),s.addLayer({id:"events-icons",type:"symbol",source:"events-source",layout:{"icon-image":["get","iconId"],"icon-size":.55,"icon-allow-overlap":!0,"icon-ignore-placement":!0,visibility:"none"}})},[O]);return l.useEffect(()=>{if(!g.current||t.current)return;const s=new ie.Map({container:g.current,style:Qe,center:qe,zoom:Xe,pitch:0,maxPitch:0});return s.dragRotate.disable(),s.touchPitch.disable(),s.addControl(new ie.NavigationControl({visualizePitch:!1}),"bottom-right"),s.on("load",()=>
1{t.current=s,v(!0),I(s),M(s),s.getStyle().layers.forEach(u=>{var h;u.type==="symbol"&&((h=u.layout)!=null&&h["text-field"])&&s.setLayoutProperty(u.id,"text-field",["coalesce",["get","name:fr"],["get","name"]])})}),s.on("click","clusters-circles",async u=>{var k;const h=s.queryRenderedFeatures(u.point,{layers:["clusters-circles"]});if(!h.length)return;const y=(k=h[0].properties)==null?void 0:k.cluster_id,w=s.getSource("venues-source");try{const d=await w.getClusterExpansionZoom(y),D=h[0].geometry.coordinates;s.easeTo({center:D,zoom:d,duration:500})}catch(d){console.error("Error expanding cluster:",d)}}),s.on("click","venues-icons",u=>{var k;const h=s.queryRenderedFeatures(u.point,{layers:["venues-icons"]});if(!h.length)return;const y=(k=h[0].properties)==null?void 0:k.id,w=N.current.find(d=>d.id===y);w&&(V(w.id),o(w),s.flyTo({center:[w.longitude,w.latitude],zoom:12,duration:1500}))}),s.on("mouseenter","clusters-circles",()=>{s.getCanvas().style.cursor="pointer"}),s.on("mouseleave","clusters-circles",()=>{s.getCanvas().style.cursor=""}),s.on("mouseenter","venues-icons",()=>{s.getCanvas().style.cursor="pointer"}),s.on("mouseleave","venues-icons",()=>{s.getCanvas().style.cursor=""}),()=>{s.remove(),t.current=null}},[]),l.useEffect(()=>{!t.current||!m||!c||x.current||(x.current=!0,t.current.flyTo({center:[c.lng,c.lat],zoom:i,duration:1500}))},[c,i,m]),l.useEffect(()=>{if(!t.current||!m)return;const s=t.current,u=s.getSource("venues-source");u&&(E(s),u.setData(R()))},[L,C,m,R,E]),l.useEffect(()=>{if(!t.current||!m)return;const s=t.current;if(s.getLayer("events-icons")&&(s.setLayoutProperty("events-icons","visibility",S?"visible":"none"),S)){const u=s.getSource("events-source");u&&u.setData(O())}},[S,m,O]),l.useEffect(()=>{if(!t.current||!m||!C)return;const s=n.find(u=>u.id===C);s&&t.current.flyTo({center:[s.longitude,s.latitude],zoom:12,duration:1500})},[C,n,m]),e.jsxs("div",{className:"relative flex-1 h-full",children:[e.jsx("div",{ref:g,className:"absolute inset-0"}),e.jsx("div",{className:"absolute inset-x-0 bottom-0 h-24 pointer-events-none bg-gradient-to-t from-background/30 to-transparent"})]})});be.displayName="VenuesMapView";function os({value:n,onChange:o,onVenueSelect:c,onEventSelect:i,placeholder:f="Rechercher une adresse, un lieu, un événement...",className:g,showVenues:t=!0,showEvents:j=!0,initialCity:N}){const[m,v]=l.useState((n==null?void 0:n.label)||(N?`Près de ${N}`:"")),[x,C]=l.useState([]),[V,S]=l.useState(!1),[L,R]=l.useState(!1),[O,E]=l.useState(!1),[I,M]=l.useState(-1),s=l.useRef(null),u=l.useRef(null),h=l.useRef(null),y=l.useCallback(async r=>{if(r.length<2){C([]),S(!1);return}R(!0);try{const a=[],p=Ze(r),z=Je(p),P=new Date().toISOString(),[$,Y,Q]=await Promise.allSettled([ye(r,3),t?le.from("venues").select("id, slug, name, city, latitude, longitude").ilike("name_normalized",z).eq("status","published").limit(3):Promise.resolve({data:[]}),j?le.from("events").select("id, slug, title, datetime_start, venues!events_venue_id_fkey(name)").ilike("title_normalized",z).eq("status","PUBLISHED").or(`datetime_start.gte.${P},datetime_end.gte.${P}`).order("datetime_start",{ascending:!0}).limit(3):Promise.resolve({data:[]})]);$.status==="fulfilled"&&$.value.forEach(b=>{a.push({type:"address",label:b.label,city:b.city,lat:b.lat,lng:b.lng})}),Y.status==="fulfilled"&&Y.value.data&&Y.value.data.forEach(b=>{a.push({type:"venue",id:b.id,slug:b.slug,name:b.name,city:b.city,lat:b.latitude,lng:b.longitude})}),Q.status==="fulfilled"&&Q.value.data&&Q.value.data.forEach(b=>{var B;a.push({type:"event",id:b.id,slug:b.slug,title:b.title,datetime_start:b.datetime_start,venue_name:(B=b.venues)==null?void 0:B.name})}),C(a),S(a.length>0),M(-1)}catch(a){console.error("Search error:",a),C([])}finally{R(!1)}},[t,j]),w=r=>{const a=r.target.value;v(a),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{y(a)},300)},k=r=>{S(!1),C([]),r.type==="address"?(v(r.label),o({lat:r.lat,lng:r.lng,label:r.label})):r.type==="venue"?(v(r.name),r.lat&&r.lng&&o({lat:r.lat,lng:r.lng,label:r.name}),c==null||c(r)):r.type==="event"&&(v(r.title),i==null||i(r))},d=()=>{navigator.geolocation&&(E(!0),navigator.geolocation.getCurrentPosition(async r=>{var z,P,$;const{latitude:a,longitude:p}=r.coords;try{const b=(z=(await(await fetch(`https://photon.komoot.io/reverse?lat=${a}&lon=${p}`)).json()).features)==null?void 0:z[0],B=((P=b==null?void 0:b.properties)==null?void 0:P.city)||(($=b==null?void 0:b.properties)==null?void 0:$.name)||"Ma position";v(B),o({lat:a,lng:p,label:B})}catch{v("Ma position"),o({lat:a,lng:p,label:"Ma position"})}E(!1)},r=>{console.error("Geolocation error:",r),E(!1)},{enableHighAccuracy:!0,timeout:1e4}))},D=()=>{var r;v(""),C([]),S(!1),o(null),(r=s.current)==null||r.focus()},H=r=>{if(V)switch(r.key){case"ArrowDown":r.preventDefault(),M(a=>a<x.length-1?a+1:a);break;case"ArrowUp":r.preventDefault(),M(a=>a>0?a-1:a);break;case"Enter":r.preventDefault(),I>=0&&x[I]&&k(x[I]);break;case"Escape":S(!1);break}};l.useEffect(()=>{const r=a=>{u.current&&!u.current.contains(a.target)&&S(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[]),l.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]);const T=x.filter(r=>r.type==="address"),F=x.filter(r=>r.type==="venue"),G=x.filter(r=>r.type==="event"),J=r=>r?ke(r,"d MMM"):"";return e.jsxs("div",{ref:u,className:q("relative w-full",g),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(A,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}
1),e.jsx(we,{ref:s,type:"text",value:m,onChange:w,onKeyDown:H,onFocus:()=>x.length>0&&S(!0),placeholder:f,className:"pl-10 pr-10 bg-background/50 backdrop-blur-sm border-border/50 h-12"}),L&&e.jsx(ne,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 animate-spin text-muted-foreground"}),!L&&m&&e.jsx("button",{type:"button",onClick:D,className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(W,{className:"h-4 w-4"})})]}),e.jsx(_,{type:"button",variant:"outline",size:"icon",onClick:d,disabled:O,className:"h-12 w-12 shrink-0 bg-background/50 backdrop-blur-sm border-border/50",title:"Utiliser ma position",children:O?e.jsx(ne,{className:"h-4 w-4 animate-spin"}):e.jsx(Ne,{className:"h-4 w-4"})})]}),V&&x.length>0&&e.jsxs("div",{className:"absolute z-50 w-full mt-2 py-2 bg-card backdrop-blur-md border border-border/50 rounded-xl shadow-xl overflow-hidden animate-in fade-in-0 zoom-in-95 duration-150 max-h-48 sm:max-h-80 overflow-y-auto",children:[T.length>0&&e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"ð Adresses"}),T.map((r,a)=>{const p=a;return e.jsxs("button",{type:"button",onClick:()=>k(r),className:q("w-full flex items-start gap-3 px-4 py-2.5 text-left transition-colors",I===p?"bg-primary/10":"hover:bg-muted/50"),children:[e.jsx(A,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"text-sm truncate",children:r.label})]},`addr-${r.lat}-${r.lng}`)})]}),F.length>0&&e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"ðï¸ Lieux"}),F.map((r,a)=>{const p=T.length+a;return e.jsxs("button",{type:"button",onClick:()=>k(r),className:q("w-full flex items-start gap-3 px-4 py-2.5 text-left transition-colors",I===p?"bg-primary/10":"hover:bg-muted/50"),children:[e.jsx(Ce,{className:"h-4 w-4 mt-0.5 shrink-0 text-primary"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium truncate block",children:r.name}),r.city&&e.jsx("span",{className:"text-xs text-muted-foreground",children:r.city})]})]},`venue-${r.id}`)})]}),G.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"ð Ãvénements"}),G.map((r,a)=>{const p=T.length+F.length+a;return e.jsxs("button",{type:"button",onClick:()=>k(r),className:q("w-full flex items-start gap-3 px-4 py-2.5 text-left transition-colors",I===p?"bg-primary/10":"hover:bg-muted/50"),children:[e.jsx(ae,{className:"h-4 w-4 mt-0.5 shrink-0 text-accent"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium truncate block",children:r.title}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[J(r.datetime_start),r.venue_name&&` ⢠${r.venue_name}`]})]})]},`event-${r.id}`)})]})]})]})}function cs({venues:n,isLoading:o,onCenterMap:c}){const i=he(),f=me(),{searchQuery:g,selectedRegions:t,toggleRegion:j,setSelectedRegions:N,showOnlyWithEvents:m,setShowOnlyWithEvents:v,showOnlyVerified:x,setShowOnlyVerified:C,showEvents:V,setShowEvents:S,isSidebarOpen:L,setIsSidebarOpen:R,resetFilters:O}=Z(),{data:E=[]}=Te(),I=n,M=g||t.length>0||m||x,s=l.useMemo(()=>{let d=0;return t.length>0&&d++,m&&d++,x&&d++,d},[t,m,x]),u=l.useMemo(()=>E.filter(d=>t.includes(d.id)).map(d=>d.name),[E,t]),h=l.useCallback(d=>{d&&(c==null||c(d.lat,d.lng),f&&R(!1))},[c,f,R]),y=l.useCallback(d=>{d.lat&&d.lng&&(c==null||c(d.lat,d.lng)),f&&R(!1)},[c,f,R]),w=l.useCallback(d=>{i(`/evenements/${d.slug}`)},[i]),k=e.jsxs("div",{className:"flex flex-col h-full bg-card/95 backdrop-blur-md",children:[e.jsxs("div",{className:"p-4 border-b border-border/50 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Filtres"}),s>0&&e.jsx(U,{variant:"secondary",className:"h-5 px-1.5 text-xs",children:s})]}),e.jsx(_,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>R(!1),children:e.jsx(W,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"p-4 border-b border-border/50",children:[e.jsx(os,{onChange:h,onVenueSelect:y,onEventSelect:w,placeholder:"Rechercher un lieu, une adresse...",showEvents:!1,showVenues:!0}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-3 flex items-center gap-1.5",children:[e.jsx(A,{className:"h-3 w-3"}),o?e.jsx("span",{className:"inline-block h-3 w-28 animate-pulse rounded bg-muted"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:I.length})," lieu",I.length!==1?"x":""," sur la carte"]})]})]}),e.jsxs("div",{className:"p-4 space-y-5 flex-1",children:[E.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{className:"text-xs text-muted-foreground",children:"Région"}),e.jsxs(Se,{children:[e.jsx(Ee,{asChild:!0,children:e.jsxs(_,{variant:"outline",className:"w-full justify-between h-10 text-sm font-normal bg-background/50",children:[t.length===0?e.jsx("span",{className:"text-muted-foreground",children:"Toutes les régions"}):t.length===1?e.jsx("span",{className:"truncate",children:u[0]}):e.jsxs("span",{children:[t.length," régions"]}),e.jsx(Re,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsxs(Ie,{className:"w-[260px] max-h-64 overflow-y-auto bg-popover z-[200]",align:"start",sideOffset:4,children:[t.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"w-full flex items-center gap-2 px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded-sm",onClick:()=>N([]),children:[e.jsx(oe,{className:"h-4 w-4"}),"Effacer la sélection"]}),e.jsx(Le,{})]}),E.map(d=>e.jsx(_e,{checked:t.includes(d.id),onCheckedChange:()=>j(d.id),onSelect:D=>D.preventDefault(),children:d.name},d.id))]})]}),t.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[u.slice(0,2).map(d=>e.jsx(U,{variant:"secondary",className:"text-xs",children:d},d)),t.length>2&&e.jsxs(U,{variant:"outline",className:"text-xs",children:["+",t.length-2]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs(X,{htmlFor:"with-events",className:"text-sm cursor-pointer flex items-center gap-2.5",children:[e.jsx(ae,{className:"h-4 w-4 text-primary/70"}),"Avec événements"]}),e.jsx(K,{id:"with-events",checked:m,onCheckedChange:v})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs(X,{htmlFor:"verified",className:"text-sm cursor-pointer flex items-center gap-2.5",children:[e.jsx(fe,{className:"h-4 w-4 text-primary/70"}),"Lieux vérifiés"]}),e.jsx(K,{id:"verified",checked:x,onCheckedChange:C})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-accent/10 hover:bg-accent/20 transition-colors border border-accent/20",children:[e.jsxs(X,{htmlFor:"show-events",className:"text-sm cursor-pointer flex items-center gap-2.5",children:[e.jsx(Oe,{className:"h-4 w-4 text-accent-foreground
1/70"}),"Ãvénements"]}),e.jsx(K,{id:"show-events",checked:V,onCheckedChange:S})]})]}),M&&e.jsxs(_,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground hover:text-foreground",onClick:O,children:[e.jsx(oe,{className:"h-3.5 w-3.5 mr-1.5"}),"Réinitialiser les filtres"]})]}),e.jsx("div",{className:"p-4 border-t border-border/50 mt-auto",children:e.jsxs(_,{variant:"outline",className:"w-full h-11 bg-background/50 hover:bg-primary hover:text-primary-foreground transition-all",onClick:()=>i("/lieux"),children:[e.jsx(ue,{className:"h-4 w-4 mr-2"}),"Voir en mode liste"]})})]});return L?f?e.jsxs("div",{className:"fixed inset-0 z-50",children:[e.jsx("div",{className:"absolute inset-0 bg-background/60 backdrop-blur-sm",onClick:()=>R(!1)}),e.jsx("div",{className:"absolute right-0 top-0 bottom-0 w-72 max-w-[calc(100vw-2rem)] shadow-xl animate-in slide-in-from-right duration-200",children:k})]}):e.jsx("div",{className:"w-72 border-l border-border/50 flex-col h-full flex",children:k}):null}function ce({venue:n,onClose:o}){var j,N;const{data:c,isLoading:i}=$e(n.id),f=(c==null?void 0:c.cover_image)||n.cover_image,g=(c==null?void 0:c.upcoming_events)||n.upcoming_events,t=(c==null?void 0:c.event_count)||n.event_count;return e.jsxs("div",{className:"flex flex-col gap-3",children:[i?e.jsx(ee,{className:"w-full h-32 rounded-lg"}):f?e.jsx("img",{src:f,alt:n.name,className:"w-full h-32 object-cover rounded-lg"}):e.jsx("div",{className:"w-full h-24 bg-muted rounded-lg flex items-center justify-center",children:e.jsx(A,{className:"h-8 w-8 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-display font-semibold text-base",children:n.name}),((c==null?void 0:c.is_verified)??n.is_verified)&&e.jsx(fe,{className:"h-4 w-4 text-primary flex-shrink-0"})]}),(n.city||((j=n.region)==null?void 0:j.name))&&e.jsx("p",{className:"text-sm text-muted-foreground",children:[n.city,(N=n.region)==null?void 0:N.name].filter(Boolean).join(", ")})]}),i?e.jsxs("div",{className:"border-t pt-3 space-y-2",children:[e.jsx(ee,{className:"h-4 w-32"}),e.jsx(ee,{className:"h-4 w-48"})]}):g.length>0?e.jsxs("div",{className:"border-t pt-3",children:[e.jsxs("h4",{className:"text-xs font-medium text-muted-foreground mb-2 flex items-center gap-1",children:[e.jsx(ae,{className:"h-3 w-3"}),"Prochains événements"]}),e.jsx("div",{className:"space-y-2",children:g.slice(0,3).map(m=>e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium truncate",children:m.title}),m.datetime_start&&e.jsx("p",{className:"text-xs text-muted-foreground",children:ze(m.datetime_start,"EEEE d MMMM")})]},m.id))}),t>3&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["+ ",t-3," autres événements"]})]}):null,e.jsx(re,{to:`/lieux/${n.slug}`,className:"mt-1",children:e.jsxs(_,{className:"w-full",size:"sm",children:[e.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Voir le lieu"]})})]})}function ds({venue:n,onClose:o,isMobile:c}){return n?c?e.jsx(Ke,{open:!!n,onOpenChange:i=>!i&&o(),children:e.jsxs(es,{className:"max-h-[80vh]",children:[e.jsx(ss,{className:"border-b pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ts,{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-4 w-4 text-primary"}),n.name]}),e.jsx(ns,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(W,{className:"h-4 w-4"})})})]})}),e.jsx("div",{className:"p-4 overflow-y-auto",children:e.jsx(ce,{venue:n,onClose:o})})]})}):e.jsx("div",{className:"absolute top-4 left-4 z-40 w-80 glass-card animate-fade-in",children:e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs(U,{variant:"secondary",className:"text-xs",children:[e.jsx(A,{className:"h-3 w-3 mr-1"}),"Lieu sélectionné"]}),e.jsx(_,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:o,children:e.jsx(W,{className:"h-4 w-4"})})]}),e.jsx(ce,{venue:n,onClose:o})]})}):null}function us({onShowAll:n,regionName:o}){return e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center pointer-events-none p-4",children:e.jsxs("div",{className:"pointer-events-auto bg-card/80 backdrop-blur-xl border border-border/50 rounded-2xl shadow-2xl p-6 max-w-sm w-full text-center space-y-4",children:[e.jsx("div",{className:"mx-auto w-12 h-12 rounded-full bg-muted flex items-center justify-center",children:e.jsx(A,{className:"h-6 w-6 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:"Aucun lieu trouvé"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o?`Aucun lieu référencé en ${o} pour le moment.`:"Aucun lieu ne correspond à vos filtres."})]}),e.jsx(_,{onClick:n,className:"w-full",children:"Voir tous les lieux de France"})]})})}const de={lat:46.6,lng:2.2};function Ss(){const{data:n}=Me(),{setSelectedVenueId:o,selectedVenueId:c,selectedRegions:i,setSelectedRegions:f,searchQuery:g,showOnlyWithEvents:t,showOnlyVerified:j,resetFilters:N}=Z(),{location:m}=Pe(),v=me(),[x,C]=l.useState(null),[V]=Fe(),[S,L]=l.useState(null),[R,O]=l.useState(null),E=l.useRef(null),I=l.useRef(!1),M=l.useRef(!1),s=(V.get("region")??"").trim().toUpperCase()||null,u=l.useMemo(()=>
1{if(!s||!(n!=null&&n.length))return null;const a=n.find(p=>p.code.toUpperCase()===s);return a!=null&&a.id?a:null},[s,n]),{data:h=[],isLoading:y,isError:w,refetch:k}=Be((u==null?void 0:u.id)??null);l.useEffect(()=>{!u||M.current||(M.current=!0,I.current=!0,f([u.id]),L(u.name),O({lat:u.centroid_lat,lng:u.centroid_lng}))},[u,f]),l.useEffect(()=>{const a=V.get("lat"),p=V.get("lng");a&&p?O({lat:parseFloat(a),lng:parseFloat(p)}):m&&!s&&O({lat:m.lat,lng:m.lng})},[V,m,s]),l.useEffect(()=>{if(I.current||!m||!(n!=null&&n.length))return;if(i.length>0){I.current=!0;return}const a=Ae(m.lat,m.lng,n,m.city,m.country,m.postal);if(a){const p=n.find(z=>z.code===a);p&&(f([p.id]),L(p.name))}I.current=!0},[m,n,i.length,f]);const d=l.useMemo(()=>h.filter(a=>{var p,z;if(g){const P=g.toLowerCase();if(!(a.name.toLowerCase().includes(P)||((p=a.city)==null?void 0:p.toLowerCase().includes(P))||((z=a.region)==null?void 0:z.name.toLowerCase().includes(P))))return!1}return!(i.length>0&&a.region&&!i.includes(a.region.id)||t&&a.event_count===0||j&&!a.is_verified)}),[h,g,i,t,j]),D=i.length>0||!!g||t||j,H=l.useMemo(()=>{var a;return i.length===1&&n?((a=n.find(p=>p.id===i[0]))==null?void 0:a.name)??S:S},[i,n,S]),T=l.useCallback(()=>{var a;N(),L(null),(a=E.current)==null||a.flyTo(de.lat,de.lng,5.5)},[N]),F=l.useCallback(a=>{C(a),o((a==null?void 0:a.id)||null)},[o]),G=l.useCallback(a=>{F(a)},[F]),J=l.useCallback(()=>{C(null),o(null)},[o]),r=l.useCallback((a,p)=>{var z;(z=E.current)==null||z.flyTo(a,p,12)},[]);return e.jsxs(e.Fragment,{children:[e.jsxs(De,{children:[e.jsx("title",{children:"Carte des lieux culturels | Sortir"}),e.jsx("meta",{name:"description",content:"Explorez les lieux culturels en France sur notre carte interactive. Découvrez théâtres, salles de concert, musées et espaces événementiels."}),e.jsx("meta",{property:"og:title",content:"Carte des lieux culturels | Sortir"}),e.jsx("meta",{property:"og:description",content:"Explorez les lieux culturels en France sur notre carte interactive."})]}),e.jsxs("div",{className:"h-screen flex flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:"Carte interactive des lieux culturels"}),e.jsx(rs,{venueCount:d.length,totalVenueCount:h.length,activeRegionName:H,onClearRegion:()=>{f([]),L(null)}}),e.jsxs("div",{className:"flex-1 flex relative overflow-hidden",children:[e.jsx(be,{ref:E,venues:d,onVenueSelect:F,initialCenter:R,initialZoom:u?8:10}),(y||w)&&e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-background/60 backdrop-blur-sm",children:y?e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl bg-card/90 px-6 py-5 shadow-lg",children:[e.jsx(ne,{className:"h-6 w-6 animate-spin text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Chargement des lieuxâ¦"})]}):e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl bg-card/95 px-6 py-5 text-center shadow-lg",children:[e.jsx("p",{className:"text-sm font-medium",children:"Impossible de charger les lieux"}),e.jsx("p",{className:"max-w-xs text-xs text-muted-foreground",children:"Vérifiez votre connexion puis réessayez."}),e.jsx(_,{size:"sm",onClick:()=>k(),children:"Réessayer"})]})}),!y&&!w&&d.length===0&&h.length>0&&D&&e.jsx(us,{onShowAll:T,regionName:H??void 0}),e.jsx(cs,{venues:d,isLoading:y,onVenueClick:G,onCenterMap:r}),e.jsx(ds,{venue:x,onClose:J,isMobile:v})]})]})]})}export{Ss as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.