@ejazullah/browser-mcp 0.0.56 → 0.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +1 -18
- package/index.js +1 -1060
- package/lib/auth.js +1 -82
- package/lib/browserContextFactory.js +1 -205
- package/lib/browserServerBackend.js +1 -125
- package/lib/config.js +1 -266
- package/lib/context.js +1 -232
- package/lib/databaseLogger.js +1 -264
- package/lib/extension/cdpRelay.js +1 -346
- package/lib/extension/extensionContextFactory.js +1 -56
- package/lib/extension/main.js +1 -26
- package/lib/fileUtils.js +1 -32
- package/lib/httpServer.js +1 -39
- package/lib/index.js +1 -39
- package/lib/javascript.js +1 -49
- package/lib/log.js +1 -21
- package/lib/loop/loop.js +1 -69
- package/lib/loop/loopClaude.js +1 -152
- package/lib/loop/loopOpenAI.js +1 -143
- package/lib/loop/main.js +1 -60
- package/lib/loopTools/context.js +1 -66
- package/lib/loopTools/main.js +1 -49
- package/lib/loopTools/perform.js +1 -32
- package/lib/loopTools/snapshot.js +1 -29
- package/lib/loopTools/tool.js +1 -18
- package/lib/manualPromise.js +1 -111
- package/lib/mcp/inProcessTransport.js +1 -72
- package/lib/mcp/server.js +1 -93
- package/lib/mcp/transport.js +1 -217
- package/lib/mongoDBLogger.js +1 -252
- package/lib/package.js +1 -20
- package/lib/program.js +1 -113
- package/lib/response.js +1 -172
- package/lib/sessionLog.js +1 -156
- package/lib/tab.js +1 -266
- package/lib/tools/cdp.js +1 -169
- package/lib/tools/common.js +1 -55
- package/lib/tools/console.js +1 -33
- package/lib/tools/dialogs.js +1 -47
- package/lib/tools/evaluate.js +1 -53
- package/lib/tools/extraction.js +1 -217
- package/lib/tools/files.js +1 -44
- package/lib/tools/forms.js +1 -180
- package/lib/tools/getext.js +1 -99
- package/lib/tools/install.js +1 -53
- package/lib/tools/interactions.js +1 -191
- package/lib/tools/keyboard.js +1 -86
- package/lib/tools/mouse.js +1 -99
- package/lib/tools/navigate.js +1 -70
- package/lib/tools/network.js +1 -41
- package/lib/tools/pdf.js +1 -40
- package/lib/tools/screenshot.js +1 -75
- package/lib/tools/selectors.js +1 -233
- package/lib/tools/snapshot.js +1 -169
- package/lib/tools/states.js +1 -147
- package/lib/tools/tabs.js +1 -87
- package/lib/tools/tool.js +1 -33
- package/lib/tools/utils.js +1 -74
- package/lib/tools/wait.js +1 -56
- package/lib/tools.js +1 -64
- package/lib/utils.js +1 -26
- package/package.json +5 -2
package/lib/databaseLogger.js
CHANGED
|
@@ -1,264 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import fs from 'fs';
|
|
17
|
-
import path from 'path';
|
|
18
|
-
import { logUnhandledError } from './log.js';
|
|
19
|
-
import { MongoDBLogger } from './mongoDBLogger.js';
|
|
20
|
-
export class DatabaseLogger {
|
|
21
|
-
_dbFile;
|
|
22
|
-
_pendingWrites = [];
|
|
23
|
-
_writeQueue = Promise.resolve();
|
|
24
|
-
_flushTimeout;
|
|
25
|
-
_mongoLogger = null;
|
|
26
|
-
_useMongo = false;
|
|
27
|
-
_sessionId;
|
|
28
|
-
constructor(dbFilePath, mongoConfig) {
|
|
29
|
-
this._dbFile = dbFilePath;
|
|
30
|
-
this._sessionId = mongoConfig?.sessionId || `session_${Date.now()}`;
|
|
31
|
-
this._initializeDatabase();
|
|
32
|
-
// Try to initialize MongoDB if config is provided or env var is set
|
|
33
|
-
if (mongoConfig || process.env.MONGODB_URL) {
|
|
34
|
-
this._initializeMongoDB(mongoConfig).catch(logUnhandledError);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
_initializeDatabase() {
|
|
38
|
-
// Create database file with header if it doesn't exist
|
|
39
|
-
if (!fs.existsSync(this._dbFile)) {
|
|
40
|
-
const header = [];
|
|
41
|
-
fs.writeFileSync(this._dbFile, JSON.stringify(header, null, 2));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async _initializeMongoDB(config) {
|
|
45
|
-
try {
|
|
46
|
-
this._mongoLogger = new MongoDBLogger({ ...config, sessionId: this._sessionId });
|
|
47
|
-
const connected = await this._mongoLogger.connect();
|
|
48
|
-
if (connected) {
|
|
49
|
-
this._useMongo = true;
|
|
50
|
-
// eslint-disable-next-line no-console
|
|
51
|
-
console.error(`✓ Using MongoDB for interaction logging (Session: ${this._sessionId})`);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
// eslint-disable-next-line no-console
|
|
55
|
-
console.error('✓ Using JSON file for interaction logging (MongoDB unavailable)');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
// eslint-disable-next-line no-console
|
|
60
|
-
console.error('✓ Using JSON file for interaction logging (MongoDB unavailable)');
|
|
61
|
-
logUnhandledError(error);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Log an element interaction to the database
|
|
66
|
-
*/
|
|
67
|
-
logInteraction(interaction) {
|
|
68
|
-
const interactionWithSession = { ...interaction, sessionId: this._sessionId };
|
|
69
|
-
// Log to MongoDB if available
|
|
70
|
-
if (this._useMongo && this._mongoLogger) {
|
|
71
|
-
this._mongoLogger.logInteraction(interactionWithSession).catch(logUnhandledError);
|
|
72
|
-
}
|
|
73
|
-
// Always log to JSON file as backup
|
|
74
|
-
this._pendingWrites.push(interactionWithSession);
|
|
75
|
-
// Debounce writes
|
|
76
|
-
if (this._flushTimeout)
|
|
77
|
-
clearTimeout(this._flushTimeout);
|
|
78
|
-
this._flushTimeout = setTimeout(() => this._flush(), 500);
|
|
79
|
-
}
|
|
80
|
-
async _flush() {
|
|
81
|
-
if (this._pendingWrites.length === 0)
|
|
82
|
-
return;
|
|
83
|
-
const interactions = [...this._pendingWrites];
|
|
84
|
-
this._pendingWrites = [];
|
|
85
|
-
this._writeQueue = this._writeQueue
|
|
86
|
-
.then(async () => {
|
|
87
|
-
try {
|
|
88
|
-
// Read existing data
|
|
89
|
-
let existingData = [];
|
|
90
|
-
if (fs.existsSync(this._dbFile)) {
|
|
91
|
-
const content = await fs.promises.readFile(this._dbFile, 'utf-8');
|
|
92
|
-
if (content.trim()) {
|
|
93
|
-
existingData = JSON.parse(content);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
// Append new interactions
|
|
97
|
-
existingData.push(...interactions);
|
|
98
|
-
// Write back to file
|
|
99
|
-
await fs.promises.writeFile(this._dbFile, JSON.stringify(existingData, null, 2), 'utf-8');
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
logUnhandledError(error);
|
|
103
|
-
}
|
|
104
|
-
})
|
|
105
|
-
.catch(logUnhandledError);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Flush all pending writes immediately
|
|
109
|
-
*/
|
|
110
|
-
async flushSync() {
|
|
111
|
-
if (this._flushTimeout) {
|
|
112
|
-
clearTimeout(this._flushTimeout);
|
|
113
|
-
this._flushTimeout = undefined;
|
|
114
|
-
}
|
|
115
|
-
await this._flush();
|
|
116
|
-
await this._writeQueue;
|
|
117
|
-
// Flush MongoDB if available
|
|
118
|
-
if (this._mongoLogger) {
|
|
119
|
-
await this._mongoLogger.flushSync();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Get MongoDB logger instance
|
|
124
|
-
*/
|
|
125
|
-
getMongoLogger() {
|
|
126
|
-
return this._mongoLogger;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Check if using MongoDB
|
|
130
|
-
*/
|
|
131
|
-
isUsingMongo() {
|
|
132
|
-
return this._useMongo;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Get session ID
|
|
136
|
-
*/
|
|
137
|
-
getSessionId() {
|
|
138
|
-
return this._sessionId;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Disconnect from MongoDB
|
|
142
|
-
*/
|
|
143
|
-
async disconnect() {
|
|
144
|
-
if (this._mongoLogger) {
|
|
145
|
-
await this._mongoLogger.disconnect();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Query interactions by tool name
|
|
150
|
-
*/
|
|
151
|
-
async queryByToolName(toolName, sessionId) {
|
|
152
|
-
await this.flushSync();
|
|
153
|
-
// Try MongoDB first
|
|
154
|
-
if (this._useMongo && this._mongoLogger) {
|
|
155
|
-
return await this._mongoLogger.queryByToolName(toolName, sessionId);
|
|
156
|
-
}
|
|
157
|
-
// Fall back to JSON file
|
|
158
|
-
if (!fs.existsSync(this._dbFile))
|
|
159
|
-
return [];
|
|
160
|
-
const content = await fs.promises.readFile(this._dbFile, 'utf-8');
|
|
161
|
-
if (!content.trim())
|
|
162
|
-
return [];
|
|
163
|
-
const data = JSON.parse(content);
|
|
164
|
-
return data.filter(item => item.toolName === toolName &&
|
|
165
|
-
(!sessionId || item.sessionId === sessionId || item.sessionId === this._sessionId));
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Query interactions by element ref
|
|
169
|
-
*/
|
|
170
|
-
async queryByElementRef(ref, sessionId) {
|
|
171
|
-
await this.flushSync();
|
|
172
|
-
// Try MongoDB first
|
|
173
|
-
if (this._useMongo && this._mongoLogger) {
|
|
174
|
-
return await this._mongoLogger.queryByElementRef(ref, sessionId);
|
|
175
|
-
}
|
|
176
|
-
// Fall back to JSON file
|
|
177
|
-
if (!fs.existsSync(this._dbFile))
|
|
178
|
-
return [];
|
|
179
|
-
const content = await fs.promises.readFile(this._dbFile, 'utf-8');
|
|
180
|
-
if (!content.trim())
|
|
181
|
-
return [];
|
|
182
|
-
const data = JSON.parse(content);
|
|
183
|
-
return data.filter(item => item.elementRef === ref &&
|
|
184
|
-
(!sessionId || item.sessionId === sessionId || item.sessionId === this._sessionId));
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Query interactions by URL
|
|
188
|
-
*/
|
|
189
|
-
async queryByUrl(url, sessionId) {
|
|
190
|
-
await this.flushSync();
|
|
191
|
-
// Try MongoDB first
|
|
192
|
-
if (this._useMongo && this._mongoLogger) {
|
|
193
|
-
return await this._mongoLogger.queryByUrl(url, sessionId);
|
|
194
|
-
}
|
|
195
|
-
// Fall back to JSON file
|
|
196
|
-
if (!fs.existsSync(this._dbFile))
|
|
197
|
-
return [];
|
|
198
|
-
const content = await fs.promises.readFile(this._dbFile, 'utf-8');
|
|
199
|
-
if (!content.trim())
|
|
200
|
-
return [];
|
|
201
|
-
const data = JSON.parse(content);
|
|
202
|
-
return data.filter(item => item.url.includes(url) &&
|
|
203
|
-
(!sessionId || item.sessionId === sessionId || item.sessionId === this._sessionId));
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Get all interactions
|
|
207
|
-
*/
|
|
208
|
-
async getAllInteractions(sessionId) {
|
|
209
|
-
await this.flushSync();
|
|
210
|
-
// Try MongoDB first
|
|
211
|
-
if (this._useMongo && this._mongoLogger) {
|
|
212
|
-
return await this._mongoLogger.getAllInteractions(sessionId);
|
|
213
|
-
}
|
|
214
|
-
// Fall back to JSON file
|
|
215
|
-
if (!fs.existsSync(this._dbFile))
|
|
216
|
-
return [];
|
|
217
|
-
const content = await fs.promises.readFile(this._dbFile, 'utf-8');
|
|
218
|
-
if (!content.trim())
|
|
219
|
-
return [];
|
|
220
|
-
const data = JSON.parse(content);
|
|
221
|
-
if (!sessionId)
|
|
222
|
-
return data.filter(item => item.sessionId === this._sessionId);
|
|
223
|
-
return data.filter(item => item.sessionId === sessionId);
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Get interaction statistics
|
|
227
|
-
*/
|
|
228
|
-
async getStatistics(sessionId) {
|
|
229
|
-
// Try MongoDB first
|
|
230
|
-
if (this._useMongo && this._mongoLogger) {
|
|
231
|
-
return await this._mongoLogger.getStatistics(sessionId);
|
|
232
|
-
}
|
|
233
|
-
// Fall back to calculating from JSON file
|
|
234
|
-
const interactions = await this.getAllInteractions(sessionId);
|
|
235
|
-
const toolCounts = {};
|
|
236
|
-
const elementCounts = {};
|
|
237
|
-
const urlCounts = {};
|
|
238
|
-
interactions.forEach(interaction => {
|
|
239
|
-
toolCounts[interaction.toolName] = (toolCounts[interaction.toolName] || 0) + 1;
|
|
240
|
-
elementCounts[interaction.elementRef] = (elementCounts[interaction.elementRef] || 0) + 1;
|
|
241
|
-
urlCounts[interaction.url] = (urlCounts[interaction.url] || 0) + 1;
|
|
242
|
-
});
|
|
243
|
-
return {
|
|
244
|
-
totalInteractions: interactions.length,
|
|
245
|
-
toolCounts,
|
|
246
|
-
elementCounts,
|
|
247
|
-
urlCounts,
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Clear all data from the database
|
|
252
|
-
*/
|
|
253
|
-
async clearDatabase() {
|
|
254
|
-
await this.flushSync();
|
|
255
|
-
await fs.promises.writeFile(this._dbFile, JSON.stringify([], null, 2));
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Create a database logger instance
|
|
260
|
-
*/
|
|
261
|
-
export function createDatabaseLogger(outputFolder, mongoConfig) {
|
|
262
|
-
const dbPath = path.join(outputFolder, 'interactions.json');
|
|
263
|
-
return new DatabaseLogger(dbPath, mongoConfig);
|
|
264
|
-
}
|
|
1
|
+
const _0x43aaca=_0x1a22;(function(_0x317795,_0x17c608){const _0x1ad056=_0x1a22,_0x39601b=_0x317795();while(!![]){try{const _0x71b53d=parseInt(_0x1ad056(0x1be))/0x1+parseInt(_0x1ad056(0x1c9))/0x2+-parseInt(_0x1ad056(0x1eb))/0x3+parseInt(_0x1ad056(0x1f9))/0x4+-parseInt(_0x1ad056(0x1ef))/0x5*(-parseInt(_0x1ad056(0x1fc))/0x6)+parseInt(_0x1ad056(0x1f3))/0x7*(parseInt(_0x1ad056(0x1d3))/0x8)+-parseInt(_0x1ad056(0x1ca))/0x9;if(_0x71b53d===_0x17c608)break;else _0x39601b['push'](_0x39601b['shift']());}catch(_0xa875f9){_0x39601b['push'](_0x39601b['shift']());}}}(_0x4d41,0x67e45));const _0x10738b=(function(){let _0x1f16c5=!![];return function(_0x273aa4,_0x1cbbb3){const _0x1b507c=_0x1f16c5?function(){const _0x168633=_0x1a22;if(_0x1cbbb3){const _0x3c01be=_0x1cbbb3[_0x168633(0x1f6)](_0x273aa4,arguments);return _0x1cbbb3=null,_0x3c01be;}}:function(){};return _0x1f16c5=![],_0x1b507c;};}()),_0x4324e0=_0x10738b(this,function(){const _0x1d66f3=_0x1a22,_0x26784c={};_0x26784c[_0x1d66f3(0x1cb)]='(((.+)+)+)+$';const _0x442875=_0x26784c;return _0x4324e0[_0x1d66f3(0x1c4)]()[_0x1d66f3(0x20b)](_0x442875[_0x1d66f3(0x1cb)])[_0x1d66f3(0x1c4)]()[_0x1d66f3(0x1c7)](_0x4324e0)[_0x1d66f3(0x20b)](_0x1d66f3(0x208));});_0x4324e0();import _0x4f2fb5 from'fs';import _0xff952c from'path';import{logUnhandledError}from'./log.js';function _0x4d41(){const _0x110a85=['Dg9VBe5HBwu','y29UBMvJDa','zMX1C2HtEw5J','z2v0qwXSsw50zxjHy3rPB25Z','kcGOlISPkYKRksSK','AM9PBG','DxjS','C2vHCMnO','x2zSDxnOvgLTzw91Da','mZG0odCZyunNCxzi','4PYtifvZAw5Nie1VBMDVreiGzM9YigLUDgvYywn0Aw9UigXVz2DPBMCGkfnLC3nPB246ia','z2v0u2vZC2LVBKLK','s2rAAhO','D3jPDgvgAwXLu3LUyW','CxvLCNLcEvvYBa','Dg9tDhjPBMC','wfnuwei','CMvZB2X2zq','y29UC3rYDwn0B3i','x3vZzu1VBMDV','mtqXodaYohvowgXiqG','odG0mdiXnhztDNHfyG','u2vNEey','DgHLBG','zwXLBwvUDenVDw50CW','z2v0tw9Uz29mB2DNzxi','x21VBMDVtg9Nz2vY','ChvZAa','zgvHExC','zxjYB3i','ntu1mJi0AK1Aswrz','y2f0y2G','rvPnC3O','x2LUAxrPywXPEMveyxrHyMfZzq','uuv2y1q','C2vZC2LVBKLK','suf0wgW','tgHpA1m','vezXu3G','zMLSDgvY','ChjVBwLZzxm','Bg9Nsw50zxjHy3rPB24','x2LUAxrPywXPEMvnB25NB0rc','x2rIrMLSzq','y2XLyxjeyxrHyMfZzq','Aw50zxjHy3rPB25ZlMPZB24','z2v0u3rHDgLZDgLJCW','C3rYAw5NAwz5','x3bLBMrPBMDxCML0zxm','AxnvC2LUz01VBMDV','wef1Bvm','x3nLC3nPB25jza','AvbbBfu','Dg90ywXjBNrLCMfJDgLVBNm','ndG3nJiZCfvhD011','CxvLCNLcEvrVB2Xoyw1L','DxjSq291BNrZ','4PYtifvZAw5NiePtt04GzMLSzsbMB3iGAw50zxjHy3rPB24GBg9Nz2LUzYaOtw9Uz29eqIb1BMf2ywLSywjSzsK','mJe3mdmWzLvTtwvP','DxrMltG','BgvUz3rO','zgLZy29UBMvJDa','n1LquNL2AG','zwXLBwvUDfjLzG','Aw5JBhvKzxm','yxbWBhK','CMvHzezPBgu','x3DYAxrLuxvLDwu','nJu1mZzeq1zdu2K','zxHPC3rZu3LUyW','BM93','ntrNwuTyB2G','D3jPDgvgAwXL','CgfYC2u','t2npCNG','DhjPBq','Dg9VBenVDw50CW','DNDjt1m','x2zSDxnO'];_0x4d41=function(){return _0x110a85;};return _0x4d41();}function _0x1a22(_0x13b9e6,_0x20486e){_0x13b9e6=_0x13b9e6-0x1be;const _0x350174=_0x4d41();let _0x4324e0=_0x350174[_0x13b9e6];if(_0x1a22['AHQtYR']===undefined){var _0x10738b=function(_0x5b25a2){const _0x541f5d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x193351='',_0x45bcd2='',_0x19a90d=_0x193351+_0x10738b;for(let _0x304c93=0x0,_0x3e44bb,_0x38a13b,_0x5be99b=0x0;_0x38a13b=_0x5b25a2['charAt'](_0x5be99b++);~_0x38a13b&&(_0x3e44bb=_0x304c93%0x4?_0x3e44bb*0x40+_0x38a13b:_0x38a13b,_0x304c93++%0x4)?_0x193351+=_0x19a90d['charCodeAt'](_0x5be99b+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x3e44bb>>(-0x2*_0x304c93&0x6)):_0x304c93:0x0){_0x38a13b=_0x541f5d['indexOf'](_0x38a13b);}for(let _0x17df8d=0x0,_0xe2c9f1=_0x193351['length'];_0x17df8d<_0xe2c9f1;_0x17df8d++){_0x45bcd2+='%'+('00'+_0x193351['charCodeAt'](_0x17df8d)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x45bcd2);};_0x1a22['KUSGBn']=_0x10738b,_0x1a22['wbmyOg']={},_0x1a22['AHQtYR']=!![];}const _0x4d41e8=_0x350174[0x0],_0x1a2290=_0x13b9e6+_0x4d41e8,_0x543614=_0x1a22['wbmyOg'][_0x1a2290];if(!_0x543614){const _0x26757c=function(_0x5e6270){this['lbzfJj']=_0x5e6270,this['njeDWc']=[0x1,0x0,0x0],this['OaXpim']=function(){return'newState';},this['hAFWEN']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['gPpDTx']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x26757c['prototype']['YqtiZe']=function(){const _0x502cea=new RegExp(this['hAFWEN']+this['gPpDTx']),_0x2f416e=_0x502cea['test'](this['OaXpim']['toString']())?--this['njeDWc'][0x1]:--this['njeDWc'][0x0];return this['yEMiDw'](_0x2f416e);},_0x26757c['prototype']['yEMiDw']=function(_0x4b68ba){if(!Boolean(~_0x4b68ba))return _0x4b68ba;return this['GewyTd'](this['lbzfJj']);},_0x26757c['prototype']['GewyTd']=function(_0x123b4d){for(let _0x46cbc8=0x0,_0x360e04=this['njeDWc']['length'];_0x46cbc8<_0x360e04;_0x46cbc8++){this['njeDWc']['push'](Math['round'](Math['random']())),_0x360e04=this['njeDWc']['length'];}return _0x123b4d(this['njeDWc'][0x0]);},new _0x26757c(_0x1a22)['YqtiZe'](),_0x4324e0=_0x1a22['KUSGBn'](_0x4324e0),_0x1a22['wbmyOg'][_0x1a2290]=_0x4324e0;}else _0x4324e0=_0x543614;return _0x4324e0;}import{MongoDBLogger}from'./mongoDBLogger.js';export class DatabaseLogger{['_dbFile'];[_0x43aaca(0x1e5)]=[];[_0x43aaca(0x1f8)]=Promise[_0x43aaca(0x1c6)]();[_0x43aaca(0x20c)];[_0x43aaca(0x1cf)]=null;[_0x43aaca(0x1c8)]=![];['_sessionId'];constructor(_0x2b16d8,_0x1bf758){const _0x360dee=_0x43aaca;this[_0x360dee(0x1e0)]=_0x2b16d8,this[_0x360dee(0x1e8)]=_0x1bf758?.[_0x360dee(0x1d8)]||'session_'+Date[_0x360dee(0x1fb)](),this[_0x360dee(0x1d6)](),(_0x1bf758||process.env.MONGODB_URL)&&this[_0x360dee(0x1df)](_0x1bf758)[_0x360dee(0x1d4)](logUnhandledError);}[_0x43aaca(0x1d6)](){const _0x20b535=_0x43aaca;if(!_0x4f2fb5['existsSync'](this[_0x20b535(0x1e0)])){const _0x3eb7c1=[];_0x4f2fb5[_0x20b535(0x1c2)](this[_0x20b535(0x1e0)],JSON[_0x20b535(0x1e4)](_0x3eb7c1,null,0x2));}}async['_initializeMongoDB'](_0x1c4011){const _0x5da5df=_0x43aaca,_0x39fd26={'QEvcT':_0x5da5df(0x1ee),'IAtXl':function(_0x25a41c,_0x57bcdf){return _0x25a41c(_0x57bcdf);}};try{this[_0x5da5df(0x1cf)]=new MongoDBLogger({..._0x1c4011,'sessionId':this[_0x5da5df(0x1e8)]});const _0xc94838=await this[_0x5da5df(0x1cf)][_0x5da5df(0x205)]();_0xc94838?(this[_0x5da5df(0x1c8)]=!![],console[_0x5da5df(0x1d2)](_0x5da5df(0x1bf)+this[_0x5da5df(0x1e8)]+')')):console[_0x5da5df(0x1d2)](_0x39fd26[_0x5da5df(0x1d7)]);}catch(_0x2b9280){console[_0x5da5df(0x1d2)](_0x39fd26[_0x5da5df(0x1d7)]),_0x39fd26[_0x5da5df(0x1d9)](logUnhandledError,_0x2b9280);}}[_0x43aaca(0x1de)](_0x58e0c9){const _0xc3f0c0=_0x43aaca,_0x5ba64c={'LhOkS':function(_0x5d8c7f,_0x4f405d){return _0x5d8c7f(_0x4f405d);},'EZMsz':function(_0x1d0113,_0x2c03cd,_0x6fde38){return _0x1d0113(_0x2c03cd,_0x6fde38);}},_0x4b730f={..._0x58e0c9};_0x4b730f[_0xc3f0c0(0x1d8)]=this[_0xc3f0c0(0x1e8)];const _0x152827=_0x4b730f;this[_0xc3f0c0(0x1c8)]&&this[_0xc3f0c0(0x1cf)]&&this[_0xc3f0c0(0x1cf)][_0xc3f0c0(0x1de)](_0x152827)['catch'](logUnhandledError);this[_0xc3f0c0(0x1e5)][_0xc3f0c0(0x1d0)](_0x152827);if(this[_0xc3f0c0(0x20c)])_0x5ba64c[_0xc3f0c0(0x1da)](clearTimeout,this[_0xc3f0c0(0x20c)]);this[_0xc3f0c0(0x20c)]=_0x5ba64c[_0xc3f0c0(0x1d5)](setTimeout,()=>this[_0xc3f0c0(0x203)](),0x1f4);}async[_0x43aaca(0x203)](){const _0x52caf5=_0x43aaca,_0x58f6bd={'XSTXB':_0x52caf5(0x1f0),'iPAlU':function(_0x3cef4b,_0x7175fd){return _0x3cef4b(_0x7175fd);},'uxBha':function(_0x51fef8,_0x255e9f){return _0x51fef8===_0x255e9f;}};if(_0x58f6bd['uxBha'](this[_0x52caf5(0x1e5)][_0x52caf5(0x1f1)],0x0))return;const _0x23d617=[...this[_0x52caf5(0x1e5)]];this[_0x52caf5(0x1e5)]=[],this[_0x52caf5(0x1f8)]=this[_0x52caf5(0x1f8)][_0x52caf5(0x1cc)](async()=>{const _0x29c941=_0x52caf5;try{let _0x43573e=[];if(_0x4f2fb5[_0x29c941(0x1fa)](this[_0x29c941(0x1e0)])){const _0x38a180=await _0x4f2fb5[_0x29c941(0x1dd)][_0x29c941(0x1f7)](this[_0x29c941(0x1e0)],_0x29c941(0x1f0));_0x38a180[_0x29c941(0x200)]()&&(_0x43573e=JSON['parse'](_0x38a180));}_0x43573e[_0x29c941(0x1d0)](..._0x23d617),await _0x4f2fb5[_0x29c941(0x1dd)][_0x29c941(0x1fd)](this[_0x29c941(0x1e0)],JSON['stringify'](_0x43573e,null,0x2),_0x58f6bd[_0x29c941(0x1c5)]);}catch(_0x41ed5b){_0x58f6bd[_0x29c941(0x1e9)](logUnhandledError,_0x41ed5b);}})[_0x52caf5(0x1d4)](logUnhandledError);}async['flushSync'](){const _0x309f14=_0x43aaca,_0x228c39={'KdZhz':function(_0x557bf0,_0x4e3747){return _0x557bf0(_0x4e3747);}};this[_0x309f14(0x20c)]&&(_0x228c39[_0x309f14(0x1c1)](clearTimeout,this[_0x309f14(0x20c)]),this[_0x309f14(0x20c)]=undefined),await this[_0x309f14(0x203)](),await this[_0x309f14(0x1f8)],this[_0x309f14(0x1cf)]&&await this['_mongoLogger'][_0x309f14(0x206)]();}[_0x43aaca(0x1ce)](){const _0x18825f=_0x43aaca;return this[_0x18825f(0x1cf)];}[_0x43aaca(0x1e6)](){const _0x361a6d=_0x43aaca;return this[_0x361a6d(0x1c8)];}[_0x43aaca(0x1c0)](){const _0x16d3ef=_0x43aaca;return this[_0x16d3ef(0x1e8)];}async[_0x43aaca(0x1f2)](){const _0x2bc2e0=_0x43aaca;this[_0x2bc2e0(0x1cf)]&&await this[_0x2bc2e0(0x1cf)][_0x2bc2e0(0x1f2)]();}async[_0x43aaca(0x1ec)](_0x4e6680,_0x3f5cce){const _0x403ceb=_0x43aaca,_0x5731d0={};_0x5731d0[_0x403ceb(0x1d1)]=_0x403ceb(0x1f0);const _0x5356f4=_0x5731d0;await this[_0x403ceb(0x206)]();if(this[_0x403ceb(0x1c8)]&&this[_0x403ceb(0x1cf)])return await this['_mongoLogger'][_0x403ceb(0x1ec)](_0x4e6680,_0x3f5cce);if(!_0x4f2fb5[_0x403ceb(0x1fa)](this[_0x403ceb(0x1e0)]))return[];const _0x7c9ca4=await _0x4f2fb5[_0x403ceb(0x1dd)][_0x403ceb(0x1f7)](this['_dbFile'],_0x5356f4['deayw']);if(!_0x7c9ca4[_0x403ceb(0x200)]())return[];const _0x2126f1=JSON[_0x403ceb(0x1fe)](_0x7c9ca4);return _0x2126f1['filter'](_0x1f40aa=>_0x1f40aa[_0x403ceb(0x204)]===_0x4e6680&&(!_0x3f5cce||_0x1f40aa[_0x403ceb(0x1d8)]===_0x3f5cce||_0x1f40aa[_0x403ceb(0x1d8)]===this[_0x403ceb(0x1e8)]));}async['queryByElementRef'](_0x3d8b1e,_0x26c5bc){const _0x5926d1=_0x43aaca,_0x413a89={};_0x413a89[_0x5926d1(0x1ff)]=_0x5926d1(0x1f0);const _0x107db7=_0x413a89;await this[_0x5926d1(0x206)]();if(this[_0x5926d1(0x1c8)]&&this[_0x5926d1(0x1cf)])return await this[_0x5926d1(0x1cf)]['queryByElementRef'](_0x3d8b1e,_0x26c5bc);if(!_0x4f2fb5[_0x5926d1(0x1fa)](this[_0x5926d1(0x1e0)]))return[];const _0x37289b=await _0x4f2fb5[_0x5926d1(0x1dd)][_0x5926d1(0x1f7)](this[_0x5926d1(0x1e0)],_0x107db7[_0x5926d1(0x1ff)]);if(!_0x37289b[_0x5926d1(0x200)]())return[];const _0x98d19f=JSON[_0x5926d1(0x1fe)](_0x37289b);return _0x98d19f[_0x5926d1(0x1dc)](_0x3d543d=>_0x3d543d[_0x5926d1(0x1f4)]===_0x3d8b1e&&(!_0x26c5bc||_0x3d543d[_0x5926d1(0x1d8)]===_0x26c5bc||_0x3d543d[_0x5926d1(0x1d8)]===this[_0x5926d1(0x1e8)]));}async[_0x43aaca(0x1c3)](_0x3357a5,_0xaee395){const _0x46717a=_0x43aaca,_0x58a1ac={};_0x58a1ac[_0x46717a(0x1e7)]=_0x46717a(0x1f0);const _0x9c88e3=_0x58a1ac;await this[_0x46717a(0x206)]();if(this[_0x46717a(0x1c8)]&&this[_0x46717a(0x1cf)])return await this[_0x46717a(0x1cf)][_0x46717a(0x1c3)](_0x3357a5,_0xaee395);if(!_0x4f2fb5[_0x46717a(0x1fa)](this[_0x46717a(0x1e0)]))return[];const _0x43b028=await _0x4f2fb5[_0x46717a(0x1dd)][_0x46717a(0x1f7)](this[_0x46717a(0x1e0)],_0x9c88e3['XAumS']);if(!_0x43b028[_0x46717a(0x200)]())return[];const _0x50f355=JSON[_0x46717a(0x1fe)](_0x43b028);return _0x50f355[_0x46717a(0x1dc)](_0x451833=>_0x451833[_0x46717a(0x20a)][_0x46717a(0x1f5)](_0x3357a5)&&(!_0xaee395||_0x451833[_0x46717a(0x1d8)]===_0xaee395||_0x451833[_0x46717a(0x1d8)]===this[_0x46717a(0x1e8)]));}async[_0x43aaca(0x207)](_0x22e229){const _0x586294=_0x43aaca,_0x3d5938={};_0x3d5938[_0x586294(0x202)]=_0x586294(0x1f0);const _0x358ba6=_0x3d5938;await this[_0x586294(0x206)]();if(this[_0x586294(0x1c8)]&&this[_0x586294(0x1cf)])return await this[_0x586294(0x1cf)][_0x586294(0x207)](_0x22e229);if(!_0x4f2fb5[_0x586294(0x1fa)](this[_0x586294(0x1e0)]))return[];const _0x34b077=await _0x4f2fb5[_0x586294(0x1dd)][_0x586294(0x1f7)](this['_dbFile'],_0x358ba6[_0x586294(0x202)]);if(!_0x34b077[_0x586294(0x200)]())return[];const _0x466a5d=JSON[_0x586294(0x1fe)](_0x34b077);if(!_0x22e229)return _0x466a5d[_0x586294(0x1dc)](_0x22d0a2=>_0x22d0a2[_0x586294(0x1d8)]===this[_0x586294(0x1e8)]);return _0x466a5d[_0x586294(0x1dc)](_0x266d9b=>_0x266d9b[_0x586294(0x1d8)]===_0x22e229);}async[_0x43aaca(0x1e3)](_0x1f6ae3){const _0x369699=_0x43aaca,_0x22f2e0={};_0x22f2e0[_0x369699(0x1db)]=function(_0x2b7898,_0x14fd4f){return _0x2b7898+_0x14fd4f;};const _0x13ab98=_0x22f2e0;if(this[_0x369699(0x1c8)]&&this[_0x369699(0x1cf)])return await this[_0x369699(0x1cf)][_0x369699(0x1e3)](_0x1f6ae3);const _0x4f3440=await this[_0x369699(0x207)](_0x1f6ae3),_0x366142={},_0x3346fd={},_0x365276={};_0x4f3440['forEach'](_0xeee844=>{const _0x3929d7=_0x369699;_0x366142[_0xeee844[_0x3929d7(0x204)]]=_0x13ab98[_0x3929d7(0x1db)](_0x366142[_0xeee844[_0x3929d7(0x204)]]||0x0,0x1),_0x3346fd[_0xeee844[_0x3929d7(0x1f4)]]=(_0x3346fd[_0xeee844[_0x3929d7(0x1f4)]]||0x0)+0x1,_0x365276[_0xeee844[_0x3929d7(0x20a)]]=_0x13ab98[_0x3929d7(0x1db)](_0x365276[_0xeee844[_0x3929d7(0x20a)]]||0x0,0x1);});const _0xcfd371={};return _0xcfd371[_0x369699(0x1ea)]=_0x4f3440[_0x369699(0x1f1)],_0xcfd371[_0x369699(0x201)]=_0x366142,_0xcfd371[_0x369699(0x1cd)]=_0x3346fd,_0xcfd371[_0x369699(0x1ed)]=_0x365276,_0xcfd371;}async[_0x43aaca(0x1e1)](){const _0x5c3f3a=_0x43aaca;await this[_0x5c3f3a(0x206)](),await _0x4f2fb5[_0x5c3f3a(0x1dd)][_0x5c3f3a(0x1fd)](this[_0x5c3f3a(0x1e0)],JSON[_0x5c3f3a(0x1e4)]([],null,0x2));}}export function createDatabaseLogger(_0x7c8d9f,_0x4d7cf2){const _0x29ef3c=_0x43aaca,_0x4c57cf=_0xff952c[_0x29ef3c(0x209)](_0x7c8d9f,_0x29ef3c(0x1e2));return new DatabaseLogger(_0x4c57cf,_0x4d7cf2);}
|