hansaka01 commited on
Commit
bb2cf03
Β·
verified Β·
1 Parent(s): c160796

Upload 11 files

Browse files
Files changed (8) hide show
  1. .env.example +11 -0
  2. .gitignore +3 -7
  3. Dockerfile +13 -19
  4. bot.js +295 -244
  5. ocr.js +251 -90
  6. package-lock.json +803 -91
  7. package.json +8 -7
  8. solver.js +188 -105
.env.example ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ── Required ──────────────────────────────────────────────────
2
+ # Get your BOT_TOKEN from @BotFather on Telegram
3
+ BOT_TOKEN=your_bot_token_here
4
+
5
+ # Get API_ID and API_HASH from https://my.telegram.org/apps
6
+ API_ID=12345678
7
+ API_HASH=your_api_hash_here
8
+
9
+ # ── Optional ───────────────────────────────────────────────────
10
+ # Dashboard port (default 7860 for Hugging Face Spaces)
11
+ PORT=7860
.gitignore CHANGED
@@ -1,10 +1,6 @@
1
  node_modules/
2
  .env
3
  *.jpg
4
- photo_*.jpg
5
- exampleimgs/
6
- test.js
7
- test_ocr.js
8
- test_ocr.py
9
- test_symbols.js
10
- eng.traineddata
 
1
  node_modules/
2
  .env
3
  *.jpg
4
+ *.jpeg
5
+ *.png
6
+ *.log
 
 
 
 
Dockerfile CHANGED
@@ -1,38 +1,32 @@
1
- FROM node:18-slim
2
 
3
- # Install system dependencies
4
- RUN apt-get update && apt-get install -y \
5
- python3 \
6
- python3-pip \
7
- python3-venv \
8
  tesseract-ocr \
 
9
  libtesseract-dev \
10
  libgl1-mesa-glx \
11
- git \
 
 
 
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
- # Set up the app directory with correct permissions for the 'node' user
15
  WORKDIR /home/node/app
16
  RUN chown -R node:node /home/node/app
17
 
18
- # Switch to non-root user
19
  USER node
20
  ENV HOME=/home/node \
21
- PATH="/home/node/.local/bin:/opt/venv/bin:$PATH"
22
 
23
- # Set up Python virtual environment (if allowed in home)
24
- # For simplicity in this container, we'll install python libs in the node home if needed
25
- # but let's stick to the previous venv logic if possible, adjusted for permissions
26
- # Actually, let's keep it simple: install node deps first
27
  COPY --chown=node:node package*.json ./
28
- RUN npm install
29
 
30
- # Copy the rest
31
  COPY --chown=node:node . .
32
 
33
- # Environment variables
34
- ENV PORT=7860
35
  EXPOSE 7860
36
 
37
- # Start the application
38
  CMD ["node", "bot.js"]
 
1
+ FROM node:20-slim
2
 
3
+ # Install system dependencies for Tesseract OCR and Sharp
4
+ RUN apt-get update && apt-get install -y --no-install-recommends \
 
 
 
5
  tesseract-ocr \
6
+ tesseract-ocr-eng \
7
  libtesseract-dev \
8
  libgl1-mesa-glx \
9
+ libvips42 \
10
+ python3 \
11
+ python3-pip \
12
+ ca-certificates \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
+ # Set up app directory with correct ownership
16
  WORKDIR /home/node/app
17
  RUN chown -R node:node /home/node/app
18
 
 
19
  USER node
20
  ENV HOME=/home/node \
21
+ PORT=7860
22
 
23
+ # Install Node dependencies first (layer caching)
 
 
 
24
  COPY --chown=node:node package*.json ./
25
+ RUN npm install --omit=dev
26
 
27
+ # Copy source files
28
  COPY --chown=node:node . .
29
 
 
 
30
  EXPOSE 7860
31
 
 
32
  CMD ["node", "bot.js"]
bot.js CHANGED
@@ -1,302 +1,353 @@
1
- const { Telegraf } = require('telegraf');
2
- const axios = require('axios');
3
- const fs = require('fs');
4
- const path = require('path');
5
- const { finished } = require('stream/promises');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  const express = require('express');
7
- const https = require('https');
8
- const { HttpsProxyAgent } = require('https-proxy-agent');
 
9
 
10
  const { extractGrid } = require('./ocr');
11
- const { solve } = require('./solver');
12
- require('dotenv').config();
13
 
14
- // Stats tracking
15
- const stats = {
16
- imagesProcessed: 0,
17
- wordsFound: 0,
18
- startTime: Date.now(),
19
- botUsername: 'Loading...'
20
- };
21
 
 
 
 
 
 
 
 
 
22
 
23
- // Load dictionary into memory for safety and speed
24
  const dictionaryPath = path.join(__dirname, 'node_modules/check-word/words/en.txt');
25
  const dictionary = new Set();
26
  try {
27
- const data = fs.readFileSync(dictionaryPath, 'utf8');
28
- data.split('\n').forEach(line => {
29
- const w = line.trim().toLowerCase();
30
- if (w) dictionary.add(w);
31
- });
32
- console.log(`Dictionary loaded with ${dictionary.size} words.`);
33
  } catch (err) {
34
- console.error('Failed to load dictionary:', err);
35
  }
36
 
37
  function isWord(w) {
38
- return dictionary.has((w || '').toLowerCase());
39
- }
40
-
41
- const BOT_TOKEN = process.env.BOT_TOKEN;
42
- if (!BOT_TOKEN) {
43
- console.error('BOT_TOKEN is required in process.env.BOT_TOKEN');
44
  }
45
 
46
- // --- Connectivity Diagnostic Test ---
47
- (async function testConnectivity() {
48
- if (!BOT_TOKEN || BOT_TOKEN === 'DUMMY_TOKEN') return;
49
- console.log('--- Connectivity Test ---');
50
-
51
- // Log environment info
52
- console.log('Proxy Environment:', {
53
- HTTPS_PROXY: process.env.HTTPS_PROXY,
54
- HTTP_PROXY: process.env.HTTP_PROXY,
55
- npm_config_proxy: process.env.npm_config_proxy
56
- });
57
 
 
 
 
58
  try {
59
- // Log current IP (using a public service)
60
- const ipRes = await axios.get('https://api.ipify.org?format=json', { timeout: 5000 });
61
- console.log('Current Outbound IP:', ipRes.data.ip);
62
  } catch (e) {
63
- console.log('Could not detect Outbound IP:', e.message);
64
  }
 
 
65
 
66
- try {
67
- const config = { timeout: 30000 }; // Increased to 30s
68
- const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
69
- if (proxyUrl) {
70
- console.log(`Using Proxy: ${proxyUrl}`);
71
- config.httpsAgent = new HttpsProxyAgent(proxyUrl);
72
- }
73
 
74
- const response = await axios.get(`https://api.telegram.org/bot${BOT_TOKEN}/getMe`, config);
75
- console.log('βœ… Connectivity Test (Axios): SUCCESS');
76
- console.log('Bot Username from Axios:', response.data.result.username);
77
- } catch (err) {
78
- console.error('❌ Connectivity Test (Axios): FAILED');
79
- console.error('Error Code:', err.code);
80
- console.error('Error Message:', err.message);
81
- }
82
- console.log('-------------------------');
83
- })();
84
-
85
- // Windows EPERM Fix: Retry-based file deletion
86
- async function deleteFileWithRetry(filePath, retries = 5, delay = 1000) {
87
- for (let i = 0; i < retries; i++) {
88
- try {
89
- if (fs.existsSync(filePath)) {
90
- fs.unlinkSync(filePath);
91
- return;
92
- }
93
- } catch (err) {
94
- if (i === retries - 1) console.error(`Cleanup error: ${err.message}`);
95
- await new Promise(resolve => setTimeout(resolve, delay));
96
- }
97
  }
 
 
 
98
  }
99
 
100
- const bot = new Telegraf(BOT_TOKEN || 'DUMMY_TOKEN');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
 
 
 
 
102
 
103
- bot.start((ctx) => ctx.reply('Send me a word grid image and the word patterns (e.g., M--- (4)) to solve it!'));
 
 
104
 
105
- bot.on('photo', async (ctx) => {
106
- let imagePath = null;
107
- try {
108
- const photo = ctx.message.photo[ctx.message.photo.length - 1];
109
- const fileLink = await ctx.telegram.getFileLink(photo.file_id);
110
- imagePath = path.join(__dirname, `photo_${Date.now()}.jpg`);
111
-
112
- // Retry-based download for flaky networks
113
- let response;
114
- for (let i = 0; i < 3; i++) {
115
- try {
116
- response = await axios({
117
- url: fileLink.href,
118
- responseType: 'stream',
119
- timeout: 20000
120
- });
121
- break;
122
- } catch (e) {
123
- if (i === 2) throw e;
124
- console.log(`Download attempt ${i + 1} failed, retrying...`);
125
- await new Promise(r => setTimeout(r, 2000));
126
- }
127
- }
128
 
129
- const writer = fs.createWriteStream(imagePath);
130
- response.data.pipe(writer);
131
- await finished(writer);
132
 
133
- ctx.reply('πŸ” Processing image...');
 
134
 
135
- const text = ctx.message.caption || '';
136
- const upperText = text.toUpperCase();
 
 
137
 
138
- // Detect grid dimension based on phrases or explicit NxN format
139
- let gridSize = 8;
140
- if (upperText.includes('HARD MODE CHALLENGE')) {
141
- gridSize = 10;
142
- } else if (upperText.includes('WORD GRID CHALLENGE')) {
143
- gridSize = 8;
144
- }
145
 
146
- // Explicit override still has highest priority (e.g., "12x12" in caption)
147
- const sizeMatch = text.match(/\b(\d+)\s*[xX*]\s*\1\b/);
148
- if (sizeMatch) {
149
- gridSize = parseInt(sizeMatch[1], 10);
150
- console.log(`Explicit grid size override: ${gridSize}x${gridSize}`);
151
- } else {
152
- console.log(`Detected grid size from phrase/level: ${gridSize}x${gridSize}`);
153
  }
154
 
155
- const grid = await extractGrid(imagePath, gridSize);
156
- if (!grid || grid.length === 0) {
157
- fs.unlinkSync(imagePath);
158
- return ctx.reply('❌ Could not extract grid from image.');
 
159
  }
160
 
161
- stats.imagesProcessed++;
162
- const patterns = parsePatterns(text);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
 
164
- if (patterns.length === 0) {
165
- fs.unlinkSync(imagePath);
166
- return ctx.reply('❓ No word patterns found in caption. Please provide patterns like M--- (4).');
167
- }
168
 
169
- const results = solve(grid, patterns);
170
-
171
- let responseText = '🎯 WORD GRID RESULTS 🎯\n\n';
172
- let foundAny = false;
173
-
174
- for (const p in results) {
175
- foundAny = true;
176
- const targetStart = p[0].toUpperCase();
177
-
178
- if (Array.isArray(results[p])) {
179
- const wordMatches = results[p]
180
- .map(m => {
181
- const match = m.match.toUpperCase();
182
- // 1. Perfect Match?
183
- if (isWord(match) && match[0] === targetStart) return match;
184
-
185
- // 2. OCR Error on first letter? (Try forcing target start)
186
- const forced = targetStart + match.slice(1);
187
- if (isWord(forced)) return forced;
188
-
189
- // Log candidates that are NOT words for debugging
190
- if (match[0] === targetStart) {
191
- console.log(`[Pattern Debug] Rejected non-word candidate for ${p}: ${match}`);
192
- }
193
-
194
- return null;
195
- })
196
- .filter(w => w !== null)
197
- // Remove duplicates
198
- .filter((value, index, self) => self.indexOf(value) === index);
199
-
200
- if (wordMatches.length > 0) {
201
- responseText += `βœ… ${p}: ${wordMatches.map(w => `<code>${w}</code>`).join(', ')}\n`;
202
- stats.wordsFound += wordMatches.length;
203
- }
204
- }
205
- }
206
 
207
- if (responseText === '🎯 WORD GRID RESULTS 🎯\n\n') {
208
- responseText += 'πŸ˜” No real word matches found for these patterns.\n\n';
209
- }
210
 
211
- responseText += '\nπŸ” <b>Extracted Grid (Debug):</b>\n';
212
- responseText += '<pre>' + grid.map(row => row.join(' ')).join('\n') + '</pre>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
 
214
- ctx.reply(responseText, { parse_mode: 'HTML' });
 
 
 
 
215
 
216
- // Cleanup
217
- await deleteFileWithRetry(imagePath);
218
 
219
- } catch (err) {
220
- console.error(err);
221
- ctx.reply('🚨 Error processing image.');
222
- }
223
- });
224
 
225
- function parsePatterns(text) {
226
- const regex = /([A-Z]\-+)\s*\((\d+)\)/g;
227
- const matches = [];
228
- let match;
229
- while ((match = regex.exec(text)) !== null) {
230
- matches.push({ pattern: match[1] });
 
 
 
 
 
 
231
  }
232
- return matches;
233
- }
234
 
235
- if (BOT_TOKEN) {
236
- bot.telegram.getMe().then((me) => {
237
- stats.botUsername = me.username;
238
- console.log(`Bot is running as @${me.username}`);
239
- }).catch(err => {
240
- console.error('Failed to get bot info:', err.message);
241
- });
242
-
243
- // Retry-based launch to handle transient network issues on Hugging Face
244
- const launchBot = async (retries = 5) => {
245
- const options = {};
246
- const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
247
- if (proxyUrl) {
248
- options.telegram = {
249
- agent: new HttpsProxyAgent(proxyUrl)
250
- };
251
- console.log('Telegraf will use proxy:', proxyUrl);
252
- }
253
 
254
- for (let i = 0; i < retries; i++) {
255
- try {
256
- await bot.launch(options);
257
- console.log('Bot launched and polling.');
258
- return;
259
- } catch (err) {
260
- console.error(`Bot launch attempt ${i + 1} failed:`, err.message);
261
- if (i < retries - 1) {
262
- const delay = Math.pow(2, i) * 1000;
263
- console.log(`Retrying in ${delay}ms...`);
264
- await new Promise(resolve => setTimeout(resolve, delay));
265
- } else {
266
- console.error('Max retries reached. Bot failed to launch.');
267
- }
268
- }
269
- }
270
- };
271
 
272
- launchBot();
273
- } else {
274
- console.log('Bot is ready but BOT_TOKEN is missing. Please set it to start the bot.');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  }
276
 
277
- // Express Server for Hugging Face / Dashboard
278
- const app = express();
279
- const port = process.env.PORT || 7860;
280
 
281
  app.use(express.static(path.join(__dirname, 'public')));
282
 
283
- app.get('/api/stats', (req, res) => {
284
- res.json({
285
- ...stats,
286
- uptime: Math.floor((Date.now() - stats.startTime) / 1000)
287
- });
288
  });
289
 
290
- app.listen(port, () => {
291
- console.log(`Dashboard running on port ${port}`);
292
  });
293
 
294
- // Enable graceful stop
295
- process.once('SIGINT', () => {
296
- bot.stop('SIGINT');
297
- process.exit(0);
298
- });
299
- process.once('SIGTERM', () => {
300
- bot.stop('SIGTERM');
301
- process.exit(0);
302
  });
 
1
+ /**
2
+ * bot.js β€” Word Grid Solver Bot (GramJS / pure MTProto)
3
+ *
4
+ * Uses the `telegram` npm package (GramJS) with a BOT_TOKEN for pure MTProto,
5
+ * no webhooks, no HTTP polling through Bot API JSON layer.
6
+ *
7
+ * Required env vars:
8
+ * BOT_TOKEN – Telegram bot token (from @BotFather)
9
+ * API_ID – Telegram API ID (from my.telegram.org)
10
+ * API_HASH – Telegram API hash (from my.telegram.org)
11
+ *
12
+ * Optional:
13
+ * PORT – HTTP dashboard port (default 7860)
14
+ */
15
+
16
+ 'use strict';
17
+
18
+ require('dotenv').config();
19
+
20
+ const { TelegramClient } = require('telegram');
21
+ const { StringSession } = require('telegram/sessions');
22
+ const { NewMessage } = require('telegram/events');
23
+ const { Api } = require('telegram');
24
+
25
  const express = require('express');
26
+ const fs = require('fs');
27
+ const path = require('path');
28
+ const axios = require('axios');
29
 
30
  const { extractGrid } = require('./ocr');
31
+ const { solve } = require('./solver');
 
32
 
33
+ // ─── Environment ──────────────────────────────────────────────────────────────
34
+ const BOT_TOKEN = process.env.BOT_TOKEN;
35
+ const API_ID = parseInt(process.env.API_ID || '0', 10);
36
+ const API_HASH = process.env.API_HASH || '';
 
 
 
37
 
38
+ if (!BOT_TOKEN) {
39
+ console.error('[FATAL] BOT_TOKEN is required.');
40
+ process.exit(1);
41
+ }
42
+ if (!API_ID || !API_HASH) {
43
+ console.error('[FATAL] API_ID and API_HASH are required for GramJS MTProto.');
44
+ process.exit(1);
45
+ }
46
 
47
+ // ─── Dictionary ───────────────────────────────────────────────────────────────
48
  const dictionaryPath = path.join(__dirname, 'node_modules/check-word/words/en.txt');
49
  const dictionary = new Set();
50
  try {
51
+ const data = fs.readFileSync(dictionaryPath, 'utf8');
52
+ data.split('\n').forEach(line => {
53
+ const w = line.trim().toLowerCase();
54
+ if (w.length >= 3) dictionary.add(w);
55
+ });
56
+ console.log(`[Dict] Loaded ${dictionary.size} words.`);
57
  } catch (err) {
58
+ console.error('[Dict] Failed to load dictionary:', err.message);
59
  }
60
 
61
  function isWord(w) {
62
+ return dictionary.has((w || '').toLowerCase());
 
 
 
 
 
63
  }
64
 
65
+ // ─── Stats ────────────────────────────────────────────────────────────────────
66
+ const stats = {
67
+ imagesProcessed: 0,
68
+ wordsFound: 0,
69
+ startTime: Date.now(),
70
+ botUsername: 'loading...',
71
+ };
 
 
 
 
72
 
73
+ // ─── Helpers ──────────────────────────────────────────────────────────────────
74
+ async function deleteFile(filePath) {
75
+ for (let i = 0; i < 5; i++) {
76
  try {
77
+ if (fs.existsSync(filePath)) fs.unlinkSync(filePath);
78
+ return;
 
79
  } catch (e) {
80
+ await sleep(800);
81
  }
82
+ }
83
+ }
84
 
85
+ function sleep(ms) {
86
+ return new Promise(r => setTimeout(r, ms));
87
+ }
 
 
 
 
88
 
89
+ /**
90
+ * Parse word patterns from caption text.
91
+ * Accepts formats like: M--- (4) or M---- or MATRIX (6)
92
+ */
93
+ function parsePatterns(text) {
94
+ const results = [];
95
+
96
+ // Format 1: M--- (4) β€” pattern with explicit length
97
+ const re1 = /([A-Z])(-+)\s*\(\d+\)/gi;
98
+ let m;
99
+ while ((m = re1.exec(text)) !== null) {
100
+ const pattern = (m[1] + m[2]).toUpperCase();
101
+ results.push({ pattern });
102
+ }
103
+
104
+ // Format 2: standalone pattern like M--- (3+ dashes, capital start)
105
+ const re2 = /\b([A-Z])(-{2,})\b/g;
106
+ while ((m = re2.exec(text)) !== null) {
107
+ const pattern = (m[1] + m[2]).toUpperCase();
108
+ if (!results.find(r => r.pattern === pattern)) {
109
+ results.push({ pattern });
 
 
110
  }
111
+ }
112
+
113
+ return results;
114
  }
115
 
116
+ /**
117
+ * Detect grid size from caption text heuristics or explicit NxN.
118
+ */
119
+ function detectGridSizeFromCaption(text) {
120
+ const upper = text.toUpperCase();
121
+
122
+ // Explicit NxN override
123
+ const sizeMatch = text.match(/\b(\d+)\s*[xXΓ—]\s*\1\b/);
124
+ if (sizeMatch) {
125
+ const n = parseInt(sizeMatch[1], 10);
126
+ if (n >= 4 && n <= 15) {
127
+ console.log(`[Grid] Explicit size override: ${n}Γ—${n}`);
128
+ return n;
129
+ }
130
+ }
131
 
132
+ if (upper.includes('HARD MODE') || upper.includes('10X10') || upper.includes('10 X 10')) {
133
+ console.log('[Grid] Detected 10Γ—10 from caption phrase.');
134
+ return 10;
135
+ }
136
 
137
+ // Let OCR auto-detect β€” return null
138
+ return null;
139
+ }
140
 
141
+ /**
142
+ * Format results into a Telegram HTML message.
143
+ */
144
+ function formatResults(results, grid, patterns) {
145
+ let msg = '🎯 <b>WORD GRID RESULTS</b>\n\n';
146
+ let foundAny = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
 
148
+ for (const p of patterns) {
149
+ const key = p.pattern || p.word;
150
+ if (!key) continue;
151
 
152
+ const resultEntry = results[key];
153
+ if (!resultEntry) continue;
154
 
155
+ if (Array.isArray(resultEntry)) {
156
+ // Pattern search β€” validate against dictionary
157
+ const startChar = key[0].toUpperCase();
158
+ const wordMatches = [];
159
 
160
+ for (const hit of resultEntry) {
161
+ const raw = hit.match.toUpperCase();
 
 
 
 
 
162
 
163
+ // Exact word?
164
+ if (isWord(raw)) {
165
+ wordMatches.push(raw);
166
+ continue;
 
 
 
167
  }
168
 
169
+ // Try forcing the known start character (OCR may have mis-read first char)
170
+ const forced = startChar + raw.slice(1);
171
+ if (isWord(forced)) {
172
+ wordMatches.push(forced);
173
+ continue;
174
  }
175
 
176
+ // Try looking at all lookalike combos for first char
177
+ // (already handled by charMatch in solver, just log for debug)
178
+ console.log(`[Solver] Rejected non-word for ${key}: ${raw}`);
179
+ }
180
+
181
+ // Deduplicate
182
+ const unique = [...new Set(wordMatches)];
183
+ if (unique.length > 0) {
184
+ msg += `βœ… ${key}: ${unique.map(w => `<code>${w}</code>`).join(', ')}\n`;
185
+ stats.wordsFound += unique.length;
186
+ foundAny = true;
187
+ } else {
188
+ msg += `❓ ${key}: no valid words found\n`;
189
+ }
190
+ } else {
191
+ // Exact word found
192
+ msg += `βœ… <code>${resultEntry.match}</code> at [${resultEntry.r},${resultEntry.c}] dir:${resultEntry.dir}\n`;
193
+ foundAny = true;
194
+ }
195
+ }
196
 
197
+ if (!foundAny) {
198
+ msg += 'πŸ˜” No real word matches found for these patterns.\n';
199
+ }
 
200
 
201
+ // Append grid debug
202
+ msg += '\nπŸ” <b>Extracted Grid:</b>\n';
203
+ msg += '<pre>' + grid.map(row => row.join(' ')).join('\n') + '</pre>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
 
205
+ return msg;
206
+ }
 
207
 
208
+ // ─── GramJS Bot Setup ─────────────────────────────────────────────────────────
209
+ async function startBot() {
210
+ // For bots, we use an empty StringSession β€” GramJS handles the rest
211
+ const session = new StringSession('');
212
+
213
+ const client = new TelegramClient(session, API_ID, API_HASH, {
214
+ connectionRetries: 10,
215
+ retryDelay: 2000,
216
+ useWSS: false,
217
+ });
218
+
219
+ console.log('[GramJS] Connecting via MTProto...');
220
+
221
+ // Login as a bot using the token
222
+ await client.start({
223
+ botAuthToken: BOT_TOKEN,
224
+ });
225
+
226
+ console.log('[GramJS] Connected successfully.');
227
+
228
+ const me = await client.getMe();
229
+ stats.botUsername = me.username || 'unknown';
230
+ console.log(`[Bot] Running as @${stats.botUsername}`);
231
+
232
+ // ─── Handle new messages ───────────────────────────────────────────────────
233
+ client.addEventHandler(async (event) => {
234
+ const msg = event.message;
235
+ if (!msg) return;
236
+
237
+ const chatId = msg.peerId;
238
+ const caption = msg.message || '';
239
+
240
+ // /start command
241
+ if (caption.trim() === '/start') {
242
+ await client.sendMessage(chatId, {
243
+ message: 'πŸ‘‹ Welcome to the Word Grid Solver!\n\nSend me a word grid image with your word patterns in the caption.\n\nExample caption: <code>M--- (4) P------- (8)</code>\n\nI support 8Γ—8 and 10Γ—10 grids and auto-detect the size!',
244
+ parseMode: 'html',
245
+ });
246
+ return;
247
+ }
248
 
249
+ // Check if message has a photo
250
+ const hasPhoto = msg.media && (
251
+ msg.media.className === 'MessageMediaPhoto' ||
252
+ (msg.media.document && msg.media.document.mimeType && msg.media.document.mimeType.startsWith('image/'))
253
+ );
254
 
255
+ if (!hasPhoto) return;
 
256
 
257
+ // ── Download image ────────────────────────────────────────────────────────
258
+ const imagePath = path.join(__dirname, `photo_${Date.now()}_${Math.random().toString(36).slice(2)}.jpg`);
259
+ let downloadedOk = false;
 
 
260
 
261
+ try {
262
+ await client.sendMessage(chatId, { message: 'πŸ” Processing your grid image...' });
263
+
264
+ const buffer = await client.downloadMedia(msg.media, { outputFile: Buffer });
265
+ if (!buffer || buffer.length === 0) throw new Error('Empty download buffer');
266
+ fs.writeFileSync(imagePath, buffer);
267
+ downloadedOk = true;
268
+ } catch (dlErr) {
269
+ console.error('[Download] Failed:', dlErr.message);
270
+ await client.sendMessage(chatId, { message: '❌ Failed to download the image. Please try again.' });
271
+ await deleteFile(imagePath);
272
+ return;
273
  }
 
 
274
 
275
+ try {
276
+ stats.imagesProcessed++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
 
278
+ // ── Detect grid size ────────────────────────────────────────────────────
279
+ const forcedSize = detectGridSizeFromCaption(caption);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
 
281
+ // ── Extract grid via OCR ────────────────────────────────────────────────
282
+ const grid = await extractGrid(imagePath, forcedSize);
283
+
284
+ if (!grid || grid.length === 0) {
285
+ await client.sendMessage(chatId, { message: '❌ Could not extract grid from the image. Make sure the grid is clearly visible.' });
286
+ await deleteFile(imagePath);
287
+ return;
288
+ }
289
+
290
+ // ── Parse patterns ──────────────────────────────────────────────────────
291
+ const patterns = parsePatterns(caption);
292
+
293
+ if (patterns.length === 0) {
294
+ // No patterns β†’ just show the grid
295
+ let noPatternMsg = 'πŸ“‹ <b>Grid extracted</b> (no patterns found in caption):\n\n';
296
+ noPatternMsg += '<pre>' + grid.map(r => r.join(' ')).join('\n') + '</pre>';
297
+ noPatternMsg += '\n\nAdd patterns like <code>M--- (4)</code> to the caption to search for words!';
298
+ await client.sendMessage(chatId, { message: noPatternMsg, parseMode: 'html' });
299
+ await deleteFile(imagePath);
300
+ return;
301
+ }
302
+
303
+ // ── Solve ───────────────────────────────────────────────────────────────
304
+ const results = solve(grid, patterns);
305
+
306
+ // ── Format and reply ────────────────────────────────────────────────────
307
+ const reply = formatResults(results, grid, patterns);
308
+
309
+ await client.sendMessage(chatId, { message: reply, parseMode: 'html' });
310
+
311
+ } catch (err) {
312
+ console.error('[Handler] Error:', err);
313
+ await client.sendMessage(chatId, { message: '🚨 An error occurred while processing. Please try again.' });
314
+ } finally {
315
+ await deleteFile(imagePath);
316
+ }
317
+ }, new NewMessage({}));
318
+
319
+ // Keep alive
320
+ console.log('[Bot] Listening for messages...');
321
+
322
+ // Graceful shutdown
323
+ const shutdown = async (signal) => {
324
+ console.log(`[Bot] Received ${signal}, disconnecting...`);
325
+ await client.disconnect();
326
+ process.exit(0);
327
+ };
328
+ process.once('SIGINT', () => shutdown('SIGINT'));
329
+ process.once('SIGTERM', () => shutdown('SIGTERM'));
330
  }
331
 
332
+ // ─── Express Dashboard ────────────────────────────────────────────────────────
333
+ const app = express();
334
+ const PORT = process.env.PORT || 7860;
335
 
336
  app.use(express.static(path.join(__dirname, 'public')));
337
 
338
+ app.get('/api/stats', (_req, res) => {
339
+ res.json({
340
+ ...stats,
341
+ uptime: Math.floor((Date.now() - stats.startTime) / 1000),
342
+ });
343
  });
344
 
345
+ app.listen(PORT, () => {
346
+ console.log(`[Dashboard] Running on port ${PORT}`);
347
  });
348
 
349
+ // ─── Launch ───────────────────────────────────────────────────────────────────
350
+ startBot().catch(err => {
351
+ console.error('[FATAL] Bot startup failed:', err);
352
+ process.exit(1);
 
 
 
 
353
  });
ocr.js CHANGED
@@ -1,106 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
1
  const sharp = require('sharp');
2
  sharp.cache(false);
3
  const { createWorker } = require('tesseract.js');
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  /**
6
- * Ultimate Mathematical + Multi-Pass Voting OCR (Dynamic N x N)
 
 
7
  */
8
- async function extractGrid(imagePath, gridSize = 8) {
9
- let worker = null;
10
- try {
11
- console.log(`Starting Mathematical Voting OCR (${gridSize}x${gridSize})...`);
12
-
13
- worker = await createWorker('eng');
14
- await worker.setParameters({
15
- tessedit_char_whitelist: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
16
- });
17
-
18
- const thresholds = [80, 110, 140, 170, 200];
19
- const allSymbols = [];
20
-
21
- for (const th of thresholds) {
22
- const processedImageBuffer = await sharp(imagePath)
23
- .grayscale()
24
- .negate() // Black on white
25
- .normalize()
26
- .sharpen()
27
- .threshold(th)
28
- .toBuffer();
29
-
30
- const res = await worker.recognize(processedImageBuffer);
31
-
32
- if (res.data.symbols && res.data.symbols.length > 0) {
33
- for (const s of res.data.symbols) {
34
- const text = s.text.replace(/[^A-Z]/gi, '').toUpperCase();
35
- if (text && text.length === 1) {
36
- const midX = (s.bbox.x0 + s.bbox.x1) / 2;
37
- const midY = (s.bbox.y0 + s.bbox.y1) / 2;
38
- allSymbols.push({ char: text, x: midX, y: midY });
39
- }
40
- }
41
- }
42
- }
43
 
44
- if (allSymbols.length === 0) {
45
- await worker.terminate();
46
- return null;
47
- }
48
 
49
- let minX = Infinity, minY = Infinity;
50
- let maxX = -Infinity, maxY = -Infinity;
51
-
52
- for (const s of allSymbols) {
53
- if (s.x < minX) minX = s.x;
54
- if (s.y < minY) minY = s.y;
55
- if (s.x > maxX) maxX = s.x;
56
- if (s.y > maxY) maxY = s.y;
57
- }
58
 
59
- const padX = (maxX - minX) * 0.05;
60
- const padY = (maxY - minY) * 0.05;
61
- minX -= padX;
62
- maxX += padX;
63
- minY -= padY;
64
- maxY += padY;
65
-
66
- const cellW = (maxX - minX) / gridSize;
67
- const cellH = (maxY - minY) / gridSize;
68
-
69
- const cellMap = Array.from({ length: gridSize }, () => Array.from({ length: gridSize }, () => ({})));
70
-
71
- for (const s of allSymbols) {
72
- let c = Math.floor((s.x - minX) / cellW);
73
- let r = Math.floor((s.y - minY) / cellH);
74
-
75
- c = Math.max(0, Math.min(gridSize - 1, c));
76
- r = Math.max(0, Math.min(gridSize - 1, r));
77
-
78
- cellMap[r][c][s.char] = (cellMap[r][c][s.char] || 0) + 1;
79
- }
80
 
81
- const grid = Array.from({ length: gridSize }, () => Array(gridSize).fill(' '));
82
- for (let r = 0; r < gridSize; r++) {
83
- for (let c = 0; c < gridSize; c++) {
84
- const votes = cellMap[r][c];
85
- let bestChar = ' ';
86
- let maxVotes = 0;
87
- for (const char in votes) {
88
- if (votes[char] > maxVotes) {
89
- maxVotes = votes[char];
90
- bestChar = char;
91
- }
92
- }
93
- grid[r][c] = bestChar;
94
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  }
 
 
 
 
 
 
 
 
 
96
 
97
- await worker.terminate();
98
- return grid;
99
- } catch (err) {
100
- console.error('OCR Error:', err);
101
- if (worker) try { await worker.terminate(); } catch(e) {}
102
- return null;
103
  }
 
 
104
  }
105
 
106
  module.exports = { extractGrid };
 
1
+ /**
2
+ * ocr.js β€” Advanced multi-pass Tesseract OCR with auto-detecting grid size
3
+ *
4
+ * Key improvements over v1:
5
+ * β€’ Auto-detect grid size (8Γ—8 vs 10Γ—10 vs other NxN) via symbol clustering
6
+ * β€’ Multi-threshold voting (5 passes) for better letter accuracy
7
+ * β€’ K-means-style column/row centroid detection instead of fixed bucket math
8
+ * β€’ Lookalike-aware majority voting per cell (I/L, O/0, B/8, etc.)
9
+ * β€’ No magic assumption of exactly N symbols – works with noise/gaps
10
+ */
11
+
12
  const sharp = require('sharp');
13
  sharp.cache(false);
14
  const { createWorker } = require('tesseract.js');
15
 
16
+ // ─── OCR lookalike corrections (applied at voting time) ───────────────────────
17
+ const LOOKALIKE_GROUPS = [
18
+ ['I', 'L', '1', '|', 'J'],
19
+ ['O', '0', 'Q', 'D'],
20
+ ['B', '8', '3'],
21
+ ['S', '5'],
22
+ ['G', '6', 'C'],
23
+ ['Z', '2'],
24
+ ['E', 'F'],
25
+ ['U', 'V'],
26
+ ];
27
+
28
+ // Build canonical map: non-alpha β†’ preferred alpha
29
+ const CANONICAL = {};
30
+ for (const group of LOOKALIKE_GROUPS) {
31
+ const alpha = group.find(c => /^[A-Z]$/.test(c));
32
+ if (!alpha) continue;
33
+ for (const c of group) {
34
+ if (!/^[A-Z]$/.test(c)) CANONICAL[c] = alpha;
35
+ }
36
+ }
37
+
38
+ function canonicalise(char) {
39
+ return CANONICAL[char.toUpperCase()] || char.toUpperCase();
40
+ }
41
+
42
+ // ─── Simple 1-D k-means-style centroid finder ─────────────────────────────────
43
  /**
44
+ * Given a sorted list of values and a target cluster count,
45
+ * iteratively refine cluster centroids until stable.
46
+ * Returns sorted list of centroids.
47
  */
48
+ function findCentroids(values, k) {
49
+ if (values.length === 0) return [];
50
+ const sorted = [...values].sort((a, b) => a - b);
51
+ const min = sorted[0], max = sorted[sorted.length - 1];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
+ if (k <= 1) return [(min + max) / 2];
 
 
 
54
 
55
+ // Initialise centroids evenly spaced
56
+ let centroids = Array.from({ length: k }, (_, i) => min + (i / (k - 1)) * (max - min));
 
 
 
 
 
 
 
57
 
58
+ for (let iter = 0; iter < 30; iter++) {
59
+ // Assign each value to nearest centroid
60
+ const clusters = Array.from({ length: k }, () => []);
61
+ for (const v of sorted) {
62
+ let best = 0, bestDist = Infinity;
63
+ for (let i = 0; i < k; i++) {
64
+ const d = Math.abs(v - centroids[i]);
65
+ if (d < bestDist) { bestDist = d; best = i; }
66
+ }
67
+ clusters[best].push(v);
68
+ }
69
+
70
+ // Recompute centroids
71
+ const newCentroids = centroids.map((c, i) => {
72
+ if (clusters[i].length === 0) return c;
73
+ return clusters[i].reduce((a, b) => a + b, 0) / clusters[i].length;
74
+ });
 
 
 
 
75
 
76
+ // Check convergence
77
+ const moved = newCentroids.some((nc, i) => Math.abs(nc - centroids[i]) > 0.01);
78
+ centroids = newCentroids;
79
+ if (!moved) break;
80
+ }
81
+
82
+ return centroids.sort((a, b) => a - b);
83
+ }
84
+
85
+ // ─── Auto-detect grid size from symbol cloud ──────────────────────────────────
86
+ /**
87
+ * Try k=8 and k=10 clusterings on the X coordinates.
88
+ * Pick whichever produces tighter within-cluster variance.
89
+ */
90
+ function detectGridSize(xs) {
91
+ if (xs.length === 0) return 8;
92
+
93
+ const tryK = (k) => {
94
+ const cents = findCentroids(xs, k);
95
+ let totalVar = 0;
96
+ const clusters = Array.from({ length: k }, () => []);
97
+ for (const x of xs) {
98
+ let best = 0, bestDist = Infinity;
99
+ for (let i = 0; i < k; i++) {
100
+ const d = Math.abs(x - cents[i]);
101
+ if (d < bestDist) { bestDist = d; best = i; }
102
+ }
103
+ clusters[best].push(x);
104
+ }
105
+ for (const cl of clusters) {
106
+ if (cl.length === 0) continue;
107
+ const mean = cl.reduce((a, b) => a + b, 0) / cl.length;
108
+ totalVar += cl.reduce((s, v) => s + (v - mean) ** 2, 0);
109
+ }
110
+ // Normalise by k so we compare fairly
111
+ return totalVar / k;
112
+ };
113
+
114
+ // If very few symbols, default to 8
115
+ if (xs.length < 30) return 8;
116
+
117
+ const v8 = tryK(8);
118
+ const v10 = tryK(10);
119
+
120
+ // Heuristic: also check symbol density
121
+ // A 10Γ—10 grid should have ~100 symbols; an 8Γ—8 ~ 64
122
+ const symbolCount = xs.length;
123
+ if (symbolCount > 350) return 10; // many multi-pass hits β†’ likely 10Γ—10
124
+
125
+ // Use variance ratio to decide
126
+ // If v10 is significantly better (lower) than v8, go with 10
127
+ return (v10 < v8 * 0.85) ? 10 : 8;
128
+ }
129
+
130
+ // ─── Main extractGrid function ────────────────────────────────────────────────
131
+ /**
132
+ * @param {string} imagePath
133
+ * @param {number|null} forcedSize - if null, auto-detect
134
+ * @returns {string[][]|null}
135
+ */
136
+ async function extractGrid(imagePath, forcedSize = null) {
137
+ let worker = null;
138
+ try {
139
+ const THRESHOLDS = [70, 100, 130, 160, 190, 210];
140
+ const allSymbols = []; // { char, x, y }
141
+
142
+ worker = await createWorker('eng');
143
+ await worker.setParameters({
144
+ tessedit_char_whitelist: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
145
+ tessedit_pageseg_mode: '6', // Assume uniform block of text
146
+ });
147
+
148
+ for (const th of THRESHOLDS) {
149
+ let buf;
150
+ try {
151
+ buf = await sharp(imagePath)
152
+ .grayscale()
153
+ .normalize()
154
+ .sharpen({ sigma: 1.5 })
155
+ .threshold(th)
156
+ .toBuffer();
157
+ } catch (e) {
158
+ console.warn(`Sharp preprocessing failed at threshold ${th}:`, e.message);
159
+ continue;
160
+ }
161
+
162
+ let res;
163
+ try {
164
+ res = await worker.recognize(buf);
165
+ } catch (e) {
166
+ console.warn(`Tesseract failed at threshold ${th}:`, e.message);
167
+ continue;
168
+ }
169
+
170
+ if (!res.data.symbols) continue;
171
+
172
+ for (const s of res.data.symbols) {
173
+ const raw = (s.text || '').replace(/[^A-Za-z0-9|]/g, '').toUpperCase();
174
+ if (!raw || raw.length !== 1) continue;
175
+ const ch = canonicalise(raw);
176
+ if (!/^[A-Z]$/.test(ch)) continue;
177
+
178
+ const midX = (s.bbox.x0 + s.bbox.x1) / 2;
179
+ const midY = (s.bbox.y0 + s.bbox.y1) / 2;
180
+ allSymbols.push({ char: ch, x: midX, y: midY });
181
+ }
182
+ }
183
+
184
+ await worker.terminate();
185
+ worker = null;
186
+
187
+ if (allSymbols.length === 0) {
188
+ console.warn('No symbols detected from OCR.');
189
+ return null;
190
+ }
191
+
192
+ console.log(`Total symbol observations (all passes): ${allSymbols.length}`);
193
+
194
+ // ── Detect or use forced grid size ──
195
+ const xs = allSymbols.map(s => s.x);
196
+ const ys = allSymbols.map(s => s.y);
197
+
198
+ const gridSize = forcedSize !== null ? forcedSize : detectGridSize(xs);
199
+ console.log(`Using grid size: ${gridSize}Γ—${gridSize}`);
200
+
201
+ // ── Cluster columns and rows ──
202
+ const colCentroids = findCentroids(xs, gridSize);
203
+ const rowCentroids = findCentroids(ys, gridSize);
204
+
205
+ // ── Vote per cell ──
206
+ // cellVotes[r][c] = { char: count }
207
+ const cellVotes = Array.from({ length: gridSize }, () =>
208
+ Array.from({ length: gridSize }, () => ({}))
209
+ );
210
+
211
+ const colSpan = colCentroids.length > 1
212
+ ? (colCentroids[colCentroids.length - 1] - colCentroids[0]) / (gridSize - 1)
213
+ : 50;
214
+ const rowSpan = rowCentroids.length > 1
215
+ ? (rowCentroids[rowCentroids.length - 1] - rowCentroids[0]) / (gridSize - 1)
216
+ : 50;
217
+ const colTol = colSpan * 0.5;
218
+ const rowTol = rowSpan * 0.5;
219
+
220
+ for (const s of allSymbols) {
221
+ // Assign to nearest column centroid within tolerance
222
+ let bestC = -1, bestCDist = Infinity;
223
+ for (let i = 0; i < colCentroids.length; i++) {
224
+ const d = Math.abs(s.x - colCentroids[i]);
225
+ if (d < bestCDist) { bestCDist = d; bestC = i; }
226
+ }
227
+ if (bestCDist > colTol * 2) continue; // too far from any centroid β†’ noise
228
+
229
+ let bestR = -1, bestRDist = Infinity;
230
+ for (let i = 0; i < rowCentroids.length; i++) {
231
+ const d = Math.abs(s.y - rowCentroids[i]);
232
+ if (d < bestRDist) { bestRDist = d; bestR = i; }
233
+ }
234
+ if (bestRDist > rowTol * 2) continue;
235
+
236
+ cellVotes[bestR][bestC][s.char] = (cellVotes[bestR][bestC][s.char] || 0) + 1;
237
+ }
238
+
239
+ // ── Build final grid ──
240
+ const grid = Array.from({ length: gridSize }, (_, r) =>
241
+ Array.from({ length: gridSize }, (_, c) => {
242
+ const votes = cellVotes[r][c];
243
+ let best = '?', maxV = 0;
244
+ for (const [ch, v] of Object.entries(votes)) {
245
+ if (v > maxV) { maxV = v; best = ch; }
246
  }
247
+ return best;
248
+ })
249
+ );
250
+
251
+ // Log the extracted grid for debugging
252
+ console.log('Extracted grid:');
253
+ for (const row of grid) {
254
+ console.log(row.join(' '));
255
+ }
256
 
257
+ return grid;
258
+ } catch (err) {
259
+ console.error('OCR Error:', err);
260
+ if (worker) {
261
+ try { await worker.terminate(); } catch (_) {}
 
262
  }
263
+ return null;
264
+ }
265
  }
266
 
267
  module.exports = { extractGrid };
package-lock.json CHANGED
@@ -1,22 +1,30 @@
1
  {
2
  "name": "wordgridsolver",
3
- "version": "1.0.0",
4
  "lockfileVersion": 3,
5
  "requires": true,
6
  "packages": {
7
  "": {
8
  "name": "wordgridsolver",
9
- "version": "1.0.0",
10
  "dependencies": {
11
  "axios": "^1.6.0",
 
12
  "check-word": "^1.1.0",
13
  "dotenv": "^17.4.2",
14
  "express": "^5.2.1",
 
15
  "sharp": "^0.34.5",
16
- "telegraf": "^4.14.0",
17
  "tesseract.js": "^5.0.0"
18
  }
19
  },
 
 
 
 
 
 
20
  "node_modules/@emnapi/runtime": {
21
  "version": "1.9.2",
22
  "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.9.2.tgz",
@@ -492,24 +500,6 @@
492
  "url": "https://opencollective.com/libvips"
493
  }
494
  },
495
- "node_modules/@telegraf/types": {
496
- "version": "7.1.0",
497
- "resolved": "https://registry.npmjs.org/@telegraf/types/-/types-7.1.0.tgz",
498
- "integrity": "sha512-kGevOIbpMcIlCDeorKGpwZmdH7kHbqlk/Yj6dEpJMKEQw5lk0KVQY0OLXaCswy8GqlIVLd5625OB+rAntP9xVw==",
499
- "license": "MIT"
500
- },
501
- "node_modules/abort-controller": {
502
- "version": "3.0.0",
503
- "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
504
- "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
505
- "license": "MIT",
506
- "dependencies": {
507
- "event-target-shim": "^5.0.0"
508
- },
509
- "engines": {
510
- "node": ">=6.5"
511
- }
512
- },
513
  "node_modules/accepts": {
514
  "version": "2.0.0",
515
  "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz",
@@ -548,6 +538,42 @@
548
  "url": "https://opencollective.com/express"
549
  }
550
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
551
  "node_modules/asynckit": {
552
  "version": "0.4.0",
553
  "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
@@ -565,6 +591,51 @@
565
  "proxy-from-env": "^2.1.0"
566
  }
567
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
568
  "node_modules/bmp-js": {
569
  "version": "0.1.0",
570
  "resolved": "https://registry.npmjs.org/bmp-js/-/bmp-js-0.1.0.tgz",
@@ -595,27 +666,42 @@
595
  "url": "https://opencollective.com/express"
596
  }
597
  },
598
- "node_modules/buffer-alloc": {
599
- "version": "1.2.0",
600
- "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz",
601
- "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
602
  "license": "MIT",
603
  "dependencies": {
604
- "buffer-alloc-unsafe": "^1.1.0",
605
- "buffer-fill": "^1.0.0"
606
  }
607
  },
608
- "node_modules/buffer-alloc-unsafe": {
609
- "version": "1.1.0",
610
- "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz",
611
- "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==",
612
- "license": "MIT"
613
- },
614
- "node_modules/buffer-fill": {
615
- "version": "1.0.0",
616
- "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz",
617
- "integrity": "sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==",
618
- "license": "MIT"
 
619
  },
620
  "node_modules/bytes": {
621
  "version": "3.1.2",
@@ -655,12 +741,55 @@
655
  "url": "https://github.com/sponsors/ljharb"
656
  }
657
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
658
  "node_modules/check-word": {
659
  "version": "1.1.0",
660
  "resolved": "https://registry.npmjs.org/check-word/-/check-word-1.1.0.tgz",
661
  "integrity": "sha512-lkPjTvHn+3gPQ+sA2Z3QrV9fNqX2NXpvxQIxiG7pQaPQ8NhPR4dUmpHLRlCbqrP5Wo0oAzVVh7MKhwGECcvhyQ==",
662
  "license": "GPL 2.0"
663
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
664
  "node_modules/combined-stream": {
665
  "version": "1.0.8",
666
  "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
@@ -713,6 +842,27 @@
713
  "node": ">=6.6.0"
714
  }
715
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
716
  "node_modules/debug": {
717
  "version": "4.4.3",
718
  "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
@@ -757,6 +907,61 @@
757
  "node": ">=8"
758
  }
759
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
760
  "node_modules/dotenv": {
761
  "version": "17.4.2",
762
  "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz",
@@ -798,6 +1003,15 @@
798
  "node": ">= 0.8"
799
  }
800
  },
 
 
 
 
 
 
 
 
 
801
  "node_modules/es-define-property": {
802
  "version": "1.0.1",
803
  "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
@@ -843,12 +1057,76 @@
843
  "node": ">= 0.4"
844
  }
845
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
846
  "node_modules/escape-html": {
847
  "version": "1.0.3",
848
  "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
849
  "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
850
  "license": "MIT"
851
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
852
  "node_modules/etag": {
853
  "version": "1.8.1",
854
  "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
@@ -858,13 +1136,23 @@
858
  "node": ">= 0.6"
859
  }
860
  },
861
- "node_modules/event-target-shim": {
862
- "version": "5.0.1",
863
- "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
864
- "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
 
 
 
 
 
 
 
 
 
 
865
  "license": "MIT",
866
  "engines": {
867
- "node": ">=6"
868
  }
869
  },
870
  "node_modules/express": {
@@ -935,6 +1223,28 @@
935
  "url": "https://opencollective.com/express"
936
  }
937
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
938
  "node_modules/finalhandler": {
939
  "version": "2.1.1",
940
  "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz",
@@ -1068,6 +1378,24 @@
1068
  "url": "https://github.com/sponsors/ljharb"
1069
  }
1070
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1071
  "node_modules/has-symbols": {
1072
  "version": "1.1.0",
1073
  "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
@@ -1107,6 +1435,25 @@
1107
  "node": ">= 0.4"
1108
  }
1109
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1110
  "node_modules/http-errors": {
1111
  "version": "2.0.1",
1112
  "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
@@ -1149,12 +1496,86 @@
1149
  "integrity": "sha512-yjD9nARJ/jb1g+CvD0tlhUHOrJ9Sy0P8T9MF3YaLlHnSRpwPfpTX0XIvpmw3gAJUmEu3FiICLBDPXVwyEvrleg==",
1150
  "license": "Apache-2.0"
1151
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1152
  "node_modules/inherits": {
1153
  "version": "2.0.4",
1154
  "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
1155
  "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
1156
  "license": "ISC"
1157
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1158
  "node_modules/ipaddr.js": {
1159
  "version": "1.9.1",
1160
  "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
@@ -1170,18 +1591,42 @@
1170
  "integrity": "sha512-FO/Rhvz5tuw4MCWkpMzHFKWD2LsfHzIb7i6MdPYZ/KW7AlxawyLkqdy+jPZP1WubqEADE3O4FUENlJHDfQASRg==",
1171
  "license": "MIT"
1172
  },
 
 
 
 
 
 
 
 
 
 
 
 
1173
  "node_modules/is-promise": {
1174
  "version": "4.0.0",
1175
  "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
1176
  "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==",
1177
  "license": "MIT"
1178
  },
 
 
 
 
 
 
1179
  "node_modules/is-url": {
1180
  "version": "1.2.4",
1181
  "resolved": "https://registry.npmjs.org/is-url/-/is-url-1.2.4.tgz",
1182
  "integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==",
1183
  "license": "MIT"
1184
  },
 
 
 
 
 
 
1185
  "node_modules/math-intrinsics": {
1186
  "version": "1.1.0",
1187
  "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
@@ -1212,6 +1657,18 @@
1212
  "url": "https://github.com/sponsors/sindresorhus"
1213
  }
1214
  },
 
 
 
 
 
 
 
 
 
 
 
 
1215
  "node_modules/mime-db": {
1216
  "version": "1.52.0",
1217
  "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
@@ -1233,21 +1690,18 @@
1233
  "node": ">= 0.6"
1234
  }
1235
  },
1236
- "node_modules/mri": {
1237
- "version": "1.2.0",
1238
- "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
1239
- "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
1240
- "license": "MIT",
1241
- "engines": {
1242
- "node": ">=4"
1243
- }
1244
- },
1245
  "node_modules/ms": {
1246
  "version": "2.1.3",
1247
  "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1248
  "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1249
  "license": "MIT"
1250
  },
 
 
 
 
 
 
1251
  "node_modules/negotiator": {
1252
  "version": "1.0.0",
1253
  "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz",
@@ -1257,6 +1711,12 @@
1257
  "node": ">= 0.6"
1258
  }
1259
  },
 
 
 
 
 
 
1260
  "node_modules/node-fetch": {
1261
  "version": "2.7.0",
1262
  "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
@@ -1277,6 +1737,47 @@
1277
  }
1278
  }
1279
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1280
  "node_modules/object-inspect": {
1281
  "version": "1.13.4",
1282
  "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
@@ -1310,6 +1811,15 @@
1310
  "wrappy": "1"
1311
  }
1312
  },
 
 
 
 
 
 
 
 
 
1313
  "node_modules/opencollective-postinstall": {
1314
  "version": "2.0.3",
1315
  "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz",
@@ -1319,14 +1829,11 @@
1319
  "opencollective-postinstall": "index.js"
1320
  }
1321
  },
1322
- "node_modules/p-timeout": {
1323
- "version": "4.1.0",
1324
- "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-4.1.0.tgz",
1325
- "integrity": "sha512-+/wmHtzJuWii1sXn3HCuH/FTwGhrp4tmJTxSKJbfS+vkipci6osxXM5mY0jUiRzWKMTgUT8l7HFbeSwZAynqHw==",
1326
- "license": "MIT",
1327
- "engines": {
1328
- "node": ">=10"
1329
- }
1330
  },
1331
  "node_modules/parseurl": {
1332
  "version": "1.3.3",
@@ -1337,6 +1844,12 @@
1337
  "node": ">= 0.8"
1338
  }
1339
  },
 
 
 
 
 
 
1340
  "node_modules/path-to-regexp": {
1341
  "version": "8.4.2",
1342
  "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz",
@@ -1408,12 +1921,42 @@
1408
  "node": ">= 0.10"
1409
  }
1410
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1411
  "node_modules/regenerator-runtime": {
1412
  "version": "0.13.11",
1413
  "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
1414
  "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==",
1415
  "license": "MIT"
1416
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
1417
  "node_modules/router": {
1418
  "version": "2.2.0",
1419
  "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
@@ -1430,30 +1973,26 @@
1430
  "node": ">= 18"
1431
  }
1432
  },
1433
- "node_modules/safe-compare": {
1434
- "version": "1.1.4",
1435
- "resolved": "https://registry.npmjs.org/safe-compare/-/safe-compare-1.1.4.tgz",
1436
- "integrity": "sha512-b9wZ986HHCo/HbKrRpBJb2kqXMK9CEWIE1egeEvZsYn69ay3kdfl9nG3RyOcR+jInTDf7a86WQ1d4VJX7goSSQ==",
1437
  "license": "MIT",
1438
  "dependencies": {
1439
- "buffer-alloc": "^1.2.0"
1440
  }
1441
  },
 
 
 
 
 
1442
  "node_modules/safer-buffer": {
1443
  "version": "2.1.2",
1444
  "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
1445
  "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
1446
  "license": "MIT"
1447
  },
1448
- "node_modules/sandwich-stream": {
1449
- "version": "2.0.2",
1450
- "resolved": "https://registry.npmjs.org/sandwich-stream/-/sandwich-stream-2.0.2.tgz",
1451
- "integrity": "sha512-jLYV0DORrzY3xaz/S9ydJL6Iz7essZeAfnAavsJ+zsJGZ1MOnsS52yRjU3uF3pJa/lla7+wisp//fxOwOH8SKQ==",
1452
- "license": "Apache-2.0",
1453
- "engines": {
1454
- "node": ">= 0.10"
1455
- }
1456
- },
1457
  "node_modules/semver": {
1458
  "version": "7.7.4",
1459
  "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
@@ -1658,6 +2197,39 @@
1658
  "url": "https://github.com/sponsors/ljharb"
1659
  }
1660
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1661
  "node_modules/statuses": {
1662
  "version": "2.0.2",
1663
  "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
@@ -1667,26 +2239,71 @@
1667
  "node": ">= 0.8"
1668
  }
1669
  },
1670
- "node_modules/telegraf": {
1671
- "version": "4.16.3",
1672
- "resolved": "https://registry.npmjs.org/telegraf/-/telegraf-4.16.3.tgz",
1673
- "integrity": "sha512-yjEu2NwkHlXu0OARWoNhJlIjX09dRktiMQFsM678BAH/PEPVwctzL67+tvXqLCRQQvm3SDtki2saGO9hLlz68w==",
 
 
 
 
 
 
1674
  "license": "MIT",
1675
  "dependencies": {
1676
- "@telegraf/types": "^7.1.0",
1677
- "abort-controller": "^3.0.0",
1678
- "debug": "^4.3.4",
1679
- "mri": "^1.2.0",
1680
- "node-fetch": "^2.7.0",
1681
- "p-timeout": "^4.1.0",
1682
- "safe-compare": "^1.1.4",
1683
- "sandwich-stream": "^2.0.2"
1684
  },
1685
- "bin": {
1686
- "telegraf": "lib/cli.mjs"
 
 
 
 
 
 
 
 
 
1687
  },
1688
  "engines": {
1689
- "node": "^12.20.0 || >=14.13.1"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1690
  }
1691
  },
1692
  "node_modules/tesseract.js": {
@@ -1714,6 +2331,12 @@
1714
  "integrity": "sha512-KX3bYSU5iGcO1XJa+QGPbi+Zjo2qq6eBhNjSGR5E5q0JtzkoipJKOUQD7ph8kFyteCEfEQ0maWLu8MCXtvX5uQ==",
1715
  "license": "Apache-2.0"
1716
  },
 
 
 
 
 
 
1717
  "node_modules/toidentifier": {
1718
  "version": "1.0.1",
1719
  "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
@@ -1729,12 +2352,26 @@
1729
  "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
1730
  "license": "MIT"
1731
  },
 
 
 
 
 
 
 
 
 
1732
  "node_modules/tslib": {
1733
  "version": "2.8.1",
1734
  "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
1735
  "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
1736
- "license": "0BSD",
1737
- "optional": true
 
 
 
 
 
1738
  },
1739
  "node_modules/type-is": {
1740
  "version": "2.0.1",
@@ -1775,6 +2412,15 @@
1775
  "url": "https://opencollective.com/express"
1776
  }
1777
  },
 
 
 
 
 
 
 
 
 
1778
  "node_modules/unpipe": {
1779
  "version": "1.0.0",
1780
  "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
@@ -1784,6 +2430,19 @@
1784
  "node": ">= 0.8"
1785
  }
1786
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
1787
  "node_modules/vary": {
1788
  "version": "1.1.2",
1789
  "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
@@ -1805,6 +2464,38 @@
1805
  "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
1806
  "license": "BSD-2-Clause"
1807
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1808
  "node_modules/whatwg-url": {
1809
  "version": "5.0.0",
1810
  "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
@@ -1821,6 +2512,27 @@
1821
  "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
1822
  "license": "ISC"
1823
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1824
  "node_modules/zlibjs": {
1825
  "version": "0.3.1",
1826
  "resolved": "https://registry.npmjs.org/zlibjs/-/zlibjs-0.3.1.tgz",
 
1
  {
2
  "name": "wordgridsolver",
3
+ "version": "2.0.0",
4
  "lockfileVersion": 3,
5
  "requires": true,
6
  "packages": {
7
  "": {
8
  "name": "wordgridsolver",
9
+ "version": "2.0.0",
10
  "dependencies": {
11
  "axios": "^1.6.0",
12
+ "big-integer": "^1.6.52",
13
  "check-word": "^1.1.0",
14
  "dotenv": "^17.4.2",
15
  "express": "^5.2.1",
16
+ "input": "^1.0.1",
17
  "sharp": "^0.34.5",
18
+ "telegram": "^2.26.0",
19
  "tesseract.js": "^5.0.0"
20
  }
21
  },
22
+ "node_modules/@cryptography/aes": {
23
+ "version": "0.1.1",
24
+ "resolved": "https://registry.npmjs.org/@cryptography/aes/-/aes-0.1.1.tgz",
25
+ "integrity": "sha512-PcYz4FDGblO6tM2kSC+VzhhK62vml6k6/YAkiWtyPvrgJVfnDRoHGDtKn5UiaRRUrvUTTocBpvc2rRgTCqxjsg==",
26
+ "license": "GPL-3.0-or-later"
27
+ },
28
  "node_modules/@emnapi/runtime": {
29
  "version": "1.9.2",
30
  "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.9.2.tgz",
 
500
  "url": "https://opencollective.com/libvips"
501
  }
502
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
503
  "node_modules/accepts": {
504
  "version": "2.0.0",
505
  "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz",
 
538
  "url": "https://opencollective.com/express"
539
  }
540
  },
541
+ "node_modules/ansi-escapes": {
542
+ "version": "1.4.0",
543
+ "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz",
544
+ "integrity": "sha512-wiXutNjDUlNEDWHcYH3jtZUhd3c4/VojassD8zHdHCY13xbZy2XbW+NKQwA0tWGBVzDA9qEzYwfoSsWmviidhw==",
545
+ "license": "MIT",
546
+ "engines": {
547
+ "node": ">=0.10.0"
548
+ }
549
+ },
550
+ "node_modules/ansi-regex": {
551
+ "version": "2.1.1",
552
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
553
+ "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==",
554
+ "license": "MIT",
555
+ "engines": {
556
+ "node": ">=0.10.0"
557
+ }
558
+ },
559
+ "node_modules/ansi-styles": {
560
+ "version": "2.2.1",
561
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
562
+ "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==",
563
+ "license": "MIT",
564
+ "engines": {
565
+ "node": ">=0.10.0"
566
+ }
567
+ },
568
+ "node_modules/async-mutex": {
569
+ "version": "0.3.2",
570
+ "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.3.2.tgz",
571
+ "integrity": "sha512-HuTK7E7MT7jZEh1P9GtRW9+aTWiDWWi9InbZ5hjxrnRa39KS4BW04+xLBhYNS2aXhHUIKZSw3gj4Pn1pj+qGAA==",
572
+ "license": "MIT",
573
+ "dependencies": {
574
+ "tslib": "^2.3.1"
575
+ }
576
+ },
577
  "node_modules/asynckit": {
578
  "version": "0.4.0",
579
  "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
 
591
  "proxy-from-env": "^2.1.0"
592
  }
593
  },
594
+ "node_modules/babel-runtime": {
595
+ "version": "6.26.0",
596
+ "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
597
+ "integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==",
598
+ "license": "MIT",
599
+ "dependencies": {
600
+ "core-js": "^2.4.0",
601
+ "regenerator-runtime": "^0.11.0"
602
+ }
603
+ },
604
+ "node_modules/babel-runtime/node_modules/regenerator-runtime": {
605
+ "version": "0.11.1",
606
+ "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
607
+ "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==",
608
+ "license": "MIT"
609
+ },
610
+ "node_modules/base64-js": {
611
+ "version": "1.5.1",
612
+ "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
613
+ "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
614
+ "funding": [
615
+ {
616
+ "type": "github",
617
+ "url": "https://github.com/sponsors/feross"
618
+ },
619
+ {
620
+ "type": "patreon",
621
+ "url": "https://www.patreon.com/feross"
622
+ },
623
+ {
624
+ "type": "consulting",
625
+ "url": "https://feross.org/support"
626
+ }
627
+ ],
628
+ "license": "MIT"
629
+ },
630
+ "node_modules/big-integer": {
631
+ "version": "1.6.52",
632
+ "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.52.tgz",
633
+ "integrity": "sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==",
634
+ "license": "Unlicense",
635
+ "engines": {
636
+ "node": ">=0.6"
637
+ }
638
+ },
639
  "node_modules/bmp-js": {
640
  "version": "0.1.0",
641
  "resolved": "https://registry.npmjs.org/bmp-js/-/bmp-js-0.1.0.tgz",
 
666
  "url": "https://opencollective.com/express"
667
  }
668
  },
669
+ "node_modules/buffer": {
670
+ "version": "6.0.3",
671
+ "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
672
+ "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
673
+ "funding": [
674
+ {
675
+ "type": "github",
676
+ "url": "https://github.com/sponsors/feross"
677
+ },
678
+ {
679
+ "type": "patreon",
680
+ "url": "https://www.patreon.com/feross"
681
+ },
682
+ {
683
+ "type": "consulting",
684
+ "url": "https://feross.org/support"
685
+ }
686
+ ],
687
  "license": "MIT",
688
  "dependencies": {
689
+ "base64-js": "^1.3.1",
690
+ "ieee754": "^1.2.1"
691
  }
692
  },
693
+ "node_modules/bufferutil": {
694
+ "version": "4.1.0",
695
+ "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.1.0.tgz",
696
+ "integrity": "sha512-ZMANVnAixE6AWWnPzlW2KpUrxhm9woycYvPOo67jWHyFowASTEd9s+QN1EIMsSDtwhIxN4sWE1jotpuDUIgyIw==",
697
+ "hasInstallScript": true,
698
+ "license": "MIT",
699
+ "dependencies": {
700
+ "node-gyp-build": "^4.3.0"
701
+ },
702
+ "engines": {
703
+ "node": ">=6.14.2"
704
+ }
705
  },
706
  "node_modules/bytes": {
707
  "version": "3.1.2",
 
741
  "url": "https://github.com/sponsors/ljharb"
742
  }
743
  },
744
+ "node_modules/chalk": {
745
+ "version": "1.1.3",
746
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
747
+ "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==",
748
+ "license": "MIT",
749
+ "dependencies": {
750
+ "ansi-styles": "^2.2.1",
751
+ "escape-string-regexp": "^1.0.2",
752
+ "has-ansi": "^2.0.0",
753
+ "strip-ansi": "^3.0.0",
754
+ "supports-color": "^2.0.0"
755
+ },
756
+ "engines": {
757
+ "node": ">=0.10.0"
758
+ }
759
+ },
760
  "node_modules/check-word": {
761
  "version": "1.1.0",
762
  "resolved": "https://registry.npmjs.org/check-word/-/check-word-1.1.0.tgz",
763
  "integrity": "sha512-lkPjTvHn+3gPQ+sA2Z3QrV9fNqX2NXpvxQIxiG7pQaPQ8NhPR4dUmpHLRlCbqrP5Wo0oAzVVh7MKhwGECcvhyQ==",
764
  "license": "GPL 2.0"
765
  },
766
+ "node_modules/cli-cursor": {
767
+ "version": "1.0.2",
768
+ "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz",
769
+ "integrity": "sha512-25tABq090YNKkF6JH7lcwO0zFJTRke4Jcq9iX2nr/Sz0Cjjv4gckmwlW6Ty/aoyFd6z3ysR2hMGC2GFugmBo6A==",
770
+ "license": "MIT",
771
+ "dependencies": {
772
+ "restore-cursor": "^1.0.1"
773
+ },
774
+ "engines": {
775
+ "node": ">=0.10.0"
776
+ }
777
+ },
778
+ "node_modules/cli-width": {
779
+ "version": "2.2.1",
780
+ "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.1.tgz",
781
+ "integrity": "sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==",
782
+ "license": "ISC"
783
+ },
784
+ "node_modules/code-point-at": {
785
+ "version": "1.1.0",
786
+ "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
787
+ "integrity": "sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==",
788
+ "license": "MIT",
789
+ "engines": {
790
+ "node": ">=0.10.0"
791
+ }
792
+ },
793
  "node_modules/combined-stream": {
794
  "version": "1.0.8",
795
  "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
 
842
  "node": ">=6.6.0"
843
  }
844
  },
845
+ "node_modules/core-js": {
846
+ "version": "2.6.12",
847
+ "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz",
848
+ "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==",
849
+ "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.",
850
+ "hasInstallScript": true,
851
+ "license": "MIT"
852
+ },
853
+ "node_modules/d": {
854
+ "version": "1.0.2",
855
+ "resolved": "https://registry.npmjs.org/d/-/d-1.0.2.tgz",
856
+ "integrity": "sha512-MOqHvMWF9/9MX6nza0KgvFH4HpMU0EF5uUDXqX/BtxtU8NfB0QzRtJ8Oe/6SuS4kbhyzVJwjd97EA4PKrzJ8bw==",
857
+ "license": "ISC",
858
+ "dependencies": {
859
+ "es5-ext": "^0.10.64",
860
+ "type": "^2.7.2"
861
+ },
862
+ "engines": {
863
+ "node": ">=0.12"
864
+ }
865
+ },
866
  "node_modules/debug": {
867
  "version": "4.4.3",
868
  "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
 
907
  "node": ">=8"
908
  }
909
  },
910
+ "node_modules/dom-serializer": {
911
+ "version": "1.4.1",
912
+ "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz",
913
+ "integrity": "sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==",
914
+ "license": "MIT",
915
+ "dependencies": {
916
+ "domelementtype": "^2.0.1",
917
+ "domhandler": "^4.2.0",
918
+ "entities": "^2.0.0"
919
+ },
920
+ "funding": {
921
+ "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
922
+ }
923
+ },
924
+ "node_modules/domelementtype": {
925
+ "version": "2.3.0",
926
+ "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz",
927
+ "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==",
928
+ "funding": [
929
+ {
930
+ "type": "github",
931
+ "url": "https://github.com/sponsors/fb55"
932
+ }
933
+ ],
934
+ "license": "BSD-2-Clause"
935
+ },
936
+ "node_modules/domhandler": {
937
+ "version": "4.3.1",
938
+ "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.1.tgz",
939
+ "integrity": "sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==",
940
+ "license": "BSD-2-Clause",
941
+ "dependencies": {
942
+ "domelementtype": "^2.2.0"
943
+ },
944
+ "engines": {
945
+ "node": ">= 4"
946
+ },
947
+ "funding": {
948
+ "url": "https://github.com/fb55/domhandler?sponsor=1"
949
+ }
950
+ },
951
+ "node_modules/domutils": {
952
+ "version": "2.8.0",
953
+ "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz",
954
+ "integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==",
955
+ "license": "BSD-2-Clause",
956
+ "dependencies": {
957
+ "dom-serializer": "^1.0.1",
958
+ "domelementtype": "^2.2.0",
959
+ "domhandler": "^4.2.0"
960
+ },
961
+ "funding": {
962
+ "url": "https://github.com/fb55/domutils?sponsor=1"
963
+ }
964
+ },
965
  "node_modules/dotenv": {
966
  "version": "17.4.2",
967
  "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz",
 
1003
  "node": ">= 0.8"
1004
  }
1005
  },
1006
+ "node_modules/entities": {
1007
+ "version": "2.2.0",
1008
+ "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz",
1009
+ "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==",
1010
+ "license": "BSD-2-Clause",
1011
+ "funding": {
1012
+ "url": "https://github.com/fb55/entities?sponsor=1"
1013
+ }
1014
+ },
1015
  "node_modules/es-define-property": {
1016
  "version": "1.0.1",
1017
  "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
 
1057
  "node": ">= 0.4"
1058
  }
1059
  },
1060
+ "node_modules/es5-ext": {
1061
+ "version": "0.10.64",
1062
+ "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz",
1063
+ "integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==",
1064
+ "hasInstallScript": true,
1065
+ "license": "ISC",
1066
+ "dependencies": {
1067
+ "es6-iterator": "^2.0.3",
1068
+ "es6-symbol": "^3.1.3",
1069
+ "esniff": "^2.0.1",
1070
+ "next-tick": "^1.1.0"
1071
+ },
1072
+ "engines": {
1073
+ "node": ">=0.10"
1074
+ }
1075
+ },
1076
+ "node_modules/es6-iterator": {
1077
+ "version": "2.0.3",
1078
+ "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
1079
+ "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==",
1080
+ "license": "MIT",
1081
+ "dependencies": {
1082
+ "d": "1",
1083
+ "es5-ext": "^0.10.35",
1084
+ "es6-symbol": "^3.1.1"
1085
+ }
1086
+ },
1087
+ "node_modules/es6-symbol": {
1088
+ "version": "3.1.4",
1089
+ "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.4.tgz",
1090
+ "integrity": "sha512-U9bFFjX8tFiATgtkJ1zg25+KviIXpgRvRHS8sau3GfhVzThRQrOeksPeT0BWW2MNZs1OEWJ1DPXOQMn0KKRkvg==",
1091
+ "license": "ISC",
1092
+ "dependencies": {
1093
+ "d": "^1.0.2",
1094
+ "ext": "^1.7.0"
1095
+ },
1096
+ "engines": {
1097
+ "node": ">=0.12"
1098
+ }
1099
+ },
1100
  "node_modules/escape-html": {
1101
  "version": "1.0.3",
1102
  "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
1103
  "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
1104
  "license": "MIT"
1105
  },
1106
+ "node_modules/escape-string-regexp": {
1107
+ "version": "1.0.5",
1108
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
1109
+ "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==",
1110
+ "license": "MIT",
1111
+ "engines": {
1112
+ "node": ">=0.8.0"
1113
+ }
1114
+ },
1115
+ "node_modules/esniff": {
1116
+ "version": "2.0.1",
1117
+ "resolved": "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz",
1118
+ "integrity": "sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==",
1119
+ "license": "ISC",
1120
+ "dependencies": {
1121
+ "d": "^1.0.1",
1122
+ "es5-ext": "^0.10.62",
1123
+ "event-emitter": "^0.3.5",
1124
+ "type": "^2.7.2"
1125
+ },
1126
+ "engines": {
1127
+ "node": ">=0.10"
1128
+ }
1129
+ },
1130
  "node_modules/etag": {
1131
  "version": "1.8.1",
1132
  "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
 
1136
  "node": ">= 0.6"
1137
  }
1138
  },
1139
+ "node_modules/event-emitter": {
1140
+ "version": "0.3.5",
1141
+ "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz",
1142
+ "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==",
1143
+ "license": "MIT",
1144
+ "dependencies": {
1145
+ "d": "1",
1146
+ "es5-ext": "~0.10.14"
1147
+ }
1148
+ },
1149
+ "node_modules/exit-hook": {
1150
+ "version": "1.1.1",
1151
+ "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz",
1152
+ "integrity": "sha512-MsG3prOVw1WtLXAZbM3KiYtooKR1LvxHh3VHsVtIy0uiUu8usxgB/94DP2HxtD/661lLdB6yzQ09lGJSQr6nkg==",
1153
  "license": "MIT",
1154
  "engines": {
1155
+ "node": ">=0.10.0"
1156
  }
1157
  },
1158
  "node_modules/express": {
 
1223
  "url": "https://opencollective.com/express"
1224
  }
1225
  },
1226
+ "node_modules/ext": {
1227
+ "version": "1.7.0",
1228
+ "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz",
1229
+ "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==",
1230
+ "license": "ISC",
1231
+ "dependencies": {
1232
+ "type": "^2.7.2"
1233
+ }
1234
+ },
1235
+ "node_modules/figures": {
1236
+ "version": "1.7.0",
1237
+ "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz",
1238
+ "integrity": "sha512-UxKlfCRuCBxSXU4C6t9scbDyWZ4VlaFFdojKtzJuSkuOBQ5CNFum+zZXFwHjo+CxBC1t6zlYPgHIgFjL8ggoEQ==",
1239
+ "license": "MIT",
1240
+ "dependencies": {
1241
+ "escape-string-regexp": "^1.0.5",
1242
+ "object-assign": "^4.1.0"
1243
+ },
1244
+ "engines": {
1245
+ "node": ">=0.10.0"
1246
+ }
1247
+ },
1248
  "node_modules/finalhandler": {
1249
  "version": "2.1.1",
1250
  "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz",
 
1378
  "url": "https://github.com/sponsors/ljharb"
1379
  }
1380
  },
1381
+ "node_modules/graceful-fs": {
1382
+ "version": "4.2.11",
1383
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
1384
+ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
1385
+ "license": "ISC"
1386
+ },
1387
+ "node_modules/has-ansi": {
1388
+ "version": "2.0.0",
1389
+ "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
1390
+ "integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==",
1391
+ "license": "MIT",
1392
+ "dependencies": {
1393
+ "ansi-regex": "^2.0.0"
1394
+ },
1395
+ "engines": {
1396
+ "node": ">=0.10.0"
1397
+ }
1398
+ },
1399
  "node_modules/has-symbols": {
1400
  "version": "1.1.0",
1401
  "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
 
1435
  "node": ">= 0.4"
1436
  }
1437
  },
1438
+ "node_modules/htmlparser2": {
1439
+ "version": "6.1.0",
1440
+ "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz",
1441
+ "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==",
1442
+ "funding": [
1443
+ "https://github.com/fb55/htmlparser2?sponsor=1",
1444
+ {
1445
+ "type": "github",
1446
+ "url": "https://github.com/sponsors/fb55"
1447
+ }
1448
+ ],
1449
+ "license": "MIT",
1450
+ "dependencies": {
1451
+ "domelementtype": "^2.0.1",
1452
+ "domhandler": "^4.0.0",
1453
+ "domutils": "^2.5.2",
1454
+ "entities": "^2.0.0"
1455
+ }
1456
+ },
1457
  "node_modules/http-errors": {
1458
  "version": "2.0.1",
1459
  "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
 
1496
  "integrity": "sha512-yjD9nARJ/jb1g+CvD0tlhUHOrJ9Sy0P8T9MF3YaLlHnSRpwPfpTX0XIvpmw3gAJUmEu3FiICLBDPXVwyEvrleg==",
1497
  "license": "Apache-2.0"
1498
  },
1499
+ "node_modules/ieee754": {
1500
+ "version": "1.2.1",
1501
+ "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
1502
+ "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
1503
+ "funding": [
1504
+ {
1505
+ "type": "github",
1506
+ "url": "https://github.com/sponsors/feross"
1507
+ },
1508
+ {
1509
+ "type": "patreon",
1510
+ "url": "https://www.patreon.com/feross"
1511
+ },
1512
+ {
1513
+ "type": "consulting",
1514
+ "url": "https://feross.org/support"
1515
+ }
1516
+ ],
1517
+ "license": "BSD-3-Clause"
1518
+ },
1519
+ "node_modules/imurmurhash": {
1520
+ "version": "0.1.4",
1521
+ "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
1522
+ "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==",
1523
+ "license": "MIT",
1524
+ "engines": {
1525
+ "node": ">=0.8.19"
1526
+ }
1527
+ },
1528
  "node_modules/inherits": {
1529
  "version": "2.0.4",
1530
  "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
1531
  "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
1532
  "license": "ISC"
1533
  },
1534
+ "node_modules/input": {
1535
+ "version": "1.0.1",
1536
+ "resolved": "https://registry.npmjs.org/input/-/input-1.0.1.tgz",
1537
+ "integrity": "sha512-5DKQKQ7Nm/CaPGYKF74uUvk5ftC3S04fLYWcDrNG2rOVhhRgB4E2J8JNb7AAh+RlQ/954ukas4bEbrRQ3/kPGA==",
1538
+ "license": "MIT",
1539
+ "dependencies": {
1540
+ "babel-runtime": "^6.6.1",
1541
+ "chalk": "^1.1.1",
1542
+ "inquirer": "^0.12.0",
1543
+ "lodash": "^4.6.1"
1544
+ },
1545
+ "engines": {
1546
+ "node": ">=0.12"
1547
+ }
1548
+ },
1549
+ "node_modules/inquirer": {
1550
+ "version": "0.12.0",
1551
+ "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz",
1552
+ "integrity": "sha512-bOetEz5+/WpgaW4D1NYOk1aD+JCqRjqu/FwRFgnIfiP7FC/zinsrfyO1vlS3nyH/R7S0IH3BIHBu4DBIDSqiGQ==",
1553
+ "license": "MIT",
1554
+ "dependencies": {
1555
+ "ansi-escapes": "^1.1.0",
1556
+ "ansi-regex": "^2.0.0",
1557
+ "chalk": "^1.0.0",
1558
+ "cli-cursor": "^1.0.1",
1559
+ "cli-width": "^2.0.0",
1560
+ "figures": "^1.3.5",
1561
+ "lodash": "^4.3.0",
1562
+ "readline2": "^1.0.1",
1563
+ "run-async": "^0.1.0",
1564
+ "rx-lite": "^3.1.2",
1565
+ "string-width": "^1.0.1",
1566
+ "strip-ansi": "^3.0.0",
1567
+ "through": "^2.3.6"
1568
+ }
1569
+ },
1570
+ "node_modules/ip-address": {
1571
+ "version": "10.2.0",
1572
+ "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.2.0.tgz",
1573
+ "integrity": "sha512-/+S6j4E9AHvW9SWMSEY9Xfy66O5PWvVEJ08O0y5JGyEKQpojb0K0GKpz/v5HJ/G0vi3D2sjGK78119oXZeE0qA==",
1574
+ "license": "MIT",
1575
+ "engines": {
1576
+ "node": ">= 12"
1577
+ }
1578
+ },
1579
  "node_modules/ipaddr.js": {
1580
  "version": "1.9.1",
1581
  "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
 
1591
  "integrity": "sha512-FO/Rhvz5tuw4MCWkpMzHFKWD2LsfHzIb7i6MdPYZ/KW7AlxawyLkqdy+jPZP1WubqEADE3O4FUENlJHDfQASRg==",
1592
  "license": "MIT"
1593
  },
1594
+ "node_modules/is-fullwidth-code-point": {
1595
+ "version": "1.0.0",
1596
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
1597
+ "integrity": "sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==",
1598
+ "license": "MIT",
1599
+ "dependencies": {
1600
+ "number-is-nan": "^1.0.0"
1601
+ },
1602
+ "engines": {
1603
+ "node": ">=0.10.0"
1604
+ }
1605
+ },
1606
  "node_modules/is-promise": {
1607
  "version": "4.0.0",
1608
  "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
1609
  "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==",
1610
  "license": "MIT"
1611
  },
1612
+ "node_modules/is-typedarray": {
1613
+ "version": "1.0.0",
1614
+ "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
1615
+ "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==",
1616
+ "license": "MIT"
1617
+ },
1618
  "node_modules/is-url": {
1619
  "version": "1.2.4",
1620
  "resolved": "https://registry.npmjs.org/is-url/-/is-url-1.2.4.tgz",
1621
  "integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==",
1622
  "license": "MIT"
1623
  },
1624
+ "node_modules/lodash": {
1625
+ "version": "4.18.1",
1626
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz",
1627
+ "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==",
1628
+ "license": "MIT"
1629
+ },
1630
  "node_modules/math-intrinsics": {
1631
  "version": "1.1.0",
1632
  "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
 
1657
  "url": "https://github.com/sponsors/sindresorhus"
1658
  }
1659
  },
1660
+ "node_modules/mime": {
1661
+ "version": "3.0.0",
1662
+ "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz",
1663
+ "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==",
1664
+ "license": "MIT",
1665
+ "bin": {
1666
+ "mime": "cli.js"
1667
+ },
1668
+ "engines": {
1669
+ "node": ">=10.0.0"
1670
+ }
1671
+ },
1672
  "node_modules/mime-db": {
1673
  "version": "1.52.0",
1674
  "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
 
1690
  "node": ">= 0.6"
1691
  }
1692
  },
 
 
 
 
 
 
 
 
 
1693
  "node_modules/ms": {
1694
  "version": "2.1.3",
1695
  "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1696
  "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1697
  "license": "MIT"
1698
  },
1699
+ "node_modules/mute-stream": {
1700
+ "version": "0.0.5",
1701
+ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz",
1702
+ "integrity": "sha512-EbrziT4s8cWPmzr47eYVW3wimS4HsvlnV5ri1xw1aR6JQo/OrJX5rkl32K/QQHdxeabJETtfeaROGhd8W7uBgg==",
1703
+ "license": "ISC"
1704
+ },
1705
  "node_modules/negotiator": {
1706
  "version": "1.0.0",
1707
  "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz",
 
1711
  "node": ">= 0.6"
1712
  }
1713
  },
1714
+ "node_modules/next-tick": {
1715
+ "version": "1.1.0",
1716
+ "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
1717
+ "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==",
1718
+ "license": "ISC"
1719
+ },
1720
  "node_modules/node-fetch": {
1721
  "version": "2.7.0",
1722
  "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
 
1737
  }
1738
  }
1739
  },
1740
+ "node_modules/node-gyp-build": {
1741
+ "version": "4.8.4",
1742
+ "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz",
1743
+ "integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==",
1744
+ "license": "MIT",
1745
+ "bin": {
1746
+ "node-gyp-build": "bin.js",
1747
+ "node-gyp-build-optional": "optional.js",
1748
+ "node-gyp-build-test": "build-test.js"
1749
+ }
1750
+ },
1751
+ "node_modules/node-localstorage": {
1752
+ "version": "2.2.1",
1753
+ "resolved": "https://registry.npmjs.org/node-localstorage/-/node-localstorage-2.2.1.tgz",
1754
+ "integrity": "sha512-vv8fJuOUCCvSPjDjBLlMqYMHob4aGjkmrkaE42/mZr0VT+ZAU10jRF8oTnX9+pgU9/vYJ8P7YT3Vd6ajkmzSCw==",
1755
+ "license": "MIT",
1756
+ "dependencies": {
1757
+ "write-file-atomic": "^1.1.4"
1758
+ },
1759
+ "engines": {
1760
+ "node": ">=0.12"
1761
+ }
1762
+ },
1763
+ "node_modules/number-is-nan": {
1764
+ "version": "1.0.1",
1765
+ "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
1766
+ "integrity": "sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==",
1767
+ "license": "MIT",
1768
+ "engines": {
1769
+ "node": ">=0.10.0"
1770
+ }
1771
+ },
1772
+ "node_modules/object-assign": {
1773
+ "version": "4.1.1",
1774
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
1775
+ "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
1776
+ "license": "MIT",
1777
+ "engines": {
1778
+ "node": ">=0.10.0"
1779
+ }
1780
+ },
1781
  "node_modules/object-inspect": {
1782
  "version": "1.13.4",
1783
  "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
 
1811
  "wrappy": "1"
1812
  }
1813
  },
1814
+ "node_modules/onetime": {
1815
+ "version": "1.1.0",
1816
+ "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz",
1817
+ "integrity": "sha512-GZ+g4jayMqzCRMgB2sol7GiCLjKfS1PINkjmx8spcKce1LiVqcbQreXwqs2YAFXC6R03VIG28ZS31t8M866v6A==",
1818
+ "license": "MIT",
1819
+ "engines": {
1820
+ "node": ">=0.10.0"
1821
+ }
1822
+ },
1823
  "node_modules/opencollective-postinstall": {
1824
  "version": "2.0.3",
1825
  "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz",
 
1829
  "opencollective-postinstall": "index.js"
1830
  }
1831
  },
1832
+ "node_modules/pako": {
1833
+ "version": "2.1.0",
1834
+ "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz",
1835
+ "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==",
1836
+ "license": "(MIT AND Zlib)"
 
 
 
1837
  },
1838
  "node_modules/parseurl": {
1839
  "version": "1.3.3",
 
1844
  "node": ">= 0.8"
1845
  }
1846
  },
1847
+ "node_modules/path-browserify": {
1848
+ "version": "1.0.1",
1849
+ "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz",
1850
+ "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==",
1851
+ "license": "MIT"
1852
+ },
1853
  "node_modules/path-to-regexp": {
1854
  "version": "8.4.2",
1855
  "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz",
 
1921
  "node": ">= 0.10"
1922
  }
1923
  },
1924
+ "node_modules/readline2": {
1925
+ "version": "1.0.1",
1926
+ "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz",
1927
+ "integrity": "sha512-8/td4MmwUB6PkZUbV25uKz7dfrmjYWxsW8DVfibWdlHRk/l/DfHKn4pU+dfcoGLFgWOdyGCzINRQD7jn+Bv+/g==",
1928
+ "license": "MIT",
1929
+ "dependencies": {
1930
+ "code-point-at": "^1.0.0",
1931
+ "is-fullwidth-code-point": "^1.0.0",
1932
+ "mute-stream": "0.0.5"
1933
+ }
1934
+ },
1935
+ "node_modules/real-cancellable-promise": {
1936
+ "version": "1.2.3",
1937
+ "resolved": "https://registry.npmjs.org/real-cancellable-promise/-/real-cancellable-promise-1.2.3.tgz",
1938
+ "integrity": "sha512-hBI5Gy/55VEeeMtImMgEirD7eq5UmqJf1J8dFZtbJZA/3rB0pYFZ7PayMGueb6v4UtUtpKpP+05L0VwyE1hI9Q==",
1939
+ "license": "MIT"
1940
+ },
1941
  "node_modules/regenerator-runtime": {
1942
  "version": "0.13.11",
1943
  "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
1944
  "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==",
1945
  "license": "MIT"
1946
  },
1947
+ "node_modules/restore-cursor": {
1948
+ "version": "1.0.1",
1949
+ "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz",
1950
+ "integrity": "sha512-reSjH4HuiFlxlaBaFCiS6O76ZGG2ygKoSlCsipKdaZuKSPx/+bt9mULkn4l0asVzbEfQQmXRg6Wp6gv6m0wElw==",
1951
+ "license": "MIT",
1952
+ "dependencies": {
1953
+ "exit-hook": "^1.0.0",
1954
+ "onetime": "^1.0.0"
1955
+ },
1956
+ "engines": {
1957
+ "node": ">=0.10.0"
1958
+ }
1959
+ },
1960
  "node_modules/router": {
1961
  "version": "2.2.0",
1962
  "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
 
1973
  "node": ">= 18"
1974
  }
1975
  },
1976
+ "node_modules/run-async": {
1977
+ "version": "0.1.0",
1978
+ "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz",
1979
+ "integrity": "sha512-qOX+w+IxFgpUpJfkv2oGN0+ExPs68F4sZHfaRRx4dDexAQkG83atugKVEylyT5ARees3HBbfmuvnjbrd8j9Wjw==",
1980
  "license": "MIT",
1981
  "dependencies": {
1982
+ "once": "^1.3.0"
1983
  }
1984
  },
1985
+ "node_modules/rx-lite": {
1986
+ "version": "3.1.2",
1987
+ "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz",
1988
+ "integrity": "sha512-1I1+G2gteLB8Tkt8YI1sJvSIfa0lWuRtC8GjvtyPBcLSF5jBCCJJqKrpER5JU5r6Bhe+i9/pK3VMuUcXu0kdwQ=="
1989
+ },
1990
  "node_modules/safer-buffer": {
1991
  "version": "2.1.2",
1992
  "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
1993
  "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
1994
  "license": "MIT"
1995
  },
 
 
 
 
 
 
 
 
 
1996
  "node_modules/semver": {
1997
  "version": "7.7.4",
1998
  "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
 
2197
  "url": "https://github.com/sponsors/ljharb"
2198
  }
2199
  },
2200
+ "node_modules/slide": {
2201
+ "version": "1.1.6",
2202
+ "resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz",
2203
+ "integrity": "sha512-NwrtjCg+lZoqhFU8fOwl4ay2ei8PaqCBOUV3/ektPY9trO1yQ1oXEfmHAhKArUVUr/hOHvy5f6AdP17dCM0zMw==",
2204
+ "license": "ISC",
2205
+ "engines": {
2206
+ "node": "*"
2207
+ }
2208
+ },
2209
+ "node_modules/smart-buffer": {
2210
+ "version": "4.2.0",
2211
+ "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
2212
+ "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==",
2213
+ "license": "MIT",
2214
+ "engines": {
2215
+ "node": ">= 6.0.0",
2216
+ "npm": ">= 3.0.0"
2217
+ }
2218
+ },
2219
+ "node_modules/socks": {
2220
+ "version": "2.8.9",
2221
+ "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.9.tgz",
2222
+ "integrity": "sha512-LJhUYUvItdQ0LkJTmPeaEObWXAqFyfmP85x0tch/ez9cahmhlBBLbIqDFnvBnUJGagb0JbIQrkBs1wJ+yRYpEw==",
2223
+ "license": "MIT",
2224
+ "dependencies": {
2225
+ "ip-address": "^10.1.1",
2226
+ "smart-buffer": "^4.2.0"
2227
+ },
2228
+ "engines": {
2229
+ "node": ">= 10.0.0",
2230
+ "npm": ">= 3.0.0"
2231
+ }
2232
+ },
2233
  "node_modules/statuses": {
2234
  "version": "2.0.2",
2235
  "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
 
2239
  "node": ">= 0.8"
2240
  }
2241
  },
2242
+ "node_modules/store2": {
2243
+ "version": "2.14.4",
2244
+ "resolved": "https://registry.npmjs.org/store2/-/store2-2.14.4.tgz",
2245
+ "integrity": "sha512-srTItn1GOvyvOycgxjAnPA63FZNwy0PTyUBFMHRM+hVFltAeoh0LmNBz9SZqUS9mMqGk8rfyWyXn3GH5ReJ8Zw==",
2246
+ "license": "MIT"
2247
+ },
2248
+ "node_modules/string-width": {
2249
+ "version": "1.0.2",
2250
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
2251
+ "integrity": "sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw==",
2252
  "license": "MIT",
2253
  "dependencies": {
2254
+ "code-point-at": "^1.0.0",
2255
+ "is-fullwidth-code-point": "^1.0.0",
2256
+ "strip-ansi": "^3.0.0"
 
 
 
 
 
2257
  },
2258
+ "engines": {
2259
+ "node": ">=0.10.0"
2260
+ }
2261
+ },
2262
+ "node_modules/strip-ansi": {
2263
+ "version": "3.0.1",
2264
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
2265
+ "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==",
2266
+ "license": "MIT",
2267
+ "dependencies": {
2268
+ "ansi-regex": "^2.0.0"
2269
  },
2270
  "engines": {
2271
+ "node": ">=0.10.0"
2272
+ }
2273
+ },
2274
+ "node_modules/supports-color": {
2275
+ "version": "2.0.0",
2276
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
2277
+ "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==",
2278
+ "license": "MIT",
2279
+ "engines": {
2280
+ "node": ">=0.8.0"
2281
+ }
2282
+ },
2283
+ "node_modules/telegram": {
2284
+ "version": "2.26.22",
2285
+ "resolved": "https://registry.npmjs.org/telegram/-/telegram-2.26.22.tgz",
2286
+ "integrity": "sha512-EIj7Yrjiu0Yosa3FZ/7EyPg9s6UiTi/zDQrFmR/2Mg7pIUU+XjAit1n1u9OU9h2oRnRM5M+67/fxzQluZpaJJg==",
2287
+ "license": "MIT",
2288
+ "dependencies": {
2289
+ "@cryptography/aes": "^0.1.1",
2290
+ "async-mutex": "^0.3.0",
2291
+ "big-integer": "^1.6.48",
2292
+ "buffer": "^6.0.3",
2293
+ "htmlparser2": "^6.1.0",
2294
+ "mime": "^3.0.0",
2295
+ "node-localstorage": "^2.2.1",
2296
+ "pako": "^2.0.3",
2297
+ "path-browserify": "^1.0.1",
2298
+ "real-cancellable-promise": "^1.1.1",
2299
+ "socks": "^2.6.2",
2300
+ "store2": "^2.13.0",
2301
+ "ts-custom-error": "^3.2.0",
2302
+ "websocket": "^1.0.34"
2303
+ },
2304
+ "optionalDependencies": {
2305
+ "bufferutil": "^4.0.3",
2306
+ "utf-8-validate": "^5.0.5"
2307
  }
2308
  },
2309
  "node_modules/tesseract.js": {
 
2331
  "integrity": "sha512-KX3bYSU5iGcO1XJa+QGPbi+Zjo2qq6eBhNjSGR5E5q0JtzkoipJKOUQD7ph8kFyteCEfEQ0maWLu8MCXtvX5uQ==",
2332
  "license": "Apache-2.0"
2333
  },
2334
+ "node_modules/through": {
2335
+ "version": "2.3.8",
2336
+ "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
2337
+ "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==",
2338
+ "license": "MIT"
2339
+ },
2340
  "node_modules/toidentifier": {
2341
  "version": "1.0.1",
2342
  "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
 
2352
  "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
2353
  "license": "MIT"
2354
  },
2355
+ "node_modules/ts-custom-error": {
2356
+ "version": "3.3.1",
2357
+ "resolved": "https://registry.npmjs.org/ts-custom-error/-/ts-custom-error-3.3.1.tgz",
2358
+ "integrity": "sha512-5OX1tzOjxWEgsr/YEUWSuPrQ00deKLh6D7OTWcvNHm12/7QPyRh8SYpyWvA4IZv8H/+GQWQEh/kwo95Q9OVW1A==",
2359
+ "license": "MIT",
2360
+ "engines": {
2361
+ "node": ">=14.0.0"
2362
+ }
2363
+ },
2364
  "node_modules/tslib": {
2365
  "version": "2.8.1",
2366
  "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
2367
  "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
2368
+ "license": "0BSD"
2369
+ },
2370
+ "node_modules/type": {
2371
+ "version": "2.7.3",
2372
+ "resolved": "https://registry.npmjs.org/type/-/type-2.7.3.tgz",
2373
+ "integrity": "sha512-8j+1QmAbPvLZow5Qpi6NCaN8FB60p/6x8/vfNqOk/hC+HuvFZhL4+WfekuhQLiqFZXOgQdrs3B+XxEmCc6b3FQ==",
2374
+ "license": "ISC"
2375
  },
2376
  "node_modules/type-is": {
2377
  "version": "2.0.1",
 
2412
  "url": "https://opencollective.com/express"
2413
  }
2414
  },
2415
+ "node_modules/typedarray-to-buffer": {
2416
+ "version": "3.1.5",
2417
+ "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
2418
+ "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
2419
+ "license": "MIT",
2420
+ "dependencies": {
2421
+ "is-typedarray": "^1.0.0"
2422
+ }
2423
+ },
2424
  "node_modules/unpipe": {
2425
  "version": "1.0.0",
2426
  "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
 
2430
  "node": ">= 0.8"
2431
  }
2432
  },
2433
+ "node_modules/utf-8-validate": {
2434
+ "version": "5.0.10",
2435
+ "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz",
2436
+ "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==",
2437
+ "hasInstallScript": true,
2438
+ "license": "MIT",
2439
+ "dependencies": {
2440
+ "node-gyp-build": "^4.3.0"
2441
+ },
2442
+ "engines": {
2443
+ "node": ">=6.14.2"
2444
+ }
2445
+ },
2446
  "node_modules/vary": {
2447
  "version": "1.1.2",
2448
  "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
 
2464
  "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
2465
  "license": "BSD-2-Clause"
2466
  },
2467
+ "node_modules/websocket": {
2468
+ "version": "1.0.35",
2469
+ "resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.35.tgz",
2470
+ "integrity": "sha512-/REy6amwPZl44DDzvRCkaI1q1bIiQB0mEFQLUrhz3z2EK91cp3n72rAjUlrTP0zV22HJIUOVHQGPxhFRjxjt+Q==",
2471
+ "license": "Apache-2.0",
2472
+ "dependencies": {
2473
+ "bufferutil": "^4.0.1",
2474
+ "debug": "^2.2.0",
2475
+ "es5-ext": "^0.10.63",
2476
+ "typedarray-to-buffer": "^3.1.5",
2477
+ "utf-8-validate": "^5.0.2",
2478
+ "yaeti": "^0.0.6"
2479
+ },
2480
+ "engines": {
2481
+ "node": ">=4.0.0"
2482
+ }
2483
+ },
2484
+ "node_modules/websocket/node_modules/debug": {
2485
+ "version": "2.6.9",
2486
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
2487
+ "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
2488
+ "license": "MIT",
2489
+ "dependencies": {
2490
+ "ms": "2.0.0"
2491
+ }
2492
+ },
2493
+ "node_modules/websocket/node_modules/ms": {
2494
+ "version": "2.0.0",
2495
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
2496
+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
2497
+ "license": "MIT"
2498
+ },
2499
  "node_modules/whatwg-url": {
2500
  "version": "5.0.0",
2501
  "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
 
2512
  "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
2513
  "license": "ISC"
2514
  },
2515
+ "node_modules/write-file-atomic": {
2516
+ "version": "1.3.4",
2517
+ "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.4.tgz",
2518
+ "integrity": "sha512-SdrHoC/yVBPpV0Xq/mUZQIpW2sWXAShb/V4pomcJXh92RuaO+f3UTWItiR3Px+pLnV2PvC2/bfn5cwr5X6Vfxw==",
2519
+ "license": "ISC",
2520
+ "dependencies": {
2521
+ "graceful-fs": "^4.1.11",
2522
+ "imurmurhash": "^0.1.4",
2523
+ "slide": "^1.1.5"
2524
+ }
2525
+ },
2526
+ "node_modules/yaeti": {
2527
+ "version": "0.0.6",
2528
+ "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
2529
+ "integrity": "sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug==",
2530
+ "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.",
2531
+ "license": "MIT",
2532
+ "engines": {
2533
+ "node": ">=0.10.32"
2534
+ }
2535
+ },
2536
  "node_modules/zlibjs": {
2537
  "version": "0.3.1",
2538
  "resolved": "https://registry.npmjs.org/zlibjs/-/zlibjs-0.3.1.tgz",
package.json CHANGED
@@ -1,20 +1,21 @@
1
  {
2
  "name": "wordgridsolver",
3
- "version": "1.0.0",
4
- "description": "Telegram bot to solve word grid puzzles",
5
- "main": "index.js",
6
  "scripts": {
7
  "start": "node bot.js",
8
- "test": "node solver.js"
9
  },
10
  "dependencies": {
11
  "axios": "^1.6.0",
12
  "check-word": "^1.1.0",
13
  "dotenv": "^17.4.2",
14
  "express": "^5.2.1",
15
- "https-proxy-agent": "^7.0.5",
16
  "sharp": "^0.34.5",
17
- "telegraf": "^4.16.3",
18
- "tesseract.js": "^5.0.0"
 
 
19
  }
20
  }
 
1
  {
2
  "name": "wordgridsolver",
3
+ "version": "2.0.0",
4
+ "description": "Telegram bot (GramJS MTProto) to solve 8x8 and 10x10 word grid puzzles",
5
+ "main": "bot.js",
6
  "scripts": {
7
  "start": "node bot.js",
8
+ "test": "node -e \"const {solve}=require('./solver'); console.log('Solver OK');\""
9
  },
10
  "dependencies": {
11
  "axios": "^1.6.0",
12
  "check-word": "^1.1.0",
13
  "dotenv": "^17.4.2",
14
  "express": "^5.2.1",
 
15
  "sharp": "^0.34.5",
16
+ "telegram": "^2.26.0",
17
+ "tesseract.js": "^5.0.0",
18
+ "input": "^1.0.1",
19
+ "big-integer": "^1.6.52"
20
  }
21
  }
solver.js CHANGED
@@ -1,129 +1,212 @@
1
- const directions = [
2
- { r: 0, c: 1, name: 'LtoR' },
3
- { r: 0, c: -1, name: 'RtoL' },
4
- { r: 1, c: 0, name: 'UtoD' },
5
- { r: -1, c: 0, name: 'DtoU' },
6
- { r: 1, c: 1, name: 'diagDR' },
7
- { r: -1, c: -1, name: 'diagUL' },
8
- { r: 1, c: -1, name: 'diagDL' },
9
- { r: -1, c: 1, name: 'diagUR' }
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  ];
11
 
12
- const LOOKALIKES = {
13
- 'G': ['C', 'O', '6', 'Q'],
14
- 'C': ['G', 'O', 'Q', '(', 'L'],
15
- 'I': ['L', '1', 'T', 'J', '|'],
16
- 'L': ['I', '1', 'T', '|', '['],
17
- 'O': ['0', 'Q', 'G', 'C', 'D', 'U'],
18
- 'S': ['5', '8', 'B', '6'],
19
- 'B': ['8', 'S', 'R', '3', 'E'],
20
- 'R': ['B', 'P', 'K', 'I', 'A'],
21
- 'T': ['I', 'L', '7', '+'],
22
- 'E': ['F', 'B', '3', 'L'],
23
- 'U': ['V', 'W', 'O', 'Y'],
24
- 'V': ['U', 'Y', 'V'],
25
- 'D': ['0', 'O', 'B'],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  };
27
 
28
- function charMatch(target, grid) {
29
- if (!grid || grid === ' ') return false;
30
- if (target === grid) return true;
31
- const lookalikes = LOOKALIKES[target];
32
- return lookalikes && lookalikes.includes(grid);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  }
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  function solve(grid, words) {
36
- const results = {};
37
- const rows = grid.length;
38
- const cols = grid[0].length;
39
-
40
- for (let wordObj of words) {
41
- const word = wordObj.word;
42
- const pattern = wordObj.pattern; // e.g., "M---"
43
- let found = false;
44
-
45
- // If word is explicitly given
46
- if (word && !word.includes('-')) {
47
- const target = word.toUpperCase();
48
- for (let r = 0; r < rows; r++) {
49
- for (let c = 0; c < cols; c++) {
50
- if (charMatch(target[0], grid[r][c])) {
51
- for (const dir of directions) {
52
- let match = true;
53
- for (let i = 1; i < target.length; i++) {
54
- const nr = r + dir.r * i;
55
- const nc = c + dir.c * i;
56
- if (nr < 0 || nr >= rows || !grid[nr] || nc < 0 || nc >= grid[nr].length || !charMatch(target[i], grid[nr][nc])) {
57
- match = false;
58
- break;
59
- }
60
- }
61
- if (match) {
62
- results[word] = { r, c, dir: dir.name, match: target };
63
- found = true;
64
- break;
65
- }
66
- }
67
- }
68
- if (found) break;
69
- }
70
- if (found) break;
71
  }
72
- } else if (pattern) {
73
- const startChar = pattern[0].toUpperCase();
74
- const length = pattern.length;
75
-
76
- for (let r = 0; r < rows; r++) {
77
- for (let c = 0; c < cols; c++) {
78
- if (charMatch(startChar, grid[r][c])) {
79
- for (const dir of directions) {
80
- let candidate = grid[r][c];
81
- let possible = true;
82
- for (let i = 1; i < length; i++) {
83
- const nr = r + dir.r * i;
84
- const nc = c + dir.c * i;
85
- if (nr < 0 || nr >= rows || !grid[nr] || nc < 0 || nc >= grid[nr].length) {
86
- possible = false;
87
- break;
88
- }
89
- const char = grid[nr][nc];
90
- if (char === undefined || char === ' ') {
91
- possible = false;
92
- break;
93
- }
94
- candidate += char;
95
- }
96
- if (possible) {
97
- if (!results[pattern]) results[pattern] = [];
98
- results[pattern].push({ r, c, dir: dir.name, match: candidate });
99
- }
100
- }
101
- }
102
- }
103
  }
 
104
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  }
106
- return results;
 
 
107
  }
108
 
109
- /**
110
- * Scoring System
111
- */
112
  let leaderboard = [];
113
 
114
  function getWordScore(word) {
115
- // Length based scoring
116
- return word.length * 10;
117
  }
118
 
119
  function recordScore(userName, score) {
120
- leaderboard.push({ name: userName, score, date: new Date().toISOString() });
121
- leaderboard.sort((a, b) => b.score - a.score);
122
- leaderboard = leaderboard.slice(0, 10);
123
  }
124
 
125
  function getLeaderboard() {
126
- return leaderboard;
127
  }
128
 
129
- module.exports = { solve, getWordScore, recordScore, getLeaderboard };
 
1
+ /**
2
+ * solver.js β€” Word Grid solver with comprehensive lookalike tolerance
3
+ *
4
+ * Improvements over v1:
5
+ * ‒ Symmetric LOOKALIKES map (A→B implies B can match A)
6
+ * β€’ Wildcard (-) pattern matching ignores only dashes, not all unknowns
7
+ * β€’ Pattern matching collects ALL candidates with their actual grid characters
8
+ * β€’ charMatch is stricter: only matches confirmed lookalike pairs, not random guesses
9
+ * β€’ Grid boundary checks are consolidated in one place (no off-by-one)
10
+ * β€’ Deduplication of candidates by match string
11
+ */
12
+
13
+ // ─── Directions ───────────────────────────────────────────────────────────────
14
+ const DIRECTIONS = [
15
+ { r: 0, c: 1, name: 'LtoR' },
16
+ { r: 0, c: -1, name: 'RtoL' },
17
+ { r: 1, c: 0, name: 'UtoD' },
18
+ { r: -1, c: 0, name: 'DtoU' },
19
+ { r: 1, c: 1, name: 'diagDR'},
20
+ { r: -1, c: -1, name: 'diagUL'},
21
+ { r: 1, c: -1, name: 'diagDL'},
22
+ { r: -1, c: 1, name: 'diagUR'},
23
  ];
24
 
25
+ // ─── Lookalike table (symmetric) ─────────────────────────────────────────────
26
+ // Each entry lists chars that can be confused FOR the key char by OCR.
27
+ const LOOKALIKES_RAW = {
28
+ 'A': ['4', 'R'],
29
+ 'B': ['8', '3', 'R', 'S', 'E'],
30
+ 'C': ['G', 'O', 'Q', '(', 'L'],
31
+ 'D': ['O', 'Q', 'B', '0'],
32
+ 'E': ['F', 'B', '3', 'L'],
33
+ 'F': ['E', 'P'],
34
+ 'G': ['C', 'O', '6', 'Q', 'D'],
35
+ 'H': ['N', 'M'],
36
+ 'I': ['L', '1', 'T', 'J', '|'],
37
+ 'J': ['I', 'L', '1'],
38
+ 'K': ['R', 'X'],
39
+ 'L': ['I', '1', 'T', '|', '[', 'J'],
40
+ 'M': ['N', 'H', 'W'],
41
+ 'N': ['M', 'H', 'R'],
42
+ 'O': ['0', 'Q', 'G', 'C', 'D', 'U'],
43
+ 'P': ['F', 'B', 'R'],
44
+ 'Q': ['O', 'G', 'C', '0'],
45
+ 'R': ['B', 'P', 'K', 'I', 'A', 'N'],
46
+ 'S': ['5', '8', 'B', '6'],
47
+ 'T': ['I', 'L', '7', '+'],
48
+ 'U': ['V', 'W', 'O', 'Y'],
49
+ 'V': ['U', 'Y', 'W'],
50
+ 'W': ['M', 'V', 'U'],
51
+ 'X': ['K', 'Y'],
52
+ 'Y': ['V', 'U', 'X'],
53
+ 'Z': ['2', '7'],
54
  };
55
 
56
+ // Build symmetric version: if A can be confused as B, then B can be confused as A
57
+ const LOOKALIKES = {};
58
+ for (const [key, alts] of Object.entries(LOOKALIKES_RAW)) {
59
+ if (!LOOKALIKES[key]) LOOKALIKES[key] = new Set();
60
+ for (const alt of alts) {
61
+ LOOKALIKES[key].add(alt);
62
+ // symmetric
63
+ if (/^[A-Z]$/.test(alt)) {
64
+ if (!LOOKALIKES[alt]) LOOKALIKES[alt] = new Set();
65
+ LOOKALIKES[alt].add(key);
66
+ }
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Does `gridChar` match `targetChar` considering OCR lookalikes?
72
+ * Both must be non-empty, non-space.
73
+ */
74
+ function charMatch(target, gridChar) {
75
+ if (!gridChar || gridChar === ' ' || gridChar === '?') return false;
76
+ const t = target.toUpperCase();
77
+ const g = gridChar.toUpperCase();
78
+ if (t === g) return true;
79
+ const alts = LOOKALIKES[t];
80
+ return !!(alts && alts.has(g));
81
  }
82
 
83
+ /**
84
+ * Check all cells are in bounds on a grid
85
+ */
86
+ function inBounds(grid, r, c) {
87
+ return r >= 0 && r < grid.length && c >= 0 && c < (grid[r] ? grid[r].length : 0);
88
+ }
89
+
90
+ /**
91
+ * Solve the grid for a list of word/pattern objects.
92
+ *
93
+ * Each item in `words` is one of:
94
+ * { word: 'MATRIX' } β†’ exact word search
95
+ * { pattern: 'M---' } β†’ pattern search (first char + length)
96
+ *
97
+ * Returns an object:
98
+ * { 'M---': [ { r, c, dir, match, reliable } ], ... }
99
+ * { 'MATRIX': { r, c, dir, match } }
100
+ */
101
  function solve(grid, words) {
102
+ const results = {};
103
+ const rows = grid.length;
104
+ if (rows === 0) return results;
105
+
106
+ for (const wordObj of words) {
107
+ const isExact = wordObj.word && !wordObj.word.includes('-');
108
+ const isPattern = !!wordObj.pattern;
109
+
110
+ if (isExact) {
111
+ const target = wordObj.word.toUpperCase();
112
+ const len = target.length;
113
+ let found = false;
114
+
115
+ outer:
116
+ for (let r = 0; r < rows && !found; r++) {
117
+ const cols = grid[r].length;
118
+ for (let c = 0; c < cols && !found; c++) {
119
+ if (!charMatch(target[0], grid[r][c])) continue;
120
+ for (const dir of DIRECTIONS) {
121
+ // Quick bounds check for last character
122
+ const er = r + dir.r * (len - 1);
123
+ const ec = c + dir.c * (len - 1);
124
+ if (!inBounds(grid, er, ec)) continue;
125
+
126
+ let match = true;
127
+ let candidate = '';
128
+ for (let i = 0; i < len; i++) {
129
+ const nr = r + dir.r * i;
130
+ const nc = c + dir.c * i;
131
+ if (!inBounds(grid, nr, nc) || !charMatch(target[i], grid[nr][nc])) {
132
+ match = false;
133
+ break;
134
+ }
135
+ candidate += grid[nr][nc];
 
136
  }
137
+ if (match) {
138
+ results[wordObj.word] = { r, c, dir: dir.name, match: candidate };
139
+ found = true;
140
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  }
142
+ }
143
  }
144
+ }
145
+ } else if (isPattern) {
146
+ const pattern = wordObj.pattern.toUpperCase(); // e.g. "M---"
147
+ const startChar = pattern[0];
148
+ const len = pattern.length;
149
+ const hits = [];
150
+
151
+ for (let r = 0; r < rows; r++) {
152
+ const cols = grid[r].length;
153
+ for (let c = 0; c < cols; c++) {
154
+ if (!charMatch(startChar, grid[r][c])) continue;
155
+
156
+ for (const dir of DIRECTIONS) {
157
+ // Bounds check for last char
158
+ const er = r + dir.r * (len - 1);
159
+ const ec = c + dir.c * (len - 1);
160
+ if (!inBounds(grid, er, ec)) continue;
161
+
162
+ let possible = true;
163
+ let candidate = '';
164
+ for (let i = 0; i < len; i++) {
165
+ const nr = r + dir.r * i;
166
+ const nc = c + dir.c * i;
167
+ if (!inBounds(grid, nr, nc)) { possible = false; break; }
168
+ const ch = grid[nr][nc];
169
+ if (!ch || ch === ' ') { possible = false; break; }
170
+ candidate += ch;
171
+ }
172
+
173
+ if (possible && candidate.length === len) {
174
+ hits.push({ r, c, dir: dir.name, match: candidate });
175
+ }
176
+ }
177
+ }
178
+ }
179
+
180
+ // Deduplicate by match string
181
+ const seen = new Set();
182
+ const unique = hits.filter(h => {
183
+ if (seen.has(h.match)) return false;
184
+ seen.add(h.match);
185
+ return true;
186
+ });
187
+
188
+ if (unique.length > 0) results[pattern] = unique;
189
  }
190
+ }
191
+
192
+ return results;
193
  }
194
 
195
+ // ─── Leaderboard ──────────────────────────────────────────────────────────────
 
 
196
  let leaderboard = [];
197
 
198
  function getWordScore(word) {
199
+ return word.length * 10;
 
200
  }
201
 
202
  function recordScore(userName, score) {
203
+ leaderboard.push({ name: userName, score, date: new Date().toISOString() });
204
+ leaderboard.sort((a, b) => b.score - a.score);
205
+ leaderboard = leaderboard.slice(0, 10);
206
  }
207
 
208
  function getLeaderboard() {
209
+ return leaderboard;
210
  }
211
 
212
+ module.exports = { solve, charMatch, getWordScore, recordScore, getLeaderboard };