import{u as te,f as se,r as n,j as e,s as S,P as ae,n as re,v as ne,a3 as ie,R as w,X as le,M as oe,D as ce}from"./index-2dTGQAIg.js";import{u as de}from"./use-mobile-BW_8EZ66.js";import{R as me}from"./rotate-ccw-DIpPewX8.js";import{W as xe}from"./wrench-DV3lqoXJ.js";import"./analytics-Bu8LxldC.js";const he=()=>{try{const r=new(window.AudioContext||window.webkitAudioContext);[261.63,329.63,392,523.25].forEach((u,m)=>{const o=r.createOscillator(),x=r.createGain();o.connect(x),x.connect(r.destination),o.type="sine",o.frequency.value=u;const c=r.currentTime+m*.1,p=.15;x.gain.setValueAtTime(0,c),x.gain.linearRampToValueAtTime(.3,c+.02),x.gain.linearRampToValueAtTime(0,c+p),o.start(c),o.stop(c+p)});const i=r.currentTime+.4;[523.25,659.25,783.99].forEach(u=>{const m=r.createOscillator(),o=r.createGain();m.connect(o),o.connect(r.destination),m.type="triangle",m.frequency.value=u,o.gain.setValueAtTime(0,i),o.gain.linearRampToValueAtTime(.2,i+.05),o.gain.linearRampToValueAtTime(0,i+.4),m.start(i),m.stop(i+.4)})}catch{console.log("Audio not supported")}},ue=()=>{try{const r=new(window.AudioContext||window.webkitAudioContext),a=r.createOscillator(),i=r.createGain();a.connect(i),i.connect(r.destination),a.type="sine",a.frequency.setValueAtTime(440,r.currentTime),a.frequency.linearRampToValueAtTime(880,r.currentTime+.1),i.gain.setValueAtTime(.2,r.currentTime),i.gain.linearRampToValueAtTime(0,r.currentTime+.15),a.start(),a.stop(r.currentTime+.15)}catch{console.log("Audio not supported")}},pe=()=>{try{const r=new(window.AudioContext||window.webkitAudioContext),a=r.createOscillator(),i=r.createGain();a.connect(i),i.connect(r.destination),a.type="sawtooth",a.frequency.setValueAtTime(200,r.currentTime),a.frequency.linearRampToValueAtTime(100,r.currentTime+.15),i.gain.setValueAtTime(.15,r.currentTime),i.gain.linearRampToValueAtTime(0,r.currentTime+.2),a.start(),a.stop(r.currentTime+.2)}catch{console.log("Audio not supported")}},O={guest:oe,ops:xe,revenue:ce},je=({onBookDemo:r})=>{const{t:a,i18n:i}=te("game"),u=se(),m=de(),o=i.language,x=o==="en"?"":`/${o}`,[c,p]=n.useState("idle"),[j,N]=n.useState([]),[V,_]=n.useState(0),[M,g]=n.useState(0),[y,T]=n.useState(0),[d,b]=n.useState(null),[h,E]=n.useState(null),[Z,G]=n.useState(null),[q,$]=n.useState(2500),z=n.useRef(null),v=n.useRef(null),f=n.useRef(null),P=n.useMemo(()=>({guest:a("tasks.guest",{returnObjects:!0}),ops:a("tasks.ops",{returnObjects:!0}),revenue:a("tasks.revenue",{returnObjects:!0})}),[a]),k=n.useMemo(()=>[{type:"guest",label:a("agents.guest"),icon:O.guest},{type:"ops",label:a("agents.ops"),icon:O.ops},{type:"revenue",label:a("agents.revenue"),icon:O.revenue}],[a]),B=n.useCallback(()=>{const t=["guest","ops","revenue"],s=t[Math.floor(Math.random()*t.length)],l=P[s],C=l[Math.floor(Math.random()*l.length)];return{id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,message:C.message,type:s,emoji:C.emoji}},[P]),F=a("feedback.positive",{returnObjects:!0}),L=a("feedback.negative",{returnObjects:!0}),R=n.useCallback((t,s)=>{const l=t==="success"?F:L,C=l[Math.floor(Math.random()*l.length)];E({message:C,type:t,correctAgent:s}),setTimeout(()=>E(null),1500)},[F,L]),H=n.useCallback(()=>{he(),p("playing"),N([]),_(0),g(0),T(0),$(4e3)},[]),W=n.useCallback(()=>{p("gameover"),z.current&&clearInterval(z.current),v.current&&clearInterval(v.current),f.current&&clearInterval(f.current)},[]);n.useEffect(()=>{if(c!=="playing")return;const t=()=>{N(s=>s.length>=8?s:[...s,B()])};return t(),v.current=setInterval(t,q),()=>{v.current&&clearInterval(v.current)}},[c,q]),n.useEffect(()=>{if(c!=="playing")return;const t=setInterval(()=>{$(s=>Math.max(1800,s-100))},3e4);return()=>clearInterval(t)},[c]),n.useEffect(()=>{if(c==="playing")return f.current=setInterval(()=>{g(t=>{const s=j.length*1.5,l=Math.min(100,t+s);return l>=100&&W(),l})},500),()=>{f.current&&clearInterval(f.current)}},[c,j.length,W]);const D=n.useCallback(t=>{if(d){if(d.type===t)ue(),_(s=>s+10*(y+1)),T(s=>Math.min(s+1,5)),g(s=>Math.max(0,s-5)),R("success"),N(s=>s.filter(l=>l.id!==d.id));else{pe(),g(l=>Math.min(100,l+15)),T(0);const s=a(`agents.${d.type}`);R("error",s),G(d.id),setTimeout(()=>G(null),500)}b(null)}},[d,y,R,a]),U=n.useCallback((t,s)=>{s.preventDefault(),s.stopPropagation(),d?.id===t.id?b(null):b(t)},[d]),X=n.useCallback((t,s)=>{s.preventDefault(),s.stopPropagation(),d&&D(t)},[d,D]),J=t=>b(t),K=()=>b(null),Q=t=>t.preventDefault(),Y=(t,s)=>{t.preventDefault(),D(s)},ee=t=>{N(s=>s.filter(l=>l.id!==t)),g(s=>Math.min(100,s+10)),T(0)},I=({children:t})=>e.jsxs("div",{className:"relative w-full overflow-hidden rounded-2xl md:rounded-3xl",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-[hsl(var(--dark-page-bg))] via-[hsl(var(--dark-page-bg-subtle))] to-[hsl(var(--primary-700))]",style:{backgroundImage:`
linear-gradient(to bottom right, hsl(var(--dark-page-bg)), hsl(var(--dark-page-bg-subtle)), hsl(var(--primary-700))),
radial-gradient(circle at 20% 50%, hsl(var(--primary-600) / 0.15) 0%, transparent 50%),
radial-gradient(circle at 80% 80%, hsl(var(--info-600) / 0.1) 0%, transparent 40%)
`}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:`
linear-gradient(hsl(0 0% 100% / 0.1) 1px, transparent 1px),
linear-gradient(90deg, hsl(0 0% 100% / 0.1) 1px, transparent 1px)
`,backgroundSize:"40px 40px"}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-transparent via-transparent to-black/20"}),e.jsx("div",{className:"relative z-10",children:t})]}),A=({children:t,className:s,...l})=>e.jsx("div",{className:w("backdrop-blur-xl bg-white/[0.03] border border-white/[0.08] rounded-xl shadow-[0_8px_32px_-8px_rgba(0,0,0,0.4)]",s),...l,children:t});return c==="idle"?e.jsx(I,{children:e.jsxs("div",{className:"px-6 py-12 md:px-12 md:py-16 text-center",children:[e.jsx("h2",{className:"text-3xl md:text-4xl lg:text-5xl font-bold mb-4 text-white tracking-tight",children:a("title")}),e.jsx("p",{className:"text-base md:text-lg text-white/60 mb-10 max-w-xl mx-auto leading-relaxed",children:a("description")}),m?e.jsx("div",{className:"overflow-hidden -mx-6 mb-10",children:e.jsx("div",{className:"flex gap-3 w-max animate-marquee-slow",children:[...k,...k].map((t,s)=>e.jsxs(A,{className:"flex items-center gap-2.5 px-4 py-2.5 whitespace-nowrap",children:[e.jsx(t.icon,{className:"h-4 w-4 text-white/70"}),e.jsx("span",{className:"text-sm text-white/80 font-medium",children:t.label})]},`${t.type}-${s}`))})}):e.jsx("div",{className:"flex flex-wrap justify-center gap-3 mb-10",children:k.map(t=>e.jsxs(A,{className:"flex items-center gap-2.5 px-5 py-3",children:[e.jsx(t.icon,{className:"h-4 w-4 text-white/70"}),e.jsx("span",{className:"text-sm text-white/80 font-medium",children:t.label})]},t.type))}),e.jsxs(S,{onClick:H,size:"lg",className:"h-14 px-10 text-base font-semibold bg-white text-[hsl(var(--primary-700))] hover:bg-white/90 shadow-[0_8px_32px_-8px_rgba(255,255,255,0.25)] hover:shadow-[0_12px_40px_-8px_rgba(255,255,255,0.3)] transition-all hover:scale-[1.02]",children:[e.jsx(ae,{className:"mr-2.5 h-5 w-5"}),a("startGame")]})]})}):c==="gameover"?e.jsx(I,{children:e.jsxs("div",{className:"px-6 py-12 md:px-12 md:py-16 text-center",children:[e.jsxs(A,{className:"max-w-md mx-auto p-8 md:p-10 mb-8",children:[e.jsx("h2",{className:"text-2xl md:text-3xl font-bold mb-2 text-white tracking-tight",children:a("gameOver.title").replace(/😰|🎉/g,"")}),e.jsx("p",{className:"text-6xl md:text-7xl font-bold text-white mb-4 tracking-tighter",children:V}),e.jsx("p",{className:"text-white/50 mb-8 leading-relaxed",children:a("gameOver.message")}),e.jsxs("div",{className:"bg-white/[0.04] border border-white/[0.06] rounded-lg p-5 mb-8",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-3",children:[e.jsx(re,{className:"h-5 w-5 text-[hsl(var(--accent-500))]"}),e.jsx("p",{className:"text-base font-semibold text-white",children:a("gameOver.cendraHelps")})]}),e.jsx("p",{className:"text-sm text-white/50 leading-relaxed",children:a("gameOver.cendraHelpsDesc")})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[e.jsxs(S,{onClick:H,variant:"outline",size:"lg",className:"h-12 px-6 border-white/20 bg-white/5 text-white hover:bg-white/10 hover:border-white/30",children:[e.jsx(me,{className:"mr-2 h-4 w-4"}),a("playAgain")]}),r?e.jsx(S,{onClick:r,size:"lg",className:"h-12 px-6 bg-white text-[hsl(var(--primary-700))] hover:bg-white/90 font-semibold",children:a("bookDemo")}):e.jsx(S,{asChild:!0,size:"lg",className:"h-12 px-6 bg-white text-[hsl(var(--primary-700))] hover:bg-white/90 font-semibold",children:e.jsx("a",{href:"mailto:ceo@botel.ai",children:a("bookDemo")})})]})]}),e.jsxs("button",{onClick:()=>u(`${x}/about`),className:"inline-flex items-center gap-2 text-white/40 hover:text-white/70 transition-colors text-sm font-medium group",children:[a("meetTheTeam","Meet the team behind Cendra"),e.jsx(ne,{className:"h-4 w-4 group-hover:translate-x-1 transition-transform"})]})]})}):e.jsx(I,{children:e.jsxs("div",{className:"px-4 py-6 md:px-8 md:py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6 gap-4",children:[e.jsxs("div",{className:"flex-1 max-w-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(ie,{className:"h-3.5 w-3.5 text-white/50"}),e.jsx("p",{className:"text-xs font-medium text-white/50 uppercase tracking-wide",children:a("stressLevel")})]}),e.jsx("div",{className:"h-2 bg-white/10 rounded-full overflow-hidden",children:e.jsx("div",{className:w("h-full transition-all duration-300 rounded-full",M>70?"bg-[hsl(var(--error-600))]":M>40?"bg-[hsl(var(--warning-600))]":"bg-[hsl(var(--success-600))]"),style:{width:`${M}%`}})})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-xs font-medium text-white/50 uppercase tracking-wide mb-0.5",children:a("score")}),e.jsx("p",{className:"text-3xl md:text-4xl font-bold text-white tracking-tighter",children:V}),y>1&&e.jsxs("p",{className:"text-xs text-[hsl(var(--accent-500))] font-semibold",children:["x",y," ",a("combo")]})]})]}),h&&e.jsxs("div",{className:w("fixed top-24 left-1/2 -translate-x-1/2 z-50 px-6 py-3 rounded-xl font-semibold text-white shadow-2xl animate-fade-in flex flex-col items-center gap-1 backdrop-blur-xl",h.type==="success"?"bg-[hsl(var(--success-600))]/90":"bg-[hsl(var(--error-600))]/90"),children:[e.jsx("span",{className:"text-sm",children:h.message}),h.type==="error"&&h.correctAgent&&e.jsxs("span",{className:"text-xs font-normal opacity-80",children:["→ ",h.correctAgent]})]}),e.jsx("p",{className:"text-sm text-white/40 mb-4 text-center",children:a(d?"instructionsTapAgent":"instructionsTapTask")}),e.jsxs("div",{className:"min-h-[180px] mb-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:j.map(t=>e.jsxs(A,{draggable:!0,onDragStart:()=>J(t),onDragEnd:K,onTouchEnd:s=>U(t,s),onClick:s=>U(t,s),className:w("p-4 cursor-grab active:cursor-grabbing transition-all relative group touch-manipulation","hover:bg-white/[0.06] hover:scale-[1.02]",d?.id===t.id?"ring-2 ring-[hsl(var(--accent-500))] bg-white/[0.08] scale-[1.02]":"",Z===t.id&&"animate-[shake_0.5s_ease-in-out]"),children:[e.jsx("button",{onClick:s=>{s.stopPropagation(),ee(t.id)},className:"absolute -top-1.5 -right-1.5 w-6 h-6 bg-white/10 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-[hsl(var(--error-600))] border border-white/10",children:e.jsx(le,{className:"h-3 w-3 text-white/70"})}),e.jsx("span",{className:"text-2xl mb-2 block",children:t.emoji}),e.jsx("p",{className:"text-xs text-white/80 leading-relaxed",children:t.message})]},t.id))}),j.length===0&&e.jsx("div",{className:"text-center py-10 text-white/30",children:e.jsx("p",{className:"text-sm",children:a("waiting")})})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:k.map(t=>e.jsxs("div",{onDragOver:Q,onDrop:s=>Y(s,t.type),onTouchEnd:s=>X(t.type,s),onClick:s=>X(t.type,s),className:w("p-4 md:p-6 rounded-xl border border-white/10 transition-all cursor-pointer touch-manipulation bg-white/[0.02]","hover:bg-white/[0.05] hover:border-white/20",d&&"hover:scale-[1.03] hover:border-[hsl(var(--info-500))] hover:bg-[hsl(var(--info-500))]/10"),children:[e.jsx(t.icon,{className:"h-7 w-7 md:h-8 md:w-8 mx-auto mb-2 text-white/60"}),e.jsx("p",{className:"text-xs md:text-sm font-medium text-center text-white/70",children:t.label})]},t.type))}),e.jsx("p",{className:"text-center text-xs text-white/30 mt-6",children:a("instructions")})]})})};export{je as default};