1import{a,j as e}from"./vendor-react-CDFIE44H.js";import{b as k,L}from"./vendor-router-nJKcHAGV.js";import{u as E}from"./vendor-query-BKeeEAAr.js";import{C as I,L as P,S as R,h,B as $,k as C,c as A,v as T,f as U}from"./index-B7SSE3m4.js";import{P as q}from"./PageBreadcrumb-DL8fcZSU.js";import{c as M,L as y}from"./vendor-icons-BsQZz6Pl.js";import"./vendor-radix-Cxb7F2zo.js";import"./vendor-utils-DSOPSYhy.js";function z(){const N=k(),s=new URLSearchParams(N).get("q")||"",[u,p]=a.useState(s),[o,f]=a.useState(s),[i,n]=a.useState(1),[d,c]=a.useState([]);a.useEffect(()=>{window.scrollTo(0,0)},[]),a.useEffect(()=>{s&&(p(s),f(s),n(1),c([]))},[s]);const{data:r,isLoading:b,isFetching:m}=E(I(o,i));a.useEffect(()=>{r?.articles&&c(t=>{if(i===1)return r.articles;const l=new Set(t.map(x=>x.id)),v=r.articles.filter(x=>!l.has(x.id));return[...t,...v]})},[r,i]);const g=r?r.currentPage<r.lastPage:!1,j=r?.total??0,S=t=>{t.preventDefault();const l=u.trim();l&&(l===o?(n(1),c([])):(f(l),n(1),c([]),window.history.replaceState(null,"",`/search-7.117?q=${encodeURIComponent(l)}`)))},w=()=>{n(t=>t+1)};return e.jsxs(P,{children:[e.jsx(R,{title:"Search",description:"Search Emirates 24|7 for the latest news, articles and stories from the UAE and around the world.",canonicalPath:"/search-7.117",ogTitle:"Search",noIndex:!0,jsonLd:[$("Search","Search Emirates 24|7 for the latest news.","/search-7.117"),{"@context":"https://schema.org","@type":"BreadcrumbList","@id":`${h}/search-7.117#breadcrumb`,itemListElement:[{"@type":"ListItem",position:1,name:"Home",item:h},{"@type":"ListItem",position:2,name:"Search",item:`${h}/search`}]}]}),e.jsxs("main",{className:"container mx-auto px-4 pb-12 flex-1 max-w-4xl",style:{paddingTop:"40px"},children:[e.jsx(q,{items:s?[{name:`Search: ${s}`}]:[{name:"Search"}],className:"mb-4 text-xs"}),e.jsx("div",{className:"mb-8 border-b-4 border-slate-900 dark:border-white inline-block pb-2",children:e.jsx("h1",{className:"text-4xl font-bold uppercase","data-testid":"text-search-title",children:"Search - Emirates 24|7"})}),e.jsx("div",{className:"flex flex-col mb-10",children:e.jsxs("form",{onSubmit:S,className:"flex w-full h-14",children:[e.jsx("input",{type:"text",value:u,onChange:t=>p(t.target.value),placeholder:"Search for news, topics, or authors...",className:"flex-1 border-2 border-r-0 border-slate-300 dark:border-slate-600 px-4 text-lg focus:outline-none focus:border-primary transition-colors h-full bg-background text-foreground",autoFocus:!0,"data-testid":"input-search"}),e.jsx("button",{type:"submit",className:"bg-primary text-white px-8 border-2 border-primary hover:bg-red-700 transition-colors flex items-center justify-center h-full min-w-[80px]","data-testid":"button-search",children:e.jsx(M,{className:"w-6 h-6"})})]})}),b&&i===1?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(y,{className:"w-10 h-10 animate-spin text-primary mb-4"}),e.jsx("p",{className:"text-lg font-medium",children:"Searching..."})]}):o&&d.length>0?e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-bold mb-6 text-slate-800 dark:text-white","data-testid":"text-search-results-heading",children:['Search Results for "',o,'"',j>0&&e.jsxs("span",{className:"text-slate-500 dark:text-slate-400 font-normal text-base ml-2",children:["(",j.toLocaleString()," found)"]})]}),e.jsx("div",{className:"flex flex-col gap-8",children:d.map(t=>e.jsxs(L,{href:U(t),className:"group flex flex-col md:flex-row gap-6 border-b border-slate-200 dark:border-slate-700 pb-8 last:border-0 cursor-pointer","data-testid":`link-search-result-${t.id}`,children:[e.jsxs("div",{className:"md:w-1/3 relative overflow-hidden rounded-sm shrink-0 aspect-[16/9]",children:[e.jsx(C,{article:t}),e.jsx("div",{className:"absolute top-2 left-2 bg-primary text-white text-[10px] font-bold uppercase px-2 py-1",children:A(t.sectionId)})]}),e.jsxs("div",{className:"md:w-2/3 flex flex-col justify-center",children:[e.jsx("h3",{className:"text-2xl font-serif font-bold mb-2 group-hover:text-primary transition-colors leading-tight","data-testid":`text-search-title-${t.id}`,children:t.title}),e.jsx("p",{className:"text-muted-foreground text-sm mb-3","data-testid":`text-search-date-${t.id}`,children:T(t.publishTime)}
1),t.bodyClean&&e.jsxs("p",{className:"text-slate-600 dark:text-slate-400 line-clamp-2",children:[t.bodyClean.substring(0,200),"..."]})]})]},t.id))}),e.jsxs("div",{className:"py-12 mt-2 flex flex-col items-center justify-center border-t border-dashed border-slate-300 dark:border-slate-700",children:[m&&i>1&&e.jsxs("div",{className:"flex flex-col items-center text-muted-foreground",children:[e.jsx(y,{className:"w-8 h-8 animate-spin mb-2 text-primary"}),e.jsx("p",{className:"text-sm uppercase tracking-widest font-bold",children:"Loading More Stories..."})]}),g&&!m&&e.jsx("button",{onClick:w,className:"bg-primary text-white px-8 py-3 font-bold uppercase tracking-wider hover:bg-red-700 transition-colors","data-testid":"button-load-more",children:"Load More Results"}),!g&&d.length>0&&!m&&e.jsx("p",{className:"text-sm uppercase tracking-widest font-bold text-muted-foreground",children:"You've reached the end."})]})]}):o&&!b?e.jsxs("div",{className:"py-12 text-center text-slate-500 dark:text-slate-400",children:[e.jsxs("p",{className:"text-xl",children:['No results found for "',o,'".']}),e.jsx("p",{className:"mt-2",children:"Try different keywords or check your spelling."})]}):null]})]})}export{z 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.