@inappstory/slide-api 0.1.3 → 0.1.5

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/dist/index.cjs CHANGED
@@ -197,41 +197,31 @@ const container = new DIContainer();
197
197
 
198
198
  class WidgetsService {
199
199
  _env;
200
- _sdkApi;
201
- constructor(_env, _sdkApi) {
200
+ constructor(_env) {
202
201
  this._env = _env;
203
- this._sdkApi = _sdkApi;
204
202
  }
205
203
  get env() {
206
204
  return this._env;
207
205
  }
208
- get sdkApi() {
209
- return this._sdkApi;
210
- }
211
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`Window`, `SDKApi`]; }
206
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`Window`]; }
212
207
  }
213
208
 
214
209
  container.registerSingleton(undefined, { identifier: `WidgetsService`, implementation: WidgetsService });
215
210
 
216
211
  class LayoutService {
217
212
  _env;
218
- _sdkApi;
219
213
  _layoutApi;
220
- constructor(_env, _sdkApi, _layoutApi) {
214
+ constructor(_env, _layoutApi) {
221
215
  this._env = _env;
222
- this._sdkApi = _sdkApi;
223
216
  this._layoutApi = _layoutApi;
224
217
  }
225
218
  get env() {
226
219
  return this._env;
227
220
  }
228
- get sdkApi() {
229
- return this._sdkApi;
230
- }
231
221
  get layoutApi() {
232
222
  return this._layoutApi;
233
223
  }
234
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`Window`, `SDKApi`, `ILayoutApi`]; }
224
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`Window`, `ILayoutApi`]; }
235
225
  }
236
226
 
237
227
  container.registerSingleton(undefined, { identifier: `LayoutService`, implementation: LayoutService });
@@ -243,8 +233,6 @@ container.registerSingleton(undefined, { identifier: `LayoutService`, implementa
243
233
  // import '../effects/timer/composition';
244
234
  container.registerSingleton(() => window, { identifier: `Window` });
245
235
 
246
- const DEFAULT_SLIDE_DURATION = 10000;
247
-
248
236
  const arPrototype = Array.prototype;
249
237
  const obPrototype = Object.prototype;
250
238
  const slice = arPrototype.slice;
@@ -1054,28 +1042,25 @@ class EsModuleSdkApi {
1054
1042
  this.sdkBinding = sdkBinding;
1055
1043
  }
1056
1044
  getCardServerData(cardId) {
1057
- return this.sdkBinding().getCardServerData(cardId);
1045
+ return this.sdkBinding.getCardServerData(cardId);
1058
1046
  }
1059
1047
  updateCardServerDataLocally(cardId, data) {
1060
- return this.sdkBinding().updateCardServerDataLocally(data);
1061
- }
1062
- getSlideDuration(cardId, slideIndex) {
1063
- return this.sdkBinding().getSlideDuration(cardId, slideIndex);
1048
+ return this.sdkBinding.updateCardServerDataLocally(data);
1064
1049
  }
1065
1050
  showNextSlide(duration) {
1066
- this.sdkBinding().showNextSlide(duration);
1051
+ this.sdkBinding.showNextSlide();
1067
1052
  }
1068
1053
  sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2) {
1069
- this.sdkBinding().sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2);
1054
+ this.sdkBinding.sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2);
1070
1055
  }
1071
1056
  getCardLocalData() {
1072
- return this.sdkBinding().getCardLocalData();
1057
+ return this.sdkBinding.getCardLocalData();
1073
1058
  }
1074
1059
  isExistsShowLayer() {
1075
1060
  return true;
1076
1061
  }
1077
1062
  showLayer(index) {
1078
- this.sdkBinding().showLayer(index);
1063
+ this.sdkBinding.showLayer(index);
1079
1064
  }
1080
1065
  get cardAnimation() {
1081
1066
  return animationApi;
@@ -1090,37 +1075,37 @@ class EsModuleSdkApi {
1090
1075
  return true;
1091
1076
  }
1092
1077
  pauseUI() {
1093
- this.sdkBinding().pauseUI();
1078
+ this.sdkBinding.pauseUI();
1094
1079
  }
1095
1080
  resumeUI() {
1096
- this.sdkBinding().resumeUI();
1081
+ this.sdkBinding.resumeUI();
1097
1082
  }
1098
1083
  get isExistsShowCardTextInput() {
1099
1084
  return true;
1100
1085
  }
1101
1086
  showCardTextInput(id, data) {
1102
- this.sdkBinding().showCardTextInput(id, data);
1087
+ this.sdkBinding.showCardTextInput(id, data);
1103
1088
  }
1104
1089
  setCardLocalData(keyValue, sendToServer) {
1105
- this.sdkBinding().setCardLocalData(keyValue, sendToServer);
1090
+ this.sdkBinding.setCardLocalData(keyValue, sendToServer);
1106
1091
  }
1107
1092
  getWidgetsSharedData(cardId, widget) {
1108
- return this.sdkBinding().getWidgetsSharedData(cardId, widget);
1093
+ return this.sdkBinding.getWidgetsSharedData(cardId, widget);
1109
1094
  }
1110
1095
  vibrate(pattern) {
1111
1096
  navigator.vibrate(pattern);
1112
1097
  }
1113
1098
  openUrl(data) {
1114
- this.sdkBinding().openUrl(data);
1099
+ this.sdkBinding.openUrl(data);
1115
1100
  }
1116
1101
  sendApiRequest(url, method, params, headers, data, profilingKey) {
1117
- return this.sdkBinding().sendApiRequest(url, method, params, headers, data, profilingKey);
1102
+ return this.sdkBinding.sendApiRequest(url, method, params, headers, data, profilingKey);
1118
1103
  }
1119
1104
  sendApiRequestSupported() {
1120
1105
  return true;
1121
1106
  }
1122
1107
  showToast(text) {
1123
- this.sdkBinding().showToast(text);
1108
+ this.sdkBinding.showToast(text);
1124
1109
  }
1125
1110
  get sdkCanSendShareComplete() {
1126
1111
  return true;
@@ -1129,79 +1114,81 @@ class EsModuleSdkApi {
1129
1114
  return true;
1130
1115
  }
1131
1116
  share(id, config) {
1132
- this.sdkBinding().share(id, config);
1117
+ this.sdkBinding.share(id, config);
1133
1118
  }
1134
1119
  shareSlideScreenshot(shareId, hideElementsSelector, shareText) {
1135
- this.sdkBinding().shareSlideScreenshot(shareId, hideElementsSelector, shareText);
1120
+ this.sdkBinding.shareSlideScreenshot(shareId, hideElementsSelector, shareText);
1136
1121
  }
1137
1122
  get isExistsShowCardSlide() {
1138
1123
  return true;
1139
1124
  }
1140
1125
  showCardSlide(index) {
1141
- this.sdkBinding().showCardSlide(index);
1126
+ this.sdkBinding.showCardSlide(index);
1142
1127
  }
1143
1128
  get isExistsShowNextCard() {
1144
1129
  return true;
1145
1130
  }
1146
1131
  cardShowNext() {
1147
- this.sdkBinding().cardShowNext();
1132
+ this.sdkBinding.cardShowNext();
1148
1133
  }
1149
1134
  setCardSessionValue(element, key, value) {
1150
- this.sdkBinding().setCardSessionValue(key, value);
1135
+ this.sdkBinding.setCardSessionValue(key, value);
1151
1136
  }
1152
1137
  getCardSessionValue(element, key) {
1153
- return this.sdkBinding().getCardSessionValue(key);
1138
+ return this.sdkBinding.getCardSessionValue(key);
1154
1139
  }
1155
1140
  updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError) {
1156
- const updateTimeline = this.sdkBinding().updateTimeline;
1157
- if (updateTimeline != null) {
1158
- updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError);
1159
- }
1141
+ this.sdkBinding.updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError);
1160
1142
  }
1161
1143
  cardPausedCallback(currentTime) { }
1162
1144
  cardResumedCallback(currentTime) { }
1163
- startDisabledTimeline(cardId, slideIndex) {
1164
- // old api
1165
- this.showNextSlide(this.getSlideDuration(cardId, slideIndex) ?? DEFAULT_SLIDE_DURATION);
1166
- }
1167
1145
  getCardFonts() {
1168
- return this.sdkBinding().getCardFonts();
1146
+ return this.sdkBinding.getCardFonts();
1169
1147
  }
1170
1148
  disableVerticalSwipeGesture() {
1171
- this.sdkBinding().disableVerticalSwipeGesture();
1149
+ this.sdkBinding.disableVerticalSwipeGesture();
1172
1150
  }
1173
1151
  enableVerticalSwipeGesture() {
1174
- this.sdkBinding().enableVerticalSwipeGesture();
1152
+ this.sdkBinding.enableVerticalSwipeGesture();
1175
1153
  }
1176
1154
  disableBackpress() { }
1177
1155
  enableBackpress() { }
1178
1156
  closeCard(reason) {
1179
- this.sdkBinding().closeCard(reason);
1157
+ this.sdkBinding.closeCard(reason);
1180
1158
  }
1181
1159
  openStory(id, index) {
1182
- this.sdkBinding().openStory(id, index);
1160
+ this.sdkBinding.openStory(id, index);
1183
1161
  }
1184
1162
  openGame(gameInstanceId) {
1185
- this.sdkBinding().openGame(gameInstanceId);
1163
+ this.sdkBinding.openGame(gameInstanceId);
1186
1164
  }
1187
1165
  writeToClipboard(data) {
1188
- this.sdkBinding().writeToClipboard(data);
1166
+ this.sdkBinding.writeToClipboard(data);
1167
+ }
1168
+ isSdkSupportTimelineOnBeforeStart() {
1169
+ return true;
1189
1170
  }
1190
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`() => SDKInterface`]; }
1171
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`SDKInterface`]; }
1191
1172
  }
1192
1173
 
1174
+ const DEFAULT_SLIDE_DURATION = 10000;
1175
+
1193
1176
  class DataInput {
1194
1177
  _elementNodeRef;
1195
1178
  _layer;
1196
1179
  _widgetApi;
1180
+ _onWidgetComplete;
1181
+ sdkApi;
1197
1182
  static _className = "narrative-element-data-input";
1198
1183
  static className() {
1199
1184
  return DataInput._className;
1200
1185
  }
1201
- constructor(_elementNodeRef, _layer, _widgetApi) {
1186
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1202
1187
  this._elementNodeRef = _elementNodeRef;
1203
1188
  this._layer = _layer;
1204
1189
  this._widgetApi = _widgetApi;
1190
+ this._onWidgetComplete = _onWidgetComplete;
1191
+ this.sdkApi = sdkApi;
1205
1192
  }
1206
1193
  static isTypeOf(element) {
1207
1194
  return element instanceof DataInput;
@@ -1209,7 +1196,7 @@ class DataInput {
1209
1196
  mediaElementsLoadingPromises = [];
1210
1197
  init(localData) {
1211
1198
  try {
1212
- this._widgetApi.init(this._elementNodeRef, localData);
1199
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1213
1200
  }
1214
1201
  catch (e) {
1215
1202
  console.error(e);
@@ -1224,6 +1211,7 @@ class DataInput {
1224
1211
  onStop() {
1225
1212
  this._widgetApi.onStop(this._elementNodeRef);
1226
1213
  }
1214
+ onBeforeUnmount() { }
1227
1215
  handleClick() {
1228
1216
  return false;
1229
1217
  }
@@ -1233,26 +1221,30 @@ class DataInput {
1233
1221
  get isLayerForcePaused() {
1234
1222
  return false;
1235
1223
  }
1236
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetDataInput.api`]; }
1224
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetDataInput.api`, `OnWidgetComplete`, `SDKApi`]; }
1237
1225
  }
1238
1226
 
1239
1227
  class Barcode {
1240
1228
  _elementNodeRef;
1241
1229
  _layer;
1242
1230
  _widgetApi;
1231
+ _onWidgetComplete;
1232
+ sdkApi;
1243
1233
  static _className = "narrative-element-barcode";
1244
1234
  static className() {
1245
1235
  return Barcode._className;
1246
1236
  }
1247
- constructor(_elementNodeRef, _layer, _widgetApi) {
1237
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1248
1238
  this._elementNodeRef = _elementNodeRef;
1249
1239
  this._layer = _layer;
1250
1240
  this._widgetApi = _widgetApi;
1241
+ this._onWidgetComplete = _onWidgetComplete;
1242
+ this.sdkApi = sdkApi;
1251
1243
  }
1252
1244
  mediaElementsLoadingPromises = [];
1253
1245
  init(localData) {
1254
1246
  try {
1255
- this._widgetApi.init(this._elementNodeRef, localData);
1247
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1256
1248
  }
1257
1249
  catch (e) {
1258
1250
  console.error(e);
@@ -1267,13 +1259,14 @@ class Barcode {
1267
1259
  onStop() {
1268
1260
  this._widgetApi.onStop(this._elementNodeRef);
1269
1261
  }
1262
+ onBeforeUnmount() { }
1270
1263
  handleClick() {
1271
1264
  return false;
1272
1265
  }
1273
1266
  get isLayerForcePaused() {
1274
1267
  return false;
1275
1268
  }
1276
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetBarcode.api`]; }
1269
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetBarcode.api`, `OnWidgetComplete`, `SDKApi`]; }
1277
1270
  }
1278
1271
 
1279
1272
  class ClickableBase {
@@ -1304,6 +1297,7 @@ class Button extends ClickableBase {
1304
1297
  onResume() { }
1305
1298
  onStart() { }
1306
1299
  onStop() { }
1300
+ onBeforeUnmount() { }
1307
1301
  handleClick() {
1308
1302
  return false;
1309
1303
  }
@@ -1317,19 +1311,23 @@ class Copy {
1317
1311
  _elementNodeRef;
1318
1312
  _layer;
1319
1313
  _widgetApi;
1314
+ _onWidgetComplete;
1315
+ sdkApi;
1320
1316
  static _className = "narrative-element-copy";
1321
1317
  static className() {
1322
1318
  return Copy._className;
1323
1319
  }
1324
- constructor(_elementNodeRef, _layer, _widgetApi) {
1320
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1325
1321
  this._elementNodeRef = _elementNodeRef;
1326
1322
  this._layer = _layer;
1327
1323
  this._widgetApi = _widgetApi;
1324
+ this._onWidgetComplete = _onWidgetComplete;
1325
+ this.sdkApi = sdkApi;
1328
1326
  }
1329
1327
  mediaElementsLoadingPromises = [];
1330
1328
  init(localData) {
1331
1329
  try {
1332
- this._widgetApi.init(this._elementNodeRef, localData);
1330
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1333
1331
  }
1334
1332
  catch (e) {
1335
1333
  console.error(e);
@@ -1344,13 +1342,14 @@ class Copy {
1344
1342
  onStop() {
1345
1343
  this._widgetApi.onStop(this._elementNodeRef);
1346
1344
  }
1345
+ onBeforeUnmount() { }
1347
1346
  handleClick() {
1348
1347
  return false;
1349
1348
  }
1350
1349
  get isLayerForcePaused() {
1351
1350
  return false;
1352
1351
  }
1353
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetCopy.api`]; }
1352
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetCopy.api`, `OnWidgetComplete`, `SDKApi`]; }
1354
1353
  }
1355
1354
 
1356
1355
  class DateCountdown {
@@ -1358,20 +1357,24 @@ class DateCountdown {
1358
1357
  _layer;
1359
1358
  _layersNodesRefs;
1360
1359
  _widgetApi;
1360
+ _onWidgetComplete;
1361
+ sdkApi;
1361
1362
  static _className = "narrative-element-date-countdown";
1362
1363
  static className() {
1363
1364
  return DateCountdown._className;
1364
1365
  }
1365
- constructor(_elementNodeRef, _layer, _layersNodesRefs, _widgetApi) {
1366
+ constructor(_elementNodeRef, _layer, _layersNodesRefs, _widgetApi, _onWidgetComplete, sdkApi) {
1366
1367
  this._elementNodeRef = _elementNodeRef;
1367
1368
  this._layer = _layer;
1368
1369
  this._layersNodesRefs = _layersNodesRefs;
1369
1370
  this._widgetApi = _widgetApi;
1371
+ this._onWidgetComplete = _onWidgetComplete;
1372
+ this.sdkApi = sdkApi;
1370
1373
  }
1371
1374
  mediaElementsLoadingPromises = [];
1372
1375
  init(localData) {
1373
1376
  try {
1374
- this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData);
1377
+ this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._onWidgetComplete, this.sdkApi);
1375
1378
  }
1376
1379
  catch (e) {
1377
1380
  console.error(e);
@@ -1390,27 +1393,32 @@ class DateCountdown {
1390
1393
  onStop() {
1391
1394
  this._widgetApi.onStop(this._elementNodeRef);
1392
1395
  }
1396
+ onBeforeUnmount() { }
1393
1397
  handleClick() {
1394
1398
  return false;
1395
1399
  }
1396
1400
  get isLayerForcePaused() {
1397
1401
  return false;
1398
1402
  }
1399
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `Array`, `typeof WidgetDateCountdown.api`]; }
1403
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `Array`, `typeof WidgetDateCountdown.api`, `OnWidgetComplete`, `SDKApi`]; }
1400
1404
  }
1401
1405
 
1402
1406
  class Poll {
1403
1407
  _elementNodeRef;
1404
1408
  _layer;
1405
1409
  _widgetApi;
1410
+ _onWidgetComplete;
1411
+ sdkApi;
1406
1412
  static _className = "narrative-element-poll";
1407
1413
  static className() {
1408
1414
  return Poll._className;
1409
1415
  }
1410
- constructor(_elementNodeRef, _layer, _widgetApi) {
1416
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1411
1417
  this._elementNodeRef = _elementNodeRef;
1412
1418
  this._layer = _layer;
1413
1419
  this._widgetApi = _widgetApi;
1420
+ this._onWidgetComplete = _onWidgetComplete;
1421
+ this.sdkApi = sdkApi;
1414
1422
  }
1415
1423
  static isTypeOf(element) {
1416
1424
  return element instanceof Poll;
@@ -1418,7 +1426,7 @@ class Poll {
1418
1426
  mediaElementsLoadingPromises = [];
1419
1427
  init(localData) {
1420
1428
  try {
1421
- this._widgetApi.init(this._elementNodeRef, localData);
1429
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1422
1430
  }
1423
1431
  catch (e) {
1424
1432
  console.error(e);
@@ -1433,6 +1441,7 @@ class Poll {
1433
1441
  onStop() {
1434
1442
  this._widgetApi.onStop(this._elementNodeRef);
1435
1443
  }
1444
+ onBeforeUnmount() { }
1436
1445
  handleClick() {
1437
1446
  return false;
1438
1447
  }
@@ -1442,7 +1451,7 @@ class Poll {
1442
1451
  get isLayerForcePaused() {
1443
1452
  return false;
1444
1453
  }
1445
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetPoll.api`]; }
1454
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetPoll.api`, `OnWidgetComplete`, `SDKApi`]; }
1446
1455
  }
1447
1456
 
1448
1457
  class PollLayers {
@@ -1450,15 +1459,19 @@ class PollLayers {
1450
1459
  _layer;
1451
1460
  _layersNodesRefs;
1452
1461
  _widgetApi;
1462
+ _onWidgetComplete;
1463
+ sdkApi;
1453
1464
  static _className = "narrative-element-poll-layers";
1454
1465
  static className() {
1455
1466
  return PollLayers._className;
1456
1467
  }
1457
- constructor(_elementNodeRef, _layer, _layersNodesRefs, _widgetApi) {
1468
+ constructor(_elementNodeRef, _layer, _layersNodesRefs, _widgetApi, _onWidgetComplete, sdkApi) {
1458
1469
  this._elementNodeRef = _elementNodeRef;
1459
1470
  this._layer = _layer;
1460
1471
  this._layersNodesRefs = _layersNodesRefs;
1461
1472
  this._widgetApi = _widgetApi;
1473
+ this._onWidgetComplete = _onWidgetComplete;
1474
+ this.sdkApi = sdkApi;
1462
1475
  }
1463
1476
  static isTypeOf(element) {
1464
1477
  return element instanceof PollLayers;
@@ -1466,7 +1479,7 @@ class PollLayers {
1466
1479
  mediaElementsLoadingPromises = [];
1467
1480
  init(localData) {
1468
1481
  try {
1469
- this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData);
1482
+ this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._onWidgetComplete, this.sdkApi);
1470
1483
  }
1471
1484
  catch (e) {
1472
1485
  console.error(e);
@@ -1481,27 +1494,32 @@ class PollLayers {
1481
1494
  onStop() {
1482
1495
  this._widgetApi.onStop(this._elementNodeRef);
1483
1496
  }
1497
+ onBeforeUnmount() { }
1484
1498
  handleClick() {
1485
1499
  return false;
1486
1500
  }
1487
1501
  get isLayerForcePaused() {
1488
1502
  return false;
1489
1503
  }
1490
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `Array`, `typeof WidgetPollLayers.api`]; }
1504
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `Array`, `typeof WidgetPollLayers.api`, `OnWidgetComplete`, `SDKApi`]; }
1491
1505
  }
1492
1506
 
1493
1507
  class Products {
1494
1508
  _elementNodeRef;
1495
1509
  _layer;
1496
1510
  _widgetApi;
1511
+ _onWidgetComplete;
1512
+ sdkApi;
1497
1513
  static _className = "narrative-element-products";
1498
1514
  static className() {
1499
1515
  return Products._className;
1500
1516
  }
1501
- constructor(_elementNodeRef, _layer, _widgetApi) {
1517
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1502
1518
  this._elementNodeRef = _elementNodeRef;
1503
1519
  this._layer = _layer;
1504
1520
  this._widgetApi = _widgetApi;
1521
+ this._onWidgetComplete = _onWidgetComplete;
1522
+ this.sdkApi = sdkApi;
1505
1523
  }
1506
1524
  static isTypeOf(element) {
1507
1525
  return element instanceof Products;
@@ -1509,7 +1527,7 @@ class Products {
1509
1527
  mediaElementsLoadingPromises = [];
1510
1528
  init(localData) {
1511
1529
  try {
1512
- this._widgetApi.init(this._elementNodeRef, localData);
1530
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1513
1531
  }
1514
1532
  catch (e) {
1515
1533
  console.error(e);
@@ -1524,6 +1542,7 @@ class Products {
1524
1542
  onStop() {
1525
1543
  this._widgetApi.onStop(this._elementNodeRef);
1526
1544
  }
1545
+ onBeforeUnmount() { }
1527
1546
  handleClick() {
1528
1547
  return false;
1529
1548
  }
@@ -1539,28 +1558,32 @@ class Products {
1539
1558
  get isLayerForcePaused() {
1540
1559
  return this._widgetApi.isForcePaused(this._elementNodeRef);
1541
1560
  }
1542
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetProducts.api`]; }
1561
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetProducts.api`, `OnWidgetComplete`, `SDKApi`]; }
1543
1562
  }
1544
1563
 
1545
1564
  class Quest {
1546
1565
  _elementNodeRef;
1547
1566
  _layer;
1548
1567
  _widgetApi;
1568
+ _onWidgetComplete;
1569
+ sdkApi;
1549
1570
  static _className = "narrative-element-quest";
1550
1571
  static className() {
1551
1572
  return Quest._className;
1552
1573
  }
1553
- constructor(_elementNodeRef, _layer, _widgetApi) {
1574
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1554
1575
  this._elementNodeRef = _elementNodeRef;
1555
1576
  this._layer = _layer;
1556
1577
  this._widgetApi = _widgetApi;
1578
+ this._onWidgetComplete = _onWidgetComplete;
1579
+ this.sdkApi = sdkApi;
1557
1580
  }
1558
1581
  static isTypeOf(element) {
1559
1582
  return element instanceof Quest;
1560
1583
  }
1561
1584
  mediaElementsLoadingPromises = [];
1562
1585
  init(localData) {
1563
- return this._widgetApi.init(this._elementNodeRef, localData);
1586
+ return this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1564
1587
  }
1565
1588
  onPause() { }
1566
1589
  onResume() { }
@@ -1570,6 +1593,7 @@ class Quest {
1570
1593
  onStop() {
1571
1594
  this._widgetApi.onStop(this._elementNodeRef);
1572
1595
  }
1596
+ onBeforeUnmount() { }
1573
1597
  handleClick() {
1574
1598
  return false;
1575
1599
  }
@@ -1579,22 +1603,26 @@ class Quest {
1579
1603
  get isLayerForcePaused() {
1580
1604
  return false;
1581
1605
  }
1582
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetQuest.api`]; }
1606
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetQuest.api`, `OnWidgetComplete`, `SDKApi`]; }
1583
1607
  }
1584
1608
 
1585
1609
  class Quiz {
1586
1610
  _elementNodeRef;
1587
1611
  _layer;
1588
1612
  _widgetApi;
1613
+ _onWidgetComplete;
1614
+ sdkApi;
1589
1615
  static _className = "narrative-element-quiz";
1590
1616
  static className() {
1591
1617
  return Quiz._className;
1592
1618
  }
1593
1619
  // widgetApi in ctor
1594
- constructor(_elementNodeRef, _layer, _widgetApi) {
1620
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1595
1621
  this._elementNodeRef = _elementNodeRef;
1596
1622
  this._layer = _layer;
1597
1623
  this._widgetApi = _widgetApi;
1624
+ this._onWidgetComplete = _onWidgetComplete;
1625
+ this.sdkApi = sdkApi;
1598
1626
  }
1599
1627
  static isTypeOf(element) {
1600
1628
  return element instanceof Quiz;
@@ -1602,7 +1630,7 @@ class Quiz {
1602
1630
  mediaElementsLoadingPromises = [];
1603
1631
  init(localData) {
1604
1632
  try {
1605
- this._widgetApi.init(this._elementNodeRef, localData);
1633
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1606
1634
  }
1607
1635
  catch (e) {
1608
1636
  console.error(e);
@@ -1617,6 +1645,7 @@ class Quiz {
1617
1645
  onStop() {
1618
1646
  this._widgetApi.onStop(this._elementNodeRef);
1619
1647
  }
1648
+ onBeforeUnmount() { }
1620
1649
  handleClick() {
1621
1650
  return false;
1622
1651
  }
@@ -1626,21 +1655,25 @@ class Quiz {
1626
1655
  get isLayerForcePaused() {
1627
1656
  return false;
1628
1657
  }
1629
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetQuiz.api`]; }
1658
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetQuiz.api`, `OnWidgetComplete`, `SDKApi`]; }
1630
1659
  }
1631
1660
 
1632
1661
  class QuizGrouped {
1633
1662
  _elementNodeRef;
1634
1663
  _layer;
1635
1664
  _widgetApi;
1665
+ _onWidgetComplete;
1666
+ sdkApi;
1636
1667
  static _className = "narrative-element-quiz-grouped";
1637
1668
  static className() {
1638
1669
  return QuizGrouped._className;
1639
1670
  }
1640
- constructor(_elementNodeRef, _layer, _widgetApi) {
1671
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1641
1672
  this._elementNodeRef = _elementNodeRef;
1642
1673
  this._layer = _layer;
1643
1674
  this._widgetApi = _widgetApi;
1675
+ this._onWidgetComplete = _onWidgetComplete;
1676
+ this.sdkApi = sdkApi;
1644
1677
  }
1645
1678
  static isTypeOf(element) {
1646
1679
  return element instanceof QuizGrouped;
@@ -1648,7 +1681,7 @@ class QuizGrouped {
1648
1681
  mediaElementsLoadingPromises = [];
1649
1682
  init(localData) {
1650
1683
  try {
1651
- this._widgetApi.init(this._elementNodeRef, localData);
1684
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1652
1685
  }
1653
1686
  catch (e) {
1654
1687
  console.error(e);
@@ -1663,6 +1696,7 @@ class QuizGrouped {
1663
1696
  onStop() {
1664
1697
  this._widgetApi.onStop(this._elementNodeRef);
1665
1698
  }
1699
+ onBeforeUnmount() { }
1666
1700
  handleClick() {
1667
1701
  return false;
1668
1702
  }
@@ -1672,21 +1706,25 @@ class QuizGrouped {
1672
1706
  get isLayerForcePaused() {
1673
1707
  return false;
1674
1708
  }
1675
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetQuizGrouped.api`]; }
1709
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetQuizGrouped.api`, `OnWidgetComplete`, `SDKApi`]; }
1676
1710
  }
1677
1711
 
1678
1712
  class RangeSlider {
1679
1713
  _elementNodeRef;
1680
1714
  _layer;
1681
1715
  _widgetApi;
1716
+ _onWidgetComplete;
1717
+ sdkApi;
1682
1718
  static _className = "narrative-element-range-slider";
1683
1719
  static className() {
1684
1720
  return RangeSlider._className;
1685
1721
  }
1686
- constructor(_elementNodeRef, _layer, _widgetApi) {
1722
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1687
1723
  this._elementNodeRef = _elementNodeRef;
1688
1724
  this._layer = _layer;
1689
1725
  this._widgetApi = _widgetApi;
1726
+ this._onWidgetComplete = _onWidgetComplete;
1727
+ this.sdkApi = sdkApi;
1690
1728
  }
1691
1729
  static isTypeOf(element) {
1692
1730
  return element instanceof RangeSlider;
@@ -1694,7 +1732,7 @@ class RangeSlider {
1694
1732
  mediaElementsLoadingPromises = [];
1695
1733
  init(localData) {
1696
1734
  try {
1697
- this._widgetApi.init(this._elementNodeRef, localData);
1735
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1698
1736
  }
1699
1737
  catch (e) {
1700
1738
  console.error(e);
@@ -1709,6 +1747,7 @@ class RangeSlider {
1709
1747
  onStop() {
1710
1748
  this._widgetApi.onStop(this._elementNodeRef);
1711
1749
  }
1750
+ onBeforeUnmount() { }
1712
1751
  get isClickCapturedBySlider() {
1713
1752
  return this._widgetApi.isClickCapturedBySlider(this._elementNodeRef);
1714
1753
  }
@@ -1718,21 +1757,25 @@ class RangeSlider {
1718
1757
  get isLayerForcePaused() {
1719
1758
  return false;
1720
1759
  }
1721
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetRangeSlider.api`]; }
1760
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetRangeSlider.api`, `OnWidgetComplete`, `SDKApi`]; }
1722
1761
  }
1723
1762
 
1724
1763
  class Rate {
1725
1764
  _elementNodeRef;
1726
1765
  _layer;
1727
1766
  _widgetApi;
1767
+ _onWidgetComplete;
1768
+ sdkApi;
1728
1769
  static _className = "narrative-element-rate";
1729
1770
  static className() {
1730
1771
  return Rate._className;
1731
1772
  }
1732
- constructor(_elementNodeRef, _layer, _widgetApi) {
1773
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1733
1774
  this._elementNodeRef = _elementNodeRef;
1734
1775
  this._layer = _layer;
1735
1776
  this._widgetApi = _widgetApi;
1777
+ this._onWidgetComplete = _onWidgetComplete;
1778
+ this.sdkApi = sdkApi;
1736
1779
  }
1737
1780
  static isTypeOf(element) {
1738
1781
  return element instanceof Rate;
@@ -1740,7 +1783,7 @@ class Rate {
1740
1783
  mediaElementsLoadingPromises = [];
1741
1784
  init(localData) {
1742
1785
  try {
1743
- this._widgetApi.init(this._elementNodeRef, localData);
1786
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1744
1787
  }
1745
1788
  catch (e) {
1746
1789
  console.error(e);
@@ -1755,6 +1798,7 @@ class Rate {
1755
1798
  onStop() {
1756
1799
  this._widgetApi.onStop(this._elementNodeRef);
1757
1800
  }
1801
+ onBeforeUnmount() { }
1758
1802
  handleClick() {
1759
1803
  return false;
1760
1804
  }
@@ -1764,7 +1808,7 @@ class Rate {
1764
1808
  get isLayerForcePaused() {
1765
1809
  return false;
1766
1810
  }
1767
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetRate.api`]; }
1811
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetRate.api`, `OnWidgetComplete`, `SDKApi`]; }
1768
1812
  }
1769
1813
 
1770
1814
  class Share {
@@ -1772,16 +1816,20 @@ class Share {
1772
1816
  _layer;
1773
1817
  _layersNodesRefs;
1774
1818
  _widgetApi;
1819
+ _onWidgetComplete;
1820
+ sdkApi;
1775
1821
  static _className = "narrative-element-share";
1776
1822
  static _widgetApiName = "_narrative_share";
1777
1823
  static className() {
1778
1824
  return Share._className;
1779
1825
  }
1780
- constructor(_elementNodeRef, _layer, _layersNodesRefs, _widgetApi) {
1826
+ constructor(_elementNodeRef, _layer, _layersNodesRefs, _widgetApi, _onWidgetComplete, sdkApi) {
1781
1827
  this._elementNodeRef = _elementNodeRef;
1782
1828
  this._layer = _layer;
1783
1829
  this._layersNodesRefs = _layersNodesRefs;
1784
1830
  this._widgetApi = _widgetApi;
1831
+ this._onWidgetComplete = _onWidgetComplete;
1832
+ this.sdkApi = sdkApi;
1785
1833
  }
1786
1834
  static isTypeOf(element) {
1787
1835
  return element instanceof Share;
@@ -1789,7 +1837,7 @@ class Share {
1789
1837
  mediaElementsLoadingPromises = [];
1790
1838
  init(localData) {
1791
1839
  try {
1792
- this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData);
1840
+ this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._onWidgetComplete, this.sdkApi);
1793
1841
  }
1794
1842
  catch (e) {
1795
1843
  console.error(e);
@@ -1804,6 +1852,7 @@ class Share {
1804
1852
  onStop() {
1805
1853
  this._widgetApi.onStop(this._elementNodeRef);
1806
1854
  }
1855
+ onBeforeUnmount() { }
1807
1856
  handleClick() {
1808
1857
  return false;
1809
1858
  }
@@ -1813,7 +1862,7 @@ class Share {
1813
1862
  get isLayerForcePaused() {
1814
1863
  return false;
1815
1864
  }
1816
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `Array`, `typeof WidgetShare.api`]; }
1865
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `Array`, `typeof WidgetShare.api`, `OnWidgetComplete`, `SDKApi`]; }
1817
1866
  }
1818
1867
 
1819
1868
  class SwipeUpItems {
@@ -1838,6 +1887,7 @@ class SwipeUpItems {
1838
1887
  onResume() { }
1839
1888
  onStart() { }
1840
1889
  onStop() { }
1890
+ onBeforeUnmount() { }
1841
1891
  handleClick() {
1842
1892
  return false;
1843
1893
  }
@@ -1854,14 +1904,18 @@ class Test {
1854
1904
  _elementNodeRef;
1855
1905
  _layer;
1856
1906
  _widgetApi;
1907
+ _onWidgetComplete;
1908
+ sdkApi;
1857
1909
  static _className = "narrative-element-test";
1858
1910
  static className() {
1859
1911
  return Test._className;
1860
1912
  }
1861
- constructor(_elementNodeRef, _layer, _widgetApi) {
1913
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1862
1914
  this._elementNodeRef = _elementNodeRef;
1863
1915
  this._layer = _layer;
1864
1916
  this._widgetApi = _widgetApi;
1917
+ this._onWidgetComplete = _onWidgetComplete;
1918
+ this.sdkApi = sdkApi;
1865
1919
  }
1866
1920
  static isTypeOf(element) {
1867
1921
  return element instanceof Test;
@@ -1869,7 +1923,7 @@ class Test {
1869
1923
  mediaElementsLoadingPromises = [];
1870
1924
  init(localData) {
1871
1925
  try {
1872
- this._widgetApi.init(this._elementNodeRef, localData);
1926
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1873
1927
  }
1874
1928
  catch (e) {
1875
1929
  console.error(e);
@@ -1884,6 +1938,7 @@ class Test {
1884
1938
  onStop() {
1885
1939
  this._widgetApi.onStop(this._elementNodeRef);
1886
1940
  }
1941
+ onBeforeUnmount() { }
1887
1942
  handleClick() {
1888
1943
  return false;
1889
1944
  }
@@ -1896,26 +1951,30 @@ class Test {
1896
1951
  get isLayerForcePaused() {
1897
1952
  return false;
1898
1953
  }
1899
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetTest.api`]; }
1954
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetTest.api`, `OnWidgetComplete`, `SDKApi`]; }
1900
1955
  }
1901
1956
 
1902
1957
  class Vote {
1903
1958
  _elementNodeRef;
1904
1959
  _layer;
1905
1960
  _widgetApi;
1961
+ _onWidgetComplete;
1962
+ sdkApi;
1906
1963
  static _className = "narrative-element-vote";
1907
1964
  static className() {
1908
1965
  return Vote._className;
1909
1966
  }
1910
- constructor(_elementNodeRef, _layer, _widgetApi) {
1967
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1911
1968
  this._elementNodeRef = _elementNodeRef;
1912
1969
  this._layer = _layer;
1913
1970
  this._widgetApi = _widgetApi;
1971
+ this._onWidgetComplete = _onWidgetComplete;
1972
+ this.sdkApi = sdkApi;
1914
1973
  }
1915
1974
  mediaElementsLoadingPromises = [];
1916
1975
  init(localData) {
1917
1976
  try {
1918
- this._widgetApi.init(this._elementNodeRef, localData);
1977
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1919
1978
  }
1920
1979
  catch (e) {
1921
1980
  console.error(e);
@@ -1930,13 +1989,14 @@ class Vote {
1930
1989
  onStop() {
1931
1990
  this._widgetApi.onStop(this._elementNodeRef);
1932
1991
  }
1992
+ onBeforeUnmount() { }
1933
1993
  handleClick() {
1934
1994
  return false;
1935
1995
  }
1936
1996
  get isLayerForcePaused() {
1937
1997
  return false;
1938
1998
  }
1939
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetVote.api`]; }
1999
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetVote.api`, `OnWidgetComplete`, `SDKApi`]; }
1940
2000
  }
1941
2001
 
1942
2002
  class Text {
@@ -1958,6 +2018,7 @@ class Text {
1958
2018
  onResume() { }
1959
2019
  onStart() { }
1960
2020
  onStop() { }
2021
+ onBeforeUnmount() { }
1961
2022
  handleClick() {
1962
2023
  return false;
1963
2024
  }
@@ -1970,19 +2031,34 @@ class Text {
1970
2031
  const waitForImageHtmlElementLoad = async (nodeRef) => {
1971
2032
  return new Promise((resolve, reject) => {
1972
2033
  const onLoad = function () {
1973
- requestAnimationFrame(() => requestAnimationFrame(() => {
1974
- resolve(nodeRef);
1975
- nodeRef.removeEventListener("load", onLoad);
1976
- }));
2034
+ nodeRef.decoding = "sync";
2035
+ if (nodeRef.decode != null) {
2036
+ nodeRef.decode().then(() => {
2037
+ // @ts-ignore
2038
+ // _log("img loaded 1", true);
2039
+ resolve(nodeRef);
2040
+ nodeRef.removeEventListener("load", onLoad);
2041
+ }, reason => reject(reason));
2042
+ }
2043
+ else {
2044
+ requestAnimationFrame(() => requestAnimationFrame(() => {
2045
+ // @ts-ignore
2046
+ // _log("img loaded 1", true);
2047
+ resolve(nodeRef);
2048
+ nodeRef.removeEventListener("load", onLoad);
2049
+ }));
2050
+ }
1977
2051
  };
1978
2052
  nodeRef.addEventListener("load", onLoad);
1979
- if (nodeRef.complete && 0 !== nodeRef.naturalHeight) {
1980
- requestAnimationFrame(() => {
1981
- requestAnimationFrame(() => {
1982
- resolve(nodeRef);
1983
- });
1984
- });
1985
- }
2053
+ // if (nodeRef.complete && 0 !== nodeRef.naturalHeight) {
2054
+ // requestAnimationFrame(() => {
2055
+ // requestAnimationFrame(() => {
2056
+ // // @ts-ignore
2057
+ // _log("img loaded 2", true)
2058
+ // resolve(nodeRef);
2059
+ // });
2060
+ // });
2061
+ // }
1986
2062
  nodeRef.addEventListener("error", err => reject(err));
1987
2063
  });
1988
2064
  };
@@ -1992,6 +2068,8 @@ const waitForVideoHtmlElementLoad = async (nodeRef) => {
1992
2068
  const onCanplaythrough = () => {
1993
2069
  requestAnimationFrame(() => {
1994
2070
  requestAnimationFrame(() => {
2071
+ // @ts-ignore
2072
+ // _log("video loaded 1", true)
1995
2073
  resolve(nodeRef);
1996
2074
  nodeRef.removeEventListener("canplaythrough", onCanplaythrough);
1997
2075
  });
@@ -2004,6 +2082,8 @@ const waitForVideoHtmlElementLoad = async (nodeRef) => {
2004
2082
  var onCanPlay = function () {
2005
2083
  requestAnimationFrame(() => {
2006
2084
  requestAnimationFrame(() => {
2085
+ // @ts-ignore
2086
+ // _log("video loaded 2", true)
2007
2087
  resolve(nodeRef);
2008
2088
  nodeRef.removeEventListener("canplay", onCanPlay);
2009
2089
  });
@@ -2045,6 +2125,7 @@ class Image extends ClickableBase {
2045
2125
  onResume() { }
2046
2126
  onStart() { }
2047
2127
  onStop() { }
2128
+ onBeforeUnmount() { }
2048
2129
  handleClick() {
2049
2130
  return false;
2050
2131
  }
@@ -2076,6 +2157,7 @@ class SwipeUp {
2076
2157
  onResume() { }
2077
2158
  onStart() { }
2078
2159
  onStop() { }
2160
+ onBeforeUnmount() { }
2079
2161
  handleClick() {
2080
2162
  return false;
2081
2163
  }
@@ -2167,6 +2249,12 @@ class Video {
2167
2249
  }
2168
2250
  onStart() { }
2169
2251
  onStop() { }
2252
+ onBeforeUnmount() {
2253
+ // clean up memory and cpu processes
2254
+ // @ts-ignore
2255
+ // _log("onBeforeUnmount", true)
2256
+ this._destroyVODPlayer();
2257
+ }
2170
2258
  _initVOD(vodData) {
2171
2259
  const onWaiting = () => {
2172
2260
  /**
@@ -2223,7 +2311,8 @@ class Video {
2223
2311
  console.error("Error code", error.code, "object", error);
2224
2312
  // _log(`video error: ${video.currentTime} code: ${error.code}`, true);
2225
2313
  if (this._video.paused) {
2226
- this._layer.stopInternal();
2314
+ this._layer.stopInternal({ prepareForRestart: 2 /* ON_SLIDE_STOP_PREPARE_FOR_RESTART.NOT_PREPARE */ });
2315
+ this._layer.onBeforeUnmount();
2227
2316
  this._layer.timeline.onSlideError(this._video.currentTime * 1000);
2228
2317
  }
2229
2318
  };
@@ -2238,6 +2327,8 @@ class Video {
2238
2327
  // console.log("_initVOD 5");
2239
2328
  this._vodPlayerInstance = player;
2240
2329
  // This runs if the asynchronous load is successful.
2330
+ // @ts-ignore
2331
+ _log("vod loaded 1", true);
2241
2332
  resolve(this._video);
2242
2333
  })
2243
2334
  .catch(reason => {
@@ -2262,6 +2353,8 @@ class Video {
2262
2353
  if (vodData && vodData.formats != null && Array.isArray(vodData.formats) && vodData.formats.length > 0) {
2263
2354
  src = vodData.formats[0].url;
2264
2355
  this._video.src = src;
2356
+ // @ts-ignore
2357
+ // _log("vod loaded 2", true)
2265
2358
  resolve(this._video);
2266
2359
  }
2267
2360
  else {
@@ -2283,6 +2376,25 @@ class Video {
2283
2376
  }
2284
2377
  return mpd_;
2285
2378
  }
2379
+ async _destroyVODPlayer() {
2380
+ //@ts-ignore
2381
+ // _log("call _destroyVODPlayer", true)
2382
+ if (this._vodPlayerInstance != null) {
2383
+ try {
2384
+ if (this._videoStateAdapter) {
2385
+ this._videoStateAdapter.destroy();
2386
+ this._videoStateAdapter = null;
2387
+ }
2388
+ await this._vodPlayerInstance.detach();
2389
+ await this._vodPlayerInstance.destroy();
2390
+ // clean up - so we can reinit on slide start, id need it
2391
+ this._vodPlayerInstance = null;
2392
+ }
2393
+ catch (e) {
2394
+ console.error(e);
2395
+ }
2396
+ }
2397
+ }
2286
2398
  handleClick() {
2287
2399
  return false;
2288
2400
  }
@@ -2293,7 +2405,7 @@ class Video {
2293
2405
  get videoStartedPromise() {
2294
2406
  return this._videoStartedPromise;
2295
2407
  }
2296
- start(muted = true) {
2408
+ start(muted = true, loop = true) {
2297
2409
  this._videoStartedPromise = new Promise(async (resolve) => {
2298
2410
  // invariant - always wait for mediaElementsLoadingPromises
2299
2411
  // else call of _initVOD can start and onAllMediaLoaded failed
@@ -2307,6 +2419,7 @@ class Video {
2307
2419
  // console.log("Video:start => this._video.pause()");
2308
2420
  this._video.pause();
2309
2421
  this._video.currentTime = 0;
2422
+ this._video.loop = loop;
2310
2423
  // remove init class
2311
2424
  // if vod - create VoD player
2312
2425
  if (this._video.getAttribute("data-default-muted") !== "1") {
@@ -2400,31 +2513,41 @@ class Video {
2400
2513
  });
2401
2514
  return this._videoStartedPromise;
2402
2515
  }
2403
- async stop() {
2516
+ async stop({ prepareForRestart }) {
2404
2517
  if (this._video) {
2405
- // console.log("Video:stop => this._video.pause()");
2518
+ // @ts-ignore
2519
+ // _log(`Video:stop => this._video.pause(), currentTime: ${this._video.currentTime}`, true);
2406
2520
  this._video.pause();
2407
2521
  }
2408
- if (this._vodPlayerInstance) {
2409
- setTimeout(async () => {
2410
- // destroy VOD on slideStop with timeout, bcz on Android flashes white screen on several frames (if destroy without timeout)
2411
- if (this._vodPlayerInstance) {
2412
- try {
2413
- // show poster
2414
- this._elementNodeRef.classList.add("init");
2415
- if (this._videoStateAdapter) {
2416
- this._videoStateAdapter.destroy();
2417
- this._videoStateAdapter = null;
2418
- }
2419
- await this._vodPlayerInstance.detach();
2420
- await this._vodPlayerInstance.destroy();
2421
- // clean up - so we can reinit on slide start, id need it
2422
- this._vodPlayerInstance = null;
2423
- }
2424
- catch (e) {
2425
- console.error(e);
2426
- }
2522
+ if (prepareForRestart !== 0 /* ON_SLIDE_STOP_PREPARE_FOR_RESTART.UNKNOWN */) {
2523
+ /**
2524
+ * In case prepareForReinit = false (stop event before unmounting - navigation to prev|next slide)
2525
+ * VOD will be destroyed in onBeforeUnmount
2526
+ *
2527
+ * In case prepareForReinit = true (stop event after navigation to prev|next story)
2528
+ * We need to go to frame 0 and show poster, and destroy VOD (clean up memory and cpu processes)
2529
+ */
2530
+ if (prepareForRestart === 1 /* ON_SLIDE_STOP_PREPARE_FOR_RESTART.PREPARE */) {
2531
+ this._elementNodeRef.classList.add("init");
2532
+ if (this._video && !this._vodPlayerInstance) {
2533
+ // only for not VOD video
2534
+ this._video.currentTime = 0;
2427
2535
  }
2536
+ this._destroyVODPlayer();
2537
+ }
2538
+ }
2539
+ else {
2540
+ /**
2541
+ * Old sdk behavior: on any stop event - destroy VOD and show poster (prepare for restart after returning to this story)
2542
+ * with 100 ms timeout (try to prevent frame blinking on slide switching)
2543
+ */
2544
+ setTimeout(() => {
2545
+ this._elementNodeRef.classList.add("init");
2546
+ if (this._video && !this._vodPlayerInstance) {
2547
+ // only for not VOD video
2548
+ this._video.currentTime = 0;
2549
+ }
2550
+ this._destroyVODPlayer();
2428
2551
  }, 100);
2429
2552
  }
2430
2553
  }
@@ -2558,7 +2681,7 @@ class VideoStateAdapter {
2558
2681
  // _log(`_onPlaying, _timeupdate: ${this._timeupdate}`, true);
2559
2682
  this._playingCheckerId = window.setTimeout(() => {
2560
2683
  // @ts-ignore
2561
- _log(`_onPlaying cb, _timeupdate: ${this._timeupdate}, now: ${Date.now()}, diff: ${Date.now() - this._timeupdate}`, true);
2684
+ // _log(`_onPlaying cb, _timeupdate: ${this._timeupdate}, now: ${Date.now()}, diff: ${Date.now() - this._timeupdate}`, true);
2562
2685
  if (Date.now() - this._timeupdate <= this._maxDiff / 2) {
2563
2686
  // @ts-ignore
2564
2687
  // _log(`_onPlaying if`, true);
@@ -2605,7 +2728,7 @@ class VideoStateAdapter {
2605
2728
  // const
2606
2729
  // }
2607
2730
  // args nodeRef, elementClassName
2608
- const tryCreateFromHtmlElement = (nodeRef, layer) => {
2731
+ const tryCreateFromHtmlElement = (nodeRef, layer, onWidgetComplete, sdkApi) => {
2609
2732
  const layoutApi = layer.layoutService.layoutApi;
2610
2733
  const layersNodesRefs = layer.slide.layersNodesRefs;
2611
2734
  for (let elementClassName of nodeRef.classList.values()) {
@@ -2623,38 +2746,42 @@ const tryCreateFromHtmlElement = (nodeRef, layer) => {
2623
2746
  case SwipeUpItems.className():
2624
2747
  return new SwipeUpItems(nodeRef, layer);
2625
2748
  case Video.className():
2626
- return new Video(nodeRef, layer, layoutApi.VideoPlayer, layer.layoutService.sdkApi);
2749
+ return new Video(nodeRef, layer, layoutApi.VideoPlayer, layer.sdkApi);
2627
2750
  //////// widgets ///////
2628
2751
  case Copy.className():
2629
- return layoutApi.widgetCopyApi ? new Copy(nodeRef, layer, layoutApi.widgetCopyApi) : null;
2752
+ return layoutApi.widgetCopyApi ? new Copy(nodeRef, layer, layoutApi.widgetCopyApi, onWidgetComplete, sdkApi) : null;
2630
2753
  case Barcode.className():
2631
- return layoutApi.widgetBarcodeApi ? new Barcode(nodeRef, layer, layoutApi.widgetBarcodeApi) : null;
2754
+ return layoutApi.widgetBarcodeApi ? new Barcode(nodeRef, layer, layoutApi.widgetBarcodeApi, onWidgetComplete, sdkApi) : null;
2632
2755
  case DataInput.className():
2633
- return layoutApi.widgetDataInputApi ? new DataInput(nodeRef, layer, layoutApi.widgetDataInputApi) : null;
2756
+ return layoutApi.widgetDataInputApi ? new DataInput(nodeRef, layer, layoutApi.widgetDataInputApi, onWidgetComplete, sdkApi) : null;
2634
2757
  case DateCountdown.className():
2635
- return layoutApi.widgetDateCountdownApi ? new DateCountdown(nodeRef, layer, layersNodesRefs, layoutApi.widgetDateCountdownApi) : null;
2758
+ return layoutApi.widgetDateCountdownApi
2759
+ ? new DateCountdown(nodeRef, layer, layersNodesRefs, layoutApi.widgetDateCountdownApi, onWidgetComplete, sdkApi)
2760
+ : null;
2636
2761
  case Poll.className():
2637
- return layoutApi.widgetPollApi ? new Poll(nodeRef, layer, layoutApi.widgetPollApi) : null;
2762
+ return layoutApi.widgetPollApi ? new Poll(nodeRef, layer, layoutApi.widgetPollApi, onWidgetComplete, sdkApi) : null;
2638
2763
  case PollLayers.className():
2639
- return layoutApi.widgetPollLayersApi ? new PollLayers(nodeRef, layer, layersNodesRefs, layoutApi.widgetPollLayersApi) : null;
2764
+ return layoutApi.widgetPollLayersApi
2765
+ ? new PollLayers(nodeRef, layer, layersNodesRefs, layoutApi.widgetPollLayersApi, onWidgetComplete, sdkApi)
2766
+ : null;
2640
2767
  case Quest.className():
2641
- return layoutApi.widgetQuestApi ? new Quest(nodeRef, layer, layoutApi.widgetQuestApi) : null;
2768
+ return layoutApi.widgetQuestApi ? new Quest(nodeRef, layer, layoutApi.widgetQuestApi, onWidgetComplete, sdkApi) : null;
2642
2769
  case Quiz.className():
2643
- return layoutApi.widgetQuizApi ? new Quiz(nodeRef, layer, layoutApi.widgetQuizApi) : null;
2770
+ return layoutApi.widgetQuizApi ? new Quiz(nodeRef, layer, layoutApi.widgetQuizApi, onWidgetComplete, sdkApi) : null;
2644
2771
  case QuizGrouped.className():
2645
- return layoutApi.widgetQuizGroupedApi ? new QuizGrouped(nodeRef, layer, layoutApi.widgetQuizGroupedApi) : null;
2772
+ return layoutApi.widgetQuizGroupedApi ? new QuizGrouped(nodeRef, layer, layoutApi.widgetQuizGroupedApi, onWidgetComplete, sdkApi) : null;
2646
2773
  case RangeSlider.className():
2647
- return layoutApi.widgetRangeSliderApi ? new RangeSlider(nodeRef, layer, layoutApi.widgetRangeSliderApi) : null;
2774
+ return layoutApi.widgetRangeSliderApi ? new RangeSlider(nodeRef, layer, layoutApi.widgetRangeSliderApi, onWidgetComplete, sdkApi) : null;
2648
2775
  case Rate.className():
2649
- return layoutApi.widgetRateApi ? new Rate(nodeRef, layer, layoutApi.widgetRateApi) : null;
2776
+ return layoutApi.widgetRateApi ? new Rate(nodeRef, layer, layoutApi.widgetRateApi, onWidgetComplete, sdkApi) : null;
2650
2777
  case Share.className():
2651
- return layoutApi.widgetShareApi ? new Share(nodeRef, layer, layersNodesRefs, layoutApi.widgetShareApi) : null;
2778
+ return layoutApi.widgetShareApi ? new Share(nodeRef, layer, layersNodesRefs, layoutApi.widgetShareApi, onWidgetComplete, sdkApi) : null;
2652
2779
  case Test.className():
2653
- return layoutApi.widgetTestApi ? new Test(nodeRef, layer, layoutApi.widgetTestApi) : null;
2780
+ return layoutApi.widgetTestApi ? new Test(nodeRef, layer, layoutApi.widgetTestApi, onWidgetComplete, sdkApi) : null;
2654
2781
  case Vote.className():
2655
- return layoutApi.widgetVoteApi ? new Vote(nodeRef, layer, layoutApi.widgetVoteApi) : null;
2782
+ return layoutApi.widgetVoteApi ? new Vote(nodeRef, layer, layoutApi.widgetVoteApi, onWidgetComplete, sdkApi) : null;
2656
2783
  case Products.className():
2657
- return layoutApi.widgetProductsApi ? new Products(nodeRef, layer, layoutApi.widgetProductsApi) : null;
2784
+ return layoutApi.widgetProductsApi ? new Products(nodeRef, layer, layoutApi.widgetProductsApi, onWidgetComplete, sdkApi) : null;
2658
2785
  }
2659
2786
  }
2660
2787
  return null;
@@ -2665,18 +2792,24 @@ var TimelineDisabledState;
2665
2792
  TimelineDisabledState[TimelineDisabledState["disabled"] = 0] = "disabled";
2666
2793
  TimelineDisabledState[TimelineDisabledState["enabled"] = 1] = "enabled";
2667
2794
  })(TimelineDisabledState || (TimelineDisabledState = {}));
2795
+ // use Promise
2796
+ // await Promise()
2797
+ // call timeLine api
2798
+ // promise - slideReadyPromise
2668
2799
  class SlideTimeline {
2669
2800
  slideIndex;
2670
2801
  slideDuration;
2671
2802
  slideDisabledTimer;
2672
2803
  slideReady;
2673
2804
  _afterResumeQueuePush;
2674
- constructor(slideIndex, slideDuration, slideDisabledTimer, slideReady, _afterResumeQueuePush) {
2805
+ sdkApi;
2806
+ constructor(slideIndex, slideDuration, slideDisabledTimer, slideReady, _afterResumeQueuePush, sdkApi) {
2675
2807
  this.slideIndex = slideIndex;
2676
2808
  this.slideDuration = slideDuration;
2677
2809
  this.slideDisabledTimer = slideDisabledTimer;
2678
2810
  this.slideReady = slideReady;
2679
2811
  this._afterResumeQueuePush = _afterResumeQueuePush;
2812
+ this.sdkApi = sdkApi;
2680
2813
  this.timelineDisabledState = this.slideDisabledTimer ? TimelineDisabledState.disabled : TimelineDisabledState.enabled;
2681
2814
  }
2682
2815
  resumedAt = new Date().getTime();
@@ -2690,20 +2823,29 @@ class SlideTimeline {
2690
2823
  return SlideTimeline.layoutService;
2691
2824
  }
2692
2825
  get isSDKSupportUpdateTimeline() {
2693
- if (SlideTimeline.layoutService.sdkApi.isAndroid) {
2694
- return SlideTimeline.layoutService.env.Android && "updateTimeline" in SlideTimeline.layoutService.env.Android;
2826
+ if (this.sdkApi.isAndroid) {
2827
+ return Boolean(SlideTimeline.layoutService.env.Android && "updateTimeline" in SlideTimeline.layoutService.env.Android);
2695
2828
  }
2696
- else if (SlideTimeline.layoutService.sdkApi.isIOS) {
2829
+ else if (this.sdkApi.isIOS) {
2697
2830
  const mh = SlideTimeline.layoutService.env?.webkit?.messageHandlers ?? {};
2698
2831
  return "updateTimeline" in mh;
2699
2832
  }
2833
+ else if (this.sdkApi.isWeb) {
2834
+ return true;
2835
+ }
2700
2836
  else {
2701
2837
  return false;
2702
2838
  }
2703
2839
  }
2840
+ get isSdkSupportTimelineOnBeforeStart() {
2841
+ return this.sdkApi.isSdkSupportTimelineOnBeforeStart();
2842
+ }
2704
2843
  get index() {
2705
2844
  return this.slideIndex;
2706
2845
  }
2846
+ get isTimelineDisabled() {
2847
+ return this.timelineDisabledState === TimelineDisabledState.disabled;
2848
+ }
2707
2849
  async updateTimeline(action, showLoader = false, showError = false) {
2708
2850
  // два кейса
2709
2851
  // когда есть слои и у слоя вызываем showLayer который вызывает startTimer до старта слайда, потом start от sdk
@@ -2735,7 +2877,24 @@ class SlideTimeline {
2735
2877
  //@ts-ignore
2736
2878
  // window._log(`updateTimeline, a: ${action} ct: ${currentTime} d: ${duration} tds: ${this.timelineDisabledState}`, true);
2737
2879
  // console.trace(`updateTimeline ${action} slideIndex: ${this.slideIndex} currentTime:${currentTime} duration:${duration} tds: ${this.timelineDisabledState}`);
2738
- SlideTimeline.layoutService.sdkApi.updateTimeline(this.slideIndex, action, currentTime, duration, showLoader, showError);
2880
+ this.sdkApi.updateTimeline(this.slideIndex, action, currentTime, duration, showLoader, showError);
2881
+ }
2882
+ /**
2883
+ * trigger timeline update for new slide in sdk, before slide strat event (prevent timeout in timeline while we wait for video start)
2884
+ */
2885
+ triggerSlideLoadState() {
2886
+ if (this.isSDKSupportUpdateTimeline && this.isSdkSupportTimelineOnBeforeStart) {
2887
+ let duration = this.slideDuration;
2888
+ // tmp
2889
+ // todo брать из модели
2890
+ if (!duration) {
2891
+ duration = DEFAULT_SLIDE_DURATION;
2892
+ }
2893
+ if (this.timelineDisabledState === TimelineDisabledState.disabled) {
2894
+ duration = 0;
2895
+ }
2896
+ this.sdkApi.updateTimeline(this.slideIndex, "before_start" /* TIMELINE_ACTION.BEFORE_START */, 0, duration, false, false);
2897
+ }
2739
2898
  }
2740
2899
  /**
2741
2900
  * Start timeline after slide started
@@ -2774,7 +2933,7 @@ class SlideTimeline {
2774
2933
  this.updateTimeline("pause" /* TIMELINE_ACTION.PAUSE */);
2775
2934
  }
2776
2935
  else {
2777
- this.layoutService.sdkApi.cardPausedCallback(videoCurrentTime);
2936
+ this.sdkApi.cardPausedCallback(videoCurrentTime);
2778
2937
  }
2779
2938
  }
2780
2939
  slideResumed(videoCurrentTime) {
@@ -2789,7 +2948,7 @@ class SlideTimeline {
2789
2948
  this.updateTimeline("start" /* TIMELINE_ACTION.START */);
2790
2949
  }
2791
2950
  else {
2792
- this.layoutService.sdkApi.cardResumedCallback(videoCurrentTime);
2951
+ this.sdkApi.cardResumedCallback(videoCurrentTime);
2793
2952
  }
2794
2953
  }
2795
2954
  slideStopped() {
@@ -2846,7 +3005,7 @@ class SlideTimeline {
2846
3005
  }
2847
3006
  this.updateTimeline("stop" /* TIMELINE_ACTION.STOP */, false, true);
2848
3007
  }
2849
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`number`, `number`, `boolean`, `Promise`, `(cb: () => void) => void`]; }
3008
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`number`, `number`, `boolean`, `Promise`, `(cb: () => void) => void`, `SDKApi`]; }
2850
3009
  }
2851
3010
 
2852
3011
  class Layer {
@@ -2854,6 +3013,9 @@ class Layer {
2854
3013
  _slide;
2855
3014
  _slideReadyPromise;
2856
3015
  _afterResumeQueuePush;
3016
+ _afterStartInitQueuePush;
3017
+ _showNextSlide;
3018
+ sdkApi;
2857
3019
  _slideIndex;
2858
3020
  _cardId;
2859
3021
  _cardType;
@@ -2863,11 +3025,14 @@ class Layer {
2863
3025
  _disabledNavigation;
2864
3026
  _elements = [];
2865
3027
  _timeline;
2866
- constructor(_nodeRef, _slide, _slideReadyPromise, _afterResumeQueuePush) {
3028
+ constructor(_nodeRef, _slide, _slideReadyPromise, _afterResumeQueuePush, _afterStartInitQueuePush, _showNextSlide, sdkApi) {
2867
3029
  this._nodeRef = _nodeRef;
2868
3030
  this._slide = _slide;
2869
3031
  this._slideReadyPromise = _slideReadyPromise;
2870
3032
  this._afterResumeQueuePush = _afterResumeQueuePush;
3033
+ this._afterStartInitQueuePush = _afterStartInitQueuePush;
3034
+ this._showNextSlide = _showNextSlide;
3035
+ this.sdkApi = sdkApi;
2871
3036
  this._slideIndex = parseInt(this._nodeRef.getAttribute("data-index") ?? "0");
2872
3037
  this._cardId = parseInt(this._nodeRef.getAttribute("data-id") ?? "0");
2873
3038
  this._cardType = parseInt(this._nodeRef.getAttribute("data-card-type") ?? "1") || 1 /* CARD_TYPE.STORY */;
@@ -2875,11 +3040,19 @@ class Layer {
2875
3040
  this._duration = parseInt(this._nodeRef.getAttribute("data-duration") ?? "") || DEFAULT_SLIDE_DURATION;
2876
3041
  this._disabledTimer = this._nodeRef.getAttribute("data-disable-timer") === "1";
2877
3042
  this._disabledNavigation = this._nodeRef.getAttribute("data-disable-navigation") === "1";
2878
- this._timeline = new SlideTimeline(this._slideIndex, this._duration, this._disabledTimer, this._slideReadyPromise, this._afterResumeQueuePush);
3043
+ this._timeline = new SlideTimeline(this._slideIndex, this._duration, this._disabledTimer, this._slideReadyPromise, this._afterResumeQueuePush, this.sdkApi);
3044
+ const onWidgetComplete = (cardId, slideIndex) => {
3045
+ // todo if nothing more widgets with disabled timers - we can start layer timeline
3046
+ const fallback = () => this._showNextSlide(DEFAULT_SLIDE_DURATION);
3047
+ // для android sdk важно чтобы этот метод вызывался только после slide_start
3048
+ this._afterStartInitQueuePush(() => {
3049
+ this._timeline.startDisabledTimeline(fallback);
3050
+ });
3051
+ };
2879
3052
  const _elementsNodes = this._nodeRef.querySelectorAll(".narrative-slide-elements .narrative-element");
2880
3053
  let layerWithWidgetQuest = false;
2881
3054
  _elementsNodes.forEach(item => {
2882
- let element = tryCreateFromHtmlElement(item, this);
3055
+ let element = tryCreateFromHtmlElement(item, this, onWidgetComplete, this.sdkApi);
2883
3056
  if (element) {
2884
3057
  this._elements.push(element);
2885
3058
  if (element instanceof Quest) {
@@ -2894,7 +3067,7 @@ class Layer {
2894
3067
  * - then init WidgetQuest with layer instead of WidgetQuest element (required for WidgetQuest slides navigation)
2895
3068
  */
2896
3069
  if (this.isQuest && !layerWithWidgetQuest && this.layoutService.layoutApi.widgetQuestApi != null) {
2897
- this._elements.push(new Quest(this._nodeRef, this, this.layoutService.layoutApi.widgetQuestApi));
3070
+ this._elements.push(new Quest(this._nodeRef, this, this.layoutService.layoutApi.widgetQuestApi, onWidgetComplete, this.sdkApi));
2898
3071
  }
2899
3072
  }
2900
3073
  init(localData) {
@@ -2923,11 +3096,8 @@ class Layer {
2923
3096
  get layoutService() {
2924
3097
  return container.get({ identifier: "LayoutService" });
2925
3098
  }
2926
- get sdkApi() {
2927
- return container.get({ identifier: "SDKApi" });
2928
- }
2929
3099
  getLocalData() {
2930
- return this.layoutService.sdkApi.getCardLocalData();
3100
+ return this.sdkApi.getCardLocalData();
2931
3101
  }
2932
3102
  get isQuest() {
2933
3103
  return this._nodeRef.getAttribute("data-quest-count") != null;
@@ -3080,7 +3250,11 @@ class Layer {
3080
3250
  const videoElement = this.videoElement;
3081
3251
  let currentTime = 0;
3082
3252
  if (videoElement != null) {
3083
- currentTime = (await videoElement.start(muted)).currentTime;
3253
+ let videoLoop = false;
3254
+ if (this.timeline.isTimelineDisabled) {
3255
+ videoLoop = true;
3256
+ }
3257
+ currentTime = (await videoElement.start(muted, videoLoop)).currentTime;
3084
3258
  }
3085
3259
  if (this.sdkApi.cardAnimation) {
3086
3260
  this._animationPauseCb = this.sdkApi.cardAnimation.start(this._nodeRef);
@@ -3097,8 +3271,8 @@ class Layer {
3097
3271
  }
3098
3272
  return { currentTime };
3099
3273
  }
3100
- async stop() {
3101
- this.videoElement?.stop();
3274
+ async stop(options) {
3275
+ this.videoElement?.stop(options);
3102
3276
  this.sdkApi.cardAnimation?.stop(this._nodeRef);
3103
3277
  for (const element of this._elements) {
3104
3278
  element.onPause();
@@ -3108,8 +3282,8 @@ class Layer {
3108
3282
  }
3109
3283
  this._timeline.slideStopped();
3110
3284
  }
3111
- stopInternal() {
3112
- this.videoElement?.stop();
3285
+ stopInternal(options) {
3286
+ this.videoElement?.stop(options);
3113
3287
  this.sdkApi.cardAnimation?.stop(this._nodeRef);
3114
3288
  for (const element of this._elements) {
3115
3289
  element.onPause();
@@ -3179,10 +3353,15 @@ class Layer {
3179
3353
  disableAudio() {
3180
3354
  this.videoElement?.disableAudio();
3181
3355
  }
3356
+ onBeforeUnmount() {
3357
+ for (const element of this._elements) {
3358
+ element.onBeforeUnmount();
3359
+ }
3360
+ }
3182
3361
  get isLayerForcePaused() {
3183
3362
  return this.elements.some(element => element.isLayerForcePaused);
3184
3363
  }
3185
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Slide`, `Promise`, `(cb: () => void) => void`]; }
3364
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Slide`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `(duration: number) => void`, `SDKApi`]; }
3186
3365
  }
3187
3366
  const TextFit = (function () {
3188
3367
  const defaultSettings = {
@@ -3356,17 +3535,23 @@ class Slide {
3356
3535
  _slidesNodesRefs;
3357
3536
  _slideReadyPromise;
3358
3537
  _afterResumeQueuePush;
3538
+ _afterStartInitQueuePush;
3539
+ _showNextSlide;
3540
+ sdkApi;
3359
3541
  _layers;
3360
3542
  _start;
3361
- constructor(_slidesNodesRefs, _slideReadyPromise, _afterResumeQueuePush) {
3543
+ constructor(_slidesNodesRefs, _slideReadyPromise, _afterResumeQueuePush, _afterStartInitQueuePush, _showNextSlide, sdkApi) {
3362
3544
  this._slidesNodesRefs = _slidesNodesRefs;
3363
3545
  this._slideReadyPromise = _slideReadyPromise;
3364
3546
  this._afterResumeQueuePush = _afterResumeQueuePush;
3547
+ this._afterStartInitQueuePush = _afterStartInitQueuePush;
3548
+ this._showNextSlide = _showNextSlide;
3549
+ this.sdkApi = sdkApi;
3365
3550
  this._start = window.performance.now();
3366
3551
  if (!this._slidesNodesRefs.length) {
3367
3552
  throw new Error("No slides found.");
3368
3553
  }
3369
- this._layers = this._slidesNodesRefs.map(item => new Layer(item, this, this._slideReadyPromise, this._afterResumeQueuePush));
3554
+ this._layers = this._slidesNodesRefs.map(item => new Layer(item, this, this._slideReadyPromise, this._afterResumeQueuePush, this._afterStartInitQueuePush, this._showNextSlide, this.sdkApi));
3370
3555
  this._activeLayer = this._layers[0];
3371
3556
  }
3372
3557
  _activeLayer;
@@ -3385,7 +3570,7 @@ class Slide {
3385
3570
  const multiSlideApi = this.layoutService.layoutApi.widgetMultiSlideApi;
3386
3571
  if (multiSlideApi != null && this.layers.length > 1) {
3387
3572
  try {
3388
- multiSlideApi.init(this.layersNodesRefs, localData);
3573
+ multiSlideApi.init(this.layersNodesRefs, localData, this.sdkApi);
3389
3574
  }
3390
3575
  catch (e) {
3391
3576
  console.error(e);
@@ -3422,7 +3607,7 @@ class Slide {
3422
3607
  // const isHidden = layer.nodeRef.classList.contains("hidden");
3423
3608
  if (index !== showIndex) {
3424
3609
  layer.nodeRef.classList.add("hidden");
3425
- layer.stop();
3610
+ layer.stop({ prepareForRestart: 1 /* ON_SLIDE_STOP_PREPARE_FOR_RESTART.PREPARE */ });
3426
3611
  }
3427
3612
  });
3428
3613
  this.layers.forEach((layer, index) => {
@@ -3434,6 +3619,11 @@ class Slide {
3434
3619
  }
3435
3620
  });
3436
3621
  }
3622
+ onBeforeUnmount() {
3623
+ for (const layer of this._layers) {
3624
+ layer.onBeforeUnmount();
3625
+ }
3626
+ }
3437
3627
  get layoutService() {
3438
3628
  return container.get({ identifier: "LayoutService" });
3439
3629
  }
@@ -3452,15 +3642,9 @@ class Slide {
3452
3642
  get disabledNavigation() {
3453
3643
  return this._activeLayer.disabledNavigation;
3454
3644
  }
3455
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`Array`, `Promise`, `(cb: () => void) => void`]; }
3645
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`Array`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `(duration: number) => void`, `SDKApi`]; }
3456
3646
  }
3457
3647
 
3458
- function getViewportWidth(viewport) {
3459
- return viewport.innerWidth || viewport.document.documentElement.clientWidth || viewport.document.body.clientWidth;
3460
- }
3461
- function getViewportHeight(viewport) {
3462
- return viewport.innerHeight || viewport.document.documentElement.clientHeight || viewport.document.body.clientHeight;
3463
- }
3464
3648
  let SlideApi$1 = class SlideApi {
3465
3649
  config;
3466
3650
  get layoutDirection() {
@@ -3471,10 +3655,16 @@ let SlideApi$1 = class SlideApi {
3471
3655
  static prerenderBoxClassName = "narrative-slide-box-prerender";
3472
3656
  _slideWrapper;
3473
3657
  _viewport;
3658
+ _getViewportWidth;
3659
+ _getViewportHeight;
3660
+ sdkApi;
3474
3661
  constructor(config) {
3475
3662
  this.config = config;
3663
+ this.sdkApi = config.sdkApi;
3476
3664
  this._slideWrapper = config.slideWrapper;
3477
3665
  this._viewport = config.viewport;
3666
+ this._getViewportWidth = config.getViewportWidth;
3667
+ this._getViewportHeight = config.getViewportHeight;
3478
3668
  this.refreshSizes = proxy(this.refreshSizes, this);
3479
3669
  this.initListeners();
3480
3670
  this.refreshSizes();
@@ -3483,7 +3673,7 @@ let SlideApi$1 = class SlideApi {
3483
3673
  if (slideBox && slideBox.innerText.trim() !== "{%content}".replace("{", "{{").replace("}", "}}")) {
3484
3674
  this._slideInInit = null;
3485
3675
  this._slideInRender = true;
3486
- this._init(() => this._slideBoxRenderComplete(), () => this._slideBoxRenderError()).then(({ slide, result, reason }) => {
3676
+ this._init(() => this._slideBoxRenderComplete(null), () => this._slideBoxRenderError(null)).then(({ slide, result, reason }) => {
3487
3677
  this._slide = slide;
3488
3678
  if (config.slideLoadedCb != null) {
3489
3679
  config.slideLoadedCb({ slide, result, reason });
@@ -3492,6 +3682,9 @@ let SlideApi$1 = class SlideApi {
3492
3682
  }
3493
3683
  }
3494
3684
  destroy() {
3685
+ if (this.slide != null) {
3686
+ this.slide.onBeforeUnmount();
3687
+ }
3495
3688
  this.destroyListeners();
3496
3689
  }
3497
3690
  initListeners() {
@@ -3501,8 +3694,8 @@ let SlideApi$1 = class SlideApi {
3501
3694
  this._viewport.removeEventListener("resize", this.refreshSizes);
3502
3695
  }
3503
3696
  refreshSizes() {
3504
- const viewportWidth = getViewportWidth(this._viewport);
3505
- const viewportHeight = getViewportHeight(this._viewport);
3697
+ const viewportWidth = this._getViewportWidth();
3698
+ const viewportHeight = this._getViewportHeight();
3506
3699
  const viewportRatio = viewportWidth / viewportHeight;
3507
3700
  let slideWidth = 0;
3508
3701
  let slideHeight = 0;
@@ -3577,12 +3770,13 @@ let SlideApi$1 = class SlideApi {
3577
3770
  if (slideBox && slideBoxPrerender) {
3578
3771
  if (this._slideInRender) {
3579
3772
  this._slideInRender = false;
3580
- this._slideBoxRenderComplete();
3773
+ this._slideBoxRenderComplete(null);
3581
3774
  }
3582
3775
  this._slideInInit = null;
3583
3776
  this._slideInRender = true;
3584
3777
  slideBoxPrerender.innerHTML = html;
3585
- const { slide, result, reason } = await this._init(() => this._slideBoxRenderComplete(), () => this._slideBoxRenderError());
3778
+ const prevSlide = this.slide ? Object.assign(Object.create(Object.getPrototypeOf(this.slide)), this.slide) : null;
3779
+ const { slide, result, reason } = await this._init(() => this._slideBoxRenderComplete(prevSlide), () => this._slideBoxRenderError(prevSlide));
3586
3780
  this._slide = slide;
3587
3781
  _result.result = result;
3588
3782
  _result.reason = reason;
@@ -3597,10 +3791,7 @@ let SlideApi$1 = class SlideApi {
3597
3791
  return container.get({ identifier: "LayoutService" });
3598
3792
  }
3599
3793
  getLocalData() {
3600
- return this.layoutService.sdkApi.getCardLocalData();
3601
- }
3602
- get sdkApi() {
3603
- return container.get({ identifier: "SDKApi" });
3794
+ return this.sdkApi.getCardLocalData();
3604
3795
  }
3605
3796
  _fontsInit = false;
3606
3797
  _initAndLoadFonts(fonts) {
@@ -3655,6 +3846,7 @@ let SlideApi$1 = class SlideApi {
3655
3846
  async _onAllMediaLoaded(slide) {
3656
3847
  return new Promise((resolve, reject) => {
3657
3848
  const promises = slide.layers.flatMap(layer => layer.elements.flatMap(element => element.mediaElementsLoadingPromises));
3849
+ console.log({ promises });
3658
3850
  let checkerTimerId = undefined;
3659
3851
  let timeOutFired = false;
3660
3852
  if (promises.length > 0) {
@@ -3696,15 +3888,16 @@ let SlideApi$1 = class SlideApi {
3696
3888
  slideReadyResolve = resolve;
3697
3889
  slideReadyReject = reject;
3698
3890
  });
3699
- const slide = new Slide(slidesNodesRefs, slideReadyPromise, this.afterResumeQueuePush.bind(this));
3891
+ const slide = new Slide(slidesNodesRefs, slideReadyPromise, this.afterResumeQueuePush.bind(this), this.afterStartInitQueuePush.bind(this), this.sdkApi.showNextSlide.bind(this), this.sdkApi);
3700
3892
  this._slideInInit = slide;
3893
+ slide.activeLayer.timeline.triggerSlideLoadState();
3701
3894
  const onAllMediaLoaded = this._onAllMediaLoaded(slide);
3702
3895
  if (this.sdkApi.isAndroid) {
3703
3896
  this._afterStartInitQueue = [];
3704
3897
  }
3705
3898
  this._afterResumeQueue = [];
3706
3899
  const result = { slide, result: false, reason: "" };
3707
- await this._initAndLoadFonts(this.layoutService.sdkApi.getCardFonts());
3900
+ await this._initAndLoadFonts(this.sdkApi.getCardFonts());
3708
3901
  const localData = await this.getLocalData();
3709
3902
  const finishRender = await slide.init(localData);
3710
3903
  /**
@@ -3741,7 +3934,7 @@ let SlideApi$1 = class SlideApi {
3741
3934
  return result;
3742
3935
  }
3743
3936
  _slideInRender = false;
3744
- _slideBoxRenderComplete() {
3937
+ _slideBoxRenderComplete(prevSlide) {
3745
3938
  if (!this._slideInRender) {
3746
3939
  this._slideInRender = true;
3747
3940
  return;
@@ -3752,12 +3945,20 @@ let SlideApi$1 = class SlideApi {
3752
3945
  slideBoxPrerender.classList.remove(SlideApi.prerenderBoxClassName);
3753
3946
  slideBox.classList.remove(SlideApi.renderedBoxClassName);
3754
3947
  slideBox.classList.add(SlideApi.prerenderBoxClassName);
3755
- slideBox.innerHTML = "";
3948
+ // 2 RAF - wait for browser render complete (CSS changes, etc.)
3949
+ this.layoutService.env.requestAnimationFrame(() => {
3950
+ this.layoutService.env.requestAnimationFrame(() => {
3951
+ prevSlide?.onBeforeUnmount();
3952
+ // @ts-ignore
3953
+ // _log("clear innerHTML", true);
3954
+ slideBox.innerHTML = "";
3955
+ });
3956
+ });
3756
3957
  slideBoxPrerender.classList.add(SlideApi.renderedBoxClassName);
3757
3958
  }
3758
3959
  this._slideInRender = false;
3759
3960
  }
3760
- _slideBoxRenderError() {
3961
+ _slideBoxRenderError(prevSlide) {
3761
3962
  // if (!slideInRender) {
3762
3963
  // slideInRender = true;
3763
3964
  // return;
@@ -3775,23 +3976,12 @@ let SlideApi$1 = class SlideApi {
3775
3976
  slideBoxPrerender.classList.remove(SlideApi.prerenderBoxClassName);
3776
3977
  slideBox.classList.remove(SlideApi.renderedBoxClassName);
3777
3978
  slideBox.classList.add(SlideApi.prerenderBoxClassName);
3979
+ prevSlide?.onBeforeUnmount();
3778
3980
  slideBox.innerHTML = "";
3779
3981
  slideBoxPrerender.classList.add(SlideApi.renderedBoxClassName);
3780
3982
  }
3781
3983
  // slideInRender = false;
3782
3984
  }
3783
- async _startVideo(cb) {
3784
- const videoElement = this.slide?.activeLayer?.videoElement;
3785
- const videoStartedPromise = videoElement?.start(this._slideConfig.muted);
3786
- if (videoStartedPromise) {
3787
- videoStartedPromise.then(({ currentTime }) => {
3788
- cb({ currentTime, slideIndex: this.slide?.slideIndex || 0 });
3789
- });
3790
- }
3791
- else {
3792
- cb({ currentTime: 0, slideIndex: this.slide?.slideIndex || 0 });
3793
- }
3794
- }
3795
3985
  _slideConfig = {};
3796
3986
  async slideStart(config) {
3797
3987
  // console.log(`slideStart slideIdx: ${this.activeLayer.slideIndex} state: ${this._state}`);
@@ -3881,7 +4071,7 @@ let SlideApi$1 = class SlideApi {
3881
4071
  this.slide.activeLayer.resume();
3882
4072
  this._state = 5 /* STATE.RESUMED */;
3883
4073
  }
3884
- async slideStop() {
4074
+ async slideStop(options) {
3885
4075
  if (!(this._state === 3 /* STATE.STARTED */ || this._state === 5 /* STATE.RESUMED */ || this._state === 7 /* STATE.PAUSED */)) {
3886
4076
  return;
3887
4077
  }
@@ -3890,7 +4080,7 @@ let SlideApi$1 = class SlideApi {
3890
4080
  // отменяем pause если есть (баг андроида - шлет pause/resume на простой клик)
3891
4081
  clearTimeout(this._pauseCbTimer);
3892
4082
  }
3893
- await this.slide.activeLayer.stop();
4083
+ await this.slide.activeLayer.stop(options);
3894
4084
  this._state = 10 /* STATE.STOPPED */;
3895
4085
  }
3896
4086
  slideTimerEnd() {
@@ -3996,7 +4186,7 @@ let SlideApi$1 = class SlideApi {
3996
4186
  element = target?.closest(".narrative-element-link");
3997
4187
  }
3998
4188
  if (element) {
3999
- const { handled } = this._performLinkTarget(element);
4189
+ const { handled } = this._handleLinkAndSwipeUpActivation(element);
4000
4190
  result.canClickNext = !handled;
4001
4191
  return result;
4002
4192
  }
@@ -4009,7 +4199,7 @@ let SlideApi$1 = class SlideApi {
4009
4199
  element = target?.closest(".narrative-element-image");
4010
4200
  }
4011
4201
  if (element) {
4012
- const { handled } = this._performLinkTarget(element);
4202
+ const { handled } = this._handleLinkAndSwipeUpActivation(element);
4013
4203
  result.canClickNext = !handled;
4014
4204
  return result;
4015
4205
  }
@@ -4021,7 +4211,8 @@ let SlideApi$1 = class SlideApi {
4021
4211
  element = target?.closest(".narrative-element-swipe-up");
4022
4212
  }
4023
4213
  if (element) {
4024
- if (this.slideSwipeUpHandler(element)) {
4214
+ const { handled } = this._handleLinkAndSwipeUpActivation(element);
4215
+ if (handled) {
4025
4216
  result.canClickNext = false;
4026
4217
  return result;
4027
4218
  }
@@ -4034,7 +4225,8 @@ let SlideApi$1 = class SlideApi {
4034
4225
  element = target?.closest(".narrative-element-swipe-up-items");
4035
4226
  }
4036
4227
  if (element) {
4037
- if (this.slideSwipeUpHandler(element)) {
4228
+ const { handled } = this._handleLinkAndSwipeUpActivation(element);
4229
+ if (handled) {
4038
4230
  result.canClickNext = false;
4039
4231
  return result;
4040
4232
  }
@@ -4047,7 +4239,8 @@ let SlideApi$1 = class SlideApi {
4047
4239
  element = target?.closest(".narrative-element-products");
4048
4240
  }
4049
4241
  if (element) {
4050
- if (this.slideSwipeUpHandler(element)) {
4242
+ const { handled } = this._handleLinkAndSwipeUpActivation(element);
4243
+ if (handled) {
4051
4244
  result.canClickNext = false;
4052
4245
  return result;
4053
4246
  }
@@ -4310,14 +4503,21 @@ let SlideApi$1 = class SlideApi {
4310
4503
  }
4311
4504
  /** can tap to next slide */
4312
4505
  if (this.activeLayer.quizElement) {
4313
- result.canClickNext = this.activeLayer.quizElement.slideQuizIsDone;
4506
+ if (!this.activeLayer.quizElement.slideQuizIsDone && navigationDirection === "forward") {
4507
+ result.canClickNext = false;
4508
+ }
4314
4509
  }
4315
4510
  if (this.activeLayer.quizGroupedElement) {
4316
- result.canClickNext = this.activeLayer.quizGroupedElement.slideQuizGroupedIsDone;
4511
+ if (!this.activeLayer.quizGroupedElement.slideQuizGroupedIsDone && navigationDirection === "forward") {
4512
+ result.canClickNext = false;
4513
+ }
4317
4514
  }
4318
4515
  if (this.activeLayer.testElement) {
4319
- result.canClickNext = this.activeLayer.testElement.slideTestIsDone;
4320
- if (this.activeLayer.testElement.slideTestWithTimer && !result.canClickNext) {
4516
+ const isDone = this.activeLayer.testElement.slideTestIsDone;
4517
+ if (!isDone && navigationDirection === "forward") {
4518
+ result.canClickNext = false;
4519
+ }
4520
+ if (this.activeLayer.testElement.slideTestWithTimer && !isDone) {
4321
4521
  result.canClickNext = false;
4322
4522
  return result; // disable all clicks
4323
4523
  }
@@ -4353,13 +4553,18 @@ let SlideApi$1 = class SlideApi {
4353
4553
  // _clickNext(canClickNext, xPercent);
4354
4554
  return result;
4355
4555
  }
4356
- _performLinkSpecialAndReturnTarget(element) {
4556
+ /**
4557
+ * Handle click or swipeUp on linkable elements (elements with data: linkType & linkTarget)
4558
+ * And click or swipeUp on SwipeUp elements (WidgetProducts, WidgetGoods)
4559
+ */
4560
+ _handleLinkAndSwipeUpActivation(element, isSwipeUpAction = false) {
4357
4561
  const linkType = element.getAttribute("data-link-type");
4358
4562
  let linkTarget = element.getAttribute("data-link-target");
4359
4563
  const linkTargetIos = element.getAttribute("data-link-target-ios");
4360
4564
  const linkTargetAndroid = element.getAttribute("data-link-target-android");
4361
4565
  const linkTargetWeb = element.getAttribute("data-link-target-web");
4362
- let emitClick = false;
4566
+ const elementId = element.getAttribute("data-element-id") ?? "";
4567
+ let handled = false;
4363
4568
  if (this.sdkApi.isAndroid && linkTargetAndroid) {
4364
4569
  linkTarget = linkTargetAndroid;
4365
4570
  }
@@ -4369,58 +4574,81 @@ let SlideApi$1 = class SlideApi {
4369
4574
  if (this.sdkApi.isWeb && linkTargetWeb) {
4370
4575
  linkTarget = linkTargetWeb;
4371
4576
  }
4577
+ // for btn(link) without url (openGame, openStory, closeCard, products, goods, etc)
4578
+ let statisticWidgetValue = linkType;
4579
+ let statisticWidgetEventType = "w-link";
4372
4580
  if (linkType === "closeStory" || linkType === "closeIAM") {
4373
4581
  this.layoutService.env.setTimeout(() => this.sdkApi.closeCard("click"));
4374
- emitClick = false;
4582
+ handled = true;
4375
4583
  }
4376
- if (linkType && linkTarget) {
4377
- emitClick = true;
4584
+ else if (linkType && linkTarget) {
4378
4585
  if (linkType === "story") {
4379
4586
  // storyId: number, slideIndex: number
4380
4587
  this.layoutService.env.setTimeout(() => this.sdkApi.openStory(parseInt(linkTarget), 0));
4381
- emitClick = false;
4588
+ handled = true;
4382
4589
  }
4383
- if (linkType === "slide") {
4590
+ else if (linkType === "slide") {
4384
4591
  const __slideIndex = parseInt(linkTarget);
4385
4592
  const __slideCount = this.slide.slideCount;
4386
4593
  if (__slideIndex >= 0 && __slideIndex < __slideCount) {
4387
4594
  this.layoutService.env.setTimeout(() => this.sdkApi.showCardSlide(__slideIndex));
4388
- emitClick = false;
4595
+ handled = true;
4389
4596
  }
4390
4597
  }
4391
- if (linkType === "game") {
4598
+ else if (linkType === "game") {
4392
4599
  this.layoutService.env.setTimeout(() => this.sdkApi.openGame(linkTarget));
4393
- emitClick = false;
4600
+ handled = true;
4394
4601
  }
4395
- if (linkType === "layer") {
4602
+ else if (linkType === "layer") {
4396
4603
  const layerIndex = parseInt(linkTarget);
4397
4604
  if (layerIndex >= 0) {
4398
4605
  this.layoutService.env.setTimeout(() => this.sdkApi.showLayer(layerIndex));
4399
- emitClick = false;
4606
+ handled = true;
4400
4607
  }
4401
4608
  }
4402
- }
4403
- return { linkType, linkTarget, emitClick };
4404
- }
4405
- _performLinkTarget(element) {
4406
- const { linkType, linkTarget, emitClick } = this._performLinkSpecialAndReturnTarget(element);
4407
- // for btn(link) without url (openGame, openStory, closeCard, etc)
4408
- let statisticWidgetValue = linkType;
4409
- let handled = false;
4410
- if (emitClick && linkTarget && (linkType === "url" || linkType === "json")) {
4411
- handled = true;
4412
- const obj = {
4413
- type: "link",
4414
- link: {
4415
- type: linkType,
4416
- target: linkTarget,
4417
- },
4418
- };
4419
- // traditional link, with url
4420
- statisticWidgetValue = linkTarget;
4421
- this.layoutService.env.setTimeout(() => {
4422
- this.sdkApi.openUrl(obj);
4423
- });
4609
+ else if (linkType === "url") {
4610
+ // traditional link, with url
4611
+ statisticWidgetValue = linkTarget;
4612
+ this.layoutService.env.setTimeout(() => {
4613
+ this.sdkApi.openUrl({
4614
+ type: isSwipeUpAction ? "swipeUpLink" : "link",
4615
+ link: {
4616
+ type: "url",
4617
+ target: linkTarget,
4618
+ },
4619
+ });
4620
+ });
4621
+ handled = true;
4622
+ }
4623
+ else if (linkType === "products") {
4624
+ if (this.layoutService.layoutApi.widgetProductsApi) {
4625
+ this.layoutService.layoutApi.widgetProductsApi.click(element);
4626
+ handled = true;
4627
+ }
4628
+ }
4629
+ else if (linkType === "swipe-up-items") {
4630
+ const target = decodeURIComponent(linkTarget ?? "");
4631
+ this.layoutService.env.setTimeout(() => {
4632
+ this.sdkApi.openUrl({
4633
+ type: "swipeUpItems",
4634
+ link: {
4635
+ type: "json",
4636
+ target,
4637
+ },
4638
+ elementId,
4639
+ });
4640
+ });
4641
+ statisticWidgetValue = target;
4642
+ statisticWidgetEventType = "w-goods-open";
4643
+ try {
4644
+ // TODO CSP violation
4645
+ element.style.setProperty("opacity", "0");
4646
+ }
4647
+ catch (e) {
4648
+ console.error(e);
4649
+ }
4650
+ handled = true;
4651
+ }
4424
4652
  }
4425
4653
  try {
4426
4654
  const cardId = this.slide.cardId;
@@ -4436,17 +4664,16 @@ let SlideApi$1 = class SlideApi {
4436
4664
  baseFields.message_id = cardId;
4437
4665
  break;
4438
4666
  }
4439
- const elementId = element.getAttribute("data-element-id");
4440
- this.sdkApi.sendStatisticEvent("w-link", {
4667
+ this.sdkApi.sendStatisticEvent(statisticWidgetEventType, {
4441
4668
  i: cardId,
4442
4669
  si: slideIndex,
4443
- wi: elementId ?? "",
4670
+ wi: elementId,
4444
4671
  wl: element.textContent ?? "",
4445
4672
  wv: statisticWidgetValue ?? "",
4446
4673
  }, {
4447
4674
  ...baseFields,
4448
4675
  slide_index: slideIndex,
4449
- widget_id: elementId ?? "",
4676
+ widget_id: elementId,
4450
4677
  widget_label: element.textContent ?? "",
4451
4678
  widget_value: statisticWidgetValue ?? "",
4452
4679
  });
@@ -4456,98 +4683,14 @@ let SlideApi$1 = class SlideApi {
4456
4683
  }
4457
4684
  return { handled };
4458
4685
  }
4459
- // получать событие swipeUp от sdk, в том числе и от web sdk
4460
- slideSwipeUpHandler(target) {
4461
- if (target == null) {
4462
- const targetElement = this.activeLayer.swipeUpElement || this.activeLayer.swipeUpItemsElement || this.activeLayer.productsElement;
4463
- target = targetElement?.elementNodeRef;
4464
- }
4686
+ slideSwipeUpHandler() {
4687
+ const targetElement = this.activeLayer.swipeUpElement || this.activeLayer.swipeUpItemsElement || this.activeLayer.productsElement;
4688
+ const target = targetElement?.elementNodeRef;
4465
4689
  if (!target) {
4466
4690
  return false;
4467
4691
  }
4468
- const elementId = target.getAttribute("data-element-id") || "";
4469
- const { linkType, linkTarget: _linkTarget, emitClick } = this._performLinkSpecialAndReturnTarget(target);
4470
- if (emitClick) {
4471
- const linkTarget = decodeURIComponent(_linkTarget ?? "");
4472
- if (linkType === "products") {
4473
- if (this.layoutService.layoutApi.widgetProductsApi) {
4474
- this.layoutService.layoutApi.widgetProductsApi.click(target);
4475
- }
4476
- return true;
4477
- }
4478
- let swipeUpLinkObj = {
4479
- type: "swipeUpLink",
4480
- link: {
4481
- type: "url",
4482
- target: linkTarget,
4483
- },
4484
- elementId,
4485
- };
4486
- if (linkType === "swipe-up-items") {
4487
- swipeUpLinkObj = {
4488
- type: "swipeUpItems",
4489
- link: {
4490
- type: "json",
4491
- target: linkTarget,
4492
- },
4493
- elementId,
4494
- };
4495
- try {
4496
- // TODO CSP violation
4497
- target.style.setProperty("opacity", "0");
4498
- }
4499
- catch (e) {
4500
- console.error(e);
4501
- }
4502
- }
4503
- this.layoutService.env.setTimeout(() => {
4504
- this.sdkApi.openUrl(swipeUpLinkObj);
4505
- });
4506
- let eventType = "";
4507
- if (linkType === "url") {
4508
- eventType = "w-link";
4509
- }
4510
- else if (linkType === "swipe-up-items") {
4511
- eventType = "w-goods-open";
4512
- }
4513
- if (eventType) {
4514
- try {
4515
- const cardId = this.slide.cardId;
4516
- const cardType = this.slide.cardType;
4517
- const slideIndex = this.slide.slideIndex;
4518
- let baseFields = {};
4519
- switch (cardType) {
4520
- case 1 /* CARD_TYPE.STORY */:
4521
- case 2 /* CARD_TYPE.UGC_STORY */:
4522
- baseFields.story_id = cardId;
4523
- break;
4524
- case 4 /* CARD_TYPE.IN_APP_MESSAGING */:
4525
- baseFields.message_id = cardId;
4526
- break;
4527
- }
4528
- this.sdkApi.sendStatisticEvent(eventType, {
4529
- i: cardId,
4530
- si: slideIndex,
4531
- wi: elementId,
4532
- wl: target.textContent ?? "",
4533
- wv: linkTarget,
4534
- }, {
4535
- ...baseFields,
4536
- slide_index: slideIndex,
4537
- widget_id: elementId,
4538
- widget_label: target.textContent ?? "",
4539
- widget_value: linkTarget,
4540
- });
4541
- }
4542
- catch (error) {
4543
- console.error(error);
4544
- }
4545
- }
4546
- return true;
4547
- }
4548
- else {
4549
- return false;
4550
- }
4692
+ const { handled } = this._handleLinkAndSwipeUpActivation(target, true);
4693
+ return handled;
4551
4694
  }
4552
4695
  setTextInputResult(id, text) {
4553
4696
  if (this.activeLayer.dataInputElement) {
@@ -4565,10 +4708,9 @@ let SlideApi$1 = class SlideApi {
4565
4708
  this.activeLayer.shareElement.complete(id, isSuccess);
4566
4709
  }
4567
4710
  }
4568
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`{\n slideWrapper: HTMLElement;\n viewport: Window;\n userResizeHandler?: (data: { viewportWidth: number; viewportHeight: number; fontSize: number }) => void;\n slideRatio: number;\n isFullscreen: boolean;\n slideLoadedCb?: (data: { slide: Slide; result: boolean; reason?: string }) => void;\n }`]; }
4711
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`{\n sdkApi: SDKApi;\n slideWrapper: HTMLElement;\n viewport: Window;\n userResizeHandler?: (data: { viewportWidth: number; viewportHeight: number; fontSize: number }) => void;\n slideRatio: number;\n isFullscreen: boolean;\n slideLoadedCb?: (data: { slide: Slide; result: boolean; reason?: string }) => void;\n getViewportWidth: () => number;\n getViewportHeight: () => number;\n }`]; }
4569
4712
  };
4570
4713
 
4571
- let sdkInterface;
4572
4714
  const slideApiPeerDeps = {};
4573
4715
  const createSlideWrapper = ({ slideBoxRatio, nonce }) => {
4574
4716
  const slideWrapper = document.createElement("div");
@@ -4590,7 +4732,9 @@ const createSlideWrapper = ({ slideBoxRatio, nonce }) => {
4590
4732
  // .narrative-slide-box {
4591
4733
  // padding: <?= $slideRatioPadding ?> 0 0 0;
4592
4734
  // }
4593
- style.sheet?.insertRule(`.narrative-slide-box {padding: ${paddingTop} 0 0 0;`);
4735
+ // style.sheet?.insertRule(`.narrative-slide-box {padding: ${paddingTop} 0 0 0;`);
4736
+ slideBoxRendered.style.padding = `${paddingTop} 0 0 0`;
4737
+ slideBoxPrerender.style.padding = `${paddingTop} 0 0 0`;
4594
4738
  slideOffset.appendChild(slideBoxPrerender);
4595
4739
  slideOffset.appendChild(slideBoxRendered);
4596
4740
  slideWrapper.appendChild(slideOffset);
@@ -4599,24 +4743,24 @@ const createSlideWrapper = ({ slideBoxRatio, nonce }) => {
4599
4743
  };
4600
4744
  class SlideApi extends SlideApi$1 {
4601
4745
  constructor(_sdkInterface, config) {
4602
- sdkInterface = _sdkInterface;
4603
4746
  slideApiPeerDeps.VODPlayer = config.VODPlayer;
4604
4747
  const slideWrapper = createSlideWrapper({ slideBoxRatio: config.slideRatio, nonce: config.nonce });
4605
4748
  // todo need to clear root node before append slideWrapper?
4606
4749
  config.root.appendChild(slideWrapper);
4607
4750
  super({
4751
+ sdkApi: new EsModuleSdkApi(_sdkInterface),
4608
4752
  slideWrapper,
4609
4753
  viewport: config.viewport,
4610
4754
  slideRatio: config.slideRatio,
4611
4755
  isFullscreen: config.isFullscreen,
4612
4756
  userResizeHandler: config.userResizeHandler,
4757
+ getViewportWidth: () => slideWrapper.clientWidth,
4758
+ getViewportHeight: () => slideWrapper.clientHeight,
4613
4759
  });
4614
4760
  }
4615
4761
  static get [Symbol.for("___CTOR_ARGS___")]() { return [`SDKInterface`, `{\n root: HTMLElement;\n slideRatio: number;\n isFullscreen: boolean;\n nonce?: string;\n viewport: Window;\n userResizeHandler?: (data: { viewportWidth: number; viewportHeight: number; fontSize: number }) => void;\n VODPlayer?: typeof VODPlayer;\n }`]; }
4616
4762
  }
4617
4763
 
4618
- container.registerSingleton(() => new EsModuleSdkApi(() => sdkInterface), { identifier: `SDKApi` });
4619
-
4620
4764
  // This file is part of the bwip-js project available at:
4621
4765
  //
4622
4766
  // http://metafloor.github.io/bwip-js
@@ -13973,6 +14117,8 @@ FontLib.loadFont("OCR-B", 96, 100, "AAEAAAAPAIAAAwBwRkZUTXxHn14AADmUAAAAHEdERUYA
13973
14117
  function ean13(opts,dwg) { return _ToAny(bwipp_ean13,opts,dwg); }function pdf417(opts,dwg) { return _ToAny(bwipp_pdf417,opts,dwg); }function qrcode(opts,dwg) { return _ToAny(bwipp_qrcode,opts,dwg); }
13974
14118
 
13975
14119
  class WidgetBase {
14120
+ _onWidgetComplete;
14121
+ sdkApi;
13976
14122
  static DEFAULTS = {
13977
14123
  slide: null,
13978
14124
  activateAfterCreate: false,
@@ -13981,7 +14127,6 @@ class WidgetBase {
13981
14127
  };
13982
14128
  static widgetIndex = 0;
13983
14129
  env = WidgetBase.widgetsService.env;
13984
- sdkApi = WidgetBase.widgetsService.sdkApi;
13985
14130
  options = null;
13986
14131
  element = null;
13987
14132
  elementId = null;
@@ -14001,7 +14146,9 @@ class WidgetBase {
14001
14146
  id;
14002
14147
  startReadyPromise = null;
14003
14148
  startReadyResolve = null;
14004
- constructor(element, options, elementIdGetter, slideGetter) {
14149
+ constructor(element, options, _onWidgetComplete, sdkApi, elementIdGetter, slideGetter) {
14150
+ this._onWidgetComplete = _onWidgetComplete;
14151
+ this.sdkApi = sdkApi;
14005
14152
  this.options = extend({}, this.constructor.DEFAULTS, options);
14006
14153
  this.element = element;
14007
14154
  if (elementIdGetter) {
@@ -14109,68 +14256,24 @@ class WidgetBase {
14109
14256
  return instance;
14110
14257
  }
14111
14258
  static initWidget(htmlElement, localData, instantiate) {
14112
- if (localData != null) {
14113
- const widget = this.createInstance(instantiate, htmlElement, {
14114
- slide: null,
14115
- localData,
14116
- });
14117
- // start widget (just created or cached instance)
14118
- widget.onRefreshUserData(localData);
14119
- return Promise.resolve(localData);
14120
- }
14121
- else {
14122
- return new Promise(resolve => {
14123
- this.getLocalData().then(localData => {
14124
- const widget = this.createInstance(instantiate, htmlElement, {
14125
- slide: null,
14126
- localData,
14127
- });
14128
- // start widget (just created or cached instance)
14129
- widget.onRefreshUserData(localData);
14130
- resolve(localData);
14131
- });
14132
- });
14133
- }
14134
- }
14135
- /** @deprecated */
14136
- static initWidgets(instantiate, elements, localData) {
14137
- if (localData != null) {
14138
- forEach(elements, element => {
14139
- const widget = this.createInstance(instantiate, element, {
14140
- slide: null,
14141
- localData,
14142
- });
14143
- // start widget (just created or cached instance)
14144
- widget.onRefreshUserData(localData);
14145
- });
14146
- return Promise.resolve(localData);
14147
- }
14148
- else {
14149
- return new Promise(resolve => {
14150
- this.getLocalData().then(localData => {
14151
- forEach(elements, element => {
14152
- const widget = this.createInstance(instantiate, element, {
14153
- slide: null,
14154
- localData,
14155
- });
14156
- // start widget (just created or cached instance)
14157
- widget.onRefreshUserData(localData);
14158
- });
14159
- resolve(localData);
14160
- });
14161
- });
14162
- }
14259
+ const widget = this.createInstance(instantiate, htmlElement, {
14260
+ slide: null,
14261
+ localData,
14262
+ });
14263
+ // start widget (just created or cached instance)
14264
+ widget.onRefreshUserData(localData);
14265
+ return Promise.resolve(localData);
14163
14266
  }
14164
14267
  static get widgetsService() {
14165
14268
  return container.get({ identifier: "WidgetsService" });
14166
14269
  }
14167
- static getLocalData() {
14168
- return this.widgetsService.sdkApi.getCardLocalData();
14270
+ static getLocalData(sdkApi) {
14271
+ return sdkApi.getCardLocalData();
14169
14272
  }
14170
14273
  getLocalData() {
14171
- return this.constructor.getLocalData();
14274
+ return this.constructor.getLocalData(this.sdkApi);
14172
14275
  }
14173
- static setLocalData(keyValue, sendToServer, syncWithRuntimeLocalData) {
14276
+ static setLocalData(sdkApi, keyValue, sendToServer, syncWithRuntimeLocalData) {
14174
14277
  // push json object as string
14175
14278
  if (sendToServer === undefined) {
14176
14279
  sendToServer = true;
@@ -14185,20 +14288,20 @@ class WidgetBase {
14185
14288
  syncWithRuntimeLocalData = Boolean(syncWithRuntimeLocalData);
14186
14289
  }
14187
14290
  if (syncWithRuntimeLocalData) {
14188
- this.getLocalData().then(localData => {
14291
+ this.getLocalData(sdkApi).then(localData => {
14189
14292
  // 1 - old values, 2 - new values
14190
14293
  keyValue = extend({}, localData, keyValue);
14191
14294
  // todo make async via promise or async
14192
- this.widgetsService.sdkApi.setCardLocalData(keyValue, sendToServer);
14295
+ sdkApi.setCardLocalData(keyValue, sendToServer);
14193
14296
  });
14194
14297
  }
14195
14298
  else {
14196
14299
  // todo make async via promise or async
14197
- this.widgetsService.sdkApi.setCardLocalData(keyValue, sendToServer);
14300
+ sdkApi.setCardLocalData(keyValue, sendToServer);
14198
14301
  }
14199
14302
  }
14200
14303
  setLocalData(keyValue, sendToServer, syncWithRuntimeLocalData) {
14201
- return this.constructor.setLocalData(keyValue, sendToServer, syncWithRuntimeLocalData);
14304
+ return this.constructor.setLocalData(this.sdkApi, keyValue, sendToServer, syncWithRuntimeLocalData);
14202
14305
  }
14203
14306
  get statisticEventBaseFieldsShortForm() {
14204
14307
  return WidgetBase.getStatisticEventBaseFieldsShortForm(this.cardId, this.slideIndex);
@@ -14225,14 +14328,14 @@ class WidgetBase {
14225
14328
  }
14226
14329
  return data;
14227
14330
  }
14228
- static sendStatisticEventToApp(name, data, devPayload, options) {
14229
- sendStatisticEventToApp(this.widgetsService.sdkApi, name, data, devPayload, options);
14331
+ static sendStatisticEventToApp(sdkApi, name, data, devPayload, options) {
14332
+ sendStatisticEventToApp(sdkApi, name, data, devPayload, options);
14230
14333
  }
14231
14334
  sendStatisticEventToApp(name, data, devPayload, options) {
14232
- this.constructor.sendStatisticEventToApp(name, data, devPayload, options);
14335
+ this.constructor.sendStatisticEventToApp(this.sdkApi, name, data, devPayload, options);
14233
14336
  }
14234
- startDisabledTimeline() {
14235
- this.sdkApi.startDisabledTimeline(this.cardId, this.slideIndex);
14337
+ onWidgetComplete() {
14338
+ this._onWidgetComplete(this.cardId, this.slideIndex);
14236
14339
  }
14237
14340
  _showLayer(layers, selectIndex, withStatEvent = false) {
14238
14341
  if (this.sdkApi.isExistsShowLayer()) {
@@ -14267,45 +14370,13 @@ class WidgetBase {
14267
14370
  console.error(error);
14268
14371
  }
14269
14372
  }
14270
- /** @deprecated */
14271
- static refreshUserData(nodes, localData) {
14272
- const cb = (el, localData) => {
14273
- const widgetElement = el.closest(`.${this.widgetClassName}`);
14274
- if (widgetElement) {
14275
- const widget = WidgetBase.getInstance(widgetElement);
14276
- if (widget) {
14277
- widget.onRefreshUserData(localData);
14278
- }
14279
- }
14280
- };
14281
- if (localData != null) {
14282
- const elements = slice.call(nodes);
14283
- forEach(elements, el => cb(el, localData));
14284
- }
14285
- else {
14286
- WidgetBase.getLocalData().then(localData => {
14287
- const elements = slice.call(nodes);
14288
- forEach(elements, el => cb(el, localData));
14289
- });
14290
- }
14291
- }
14292
14373
  static onRefreshUserData(element, localData) {
14293
- const cb = (el, localData) => {
14294
- const widgetElement = el.closest(`.${this.widgetClassName}`);
14295
- if (widgetElement) {
14296
- const widget = WidgetBase.getInstance(widgetElement);
14297
- if (widget) {
14298
- widget.onRefreshUserData(localData);
14299
- }
14374
+ const widgetElement = element.closest(`.${this.widgetClassName}`);
14375
+ if (widgetElement) {
14376
+ const widget = WidgetBase.getInstance(widgetElement);
14377
+ if (widget) {
14378
+ widget.onRefreshUserData(localData);
14300
14379
  }
14301
- };
14302
- if (localData != null) {
14303
- cb(element, localData);
14304
- }
14305
- else {
14306
- WidgetBase.getLocalData().then(localData => {
14307
- cb(element, localData);
14308
- });
14309
14380
  }
14310
14381
  }
14311
14382
  getPromotionalCodeFetchPath(promotionalCodeId) {
@@ -14316,7 +14387,7 @@ class WidgetBase {
14316
14387
  return `story/${this.cardId}/widget/${this.elementId}/promo-code/${promotionalCodeId}`;
14317
14388
  }
14318
14389
  }
14319
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `(element: HTMLElement) => string`, `(element: HTMLElement) => HTMLElement`]; }
14390
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`, `(element: HTMLElement) => string`, `(element: HTMLElement) => HTMLElement`]; }
14320
14391
  }
14321
14392
 
14322
14393
  class WidgetBarcode extends WidgetBase {
@@ -14340,8 +14411,8 @@ class WidgetBarcode extends WidgetBase {
14340
14411
  msgNoMoreCodes;
14341
14412
  msgTryAgain;
14342
14413
  msgBarcodeRenderError;
14343
- constructor(element, options) {
14344
- super(element, options);
14414
+ constructor(element, options, onWidgetComplete, sdkApi) {
14415
+ super(element, options, onWidgetComplete, sdkApi);
14345
14416
  this.captionView = this.element.querySelector(".narrative-element-text-lines");
14346
14417
  this.clipboardTarget = getTagData(element, "clipboardTarget");
14347
14418
  this.isPromotionalCode = getTagData(element, "clipboardType") === "promocode";
@@ -14564,7 +14635,7 @@ class WidgetBarcode extends WidgetBase {
14564
14635
  // флаг - что таймер уже стартанул (в layout или добавить объект sharedMemory)
14565
14636
  // смотрим что прозрачный текст - тогда и лоадер прозрачный
14566
14637
  // _log("_showNarrativeNextSlide: " + getSlideDuration(this.narrativeId, this.slideIndex), true);
14567
- this.startDisabledTimeline();
14638
+ this.onWidgetComplete();
14568
14639
  }
14569
14640
  });
14570
14641
  if (this.copiedText) {
@@ -14589,18 +14660,9 @@ class WidgetBarcode extends WidgetBase {
14589
14660
  }
14590
14661
  static api = {
14591
14662
  widgetClassName: WidgetBarcode.widgetClassName,
14592
- /** @deprecated */
14593
- refreshUserData: WidgetBarcode.refreshUserData,
14594
14663
  onRefreshUserData: WidgetBarcode.onRefreshUserData,
14595
- init: function (element, localData) {
14596
- WidgetBarcode.initWidget(element, localData, (element, options) => new WidgetBarcode(element, options));
14597
- },
14598
- /** @deprecated */
14599
- initWidget: function (nodeList, localData) {
14600
- const elements = slice.call(nodeList);
14601
- WidgetBarcode.initWidgets((element, options) => new WidgetBarcode(element, options), elements, localData).then(() => {
14602
- elements.forEach(element => WidgetBarcode.getInstance(element)?.onStart());
14603
- });
14664
+ init: function (element, localData, onWidgetComplete, sdkApi) {
14665
+ WidgetBarcode.initWidget(element, localData, (element, options) => new WidgetBarcode(element, options, onWidgetComplete, sdkApi));
14604
14666
  },
14605
14667
  onStart: function (element) {
14606
14668
  WidgetBarcode.getInstance(element)?.onStart();
@@ -14627,7 +14689,7 @@ class WidgetBarcode extends WidgetBase {
14627
14689
  return false;
14628
14690
  },
14629
14691
  };
14630
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
14692
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
14631
14693
  }
14632
14694
 
14633
14695
  class WidgetCopy extends WidgetBase {
@@ -14649,8 +14711,8 @@ class WidgetCopy extends WidgetBase {
14649
14711
  geometry;
14650
14712
  resultLayer;
14651
14713
  resultLayerGeometry;
14652
- constructor(element, options) {
14653
- super(element, options);
14714
+ constructor(element, options, onWidgetComplete, sdkApi) {
14715
+ super(element, options, onWidgetComplete, sdkApi);
14654
14716
  this.button = this.element.querySelector(".narrative-element-text-lines");
14655
14717
  this.clipboardTarget = getTagData(element, "clipboardTarget");
14656
14718
  this.isPromotionalCode = getTagData(element, "clipboardType") === "promocode";
@@ -14834,7 +14896,7 @@ class WidgetCopy extends WidgetBase {
14834
14896
  // флаг - что таймер уже стартанул (в layout или добавить объект sharedMemory)
14835
14897
  // смотрим что прозрачный текст - тогда и лоадер прозрачный
14836
14898
  // _log("_showNarrativeNextSlide: " + getSlideDuration(this.narrativeId, this.slideIndex), true);
14837
- this.startDisabledTimeline();
14899
+ this.onWidgetComplete();
14838
14900
  }
14839
14901
  });
14840
14902
  }
@@ -14856,23 +14918,13 @@ class WidgetCopy extends WidgetBase {
14856
14918
  }
14857
14919
  static api = {
14858
14920
  widgetClassName: WidgetCopy.widgetClassName,
14859
- /** @deprecated */
14860
- refreshUserData: WidgetCopy.refreshUserData,
14861
14921
  onRefreshUserData: WidgetCopy.onRefreshUserData,
14862
- init: function (element, localData) {
14922
+ init: function (element, localData, onWidgetComplete, sdkApi) {
14863
14923
  // prevent initWidget for result layer
14864
14924
  if (!element.classList.contains("narrative-element-copy-result-variant")) {
14865
- WidgetCopy.initWidget(element, localData, (element, options) => new WidgetCopy(element, options));
14925
+ WidgetCopy.initWidget(element, localData, (element, options) => new WidgetCopy(element, options, onWidgetComplete, sdkApi));
14866
14926
  }
14867
14927
  },
14868
- /** @deprecated */
14869
- initWidget: function (nodeList, localData) {
14870
- // prevent initWidget for result layer
14871
- const elements = slice.call(nodeList).filter(element => !element.classList.contains("narrative-element-copy-result-variant"));
14872
- WidgetCopy.initWidgets((element, options) => new WidgetCopy(element, options), elements, localData).then(() => {
14873
- elements.forEach(element => WidgetCopy.getInstance(element)?.onStart());
14874
- });
14875
- },
14876
14928
  onStart: function (element) {
14877
14929
  WidgetCopy.getInstance(element)?.onStart();
14878
14930
  },
@@ -14898,10 +14950,9 @@ class WidgetCopy extends WidgetBase {
14898
14950
  return false;
14899
14951
  },
14900
14952
  };
14901
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
14953
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
14902
14954
  }
14903
14955
 
14904
- /** QUIZ */
14905
14956
  class WidgetDataInput extends WidgetBase {
14906
14957
  static DEFAULTS = {
14907
14958
  slide: null,
@@ -14919,9 +14970,11 @@ class WidgetDataInput extends WidgetBase {
14919
14970
  * @throws Error
14920
14971
  * @param element
14921
14972
  * @param options
14973
+ * @param onWidgetComplete
14974
+ * @param sdkApi
14922
14975
  */
14923
- constructor(element, options) {
14924
- super(element, options);
14976
+ constructor(element, options, onWidgetComplete, sdkApi) {
14977
+ super(element, options, onWidgetComplete, sdkApi);
14925
14978
  this.label = this.element.querySelector(".label-view .label");
14926
14979
  this.elementRect = this.element.getBoundingClientRect();
14927
14980
  this.inputElement = getValueOrException(this.element.querySelector(".input-view .input"), "Empty .input-view .input");
@@ -14940,7 +14993,7 @@ class WidgetDataInput extends WidgetBase {
14940
14993
  this.element.classList.add("done");
14941
14994
  this.startReadyPromise.then(() => {
14942
14995
  if (this.disableTimer) {
14943
- this.startDisabledTimeline();
14996
+ this.onWidgetComplete();
14944
14997
  }
14945
14998
  });
14946
14999
  }
@@ -15057,7 +15110,7 @@ class WidgetDataInput extends WidgetBase {
15057
15110
  this.setLocalData(this.localData, true);
15058
15111
  this._statEventInputSave(text);
15059
15112
  if (this.disableTimer) {
15060
- this.startDisabledTimeline();
15113
+ this.onWidgetComplete();
15061
15114
  needResumeUITimer = false;
15062
15115
  }
15063
15116
  }
@@ -15067,18 +15120,9 @@ class WidgetDataInput extends WidgetBase {
15067
15120
  }
15068
15121
  static api = {
15069
15122
  widgetClassName: WidgetDataInput.widgetClassName,
15070
- /** @deprecated */
15071
- refreshUserData: WidgetDataInput.refreshUserData,
15072
15123
  onRefreshUserData: WidgetDataInput.onRefreshUserData,
15073
- init: function (element, localData) {
15074
- WidgetDataInput.initWidget(element, localData, (element, options) => new WidgetDataInput(element, options));
15075
- },
15076
- /** @deprecated */
15077
- initWidget: function (nodeList, localData) {
15078
- const elements = slice.call(nodeList);
15079
- WidgetDataInput.initWidgets((element, options) => new WidgetDataInput(element, options), slice.call(nodeList), localData).then(() => {
15080
- elements.forEach(element => WidgetDataInput.getInstance(element)?.onStart());
15081
- });
15124
+ init: function (element, localData, onWidgetComplete, sdkApi) {
15125
+ WidgetDataInput.initWidget(element, localData, (element, options) => new WidgetDataInput(element, options, onWidgetComplete, sdkApi));
15082
15126
  },
15083
15127
  onStart: function (element) {
15084
15128
  WidgetDataInput.getInstance(element)?.onStart();
@@ -15100,7 +15144,7 @@ class WidgetDataInput extends WidgetBase {
15100
15144
  WidgetDataInput.getInstanceById(id)?.setUserText(text);
15101
15145
  },
15102
15146
  };
15103
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
15147
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
15104
15148
  }
15105
15149
 
15106
15150
  class WidgetDateCountdown extends WidgetBase {
@@ -15128,8 +15172,8 @@ class WidgetDateCountdown extends WidgetBase {
15128
15172
  thirdGroup1;
15129
15173
  thirdGroup2;
15130
15174
  thirdGroupCaption;
15131
- constructor(element, options) {
15132
- super(element, options);
15175
+ constructor(element, options, onWidgetComplete, sdkApi) {
15176
+ super(element, options, onWidgetComplete, sdkApi);
15133
15177
  this.label = this.element.querySelector(".label-view .label");
15134
15178
  this.messages = {
15135
15179
  days: getTagData(this.element, "tDays") ?? "",
@@ -15306,18 +15350,9 @@ class WidgetDateCountdown extends WidgetBase {
15306
15350
  }
15307
15351
  static api = {
15308
15352
  widgetClassName: WidgetDateCountdown.widgetClassName,
15309
- /** @deprecated */
15310
- refreshUserData: WidgetDateCountdown.refreshUserData,
15311
15353
  onRefreshUserData: WidgetDateCountdown.onRefreshUserData,
15312
- init: function (element, layers, localData) {
15313
- WidgetDateCountdown.initWidget(element, localData, (element, options) => new WidgetDateCountdown(element, { ...options, layers }));
15314
- },
15315
- /** @deprecated */
15316
- initWidget: function (nodeList, layers, localData) {
15317
- const elements = slice.call(nodeList);
15318
- WidgetDateCountdown.initWidgets((element, options) => new WidgetDateCountdown(element, { ...options, layers }), elements, localData).then(() => {
15319
- elements.forEach(element => WidgetDateCountdown.getInstance(element)?.onStart());
15320
- });
15354
+ init: function (element, layers, localData, onWidgetComplete, sdkApi) {
15355
+ WidgetDateCountdown.initWidget(element, localData, (element, options) => new WidgetDateCountdown(element, { ...options, layers }, onWidgetComplete, sdkApi));
15321
15356
  },
15322
15357
  onStart: function (element) {
15323
15358
  WidgetDateCountdown.getInstance(element)?.onStart();
@@ -15331,23 +15366,11 @@ class WidgetDateCountdown extends WidgetBase {
15331
15366
  onResume: function (element) {
15332
15367
  WidgetDateCountdown.getInstance(element)?.onResume();
15333
15368
  },
15334
- /** @deprecated */
15335
- pause: function (nodeList) {
15336
- forEach(slice.call(nodeList), function (el, index) {
15337
- WidgetDateCountdown.getInstance(el)?.onPause();
15338
- });
15339
- },
15340
- /** @deprecated */
15341
- resume: function (nodeList) {
15342
- forEach(slice.call(nodeList), function (el, index) {
15343
- WidgetDateCountdown.getInstance(el)?.onResume();
15344
- });
15345
- },
15346
15369
  };
15347
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
15370
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
15348
15371
  }
15349
15372
 
15350
- const displaySlide = function (slides, localData) {
15373
+ const displaySlide = function (slides, localData, sdkApi) {
15351
15374
  const multiSlideItem = slides[0];
15352
15375
  let cardId = undefined;
15353
15376
  let cardType = 1 /* CARD_TYPE.STORY */;
@@ -15412,7 +15435,7 @@ const displaySlide = function (slides, localData) {
15412
15435
  if (slides.length > 0) {
15413
15436
  var slide = slides[0];
15414
15437
  slide.classList.remove("hidden");
15415
- WidgetBase.widgetsService.sdkApi.cardAnimation?.start(slide);
15438
+ sdkApi.cardAnimation?.start(slide);
15416
15439
  return;
15417
15440
  }
15418
15441
  score = 0;
@@ -15441,19 +15464,19 @@ const displaySlide = function (slides, localData) {
15441
15464
  if (index === selectedIndex) {
15442
15465
  slide.classList.remove("hidden");
15443
15466
  undefinedResult = false;
15444
- WidgetBase.widgetsService.sdkApi.cardAnimation?.start(slide);
15445
- _sendStatEvent(cardId, cardType, slideIndex, selectedIndex);
15467
+ sdkApi.cardAnimation?.start(slide);
15468
+ _sendStatEvent(sdkApi, cardId, cardType, slideIndex, selectedIndex);
15446
15469
  }
15447
15470
  });
15448
15471
  }
15449
15472
  if (undefinedResult) {
15450
15473
  console.warn("undefinedResult layer index");
15451
- WidgetBase.widgetsService.sdkApi.showLayer(0);
15474
+ sdkApi.showLayer(0);
15452
15475
  }
15453
15476
  };
15454
- const _sendStatEvent = function (cardId, cardType, slideIndex, layerIndex) {
15477
+ const _sendStatEvent = function (sdkApi, cardId, cardType, slideIndex, layerIndex) {
15455
15478
  try {
15456
- WidgetBase.sendStatisticEventToApp("layout-show", {
15479
+ WidgetBase.sendStatisticEventToApp(sdkApi, "layout-show", {
15457
15480
  ...WidgetBase.getStatisticEventBaseFieldsShortForm(cardId, slideIndex),
15458
15481
  li: layerIndex,
15459
15482
  }, {
@@ -15467,15 +15490,8 @@ const _sendStatEvent = function (cardId, cardType, slideIndex, layerIndex) {
15467
15490
  };
15468
15491
  class WidgetMultiSlide {
15469
15492
  static api = {
15470
- init: function (slides, localData) {
15471
- if (localData != null) {
15472
- displaySlide(slides, localData);
15473
- }
15474
- else {
15475
- WidgetBase.getLocalData().then(function (localData) {
15476
- displaySlide(slides, localData);
15477
- });
15478
- }
15493
+ init: function (slides, localData, sdkApi) {
15494
+ displaySlide(slides, localData, sdkApi);
15479
15495
  },
15480
15496
  };
15481
15497
  }
@@ -15506,9 +15522,10 @@ class WidgetPoll extends WidgetBase {
15506
15522
  * @throws Error
15507
15523
  * @param element
15508
15524
  * @param options
15525
+ * @param onWidgetComplete
15509
15526
  */
15510
- constructor(element, options) {
15511
- super(element, options);
15527
+ constructor(element, options, onWidgetComplete, sdkApi) {
15528
+ super(element, options, onWidgetComplete, sdkApi);
15512
15529
  this.label = this.element.querySelector(".label-view .label");
15513
15530
  this.percentFillMask = this.element.querySelector(".percent-filled-variants-view-group-mask");
15514
15531
  this.maskedVariants = slice.call(this.element.querySelectorAll(".variants-box .variants-view-group.percent-filled-variants-view-group .variant-view"));
@@ -15617,7 +15634,7 @@ class WidgetPoll extends WidgetBase {
15617
15634
  }
15618
15635
  this.startReadyPromise.then(() => {
15619
15636
  if (this.disableTimer) {
15620
- this.startDisabledTimeline();
15637
+ this.onWidgetComplete();
15621
15638
  }
15622
15639
  });
15623
15640
  }
@@ -15957,17 +15974,9 @@ class WidgetPoll extends WidgetBase {
15957
15974
  }
15958
15975
  static api = {
15959
15976
  widgetClassName: WidgetPoll.widgetClassName,
15960
- /** @deprecated */
15961
- refreshUserData: WidgetPoll.refreshUserData,
15962
15977
  onRefreshUserData: WidgetPoll.onRefreshUserData,
15963
- init: function (element, localData) {
15964
- WidgetPoll.initWidget(element, localData, (element, options) => new WidgetPoll(element, options));
15965
- },
15966
- /** @deprecated */
15967
- initWidget: function (element, localData) {
15968
- WidgetPoll.initWidgets((element, options) => new WidgetPoll(element, options), [element], localData).then(() => {
15969
- WidgetPoll.getInstance(element)?.onStart();
15970
- });
15978
+ init: function (element, localData, onWidgetComplete, sdkApi) {
15979
+ WidgetPoll.initWidget(element, localData, (element, options) => new WidgetPoll(element, options, onWidgetComplete, sdkApi));
15971
15980
  },
15972
15981
  onStart: function (element) {
15973
15982
  WidgetPoll.getInstance(element)?.onStart();
@@ -16013,7 +16022,7 @@ class WidgetPoll extends WidgetBase {
16013
16022
  }
16014
16023
  },
16015
16024
  };
16016
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
16025
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
16017
16026
  }
16018
16027
 
16019
16028
  class WidgetPollLayers extends WidgetBase {
@@ -16030,8 +16039,8 @@ class WidgetPollLayers extends WidgetBase {
16030
16039
  variantsTexts;
16031
16040
  selectedVariant;
16032
16041
  layers;
16033
- constructor(element, options) {
16034
- super(element, options);
16042
+ constructor(element, options, onWidgetComplete, sdkApi) {
16043
+ super(element, options, onWidgetComplete, sdkApi);
16035
16044
  this.layers = this.options.layers;
16036
16045
  this.label = this.element.querySelector(".label-view .label");
16037
16046
  this.variants = slice.call(this.element.querySelectorAll(".variants-box .variant-view"));
@@ -16103,7 +16112,7 @@ class WidgetPollLayers extends WidgetBase {
16103
16112
  this._showLayer(this.layers, layerIndex, userAction);
16104
16113
  this.startReadyPromise.then(() => {
16105
16114
  if (this.disableTimer) {
16106
- this.startDisabledTimeline();
16115
+ this.onWidgetComplete();
16107
16116
  }
16108
16117
  });
16109
16118
  }
@@ -16142,28 +16151,9 @@ class WidgetPollLayers extends WidgetBase {
16142
16151
  }
16143
16152
  static api = {
16144
16153
  widgetClassName: WidgetPollLayers.widgetClassName,
16145
- /** @deprecated */
16146
- refreshUserData: WidgetPollLayers.refreshUserData,
16147
16154
  onRefreshUserData: WidgetPollLayers.onRefreshUserData,
16148
- init: function (element, layers, localData) {
16149
- WidgetPollLayers.initWidget(element, localData, (element, options) => new WidgetPollLayers(element, { ...options, layers }));
16150
- },
16151
- /** @deprecated
16152
- *
16153
- * signature variants
16154
- * (widget, layers, undefined) - modern web sdk
16155
- * (widget, undefined, layers) - old web sdk and rn
16156
- * (widget, layers, localData) - native sdk
16157
- */
16158
- initWidget: function (element, layers, localData) {
16159
- if (layers === undefined && localData !== undefined) {
16160
- // @ts-ignore
16161
- layers = localData;
16162
- localData = undefined;
16163
- }
16164
- WidgetPollLayers.initWidgets((element, options) => new WidgetPollLayers(element, { ...options, layers }), [element], localData).then(() => {
16165
- WidgetPollLayers.getInstance(element)?.onStart();
16166
- });
16155
+ init: function (element, layers, localData, onWidgetComplete, sdkApi) {
16156
+ WidgetPollLayers.initWidget(element, localData, (element, options) => new WidgetPollLayers(element, { ...options, layers }, onWidgetComplete, sdkApi));
16167
16157
  },
16168
16158
  onStart: function (element) {
16169
16159
  WidgetPollLayers.getInstance(element)?.onStart();
@@ -16187,7 +16177,7 @@ class WidgetPollLayers extends WidgetBase {
16187
16177
  return false;
16188
16178
  },
16189
16179
  };
16190
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
16180
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
16191
16181
  }
16192
16182
 
16193
16183
  class Formatter {
@@ -16814,8 +16804,8 @@ class WidgetProducts extends WidgetBase {
16814
16804
  swipeGestureDetector = null;
16815
16805
  isClickCapturedByWidget = false;
16816
16806
  isScreenSupportsTouch = false;
16817
- constructor(element, options) {
16818
- super(element, options);
16807
+ constructor(element, options, onWidgetComplete, sdkApi) {
16808
+ super(element, options, onWidgetComplete, sdkApi);
16819
16809
  this.captionView = this.element.querySelector(".narrative-element-text-lines");
16820
16810
  const linkTarget = decodeURIComponent(getTagData(element, "linkTarget") ?? "[]");
16821
16811
  try {
@@ -17290,8 +17280,8 @@ class WidgetProducts extends WidgetBase {
17290
17280
  static api = {
17291
17281
  widgetClassName: WidgetProducts.widgetClassName,
17292
17282
  onRefreshUserData: WidgetProducts.onRefreshUserData,
17293
- init: function (element, localData) {
17294
- WidgetProducts.initWidget(element, localData, (element, options) => new WidgetProducts(element, options));
17283
+ init: function (element, localData, onWidgetComplete, sdkApi) {
17284
+ WidgetProducts.initWidget(element, localData, (element, options) => new WidgetProducts(element, options, onWidgetComplete, sdkApi));
17295
17285
  },
17296
17286
  onStart: function (element) {
17297
17287
  WidgetProducts.getInstance(element)?.onStart();
@@ -17340,7 +17330,7 @@ class WidgetProducts extends WidgetBase {
17340
17330
  return false;
17341
17331
  },
17342
17332
  };
17343
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
17333
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
17344
17334
  }
17345
17335
 
17346
17336
  class WidgetQuest extends WidgetBase {
@@ -17360,11 +17350,11 @@ class WidgetQuest extends WidgetBase {
17360
17350
  navigationNextSlide;
17361
17351
  slideDisabledNavigation;
17362
17352
  finalSlide;
17363
- constructor(element, options) {
17353
+ constructor(element, options, onWidgetComplete, sdkApi) {
17364
17354
  const isWidget = !hasClass(element, "narrative-slide");
17365
17355
  const elementIdGetter = (element) => getValueOrDefault(getTagData(element, "elementId"), "");
17366
17356
  const slideGetter = (element) => isWidget ? getValueOrException(element.closest(".narrative-slide"), "Empty slide") : element;
17367
- super(element, options, elementIdGetter, slideGetter);
17357
+ super(element, options, onWidgetComplete, sdkApi, elementIdGetter, slideGetter);
17368
17358
  this.isWidget = isWidget;
17369
17359
  this.slideCount = getTagDataAsNumber(this.slide, "slideCount") ?? 0;
17370
17360
  const nonFinalSlide = getTagDataAsNumber(this.slide, "nonFinalSlide");
@@ -17561,6 +17551,14 @@ class WidgetQuest extends WidgetBase {
17561
17551
  if (this.nonFinalSlide == null) {
17562
17552
  // widget v2 (with navigationNextSlide)
17563
17553
  if (directionForward) {
17554
+ if (this.navigationNextSlide === -1) {
17555
+ // this is the final slide - exit from this quest
17556
+ if (this.sdkApi.isExistsShowNextCard) {
17557
+ this.sdkApi.cardShowNext();
17558
+ }
17559
+ result.continueDefaultNavigation = false;
17560
+ return result;
17561
+ }
17564
17562
  const nextSlideIndex = this.navigationNextSlide ?? event.slideIndex + 1;
17565
17563
  if (nextSlideIndex < this.slideCount) {
17566
17564
  this._addNewRouteHistory(nextSlideIndex);
@@ -17662,12 +17660,10 @@ class WidgetQuest extends WidgetBase {
17662
17660
  }
17663
17661
  static api = {
17664
17662
  widgetClassName: WidgetQuest.widgetClassName,
17665
- /** @deprecated */
17666
- refreshUserData: WidgetQuest.refreshUserData,
17667
17663
  onRefreshUserData: WidgetQuest.onRefreshUserData,
17668
- init: function (element, localData) {
17664
+ init: function (element, localData, onWidgetComplete, sdkApi) {
17669
17665
  return new Promise(function (resolve, reject) {
17670
- WidgetQuest.initWidget(element, localData, (element, options) => new WidgetQuest(element, options)).then(localData => {
17666
+ WidgetQuest.initWidget(element, localData, (element, options) => new WidgetQuest(element, options, onWidgetComplete, sdkApi)).then(localData => {
17671
17667
  const widget = WidgetQuest.getInstance(element);
17672
17668
  if (widget) {
17673
17669
  resolve(widget.init());
@@ -17678,22 +17674,6 @@ class WidgetQuest extends WidgetBase {
17678
17674
  });
17679
17675
  });
17680
17676
  },
17681
- /** @deprecated */
17682
- initWidget: function (element, localData) {
17683
- return new Promise(function (resolve, reject) {
17684
- WidgetQuest.initWidgets((element, options) => new WidgetQuest(element, options), [element], localData).then(localData => {
17685
- const widget = WidgetQuest.getInstance(element);
17686
- if (widget) {
17687
- const result = widget.init();
17688
- widget.onStart();
17689
- resolve(result);
17690
- }
17691
- else {
17692
- resolve(true);
17693
- }
17694
- });
17695
- });
17696
- },
17697
17677
  onStart: function (element) {
17698
17678
  WidgetQuest.getInstance(element)?.onStart();
17699
17679
  },
@@ -17725,7 +17705,7 @@ class WidgetQuest extends WidgetBase {
17725
17705
  return { continueDefaultNavigation: true };
17726
17706
  },
17727
17707
  };
17728
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
17708
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
17729
17709
  }
17730
17710
 
17731
17711
  class WidgetQuiz extends WidgetBase {
@@ -17740,8 +17720,8 @@ class WidgetQuiz extends WidgetBase {
17740
17720
  answers;
17741
17721
  questionCount;
17742
17722
  selectedAnswer;
17743
- constructor(element, options) {
17744
- super(element, options);
17723
+ constructor(element, options, onWidgetComplete, sdkApi) {
17724
+ super(element, options, onWidgetComplete, sdkApi);
17745
17725
  this.question = this.element.querySelector(".label-view .label");
17746
17726
  this.answers = slice.call(this.element.querySelectorAll(".variants-box .variant-view-group"));
17747
17727
  this.questionCount = getValueOrException(getTagDataAsNumber(this.slide, "quizCount"), "Empty quizCount");
@@ -17796,7 +17776,7 @@ class WidgetQuiz extends WidgetBase {
17796
17776
  // }
17797
17777
  this.startReadyPromise.then(() => {
17798
17778
  if (this.disableTimer) {
17799
- this.startDisabledTimeline();
17779
+ this.onWidgetComplete();
17800
17780
  }
17801
17781
  });
17802
17782
  }
@@ -17888,17 +17868,9 @@ class WidgetQuiz extends WidgetBase {
17888
17868
  }
17889
17869
  static api = {
17890
17870
  widgetClassName: WidgetQuiz.widgetClassName,
17891
- /** @deprecated */
17892
- refreshUserData: WidgetQuiz.refreshUserData,
17893
17871
  onRefreshUserData: WidgetQuiz.onRefreshUserData,
17894
- init: function (element, localData) {
17895
- WidgetQuiz.initWidget(element, localData, (element, options) => new WidgetQuiz(element, options));
17896
- },
17897
- /** @deprecated */
17898
- initWidget: function (element, localData) {
17899
- WidgetQuiz.initWidgets((element, options) => new WidgetQuiz(element, options), [element], localData).then(() => {
17900
- WidgetQuiz.getInstance(element)?.onStart();
17901
- });
17872
+ init: function (element, localData, onWidgetComplete, sdkApi) {
17873
+ WidgetQuiz.initWidget(element, localData, (element, options) => new WidgetQuiz(element, options, onWidgetComplete, sdkApi));
17902
17874
  },
17903
17875
  onStart: function (element) {
17904
17876
  WidgetQuiz.getInstance(element)?.onStart();
@@ -17927,7 +17899,7 @@ class WidgetQuiz extends WidgetBase {
17927
17899
  return true;
17928
17900
  },
17929
17901
  };
17930
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
17902
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
17931
17903
  }
17932
17904
 
17933
17905
  class WidgetQuizGrouped extends WidgetBase {
@@ -17946,9 +17918,11 @@ class WidgetQuizGrouped extends WidgetBase {
17946
17918
  * @throws Error
17947
17919
  * @param element
17948
17920
  * @param options
17921
+ * @param onWidgetComplete
17922
+ * @param sdkApi
17949
17923
  */
17950
- constructor(element, options) {
17951
- super(element, options);
17924
+ constructor(element, options, onWidgetComplete, sdkApi) {
17925
+ super(element, options, onWidgetComplete, sdkApi);
17952
17926
  this.question = this.element.querySelector(".label-view .label");
17953
17927
  this.answers = slice.call(this.element.querySelectorAll(".variants-box .variant-view-group"));
17954
17928
  this.questionCount = getValueOrException(getTagDataAsNumber(this.slide, "quizCount"), "Empty quizCount");
@@ -17990,7 +17964,7 @@ class WidgetQuizGrouped extends WidgetBase {
17990
17964
  });
17991
17965
  this.startReadyPromise.then(() => {
17992
17966
  if (this.disableTimer) {
17993
- this.startDisabledTimeline();
17967
+ this.onWidgetComplete();
17994
17968
  }
17995
17969
  });
17996
17970
  }
@@ -18099,17 +18073,9 @@ class WidgetQuizGrouped extends WidgetBase {
18099
18073
  }
18100
18074
  static api = {
18101
18075
  widgetClassName: WidgetQuizGrouped.widgetClassName,
18102
- /** @deprecated */
18103
- refreshUserData: WidgetQuizGrouped.refreshUserData,
18104
18076
  onRefreshUserData: WidgetQuizGrouped.onRefreshUserData,
18105
- init: function (element, localData) {
18106
- WidgetQuizGrouped.initWidget(element, localData, (element, options) => new WidgetQuizGrouped(element, options));
18107
- },
18108
- /** @deprecated */
18109
- initWidget: function (element, localData) {
18110
- WidgetQuizGrouped.initWidgets((element, options) => new WidgetQuizGrouped(element, options), [element], localData).then(() => {
18111
- WidgetQuizGrouped.getInstance(element)?.onStart();
18112
- });
18077
+ init: function (element, localData, onWidgetComplete, sdkApi) {
18078
+ WidgetQuizGrouped.initWidget(element, localData, (element, options) => new WidgetQuizGrouped(element, options, onWidgetComplete, sdkApi));
18113
18079
  },
18114
18080
  onStart: function (element) {
18115
18081
  WidgetQuizGrouped.getInstance(element)?.onStart();
@@ -18138,7 +18104,7 @@ class WidgetQuizGrouped extends WidgetBase {
18138
18104
  return true;
18139
18105
  },
18140
18106
  };
18141
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
18107
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
18142
18108
  }
18143
18109
 
18144
18110
  // Polyfill Number.isNaN(value)
@@ -18308,9 +18274,10 @@ class WidgetRangeSlider extends WidgetBase {
18308
18274
  * @throws Error
18309
18275
  * @param element
18310
18276
  * @param options
18277
+ * @param onWidgetComplete
18311
18278
  */
18312
- constructor(element, options) {
18313
- super(element, options);
18279
+ constructor(element, options, onWidgetComplete, sdkApi) {
18280
+ super(element, options, onWidgetComplete, sdkApi);
18314
18281
  this.hasSubmitButton = Boolean(this.element.querySelector(".submit-button-view"));
18315
18282
  this.topScale = this.element.querySelector(".top-scale-bar-view-group");
18316
18283
  this.snapPosition = false;
@@ -18379,7 +18346,7 @@ class WidgetRangeSlider extends WidgetBase {
18379
18346
  this.displayAverageAnswer();
18380
18347
  this.startReadyPromise.then(() => {
18381
18348
  if (this.disableTimer) {
18382
- this.startDisabledTimeline();
18349
+ this.onWidgetComplete();
18383
18350
  }
18384
18351
  });
18385
18352
  }
@@ -18455,7 +18422,7 @@ class WidgetRangeSlider extends WidgetBase {
18455
18422
  }
18456
18423
  });
18457
18424
  // if (this.disableTimer) {
18458
- this.startDisabledTimeline();
18425
+ this.onWidgetComplete();
18459
18426
  // }
18460
18427
  this.setLocalData(this.localData, true);
18461
18428
  this._statEventInputSave(this.localData["_rs_g_" + this.elementId + "_v"]);
@@ -18752,17 +18719,9 @@ class WidgetRangeSlider extends WidgetBase {
18752
18719
  }
18753
18720
  static api = {
18754
18721
  widgetClassName: WidgetRangeSlider.widgetClassName,
18755
- /** @deprecated */
18756
- refreshUserData: WidgetRangeSlider.refreshUserData,
18757
18722
  onRefreshUserData: WidgetRangeSlider.onRefreshUserData,
18758
- init: function (element, localData) {
18759
- WidgetRangeSlider.initWidget(element, localData, (element, options) => new WidgetRangeSlider(element, options));
18760
- },
18761
- /** @deprecated */
18762
- initWidget: function (element, localData) {
18763
- WidgetRangeSlider.initWidgets((element, options) => new WidgetRangeSlider(element, options), [element], localData).then(() => {
18764
- WidgetRangeSlider.getInstance(element)?.onStart();
18765
- });
18723
+ init: function (element, localData, onWidgetComplete, sdkApi) {
18724
+ WidgetRangeSlider.initWidget(element, localData, (element, options) => new WidgetRangeSlider(element, options, onWidgetComplete, sdkApi));
18766
18725
  },
18767
18726
  onStart: function (element) {
18768
18727
  WidgetRangeSlider.getInstance(element)?.onStart();
@@ -18791,7 +18750,7 @@ class WidgetRangeSlider extends WidgetBase {
18791
18750
  return false;
18792
18751
  },
18793
18752
  };
18794
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
18753
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
18795
18754
  }
18796
18755
 
18797
18756
  class WidgetRate extends WidgetBase {
@@ -18814,8 +18773,8 @@ class WidgetRate extends WidgetBase {
18814
18773
  selectedStar;
18815
18774
  answerSelectDuration;
18816
18775
  elementRect;
18817
- constructor(element, options) {
18818
- super(element, options);
18776
+ constructor(element, options, onWidgetComplete, sdkApi) {
18777
+ super(element, options, onWidgetComplete, sdkApi);
18819
18778
  this.label = this.element.querySelector(".label-view .label");
18820
18779
  this.stars = slice.call(this.element.querySelectorAll(".input-view"));
18821
18780
  this.submitToStores = Boolean(getValueOrDefault(getTagDataAsNumber(this.element, "submitToStores"), 0));
@@ -18890,7 +18849,7 @@ class WidgetRate extends WidgetBase {
18890
18849
  this.element.classList.add("done");
18891
18850
  this.startReadyPromise.then(() => {
18892
18851
  if (this.disableTimer && runTimer) {
18893
- this.startDisabledTimeline();
18852
+ this.onWidgetComplete();
18894
18853
  }
18895
18854
  });
18896
18855
  }
@@ -19017,18 +18976,9 @@ class WidgetRate extends WidgetBase {
19017
18976
  }
19018
18977
  static api = {
19019
18978
  widgetClassName: WidgetRate.widgetClassName,
19020
- /** @deprecated */
19021
- refreshUserData: WidgetRate.refreshUserData,
19022
18979
  onRefreshUserData: WidgetRate.onRefreshUserData,
19023
- init: function (element, localData) {
19024
- WidgetRate.initWidget(element, localData, (element, options) => new WidgetRate(element, options));
19025
- },
19026
- /** @deprecated */
19027
- initWidget: function (nodeList, localData) {
19028
- const elements = slice.call(nodeList);
19029
- WidgetRate.initWidgets((element, options) => new WidgetRate(element, options), elements, localData).then(() => {
19030
- elements.forEach(element => WidgetRate.getInstance(element)?.onStart());
19031
- });
18980
+ init: function (element, localData, onWidgetComplete, sdkApi) {
18981
+ WidgetRate.initWidget(element, localData, (element, options) => new WidgetRate(element, options, onWidgetComplete, sdkApi));
19032
18982
  },
19033
18983
  onStart: function (element) {
19034
18984
  WidgetRate.getInstance(element)?.onStart();
@@ -19057,7 +19007,7 @@ class WidgetRate extends WidgetBase {
19057
19007
  WidgetRate.getInstanceById(id)?.setUserText(text);
19058
19008
  },
19059
19009
  };
19060
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
19010
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
19061
19011
  }
19062
19012
 
19063
19013
  class WidgetShare extends WidgetBase {
@@ -19074,8 +19024,8 @@ class WidgetShare extends WidgetBase {
19074
19024
  shareTarget;
19075
19025
  withLayer;
19076
19026
  btnDisabled;
19077
- constructor(element, options) {
19078
- super(element, options);
19027
+ constructor(element, options, onWidgetComplete, sdkApi) {
19028
+ super(element, options, onWidgetComplete, sdkApi);
19079
19029
  this.shareType = getTagData(this.element, "shareType");
19080
19030
  this.shareTarget = getTagData(this.element, "shareTarget");
19081
19031
  this.layers = this.options.layers;
@@ -19097,7 +19047,7 @@ class WidgetShare extends WidgetBase {
19097
19047
  }
19098
19048
  this.startReadyPromise.then(() => {
19099
19049
  if (this.isDone() && this.disableTimer) {
19100
- this.startDisabledTimeline();
19050
+ this.onWidgetComplete();
19101
19051
  }
19102
19052
  });
19103
19053
  this.btnDisabled = false;
@@ -19157,7 +19107,7 @@ class WidgetShare extends WidgetBase {
19157
19107
  this._showLayer(this.layers, 1, true);
19158
19108
  }
19159
19109
  if (this.disableTimer) {
19160
- this.startDisabledTimeline();
19110
+ this.onWidgetComplete();
19161
19111
  }
19162
19112
  this.btnDisabled = false;
19163
19113
  }
@@ -19166,31 +19116,12 @@ class WidgetShare extends WidgetBase {
19166
19116
  }
19167
19117
  static api = {
19168
19118
  widgetClassName: WidgetShare.widgetClassName,
19169
- /** @deprecated */
19170
- refreshUserData: WidgetShare.refreshUserData,
19171
19119
  onRefreshUserData: WidgetShare.onRefreshUserData,
19172
- init: function (element, layers, localData) {
19120
+ init: function (element, layers, localData, onWidgetComplete, sdkApi) {
19173
19121
  WidgetShare.initWidget(element, localData, (element, options) => new WidgetShare(element, {
19174
19122
  ...options,
19175
19123
  layers,
19176
- }));
19177
- },
19178
- /** @deprecated
19179
- * signature variants
19180
- * (widget, layers, undefined) - modern web sdk
19181
- * (widget, undefined, layers) - old web sdk and rn
19182
- * (widget, layers, localData) - native sdk
19183
- */
19184
- initWidget: function (nodeList, layers, localData) {
19185
- if (layers === undefined && localData !== undefined) {
19186
- // @ts-ignore
19187
- layers = localData;
19188
- localData = undefined;
19189
- }
19190
- const elements = slice.call(nodeList);
19191
- WidgetShare.initWidgets((element, options) => new WidgetShare(element, { ...options, layers }), elements, localData).then(() => {
19192
- elements.forEach(element => WidgetShare.getInstance(element)?.onStart());
19193
- });
19124
+ }, onWidgetComplete, sdkApi));
19194
19125
  },
19195
19126
  onStart: function (element) {
19196
19127
  WidgetShare.getInstance(element)?.onStart();
@@ -19211,7 +19142,7 @@ class WidgetShare extends WidgetBase {
19211
19142
  WidgetShare.getInstanceById(id)?._complete(isSuccess);
19212
19143
  },
19213
19144
  };
19214
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
19145
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
19215
19146
  }
19216
19147
 
19217
19148
  class WidgetTest extends WidgetBase {
@@ -19236,8 +19167,8 @@ class WidgetTest extends WidgetBase {
19236
19167
  timeLeftDefault;
19237
19168
  timeline;
19238
19169
  isWidgetTimerInit = false;
19239
- constructor(element, options) {
19240
- super(element, options);
19170
+ constructor(element, options, onWidgetComplete, sdkApi) {
19171
+ super(element, options, onWidgetComplete, sdkApi);
19241
19172
  this.label = this.element.querySelector(".label-view .label");
19242
19173
  this.variants = slice.call(this.element.querySelectorAll(".variants-box .variant-view"));
19243
19174
  this.testCount = getValueOrException(getTagDataAsNumber(this.slide, "testCount"), "Empty testCount");
@@ -19392,7 +19323,7 @@ class WidgetTest extends WidgetBase {
19392
19323
  });
19393
19324
  this.startReadyPromise.then(() => {
19394
19325
  if (this.disableTimer) {
19395
- this.startDisabledTimeline();
19326
+ this.onWidgetComplete();
19396
19327
  }
19397
19328
  });
19398
19329
  }
@@ -19464,17 +19395,9 @@ class WidgetTest extends WidgetBase {
19464
19395
  }
19465
19396
  static api = {
19466
19397
  widgetClassName: WidgetTest.widgetClassName,
19467
- /** @deprecated */
19468
- refreshUserData: WidgetTest.refreshUserData,
19469
19398
  onRefreshUserData: WidgetTest.onRefreshUserData,
19470
- init: function (element, localData) {
19471
- WidgetTest.initWidget(element, localData, (element, options) => new WidgetTest(element, options));
19472
- },
19473
- /** @deprecated */
19474
- initWidget: function (element, localData) {
19475
- WidgetTest.initWidgets((element, options) => new WidgetTest(element, options), [element], localData).then(() => {
19476
- WidgetTest.getInstance(element)?.onStart();
19477
- });
19399
+ init: function (element, localData, onWidgetComplete, sdkApi) {
19400
+ WidgetTest.initWidget(element, localData, (element, options) => new WidgetTest(element, options, onWidgetComplete, sdkApi));
19478
19401
  },
19479
19402
  onStart: function (element) {
19480
19403
  WidgetTest.getInstance(element)?.onStart();
@@ -19510,7 +19433,7 @@ class WidgetTest extends WidgetBase {
19510
19433
  return true;
19511
19434
  },
19512
19435
  };
19513
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
19436
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
19514
19437
  }
19515
19438
 
19516
19439
  class WidgetVote extends WidgetBase {
@@ -19536,9 +19459,11 @@ class WidgetVote extends WidgetBase {
19536
19459
  * @throws Error
19537
19460
  * @param element
19538
19461
  * @param options
19462
+ * @param onWidgetComplete
19463
+ * @param sdkApi
19539
19464
  */
19540
- constructor(element, options) {
19541
- super(element, options);
19465
+ constructor(element, options, onWidgetComplete, sdkApi) {
19466
+ super(element, options, onWidgetComplete, sdkApi);
19542
19467
  this.voteAllocation = getTagData(this.slide, "voteAllocation");
19543
19468
  this.label = this.element.querySelector(".label-view .label");
19544
19469
  this.variants = slice.call(this.element.querySelectorAll(".variants-box .variant-view-group"));
@@ -19722,7 +19647,7 @@ class WidgetVote extends WidgetBase {
19722
19647
  }
19723
19648
  this.startReadyPromise.then(() => {
19724
19649
  if (this.disableTimer) {
19725
- this.startDisabledTimeline();
19650
+ this.onWidgetComplete();
19726
19651
  }
19727
19652
  });
19728
19653
  }
@@ -19920,45 +19845,9 @@ class WidgetVote extends WidgetBase {
19920
19845
  }
19921
19846
  static api = {
19922
19847
  widgetClassName: WidgetVote.widgetClassName,
19923
- /** @deprecated */
19924
- refreshUserData: WidgetVote.refreshUserData,
19925
19848
  onRefreshUserData: WidgetVote.onRefreshUserData,
19926
- init: function (element, localData) {
19927
- WidgetVote.initWidget(element, localData, (element, options) => new WidgetVote(element, options));
19928
- },
19929
- /** @deprecated
19930
- *
19931
- * fix for WidgetVote on every layer of multilayers story
19932
- */
19933
- fallbackInitOnMultiSlide: function (element, localData) {
19934
- if (element.dataset.fallbackInitOnMultiSlide) {
19935
- return;
19936
- }
19937
- const multiSlide = element.closest(".narrative-multi-slide");
19938
- if (multiSlide != null) {
19939
- const container = multiSlide.parentElement;
19940
- const widgetElements = container?.querySelectorAll(`.${WidgetVote.widgetClassName}`);
19941
- if (widgetElements != null) {
19942
- for (let i = 0; i < widgetElements.length; ++i) {
19943
- const widgetElement = widgetElements[i];
19944
- const widget = WidgetVote.getInstance(widgetElement);
19945
- if (!widget) {
19946
- WidgetVote.initWidgets((element, options) => new WidgetVote(element, options), [widgetElement], localData);
19947
- }
19948
- }
19949
- }
19950
- }
19951
- element.dataset.fallbackInitOnMultiSlide = "1";
19952
- },
19953
- /** @deprecated */
19954
- initWidget: function (element, localData) {
19955
- WidgetVote.initWidgets((element, options) => new WidgetVote(element, options), [element], localData)
19956
- .then(localData => {
19957
- WidgetVote.api.fallbackInitOnMultiSlide(element, localData);
19958
- })
19959
- .then(() => {
19960
- WidgetVote.getInstance(element)?.onStart();
19961
- });
19849
+ init: function (element, localData, onWidgetComplete, sdkApi) {
19850
+ WidgetVote.initWidget(element, localData, (element, options) => new WidgetVote(element, options, onWidgetComplete, sdkApi));
19962
19851
  },
19963
19852
  onStart: function (element) {
19964
19853
  WidgetVote.getInstance(element)?.onStart();
@@ -19994,7 +19883,7 @@ class WidgetVote extends WidgetBase {
19994
19883
  return true;
19995
19884
  },
19996
19885
  };
19997
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
19886
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
19998
19887
  }
19999
19888
 
20000
19889
  class EsModuleLayoutApi {