import{n as e}from"./chunk-B3K2TuZy.js";import{a as t,d as n,p as r,r as i,t as a}from"./jsx-runtime-C2-Nj7wv.js";import{t as o}from"./useTranslation-CVci57dC.js";import{a as s,n as c}from"./urlUtils-DtzVplAm.js";import{l}from"./index-C1EcSSX1.js";import{t as u}from"./associationService-CTQM8gr1.js";import{t as d}from"./SEOHead-CRtMe0pb.js";import{n as f,r as p}from"./frenchRegions-A9cWslJg.js";var m=e(r()),h=a(),g=100,_=[],v=()=>{let{t:e}=o(),{region:r,ville:a}=n(),v=r?f[r]:void 0,[y,b]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!v)return;let e=!0,{slug:t,name:n}=v;return u.getAssociations({region:n,page_size:g}).then(n=>{e&&b({regionSlug:t,associations:n.associations||[]})}).catch(()=>{e&&b({regionSlug:t,associations:[]})}),()=>{e=!1}},[v]);let x=y!==null&&y.regionSlug===v?.slug,S=x?y.associations:_,C=(0,m.useMemo)(()=>S.filter(e=>e.city&&s(e.city)===a),[S,a]),w=C[0]?.city,T=(0,m.useMemo)(()=>{let e=new Map;for(let t of S){if(!t.city)continue;let n=s(t.city);n&&n!==a&&e.set(n,t.city)}return[...e.entries()].sort((e,t)=>e[1].localeCompare(t[1],`fr`)).slice(0,12)},[S,a]);if(!v)return(0,h.jsx)(t,{to:`/airsoft`,replace:!0});if(x&&!w)return(0,h.jsx)(t,{to:`/airsoft/${v.slug}`,replace:!0});let E=w??``;return(0,h.jsxs)(`div`,{className:`min-h-screen bg-gray-50`,children:[w&&a&&(0,h.jsx)(d,{...l(v,w,a,C.length)}),(0,h.jsxs)(`div`,{className:`max-w-5xl mx-auto px-6 pt-6 text-xs text-gray-400`,children:[(0,h.jsx)(i,{to:`/airsoft`,className:`hover:text-gray-700`,children:e(`cityHub.breadcrumbRegions`)}),(0,h.jsx)(`span`,{className:`mx-1.5`,children:`/`}),(0,h.jsx)(i,{to:`/airsoft/${v.slug}`,className:`hover:text-gray-700`,children:v.name}),(0,h.jsx)(`span`,{className:`mx-1.5`,children:`/`}),(0,h.jsx)(`span`,{className:`text-gray-600`,children:E})]}),(0,h.jsxs)(`section`,{className:`max-w-5xl mx-auto px-6 pt-4 pb-8`,children:[(0,h.jsx)(`h1`,{className:`text-3xl md:text-4xl font-bold text-gray-900 leading-tight mb-4`,children:e(`cityHub.title`,{city:E})}),(0,h.jsx)(`p`,{className:`text-gray-600 text-sm md:text-base leading-relaxed max-w-3xl`,children:C.length>0?e(`cityHub.introListed`,{count:C.length,city:E}):e(`cityHub.introEmpty`,{city:E})})]}),(0,h.jsxs)(`div`,{className:`max-w-5xl mx-auto px-6 space-y-10 pb-16`,children:[(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h2`,{className:`text-lg font-bold text-gray-900 mb-4`,children:e(`cityHub.associationsTitle`,{city:E})}),x?(0,h.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:C.map(t=>(0,h.jsxs)(i,{to:c(t.id,t.name),className:`bg-white rounded-xl border border-gray-100 p-4 hover:shadow-md transition-shadow`,children:[(0,h.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 truncate`,children:t.name}),(0,h.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:[t.city,e(`cityHub.memberCount`,{count:t.member_count})].filter(Boolean).join(` · `)})]},t.id))}):(0,h.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,"aria-busy":`true`,children:[0,1].map(e=>(0,h.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-100 p-4`,children:[(0,h.jsx)(`div`,{className:`h-4 w-2/3 bg-gray-100 rounded animate-pulse`}),(0,h.jsx)(`div`,{className:`h-3 w-1/3 bg-gray-100 rounded mt-2 animate-pulse`})]},e))})]}),(0,h.jsxs)(`section`,{className:`bg-white rounded-2xl border border-gray-100 p-6`,children:[(0,h.jsx)(`h2`,{className:`text-lg font-bold text-gray-900 mb-3`,children:e(`cityHub.startTitle`,{city:E})}),(0,h.jsx)(`p`,{className:`text-sm text-gray-600 leading-relaxed mb-3`,children:e(`cityHub.startParagraph1`,{city:E})}),(0,h.jsxs)(`p`,{className:`text-sm text-gray-600 leading-relaxed`,children:[e(`cityHub.startParagraph2Before`,{city:E,region:v.name}),(0,h.jsx)(i,{to:`/blog`,className:`text-primary-600 hover:underline`,children:e(`cityHub.startGuidesLink`)}),e(`cityHub.startParagraph2Middle`),(0,h.jsx)(i,{to:p(E),className:`text-primary-600 hover:underline`,children:e(`cityHub.startOrganizeLink`)}),e(`cityHub.startParagraph2After`)]})]}),T.length>0&&(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold text-gray-500 mb-3`,children:e(`cityHub.nearbyTitle`,{region:v.name})}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[T.map(([e,t])=>(0,h.jsx)(i,{to:`/airsoft/${v.slug}/${e}`,className:`px-3 py-1.5 bg-white border border-gray-200 rounded-full text-xs font-medium text-gray-600 hover:border-gray-400 hover:bg-gray-50 transition-colors`,children:t},e)),(0,h.jsx)(i,{to:`/airsoft/${v.slug}`,className:`px-3 py-1.5 bg-gray-900 text-white rounded-full text-xs font-semibold hover:bg-gray-800 transition-colors`,children:e(`cityHub.nearbyAll`,{region:v.name})})]})]})]})]})};export{v as default};