GameDotMgr.js
39.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
(function() {
var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined';
var __module = nodeEnv ? module : {exports:{}};
var __filename = 'preview-scripts/assets/script/game/GameDotMgr.js';
var __require = nodeEnv ? function (request) {
return cc.require(request);
} : function (request) {
return __quick_compile_project__.require(request, __filename);
};
function __define (exports, require, module) {
if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict";
cc._RF.push(module, '42c85SZlkZBiK4oiwPhmvGG', 'GameDotMgr');
// script/game/GameDotMgr.ts
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const simba_sdk_1 = require("simba-sdk");
const EditorEnums_1 = require("../avg/EditorEnums");
const AVG_1 = require("../avg/AVG");
const simba_config_manager_1 = require("simba-config-manager");
const Role_1 = require("../config/Role");
const GameConfig_1 = require("../GameConfig");
const Enums_1 = require("./Enums");
const GameModelManager_1 = require("./model/GameModelManager");
let GameDotMgr = /** @class */ (() => {
class GameDotMgr {
constructor() {
this._majorIds = [];
}
static getInstance() {
return GameDotMgr._instance;
}
async dot(eventKey, data, category) {
// if (channel === "dummy") return;
// category = category ? category : "yybs_event";
// let baseElements = this.getBaseElements();
// let biRet = await SDK.bi(category, eventKey, baseElements, data);
}
getBaseElements() {
let regV = AVG_1.GameRecord.globalVariables["register_version"];
if (!regV) {
regV = GameConfig_1.GameConfig.gameVersion;
AVG_1.GameRecord.globalVariables["register_version"] = regV;
AVG_1.GameRecord.saveRecord();
}
let player = GameModelManager_1.GameModelManager.getPlayerData();
let base = {
energy: player.getEnergy(),
gold: player.getGoldCoin(),
silver: player.getClothCoin(),
grace: [],
user_register_version: regV,
login_duration: simba_sdk_1.TimeManager.getGameTime(),
total_duration: simba_sdk_1.TimeManager.getTotalGameTime(),
daily_duration: simba_sdk_1.TimeManager.getTodayGameTime(),
};
let gArr = [];
if (!this._majorIds || 0 === this._majorIds.length) {
let r = simba_config_manager_1.ConfigManager.getAllConfig(Role_1.role);
for (let id in r) {
let c = r[id];
if (c && c.RoleType === EditorEnums_1.RoleType.Role_Major) {
this._majorIds.push(c.id);
}
}
}
for (let i = 0; i < this._majorIds.length; i++) {
let rid = this._majorIds[i];
let role = GameModelManager_1.GameModelManager.getRoleData(rid);
let gv = role === null || role === void 0 ? void 0 : role.getRoleLike();
gv = gv ? gv : 0;
let item = {
roleId: rid,
grace: gv
};
gArr.push(item);
}
base.grace = gArr;
return base;
}
async dotClickUI(uiName) {
let eventKey = "click_ui";
let recordKey = "click_ui_count_" + uiName + "_t_" + GameModelManager_1.GameModelManager.getCurDayStr();
let clickCount = AVG_1.GameRecord.globalVariables[recordKey];
if (undefined === clickCount) {
clickCount = 0;
}
clickCount += 1;
AVG_1.GameRecord.globalVariables[recordKey] = clickCount;
AVG_1.GameRecord.saveRecord();
// console.log("dotClickUI = ", { click_ui: clickCount, ui_location: uiName });
await this.dot(eventKey, { click_ui: clickCount, ui_location: uiName }, "click_ui");
}
async dotLoading(state) {
let eventKey = "loading";
await this.dot(eventKey, { loading: state }, "loading");
}
/**
*
* @param playerId 玩家的PlayerId
* @param gameConstData 兑换码兑换的道具ID
*/
async dotExchangeCodeSuccess(playerId, gameConstData) {
let eventKey = "exchange_code_success";
await this.dot(eventKey, { exchange_code_success: playerId, gameConstData: gameConstData }, "exchange_code_success");
}
async dotCost(cType, cNum) {
// let eventKey = "cost";
// let recordKey = cType + GameModelManager.getCurDayStr();
// let count = GameRecord.globalVariables[recordKey] as number;
// if (undefined === count) {
// count = 0;
// }
// count = count + cNum;
// GameRecord.globalVariables[recordKey] = count;
// GameRecord.saveRecord();
// let data = {};
// data[cType] = count;
// // console.log("dotCost = ", data);
// await this.dot(eventKey, data, "cost");
}
async dotPlot(session, state) {
let eventKey = "plot";
let v = session + "_" + state;
// console.log("dotPlot = ", { plot_state: v });
await this.dot(eventKey, { plot_state: v }, "plot");
}
async dotExposure(eType) {
// let eventKey = "show";
// // console.log("dotExposure = ", { show: eType });
// await this.dot(eventKey, { show: eType }, "show");
}
async dotShop(sType, param) {
// let eventKey = "shop";
// let data = {};
// switch (sType) {
// case DotShopType.LuckyDraw:
// {
// data[sType] = param.location;
// }
// break;
// case DotShopType.Clothes:
// {
// if (param.isWear) {
// data[sType] = "wear_" + param.sid + "_" + param.rid;
// } else {
// data[sType] = "have_" + param.sid + "_" + param.rid;
// }
// }
// break;
// }
// // console.log("dotShop = ", data);
// await this.dot(eventKey, data, "shop");
}
async dotShopTotal(sType, param) {
// let eventKey = "shop_total";
// let data = {};
// switch (sType) {
// case DotShopTotalType.ShowGift:
// {
// let rKey = "g_i_t_show_c" + GameModelManager.getCurDayStr();;
// let total = GameRecord.globalVariables[rKey] as number;
// total = total ? total : 0;
// total++;
// data[sType] = {
// show_id: "show_item_" + param.id,
// total_show: total
// }
// GameRecord.globalVariables[rKey] = total;
// }
// break;
// case DotShopTotalType.BuyItem:
// {
// let rKey = "g_i_t_buy_c" + GameModelManager.getCurDayStr();;
// let total = GameRecord.globalVariables[rKey] as number;
// total = total ? total : 0;
// total++;
// data[sType] = {
// buy_id: "buy_" + param.id,
// total_buy: total
// }
// GameRecord.globalVariables[rKey] = total;
// }
// break;
// case DotShopTotalType.SendGift:
// {
// let rKey = "g_i_t_send_c" + GameModelManager.getCurDayStr();;
// let total = GameRecord.globalVariables[rKey] as number;
// total = total ? total : 0;
// total++;
// data[sType] =
// {
// send_id: param.gid,
// role_id: param.rid,
// total_send: total
// };
// GameRecord.globalVariables[rKey] = total;
// }
// break;
// case DotShopTotalType.Popup:
// {
// data[sType] = param.popType;
// }
// break;
// }
// GameRecord.autoSave();
// // console.log("dotShopTotal = ", data);
// await this.dot(eventKey, data, "shop_total");
}
async dotTask(taskDotType, tId) {
// let eventKey = "task";
// let data = {};
// data["daily_task"] = {};
// switch (taskDotType) {
// case TaskDotType.CompleteTask:
// {
// data["daily_task"] = "completed_" + tId;
// }
// break;
// case TaskDotType.GetTaskRewards:
// {
// data["daily_task"] = "get_rewards_" + tId;
// }
// break;
// }
// await this.dot(eventKey, data, "task");
}
async dotMoment(id, optionType) {
// let eventKey = "circle_of_friends";
// let v = "circle_" + optionType;
// await this.dot(eventKey, { circle: v }, "circle_of_friends");
}
async dotTutorial(tType, state, param) {
let eventKey = "tutorial";
let k = "" + tType;
let v = "" + param.session;
switch (state) {
case Enums_1.TutorialState.SelectSentence:
{
v += state + param.plotId;
}
break;
case Enums_1.TutorialState.SelectSentenceRet:
{
k += "_plot_select";
v += Enums_1.TutorialState.SelectSentence + param.plotId + state + param.select;
}
break;
case Enums_1.TutorialState.Progress:
{
k += "_plot_progress";
v += state + param.progress;
}
break;
}
let data = {};
data[k] = v;
// console.log("dotTutorial = ", data);
await this.dot(eventKey, data, "tutorial");
}
async dotShare(shareType, shareLocation) {
let eventKey = "share";
// console.log("dotShare = ", { share_type: shareType, share_location: shareLocation });
await this.dot(eventKey, { share_type: shareType, share_location: shareLocation }, "share");
}
async dotVideo(videoType, videoLocation) {
let eventKey = "video";
// console.log("dotVideo = ", { video_type: videoType, video_location: videoLocation });
await this.dot(eventKey, { video_type: videoType, video_location: videoLocation }, "video");
}
//todo
async dotShareRes(location, titleId, imgId) {
let eventKey = "share_source";
let v = location + "_" + titleId + "_" + imgId;
await this.dot(eventKey, { share_source: v }, "share_source");
}
async dotGuide(oprType, location) {
let eventKey = "guide";
let v = location + oprType;
// console.log("dotGuide = ",{ guide: v });
await this.dot(eventKey, { guide: v }, "guide");
}
async dotEvent(oprType, location) {
let eventKey = 'event';
let v = location;
let data = {};
data[oprType] = v;
// console.log("dotEvent = ",data);
await this.dot(eventKey, data, 'event');
}
async dotSpecialPlot(sceneId, plotId, selectIndex, contenType, contentStatus) {
let eventKey = 'special_plot';
let data = {
scene: sceneId,
plot: plotId,
select: selectIndex,
contentype: contenType,
status: contentStatus
};
// console.log("dotSpecialPlot = ", data);
await this.dot(eventKey, data, 'special_plot');
}
}
GameDotMgr._instance = new GameDotMgr();
return GameDotMgr;
})();
exports.default = GameDotMgr;
cc._RF.pop();
}
if (nodeEnv) {
__define(__module.exports, __require, __module);
}
else {
__quick_compile_project__.registerModuleFunc(__filename, function () {
__define(__module.exports, __require, __module);
});
}
})();
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0cy9zY3JpcHQvZ2FtZS9HYW1lRG90TWdyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEseUNBQTZDO0FBQzdDLG9EQUE4QztBQUM5QyxvQ0FBd0M7QUFDeEMsK0RBQXFEO0FBQ3JELHlDQUFzQztBQUN0Qyw4Q0FBb0Q7QUFDcEQsbUNBQTZUO0FBQzdULCtEQUE0RDtBQWE1RDtJQUFB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ICBsZXQgcGxheWVyID0gR2FtZU1vZGVsTWFuYWdlci5nZXRQbGF5ZXJEYXRhKCk7XG4gICAgICAgIGxldCBiYXNlOiBCYXNlRG90RWxlbWVudHMgPSB7XG4gICAgICAgICAgICBlbmVyZ3k6IHBsYXllci5nZXRFbmVyZ3koKSxcbiAgICAgICAgICAgIGdvbGQ6IHBsYXllci5nZXRHb2xkQ29pbigpLFxuICAgICAgICAgICAgc2lsdmVyOiBwbGF5ZXIuZ2V0Q2xvdGhDb2luKCksXG4gICAgICAgICAgICBncmFjZTogW10sXG4gICAgICAgICAgICB1c2VyX3JlZ2lzdGVyX3ZlcnNpb246IHJlZ1YsXG4gICAgICAgICAgICBsb2dpbl9kdXJhdGlvbjogVGltZU1hbmFnZXIuZ2V0R2FtZVRpbWUoKSxcbiAgICAgICAgICAgIHRvdGFsX2R1cmF0aW9uOiBUaW1lTWFuYWdlci5nZXRUb3RhbEdhbWVUaW1lKCksXG4gICAgICAgICAgICBkYWlseV9kdXJhdGlvbjogVGltZU1hbmFnZXIuZ2V0VG9kYXlHYW1lVGltZSgpLFxuICAgICAgICB9O1xuICAgICAgICBsZXQgZ0FycjogeyByb2xlSWQ6IG51bWJlciwgZ3JhY2U6IG51bWJlciB9W10gPSBbXTtcbiAgICAgICAgaWYgKCF0aGlzLl9tYWpvcklkcyB8fCAwID09PSB0aGlzLl9tYWpvcklkcy5sZW5ndGgpIHtcbiAgICAgICAgICAgIGxldCByID0gQ29uZmlnTWFuYWdlci5nZXRBbGxDb25maWcocm9sZSk7XG4gICAgICAgICAgICBmb3IgKGxldCBpZCBpbiByKSB7XG4gICAgICAgICAgICAgICAgbGV0IGMgPSByW2lkXTtcbiAgICAgICAgICAgICAgICBpZiAoYyAmJiBjLlJvbGVUeXBlID09PSBSb2xlVHlwZS5Sb2xlX01ham9yKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX21ham9ySWRzLnB1c2goYy5pZCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdGhpcy5fbWFqb3JJZHMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIGxldCByaWQgPSB0aGlzLl9tYWpvcklkc1tpXTtcbiAgICAgICAgICAgIGxldCByb2xlID0gR2FtZU1vZGVsTWFuYWdlci5nZXRSb2xlRGF0YShyaWQpO1xuICAgICAgICAgICAgbGV0IGd2ID0gcm9sZT8uZ2V0Um9sZUxpa2UoKTtcbiAgICAgICAgICAgIGd2ID0gZ3YgPyBndiA6IDA7XG4gICAgICAgICAgICBsZXQgaXRlbTogeyByb2xlSWQ6IG51bWJlciwgZ3JhY2U6IG51bWJlciB9ID0ge1xuICAgICAgICAgICAgICAgIHJvbGVJZDogcmlkLFxuICAgICAgICAgICAgICAgIGdyYWNlOiBndlxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZ0Fyci5wdXNoKGl0ZW0pO1xuICAgICAgICB9XG4gICAgICAgIGJhc2UuZ3JhY2UgPSBnQXJyO1xuICAgICAgICByZXR1cm4gYmFzZTtcbiAgICB9XG5cbiAgICBwdWJsaWMgYXN5bmMgZG90Q2xpY2tVSSh1aU5hbWU6IHN0cmluZykge1xuICAgICAgICBsZXQgZXZlbnRLZXkgPSBcImNsaWNrX3VpXCI7XG4gICAgICAgIGxldCByZWNvcmRLZXkgPSBcImNsaWNrX3VpX2NvdW50X1wiICsgdWlOYW1lICsgXCJfdF9cIiArIEdhbWVNb2RlbE1hbmFnZXIuZ2V0Q3VyRGF5U3RyKCk7XG4gICAgICAgIGxldCBjbGlja0NvdW50ID0gR2FtZVJlY29yZC5nbG9iYWxWYXJpYWJsZXNbcmVjb3JkS2V5XSBhcyBudW1iZXI7XG4gICAgICAgIGlmICh1bmRlZmluZWQgPT09IGNsaWNrQ291bnQpIHtcbiAgICAgICAgICAgIGNsaWNrQ291bnQgPSAwO1xuICAgICAgICB9XG4gICAgICAgIGNsaWNrQ291bn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XCJfXCIgKyBwYXJhbS5yaWQ7XG4gICAgICAgIC8vICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgIC8vICAgICAgICAgICAgICAgICBkYXRhW3NUeXBlXSA9IFwiaGF2ZV9cIiArIHBhcmFtLnNpZCArIFwiX1wiICsgcGFyYW0ucmlkO1xuICAgICAgICAvLyAgICAgICAgICAgICB9XG4gICAgICAgIC8vICAgICAgICAgfVxuICAgICAgICAvLyAgICAgICAgIGJyZWFrO1xuICAgICAgICAvLyB9XG4gICAgICAgIC8vIC8vIGNvbnNvbGUubG9nKFwiZG90U2hvcCA9IFwiLCBkYXRhKTtcbiAgICAgICAgLy8gYXdhaXQgdGhpcy5kb3QoZXZlbnRLZXksIGRhdGEsIFwic2hvcFwiKTtcbiAgICB9XG5cbiAgICBwdWJsaWMgYXN5bmMgZG90U2hvcFRvdGFsKHNUeXBlOiBEb3RTaG9wVG90YWxUeXBlLCBwYXJhbT86IGFueSkge1xuICAgICAgICAvLyBsZXQgZXZlbnRLZXkgPSBcInNob3BfdG90YWxcIjtcbiAgICAgICAgLy8gbGV0IGRhdGEgPSB7fTtcbiAgICAgICAgLy8gc3dpdGNoIChzVHlwZSkge1xuICAgICAgICAvLyAgICAgY2FzZSBEb3RTaG9wVG90YWxUeXBlLlNob3dHaWZ0OlxuICAgICAgICAvLyAgICAgICAgIHtcbiAgICAgICAgLy8gICAgICAgICAgICAgbGV0IHJLZXkgPSBcImdfaV90X3Nob3dfY1wiICsgR2FtZU1vZGVsTWFuYWdlci5nZXRDdXJEYXlTdHIoKTs7XG4gICAgICAgIC8vICAgICAgICAgICAgIGxldCB0b3RhbCA9IEdhbWVSZWNvcmQuZ2xvYmFsVmFyaWFibGVzW3JLZXldIGFzIG51bWJlcjtcbiAgICAgICAgLy8gICAgICAgICAgICAgdG90YWwgPSB0b3RhbCA/IHRvdGFsIDogMDtcbiAgICAgICAgLy8gICAgICAgICAgICAgdG90YWwrKztcbiAgICAgICAgLy8gICAgICAgICAgICAgZGF0YVtzVHlwZV0gPSB7XG4gICAgICAgIC8vICAgICAgICAgICAgICAgICBzaG93X2lkOiBcInNob3dfaXRlbV9cIiArIHBhcmFtLmlkLFxuICAgICAgICAvLyAgICAgICAgICAgICAgICAgdG90YWxfc2hvdzogdG90YWxcbiAgICAgICAgLy8gICAgICAgICAgICAgfVxuICAgICAgICAvLyAgICAgICAgICAgICBHYW1lUmVjb3JkLmdsb2JhbFZhcmlhYmxlc1tyS2V5XSA9IHRvdGFsO1xuICAgICAgICAvLyAgICAgICAgIH1cbiAgICAgICAgLy8gICAgICAgICBicmVhaztcbiAgICAgICAgLy8gICAgIGNhc2UgRG90U2hvcFRvdGFsVHlwZS5CdXlJdGVtOlxuICAgICAgICAvLyAgICAgICAgIHtcbiAgICAgICAgLy8gICAgICAgICAgICAgbGV0IHJLZXkgPSBcImdfaV90X2J1eV9jXCIgKyBHYW1lTW9kZWxNYW5hZ2VyLmdldEN1ckRheVN0cigpOztcbiAgICAgICAgLy8gICAgICAgICAgICAgbGV0IHRvdGFsID0gR2FtZVJlY29yZC5nbG9iYWxWYXJpYWJsZXNbcktleV0gYXMgbnVtYmVyO1xuICAgICAgICAvLyAgICAgICAgICAgICB0b3RhbCA9IHRvdGFsID8gdG90YWwgOiAwO1xuICAgICAgICAvLyAgICAgICAgICAgICB0b3RhbCsrO1xuICAgICAgICAvLyAgICAgICAgICAgICBkYXRhW3NUeXBlXSA9IHtcbiAgICAgICAgLy8gICAgICAgICAgICAgICAgIGJ1eV9pZDogXCJidXlfXCIgKyBwYXJhbS5pZCxcbiAgICAgICAgLy8gICAgICAgICAgICAgICAgIHRvdGFsX2J1eTogdG90YWxcbiAgICAgICAgLy8gICAgICAgICAgICAgfVxuICAgICAgICAvLyAgICAgICAgICAgICBHYW1lUmVjb3JkLmdsb2JhbFZhcmlhYmxlc1tyS2V5XSA9IHRvdGFsO1xuICAgICAgICAvLyAgICAgICAgIH1cbiAgICAgICAgLy8gICAgICAgICBicmVhaztcbiAgICAgICAgLy8gICAgIGNhc2UgRG90U2hvcFRvdGFsVHlwZS5TZW5kR2lmdDpcbiAgICAgICAgLy8gICAgICAgICB7XG4gICAgICAgIC8vICAgICAgICAgICAgIGxldCByS2V5ID0gXCJnX2lfdF9zZW5kX2NcIiArIEdhbWVNb2RlbE1hbmFnZXIuZ2V0Q3VyRGF5U3RyKCk7O1xuICAgICAgICAvLyAgICAgICAgICAgICBsZXQgdG90YWwgPSBHYW1lUmVjb3JkLmdsb2JhbFZhcmlhYmxlc1tyS2V5XSBhcyBudW1iZXI7XG4gICAgICAgIC8vICAgICAgICAgICAgIHRvdGFsID0gdG90YWwgPyB0b3RhbCA6IDA7XG4gICAgICAgIC8vICAgICAgICAgICAgIHRvdGFsKys7XG4gICAgICAgIC8vICAgICAgICAgICAgIGRhdGFbc1R5cGVdID1cbiAgICAgICAgLy8gICAgICAgICAgICAge1xuICAgICAgICAvLyAgICAgICAgICAgICAgICAgc2VuZF9pZDogcGFyYW0uZ2lkLFxuICAgICAgICAvLyAgICAgICAgICAgICAgICAgcm9sZV9pZDogcGFyYW0ucmlkLFxuICAgICAgICAvLyAgICAgICAgICAgICAgICAgdG90YWxfc2VuZDogdG90YWxcbiAgICAgICAgLy8gICAgICAgICAgICAgfTtcbiAgICAgICAgLy8gICAgICAgICAgICAgR2FtZVJlY29yZC5nbG9iYWxWYXJpYWJsZXNbcktleV0gPSB0b3RhbDtcbiAgICAgICAgLy8gICAgICAgICB9XG4gICAgICAgIC8vICAgICAgICAgYnJlYWs7XG4gICAgICAgIC8vICAgICBjYXNlIERvdFNob3BUb3RhbFR5cGUuUG9wdXA6XG4gICAgICAgIC8vICAgICAgICAge1xuICAgICAgICAvLyAgICAgICAgICAgICBkYXRhW3NUeXBlXSA9IHBhcmFtLnBvcFR5cGU7XG4gICAgICAgIC8vICAgICAgICAgfVxuICAgICAgICAvLyAgICAgICAgIGJyZWFrO1xuICAgICAgICAvLyB9XG4gICAgICAgIC8vIEdhbWVSZWNvcmQuYXV0b1NhdmUoKTtcbiAgICAgICAgLy8gLy8gY29uc29sZS5sb2coXCJkb3RTaG9wVG90YWwgPSBcIiwgZGF0YSk7XG4gICAgICAgIC8vIGF3YWl0IHRoaXMuZG90KGV2ZW50S2V5LCBkYXRhLCBcInNob3BfdG90YWxcIik7XG4gICAgfVxuXG4gICAgcHVibGljIGFzeW5jIGRvdFRhc2sodGFza0RvdFR5cGU6IFRhc2tEb3RUeXBlLCB0SWQ6IG51bWJlcikge1xuICAgICAgICAvLyBsZXQgZXZlbnRLZXkgPSBcInRhc2tcIjtcbiAgICAgICAgLy8gbGV0IGRhdGEgPSB7fTtcbiAgICAgICAgLy8gZGF0YVtcImRhaWx5X3Rhc2tcIl0gPSB7fTtcbiAgICAgICAgLy8gc3dpdGNoICh0YXNrRG90VHlwZSkge1xuICAgICAgICAvLyAgICAgY2FzZSBUYXNrRG90VHlwZS5Db21wbGV0ZVRhc2s6XG4gICAgICAgIC8vICAgICAgICAge1xuICAgICAgICAvLyAgICAgICAgICAgICBkYXRhW1wiZGFpbHlfdGFza1wiXSA9IFwiY29tcGxldGVkX1wiICsgdElkO1xuICAgICAgICAvLyAgICAgICAgIH1cbiAgICAgICAgLy8gICAgICAgICBicmVhaztcbiAgICAgICAgLy8gICAgIGNhc2UgVGFza0RvdFR5cGUuR2V0VGFza1Jld2FyZHM6XG4gICAgICAgIC8vICAgICAgICAge1xuICAgICAgICAvLyAgICAgICAgICAgICBkYXRhW1wiZGFpbHlfdGFza1wiXSA9IFwiZ2V0X3Jld2FyZHNfXCIgKyB0SWQ7XG4gICAgICAgIC8vICAgICAgICAgfVxuICAgICAgICAvLyAgICAgICAgIGJyZWFrO1xuICAgICAgICAvLyB9XG4gICAgICAgIC8vIGF3YWl0IHRoaXMuZG90KGV2ZW50S2V5LCBkYXRhLCBcInRhc2tcIik7XG4gICAgfVxuXG4gICAgcHVibGljIGFzeW5jIGRvdE1vbWVudChpZDogbnVtYmVyLCBvcHRpb25UeXBlOiBNb21lbnRPcHRpb25UeXBlKSB7XG4gICAgICAgIC8vIGxldCBldmVudEtleSA9IFwiY2lyY2xlX29mX2ZyaWVuZHNcIjtcbiAgICAgICAgLy8gbGV0IHYgPSBcImNpcmNsZV9cIiArIG9wdGlvblR5cGU7XG4gICAgICAgIC8vIGF3YWl0IHRoaXMuZG90KGV2ZW50S2V5LCB7IGNpcmNsZTogdiB9LCBcImNpcmNsZV9vZl9mcmllbmRzXCIpO1xuICAgIH1cblxuICAgIHB1YmxpYyBhc3luYyBkb3RUdXRvcmlhbCh0VHlwZTogVHV0b3JpYWxUeXBlLCBzdGF0ZTogVHV0b3JpYWxTdGF0ZSwgcGFyYW06IGFueSkge1xuICAgICAgICBsZXQgZXZlbnRLZXkgPSBcInR1dG9yaWFsXCI7XG4gICAgICAgIGxldCBrID0gXCJcIiArIHRUeXBlO1xuICAgICAgICBsZXQgdiA9IFwiXCIgKyBwYXJhbS5zZXNzaW9uO1xuICAgICAgICBzd2l0Y2ggKHN0YXRlKSB7XG4gICAgICAgICAgICBjYXNlIFR1dG9yaWFsU3RhdGUuU2VsZWN0U2VudGVuY2U6XG4gICAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgICAgICB2ICs9IHN0YXRlICsgcGFyYW0ucGxvdElkO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgVHV0b3JpYWxTdGF0ZS5TZWxlY3RTZW50ZW5jZVJldDpcbiAgICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgICAgIGsgKz0gXCJfcGxvdF9zZWxlY3RcIjtcbiAgICAgICAgICAgICAgICAgICAgdiArPSBUdXRvcmlhbFN0YXRlLlNlbGVjdFNlbnRlbmNlICsgcGFyYW0ucGxvdElkICsgc3RhdGUgKyBwYXJhbS5zZWxlY3Q7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBUdXRvcm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