1import{j as e,m as ie,u as Le}from"./vendor-motion-hRg_q8lq.js";import{r as n,a as Ce}from"./vendor-react-E98sgxjj.js";import{u as Pe}from"./useLocaleNavigate-BNriJdRU.js";import{u as I,a as De}from"./vendor-query-bOUN_gKe.js";import{u as V,L as Ie,d as w,ce as le,c as T,cf as de,cg as Re,P as z,V as Te,as as Ae,o as Me,b as Fe,b4 as $e,a0 as Ee,a9 as Ue,l as Y,H as Ge,ch as Be,ci as Z,c0 as ze,b_ as Ve,c5 as J,bX as R,cj as We,I as Oe,bZ as He,a5 as ee,ck as qe,s as Ke}from"./index-BKzE8EQ8.js";import{r as Qe}from"./games-CnVZUdx7.js";import{du as j}from"./vendor-fa-Bn2dnpnC.js";import{u as Xe}from"./cardParts-5JiJu2RB.js";import{p as Ye,P as Ze,s as Je}from"./GamePlanCard-DWIEA9Db.js";import{e as et,f as tt,g as at,u as rt}from"./exploreHandoff-RQymaHkp.js";import{E as st}from"./ExploreGameCard-CoU7JXPp.js";import{U as ot}from"./index-i1nPji9k.js";import{U as nt,T as it,A as lt}from"./index-DoPwtVAc.js";import"./plans-CbMJY2XS.js";import dt from"./index-BF_INNIk.js";import{G as te}from"./GameCardSkeleton-DXy1eHov.js";import{i as ct,a as mt}from"./StudioContext-C1fnzqLL.js";import{G as ut}from"./GameCard-koPJLRWA.js";import{N as pt}from"./NotificationPrompt-DCfg1qM2.js";import{u as gt}from"./useExperiment-DuA8vjwk.js";import{u as xt}from"./usePlanChat-D_HjNnxd.js";import{p as ht}from"./plansApi-C_2vGYRm.js";import{p as ft}from"./planChat-Cir7UVv6.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"./MediaImage-DKgx-nW4.js";import"./MediaVideo-CBR0-TKg.js";import"./BadgeRow-Dfwgl-tB.js";import"./PlayingNowBadge-CH2HUoBo.js";import"./playingNowApi-CB_pr25U.js";import"./Avatar-B60wpoS5.js";import"./AdminGameMenu-DlEcDyIv.js";import"./useIsStaff-DZf24Ivp.js";import"./MakeCopy-DWExybqc.js";import"./paywall-CG7xVZtx.js";import"./pricingExperiments-zMZby8z7.js";import"./organization-BuGhuc22.js";import"./Markdown-BgzYVg9N.js";import"./StreamingWords-Ds3Ch0UQ.js";import"./index-DtA29OOy.js";import"./index-Cq7f-X06.js";import"./useOrchestrationEnabled-BWYxrOff.js";import"./ActivityGrid-DDQeSjer.js";import"./LoopBudgetModal-MJKH0M3w.js";import"./useHasCredits-D0Kot1Ju.js";import"./useDevModelsVisible-BHgONHQI.js";import"./useTypewriterPlaceholder-7bmK5vs4.js";import"./useIsPaid-Cw2jGyd_.js";import"./makeCopy-DTZjoJnY.js";import"./OrgScopeLabel-C9yeV7Fb.js";import"./MemberAvatar-CfukMFmI.js";import"./useNotifications-CrW-0d5F.js";const bt=2;function vt({hasGames:l}){const{data:r}=Xe(bt,{enabled:l===!1});return l!==!1||!r?.results.length?null:e.jsx("div",{className:"mb-2","data-testid":"continue-plan-strip",children:e.jsx("div",{className:"-mx-1 flex gap-2 overflow-x-auto px-1 pb-1",children:r.results.map(c=>e.jsx(jt,{plan:c},c.id))})})}function jt({plan:l}){const{t:r}=V("game"),[c,d]=n.useState(!1),o=l.status==="ready",s=l.key_art_url&&!c?l.key_art_url:null;return e.jsxs(Ie,{to:Ye(l),className:"group flex min-w-[260px] flex-1 items-center gap-3 rounded-xl border border-border/70 bg-card/80 p-2 pr-3 transition-colors hover:border-border-hover",children:[e.jsx("div",{className:"relative h-11 w-[78px] shrink-0 overflow-hidden rounded-md bg-foreground
1/6",children:s?e.jsx("img",{src:s,alt:"",loading:"lazy",className:"h-full w-full object-cover",onError:()=>d(!0)}):e.jsx(j,{icon:["far","file-lines"],className:"absolute inset-0 m-auto text-sm text-muted-foreground/60"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:w("truncate text-sm",l.title?"text-foreground":"text-muted-foreground"),children:l.title||l.prompt_preview||r("planCard.untitled")}),e.jsxs("p",{className:"mt-0.5 flex items-center gap-1.5 truncate text-xs",children:[e.jsx("span",{className:w("h-1.5 w-1.5 shrink-0 rounded-full",o?"bg-success":"bg-amber-500")}),e.jsx("span",{className:o?"text-success":"text-amber-500",children:o?r("planCard.ready"):r("planCard.planning",{done:Je(l),total:Ze})})]})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground transition-colors group-hover:text-foreground",children:[r(o?"planCard.review":"planStrip.continue"),e.jsx(j,{icon:["far","arrow-right"],className:"text-[10px]"})]})]})}const ae={green:{hero:"bg-white/10 text-white border border-white/15 hover:bg-white/15",pillLight:"bg-green-500/10 text-green-700 hover:bg-green-500/15",pillDark:"bg-green-400/12 text-green-400 hover:bg-green-400/20",dotLight:"bg-green-500",dotDark:"bg-green-400"},emerald:{hero:"bg-white/10 text-white border border-white/15 hover:bg-white/15",pillLight:"bg-emerald-500/10 text-emerald-700 hover:bg-emerald-500/15",pillDark:"bg-emerald-400/12 text-emerald-400 hover:bg-emerald-400/20",dotLight:"bg-emerald-500",dotDark:"bg-emerald-400"},violet:{hero:"bg-white/10 text-white border border-white/15 hover:bg-white/15",pillLight:"bg-violet-500/10 text-violet-700 hover:bg-violet-500/15",pillDark:"bg-violet-400/12 text-violet-400 hover:bg-violet-400/20",dotLight:"bg-violet-500",dotDark:"bg-violet-400"},blue:{hero:"bg-white/10 text-white border border-white/15 hover:bg-white/15",pillLight:"bg-blue-500/10 text-blue-700 hover:bg-blue-500/15",pillDark:"bg-blue-400/12 text-blue-400 hover:bg-blue-400/20",dotLight:"bg-blue-500",dotDark:"bg-blue-400"},amber:{hero:"bg-white/10 text-white border border-white/15 hover:bg-white/15",pillLight:"bg-amber-500/10 text-amber-700 hover:bg-amber-500/15",pillDark:"bg-amber-400/12 text-amber-400 hover:bg-amber-400/20",dotLight:"bg-amber-500",dotDark:"bg-amber-400"},foreground:{hero:"bg-white/10 text-white border border-white/15 hover:bg-white/15",pillLight:"bg-foreground
1/8 text-foreground hover:bg-foreground/12",pillDark:"bg-foreground/10 text-foreground hover:bg-foreground/15",dotLight:"bg-foreground",dotDark:"bg-foreground"}},wt=["pointer-events-none absolute inset-0 rounded-full p-px","bg-[linear-gradient(90deg,var(--color-1),var(--color-5),var(--color-3),var(--color-4),var(--color-2))]","bg-[length:200%] animate-rainbow opacity-20","[mask:linear-gradient(#fff,#fff)_content-box,linear-gradient(#fff,#fff)]","[mask-composite:exclude] [mask-repeat:no-repeat]","[-webkit-mask:linear-gradient(#fff,#fff)_content-box,linear-gradient(#fff,#fff)]","[-webkit-mask-composite:xor]"].join(" "),yt=["pointer-events-none absolute left-1/2 -translate-x-1/2","bottom-[-60%] h-full w-[90%] opacity-10 [mask-image:radial-gradient(closest-side,rgba(0,0,0,0.6),transparent)]","bg-[linear-gradient(90deg,var(--color-1),var(--color-5),var(--color-3),var(--color-4),var(--color-2))]","bg-[length:200%] animate-rainbow"].join(" ");function re({surface:l="page",className:r}){const{open:c}=le(),{isLight:d}=T(),{promo:o}=de("pill");if(!o)return null;const s=l==="hero",m=ae[o.pill.accent]??ae.emerald;return e.jsxs(ie.button,{type:"button",onClick:()=>c("pill",o.key),initial:{opacity:0,y:-6},animate:{opacity:1,y:0},transition:{duration:.4,ease:[.16,1,.3,1]},className:w("group relative inline-flex items-center gap-2 rounded-full px-3 py-1 text-[11px] md:text-xs uppercase tracking-wider font-medium transition-all cursor-pointer",!s&&"overflow-visible",s?m.hero:d?m.pillLight:m.pillDark,r),"aria-label":o.copy.pillAria??o.copy.pillLabel,children:[!s&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,className:yt}),e.jsx("span",{"aria-hidden":!0,className:wt}),e.jsx("span",{"aria-hidden":!0,className:"absolute inset- rounded-full"}),e.jsx("span",{"aria-hidden":!0,className:"absolute inset-0.25 rounded-full bg-background"})]}),e.jsxs("span",{className:"relative flex h-2 w-2","aria-hidden":"true",children:[e.jsx("span",{className:w("animate-ping absolute inline-flex h-full w-full rounded-full opacity-70",s?"bg-white":d?m.dotLight:m.dotDark)}),e.jsx("span",{className:w("relative inline-flex rounded-full h-2 w-2",s?"bg-white":d?m.dotLight:m.dotDark)})]}),e.jsx("span",{className:"relative",children:o.copy.pillLabel}),e.jsx(j,{icon:["far","arrow-right"],className:"relative text-[10px] transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})}function se({className:l}){const{open:r}=Re();return e.jsxs(ie.button,{type:"button",onClick:()=>r("pill"),initial:{opacity:0,y:-6},animate:{opacity:1,y:0},transition:{duration:.4,ease:[.16,1,.3,1]},className:w("group inline-flex items-center gap-2 rounded-full px-3 py-1 text-[11px] md:text-xs uppercase tracking-wider font-medium transition-all cursor-pointer","bg-[#ff2fa8]/10 text-[#ff2fa8] border border-[#ff2fa8]/25 hover:bg-[#ff2fa8]/18 hover:border-[#ff2fa8]/40",l),"aria-label":"Tower Defense competition is live â learn more",children:[e.jsxs("span",{className:"relative flex h-2 w-2","aria-hidden":"true",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-70 bg-[#ff2fa8]"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-[#ff2fa8]"})]}),e.jsxs("span",{children:["Tower Defense competition",e.jsx("span",{className:"hidden sm:inline",children:" â win up to $1,000"})]}),e.jsx(j,{icon:["far","arrow-right"],className:"text-[10px] transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})}function oe({src:l,poster:r,alt:c,aspectClass:d,className:o=""}){const s=Le(),[m,h]=n.useState(!1),[u,x]=n.useState(!1),i=n.useRef(null);return n.useEffect(()=>{if(s)return;const f=i.current;if(!f)return;const p=new IntersectionObserver(([A])=>{A.isIntersecting&&(h(!0),p.disconnect())},{rootMargin:"200px"});return p.observe(f),()=>p.disconnect()},[s]),e.jsxs("div",{ref:i,className:`relative overflow-hidden ${d} ${o}`,children:[e.jsx(z,{src:r,alt:c,loading:"lazy",className:`absolute inset-0 w-full h-full object-cover object-center transition-opacity duration-500 ${u?"opacity-0":"opacity-100"}`}),m&&!s&&e.jsx(Te,{slot:"ambient",src:l,poster:r,className:`absolute inset-0 w-full h-full object-cover object-center transition-opacity duration-500 ${u?"opacity-100":"opacity-0"}
1`,muted:!0,playsInline:!0,loop:!0,autoPlay:!0,preload:"metadata","aria-hidden":"true",onLoadedData:()=>x(!0)})]})}const ne="linear-gradient(to right, transparent 0%, black 62%)";function Nt(){const{open:l}=le(),{promo:r}=de("dashboard"),{isLight:c}=T();if(!r)return null;const{banner:d,copy:o}=r,s=o.bannerAria??o.bannerAlt??d.alt,m=o.bannerLead??o.lead,h=c?d.desktopLight??d.desktop:d.desktop,u=c?d.mobileLight??d.mobile:d.mobile,x=c?d.videoLight??d.video:d.video;return!h&&!u?null:e.jsx("section",{className:"px-4 md:px-8 pb-12 md:pb-16 max-w-[1280px] mx-auto",children:e.jsxs("button",{type:"button",onClick:()=>l("banner",r.key),"aria-label":s,className:["group relative block w-full cursor-pointer overflow-hidden rounded-lg border border-border",`${c?"bg-background":"bg-black"} text-left transition-colors hover:border-foreground/25 min-h-[500px] md:min-h-[250px] flex flex-col justify-end md:justify-center`].join(" "),children:[u&&e.jsxs("div",{className:"absolute inset-0 md:hidden",children:[x?e.jsx(oe,{src:x,poster:u,alt:"",aspectClass:"h-full w-full",className:"h-full"}):e.jsx(z,{src:u,alt:"",loading:"lazy",className:"h-full w-full object-cover object-center"}),e.jsx("div",{"aria-hidden":!0,className:"absolute inset-0",style:{background:c?"linear-gradient(to top, rgba(255,255,255,0.9) 30%, rgba(255,255,255,0.0) 100%)":"linear-gradient(to top, rgba(0,0,0,0.9) 30%, rgba(0,0,0,0.0) 100%)"}})]}),h&&e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 right-0 hidden w-[65%] md:block",style:{maskImage:ne,WebkitMaskImage:ne},children:x?e.jsx(oe,{src:x,poster:h,alt:"",aspectClass:"h-full w-full",className:"h-full"}):e.jsx(z,{src:h,alt:"",loading:"lazy",className:"h-full w-full object-cover object-center"})}),e.jsx("div",{className:"relative flex flex-col items-start gap-5 px-6 py-7 md:flex-row md:items-end md:justify-between md:gap-12 md:px-10 md:py-9",children:e.jsxs("div",{className:"flex flex-col items-start gap-2.5 md:max-w-[46%]",children:[o.eyebrow&&e.jsx("span",{className:"inline-flex items-center rounded-full bg-foreground
1/10 px-3 py-1 text-[11px] font-medium uppercase tracking-[0.14em] text-foreground",children:o.eyebrow}),o.title&&e.jsx("h3",{className:"text-2xl font-medium leading-tight text-foreground md:text-4xl",children:o.title}),m&&e.jsx("p",{className:"text-sm leading-relaxed text-foreground/85 md:text-base",children:m}),o.primaryLabel&&e.jsxs("span",{className:w("relative z-10 inline-flex h-10 shrink-0 items-center gap-2 rounded-md px-5 text-sm font-medium","transition-transform hover:-translate-y-0.5 mt-1.5",Ae("themed")),children:[e.jsx("span",{className:"relative z-10",children:o.primaryLabel}),e.jsx(j,{icon:["far","arrow-right"],className:"relative z-10 text-xs"})]})]})})]})})}const kt=n.memo(function({game:r,onSelect:c,featured:d=!1,improvedStyle:o=!1}){const{t:s}=V("studio"),[m,h]=n.useState(!1),{isLight:u}=T(),x=Me(r),i=async()=>{m||(h(!0),c(r.id))};return e.jsxs("button",{onClick:i,disabled:m,className:w("h-full group relative w-full text-left rounded-lg border transition-all cursor-pointer overflow-hidden border-border bg-card flex flex-col shadow-lg","hover:border-foreground
1/25",o&&"hover:border-foreground/40 hover:shadow-xl hover:shadow-black/20",m&&"opacity-70 pointer-events-none"),children:[x&&e.jsxs("div",{className:"relative w-full aspect-[5/4] overflow-hidden",children:[e.jsx("img",{src:x,alt:r.name,className:"absolute inset-0 w-full h-full object-cover transition-transform duration-300 group-hover:scale-105",loading:"lazy"}),e.jsx("div",{className:"absolute inset-0",style:{background:u?"linear-gradient(to bottom, rgba(255,255,255,0.6) 40%, rgba(255,255,255,1) 80%)":"linear-gradient(to bottom, rgba(30,30,30,0.6) 40%, rgba(30,30,30,1) 80%)"}}),!o&&r.template_genre&&e.jsx("span",{className:"absolute top-3 left-3 px-2.5 py-1 rounded-full text-xs uppercase tracking-wider bg-black/70 text-white",children:r.template_genre}),o&&e.jsxs("span",{className:"absolute top-3 right-3 inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] uppercase tracking-wider bg-foreground text-background",children:[e.jsx(j,{icon:["far","crown"],className:"text-[9px]"}),s("templateCard.proBadge",{defaultValue:"Pro"})]})]}),e.jsxs("div",{className:"p-4 pt-0 -mt-12 relative z-10 flex-1 flex flex-col justify-stretch",children:[e.jsx("p",{className:"text-base text-foreground leading-snug mb-1",children:r.template_prompt||r.prompt||r.name}),e.jsx("div",{className:"flex-1"}),o&&e.jsxs("div",{className:"mt-2 flex items-center justify-between text-xs text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(j,{icon:["far","wand-magic-sparkles"],className:"text-[10px]"}),s("templateCard.makeItYours",{defaultValue:"Make it yours"})]}),e.jsx(j,{icon:["far","arrow-right"],className:"text-[10px]"})]})]})]})}),_t=Ke;function St({games:l,onSelect:r,improvedStyle:c=!1}){const d=n.useRef(null),[o,s]=n.useState(!1),[m,h]=n.useState(!1),u=n.useCallback(()=>{const i=d.current;i&&(s(i.scrollLeft>8),h(i.scrollLeft+i.clientWidth<i.scrollWidth-8))},[]);n.useEffect(()=>{const i=d.current;if(!i)return;u(),i.addEventListener("scroll",u,{passive:!0});const f=new ResizeObserver(u);return f.observe(i),()=>{i.removeEventListener("scroll",u),f.disconnect()}},[u,l]);const x=i=>{const f=d.current;if(!f)return;const p=226;f.scrollBy({left:i==="right"?p*2:-p*2,behavior:"smooth"})};return e.jsxs("section",{className:"w-[100vw] max-w-[600px] md:max-w-[800px] lg:max-w-[900px] xl:max-w-[1020px] mx-auto relative",children:[e.jsx("button",{onClick:()=>x("left"),className:`absolute -left-8 top-1/2 -translate-y-1/2 z-20 w-9 h-9 rounded-full bg-card/90 border border-border flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-card transition-all cursor-pointer shadow-lg ${o?"opacity-100":"opacity-0"} transition-opacity`,children:e.jsx(j,{icon:["far","chevron-left"],className:"text-sm"})}),e.jsx("button",{onClick:()=>x("right"),className:`absolute -right-8 top-1/2 -translate-y-1/2 z-20 w-9 h-9 rounded-full bg-card/90 border border-border flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-card transition-all cursor-pointer shadow-lg ${m?"opacity-100":"opacity-0"} transition-opacity`,children:e.jsx(j,{icon:["far","chevron-right"],className:"text-sm"})}),e.jsx("div",{ref:d,className:"flex gap-4 overflow-x-auto scroll-smooth px-4 md:px-8 py-6 scrollbar-hidden justify-stretch",style:{maskImage:`linear-gradient(to right, ${o?"transparent":"black"} 0%, black ${o?"48px":"0px"}, black calc(100% - ${m?"48px":"0px"}), ${m?"transparent":"black"} 100%)`,WebkitMaskImage:`linear-gradient(to right, ${o?"transparent":"black"} 0%, black ${o?"48px":"0px"}, black calc(100% - ${m?"48px":"0px"}), ${m?"transparent":"black"} 100%)`},children:l.map((i,f)=>e.jsx("div",{className:"flex-shrink-0 w-[210px]",style:{scrollSnapAlign:"start"},children:e.jsx(kt,{game:i,onSelect:r,featured:f===0,improvedStyle:c})},i.id))})]})}function Da(){const l=Pe(),r=Ce(),{user:c,isAuthenticated:d}=Fe(),{isLight:o}=T(),{t:s,i18n:m}=V("studio"),[h,u]=n.useState(null),[x,i]=n.useState(!1),[f,p]=n.useState("credits-exhausted"),[A,M]=n.useState(null),[y,F]=n.useState(!1),[b,_]=n.useState(null),ce=$e(
1),[me,$]=n.useState(!1),L=n.useRef(0),ue=n.useCallback(t=>{t.preventDefault(),L.current++,t.dataTransfer.types.includes("Files")&&$(!0)},[]),pe=n.useCallback(t=>{t.preventDefault(),L.current--,L.current<=0&&(L.current=0,$(!1))},[]),ge=n.useCallback(t=>{t.preventDefault(),L.current=0,$(!1)},[]),[P]=n.useState(()=>{if(r.state?.prompt)return sessionStorage.removeItem("onetap_pending_prompt"),r.state.prompt;const t=sessionStorage.getItem("onetap_pending_prompt");return t?(sessionStorage.removeItem("onetap_pending_prompt"),t):""}),[E]=n.useState(()=>{const t=r.state?.styleImageSrc;return t?(sessionStorage.removeItem("onetap_pending_style_image"),t):et()}),[D]=n.useState(()=>{const t=r.state?.runMode;return t?(sessionStorage.removeItem("onetap_pending_run_mode"),t):tt()}),[W]=n.useState(()=>{const t=r.state?.loopBudgetCredits;return t!=null?(sessionStorage.removeItem("onetap_pending_loop_budget"),t):at()}),O=n.useRef(!1);n.useEffect(()=>{O.current||!P||!E||(O.current=!0,(async()=>{const t={prompt:P,runMode:D,loopBudgetCredits:W,planFirst:D==="plan"};try{const a=await rt(E);l("/studio",{state:{...t,styleReferenceUrls:[a]}})}catch(a){console.error("Failed to attach concept image",a),l("/studio",{state:t})}})())},[P,E,D,W,l]);const[xe,Lt]=n.useState(""),{data:C,isLoading:he}=I(Qe()),{data:U,isLoading:fe}=I({queryKey:["top-games-dashboard"],queryFn:()=>{const t=new Date;return t.setDate(t.getDate()-7),Ee.explore({sort:"plays",limit:15,since:t.toISOString()})}}),{data:N}=I({queryKey:["user-usage"],queryFn:Ue.getUsage,enabled:d}),v=!c||c.subscription_tier==="free",G=(c?.subscription_tier??"").trim().toLowerCase(),be=G==="max"||G==="gamer"||G==="ultra",{data:B,isLoading:ve}=I({queryKey:["game-templates"],queryFn:()=>Y.listTemplates(),enabled:v}),je=De({mutationFn:t=>Y.createFromTemplate(t),onSuccess:t=>{console.log("[TemplateCreate] Success:",{gameId:t.id,hasActivityLog:!!t.template_activity_log,activityLogLength:t.template_activity_log?.length,activityLogSample:t.template_activity_log?.[0]}),l(`/studio/${t.id}`,{state:{templateActivityLog:t.template_activity_log}})},onError:t=>{console.error("Template creation failed:",t)}}),we=t=>{je.mutate(t)};n.useEffect(()=>{if(r.state?.welcomeMessage){u(r.state.welcomeMessage),window.history.replaceState({},document.title);const t=setTimeout(()=>u(null),4e3);return()=>clearTimeout(t)}},[r.state]),n.useEffect(()=>{const t=r.state?.openPaywall;t&&(p(t),i(!0),window.history.replaceState({},document.title))},[r.state]);const H=gt("onboarding_flow"),S=Be(H),q=H==="improved_templates",{available:ye,planFirst:Ne}=xt(),K=async(t,a)=>{F(!0);try{const k=await ht.create({source:"dashboard",prompt:t,style_reference_urls:a.styleRefs?.length?a.styleRefs:void 0,omni_reference_url:a.omniRef||void 0,asset_ids:a.assetIds?.length?a.assetIds:void 0,language:m.language});qe({plan_id:k.id,source:"dashboard",has_refs:!!(a.styleRefs?.length||a.omniRef),asset_count:a.assetIds?.length??0}),l(ft(k.id))}catch(k){F(!1),ee(k,s("errors.createFailed",{ns:"planChat"}))}},Q=(t,a)=>{if(y)return;if(c?.daily_credits_paused_notice?.should_show){M(t),p("daily-credits-paused-grandfather"),i(!0);return}if(ye&&a.runMode==="plan"){K(t,a);return}if(a.runMode==="auto"&&!_t){X(t,a);return}if(!(a.runMode==="plan"&&ze(N))&&(!N||N.is_overdrawn||N.edits_remaining<Ve(N))){M(t);const Se=N?.is_overdrawn?"overdrawn":"credits-exhausted";p(Se),i(!0);return}const g=!!a.planFirst;J(),R("dashboard_submit",{planFirst:g,runMode:a.runMode,hasRefs:!!(a.styleRefs?.length||a.omniRef||a.assetIds?.length)}),F(!0),setTimeout(()=>{R("dashboard_navigate_studio"),l("/studio",{state:{prompt:t,styleReferenceUrls:a.styleRefs,omniReferenceUrl:a.omniRef,assetIds:a.assetIds,planFirst:g,runMode:a.runMode,loopBudgetCredits:a.loopBudgetCredits,tier:a.tier}})},500)},ke=(t,a)=>{We({surface:"dashboard",has_refs:!!(a.styleRefs?.length||a.omniRef||a.assetIds?.length)}),Q(t,a)},X=async(t,a,k)=>{_({kind:"thinking",prompt:t}),J(),R("dashboard_submit",{planFirst:!1,runMode:"auto",hasRefs:!!(a.styleRefs?.length||a.omniRef||a.assetIds?.length)});try{const g=await Oe.generateGame({prompt:t,style_reference_urls:a.styleRefs,omni_reference_url:a.omniRef,asset_ids:a.assetIds,plan_first:!1,run_mode:"auto",tier:a.tier,platform_tier:"web",ui_source:k}
1);g.route&&He({route:g.route,paying:!!g.orchestration?.paying_customer,surface:"dashboard"}),ct(g)?_({kind:"guide",prompt:t,refs:a,data:g}):mt(g)?(_(null),K(g.prompt||t,a)):(_(null),R("dashboard_navigate_studio"),l(`/studio/${g.game_id}`,{state:{tier:a.tier}}))}catch(g){if(_(null),g?.response?.status===402){p(g.response?.data?.is_overdrawn?"overdrawn":"credits-exhausted"),i(!0);return}ee(g)}},_e=t=>{b?.kind==="guide"&&X(t,{tier:b.refs.tier,runMode:"auto"},"proposal")};return e.jsxs(e.Fragment,{children:[e.jsx(Ge,{children:e.jsx("title",{children:s("dashboard.pageTitle")})}),e.jsxs("div",{onDragEnter:ue,onDragLeave:pe,onDragOver:t=>t.preventDefault(),onDrop:ge,children:[e.jsx(ot,{isOpen:x,onClose:()=>{i(!1),M(null),p("credits-exhausted")},pendingPrompt:A||void 0,context:f}),h&&e.jsx("div",{className:"fixed top-6 right-6 z-50 animate-in slide-in-from-top-2 fade-in duration-300",children:e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 bg-[color-mix(in_srgb,var(--color-success)_20%,var(--color-card))] border border-success/40 rounded-md shadow-lg",children:[e.jsx("span",{className:"text-success text-lg",children:"â"}),e.jsx("span",{className:"text-success",children:h}),e.jsx("button",{onClick:()=>u(null),className:"ml-2 text-success/60 hover:text-success transition-colors",children:"â"})]})}),e.jsxs("section",{className:`relative overflow-hidden transition-all duration-500 ${y?"opacity-0 scale-[0.985]":""} ${v&&!S?"h-[calc(100vh-100px)] md:h-[calc(100vh-26px)] min-h-[600px] md:min-h-[700px]":"h-[calc(100vh-100px)] md:h-[calc(100vh-81px)] min-h-[600px] md:min-h-[700px] max-h-[810px] md:max-h-[1200px]"}`,children:[e.jsx("div",{"aria-hidden":"true",className:"absolute inset-0 pointer-events-none",style:{backgroundImage:`url(${o?"/grids/grid-light.png":"/grids/grid-dark.png"})`,backgroundSize:"cover",backgroundPosition:"center top",backgroundRepeat:"no-repeat",maskImage:"linear-gradient(to bottom, black 0%, black 60%, transparent 99%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, black 60%, transparent 99%)"}}),e.jsxs("div",{className:w("relative z-10 flex flex-col items-center h-full px-4",v&&!S?"justify-stretch":"justify-center"),children:[v&&!S?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[Z()?e.jsx(se,{className:"mb-3"}):e.jsx(re,{surface:"page",className:"mb-3"}),e.jsx("h1",{className:"text-h3-sm md:text-h3 text-foreground text-center mb-2",children:s("dashboard.heroTitle",{username:c?.username||s("dashboard.heroFallbackName")})}),q&&e.jsx("p",{className:"text-sm text-muted-foreground text-center mb-2 mt-2",children:s("dashboard.improvedTemplatesTagline",{defaultValue:"Pick a template to play with â upgrade to Pro to make it yours."})}),v&&ve&&e.jsx("section",{className:"w-[100vw] max-w-[600px] md:max-w-[800px] lg:max-w-[900px] xl:max-w-[1020px] mx-auto relative",children:e.jsx("div",{className:"flex gap-4 overflow-x-hidden px-4 md:px-8 py-6",style:{maskImage:"linear-gradient(to right, black 0%, black calc(100% - 48px), transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 0%, black calc(100% - 48px), transparent 100%)"},children:Array.from({length:7}).map((t,a)=>e.jsx("div",{className:"flex-shrink-0 w-[210px]",style:{scrollSnapAlign:"start"},children:e.jsxs("div",{className:"rounded-lg border border-border bg-card overflow-hidden animate-pulse shadow-lg relative",children:[e.jsx("div",{className:"w-full aspect-[5/4]"}
1),e.jsx("div",{className:"h-6 w-16 rounded-full bg-foreground/8 absolute top-3.5 left-3.5"}),e.jsxs("div",{className:"p-4 pt-0 -mt-12",children:[e.jsx("div",{className:"h-5.5 w-full flex items-center justify-stretch",children:e.jsx("div",{className:"h-3 w-4/5 rounded bg-foreground/6"})}),e.jsx("div",{className:"h-5.5 w-full flex items-center justify-stretch",children:e.jsx("div",{className:"h-3 w-9/10 rounded bg-foreground/6"})}),e.jsx("div",{className:"h-5.5 w-full flex items-center justify-stretch",children:e.jsx("div",{className:"h-3 w-3/4 rounded bg-foreground/6"})}),e.jsx("div",{className:"h-5.5 w-full flex items-center justify-stretch mb-1",children:e.jsx("div",{className:"h-3 w-1/2 rounded bg-foreground/6"})})]})]})},a))})}),v&&B&&B.length>0&&e.jsx(St,{games:B,onSelect:we,improvedStyle:q})]}):e.jsxs("div",{className:"flex flex-col items-center mb-8",children:[Z()?e.jsx(se,{className:"mb-5"}):e.jsx(re,{surface:"page",className:"mb-5"}),e.jsx("h1",{className:"text-h3-sm md:text-h3 text-foreground text-center",children:s("dashboard.heroTitle",{username:c?.username||s("dashboard.heroFallbackName")})})]}),e.jsxs("div",{className:w("relative w-full px-4 md:px-8",v?"max-w-[838px] mb-4":"max-w-[838px]"),children:[!S&&e.jsx(nt,{isFreeUser:v,usage:N,onUpgrade:()=>i(!0),className:"mb-4"}),e.jsx(n.Suspense,{fallback:null,children:e.jsx(vt,{hasGames:C?C.length>0:void 0})}),e.jsx(dt,{onSubmit:Q,disabled:y||b?.kind==="thinking",isFreeUser:S?!1:v,isAssetUploadGated:!be,initialPrompt:xe||P,initialTier:r.state?.tier,initialRunMode:D,pageDragActive:me,onAssetUploadBlocked:()=>{p("asset-import-locked"),i(!0)},onAtomosBlocked:()=>{p("atomos-locked"),i(!0)},onMuranyiBlocked:()=>{p("muranyi-locked"),i(!0)},onLoopBlocked:()=>{p("loop-locked"),i(!0)},onBuildBlocked:()=>{p("credits-exhausted"),i(!0)},onPlanFirst:Ne?ke:void 0}),b&&e.jsxs("div",{className:"absolute left-4 right-4 md:left-8 md:right-8 top-full mt-3 z-20",children:[b.kind==="thinking"&&(ce?e.jsxs("div",{"data-testid":"auto-thinking",className:"flex items-center gap-2 px-1 text-sm text-muted-foreground",children:[e.jsx(j,{icon:["far","compass"],className:"text-violet-400 animate-pulse"}),s("autoRoute.thinking","Working out what you needâ¦")]}):e.jsx("div",{"data-testid":"auto-waiting",className:"px-1",children:e.jsx(it,{text:"",streaming:!0})})),b.kind==="guide"&&e.jsx(lt,{variant:"card",answer:b.data.answer,proposal:b.data.build_suggestion,proposalLabel:b.data.build_label,orchestration:b.data.orchestration,guideModel:b.data.guide_model,onPropose:_e,onDismiss:()=>_(null)})]})]})]})]}),(!v||S)&&e.jsxs(e.Fragment,{children:[e.jsx(Nt,{}),he?e.jsxs("section",{className:`px-4 md:px-8 pb-12 transition-all duration-500 ${y?"opacity-0 translate-y-8":""} max-w-[1280px] mx-auto`,children:[e.jsx("div",{className:"flex items-end justify-between mb-6",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg-sm md:text-lg text-foreground",children:s("dashboard.recentlyViewed")}),e.jsx("p",{className:"text-base text-muted-foreground mt-1",children:s("dashboard.recentlyViewedDescription")})]})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-8",children:e.jsx(te,{count:3})})]}):C&&C.length>0&&e.jsxs("section",{className:`px-4 md:px-8 pb-12 transition-all duration-500 ${y?"opacity-0 translate-y-8":""} max-w-[1280px] mx-auto`,children:[e.jsxs("div",{className:"flex items-end justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg-sm md:text-lg text-foreground",children:s("dashboard.recentlyViewed")}),e.jsx("p",{className:"text-base text-muted-foreground mt-1",children:s("dashboard.recentlyViewedDescription")})]}),e.jsx("a",{href:"/my-games",className:"text-base text-muted-foreground hover:text-foreground transition-colors",children:s("dashboard.viewAll")})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-8",children:[...C].sort((t,a)=>new Date(a.updated_at||a.created_at).getTime()-new Date(t.updated_at||t.created_at).getTime()).slice(0,3).map(t=>e.jsx(ut,{game:t},t.id))})]}),fe?e.jsxs("section",{className:`px-4 md:px-8 pb-12 transition-all duration-500 ${y?"opacity-0 translate-y-8":""} max-w-[1280px] mx-auto`,children:[e.jsx("div",{className:"flex items-end justify-between mb-6",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg-sm md:text-lg text-foreground",children:s("dashboard.topGamesThisWeek")}),e.jsx("p",{className:"text-base text-muted-foreground mt-1",children:s("dashboard.topGamesDescription")})]})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-8",children:e.jsx(te,{count:6})})]}):U&&U.games.length>0&&e.jsxs("section",{className:`px-4 md:px-8 pb-12 transition-all duration-500 ${y?"opacity-0 translate-y-8":""} max-w-[1280px] mx-auto`,children:[e.jsxs("div",{className:"flex items-end justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg-sm md:text-lg text-foreground",children:s("dashboard.topGamesThisWeek")}),e.jsx("p",{className:"text-base text-muted-foreground mt-1",children:s("dashboard.topGamesDescription")})]}),e.jsx("a",{href:"/play",className:"text-base text-muted-foreground hover:text-foreground transition-colors",children:s("dashboard.viewAll")})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-8",children:U.games.map(t=>e.jsx(st,{game:t},t.id))})]})]})]}),!v&&e.jsx(pt,{variant:"dashboard"})]})}
1export{Da 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.