PageSourceSearch

https://4u.ai/assets/Duplicates-DcRP-5-c.js

js 4u.ai collected 2026-10-05 11:47:11 UTC 6,485 bytes, 1 lines download raw bytes

1import{r as m,j as e,g as D,h as k,L as T,H as R,v as E,B as j,a as I,i as L}from"./index-BpZ236K-.js";import{B as x}from"./badge-BgkV1kVo.js";var O=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],z=O.reduce((r,s)=>{const i=D(`Primitive.${s}`),a=m.forwardRef((c,d)=>{const{asChild:u,...h}=c,l=u?i:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(l,{...h,ref:d})});return a.displayName=`Primitive.${s}`,{...r,[s]:a}},{}),G="Separator",y="horizontal",M=["horizontal","vertical"],w=m.forwardRef((r,s)=>{const{decorative:i,orientation:a=y,...c}=r,d=A(a)?a:y,h=i?{role:"none"}:{"aria-orientation":d==="vertical"?d:void 0,role:"separator"};return e.jsx(z.div,{"data-orientation":d,...h,...c,ref:s})});w.displayName=G;function A(r){return M.includes(r)}var S=w;const C=m.forwardRef(({className:r,orientation:s="horizontal",decorative:i=!0,...a},c)=>e.jsx(S,{ref:c,decorative:i,orientation:s,className:k("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",r),...a}));C.displayName=S.displayName;const P=7;function $(r){let s=r.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"");s=s.replace(/[“”\"']/g,"").replace(/[\s]+/g," ").trim();const i=[" - "," – "," | "].map(a=>s.lastIndexOf(a)).filter(a=>a>0).reduce((a,c)=>Math.max(a,c),-1);return i>20&&(s=s.slice(0,i).trim()),s}function F(r){try{const s=new URL(r),i=s.hostname.split(".");return i.length>=2?i.slice(-2).join("."):s.hostname}catch{return""}}function B(r){const s=r.replace(/^www\./,"");return/\b(is|hs|taloussanomat|iltasanomat)\.fi$/.test(s)?"Sanoma":/\b(iltalehti|kauppalehti|talouselama)\.fi$/.test(s)?"Alma Media":/\byle\.fi$/.test(s)?"Yle":/\bmtv\.fi$/.test(s)?"MTV":s}async function U(r){const s=Date.now()/1e3-r*86400,i=new Set,a=[];let c;for(let d=0;d<=r;d++){const u=await L(c??void 0);for(const l of u.items)(l.publishedTs??0)<s||i.has(l.url)||(i.add(l.url),a.push(l));if(!u.nextChunk)break;const h=Math.min(...u.items.map(l=>l.publishedTs??1/0));if(Number.isFinite(h)&&h<s)break;c=u.nextChunk}return a}function H(){const[r,s]=m.useState([]),[i,a]=m.useState(!0),[c,d]=m.useState(null),[u,h]=m.useState(2),[l,v]=m.useState("all");m.useEffect(()=>{(async()=>{try{a(!0);const t=await U(P);s(t.filter(n=>(n.feedType||"news").toLowerCase()==="news")),d(null)}catch(t){d((t==null?void 0:t.message)||"Failed to load data")}finally{a(!1)}})()},[]);const b=m.useMemo(()=>{const t={};return r.forEach(n=>{const o=$(n.title),f=(()=>{try{return new URL(n.url).hostname.replace(/^www\./,"")}catch{return""}})(),p=F(n.url),g=B(f||p);t[o]||(t[o]={key:o,title:n.title,items:[],domains:[],baseDomains:[],mediaGroups:[]}),t[o].items.push(n),f&&!t[o].domains.includes(f)&&t[o].domains.push(f),p&&!t[o].baseDomains.includes(p)&&t[o].baseDomains.push(p),g&&!t[o].mediaGroups.includes(g)&&t[o].mediaGroups.push(g)}),Object.values(t).filter(n=>n.items.length>=u).sort((n,o)=>o.items.length-n.items.length)},[r,u]),N=m.useMemo(()=>l==="all"?b:l==="syndicated"?b.filter(t=>t.mediaGroups.length===1||t.baseDomains.length===1):b.filter(t=>t.mediaGroups.length>=2&&t.baseDomains.length>=2),[b,l]);return e.jsxs(T,{children:[e.jsxs(R,{children:[e.jsxs("title",{children:["Duplicates — ",E.metaTitle]}),e.jsx("meta",{name:"description",content:"Grouped duplicates across media: syndicated vs cross‑media coverage."})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{variant:l==="all"?"default":"outline",size:"sm",onClick:()=>v("all"),children:"All"}),e.jsx(j,{variant:l==="syndicated"?"default":"outline",size:"sm",onClick:()=>v("syndicated"),children:"Syndicated"}),e.jsx(j,{variant:l==="cross"?"default":"outline",size:"sm",onClick:()=>v("cross"),children:"Cross‑media"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Min. articles"}),e.jsx("select",{value:u,onChange:t=>h(parseInt(t.target.value,10)),className:"h-9 rounded-md border border-border bg-background px-2",children:[2,3,4,5,6,7,8,9,10].map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),i&&e.jsxs("div",{className:"text-center py-12 bg-card rounded-lg border border-border",children:[e.jsx("div",{className:"inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-primary border-r-transparent mb-4"}),e.jsx("p",{className:"text-[15px] text-muted-foreground font-mono",children:"Loading…"})]}),c&&!i&&e.jsx("div",{className:"text-center py-12 bg-card rounded-lg border border-destructive",children:e.jsx("p",{className:"text-[15px] text-destructive font-mono",children:c})}),!i&&!c&&e.jsxs("div",{className:"space-y-4",children:[N.map(t=>e.jsxs(I,{className:"p-4 border-border",children:[e.jsx("div",{className:"flex items-start justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-1",children:t.title}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:[e.jsxs(x,{variant:"outline",className:"text-xs",children:[t.items.length," articles"]}),e.jsxs(x,{variant:"outline",className:"text-xs",children:[t.baseDomains.length," domains"]}),e.jsxs(x,{variant:"outline",className:"text-xs",children:[t.mediaGroups.length," media groups"]}),t.mediaGroups.length===1||t.baseDomains.length===1?e.jsx(x,{variant:"secondary",className:"text-xs",children:"Syndicated"}):e.jsx(x,{variant:"secondary",className:"text-xs",children:"Cross‑media"})]})]})}),e.jsx(C,{className:"my-3"}),e.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:t.items.slice().sort((n,o)=>(o.publishedTs??0)-(n.publishedTs??0)).map((n,o)=>{var p;const f=(()=>{try{return new URL(n.url).hostname.replace(/^www\./,"")}catch{return n.source}})();return e.jsxs("div",{className:"flex items-center justify-between gap-4 text-[13px]",children:[e.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"text-foreground hover:text-primary truncate",title:n.title,children:f}),e.jsx("span",{className:"text-muted-foreground tabular-nums",children:((p=n.published)==null?void 0:p.slice(0,16))??""})]},o)})})]},t.key)),N.length===0&&e.jsx("div",{className:"text-center py-12 bg-card rounded-lg border border-border",children:e.jsx("p",{className:"text-[15px] text-muted-foreground font-mono",children:"No groups match the current filters."})})]})]})}export{H 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.