{"version":3,"sources":["WordGrid/index.js","WordList/index.js","utils/PlaceWords.js","App/index.js","serviceWorker.js","index.js"],"names":["App","props","state","wordGrid","grid","className","this","map","row","y","key","letter","x","React","Component","wordList","list","word","placeWords","wordlist","width","height","i","h","w","gridRow","generateEmptyGrid","placing","length","Math","random","floor","maxY","j","charAt","maxX","characterLength","fillGrid","randomWords","exactly","maxLength","formatter","toUpperCase","console","log","WordGrid","WordList","Boolean","window","location","hostname","match","ReactDOM","render","document","getElementById","navigator","serviceWorker","ready","then","registration","unregister"],"mappings":"gVAoCeA,G,kBA/Bb,WAAYC,GAAQ,IAAD,8BACjB,4CAAMA,KAEDC,MAAQ,CACXC,SAAUF,EAAMG,MAJD,E,sEASjB,OACE,yBAAKC,UAAU,aACb,+BACE,+BACGC,KAAKJ,MAAMC,SAASI,KAAI,SAACC,EAAKC,GAAN,OAErB,wBAAIC,IAAKD,EAAGJ,UAAU,YAEjBG,EAAID,KAAI,SAACI,EAAQC,GAAT,OACP,wBAAIF,IAAKE,EAAGP,UAAU,eAAeM,iB,GApBzCE,IAAMC,YCyBTd,G,kBAtBb,WAAYC,GAAQ,IAAD,8BACjB,4CAAMA,KAEDC,MAAQ,CACXa,SAAUd,EAAMe,MAJD,E,sEASjB,OACE,yBAAKX,UAAU,aACZC,KAAKJ,MAAMa,SAASR,KAAI,SAACU,EAAMP,GAAP,OACrB,yBAAKA,IAAKA,EAAKL,UAAU,QACtBY,W,GAfGJ,IAAMC,YC+FTI,MAjEf,SAAoBC,EAAUC,EAAOC,GACnC,IAAIC,EAAI,EACJlB,EApCN,SAA2BmB,EAAGC,GAI5B,IAFA,IAAIpB,EAAO,GACPqB,EAAU,GACLhB,EAAI,EAAGA,EAAIc,EAAGd,IAAK,CAC1BgB,EAAU,GACV,IAAK,IAAIb,EAAI,EAAGA,EAAIY,EAAGZ,IAErBa,EAAQb,GAAK,EAEfR,EAAKK,GAAKgB,EAGZ,OAAOrB,EAuBIsB,CAAkBL,EAAQD,GAErCO,E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+DAiC,CAASjC,IC3DHJ,G,kBAzBb,WAAYC,GAAQ,IAAD,sBACjB,4CAAMA,IAEN,IAAMe,EAAOsB,IAAY,CAACC,QAAS,GAAIC,UAAW,GAAIC,UAAW,SAACxB,GAAD,OAAUA,EAAKyB,iBAC1EtC,EAAOc,EAAWF,EAAM,GAAI,IAJjB,OAMjB,EAAKd,MAAQ,CACXa,SAAUC,EACVZ,KAAMA,GARS,E,sEAcjB,OADAuC,QAAQC,IAAItC,KAAKJ,MAAMa,UAErB,yBAAKV,UAAU,OACb,yBAAKA,UAAY,QACf,kBAACwC,EAAD,CAAUzC,KAAME,KAAKJ,MAAME,OAC3B,kBAAC0C,EAAD,CAAU9B,KAAMV,KAAKJ,MAAMa,iB,GAnBnBF,IAAMC,YCGJiC,QACW,cAA7BC,OAAOC,SAASC,UAEe,UAA7BF,OAAOC,SAASC,UAEhBF,OAAOC,SAASC,SAASC,MACvB,2DCZNC,IAASC,OAAO,kBAAC,EAAD,MAASC,SAASC,eAAe,SD6H3C,kBAAmBC,WACrBA,UAAUC,cAAcC,MAAMC,MAAK,SAAAC,GACjCA,EAAaC,kB","file":"static/js/main.c719ec00.chunk.js","sourcesContent":["import React from 'react';\nimport './grid.css';\n\nclass App extends React.Component {\n\n constructor(props) {\n super(props);\n\n this.state = {\n wordGrid: props.grid\n };\n }\n\n render() {\n return (\n
\n \n \n {this.state.wordGrid.map((row, y) =>\n (\n \n {\n (row.map((letter, x) =>\n \n ))\n }\n \n )\n )}\n \n
{letter}
\n
\n );\n }\n}\n\nexport default App;\n","import React from 'react';\n\nimport './list.css';\n\nclass App extends React.Component {\n \n constructor(props) {\n super(props);\n\n this.state = {\n wordList: props.list\n };\n }\n\n render() {\n return (\n
\n {this.state.wordList.map((word, key) => (\n
\n {word}\n
\n ))\n }\n
\n );\n }\n}\n\nexport default App;\n","function generateEmptyGrid(h, w) {\n //\n let grid = []\n let gridRow = []\n for (let y = 0; y < h; y++) {\n gridRow = [];\n for (let x = 0; x < w; x++) {\n //0 meaning the space is empty/can be occupied\n gridRow[x] = 0\n }\n grid[y] = gridRow;\n }\n\n return grid;\n}\n\nfunction fillGrid(grid) {\n const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n const characterLength = characters.length;\n\n let width = grid[0].length;\n let height = grid.length;\n\n for (let y = 0; y < height; y ++) {\n for (let x = 0; x < width; x ++) {\n if (!grid[y][x]) {\n grid[y][x] = characters.charAt(Math.floor(Math.random() * characterLength));\n }\n }\n }\n\n return grid;\n}\n\nfunction placeWords(wordlist, width, height) {\n let i = 0;\n let grid = generateEmptyGrid(height, width);\n\n placing: while(i < wordlist.length) {\n let word = wordlist[i];\n\n // start with left -> Right or Up -> down\n // if greater than .5 up -> down otherwise left->right\n // true is for up -> down\n let upDown = Math.random() > 0.5 ? true : false;\n\n let x;\n let y;\n\n if(upDown) {\n y = Math.floor(Math.random() * (height - word.length));\n x = Math.floor(Math.random() * width);\n\n const maxY = y + word.length;\n\n // Check if word fits\n for(let j = y; j < maxY; j ++) {\n if (grid[j][x]) {\n if(!(word.charAt(j-y) === (grid[j][x]))) {\n //retry - find better non infinite loop possible solution\n continue placing;\n }\n }\n }\n\n for(let j = y; j < maxY; j++) {\n grid[j][x] = word.charAt(j-y);\n }\n \n i++;\n } else {\n x = Math.floor(Math.random() * (width - word.length));\n y = Math.floor(Math.random() * height);\n\n const maxX = x + word.length;\n\n // Check if word fits\n for(let j = x; j < maxX; j ++) {\n if (grid[y][j]) {\n if(!(word.charAt(j-x) === grid[y][j])) {\n //retry - find better non infinite loop possible solution\n continue placing;\n }\n }\n }\n\n for(let j = x; j < maxX; j ++) {\n grid[y][j] = word.charAt(j-x);\n }\n\n i++;\n }\n }\n\n grid = fillGrid(grid);\n\n return grid;\n}\n\nexport default placeWords;","import React from 'react';\nimport randomWords from 'random-words';\n\nimport WordGrid from '../WordGrid';\nimport WordList from '../WordList';\nimport placeWords from '../utils/PlaceWords';\n\nimport './App.css';\n\nclass App extends React.Component {\n constructor(props) {\n super(props);\n\n const list = randomWords({exactly: 12, maxLength: 10, formatter: (word) => word.toUpperCase()});\n const grid = placeWords(list, 20, 20);\n\n this.state = {\n wordList: list,\n grid: grid\n };\n }\n render() {\n\n console.log(this.state.wordList);\n return (\n
\n
\n \n \n
\n
\n );\n }\n}\n\nexport default App;\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.0/8 are considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl, {\n headers: { 'Service-Worker': 'script' }\n })\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister();\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(, document.getElementById('root'));\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n"],"sourceRoot":""}