1import{j as e}from"./vendor-motion-hRg_q8lq.js";import{d as L,r as p}from"./vendor-react-E98sgxjj.js";import{u as G,L as N,d as g,K as M,b as O,H as A}from"./index-BKzE8EQ8.js";import{u as F}from"./vendor-query-bOUN_gKe.js";import{du as f}from"./vendor-fa-Bn2dnpnC.js";import{a as I}from"./games-CnVZUdx7.js";import{G as P}from"./GameCard-koPJLRWA.js";import{u as D}from"./cardParts-5JiJu2RB.js";import{G as R}from"./GamePlanCard-DWIEA9Db.js";import{G as T}from"./GameCardSkeleton-DXy1eHov.js";import{C}from"./SettingsRowCard--YUcmpPt.js";import"./plans-CbMJY2XS.js";import{h as q}from"./organization-BuGhuc22.js";import"./useLocaleNavigate-BNriJdRU.js";import"./MediaImage-DKgx-nW4.js";import"./Tooltip-C8AvPGtA.js";import"./ShareModal-YOmfr9ti.js";import"./SubmitVideoModal-DzX5MAqQ.js";import"./earnProgram-B9pqjKbP.js";import"./trailerShare-BGlMG0RV.js";import"./usePublishingFeatures-C8zY31rs.js";import"./useIsPaid-Cw2jGyd_.js";import"./index-i1nPji9k.js";import"./paywall-CG7xVZtx.js";import"./pricingExperiments-zMZby8z7.js";import"./makeCopy-DTZjoJnY.js";import"./useIsStaff-DZf24Ivp.js";import"./MakeCopy-DWExybqc.js";import"./OrgScopeLabel-C9yeV7Fb.js";import"./MemberAvatar-CfukMFmI.js";import"./Avatar-B60wpoS5.js";import"./planChat-Cir7UVv6.js";import"./usePlanChat-D_HjNnxd.js";import"./plansApi-C_2vGYRm.js";const z=4;function B(){const{t:n}=G("explore"),{data:m}=D(z),s=m?.results??[];return s.length?e.jsxs("section",{className:"mb-10","aria-labelledby":"my-plans-heading","data-testid":"my-plans-row",children:[e.jsxs("div",{className:"mb-4 flex items-baseline justify-between gap-3",children:[e.jsxs("h2",{id:"my-plans-heading",className:"text-base text-foreground",children:[n("myGames.plansTitle")," ",e.jsxs("span",{className:"text-muted-foreground",children:["· ",m?.count??s.length]})]}),e.jsxs(N,{to:"/my-games/plans",className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[n("myGames.plansSeeAll"),e.jsx(f,{icon:["far","chevron-right"],className:"text-[11px]"})]})]}),e.jsx("div",{className:g("scrollbar-hide -mx-4 flex snap-x snap-mandatory scroll-px-4 gap-4 overflow-x-auto px-4","md:mx-0 md:grid md:snap-none md:grid-cols-2 md:gap-8 md:overflow-visible md:px-0 lg:grid-cols-3 2xl:grid-cols-4"),children:s.map((o,r)=>
1e.jsx("div",{className:g("w-[78%] shrink-0 snap-start md:w-auto",r===2&&"md:hidden lg:block",r===3&&"md:hidden 2xl:block"),children:e.jsx(R,{plan:o})},o.id))})]}):null}const S=["shared","mine","all"];function $({orgName:n,search:m}){const{t:s}=G("company"),o=M(),[r,u]=L(),i=r.get("scope"),c=i&&S.includes(i)&&(i!=="all"||o)?i:"shared",t=q(c),h=t.data?.pages.flatMap(l=>l.results)??[],d=m.trim().toLowerCase(),b=d?h.filter(l=>l.name.toLowerCase().includes(d)):h,w=t.data?.pages[0]?.count??0,x=l=>{const y=new URLSearchParams(r);l==="shared"?y.delete("scope"):y.set("scope",l),u(y,{replace:!0})};return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{role:"tablist","aria-label":s("library.scopeLabel"),className:"inline-flex rounded-md bg-foreground/6 p-0.5",children:S.filter(l=>l!=="all"||o).map(l=>e.jsx("button",{type:"button",role:"tab","aria-selected":c===l,onClick:()=>x(l),className:g("h-8 cursor-pointer rounded-[8px] px-3 text-sm transition-colors",c===l?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:s(`library.scopes.${l}`,{org:n})},l))}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s(`library.scopeHint.${c}`,{org:n})})]}),t.isLoading?e.jsx("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-8 lg:grid-cols-3 2xl:grid-cols-4",children:e.jsx(T,{count:8})}):t.isError?e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-md border border-border p-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("common.loadFailed")}),e.jsx(C,{tone:"quiet",onClick:()=>t.refetch(),children:s("common.retry")})]}):b.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-md border border-border py-16 text-center",children:[e.jsx(f,{icon:["far",d?"search":"building"],className:"mb-7 text-4xl text-muted-foreground/50","aria-hidden":!0}),e.jsx("p",{className:"mb-3 text-lg text-foreground",children:d?s("library.noMatch"):s(`library.empty.${c}.title`,{org:n})}),e.jsx("p",{className:"max-w-md px-4 text-base text-muted-foreground",children:d?s("library.noMatchBody",{search:m}):s(`library.empty.${c}.body`,{org:n})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-8 lg:grid-cols-3 2xl:grid-cols-4",children:b.map(l=>e.jsx(P,{game:l},l.id))}),e.jsxs("div",{className:"mt-12 flex flex-col items-center gap-3",children:[t.hasNextPage&&e.jsx(C,{tone:"secondary",onClick:()=>t.fetchNextPage(),disabled:t.isFetchingNextPage,children:t.isFetchingNextPage?s("common.loading"):s("library.loadMore")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("library.count",{shown:b.length,total:Math.max(w,b.length)})})]})]})]})}const H=[{value:"last_edited",label:"myGames.sortLastEdited"},{value:"newest",label:"myGames.sortNewest"},{value:"name_az",label:"myGames.sortNameAZ"},{value:"name_za",label:"myGames.sortNameZA"},{value:"most_plays",label:"myGames.sortMostPlays"},{value:"most_likes",label:"myGames.sortMostLikes"}],Q=[{value:"all",label:"myGames.filterAll"},{value:"draft",label:"myGames.filterDraft"},{value:"published",label:"myGames.filterPublished"}];function k({options:n,value:m,onChange:s,label:o}){const[r,u]=p.useState(!1),i=p.useRef(null);p.useEffect(()=>{if(!r)return;const t=d=>{i.current&&!i.current.contains(d.target)&&u(!1)},h=d=>{d.key==="Escape"&&u(!1)};return document.addEventListener("mousedown",t),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("keydown",h)}},[r]);const c=n.find(t=>t.value===m);return e.jsxs("div",{ref:i,className:"relative",children:[e.jsxs("button",{onClick:()=>u(!r),className:g("h-9 px-3 rounded-md border text-sm flex items-center gap-4 transition-colors cursor-pointer",r?"border-foreground":"border-border"),children:[e.jsx("span",{className:"text-foreground",children:c?.label||o}),e.jsx(f,{icon:["far","chevron-down"],className:"text-[10px] text-muted-foreground transition-transform duration-150",style:{transform:r?"rotate(180deg)":"rotate(0deg)"}})]}),e.jsx("div",{className:g("absolute top-full right-0 mt-1 min-w-[160px] rounded-md border border-border bg-card z-50 p-2 duration-150",r?"scale-100 opacity-100":"scale-95 opacity-0 pointer-events-none"),children:n.map(t=>e.jsxs("button",{onClick:()=>{s(t.value),u(!1)},className:g("w-full px-3 py-2 rounded-md text-sm text-left flex items-center gap-2 transition-colors cursor-pointer",m===t.value?"text-foreground":"text-muted-foreground hover:text-foreground hover:bg-foreground
1/3"),children:[e.jsx(f,{icon:m===t.value?["fas","square-check"]:["far","square"],className:g("text-sm",m===t.value?"text-foreground":"text-muted-foreground/50")}),t.label]},t.value))})]})}function V(n,m){const s=[...n];switch(m){case"last_edited":return s.sort((o,r)=>new Date(r.updated_at||r.created_at).getTime()-new Date(o.updated_at||o.created_at).getTime());case"newest":return s.sort((o,r)=>new Date(r.created_at).getTime()-new Date(o.created_at).getTime());case"name_az":return s.sort((o,r)=>o.name.localeCompare(r.name));case"name_za":return s.sort((o,r)=>r.name.localeCompare(o.name));case"most_plays":return s.sort((o,r)=>(r.play_count||0)-(o.play_count||0));case"most_likes":return s.sort((o,r)=>(r.favorite_count||0)-(o.favorite_count||0));default:return s}}function Se(){const[n,m]=p.useState(""),[s,o]=p.useState(""),[r,u]=p.useState("last_edited"),[i,c]=p.useState("all"),{t}=G("explore"),{user:h}=O(),d=h?.organization??null,[b,w]=L(),x=d&&b.get("view")==="company"?"company":"mine",l=a=>{const j=new URLSearchParams(b);a==="company"?j.set("view","company"):(j.delete("view"),j.delete("scope")),w(j,{replace:!0})};p.useEffect(()=>{const a=setTimeout(()=>o(n),300);return()=>clearTimeout(a)},[n]);const{data:y,isLoading:E}=F({...I(),enabled:x==="mine"});let v=y||[];if(s.trim()){const a=s.toLowerCase();v=v.filter(j=>j.name.toLowerCase().includes(a))}i!=="all"&&(v=v.filter(a=>a.visibility===i));const _=V(v,r);return e.jsxs(e.Fragment,{children:[e.jsx(A,{children:e.jsx("title",{children:t("myGames.pageTitle")})}),e.jsxs("div",{className:"px-4 md:px-8 pt-22 md:pt-8 pb-12 max-w-[1280px] mx-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-lg text-foreground",children:t("myGames.title")}),e.jsx("p",{className:"text-base text-muted-foreground mt-1",children:t("myGames.subtitle")})]}),d&&e.jsx("div",{role:"tablist","aria-label":t("myGames.title"),className:"mb-6 flex items-center gap-1 border-b border-border",children:["mine","company"].map(a=>e.jsx("button",{type:"button",role:"tab","aria-selected":x===a,onClick:()=>l(a),className:g("-mb-px h-10 cursor-pointer border-b-2 px-3 text-sm transition-colors",x===a?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:a==="mine"?t("myGames.title"):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(f,{icon:["far","building"],className:"text-xs","aria-hidden":!0}),d.name]})},a))}),e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center gap-2 md:gap-3 mb-6",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(f,{icon:["far","search"],className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground"}),e.jsx("input",{type:"text",value:n,onChange:a=>m(a.target.value),placeholder:t("myGames.search"),className:"w-full min-w-[300px] h-9 pl-9 pr-3 rounded-md border border-border bg-transparent text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-foreground transition-colors"})]}),e.jsx("div",{className:"flex-1"}),x==="mine"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{options:H.map(a=>({...a,label:t(a.label)})),value:r,onChange:u,label:t("myGames.sortBy")}),e.jsx(k,{options:Q.map(a=>({...a,label:t(a.label)})),value:i,onChange:c,label:t("myGames.visibility")})]})]}),x==="mine"&&e.jsx(B,{}),x==="company"&&d?e.jsx($,{orgName:d.name,search:s}):E?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 gap-6 md:gap-8",children:e.jsx(T,{count:20})}):_.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 gap-6 md:gap-8",children:[e.jsxs("div",{children:[e.jsx(N,{to:"/dashboard",className:"flex flex-col items-center justify-center rounded-md bg-foreground
1/6 hover:bg-foreground/10 transition-colors group aspect-video",children:e.jsx("div",{className:"flex flex-col items-center gap-2 text-muted-foreground/50 group-hover:text-muted-foreground transition-colors",children:e.jsx(f,{icon:["far","plus"],className:"text-xl"})})}),e.jsx("div",{className:"mt-2",children:e.jsx(N,{to:"/dashboard",children:e.jsx("h3",{className:"text-base text-foreground hover:text-muted-foreground transition-colors truncate",children:t("myGames.createNewProject")})})})]}),_.map(a=>e.jsx(P,{game:a},a.id))]}),e.jsx("p",{className:"text-sm text-muted-foreground text-center mt-12",children:t("myGames.gamesMade",{count:y?.length||0})})]}):e.jsxs("div",{className:"text-center py-16 rounded-md border border-border flex flex-col items-center justify-center",children:[e.jsx(f,{icon:n.trim()?["far","search"]:["far","gamepad-modern"],className:"text-4xl mb-7 text-muted-foreground/50"}),e.jsx("p",{className:"text-foreground text-lg mb-3",children:n.trim()?t("myGames.noGamesFound"):t("myGames.noGamesYet")}),e.jsx("p",{className:"text-muted-foreground text-base mb-7",children:n.trim()?t("myGames.noGamesMatching",{search:n}):t("myGames.getStarted")}),!n.trim()&&e.jsx(N,{to:"/dashboard",className:"mx-auto px-3 h-9 flex items-center bg-foreground text-background rounded-md text-sm hover:opacity-80 transition-opacity",children:t("myGames.createFirstGame")})]})]})]})}export{Se 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.