PageSourceSearch

https://tesana.com/assets/GuidedCreationPage-DNmLofWy.js

js tesana.com collected 2026-10-09 22:40:22 UTC 31,896 bytes, 1 lines download raw bytes

1import{j as e,u as F,m as C,A as O}from"./vendor-motion-hRg_q8lq.js";import{r as n,a as je}from"./vendor-react-E98sgxjj.js";import{u as T,c as _e,d as E,l as de,n as Se,I as X,cb as ke,b as Ne,ac as re,a9 as Ge,cl as Ie,j as Re,ck as Ae,a5 as Te,cm as Ce,cn as Ee,co as Pe,cp as W,f as Le,H as Me,cq as Fe,a1 as Ue,cr as De,cs as Oe,ct as $e}from"./index-BKzE8EQ8.js";import{u as Ke}from"./vendor-query-bOUN_gKe.js";import{u as He}from"./useLocaleNavigate-BNriJdRU.js";import{p as Qe}from"./plansApi-C_2vGYRm.js";import{u as Be}from"./usePlanChat-D_HjNnxd.js";import{b as ze,c as Ve,p as We}from"./planChat-Cir7UVv6.js";import{u as Ye,c as ne,d as qe}from"./exploreHandoff-RQymaHkp.js";import{U as Xe}from"./index-i1nPji9k.js";import{du as $}from"./vendor-fa-Bn2dnpnC.js";import{S as Ze,a as L,b as Je,e as Y,c as et,d as tt}from"./scenes-D-OxP8-v.js";import{b as st}from"./AvatarCarousel-DJMyzfiE.js";import at from"./index-BF_INNIk.js";import{a as rt,b as nt,E as it}from"./ExploreConceptView-vqE-9DmN.js";import{G as ot}from"./GameFrame-COJWxWBt.js";import{u as lt,A as ct}from"./LoopBudgetModal-MJKH0M3w.js";import{a as ie}from"./index-DoPwtVAc.js";import{U as dt,S as ut,Q as mt,u as pt}from"./ChatPanel-YMYP4TKG.js";import{M as ft}from"./Markdown-BgzYVg9N.js";import{u as gt,b as oe,f as ht}from"./StudioContext-C1fnzqLL.js";import{P as xt}from"./PlanPreviewCard-C70rpRPP.js";import{C as bt}from"./CoinTopUpModal-CAwRJTIr.js";import"./paywall-CG7xVZtx.js";import"./plans-CbMJY2XS.js";import"./pricingExperiments-zMZby8z7.js";import"./organization-BuGhuc22.js";import"./LazyVideo-1GeND61g.js";import"./useOrchestrationEnabled-BWYxrOff.js";import"./useDevModelsVisible-BHgONHQI.js";import"./useTypewriterPlaceholder-7bmK5vs4.js";import"./useHasCredits-D0Kot1Ju.js";import"./MediaImage-DKgx-nW4.js";import"./index-BxtVm1Yj.js";import"./AuthShell-DPeun0C_.js";import"./AuthPanel-B4zt6SJ5.js";import"./pendingReferral-B4JPXhl_.js";import"./LaunchPromoClips-eRoWsyBt.js";import"./Tooltip-C8AvPGtA.js";import"./StreamingWords-Ds3Ch0UQ.js";import"./ActivityGrid-DDQeSjer.js";import"./screenshotStore-B6ItflPb.js";import"./useIsMaxTier-CA74KWZY.js";import"./index-DtA29OOy.js";import"./index-Cq7f-X06.js";function yt({stepCount:r,stepIndex:i,onBack:g,onSkip:c,width:p="narrow",children:m}){const{t:v}=T("onboarding"),{isLight:j}=_e();return e.jsxs("div",{className:E("relative flex min-h-screen flex-col justify-stretch align-stretch",j?"bg-card":"bg-background"),children:[e.jsxs("div",{className:"relative flex h-16 shrink-0 items-center justify-center px-4 lg:h-20 lg:px-6",children:[g&&e.jsx("button",{type:"button",onClick:g,"aria-label":v("firstGame.back"),className:"absolute left-4 top-1/2 flex h-9 w-9 -translate-y-1/2 items-center justify-center rounded-full bg-foreground
1/6 text-muted-foreground transition-colors hover:bg-foreground/10 hover:text-foreground cursor-pointer lg:left-6",children:e.jsx($,{icon:["far","chevron-left"],className:"text-xs"})}),e.jsx(Ze,{total:r,current:i}),c&&e.jsx("button",{type:"button",onClick:c,className:"absolute right-4 top-1/2 flex h-9 -translate-y-1/2 items-center rounded-full bg-foreground/6 px-4 text-sm text-muted-foreground transition-colors hover:bg-foreground/10 hover:text-foreground cursor-pointer lg:right-6",children:v("firstGame.skip")})]}),e.jsx("div",{className:"flex flex-1 flex-col items-center px-4 pb-12 pt-4 sm:px-6 lg:pt-8",children:e.jsx("div",{className:E("w-full",p==="narrow"?"max-w-[560px]":"max-w-[840px]"),children:m})})]})}const wt=[112,127,139];function vt({onReady:r}){const{t:i}=T("onboarding"),g=F();return e.jsxs("div",{className:"flex flex-col items-center pt-[12vh] text-center",children:[e.jsx(L,{lead:i("firstGame.commitment.lead"),tail:i("firstGame.commitment.tail")}),e.jsxs(C.div,{className:"inline-flex h-10 items-center gap-2.5 rounded-full border border-border/70 bg-card pl-2 pr-4",initial:g?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:.15,duration:.4,ease:[.16,1,.3,1]},children:[e.jsx("span",{className:"flex -space-x-2",children:wt.map(c=>e.jsx("img",{src:`${st}/avatar_${c}.webp`,alt:"","aria-hidden":!0,className:"h-6 w-6 rounded-full object-cover ring-2 ring-card"},c))}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i("firstGame.commitment.socialProof")}
1)]}),e.jsx(C.button,{type:"button",onClick:r,className:"mt-8 flex h-11 w-full max-w-[360px] items-center justify-center rounded-md bg-foreground text-sm font-medium text-background transition-opacity hover:opacity-90 cursor-pointer",initial:g?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:.25,duration:.4,ease:[.16,1,.3,1]},children:i("firstGame.commitment.cta")})]})}const jt=[{id:"idea",icon:["far","lightbulb"]},{id:"image",icon:["far","image"]},{id:"assets",icon:["far","cloud-arrow-up"]},{id:"not_sure",icon:["far","compass"]}];function _t(r){return["commitment","fork",r==="image"?"image":r==="assets"?"assets":"prompt","creating","result"]}function St(r){return r?.plan_preview_active?"plan":"build"}const H={start:"first_game_start",skippedAt:"first_game_skipped_at",runKind:"first_game_run_kind"},kt=[{id:"kingdom",emoji:"🏰",titleKey:"firstGame.ideas.kingdom",seed:"a cozy medieval kingdom builder where you grow a village and keep your people happy"},{id:"racer",emoji:"🏎️",titleKey:"firstGame.ideas.racer",seed:"a neon-lit arcade racer with drifting, boost pads and a night city track"},{id:"dungeon",emoji:"🗡️",titleKey:"firstGame.ideas.dungeon",seed:"a top-down dungeon crawler with procedurally generated rooms, loot and a final boss"},{id:"farm",emoji:"🌾",titleKey:"firstGame.ideas.farm",seed:"a relaxing farming sim on a floating island where you plant crops, raise animals and trade with visitors"},{id:"platformer",emoji:"🦊",titleKey:"firstGame.ideas.platformer",seed:"a 2D platformer starring a fox who can double-jump and wall-climb through a misty forest"},{id:"space",emoji:"🚀",titleKey:"firstGame.ideas.space",seed:"a space trading game where you fly between planets, upgrade your ship and dodge pirates"}];function Nt({value:r,onSelect:i,locked:g}){const{t:c}=T("onboarding");return e.jsxs("div",{className:"pt-[8vh]",children:[e.jsx(L,{lead:c("firstGame.fork.lead"),tail:c("firstGame.fork.tail")}),e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"radiogroup","aria-label":c("firstGame.fork.lead"),children:jt.map(p=>e.jsx(Je,{icon:p.icon,title:c(`firstGame.fork.${p.id}.title`),description:c(`firstGame.fork.${p.id}.desc`),selected:r===p.id,onSelect:()=>i(p.id),disabled:g},p.id))})]})}function ue({variant:r,initialPrompt:i="",assetIds:g,canImportAssets:c,onAssetUploadBlocked:p,onSubmit:m,submitting:v,submitLabel:j}){const{t:h}=T("onboarding"),G=F(),[u,S]=n.useState({text:i,key:0}),[l,f]=n.useState(null),s=r==="not_sure";return e.jsxs("div",{className:"pt-[6vh]",children:[e.jsx(L,{lead:h(s?"firstGame.notSure.lead":"firstGame.prompt.lead"),tail:h(s?"firstGame.notSure.tail":"firstGame.prompt.tail")}),s&&e.jsx("div",{className:"mb-5 flex flex-wrap justify-center gap-2",role:"listbox","aria-label":h("firstGame.notSure.lead"),children:kt.map((o,t)=>e.jsxs(C.button,{type:"button",role:"option","aria-selected":l===o.id,onClick:()=>{f(o.id),S({text:o.seed,key:Date.now()})},className:E("inline-flex h-10 items-center gap-2 rounded-full border px-4 text-sm transition-all cursor-pointer","bg-card border-border/70 text-foreground hover:border-border-hover hover:bg-foreground
1/[0.03]",l===o.id&&"border-success/60 bg-success/[0.1] hover:border-success/60 hover:bg-success/[0.1]"),initial:G?!1:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{delay:.05*t,duration:.3},children:[e.jsx("span",{"aria-hidden":!0,children:o.emoji}),h(o.titleKey)]},o.id))}),e.jsx("div",{className:E(v&&"pointer-events-none opacity-60"),children:e.jsx(at,{initialPrompt:u.text,onSubmit:(o,t)=>m(o,{...t,assetIds:g?.length?[...t.assetIds??[],...g]:t.assetIds}),disabled:v,isFreeUser:!0,isAssetUploadGated:!c,onAssetUploadBlocked:p,hidePickers:!0,submitLabel:j},u.key)}),e.jsx("p",{className:"mt-4 text-center text-xs text-muted-foreground/70",children:h(s?"firstGame.notSure.hint":"firstGame.prompt.hint")})]})}const le=12,Gt=700;function It({onSubmit:r,submitting:i,onLoopBlocked:g}){const{t:c}=T("onboarding"),p=F(),[m,v]=n.useState(null),[j,h]=n.useState(null),[G,u]=n.useState(null),[S,l]=n.useState(null),f=n.useRef(null),s=n.useRef(null);n.useEffect(()=>{let t=!0;return de.exploreConcepts().then(k=>{t&&v(k.filter(b=>b.src).slice(0,le))}).catch(()=>{t&&v([])}),()=>{t=!1}},[]),n.useEffect(()=>()=>{f.current&&window.clearTimeout(f.current)},[]);const o=n.useCallback(t=>{l(t.id),u({text:t.prompt,imageSrc:t.still_url||t.src,key:Date.now(),conceptId:t.id}),f.current&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>{h(null),f.current=null,s.current?.scrollIntoView({block:"center",behavior:p?"auto":"smooth"})},p?0:Gt)},[p]);return e.jsxs("div",{className:"pt-[4vh]",children:[e.jsx(L,{lead:c("firstGame.image.lead"),tail:c("firstGame.image.tail")}),e.jsx("div",{ref:s,className:E("mb-5",i&&"pointer-events-none opacity-60"),children:e.jsx(rt,{onSubmit:r,seed:G,submitting:i,onLoopBlocked:g})}),e.jsx(O,{mode:"wait",initial:!1,children:j?e.jsx(C.div,{className:"overflow-hidden",initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:e.jsx(nt,{concepts:m??[],initialId:j.id,onClose:()=>{f.current&&(window.clearTimeout(f.current),f.current=null),h(null)},onInspire:o})},"view"):e.jsx(C.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:m===null?e.jsx("div",{className:"grid grid-cols-2 gap-1 overflow-hidden rounded-xl sm:grid-cols-3",children:Array.from({length:le},(t,k)=>e.jsx("div",{className:"aspect-video animate-pulse bg-foreground/[0.06]"},k))}):m.length===0?e.jsx("p",{className:"py-16 text-center text-sm text-muted-foreground",children:c("firstGame.image.empty")}):e.jsx("div",{className:"grid grid-cols-2 gap-1 overflow-hidden rounded-xl sm:grid-cols-3",children:m.map((t,k)=>e.jsx(it,{concept:t,cornerClass:"",active:S===t.id,eager:k<6,onSelect:h},t.id))})},"wall")}),e.jsx("p",{className:"mt-4 text-center text-xs text-muted-foreground/70",children:c("firstGame.image.hint")})]})}const ce=8;function Rt({canImportAssets:r,onAssetUploadBlocked:i,onSubmit:g,submitting:c,submitLabel:p}){const{t:m}=T("onboarding"),v=F(),[j,h]=n.useState([]),[G,u]=n.useState(!1),S=n.useRef(null),l=(a,_)=>h(w=>w.map(I=>I.key===a?{...I,..._}:I)),f=n.useCallback(a=>{const _=`${a.name}-${a.size}-${Date.now()}`;h(w=>[...w,{key:_,filename:a.name,size:a.size,status:"uploading",progress:0}]),lt(a,w=>{const I=w.total?Math.round(w.loaded/w.total*100):0;l(_,I>=100?{progress:100,status:"scanning"}:{progress:I})}).then(w=>l(_,{status:w.scan_status==="clean"?"clean":w.scan_status==="malicious"?"malicious":"error",asset:w})).catch(w=>{if(w?.response?.status===403){i(),h(N=>N.filter(A=>A.key!==_));return}l(_,{status:"error",error:m("firstGame.assets.uploadFailed")})})},[i,m]),s=a=>{if(!r){i();return}const _=Math.max(0,ce-j.length);Array.from(a).slice(0,_).forEach(f)},o=a=>{a.preventDefault(),u(!1),a.dataTransfer.files?.length&&s(a.dataTransfer.files)},t=j.filter(a=>a.status==="clean"&&a.asset).map(a=>a.asset.id),k=t.length>0,b=j.some(a=>a.status==="uploading"||a.status==="scanning");return e.jsxs("div",{className:"pt-[6vh]",children:[e.jsx(O,{initial:!1,children:!k&&e.jsx(C.div,{exit:{opacity:0,height:0},transition:{duration:.2},children:e.jsx(L,{lead:m("firstGame.assets.lead"),tail:m("firstGame.assets.tail")})},"title")}),e.jsxs("div",{onDragOver:a=>{a.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:o,className:E("rounded-xl border border-dashed p-6 text-center transition-colors",G?"border-success/60 bg-success/[0.06]":"border-border/80 bg-card",k&&"p-4"),children:[e.jsx("input",{ref:S,type:"file",multiple:!0,className:"hidden",onChange:a=>{a.target.files&&s(a.target.files),a.currentTarget.value=""}}),j.length===0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-foreground
1/6 text-muted-foreground",children:e.jsx($,{icon:["far","cloud-arrow-up"],className:"text-lg"})}),e.jsx("button",{type:"button",onClick:()=>S.current?.click(),className:"mt-4 inline-flex h-10 items-center justify-center rounded-md bg-foreground px-5 text-sm font-medium text-background transition-opacity hover:opacity-90 cursor-pointer",children:m("firstGame.assets.upload")}),e.jsx("p",{className:"mt-3 text-xs text-muted-foreground/70",children:m("firstGame.assets.types")})]}):e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[j.map(a=>e.jsx(ct,{filename:a.filename,size:a.size,assetKind:a.asset?.asset_kind,status:a.status,progress:a.progress,errorMessage:a.error,onRemove:()=>h(_=>_.filter(w=>w.key!==a.key))},a.key)),j.length<ce&&e.jsxs("button",{type:"button",onClick:()=>S.current?.click(),className:"inline-flex h-8 items-center gap-1.5 rounded-full border border-border/70 px-3 text-xs text-muted-foreground transition-colors hover:border-border-hover hover:text-foreground cursor-pointer",children:[e.jsx($,{icon:["far","plus"],className:"text-[10px]"}),m("firstGame.assets.addMore")]})]})]}),e.jsx(O,{initial:!1,children:k&&e.jsx(C.div,{initial:v?!1:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,ease:[.16,1,.3,1]},className:"mt-2",children:e.jsx(ue,{variant:"idea",assetIds:t,canImportAssets:r,onAssetUploadBlocked:i,onSubmit:g,submitting:c||b,submitLabel:p})},"composer")}),!k&&e.jsx("p",{className:"mt-4 text-center text-xs text-muted-foreground/70",children:m("firstGame.assets.hint")})]})}function At({gameId:r,activeSessionId:i,isGenerating:g,startedAt:c,messages:p,liveItems:m,liveSubagents:v,pendingQuestion:j,answering:h,onAnswer:G}){const{t:u}=T("onboarding"),S=p.some(s=>s.message_type==="question"&&!s.metadata?.answered),l=j&&!S?[...p,{role:"assistant",content:"",timestamp:new Date().toISOString(),message_type:"question",metadata:{pending_question:j},session_id:i??void 0}]:p;let f=-1;for(let s=l.length-1;s>=0;s--){const o=l[s];if(o.message_type==="generation"&&(!i||o.session_id===i)){f=s;break}}return l.length===0?e.jsx("div",{className:"flex h-[188px] items-center justify-center text-sm text-muted-foreground",children:u("firstGame.creating.starting")}):e.jsx("div",{className:"",children:l.map((s,o)=>{const t=s.id??`${s.message_type}-${s.timestamp}-${o}`,k=l[o+1]?.message_type??null;if(s.role==="user")return e.jsx("div",{className:"mb-4",children:e.jsx(dt,{content:s.content,assets:s.metadata?.assets,imageAttachments:s.metadata?.image_attachments,isOnboarding:!0})},t);switch(s.message_type){case"generation":{const b=o===f,a=s.metadata??{status:"in_progress",summary:"",steps:[],updated_at:s.timestamp,session_id:s.session_id};return e.jsx("div",{className:"mb-4",children:e.jsx(ie,{metadata:a,isLast:o===l.length-1,isGenerating:b&&g,messageTimestamp:s.timestamp||c||new Date().toISOString(),nextMessageType:k,mode:"tail",gameId:r,sessionId:s.session_id??null,liveItems:b?m:void 0,liveSubagents:b?v:void 0,runStartedAt:b?c:null,emptyLabel:u("firstGame.creating.starting")})},t)}case"question":return e.jsx("div",{className:"mb-4",children:e.jsx(mt,{message:s,onAnswer:G,disabled:h||s.metadata?.answered===!0})},t);case"system":return e.jsx(ut,{content:s.content,forceError:s.metadata?.system_error},t);case"text":{const b=s.session_id??s.metadata?.session_id;if(b){const a=s.metadata??{status:"complete",summary:"",steps:[],updated_at:s.timestamp,session_id:b};return e.jsx("div",{className:"mb-4",children:e.jsx(ie,{metadata:a,isLast:o===l.length-1,isGenerating:!1,messageTimestamp:s.timestamp,nextMessageType:k,mode:"tail",gameId:r,sessionId:b})},t)}return s.content?.trim()?e.jsx("div",{className:"mb-4 text-sm leading-relaxed text-foreground",children:e.jsx(ft,{children:s.content})},t):null}case"plan":case"summary":default:return null}})})}const Tt=9e3;function Ct(r,i){const[g,c]=n.useState(()=>Date.now());if(n.useEffect(()=>{if(!i)return;const m=window.setInterval(()=>c(Date.now()),1e3);return()=>window.clearInterval(m)},[i]),!r)return"0:00";const p=Math.max(0,Math.floor((g-new Date(r).getTime())/1e3));return`${Math.floor(p/60)}:${String(p%60).padStart(2,"0")}`}function Et({kind:r,gameId:i,sessionId:g,isGenerating:c,dispatching:p,currentAction:m,startedAt:v,liveItems:j,liveSubagents:h,messages:G,pendingQuestion:u,answering:S,onAnswer:l}){const{t:f}=T("onboarding"),{t:s}=T("auth"),o=F(),t=u!=null,k=Ct(v,c||p||t),[b,a]=n.useState(0),_=n.useRef(null);n.useEffect(()=>{if(o)return;const N=window.setInterval(()=>a(A=>(A+1)%Y.length),Tt);return()=>window.clearInterval(N)},[o]),n.useEffect(()=>{const N=_.current;if(!N)return;(N.scrollHeight-N.scrollTop-N.clientHeight<120||t)&&(N.scrollTop=N.scrollHeight)},[j.length,G.length,t]);const w=Y[b],I=et[w];return e.jsxs("div",{className:"pt-[3vh]",children:[e.jsx(L,{lead:f(r==="plan"?"firstGame.creating.planLead":"firstGame.creating.buildLead"),tail:f(r==="plan"?"firstGame.creating.planTail":"firstGame.creating.buildTail")}),e.jsxs("div",{className:"mb-3 flex items-center justify-between px-1 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs("span",{className:"relative flex h-2 w-2 shrink-0",children:[e.jsx("span",{className:E("absolute inline-flex h-full w-full rounded-full opacity-75",t?"bg-amber-400":"bg-success",!o&&!t&&"animate-ping")}),e.jsx("span",{className:E("relative inline-flex h-2 w-2 rounded-full",t?"bg-amber-400":"bg-success")})]}),e.jsx("span",{className:"truncate",children:p?f("firstGame.creating.dispatching"):t?f("firstGame.creating.waitingForYou"):m||f(r==="plan"?"firstGame.creating.planWorking":"firstGame.creating.buildWorking")})]}),e.jsx("span",{className:"shrink-0 tabular-nums",children:k})]}),e.jsx("div",{ref:_,className:E("overflow-y-auto rounded-xl border border-border/70 bg-card px-4 pb-4 pt-1",t?"max-h-[60vh] min-h-[220px]":"max-h-[46vh] min-h-[220px]"),children:i!=null?e.jsx(At,{gameId:i,activeSessionId:g,isGenerating:c,startedAt:v,messages:G,liveItems:j,liveSubagents:h,pendingQuestion:u,answering:S,onAnswer:l}):e.jsx("div",{className:"flex h-[188px] items-center justify-center text-sm text-muted-foreground",children:f("firstGame.creating.dispatching")})}),e.jsxs("div",{className:"mt-6 overflow-hidden rounded-xl border border-border/70 bg-[#171615]",children:[e.jsx(O,{mode:"wait",initial:!1,children:e.jsxs(C.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.4},children:[e.jsx("div",{className:"[&>div]:h-[200px]",children:e.jsx(I,{})}),e.jsxs("div",{className:"px-6 pb-5 pt-1 text-center",children:[e.jsx("h3",{className:"text-base font-medium text-white",children:s(`onboarding.spotlight.${w}.title`)}),e.jsx("p",{className:"mx-auto mt-1 max-w-[420px] text-xs leading-relaxed text-white/55",children:s(`onboarding.spotlight.${w}.body`)})]})]},w)}),e.jsx("div",{className:"flex justify-center gap-1.5 pb-4",role:"tablist","aria-label":f("firstGame.creating.whileYouWait"),children:Y.map((N,A)=>e.jsx("button",{type:"button",role:"tab","aria-selected":A===b,"aria-label":s(`onboarding.spotlight.${N}.title`),onClick:()=>a(A),className:E("h-1 rounded-full transition-all cursor-pointer",A===b?"w-5 bg-white":"w-2 bg-white/25 hover:bg-white/40")},N))})]})]})}function Pt({kind:r,gameId:i,gameName:g,messages:c,failed:p,onUpgrade:m,onContinueToStudio:v,onRetry:j}){const{t:h}=T("onboarding"),G=F(),[u,S]=n.useState(null),l=n.useRef(null),[f,s]=n.useState(!1),o=n.useCallback(()=>s(!0),[]),t=n.useCallback(_=>{if(s(!1),typeof _=="number"){l.current?.completeTopUp(!0,_);return}Se.getWallet().then(w=>l.current?.completeTopUp(!0,w.balance)).catch(()=>l.current?.completeTopUp(!1))},[]);n.useEffect(()=>{let _=!0;return de.get(i).then(w=>{_&&S(w)}).catch(()=>{}),()=>{_=!1}},[i]);const k=gt(i,g??u?.engine_game_name??void 0,!1,u?.engine_version,u);if(p)return e.jsxs("div",{className:"pt-[10vh] text-center",children:[e.jsx(L,{lead:h("firstGame.result.failedLead"),tail:h("firstGame.result.failedTail")}),e.jsxs("div",{className:"flex flex-col items-center gap-2 sm:flex-row sm:justify-center",children:[e.jsx("button",{type:"button",onClick:j,className:"inline-flex h-11 items-center justify-center rounded-md bg-foreground px-6 text-sm font-medium text-background transition-opacity hover:opacity-90 cursor-pointer",children:h("firstGame.result.tryAgain")}),e.jsx("button",{type:"button",onClick:v,className:"inline-flex h-11 items-center justify-center rounded-md bg-foreground
1/6 px-6 text-sm text-foreground transition-colors hover:bg-foreground/10 cursor-pointer",children:h("firstGame.result.openStudio")})]})]});if(r==="plan")return e.jsxs(C.div,{className:"pt-[2vh]",initial:G?!1:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4,ease:[.16,1,.3,1]},children:[e.jsx(L,{lead:h("firstGame.result.planLead"),tail:h("firstGame.result.planTail")}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border/70 bg-card",children:e.jsx(xt,{messages:c,assets:k.viewableAssets,isGenerating:!1,isHydratingAssets:k.isHydrating,ensureHydratedAssets:k.ensureHydrated,isLockedToUpgrade:!0,onUpgrade:m,variant:"visual_card",gameId:i,gameName:g})}),e.jsxs("button",{type:"button",onClick:v,className:"mx-auto mt-5 flex items-center gap-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground cursor-pointer",children:[h("firstGame.result.openStudio"),e.jsx($,{icon:["far","arrow-right"],className:"text-xs"})]})]});const b=u?X.getGameIframeUrl(u):null,a=u?e.jsx(bt,{isOpen:f,onClose:t,returnUrl:typeof window>"u"?"":window.location.href}):null;return e.jsxs(C.div,{className:"pt-[4vh] text-center",initial:G?!1:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4,ease:[.16,1,.3,1]},children:[e.jsx(L,{lead:h("firstGame.result.buildLead"),tail:h("firstGame.result.buildTail")}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border/70 bg-black shadow-2xl shadow-black/40",children:b&&u?e.jsx(ot,{ref:l,gameId:u.id,playGameId:u.public_id??null,studio:!0,onTopUpRequest:o,title:u.name??"Your game",className:"aspect-video w-full",allow:"autoplay; fullscreen; gamepad; pointer-lock"}):e.jsx("div",{className:"flex aspect-video items-center justify-center text-sm text-white/60",children:h("firstGame.result.loadingGame")})}),e.jsx("div",{className:"mt-6 flex flex-col items-center gap-2 sm:flex-row sm:justify-center",children:e.jsxs("button",{type:"button",onClick:v,className:"inline-flex h-11 items-center justify-center gap-2 rounded-md bg-foreground px-6 text-sm font-medium text-background transition-opacity hover:opacity-90 cursor-pointer",children:[h("firstGame.result.continueStudio"),e.jsx($,{icon:["far","arrow-right"],className:"text-xs"})]})}),a]})}const Lt=2e3,q={phase:"idle",kind:"build",gameId:null,gameName:null,sessionId:null,
1status:null,currentPhase:null,currentAction:null,messages:[],pendingQuestion:null,answering:!1,startedAt:null,error:null};function Mt(r){return{id:r.id,role:r.role,content:r.content,timestamp:r.created_at,message_type:r.message_type,metadata:r.metadata??null,session_id:r.session_id,reverted:r.reverted}}const Ft=new Set(["complete","awaiting_approval","failed","cancelled"]);function Ut(){const[r,i]=n.useState(q),g=n.useRef(null),c=n.useRef(null),p=n.useRef(!1),m=r.phase==="running",v=pt({gameId:r.gameId,sessionId:r.sessionId,active:m}),j=n.useCallback(async(u,S)=>{p.current=!1,g.current=null,c.current=null,i({...q,kind:u,phase:"dispatching",startedAt:new Date().toISOString()});try{const l=await X.generateGame({...S,plan_first:u==="plan",run_mode:u==="plan"?"plan":"agent"});if(p.current)return;if(!oe(l))throw new Error("Something went wrong.");i(f=>({...f,phase:"running",gameId:l.game_id,gameName:l.game_name,sessionId:l.session_id,status:"generating"}))}catch(l){if(p.current)return;const f=l?.response?.data??{};i(s=>({...s,phase:"failed",error:{code:f.error??"network",message:f.message??l?.message??"Something went wrong.",status:l?.response?.status}}))}},[]),h=n.useCallback(()=>{p.current=!0,i(q)},[]),G=n.useCallback(async u=>{const{gameId:S,kind:l,answering:f}=r;if(!(S==null||f)){i(s=>({...s,answering:!0}));try{const s=await X.continueGame(S,{prompt:ht(u),plan_first:l==="plan",run_mode:l==="plan"?"plan":"agent"});if(p.current)return;if(!oe(s))throw new Error("Something went wrong.");i(o=>({...o,answering:!1,pendingQuestion:null,sessionId:s.session_id??o.sessionId,status:"generating",phase:"running",messages:o.messages.map(t=>t.message_type==="question"&&!t.metadata?.answered?{...t,metadata:{...t.metadata??{},answered:!0}}:t)}))}catch(s){if(p.current)return;const o=s?.response?.data??{};i(t=>({...t,answering:!1,phase:"failed",error:{code:o.error??"network",message:o.message??s?.message??"Something went wrong.",status:s?.response?.status}}))}}},[r.gameId,r.kind,r.answering]);return n.useEffect(()=>{if(!m||r.gameId==null)return;const u=r.gameId;let S=!1;const l=async()=>{try{const s=await ke.studioPoll(u,g.current,c.current);if(S)return;s.new_messages?.length?g.current=s.new_messages[s.new_messages.length-1].created_at:g.current||(g.current=s.server_time),typeof s.generation.activity_cursor=="number"&&(c.current=s.generation.activity_cursor);const o=s.generation,t=o.status??null,k=!o.active&&t!=null&&Ft.has(t),b=t==="awaiting_input";i(a=>{const _=(s.new_messages??[]).map(Mt),w=new Set(a.messages.map(N=>N.id)),I=_.length?[...a.messages,..._.filter(N=>N.id==null||!w.has(N.id))]:a.messages;return{...a,status:t,currentPhase:o.current_phase??o.phase??a.currentPhase,currentAction:o.current_action??a.currentAction,sessionId:o.session_id??a.sessionId,messages:I,pendingQuestion:b?o.pending_question??a.pendingQuestion:a.answering?a.pendingQuestion:null,phase:k?t==="failed"||t==="cancelled"?"failed":"done":a.phase,error:k&&(t==="failed"||t==="cancelled")?{code:t,message:t==="failed"?"The run failed.":"The run was cancelled."}:a.error}})}catch{}};l();const f=window.setInterval(l,Lt);return()=>{S=!0,window.clearInterval(f)}},[m,r.gameId]),{...r,isGenerating:m&&r.status!=="awaiting_input",liveItems:v.liveItems,liveSubagents:v.liveSubagents,start:j,answer:G,reset:h}}function As(){const{t:r,i18n:i}=T("onboarding"),{t:g}=T("planChat"),c=He(),p=je(),{user:m,loading:v,isAuthenticated:j}=Ne(),h=F(),G=p.state?.prompt??"",{byDefault:u,ready:S}=Be(),l=n.useMemo(()=>!m||!S?null:u?re(ze,m.id)==="rail":re("guided_creation_flow",m.id)==="guided_flow",[m,u,S]);n.useEffect(()=>{v||!m||l===null||l||c("/dashboard",{replace:!0})},[v,m,l,c]);const{data:f}=Ke({queryKey:["user-usage"],queryFn:Ge.getUsage,enabled:j}),s=St(f),o=m?.can_import_assets??!1,[t,k]=n.useState("commitment"),[b,a]=n.useState(null),[_,w]=n.useState(1),[I,N]=n.useState(!1),[A,K]=n.useState(!1),[Z,M]=n.useState(null),Q=n.useRef(null),B=n.useRef(null),d=Ut(),J=n.useMemo(()=>_t(b),[b]),me=Math.max(0,J.indexOf(t));n.useEffect(()=>{Ie(t)},[t]),n.useEffect(()=>()=>{Q.current&&window.clearTimeout(Q.current)},[]);const U=n.useCallback((y,x)=>{Re.answerOnboarding(y,x).catch(()=>{})},[]),P=n.useCallback((y,x=1)=>{w(x),k(y),N(!1)},[]),pe=y=>
1{I||(N(!0),a(y),Fe(y),U(H.start,y),Q.current=window.setTimeout(()=>{P(y==="image"?"image":y==="assets"?"assets":"prompt")},tt))},ee=n.useCallback(async(y,x)=>{try{const R=await Qe.create({source:Ve(b),prompt:y,style_reference_urls:x.style_reference_urls,omni_reference_url:x.omni_reference_url||void 0,asset_ids:x.asset_ids,language:i.language});Ae({plan_id:R.id,source:R.source,has_refs:!!(x.style_reference_urls?.length||x.omni_reference_url),asset_count:x.asset_ids?.length??0}),c(We(R.id),{replace:!0})}catch(R){Te(R,g("errors.createFailed"))}},[b,i.language,c,g]),te=n.useCallback(async(y,x)=>{const R=b??"idea";if(Ce(R,y.length),u){U(H.runKind,"plan_chat"),await ee(y,x);return}Ee({kind:s,source:R,has_refs:!!(x.style_reference_urls?.length||x.omni_reference_url),asset_count:x.asset_ids?.length??0}),U(H.runKind,s),B.current=Date.now(),P("creating"),await d.start(s,{prompt:y,...x})},[b,s,U,P,d,u,ee]),se=async(y,x)=>{if(!A){K(!0);try{await te(y,{style_reference_urls:x.styleRefs?.length?x.styleRefs:void 0,omni_reference_url:x.omniRef,asset_ids:x.assetIds?.length?x.assetIds:void 0,tier:x.tier})}finally{K(!1)}}},fe=async(y,x)=>{if(!A){K(!0);try{const R=[...x.styleRefs];for(const V of x.publicStyleSrcs)R.push(await Ye(V));for(const V of x.pendingStyleFiles)R.push(await ne(V,"style"));let D=x.omniRef;!D&&x.omniFile&&(D=await ne(x.omniFile,"omni")),!D&&x.omniPublicSrc&&(D=await qe(x.omniPublicSrc,"omni")),await te(y,{style_reference_urls:R.length?R:void 0,omni_reference_url:D})}catch(R){console.error("First-game image start failed to prepare references",R),Ue.error(r("firstGame.image.uploadFailed"))}finally{K(!1)}}};n.useEffect(()=>{if(t==="creating"){if(d.phase==="done"||d.phase==="failed"){const y=d.status??(d.phase==="failed"?"failed":"complete");Pe({kind:d.kind,status:["complete","awaiting_approval","failed","cancelled"].includes(y)?y:"failed",duration_s:B.current?Math.round((Date.now()-B.current)/1e3):0})}if(d.phase==="done"&&P("result"),d.phase==="failed"){const y=d.error?.code;if(y==="upgrade_required_for_build"||y==="freemium_plan_quota_exceeded"){M("plan-preview-build"),W(d.kind);return}if(y==="edit_limit_reached"||y==="overdrawn"||y==="no_credits"){M(y==="overdrawn"?"overdrawn":"credits-exhausted"),W(d.kind);return}P("result")}}},[d.phase]),n.useEffect(()=>{t==="result"&&d.kind==="plan"&&!d.error&&W("plan")},[t]);const ge=()=>{De(t),U(H.skippedAt,t),c("/dashboard",{replace:!0})},he=()=>{Oe(d.kind),d.gameId!=null?c(`/studio/${d.gameId}`,{replace:!0}):c("/dashboard",{replace:!0})},xe=()=>{$e(d.kind),M("plan-preview-build")},z=()=>{d.reset(),P(b==="image"?"image":b==="assets"?"assets":"prompt",-1)},be=()=>{I||t==="creating"||(t==="fork"?P("commitment",-1):t==="prompt"||t==="image"||t==="assets"?P("fork",-1):t==="result"&&z())};if(v||!m||!l)return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsx(Le,{size:"md"})});const ye=t!=="commitment"&&t!=="creating",we=t!=="creating"&&t!=="result",ve=t==="creating"||t==="result"||t==="image",ae=h?0:28*_;return e.jsxs(e.Fragment,{children:[e.jsx(Me,{children:e.jsx("title",{children:r("firstGame.pageTitle")})}),e.jsx(yt,{stepCount:J.length,stepIndex:me,onBack:ye?be:void 0,onSkip:we?ge:void 0,width:ve?"wide":"narrow",children:e.jsx(O,{mode:"wait",initial:!1,children:e.jsxs(C.div,{initial:{opacity:0,x:ae},animate:{opacity:1,x:0},exit:{opacity:0,x:-ae},transition:{duration:.28,ease:[.16,1,.3,1]},children:[t==="commitment"&&e.jsx(vt,{onReady:()=>P("fork")}),t==="fork"&&e.jsx(Nt,{value:b,onSelect:pe,locked:I}),t==="prompt"&&e.jsx(ue,{variant:b==="not_sure"?"not_sure":"idea",initialPrompt:G,canImportAssets:o,onAssetUploadBlocked:()=>M("asset-import-locked"),onSubmit:se,submitting:A,submitLabel:u?g("composer.continue"):void 0}),t==="image"&&e.jsx(It,{onSubmit:fe,submitting:A,onLoopBlocked:()=>M("loop-locked")}),t==="assets"&&e.jsx(Rt,{canImportAssets:o,onAssetUploadBlocked:()=>M("asset-import-locked"),onSubmit:se,submitting:A,submitLabel:u?g("composer.continue"):void 0}),t==="creating"&&e.jsx(Et,{kind:d.kind,gameId:d.gameId,sessionId:d.sessionId,isGenerating:d.isGenerating,dispatching:d.phase==="dispatching",currentAction:d.currentAction,startedAt:
1d.startedAt,liveItems:d.liveItems,liveSubagents:d.liveSubagents,messages:d.messages,pendingQuestion:d.pendingQuestion,answering:d.answering,onAnswer:d.answer}),t==="result"&&d.gameId!=null&&e.jsx(Pt,{kind:d.kind,gameId:d.gameId,gameName:d.gameName,messages:d.messages,failed:d.phase==="failed",onUpgrade:xe,onContinueToStudio:he,onRetry:z})]},t)})}),e.jsx(Xe,{isOpen:Z!==null,onClose:()=>{M(null),t==="creating"&&d.phase==="failed"&&z()},gameId:d.gameId??void 0,context:Z??"credits-exhausted"})]})}export{As 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.