speakid-build-a-sentence 1.0.19 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"Game.d.ts","sourceRoot":"","sources":["../src/Game.tsx"],"names":[],"mappings":"AA2DA,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,iBAAS,aAAa,CAAC,KAAK,GAAE,SAAc,2CA89B3C;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"Game.d.ts","sourceRoot":"","sources":["../src/Game.tsx"],"names":[],"mappings":"AA4DA,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,iBAAS,aAAa,CAAC,KAAK,GAAE,SAAc,2CAypC3C;AAED,eAAe,aAAa,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Game.styles.d.ts","sourceRoot":"","sources":["../src/Game.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAoEtC,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAuNhD,CAAC"}
1
+ {"version":3,"file":"Game.styles.d.ts","sourceRoot":"","sources":["../src/Game.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAoEtC,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAmNhD,CAAC"}
@@ -1,37 +1,37 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),s=require("react"),Ue=`
2
- @keyframes magic-sentence-spin {
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),s=require("react"),st=`
2
+ @keyframes spin {
3
3
  from { transform: rotate(0deg); }
4
4
  to { transform: rotate(360deg); }
5
5
  }
6
6
 
7
- @keyframes magic-sentence-pulse {
7
+ @keyframes pulse {
8
8
  0%, 100% { transform: scale(1); }
9
9
  50% { transform: scale(1.05); }
10
10
  }
11
11
 
12
- @keyframes magic-sentence-shake {
12
+ @keyframes shake {
13
13
  0%, 100% { transform: translateX(0); }
14
14
  25% { transform: translateX(-5px); }
15
15
  75% { transform: translateX(5px); }
16
16
  }
17
17
 
18
- @keyframes magic-sentence-slideIn {
18
+ @keyframes slideIn {
19
19
  from { transform: translateY(-20px); opacity: 0; }
20
20
  to { transform: translateY(0); opacity: 1; }
21
21
  }
22
22
 
23
- @keyframes magic-sentence-bounce {
23
+ @keyframes bounce {
24
24
  0%, 20%, 53%, 80%, 100% { transform: translate3d(0,0,0); }
25
25
  40%, 43% { transform: translate3d(0, -8px, 0); }
26
26
  70% { transform: translate3d(0, -4px, 0); }
27
27
  90% { transform: translate3d(0, -2px, 0); }
28
28
  }
29
29
 
30
- @keyframes magic-sentence-glow {
30
+ @keyframes glow {
31
31
  0%, 100% { box-shadow: 0 0 5px rgba(76, 175, 80, 0.5); }
32
32
  50% { box-shadow: 0 0 20px rgba(76, 175, 80, 0.8), 0 0 30px rgba(76, 175, 80, 0.6); }
33
33
  }
34
- `;if(typeof document<"u"&&!document.getElementById("magic-sentence-keyframes")){const g=document.createElement("style");g.id="magic-sentence-keyframes",g.innerHTML=Ue,document.head.appendChild(g)}const fe={spin:{animation:"magic-sentence-spin 1.4s linear infinite"},pulse:{animation:"magic-sentence-pulse 0.6s ease-in-out"},shake:{animation:"magic-sentence-shake 0.4s ease-in-out"},slideIn:{animation:"magic-sentence-slideIn 0.3s ease-out"},bounce:{animation:"magic-sentence-bounce 0.6s ease-in-out"},glow:{animation:"magic-sentence-glow 1s ease-in-out infinite"}},p={gmCenterScreen:{position:"relative",zIndex:1,minHeight:"100%",width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",textAlign:"center",color:"#1f2937",padding:"24px 16px",boxSizing:"border-box",transform:"translateY(20px)"},gmHeadline1:{fontWeight:700,fontSize:"clamp(28px, 4vw, 40px)",lineHeight:"110%"},gmHeadline2:{fontWeight:600,fontSize:"24px",lineHeight:"120%"},gmBodyM:{fontWeight:400,fontSize:"16px",lineHeight:"140%"},gmBodyS:{fontWeight:400,fontSize:"14px",lineHeight:"140%",color:"#6b7280"},gmButton:{fontFamily:'"Geist", system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans"',fontWeight:600,fontSize:"16px",padding:"10px 16px",borderRadius:"12px",border:"1px solid #e5e7eb",background:"#ec4c44",color:"#ffffff",cursor:"pointer",boxShadow:"0 6px 18px rgba(236, 76, 68, .18)",transition:"transform .06s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease"},gmGameLayout:{position:"relative",width:"100%",maxWidth:"none",minHeight:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",color:"#1f2937",padding:"16px 8px",margin:"0 auto"},gmInput:{padding:"6px 10px",borderRadius:"6px",border:"1px solid #ccc",fontSize:"16px",fontFamily:'"Geist", system-ui',width:"160px"},gmLogoFixed:{position:"absolute",top:"16px",left:"16px",width:"120px",zIndex:30,pointerEvents:"none",background:"transparent",transform:"none",willChange:"auto"},gmLogoImg:{height:"clamp(28px, 5vw, 40px)",width:"auto",background:"transparent",objectFit:"contain",imageRendering:"auto",transform:"translateZ(0)",backfaceVisibility:"hidden",WebkitFontSmoothing:"antialiased",display:"block"},gmLogoFallback:{height:"clamp(28px, 5vw, 40px)",width:"auto",background:"transparent",backgroundImage:"url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjQwIiB2aWV3Qm94PSIwIDAgMTAwIDQwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8dGV4dCB4PSI1MCIgeT0iMjUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyMCIgZm9udC13ZWlnaHQ9ImJvbGQiIGZpbGw9IiNlYzRjNDQiIHRleHQtYW5jaG9yPSJtaWRkbGUiPlNQRUFLSUQ8L3RleHQ+Cjwvc3ZnPgo=')",backgroundSize:"contain",backgroundRepeat:"no-repeat",backgroundPosition:"center",transform:"translateZ(0)",backfaceVisibility:"hidden",WebkitFontSmoothing:"antialiased",display:"block"},gmReadyWrapper:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"60%",gap:"16px"},gmHourglass:{fontSize:"42px",...fe.spin},...fe},xe=()=>{const[g,a]=s.useState([]),b=s.useCallback((k,H,w)=>{const m=[];k.trim()||m.push({type:"empty",message:"Sentence cannot be empty"}),k.length>41&&m.push({type:"length",message:`Sentence is too long (${k.length}/41 characters)`}),k&&!/^[a-zA-Z0-9\s.,!?;:'"-]*$/.test(k)&&m.push({type:"characters",message:"Only Latin characters, numbers, spaces and punctuation are allowed"});const y=w.findIndex((C,V)=>V!==H&&C.toLowerCase().trim()===k.toLowerCase().trim());return y!==-1&&m.push({type:"duplicate",message:`Duplicate sentence (same as sentence ${y+1})`}),a(m),{isValid:m.length===0,errors:m}},[]),K=s.useCallback(k=>{const H=[];return k.forEach((w,m)=>{const x=b(w,m,k);H.push(...x.errors.map(y=>({...y,message:`Sentence ${m+1}: ${y.message}`})))}),{isValid:H.length===0,errors:H}},[b]),_=s.useCallback(()=>{a([])},[]);return{errors:g,validateSentence:b,validateAllSentences:K,clearErrors:_}},ye=(g,a,b)=>a&&b?`${g} word "${a}" ${b}`:a?`${g} word "${a}"`:g,be=(g,a,b=["Enter"," "])=>{b.includes(g.key)&&(g.preventDefault(),a())},P=g=>{const a=document.createElement("div");a.setAttribute("aria-live","polite"),a.setAttribute("aria-atomic","true"),a.style.position="absolute",a.style.left="-10000px",a.style.width="1px",a.style.height="1px",a.style.overflow="hidden",document.body.appendChild(a),a.textContent=g,setTimeout(()=>{document.body.removeChild(a)},1e3)},Ye=()=>{const g=document.createElement("style");g.id="magic-sentence-reset";const a=document.getElementById("magic-sentence-reset");a&&a.remove(),g.textContent=`
34
+ `;if(typeof document<"u"&&!document.getElementById("game-keyframes")){const w=document.createElement("style");w.id="game-keyframes",w.innerHTML=st,document.head.appendChild(w)}const He={spin:{animation:"spin 1.4s linear infinite"},pulse:{animation:"pulse 0.6s ease-in-out"},shake:{animation:"shake 0.4s ease-in-out"},slideIn:{animation:"slideIn 0.3s ease-out"},bounce:{animation:"bounce 0.6s ease-in-out"},glow:{animation:"glow 1s ease-in-out infinite"}},g={gmCenterScreen:{position:"relative",zIndex:1,minHeight:"100%",width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",textAlign:"center",color:"#1f2937",padding:"24px 16px",boxSizing:"border-box",transform:"translateY(20px)"},gmHeadline1:{fontWeight:700,fontSize:"clamp(28px, 4vw, 40px)",lineHeight:"110%"},gmHeadline2:{fontWeight:600,fontSize:"24px",lineHeight:"120%"},gmBodyM:{fontWeight:400,fontSize:"16px",lineHeight:"140%"},gmBodyS:{fontWeight:400,fontSize:"14px",lineHeight:"140%",color:"#6b7280"},gmButton:{fontFamily:'"Geist", system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans"',fontWeight:600,fontSize:"16px",padding:"10px 16px",borderRadius:"12px",border:"1px solid #e5e7eb",background:"#ec4c44",color:"#ffffff",cursor:"pointer",boxShadow:"0 6px 18px rgba(236, 76, 68, .18)",transition:"transform .06s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease"},gmGameLayout:{position:"relative",width:"100%",maxWidth:"none",minHeight:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",color:"#1f2937",padding:"16px 8px",margin:"0 auto"},gmInput:{padding:"6px 10px",borderRadius:"6px",border:"1px solid #ccc",fontSize:"16px",fontFamily:'"Geist", system-ui',width:"160px"},gmLogoFixed:{position:"absolute",top:"16px",left:"16px",width:"auto",zIndex:10,pointerEvents:"none",background:"transparent",transform:"none",willChange:"auto"},gmLogoImg:{height:"28px",width:"auto",background:"transparent",objectFit:"contain",imageRendering:"auto",transform:"translateZ(0)",backfaceVisibility:"hidden",WebkitFontSmoothing:"antialiased",display:"block"},gmReadyWrapper:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"60%",gap:"16px"},gmHourglass:{fontSize:"42px",...He.spin},...He},Ie=()=>{const[w,d]=s.useState([]),H=s.useCallback((C,j,m)=>{const S=[];C.trim()||S.push({type:"empty",message:"Sentence cannot be empty"}),C.length>41&&S.push({type:"length",message:`Sentence is too long (${C.length}/41 characters)`}),C&&!/^[a-zA-Z0-9\s.,!?;:'"-]*$/.test(C)&&S.push({type:"characters",message:"Only Latin characters, numbers, spaces and punctuation are allowed"});const v=m.findIndex((D,K)=>K!==j&&D.toLowerCase().trim()===C.toLowerCase().trim());return v!==-1&&S.push({type:"duplicate",message:`Duplicate sentence (same as sentence ${v+1})`}),d(S),{isValid:S.length===0,errors:S}},[]),re=s.useCallback(C=>{const j=[];return C.forEach((m,S)=>{const b=H(m,S,C);j.push(...b.errors.map(v=>({...v,message:`Sentence ${S+1}: ${v.message}`})))}),{isValid:j.length===0,errors:j}},[H]),oe=s.useCallback(()=>{d([])},[]);return{errors:w,validateSentence:H,validateAllSentences:re,clearErrors:oe}},Te=(w,d,H)=>d&&H?`${w} word "${d}" ${H}`:d?`${w} word "${d}"`:w,Ce=(w,d,H=["Enter"," "])=>{H.includes(w.key)&&(w.preventDefault(),d())},z=w=>{const d=document.createElement("div");d.setAttribute("aria-live","polite"),d.setAttribute("aria-atomic","true"),d.style.position="absolute",d.style.left="-10000px",d.style.width="1px",d.style.height="1px",d.style.overflow="hidden",document.body.appendChild(d),d.textContent=w,setTimeout(()=>{document.body.removeChild(d)},1e3)},at=()=>{const w=document.createElement("style");w.id="magic-sentence-reset",w.textContent=`
35
35
  #magic-sentence-root, #magic-sentence-root * {
36
36
  box-sizing: border-box;
37
37
  font-family: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
@@ -48,7 +48,7 @@
48
48
  width: 100% !important;
49
49
  height: 100% !important;
50
50
  overflow: hidden !important;
51
- zoom: 1 !important;
51
+ zoom: 1 !important; /* ✅ защита от подзума */
52
52
  }
53
53
  #root {
54
54
  margin: 0 !important;
@@ -57,5 +57,5 @@
57
57
  height: 100% !important;
58
58
  overflow: hidden !important;
59
59
  }
60
- `,document.head.appendChild(g)},Ke=g=>[...g].sort(()=>Math.random()-.5);function Se(g={}){const{logoUrl:a,showLogo:b=!0}=g,K=s.useRef(null),{validateAllSentences:_,errors:k}=xe(),H=()=>c||window.innerWidth<768,w=()=>c||window.innerWidth<768||window.innerWidth>=320&&window.innerWidth<=932&&window.innerHeight>=390&&window.innerHeight<=932,m=(e="medium")=>{if(!w())return{padding:"12px 24px",fontSize:"16px",minWidth:"auto"};switch(e){case"small":return{padding:"4px 6px",fontSize:"9px",minWidth:"40px"};case"medium":return{padding:"5px 8px",fontSize:"10px",minWidth:"50px"};case"large":return{padding:"6px 10px",fontSize:"11px",minWidth:"60px"}}};s.useEffect(()=>(Ye(),()=>{document.documentElement.style.overflow="",document.body.style.overflow="";const e=document.getElementById("magic-sentence-reset");e&&e.remove()}),[]);const[x,y]=s.useState("select"),[C,V]=s.useState(null),[le,ce]=s.useState(null),[I,X]=s.useState([]),[j,pe]=s.useState(0),[ee,ge]=s.useState([]),[v,ne]=s.useState([]),[E,ue]=s.useState(20),[Z,J]=s.useState(0),[en,he]=s.useState(null),[z,R]=s.useState(null),[l,q]=s.useState(!1),[te,We]=s.useState(Number(localStorage.getItem("magicSentenceBest"))||0),Q=s.useRef(null),[S,D]=s.useState({list:null,index:null,side:null}),[c,ve]=s.useState(!1),[nn,ie]=s.useState(1),[we,oe]=s.useState(null),[ke,He]=s.useState(!1),[B,Ie]=s.useState(!1),[M,Ce]=s.useState(!1),[L,je]=s.useState(!1),[A,De]=s.useState(!1),[G,Te]=s.useState(!1),[$,Pe]=s.useState(!1),[N,Re]=s.useState(!1),[O,Ee]=s.useState(!1);s.useEffect(()=>{const e=()=>{const t=window.innerWidth,n=window.innerHeight,i=t<768||t===926&&n===428||t===932&&n===430,r=n<700,h=t===768&&n===1024,f=t===1024&&n===768,d=t===820&&n===1180,u=t===1180&&n===820,F=t===540&&n===720,W=t===720&&n===540,de=t===1024&&n===1366,Xe=t===1366&&n===1024,Je=t>=1200&&n>=600&&!i;if(He(Je),Ie(h),Ce(f),je(d),De(u),Te(F),Pe(W),Re(de),Ee(Xe),ve(i),i)oe(null),ie(1);else if(r)oe(null),ie(1);else{const qe=Math.min(1e3,Math.min(t,n)*.9);oe(qe),ie(1)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const U=(e,t,n,i)=>{if(l)return;let r=[...ee],h=[...v];const f=e==="bank"?r:h,d=t==="bank"?r:h,u=f.findIndex(de=>de.id===n);if(u===-1)return;const[F]=f.splice(u,1);let W=i;e===t&&W!==null&&W!==void 0&&W>u&&(W=W-1),W==null||W<0||W>d.length?d.push(F):d.splice(W,0,F),e==="bank"?r=f:h=f,t==="bank"?r=d:h=d,ge(r),ne(h)},Y=(e,t,n)=>{if(e.preventDefault(),l){D({list:null,index:null,side:null});return}const i=e.dataTransfer.getData("application/x-token")||(()=>{const r=e.dataTransfer.getData("text/plain");if(!r)return"";const h=ee.some(u=>u.id===r),f=v.some(u=>u.id===r),d=h?"bank":f?"selected":null;return d?JSON.stringify({from:d,id:r}):""})();if(i){try{const r=JSON.parse(i);if(!r||!r.id||!r.from)return;U(r.from,t,r.id,n)}catch{}D({list:null,index:null,side:null})}},ze=e=>{V(e),X(Array(e).fill("")),y("time")},Be=e=>{ce(e),y("type")},Me=(e,t)=>{if(t.length>41||t&&!/^[a-zA-Z0-9\s.,!?;:'"-]*$/.test(t))return;const i=[...I];i[e]=t,X(i);const r=_(i);r.isValid||console.warn("Validation errors:",r.errors)},Le=e=>e.trim().replace(/\s+/g," "),me=e=>e<=3?20:e<=5?18:e<=7?16:e<=9?14:12,Ae=()=>{I.some(t=>t.trim().length===0)||(X(t=>t.map(n=>Le(n))),J(0),pe(0),he(null),y("getready"))};s.useEffect(()=>{if(x==="getready"){const e=setTimeout(()=>re(0),3e3);return()=>clearTimeout(e)}},[x]);const re=e=>{const t=I[e];if(!t)return;const i=Ke(t.trim().split(/\s+/).filter(Boolean)).map((r,h)=>({id:`${Date.now()}-${e}-${h}-${Math.random().toString(36).slice(2)}`,text:r}));ge(i),ne([]),pe(e),ue(le||20),R(null),q(!1),y("play")};s.useEffect(()=>{if(x==="play"&&!l)if(Q.current!==null&&window.clearTimeout(Q.current),E>0)Q.current=window.setTimeout(()=>ue(e=>e-1),1e3);else{q(!0);const t=I[j].trim().split(/\s+/),n=v.map(d=>d.text),i=t.filter(d=>!n.includes(d)).length,r=n.filter(d=>!t.includes(d)).length,h=t.filter((d,u)=>d!==n[u]).length,f=i+r+h;f===0?(R("correct"),T("correct"),P("Correct! Well done!")):f===1?(R("almost"),T("half"),P("Almost correct! Just one mistake.")):(R("wrong"),T("wrong"),P("Not quite right. Keep trying!"))}return()=>{Q.current!==null&&window.clearTimeout(Q.current)}},[x,E,l,I,j,v]);const Ge=(e=!0)=>{if(l&&e){j+1<(C||0)?re(j+1):(y("results"),setTimeout(()=>se(),600));return}if(e&&!l){const n=I[j].trim().split(/\s+/),i=v.map(u=>u.text),r=n.filter(u=>!i.includes(u)).length,h=i.filter(u=>!n.includes(u)).length,f=n.filter((u,F)=>u!==i[F]).length,d=r+h+f;d===0&&E>0?(J(u=>u+1),R("correct"),T("correct"),P("Correct! Well done!")):d===1?(J(u=>u+.5),R("almost"),T("half"),P("Almost correct! Just one mistake.")):(R("wrong"),T("wrong"),P("Not quite right. Keep trying!")),j+1<(C||0)?setTimeout(()=>re(j+1),800):(y("results"),setTimeout(()=>se(),600))}};s.useEffect(()=>{x==="results"&&Z>te&&(We(Z),localStorage.setItem("magicSentenceBest",String(Z)))},[x,Z,te]);const T=e=>{const t=new(window.AudioContext||window.webkitAudioContext),n=t.createOscillator(),i=t.createGain();switch(n.connect(i),i.connect(t.destination),e){case"start":n.frequency.value=500;break;case"click":n.frequency.value=800;break;case"correct":n.frequency.value=1e3;break;case"half":n.frequency.value=700;break;case"wrong":n.frequency.value=200;break}i.gain.setValueAtTime(.1,t.currentTime),n.start(),n.stop(t.currentTime+.2)},se=()=>{const t=Date.now()+2500,n=["#ec4c44","#f7c948","#6fcf97","#56ccf2","#bb6bd9"],i=document.createElement("canvas"),r=i.getContext("2d");i.width=window.innerWidth,i.height=window.innerHeight,i.style.position="fixed",i.style.top="0",i.style.left="0",i.style.pointerEvents="none",document.body.appendChild(i);const h=Array.from({length:100}).map(()=>({x:Math.random()*i.width,y:Math.random()*i.height-i.height,size:6+Math.random()*6,color:n[Math.floor(Math.random()*n.length)],speed:2+Math.random()*4,tilt:Math.random()*2*Math.PI})),f=()=>{r.clearRect(0,0,i.width,i.height),h.forEach(d=>{r.fillStyle=d.color,r.beginPath(),r.ellipse(d.x,d.y,d.size,d.size/2,d.tilt,0,2*Math.PI),r.fill(),d.y+=d.speed,d.x+=Math.sin(d.tilt)}),Date.now()<t?requestAnimationFrame(f):document.body.removeChild(i)};f()},$e=()=>o.jsxs("div",{style:p.gmCenterScreen,children:[o.jsx("h1",{style:p.gmHeadline1,children:"MAGIC SENTENCE"}),o.jsx("p",{style:p.gmBodyM,children:"Select number of rounds"}),o.jsx("div",{style:{display:"flex",gap:w()?"8px":"16px",justifyContent:"center"},children:[3,4,5].map(e=>o.jsxs("button",{onClick:()=>ze(e),style:{...p.gmButton,...m("medium")},children:[e," ROUNDS"]},e))})]}),Ne=()=>o.jsxs("div",{style:p.gmCenterScreen,children:[o.jsx("h1",{style:p.gmHeadline1,children:"MAGIC SENTENCE"}),o.jsx("p",{style:p.gmBodyM,children:"Select time per round"}),o.jsx("div",{style:{display:"flex",gap:w()?"8px":"16px",justifyContent:"center"},children:[15,20,30].map(e=>o.jsxs("button",{onClick:()=>Be(e),style:{...p.gmButton,...m("medium")},children:[e,"s"]},e))})]}),Oe=()=>o.jsxs("div",{style:p.gmCenterScreen,children:[o.jsxs("h2",{style:{...p.gmBodyM,marginBottom:"0px"},children:["Type down ",C," sentence",C&&C>1?"s":""," for your student"]}),o.jsx("p",{style:{...p.gmBodyS,marginBottom:"16px",marginTop:"0px",color:"#6b7280"},children:"Maximum 41 characters per sentence"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,width:"auto",minWidth:"fit-content",maxWidth:"600px"},children:I.map((e,t)=>o.jsx("input",{value:e,placeholder:`Sentence ${t+1}`,onChange:n=>Me(t,n.target.value),style:{...p.gmInput,padding:w()?"8px 12px":"12px 16px",fontSize:w()?"14px":"16px",width:"100%",textAlign:"center"}},t))}),o.jsx("button",{onClick:Ae,disabled:I.some(e=>e.trim().length===0),style:{...p.gmButton,marginTop:30,background:I.some(e=>e.trim().length===0)?"#ccc":"#ec4c44",cursor:I.some(e=>e.trim().length===0)?"not-allowed":"pointer",...m("large")},children:"PLAY"})]}),Fe=()=>o.jsxs("div",{style:p.gmReadyWrapper,children:[o.jsx("h1",{style:{...p.gmHeadline1,color:"#ec4c44"},children:"GET READY"}),o.jsx("div",{style:p.gmHourglass,children:"⏳"})]}),Ze=()=>o.jsxs("div",{style:p.gmGameLayout,children:[o.jsxs("h2",{style:{marginBottom:w()?"5px":"10px",fontSize:w()?"16px":"20px"},children:["Round ",j+1,"/",C," — ",l?"TIME'S UP!":`Time: ${E}s`]}),o.jsx("div",{style:{width:"60%",height:w()?"8px":"14px",borderRadius:8,background:"#eee",overflow:"hidden",marginBottom:w()?"10px":"20px"},children:o.jsx("div",{style:{height:"100%",width:`${E/(le||20)*100}%`,background:E<=5?"#ec4c44":"#4caf50",transition:"width 1s linear"}})}),o.jsx("div",{onDragOver:e=>e.preventDefault(),onDrop:e=>Y(e,"bank",null),style:{display:"flex",flexWrap:H()?"wrap":"nowrap",gap:c||window.innerWidth<768?"6px":"10px",justifyContent:"center",marginBottom:c||window.innerWidth<768?"15px":"30px",padding:c||window.innerWidth<768?"5px":"10px",width:"100%",boxSizing:"border-box"},children:ee.map((e,t)=>o.jsx("div",{draggable:!l,role:"button",tabIndex:l?-1:0,"aria-label":l?`Word: ${e.text} (time expired)`:ye("Drag word",e.text,"to build sentence"),onDragStart:n=>{if(l){n.preventDefault();return}n.dataTransfer.setData("application/x-token",JSON.stringify({from:"bank",id:e.id})),n.dataTransfer.setData("text/plain",e.id),P(`Dragging word: ${e.text}`)},onKeyDown:n=>{l||be(n,()=>U("bank","selected",e.id,null))},onDragOver:n=>n.preventDefault(),onDrop:n=>{const i=n.currentTarget.getBoundingClientRect(),r=i.left+i.width/2,h=n.clientX>r?t+1:t;D({list:null,index:null,side:null}),n.stopPropagation(),Y(n,"bank",h)},onDragEnter:n=>{if(l)return;const i=n.currentTarget.getBoundingClientRect(),r=i.left+i.width/2;D({list:"bank",index:t,side:n.clientX>r?"right":"left"})},onDragLeave:()=>D({list:null,index:null,side:null}),onClick:()=>{l||U("bank","selected",e.id,null)},style:{padding:c||window.innerWidth<768?"6px 10px":"10px 16px",borderRadius:c||window.innerWidth<768?"6px":"10px",border:"1px solid #ccc",background:l?"#f0f0f0":"#f9f9f9",cursor:l?"not-allowed":"pointer",fontSize:c||window.innerWidth<768?"12px":"18px",borderLeft:S.list==="bank"&&S.index===t&&S.side==="left"?"3px solid #3b82f6":"1px solid #ccc",borderRight:S.list==="bank"&&S.index===t&&S.side==="right"?"3px solid #3b82f6":"1px solid #ccc",flexShrink:0,flexBasis:"auto",opacity:l?.6:1,transition:"opacity 0.3s ease"},children:e.text},e.id))}),o.jsx("div",{onDragOver:e=>e.preventDefault(),onDrop:e=>Y(e,"selected",null),style:{minHeight:c||window.innerWidth<768?"50px":"70px",width:"auto",maxWidth:"none",minWidth:"245px",border:z==="correct"?"2px dashed #4caf50":z==="almost"?"2px dashed #ff9800":z==="wrong"?"2px dashed #f44336":"2px dashed #ccc",borderRadius:c||window.innerWidth<768?"8px":"12px",padding:c||window.innerWidth<768?"8px":"12px",display:"flex",flexWrap:H()?"wrap":"nowrap",alignItems:"center",justifyContent:"center",fontSize:`${me(v.length)}px`,background:z==="correct"?"#e8f5e8":z==="almost"?"#fff3e0":z==="wrong"?"#ffebee":"#fafafa",overflowX:H()?"hidden":"auto",whiteSpace:H()?"normal":"nowrap"},children:v.map((e,t)=>o.jsx("span",{draggable:!l,onDragStart:n=>{if(l){n.preventDefault();return}n.dataTransfer.setData("application/x-token",JSON.stringify({from:"selected",id:e.id})),n.dataTransfer.setData("text/plain",e.id)},onDragOver:n=>n.preventDefault(),onDrop:n=>{const i=n.currentTarget.getBoundingClientRect(),r=i.left+i.width/2,h=n.clientX>r?t+1:t;D({list:null,index:null,side:null}),n.stopPropagation(),Y(n,"selected",h)},onDragEnter:n=>{if(l)return;const i=n.currentTarget.getBoundingClientRect(),r=i.left+i.width/2;D({list:"selected",index:t,side:n.clientX>r?"right":"left"})},onDragLeave:()=>D({list:null,index:null,side:null}),onClick:()=>{l||U("selected","bank",e.id,null)},title:l?"Time expired":"Click to remove back to bank",style:{padding:w()?"4px 6px":"6px 10px",margin:w()?"2px":"4px",borderRadius:w()?"4px":"8px",background:l?"#f0f0f0":"#ffe9e7",border:l?"1px solid #ccc":"1px solid #ec4c44",borderLeft:S.list==="selected"&&S.index===t&&S.side==="left"?"3px solid #3b82f6":void 0,borderRight:S.list==="selected"&&S.index===t&&S.side==="right"?"3px solid #3b82f6":void 0,cursor:l?"not-allowed":"pointer",userSelect:"none",fontSize:`${me(v.length)}px`,fontFamily:'"Roboto", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif',whiteSpace:"nowrap",opacity:l?.6:1,transition:"opacity 0.3s ease"},children:e.text},e.id))}),o.jsx("button",{onClick:()=>Ge(!0),disabled:!l&&v.length===0,style:{marginTop:w()?"15px":"30px",fontSize:w()?"14px":"20px",padding:w()?"6px 12px":"10px 24px",borderRadius:w()?"8px":"12px",background:l||v.length>0?"#ec4c44":"#ccc",color:"white",border:"none",cursor:l||v.length>0?"pointer":"not-allowed"},children:"NEXT"})]}),Qe=()=>o.jsxs("div",{style:p.gmCenterScreen,children:[o.jsx("h1",{style:{...p.gmHeadline1,marginTop:(c&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||B||M||L||A||G||$||N||O,"0px"),marginBottom:c&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||B||M||L||A||G||$||N||O?"2px":"10px",fontSize:c&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"32px":"clamp(28px, 4vw, 40px)"},children:"Game Over 🎯"}),o.jsxs("h2",{style:{...p.gmHeadline2,marginTop:(c&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||B||M||L||A||G||$||N||O,"0px"),marginBottom:c&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||B||M||L||A||G||$||N||O?"2px":"16px",fontSize:c&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"18px":"24px"},children:["Your score: ",Z," out of ",C]}),o.jsxs("p",{style:{...p.gmBodyM,color:"#10b981",marginTop:c&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||B||M||L||A||G||$||N||O?"0px":"12px",marginBottom:c&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||B||M||L||A||G||$||N||O?"2px":"16px",fontSize:c&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"14px":"16px"},children:["Best score: ",te]}),o.jsxs("div",{style:{display:"flex",gap:c&&window.innerWidth>window.innerHeight||c&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"6px":"12px",marginTop:c&&window.innerWidth>window.innerHeight||c&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"2px":window.innerWidth===1366&&window.innerHeight===766||window.innerWidth===1366&&window.innerHeight===768||window.innerWidth===1280&&window.innerHeight===720||window.innerWidth===1440&&window.innerHeight===900||ke?"12px":"24px"},children:[o.jsx("button",{onClick:()=>{se(),T("start"),setTimeout(()=>{y("getready"),he(null),q(!1)},800)},style:{...p.gmButton,...m("medium")},children:"🔁 Play again"}),o.jsx("button",{onClick:()=>{T("click"),y("select"),V(null),ce(null),X([]),J(0),ne([]),q(!1)},style:{...p.gmButton,...m("medium")},children:"⬅️ Exit"})]})]}),ae=a||(typeof window<"u"&&window.origin?`${window.origin}/cloud/speakid/games/magic%20sentence/logo.svg`:null),Ve=!c&&b;return o.jsx("div",{ref:K,style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",transition:"background 0.3s ease",overflow:"hidden",position:"absolute",top:0,left:0,right:0,bottom:0},children:o.jsxs("div",{style:{width:c?"100%":we||1e3,height:c?"100%":we||1e3,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",borderRadius:c?0:"20px",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",boxShadow:c?"none":"0 0 40px rgba(0,0,0,0.1)",margin:c?"0 auto":"unset",position:"relative"},children:[Ve?o.jsx("div",{style:{...p.gmLogoFixed,position:"absolute",top:16,left:16,zIndex:30},children:ae?o.jsxs("picture",{children:[o.jsx("source",{srcSet:ae,type:"image/svg+xml"}),o.jsx("img",{src:ae.replace(".svg",".png"),alt:"SPEAKID Logo",style:p.gmLogoImg,loading:"lazy"})]}):o.jsx("div",{style:p.gmLogoFallback,children:"SPEAKID"})}):null,o.jsx("div",{style:{transform:"none",width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:o.jsxs("div",{id:"magic-sentence-root",children:[x==="select"?$e():null,x==="time"?Ne():null,x==="type"?Oe():null,x==="getready"?Fe():null,x==="play"?Ze():null,x==="results"?Qe():null]})})]})})}class _e extends s.Component{constructor(a){super(a),this.state={hasError:!1}}static getDerivedStateFromError(a){return{hasError:!0,error:a}}componentDidCatch(a,b){console.error("Game Error:",a,b),this.setState({error:a,errorInfo:b})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"100vh",padding:"20px",textAlign:"center",backgroundColor:"#fef2f2",color:"#dc2626",fontFamily:"system-ui, sans-serif"},children:[o.jsx("h1",{style:{fontSize:"24px",marginBottom:"16px"},children:"🚨 Oops! Something went wrong"}),o.jsx("p",{style:{fontSize:"16px",marginBottom:"24px",maxWidth:"500px"},children:"The game encountered an unexpected error. Don't worry, your progress is saved!"}),o.jsx("button",{onClick:this.handleReset,style:{padding:"12px 24px",fontSize:"16px",backgroundColor:"#dc2626",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",transition:"background-color 0.2s"},onMouseOver:a=>a.currentTarget.style.backgroundColor="#b91c1c",onMouseOut:a=>a.currentTarget.style.backgroundColor="#dc2626",children:"🔄 Restart Game"}),typeof process<"u"&&process.env.NODE_ENV==="development"&&this.state.error&&o.jsxs("details",{style:{marginTop:"20px",textAlign:"left",maxWidth:"600px"},children:[o.jsx("summary",{style:{cursor:"pointer",fontSize:"14px"},children:"Technical Details (Development Only)"}),o.jsxs("pre",{style:{backgroundColor:"#f3f4f6",padding:"12px",borderRadius:"4px",fontSize:"12px",overflow:"auto",marginTop:"8px"},children:[this.state.error.toString(),this.state.errorInfo?.componentStack]})]})]}):this.props.children}}exports.ErrorBoundary=_e;exports.Game=Se;exports.announceToScreenReader=P;exports.createAriaLabel=ye;exports.default=Se;exports.handleKeyDown=be;exports.useValidation=xe;
60
+ `;const d=document.getElementById("magic-sentence-reset");d&&d.remove(),document.head.appendChild(w)},dt=w=>[...w].sort(()=>Math.random()-.5);function je(w={}){const{logoUrl:d,showLogo:H=!0}=w,re=s.useRef(null),{validateAllSentences:oe,errors:C}=Ie(),j=()=>c||window.innerWidth<768,m=()=>c||window.innerWidth<768||window.innerWidth>=320&&window.innerWidth<=932&&window.innerHeight>=390&&window.innerHeight<=932,S=(e="medium")=>{if(!m())return{padding:"12px 24px",fontSize:"16px",minWidth:"auto"};switch(e){case"small":return{padding:"4px 6px",fontSize:"9px",minWidth:"40px"};case"medium":return{padding:"5px 8px",fontSize:"10px",minWidth:"50px"};case"large":return{padding:"6px 10px",fontSize:"11px",minWidth:"60px"}}};s.useEffect(()=>(at(),()=>{document.documentElement.style.overflow="",document.body.style.overflow="";const e=document.getElementById("magic-sentence-reset");e&&e.remove()}),[]);const[b,v]=s.useState("select"),[D,K]=s.useState(null),[he,ge]=s.useState(null),[T,Y]=s.useState([]),[R,pe]=s.useState(0),[se,we]=s.useState([]),[W,ae]=s.useState([]),[L,fe]=s.useState(20),[V,M]=s.useState(0),[ct,me]=s.useState(null),[B,I]=s.useState(null),[l,Z]=s.useState(!1),[_,Q]=s.useState(!1),[de,De]=s.useState(Number(localStorage.getItem("magicSentenceBest"))||0),U=s.useRef(null),Re=s.useRef(null),xe=s.useRef(0),[x,P]=s.useState({list:null,id:null,side:null}),[c,Ee]=s.useState(!1),[ze,ee]=s.useState(1),[ye,te]=s.useState(null),[Pe,Me]=s.useState(!1),[A,Be]=s.useState(!1),[$,Le]=s.useState(!1),[O,Ae]=s.useState(!1),[N,$e]=s.useState(!1),[G,Oe]=s.useState(!1),[X,Ne]=s.useState(!1),[F,Ge]=s.useState(!1),[q,Xe]=s.useState(!1),[ut,Fe]=s.useState(!1),[ht,qe]=s.useState(!1);s.useEffect(()=>{const e=()=>{const n=window.innerWidth,t=window.innerHeight,i=n<768||n===926&&t===428||n===932&&t===430,r=t<700,u=n/t>1.8,p=n===768&&t===1024,a=n===1024&&t===768,h=n===820&&t===1180,y=n===1180&&t===820,k=n===540&&t===720,ie=n===720&&t===540,We=n===1024&&t===1366,ke=n===1366&&t===1024,ve=n>=1200&&t>=600&&!i;Me(ve),Be(p),Le(a),Ae(h),$e(y),Oe(k),Ne(ie),Ge(We),Xe(ke),qe(u);const ot=i&&n>t||i||t<700||u||n===1366&&t===766||n===1366&&t===768||n===1280&&t===720||n===1440&&t===900||p||a||h||y||k||ie||We||ke||ve;if(Fe(ot),Ee(i),i)te(null),ee(1);else if(r)te(null),ee(1);else if(u){const ue=Math.min(1e3,Math.min(n,t)*.9);te(ue),ee(.85)}else{const ue=Math.min(1e3,Math.min(n,t)*.9);te(ue),ee(1)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const ne=(e,n,t,i)=>{if(l)return;let r=[...se],u=[...W];const p=e==="bank"?r:u,a=n==="bank"?r:u,h=p.findIndex(ie=>ie.id===t);if(h===-1)return;const[y]=p.splice(h,1);let k=i;e===n&&k!==null&&k!==void 0&&k>h&&(k=k-1),k==null||k<0||k>a.length?a.push(y):a.splice(k,0,y),e==="bank"?r=p:u=p,n==="bank"?r=a:u=a,we(r),ae(u)},J=(e,n,t)=>{if(e.preventDefault(),l){P({list:null,id:null,side:null});return}const i=e.dataTransfer.getData("application/x-token")||(()=>{const r=e.dataTransfer.getData("text/plain");if(!r)return"";const u=se.some(h=>h.id===r),p=W.some(h=>h.id===r),a=u?"bank":p?"selected":null;return a?JSON.stringify({from:a,id:r}):""})();if(i){try{const r=JSON.parse(i);if(!r||!r.id||!r.from)return;ne(r.from,n,r.id,t)}catch{}P({list:null,id:null,side:null})}},Ve=e=>{K(e),Re.current=e,Y(Array(e).fill("")),v("time")},Ue=e=>{ge(e),v("type")},Je=(e,n)=>{if(n.length>41||n&&!/^[a-zA-Z0-9\s.,!?;:'"-]*$/.test(n))return;const i=[...T];i[e]=n,Y(i);const r=oe(i);r.isValid||console.warn("Validation errors:",r.errors)},Ke=e=>e.trim().replace(/\s+/g," "),be=e=>e<=3?20:e<=5?18:e<=7?16:e<=9?14:12,Ye=()=>{T.some(n=>n.trim().length===0)||(Y(n=>n.map(t=>Ke(t))),M(0),pe(0),xe.current=0,me(null),v("getready"))};s.useEffect(()=>{if(b==="getready"){const e=setTimeout(()=>le(0),3e3);return()=>clearTimeout(e)}},[b]);const le=e=>{const n=T[e];if(!n)return;const i=dt(n.trim().split(/\s+/).filter(Boolean)).map((r,u)=>({id:`${Date.now()}-${e}-${u}-${Math.random().toString(36).slice(2)}`,text:r}));we(i),ae([]),pe(e),xe.current=e,fe(he||20),I(null),Z(!1),Q(!1),v("play")},f=s.useRef(null);s.useEffect(()=>{if(b!=="play"||l){f.current!==null&&(window.clearTimeout(f.current),f.current=null);return}const e=T[R];if(!e){I(null),f.current!==null&&(window.clearTimeout(f.current),f.current=null);return}if(W.length===0){I(null),f.current!==null&&(window.clearTimeout(f.current),f.current=null);return}const n=e.trim().split(/\s+/),t=W.map(r=>r.text);if(t.length===n.length&&t.every((r,u)=>r===n[u]))f.current!==null&&(window.clearTimeout(f.current),f.current=null),I("correct"),_||(Q(!0),M(r=>r+1),E("correct"),z("Correct! Well done!"));else if(t.length>=n.length||t.length>=2){f.current!==null&&(window.clearTimeout(f.current),f.current=null);const u=n.filter(y=>!t.includes(y)).length,p=t.filter(y=>!n.includes(y)).length,a=n.filter((y,k)=>y!==t[k]).length,h=u+p+a;I(h===1?"almost":"wrong"),_&&(Q(!1),M(y=>Math.max(0,y-1)))}else I(null),f.current!==null&&(window.clearTimeout(f.current),f.current=null);return()=>{f.current!==null&&(window.clearTimeout(f.current),f.current=null)}},[b,W,T,R,l,B,_,D]),s.useEffect(()=>{if(b==="play"&&!l)if(U.current!==null&&window.clearTimeout(U.current),L>0)U.current=window.setTimeout(()=>fe(e=>e-1),1e3);else{Z(!0);const n=T[R].trim().split(/\s+/),t=W.map(a=>a.text),i=n.filter(a=>!t.includes(a)).length,r=t.filter(a=>!n.includes(a)).length,u=n.filter((a,h)=>a!==t[h]).length,p=i+r+u;p===0?(I("correct"),_||(Q(!0),M(a=>a+1)),E("correct"),z("Correct! Well done!")):p===1?(I("almost"),E("half"),z("Almost correct! Just one mistake.")):(I("wrong"),E("wrong"),z("Not quite right. Keep trying!"))}return()=>{U.current!==null&&window.clearTimeout(U.current)}},[b,L,l,T,R,W]);const Ze=(e=!0)=>{if(l&&e){R+1<(D||0)?le(R+1):(v("results"),setTimeout(()=>ce(),600));return}if(e&&!l){const t=T[R].trim().split(/\s+/),i=W.map(h=>h.text),r=t.filter(h=>!i.includes(h)).length,u=i.filter(h=>!t.includes(h)).length,p=t.filter((h,y)=>h!==i[y]).length,a=r+u+p;a===0&&L>0?(M(h=>h+1),I("correct"),E("correct"),z("Correct! Well done!")):a===1?(M(h=>h+.5),I("almost"),E("half"),z("Almost correct! Just one mistake.")):(I("wrong"),E("wrong"),z("Not quite right. Keep trying!")),R+1<(D||0)?setTimeout(()=>le(R+1),800):(v("results"),setTimeout(()=>ce(),600))}};s.useEffect(()=>{b==="results"&&V>de&&(De(V),localStorage.setItem("magicSentenceBest",String(V)))},[b,V,de]);const E=e=>{const n=new(window.AudioContext||window.webkitAudioContext),t=n.createOscillator(),i=n.createGain();switch(t.connect(i),i.connect(n.destination),e){case"start":t.frequency.value=500;break;case"click":t.frequency.value=800;break;case"correct":t.frequency.value=1e3;break;case"half":t.frequency.value=700;break;case"wrong":t.frequency.value=200;break}i.gain.setValueAtTime(.1,n.currentTime),t.start(),t.stop(n.currentTime+.2)},ce=()=>{const n=Date.now()+2500,t=["#ec4c44","#f7c948","#6fcf97","#56ccf2","#bb6bd9"],i=document.createElement("canvas"),r=i.getContext("2d");i.width=window.innerWidth,i.height=window.innerHeight,i.style.position="fixed",i.style.top="0",i.style.left="0",i.style.pointerEvents="none",document.body.appendChild(i);const u=Array.from({length:100}).map(()=>({x:Math.random()*i.width,y:Math.random()*i.height-i.height,size:6+Math.random()*6,color:t[Math.floor(Math.random()*t.length)],speed:2+Math.random()*4,tilt:Math.random()*2*Math.PI})),p=()=>{r.clearRect(0,0,i.width,i.height),u.forEach(a=>{r.fillStyle=a.color,r.beginPath(),r.ellipse(a.x,a.y,a.size,a.size/2,a.tilt,0,2*Math.PI),r.fill(),a.y+=a.speed,a.x+=Math.sin(a.tilt)}),Date.now()<n?requestAnimationFrame(p):document.body.removeChild(i)};p()},_e=()=>o.jsxs("div",{style:g.gmCenterScreen,children:[o.jsx("h1",{style:g.gmHeadline1,children:"MAGIC SENTENCE"}),o.jsx("p",{style:g.gmBodyM,children:"Select number of rounds"}),o.jsx("div",{style:{display:"flex",gap:m()?"8px":"16px",justifyContent:"center"},children:[3,4,5].map(e=>o.jsxs("button",{onClick:()=>Ve(e),style:{...g.gmButton,...S("medium")},children:[e," ROUNDS"]},e))})]}),Qe=()=>o.jsxs("div",{style:g.gmCenterScreen,children:[o.jsx("h1",{style:g.gmHeadline1,children:"MAGIC SENTENCE"}),o.jsx("p",{style:g.gmBodyM,children:"Select time per round"}),o.jsx("div",{style:{display:"flex",gap:m()?"8px":"16px",justifyContent:"center"},children:[15,20,30].map(e=>o.jsxs("button",{onClick:()=>Ue(e),style:{...g.gmButton,...S("medium")},children:[e,"s"]},e))})]}),et=()=>o.jsxs("div",{style:g.gmCenterScreen,children:[o.jsxs("h2",{style:{...g.gmBodyM,marginBottom:"0px"},children:["Type down ",D," sentence",D&&D>1?"s":""," for your student"]}),o.jsx("p",{style:{...g.gmBodyS,marginBottom:"16px",marginTop:"0px",color:"#6b7280"},children:"Maximum 41 characters per sentence"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,width:"auto",minWidth:"fit-content",maxWidth:"600px"},children:T.map((e,n)=>o.jsx("input",{value:e,placeholder:`Sentence ${n+1}`,onChange:t=>Je(n,t.target.value),style:{...g.gmInput,padding:m()?"8px 12px":"12px 16px",fontSize:m()?"14px":"16px",width:"100%",textAlign:"center"}},n))}),o.jsx("button",{onClick:Ye,disabled:T.some(e=>e.trim().length===0),style:{...g.gmButton,marginTop:30,background:T.some(e=>e.trim().length===0)?"#ccc":"#ec4c44",cursor:T.some(e=>e.trim().length===0)?"not-allowed":"pointer",...S("large")},children:"PLAY"})]}),tt=()=>o.jsxs("div",{style:g.gmReadyWrapper,children:[o.jsx("h1",{style:{...g.gmHeadline1,color:"#ec4c44"},children:"GET READY"}),o.jsx("div",{style:g.gmHourglass,children:"⏳"})]}),nt=()=>o.jsxs("div",{style:g.gmGameLayout,children:[o.jsxs("h2",{style:{marginBottom:m()?"5px":"10px",fontSize:m()?"16px":"20px"},children:["Round ",R+1,"/",D," — ",l?"TIME'S UP!":`Time: ${L}s`]}),o.jsx("div",{style:{width:"60%",height:m()?"8px":"14px",borderRadius:8,background:"#eee",overflow:"hidden",marginBottom:m()?"10px":"20px"},children:o.jsx("div",{style:{height:"100%",width:`${L/(he||20)*100}%`,background:L<=5?"#ec4c44":"#4caf50",transition:"width 1s linear"}})}),o.jsx("div",{onDragOver:e=>e.preventDefault(),onDrop:e=>J(e,"bank",null),style:{display:"flex",flexWrap:j()?"wrap":"nowrap",gap:c||window.innerWidth<768?"6px":"10px",justifyContent:"center",marginBottom:c||window.innerWidth<768?"15px":"30px",padding:c||window.innerWidth<768?"5px":"10px",width:"100%",boxSizing:"border-box"},children:se.map((e,n)=>o.jsx("div",{draggable:!l,role:"button",tabIndex:l?-1:0,"aria-label":l?`Word: ${e.text} (time expired)`:Te("Drag word",e.text,"to build sentence"),onDragStart:t=>{if(l){t.preventDefault();return}t.dataTransfer.setData("application/x-token",JSON.stringify({from:"bank",id:e.id})),t.dataTransfer.setData("text/plain",e.id),z(`Dragging word: ${e.text}`)},onKeyDown:t=>{l||Ce(t,()=>ne("bank","selected",e.id,null))},onDragOver:t=>t.preventDefault(),onDrop:t=>{const i=t.currentTarget.getBoundingClientRect(),r=i.left+i.width/2,u=t.clientX>r?n+1:n;P({list:null,id:null,side:null}),t.stopPropagation(),J(t,"bank",u)},onDragEnter:t=>{if(l)return;const i=t.currentTarget.getBoundingClientRect(),r=i.left+i.width/2;P({list:"bank",id:e.id,side:t.clientX>r?"right":"left"})},onDragLeave:()=>P({list:null,id:null,side:null}),onClick:()=>{l||ne("bank","selected",e.id,null)},style:{padding:c||window.innerWidth<768?"6px 10px":"10px 16px",borderRadius:c||window.innerWidth<768?"6px":"10px",border:"1px solid #ccc",background:l?"#f0f0f0":"#f9f9f9",cursor:l?"not-allowed":x.list==="bank"&&x.id===e.id?"grabbing":"grab",fontSize:c||window.innerWidth<768?"12px":"18px",...x.list==="bank"&&x.id===e.id&&x.side==="left"?{borderLeft:"3px solid #3b82f6"}:{},...x.list==="bank"&&x.id===e.id&&x.side==="right"?{borderRight:"3px solid #3b82f6"}:{},flexShrink:0,flexBasis:"auto",opacity:l?.6:1,transition:"opacity 0.3s ease, transform 0.2s ease",...x.list==="bank"&&x.id===e.id?{transform:"scale(1.05)",boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"}:{}},children:e.text},e.id))}),o.jsx("div",{onDragOver:e=>e.preventDefault(),onDrop:e=>{const n=e.currentTarget.getBoundingClientRect(),t=Array.from(e.currentTarget.children);if(t.length===0){J(e,"selected",0);return}let i=W.length,r=1/0;t.forEach((u,p)=>{const a=u.getBoundingClientRect(),h=a.left+a.width/2,y=Math.abs(e.clientX-h);y<r&&(r=y,i=e.clientX<h?p:p+1)}),e.clientX>n.right-30&&(i=W.length),e.clientX<n.left+30&&(i=0),J(e,"selected",i)},style:{minHeight:c||window.innerWidth<768?"50px":"70px",width:"auto",maxWidth:"none",minWidth:"245px",border:B==="correct"?"2px dashed #4caf50":B==="almost"?"2px dashed #ff9800":B==="wrong"?"2px dashed #f44336":"2px dashed #ccc",borderRadius:c||window.innerWidth<768?"8px":"12px",padding:c||window.innerWidth<768?"8px":"12px",display:"flex",flexWrap:j()?"wrap":"nowrap",alignItems:"center",justifyContent:"center",fontSize:`${be(W.length)}px`,background:B==="correct"?"#e8f5e8":B==="almost"?"#fff3e0":B==="wrong"?"#ffebee":"#fafafa",overflowX:j()?"hidden":"auto",whiteSpace:j()?"normal":"nowrap"},children:W.map((e,n)=>o.jsx("span",{draggable:!l,onDragStart:t=>{if(l){t.preventDefault();return}t.dataTransfer.setData("application/x-token",JSON.stringify({from:"selected",id:e.id})),t.dataTransfer.setData("text/plain",e.id)},onDragOver:t=>t.preventDefault(),onDrop:t=>{const i=t.currentTarget.getBoundingClientRect(),r=i.left+i.width/2,u=i.width*.25,p=t.clientX<r-u?n:t.clientX>r+u||t.clientX>r?n+1:n;P({list:null,id:null,side:null}),t.stopPropagation(),J(t,"selected",p)},onDragEnter:t=>{if(l)return;const i=t.currentTarget.getBoundingClientRect(),r=i.left+i.width/2;P({list:"selected",id:e.id,side:t.clientX>r?"right":"left"})},onDragLeave:()=>P({list:null,id:null,side:null}),onClick:()=>{l||ne("selected","bank",e.id,null)},title:l?"Time expired":"Click to remove back to bank",style:{padding:m()?"4px 6px":"6px 10px",margin:m()?"2px":"4px",borderRadius:m()?"4px":"8px",background:l?"#f0f0f0":"#ffe9e7",border:l?"1px solid #ccc":"1px solid #ec4c44",...x.list==="selected"&&x.id===e.id&&x.side==="left"?{borderLeft:"3px solid #3b82f6"}:{},...x.list==="selected"&&x.id===e.id&&x.side==="right"?{borderRight:"3px solid #3b82f6"}:{},cursor:l?"not-allowed":x.list==="selected"&&x.id===e.id?"grabbing":"grab",userSelect:"none",fontSize:`${be(W.length)}px`,fontFamily:'"Roboto", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif',whiteSpace:"nowrap",opacity:l?.6:1,transition:"opacity 0.3s ease, transform 0.2s ease",...x.list==="selected"&&x.id===e.id?{transform:"scale(1.05)",boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"}:{}},children:e.text},e.id))}),o.jsx("button",{onClick:()=>Ze(!0),disabled:!l&&W.length===0,style:{marginTop:m()?"15px":"30px",fontSize:m()?"14px":"20px",padding:m()?"6px 12px":"10px 24px",borderRadius:m()?"8px":"12px",background:l||W.length>0?"#ec4c44":"#ccc",color:"white",border:"none",cursor:l||W.length>0?"pointer":"not-allowed"},children:"NEXT"})]}),it=()=>o.jsxs("div",{style:g.gmCenterScreen,children:[o.jsx("h1",{style:{...g.gmHeadline1,marginTop:(c&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||A||$||O||N||G||X||F||q,"0px"),marginBottom:c&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||A||$||O||N||G||X||F||q?"2px":"10px",fontSize:c&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"32px":"clamp(28px, 4vw, 40px)"},children:"Game Over 🎯"}),o.jsxs("h2",{style:{...g.gmHeadline2,marginTop:(c&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||A||$||O||N||G||X||F||q,"0px"),marginBottom:c&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||A||$||O||N||G||X||F||q?"2px":"16px",fontSize:c&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"18px":"24px"},children:["Your score: ",V," out of ",D]}),o.jsxs("p",{style:{...g.gmBodyM,color:"#10b981",marginTop:c&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||A||$||O||N||G||X||F||q?"0px":"12px",marginBottom:c&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||A||$||O||N||G||X||F||q?"2px":"16px",fontSize:c&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"14px":"16px"},children:["Best score: ",de]}),o.jsxs("div",{style:{display:"flex",gap:c&&window.innerWidth>window.innerHeight||c&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"6px":"12px",marginTop:c&&window.innerWidth>window.innerHeight||c&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"2px":window.innerWidth===1366&&window.innerHeight===766||window.innerWidth===1366&&window.innerHeight===768||window.innerWidth===1280&&window.innerHeight===720||window.innerWidth===1440&&window.innerHeight===900||Pe?"12px":"24px"},children:[o.jsx("button",{onClick:()=>{ce(),E("start"),setTimeout(()=>{v("getready"),me(null),Z(!1)},800)},style:{...g.gmButton,...S("medium")},children:"🔁 Play again"}),o.jsx("button",{onClick:()=>{E("click"),v("select"),K(null),ge(null),Y([]),M(0),ae([]),Z(!1)},style:{...g.gmButton,...S("medium")},children:"⬅️ Exit"})]})]}),Se=!c&&H,rt=s.useMemo(()=>{if(c&&window.innerWidth>window.innerHeight||window.innerHeight<700||!Se)return null;const e=d||(typeof window<"u"&&window.origin?`${window.origin}/cloud/speakid/games/magic%20sentence/logo`:"/cloud/speakid/games/magic%20sentence/logo");return o.jsx("div",{style:{...g.gmLogoFixed,position:"absolute",top:16,left:16,zIndex:30},children:o.jsxs("picture",{children:[o.jsx("source",{srcSet:`${e}.svg`,type:"image/svg+xml"}),o.jsx("img",{src:`${e}.png`,alt:"SPEAKID Logo",style:g.gmLogoImg,loading:"lazy"})]})})},[c,Se,d]);return o.jsx("div",{ref:re,style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",transition:"background 0.3s ease",overflow:"hidden",position:"absolute",top:0,left:0,right:0,bottom:0},children:o.jsx("div",{style:{width:c?"100%":ye||1e3,height:c?"100%":ye||1e3,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",borderRadius:c?0:"20px",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",boxShadow:c?"none":"0 0 40px rgba(0,0,0,0.1)",margin:c?"0 auto":"unset",position:"relative",transform:`scale(${ze})`},children:o.jsx("div",{style:{transform:"translateZ(0)",width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:o.jsxs("div",{id:"magic-sentence-root",children:[rt,b==="select"?_e():null,b==="time"?Qe():null,b==="type"?et():null,b==="getready"?tt():null,b==="play"?nt():null,b==="results"?it():null]})})})})}class lt extends s.Component{constructor(d){super(d),this.state={hasError:!1}}static getDerivedStateFromError(d){return{hasError:!0,error:d}}componentDidCatch(d,H){console.error("Game Error:",d,H),this.setState({error:d,errorInfo:H})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"100vh",padding:"20px",textAlign:"center",backgroundColor:"#fef2f2",color:"#dc2626",fontFamily:"system-ui, sans-serif"},children:[o.jsx("h1",{style:{fontSize:"24px",marginBottom:"16px"},children:"🚨 Oops! Something went wrong"}),o.jsx("p",{style:{fontSize:"16px",marginBottom:"24px",maxWidth:"500px"},children:"The game encountered an unexpected error. Don't worry, your progress is saved!"}),o.jsx("button",{onClick:this.handleReset,style:{padding:"12px 24px",fontSize:"16px",backgroundColor:"#dc2626",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",transition:"background-color 0.2s"},onMouseOver:d=>d.currentTarget.style.backgroundColor="#b91c1c",onMouseOut:d=>d.currentTarget.style.backgroundColor="#dc2626",children:"🔄 Restart Game"}),typeof process<"u"&&process.env.NODE_ENV==="development"&&this.state.error&&o.jsxs("details",{style:{marginTop:"20px",textAlign:"left",maxWidth:"600px"},children:[o.jsx("summary",{style:{cursor:"pointer",fontSize:"14px"},children:"Technical Details (Development Only)"}),o.jsxs("pre",{style:{backgroundColor:"#f3f4f6",padding:"12px",borderRadius:"4px",fontSize:"12px",overflow:"auto",marginTop:"8px"},children:[this.state.error.toString(),this.state.errorInfo?.componentStack]})]})]}):this.props.children}}exports.ErrorBoundary=lt;exports.Game=je;exports.announceToScreenReader=z;exports.createAriaLabel=Te;exports.default=je;exports.handleKeyDown=Ce;exports.useValidation=Ie;
61
61
  //# sourceMappingURL=speakid-build-a-sentence.cjs.js.map