import{u as te,l as se,r as n,j as e,B as I,G as ae,S as re,Y as ne,o as ie,a6 as le,a as w,_ as oe,M as ce,Q as de}from"./index-DMhQuCwd.js";import{u as me}from"./use-mobile-BYLM1a7U.js";import{c as xe}from"./can-koseoglu-cendra-ceo-BeoWwWry.js";import{R as he}from"./rotate-ccw-C6eTG5uq.js";import{W as ue}from"./wrench-DXqJn1fG.js";import"./analytics-Bu8LxldC.js";const pe=()=>{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")}},ge=()=>{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")}},be=()=>{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")}},_={guest:ce,ops:ue,revenue:de},Te=({onBookDemo:r})=>{const{t:a,i18n:i}=te("game"),u=se(),m=me(),o=i.language,x=o==="en"?"":`/${o}`,[c,p]=n.useState("idle"),[j,N]=n.useState([]),[O,G]=n.useState(0),[S,g]=n.useState(0),[y,T]=n.useState(0),[d,b]=n.useState(null),[h,V]=n.useState(null),[Q,E]=n.useState(null),[q,$]=n.useState(2500),z=n.useRef(null),f=n.useRef(null),v=n.useRef(null),L=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:_.guest},{type:"ops",label:a("agents.ops"),icon:_.ops},{type:"revenue",label:a("agents.revenue"),icon:_.revenue}],[a]),U=n.useCallback(()=>{const t=["guest","ops","revenue"],s=t[Math.floor(Math.random()*t.length)],l=L[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}},[L]),P=a("feedback.positive",{returnObjects:!0}),F=a("feedback.negative",{returnObjects:!0}),M=n.useCallback((t,s)=>{const l=t==="success"?P:F,C=l[Math.floor(Math.random()*l.length)];V({message:C,type:t,correctAgent:s}),setTimeout(()=>V(null),1500)},[P,F]),H=n.useCallback(()=>{pe(),p("playing"),N([]),G(0),g(0),T(0),$(4e3)},[]),W=n.useCallback(()=>{p("gameover"),z.current&&clearInterval(z.current),f.current&&clearInterval(f.current),v.current&&clearInterval(v.current)},[]);n.useEffect(()=>{if(c!=="playing")return;const t=()=>{N(s=>s.length>=8?s:[...s,U()])};return t(),f.current=setInterval(t,q),()=>{f.current&&clearInterval(f.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 v.current=setInterval(()=>{g(t=>{const s=j.length*1.5,l=Math.min(100,t+s);return l>=100&&W(),l})},500),()=>{v.current&&clearInterval(v.current)}},[c,j.length,W]);const R=n.useCallback(t=>{if(d){if(d.type===t)ge(),G(s=>s+10*(y+1)),T(s=>Math.min(s+1,5)),g(s=>Math.max(0,s-5)),M("success"),N(s=>s.filter(l=>l.id!==d.id));else{be(),g(l=>Math.min(100,l+15)),T(0);const s=a(`agents.${d.type}`);M("error",s),E(d.id),setTimeout(()=>E(null),500)}b(null)}},[d,y,M,a]),B=n.useCallback((t,s)=>{s.preventDefault(),s.stopPropagation(),d?.id===t.id?b(null):b(t)},[d]),K=n.useCallback((t,s)=>{s.preventDefault(),s.stopPropagation(),d&&R(t)},[d,R]),X=t=>b(t),Y=()=>b(null),Z=t=>t.preventDefault(),J=(t,s)=>{t.preventDefault(),R(s)},ee=t=>{N(s=>s.filter(l=>l.id!==t)),g(s=>Math.min(100,s+10)),T(0)},D=({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(D,{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(I,{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(D,{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:O}),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(I,{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(he,{className:"mr-2 h-4 w-4"}),a("playAgain")]}),r?e.jsx(I,{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.jsxs("a",{href:"https://linkedin.com/in/koseoglu",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-3 h-12 px-6 bg-white text-[hsl(var(--primary-700))] hover:bg-white/90 font-semibold rounded-lg transition-all",children:[e.jsx("img",{src:xe,alt:"Can Koseoglu",className:"w-7 h-7 rounded-full border border-[hsl(var(--primary-700))]/20 object-cover"}),e.jsx("span",{children:a("bookDemo")}),e.jsx(ne,{className:"h-4 w-4 opacity-60"})]})]})]}),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(ie,{className:"h-4 w-4 group-hover:translate-x-1 transition-transform"})]})]})}):e.jsx(D,{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(le,{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",S>70?"bg-[hsl(var(--error-600))]":S>40?"bg-[hsl(var(--warning-600))]":"bg-[hsl(var(--success-600))]"),style:{width:`${S}%`}})})]}),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:O}),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:()=>X(t),onDragEnd:Y,onTouchEnd:s=>B(t,s),onClick:s=>B(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]":"",Q===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(oe,{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:Z,onDrop:s=>J(s,t.type),onTouchEnd:s=>K(t.type,s),onClick:s=>K(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{Te as default};