@inappstory/slide-api 0.1.4 → 0.1.6

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.js CHANGED
@@ -195,41 +195,31 @@ const container = new DIContainer();
195
195
 
196
196
  class WidgetsService {
197
197
  _env;
198
- _sdkApi;
199
- constructor(_env, _sdkApi) {
198
+ constructor(_env) {
200
199
  this._env = _env;
201
- this._sdkApi = _sdkApi;
202
200
  }
203
201
  get env() {
204
202
  return this._env;
205
203
  }
206
- get sdkApi() {
207
- return this._sdkApi;
208
- }
209
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`Window`, `SDKApi`]; }
204
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`Window`]; }
210
205
  }
211
206
 
212
207
  container.registerSingleton(undefined, { identifier: `WidgetsService`, implementation: WidgetsService });
213
208
 
214
209
  class LayoutService {
215
210
  _env;
216
- _sdkApi;
217
211
  _layoutApi;
218
- constructor(_env, _sdkApi, _layoutApi) {
212
+ constructor(_env, _layoutApi) {
219
213
  this._env = _env;
220
- this._sdkApi = _sdkApi;
221
214
  this._layoutApi = _layoutApi;
222
215
  }
223
216
  get env() {
224
217
  return this._env;
225
218
  }
226
- get sdkApi() {
227
- return this._sdkApi;
228
- }
229
219
  get layoutApi() {
230
220
  return this._layoutApi;
231
221
  }
232
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`Window`, `SDKApi`, `ILayoutApi`]; }
222
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`Window`, `ILayoutApi`]; }
233
223
  }
234
224
 
235
225
  container.registerSingleton(undefined, { identifier: `LayoutService`, implementation: LayoutService });
@@ -241,8 +231,6 @@ container.registerSingleton(undefined, { identifier: `LayoutService`, implementa
241
231
  // import '../effects/timer/composition';
242
232
  container.registerSingleton(() => window, { identifier: `Window` });
243
233
 
244
- const DEFAULT_SLIDE_DURATION = 10000;
245
-
246
234
  const arPrototype = Array.prototype;
247
235
  const obPrototype = Object.prototype;
248
236
  const slice = arPrototype.slice;
@@ -1052,30 +1040,25 @@ class EsModuleSdkApi {
1052
1040
  this.sdkBinding = sdkBinding;
1053
1041
  }
1054
1042
  getCardServerData(cardId) {
1055
- return this.sdkBinding().getCardServerData(cardId);
1043
+ return this.sdkBinding.getCardServerData(cardId);
1056
1044
  }
1057
1045
  updateCardServerDataLocally(cardId, data) {
1058
- return this.sdkBinding().updateCardServerDataLocally(data);
1059
- }
1060
- getSlideDuration(cardId, slideIndex) {
1061
- return DEFAULT_SLIDE_DURATION;
1062
- // unnecessary for es_module (without backward compatibility)
1063
- // return this.sdkBinding().getSlideDuration(cardId, slideIndex);
1046
+ return this.sdkBinding.updateCardServerDataLocally(data);
1064
1047
  }
1065
1048
  showNextSlide(duration) {
1066
- this.sdkBinding().showNextSlide();
1049
+ this.sdkBinding.showNextSlide();
1067
1050
  }
1068
1051
  sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2) {
1069
- this.sdkBinding().sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2);
1052
+ this.sdkBinding.sendStatisticEvent(name, data, devPayload, forceEnableStatisticV2);
1070
1053
  }
1071
1054
  getCardLocalData() {
1072
- return this.sdkBinding().getCardLocalData();
1055
+ return this.sdkBinding.getCardLocalData();
1073
1056
  }
1074
1057
  isExistsShowLayer() {
1075
1058
  return true;
1076
1059
  }
1077
1060
  showLayer(index) {
1078
- this.sdkBinding().showLayer(index);
1061
+ this.sdkBinding.showLayer(index);
1079
1062
  }
1080
1063
  get cardAnimation() {
1081
1064
  return animationApi;
@@ -1090,37 +1073,37 @@ class EsModuleSdkApi {
1090
1073
  return true;
1091
1074
  }
1092
1075
  pauseUI() {
1093
- this.sdkBinding().pauseUI();
1076
+ this.sdkBinding.pauseUI();
1094
1077
  }
1095
1078
  resumeUI() {
1096
- this.sdkBinding().resumeUI();
1079
+ this.sdkBinding.resumeUI();
1097
1080
  }
1098
1081
  get isExistsShowCardTextInput() {
1099
1082
  return true;
1100
1083
  }
1101
1084
  showCardTextInput(id, data) {
1102
- this.sdkBinding().showCardTextInput(id, data);
1085
+ this.sdkBinding.showCardTextInput(id, data);
1103
1086
  }
1104
1087
  setCardLocalData(keyValue, sendToServer) {
1105
- this.sdkBinding().setCardLocalData(keyValue, sendToServer);
1088
+ this.sdkBinding.setCardLocalData(keyValue, sendToServer);
1106
1089
  }
1107
1090
  getWidgetsSharedData(cardId, widget) {
1108
- return this.sdkBinding().getWidgetsSharedData(cardId, widget);
1091
+ return this.sdkBinding.getWidgetsSharedData(cardId, widget);
1109
1092
  }
1110
1093
  vibrate(pattern) {
1111
1094
  navigator.vibrate(pattern);
1112
1095
  }
1113
1096
  openUrl(data) {
1114
- this.sdkBinding().openUrl(data);
1097
+ this.sdkBinding.openUrl(data);
1115
1098
  }
1116
1099
  sendApiRequest(url, method, params, headers, data, profilingKey) {
1117
- return this.sdkBinding().sendApiRequest(url, method, params, headers, data, profilingKey);
1100
+ return this.sdkBinding.sendApiRequest(url, method, params, headers, data, profilingKey);
1118
1101
  }
1119
1102
  sendApiRequestSupported() {
1120
1103
  return true;
1121
1104
  }
1122
1105
  showToast(text) {
1123
- this.sdkBinding().showToast(text);
1106
+ this.sdkBinding.showToast(text);
1124
1107
  }
1125
1108
  get sdkCanSendShareComplete() {
1126
1109
  return true;
@@ -1129,83 +1112,81 @@ class EsModuleSdkApi {
1129
1112
  return true;
1130
1113
  }
1131
1114
  share(id, config) {
1132
- this.sdkBinding().share(id, config);
1115
+ this.sdkBinding.share(id, config);
1133
1116
  }
1134
1117
  shareSlideScreenshot(shareId, hideElementsSelector, shareText) {
1135
- this.sdkBinding().shareSlideScreenshot(shareId, hideElementsSelector, shareText);
1118
+ this.sdkBinding.shareSlideScreenshot(shareId, hideElementsSelector, shareText);
1136
1119
  }
1137
1120
  get isExistsShowCardSlide() {
1138
1121
  return true;
1139
1122
  }
1140
1123
  showCardSlide(index) {
1141
- this.sdkBinding().showCardSlide(index);
1124
+ this.sdkBinding.showCardSlide(index);
1142
1125
  }
1143
1126
  get isExistsShowNextCard() {
1144
1127
  return true;
1145
1128
  }
1146
1129
  cardShowNext() {
1147
- this.sdkBinding().cardShowNext();
1130
+ this.sdkBinding.cardShowNext();
1148
1131
  }
1149
1132
  setCardSessionValue(element, key, value) {
1150
- this.sdkBinding().setCardSessionValue(key, value);
1133
+ this.sdkBinding.setCardSessionValue(key, value);
1151
1134
  }
1152
1135
  getCardSessionValue(element, key) {
1153
- return this.sdkBinding().getCardSessionValue(key);
1136
+ return this.sdkBinding.getCardSessionValue(key);
1154
1137
  }
1155
1138
  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
- }
1139
+ this.sdkBinding.updateTimeline(slideIndex, action, currentTime, duration, showLoader, showError);
1160
1140
  }
1161
1141
  cardPausedCallback(currentTime) { }
1162
1142
  cardResumedCallback(currentTime) { }
1163
- startDisabledTimeline(cardId, slideIndex) {
1164
- // для android sdk важно чтобы этот метод вызывался только после slide_start
1165
- //@ts-ignore
1166
- // slideApi.afterStartInitQueuePush(function () {
1167
- // //@ts-ignore
1168
- // slideApi.activeLayer.timeline.startDisabledTimeline(() => {});
1169
- // });
1170
- }
1171
1143
  getCardFonts() {
1172
- return this.sdkBinding().getCardFonts();
1144
+ return this.sdkBinding.getCardFonts();
1173
1145
  }
1174
1146
  disableVerticalSwipeGesture() {
1175
- this.sdkBinding().disableVerticalSwipeGesture();
1147
+ this.sdkBinding.disableVerticalSwipeGesture();
1176
1148
  }
1177
1149
  enableVerticalSwipeGesture() {
1178
- this.sdkBinding().enableVerticalSwipeGesture();
1150
+ this.sdkBinding.enableVerticalSwipeGesture();
1179
1151
  }
1180
1152
  disableBackpress() { }
1181
1153
  enableBackpress() { }
1182
1154
  closeCard(reason) {
1183
- this.sdkBinding().closeCard(reason);
1155
+ this.sdkBinding.closeCard(reason);
1184
1156
  }
1185
1157
  openStory(id, index) {
1186
- this.sdkBinding().openStory(id, index);
1158
+ this.sdkBinding.openStory(id, index);
1187
1159
  }
1188
1160
  openGame(gameInstanceId) {
1189
- this.sdkBinding().openGame(gameInstanceId);
1161
+ this.sdkBinding.openGame(gameInstanceId);
1190
1162
  }
1191
1163
  writeToClipboard(data) {
1192
- this.sdkBinding().writeToClipboard(data);
1164
+ this.sdkBinding.writeToClipboard(data);
1165
+ }
1166
+ isSdkSupportTimelineOnBeforeStart() {
1167
+ return true;
1193
1168
  }
1194
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`() => SDKInterface`]; }
1169
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`SDKInterface`]; }
1195
1170
  }
1196
1171
 
1172
+ const DEFAULT_SLIDE_DURATION = 10000;
1173
+
1197
1174
  class DataInput {
1198
1175
  _elementNodeRef;
1199
1176
  _layer;
1200
1177
  _widgetApi;
1178
+ _onWidgetComplete;
1179
+ sdkApi;
1201
1180
  static _className = "narrative-element-data-input";
1202
1181
  static className() {
1203
1182
  return DataInput._className;
1204
1183
  }
1205
- constructor(_elementNodeRef, _layer, _widgetApi) {
1184
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1206
1185
  this._elementNodeRef = _elementNodeRef;
1207
1186
  this._layer = _layer;
1208
1187
  this._widgetApi = _widgetApi;
1188
+ this._onWidgetComplete = _onWidgetComplete;
1189
+ this.sdkApi = sdkApi;
1209
1190
  }
1210
1191
  static isTypeOf(element) {
1211
1192
  return element instanceof DataInput;
@@ -1213,7 +1194,7 @@ class DataInput {
1213
1194
  mediaElementsLoadingPromises = [];
1214
1195
  init(localData) {
1215
1196
  try {
1216
- this._widgetApi.init(this._elementNodeRef, localData);
1197
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1217
1198
  }
1218
1199
  catch (e) {
1219
1200
  console.error(e);
@@ -1238,26 +1219,30 @@ class DataInput {
1238
1219
  get isLayerForcePaused() {
1239
1220
  return false;
1240
1221
  }
1241
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetDataInput.api`]; }
1222
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetDataInput.api`, `OnWidgetComplete`, `SDKApi`]; }
1242
1223
  }
1243
1224
 
1244
1225
  class Barcode {
1245
1226
  _elementNodeRef;
1246
1227
  _layer;
1247
1228
  _widgetApi;
1229
+ _onWidgetComplete;
1230
+ sdkApi;
1248
1231
  static _className = "narrative-element-barcode";
1249
1232
  static className() {
1250
1233
  return Barcode._className;
1251
1234
  }
1252
- constructor(_elementNodeRef, _layer, _widgetApi) {
1235
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1253
1236
  this._elementNodeRef = _elementNodeRef;
1254
1237
  this._layer = _layer;
1255
1238
  this._widgetApi = _widgetApi;
1239
+ this._onWidgetComplete = _onWidgetComplete;
1240
+ this.sdkApi = sdkApi;
1256
1241
  }
1257
1242
  mediaElementsLoadingPromises = [];
1258
1243
  init(localData) {
1259
1244
  try {
1260
- this._widgetApi.init(this._elementNodeRef, localData);
1245
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1261
1246
  }
1262
1247
  catch (e) {
1263
1248
  console.error(e);
@@ -1279,7 +1264,7 @@ class Barcode {
1279
1264
  get isLayerForcePaused() {
1280
1265
  return false;
1281
1266
  }
1282
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetBarcode.api`]; }
1267
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetBarcode.api`, `OnWidgetComplete`, `SDKApi`]; }
1283
1268
  }
1284
1269
 
1285
1270
  class ClickableBase {
@@ -1324,19 +1309,23 @@ class Copy {
1324
1309
  _elementNodeRef;
1325
1310
  _layer;
1326
1311
  _widgetApi;
1312
+ _onWidgetComplete;
1313
+ sdkApi;
1327
1314
  static _className = "narrative-element-copy";
1328
1315
  static className() {
1329
1316
  return Copy._className;
1330
1317
  }
1331
- constructor(_elementNodeRef, _layer, _widgetApi) {
1318
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1332
1319
  this._elementNodeRef = _elementNodeRef;
1333
1320
  this._layer = _layer;
1334
1321
  this._widgetApi = _widgetApi;
1322
+ this._onWidgetComplete = _onWidgetComplete;
1323
+ this.sdkApi = sdkApi;
1335
1324
  }
1336
1325
  mediaElementsLoadingPromises = [];
1337
1326
  init(localData) {
1338
1327
  try {
1339
- this._widgetApi.init(this._elementNodeRef, localData);
1328
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1340
1329
  }
1341
1330
  catch (e) {
1342
1331
  console.error(e);
@@ -1358,7 +1347,7 @@ class Copy {
1358
1347
  get isLayerForcePaused() {
1359
1348
  return false;
1360
1349
  }
1361
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetCopy.api`]; }
1350
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetCopy.api`, `OnWidgetComplete`, `SDKApi`]; }
1362
1351
  }
1363
1352
 
1364
1353
  class DateCountdown {
@@ -1366,20 +1355,24 @@ class DateCountdown {
1366
1355
  _layer;
1367
1356
  _layersNodesRefs;
1368
1357
  _widgetApi;
1358
+ _onWidgetComplete;
1359
+ sdkApi;
1369
1360
  static _className = "narrative-element-date-countdown";
1370
1361
  static className() {
1371
1362
  return DateCountdown._className;
1372
1363
  }
1373
- constructor(_elementNodeRef, _layer, _layersNodesRefs, _widgetApi) {
1364
+ constructor(_elementNodeRef, _layer, _layersNodesRefs, _widgetApi, _onWidgetComplete, sdkApi) {
1374
1365
  this._elementNodeRef = _elementNodeRef;
1375
1366
  this._layer = _layer;
1376
1367
  this._layersNodesRefs = _layersNodesRefs;
1377
1368
  this._widgetApi = _widgetApi;
1369
+ this._onWidgetComplete = _onWidgetComplete;
1370
+ this.sdkApi = sdkApi;
1378
1371
  }
1379
1372
  mediaElementsLoadingPromises = [];
1380
1373
  init(localData) {
1381
1374
  try {
1382
- this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData);
1375
+ this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._onWidgetComplete, this.sdkApi);
1383
1376
  }
1384
1377
  catch (e) {
1385
1378
  console.error(e);
@@ -1405,21 +1398,25 @@ class DateCountdown {
1405
1398
  get isLayerForcePaused() {
1406
1399
  return false;
1407
1400
  }
1408
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `Array`, `typeof WidgetDateCountdown.api`]; }
1401
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `Array`, `typeof WidgetDateCountdown.api`, `OnWidgetComplete`, `SDKApi`]; }
1409
1402
  }
1410
1403
 
1411
1404
  class Poll {
1412
1405
  _elementNodeRef;
1413
1406
  _layer;
1414
1407
  _widgetApi;
1408
+ _onWidgetComplete;
1409
+ sdkApi;
1415
1410
  static _className = "narrative-element-poll";
1416
1411
  static className() {
1417
1412
  return Poll._className;
1418
1413
  }
1419
- constructor(_elementNodeRef, _layer, _widgetApi) {
1414
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1420
1415
  this._elementNodeRef = _elementNodeRef;
1421
1416
  this._layer = _layer;
1422
1417
  this._widgetApi = _widgetApi;
1418
+ this._onWidgetComplete = _onWidgetComplete;
1419
+ this.sdkApi = sdkApi;
1423
1420
  }
1424
1421
  static isTypeOf(element) {
1425
1422
  return element instanceof Poll;
@@ -1427,7 +1424,7 @@ class Poll {
1427
1424
  mediaElementsLoadingPromises = [];
1428
1425
  init(localData) {
1429
1426
  try {
1430
- this._widgetApi.init(this._elementNodeRef, localData);
1427
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1431
1428
  }
1432
1429
  catch (e) {
1433
1430
  console.error(e);
@@ -1452,7 +1449,7 @@ class Poll {
1452
1449
  get isLayerForcePaused() {
1453
1450
  return false;
1454
1451
  }
1455
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetPoll.api`]; }
1452
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetPoll.api`, `OnWidgetComplete`, `SDKApi`]; }
1456
1453
  }
1457
1454
 
1458
1455
  class PollLayers {
@@ -1460,15 +1457,19 @@ class PollLayers {
1460
1457
  _layer;
1461
1458
  _layersNodesRefs;
1462
1459
  _widgetApi;
1460
+ _onWidgetComplete;
1461
+ sdkApi;
1463
1462
  static _className = "narrative-element-poll-layers";
1464
1463
  static className() {
1465
1464
  return PollLayers._className;
1466
1465
  }
1467
- constructor(_elementNodeRef, _layer, _layersNodesRefs, _widgetApi) {
1466
+ constructor(_elementNodeRef, _layer, _layersNodesRefs, _widgetApi, _onWidgetComplete, sdkApi) {
1468
1467
  this._elementNodeRef = _elementNodeRef;
1469
1468
  this._layer = _layer;
1470
1469
  this._layersNodesRefs = _layersNodesRefs;
1471
1470
  this._widgetApi = _widgetApi;
1471
+ this._onWidgetComplete = _onWidgetComplete;
1472
+ this.sdkApi = sdkApi;
1472
1473
  }
1473
1474
  static isTypeOf(element) {
1474
1475
  return element instanceof PollLayers;
@@ -1476,7 +1477,7 @@ class PollLayers {
1476
1477
  mediaElementsLoadingPromises = [];
1477
1478
  init(localData) {
1478
1479
  try {
1479
- this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData);
1480
+ this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._onWidgetComplete, this.sdkApi);
1480
1481
  }
1481
1482
  catch (e) {
1482
1483
  console.error(e);
@@ -1498,21 +1499,25 @@ class PollLayers {
1498
1499
  get isLayerForcePaused() {
1499
1500
  return false;
1500
1501
  }
1501
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `Array`, `typeof WidgetPollLayers.api`]; }
1502
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `Array`, `typeof WidgetPollLayers.api`, `OnWidgetComplete`, `SDKApi`]; }
1502
1503
  }
1503
1504
 
1504
1505
  class Products {
1505
1506
  _elementNodeRef;
1506
1507
  _layer;
1507
1508
  _widgetApi;
1509
+ _onWidgetComplete;
1510
+ sdkApi;
1508
1511
  static _className = "narrative-element-products";
1509
1512
  static className() {
1510
1513
  return Products._className;
1511
1514
  }
1512
- constructor(_elementNodeRef, _layer, _widgetApi) {
1515
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1513
1516
  this._elementNodeRef = _elementNodeRef;
1514
1517
  this._layer = _layer;
1515
1518
  this._widgetApi = _widgetApi;
1519
+ this._onWidgetComplete = _onWidgetComplete;
1520
+ this.sdkApi = sdkApi;
1516
1521
  }
1517
1522
  static isTypeOf(element) {
1518
1523
  return element instanceof Products;
@@ -1520,7 +1525,7 @@ class Products {
1520
1525
  mediaElementsLoadingPromises = [];
1521
1526
  init(localData) {
1522
1527
  try {
1523
- this._widgetApi.init(this._elementNodeRef, localData);
1528
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1524
1529
  }
1525
1530
  catch (e) {
1526
1531
  console.error(e);
@@ -1551,28 +1556,32 @@ class Products {
1551
1556
  get isLayerForcePaused() {
1552
1557
  return this._widgetApi.isForcePaused(this._elementNodeRef);
1553
1558
  }
1554
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetProducts.api`]; }
1559
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetProducts.api`, `OnWidgetComplete`, `SDKApi`]; }
1555
1560
  }
1556
1561
 
1557
1562
  class Quest {
1558
1563
  _elementNodeRef;
1559
1564
  _layer;
1560
1565
  _widgetApi;
1566
+ _onWidgetComplete;
1567
+ sdkApi;
1561
1568
  static _className = "narrative-element-quest";
1562
1569
  static className() {
1563
1570
  return Quest._className;
1564
1571
  }
1565
- constructor(_elementNodeRef, _layer, _widgetApi) {
1572
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1566
1573
  this._elementNodeRef = _elementNodeRef;
1567
1574
  this._layer = _layer;
1568
1575
  this._widgetApi = _widgetApi;
1576
+ this._onWidgetComplete = _onWidgetComplete;
1577
+ this.sdkApi = sdkApi;
1569
1578
  }
1570
1579
  static isTypeOf(element) {
1571
1580
  return element instanceof Quest;
1572
1581
  }
1573
1582
  mediaElementsLoadingPromises = [];
1574
1583
  init(localData) {
1575
- return this._widgetApi.init(this._elementNodeRef, localData);
1584
+ return this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1576
1585
  }
1577
1586
  onPause() { }
1578
1587
  onResume() { }
@@ -1592,22 +1601,26 @@ class Quest {
1592
1601
  get isLayerForcePaused() {
1593
1602
  return false;
1594
1603
  }
1595
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetQuest.api`]; }
1604
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetQuest.api`, `OnWidgetComplete`, `SDKApi`]; }
1596
1605
  }
1597
1606
 
1598
1607
  class Quiz {
1599
1608
  _elementNodeRef;
1600
1609
  _layer;
1601
1610
  _widgetApi;
1611
+ _onWidgetComplete;
1612
+ sdkApi;
1602
1613
  static _className = "narrative-element-quiz";
1603
1614
  static className() {
1604
1615
  return Quiz._className;
1605
1616
  }
1606
1617
  // widgetApi in ctor
1607
- constructor(_elementNodeRef, _layer, _widgetApi) {
1618
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1608
1619
  this._elementNodeRef = _elementNodeRef;
1609
1620
  this._layer = _layer;
1610
1621
  this._widgetApi = _widgetApi;
1622
+ this._onWidgetComplete = _onWidgetComplete;
1623
+ this.sdkApi = sdkApi;
1611
1624
  }
1612
1625
  static isTypeOf(element) {
1613
1626
  return element instanceof Quiz;
@@ -1615,7 +1628,7 @@ class Quiz {
1615
1628
  mediaElementsLoadingPromises = [];
1616
1629
  init(localData) {
1617
1630
  try {
1618
- this._widgetApi.init(this._elementNodeRef, localData);
1631
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1619
1632
  }
1620
1633
  catch (e) {
1621
1634
  console.error(e);
@@ -1640,21 +1653,25 @@ class Quiz {
1640
1653
  get isLayerForcePaused() {
1641
1654
  return false;
1642
1655
  }
1643
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetQuiz.api`]; }
1656
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetQuiz.api`, `OnWidgetComplete`, `SDKApi`]; }
1644
1657
  }
1645
1658
 
1646
1659
  class QuizGrouped {
1647
1660
  _elementNodeRef;
1648
1661
  _layer;
1649
1662
  _widgetApi;
1663
+ _onWidgetComplete;
1664
+ sdkApi;
1650
1665
  static _className = "narrative-element-quiz-grouped";
1651
1666
  static className() {
1652
1667
  return QuizGrouped._className;
1653
1668
  }
1654
- constructor(_elementNodeRef, _layer, _widgetApi) {
1669
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1655
1670
  this._elementNodeRef = _elementNodeRef;
1656
1671
  this._layer = _layer;
1657
1672
  this._widgetApi = _widgetApi;
1673
+ this._onWidgetComplete = _onWidgetComplete;
1674
+ this.sdkApi = sdkApi;
1658
1675
  }
1659
1676
  static isTypeOf(element) {
1660
1677
  return element instanceof QuizGrouped;
@@ -1662,7 +1679,7 @@ class QuizGrouped {
1662
1679
  mediaElementsLoadingPromises = [];
1663
1680
  init(localData) {
1664
1681
  try {
1665
- this._widgetApi.init(this._elementNodeRef, localData);
1682
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1666
1683
  }
1667
1684
  catch (e) {
1668
1685
  console.error(e);
@@ -1687,21 +1704,25 @@ class QuizGrouped {
1687
1704
  get isLayerForcePaused() {
1688
1705
  return false;
1689
1706
  }
1690
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetQuizGrouped.api`]; }
1707
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetQuizGrouped.api`, `OnWidgetComplete`, `SDKApi`]; }
1691
1708
  }
1692
1709
 
1693
1710
  class RangeSlider {
1694
1711
  _elementNodeRef;
1695
1712
  _layer;
1696
1713
  _widgetApi;
1714
+ _onWidgetComplete;
1715
+ sdkApi;
1697
1716
  static _className = "narrative-element-range-slider";
1698
1717
  static className() {
1699
1718
  return RangeSlider._className;
1700
1719
  }
1701
- constructor(_elementNodeRef, _layer, _widgetApi) {
1720
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1702
1721
  this._elementNodeRef = _elementNodeRef;
1703
1722
  this._layer = _layer;
1704
1723
  this._widgetApi = _widgetApi;
1724
+ this._onWidgetComplete = _onWidgetComplete;
1725
+ this.sdkApi = sdkApi;
1705
1726
  }
1706
1727
  static isTypeOf(element) {
1707
1728
  return element instanceof RangeSlider;
@@ -1709,7 +1730,7 @@ class RangeSlider {
1709
1730
  mediaElementsLoadingPromises = [];
1710
1731
  init(localData) {
1711
1732
  try {
1712
- this._widgetApi.init(this._elementNodeRef, localData);
1733
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1713
1734
  }
1714
1735
  catch (e) {
1715
1736
  console.error(e);
@@ -1734,21 +1755,25 @@ class RangeSlider {
1734
1755
  get isLayerForcePaused() {
1735
1756
  return false;
1736
1757
  }
1737
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetRangeSlider.api`]; }
1758
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetRangeSlider.api`, `OnWidgetComplete`, `SDKApi`]; }
1738
1759
  }
1739
1760
 
1740
1761
  class Rate {
1741
1762
  _elementNodeRef;
1742
1763
  _layer;
1743
1764
  _widgetApi;
1765
+ _onWidgetComplete;
1766
+ sdkApi;
1744
1767
  static _className = "narrative-element-rate";
1745
1768
  static className() {
1746
1769
  return Rate._className;
1747
1770
  }
1748
- constructor(_elementNodeRef, _layer, _widgetApi) {
1771
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1749
1772
  this._elementNodeRef = _elementNodeRef;
1750
1773
  this._layer = _layer;
1751
1774
  this._widgetApi = _widgetApi;
1775
+ this._onWidgetComplete = _onWidgetComplete;
1776
+ this.sdkApi = sdkApi;
1752
1777
  }
1753
1778
  static isTypeOf(element) {
1754
1779
  return element instanceof Rate;
@@ -1756,7 +1781,7 @@ class Rate {
1756
1781
  mediaElementsLoadingPromises = [];
1757
1782
  init(localData) {
1758
1783
  try {
1759
- this._widgetApi.init(this._elementNodeRef, localData);
1784
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1760
1785
  }
1761
1786
  catch (e) {
1762
1787
  console.error(e);
@@ -1781,7 +1806,7 @@ class Rate {
1781
1806
  get isLayerForcePaused() {
1782
1807
  return false;
1783
1808
  }
1784
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetRate.api`]; }
1809
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetRate.api`, `OnWidgetComplete`, `SDKApi`]; }
1785
1810
  }
1786
1811
 
1787
1812
  class Share {
@@ -1789,16 +1814,20 @@ class Share {
1789
1814
  _layer;
1790
1815
  _layersNodesRefs;
1791
1816
  _widgetApi;
1817
+ _onWidgetComplete;
1818
+ sdkApi;
1792
1819
  static _className = "narrative-element-share";
1793
1820
  static _widgetApiName = "_narrative_share";
1794
1821
  static className() {
1795
1822
  return Share._className;
1796
1823
  }
1797
- constructor(_elementNodeRef, _layer, _layersNodesRefs, _widgetApi) {
1824
+ constructor(_elementNodeRef, _layer, _layersNodesRefs, _widgetApi, _onWidgetComplete, sdkApi) {
1798
1825
  this._elementNodeRef = _elementNodeRef;
1799
1826
  this._layer = _layer;
1800
1827
  this._layersNodesRefs = _layersNodesRefs;
1801
1828
  this._widgetApi = _widgetApi;
1829
+ this._onWidgetComplete = _onWidgetComplete;
1830
+ this.sdkApi = sdkApi;
1802
1831
  }
1803
1832
  static isTypeOf(element) {
1804
1833
  return element instanceof Share;
@@ -1806,7 +1835,7 @@ class Share {
1806
1835
  mediaElementsLoadingPromises = [];
1807
1836
  init(localData) {
1808
1837
  try {
1809
- this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData);
1838
+ this._widgetApi.init(this._elementNodeRef, this._layersNodesRefs, localData, this._onWidgetComplete, this.sdkApi);
1810
1839
  }
1811
1840
  catch (e) {
1812
1841
  console.error(e);
@@ -1831,7 +1860,7 @@ class Share {
1831
1860
  get isLayerForcePaused() {
1832
1861
  return false;
1833
1862
  }
1834
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `Array`, `typeof WidgetShare.api`]; }
1863
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `Array`, `typeof WidgetShare.api`, `OnWidgetComplete`, `SDKApi`]; }
1835
1864
  }
1836
1865
 
1837
1866
  class SwipeUpItems {
@@ -1873,14 +1902,18 @@ class Test {
1873
1902
  _elementNodeRef;
1874
1903
  _layer;
1875
1904
  _widgetApi;
1905
+ _onWidgetComplete;
1906
+ sdkApi;
1876
1907
  static _className = "narrative-element-test";
1877
1908
  static className() {
1878
1909
  return Test._className;
1879
1910
  }
1880
- constructor(_elementNodeRef, _layer, _widgetApi) {
1911
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1881
1912
  this._elementNodeRef = _elementNodeRef;
1882
1913
  this._layer = _layer;
1883
1914
  this._widgetApi = _widgetApi;
1915
+ this._onWidgetComplete = _onWidgetComplete;
1916
+ this.sdkApi = sdkApi;
1884
1917
  }
1885
1918
  static isTypeOf(element) {
1886
1919
  return element instanceof Test;
@@ -1888,7 +1921,7 @@ class Test {
1888
1921
  mediaElementsLoadingPromises = [];
1889
1922
  init(localData) {
1890
1923
  try {
1891
- this._widgetApi.init(this._elementNodeRef, localData);
1924
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1892
1925
  }
1893
1926
  catch (e) {
1894
1927
  console.error(e);
@@ -1916,26 +1949,30 @@ class Test {
1916
1949
  get isLayerForcePaused() {
1917
1950
  return false;
1918
1951
  }
1919
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetTest.api`]; }
1952
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetTest.api`, `OnWidgetComplete`, `SDKApi`]; }
1920
1953
  }
1921
1954
 
1922
1955
  class Vote {
1923
1956
  _elementNodeRef;
1924
1957
  _layer;
1925
1958
  _widgetApi;
1959
+ _onWidgetComplete;
1960
+ sdkApi;
1926
1961
  static _className = "narrative-element-vote";
1927
1962
  static className() {
1928
1963
  return Vote._className;
1929
1964
  }
1930
- constructor(_elementNodeRef, _layer, _widgetApi) {
1965
+ constructor(_elementNodeRef, _layer, _widgetApi, _onWidgetComplete, sdkApi) {
1931
1966
  this._elementNodeRef = _elementNodeRef;
1932
1967
  this._layer = _layer;
1933
1968
  this._widgetApi = _widgetApi;
1969
+ this._onWidgetComplete = _onWidgetComplete;
1970
+ this.sdkApi = sdkApi;
1934
1971
  }
1935
1972
  mediaElementsLoadingPromises = [];
1936
1973
  init(localData) {
1937
1974
  try {
1938
- this._widgetApi.init(this._elementNodeRef, localData);
1975
+ this._widgetApi.init(this._elementNodeRef, localData, this._onWidgetComplete, this.sdkApi);
1939
1976
  }
1940
1977
  catch (e) {
1941
1978
  console.error(e);
@@ -1957,7 +1994,7 @@ class Vote {
1957
1994
  get isLayerForcePaused() {
1958
1995
  return false;
1959
1996
  }
1960
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetVote.api`]; }
1997
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Layer`, `typeof WidgetVote.api`, `OnWidgetComplete`, `SDKApi`]; }
1961
1998
  }
1962
1999
 
1963
2000
  class Text {
@@ -1992,28 +2029,71 @@ class Text {
1992
2029
  const waitForImageHtmlElementLoad = async (nodeRef) => {
1993
2030
  return new Promise((resolve, reject) => {
1994
2031
  const onLoad = function () {
1995
- requestAnimationFrame(() => requestAnimationFrame(() => {
1996
- resolve(nodeRef);
1997
- nodeRef.removeEventListener("load", onLoad);
1998
- }));
1999
- };
2000
- nodeRef.addEventListener("load", onLoad);
2001
- if (nodeRef.complete && 0 !== nodeRef.naturalHeight) {
2002
- requestAnimationFrame(() => {
2032
+ // this is already in HTML markup
2033
+ // nodeRef.decoding = "sync";
2034
+ if (nodeRef.decode != null) {
2035
+ // requestAnimationFrame(() =>
2003
2036
  requestAnimationFrame(() => {
2004
- resolve(nodeRef);
2037
+ nodeRef.decode().then(() => {
2038
+ // @ts-ignore
2039
+ // _log("img loaded 1", true);
2040
+ resolve(nodeRef);
2041
+ nodeRef.removeEventListener("load", onLoad);
2042
+ }, reason => reject(reason));
2005
2043
  });
2006
- });
2007
- }
2044
+ // );
2045
+ }
2046
+ else {
2047
+ requestAnimationFrame(() => requestAnimationFrame(() => {
2048
+ // @ts-ignore
2049
+ // _log("img loaded 1", true);
2050
+ resolve(nodeRef);
2051
+ nodeRef.removeEventListener("load", onLoad);
2052
+ }));
2053
+ }
2054
+ };
2055
+ nodeRef.addEventListener("load", onLoad);
2056
+ // if (nodeRef.complete && 0 !== nodeRef.naturalHeight) {
2057
+ // requestAnimationFrame(() => {
2058
+ // requestAnimationFrame(() => {
2059
+ // // @ts-ignore
2060
+ // _log("img loaded 2", true)
2061
+ // resolve(nodeRef);
2062
+ // });
2063
+ // });
2064
+ // }
2008
2065
  nodeRef.addEventListener("error", err => reject(err));
2009
2066
  });
2010
2067
  };
2068
+ // export const waitForImageHtmlElementLoad = async (nodeRef: HTMLImageElement): Promise<HTMLImageElement> => {
2069
+ // return new Promise((resolve, reject) => {
2070
+ // const onLoad = function () {
2071
+ // requestAnimationFrame(() =>
2072
+ // requestAnimationFrame(() => {
2073
+ // resolve(nodeRef);
2074
+ // nodeRef.removeEventListener("load", onLoad);
2075
+ // })
2076
+ // );
2077
+ // };
2078
+ // nodeRef.addEventListener("load", onLoad);
2079
+ // if (nodeRef.complete && 0 !== nodeRef.naturalHeight) {
2080
+ // requestAnimationFrame(() => {
2081
+ // requestAnimationFrame(() => {
2082
+ // resolve(nodeRef);
2083
+ // });
2084
+ // });
2085
+ // }
2086
+ // nodeRef.addEventListener("error", err => reject(err));
2087
+ // });
2088
+ // };
2011
2089
  const waitForVideoHtmlElementLoad = async (nodeRef) => {
2012
2090
  return new Promise((resolve, reject) => {
2013
2091
  if (void 0 !== nodeRef.oncanplaythrough) {
2014
2092
  const onCanplaythrough = () => {
2015
2093
  requestAnimationFrame(() => {
2016
2094
  requestAnimationFrame(() => {
2095
+ // @ts-ignore
2096
+ // _log("video loaded 1", true)
2017
2097
  resolve(nodeRef);
2018
2098
  nodeRef.removeEventListener("canplaythrough", onCanplaythrough);
2019
2099
  });
@@ -2026,6 +2106,8 @@ const waitForVideoHtmlElementLoad = async (nodeRef) => {
2026
2106
  var onCanPlay = function () {
2027
2107
  requestAnimationFrame(() => {
2028
2108
  requestAnimationFrame(() => {
2109
+ // @ts-ignore
2110
+ // _log("video loaded 2", true)
2029
2111
  resolve(nodeRef);
2030
2112
  nodeRef.removeEventListener("canplay", onCanPlay);
2031
2113
  });
@@ -2193,6 +2275,8 @@ class Video {
2193
2275
  onStop() { }
2194
2276
  onBeforeUnmount() {
2195
2277
  // clean up memory and cpu processes
2278
+ // @ts-ignore
2279
+ // _log("onBeforeUnmount", true)
2196
2280
  this._destroyVODPlayer();
2197
2281
  }
2198
2282
  _initVOD(vodData) {
@@ -2267,6 +2351,8 @@ class Video {
2267
2351
  // console.log("_initVOD 5");
2268
2352
  this._vodPlayerInstance = player;
2269
2353
  // This runs if the asynchronous load is successful.
2354
+ // @ts-ignore
2355
+ _log("vod loaded 1", true);
2270
2356
  resolve(this._video);
2271
2357
  })
2272
2358
  .catch(reason => {
@@ -2291,6 +2377,8 @@ class Video {
2291
2377
  if (vodData && vodData.formats != null && Array.isArray(vodData.formats) && vodData.formats.length > 0) {
2292
2378
  src = vodData.formats[0].url;
2293
2379
  this._video.src = src;
2380
+ // @ts-ignore
2381
+ // _log("vod loaded 2", true)
2294
2382
  resolve(this._video);
2295
2383
  }
2296
2384
  else {
@@ -2313,6 +2401,8 @@ class Video {
2313
2401
  return mpd_;
2314
2402
  }
2315
2403
  async _destroyVODPlayer() {
2404
+ //@ts-ignore
2405
+ // _log("call _destroyVODPlayer", true)
2316
2406
  if (this._vodPlayerInstance != null) {
2317
2407
  try {
2318
2408
  if (this._videoStateAdapter) {
@@ -2615,7 +2705,7 @@ class VideoStateAdapter {
2615
2705
  // _log(`_onPlaying, _timeupdate: ${this._timeupdate}`, true);
2616
2706
  this._playingCheckerId = window.setTimeout(() => {
2617
2707
  // @ts-ignore
2618
- _log(`_onPlaying cb, _timeupdate: ${this._timeupdate}, now: ${Date.now()}, diff: ${Date.now() - this._timeupdate}`, true);
2708
+ // _log(`_onPlaying cb, _timeupdate: ${this._timeupdate}, now: ${Date.now()}, diff: ${Date.now() - this._timeupdate}`, true);
2619
2709
  if (Date.now() - this._timeupdate <= this._maxDiff / 2) {
2620
2710
  // @ts-ignore
2621
2711
  // _log(`_onPlaying if`, true);
@@ -2662,7 +2752,7 @@ class VideoStateAdapter {
2662
2752
  // const
2663
2753
  // }
2664
2754
  // args nodeRef, elementClassName
2665
- const tryCreateFromHtmlElement = (nodeRef, layer) => {
2755
+ const tryCreateFromHtmlElement = (nodeRef, layer, onWidgetComplete, sdkApi) => {
2666
2756
  const layoutApi = layer.layoutService.layoutApi;
2667
2757
  const layersNodesRefs = layer.slide.layersNodesRefs;
2668
2758
  for (let elementClassName of nodeRef.classList.values()) {
@@ -2680,38 +2770,42 @@ const tryCreateFromHtmlElement = (nodeRef, layer) => {
2680
2770
  case SwipeUpItems.className():
2681
2771
  return new SwipeUpItems(nodeRef, layer);
2682
2772
  case Video.className():
2683
- return new Video(nodeRef, layer, layoutApi.VideoPlayer, layer.layoutService.sdkApi);
2773
+ return new Video(nodeRef, layer, layoutApi.VideoPlayer, layer.sdkApi);
2684
2774
  //////// widgets ///////
2685
2775
  case Copy.className():
2686
- return layoutApi.widgetCopyApi ? new Copy(nodeRef, layer, layoutApi.widgetCopyApi) : null;
2776
+ return layoutApi.widgetCopyApi ? new Copy(nodeRef, layer, layoutApi.widgetCopyApi, onWidgetComplete, sdkApi) : null;
2687
2777
  case Barcode.className():
2688
- return layoutApi.widgetBarcodeApi ? new Barcode(nodeRef, layer, layoutApi.widgetBarcodeApi) : null;
2778
+ return layoutApi.widgetBarcodeApi ? new Barcode(nodeRef, layer, layoutApi.widgetBarcodeApi, onWidgetComplete, sdkApi) : null;
2689
2779
  case DataInput.className():
2690
- return layoutApi.widgetDataInputApi ? new DataInput(nodeRef, layer, layoutApi.widgetDataInputApi) : null;
2780
+ return layoutApi.widgetDataInputApi ? new DataInput(nodeRef, layer, layoutApi.widgetDataInputApi, onWidgetComplete, sdkApi) : null;
2691
2781
  case DateCountdown.className():
2692
- return layoutApi.widgetDateCountdownApi ? new DateCountdown(nodeRef, layer, layersNodesRefs, layoutApi.widgetDateCountdownApi) : null;
2782
+ return layoutApi.widgetDateCountdownApi
2783
+ ? new DateCountdown(nodeRef, layer, layersNodesRefs, layoutApi.widgetDateCountdownApi, onWidgetComplete, sdkApi)
2784
+ : null;
2693
2785
  case Poll.className():
2694
- return layoutApi.widgetPollApi ? new Poll(nodeRef, layer, layoutApi.widgetPollApi) : null;
2786
+ return layoutApi.widgetPollApi ? new Poll(nodeRef, layer, layoutApi.widgetPollApi, onWidgetComplete, sdkApi) : null;
2695
2787
  case PollLayers.className():
2696
- return layoutApi.widgetPollLayersApi ? new PollLayers(nodeRef, layer, layersNodesRefs, layoutApi.widgetPollLayersApi) : null;
2788
+ return layoutApi.widgetPollLayersApi
2789
+ ? new PollLayers(nodeRef, layer, layersNodesRefs, layoutApi.widgetPollLayersApi, onWidgetComplete, sdkApi)
2790
+ : null;
2697
2791
  case Quest.className():
2698
- return layoutApi.widgetQuestApi ? new Quest(nodeRef, layer, layoutApi.widgetQuestApi) : null;
2792
+ return layoutApi.widgetQuestApi ? new Quest(nodeRef, layer, layoutApi.widgetQuestApi, onWidgetComplete, sdkApi) : null;
2699
2793
  case Quiz.className():
2700
- return layoutApi.widgetQuizApi ? new Quiz(nodeRef, layer, layoutApi.widgetQuizApi) : null;
2794
+ return layoutApi.widgetQuizApi ? new Quiz(nodeRef, layer, layoutApi.widgetQuizApi, onWidgetComplete, sdkApi) : null;
2701
2795
  case QuizGrouped.className():
2702
- return layoutApi.widgetQuizGroupedApi ? new QuizGrouped(nodeRef, layer, layoutApi.widgetQuizGroupedApi) : null;
2796
+ return layoutApi.widgetQuizGroupedApi ? new QuizGrouped(nodeRef, layer, layoutApi.widgetQuizGroupedApi, onWidgetComplete, sdkApi) : null;
2703
2797
  case RangeSlider.className():
2704
- return layoutApi.widgetRangeSliderApi ? new RangeSlider(nodeRef, layer, layoutApi.widgetRangeSliderApi) : null;
2798
+ return layoutApi.widgetRangeSliderApi ? new RangeSlider(nodeRef, layer, layoutApi.widgetRangeSliderApi, onWidgetComplete, sdkApi) : null;
2705
2799
  case Rate.className():
2706
- return layoutApi.widgetRateApi ? new Rate(nodeRef, layer, layoutApi.widgetRateApi) : null;
2800
+ return layoutApi.widgetRateApi ? new Rate(nodeRef, layer, layoutApi.widgetRateApi, onWidgetComplete, sdkApi) : null;
2707
2801
  case Share.className():
2708
- return layoutApi.widgetShareApi ? new Share(nodeRef, layer, layersNodesRefs, layoutApi.widgetShareApi) : null;
2802
+ return layoutApi.widgetShareApi ? new Share(nodeRef, layer, layersNodesRefs, layoutApi.widgetShareApi, onWidgetComplete, sdkApi) : null;
2709
2803
  case Test.className():
2710
- return layoutApi.widgetTestApi ? new Test(nodeRef, layer, layoutApi.widgetTestApi) : null;
2804
+ return layoutApi.widgetTestApi ? new Test(nodeRef, layer, layoutApi.widgetTestApi, onWidgetComplete, sdkApi) : null;
2711
2805
  case Vote.className():
2712
- return layoutApi.widgetVoteApi ? new Vote(nodeRef, layer, layoutApi.widgetVoteApi) : null;
2806
+ return layoutApi.widgetVoteApi ? new Vote(nodeRef, layer, layoutApi.widgetVoteApi, onWidgetComplete, sdkApi) : null;
2713
2807
  case Products.className():
2714
- return layoutApi.widgetProductsApi ? new Products(nodeRef, layer, layoutApi.widgetProductsApi) : null;
2808
+ return layoutApi.widgetProductsApi ? new Products(nodeRef, layer, layoutApi.widgetProductsApi, onWidgetComplete, sdkApi) : null;
2715
2809
  }
2716
2810
  }
2717
2811
  return null;
@@ -2722,18 +2816,24 @@ var TimelineDisabledState;
2722
2816
  TimelineDisabledState[TimelineDisabledState["disabled"] = 0] = "disabled";
2723
2817
  TimelineDisabledState[TimelineDisabledState["enabled"] = 1] = "enabled";
2724
2818
  })(TimelineDisabledState || (TimelineDisabledState = {}));
2819
+ // use Promise
2820
+ // await Promise()
2821
+ // call timeLine api
2822
+ // promise - slideReadyPromise
2725
2823
  class SlideTimeline {
2726
2824
  slideIndex;
2727
2825
  slideDuration;
2728
2826
  slideDisabledTimer;
2729
2827
  slideReady;
2730
2828
  _afterResumeQueuePush;
2731
- constructor(slideIndex, slideDuration, slideDisabledTimer, slideReady, _afterResumeQueuePush) {
2829
+ sdkApi;
2830
+ constructor(slideIndex, slideDuration, slideDisabledTimer, slideReady, _afterResumeQueuePush, sdkApi) {
2732
2831
  this.slideIndex = slideIndex;
2733
2832
  this.slideDuration = slideDuration;
2734
2833
  this.slideDisabledTimer = slideDisabledTimer;
2735
2834
  this.slideReady = slideReady;
2736
2835
  this._afterResumeQueuePush = _afterResumeQueuePush;
2836
+ this.sdkApi = sdkApi;
2737
2837
  this.timelineDisabledState = this.slideDisabledTimer ? TimelineDisabledState.disabled : TimelineDisabledState.enabled;
2738
2838
  }
2739
2839
  resumedAt = new Date().getTime();
@@ -2747,17 +2847,23 @@ class SlideTimeline {
2747
2847
  return SlideTimeline.layoutService;
2748
2848
  }
2749
2849
  get isSDKSupportUpdateTimeline() {
2750
- if (SlideTimeline.layoutService.sdkApi.isAndroid) {
2751
- return SlideTimeline.layoutService.env.Android && "updateTimeline" in SlideTimeline.layoutService.env.Android;
2850
+ if (this.sdkApi.isAndroid) {
2851
+ return Boolean(SlideTimeline.layoutService.env.Android && "updateTimeline" in SlideTimeline.layoutService.env.Android);
2752
2852
  }
2753
- else if (SlideTimeline.layoutService.sdkApi.isIOS) {
2853
+ else if (this.sdkApi.isIOS) {
2754
2854
  const mh = SlideTimeline.layoutService.env?.webkit?.messageHandlers ?? {};
2755
2855
  return "updateTimeline" in mh;
2756
2856
  }
2857
+ else if (this.sdkApi.isWeb) {
2858
+ return true;
2859
+ }
2757
2860
  else {
2758
2861
  return false;
2759
2862
  }
2760
2863
  }
2864
+ get isSdkSupportTimelineOnBeforeStart() {
2865
+ return this.sdkApi.isSdkSupportTimelineOnBeforeStart();
2866
+ }
2761
2867
  get index() {
2762
2868
  return this.slideIndex;
2763
2869
  }
@@ -2795,7 +2901,24 @@ class SlideTimeline {
2795
2901
  //@ts-ignore
2796
2902
  // window._log(`updateTimeline, a: ${action} ct: ${currentTime} d: ${duration} tds: ${this.timelineDisabledState}`, true);
2797
2903
  // console.trace(`updateTimeline ${action} slideIndex: ${this.slideIndex} currentTime:${currentTime} duration:${duration} tds: ${this.timelineDisabledState}`);
2798
- SlideTimeline.layoutService.sdkApi.updateTimeline(this.slideIndex, action, currentTime, duration, showLoader, showError);
2904
+ this.sdkApi.updateTimeline(this.slideIndex, action, currentTime, duration, showLoader, showError);
2905
+ }
2906
+ /**
2907
+ * trigger timeline update for new slide in sdk, before slide strat event (prevent timeout in timeline while we wait for video start)
2908
+ */
2909
+ triggerSlideLoadState() {
2910
+ if (this.isSDKSupportUpdateTimeline && this.isSdkSupportTimelineOnBeforeStart) {
2911
+ let duration = this.slideDuration;
2912
+ // tmp
2913
+ // todo брать из модели
2914
+ if (!duration) {
2915
+ duration = DEFAULT_SLIDE_DURATION;
2916
+ }
2917
+ if (this.timelineDisabledState === TimelineDisabledState.disabled) {
2918
+ duration = 0;
2919
+ }
2920
+ this.sdkApi.updateTimeline(this.slideIndex, "before_start" /* TIMELINE_ACTION.BEFORE_START */, 0, duration, false, false);
2921
+ }
2799
2922
  }
2800
2923
  /**
2801
2924
  * Start timeline after slide started
@@ -2834,7 +2957,7 @@ class SlideTimeline {
2834
2957
  this.updateTimeline("pause" /* TIMELINE_ACTION.PAUSE */);
2835
2958
  }
2836
2959
  else {
2837
- this.layoutService.sdkApi.cardPausedCallback(videoCurrentTime);
2960
+ this.sdkApi.cardPausedCallback(videoCurrentTime);
2838
2961
  }
2839
2962
  }
2840
2963
  slideResumed(videoCurrentTime) {
@@ -2849,7 +2972,7 @@ class SlideTimeline {
2849
2972
  this.updateTimeline("start" /* TIMELINE_ACTION.START */);
2850
2973
  }
2851
2974
  else {
2852
- this.layoutService.sdkApi.cardResumedCallback(videoCurrentTime);
2975
+ this.sdkApi.cardResumedCallback(videoCurrentTime);
2853
2976
  }
2854
2977
  }
2855
2978
  slideStopped() {
@@ -2906,7 +3029,7 @@ class SlideTimeline {
2906
3029
  }
2907
3030
  this.updateTimeline("stop" /* TIMELINE_ACTION.STOP */, false, true);
2908
3031
  }
2909
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`number`, `number`, `boolean`, `Promise`, `(cb: () => void) => void`]; }
3032
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`number`, `number`, `boolean`, `Promise`, `(cb: () => void) => void`, `SDKApi`]; }
2910
3033
  }
2911
3034
 
2912
3035
  class Layer {
@@ -2914,6 +3037,9 @@ class Layer {
2914
3037
  _slide;
2915
3038
  _slideReadyPromise;
2916
3039
  _afterResumeQueuePush;
3040
+ _afterStartInitQueuePush;
3041
+ _showNextSlide;
3042
+ sdkApi;
2917
3043
  _slideIndex;
2918
3044
  _cardId;
2919
3045
  _cardType;
@@ -2923,11 +3049,14 @@ class Layer {
2923
3049
  _disabledNavigation;
2924
3050
  _elements = [];
2925
3051
  _timeline;
2926
- constructor(_nodeRef, _slide, _slideReadyPromise, _afterResumeQueuePush) {
3052
+ constructor(_nodeRef, _slide, _slideReadyPromise, _afterResumeQueuePush, _afterStartInitQueuePush, _showNextSlide, sdkApi) {
2927
3053
  this._nodeRef = _nodeRef;
2928
3054
  this._slide = _slide;
2929
3055
  this._slideReadyPromise = _slideReadyPromise;
2930
3056
  this._afterResumeQueuePush = _afterResumeQueuePush;
3057
+ this._afterStartInitQueuePush = _afterStartInitQueuePush;
3058
+ this._showNextSlide = _showNextSlide;
3059
+ this.sdkApi = sdkApi;
2931
3060
  this._slideIndex = parseInt(this._nodeRef.getAttribute("data-index") ?? "0");
2932
3061
  this._cardId = parseInt(this._nodeRef.getAttribute("data-id") ?? "0");
2933
3062
  this._cardType = parseInt(this._nodeRef.getAttribute("data-card-type") ?? "1") || 1 /* CARD_TYPE.STORY */;
@@ -2935,11 +3064,19 @@ class Layer {
2935
3064
  this._duration = parseInt(this._nodeRef.getAttribute("data-duration") ?? "") || DEFAULT_SLIDE_DURATION;
2936
3065
  this._disabledTimer = this._nodeRef.getAttribute("data-disable-timer") === "1";
2937
3066
  this._disabledNavigation = this._nodeRef.getAttribute("data-disable-navigation") === "1";
2938
- this._timeline = new SlideTimeline(this._slideIndex, this._duration, this._disabledTimer, this._slideReadyPromise, this._afterResumeQueuePush);
3067
+ this._timeline = new SlideTimeline(this._slideIndex, this._duration, this._disabledTimer, this._slideReadyPromise, this._afterResumeQueuePush, this.sdkApi);
3068
+ const onWidgetComplete = (cardId, slideIndex) => {
3069
+ // todo if nothing more widgets with disabled timers - we can start layer timeline
3070
+ const fallback = () => this._showNextSlide(DEFAULT_SLIDE_DURATION);
3071
+ // для android sdk важно чтобы этот метод вызывался только после slide_start
3072
+ this._afterStartInitQueuePush(() => {
3073
+ this._timeline.startDisabledTimeline(fallback);
3074
+ });
3075
+ };
2939
3076
  const _elementsNodes = this._nodeRef.querySelectorAll(".narrative-slide-elements .narrative-element");
2940
3077
  let layerWithWidgetQuest = false;
2941
3078
  _elementsNodes.forEach(item => {
2942
- let element = tryCreateFromHtmlElement(item, this);
3079
+ let element = tryCreateFromHtmlElement(item, this, onWidgetComplete, this.sdkApi);
2943
3080
  if (element) {
2944
3081
  this._elements.push(element);
2945
3082
  if (element instanceof Quest) {
@@ -2954,7 +3091,7 @@ class Layer {
2954
3091
  * - then init WidgetQuest with layer instead of WidgetQuest element (required for WidgetQuest slides navigation)
2955
3092
  */
2956
3093
  if (this.isQuest && !layerWithWidgetQuest && this.layoutService.layoutApi.widgetQuestApi != null) {
2957
- this._elements.push(new Quest(this._nodeRef, this, this.layoutService.layoutApi.widgetQuestApi));
3094
+ this._elements.push(new Quest(this._nodeRef, this, this.layoutService.layoutApi.widgetQuestApi, onWidgetComplete, this.sdkApi));
2958
3095
  }
2959
3096
  }
2960
3097
  init(localData) {
@@ -2983,11 +3120,8 @@ class Layer {
2983
3120
  get layoutService() {
2984
3121
  return container.get({ identifier: "LayoutService" });
2985
3122
  }
2986
- get sdkApi() {
2987
- return container.get({ identifier: "SDKApi" });
2988
- }
2989
3123
  getLocalData() {
2990
- return this.layoutService.sdkApi.getCardLocalData();
3124
+ return this.sdkApi.getCardLocalData();
2991
3125
  }
2992
3126
  get isQuest() {
2993
3127
  return this._nodeRef.getAttribute("data-quest-count") != null;
@@ -3251,7 +3385,7 @@ class Layer {
3251
3385
  get isLayerForcePaused() {
3252
3386
  return this.elements.some(element => element.isLayerForcePaused);
3253
3387
  }
3254
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Slide`, `Promise`, `(cb: () => void) => void`]; }
3388
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Slide`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `(duration: number) => void`, `SDKApi`]; }
3255
3389
  }
3256
3390
  const TextFit = (function () {
3257
3391
  const defaultSettings = {
@@ -3425,17 +3559,23 @@ class Slide {
3425
3559
  _slidesNodesRefs;
3426
3560
  _slideReadyPromise;
3427
3561
  _afterResumeQueuePush;
3562
+ _afterStartInitQueuePush;
3563
+ _showNextSlide;
3564
+ sdkApi;
3428
3565
  _layers;
3429
3566
  _start;
3430
- constructor(_slidesNodesRefs, _slideReadyPromise, _afterResumeQueuePush) {
3567
+ constructor(_slidesNodesRefs, _slideReadyPromise, _afterResumeQueuePush, _afterStartInitQueuePush, _showNextSlide, sdkApi) {
3431
3568
  this._slidesNodesRefs = _slidesNodesRefs;
3432
3569
  this._slideReadyPromise = _slideReadyPromise;
3433
3570
  this._afterResumeQueuePush = _afterResumeQueuePush;
3571
+ this._afterStartInitQueuePush = _afterStartInitQueuePush;
3572
+ this._showNextSlide = _showNextSlide;
3573
+ this.sdkApi = sdkApi;
3434
3574
  this._start = window.performance.now();
3435
3575
  if (!this._slidesNodesRefs.length) {
3436
3576
  throw new Error("No slides found.");
3437
3577
  }
3438
- this._layers = this._slidesNodesRefs.map(item => new Layer(item, this, this._slideReadyPromise, this._afterResumeQueuePush));
3578
+ this._layers = this._slidesNodesRefs.map(item => new Layer(item, this, this._slideReadyPromise, this._afterResumeQueuePush, this._afterStartInitQueuePush, this._showNextSlide, this.sdkApi));
3439
3579
  this._activeLayer = this._layers[0];
3440
3580
  }
3441
3581
  _activeLayer;
@@ -3454,7 +3594,7 @@ class Slide {
3454
3594
  const multiSlideApi = this.layoutService.layoutApi.widgetMultiSlideApi;
3455
3595
  if (multiSlideApi != null && this.layers.length > 1) {
3456
3596
  try {
3457
- multiSlideApi.init(this.layersNodesRefs, localData);
3597
+ multiSlideApi.init(this.layersNodesRefs, localData, this.sdkApi);
3458
3598
  }
3459
3599
  catch (e) {
3460
3600
  console.error(e);
@@ -3526,7 +3666,7 @@ class Slide {
3526
3666
  get disabledNavigation() {
3527
3667
  return this._activeLayer.disabledNavigation;
3528
3668
  }
3529
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`Array`, `Promise`, `(cb: () => void) => void`]; }
3669
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`Array`, `Promise`, `(cb: () => void) => void`, `(cb: () => void) => void`, `(duration: number) => void`, `SDKApi`]; }
3530
3670
  }
3531
3671
 
3532
3672
  let SlideApi$1 = class SlideApi {
@@ -3539,10 +3679,18 @@ let SlideApi$1 = class SlideApi {
3539
3679
  static prerenderBoxClassName = "narrative-slide-box-prerender";
3540
3680
  _slideWrapper;
3541
3681
  _viewport;
3682
+ _getViewportWidth;
3683
+ _getViewportHeight;
3684
+ _overlappingActionBarHeight;
3685
+ sdkApi;
3542
3686
  constructor(config) {
3543
3687
  this.config = config;
3688
+ this.sdkApi = config.sdkApi;
3544
3689
  this._slideWrapper = config.slideWrapper;
3545
3690
  this._viewport = config.viewport;
3691
+ this._getViewportWidth = config.getViewportWidth;
3692
+ this._getViewportHeight = config.getViewportHeight;
3693
+ this._overlappingActionBarHeight = config.overlappingActionBarHeight ?? 0;
3546
3694
  this.refreshSizes = proxy(this.refreshSizes, this);
3547
3695
  this.initListeners();
3548
3696
  this.refreshSizes();
@@ -3572,10 +3720,8 @@ let SlideApi$1 = class SlideApi {
3572
3720
  this._viewport.removeEventListener("resize", this.refreshSizes);
3573
3721
  }
3574
3722
  refreshSizes() {
3575
- // const viewportWidth = getViewportWidth(this._viewport);
3576
- const viewportWidth = this._slideWrapper.clientWidth;
3577
- // const viewportHeight = getViewportHeight(this._viewport);
3578
- const viewportHeight = this._slideWrapper.clientHeight;
3723
+ const viewportWidth = this._getViewportWidth();
3724
+ const viewportHeight = this._getViewportHeight();
3579
3725
  const viewportRatio = viewportWidth / viewportHeight;
3580
3726
  let slideWidth = 0;
3581
3727
  let slideHeight = 0;
@@ -3601,7 +3747,7 @@ let SlideApi$1 = class SlideApi {
3601
3747
  slideOffset.style.margin = -1 * offset + "px" + " 0 ";
3602
3748
  }
3603
3749
  // offset from viewport bottom to StoryBottom plus safe area offset bottom
3604
- yOffset = `calc(${offset}px + env(safe-area-inset-bottom))`;
3750
+ yOffset = `calc(${offset + this._overlappingActionBarHeight}px + env(safe-area-inset-bottom))`;
3605
3751
  // detect safe area offset
3606
3752
  }
3607
3753
  else {
@@ -3614,7 +3760,7 @@ let SlideApi$1 = class SlideApi {
3614
3760
  if (slideOffset != null) {
3615
3761
  slideOffset.style.margin = -offset + "px" + " 0 ";
3616
3762
  }
3617
- yOffset = offset + "px";
3763
+ yOffset = offset + this._overlappingActionBarHeight + "px";
3618
3764
  }
3619
3765
  else {
3620
3766
  // вьюпорт более вытянутый чем надо
@@ -3639,7 +3785,6 @@ let SlideApi$1 = class SlideApi {
3639
3785
  if (_isFullscreen) {
3640
3786
  slideOffset?.classList.add("narrative-slide-offset-fullscreen");
3641
3787
  }
3642
- console.log({ fontSize, slideWidth });
3643
3788
  if (this.config.userResizeHandler != null) {
3644
3789
  this.config.userResizeHandler({ viewportWidth, viewportHeight, fontSize });
3645
3790
  }
@@ -3672,10 +3817,7 @@ let SlideApi$1 = class SlideApi {
3672
3817
  return container.get({ identifier: "LayoutService" });
3673
3818
  }
3674
3819
  getLocalData() {
3675
- return this.layoutService.sdkApi.getCardLocalData();
3676
- }
3677
- get sdkApi() {
3678
- return container.get({ identifier: "SDKApi" });
3820
+ return this.sdkApi.getCardLocalData();
3679
3821
  }
3680
3822
  _fontsInit = false;
3681
3823
  _initAndLoadFonts(fonts) {
@@ -3730,6 +3872,7 @@ let SlideApi$1 = class SlideApi {
3730
3872
  async _onAllMediaLoaded(slide) {
3731
3873
  return new Promise((resolve, reject) => {
3732
3874
  const promises = slide.layers.flatMap(layer => layer.elements.flatMap(element => element.mediaElementsLoadingPromises));
3875
+ console.log({ promises });
3733
3876
  let checkerTimerId = undefined;
3734
3877
  let timeOutFired = false;
3735
3878
  if (promises.length > 0) {
@@ -3771,15 +3914,16 @@ let SlideApi$1 = class SlideApi {
3771
3914
  slideReadyResolve = resolve;
3772
3915
  slideReadyReject = reject;
3773
3916
  });
3774
- const slide = new Slide(slidesNodesRefs, slideReadyPromise, this.afterResumeQueuePush.bind(this));
3917
+ const slide = new Slide(slidesNodesRefs, slideReadyPromise, this.afterResumeQueuePush.bind(this), this.afterStartInitQueuePush.bind(this), this.sdkApi.showNextSlide.bind(this), this.sdkApi);
3775
3918
  this._slideInInit = slide;
3919
+ slide.activeLayer.timeline.triggerSlideLoadState();
3776
3920
  const onAllMediaLoaded = this._onAllMediaLoaded(slide);
3777
3921
  if (this.sdkApi.isAndroid) {
3778
3922
  this._afterStartInitQueue = [];
3779
3923
  }
3780
3924
  this._afterResumeQueue = [];
3781
3925
  const result = { slide, result: false, reason: "" };
3782
- await this._initAndLoadFonts(this.layoutService.sdkApi.getCardFonts());
3926
+ await this._initAndLoadFonts(this.sdkApi.getCardFonts());
3783
3927
  const localData = await this.getLocalData();
3784
3928
  const finishRender = await slide.init(localData);
3785
3929
  /**
@@ -3827,8 +3971,15 @@ let SlideApi$1 = class SlideApi {
3827
3971
  slideBoxPrerender.classList.remove(SlideApi.prerenderBoxClassName);
3828
3972
  slideBox.classList.remove(SlideApi.renderedBoxClassName);
3829
3973
  slideBox.classList.add(SlideApi.prerenderBoxClassName);
3830
- prevSlide?.onBeforeUnmount();
3831
- slideBox.innerHTML = "";
3974
+ // 2 RAF - wait for browser render complete (CSS changes, etc.)
3975
+ this.layoutService.env.requestAnimationFrame(() => {
3976
+ this.layoutService.env.requestAnimationFrame(() => {
3977
+ prevSlide?.onBeforeUnmount();
3978
+ // @ts-ignore
3979
+ // _log("clear innerHTML", true);
3980
+ slideBox.innerHTML = "";
3981
+ });
3982
+ });
3832
3983
  slideBoxPrerender.classList.add(SlideApi.renderedBoxClassName);
3833
3984
  }
3834
3985
  this._slideInRender = false;
@@ -4054,6 +4205,7 @@ let SlideApi$1 = class SlideApi {
4054
4205
  if (target?.classList.contains("narrative-element-geometry")) {
4055
4206
  target = target?.querySelector(".narrative-element");
4056
4207
  }
4208
+ /** Button */
4057
4209
  if (target?.classList.contains("narrative-element-link")) {
4058
4210
  element = target;
4059
4211
  }
@@ -4062,320 +4214,328 @@ let SlideApi$1 = class SlideApi {
4062
4214
  }
4063
4215
  if (element) {
4064
4216
  const { handled } = this._handleLinkAndSwipeUpActivation(element);
4065
- result.canClickNext = !handled;
4066
- return result;
4217
+ if (handled) {
4218
+ result.canClickNext = false;
4219
+ return result;
4220
+ }
4221
+ }
4222
+ /** Image */
4223
+ if (target?.classList.contains("narrative-element-image")) {
4224
+ element = target;
4067
4225
  }
4068
4226
  else {
4069
- /** Image */
4070
- if (target?.classList.contains("narrative-element-image")) {
4071
- element = target;
4072
- }
4073
- else {
4074
- element = target?.closest(".narrative-element-image");
4075
- }
4076
- if (element) {
4077
- const { handled } = this._handleLinkAndSwipeUpActivation(element);
4078
- result.canClickNext = !handled;
4227
+ element = target?.closest(".narrative-element-image");
4228
+ }
4229
+ if (element) {
4230
+ const { handled } = this._handleLinkAndSwipeUpActivation(element);
4231
+ if (handled) {
4232
+ result.canClickNext = false;
4079
4233
  return result;
4080
4234
  }
4081
- /** Swipe Up */
4082
- if (target?.classList.contains("narrative-element-swipe-up")) {
4083
- element = target;
4084
- }
4085
- else {
4086
- element = target?.closest(".narrative-element-swipe-up");
4087
- }
4088
- if (element) {
4089
- const { handled } = this._handleLinkAndSwipeUpActivation(element);
4090
- if (handled) {
4091
- result.canClickNext = false;
4092
- return result;
4093
- }
4094
- }
4095
- /** Swipe Up Items */
4096
- if (target?.classList.contains("narrative-element-swipe-up-items")) {
4097
- element = target;
4098
- }
4099
- else {
4100
- element = target?.closest(".narrative-element-swipe-up-items");
4101
- }
4102
- if (element) {
4103
- const { handled } = this._handleLinkAndSwipeUpActivation(element);
4104
- if (handled) {
4105
- result.canClickNext = false;
4106
- return result;
4107
- }
4108
- }
4109
- /** Products */
4110
- if (target?.classList.contains("narrative-element-products")) {
4111
- element = target;
4112
- }
4113
- else {
4114
- element = target?.closest(".narrative-element-products");
4115
- }
4116
- if (element) {
4117
- const { handled } = this._handleLinkAndSwipeUpActivation(element);
4118
- if (handled) {
4119
- result.canClickNext = false;
4120
- return result;
4121
- }
4122
- }
4123
- /** Vote complete button (multiple choice) */
4124
- if (target?.classList.contains("narrative-element-vote-next-button")) {
4125
- element = target;
4126
- }
4127
- else {
4128
- element = target?.closest(".narrative-element-vote-next-button");
4129
- }
4130
- if (element) {
4131
- // if is widget file connected to Window
4132
- if (this.layoutService.layoutApi.widgetVoteApi) {
4133
- if (this.layoutService.layoutApi.widgetVoteApi.click(element)) {
4134
- this.layoutService.env.setTimeout(() => {
4135
- this.sdkApi.showNextSlide(0);
4136
- });
4137
- }
4138
- result.canClickNext = false;
4139
- return result;
4140
- }
4141
- }
4142
- /** Next button */
4143
- if (target?.classList.contains("narrative-element-quiz-next-button")) {
4144
- element = target;
4145
- }
4146
- else {
4147
- element = target?.closest(".narrative-element-quiz-next-button");
4148
- }
4149
- if (!element) {
4150
- if (target?.classList.contains("narrative-element-test-next-button")) {
4151
- element = target;
4152
- }
4153
- else {
4154
- element = target?.closest(".narrative-element-test-next-button");
4155
- }
4156
- }
4157
- if (element) {
4158
- this.layoutService.env.setTimeout(() => {
4159
- this.sdkApi.showNextSlide(0);
4160
- });
4235
+ }
4236
+ /** Swipe Up */
4237
+ if (target?.classList.contains("narrative-element-swipe-up")) {
4238
+ element = target;
4239
+ }
4240
+ else {
4241
+ element = target?.closest(".narrative-element-swipe-up");
4242
+ }
4243
+ if (element) {
4244
+ const { handled } = this._handleLinkAndSwipeUpActivation(element);
4245
+ if (handled) {
4161
4246
  result.canClickNext = false;
4162
4247
  return result;
4163
4248
  }
4164
- /** Range slider */
4165
- let rangeSliderBorderBoxView = target;
4166
- if (target?.classList.contains("border-box-view") || (rangeSliderBorderBoxView = target?.closest(".border-box-view"))) {
4167
- if (rangeSliderBorderBoxView?.parentElement && rangeSliderBorderBoxView.parentElement.classList.contains("narrative-element-range-slider")) {
4168
- // skip click on .border-box-view inside .narrative-element-range-slider - prevent navigation trigger at click inside widget body (expect NextButton)
4169
- result.canClickNext = false;
4170
- return result;
4171
- }
4172
- }
4173
- // if (_hasClass(target, "rangeslider") || target.closest(".rangeslider")) {
4174
- // return;
4175
- // }
4176
- /** Range slider complete button */
4177
- if (target?.classList.contains("narrative-element-range-slider-next-button")) {
4178
- element = target;
4249
+ }
4250
+ /** Swipe Up Items */
4251
+ if (target?.classList.contains("narrative-element-swipe-up-items")) {
4252
+ element = target;
4253
+ }
4254
+ else {
4255
+ element = target?.closest(".narrative-element-swipe-up-items");
4256
+ }
4257
+ if (element) {
4258
+ const { handled } = this._handleLinkAndSwipeUpActivation(element);
4259
+ if (handled) {
4260
+ result.canClickNext = false;
4261
+ return result;
4179
4262
  }
4180
- else {
4181
- element = target?.closest(".narrative-element-range-slider-next-button");
4263
+ }
4264
+ /** Products */
4265
+ if (target?.classList.contains("narrative-element-products")) {
4266
+ element = target;
4267
+ }
4268
+ else {
4269
+ element = target?.closest(".narrative-element-products");
4270
+ }
4271
+ if (element) {
4272
+ const { handled } = this._handleLinkAndSwipeUpActivation(element);
4273
+ if (handled) {
4274
+ result.canClickNext = false;
4275
+ return result;
4182
4276
  }
4183
- if (element) {
4184
- if (this.layoutService.layoutApi.widgetRangeSliderApi) {
4185
- if (this.layoutService.layoutApi.widgetRangeSliderApi.click(element)) {
4186
- this.layoutService.env.setTimeout(() => {
4187
- this.sdkApi.showNextSlide(0);
4188
- });
4189
- }
4190
- result.canClickNext = false;
4191
- return result;
4277
+ }
4278
+ /** Vote complete button (multiple choice) */
4279
+ if (target?.classList.contains("narrative-element-vote-next-button")) {
4280
+ element = target;
4281
+ }
4282
+ else {
4283
+ element = target?.closest(".narrative-element-vote-next-button");
4284
+ }
4285
+ if (element) {
4286
+ // if is widget file connected to Window
4287
+ if (this.layoutService.layoutApi.widgetVoteApi) {
4288
+ if (this.layoutService.layoutApi.widgetVoteApi.click(element)) {
4289
+ this.layoutService.env.setTimeout(() => {
4290
+ this.sdkApi.showNextSlide(0);
4291
+ });
4192
4292
  }
4293
+ result.canClickNext = false;
4294
+ return result;
4193
4295
  }
4194
- /** Data input widget расширенный охват на весь виджет */
4195
- if (target?.classList.contains("narrative-element-data-input")) {
4296
+ }
4297
+ /** Next button */
4298
+ if (target?.classList.contains("narrative-element-quiz-next-button")) {
4299
+ element = target;
4300
+ }
4301
+ else {
4302
+ element = target?.closest(".narrative-element-quiz-next-button");
4303
+ }
4304
+ if (!element) {
4305
+ if (target?.classList.contains("narrative-element-test-next-button")) {
4196
4306
  element = target;
4197
4307
  }
4198
4308
  else {
4199
- element = target?.closest(".narrative-element-data-input");
4200
- }
4201
- if (element) {
4202
- if (this.layoutService.layoutApi.widgetDataInputApi) {
4203
- result.canClickNext = this.layoutService.layoutApi.widgetDataInputApi.click(element);
4204
- return result;
4205
- }
4309
+ element = target?.closest(".narrative-element-test-next-button");
4206
4310
  }
4207
- /** quiz */
4208
- if (target?.classList.contains("narrative-element-quiz-answer")) {
4209
- element = target;
4210
- }
4211
- else {
4212
- element = target?.closest(".narrative-element-quiz-answer");
4311
+ }
4312
+ if (element) {
4313
+ this.layoutService.env.setTimeout(() => {
4314
+ this.sdkApi.showNextSlide(0);
4315
+ });
4316
+ result.canClickNext = false;
4317
+ return result;
4318
+ }
4319
+ /** Range slider */
4320
+ let rangeSliderBorderBoxView = target;
4321
+ if (target?.classList.contains("border-box-view") || (rangeSliderBorderBoxView = target?.closest(".border-box-view"))) {
4322
+ if (rangeSliderBorderBoxView?.parentElement && rangeSliderBorderBoxView.parentElement.classList.contains("narrative-element-range-slider")) {
4323
+ // skip click on .border-box-view inside .narrative-element-range-slider - prevent navigation trigger at click inside widget body (expect NextButton)
4324
+ result.canClickNext = false;
4325
+ return result;
4213
4326
  }
4214
- if (element) {
4215
- if (element.closest(".narrative-element-quiz")) {
4216
- /* quiz */
4217
- if (this.layoutService.layoutApi.widgetQuizApi) {
4218
- propagation = this.layoutService.layoutApi.widgetQuizApi.select(element);
4219
- propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4220
- }
4221
- }
4222
- else if (element.closest(".narrative-element-quiz-grouped")) {
4223
- /* quiz-grouped */
4224
- if (this.layoutService.layoutApi.widgetQuizGroupedApi) {
4225
- propagation = this.layoutService.layoutApi.widgetQuizGroupedApi.select(element);
4226
- propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4227
- }
4327
+ }
4328
+ // if (_hasClass(target, "rangeslider") || target.closest(".rangeslider")) {
4329
+ // return;
4330
+ // }
4331
+ /** Range slider complete button */
4332
+ if (target?.classList.contains("narrative-element-range-slider-next-button")) {
4333
+ element = target;
4334
+ }
4335
+ else {
4336
+ element = target?.closest(".narrative-element-range-slider-next-button");
4337
+ }
4338
+ if (element) {
4339
+ if (this.layoutService.layoutApi.widgetRangeSliderApi) {
4340
+ if (this.layoutService.layoutApi.widgetRangeSliderApi.click(element)) {
4341
+ this.layoutService.env.setTimeout(() => {
4342
+ this.sdkApi.showNextSlide(0);
4343
+ });
4228
4344
  }
4345
+ result.canClickNext = false;
4346
+ return result;
4229
4347
  }
4230
- /** poll or poll layers */
4231
- if (target?.classList.contains("narrative-element-poll-button")) {
4232
- element = target;
4233
- }
4234
- else {
4235
- element = target?.closest(".narrative-element-poll-button");
4348
+ }
4349
+ /** Data input widget расширенный охват на весь виджет */
4350
+ if (target?.classList.contains("narrative-element-data-input")) {
4351
+ element = target;
4352
+ }
4353
+ else {
4354
+ element = target?.closest(".narrative-element-data-input");
4355
+ }
4356
+ if (element) {
4357
+ if (this.layoutService.layoutApi.widgetDataInputApi) {
4358
+ result.canClickNext = this.layoutService.layoutApi.widgetDataInputApi.click(element);
4359
+ return result;
4236
4360
  }
4237
- if (element) {
4238
- if (this.activeLayer.pollElement) {
4239
- if (this.layoutService.layoutApi.widgetPollApi) {
4240
- this.layoutService.layoutApi.widgetPollApi.select(element);
4241
- propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4242
- }
4243
- }
4244
- if (this.activeLayer.pollLayersElement) {
4245
- if (this.layoutService.layoutApi.widgetPollLayersApi) {
4246
- this.layoutService.layoutApi.widgetPollLayersApi.select(element);
4247
- propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4248
- }
4361
+ }
4362
+ /** quiz */
4363
+ if (target?.classList.contains("narrative-element-quiz-answer")) {
4364
+ element = target;
4365
+ }
4366
+ else {
4367
+ element = target?.closest(".narrative-element-quiz-answer");
4368
+ }
4369
+ if (element) {
4370
+ if (element.closest(".narrative-element-quiz")) {
4371
+ /* quiz */
4372
+ if (this.layoutService.layoutApi.widgetQuizApi) {
4373
+ propagation = this.layoutService.layoutApi.widgetQuizApi.select(element);
4374
+ propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4249
4375
  }
4250
4376
  }
4251
- /** vote */
4252
- if (target?.classList.contains("narrative-element-vote-answer")) {
4253
- element = target;
4254
- }
4255
- else {
4256
- element = target?.closest(".narrative-element-vote-answer");
4257
- }
4258
- if (element) {
4259
- if (this.layoutService.layoutApi.widgetVoteApi) {
4260
- propagation = this.layoutService.layoutApi.widgetVoteApi.select(element);
4377
+ else if (element.closest(".narrative-element-quiz-grouped")) {
4378
+ /* quiz-grouped */
4379
+ if (this.layoutService.layoutApi.widgetQuizGroupedApi) {
4380
+ propagation = this.layoutService.layoutApi.widgetQuizGroupedApi.select(element);
4261
4381
  propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4262
4382
  }
4263
4383
  }
4264
- /** rate */
4265
- if (target?.classList.contains("narrative-element-rate-input")) {
4266
- element = target;
4267
- }
4268
- else {
4269
- element = target?.closest(".narrative-element-rate-input");
4270
- }
4271
- if (element) {
4272
- if (this.layoutService.layoutApi.widgetRateApi) {
4273
- propagation = this.layoutService.layoutApi.widgetRateApi.select(element);
4384
+ }
4385
+ /** poll or poll layers */
4386
+ if (target?.classList.contains("narrative-element-poll-button")) {
4387
+ element = target;
4388
+ }
4389
+ else {
4390
+ element = target?.closest(".narrative-element-poll-button");
4391
+ }
4392
+ if (element) {
4393
+ if (this.activeLayer.pollElement) {
4394
+ if (this.layoutService.layoutApi.widgetPollApi) {
4395
+ this.layoutService.layoutApi.widgetPollApi.select(element);
4274
4396
  propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4275
4397
  }
4276
4398
  }
4277
- /** test */
4278
- if (target?.classList.contains("narrative-element-test-answer")) {
4279
- element = target;
4280
- }
4281
- else {
4282
- element = target?.closest(".narrative-element-test-answer");
4283
- }
4284
- if (element) {
4285
- if (element.closest(".narrative-element-test")) {
4286
- /* test */
4287
- if (this.layoutService.layoutApi.widgetTestApi) {
4288
- propagation = this.layoutService.layoutApi.widgetTestApi.select(element);
4289
- propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4290
- }
4291
- }
4292
- else if (element.closest(".narrative-element-quest")) {
4293
- /* quest */
4294
- if (this.layoutService.layoutApi.widgetQuestApi) {
4295
- propagation = this.layoutService.layoutApi.widgetQuestApi.select(element);
4296
- propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4297
- }
4399
+ if (this.activeLayer.pollLayersElement) {
4400
+ if (this.layoutService.layoutApi.widgetPollLayersApi) {
4401
+ this.layoutService.layoutApi.widgetPollLayersApi.select(element);
4402
+ propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4298
4403
  }
4299
4404
  }
4300
- /** copy */
4301
- if (target?.classList.contains("narrative-element-copy")) {
4302
- element = target;
4405
+ }
4406
+ /** vote */
4407
+ if (target?.classList.contains("narrative-element-vote-answer")) {
4408
+ element = target;
4409
+ }
4410
+ else {
4411
+ element = target?.closest(".narrative-element-vote-answer");
4412
+ }
4413
+ if (element) {
4414
+ if (this.layoutService.layoutApi.widgetVoteApi) {
4415
+ propagation = this.layoutService.layoutApi.widgetVoteApi.select(element);
4416
+ propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4303
4417
  }
4304
- else {
4305
- element = target?.closest(".narrative-element-copy");
4418
+ }
4419
+ /** rate */
4420
+ if (target?.classList.contains("narrative-element-rate-input")) {
4421
+ element = target;
4422
+ }
4423
+ else {
4424
+ element = target?.closest(".narrative-element-rate-input");
4425
+ }
4426
+ if (element) {
4427
+ if (this.layoutService.layoutApi.widgetRateApi) {
4428
+ propagation = this.layoutService.layoutApi.widgetRateApi.select(element);
4429
+ propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4306
4430
  }
4307
- if (element) {
4308
- // if ("_narrative_test" in window) {
4309
- // propagation = window._narrative_test.select(element);
4310
- // propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4311
- // }
4312
- if (this.layoutService.layoutApi.widgetCopyApi) {
4313
- propagation = this.layoutService.layoutApi.widgetCopyApi.click(element);
4314
- propagation = false; // по клику на Копировать не делаем клик на слайде
4431
+ }
4432
+ /** test */
4433
+ if (target?.classList.contains("narrative-element-test-answer")) {
4434
+ element = target;
4435
+ }
4436
+ else {
4437
+ element = target?.closest(".narrative-element-test-answer");
4438
+ }
4439
+ if (element) {
4440
+ if (element.closest(".narrative-element-test")) {
4441
+ /* test */
4442
+ if (this.layoutService.layoutApi.widgetTestApi) {
4443
+ propagation = this.layoutService.layoutApi.widgetTestApi.select(element);
4444
+ propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4315
4445
  }
4316
- // copyToClipboard(element.getAttribute('data-clipboard-target'));
4317
- // propagation = false;
4318
- }
4319
- /** barcode */
4320
- if (target?.classList.contains("narrative-element-barcode")) {
4321
- element = target;
4322
4446
  }
4323
- else {
4324
- element = target?.closest(".narrative-element-barcode");
4325
- }
4326
- if (element) {
4327
- // if ("_narrative_test" in window) {
4328
- // propagation = window._narrative_test.select(element);
4329
- // propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4330
- // }
4331
- if (this.layoutService.layoutApi.widgetBarcodeApi) {
4332
- propagation = this.layoutService.layoutApi.widgetBarcodeApi.click(element);
4333
- propagation = false; // по клику на Копировать не делаем клик на слайде
4447
+ else if (element.closest(".narrative-element-quest")) {
4448
+ /* quest */
4449
+ if (this.layoutService.layoutApi.widgetQuestApi) {
4450
+ propagation = this.layoutService.layoutApi.widgetQuestApi.select(element);
4451
+ propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4334
4452
  }
4335
- // copyToClipboard(element.getAttribute('data-clipboard-target'));
4336
- // propagation = false;
4337
4453
  }
4338
- /** share */
4339
- if (target?.classList.contains("narrative-element-share")) {
4340
- element = target;
4454
+ }
4455
+ /** copy */
4456
+ if (target?.classList.contains("narrative-element-copy")) {
4457
+ element = target;
4458
+ }
4459
+ else {
4460
+ element = target?.closest(".narrative-element-copy");
4461
+ }
4462
+ if (element) {
4463
+ // if ("_narrative_test" in window) {
4464
+ // propagation = window._narrative_test.select(element);
4465
+ // propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4466
+ // }
4467
+ if (this.layoutService.layoutApi.widgetCopyApi) {
4468
+ propagation = this.layoutService.layoutApi.widgetCopyApi.click(element);
4469
+ propagation = false; // по клику на Копировать не делаем клик на слайде
4341
4470
  }
4342
- else {
4343
- element = target?.closest(".narrative-element-share");
4471
+ // copyToClipboard(element.getAttribute('data-clipboard-target'));
4472
+ // propagation = false;
4473
+ }
4474
+ /** barcode */
4475
+ if (target?.classList.contains("narrative-element-barcode")) {
4476
+ element = target;
4477
+ }
4478
+ else {
4479
+ element = target?.closest(".narrative-element-barcode");
4480
+ }
4481
+ if (element) {
4482
+ // if ("_narrative_test" in window) {
4483
+ // propagation = window._narrative_test.select(element);
4484
+ // propagation = false; // по клику на варианты ответа(даже на законченной викторине) не делаем клик на слайде
4485
+ // }
4486
+ if (this.layoutService.layoutApi.widgetBarcodeApi) {
4487
+ propagation = this.layoutService.layoutApi.widgetBarcodeApi.click(element);
4488
+ propagation = false; // по клику на Копировать не делаем клик на слайде
4344
4489
  }
4345
- if (element) {
4346
- if (this.layoutService.layoutApi.widgetShareApi) {
4347
- this.layoutService.layoutApi.widgetShareApi.click(element);
4348
- propagation = false;
4349
- }
4490
+ // copyToClipboard(element.getAttribute('data-clipboard-target'));
4491
+ // propagation = false;
4492
+ }
4493
+ /** share */
4494
+ if (target?.classList.contains("narrative-element-share")) {
4495
+ element = target;
4496
+ }
4497
+ else {
4498
+ element = target?.closest(".narrative-element-share");
4499
+ }
4500
+ if (element) {
4501
+ if (this.layoutService.layoutApi.widgetShareApi) {
4502
+ this.layoutService.layoutApi.widgetShareApi.click(element);
4503
+ propagation = false;
4350
4504
  }
4351
- /** story-repeat */
4352
- if (target?.classList.contains("narrative-element-story-repeat")) {
4353
- element = target;
4505
+ }
4506
+ /** story-repeat */
4507
+ if (target?.classList.contains("narrative-element-story-repeat")) {
4508
+ element = target;
4509
+ }
4510
+ else {
4511
+ element = target?.closest(".narrative-element-story-repeat");
4512
+ }
4513
+ if (element) {
4514
+ propagation = false;
4515
+ this.sdkApi.setCardLocalData({}, true);
4516
+ this.sdkApi.updateCardServerDataLocally(this.slide.cardId, {});
4517
+ // window._resetTimers();
4518
+ // сделать async в ios
4519
+ let slideIndex = this.slide.slideIndex;
4520
+ // prevent simultaneous call _showNarrativeSlide and _showLayer - prevent 2 calls of initAfterLoad (break video start on iOS)
4521
+ if (slideIndex === 0) {
4522
+ // for story repeat on the first slide with layers
4523
+ this.sdkApi.showLayer(0);
4354
4524
  }
4355
4525
  else {
4356
- element = target?.closest(".narrative-element-story-repeat");
4357
- }
4358
- if (element) {
4359
- propagation = false;
4360
- this.sdkApi.setCardLocalData({}, true);
4361
- this.sdkApi.updateCardServerDataLocally(this.slide.cardId, {});
4362
- // window._resetTimers();
4363
- // сделать async в ios
4364
- let slideIndex = this.slide.slideIndex;
4365
- // prevent simultaneous call _showNarrativeSlide and _showLayer - prevent 2 calls of initAfterLoad (break video start on iOS)
4366
- if (slideIndex === 0) {
4367
- // for story repeat on the first slide with layers
4368
- this.sdkApi.showLayer(0);
4369
- }
4370
- else {
4371
- this.sdkApi.showCardSlide(0); // сделать ее async
4372
- }
4373
- }
4374
- if (!propagation) {
4375
- result.canClickNext = false;
4376
- return result;
4526
+ this.sdkApi.showCardSlide(0); // сделать ее async
4377
4527
  }
4378
4528
  }
4529
+ // todo в каждом виджете делать выход через
4530
+ // if (handled) {
4531
+ // result.canClickNext = false;
4532
+ // return result;
4533
+ // }
4534
+ // убрать propagation
4535
+ if (!propagation) {
4536
+ result.canClickNext = false;
4537
+ return result;
4538
+ }
4379
4539
  /** can tap to next slide */
4380
4540
  if (this.activeLayer.quizElement) {
4381
4541
  if (!this.activeLayer.quizElement.slideQuizIsDone && navigationDirection === "forward") {
@@ -4439,6 +4599,7 @@ let SlideApi$1 = class SlideApi {
4439
4599
  const linkTargetAndroid = element.getAttribute("data-link-target-android");
4440
4600
  const linkTargetWeb = element.getAttribute("data-link-target-web");
4441
4601
  const elementId = element.getAttribute("data-element-id") ?? "";
4602
+ // element without URI data
4442
4603
  let handled = false;
4443
4604
  if (this.sdkApi.isAndroid && linkTargetAndroid) {
4444
4605
  linkTarget = linkTargetAndroid;
@@ -4525,36 +4686,38 @@ let SlideApi$1 = class SlideApi {
4525
4686
  handled = true;
4526
4687
  }
4527
4688
  }
4528
- try {
4529
- const cardId = this.slide.cardId;
4530
- const cardType = this.slide.cardType;
4531
- const slideIndex = this.slide.slideIndex;
4532
- let baseFields = {};
4533
- switch (cardType) {
4534
- case 1 /* CARD_TYPE.STORY */:
4535
- case 2 /* CARD_TYPE.UGC_STORY */:
4536
- baseFields.story_id = cardId;
4537
- break;
4538
- case 4 /* CARD_TYPE.IN_APP_MESSAGING */:
4539
- baseFields.message_id = cardId;
4540
- break;
4689
+ if (handled) {
4690
+ try {
4691
+ const cardId = this.slide.cardId;
4692
+ const cardType = this.slide.cardType;
4693
+ const slideIndex = this.slide.slideIndex;
4694
+ let baseFields = {};
4695
+ switch (cardType) {
4696
+ case 1 /* CARD_TYPE.STORY */:
4697
+ case 2 /* CARD_TYPE.UGC_STORY */:
4698
+ baseFields.story_id = cardId;
4699
+ break;
4700
+ case 4 /* CARD_TYPE.IN_APP_MESSAGING */:
4701
+ baseFields.message_id = cardId;
4702
+ break;
4703
+ }
4704
+ this.sdkApi.sendStatisticEvent(statisticWidgetEventType, {
4705
+ i: cardId,
4706
+ si: slideIndex,
4707
+ wi: elementId,
4708
+ wl: element.textContent ?? "",
4709
+ wv: statisticWidgetValue ?? "",
4710
+ }, {
4711
+ ...baseFields,
4712
+ slide_index: slideIndex,
4713
+ widget_id: elementId,
4714
+ widget_label: element.textContent ?? "",
4715
+ widget_value: statisticWidgetValue ?? "",
4716
+ });
4717
+ }
4718
+ catch (error) {
4719
+ console.error(error);
4541
4720
  }
4542
- this.sdkApi.sendStatisticEvent(statisticWidgetEventType, {
4543
- i: cardId,
4544
- si: slideIndex,
4545
- wi: elementId,
4546
- wl: element.textContent ?? "",
4547
- wv: statisticWidgetValue ?? "",
4548
- }, {
4549
- ...baseFields,
4550
- slide_index: slideIndex,
4551
- widget_id: elementId,
4552
- widget_label: element.textContent ?? "",
4553
- widget_value: statisticWidgetValue ?? "",
4554
- });
4555
- }
4556
- catch (error) {
4557
- console.error(error);
4558
4721
  }
4559
4722
  return { handled };
4560
4723
  }
@@ -4583,10 +4746,20 @@ let SlideApi$1 = class SlideApi {
4583
4746
  this.activeLayer.shareElement.complete(id, isSuccess);
4584
4747
  }
4585
4748
  }
4586
- 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 }`]; }
4749
+ setWidgetGoodsComplete(elementId) {
4750
+ const element = document.querySelector('[data-element-id="' + elementId + '"]');
4751
+ if (element != null) {
4752
+ try {
4753
+ element.style.setProperty("opacity", "1");
4754
+ }
4755
+ catch (e) {
4756
+ console.error(e);
4757
+ }
4758
+ }
4759
+ }
4760
+ 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 overlappingActionBarHeight?: number;\n }`]; }
4587
4761
  };
4588
4762
 
4589
- let sdkInterface;
4590
4763
  const slideApiPeerDeps = {};
4591
4764
  const createSlideWrapper = ({ slideBoxRatio, nonce }) => {
4592
4765
  const slideWrapper = document.createElement("div");
@@ -4611,7 +4784,6 @@ const createSlideWrapper = ({ slideBoxRatio, nonce }) => {
4611
4784
  // style.sheet?.insertRule(`.narrative-slide-box {padding: ${paddingTop} 0 0 0;`);
4612
4785
  slideBoxRendered.style.padding = `${paddingTop} 0 0 0`;
4613
4786
  slideBoxPrerender.style.padding = `${paddingTop} 0 0 0`;
4614
- console.log({ paddingTop });
4615
4787
  slideOffset.appendChild(slideBoxPrerender);
4616
4788
  slideOffset.appendChild(slideBoxRendered);
4617
4789
  slideWrapper.appendChild(slideOffset);
@@ -4620,24 +4792,25 @@ const createSlideWrapper = ({ slideBoxRatio, nonce }) => {
4620
4792
  };
4621
4793
  class SlideApi extends SlideApi$1 {
4622
4794
  constructor(_sdkInterface, config) {
4623
- sdkInterface = _sdkInterface;
4624
4795
  slideApiPeerDeps.VODPlayer = config.VODPlayer;
4625
4796
  const slideWrapper = createSlideWrapper({ slideBoxRatio: config.slideRatio, nonce: config.nonce });
4626
4797
  // todo need to clear root node before append slideWrapper?
4627
4798
  config.root.appendChild(slideWrapper);
4628
4799
  super({
4800
+ sdkApi: new EsModuleSdkApi(_sdkInterface),
4629
4801
  slideWrapper,
4630
4802
  viewport: config.viewport,
4631
4803
  slideRatio: config.slideRatio,
4632
4804
  isFullscreen: config.isFullscreen,
4633
4805
  userResizeHandler: config.userResizeHandler,
4806
+ getViewportWidth: () => slideWrapper.clientWidth,
4807
+ getViewportHeight: () => slideWrapper.clientHeight,
4808
+ overlappingActionBarHeight: config.overlappingActionBarHeight,
4634
4809
  });
4635
4810
  }
4636
- 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 }`]; }
4811
+ 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 overlappingActionBarHeight?: number;\n }`]; }
4637
4812
  }
4638
4813
 
4639
- container.registerSingleton(() => new EsModuleSdkApi(() => sdkInterface), { identifier: `SDKApi` });
4640
-
4641
4814
  // This file is part of the bwip-js project available at:
4642
4815
  //
4643
4816
  // http://metafloor.github.io/bwip-js
@@ -13994,6 +14167,8 @@ FontLib.loadFont("OCR-B", 96, 100, "AAEAAAAPAIAAAwBwRkZUTXxHn14AADmUAAAAHEdERUYA
13994
14167
  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); }
13995
14168
 
13996
14169
  class WidgetBase {
14170
+ _onWidgetComplete;
14171
+ sdkApi;
13997
14172
  static DEFAULTS = {
13998
14173
  slide: null,
13999
14174
  activateAfterCreate: false,
@@ -14002,7 +14177,6 @@ class WidgetBase {
14002
14177
  };
14003
14178
  static widgetIndex = 0;
14004
14179
  env = WidgetBase.widgetsService.env;
14005
- sdkApi = WidgetBase.widgetsService.sdkApi;
14006
14180
  options = null;
14007
14181
  element = null;
14008
14182
  elementId = null;
@@ -14022,7 +14196,9 @@ class WidgetBase {
14022
14196
  id;
14023
14197
  startReadyPromise = null;
14024
14198
  startReadyResolve = null;
14025
- constructor(element, options, elementIdGetter, slideGetter) {
14199
+ constructor(element, options, _onWidgetComplete, sdkApi, elementIdGetter, slideGetter) {
14200
+ this._onWidgetComplete = _onWidgetComplete;
14201
+ this.sdkApi = sdkApi;
14026
14202
  this.options = extend({}, this.constructor.DEFAULTS, options);
14027
14203
  this.element = element;
14028
14204
  if (elementIdGetter) {
@@ -14130,68 +14306,24 @@ class WidgetBase {
14130
14306
  return instance;
14131
14307
  }
14132
14308
  static initWidget(htmlElement, localData, instantiate) {
14133
- if (localData != null) {
14134
- const widget = this.createInstance(instantiate, htmlElement, {
14135
- slide: null,
14136
- localData,
14137
- });
14138
- // start widget (just created or cached instance)
14139
- widget.onRefreshUserData(localData);
14140
- return Promise.resolve(localData);
14141
- }
14142
- else {
14143
- return new Promise(resolve => {
14144
- this.getLocalData().then(localData => {
14145
- const widget = this.createInstance(instantiate, htmlElement, {
14146
- slide: null,
14147
- localData,
14148
- });
14149
- // start widget (just created or cached instance)
14150
- widget.onRefreshUserData(localData);
14151
- resolve(localData);
14152
- });
14153
- });
14154
- }
14155
- }
14156
- /** @deprecated */
14157
- static initWidgets(instantiate, elements, localData) {
14158
- if (localData != null) {
14159
- forEach(elements, element => {
14160
- const widget = this.createInstance(instantiate, element, {
14161
- slide: null,
14162
- localData,
14163
- });
14164
- // start widget (just created or cached instance)
14165
- widget.onRefreshUserData(localData);
14166
- });
14167
- return Promise.resolve(localData);
14168
- }
14169
- else {
14170
- return new Promise(resolve => {
14171
- this.getLocalData().then(localData => {
14172
- forEach(elements, element => {
14173
- const widget = this.createInstance(instantiate, element, {
14174
- slide: null,
14175
- localData,
14176
- });
14177
- // start widget (just created or cached instance)
14178
- widget.onRefreshUserData(localData);
14179
- });
14180
- resolve(localData);
14181
- });
14182
- });
14183
- }
14309
+ const widget = this.createInstance(instantiate, htmlElement, {
14310
+ slide: null,
14311
+ localData,
14312
+ });
14313
+ // start widget (just created or cached instance)
14314
+ widget.onRefreshUserData(localData);
14315
+ return Promise.resolve(localData);
14184
14316
  }
14185
14317
  static get widgetsService() {
14186
14318
  return container.get({ identifier: "WidgetsService" });
14187
14319
  }
14188
- static getLocalData() {
14189
- return this.widgetsService.sdkApi.getCardLocalData();
14320
+ static getLocalData(sdkApi) {
14321
+ return sdkApi.getCardLocalData();
14190
14322
  }
14191
14323
  getLocalData() {
14192
- return this.constructor.getLocalData();
14324
+ return this.constructor.getLocalData(this.sdkApi);
14193
14325
  }
14194
- static setLocalData(keyValue, sendToServer, syncWithRuntimeLocalData) {
14326
+ static setLocalData(sdkApi, keyValue, sendToServer, syncWithRuntimeLocalData) {
14195
14327
  // push json object as string
14196
14328
  if (sendToServer === undefined) {
14197
14329
  sendToServer = true;
@@ -14206,20 +14338,20 @@ class WidgetBase {
14206
14338
  syncWithRuntimeLocalData = Boolean(syncWithRuntimeLocalData);
14207
14339
  }
14208
14340
  if (syncWithRuntimeLocalData) {
14209
- this.getLocalData().then(localData => {
14341
+ this.getLocalData(sdkApi).then(localData => {
14210
14342
  // 1 - old values, 2 - new values
14211
14343
  keyValue = extend({}, localData, keyValue);
14212
14344
  // todo make async via promise or async
14213
- this.widgetsService.sdkApi.setCardLocalData(keyValue, sendToServer);
14345
+ sdkApi.setCardLocalData(keyValue, sendToServer);
14214
14346
  });
14215
14347
  }
14216
14348
  else {
14217
14349
  // todo make async via promise or async
14218
- this.widgetsService.sdkApi.setCardLocalData(keyValue, sendToServer);
14350
+ sdkApi.setCardLocalData(keyValue, sendToServer);
14219
14351
  }
14220
14352
  }
14221
14353
  setLocalData(keyValue, sendToServer, syncWithRuntimeLocalData) {
14222
- return this.constructor.setLocalData(keyValue, sendToServer, syncWithRuntimeLocalData);
14354
+ return this.constructor.setLocalData(this.sdkApi, keyValue, sendToServer, syncWithRuntimeLocalData);
14223
14355
  }
14224
14356
  get statisticEventBaseFieldsShortForm() {
14225
14357
  return WidgetBase.getStatisticEventBaseFieldsShortForm(this.cardId, this.slideIndex);
@@ -14246,14 +14378,14 @@ class WidgetBase {
14246
14378
  }
14247
14379
  return data;
14248
14380
  }
14249
- static sendStatisticEventToApp(name, data, devPayload, options) {
14250
- sendStatisticEventToApp(this.widgetsService.sdkApi, name, data, devPayload, options);
14381
+ static sendStatisticEventToApp(sdkApi, name, data, devPayload, options) {
14382
+ sendStatisticEventToApp(sdkApi, name, data, devPayload, options);
14251
14383
  }
14252
14384
  sendStatisticEventToApp(name, data, devPayload, options) {
14253
- this.constructor.sendStatisticEventToApp(name, data, devPayload, options);
14385
+ this.constructor.sendStatisticEventToApp(this.sdkApi, name, data, devPayload, options);
14254
14386
  }
14255
- startDisabledTimeline() {
14256
- this.sdkApi.startDisabledTimeline(this.cardId, this.slideIndex);
14387
+ onWidgetComplete() {
14388
+ this._onWidgetComplete(this.cardId, this.slideIndex);
14257
14389
  }
14258
14390
  _showLayer(layers, selectIndex, withStatEvent = false) {
14259
14391
  if (this.sdkApi.isExistsShowLayer()) {
@@ -14288,45 +14420,13 @@ class WidgetBase {
14288
14420
  console.error(error);
14289
14421
  }
14290
14422
  }
14291
- /** @deprecated */
14292
- static refreshUserData(nodes, 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
- }
14300
- }
14301
- };
14302
- if (localData != null) {
14303
- const elements = slice.call(nodes);
14304
- forEach(elements, el => cb(el, localData));
14305
- }
14306
- else {
14307
- WidgetBase.getLocalData().then(localData => {
14308
- const elements = slice.call(nodes);
14309
- forEach(elements, el => cb(el, localData));
14310
- });
14311
- }
14312
- }
14313
14423
  static onRefreshUserData(element, localData) {
14314
- const cb = (el, localData) => {
14315
- const widgetElement = el.closest(`.${this.widgetClassName}`);
14316
- if (widgetElement) {
14317
- const widget = WidgetBase.getInstance(widgetElement);
14318
- if (widget) {
14319
- widget.onRefreshUserData(localData);
14320
- }
14424
+ const widgetElement = element.closest(`.${this.widgetClassName}`);
14425
+ if (widgetElement) {
14426
+ const widget = WidgetBase.getInstance(widgetElement);
14427
+ if (widget) {
14428
+ widget.onRefreshUserData(localData);
14321
14429
  }
14322
- };
14323
- if (localData != null) {
14324
- cb(element, localData);
14325
- }
14326
- else {
14327
- WidgetBase.getLocalData().then(localData => {
14328
- cb(element, localData);
14329
- });
14330
14430
  }
14331
14431
  }
14332
14432
  getPromotionalCodeFetchPath(promotionalCodeId) {
@@ -14337,7 +14437,7 @@ class WidgetBase {
14337
14437
  return `story/${this.cardId}/widget/${this.elementId}/promo-code/${promotionalCodeId}`;
14338
14438
  }
14339
14439
  }
14340
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `(element: HTMLElement) => string`, `(element: HTMLElement) => HTMLElement`]; }
14440
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`, `(element: HTMLElement) => string`, `(element: HTMLElement) => HTMLElement`]; }
14341
14441
  }
14342
14442
 
14343
14443
  class WidgetBarcode extends WidgetBase {
@@ -14361,8 +14461,8 @@ class WidgetBarcode extends WidgetBase {
14361
14461
  msgNoMoreCodes;
14362
14462
  msgTryAgain;
14363
14463
  msgBarcodeRenderError;
14364
- constructor(element, options) {
14365
- super(element, options);
14464
+ constructor(element, options, onWidgetComplete, sdkApi) {
14465
+ super(element, options, onWidgetComplete, sdkApi);
14366
14466
  this.captionView = this.element.querySelector(".narrative-element-text-lines");
14367
14467
  this.clipboardTarget = getTagData(element, "clipboardTarget");
14368
14468
  this.isPromotionalCode = getTagData(element, "clipboardType") === "promocode";
@@ -14585,7 +14685,7 @@ class WidgetBarcode extends WidgetBase {
14585
14685
  // флаг - что таймер уже стартанул (в layout или добавить объект sharedMemory)
14586
14686
  // смотрим что прозрачный текст - тогда и лоадер прозрачный
14587
14687
  // _log("_showNarrativeNextSlide: " + getSlideDuration(this.narrativeId, this.slideIndex), true);
14588
- this.startDisabledTimeline();
14688
+ this.onWidgetComplete();
14589
14689
  }
14590
14690
  });
14591
14691
  if (this.copiedText) {
@@ -14610,18 +14710,9 @@ class WidgetBarcode extends WidgetBase {
14610
14710
  }
14611
14711
  static api = {
14612
14712
  widgetClassName: WidgetBarcode.widgetClassName,
14613
- /** @deprecated */
14614
- refreshUserData: WidgetBarcode.refreshUserData,
14615
14713
  onRefreshUserData: WidgetBarcode.onRefreshUserData,
14616
- init: function (element, localData) {
14617
- WidgetBarcode.initWidget(element, localData, (element, options) => new WidgetBarcode(element, options));
14618
- },
14619
- /** @deprecated */
14620
- initWidget: function (nodeList, localData) {
14621
- const elements = slice.call(nodeList);
14622
- WidgetBarcode.initWidgets((element, options) => new WidgetBarcode(element, options), elements, localData).then(() => {
14623
- elements.forEach(element => WidgetBarcode.getInstance(element)?.onStart());
14624
- });
14714
+ init: function (element, localData, onWidgetComplete, sdkApi) {
14715
+ WidgetBarcode.initWidget(element, localData, (element, options) => new WidgetBarcode(element, options, onWidgetComplete, sdkApi));
14625
14716
  },
14626
14717
  onStart: function (element) {
14627
14718
  WidgetBarcode.getInstance(element)?.onStart();
@@ -14648,7 +14739,7 @@ class WidgetBarcode extends WidgetBase {
14648
14739
  return false;
14649
14740
  },
14650
14741
  };
14651
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
14742
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
14652
14743
  }
14653
14744
 
14654
14745
  class WidgetCopy extends WidgetBase {
@@ -14670,8 +14761,8 @@ class WidgetCopy extends WidgetBase {
14670
14761
  geometry;
14671
14762
  resultLayer;
14672
14763
  resultLayerGeometry;
14673
- constructor(element, options) {
14674
- super(element, options);
14764
+ constructor(element, options, onWidgetComplete, sdkApi) {
14765
+ super(element, options, onWidgetComplete, sdkApi);
14675
14766
  this.button = this.element.querySelector(".narrative-element-text-lines");
14676
14767
  this.clipboardTarget = getTagData(element, "clipboardTarget");
14677
14768
  this.isPromotionalCode = getTagData(element, "clipboardType") === "promocode";
@@ -14855,7 +14946,7 @@ class WidgetCopy extends WidgetBase {
14855
14946
  // флаг - что таймер уже стартанул (в layout или добавить объект sharedMemory)
14856
14947
  // смотрим что прозрачный текст - тогда и лоадер прозрачный
14857
14948
  // _log("_showNarrativeNextSlide: " + getSlideDuration(this.narrativeId, this.slideIndex), true);
14858
- this.startDisabledTimeline();
14949
+ this.onWidgetComplete();
14859
14950
  }
14860
14951
  });
14861
14952
  }
@@ -14877,23 +14968,13 @@ class WidgetCopy extends WidgetBase {
14877
14968
  }
14878
14969
  static api = {
14879
14970
  widgetClassName: WidgetCopy.widgetClassName,
14880
- /** @deprecated */
14881
- refreshUserData: WidgetCopy.refreshUserData,
14882
14971
  onRefreshUserData: WidgetCopy.onRefreshUserData,
14883
- init: function (element, localData) {
14972
+ init: function (element, localData, onWidgetComplete, sdkApi) {
14884
14973
  // prevent initWidget for result layer
14885
14974
  if (!element.classList.contains("narrative-element-copy-result-variant")) {
14886
- WidgetCopy.initWidget(element, localData, (element, options) => new WidgetCopy(element, options));
14975
+ WidgetCopy.initWidget(element, localData, (element, options) => new WidgetCopy(element, options, onWidgetComplete, sdkApi));
14887
14976
  }
14888
14977
  },
14889
- /** @deprecated */
14890
- initWidget: function (nodeList, localData) {
14891
- // prevent initWidget for result layer
14892
- const elements = slice.call(nodeList).filter(element => !element.classList.contains("narrative-element-copy-result-variant"));
14893
- WidgetCopy.initWidgets((element, options) => new WidgetCopy(element, options), elements, localData).then(() => {
14894
- elements.forEach(element => WidgetCopy.getInstance(element)?.onStart());
14895
- });
14896
- },
14897
14978
  onStart: function (element) {
14898
14979
  WidgetCopy.getInstance(element)?.onStart();
14899
14980
  },
@@ -14919,10 +15000,9 @@ class WidgetCopy extends WidgetBase {
14919
15000
  return false;
14920
15001
  },
14921
15002
  };
14922
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
15003
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
14923
15004
  }
14924
15005
 
14925
- /** QUIZ */
14926
15006
  class WidgetDataInput extends WidgetBase {
14927
15007
  static DEFAULTS = {
14928
15008
  slide: null,
@@ -14940,9 +15020,11 @@ class WidgetDataInput extends WidgetBase {
14940
15020
  * @throws Error
14941
15021
  * @param element
14942
15022
  * @param options
15023
+ * @param onWidgetComplete
15024
+ * @param sdkApi
14943
15025
  */
14944
- constructor(element, options) {
14945
- super(element, options);
15026
+ constructor(element, options, onWidgetComplete, sdkApi) {
15027
+ super(element, options, onWidgetComplete, sdkApi);
14946
15028
  this.label = this.element.querySelector(".label-view .label");
14947
15029
  this.elementRect = this.element.getBoundingClientRect();
14948
15030
  this.inputElement = getValueOrException(this.element.querySelector(".input-view .input"), "Empty .input-view .input");
@@ -14961,7 +15043,7 @@ class WidgetDataInput extends WidgetBase {
14961
15043
  this.element.classList.add("done");
14962
15044
  this.startReadyPromise.then(() => {
14963
15045
  if (this.disableTimer) {
14964
- this.startDisabledTimeline();
15046
+ this.onWidgetComplete();
14965
15047
  }
14966
15048
  });
14967
15049
  }
@@ -15078,7 +15160,7 @@ class WidgetDataInput extends WidgetBase {
15078
15160
  this.setLocalData(this.localData, true);
15079
15161
  this._statEventInputSave(text);
15080
15162
  if (this.disableTimer) {
15081
- this.startDisabledTimeline();
15163
+ this.onWidgetComplete();
15082
15164
  needResumeUITimer = false;
15083
15165
  }
15084
15166
  }
@@ -15088,18 +15170,9 @@ class WidgetDataInput extends WidgetBase {
15088
15170
  }
15089
15171
  static api = {
15090
15172
  widgetClassName: WidgetDataInput.widgetClassName,
15091
- /** @deprecated */
15092
- refreshUserData: WidgetDataInput.refreshUserData,
15093
15173
  onRefreshUserData: WidgetDataInput.onRefreshUserData,
15094
- init: function (element, localData) {
15095
- WidgetDataInput.initWidget(element, localData, (element, options) => new WidgetDataInput(element, options));
15096
- },
15097
- /** @deprecated */
15098
- initWidget: function (nodeList, localData) {
15099
- const elements = slice.call(nodeList);
15100
- WidgetDataInput.initWidgets((element, options) => new WidgetDataInput(element, options), slice.call(nodeList), localData).then(() => {
15101
- elements.forEach(element => WidgetDataInput.getInstance(element)?.onStart());
15102
- });
15174
+ init: function (element, localData, onWidgetComplete, sdkApi) {
15175
+ WidgetDataInput.initWidget(element, localData, (element, options) => new WidgetDataInput(element, options, onWidgetComplete, sdkApi));
15103
15176
  },
15104
15177
  onStart: function (element) {
15105
15178
  WidgetDataInput.getInstance(element)?.onStart();
@@ -15121,7 +15194,7 @@ class WidgetDataInput extends WidgetBase {
15121
15194
  WidgetDataInput.getInstanceById(id)?.setUserText(text);
15122
15195
  },
15123
15196
  };
15124
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
15197
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
15125
15198
  }
15126
15199
 
15127
15200
  class WidgetDateCountdown extends WidgetBase {
@@ -15149,8 +15222,8 @@ class WidgetDateCountdown extends WidgetBase {
15149
15222
  thirdGroup1;
15150
15223
  thirdGroup2;
15151
15224
  thirdGroupCaption;
15152
- constructor(element, options) {
15153
- super(element, options);
15225
+ constructor(element, options, onWidgetComplete, sdkApi) {
15226
+ super(element, options, onWidgetComplete, sdkApi);
15154
15227
  this.label = this.element.querySelector(".label-view .label");
15155
15228
  this.messages = {
15156
15229
  days: getTagData(this.element, "tDays") ?? "",
@@ -15327,18 +15400,9 @@ class WidgetDateCountdown extends WidgetBase {
15327
15400
  }
15328
15401
  static api = {
15329
15402
  widgetClassName: WidgetDateCountdown.widgetClassName,
15330
- /** @deprecated */
15331
- refreshUserData: WidgetDateCountdown.refreshUserData,
15332
15403
  onRefreshUserData: WidgetDateCountdown.onRefreshUserData,
15333
- init: function (element, layers, localData) {
15334
- WidgetDateCountdown.initWidget(element, localData, (element, options) => new WidgetDateCountdown(element, { ...options, layers }));
15335
- },
15336
- /** @deprecated */
15337
- initWidget: function (nodeList, layers, localData) {
15338
- const elements = slice.call(nodeList);
15339
- WidgetDateCountdown.initWidgets((element, options) => new WidgetDateCountdown(element, { ...options, layers }), elements, localData).then(() => {
15340
- elements.forEach(element => WidgetDateCountdown.getInstance(element)?.onStart());
15341
- });
15404
+ init: function (element, layers, localData, onWidgetComplete, sdkApi) {
15405
+ WidgetDateCountdown.initWidget(element, localData, (element, options) => new WidgetDateCountdown(element, { ...options, layers }, onWidgetComplete, sdkApi));
15342
15406
  },
15343
15407
  onStart: function (element) {
15344
15408
  WidgetDateCountdown.getInstance(element)?.onStart();
@@ -15352,23 +15416,11 @@ class WidgetDateCountdown extends WidgetBase {
15352
15416
  onResume: function (element) {
15353
15417
  WidgetDateCountdown.getInstance(element)?.onResume();
15354
15418
  },
15355
- /** @deprecated */
15356
- pause: function (nodeList) {
15357
- forEach(slice.call(nodeList), function (el, index) {
15358
- WidgetDateCountdown.getInstance(el)?.onPause();
15359
- });
15360
- },
15361
- /** @deprecated */
15362
- resume: function (nodeList) {
15363
- forEach(slice.call(nodeList), function (el, index) {
15364
- WidgetDateCountdown.getInstance(el)?.onResume();
15365
- });
15366
- },
15367
15419
  };
15368
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
15420
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
15369
15421
  }
15370
15422
 
15371
- const displaySlide = function (slides, localData) {
15423
+ const displaySlide = function (slides, localData, sdkApi) {
15372
15424
  const multiSlideItem = slides[0];
15373
15425
  let cardId = undefined;
15374
15426
  let cardType = 1 /* CARD_TYPE.STORY */;
@@ -15433,7 +15485,7 @@ const displaySlide = function (slides, localData) {
15433
15485
  if (slides.length > 0) {
15434
15486
  var slide = slides[0];
15435
15487
  slide.classList.remove("hidden");
15436
- WidgetBase.widgetsService.sdkApi.cardAnimation?.start(slide);
15488
+ sdkApi.cardAnimation?.start(slide);
15437
15489
  return;
15438
15490
  }
15439
15491
  score = 0;
@@ -15462,19 +15514,19 @@ const displaySlide = function (slides, localData) {
15462
15514
  if (index === selectedIndex) {
15463
15515
  slide.classList.remove("hidden");
15464
15516
  undefinedResult = false;
15465
- WidgetBase.widgetsService.sdkApi.cardAnimation?.start(slide);
15466
- _sendStatEvent(cardId, cardType, slideIndex, selectedIndex);
15517
+ sdkApi.cardAnimation?.start(slide);
15518
+ _sendStatEvent(sdkApi, cardId, cardType, slideIndex, selectedIndex);
15467
15519
  }
15468
15520
  });
15469
15521
  }
15470
15522
  if (undefinedResult) {
15471
15523
  console.warn("undefinedResult layer index");
15472
- WidgetBase.widgetsService.sdkApi.showLayer(0);
15524
+ sdkApi.showLayer(0);
15473
15525
  }
15474
15526
  };
15475
- const _sendStatEvent = function (cardId, cardType, slideIndex, layerIndex) {
15527
+ const _sendStatEvent = function (sdkApi, cardId, cardType, slideIndex, layerIndex) {
15476
15528
  try {
15477
- WidgetBase.sendStatisticEventToApp("layout-show", {
15529
+ WidgetBase.sendStatisticEventToApp(sdkApi, "layout-show", {
15478
15530
  ...WidgetBase.getStatisticEventBaseFieldsShortForm(cardId, slideIndex),
15479
15531
  li: layerIndex,
15480
15532
  }, {
@@ -15488,15 +15540,8 @@ const _sendStatEvent = function (cardId, cardType, slideIndex, layerIndex) {
15488
15540
  };
15489
15541
  class WidgetMultiSlide {
15490
15542
  static api = {
15491
- init: function (slides, localData) {
15492
- if (localData != null) {
15493
- displaySlide(slides, localData);
15494
- }
15495
- else {
15496
- WidgetBase.getLocalData().then(function (localData) {
15497
- displaySlide(slides, localData);
15498
- });
15499
- }
15543
+ init: function (slides, localData, sdkApi) {
15544
+ displaySlide(slides, localData, sdkApi);
15500
15545
  },
15501
15546
  };
15502
15547
  }
@@ -15527,9 +15572,10 @@ class WidgetPoll extends WidgetBase {
15527
15572
  * @throws Error
15528
15573
  * @param element
15529
15574
  * @param options
15575
+ * @param onWidgetComplete
15530
15576
  */
15531
- constructor(element, options) {
15532
- super(element, options);
15577
+ constructor(element, options, onWidgetComplete, sdkApi) {
15578
+ super(element, options, onWidgetComplete, sdkApi);
15533
15579
  this.label = this.element.querySelector(".label-view .label");
15534
15580
  this.percentFillMask = this.element.querySelector(".percent-filled-variants-view-group-mask");
15535
15581
  this.maskedVariants = slice.call(this.element.querySelectorAll(".variants-box .variants-view-group.percent-filled-variants-view-group .variant-view"));
@@ -15638,7 +15684,7 @@ class WidgetPoll extends WidgetBase {
15638
15684
  }
15639
15685
  this.startReadyPromise.then(() => {
15640
15686
  if (this.disableTimer) {
15641
- this.startDisabledTimeline();
15687
+ this.onWidgetComplete();
15642
15688
  }
15643
15689
  });
15644
15690
  }
@@ -15978,17 +16024,9 @@ class WidgetPoll extends WidgetBase {
15978
16024
  }
15979
16025
  static api = {
15980
16026
  widgetClassName: WidgetPoll.widgetClassName,
15981
- /** @deprecated */
15982
- refreshUserData: WidgetPoll.refreshUserData,
15983
16027
  onRefreshUserData: WidgetPoll.onRefreshUserData,
15984
- init: function (element, localData) {
15985
- WidgetPoll.initWidget(element, localData, (element, options) => new WidgetPoll(element, options));
15986
- },
15987
- /** @deprecated */
15988
- initWidget: function (element, localData) {
15989
- WidgetPoll.initWidgets((element, options) => new WidgetPoll(element, options), [element], localData).then(() => {
15990
- WidgetPoll.getInstance(element)?.onStart();
15991
- });
16028
+ init: function (element, localData, onWidgetComplete, sdkApi) {
16029
+ WidgetPoll.initWidget(element, localData, (element, options) => new WidgetPoll(element, options, onWidgetComplete, sdkApi));
15992
16030
  },
15993
16031
  onStart: function (element) {
15994
16032
  WidgetPoll.getInstance(element)?.onStart();
@@ -16034,7 +16072,7 @@ class WidgetPoll extends WidgetBase {
16034
16072
  }
16035
16073
  },
16036
16074
  };
16037
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
16075
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
16038
16076
  }
16039
16077
 
16040
16078
  class WidgetPollLayers extends WidgetBase {
@@ -16051,8 +16089,8 @@ class WidgetPollLayers extends WidgetBase {
16051
16089
  variantsTexts;
16052
16090
  selectedVariant;
16053
16091
  layers;
16054
- constructor(element, options) {
16055
- super(element, options);
16092
+ constructor(element, options, onWidgetComplete, sdkApi) {
16093
+ super(element, options, onWidgetComplete, sdkApi);
16056
16094
  this.layers = this.options.layers;
16057
16095
  this.label = this.element.querySelector(".label-view .label");
16058
16096
  this.variants = slice.call(this.element.querySelectorAll(".variants-box .variant-view"));
@@ -16124,7 +16162,7 @@ class WidgetPollLayers extends WidgetBase {
16124
16162
  this._showLayer(this.layers, layerIndex, userAction);
16125
16163
  this.startReadyPromise.then(() => {
16126
16164
  if (this.disableTimer) {
16127
- this.startDisabledTimeline();
16165
+ this.onWidgetComplete();
16128
16166
  }
16129
16167
  });
16130
16168
  }
@@ -16163,28 +16201,9 @@ class WidgetPollLayers extends WidgetBase {
16163
16201
  }
16164
16202
  static api = {
16165
16203
  widgetClassName: WidgetPollLayers.widgetClassName,
16166
- /** @deprecated */
16167
- refreshUserData: WidgetPollLayers.refreshUserData,
16168
16204
  onRefreshUserData: WidgetPollLayers.onRefreshUserData,
16169
- init: function (element, layers, localData) {
16170
- WidgetPollLayers.initWidget(element, localData, (element, options) => new WidgetPollLayers(element, { ...options, layers }));
16171
- },
16172
- /** @deprecated
16173
- *
16174
- * signature variants
16175
- * (widget, layers, undefined) - modern web sdk
16176
- * (widget, undefined, layers) - old web sdk and rn
16177
- * (widget, layers, localData) - native sdk
16178
- */
16179
- initWidget: function (element, layers, localData) {
16180
- if (layers === undefined && localData !== undefined) {
16181
- // @ts-ignore
16182
- layers = localData;
16183
- localData = undefined;
16184
- }
16185
- WidgetPollLayers.initWidgets((element, options) => new WidgetPollLayers(element, { ...options, layers }), [element], localData).then(() => {
16186
- WidgetPollLayers.getInstance(element)?.onStart();
16187
- });
16205
+ init: function (element, layers, localData, onWidgetComplete, sdkApi) {
16206
+ WidgetPollLayers.initWidget(element, localData, (element, options) => new WidgetPollLayers(element, { ...options, layers }, onWidgetComplete, sdkApi));
16188
16207
  },
16189
16208
  onStart: function (element) {
16190
16209
  WidgetPollLayers.getInstance(element)?.onStart();
@@ -16208,7 +16227,7 @@ class WidgetPollLayers extends WidgetBase {
16208
16227
  return false;
16209
16228
  },
16210
16229
  };
16211
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
16230
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
16212
16231
  }
16213
16232
 
16214
16233
  class Formatter {
@@ -16835,8 +16854,8 @@ class WidgetProducts extends WidgetBase {
16835
16854
  swipeGestureDetector = null;
16836
16855
  isClickCapturedByWidget = false;
16837
16856
  isScreenSupportsTouch = false;
16838
- constructor(element, options) {
16839
- super(element, options);
16857
+ constructor(element, options, onWidgetComplete, sdkApi) {
16858
+ super(element, options, onWidgetComplete, sdkApi);
16840
16859
  this.captionView = this.element.querySelector(".narrative-element-text-lines");
16841
16860
  const linkTarget = decodeURIComponent(getTagData(element, "linkTarget") ?? "[]");
16842
16861
  try {
@@ -17311,8 +17330,8 @@ class WidgetProducts extends WidgetBase {
17311
17330
  static api = {
17312
17331
  widgetClassName: WidgetProducts.widgetClassName,
17313
17332
  onRefreshUserData: WidgetProducts.onRefreshUserData,
17314
- init: function (element, localData) {
17315
- WidgetProducts.initWidget(element, localData, (element, options) => new WidgetProducts(element, options));
17333
+ init: function (element, localData, onWidgetComplete, sdkApi) {
17334
+ WidgetProducts.initWidget(element, localData, (element, options) => new WidgetProducts(element, options, onWidgetComplete, sdkApi));
17316
17335
  },
17317
17336
  onStart: function (element) {
17318
17337
  WidgetProducts.getInstance(element)?.onStart();
@@ -17361,7 +17380,7 @@ class WidgetProducts extends WidgetBase {
17361
17380
  return false;
17362
17381
  },
17363
17382
  };
17364
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
17383
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
17365
17384
  }
17366
17385
 
17367
17386
  class WidgetQuest extends WidgetBase {
@@ -17381,11 +17400,11 @@ class WidgetQuest extends WidgetBase {
17381
17400
  navigationNextSlide;
17382
17401
  slideDisabledNavigation;
17383
17402
  finalSlide;
17384
- constructor(element, options) {
17403
+ constructor(element, options, onWidgetComplete, sdkApi) {
17385
17404
  const isWidget = !hasClass(element, "narrative-slide");
17386
17405
  const elementIdGetter = (element) => getValueOrDefault(getTagData(element, "elementId"), "");
17387
17406
  const slideGetter = (element) => isWidget ? getValueOrException(element.closest(".narrative-slide"), "Empty slide") : element;
17388
- super(element, options, elementIdGetter, slideGetter);
17407
+ super(element, options, onWidgetComplete, sdkApi, elementIdGetter, slideGetter);
17389
17408
  this.isWidget = isWidget;
17390
17409
  this.slideCount = getTagDataAsNumber(this.slide, "slideCount") ?? 0;
17391
17410
  const nonFinalSlide = getTagDataAsNumber(this.slide, "nonFinalSlide");
@@ -17582,6 +17601,14 @@ class WidgetQuest extends WidgetBase {
17582
17601
  if (this.nonFinalSlide == null) {
17583
17602
  // widget v2 (with navigationNextSlide)
17584
17603
  if (directionForward) {
17604
+ if (this.navigationNextSlide === -1) {
17605
+ // this is the final slide - exit from this quest
17606
+ if (this.sdkApi.isExistsShowNextCard) {
17607
+ this.sdkApi.cardShowNext();
17608
+ }
17609
+ result.continueDefaultNavigation = false;
17610
+ return result;
17611
+ }
17585
17612
  const nextSlideIndex = this.navigationNextSlide ?? event.slideIndex + 1;
17586
17613
  if (nextSlideIndex < this.slideCount) {
17587
17614
  this._addNewRouteHistory(nextSlideIndex);
@@ -17683,12 +17710,10 @@ class WidgetQuest extends WidgetBase {
17683
17710
  }
17684
17711
  static api = {
17685
17712
  widgetClassName: WidgetQuest.widgetClassName,
17686
- /** @deprecated */
17687
- refreshUserData: WidgetQuest.refreshUserData,
17688
17713
  onRefreshUserData: WidgetQuest.onRefreshUserData,
17689
- init: function (element, localData) {
17714
+ init: function (element, localData, onWidgetComplete, sdkApi) {
17690
17715
  return new Promise(function (resolve, reject) {
17691
- WidgetQuest.initWidget(element, localData, (element, options) => new WidgetQuest(element, options)).then(localData => {
17716
+ WidgetQuest.initWidget(element, localData, (element, options) => new WidgetQuest(element, options, onWidgetComplete, sdkApi)).then(localData => {
17692
17717
  const widget = WidgetQuest.getInstance(element);
17693
17718
  if (widget) {
17694
17719
  resolve(widget.init());
@@ -17699,22 +17724,6 @@ class WidgetQuest extends WidgetBase {
17699
17724
  });
17700
17725
  });
17701
17726
  },
17702
- /** @deprecated */
17703
- initWidget: function (element, localData) {
17704
- return new Promise(function (resolve, reject) {
17705
- WidgetQuest.initWidgets((element, options) => new WidgetQuest(element, options), [element], localData).then(localData => {
17706
- const widget = WidgetQuest.getInstance(element);
17707
- if (widget) {
17708
- const result = widget.init();
17709
- widget.onStart();
17710
- resolve(result);
17711
- }
17712
- else {
17713
- resolve(true);
17714
- }
17715
- });
17716
- });
17717
- },
17718
17727
  onStart: function (element) {
17719
17728
  WidgetQuest.getInstance(element)?.onStart();
17720
17729
  },
@@ -17746,7 +17755,7 @@ class WidgetQuest extends WidgetBase {
17746
17755
  return { continueDefaultNavigation: true };
17747
17756
  },
17748
17757
  };
17749
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
17758
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
17750
17759
  }
17751
17760
 
17752
17761
  class WidgetQuiz extends WidgetBase {
@@ -17761,8 +17770,8 @@ class WidgetQuiz extends WidgetBase {
17761
17770
  answers;
17762
17771
  questionCount;
17763
17772
  selectedAnswer;
17764
- constructor(element, options) {
17765
- super(element, options);
17773
+ constructor(element, options, onWidgetComplete, sdkApi) {
17774
+ super(element, options, onWidgetComplete, sdkApi);
17766
17775
  this.question = this.element.querySelector(".label-view .label");
17767
17776
  this.answers = slice.call(this.element.querySelectorAll(".variants-box .variant-view-group"));
17768
17777
  this.questionCount = getValueOrException(getTagDataAsNumber(this.slide, "quizCount"), "Empty quizCount");
@@ -17817,7 +17826,7 @@ class WidgetQuiz extends WidgetBase {
17817
17826
  // }
17818
17827
  this.startReadyPromise.then(() => {
17819
17828
  if (this.disableTimer) {
17820
- this.startDisabledTimeline();
17829
+ this.onWidgetComplete();
17821
17830
  }
17822
17831
  });
17823
17832
  }
@@ -17909,17 +17918,9 @@ class WidgetQuiz extends WidgetBase {
17909
17918
  }
17910
17919
  static api = {
17911
17920
  widgetClassName: WidgetQuiz.widgetClassName,
17912
- /** @deprecated */
17913
- refreshUserData: WidgetQuiz.refreshUserData,
17914
17921
  onRefreshUserData: WidgetQuiz.onRefreshUserData,
17915
- init: function (element, localData) {
17916
- WidgetQuiz.initWidget(element, localData, (element, options) => new WidgetQuiz(element, options));
17917
- },
17918
- /** @deprecated */
17919
- initWidget: function (element, localData) {
17920
- WidgetQuiz.initWidgets((element, options) => new WidgetQuiz(element, options), [element], localData).then(() => {
17921
- WidgetQuiz.getInstance(element)?.onStart();
17922
- });
17922
+ init: function (element, localData, onWidgetComplete, sdkApi) {
17923
+ WidgetQuiz.initWidget(element, localData, (element, options) => new WidgetQuiz(element, options, onWidgetComplete, sdkApi));
17923
17924
  },
17924
17925
  onStart: function (element) {
17925
17926
  WidgetQuiz.getInstance(element)?.onStart();
@@ -17948,7 +17949,7 @@ class WidgetQuiz extends WidgetBase {
17948
17949
  return true;
17949
17950
  },
17950
17951
  };
17951
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
17952
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
17952
17953
  }
17953
17954
 
17954
17955
  class WidgetQuizGrouped extends WidgetBase {
@@ -17967,9 +17968,11 @@ class WidgetQuizGrouped extends WidgetBase {
17967
17968
  * @throws Error
17968
17969
  * @param element
17969
17970
  * @param options
17971
+ * @param onWidgetComplete
17972
+ * @param sdkApi
17970
17973
  */
17971
- constructor(element, options) {
17972
- super(element, options);
17974
+ constructor(element, options, onWidgetComplete, sdkApi) {
17975
+ super(element, options, onWidgetComplete, sdkApi);
17973
17976
  this.question = this.element.querySelector(".label-view .label");
17974
17977
  this.answers = slice.call(this.element.querySelectorAll(".variants-box .variant-view-group"));
17975
17978
  this.questionCount = getValueOrException(getTagDataAsNumber(this.slide, "quizCount"), "Empty quizCount");
@@ -18011,7 +18014,7 @@ class WidgetQuizGrouped extends WidgetBase {
18011
18014
  });
18012
18015
  this.startReadyPromise.then(() => {
18013
18016
  if (this.disableTimer) {
18014
- this.startDisabledTimeline();
18017
+ this.onWidgetComplete();
18015
18018
  }
18016
18019
  });
18017
18020
  }
@@ -18120,17 +18123,9 @@ class WidgetQuizGrouped extends WidgetBase {
18120
18123
  }
18121
18124
  static api = {
18122
18125
  widgetClassName: WidgetQuizGrouped.widgetClassName,
18123
- /** @deprecated */
18124
- refreshUserData: WidgetQuizGrouped.refreshUserData,
18125
18126
  onRefreshUserData: WidgetQuizGrouped.onRefreshUserData,
18126
- init: function (element, localData) {
18127
- WidgetQuizGrouped.initWidget(element, localData, (element, options) => new WidgetQuizGrouped(element, options));
18128
- },
18129
- /** @deprecated */
18130
- initWidget: function (element, localData) {
18131
- WidgetQuizGrouped.initWidgets((element, options) => new WidgetQuizGrouped(element, options), [element], localData).then(() => {
18132
- WidgetQuizGrouped.getInstance(element)?.onStart();
18133
- });
18127
+ init: function (element, localData, onWidgetComplete, sdkApi) {
18128
+ WidgetQuizGrouped.initWidget(element, localData, (element, options) => new WidgetQuizGrouped(element, options, onWidgetComplete, sdkApi));
18134
18129
  },
18135
18130
  onStart: function (element) {
18136
18131
  WidgetQuizGrouped.getInstance(element)?.onStart();
@@ -18159,7 +18154,7 @@ class WidgetQuizGrouped extends WidgetBase {
18159
18154
  return true;
18160
18155
  },
18161
18156
  };
18162
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
18157
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
18163
18158
  }
18164
18159
 
18165
18160
  // Polyfill Number.isNaN(value)
@@ -18329,9 +18324,10 @@ class WidgetRangeSlider extends WidgetBase {
18329
18324
  * @throws Error
18330
18325
  * @param element
18331
18326
  * @param options
18327
+ * @param onWidgetComplete
18332
18328
  */
18333
- constructor(element, options) {
18334
- super(element, options);
18329
+ constructor(element, options, onWidgetComplete, sdkApi) {
18330
+ super(element, options, onWidgetComplete, sdkApi);
18335
18331
  this.hasSubmitButton = Boolean(this.element.querySelector(".submit-button-view"));
18336
18332
  this.topScale = this.element.querySelector(".top-scale-bar-view-group");
18337
18333
  this.snapPosition = false;
@@ -18400,7 +18396,7 @@ class WidgetRangeSlider extends WidgetBase {
18400
18396
  this.displayAverageAnswer();
18401
18397
  this.startReadyPromise.then(() => {
18402
18398
  if (this.disableTimer) {
18403
- this.startDisabledTimeline();
18399
+ this.onWidgetComplete();
18404
18400
  }
18405
18401
  });
18406
18402
  }
@@ -18476,7 +18472,7 @@ class WidgetRangeSlider extends WidgetBase {
18476
18472
  }
18477
18473
  });
18478
18474
  // if (this.disableTimer) {
18479
- this.startDisabledTimeline();
18475
+ this.onWidgetComplete();
18480
18476
  // }
18481
18477
  this.setLocalData(this.localData, true);
18482
18478
  this._statEventInputSave(this.localData["_rs_g_" + this.elementId + "_v"]);
@@ -18773,17 +18769,9 @@ class WidgetRangeSlider extends WidgetBase {
18773
18769
  }
18774
18770
  static api = {
18775
18771
  widgetClassName: WidgetRangeSlider.widgetClassName,
18776
- /** @deprecated */
18777
- refreshUserData: WidgetRangeSlider.refreshUserData,
18778
18772
  onRefreshUserData: WidgetRangeSlider.onRefreshUserData,
18779
- init: function (element, localData) {
18780
- WidgetRangeSlider.initWidget(element, localData, (element, options) => new WidgetRangeSlider(element, options));
18781
- },
18782
- /** @deprecated */
18783
- initWidget: function (element, localData) {
18784
- WidgetRangeSlider.initWidgets((element, options) => new WidgetRangeSlider(element, options), [element], localData).then(() => {
18785
- WidgetRangeSlider.getInstance(element)?.onStart();
18786
- });
18773
+ init: function (element, localData, onWidgetComplete, sdkApi) {
18774
+ WidgetRangeSlider.initWidget(element, localData, (element, options) => new WidgetRangeSlider(element, options, onWidgetComplete, sdkApi));
18787
18775
  },
18788
18776
  onStart: function (element) {
18789
18777
  WidgetRangeSlider.getInstance(element)?.onStart();
@@ -18812,7 +18800,7 @@ class WidgetRangeSlider extends WidgetBase {
18812
18800
  return false;
18813
18801
  },
18814
18802
  };
18815
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
18803
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
18816
18804
  }
18817
18805
 
18818
18806
  class WidgetRate extends WidgetBase {
@@ -18835,8 +18823,8 @@ class WidgetRate extends WidgetBase {
18835
18823
  selectedStar;
18836
18824
  answerSelectDuration;
18837
18825
  elementRect;
18838
- constructor(element, options) {
18839
- super(element, options);
18826
+ constructor(element, options, onWidgetComplete, sdkApi) {
18827
+ super(element, options, onWidgetComplete, sdkApi);
18840
18828
  this.label = this.element.querySelector(".label-view .label");
18841
18829
  this.stars = slice.call(this.element.querySelectorAll(".input-view"));
18842
18830
  this.submitToStores = Boolean(getValueOrDefault(getTagDataAsNumber(this.element, "submitToStores"), 0));
@@ -18911,7 +18899,7 @@ class WidgetRate extends WidgetBase {
18911
18899
  this.element.classList.add("done");
18912
18900
  this.startReadyPromise.then(() => {
18913
18901
  if (this.disableTimer && runTimer) {
18914
- this.startDisabledTimeline();
18902
+ this.onWidgetComplete();
18915
18903
  }
18916
18904
  });
18917
18905
  }
@@ -19038,18 +19026,9 @@ class WidgetRate extends WidgetBase {
19038
19026
  }
19039
19027
  static api = {
19040
19028
  widgetClassName: WidgetRate.widgetClassName,
19041
- /** @deprecated */
19042
- refreshUserData: WidgetRate.refreshUserData,
19043
19029
  onRefreshUserData: WidgetRate.onRefreshUserData,
19044
- init: function (element, localData) {
19045
- WidgetRate.initWidget(element, localData, (element, options) => new WidgetRate(element, options));
19046
- },
19047
- /** @deprecated */
19048
- initWidget: function (nodeList, localData) {
19049
- const elements = slice.call(nodeList);
19050
- WidgetRate.initWidgets((element, options) => new WidgetRate(element, options), elements, localData).then(() => {
19051
- elements.forEach(element => WidgetRate.getInstance(element)?.onStart());
19052
- });
19030
+ init: function (element, localData, onWidgetComplete, sdkApi) {
19031
+ WidgetRate.initWidget(element, localData, (element, options) => new WidgetRate(element, options, onWidgetComplete, sdkApi));
19053
19032
  },
19054
19033
  onStart: function (element) {
19055
19034
  WidgetRate.getInstance(element)?.onStart();
@@ -19078,7 +19057,7 @@ class WidgetRate extends WidgetBase {
19078
19057
  WidgetRate.getInstanceById(id)?.setUserText(text);
19079
19058
  },
19080
19059
  };
19081
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
19060
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
19082
19061
  }
19083
19062
 
19084
19063
  class WidgetShare extends WidgetBase {
@@ -19095,8 +19074,8 @@ class WidgetShare extends WidgetBase {
19095
19074
  shareTarget;
19096
19075
  withLayer;
19097
19076
  btnDisabled;
19098
- constructor(element, options) {
19099
- super(element, options);
19077
+ constructor(element, options, onWidgetComplete, sdkApi) {
19078
+ super(element, options, onWidgetComplete, sdkApi);
19100
19079
  this.shareType = getTagData(this.element, "shareType");
19101
19080
  this.shareTarget = getTagData(this.element, "shareTarget");
19102
19081
  this.layers = this.options.layers;
@@ -19118,7 +19097,7 @@ class WidgetShare extends WidgetBase {
19118
19097
  }
19119
19098
  this.startReadyPromise.then(() => {
19120
19099
  if (this.isDone() && this.disableTimer) {
19121
- this.startDisabledTimeline();
19100
+ this.onWidgetComplete();
19122
19101
  }
19123
19102
  });
19124
19103
  this.btnDisabled = false;
@@ -19178,7 +19157,7 @@ class WidgetShare extends WidgetBase {
19178
19157
  this._showLayer(this.layers, 1, true);
19179
19158
  }
19180
19159
  if (this.disableTimer) {
19181
- this.startDisabledTimeline();
19160
+ this.onWidgetComplete();
19182
19161
  }
19183
19162
  this.btnDisabled = false;
19184
19163
  }
@@ -19187,31 +19166,12 @@ class WidgetShare extends WidgetBase {
19187
19166
  }
19188
19167
  static api = {
19189
19168
  widgetClassName: WidgetShare.widgetClassName,
19190
- /** @deprecated */
19191
- refreshUserData: WidgetShare.refreshUserData,
19192
19169
  onRefreshUserData: WidgetShare.onRefreshUserData,
19193
- init: function (element, layers, localData) {
19170
+ init: function (element, layers, localData, onWidgetComplete, sdkApi) {
19194
19171
  WidgetShare.initWidget(element, localData, (element, options) => new WidgetShare(element, {
19195
19172
  ...options,
19196
19173
  layers,
19197
- }));
19198
- },
19199
- /** @deprecated
19200
- * signature variants
19201
- * (widget, layers, undefined) - modern web sdk
19202
- * (widget, undefined, layers) - old web sdk and rn
19203
- * (widget, layers, localData) - native sdk
19204
- */
19205
- initWidget: function (nodeList, layers, localData) {
19206
- if (layers === undefined && localData !== undefined) {
19207
- // @ts-ignore
19208
- layers = localData;
19209
- localData = undefined;
19210
- }
19211
- const elements = slice.call(nodeList);
19212
- WidgetShare.initWidgets((element, options) => new WidgetShare(element, { ...options, layers }), elements, localData).then(() => {
19213
- elements.forEach(element => WidgetShare.getInstance(element)?.onStart());
19214
- });
19174
+ }, onWidgetComplete, sdkApi));
19215
19175
  },
19216
19176
  onStart: function (element) {
19217
19177
  WidgetShare.getInstance(element)?.onStart();
@@ -19232,7 +19192,7 @@ class WidgetShare extends WidgetBase {
19232
19192
  WidgetShare.getInstanceById(id)?._complete(isSuccess);
19233
19193
  },
19234
19194
  };
19235
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
19195
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
19236
19196
  }
19237
19197
 
19238
19198
  class WidgetTest extends WidgetBase {
@@ -19257,8 +19217,8 @@ class WidgetTest extends WidgetBase {
19257
19217
  timeLeftDefault;
19258
19218
  timeline;
19259
19219
  isWidgetTimerInit = false;
19260
- constructor(element, options) {
19261
- super(element, options);
19220
+ constructor(element, options, onWidgetComplete, sdkApi) {
19221
+ super(element, options, onWidgetComplete, sdkApi);
19262
19222
  this.label = this.element.querySelector(".label-view .label");
19263
19223
  this.variants = slice.call(this.element.querySelectorAll(".variants-box .variant-view"));
19264
19224
  this.testCount = getValueOrException(getTagDataAsNumber(this.slide, "testCount"), "Empty testCount");
@@ -19413,7 +19373,7 @@ class WidgetTest extends WidgetBase {
19413
19373
  });
19414
19374
  this.startReadyPromise.then(() => {
19415
19375
  if (this.disableTimer) {
19416
- this.startDisabledTimeline();
19376
+ this.onWidgetComplete();
19417
19377
  }
19418
19378
  });
19419
19379
  }
@@ -19485,17 +19445,9 @@ class WidgetTest extends WidgetBase {
19485
19445
  }
19486
19446
  static api = {
19487
19447
  widgetClassName: WidgetTest.widgetClassName,
19488
- /** @deprecated */
19489
- refreshUserData: WidgetTest.refreshUserData,
19490
19448
  onRefreshUserData: WidgetTest.onRefreshUserData,
19491
- init: function (element, localData) {
19492
- WidgetTest.initWidget(element, localData, (element, options) => new WidgetTest(element, options));
19493
- },
19494
- /** @deprecated */
19495
- initWidget: function (element, localData) {
19496
- WidgetTest.initWidgets((element, options) => new WidgetTest(element, options), [element], localData).then(() => {
19497
- WidgetTest.getInstance(element)?.onStart();
19498
- });
19449
+ init: function (element, localData, onWidgetComplete, sdkApi) {
19450
+ WidgetTest.initWidget(element, localData, (element, options) => new WidgetTest(element, options, onWidgetComplete, sdkApi));
19499
19451
  },
19500
19452
  onStart: function (element) {
19501
19453
  WidgetTest.getInstance(element)?.onStart();
@@ -19531,7 +19483,7 @@ class WidgetTest extends WidgetBase {
19531
19483
  return true;
19532
19484
  },
19533
19485
  };
19534
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
19486
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
19535
19487
  }
19536
19488
 
19537
19489
  class WidgetVote extends WidgetBase {
@@ -19557,9 +19509,11 @@ class WidgetVote extends WidgetBase {
19557
19509
  * @throws Error
19558
19510
  * @param element
19559
19511
  * @param options
19512
+ * @param onWidgetComplete
19513
+ * @param sdkApi
19560
19514
  */
19561
- constructor(element, options) {
19562
- super(element, options);
19515
+ constructor(element, options, onWidgetComplete, sdkApi) {
19516
+ super(element, options, onWidgetComplete, sdkApi);
19563
19517
  this.voteAllocation = getTagData(this.slide, "voteAllocation");
19564
19518
  this.label = this.element.querySelector(".label-view .label");
19565
19519
  this.variants = slice.call(this.element.querySelectorAll(".variants-box .variant-view-group"));
@@ -19743,7 +19697,7 @@ class WidgetVote extends WidgetBase {
19743
19697
  }
19744
19698
  this.startReadyPromise.then(() => {
19745
19699
  if (this.disableTimer) {
19746
- this.startDisabledTimeline();
19700
+ this.onWidgetComplete();
19747
19701
  }
19748
19702
  });
19749
19703
  }
@@ -19941,45 +19895,9 @@ class WidgetVote extends WidgetBase {
19941
19895
  }
19942
19896
  static api = {
19943
19897
  widgetClassName: WidgetVote.widgetClassName,
19944
- /** @deprecated */
19945
- refreshUserData: WidgetVote.refreshUserData,
19946
19898
  onRefreshUserData: WidgetVote.onRefreshUserData,
19947
- init: function (element, localData) {
19948
- WidgetVote.initWidget(element, localData, (element, options) => new WidgetVote(element, options));
19949
- },
19950
- /** @deprecated
19951
- *
19952
- * fix for WidgetVote on every layer of multilayers story
19953
- */
19954
- fallbackInitOnMultiSlide: function (element, localData) {
19955
- if (element.dataset.fallbackInitOnMultiSlide) {
19956
- return;
19957
- }
19958
- const multiSlide = element.closest(".narrative-multi-slide");
19959
- if (multiSlide != null) {
19960
- const container = multiSlide.parentElement;
19961
- const widgetElements = container?.querySelectorAll(`.${WidgetVote.widgetClassName}`);
19962
- if (widgetElements != null) {
19963
- for (let i = 0; i < widgetElements.length; ++i) {
19964
- const widgetElement = widgetElements[i];
19965
- const widget = WidgetVote.getInstance(widgetElement);
19966
- if (!widget) {
19967
- WidgetVote.initWidgets((element, options) => new WidgetVote(element, options), [widgetElement], localData);
19968
- }
19969
- }
19970
- }
19971
- }
19972
- element.dataset.fallbackInitOnMultiSlide = "1";
19973
- },
19974
- /** @deprecated */
19975
- initWidget: function (element, localData) {
19976
- WidgetVote.initWidgets((element, options) => new WidgetVote(element, options), [element], localData)
19977
- .then(localData => {
19978
- WidgetVote.api.fallbackInitOnMultiSlide(element, localData);
19979
- })
19980
- .then(() => {
19981
- WidgetVote.getInstance(element)?.onStart();
19982
- });
19899
+ init: function (element, localData, onWidgetComplete, sdkApi) {
19900
+ WidgetVote.initWidget(element, localData, (element, options) => new WidgetVote(element, options, onWidgetComplete, sdkApi));
19983
19901
  },
19984
19902
  onStart: function (element) {
19985
19903
  WidgetVote.getInstance(element)?.onStart();
@@ -20015,7 +19933,7 @@ class WidgetVote extends WidgetBase {
20015
19933
  return true;
20016
19934
  },
20017
19935
  };
20018
- static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`]; }
19936
+ static get [Symbol.for("___CTOR_ARGS___")]() { return [`HTMLElement`, `Partial`, `OnWidgetComplete`, `SDKApi`]; }
20019
19937
  }
20020
19938
 
20021
19939
  class EsModuleLayoutApi {