1import{j as s}from"./vendor-ui-BFbqUn3H.js";import{r as R,L as H}from"./vendor-react-Cv6HR0Cp.js";import{y as Z,u as C,p as q,af as I,z as J,n as U,o as V,Z as Y,v as K,t as W,D as X,a6 as ee,$ as v}from"./index-WH0x7Y2T.js";import{t as k}from"./useTranslatedVariants-DwnoCBh5.js";import{O as te}from"./OptimizedImage-BYe5YZAp.js";import"./vendor-charts-BYYF0xXr.js";import"./vendor-query-CwYi344G.js";import"./vendor-supabase-DaFVQM4L.js";const se=["horizontal","vertical","compact"],ae=["Get","Play","Try","Install","Open"],ne=["ð®","ð","ð","â","ð¥","ð","ð¯","ð²"],ge=({maxCount:f=3,excludeGameIds:x=[],title:z,filterCategory:l})=>{const[A,M]=R.useState([]),{site:d,themeClass:D}=Z(),{lang:r,langPath:O}=C(),{isNeon:$}=ee(D),m=d?.slug||"default",o=q([...se],m+"-rec-layout")||"horizontal",P=q(ae,m+"-rec-cta")||"Get",G=q(ne,m+"-rec-emoji")||"ð®",p=Array.isArray(d?.featured_game_ids)?d.featured_game_ids:[],w=Array.isArray(d?.excluded_game_ids)?d.excluded_game_ids:[];if(R.useEffect(()=>{const n=I(m);if(n?.games&&n.games.length>0){const g=n.games.filter(e=>{const i=e.language||"en";return i===r||i==="en"}),_=new Map;g.forEach(e=>{const i=e.original_id||e.id,t=_.get(i);(!t||(t.language||"en")!==r&&(e.language||"en")===r)&&_.set(i,e)});const N=Array.from(_.values()),y=(n.variations||[]).filter(e=>(e.language||"en")===r||(e.language||"en")==="en"),c=new Map;y.forEach(e=>{c.has(e.game_id)||c.set(e.game_id,e)});const b=[...x,...w];let u=N.filter(e=>!b.includes(e.id)).filter(e=>!l||e.category===l||!e.category).map(e=>{const i=c.get(e.id);return i?{...e,display_name:i.varied_title||e.name,bonus_text:i.varied_bonus_text||e.bonus_text}:{...e,display_name:e.name}});const E=typeof window<"u"?window.location.pathname:"",S=(m+E).split("").reduce((e,i)=>(e<<5)-e+i.charCodeAt(0)|0,0);for(let e=u.length-1;e>0;e--){const i=Math.abs(S*(e+1)*2654435761%(e+1));[u[e],u[i]]=[u[i],u[e]]}M(u.slice(0,f));return}(async()=>{let g=v.from("games").select("id, name, slug, icon_url, rating, bonus_text, category, description").eq("is_active",!0).eq("language",r).limit(f+(x?.length||0)+10).order("downloads_count",{ascending:!1});l&&(g=g.eq("category",l)),p.length>0&&(g=g.in("id",p));const _=d?.id,[N,y]=await Promise.all([g,_?v.from("site_content_variations").select("game_id, varied_title, varied_bonus_text, varied_description").eq("site_id",_).eq("is_active",!0):Promise.resolve({data:null})]);let c=N.data||[];if(c.length===0&&r!=="en"){let t=v.from("games").select("id, name, slug, icon_url, rating, bonus_text, category, description").eq("is_active",!0).eq("language","en").limit(f+(x?.length||0)+10);l&&(t=t.eq("category",l)),p.length>0&&(t=t.in("id",p));const{data:a}=await t;c=a||[]}if(c.length===0&&l){let t=v.from("games").select("id, name, slug, icon_url, rating, bonus_text, category, description").eq("is_active",!0).eq("language",r).limit(f+(x?.length||0)+10).order("downloads_count",{ascending:!1});p.length>0&&(t=t.in("id",p));const{data:a}=await t;c=a||[]}const b=new Map;if(y.data){const t=new Map;y.data.forEach(a=>{const j=t.get(a.game_id)||[];j.push(a),t.set(a.game_id,j)}),t.forEach((a,j)=>{const B=Math.abs(m.split("").reduce((L,F)=>(L<<5)-L+F.charCodeAt(0)|0,0))%a.length;b.set(j,a[B])})}const u=c.map(t=>{const a=b.get(t.id);return a?{...t,display_name:a.varied_title||t.name,bonus_text:a.varied_bonus_text||t.bonus_text,description:a.varied_description||t.description}:{...t,display_name:t.name}}),E=[...x,...w],h=u.filter(t=>!E.includes(t.id)),S=typeof window<"u"?window.location.pathname:"",i=(m+S).split("").reduce((t,a)=>(t<<5)-t+a.charCodeAt(0)|0,0);for(let t=h.length-1;t>0;t--){const a=Math.abs(i*(t+1)*2654435761%(t+1));[h[t],h[a]]=[h[a],h[t]]}M(h.slice(0,f))})()},[f,x.length,r,m,l,p.length,w.length,d?.id]),A.length===0)return null;const Q=J(d),T=o==="compact"?"grid grid-cols-2 sm:grid-cols-4 gap-2":o==="vertical"?"flex flex-col gap-2":"grid grid-cols-1 sm:grid-cols-3 gap-3";return s.jsxs("div",{className:"my-8 p-5 rounded-xl bg-card/50 border border-border",children:[s.jsxs("h3",{className:"text-lg font-bold mb-4 flex items-center gap-2",style:{fontFamily:"var(--font-heading)"}
1,children:[G," ",z||k("Recommended Games",r)]}),s.jsx("div",{className:T,children:A.map(n=>s.jsx(H,{to:O(`/games/${n.slug}${Q}`),children:s.jsx(U,{className:`card-hover neon-border h-full ${$?"":"hover:shadow-md"}`,children:s.jsxs(V,{className:`flex items-center gap-3 ${o==="compact"?"p-3 flex-col text-center":"p-4"}`,children:[s.jsx("div",{className:`rounded-xl bg-primary/10 flex items-center justify-center shrink-0 overflow-hidden ${o==="compact"?"w-10 h-10":"w-12 h-12"}`,children:n.icon_url?s.jsx(te,{src:n.icon_url,alt:n.name,className:"w-full h-full object-cover rounded-xl"}):s.jsx(Y,{className:"h-6 w-6 text-primary"})}),s.jsxs("div",{className:`min-w-0 ${o==="compact"?"":"flex-1"}`,children:[s.jsx("p",{className:`font-semibold truncate ${o==="compact"?"text-xs":"text-sm"}`,children:n.display_name||n.name}),s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground justify-center sm:justify-start",children:[s.jsx(K,{className:"h-3 w-3 text-accent fill-accent"}),s.jsx("span",{children:n.rating}),o!=="compact"&&n.category&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"â¢"}),s.jsx("span",{className:"capitalize",children:n.category})]})]}),o!=="compact"&&n.bonus_text&&s.jsx("p",{className:`text-xs font-medium text-primary mt-0.5 truncate max-w-[200px] ${$?"text-glow":""}`,children:n.bonus_text.length>50?n.bonus_text.slice(0,47)+"...":n.bonus_text})]}),o!=="compact"&&s.jsxs(W,{size:"sm",variant:"outline",className:"shrink-0 h-8 gap-1",children:[s.jsx(X,{className:"h-3 w-3"}),k(P,r)]})]})})},n.id))})]})};export{ge 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.