@mblinkov/whats-missing 20.0.1 → 20.0.3
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.
- package/dist/whats-missing.cjs.js +36 -0
- package/dist/whats-missing.es.js +162 -439
- package/package.json +13 -13
- package/vite.config.ts +3 -2
- package/dist/whats-missing.umd.js +0 -57
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),se=window.origin+"/cloud/speakid/games/whatsmissing/",B=(r,c)=>r.map(([l,s])=>({src:`${se}${c}/${s.replace(/\s/g,"%20")}.png`,name:s})),ne=[["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"]],re=[["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"]],ie=[["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"]],M={food:B(ne,"food"),animals:B(re,"animals"),toys:B(ie,"toys")},le=`
|
|
2
|
+
@keyframes spin {
|
|
3
|
+
from { transform: rotate(0deg); }
|
|
4
|
+
to { transform: rotate(360deg); }
|
|
5
|
+
}
|
|
6
|
+
`;if(typeof document<"u"&&!document.getElementById("spin-keyframes")){const r=document.createElement("style");r.id="spin-keyframes",r.innerHTML=le,document.head.appendChild(r)}const ae={animation:"spin 1.4s linear infinite"},o={gmCenterScreen:{position:"relative",zIndex:1,minHeight:"100vh",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:"600px",minHeight:"100vh",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",color:"#1f2937",padding:"16px 8px",margin:"0 auto"},gmGrid:{width:"100%",maxWidth:"calc(210px * 3 + 20px * 2)",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:"sticky",top:"16px",left:"20px",zIndex:9999,background:"white",padding:"4px 8px",borderRadius:"8px"},gmLogoImg:{height:"clamp(28px, 5vw, 40px)",width:"auto"},gmHourglass:{fontSize:"42px",...ae}},de=window.origin+"/cloud/speakid/games/whatsmissing/logo.png",ce=()=>{const r=document.createElement("style");r.textContent=`
|
|
7
|
+
html, body, #root {
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: 0;
|
|
10
|
+
height: 100%;
|
|
11
|
+
}
|
|
12
|
+
*, *::before, *::after {
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
}
|
|
15
|
+
body {
|
|
16
|
+
font-family: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
|
|
17
|
+
background-color: #fff;
|
|
18
|
+
color: #1f2937;
|
|
19
|
+
}
|
|
20
|
+
button, input {
|
|
21
|
+
font-family: inherit;
|
|
22
|
+
outline: none;
|
|
23
|
+
border: none;
|
|
24
|
+
background: none;
|
|
25
|
+
}
|
|
26
|
+
img {
|
|
27
|
+
max-width: 100%;
|
|
28
|
+
height: auto;
|
|
29
|
+
display: block;
|
|
30
|
+
user-select: none;
|
|
31
|
+
}
|
|
32
|
+
@keyframes spin {
|
|
33
|
+
from { transform: rotate(0deg); }
|
|
34
|
+
to { transform: rotate(360deg); }
|
|
35
|
+
}
|
|
36
|
+
`,document.head.appendChild(r)},me=(r,c)=>{const l=Array.from({length:r.length+1},()=>Array(c.length+1).fill(0));for(let s=0;s<=r.length;s++)l[s][0]=s;for(let s=0;s<=c.length;s++)l[0][s]=s;for(let s=1;s<=r.length;s++)for(let a=1;a<=c.length;a++)l[s][a]=r[s-1]===c[a-1]?l[s-1][a-1]:Math.min(l[s-1][a-1],l[s][a-1],l[s-1][a])+1;return l[r.length][c.length]};function ge(){n.useEffect(()=>{ce()},[]);const[r,c]=n.useState(null),[l,s]=n.useState([]),[a,$]=n.useState(4),[h,L]=n.useState(!1),[f,W]=n.useState(1),[u,K]=n.useState(null),[m,y]=n.useState("ready"),[E,G]=n.useState(3),[k,C]=n.useState(7),[T,F]=n.useState(20),[V,v]=n.useState(0),[b,R]=n.useState(!1),[w,D]=n.useState(""),[p,z]=n.useState(!1),[I,q]=n.useState(!1),[P,x]=n.useState(null),[Z,A]=n.useState([]),[J,U]=n.useState([]),[j,Q]=n.useState(!1);n.useEffect(()=>{const t=()=>Q(window.innerWidth<768);return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]);const Y=t=>[...t].sort(()=>Math.random()-.5).slice(0,6),N=()=>{if(!r)return;const t=Y(M[r]);s(t),L(!0),R(!1),W(1),v(0),A([]),U([]),O(t,[],!0)},O=(t=l,i=J,g=!1)=>{const d=Y(t.length?t:M[r]);let S=Math.floor(Math.random()*d.length),H=d[S].name,_=0;for(;i.includes(H)&&_<20;)S=Math.floor(Math.random()*d.length),H=d[S].name,_++;s(d),K(S),U([...i,H]),z(!1),D(""),F(20),x(null),g?(y("ready"),G(3),C(7)):(y("memorize"),C(7))};n.useEffect(()=>{if(!(!h||b||p)){if(m==="ready")if(E<=0)y("memorize");else{const t=setTimeout(()=>G(i=>i-1),1e3);return()=>clearTimeout(t)}if(m==="memorize")if(k<=0)y("guess");else{const t=setTimeout(()=>C(i=>i-1),1e3);return()=>clearTimeout(t)}if(m==="guess"){if(T<=0){z(!0),x("wrong");const i=l[u].name;A(g=>[...g,{round:f,answer:w,correct:i,result:"wrong"}]);return}const t=setTimeout(()=>F(i=>i-1),1e3);return()=>clearTimeout(t)}}},[m,E,k,T,h,b,p,l,u,f,w]);const X=()=>{if(u===null||I)return;const t=l[u].name,i=w.toLowerCase().trim();let g="wrong";i===t?(v(d=>d+1),x("correct"),g="correct"):me(i,t)===1?(v(d=>d+.5),x("almost"),g="almost"):(x("wrong"),g="wrong"),A(d=>[...d,{round:f,answer:i,correct:t,result:g}]),q(!0),setTimeout(()=>{q(!1),z(!0)},600)},ee=()=>f<a?(W(t=>t+1),O()):R(!0),te=()=>{L(!1),R(!1),c(null)},oe=()=>e.jsx("div",{style:o.gmLogoFixed,children:e.jsx("img",{src:de,alt:"SPEAKID Logo",style:o.gmLogoImg})});return e.jsxs(e.Fragment,{children:[!j&&e.jsx(oe,{}),!r&&!h&&e.jsxs("div",{style:o.gmCenterScreen,children:[e.jsx("h1",{style:o.gmHeadline1,children:"WHAT'S MISSING?"}),e.jsx("p",{style:o.gmBodyM,children:"Select a theme:"}),e.jsx("div",{style:{display:"flex",gap:16},children:["animals","food","toys"].map(t=>e.jsx("button",{style:o.gmButton,onClick:()=>c(t),children:t==="animals"?"🐶 Animals":t==="food"?"🍎 Food":"🧸 Toys"},t))}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx("p",{style:o.gmBodyS,children:"Choose number of rounds:"}),e.jsx("div",{style:{display:"flex",gap:12,marginTop:8},children:[3,4,5].map(t=>e.jsx("button",{style:{...o.gmButton,...a===t?o.gmButtonActive:{}},onClick:()=>$(t),children:t},t))})]})]}),r&&!h&&e.jsxs("div",{style:o.gmCenterScreen,children:[e.jsxs("h1",{style:o.gmHeadline1,children:["Theme selected: ",r]}),e.jsxs("p",{style:o.gmBodyM,children:["Rounds: ",a]}),e.jsx("button",{style:o.gmButton,onClick:N,children:"▶ Start game"})]}),b&&e.jsxs("div",{style:o.gmCenterScreen,children:[e.jsx("h1",{style:o.gmHeadline1,children:"Results"}),e.jsxs("h2",{style:o.gmHeadline3,children:["Your score: ",V," / ",a]}),e.jsxs("table",{style:o.gmTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Round"}),e.jsx("th",{children:"Your Answer"}),e.jsx("th",{children:"Correct"}),e.jsx("th",{children:"Result"})]})}),e.jsx("tbody",{children:Z.map((t,i)=>e.jsxs("tr",{children:[e.jsx("td",{style:o.gmTableCell,children:t.round}),e.jsx("td",{style:o.gmTableCell,children:t.answer||"—"}),e.jsx("td",{style:o.gmTableCell,children:t.correct}),e.jsx("td",{style:o.gmTableCell,children:t.result==="correct"?"✔ Correct":t.result==="almost"?"◐ Almost (0.5)":"✘ Wrong"})]},i))})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:24},children:[e.jsx("button",{style:o.gmButton,onClick:N,children:"🔁 Play again"}),e.jsx("button",{style:o.gmButton,onClick:te,children:"⬅️ Choose theme"})]})]}),h&&!b&&e.jsxs("div",{style:o.gmGameLayout,children:[e.jsxs("div",{style:{minHeight:160,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[m==="ready"&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{style:{...o.gmHeadline1,color:"#ec4c44"},children:"GET READY"}),e.jsx("div",{style:o.gmHourglass,children:"⏳"})]}),m==="memorize"&&e.jsxs("p",{style:{...o.gmBodyM,color:"#10b981"},children:["MEMORIZE (",k,")"]}),m==="guess"&&!p&&e.jsxs("p",{style:o.gmBodyM,children:["⏳ Time left: ",T,"s"]})]}),m!=="ready"&&e.jsx("div",{style:{...o.gmGrid,gridTemplateColumns:j?"repeat(2, 1fr)":"repeat(3, 210px)",gridAutoRows:j?"150px":"210px",gap:j?"12px":"20px",justifyItems:"center",...window.innerWidth>2e3?{gridTemplateColumns:"repeat(3, 260px)",gridAutoRows:"260px",gap:"28px"}:{},...window.innerWidth>2560?{gridTemplateColumns:"repeat(3, 300px)",gridAutoRows:"300px",gap:"32px"}:{}},children:l.map((t,i)=>{const g=u===i&&m==="guess"&&!p;return e.jsx("div",{style:{...o.gmCard,...P==="correct"&&u===i?o.gmCorrect:{},...P==="wrong"&&u===i?o.gmWrong:{}},children:!g&&e.jsx("img",{src:t.src,alt:t.name,style:{width:"100%",height:"100%",objectFit:"cover"}})},i)})}),e.jsxs("div",{style:{marginTop:16,height:80},children:[m==="guess"&&!p&&e.jsxs("div",{children:[e.jsx("input",{type:"text",placeholder:"Type the missing word",value:w,onChange:t=>D(t.target.value),style:o.gmInput}),e.jsx("button",{style:{...o.gmButton,marginLeft:8},onClick:X,disabled:I,children:I?"...":"Check"})]}),p&&e.jsx("button",{style:o.gmButton,onClick:ee,children:"Next round"})]})]})]})}exports.Game=ge;exports.themes=M;
|
package/dist/whats-missing.es.js
CHANGED
|
@@ -1,286 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the MIT license found in the
|
|
10
|
-
* LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/
|
|
12
|
-
var ae;
|
|
13
|
-
function ue() {
|
|
14
|
-
if (ae) return D;
|
|
15
|
-
ae = 1;
|
|
16
|
-
var a = Symbol.for("react.transitional.element"), p = Symbol.for("react.fragment");
|
|
17
|
-
function u(s, i, h) {
|
|
18
|
-
var x = null;
|
|
19
|
-
if (h !== void 0 && (x = "" + h), i.key !== void 0 && (x = "" + i.key), "key" in i) {
|
|
20
|
-
h = {};
|
|
21
|
-
for (var v in i)
|
|
22
|
-
v !== "key" && (h[v] = i[v]);
|
|
23
|
-
} else h = i;
|
|
24
|
-
return i = h.ref, {
|
|
25
|
-
$$typeof: a,
|
|
26
|
-
type: s,
|
|
27
|
-
key: x,
|
|
28
|
-
ref: i !== void 0 ? i : null,
|
|
29
|
-
props: h
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return D.Fragment = p, D.jsx = u, D.jsxs = u, D;
|
|
33
|
-
}
|
|
34
|
-
var G = {};
|
|
35
|
-
/**
|
|
36
|
-
* @license React
|
|
37
|
-
* react-jsx-runtime.development.js
|
|
38
|
-
*
|
|
39
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
40
|
-
*
|
|
41
|
-
* This source code is licensed under the MIT license found in the
|
|
42
|
-
* LICENSE file in the root directory of this source tree.
|
|
43
|
-
*/
|
|
44
|
-
var ie;
|
|
45
|
-
function me() {
|
|
46
|
-
return ie || (ie = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
47
|
-
function a(e) {
|
|
48
|
-
if (e == null) return null;
|
|
49
|
-
if (typeof e == "function")
|
|
50
|
-
return e.$$typeof === H ? null : e.displayName || e.name || null;
|
|
51
|
-
if (typeof e == "string") return e;
|
|
52
|
-
switch (e) {
|
|
53
|
-
case E:
|
|
54
|
-
return "Fragment";
|
|
55
|
-
case L:
|
|
56
|
-
return "Profiler";
|
|
57
|
-
case M:
|
|
58
|
-
return "StrictMode";
|
|
59
|
-
case A:
|
|
60
|
-
return "Suspense";
|
|
61
|
-
case F:
|
|
62
|
-
return "SuspenseList";
|
|
63
|
-
case R:
|
|
64
|
-
return "Activity";
|
|
65
|
-
}
|
|
66
|
-
if (typeof e == "object")
|
|
67
|
-
switch (typeof e.tag == "number" && console.error(
|
|
68
|
-
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
|
-
), e.$$typeof) {
|
|
70
|
-
case V:
|
|
71
|
-
return "Portal";
|
|
72
|
-
case te:
|
|
73
|
-
return e.displayName || "Context";
|
|
74
|
-
case J:
|
|
75
|
-
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
|
-
case W:
|
|
77
|
-
var n = e.render;
|
|
78
|
-
return e = e.displayName, e || (e = n.displayName || n.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
|
-
case O:
|
|
80
|
-
return n = e.displayName || null, n !== null ? n : a(e.type) || "Memo";
|
|
81
|
-
case P:
|
|
82
|
-
n = e._payload, e = e._init;
|
|
83
|
-
try {
|
|
84
|
-
return a(e(n));
|
|
85
|
-
} catch {
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
function p(e) {
|
|
91
|
-
return "" + e;
|
|
92
|
-
}
|
|
93
|
-
function u(e) {
|
|
94
|
-
try {
|
|
95
|
-
p(e);
|
|
96
|
-
var n = !1;
|
|
97
|
-
} catch {
|
|
98
|
-
n = !0;
|
|
99
|
-
}
|
|
100
|
-
if (n) {
|
|
101
|
-
n = console;
|
|
102
|
-
var l = n.error, d = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
103
|
-
return l.call(
|
|
104
|
-
n,
|
|
105
|
-
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
-
d
|
|
107
|
-
), p(e);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function s(e) {
|
|
111
|
-
if (e === E) return "<>";
|
|
112
|
-
if (typeof e == "object" && e !== null && e.$$typeof === P)
|
|
113
|
-
return "<...>";
|
|
114
|
-
try {
|
|
115
|
-
var n = a(e);
|
|
116
|
-
return n ? "<" + n + ">" : "<...>";
|
|
117
|
-
} catch {
|
|
118
|
-
return "<...>";
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function i() {
|
|
122
|
-
var e = _.A;
|
|
123
|
-
return e === null ? null : e.getOwner();
|
|
124
|
-
}
|
|
125
|
-
function h() {
|
|
126
|
-
return Error("react-stack-top-frame");
|
|
127
|
-
}
|
|
128
|
-
function x(e) {
|
|
129
|
-
if (Y.call(e, "key")) {
|
|
130
|
-
var n = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
131
|
-
if (n && n.isReactWarning) return !1;
|
|
132
|
-
}
|
|
133
|
-
return e.key !== void 0;
|
|
134
|
-
}
|
|
135
|
-
function v(e, n) {
|
|
136
|
-
function l() {
|
|
137
|
-
Z || (Z = !0, console.error(
|
|
138
|
-
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
139
|
-
n
|
|
140
|
-
));
|
|
141
|
-
}
|
|
142
|
-
l.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
143
|
-
get: l,
|
|
144
|
-
configurable: !0
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
function C() {
|
|
148
|
-
var e = a(this.type);
|
|
149
|
-
return I[e] || (I[e] = !0, console.error(
|
|
150
|
-
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
|
-
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
152
|
-
}
|
|
153
|
-
function U(e, n, l, d, z, $) {
|
|
154
|
-
var m = l.ref;
|
|
155
|
-
return e = {
|
|
156
|
-
$$typeof: N,
|
|
157
|
-
type: e,
|
|
158
|
-
key: n,
|
|
159
|
-
props: l,
|
|
160
|
-
_owner: d
|
|
161
|
-
}, (m !== void 0 ? m : null) !== null ? Object.defineProperty(e, "ref", {
|
|
162
|
-
enumerable: !1,
|
|
163
|
-
get: C
|
|
164
|
-
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
165
|
-
configurable: !1,
|
|
166
|
-
enumerable: !1,
|
|
167
|
-
writable: !0,
|
|
168
|
-
value: 0
|
|
169
|
-
}), Object.defineProperty(e, "_debugInfo", {
|
|
170
|
-
configurable: !1,
|
|
171
|
-
enumerable: !1,
|
|
172
|
-
writable: !0,
|
|
173
|
-
value: null
|
|
174
|
-
}), Object.defineProperty(e, "_debugStack", {
|
|
175
|
-
configurable: !1,
|
|
176
|
-
enumerable: !1,
|
|
177
|
-
writable: !0,
|
|
178
|
-
value: z
|
|
179
|
-
}), Object.defineProperty(e, "_debugTask", {
|
|
180
|
-
configurable: !1,
|
|
181
|
-
enumerable: !1,
|
|
182
|
-
writable: !0,
|
|
183
|
-
value: $
|
|
184
|
-
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
185
|
-
}
|
|
186
|
-
function y(e, n, l, d, z, $) {
|
|
187
|
-
var m = n.children;
|
|
188
|
-
if (m !== void 0)
|
|
189
|
-
if (d)
|
|
190
|
-
if (X(m)) {
|
|
191
|
-
for (d = 0; d < m.length; d++)
|
|
192
|
-
q(m[d]);
|
|
193
|
-
Object.freeze && Object.freeze(m);
|
|
194
|
-
} else
|
|
195
|
-
console.error(
|
|
196
|
-
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
197
|
-
);
|
|
198
|
-
else q(m);
|
|
199
|
-
if (Y.call(n, "key")) {
|
|
200
|
-
m = a(e);
|
|
201
|
-
var k = Object.keys(n).filter(function(c) {
|
|
202
|
-
return c !== "key";
|
|
203
|
-
});
|
|
204
|
-
d = 0 < k.length ? "{key: someKey, " + k.join(": ..., ") + ": ...}" : "{key: someKey}", S[m + d] || (k = 0 < k.length ? "{" + k.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
205
|
-
`A props object containing a "key" prop is being spread into JSX:
|
|
206
|
-
let props = %s;
|
|
207
|
-
<%s {...props} />
|
|
208
|
-
React keys must be passed directly to JSX without using spread:
|
|
209
|
-
let props = %s;
|
|
210
|
-
<%s key={someKey} {...props} />`,
|
|
211
|
-
d,
|
|
212
|
-
m,
|
|
213
|
-
k,
|
|
214
|
-
m
|
|
215
|
-
), S[m + d] = !0);
|
|
216
|
-
}
|
|
217
|
-
if (m = null, l !== void 0 && (u(l), m = "" + l), x(n) && (u(n.key), m = "" + n.key), "key" in n) {
|
|
218
|
-
l = {};
|
|
219
|
-
for (var r in n)
|
|
220
|
-
r !== "key" && (l[r] = n[r]);
|
|
221
|
-
} else l = n;
|
|
222
|
-
return m && v(
|
|
223
|
-
l,
|
|
224
|
-
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
225
|
-
), U(
|
|
226
|
-
e,
|
|
227
|
-
m,
|
|
228
|
-
l,
|
|
229
|
-
i(),
|
|
230
|
-
z,
|
|
231
|
-
$
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
function q(e) {
|
|
235
|
-
g(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === P && (e._payload.status === "fulfilled" ? g(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
236
|
-
}
|
|
237
|
-
function g(e) {
|
|
238
|
-
return typeof e == "object" && e !== null && e.$$typeof === N;
|
|
239
|
-
}
|
|
240
|
-
var T = de, N = Symbol.for("react.transitional.element"), V = Symbol.for("react.portal"), E = Symbol.for("react.fragment"), M = Symbol.for("react.strict_mode"), L = Symbol.for("react.profiler"), J = Symbol.for("react.consumer"), te = Symbol.for("react.context"), W = Symbol.for("react.forward_ref"), A = Symbol.for("react.suspense"), F = Symbol.for("react.suspense_list"), O = Symbol.for("react.memo"), P = Symbol.for("react.lazy"), R = Symbol.for("react.activity"), H = Symbol.for("react.client.reference"), _ = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Y = Object.prototype.hasOwnProperty, X = Array.isArray, j = console.createTask ? console.createTask : function() {
|
|
241
|
-
return null;
|
|
242
|
-
};
|
|
243
|
-
T = {
|
|
244
|
-
react_stack_bottom_frame: function(e) {
|
|
245
|
-
return e();
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
var Z, I = {}, Q = T.react_stack_bottom_frame.bind(
|
|
249
|
-
T,
|
|
250
|
-
h
|
|
251
|
-
)(), B = j(s(h)), S = {};
|
|
252
|
-
G.Fragment = E, G.jsx = function(e, n, l) {
|
|
253
|
-
var d = 1e4 > _.recentlyCreatedOwnerStacks++;
|
|
254
|
-
return y(
|
|
255
|
-
e,
|
|
256
|
-
n,
|
|
257
|
-
l,
|
|
258
|
-
!1,
|
|
259
|
-
d ? Error("react-stack-top-frame") : Q,
|
|
260
|
-
d ? j(s(e)) : B
|
|
261
|
-
);
|
|
262
|
-
}, G.jsxs = function(e, n, l) {
|
|
263
|
-
var d = 1e4 > _.recentlyCreatedOwnerStacks++;
|
|
264
|
-
return y(
|
|
265
|
-
e,
|
|
266
|
-
n,
|
|
267
|
-
l,
|
|
268
|
-
!0,
|
|
269
|
-
d ? Error("react-stack-top-frame") : Q,
|
|
270
|
-
d ? j(s(e)) : B
|
|
271
|
-
);
|
|
272
|
-
};
|
|
273
|
-
})()), G;
|
|
274
|
-
}
|
|
275
|
-
var le;
|
|
276
|
-
function fe() {
|
|
277
|
-
return le || (le = 1, process.env.NODE_ENV === "production" ? ee.exports = ue() : ee.exports = me()), ee.exports;
|
|
278
|
-
}
|
|
279
|
-
var t = fe();
|
|
280
|
-
const pe = window.origin + "/cloud/speakid/games/whatsmissing/", oe = (a, p) => a.map(([u, s]) => ({
|
|
281
|
-
src: `${pe}${p}/${s.replace(/\s/g, "%20")}.png`,
|
|
282
|
-
name: s
|
|
283
|
-
})), ge = [
|
|
1
|
+
import { jsxs as s, Fragment as O, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as M, useState as l } from "react";
|
|
3
|
+
const ie = window.origin + "/cloud/speakid/games/whatsmissing/", W = (r, m) => r.map(([a, n]) => ({
|
|
4
|
+
src: `${ie}${m}/${n.replace(/\s/g, "%20")}.png`,
|
|
5
|
+
name: n
|
|
6
|
+
})), se = [
|
|
284
7
|
["apple", "apple"],
|
|
285
8
|
["banana", "banana"],
|
|
286
9
|
["bread", "bread"],
|
|
@@ -306,7 +29,7 @@ const pe = window.origin + "/cloud/speakid/games/whatsmissing/", oe = (a, p) =>
|
|
|
306
29
|
["strawberry", "strawberry"],
|
|
307
30
|
["tomato", "tomato"],
|
|
308
31
|
["watermelon", "watermelon"]
|
|
309
|
-
],
|
|
32
|
+
], le = [
|
|
310
33
|
["bear", "bear"],
|
|
311
34
|
["cat", "cat"],
|
|
312
35
|
["crocodile", "crocodile"],
|
|
@@ -326,7 +49,7 @@ const pe = window.origin + "/cloud/speakid/games/whatsmissing/", oe = (a, p) =>
|
|
|
326
49
|
["tortoise", "tortoise"],
|
|
327
50
|
["wolf", "wolf"],
|
|
328
51
|
["zebra", "zebra"]
|
|
329
|
-
],
|
|
52
|
+
], ae = [
|
|
330
53
|
["ball", "ball"],
|
|
331
54
|
["balloon", "balloon"],
|
|
332
55
|
["blocks", "blocks"],
|
|
@@ -346,23 +69,23 @@ const pe = window.origin + "/cloud/speakid/games/whatsmissing/", oe = (a, p) =>
|
|
|
346
69
|
["teddy_bear", "teddy bear"],
|
|
347
70
|
["yo-yo", "yo-yo"],
|
|
348
71
|
["crayons", "crayons"]
|
|
349
|
-
],
|
|
350
|
-
food:
|
|
351
|
-
animals:
|
|
352
|
-
toys:
|
|
353
|
-
},
|
|
72
|
+
], V = {
|
|
73
|
+
food: W(se, "food"),
|
|
74
|
+
animals: W(le, "animals"),
|
|
75
|
+
toys: W(ae, "toys")
|
|
76
|
+
}, de = `
|
|
354
77
|
@keyframes spin {
|
|
355
78
|
from { transform: rotate(0deg); }
|
|
356
79
|
to { transform: rotate(360deg); }
|
|
357
80
|
}
|
|
358
81
|
`;
|
|
359
82
|
if (typeof document < "u" && !document.getElementById("spin-keyframes")) {
|
|
360
|
-
const
|
|
361
|
-
|
|
83
|
+
const r = document.createElement("style");
|
|
84
|
+
r.id = "spin-keyframes", r.innerHTML = de, document.head.appendChild(r);
|
|
362
85
|
}
|
|
363
|
-
const
|
|
86
|
+
const ce = {
|
|
364
87
|
animation: "spin 1.4s linear infinite"
|
|
365
|
-
},
|
|
88
|
+
}, t = {
|
|
366
89
|
gmCenterScreen: {
|
|
367
90
|
position: "relative",
|
|
368
91
|
zIndex: 1,
|
|
@@ -502,11 +225,11 @@ const ye = {
|
|
|
502
225
|
},
|
|
503
226
|
gmHourglass: {
|
|
504
227
|
fontSize: "42px",
|
|
505
|
-
...
|
|
228
|
+
...ce
|
|
506
229
|
}
|
|
507
|
-
},
|
|
508
|
-
const
|
|
509
|
-
|
|
230
|
+
}, me = window.origin + "/cloud/speakid/games/whatsmissing/logo.png", ge = () => {
|
|
231
|
+
const r = document.createElement("style");
|
|
232
|
+
r.textContent = `
|
|
510
233
|
html, body, #root {
|
|
511
234
|
margin: 0;
|
|
512
235
|
padding: 0;
|
|
@@ -536,154 +259,154 @@ const ye = {
|
|
|
536
259
|
from { transform: rotate(0deg); }
|
|
537
260
|
to { transform: rotate(360deg); }
|
|
538
261
|
}
|
|
539
|
-
`, document.head.appendChild(
|
|
540
|
-
},
|
|
541
|
-
const
|
|
542
|
-
for (let
|
|
543
|
-
for (let
|
|
544
|
-
for (let
|
|
545
|
-
for (let
|
|
546
|
-
|
|
547
|
-
return
|
|
262
|
+
`, document.head.appendChild(r);
|
|
263
|
+
}, pe = (r, m) => {
|
|
264
|
+
const a = Array.from({ length: r.length + 1 }, () => Array(m.length + 1).fill(0));
|
|
265
|
+
for (let n = 0; n <= r.length; n++) a[n][0] = n;
|
|
266
|
+
for (let n = 0; n <= m.length; n++) a[0][n] = n;
|
|
267
|
+
for (let n = 1; n <= r.length; n++)
|
|
268
|
+
for (let d = 1; d <= m.length; d++)
|
|
269
|
+
a[n][d] = r[n - 1] === m[d - 1] ? a[n - 1][d - 1] : Math.min(a[n - 1][d - 1], a[n][d - 1], a[n - 1][d]) + 1;
|
|
270
|
+
return a[r.length][m.length];
|
|
548
271
|
};
|
|
549
|
-
function
|
|
550
|
-
|
|
551
|
-
|
|
272
|
+
function ye() {
|
|
273
|
+
M(() => {
|
|
274
|
+
ge();
|
|
552
275
|
}, []);
|
|
553
|
-
const [
|
|
554
|
-
|
|
555
|
-
const
|
|
556
|
-
return
|
|
276
|
+
const [r, m] = l(null), [a, n] = l([]), [d, Z] = l(4), [f, j] = l(!1), [x, G] = l(1), [u, J] = l(null), [g, b] = l("ready"), [E, F] = l(3), [v, S] = l(7), [z, D] = l(20), [Q, R] = l(0), [w, I] = l(!1), [k, U] = l(""), [h, A] = l(!1), [H, Y] = l(!1), [N, y] = l(null), [X, B] = l([]), [ee, P] = l([]), [C, te] = l(!1);
|
|
277
|
+
M(() => {
|
|
278
|
+
const e = () => te(window.innerWidth < 768);
|
|
279
|
+
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
557
280
|
}, []);
|
|
558
|
-
const
|
|
559
|
-
if (!
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
},
|
|
563
|
-
const
|
|
564
|
-
let
|
|
565
|
-
for (;
|
|
566
|
-
|
|
567
|
-
|
|
281
|
+
const _ = (e) => [...e].sort(() => Math.random() - 0.5).slice(0, 6), $ = () => {
|
|
282
|
+
if (!r) return;
|
|
283
|
+
const e = _(V[r]);
|
|
284
|
+
n(e), j(!0), I(!1), G(1), R(0), B([]), P([]), q(e, [], !0);
|
|
285
|
+
}, q = (e = a, i = ee, p = !1) => {
|
|
286
|
+
const c = _(e.length ? e : V[r]);
|
|
287
|
+
let T = Math.floor(Math.random() * c.length), L = c[T].name, K = 0;
|
|
288
|
+
for (; i.includes(L) && K < 20; )
|
|
289
|
+
T = Math.floor(Math.random() * c.length), L = c[T].name, K++;
|
|
290
|
+
n(c), J(T), P([...i, L]), A(!1), U(""), D(20), y(null), p ? (b("ready"), F(3), S(7)) : (b("memorize"), S(7));
|
|
568
291
|
};
|
|
569
|
-
|
|
570
|
-
if (!(!
|
|
292
|
+
M(() => {
|
|
293
|
+
if (!(!f || w || h)) {
|
|
571
294
|
if (g === "ready")
|
|
572
|
-
if (
|
|
573
|
-
|
|
295
|
+
if (E <= 0)
|
|
296
|
+
b("memorize");
|
|
574
297
|
else {
|
|
575
|
-
const
|
|
576
|
-
return () => clearTimeout(
|
|
298
|
+
const e = setTimeout(() => F((i) => i - 1), 1e3);
|
|
299
|
+
return () => clearTimeout(e);
|
|
577
300
|
}
|
|
578
301
|
if (g === "memorize")
|
|
579
|
-
if (
|
|
580
|
-
|
|
302
|
+
if (v <= 0)
|
|
303
|
+
b("guess");
|
|
581
304
|
else {
|
|
582
|
-
const
|
|
583
|
-
return () => clearTimeout(
|
|
305
|
+
const e = setTimeout(() => S((i) => i - 1), 1e3);
|
|
306
|
+
return () => clearTimeout(e);
|
|
584
307
|
}
|
|
585
308
|
if (g === "guess") {
|
|
586
|
-
if (
|
|
587
|
-
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
...
|
|
591
|
-
{ round:
|
|
309
|
+
if (z <= 0) {
|
|
310
|
+
A(!0), y("wrong");
|
|
311
|
+
const i = a[u].name;
|
|
312
|
+
B((p) => [
|
|
313
|
+
...p,
|
|
314
|
+
{ round: x, answer: k, correct: i, result: "wrong" }
|
|
592
315
|
]);
|
|
593
316
|
return;
|
|
594
317
|
}
|
|
595
|
-
const
|
|
596
|
-
return () => clearTimeout(
|
|
318
|
+
const e = setTimeout(() => D((i) => i - 1), 1e3);
|
|
319
|
+
return () => clearTimeout(e);
|
|
597
320
|
}
|
|
598
321
|
}
|
|
599
322
|
}, [
|
|
600
323
|
g,
|
|
601
|
-
N,
|
|
602
324
|
E,
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
325
|
+
v,
|
|
326
|
+
z,
|
|
327
|
+
f,
|
|
328
|
+
w,
|
|
329
|
+
h,
|
|
330
|
+
a,
|
|
607
331
|
u,
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
O
|
|
332
|
+
x,
|
|
333
|
+
k
|
|
611
334
|
]);
|
|
612
|
-
const
|
|
613
|
-
if (
|
|
614
|
-
const
|
|
615
|
-
let
|
|
616
|
-
|
|
617
|
-
...
|
|
618
|
-
{ round:
|
|
335
|
+
const oe = () => {
|
|
336
|
+
if (u === null || H) return;
|
|
337
|
+
const e = a[u].name, i = k.toLowerCase().trim();
|
|
338
|
+
let p = "wrong";
|
|
339
|
+
i === e ? (R((c) => c + 1), y("correct"), p = "correct") : pe(i, e) === 1 ? (R((c) => c + 0.5), y("almost"), p = "almost") : (y("wrong"), p = "wrong"), B((c) => [
|
|
340
|
+
...c,
|
|
341
|
+
{ round: x, answer: i, correct: e, result: p }
|
|
619
342
|
]), Y(!0), setTimeout(() => {
|
|
620
|
-
Y(!1),
|
|
343
|
+
Y(!1), A(!0);
|
|
621
344
|
}, 600);
|
|
622
|
-
},
|
|
623
|
-
|
|
624
|
-
}
|
|
625
|
-
return /* @__PURE__ */
|
|
626
|
-
!
|
|
627
|
-
!
|
|
628
|
-
/* @__PURE__ */
|
|
629
|
-
/* @__PURE__ */
|
|
630
|
-
/* @__PURE__ */
|
|
631
|
-
/* @__PURE__ */
|
|
632
|
-
/* @__PURE__ */
|
|
633
|
-
/* @__PURE__ */
|
|
345
|
+
}, ne = () => x < d ? (G((e) => e + 1), q()) : I(!0), re = () => {
|
|
346
|
+
j(!1), I(!1), m(null);
|
|
347
|
+
};
|
|
348
|
+
return /* @__PURE__ */ s(O, { children: [
|
|
349
|
+
!C && /* @__PURE__ */ o(() => /* @__PURE__ */ o("div", { style: t.gmLogoFixed, children: /* @__PURE__ */ o("img", { src: me, alt: "SPEAKID Logo", style: t.gmLogoImg }) }), {}),
|
|
350
|
+
!r && !f && /* @__PURE__ */ s("div", { style: t.gmCenterScreen, children: [
|
|
351
|
+
/* @__PURE__ */ o("h1", { style: t.gmHeadline1, children: "WHAT'S MISSING?" }),
|
|
352
|
+
/* @__PURE__ */ o("p", { style: t.gmBodyM, children: "Select a theme:" }),
|
|
353
|
+
/* @__PURE__ */ o("div", { style: { display: "flex", gap: 16 }, children: ["animals", "food", "toys"].map((e) => /* @__PURE__ */ o("button", { style: t.gmButton, onClick: () => m(e), children: e === "animals" ? "🐶 Animals" : e === "food" ? "🍎 Food" : "🧸 Toys" }, e)) }),
|
|
354
|
+
/* @__PURE__ */ s("div", { style: { marginTop: 24 }, children: [
|
|
355
|
+
/* @__PURE__ */ o("p", { style: t.gmBodyS, children: "Choose number of rounds:" }),
|
|
356
|
+
/* @__PURE__ */ o("div", { style: { display: "flex", gap: 12, marginTop: 8 }, children: [3, 4, 5].map((e) => /* @__PURE__ */ o(
|
|
634
357
|
"button",
|
|
635
358
|
{
|
|
636
359
|
style: {
|
|
637
|
-
...
|
|
638
|
-
...
|
|
360
|
+
...t.gmButton,
|
|
361
|
+
...d === e ? t.gmButtonActive : {}
|
|
639
362
|
},
|
|
640
|
-
onClick: () =>
|
|
641
|
-
children:
|
|
363
|
+
onClick: () => Z(e),
|
|
364
|
+
children: e
|
|
642
365
|
},
|
|
643
|
-
|
|
366
|
+
e
|
|
644
367
|
)) })
|
|
645
368
|
] })
|
|
646
369
|
] }),
|
|
647
|
-
|
|
648
|
-
/* @__PURE__ */
|
|
370
|
+
r && !f && /* @__PURE__ */ s("div", { style: t.gmCenterScreen, children: [
|
|
371
|
+
/* @__PURE__ */ s("h1", { style: t.gmHeadline1, children: [
|
|
649
372
|
"Theme selected: ",
|
|
650
|
-
|
|
373
|
+
r
|
|
651
374
|
] }),
|
|
652
|
-
/* @__PURE__ */
|
|
375
|
+
/* @__PURE__ */ s("p", { style: t.gmBodyM, children: [
|
|
653
376
|
"Rounds: ",
|
|
654
|
-
|
|
377
|
+
d
|
|
655
378
|
] }),
|
|
656
|
-
/* @__PURE__ */
|
|
379
|
+
/* @__PURE__ */ o("button", { style: t.gmButton, onClick: $, children: "▶ Start game" })
|
|
657
380
|
] }),
|
|
658
|
-
|
|
659
|
-
/* @__PURE__ */
|
|
660
|
-
/* @__PURE__ */
|
|
381
|
+
w && /* @__PURE__ */ s("div", { style: t.gmCenterScreen, children: [
|
|
382
|
+
/* @__PURE__ */ o("h1", { style: t.gmHeadline1, children: "Results" }),
|
|
383
|
+
/* @__PURE__ */ s("h2", { style: t.gmHeadline3, children: [
|
|
661
384
|
"Your score: ",
|
|
662
|
-
|
|
385
|
+
Q,
|
|
663
386
|
" / ",
|
|
664
|
-
|
|
387
|
+
d
|
|
665
388
|
] }),
|
|
666
|
-
/* @__PURE__ */
|
|
667
|
-
/* @__PURE__ */
|
|
668
|
-
/* @__PURE__ */
|
|
669
|
-
/* @__PURE__ */
|
|
670
|
-
/* @__PURE__ */
|
|
671
|
-
/* @__PURE__ */
|
|
389
|
+
/* @__PURE__ */ s("table", { style: t.gmTable, children: [
|
|
390
|
+
/* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [
|
|
391
|
+
/* @__PURE__ */ o("th", { children: "Round" }),
|
|
392
|
+
/* @__PURE__ */ o("th", { children: "Your Answer" }),
|
|
393
|
+
/* @__PURE__ */ o("th", { children: "Correct" }),
|
|
394
|
+
/* @__PURE__ */ o("th", { children: "Result" })
|
|
672
395
|
] }) }),
|
|
673
|
-
/* @__PURE__ */
|
|
674
|
-
/* @__PURE__ */
|
|
675
|
-
/* @__PURE__ */
|
|
676
|
-
/* @__PURE__ */
|
|
677
|
-
/* @__PURE__ */
|
|
678
|
-
] },
|
|
396
|
+
/* @__PURE__ */ o("tbody", { children: X.map((e, i) => /* @__PURE__ */ s("tr", { children: [
|
|
397
|
+
/* @__PURE__ */ o("td", { style: t.gmTableCell, children: e.round }),
|
|
398
|
+
/* @__PURE__ */ o("td", { style: t.gmTableCell, children: e.answer || "—" }),
|
|
399
|
+
/* @__PURE__ */ o("td", { style: t.gmTableCell, children: e.correct }),
|
|
400
|
+
/* @__PURE__ */ o("td", { style: t.gmTableCell, children: e.result === "correct" ? "✔ Correct" : e.result === "almost" ? "◐ Almost (0.5)" : "✘ Wrong" })
|
|
401
|
+
] }, i)) })
|
|
679
402
|
] }),
|
|
680
|
-
/* @__PURE__ */
|
|
681
|
-
/* @__PURE__ */
|
|
682
|
-
/* @__PURE__ */
|
|
403
|
+
/* @__PURE__ */ s("div", { style: { display: "flex", gap: 12, marginTop: 24 }, children: [
|
|
404
|
+
/* @__PURE__ */ o("button", { style: t.gmButton, onClick: $, children: "🔁 Play again" }),
|
|
405
|
+
/* @__PURE__ */ o("button", { style: t.gmButton, onClick: re, children: "⬅️ Choose theme" })
|
|
683
406
|
] })
|
|
684
407
|
] }),
|
|
685
|
-
|
|
686
|
-
/* @__PURE__ */
|
|
408
|
+
f && !w && /* @__PURE__ */ s("div", { style: t.gmGameLayout, children: [
|
|
409
|
+
/* @__PURE__ */ s(
|
|
687
410
|
"div",
|
|
688
411
|
{
|
|
689
412
|
style: {
|
|
@@ -694,31 +417,31 @@ function Re() {
|
|
|
694
417
|
alignItems: "center"
|
|
695
418
|
},
|
|
696
419
|
children: [
|
|
697
|
-
g === "ready" && /* @__PURE__ */
|
|
698
|
-
/* @__PURE__ */
|
|
699
|
-
/* @__PURE__ */
|
|
420
|
+
g === "ready" && /* @__PURE__ */ s(O, { children: [
|
|
421
|
+
/* @__PURE__ */ o("h1", { style: { ...t.gmHeadline1, color: "#ec4c44" }, children: "GET READY" }),
|
|
422
|
+
/* @__PURE__ */ o("div", { style: t.gmHourglass, children: "⏳" })
|
|
700
423
|
] }),
|
|
701
|
-
g === "memorize" && /* @__PURE__ */
|
|
424
|
+
g === "memorize" && /* @__PURE__ */ s("p", { style: { ...t.gmBodyM, color: "#10b981" }, children: [
|
|
702
425
|
"MEMORIZE (",
|
|
703
|
-
|
|
426
|
+
v,
|
|
704
427
|
")"
|
|
705
428
|
] }),
|
|
706
|
-
g === "guess" && !
|
|
429
|
+
g === "guess" && !h && /* @__PURE__ */ s("p", { style: t.gmBodyM, children: [
|
|
707
430
|
"⏳ Time left: ",
|
|
708
|
-
|
|
431
|
+
z,
|
|
709
432
|
"s"
|
|
710
433
|
] })
|
|
711
434
|
]
|
|
712
435
|
}
|
|
713
436
|
),
|
|
714
|
-
g !== "ready" && /* @__PURE__ */
|
|
437
|
+
g !== "ready" && /* @__PURE__ */ o(
|
|
715
438
|
"div",
|
|
716
439
|
{
|
|
717
440
|
style: {
|
|
718
|
-
...
|
|
719
|
-
gridTemplateColumns:
|
|
720
|
-
gridAutoRows:
|
|
721
|
-
gap:
|
|
441
|
+
...t.gmGrid,
|
|
442
|
+
gridTemplateColumns: C ? "repeat(2, 1fr)" : "repeat(3, 210px)",
|
|
443
|
+
gridAutoRows: C ? "150px" : "210px",
|
|
444
|
+
gap: C ? "12px" : "20px",
|
|
722
445
|
justifyItems: "center",
|
|
723
446
|
// 🔹 увеличение только при >2000px
|
|
724
447
|
...window.innerWidth > 2e3 ? {
|
|
@@ -732,21 +455,21 @@ function Re() {
|
|
|
732
455
|
gap: "32px"
|
|
733
456
|
} : {}
|
|
734
457
|
},
|
|
735
|
-
children:
|
|
736
|
-
const
|
|
737
|
-
return /* @__PURE__ */
|
|
458
|
+
children: a.map((e, i) => {
|
|
459
|
+
const p = u === i && g === "guess" && !h;
|
|
460
|
+
return /* @__PURE__ */ o(
|
|
738
461
|
"div",
|
|
739
462
|
{
|
|
740
463
|
style: {
|
|
741
|
-
...
|
|
742
|
-
...
|
|
743
|
-
...
|
|
464
|
+
...t.gmCard,
|
|
465
|
+
...N === "correct" && u === i ? t.gmCorrect : {},
|
|
466
|
+
...N === "wrong" && u === i ? t.gmWrong : {}
|
|
744
467
|
},
|
|
745
|
-
children: !
|
|
468
|
+
children: !p && /* @__PURE__ */ o(
|
|
746
469
|
"img",
|
|
747
470
|
{
|
|
748
|
-
src:
|
|
749
|
-
alt:
|
|
471
|
+
src: e.src,
|
|
472
|
+
alt: e.name,
|
|
750
473
|
style: {
|
|
751
474
|
width: "100%",
|
|
752
475
|
height: "100%",
|
|
@@ -755,39 +478,39 @@ function Re() {
|
|
|
755
478
|
}
|
|
756
479
|
)
|
|
757
480
|
},
|
|
758
|
-
|
|
481
|
+
i
|
|
759
482
|
);
|
|
760
483
|
})
|
|
761
484
|
}
|
|
762
485
|
),
|
|
763
|
-
/* @__PURE__ */
|
|
764
|
-
g === "guess" && !
|
|
765
|
-
/* @__PURE__ */
|
|
486
|
+
/* @__PURE__ */ s("div", { style: { marginTop: 16, height: 80 }, children: [
|
|
487
|
+
g === "guess" && !h && /* @__PURE__ */ s("div", { children: [
|
|
488
|
+
/* @__PURE__ */ o(
|
|
766
489
|
"input",
|
|
767
490
|
{
|
|
768
491
|
type: "text",
|
|
769
492
|
placeholder: "Type the missing word",
|
|
770
|
-
value:
|
|
771
|
-
onChange: (
|
|
772
|
-
style:
|
|
493
|
+
value: k,
|
|
494
|
+
onChange: (e) => U(e.target.value),
|
|
495
|
+
style: t.gmInput
|
|
773
496
|
}
|
|
774
497
|
),
|
|
775
|
-
/* @__PURE__ */
|
|
498
|
+
/* @__PURE__ */ o(
|
|
776
499
|
"button",
|
|
777
500
|
{
|
|
778
|
-
style: { ...
|
|
779
|
-
onClick:
|
|
780
|
-
disabled:
|
|
781
|
-
children:
|
|
501
|
+
style: { ...t.gmButton, marginLeft: 8 },
|
|
502
|
+
onClick: oe,
|
|
503
|
+
disabled: H,
|
|
504
|
+
children: H ? "..." : "Check"
|
|
782
505
|
}
|
|
783
506
|
)
|
|
784
507
|
] }),
|
|
785
|
-
|
|
508
|
+
h && /* @__PURE__ */ o("button", { style: t.gmButton, onClick: ne, children: "Next round" })
|
|
786
509
|
] })
|
|
787
510
|
] })
|
|
788
511
|
] });
|
|
789
512
|
}
|
|
790
513
|
export {
|
|
791
|
-
|
|
792
|
-
|
|
514
|
+
ye as Game,
|
|
515
|
+
V as themes
|
|
793
516
|
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mblinkov/whats-missing",
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
"version": "20.0.3",
|
|
4
|
+
"main": "dist/whats-missing.umd.js",
|
|
5
|
+
"module": "dist/whats-missing.es.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"peerDependencies": {
|
|
8
|
+
"react": "^18.0.0",
|
|
9
|
+
"react-dom": "^18.0.0"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev": "vite",
|
|
13
|
+
"build": "vite build",
|
|
14
|
+
"preview": "vite preview"
|
|
15
|
+
}
|
|
16
16
|
}
|
package/vite.config.ts
CHANGED
|
@@ -5,7 +5,6 @@ export default defineConfig({
|
|
|
5
5
|
plugins: [react()],
|
|
6
6
|
server: {
|
|
7
7
|
// ✅ Прокси только для локальных тестов
|
|
8
|
-
// (чтобы локалка могла тянуть картинки из MinIO без 401)
|
|
9
8
|
proxy: {
|
|
10
9
|
"/cloud": {
|
|
11
10
|
target: "https://speakid.ru",
|
|
@@ -18,10 +17,12 @@ export default defineConfig({
|
|
|
18
17
|
lib: {
|
|
19
18
|
entry: "src/index.ts",
|
|
20
19
|
name: "WhatsMissing",
|
|
20
|
+
formats: ["es", "cjs"], // ✅ поддержка Webpack
|
|
21
21
|
fileName: (format) => `whats-missing.${format}.js`,
|
|
22
22
|
},
|
|
23
23
|
rollupOptions: {
|
|
24
|
-
|
|
24
|
+
// 🔥 добавлено "react/jsx-runtime"
|
|
25
|
+
external: ["react", "react-dom", "react/jsx-runtime"],
|
|
25
26
|
output: {
|
|
26
27
|
globals: {
|
|
27
28
|
react: "React",
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
(function(v,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],l):(v=typeof globalThis<"u"?globalThis:v||self,l(v.WhatsMissing={},v.React))})(this,(function(v,l){"use strict";var J={exports:{}},N={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var ae;function de(){if(ae)return N;ae=1;var a=Symbol.for("react.transitional.element"),p=Symbol.for("react.fragment");function m(s,i,h){var x=null;if(h!==void 0&&(x=""+h),i.key!==void 0&&(x=""+i.key),"key"in i){h={};for(var R in i)R!=="key"&&(h[R]=i[R])}else h=i;return i=h.ref,{$$typeof:a,type:s,key:x,ref:i!==void 0?i:null,props:h}}return N.Fragment=p,N.jsx=m,N.jsxs=m,N}var L={};/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.development.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var le;function ue(){return le||(le=1,process.env.NODE_ENV!=="production"&&(function(){function a(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===G?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case H:return"Profiler";case F:return"StrictMode";case O:return"Suspense";case B:return"SuspenseList";case k:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case Q:return"Portal";case oe:return e.displayName||"Context";case K:return(e._context.displayName||"Context")+".Consumer";case Y:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case P:return n=e.displayName||null,n!==null?n:a(e.type)||"Memo";case I:n=e._payload,e=e._init;try{return a(e(n))}catch{}}return null}function p(e){return""+e}function m(e){try{p(e);var n=!1}catch{n=!0}if(n){n=console;var c=n.error,u=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",u),p(e)}}function s(e){if(e===E)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===I)return"<...>";try{var n=a(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function i(){var e=_.A;return e===null?null:e.getOwner()}function h(){return Error("react-stack-top-frame")}function x(e){if(D.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function R(e,n){function c(){$||($=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",n))}c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}function A(){var e=a(this.type);return z[e]||(z[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function X(e,n,c,u,M,V){var f=c.ref;return e={$$typeof:W,type:e,key:n,props:c,_owner:u},(f!==void 0?f:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:A}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:V}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function y(e,n,c,u,M,V){var f=n.children;if(f!==void 0)if(u)if(q(f)){for(u=0;u<f.length;u++)Z(f[u]);Object.freeze&&Object.freeze(f)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Z(f);if(D.call(n,"key")){f=a(e);var S=Object.keys(n).filter(function(d){return d!=="key"});u=0<S.length?"{key: someKey, "+S.join(": ..., ")+": ...}":"{key: someKey}",C[f+u]||(S=0<S.length?"{"+S.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
-
let props = %s;
|
|
19
|
-
<%s {...props} />
|
|
20
|
-
React keys must be passed directly to JSX without using spread:
|
|
21
|
-
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,u,f,S,f),C[f+u]=!0)}if(f=null,c!==void 0&&(m(c),f=""+c),x(n)&&(m(n.key),f=""+n.key),"key"in n){c={};for(var r in n)r!=="key"&&(c[r]=n[r])}else c=n;return f&&R(c,typeof e=="function"?e.displayName||e.name||"Unknown":e),X(e,f,c,i(),M,V)}function Z(e){g(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===I&&(e._payload.status==="fulfilled"?g(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function g(e){return typeof e=="object"&&e!==null&&e.$$typeof===W}var T=l,W=Symbol.for("react.transitional.element"),Q=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),H=Symbol.for("react.profiler"),K=Symbol.for("react.consumer"),oe=Symbol.for("react.context"),Y=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),G=Symbol.for("react.client.reference"),_=T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=Object.prototype.hasOwnProperty,q=Array.isArray,j=console.createTask?console.createTask:function(){return null};T={react_stack_bottom_frame:function(e){return e()}};var $,z={},ee=T.react_stack_bottom_frame.bind(T,h)(),U=j(s(h)),C={};L.Fragment=E,L.jsx=function(e,n,c){var u=1e4>_.recentlyCreatedOwnerStacks++;return y(e,n,c,!1,u?Error("react-stack-top-frame"):ee,u?j(s(e)):U)},L.jsxs=function(e,n,c){var u=1e4>_.recentlyCreatedOwnerStacks++;return y(e,n,c,!0,u?Error("react-stack-top-frame"):ee,u?j(s(e)):U)}})()),L}var ie;function me(){return ie||(ie=1,process.env.NODE_ENV==="production"?J.exports=de():J.exports=ue()),J.exports}var t=me();const fe=window.origin+"/cloud/speakid/games/whatsmissing/",re=(a,p)=>a.map(([m,s])=>({src:`${fe}${p}/${s.replace(/\s/g,"%20")}.png`,name:s})),pe=[["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"]],ge=[["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"]],he=[["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"]],ne={food:re(pe,"food"),animals:re(ge,"animals"),toys:re(he,"toys")},xe=`
|
|
23
|
-
@keyframes spin {
|
|
24
|
-
from { transform: rotate(0deg); }
|
|
25
|
-
to { transform: rotate(360deg); }
|
|
26
|
-
}
|
|
27
|
-
`;if(typeof document<"u"&&!document.getElementById("spin-keyframes")){const a=document.createElement("style");a.id="spin-keyframes",a.innerHTML=xe,document.head.appendChild(a)}const o={gmCenterScreen:{position:"relative",zIndex:1,minHeight:"100vh",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:"600px",minHeight:"100vh",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",color:"#1f2937",padding:"16px 8px",margin:"0 auto"},gmGrid:{width:"100%",maxWidth:"calc(210px * 3 + 20px * 2)",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:"sticky",top:"16px",left:"20px",zIndex:9999,background:"white",padding:"4px 8px",borderRadius:"8px"},gmLogoImg:{height:"clamp(28px, 5vw, 40px)",width:"auto"},gmHourglass:{fontSize:"42px",...{animation:"spin 1.4s linear infinite"}}},be=window.origin+"/cloud/speakid/games/whatsmissing/logo.png",ye=()=>{const a=document.createElement("style");a.textContent=`
|
|
28
|
-
html, body, #root {
|
|
29
|
-
margin: 0;
|
|
30
|
-
padding: 0;
|
|
31
|
-
height: 100%;
|
|
32
|
-
}
|
|
33
|
-
*, *::before, *::after {
|
|
34
|
-
box-sizing: border-box;
|
|
35
|
-
}
|
|
36
|
-
body {
|
|
37
|
-
font-family: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
|
|
38
|
-
background-color: #fff;
|
|
39
|
-
color: #1f2937;
|
|
40
|
-
}
|
|
41
|
-
button, input {
|
|
42
|
-
font-family: inherit;
|
|
43
|
-
outline: none;
|
|
44
|
-
border: none;
|
|
45
|
-
background: none;
|
|
46
|
-
}
|
|
47
|
-
img {
|
|
48
|
-
max-width: 100%;
|
|
49
|
-
height: auto;
|
|
50
|
-
display: block;
|
|
51
|
-
user-select: none;
|
|
52
|
-
}
|
|
53
|
-
@keyframes spin {
|
|
54
|
-
from { transform: rotate(0deg); }
|
|
55
|
-
to { transform: rotate(360deg); }
|
|
56
|
-
}
|
|
57
|
-
`,document.head.appendChild(a)},we=(a,p)=>{const m=Array.from({length:a.length+1},()=>Array(p.length+1).fill(0));for(let s=0;s<=a.length;s++)m[s][0]=s;for(let s=0;s<=p.length;s++)m[0][s]=s;for(let s=1;s<=a.length;s++)for(let i=1;i<=p.length;i++)m[s][i]=a[s-1]===p[i-1]?m[s-1][i-1]:Math.min(m[s-1][i-1],m[s][i-1],m[s-1][i])+1;return m[a.length][p.length]};function Te(){l.useEffect(()=>{ye()},[]);const[a,p]=l.useState(null),[m,s]=l.useState([]),[i,h]=l.useState(4),[x,R]=l.useState(!1),[A,X]=l.useState(1),[y,Z]=l.useState(null),[g,T]=l.useState("ready"),[W,Q]=l.useState(3),[E,F]=l.useState(7),[H,K]=l.useState(20),[oe,Y]=l.useState(0),[O,B]=l.useState(!1),[P,I]=l.useState(""),[k,G]=l.useState(!1),[_,D]=l.useState(!1),[q,j]=l.useState(null),[$,z]=l.useState([]),[ee,U]=l.useState([]),[C,e]=l.useState(!1);l.useEffect(()=>{const r=()=>e(window.innerWidth<768);return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]);const n=r=>[...r].sort(()=>Math.random()-.5).slice(0,6),c=()=>{if(!a)return;const r=n(ne[a]);s(r),R(!0),B(!1),X(1),Y(0),z([]),U([]),u(r,[],!0)},u=(r=m,d=ee,w=!1)=>{const b=n(r.length?r:ne[a]);let te=Math.floor(Math.random()*b.length),se=b[te].name,ce=0;for(;d.includes(se)&&ce<20;)te=Math.floor(Math.random()*b.length),se=b[te].name,ce++;s(b),Z(te),U([...d,se]),G(!1),I(""),K(20),j(null),w?(T("ready"),Q(3),F(7)):(T("memorize"),F(7))};l.useEffect(()=>{if(!(!x||O||k)){if(g==="ready")if(W<=0)T("memorize");else{const r=setTimeout(()=>Q(d=>d-1),1e3);return()=>clearTimeout(r)}if(g==="memorize")if(E<=0)T("guess");else{const r=setTimeout(()=>F(d=>d-1),1e3);return()=>clearTimeout(r)}if(g==="guess"){if(H<=0){G(!0),j("wrong");const d=m[y].name;z(w=>[...w,{round:A,answer:P,correct:d,result:"wrong"}]);return}const r=setTimeout(()=>K(d=>d-1),1e3);return()=>clearTimeout(r)}}},[g,W,E,H,x,O,k,m,y,A,P]);const M=()=>{if(y===null||_)return;const r=m[y].name,d=P.toLowerCase().trim();let w="wrong";d===r?(Y(b=>b+1),j("correct"),w="correct"):we(d,r)===1?(Y(b=>b+.5),j("almost"),w="almost"):(j("wrong"),w="wrong"),z(b=>[...b,{round:A,answer:d,correct:r,result:w}]),D(!0),setTimeout(()=>{D(!1),G(!0)},600)},V=()=>A<i?(X(r=>r+1),u()):B(!0),f=()=>{R(!1),B(!1),p(null)},S=()=>t.jsx("div",{style:o.gmLogoFixed,children:t.jsx("img",{src:be,alt:"SPEAKID Logo",style:o.gmLogoImg})});return t.jsxs(t.Fragment,{children:[!C&&t.jsx(S,{}),!a&&!x&&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(r=>t.jsx("button",{style:o.gmButton,onClick:()=>p(r),children:r==="animals"?"🐶 Animals":r==="food"?"🍎 Food":"🧸 Toys"},r))}),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(r=>t.jsx("button",{style:{...o.gmButton,...i===r?o.gmButtonActive:{}},onClick:()=>h(r),children:r},r))})]})]}),a&&!x&&t.jsxs("div",{style:o.gmCenterScreen,children:[t.jsxs("h1",{style:o.gmHeadline1,children:["Theme selected: ",a]}),t.jsxs("p",{style:o.gmBodyM,children:["Rounds: ",i]}),t.jsx("button",{style:o.gmButton,onClick:c,children:"▶ Start game"})]}),O&&t.jsxs("div",{style:o.gmCenterScreen,children:[t.jsx("h1",{style:o.gmHeadline1,children:"Results"}),t.jsxs("h2",{style:o.gmHeadline3,children:["Your score: ",oe," / ",i]}),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:$.map((r,d)=>t.jsxs("tr",{children:[t.jsx("td",{style:o.gmTableCell,children:r.round}),t.jsx("td",{style:o.gmTableCell,children:r.answer||"—"}),t.jsx("td",{style:o.gmTableCell,children:r.correct}),t.jsx("td",{style:o.gmTableCell,children:r.result==="correct"?"✔ Correct":r.result==="almost"?"◐ Almost (0.5)":"✘ Wrong"})]},d))})]}),t.jsxs("div",{style:{display:"flex",gap:12,marginTop:24},children:[t.jsx("button",{style:o.gmButton,onClick:c,children:"🔁 Play again"}),t.jsx("button",{style:o.gmButton,onClick:f,children:"⬅️ Choose theme"})]})]}),x&&!O&&t.jsxs("div",{style:o.gmGameLayout,children:[t.jsxs("div",{style:{minHeight:160,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[g==="ready"&&t.jsxs(t.Fragment,{children:[t.jsx("h1",{style:{...o.gmHeadline1,color:"#ec4c44"},children:"GET READY"}),t.jsx("div",{style:o.gmHourglass,children:"⏳"})]}),g==="memorize"&&t.jsxs("p",{style:{...o.gmBodyM,color:"#10b981"},children:["MEMORIZE (",E,")"]}),g==="guess"&&!k&&t.jsxs("p",{style:o.gmBodyM,children:["⏳ Time left: ",H,"s"]})]}),g!=="ready"&&t.jsx("div",{style:{...o.gmGrid,gridTemplateColumns:C?"repeat(2, 1fr)":"repeat(3, 210px)",gridAutoRows:C?"150px":"210px",gap:C?"12px":"20px",justifyItems:"center",...window.innerWidth>2e3?{gridTemplateColumns:"repeat(3, 260px)",gridAutoRows:"260px",gap:"28px"}:{},...window.innerWidth>2560?{gridTemplateColumns:"repeat(3, 300px)",gridAutoRows:"300px",gap:"32px"}:{}},children:m.map((r,d)=>{const w=y===d&&g==="guess"&&!k;return t.jsx("div",{style:{...o.gmCard,...q==="correct"&&y===d?o.gmCorrect:{},...q==="wrong"&&y===d?o.gmWrong:{}},children:!w&&t.jsx("img",{src:r.src,alt:r.name,style:{width:"100%",height:"100%",objectFit:"cover"}})},d)})}),t.jsxs("div",{style:{marginTop:16,height:80},children:[g==="guess"&&!k&&t.jsxs("div",{children:[t.jsx("input",{type:"text",placeholder:"Type the missing word",value:P,onChange:r=>I(r.target.value),style:o.gmInput}),t.jsx("button",{style:{...o.gmButton,marginLeft:8},onClick:M,disabled:_,children:_?"...":"Check"})]}),k&&t.jsx("button",{style:o.gmButton,onClick:V,children:"Next round"})]})]})]})}v.Game=Te,v.themes=ne,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|