@mblinkov/whats-missing 20.0.1 → 20.0.2

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.
@@ -0,0 +1,57 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react");var ee={exports:{}},G={};/**
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 ce(){if(ae)return G;ae=1;var a=Symbol.for("react.transitional.element"),g=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 v in i)v!=="key"&&(h[v]=i[v])}else h=i;return i=h.ref,{$$typeof:a,type:s,key:x,ref:i!==void 0?i:null,props:h}}return G.Fragment=g,G.jsx=m,G.jsxs=m,G}var D={};/**
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 ie;function de(){return ie||(ie=1,process.env.NODE_ENV!=="production"&&(function(){function a(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===H?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case S:return"Fragment";case L:return"Profiler";case M:return"StrictMode";case A:return"Suspense";case F:return"SuspenseList";case R: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 V:return"Portal";case te:return e.displayName||"Context";case J:return(e._context.displayName||"Context")+".Consumer";case W:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case O:return n=e.displayName||null,n!==null?n:a(e.type)||"Memo";case P:n=e._payload,e=e._init;try{return a(e(n))}catch{}}return null}function g(e){return""+e}function m(e){try{g(e);var n=!1}catch{n=!0}if(n){n=console;var l=n.error,u=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return l.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",u),g(e)}}function s(e){if(e===S)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===P)return"<...>";try{var n=a(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function i(){var e=E.A;return e===null?null:e.getOwner()}function h(){return Error("react-stack-top-frame")}function x(e){if(Y.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function v(e,n){function l(){Z||(Z=!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))}l.isReactWarning=!0,Object.defineProperty(e,"key",{get:l,configurable:!0})}function C(){var e=a(this.type);return I[e]||(I[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 U(e,n,l,u,z,$){var f=l.ref;return e={$$typeof:N,type:e,key:n,props:l,_owner:u},(f!==void 0?f:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:C}):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:z}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:$}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function y(e,n,l,u,z,$){var f=n.children;if(f!==void 0)if(u)if(X(f)){for(u=0;u<f.length;u++)q(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 q(f);if(Y.call(n,"key")){f=a(e);var k=Object.keys(n).filter(function(c){return c!=="key"});u=0<k.length?"{key: someKey, "+k.join(": ..., ")+": ...}":"{key: someKey}",_[f+u]||(k=0<k.length?"{"+k.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,k,f),_[f+u]=!0)}if(f=null,l!==void 0&&(m(l),f=""+l),x(n)&&(m(n.key),f=""+n.key),"key"in n){l={};for(var r in n)r!=="key"&&(l[r]=n[r])}else l=n;return f&&v(l,typeof e=="function"?e.displayName||e.name||"Unknown":e),U(e,f,l,i(),z,$)}function q(e){p(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===P&&(e._payload.status==="fulfilled"?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e=="object"&&e!==null&&e.$$typeof===N}var T=d,N=Symbol.for("react.transitional.element"),V=Symbol.for("react.portal"),S=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"),E=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(){return null};T={react_stack_bottom_frame:function(e){return e()}};var Z,I={},Q=T.react_stack_bottom_frame.bind(T,h)(),B=j(s(h)),_={};D.Fragment=S,D.jsx=function(e,n,l){var u=1e4>E.recentlyCreatedOwnerStacks++;return y(e,n,l,!1,u?Error("react-stack-top-frame"):Q,u?j(s(e)):B)},D.jsxs=function(e,n,l){var u=1e4>E.recentlyCreatedOwnerStacks++;return y(e,n,l,!0,u?Error("react-stack-top-frame"):Q,u?j(s(e)):B)}})()),D}var le;function ue(){return le||(le=1,process.env.NODE_ENV==="production"?ee.exports=ce():ee.exports=de()),ee.exports}var t=ue();const me=window.origin+"/cloud/speakid/games/whatsmissing/",ne=(a,g)=>a.map(([m,s])=>({src:`${me}${g}/${s.replace(/\s/g,"%20")}.png`,name:s})),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"]],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"]],pe=[["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"]],oe={food:ne(fe,"food"),animals:ne(ge,"animals"),toys:ne(pe,"toys")},he=`
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=he,document.head.appendChild(a)}const xe={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",...xe}},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,g)=>{const m=Array.from({length:a.length+1},()=>Array(g.length+1).fill(0));for(let s=0;s<=a.length;s++)m[s][0]=s;for(let s=0;s<=g.length;s++)m[0][s]=s;for(let s=1;s<=a.length;s++)for(let i=1;i<=g.length;i++)m[s][i]=a[s-1]===g[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][g.length]};function Te(){d.useEffect(()=>{ye()},[]);const[a,g]=d.useState(null),[m,s]=d.useState([]),[i,h]=d.useState(4),[x,v]=d.useState(!1),[C,U]=d.useState(1),[y,q]=d.useState(null),[p,T]=d.useState("ready"),[N,V]=d.useState(3),[S,M]=d.useState(7),[L,J]=d.useState(20),[te,W]=d.useState(0),[A,F]=d.useState(!1),[O,P]=d.useState(""),[R,H]=d.useState(!1),[E,Y]=d.useState(!1),[X,j]=d.useState(null),[Z,I]=d.useState([]),[Q,B]=d.useState([]),[_,e]=d.useState(!1);d.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),l=()=>{if(!a)return;const r=n(oe[a]);s(r),v(!0),F(!1),U(1),W(0),I([]),B([]),u(r,[],!0)},u=(r=m,c=Q,w=!1)=>{const b=n(r.length?r:oe[a]);let K=Math.floor(Math.random()*b.length),re=b[K].name,se=0;for(;c.includes(re)&&se<20;)K=Math.floor(Math.random()*b.length),re=b[K].name,se++;s(b),q(K),B([...c,re]),H(!1),P(""),J(20),j(null),w?(T("ready"),V(3),M(7)):(T("memorize"),M(7))};d.useEffect(()=>{if(!(!x||A||R)){if(p==="ready")if(N<=0)T("memorize");else{const r=setTimeout(()=>V(c=>c-1),1e3);return()=>clearTimeout(r)}if(p==="memorize")if(S<=0)T("guess");else{const r=setTimeout(()=>M(c=>c-1),1e3);return()=>clearTimeout(r)}if(p==="guess"){if(L<=0){H(!0),j("wrong");const c=m[y].name;I(w=>[...w,{round:C,answer:O,correct:c,result:"wrong"}]);return}const r=setTimeout(()=>J(c=>c-1),1e3);return()=>clearTimeout(r)}}},[p,N,S,L,x,A,R,m,y,C,O]);const z=()=>{if(y===null||E)return;const r=m[y].name,c=O.toLowerCase().trim();let w="wrong";c===r?(W(b=>b+1),j("correct"),w="correct"):we(c,r)===1?(W(b=>b+.5),j("almost"),w="almost"):(j("wrong"),w="wrong"),I(b=>[...b,{round:C,answer:c,correct:r,result:w}]),Y(!0),setTimeout(()=>{Y(!1),H(!0)},600)},$=()=>C<i?(U(r=>r+1),u()):F(!0),f=()=>{v(!1),F(!1),g(null)},k=()=>t.jsx("div",{style:o.gmLogoFixed,children:t.jsx("img",{src:be,alt:"SPEAKID Logo",style:o.gmLogoImg})});return t.jsxs(t.Fragment,{children:[!_&&t.jsx(k,{}),!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:()=>g(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:l,children:"▶ Start game"})]}),A&&t.jsxs("div",{style:o.gmCenterScreen,children:[t.jsx("h1",{style:o.gmHeadline1,children:"Results"}),t.jsxs("h2",{style:o.gmHeadline3,children:["Your score: ",te," / ",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:Z.map((r,c)=>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"})]},c))})]}),t.jsxs("div",{style:{display:"flex",gap:12,marginTop:24},children:[t.jsx("button",{style:o.gmButton,onClick:l,children:"🔁 Play again"}),t.jsx("button",{style:o.gmButton,onClick:f,children:"⬅️ Choose theme"})]})]}),x&&!A&&t.jsxs("div",{style:o.gmGameLayout,children:[t.jsxs("div",{style:{minHeight:160,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[p==="ready"&&t.jsxs(t.Fragment,{children:[t.jsx("h1",{style:{...o.gmHeadline1,color:"#ec4c44"},children:"GET READY"}),t.jsx("div",{style:o.gmHourglass,children:"⏳"})]}),p==="memorize"&&t.jsxs("p",{style:{...o.gmBodyM,color:"#10b981"},children:["MEMORIZE (",S,")"]}),p==="guess"&&!R&&t.jsxs("p",{style:o.gmBodyM,children:["⏳ Time left: ",L,"s"]})]}),p!=="ready"&&t.jsx("div",{style:{...o.gmGrid,gridTemplateColumns:_?"repeat(2, 1fr)":"repeat(3, 210px)",gridAutoRows:_?"150px":"210px",gap:_?"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,c)=>{const w=y===c&&p==="guess"&&!R;return t.jsx("div",{style:{...o.gmCard,...X==="correct"&&y===c?o.gmCorrect:{},...X==="wrong"&&y===c?o.gmWrong:{}},children:!w&&t.jsx("img",{src:r.src,alt:r.name,style:{width:"100%",height:"100%",objectFit:"cover"}})},c)})}),t.jsxs("div",{style:{marginTop:16,height:80},children:[p==="guess"&&!R&&t.jsxs("div",{children:[t.jsx("input",{type:"text",placeholder:"Type the missing word",value:O,onChange:r=>P(r.target.value),style:o.gmInput}),t.jsx("button",{style:{...o.gmButton,marginLeft:8},onClick:z,disabled:E,children:E?"...":"Check"})]}),R&&t.jsx("button",{style:o.gmButton,onClick:$,children:"Next round"})]})]})]})}exports.Game=Te;exports.themes=oe;
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@mblinkov/whats-missing",
3
- "version": "20.0.1",
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
- }
3
+ "version": "20.0.2",
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,6 +17,7 @@ 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: {
@@ -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"})}));