1import{r as e,t}from"./jsx-runtime-BkSabwWG.js";import{n,z as r}from"./logo_VMV_blanc-B1BDEb6E.js";import{_ as i,n as a,r as o,t as s}from"./useVmv-DROVyCXm.js";import{n as c,r as l,s as u,t as d}from"./MobileTabBar-CCRpNjdJ.js";import{t as f}from"./chevron-left-BT3DH8tk.js";import{t as p}from"./chevron-right-Cbm-JSst.js";import{n as m,t as h}from"./CategoryIcon-BTBIdJA1.js";import{t as g}from"./play-BGNZDPFt.js";import{A as _,D as v,E as y,T as b,Z as x,f as S,k as C}from"./index-Dmfk4MRE.js";import{t as w}from"./SmartImage-CEq-btyS.js";import{n as T,t as E}from"./dialog-OwTy3i4L.js";import{t as D}from"./ArticleDetail-DtnFHxaK.js";import{t as O}from"./VmvSelect-BA7Krq1_.js";import{t as k}from"./SearchInput-BRZwTZnE.js";import{t as A}from"./video-loading-screen.png.asset-DJFMY4rY.js";var j=e(r()),M=t();function N({article:e,priority:t=!1}){let n=e.media_type===`video`,r=e.media_urls?.length?e.media_urls:e.media_url?[e.media_url]:[],[i,a]=(0,j.useState)(0),o=r[Math.min(i,r.length-1)],s=e=>t=>{t.preventDefault(),t.stopPropagation(),a(t=>(t+e+r.length)%r.length)};return(0,M.jsx)(`div`,{className:`bg-secondary relative w-full overflow-hidden`,style:{aspectRatio:`4 / 5`},children:n&&o?(0,M.jsx)(`video`,{src:o,poster:A.url,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,preload:`metadata`,className:`h-full w-full object-cover`}):n?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`img`,{src:A.url,alt:e.title,loading:`lazy`,decoding:`async`,className:`h-full w-full object-cover`}),(0,M.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,M.jsx)(`div`,{className:`flex h-14 w-14 items-center justify-center rounded-full bg-white/90 shadow-lg`,children:(0,M.jsx)(g,{className:`text-purple h-6 w-6 fill-current`,strokeWidth:2})})})]}):o?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(w,{src:o,alt:e.title,priority:t,preload:r.filter(e=>e!==o).slice(0,2),className:`h-full w-full object-cover`}),r.length>1?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{type:`button`,onClick:s(-1),"aria-label":`Média précédent`,className:`text-ink absolute top-1/2 left-2 flex h-8 w-8 -translate-y-1/2 items-center justify-center rounded-full bg-white/90 shadow-md transition hover:bg-white`,children:(0,M.jsx)(f,{className:`h-4 w-4`,strokeWidth:2.5})}),(0,M.jsx)(`button`,{type:`button`,onClick:s(1),"aria-label":`Média suivant`,className:`text-ink absolute top-1/2 right-2 flex h-8 w-8 -translate-y-1/2 items-center justify-center rounded-full bg-white/90 shadow-md transition hover:bg-white`,children:(0,M.jsx)(p,{className:`h-4 w-4`,strokeWidth:2.5})}),(0,M.jsx)(`div`,{className:`absolute bottom-2 left-1/2 flex -translate-x-1/2 gap-1.5`,children:r.map((e,t)=>(0,M.jsx)(`span`,{className:`h-1.5 rounded-full transition-all ${t===i?`bg-white w-4`:`bg-white/60 w-1.5`}`},e))})]}):null]}):(0,M.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,M.jsx)(u,{className:`text-purple/40 h-10 w-10`,strokeWidth:1.5})})})}function P(){let{territoire:e,categorie:t,q:r}=b.useSearch(),s=x(),[f,,p]=_(e),g=C(f),[w,D]=(0,j.useState)(t),[A,P]=(0,j.useState)(r),[I,L]=(0,j.useState)(null),[R,z]=(0,j.useState)(!1);(0,j.useEffect)(()=>z(!0),[]),(0,j.useEffect)(()=>P(r),[r]);let B=()=>{P(``),V({q:``})},V=t=>s({to:`/actus`,search:n=>({territoire:n.territoire??e,categorie:n.categorie??``,q:n.q??``,...t})}),H=e=>{let t=e===`Toute la France`?[]:f.includes(e)?f.filter(t=>t!==e):[...f,e];p(e),V({territoire:v(t)})},U=e=>{D(e),V({categorie:e})},W=i(),G=(0,j.useMemo)(()=>{let e=Array.from(new Set((W.data??[]).map(e=>e.territory_name).filter(Boolean))).sort((e,t)=>e.localeCompare(t,`fr`));return e.length?e:[`Digne-les-Bains`,`Sisteron`,`Manosque`]},[W.data]),K=o(`article`),q=(0,j.useMemo)(()=>(K.data??[]).filter(e=>e.name).map(e=>({value:e.name,label:e.name,icon:(0,M.jsx)(h,{icon:e.icon,name:e.name})})),[K.data]),J=v(f),Y=a({territory:f,max:300}),X=(0,j.useMemo)(()=>{let e=S(r);return(Y.data??[]).filter(t=>{let n=!w||t.category_article.includes(w),r=!e||S(`${t.title} ${t.description??``} ${t.company_name??``}`).includes(e);return n&&r}).sort((e,t)=>
1{let n=e.created_at?new Date(e.created_at).getTime():0;return(t.created_at?new Date(t.created_at).getTime():0)-n})},[Y.data,w,r]),[Z,Q]=(0,j.useState)(12);(0,j.useEffect)(()=>Q(12),[J,w,r]);let $=X.slice(0,Z);return(0,M.jsxs)(`div`,{className:`bg-background min-h-screen`,children:[(0,M.jsx)(l,{solid:!0,territory:g,selectedTerritories:f,territories:G,onToggleTerritory:H}),(0,M.jsxs)(`main`,{className:`mx-auto max-w-6xl px-4 pt-12 pb-24 sm:px-6`,children:[(0,M.jsx)(`h1`,{className:`text-ink text-4xl font-black tracking-tight sm:text-5xl`,children:`Les actus de ma ville`}),(0,M.jsxs)(`p`,{className:`text-muted-foreground mt-3 max-w-2xl text-base font-medium`,children:[`Les actualités, photos et vidéos des annonceurs de `,g,`.`]}),(0,M.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),V({q:A.trim()})},className:`shadow-card mt-8 flex items-center gap-3 rounded-full bg-white p-2 pl-2 sm:pl-3`,children:[(0,M.jsxs)(`div`,{className:`hidden items-center gap-2 sm:flex`,children:[(0,M.jsx)(O,{values:f,onToggle:H,summaryLabel:g,ariaLabel:`Choisir un ou plusieurs territoires`,icon:(0,M.jsx)(u,{className:`text-purple h-4 w-4`,strokeWidth:1.75}),options:[y,...G].map(e=>({value:e,label:e}))}),(0,M.jsx)(O,{value:w,onChange:U,ariaLabel:`Filtrer par catégorie`,placeholder:`Catégories`,triggerClassName:`border-border border bg-white`,icon:(0,M.jsx)(m,{className:`text-ink h-4 w-4`,strokeWidth:1.75}),options:[{value:``,label:`Toutes les catégories`},...q]})]}),(0,M.jsx)(k,{value:A,onChange:P,onClear:B,placeholder:`Rechercher une actualité, un commerceâ¦`,shortPlaceholder:`Une actuâ¦`,className:`ml-2`}),(0,M.jsx)(`button`,{type:`submit`,className:`bg-purple hover:bg-purple-600 shrink-0 rounded-full px-5 py-2.5 text-sm font-bold text-white transition-colors duration-200`,children:`Rechercher`})]}),!R||Y.isPending&&Y.fetchStatus===`fetching`?(0,M.jsx)(`p`,{className:`text-muted-foreground mt-10 text-sm font-medium`,children:`Chargementâ¦`}):Y.isError?(0,M.jsx)(`p`,{className:`text-muted-foreground mt-10 text-sm font-medium`,children:`Impossible de charger les actualités pour le moment.`}):X.length===0?(0,M.jsxs)(`p`,{className:`text-muted-foreground mt-10 text-sm font-medium`,children:[`Aucune actualité pour l'instant à `,g,`.`]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`ul`,{className:`mt-10 grid gap-6 sm:grid-cols-2 lg:grid-cols-3`,children:$.map((e,t)=>{let r=e.description??``,i=r.length>60?`${r.slice(0,60).trim()}...`:r;return(0,M.jsx)(`li`,{className:`shadow-card overflow-hidden rounded-3xl bg-white`,children:(0,M.jsxs)(n,{to:`/actus/$id`,params:{id:e.id},className:`block`,onClick:t=>{t.preventDefault(),L(e.id)},children:[(0,M.jsx)(N,{article:e,priority:t<3}),(0,M.jsxs)(`div`,{className:`p-5`,children:[(0,M.jsx)(`h2`,{className:`text-ink text-lg font-black`,children:e.title}),e.category_article?.length?(0,M.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:e.category_article.map(e=>(0,M.jsx)(`span`,{className:`bg-purple/15 text-purple rounded-full px-3 py-1 text-[11px] font-black uppercase tracking-wide`,children:e},e))}):null,i?(0,M.jsxs)(`p`,{className:`text-muted-foreground mt-3 text-sm font-medium`,children:[i,r.length>60?(0,M.jsx)(`span`,{className:`text-mint ml-1 font-black`,children:`voir plus`}):null]}):null,(0,M.jsxs)(`p`,{className:`text-muted-foreground mt-3 flex items-center gap-1.5 text-xs font-bold`,children:[(0,M.jsx)(u,{className:`h-3.5 w-3.5`,strokeWidth:2}),e.company_name??e.territory_name?.[0]??f]})]})]})},e.id)})}),Z<X.length?(0,M.jsx)(`div`,{className:`mt-12 flex justify-center`,children:(0,M.jsx)(`button`,{type:`button`,onClick:()=>Q(e=>e+12),className:`border-purple text-purple hover:bg-purple rounded-full border-2 px-8 py-3 text-sm font-black transition-colors duration-200 hover:text-white`,children:`Charger plus d'actualités`})}):null]})]}),(0,M.jsx)(E,{open:I!==null,onOpenChange:e=>!e&&L(null),children:(0,M.jsx)(T,{className:`top-[3%] block max-h-[94vh] w-[calc(100vw-1.5rem)] max-w-6xl translate-y-0 overflow-x-hidden overflow-y-auto overscroll-contain rounded-2xl p-0 sm:top-[5%] sm:max-h-[90vh] sm:w-[calc(100%-2rem)] sm:rou
1nded-3xl`,children:(0,M.jsx)(`div`,{className:`p-6 sm:p-8`,children:I?(0,M.jsx)(F,{id:I}):null})})}),(0,M.jsx)(c,{}),(0,M.jsx)(d,{})]})}function F({id:e}){let t=s(e),n=t.data;return t.isLoading?(0,M.jsx)(`p`,{className:`text-muted-foreground text-sm font-medium`,children:`Chargementâ¦`}):n?(0,M.jsx)(`div`,{className:`space-y-6`,children:(0,M.jsx)(D,{article:n,showPageLink:!0})}):(0,M.jsx)(`p`,{className:`text-muted-foreground text-sm font-medium`,children:`Cet article n'est plus disponible.`})}export{P as component};
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.