@mblinkov/whats-missing 20.0.39 → 20.0.41

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,9 +1,45 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),s=require("react"),he=window.origin+"/cloud/speakid/games/whatsmissing/",P=(l,m)=>l.map(([r,i])=>({src:`${he}${m}/${i.replace(/\s/g,"%20")}.png`,name:i})),fe=[["apple","apple"],["banana","banana"],["bread","bread"],["burger","burger"],["cake","cake"],["carrot","carrot"],["cheese","cheese"],["chicken","chicken"],["chocolate","chocolate"],["corn","corn"],["donut","donut"],["fish","fish"],["fries","fries"],["grapes","grapes"],["ice_cream","ice cream"],["milk","milk"],["orange","orange"],["pear","pear"],["pizza","pizza"],["rice","rice"],["sandwich","sandwich"],["soup","soup"],["strawberry","strawberry"],["tomato","tomato"],["watermelon","watermelon"]],pe=[["bear","bear"],["cat","cat"],["crocodile","crocodile"],["dolphin","dolphin"],["elephant","elephant"],["fox","fox"],["giraffe","giraffe"],["horse","horse"],["kangaroo","kangaroo"],["lion","lion"],["monkey","monkey"],["owl","owl"],["panda","panda"],["penguin","penguin"],["squirrel","squirrel"],["tiger","tiger"],["tortoise","tortoise"],["wolf","wolf"],["zebra","zebra"]],ye=[["ball","ball"],["balloon","balloon"],["blocks","blocks"],["car","car"],["doll","doll"],["drum","drum"],["guitar","guitar"],["jump_rope","jump rope"],["kite","kite"],["paints","paints"],["plane","plane"],["puzzle","puzzle"],["rocket","rocket"],["scooter","scooter"],["skateboard","skateboard"],["slide","slide"],["teddy_bear","teddy bear"],["yo-yo","yo-yo"],["crayons","crayons"]],Y={food:P(fe,"food"),animals:P(pe,"animals"),toys:P(ye,"toys")},xe=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),s=require("react"),pe=require("react-dom"),ye=window.origin+"/cloud/speakid/games/whatsmissing/",Y=(d,m)=>d.map(([r,i])=>({src:`${ye}${m}/${i.replace(/\s/g,"%20")}.png`,name:i})),xe=[["apple","apple"],["banana","banana"],["bread","bread"],["burger","burger"],["cake","cake"],["carrot","carrot"],["cheese","cheese"],["chicken","chicken"],["chocolate","chocolate"],["corn","corn"],["donut","donut"],["fish","fish"],["fries","fries"],["grapes","grapes"],["ice_cream","ice cream"],["milk","milk"],["orange","orange"],["pear","pear"],["pizza","pizza"],["rice","rice"],["sandwich","sandwich"],["soup","soup"],["strawberry","strawberry"],["tomato","tomato"],["watermelon","watermelon"]],we=[["bear","bear"],["cat","cat"],["crocodile","crocodile"],["dolphin","dolphin"],["elephant","elephant"],["fox","fox"],["giraffe","giraffe"],["horse","horse"],["kangaroo","kangaroo"],["lion","lion"],["monkey","monkey"],["owl","owl"],["panda","panda"],["penguin","penguin"],["squirrel","squirrel"],["tiger","tiger"],["tortoise","tortoise"],["wolf","wolf"],["zebra","zebra"]],be=[["ball","ball"],["balloon","balloon"],["blocks","blocks"],["car","car"],["doll","doll"],["drum","drum"],["guitar","guitar"],["jump_rope","jump rope"],["kite","kite"],["paints","paints"],["plane","plane"],["puzzle","puzzle"],["rocket","rocket"],["scooter","scooter"],["skateboard","skateboard"],["slide","slide"],["teddy_bear","teddy bear"],["yo-yo","yo-yo"],["crayons","crayons"]],Z={food:Y(xe,"food"),animals:Y(we,"animals"),toys:Y(be,"toys")},je=`
2
2
  @keyframes spin {
3
3
  from { transform: rotate(0deg); }
4
4
  to { transform: rotate(360deg); }
5
5
  }
6
- `;if(typeof document<"u"&&!document.getElementById("spin-keyframes")){const l=document.createElement("style");l.id="spin-keyframes",l.innerHTML=xe,document.head.appendChild(l)}const be={animation:"spin 1.4s linear infinite"},o={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%"},gmHeadline3:{fontWeight:600,fontSize:"18px",lineHeight:"130%"},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"},gmButtonActive:{background:"#333",color:"#fff"},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"},gmGrid:{width:"100%",maxWidth:"none",margin:"0 auto",display:"grid",gridTemplateColumns:"repeat(3, 210px)",gridAutoRows:"210px",gap:"20px",justifyContent:"center"},gmCard:{border:"1px solid #e5e7eb",borderRadius:"16px",background:"#f9f9f9",aspectRatio:"1 / 1",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"transform .2s ease, box-shadow .2s ease, border-color .2s ease"},gmCorrect:{border:"2px solid #10b981",boxShadow:"0 0 18px rgba(16,185,129,.45)",background:"#ecfdf5"},gmWrong:{border:"2px solid #ec4c44",boxShadow:"0 0 18px rgba(236,76,68,.35)",background:"#fef2f2"},gmInput:{padding:"6px 10px",borderRadius:"6px",border:"1px solid #ccc",fontSize:"16px",fontFamily:'"Geist", system-ui',width:"160px"},gmTable:{marginTop:"20px",marginBottom:"32px",borderCollapse:"collapse",width:"100%",maxWidth:"520px",tableLayout:"fixed",textAlign:"center"},gmTableCell:{padding:"8px 12px",borderBottom:"1px solid #e5e7eb",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},gmLogoFixed:{position:"absolute",top:"16px",left:"24px",width:"120px",zIndex:10,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"},gmHourglass:{fontSize:"42px",...be}},we=()=>{const l=document.createElement("style");l.textContent=`
7
- #whats-missing-root, #whats-missing-root * { box-sizing: border-box; }
8
- #whats-missing-root img { max-width:100%; height:auto; display:block; user-select:none; }
9
- `,document.head.appendChild(l)},je=(l,m)=>{const r=Array.from({length:l.length+1},()=>Array(m.length+1).fill(0));for(let i=0;i<=l.length;i++)r[i][0]=i;for(let i=0;i<=m.length;i++)r[0][i]=i;for(let i=1;i<=l.length;i++)for(let g=1;g<=m.length;g++)r[i][g]=l[i-1]===m[g-1]?r[i-1][g-1]:Math.min(r[i-1][g-1],r[i][g-1],r[i-1][g])+1;return r[l.length][m.length]};function ve(l,m={minDesktopWidth:1200,forceResize:!1}){const r=s.useRef(null),i=m.minDesktopWidth??1200,g=!!m.forceResize;s.useLayoutEffect(()=>{if(typeof window>"u"||!l||!l.current)return;const c=l.current,T=()=>{try{const a=document.body,j=getComputedStyle(a),b=parseFloat(a.style&&a.style.zoom||"");if(b&&!isNaN(b)&&b>0)return b;const S=parseFloat(j.zoom||"");if(S&&!isNaN(S)&&S>0)return S;const h=document.createElement("div");h.style.position="absolute",h.style.left="0",h.style.top="0",h.style.width="100px",h.style.height="1px",h.style.visibility="hidden",document.documentElement.appendChild(h);const C=h.getBoundingClientRect();if(document.documentElement.removeChild(h),C&&C.width>0){const p=C.width/100;if(!isNaN(p)&&p>0)return p}}catch{}return 1},H=()=>{if(i&&window.innerWidth<i){y();return}const a=T();if(!a||a===1){y();return}r.current||(r.current={transform:c.style.transform||null,transformOrigin:c.style.transformOrigin||null,width:c.style.width||null,height:c.style.height||null,willChange:c.style.willChange||null});const j=1/a;g&&(c.style.width=`${a*100}%`,c.style.height=`${a*100}%`),c.style.transformOrigin="50% 50%",c.style.transform=`scale(${j})`,c.style.willChange="transform"},y=()=>{if(!r.current)return;const a=r.current;c.style.transform=a.transform??"",c.style.transformOrigin=a.transformOrigin??"",c.style.width=a.width??"",c.style.height=a.height??"",c.style.willChange=a.willChange??"",r.current=null};let z=0;const x=()=>{cancelAnimationFrame(z),z=requestAnimationFrame(H)},R=new MutationObserver(a=>{for(const j of a)if(j.type==="attributes"&&(j.attributeName==="style"||j.attributeName==="class")){x();break}});return R.observe(document.body,{attributes:!0,attributeFilter:["style","class"]}),window.addEventListener("resize",x),x(),()=>{cancelAnimationFrame(z),R.disconnect(),window.removeEventListener("resize",x),y()}},[l,i,g])}function Se({gameCubeSize:l,screenHeight:m,screenWidth:r}){const i=s.useRef(null),g=s.useRef(null),[c,T]=s.useState(null);ve(i,{minDesktopWidth:1024,forceResize:!1}),s.useLayoutEffect(()=>{const e=i.current;if(!e)return;const n=e.style;n.position="fixed",n.top="0",n.left="0",n.width="100vw",n.height="100vh",n.zIndex="100",n.background="linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",n.overflow="hidden",n.margin="0",n.padding="0",n.setProperty("transform","none","important"),n.setProperty("zoom","1","important")},[]),s.useEffect(()=>{const e=document.body,n=document.documentElement,d=e.style.zoom,u=e.style.transform,v=n.style.zoom,I=n.style.transform;return e.style.zoom="1",e.style.transform="none",n.style.zoom="1",n.style.transform="none",()=>{e.style.zoom=d,e.style.transform=u,n.style.zoom=v,n.style.transform=I}},[]);const H=s.useMemo(()=>{const e=l??Math.min(r??1e3,m??1e3),n=r??(typeof window<"u"?window.innerWidth:1e3);return e<600&&n>768?600:n<=768?Math.min(e,n-20):e},[l,r,m]);s.useEffect(()=>(we(),()=>{document.body.style.overflow=""}),[]);const[y,z]=s.useState(null),[x,R]=s.useState([]),[a,j]=s.useState(4),[b,S]=s.useState(!1),[h,C]=s.useState(1),[p,ie]=s.useState(null),[w,B]=s.useState("ready"),[Z,U]=s.useState(3),[A,W]=s.useState(10),[F,V]=s.useState(20),[re,G]=s.useState(0),[E,$]=s.useState(!1),[L,_]=s.useState(""),[k,N]=s.useState(!1),[O,K]=s.useState(!1),[J,M]=s.useState(null),[le,D]=s.useState([]),[ae,Q]=s.useState([]),[f,de]=s.useState(!1);s.useEffect(()=>{if(typeof window>"u")return;const e=()=>{const n=r??window.innerWidth,d=window.matchMedia&&window.matchMedia("(pointer: coarse)").matches;de(n<=768||d)};return e(),window.addEventListener("resize",e),window.addEventListener("orientationchange",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e)}},[r]),s.useLayoutEffect(()=>{const e=g.current;if(!e||typeof window>"u")return;let n=null;try{n=new ResizeObserver(d=>{for(const u of d){const v=u.contentRect;T(Math.round(Math.min(v.width,v.height)))}}),n.observe(e),T(Math.round(Math.min(e.clientWidth,e.clientHeight)))}catch{T(Math.round(Math.min(e.clientWidth,e.clientHeight)))}return()=>n?.disconnect()},[f]);const X=e=>[...e].sort(()=>Math.random()-.5).slice(0,6),ee=()=>{if(!y)return;const e=X(Y[y]);R(e),S(!0),$(!1),C(1),G(0),D([]),Q([]),te(e,[],!0)},te=(e=x,n=ae,d=!1)=>{const u=X(e.length?e:Y[y]);let v=Math.floor(Math.random()*u.length),I=u[v].name,se=0;for(;n.includes(I)&&se<20;)v=Math.floor(Math.random()*u.length),I=u[v].name,se++;R(u),ie(v),Q([...n,I]),N(!1),_(""),V(20),M(null),d?(B("ready"),U(3),W(10)):(B("memorize"),W(10))};s.useEffect(()=>{if(!(!b||E||k)){if(w==="ready")if(Z<=0)B("memorize");else{const e=setTimeout(()=>U(n=>n-1),1e3);return()=>clearTimeout(e)}if(w==="memorize")if(A<=0)B("guess");else{const e=setTimeout(()=>W(n=>n-1),1e3);return()=>clearTimeout(e)}if(w==="guess"){if(F<=0){N(!0),M("wrong");const n=x[p].name;D(d=>[...d,{round:h,answer:L,correct:n,result:"wrong"}]);return}const e=setTimeout(()=>V(n=>n-1),1e3);return()=>clearTimeout(e)}}},[w,Z,A,F,b,E,k,x,p,h,L]);const ce=()=>{if(p===null||O)return;const e=x[p].name,n=L.toLowerCase().trim();let d="wrong";n===e?(G(u=>u+1),M("correct"),d="correct"):je(n,e)===1?(G(u=>u+.5),M("almost"),d="almost"):(M("wrong"),d="wrong"),D(u=>[...u,{round:h,answer:n,correct:e,result:d}]),K(!0),setTimeout(()=>{K(!1),N(!0)},600)},me=()=>h<a?(C(e=>e+1),te()):$(!0),ue=()=>{S(!1),$(!1),z(null)},ge=s.useMemo(()=>t.jsx("div",{style:{...o.gmLogoFixed,position:"absolute",top:16,left:16,zIndex:30},children:t.jsxs("picture",{children:[t.jsx("source",{srcSet:window.origin+"/cloud/speakid/games/whatsmissing/logo.svg",type:"image/svg+xml"}),t.jsx("img",{src:window.origin+"/cloud/speakid/games/whatsmissing/logo.png",alt:"SPEAKID Logo",style:o.gmLogoImg,loading:"lazy"})]})}),[]),ne=1200,oe=700,q=s.useMemo(()=>{const e=r??(typeof window<"u"?window.innerWidth:ne),n=m??(typeof window<"u"?window.innerHeight:oe),d=Math.min(e/ne,n/oe);return Math.min(1.35,Math.max(1,d))},[r,m,f]);return t.jsx("div",{ref:i,style:{position:"fixed",inset:0,display:"flex",justifyContent:"center",alignItems:"center",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",overflow:"hidden",zIndex:1,width:"100vw",height:"100vh",transform:"none",zoom:1,scale:"1 !important"},children:t.jsx("div",{ref:g,style:{width:f?"100%":`${H}px`,height:f?"100%":`${H}px`,borderRadius:f?0:"20px",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",position:"relative",overflow:"hidden",boxShadow:f?"none":"0 0 40px rgba(0,0,0,0.08)",display:"flex",justifyContent:"center",alignItems:"center"},children:t.jsxs("div",{id:"whats-missing-root",style:{transform:`scale(${q})`,transformOrigin:"center center",transition:"transform 0.2s ease-out",width:`${100/q}%`,height:`${100/q}%`,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[!f&&ge,!y&&!b&&t.jsxs("div",{style:o.gmCenterScreen,children:[t.jsx("h1",{style:o.gmHeadline1,children:"WHAT'S MISSING?"}),t.jsx("p",{style:o.gmBodyM,children:"Select a theme:"}),t.jsx("div",{style:{display:"flex",gap:16},children:["animals","food","toys"].map(e=>t.jsx("button",{style:o.gmButton,onClick:()=>z(e),children:e==="animals"?"🐶 Animals":e==="food"?"🍎 Food":"🧸 Toys"},e))}),t.jsxs("div",{style:{marginTop:24},children:[t.jsx("p",{style:o.gmBodyS,children:"Choose number of rounds:"}),t.jsx("div",{style:{display:"flex",gap:12,marginTop:8},children:[3,4,5].map(e=>t.jsx("button",{style:{...o.gmButton,...a===e?o.gmButtonActive:{}},onClick:()=>j(e),children:e},e))})]})]}),y&&!b&&t.jsxs("div",{style:o.gmCenterScreen,children:[t.jsxs("h1",{style:o.gmHeadline1,children:["Theme selected: ",y]}),t.jsxs("p",{style:o.gmBodyM,children:["Rounds: ",a]}),t.jsx("button",{style:o.gmButton,onClick:ee,children:"▶ Start game"})]}),E&&t.jsxs("div",{style:o.gmCenterScreen,children:[t.jsx("h1",{style:o.gmHeadline1,children:"Results"}),t.jsxs("h2",{style:o.gmHeadline3,children:["Your score: ",re," / ",a]}),t.jsx("p",{style:{...o.gmBodyM,color:"#10b981",marginTop:12},children:"Yahoo! You did it! 🍬✨"}),t.jsxs("table",{style:o.gmTable,children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Round"}),t.jsx("th",{children:"Your Answer"}),t.jsx("th",{children:"Correct"}),t.jsx("th",{children:"Result"})]})}),t.jsx("tbody",{children:le.map((e,n)=>t.jsxs("tr",{children:[t.jsx("td",{style:o.gmTableCell,children:e.round}),t.jsx("td",{style:o.gmTableCell,children:e.answer||"—"}),t.jsx("td",{style:o.gmTableCell,children:e.correct}),t.jsx("td",{style:o.gmTableCell,children:e.result==="correct"?"✔ Correct":e.result==="almost"?"◐ Almost (0.5)":"✘ Wrong"})]},n))})]}),t.jsxs("div",{style:{display:"flex",gap:12,marginTop:24},children:[t.jsx("button",{style:o.gmButton,onClick:ee,children:"🔁 Play again"}),t.jsx("button",{style:o.gmButton,onClick:ue,children:"⬅️ Choose theme"})]})]}),b&&!E&&t.jsxs("div",{style:o.gmGameLayout,children:[t.jsxs("div",{style:{minHeight:160,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[w==="ready"&&t.jsxs(t.Fragment,{children:[t.jsx("h1",{style:{...o.gmHeadline1,color:"#ec4c44"},children:"GET READY"}),t.jsx("div",{style:o.gmHourglass,children:"⏳"})]}),w==="memorize"&&t.jsxs("p",{style:{...o.gmBodyM,color:"#10b981"},children:["MEMORIZE (",A,")"]}),w==="guess"&&!k&&t.jsxs("p",{style:o.gmBodyM,children:["⏳ Time left: ",F,"s"]})]}),w!=="ready"&&t.jsx("div",{style:{...o.gmGrid,display:"grid",gridTemplateColumns:`repeat(${f?2:3}, 1fr)`,gridTemplateRows:`repeat(${f?3:2}, 1fr)`,gap:f?12:20,justifyContent:"center",alignContent:"center",padding:f?8:16,width:"100%",height:"100%",maxWidth:f?"100%":600,maxHeight:f?"100%":400,boxSizing:"border-box"},children:x.map((e,n)=>{const d=p===n&&w==="guess"&&!k;return t.jsx("div",{style:{...o.gmCard,width:"100%",height:"100%",...J==="correct"&&p===n?o.gmCorrect:{},...J==="wrong"&&p===n?o.gmWrong:{}},children:!d&&t.jsx("img",{src:e.src,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})},n)})}),t.jsxs("div",{style:{marginTop:16,height:80},children:[w==="guess"&&!k&&t.jsxs("div",{children:[t.jsx("input",{type:"text",placeholder:"Type the missing word",value:L,onChange:e=>_(e.target.value),style:o.gmInput}),t.jsx("button",{style:{...o.gmButton,marginLeft:8},onClick:ce,disabled:O,children:O?"...":"Check"})]}),k&&t.jsx("button",{type:"button",style:o.gmButton,onClick:me,children:"Next round"})]})]})]})})})}exports.Game=Se;exports.themes=Y;
6
+ `;if(typeof document<"u"&&!document.getElementById("spin-keyframes")){const d=document.createElement("style");d.id="spin-keyframes",d.innerHTML=je,document.head.appendChild(d)}const Se={animation:"spin 1.4s linear infinite"},o={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%"},gmHeadline3:{fontWeight:600,fontSize:"18px",lineHeight:"130%"},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"},gmButtonActive:{background:"#333",color:"#fff"},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"},gmGrid:{width:"100%",maxWidth:"none",margin:"0 auto",display:"grid",gridTemplateColumns:"repeat(3, 210px)",gridAutoRows:"210px",gap:"20px",justifyContent:"center"},gmCard:{border:"1px solid #e5e7eb",borderRadius:"16px",background:"#f9f9f9",aspectRatio:"1 / 1",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"transform .2s ease, box-shadow .2s ease, border-color .2s ease"},gmCorrect:{border:"2px solid #10b981",boxShadow:"0 0 18px rgba(16,185,129,.45)",background:"#ecfdf5"},gmWrong:{border:"2px solid #ec4c44",boxShadow:"0 0 18px rgba(236,76,68,.35)",background:"#fef2f2"},gmInput:{padding:"6px 10px",borderRadius:"6px",border:"1px solid #ccc",fontSize:"16px",fontFamily:'"Geist", system-ui',width:"160px"},gmTable:{marginTop:"20px",marginBottom:"32px",borderCollapse:"collapse",width:"100%",maxWidth:"520px",tableLayout:"fixed",textAlign:"center"},gmTableCell:{padding:"8px 12px",borderBottom:"1px solid #e5e7eb",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},gmLogoFixed:{position:"absolute",top:"16px",left:"24px",width:"120px",zIndex:10,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"},gmHourglass:{fontSize:"42px",...Se}},ve=(d,m)=>{const r=Array.from({length:d.length+1},()=>Array(m.length+1).fill(0));for(let i=0;i<=d.length;i++)r[i][0]=i;for(let i=0;i<=m.length;i++)r[0][i]=i;for(let i=1;i<=d.length;i++)for(let g=1;g<=m.length;g++)r[i][g]=d[i-1]===m[g-1]?r[i-1][g-1]:Math.min(r[i-1][g-1],r[i][g-1],r[i-1][g])+1;return r[d.length][m.length]};function ze(d,m={minDesktopWidth:1200,forceResize:!1}){const r=s.useRef(null),i=m.minDesktopWidth??1200,g=!!m.forceResize;s.useLayoutEffect(()=>{if(typeof window>"u"||!d||!d.current)return;const c=d.current,T=()=>{try{const a=document.body,y=getComputedStyle(a),w=parseFloat(a.style&&a.style.zoom||"");if(w&&!isNaN(w)&&w>0)return w;const z=parseFloat(y.zoom||"");if(z&&!isNaN(z)&&z>0)return z;const u=document.createElement("div");u.style.position="absolute",u.style.left="0",u.style.top="0",u.style.width="100px",u.style.height="1px",u.style.visibility="hidden",document.documentElement.appendChild(u);const C=u.getBoundingClientRect();if(document.documentElement.removeChild(u),C&&C.width>0){const j=C.width/100;if(!isNaN(j)&&j>0)return j}}catch{}return 1},B=()=>{if(i&&window.innerWidth<i){R();return}const a=T();if(!a||a===1){R();return}r.current||(r.current={transform:c.style.transform||null,transformOrigin:c.style.transformOrigin||null,width:c.style.width||null,height:c.style.height||null,willChange:c.style.willChange||null});const y=1/a;g&&(c.style.width=`${a*100}%`,c.style.height=`${a*100}%`),c.style.transformOrigin="50% 50%",c.style.transform=`scale(${y})`,c.style.willChange="transform"},R=()=>{if(!r.current)return;const a=r.current;c.style.transform=a.transform??"",c.style.transformOrigin=a.transformOrigin??"",c.style.width=a.width??"",c.style.height=a.height??"",c.style.willChange=a.willChange??"",r.current=null};let v=0;const p=()=>{cancelAnimationFrame(v),v=requestAnimationFrame(B)},M=new MutationObserver(a=>{for(const y of a)if(y.type==="attributes"&&(y.attributeName==="style"||y.attributeName==="class")){p();break}});return M.observe(document.body,{attributes:!0,attributeFilter:["style","class"]}),window.addEventListener("resize",p),p(),()=>{cancelAnimationFrame(v),M.disconnect(),window.removeEventListener("resize",p),R()}},[d,i,g])}function Ce({gameCubeSize:d,screenHeight:m,screenWidth:r}){const i=s.useRef(null),g=s.useRef(null),[c,T]=s.useState(null),[B,R]=s.useState(null);ze(i,{minDesktopWidth:1024,forceResize:!1}),s.useLayoutEffect(()=>{const e=i.current;if(!e)return;let n=e.shadowRoot;n||(n=e.attachShadow({mode:"open"})),n.innerHTML="";const l=document.createElement("style");l.textContent=`
7
+ :host {
8
+ position: fixed !important;
9
+ top: 0 !important;
10
+ left: 0 !important;
11
+ width: 100vw !important;
12
+ height: 100vh !important;
13
+ z-index: 100 !important;
14
+ background: linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%) !important;
15
+ overflow: hidden !important;
16
+ margin: 0 !important;
17
+ padding: 0 !important;
18
+ transform: none !important;
19
+ zoom: 1 !important;
20
+ scale: 1 !important;
21
+ }
22
+
23
+ #whats-missing-root, #whats-missing-root * {
24
+ box-sizing: border-box !important;
25
+ }
26
+
27
+ #whats-missing-root img {
28
+ max-width: 100% !important;
29
+ height: auto !important;
30
+ display: block !important;
31
+ user-select: none !important;
32
+ }
33
+
34
+ #whats-missing-root {
35
+ position: relative !important;
36
+ width: 100% !important;
37
+ height: 100% !important;
38
+ display: flex !important;
39
+ justify-content: center !important;
40
+ align-items: center !important;
41
+ transform: none !important;
42
+ zoom: 1 !important;
43
+ scale: 1 !important;
44
+ }
45
+ `,n.appendChild(l),R(n)},[]),s.useEffect(()=>{const e=document.body,n=document.documentElement,l=e.style.zoom,h=e.style.transform,b=n.style.zoom,I=n.style.transform;return e.style.zoom="1",e.style.transform="none",n.style.zoom="1",n.style.transform="none",()=>{e.style.zoom=l,e.style.transform=h,n.style.zoom=b,n.style.transform=I}},[]);const v=s.useMemo(()=>{const e=d??Math.min(r??1e3,m??1e3),n=r??(typeof window<"u"?window.innerWidth:1e3);return e<600&&n>768?600:n<=768?Math.min(e,n-20):e},[d,r,m]);s.useEffect(()=>()=>{document.body.style.overflow=""},[]);const[p,M]=s.useState(null),[a,y]=s.useState([]),[w,z]=s.useState(4),[u,C]=s.useState(!1),[j,U]=s.useState(1),[S,ae]=s.useState(null),[x,E]=s.useState("ready"),[V,_]=s.useState(3),[W,F]=s.useState(10),[G,K]=s.useState(20),[le,$]=s.useState(0),[L,N]=s.useState(!1),[A,J]=s.useState(""),[k,D]=s.useState(!1),[O,Q]=s.useState(!1),[X,H]=s.useState(null),[de,q]=s.useState([]),[ce,ee]=s.useState([]),[f,me]=s.useState(!1);s.useEffect(()=>{if(typeof window>"u")return;const e=()=>{const n=r??window.innerWidth,l=window.matchMedia&&window.matchMedia("(pointer: coarse)").matches;me(n<=768||l)};return e(),window.addEventListener("resize",e),window.addEventListener("orientationchange",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e)}},[r]),s.useLayoutEffect(()=>{const e=g.current;if(!e||typeof window>"u")return;let n=null;try{n=new ResizeObserver(l=>{for(const h of l){const b=h.contentRect;T(Math.round(Math.min(b.width,b.height)))}}),n.observe(e),T(Math.round(Math.min(e.clientWidth,e.clientHeight)))}catch{T(Math.round(Math.min(e.clientWidth,e.clientHeight)))}return()=>n?.disconnect()},[f]);const te=e=>[...e].sort(()=>Math.random()-.5).slice(0,6),ne=()=>{if(!p)return;const e=te(Z[p]);y(e),C(!0),N(!1),U(1),$(0),q([]),ee([]),oe(e,[],!0)},oe=(e=a,n=ce,l=!1)=>{const h=te(e.length?e:Z[p]);let b=Math.floor(Math.random()*h.length),I=h[b].name,re=0;for(;n.includes(I)&&re<20;)b=Math.floor(Math.random()*h.length),I=h[b].name,re++;y(h),ae(b),ee([...n,I]),D(!1),J(""),K(20),H(null),l?(E("ready"),_(3),F(10)):(E("memorize"),F(10))};s.useEffect(()=>{if(!(!u||L||k)){if(x==="ready")if(V<=0)E("memorize");else{const e=setTimeout(()=>_(n=>n-1),1e3);return()=>clearTimeout(e)}if(x==="memorize")if(W<=0)E("guess");else{const e=setTimeout(()=>F(n=>n-1),1e3);return()=>clearTimeout(e)}if(x==="guess"){if(G<=0){D(!0),H("wrong");const n=a[S].name;q(l=>[...l,{round:j,answer:A,correct:n,result:"wrong"}]);return}const e=setTimeout(()=>K(n=>n-1),1e3);return()=>clearTimeout(e)}}},[x,V,W,G,u,L,k,a,S,j,A]);const ue=()=>{if(S===null||O)return;const e=a[S].name,n=A.toLowerCase().trim();let l="wrong";n===e?($(h=>h+1),H("correct"),l="correct"):ve(n,e)===1?($(h=>h+.5),H("almost"),l="almost"):(H("wrong"),l="wrong"),q(h=>[...h,{round:j,answer:n,correct:e,result:l}]),Q(!0),setTimeout(()=>{Q(!1),D(!0)},600)},he=()=>j<w?(U(e=>e+1),oe()):N(!0),ge=()=>{C(!1),N(!1),M(null)},fe=s.useMemo(()=>t.jsx("div",{style:{...o.gmLogoFixed,position:"absolute",top:16,left:16,zIndex:30},children:t.jsxs("picture",{children:[t.jsx("source",{srcSet:window.origin+"/cloud/speakid/games/whatsmissing/logo.svg",type:"image/svg+xml"}),t.jsx("img",{src:window.origin+"/cloud/speakid/games/whatsmissing/logo.png",alt:"SPEAKID Logo",style:o.gmLogoImg,loading:"lazy"})]})}),[]),se=1200,ie=700,P=s.useMemo(()=>{const e=r??(typeof window<"u"?window.innerWidth:se),n=m??(typeof window<"u"?window.innerHeight:ie),l=Math.min(e/se,n/ie);return Math.min(1.35,Math.max(1,l))},[r,m,f]);return t.jsx("div",{ref:i,style:{width:"100%",height:"100%"},children:B&&pe.createPortal(t.jsx("div",{id:"whats-missing-root",style:{all:"unset"},children:t.jsx("div",{ref:g,style:{width:f?"100%":`${v}px`,height:f?"100%":`${v}px`,borderRadius:f?0:"20px",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",position:"relative",overflow:"hidden",boxShadow:f?"none":"0 0 40px rgba(0,0,0,0.08)",display:"flex",justifyContent:"center",alignItems:"center"},children:t.jsxs("div",{style:{transform:`scale(${P})`,transformOrigin:"center center",transition:"transform 0.2s ease-out",width:`${100/P}%`,height:`${100/P}%`,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[!f&&fe,!p&&!u&&t.jsxs("div",{style:o.gmCenterScreen,children:[t.jsx("h1",{style:o.gmHeadline1,children:"WHAT'S MISSING?"}),t.jsx("p",{style:o.gmBodyM,children:"Select a theme:"}),t.jsx("div",{style:{display:"flex",gap:16},children:["animals","food","toys"].map(e=>t.jsx("button",{style:o.gmButton,onClick:()=>M(e),children:e==="animals"?"🐶 Animals":e==="food"?"🍎 Food":"🧸 Toys"},e))}),t.jsxs("div",{style:{marginTop:24},children:[t.jsx("p",{style:o.gmBodyS,children:"Choose number of rounds:"}),t.jsx("div",{style:{display:"flex",gap:12,marginTop:8},children:[3,4,5].map(e=>t.jsx("button",{style:{...o.gmButton,...w===e?o.gmButtonActive:{}},onClick:()=>z(e),children:e},e))})]})]}),p&&!u&&t.jsxs("div",{style:o.gmCenterScreen,children:[t.jsxs("h1",{style:o.gmHeadline1,children:["Theme selected: ",p]}),t.jsxs("p",{style:o.gmBodyM,children:["Rounds: ",w]}),t.jsx("button",{style:o.gmButton,onClick:ne,children:"▶ Start game"})]}),L&&t.jsxs("div",{style:o.gmCenterScreen,children:[t.jsx("h1",{style:o.gmHeadline1,children:"Results"}),t.jsxs("h2",{style:o.gmHeadline3,children:["Your score: ",le," / ",w]}),t.jsx("p",{style:{...o.gmBodyM,color:"#10b981",marginTop:12},children:"Yahoo! You did it! 🍬✨"}),t.jsxs("table",{style:o.gmTable,children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Round"}),t.jsx("th",{children:"Your Answer"}),t.jsx("th",{children:"Correct"}),t.jsx("th",{children:"Result"})]})}),t.jsx("tbody",{children:de.map((e,n)=>t.jsxs("tr",{children:[t.jsx("td",{style:o.gmTableCell,children:e.round}),t.jsx("td",{style:o.gmTableCell,children:e.answer||"—"}),t.jsx("td",{style:o.gmTableCell,children:e.correct}),t.jsx("td",{style:o.gmTableCell,children:e.result==="correct"?"✔ Correct":e.result==="almost"?"◐ Almost (0.5)":"✘ Wrong"})]},n))})]}),t.jsxs("div",{style:{display:"flex",gap:12,marginTop:24},children:[t.jsx("button",{style:o.gmButton,onClick:ne,children:"🔁 Play again"}),t.jsx("button",{style:o.gmButton,onClick:ge,children:"⬅️ Choose theme"})]})]}),u&&!L&&t.jsxs("div",{style:o.gmGameLayout,children:[t.jsxs("div",{style:{minHeight:160,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[x==="ready"&&t.jsxs(t.Fragment,{children:[t.jsx("h1",{style:{...o.gmHeadline1,color:"#ec4c44"},children:"GET READY"}),t.jsx("div",{style:o.gmHourglass,children:"⏳"})]}),x==="memorize"&&t.jsxs("p",{style:{...o.gmBodyM,color:"#10b981"},children:["MEMORIZE (",W,")"]}),x==="guess"&&!k&&t.jsxs("p",{style:o.gmBodyM,children:["⏳ Time left: ",G,"s"]})]}),x!=="ready"&&t.jsx("div",{style:{...o.gmGrid,display:"grid",gridTemplateColumns:`repeat(${f?2:3}, 1fr)`,gridTemplateRows:`repeat(${f?3:2}, 1fr)`,gap:f?12:20,justifyContent:"center",alignContent:"center",padding:f?8:16,width:"100%",height:"100%",maxWidth:f?"100%":600,maxHeight:f?"100%":400,boxSizing:"border-box"},children:a.map((e,n)=>{const l=S===n&&x==="guess"&&!k;return t.jsx("div",{style:{...o.gmCard,width:"100%",height:"100%",...X==="correct"&&S===n?o.gmCorrect:{},...X==="wrong"&&S===n?o.gmWrong:{}},children:!l&&t.jsx("img",{src:e.src,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})},n)})}),t.jsxs("div",{style:{marginTop:16,height:80},children:[x==="guess"&&!k&&t.jsxs("div",{children:[t.jsx("input",{type:"text",placeholder:"Type the missing word",value:A,onChange:e=>J(e.target.value),style:o.gmInput}),t.jsx("button",{style:{...o.gmButton,marginLeft:8},onClick:ue,disabled:O,children:O?"...":"Check"})]}),k&&t.jsx("button",{type:"button",style:o.gmButton,onClick:he,children:"Next round"})]})]})]})})}),B)})}exports.Game=Ce;exports.themes=Z;
@@ -1,9 +1,10 @@
1
- import { jsx as o, jsxs as a, Fragment as be } from "react/jsx-runtime";
2
- import { useRef as V, useState as d, useLayoutEffect as _, useEffect as j, useMemo as Z } from "react";
3
- const xe = window.origin + "/cloud/speakid/games/whatsmissing/", U = (s, u) => s.map(([r, i]) => ({
4
- src: `${xe}${u}/${i.replace(/\s/g, "%20")}.png`,
1
+ import { jsx as n, jsxs as d, Fragment as ve } from "react/jsx-runtime";
2
+ import { useRef as _, useState as l, useLayoutEffect as K, useEffect as F, useMemo as U } from "react";
3
+ import { createPortal as ze } from "react-dom";
4
+ const Ce = window.origin + "/cloud/speakid/games/whatsmissing/", V = (c, h) => c.map(([r, i]) => ({
5
+ src: `${Ce}${h}/${i.replace(/\s/g, "%20")}.png`,
5
6
  name: i
6
- })), ve = [
7
+ })), ke = [
7
8
  ["apple", "apple"],
8
9
  ["banana", "banana"],
9
10
  ["bread", "bread"],
@@ -29,7 +30,7 @@ const xe = window.origin + "/cloud/speakid/games/whatsmissing/", U = (s, u) => s
29
30
  ["strawberry", "strawberry"],
30
31
  ["tomato", "tomato"],
31
32
  ["watermelon", "watermelon"]
32
- ], ze = [
33
+ ], Se = [
33
34
  ["bear", "bear"],
34
35
  ["cat", "cat"],
35
36
  ["crocodile", "crocodile"],
@@ -49,7 +50,7 @@ const xe = window.origin + "/cloud/speakid/games/whatsmissing/", U = (s, u) => s
49
50
  ["tortoise", "tortoise"],
50
51
  ["wolf", "wolf"],
51
52
  ["zebra", "zebra"]
52
- ], Ce = [
53
+ ], Te = [
53
54
  ["ball", "ball"],
54
55
  ["balloon", "balloon"],
55
56
  ["blocks", "blocks"],
@@ -69,23 +70,23 @@ const xe = window.origin + "/cloud/speakid/games/whatsmissing/", U = (s, u) => s
69
70
  ["teddy_bear", "teddy bear"],
70
71
  ["yo-yo", "yo-yo"],
71
72
  ["crayons", "crayons"]
72
- ], de = {
73
- food: U(ve, "food"),
74
- animals: U(ze, "animals"),
75
- toys: U(Ce, "toys")
76
- }, ke = `
73
+ ], me = {
74
+ food: V(ke, "food"),
75
+ animals: V(Se, "animals"),
76
+ toys: V(Te, "toys")
77
+ }, Re = `
77
78
  @keyframes spin {
78
79
  from { transform: rotate(0deg); }
79
80
  to { transform: rotate(360deg); }
80
81
  }
81
82
  `;
82
83
  if (typeof document < "u" && !document.getElementById("spin-keyframes")) {
83
- const s = document.createElement("style");
84
- s.id = "spin-keyframes", s.innerHTML = ke, document.head.appendChild(s);
84
+ const c = document.createElement("style");
85
+ c.id = "spin-keyframes", c.innerHTML = Re, document.head.appendChild(c);
85
86
  }
86
- const Se = {
87
+ const Me = {
87
88
  animation: "spin 1.4s linear infinite"
88
- }, n = {
89
+ }, o = {
89
90
  gmCenterScreen: {
90
91
  position: "relative",
91
92
  zIndex: 1,
@@ -239,51 +240,45 @@ const Se = {
239
240
  },
240
241
  gmHourglass: {
241
242
  fontSize: "42px",
242
- ...Se
243
+ ...Me
243
244
  }
244
- }, Te = () => {
245
- const s = document.createElement("style");
246
- s.textContent = `
247
- #whats-missing-root, #whats-missing-root * { box-sizing: border-box; }
248
- #whats-missing-root img { max-width:100%; height:auto; display:block; user-select:none; }
249
- `, document.head.appendChild(s);
250
- }, Re = (s, u) => {
251
- const r = Array.from({ length: s.length + 1 }, () => Array(u.length + 1).fill(0));
252
- for (let i = 0; i <= s.length; i++) r[i][0] = i;
253
- for (let i = 0; i <= u.length; i++) r[0][i] = i;
254
- for (let i = 1; i <= s.length; i++)
255
- for (let h = 1; h <= u.length; h++)
256
- r[i][h] = s[i - 1] === u[h - 1] ? r[i - 1][h - 1] : Math.min(r[i - 1][h - 1], r[i][h - 1], r[i - 1][h]) + 1;
257
- return r[s.length][u.length];
245
+ }, He = (c, h) => {
246
+ const r = Array.from({ length: c.length + 1 }, () => Array(h.length + 1).fill(0));
247
+ for (let i = 0; i <= c.length; i++) r[i][0] = i;
248
+ for (let i = 0; i <= h.length; i++) r[0][i] = i;
249
+ for (let i = 1; i <= c.length; i++)
250
+ for (let p = 1; p <= h.length; p++)
251
+ r[i][p] = c[i - 1] === h[p - 1] ? r[i - 1][p - 1] : Math.min(r[i - 1][p - 1], r[i][p - 1], r[i - 1][p]) + 1;
252
+ return r[c.length][h.length];
258
253
  };
259
- function Me(s, u = { minDesktopWidth: 1200, forceResize: !1 }) {
260
- const r = V(null), i = u.minDesktopWidth ?? 1200, h = !!u.forceResize;
261
- _(() => {
262
- if (typeof window > "u" || !s || !s.current) return;
263
- const m = s.current, M = () => {
254
+ function Ie(c, h = { minDesktopWidth: 1200, forceResize: !1 }) {
255
+ const r = _(null), i = h.minDesktopWidth ?? 1200, p = !!h.forceResize;
256
+ K(() => {
257
+ if (typeof window > "u" || !c || !c.current) return;
258
+ const m = c.current, M = () => {
264
259
  try {
265
- const l = document.body, z = getComputedStyle(l), x = parseFloat(l.style && l.style.zoom || "");
260
+ const s = document.body, w = getComputedStyle(s), x = parseFloat(s.style && s.style.zoom || "");
266
261
  if (x && !isNaN(x) && x > 0) return x;
267
- const k = parseFloat(z.zoom || "");
268
- if (k && !isNaN(k) && k > 0) return k;
269
- const f = document.createElement("div");
270
- f.style.position = "absolute", f.style.left = "0", f.style.top = "0", f.style.width = "100px", f.style.height = "1px", f.style.visibility = "hidden", document.documentElement.appendChild(f);
271
- const T = f.getBoundingClientRect();
272
- if (document.documentElement.removeChild(f), T && T.width > 0) {
273
- const y = T.width / 100;
274
- if (!isNaN(y) && y > 0) return y;
262
+ const S = parseFloat(w.zoom || "");
263
+ if (S && !isNaN(S) && S > 0) return S;
264
+ const u = document.createElement("div");
265
+ u.style.position = "absolute", u.style.left = "0", u.style.top = "0", u.style.width = "100px", u.style.height = "1px", u.style.visibility = "hidden", document.documentElement.appendChild(u);
266
+ const T = u.getBoundingClientRect();
267
+ if (document.documentElement.removeChild(u), T && T.width > 0) {
268
+ const z = T.width / 100;
269
+ if (!isNaN(z) && z > 0) return z;
275
270
  }
276
271
  } catch {
277
272
  }
278
273
  return 1;
279
- }, L = () => {
274
+ }, A = () => {
280
275
  if (i && window.innerWidth < i) {
281
- w();
276
+ H();
282
277
  return;
283
278
  }
284
- const l = M();
285
- if (!l || l === 1) {
286
- w();
279
+ const s = M();
280
+ if (!s || s === 1) {
281
+ H();
287
282
  return;
288
283
  }
289
284
  r.current || (r.current = {
@@ -293,376 +288,403 @@ function Me(s, u = { minDesktopWidth: 1200, forceResize: !1 }) {
293
288
  height: m.style.height || null,
294
289
  willChange: m.style.willChange || null
295
290
  });
296
- const z = 1 / l;
297
- h && (m.style.width = `${l * 100}%`, m.style.height = `${l * 100}%`), m.style.transformOrigin = "50% 50%", m.style.transform = `scale(${z})`, m.style.willChange = "transform";
298
- }, w = () => {
291
+ const w = 1 / s;
292
+ p && (m.style.width = `${s * 100}%`, m.style.height = `${s * 100}%`), m.style.transformOrigin = "50% 50%", m.style.transform = `scale(${w})`, m.style.willChange = "transform";
293
+ }, H = () => {
299
294
  if (!r.current) return;
300
- const l = r.current;
301
- m.style.transform = l.transform ?? "", m.style.transformOrigin = l.transformOrigin ?? "", m.style.width = l.width ?? "", m.style.height = l.height ?? "", m.style.willChange = l.willChange ?? "", r.current = null;
295
+ const s = r.current;
296
+ m.style.transform = s.transform ?? "", m.style.transformOrigin = s.transformOrigin ?? "", m.style.width = s.width ?? "", m.style.height = s.height ?? "", m.style.willChange = s.willChange ?? "", r.current = null;
302
297
  };
303
- let S = 0;
304
- const b = () => {
305
- cancelAnimationFrame(S), S = requestAnimationFrame(L);
306
- }, I = new MutationObserver((l) => {
307
- for (const z of l)
308
- if (z.type === "attributes" && (z.attributeName === "style" || z.attributeName === "class")) {
309
- b();
298
+ let k = 0;
299
+ const y = () => {
300
+ cancelAnimationFrame(k), k = requestAnimationFrame(A);
301
+ }, I = new MutationObserver((s) => {
302
+ for (const w of s)
303
+ if (w.type === "attributes" && (w.attributeName === "style" || w.attributeName === "class")) {
304
+ y();
310
305
  break;
311
306
  }
312
307
  });
313
- return I.observe(document.body, { attributes: !0, attributeFilter: ["style", "class"] }), window.addEventListener("resize", b), b(), () => {
314
- cancelAnimationFrame(S), I.disconnect(), window.removeEventListener("resize", b), w();
308
+ return I.observe(document.body, { attributes: !0, attributeFilter: ["style", "class"] }), window.addEventListener("resize", y), y(), () => {
309
+ cancelAnimationFrame(k), I.disconnect(), window.removeEventListener("resize", y), H();
315
310
  };
316
- }, [s, i, h]);
311
+ }, [c, i, p]);
317
312
  }
318
- function Be({
319
- gameCubeSize: s,
320
- screenHeight: u,
313
+ function Ee({
314
+ gameCubeSize: c,
315
+ screenHeight: h,
321
316
  screenWidth: r
322
317
  }) {
323
- const i = V(null), h = V(null), [m, M] = d(null);
324
- Me(i, { minDesktopWidth: 1024, forceResize: !1 }), _(() => {
318
+ const i = _(null), p = _(null), [m, M] = l(null), [A, H] = l(null);
319
+ Ie(i, { minDesktopWidth: 1024, forceResize: !1 }), K(() => {
325
320
  const e = i.current;
326
321
  if (!e) return;
327
- const t = e.style;
328
- t.position = "fixed", t.top = "0", t.left = "0", t.width = "100vw", t.height = "100vh", t.zIndex = "100", t.background = "linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)", t.overflow = "hidden", t.margin = "0", t.padding = "0", t.setProperty("transform", "none", "important"), t.setProperty("zoom", "1", "important");
329
- }, []), j(() => {
330
- const e = document.body, t = document.documentElement, c = e.style.zoom, g = e.style.transform, C = t.style.zoom, B = t.style.transform;
322
+ let t = e.shadowRoot;
323
+ t || (t = e.attachShadow({ mode: "open" })), t.innerHTML = "";
324
+ const a = document.createElement("style");
325
+ a.textContent = `
326
+ :host {
327
+ position: fixed !important;
328
+ top: 0 !important;
329
+ left: 0 !important;
330
+ width: 100vw !important;
331
+ height: 100vh !important;
332
+ z-index: 100 !important;
333
+ background: linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%) !important;
334
+ overflow: hidden !important;
335
+ margin: 0 !important;
336
+ padding: 0 !important;
337
+ transform: none !important;
338
+ zoom: 1 !important;
339
+ scale: 1 !important;
340
+ }
341
+
342
+ #whats-missing-root, #whats-missing-root * {
343
+ box-sizing: border-box !important;
344
+ }
345
+
346
+ #whats-missing-root img {
347
+ max-width: 100% !important;
348
+ height: auto !important;
349
+ display: block !important;
350
+ user-select: none !important;
351
+ }
352
+
353
+ #whats-missing-root {
354
+ position: relative !important;
355
+ width: 100% !important;
356
+ height: 100% !important;
357
+ display: flex !important;
358
+ justify-content: center !important;
359
+ align-items: center !important;
360
+ transform: none !important;
361
+ zoom: 1 !important;
362
+ scale: 1 !important;
363
+ }
364
+ `, t.appendChild(a), H(t);
365
+ }, []), F(() => {
366
+ const e = document.body, t = document.documentElement, a = e.style.zoom, g = e.style.transform, v = t.style.zoom, L = t.style.transform;
331
367
  return e.style.zoom = "1", e.style.transform = "none", t.style.zoom = "1", t.style.transform = "none", () => {
332
- e.style.zoom = c, e.style.transform = g, t.style.zoom = C, t.style.transform = B;
368
+ e.style.zoom = a, e.style.transform = g, t.style.zoom = v, t.style.transform = L;
333
369
  };
334
370
  }, []);
335
- const L = Z(() => {
336
- const e = s ?? Math.min(r ?? 1e3, u ?? 1e3), t = r ?? (typeof window < "u" ? window.innerWidth : 1e3);
371
+ const k = U(() => {
372
+ const e = c ?? Math.min(r ?? 1e3, h ?? 1e3), t = r ?? (typeof window < "u" ? window.innerWidth : 1e3);
337
373
  return e < 600 && t > 768 ? 600 : t <= 768 ? Math.min(e, t - 20) : e;
338
- }, [s, r, u]);
339
- j(() => (Te(), () => {
374
+ }, [c, r, h]);
375
+ F(() => () => {
340
376
  document.body.style.overflow = "";
341
- }), []);
342
- const [w, S] = d(null), [b, I] = d([]), [l, z] = d(4), [x, k] = d(!1), [f, T] = d(1), [y, ce] = d(null), [v, A] = d("ready"), [K, J] = d(3), [F, $] = d(10), [G, Q] = d(20), [me, N] = d(0), [E, D] = d(!1), [W, X] = d(""), [R, O] = d(!1), [q, ee] = d(!1), [te, H] = d(null), [ue, P] = d([]), [ge, ne] = d([]), [p, he] = d(!1);
343
- j(() => {
377
+ }, []);
378
+ const [y, I] = l(null), [s, w] = l([]), [x, S] = l(4), [u, T] = l(!1), [z, J] = l(1), [C, he] = l(null), [b, E] = l("ready"), [Q, X] = l(3), [$, G] = l(10), [N, ee] = l(20), [ue, D] = l(0), [W, O] = l(!1), [j, te] = l(""), [R, q] = l(!1), [Y, ne] = l(!1), [oe, B] = l(null), [ge, P] = l([]), [pe, ie] = l([]), [f, fe] = l(!1);
379
+ F(() => {
344
380
  if (typeof window > "u") return;
345
381
  const e = () => {
346
- const t = r ?? window.innerWidth, c = window.matchMedia && window.matchMedia("(pointer: coarse)").matches;
347
- he(t <= 768 || c);
382
+ const t = r ?? window.innerWidth, a = window.matchMedia && window.matchMedia("(pointer: coarse)").matches;
383
+ fe(t <= 768 || a);
348
384
  };
349
385
  return e(), window.addEventListener("resize", e), window.addEventListener("orientationchange", e), () => {
350
386
  window.removeEventListener("resize", e), window.removeEventListener("orientationchange", e);
351
387
  };
352
- }, [r]), _(() => {
353
- const e = h.current;
388
+ }, [r]), K(() => {
389
+ const e = p.current;
354
390
  if (!e || typeof window > "u") return;
355
391
  let t = null;
356
392
  try {
357
- t = new ResizeObserver((c) => {
358
- for (const g of c) {
359
- const C = g.contentRect;
360
- M(Math.round(Math.min(C.width, C.height)));
393
+ t = new ResizeObserver((a) => {
394
+ for (const g of a) {
395
+ const v = g.contentRect;
396
+ M(Math.round(Math.min(v.width, v.height)));
361
397
  }
362
398
  }), t.observe(e), M(Math.round(Math.min(e.clientWidth, e.clientHeight)));
363
399
  } catch {
364
400
  M(Math.round(Math.min(e.clientWidth, e.clientHeight)));
365
401
  }
366
402
  return () => t?.disconnect();
367
- }, [p]);
368
- const oe = (e) => [...e].sort(() => Math.random() - 0.5).slice(0, 6), ie = () => {
369
- if (!w) return;
370
- const e = oe(de[w]);
371
- I(e), k(!0), D(!1), T(1), N(0), P([]), ne([]), re(e, [], !0);
372
- }, re = (e = b, t = ge, c = !1) => {
373
- const g = oe(e.length ? e : de[w]);
374
- let C = Math.floor(Math.random() * g.length), B = g[C].name, ae = 0;
375
- for (; t.includes(B) && ae < 20; )
376
- C = Math.floor(Math.random() * g.length), B = g[C].name, ae++;
377
- I(g), ce(C), ne([...t, B]), O(!1), X(""), Q(20), H(null), c ? (A("ready"), J(3), $(10)) : (A("memorize"), $(10));
403
+ }, [f]);
404
+ const re = (e) => [...e].sort(() => Math.random() - 0.5).slice(0, 6), se = () => {
405
+ if (!y) return;
406
+ const e = re(me[y]);
407
+ w(e), T(!0), O(!1), J(1), D(0), P([]), ie([]), ae(e, [], !0);
408
+ }, ae = (e = s, t = pe, a = !1) => {
409
+ const g = re(e.length ? e : me[y]);
410
+ let v = Math.floor(Math.random() * g.length), L = g[v].name, ce = 0;
411
+ for (; t.includes(L) && ce < 20; )
412
+ v = Math.floor(Math.random() * g.length), L = g[v].name, ce++;
413
+ w(g), he(v), ie([...t, L]), q(!1), te(""), ee(20), B(null), a ? (E("ready"), X(3), G(10)) : (E("memorize"), G(10));
378
414
  };
379
- j(() => {
380
- if (!(!x || E || R)) {
381
- if (v === "ready")
382
- if (K <= 0) A("memorize");
415
+ F(() => {
416
+ if (!(!u || W || R)) {
417
+ if (b === "ready")
418
+ if (Q <= 0) E("memorize");
383
419
  else {
384
- const e = setTimeout(() => J((t) => t - 1), 1e3);
420
+ const e = setTimeout(() => X((t) => t - 1), 1e3);
385
421
  return () => clearTimeout(e);
386
422
  }
387
- if (v === "memorize")
388
- if (F <= 0) A("guess");
423
+ if (b === "memorize")
424
+ if ($ <= 0) E("guess");
389
425
  else {
390
- const e = setTimeout(() => $((t) => t - 1), 1e3);
426
+ const e = setTimeout(() => G((t) => t - 1), 1e3);
391
427
  return () => clearTimeout(e);
392
428
  }
393
- if (v === "guess") {
394
- if (G <= 0) {
395
- O(!0), H("wrong");
396
- const t = b[y].name;
397
- P((c) => [
398
- ...c,
399
- { round: f, answer: W, correct: t, result: "wrong" }
429
+ if (b === "guess") {
430
+ if (N <= 0) {
431
+ q(!0), B("wrong");
432
+ const t = s[C].name;
433
+ P((a) => [
434
+ ...a,
435
+ { round: z, answer: j, correct: t, result: "wrong" }
400
436
  ]);
401
437
  return;
402
438
  }
403
- const e = setTimeout(() => Q((t) => t - 1), 1e3);
439
+ const e = setTimeout(() => ee((t) => t - 1), 1e3);
404
440
  return () => clearTimeout(e);
405
441
  }
406
442
  }
407
- }, [v, K, F, G, x, E, R, b, y, f, W]);
408
- const fe = () => {
409
- if (y === null || q) return;
410
- const e = b[y].name, t = W.toLowerCase().trim();
411
- let c = "wrong";
412
- t === e ? (N((g) => g + 1), H("correct"), c = "correct") : Re(t, e) === 1 ? (N((g) => g + 0.5), H("almost"), c = "almost") : (H("wrong"), c = "wrong"), P((g) => [...g, { round: f, answer: t, correct: e, result: c }]), ee(!0), setTimeout(() => {
413
- ee(!1), O(!0);
443
+ }, [b, Q, $, N, u, W, R, s, C, z, j]);
444
+ const ye = () => {
445
+ if (C === null || Y) return;
446
+ const e = s[C].name, t = j.toLowerCase().trim();
447
+ let a = "wrong";
448
+ t === e ? (D((g) => g + 1), B("correct"), a = "correct") : He(t, e) === 1 ? (D((g) => g + 0.5), B("almost"), a = "almost") : (B("wrong"), a = "wrong"), P((g) => [...g, { round: z, answer: t, correct: e, result: a }]), ne(!0), setTimeout(() => {
449
+ ne(!1), q(!0);
414
450
  }, 600);
415
- }, pe = () => f < l ? (T((e) => e + 1), re()) : D(!0), ye = () => {
416
- k(!1), D(!1), S(null);
417
- }, we = Z(
418
- () => /* @__PURE__ */ o("div", { style: { ...n.gmLogoFixed, position: "absolute", top: 16, left: 16, zIndex: 30 }, children: /* @__PURE__ */ a("picture", { children: [
419
- /* @__PURE__ */ o(
451
+ }, we = () => z < x ? (J((e) => e + 1), ae()) : O(!0), be = () => {
452
+ T(!1), O(!1), I(null);
453
+ }, xe = U(
454
+ () => /* @__PURE__ */ n("div", { style: { ...o.gmLogoFixed, position: "absolute", top: 16, left: 16, zIndex: 30 }, children: /* @__PURE__ */ d("picture", { children: [
455
+ /* @__PURE__ */ n(
420
456
  "source",
421
457
  {
422
458
  srcSet: window.origin + "/cloud/speakid/games/whatsmissing/logo.svg",
423
459
  type: "image/svg+xml"
424
460
  }
425
461
  ),
426
- /* @__PURE__ */ o(
462
+ /* @__PURE__ */ n(
427
463
  "img",
428
464
  {
429
465
  src: window.origin + "/cloud/speakid/games/whatsmissing/logo.png",
430
466
  alt: "SPEAKID Logo",
431
- style: n.gmLogoImg,
467
+ style: o.gmLogoImg,
432
468
  loading: "lazy"
433
469
  }
434
470
  )
435
471
  ] }) }),
436
472
  []
437
- ), se = 1200, le = 700, Y = Z(() => {
438
- const e = r ?? (typeof window < "u" ? window.innerWidth : se), t = u ?? (typeof window < "u" ? window.innerHeight : le), c = Math.min(e / se, t / le);
439
- return Math.min(1.35, Math.max(1, c));
440
- }, [r, u, p]);
441
- return /* @__PURE__ */ o(
442
- "div",
443
- {
444
- ref: i,
445
- style: {
446
- position: "fixed",
447
- inset: 0,
448
- display: "flex",
449
- justifyContent: "center",
450
- alignItems: "center",
451
- background: "linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",
452
- overflow: "hidden",
453
- zIndex: 1,
454
- width: "100vw",
455
- height: "100vh",
456
- transform: "none",
457
- zoom: 1,
458
- // игнорирует масштаб родителя
459
- scale: "1 !important"
460
- // ✅ на случай если transform тянется сверху
461
- },
462
- children: /* @__PURE__ */ o(
463
- "div",
464
- {
465
- ref: h,
466
- style: {
467
- width: p ? "100%" : `${L}px`,
468
- height: p ? "100%" : `${L}px`,
469
- borderRadius: p ? 0 : "20px",
470
- background: "linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",
471
- position: "relative",
472
- overflow: "hidden",
473
- boxShadow: p ? "none" : "0 0 40px rgba(0,0,0,0.08)",
474
- display: "flex",
475
- justifyContent: "center",
476
- alignItems: "center"
477
- },
478
- children: /* @__PURE__ */ a(
479
- "div",
480
- {
481
- id: "whats-missing-root",
482
- style: {
483
- transform: `scale(${Y})`,
484
- transformOrigin: "center center",
485
- transition: "transform 0.2s ease-out",
486
- width: `${100 / Y}%`,
487
- height: `${100 / Y}%`,
488
- display: "flex",
489
- flexDirection: "column",
490
- justifyContent: "center",
491
- alignItems: "center"
492
- },
493
- children: [
494
- !p && we,
495
- !w && !x && /* @__PURE__ */ a("div", { style: n.gmCenterScreen, children: [
496
- /* @__PURE__ */ o("h1", { style: n.gmHeadline1, children: "WHAT'S MISSING?" }),
497
- /* @__PURE__ */ o("p", { style: n.gmBodyM, children: "Select a theme:" }),
498
- /* @__PURE__ */ o("div", { style: { display: "flex", gap: 16 }, children: ["animals", "food", "toys"].map((e) => /* @__PURE__ */ o("button", { style: n.gmButton, onClick: () => S(e), children: e === "animals" ? "🐶 Animals" : e === "food" ? "🍎 Food" : "🧸 Toys" }, e)) }),
499
- /* @__PURE__ */ a("div", { style: { marginTop: 24 }, children: [
500
- /* @__PURE__ */ o("p", { style: n.gmBodyS, children: "Choose number of rounds:" }),
501
- /* @__PURE__ */ o("div", { style: { display: "flex", gap: 12, marginTop: 8 }, children: [3, 4, 5].map((e) => /* @__PURE__ */ o(
502
- "button",
503
- {
504
- style: {
505
- ...n.gmButton,
506
- ...l === e ? n.gmButtonActive : {}
473
+ ), le = 1200, de = 700, Z = U(() => {
474
+ const e = r ?? (typeof window < "u" ? window.innerWidth : le), t = h ?? (typeof window < "u" ? window.innerHeight : de), a = Math.min(e / le, t / de);
475
+ return Math.min(1.35, Math.max(1, a));
476
+ }, [r, h, f]);
477
+ return /* @__PURE__ */ n("div", { ref: i, style: { width: "100%", height: "100%" }, children: A && ze(
478
+ /* @__PURE__ */ n(
479
+ "div",
480
+ {
481
+ id: "whats-missing-root",
482
+ style: { all: "unset" },
483
+ children: /* @__PURE__ */ n(
484
+ "div",
485
+ {
486
+ ref: p,
487
+ style: {
488
+ width: f ? "100%" : `${k}px`,
489
+ height: f ? "100%" : `${k}px`,
490
+ borderRadius: f ? 0 : "20px",
491
+ background: "linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",
492
+ position: "relative",
493
+ overflow: "hidden",
494
+ boxShadow: f ? "none" : "0 0 40px rgba(0,0,0,0.08)",
495
+ display: "flex",
496
+ justifyContent: "center",
497
+ alignItems: "center"
498
+ },
499
+ children: /* @__PURE__ */ d(
500
+ "div",
501
+ {
502
+ style: {
503
+ transform: `scale(${Z})`,
504
+ transformOrigin: "center center",
505
+ transition: "transform 0.2s ease-out",
506
+ width: `${100 / Z}%`,
507
+ height: `${100 / Z}%`,
508
+ display: "flex",
509
+ flexDirection: "column",
510
+ justifyContent: "center",
511
+ alignItems: "center"
512
+ },
513
+ children: [
514
+ !f && xe,
515
+ !y && !u && /* @__PURE__ */ d("div", { style: o.gmCenterScreen, children: [
516
+ /* @__PURE__ */ n("h1", { style: o.gmHeadline1, children: "WHAT'S MISSING?" }),
517
+ /* @__PURE__ */ n("p", { style: o.gmBodyM, children: "Select a theme:" }),
518
+ /* @__PURE__ */ n("div", { style: { display: "flex", gap: 16 }, children: ["animals", "food", "toys"].map((e) => /* @__PURE__ */ n("button", { style: o.gmButton, onClick: () => I(e), children: e === "animals" ? "🐶 Animals" : e === "food" ? "🍎 Food" : "🧸 Toys" }, e)) }),
519
+ /* @__PURE__ */ d("div", { style: { marginTop: 24 }, children: [
520
+ /* @__PURE__ */ n("p", { style: o.gmBodyS, children: "Choose number of rounds:" }),
521
+ /* @__PURE__ */ n("div", { style: { display: "flex", gap: 12, marginTop: 8 }, children: [3, 4, 5].map((e) => /* @__PURE__ */ n(
522
+ "button",
523
+ {
524
+ style: {
525
+ ...o.gmButton,
526
+ ...x === e ? o.gmButtonActive : {}
527
+ },
528
+ onClick: () => S(e),
529
+ children: e
507
530
  },
508
- onClick: () => z(e),
509
- children: e
510
- },
511
- e
512
- )) })
513
- ] })
514
- ] }),
515
- w && !x && /* @__PURE__ */ a("div", { style: n.gmCenterScreen, children: [
516
- /* @__PURE__ */ a("h1", { style: n.gmHeadline1, children: [
517
- "Theme selected: ",
518
- w
519
- ] }),
520
- /* @__PURE__ */ a("p", { style: n.gmBodyM, children: [
521
- "Rounds: ",
522
- l
531
+ e
532
+ )) })
533
+ ] })
523
534
  ] }),
524
- /* @__PURE__ */ o("button", { style: n.gmButton, onClick: ie, children: "▶ Start game" })
525
- ] }),
526
- E && /* @__PURE__ */ a("div", { style: n.gmCenterScreen, children: [
527
- /* @__PURE__ */ o("h1", { style: n.gmHeadline1, children: "Results" }),
528
- /* @__PURE__ */ a("h2", { style: n.gmHeadline3, children: [
529
- "Your score: ",
530
- me,
531
- " / ",
532
- l
535
+ y && !u && /* @__PURE__ */ d("div", { style: o.gmCenterScreen, children: [
536
+ /* @__PURE__ */ d("h1", { style: o.gmHeadline1, children: [
537
+ "Theme selected: ",
538
+ y
539
+ ] }),
540
+ /* @__PURE__ */ d("p", { style: o.gmBodyM, children: [
541
+ "Rounds: ",
542
+ x
543
+ ] }),
544
+ /* @__PURE__ */ n("button", { style: o.gmButton, onClick: se, children: "▶ Start game" })
533
545
  ] }),
534
- /* @__PURE__ */ o("p", { style: { ...n.gmBodyM, color: "#10b981", marginTop: 12 }, children: "Yahoo! You did it! 🍬✨" }),
535
- /* @__PURE__ */ a("table", { style: n.gmTable, children: [
536
- /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ a("tr", { children: [
537
- /* @__PURE__ */ o("th", { children: "Round" }),
538
- /* @__PURE__ */ o("th", { children: "Your Answer" }),
539
- /* @__PURE__ */ o("th", { children: "Correct" }),
540
- /* @__PURE__ */ o("th", { children: "Result" })
541
- ] }) }),
542
- /* @__PURE__ */ o("tbody", { children: ue.map((e, t) => /* @__PURE__ */ a("tr", { children: [
543
- /* @__PURE__ */ o("td", { style: n.gmTableCell, children: e.round }),
544
- /* @__PURE__ */ o("td", { style: n.gmTableCell, children: e.answer || "" }),
545
- /* @__PURE__ */ o("td", { style: n.gmTableCell, children: e.correct }),
546
- /* @__PURE__ */ o("td", { style: n.gmTableCell, children: e.result === "correct" ? " Correct" : e.result === "almost" ? "◐ Almost (0.5)" : "✘ Wrong" })
547
- ] }, t)) })
546
+ W && /* @__PURE__ */ d("div", { style: o.gmCenterScreen, children: [
547
+ /* @__PURE__ */ n("h1", { style: o.gmHeadline1, children: "Results" }),
548
+ /* @__PURE__ */ d("h2", { style: o.gmHeadline3, children: [
549
+ "Your score: ",
550
+ ue,
551
+ " / ",
552
+ x
553
+ ] }),
554
+ /* @__PURE__ */ n("p", { style: { ...o.gmBodyM, color: "#10b981", marginTop: 12 }, children: "Yahoo! You did it! 🍬✨" }),
555
+ /* @__PURE__ */ d("table", { style: o.gmTable, children: [
556
+ /* @__PURE__ */ n("thead", { children: /* @__PURE__ */ d("tr", { children: [
557
+ /* @__PURE__ */ n("th", { children: "Round" }),
558
+ /* @__PURE__ */ n("th", { children: "Your Answer" }),
559
+ /* @__PURE__ */ n("th", { children: "Correct" }),
560
+ /* @__PURE__ */ n("th", { children: "Result" })
561
+ ] }) }),
562
+ /* @__PURE__ */ n("tbody", { children: ge.map((e, t) => /* @__PURE__ */ d("tr", { children: [
563
+ /* @__PURE__ */ n("td", { style: o.gmTableCell, children: e.round }),
564
+ /* @__PURE__ */ n("td", { style: o.gmTableCell, children: e.answer || "—" }),
565
+ /* @__PURE__ */ n("td", { style: o.gmTableCell, children: e.correct }),
566
+ /* @__PURE__ */ n("td", { style: o.gmTableCell, children: e.result === "correct" ? "✔ Correct" : e.result === "almost" ? "◐ Almost (0.5)" : "✘ Wrong" })
567
+ ] }, t)) })
568
+ ] }),
569
+ /* @__PURE__ */ d("div", { style: { display: "flex", gap: 12, marginTop: 24 }, children: [
570
+ /* @__PURE__ */ n("button", { style: o.gmButton, onClick: se, children: "🔁 Play again" }),
571
+ /* @__PURE__ */ n("button", { style: o.gmButton, onClick: be, children: "⬅️ Choose theme" })
572
+ ] })
548
573
  ] }),
549
- /* @__PURE__ */ a("div", { style: { display: "flex", gap: 12, marginTop: 24 }, children: [
550
- /* @__PURE__ */ o("button", { style: n.gmButton, onClick: ie, children: "🔁 Play again" }),
551
- /* @__PURE__ */ o("button", { style: n.gmButton, onClick: ye, children: "⬅️ Choose theme" })
552
- ] })
553
- ] }),
554
- x && !E && /* @__PURE__ */ a("div", { style: n.gmGameLayout, children: [
555
- /* @__PURE__ */ a(
556
- "div",
557
- {
558
- style: {
559
- minHeight: 160,
560
- display: "flex",
561
- flexDirection: "column",
562
- justifyContent: "center",
563
- alignItems: "center"
564
- },
565
- children: [
566
- v === "ready" && /* @__PURE__ */ a(be, { children: [
567
- /* @__PURE__ */ o("h1", { style: { ...n.gmHeadline1, color: "#ec4c44" }, children: "GET READY" }),
568
- /* @__PURE__ */ o("div", { style: n.gmHourglass, children: "⏳" })
569
- ] }),
570
- v === "memorize" && /* @__PURE__ */ a("p", { style: { ...n.gmBodyM, color: "#10b981" }, children: [
571
- "MEMORIZE (",
572
- F,
573
- ")"
574
- ] }),
575
- v === "guess" && !R && /* @__PURE__ */ a("p", { style: n.gmBodyM, children: [
576
- "⏳ Time left: ",
577
- G,
578
- "s"
579
- ] })
580
- ]
581
- }
582
- ),
583
- v !== "ready" && /* @__PURE__ */ o(
584
- "div",
585
- {
586
- style: {
587
- ...n.gmGrid,
588
- display: "grid",
589
- gridTemplateColumns: `repeat(${p ? 2 : 3}, 1fr)`,
590
- gridTemplateRows: `repeat(${p ? 3 : 2}, 1fr)`,
591
- gap: p ? 12 : 20,
592
- justifyContent: "center",
593
- alignContent: "center",
594
- padding: p ? 8 : 16,
595
- width: "100%",
596
- height: "100%",
597
- maxWidth: p ? "100%" : 600,
598
- maxHeight: p ? "100%" : 400,
599
- boxSizing: "border-box"
600
- },
601
- children: b.map((e, t) => {
602
- const c = y === t && v === "guess" && !R;
603
- return /* @__PURE__ */ o(
604
- "div",
605
- {
606
- style: {
607
- ...n.gmCard,
608
- width: "100%",
609
- height: "100%",
610
- ...te === "correct" && y === t ? n.gmCorrect : {},
611
- ...te === "wrong" && y === t ? n.gmWrong : {}
612
- },
613
- children: !c && /* @__PURE__ */ o(
614
- "img",
615
- {
616
- src: e.src,
617
- alt: e.name,
618
- style: {
619
- width: "100%",
620
- height: "100%",
621
- objectFit: "cover",
622
- display: "block"
574
+ u && !W && /* @__PURE__ */ d("div", { style: o.gmGameLayout, children: [
575
+ /* @__PURE__ */ d(
576
+ "div",
577
+ {
578
+ style: {
579
+ minHeight: 160,
580
+ display: "flex",
581
+ flexDirection: "column",
582
+ justifyContent: "center",
583
+ alignItems: "center"
584
+ },
585
+ children: [
586
+ b === "ready" && /* @__PURE__ */ d(ve, { children: [
587
+ /* @__PURE__ */ n("h1", { style: { ...o.gmHeadline1, color: "#ec4c44" }, children: "GET READY" }),
588
+ /* @__PURE__ */ n("div", { style: o.gmHourglass, children: "" })
589
+ ] }),
590
+ b === "memorize" && /* @__PURE__ */ d("p", { style: { ...o.gmBodyM, color: "#10b981" }, children: [
591
+ "MEMORIZE (",
592
+ $,
593
+ ")"
594
+ ] }),
595
+ b === "guess" && !R && /* @__PURE__ */ d("p", { style: o.gmBodyM, children: [
596
+ " Time left: ",
597
+ N,
598
+ "s"
599
+ ] })
600
+ ]
601
+ }
602
+ ),
603
+ b !== "ready" && /* @__PURE__ */ n(
604
+ "div",
605
+ {
606
+ style: {
607
+ ...o.gmGrid,
608
+ display: "grid",
609
+ gridTemplateColumns: `repeat(${f ? 2 : 3}, 1fr)`,
610
+ gridTemplateRows: `repeat(${f ? 3 : 2}, 1fr)`,
611
+ gap: f ? 12 : 20,
612
+ justifyContent: "center",
613
+ alignContent: "center",
614
+ padding: f ? 8 : 16,
615
+ width: "100%",
616
+ height: "100%",
617
+ maxWidth: f ? "100%" : 600,
618
+ maxHeight: f ? "100%" : 400,
619
+ boxSizing: "border-box"
620
+ },
621
+ children: s.map((e, t) => {
622
+ const a = C === t && b === "guess" && !R;
623
+ return /* @__PURE__ */ n(
624
+ "div",
625
+ {
626
+ style: {
627
+ ...o.gmCard,
628
+ width: "100%",
629
+ height: "100%",
630
+ ...oe === "correct" && C === t ? o.gmCorrect : {},
631
+ ...oe === "wrong" && C === t ? o.gmWrong : {}
632
+ },
633
+ children: !a && /* @__PURE__ */ n(
634
+ "img",
635
+ {
636
+ src: e.src,
637
+ alt: e.name,
638
+ style: {
639
+ width: "100%",
640
+ height: "100%",
641
+ objectFit: "cover",
642
+ display: "block"
643
+ }
623
644
  }
624
- }
625
- )
626
- },
627
- t
628
- );
629
- })
630
- }
631
- ),
632
- /* @__PURE__ */ a("div", { style: { marginTop: 16, height: 80 }, children: [
633
- v === "guess" && !R && /* @__PURE__ */ a("div", { children: [
634
- /* @__PURE__ */ o(
635
- "input",
636
- {
637
- type: "text",
638
- placeholder: "Type the missing word",
639
- value: W,
640
- onChange: (e) => X(e.target.value),
641
- style: n.gmInput
642
- }
643
- ),
644
- /* @__PURE__ */ o(
645
- "button",
646
- {
647
- style: { ...n.gmButton, marginLeft: 8 },
648
- onClick: fe,
649
- disabled: q,
650
- children: q ? "..." : "Check"
651
- }
652
- )
653
- ] }),
654
- R && /* @__PURE__ */ o("button", { type: "button", style: n.gmButton, onClick: pe, children: "Next round" })
645
+ )
646
+ },
647
+ t
648
+ );
649
+ })
650
+ }
651
+ ),
652
+ /* @__PURE__ */ d("div", { style: { marginTop: 16, height: 80 }, children: [
653
+ b === "guess" && !R && /* @__PURE__ */ d("div", { children: [
654
+ /* @__PURE__ */ n(
655
+ "input",
656
+ {
657
+ type: "text",
658
+ placeholder: "Type the missing word",
659
+ value: j,
660
+ onChange: (e) => te(e.target.value),
661
+ style: o.gmInput
662
+ }
663
+ ),
664
+ /* @__PURE__ */ n(
665
+ "button",
666
+ {
667
+ style: { ...o.gmButton, marginLeft: 8 },
668
+ onClick: ye,
669
+ disabled: Y,
670
+ children: Y ? "..." : "Check"
671
+ }
672
+ )
673
+ ] }),
674
+ R && /* @__PURE__ */ n("button", { type: "button", style: o.gmButton, onClick: we, children: "Next round" })
675
+ ] })
655
676
  ] })
656
- ] })
657
- ]
658
- }
659
- )
660
- }
661
- )
662
- }
663
- );
677
+ ]
678
+ }
679
+ )
680
+ }
681
+ )
682
+ }
683
+ ),
684
+ A
685
+ ) });
664
686
  }
665
687
  export {
666
- Be as Game,
667
- de as themes
688
+ Ee as Game,
689
+ me as themes
668
690
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mblinkov/whats-missing",
3
- "version": "20.0.39",
3
+ "version": "20.0.41",
4
4
  "main": "dist/whats-missing.umd.js",
5
5
  "module": "dist/whats-missing.es.js",
6
6
  "types": "dist/index.d.ts",
package/src/Game.tsx CHANGED
@@ -1,4 +1,5 @@
1
1
  import { useState, useEffect, useMemo, useRef, useLayoutEffect } from "react";
2
+ import { createPortal } from "react-dom";
2
3
  import { themes } from "./themes";
3
4
  import { styles } from "./Game.styles";
4
5
  import type { Theme } from "./themes";
@@ -12,15 +13,7 @@ type RoundResult = {
12
13
  result: "correct" | "almost" | "wrong";
13
14
  };
14
15
 
15
- // ✅ базовый reset (ограничен корнем игры)
16
- const globalReset = () => {
17
- const style = document.createElement("style");
18
- style.textContent = `
19
- #whats-missing-root, #whats-missing-root * { box-sizing: border-box; }
20
- #whats-missing-root img { max-width:100%; height:auto; display:block; user-select:none; }
21
- `;
22
- document.head.appendChild(style);
23
- };
16
+ // ✅ globalReset удален - теперь используется Shadow DOM изоляция
24
17
 
25
18
  // ✅ расстояние Левенштейна — для проверки “почти правильно”
26
19
  const levenshtein = (a: string, b: string) => {
@@ -158,28 +151,71 @@ export default function Game({
158
151
  const containerRef = useRef<HTMLDivElement | null>(null);
159
152
  const squareRef = useRef<HTMLDivElement | null>(null);
160
153
  const [squareSize, setSquareSize] = useState<number | null>(null);
154
+ const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null);
161
155
  useNeutralizeBodyZoom(containerRef, { minDesktopWidth: 1024, forceResize: false });
162
156
 
163
- // ✅ полная изоляция игры от внешних стилей сайта
157
+ // ✅ Shadow DOM изоляция - создаем сначала, потом рендерим
164
158
  useLayoutEffect(() => {
165
159
  const container = containerRef.current;
166
160
  if (!container) return;
167
161
 
168
- const s = container.style;
169
- s.position = "fixed";
170
- s.top = "0";
171
- s.left = "0";
172
- s.width = "100vw";
173
- s.height = "100vh";
174
- s.zIndex = "100";
175
- s.background = "linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)";
176
- s.overflow = "hidden";
177
- s.margin = "0";
178
- s.padding = "0";
179
-
180
- // вот этот блок добивает влияние zoom сверху
181
- s.setProperty("transform", "none", "important");
182
- s.setProperty("zoom", "1", "important");
162
+ // Создаем Shadow DOM если его нет
163
+ let root = container.shadowRoot;
164
+ if (!root) {
165
+ root = container.attachShadow({ mode: 'open' });
166
+ }
167
+
168
+ // Очищаем содержимое shadow root
169
+ root.innerHTML = '';
170
+
171
+ // Создаем стили для изоляции
172
+ const style = document.createElement('style');
173
+ style.textContent = `
174
+ :host {
175
+ position: fixed !important;
176
+ top: 0 !important;
177
+ left: 0 !important;
178
+ width: 100vw !important;
179
+ height: 100vh !important;
180
+ z-index: 100 !important;
181
+ background: linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%) !important;
182
+ overflow: hidden !important;
183
+ margin: 0 !important;
184
+ padding: 0 !important;
185
+ transform: none !important;
186
+ zoom: 1 !important;
187
+ scale: 1 !important;
188
+ }
189
+
190
+ #whats-missing-root, #whats-missing-root * {
191
+ box-sizing: border-box !important;
192
+ }
193
+
194
+ #whats-missing-root img {
195
+ max-width: 100% !important;
196
+ height: auto !important;
197
+ display: block !important;
198
+ user-select: none !important;
199
+ }
200
+
201
+ #whats-missing-root {
202
+ position: relative !important;
203
+ width: 100% !important;
204
+ height: 100% !important;
205
+ display: flex !important;
206
+ justify-content: center !important;
207
+ align-items: center !important;
208
+ transform: none !important;
209
+ zoom: 1 !important;
210
+ scale: 1 !important;
211
+ }
212
+ `;
213
+
214
+ // Добавляем стили в shadow root
215
+ root.appendChild(style);
216
+
217
+ // Устанавливаем shadow root для рендера
218
+ setShadowRoot(root);
183
219
  }, []);
184
220
 
185
221
  useEffect(() => {
@@ -223,7 +259,6 @@ export default function Game({
223
259
  }, [gameCubeSize, screenWidth, screenHeight]);
224
260
 
225
261
  useEffect(() => {
226
- globalReset();
227
262
  return () => {
228
263
  document.body.style.overflow = "";
229
264
  };
@@ -426,57 +461,44 @@ export default function Game({
426
461
  }, [screenWidth, screenHeight, isMobile]);
427
462
 
428
463
  return (
429
- <div
430
- ref={containerRef}
431
- style={{
432
- position: "fixed",
433
- inset: 0,
434
- display: "flex",
435
- justifyContent: "center",
436
- alignItems: "center",
437
- background: "linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",
438
- overflow: "hidden",
439
- zIndex: 1,
440
- width: "100vw",
441
- height: "100vh",
442
- transform: "none",
443
- zoom: 1, // ✅ игнорирует масштаб родителя
444
- scale: "1 !important", // ✅ на случай если transform тянется сверху
445
- }}
446
- >
447
- <div
448
- ref={squareRef}
449
- style={{
450
- width: isMobile
451
- ? "100%"
452
- : `${effectiveGameCubeSize}px`,
453
- height: isMobile
454
- ? "100%"
455
- : `${effectiveGameCubeSize}px`,
456
- borderRadius: isMobile ? 0 : "20px",
457
- background: "linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",
458
- position: "relative",
459
- overflow: "hidden",
460
- boxShadow: isMobile ? "none" : "0 0 40px rgba(0,0,0,0.08)",
461
- display: "flex",
462
- justifyContent: "center",
463
- alignItems: "center",
464
- }}
465
- >
464
+ <div ref={containerRef} style={{ width: "100%", height: "100%" }}>
465
+ {shadowRoot && createPortal(
466
466
  <div
467
467
  id="whats-missing-root"
468
- style={{
469
- transform: `scale(${scale})`,
470
- transformOrigin: "center center",
471
- transition: "transform 0.2s ease-out",
472
- width: `${100 / scale}%`,
473
- height: `${100 / scale}%`,
474
- display: "flex",
475
- flexDirection: "column",
476
- justifyContent: "center",
477
- alignItems: "center",
478
- }}
468
+ style={{ all: "unset" }}
479
469
  >
470
+ <div
471
+ ref={squareRef}
472
+ style={{
473
+ width: isMobile
474
+ ? "100%"
475
+ : `${effectiveGameCubeSize}px`,
476
+ height: isMobile
477
+ ? "100%"
478
+ : `${effectiveGameCubeSize}px`,
479
+ borderRadius: isMobile ? 0 : "20px",
480
+ background: "linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",
481
+ position: "relative",
482
+ overflow: "hidden",
483
+ boxShadow: isMobile ? "none" : "0 0 40px rgba(0,0,0,0.08)",
484
+ display: "flex",
485
+ justifyContent: "center",
486
+ alignItems: "center",
487
+ }}
488
+ >
489
+ <div
490
+ style={{
491
+ transform: `scale(${scale})`,
492
+ transformOrigin: "center center",
493
+ transition: "transform 0.2s ease-out",
494
+ width: `${100 / scale}%`,
495
+ height: `${100 / scale}%`,
496
+ display: "flex",
497
+ flexDirection: "column",
498
+ justifyContent: "center",
499
+ alignItems: "center",
500
+ }}
501
+ >
480
502
  {!isMobile && MemoizedLogo}
481
503
 
482
504
  {/* ====== ЛОББИ ====== */}
@@ -675,8 +697,11 @@ export default function Game({
675
697
  </div>
676
698
  </div>
677
699
  )}
678
- </div>
679
- </div>
700
+ </div>
701
+ </div>
702
+ </div>,
703
+ shadowRoot
704
+ )}
680
705
  </div>
681
706
  );
682
707
  }