@gamelearn/arcade-components 2.2.0 → 2.2.3

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.
Files changed (22) hide show
  1. package/dist/components/auto-evaluation-component/components/AutoEvaluation.js +2 -4
  2. package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js +3 -6
  3. package/dist/components/chained-image-click-puzzle-component/components/CurrentImagePuzzle.js +8 -20
  4. package/dist/components/comic-component/components/ComicComponent.js +4 -2
  5. package/dist/components/conversational-pro-component/components/ConversationalProComponent.js +48 -144
  6. package/dist/components/conversational-pro-component/components/SlotList.js +2 -6
  7. package/dist/components/conversational-pro-component/components/scene/Panel.js +10 -72
  8. package/dist/components/conversational-pro-component/components/scene/Panels.js +1 -3
  9. package/dist/components/conversational-pro-component/components/scene/index.js +1 -8
  10. package/dist/components/dialog-component/components/DialogComponent.js +81 -202
  11. package/dist/components/feedback-component/components/FeedbackComponent.js +3 -2
  12. package/dist/components/frame-click-puzzle-component/components/CurrentFramePuzzle.js +3 -16
  13. package/dist/components/frame-click-puzzle-component/components/FrameClickPuzzleComponent.js +2 -4
  14. package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js +1 -9
  15. package/dist/components/lectures-component/components/LecturesComponent.js +1 -1
  16. package/dist/components/survey-component/components/SurveyComponent.js +2 -4
  17. package/dist/components/terminal-puzzle-component/components/Visor/index.js +1 -1
  18. package/dist/components/test-component/components/Container.js +3 -4
  19. package/dist/components/test-component/components/TestComponent.js +4 -11
  20. package/dist/helpers/index.js +4 -70
  21. package/dist/helpers/useEkho.js +5 -1
  22. package/package.json +2 -2
@@ -20,7 +20,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
20
20
  var Panels = function Panels(_ref) {
21
21
  var characters = _ref.characters,
22
22
  slots = _ref.slots,
23
- ttsStarted = _ref.ttsStarted,
24
23
  activeIndex = _ref.activeIndex,
25
24
  flex = _ref.flex,
26
25
  lodSettings = _ref.lodSettings;
@@ -38,8 +37,7 @@ var Panels = function Panels(_ref) {
38
37
  key: "".concat("".concat(currentCharacter.uid, "_").concat(slotPosition), "_", characterPos),
39
38
  character: currentCharacter,
40
39
  active: activeIndex === currentPosition,
41
- lodSettings: lodSettings,
42
- ttsStarted: ttsStarted
40
+ lodSettings: lodSettings
43
41
  });
44
42
  }
45
43
 
@@ -36,7 +36,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
36
36
  var PanelsWrapper = function PanelsWrapper(_ref) {
37
37
  var characters = _ref.characters,
38
38
  slots = _ref.slots,
39
- ttsStarted = _ref.ttsStarted,
40
39
  slotRefs = _ref.slotRefs,
41
40
  flex = _ref.flex,
42
41
  currentMessage = _ref.currentMessage;
@@ -57,7 +56,6 @@ var PanelsWrapper = function PanelsWrapper(_ref) {
57
56
  finishBuild(true);
58
57
  }, []);
59
58
  return built ? /*#__PURE__*/_react.default.createElement(_Panels.default, {
60
- ttsStarted: ttsStarted,
61
59
  characters: characters,
62
60
  slots: slots,
63
61
  slotRefs: slotRefs,
@@ -79,13 +77,8 @@ var Scene = function Scene(props) {
79
77
  var gl = _ref3.gl;
80
78
  gl.setClearColor('white', 0);
81
79
  gl.physicallyCorrectLights = true;
82
- },
83
- frameloop: "demand"
84
- }, /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.SettingsController, {
85
- current: {
86
- animate: props.pause
87
80
  }
88
- }), /*#__PURE__*/_react.default.createElement(_react.Suspense, {
81
+ }, /*#__PURE__*/_react.default.createElement(_react.Suspense, {
89
82
  fallback: null
90
83
  }, /*#__PURE__*/_react.default.createElement(PanelsWrapper, props)));
91
84
  };
@@ -69,7 +69,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
69
69
 
70
70
  // Global
71
71
  var isMobile = (0, _deviceDetection.DeviceDetection)();
72
- var crossFadeDuration = 0.2;
72
+ var crossFadeDuration = 0.5;
73
73
  var characterMs = 75;
74
74
  var minMs = 1400;
75
75
  var headSize = 2; // Mobile always zoom in?
@@ -79,16 +79,13 @@ var maxCharacterToSwitch = 70;
79
79
  raycast.firstHitOnly = true;
80
80
 
81
81
  var DialogComponent = function DialogComponent(_ref) {
82
- var _currentLineData$slot;
83
-
84
82
  var emitEvent = _ref.emitEvent,
85
83
  lines = _ref.lines,
86
84
  actors = _ref.actors,
87
85
  edges = _ref.edges,
88
86
  soundActions = _ref.soundActions,
89
87
  zoomInActor = _ref.zoomInActor,
90
- autoPlay = _ref.autoPlay,
91
- pause = _ref.pause;
88
+ autoPlay = _ref.autoPlay;
92
89
 
93
90
  var _useState = (0, _react.useState)(0),
94
91
  _useState2 = _slicedToArray(_useState, 2),
@@ -100,15 +97,25 @@ var DialogComponent = function DialogComponent(_ref) {
100
97
  automatic = _useState4[0],
101
98
  setAutomatic = _useState4[1];
102
99
 
103
- var _useState5 = (0, _react.useState)(false),
100
+ var _useState5 = (0, _react.useState)({
101
+ text: '',
102
+ name: '',
103
+ left: false,
104
+ top: false,
105
+ inScene: false,
106
+ thinkful: false,
107
+ voiceOver: false,
108
+ avatar: '',
109
+ show: false
110
+ }),
104
111
  _useState6 = _slicedToArray(_useState5, 2),
105
- mounted = _useState6[0],
106
- setMounted = _useState6[1];
112
+ currentMessage = _useState6[0],
113
+ setCurrentMessage = _useState6[1];
107
114
 
108
115
  var _useState7 = (0, _react.useState)(false),
109
116
  _useState8 = _slicedToArray(_useState7, 2),
110
- talking = _useState8[0],
111
- startTalking = _useState8[1];
117
+ mounted = _useState8[0],
118
+ setMounted = _useState8[1];
112
119
 
113
120
  var _useState9 = (0, _react.useState)(false),
114
121
  _useState10 = _slicedToArray(_useState9, 2),
@@ -147,39 +154,15 @@ var DialogComponent = function DialogComponent(_ref) {
147
154
  setAnimationRunning = _useState12[1];
148
155
 
149
156
  var animationTarget = (0, _react.useRef)(new _three.Object3D());
150
- var currentLineData = lines[line];
157
+ var currentLine = lines[line];
151
158
  var lastLine = lines[line - 1];
152
159
  var lastSet = (0, _react.useRef)(false);
153
160
  var isBranched = !!edges;
154
161
 
155
- var _ref2 = currentLineData || {},
162
+ var _ref2 = currentLine || {},
156
163
  voiceOver = _ref2.voiceOver,
157
164
  decision = _ref2.decision;
158
165
 
159
- var talkingCharacter = currentLineData === null || currentLineData === void 0 ? void 0 : (_currentLineData$slot = currentLineData.slots) === null || _currentLineData$slot === void 0 ? void 0 : _currentLineData$slot.find(function (slot) {
160
- return slot.talking;
161
- });
162
- var autoPlayCond = automatic && !(currentLineData !== null && currentLineData !== void 0 && currentLineData.decision);
163
- var audio = Object.keys((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audio) || {}).length;
164
- var voice = Object.keys((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.voice) || {}).length;
165
- var isVoiceOver = voiceOver || (currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.type) === 'conversationalNarration';
166
- var isDecision = decision || (currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.type) === 'conversationalDecision';
167
-
168
- var _useState13 = (0, _react.useState)({
169
- text: '',
170
- name: '',
171
- left: false,
172
- top: false,
173
- inScene: false,
174
- thinkful: false,
175
- voiceOver: false,
176
- avatar: '',
177
- show: false
178
- }),
179
- _useState14 = _slicedToArray(_useState13, 2),
180
- currentMessage = _useState14[0],
181
- setCurrentMessage = _useState14[1];
182
-
183
166
  var charactersInvolved = (0, _react.useMemo)(function () {
184
167
  return lines.reduce(function (acc, current) {
185
168
  if (current.slots) {
@@ -201,37 +184,14 @@ var DialogComponent = function DialogComponent(_ref) {
201
184
  });
202
185
  }, [emitEvent]);
203
186
 
204
- var _useState15 = (0, _react.useState)([]),
205
- _useState16 = _slicedToArray(_useState15, 2),
206
- edgesHistory = _useState16[0],
207
- setEdgesHistory = _useState16[1];
208
-
209
- var lastNodeId = (0, _react.useMemo)(function () {
210
- return edgesHistory[edgesHistory.length - 1];
211
- }, [edgesHistory]);
212
- var findLastLineBranched = (0, _react.useCallback)(function () {
213
- var lastEdge = edges.find(function (edge) {
214
- return edge.fromId === lastNodeId;
215
- });
216
- var lastL = lines.find(function (l) {
217
- return l.id === lastEdge.fromId;
218
- });
219
- return lastL;
220
- }, [edges, lines, lastNodeId]);
221
- var previousLineWasDecision = (0, _react.useCallback)(function () {
222
- if (isBranched) {
223
- // if we have edges, we need to check if the previous line was a decision
224
- var _lastL = findLastLineBranched();
225
-
226
- return _lastL === null || _lastL === void 0 ? void 0 : _lastL.decision;
227
- } // if there is no branching, the previous line is the previous one
228
-
187
+ var _useState13 = (0, _react.useState)(false),
188
+ _useState14 = _slicedToArray(_useState13, 2),
189
+ previousLineWasDecision = _useState14[0],
190
+ setPreviousLineWasDecision = _useState14[1];
229
191
 
230
- var lastL = lines[currentLineData - 1] ? lines[currentLineData - 1] : {};
231
- return currentLineData > 0 && (lastL === null || lastL === void 0 ? void 0 : lastL.decision);
232
- }, [currentLineData, isBranched, lines, lastNodeId, edges]);
192
+ var isVoiceOver = voiceOver || (currentLine === null || currentLine === void 0 ? void 0 : currentLine.type) === 'conversationalNarration';
193
+ var isDecision = decision || (currentLine === null || currentLine === void 0 ? void 0 : currentLine.type) === 'conversationalDecision';
233
194
  var getCurrentVisible = (0, _react.useCallback)(function (uid) {
234
- if (!uid) return null;
235
195
  var object;
236
196
  scene.traverseVisible(function (node) {
237
197
  if (node.uid === uid && !object) {
@@ -280,8 +240,6 @@ var DialogComponent = function DialogComponent(_ref) {
280
240
  }, [loader]); // Force default animation without transition
281
241
 
282
242
  var executeDefaultAnimation = function executeDefaultAnimation(element) {
283
- if (!talkingCharacter || element.uid === talkingCharacter.uid) return;
284
-
285
243
  if (element.userData.mixer && element.userData.defaultAnim) {
286
244
  var mixer = element.userData.mixer;
287
245
  var defaultAction = mixer.clipAction(element.userData.defaultAnim, element);
@@ -301,43 +259,6 @@ var DialogComponent = function DialogComponent(_ref) {
301
259
  messagePosition.current.parent = null;
302
260
  if (zoomInActor) setAnimationRunning(true);
303
261
  }, [zoomInActor]);
304
-
305
- var restTalkingAnimation = function restTalkingAnimation() {
306
- var element = getCurrentVisible(talkingCharacter === null || talkingCharacter === void 0 ? void 0 : talkingCharacter.uid);
307
-
308
- if (!element) {
309
- startTalking(false);
310
- return;
311
- }
312
-
313
- var _element$userData = element.userData,
314
- mixer = _element$userData.mixer,
315
- defaultAnim = _element$userData.defaultAnim,
316
- emotionClip = _element$userData.emotionClip;
317
-
318
- if (defaultAnim && emotionClip) {
319
- var emotionAction = mixer.clipAction(emotionClip, element);
320
- var defaultAction = mixer.clipAction(defaultAnim, element);
321
- mixer.stopAllAction();
322
- (0, _helpers.executeCrossFade)(emotionAction, defaultAction, crossFadeDuration);
323
- }
324
-
325
- startTalking(false);
326
- };
327
-
328
- (0, _react.useEffect)(function () {
329
- var element = getCurrentVisible(talkingCharacter === null || talkingCharacter === void 0 ? void 0 : talkingCharacter.uid);
330
-
331
- if (element) {
332
- if (talking) {
333
- var _talkingCharacter$cha, _talkingCharacter$cha2, _talkingCharacter$cha3, _talkingCharacter$cha4;
334
-
335
- (0, _helpers.executeTalkingAnimation)(element, talkingCharacter === null || talkingCharacter === void 0 ? void 0 : (_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : (_talkingCharacter$cha2 = _talkingCharacter$cha.resource) === null || _talkingCharacter$cha2 === void 0 ? void 0 : (_talkingCharacter$cha3 = _talkingCharacter$cha2.animations) === null || _talkingCharacter$cha3 === void 0 ? void 0 : (_talkingCharacter$cha4 = _talkingCharacter$cha3.talking) === null || _talkingCharacter$cha4 === void 0 ? void 0 : _talkingCharacter$cha4.url);
336
- } else {
337
- restTalkingAnimation();
338
- }
339
- }
340
- }, [talkingCharacter, talking]);
341
262
  var finishConversation = (0, _react.useCallback)(function () {
342
263
  lastSet.current = true;
343
264
  changeLine(0);
@@ -354,39 +275,31 @@ var DialogComponent = function DialogComponent(_ref) {
354
275
  var handleBranchDirection = (0, _react.useCallback)(function () {
355
276
  var forward = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
356
277
  var keys = forward ? ['fromId', 'toId'] : ['toId', 'fromId'];
357
- var foundEdges = edges.filter(function (edge) {
358
- return edge[keys[0]] === currentLineData.id;
359
- });
360
- var foundEdge = foundEdges.length === 1 ? foundEdges[0] : foundEdges.find(function (edge) {
361
- return edge[keys[1]] === lastNodeId;
278
+ var foundEdge = edges.find(function (edge) {
279
+ return edge[keys[0]] === (currentLine === null || currentLine === void 0 ? void 0 : currentLine.id);
362
280
  });
363
281
 
364
282
  if (!(foundEdge !== null && foundEdge !== void 0 && foundEdge[keys[0]])) {
365
- return;
366
- } // if going backwards remove last edge from history
367
-
368
-
369
- if (!forward) {
370
- setEdgesHistory(edgesHistory.slice(0, edgesHistory.length - 1));
371
- }
372
-
373
- var destination = lines.findIndex(function (l) {
374
- return l.id === foundEdge[keys[1]];
375
- });
376
-
377
- if (destination >= 0) {
378
- setCurrentMessage({
379
- show: false
380
- });
381
- changeLine(destination);
382
- } else {
383
283
  finishConversation();
284
+ } else {
285
+ var destination = lines.findIndex(function (l) {
286
+ return l.id === foundEdge[keys[1]];
287
+ });
288
+
289
+ if (destination >= 0) {
290
+ setCurrentMessage({
291
+ show: false
292
+ });
293
+ changeLine(destination);
294
+ } else {
295
+ finishConversation();
296
+ }
384
297
  }
385
- }, [currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.id, edges, finishConversation, lines]);
298
+ }, [currentLine === null || currentLine === void 0 ? void 0 : currentLine.id, edges, finishConversation, lines]);
386
299
  var handleDecisionBranch = (0, _react.useCallback)(function (choice, reset) {
387
300
  var currentId = [3, 2, 1][choice.id];
388
301
  var optionsEdges = edges.filter(function (edge) {
389
- return edge.fromId === (currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.id);
302
+ return edge.fromId === (currentLine === null || currentLine === void 0 ? void 0 : currentLine.id);
390
303
  });
391
304
  var currentEdge = optionsEdges.find(function (edge) {
392
305
  return parseInt(edge.fromPointIndex) === currentId;
@@ -407,14 +320,13 @@ var DialogComponent = function DialogComponent(_ref) {
407
320
  } else {
408
321
  finishConversation();
409
322
  }
410
- }, [currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.id, edges, finishConversation, lines]);
323
+ }, [currentLine === null || currentLine === void 0 ? void 0 : currentLine.id, edges, finishConversation, lines]);
411
324
  var backLine = (0, _react.useCallback)(function () {
412
- restTalkingAnimation();
413
325
  setAudioFailed(false);
414
326
 
415
327
  if (isBranched) {
416
328
  handleBranchDirection(false);
417
- } else if (previousLineWasDecision()) {
329
+ } else if (lastLine && !(lastLine !== null && lastLine !== void 0 && lastLine.decision) || lastLine.type && !lastLine.type !== 'conversationalDecision') {
418
330
  setCurrentMessage({
419
331
  show: false
420
332
  });
@@ -422,8 +334,7 @@ var DialogComponent = function DialogComponent(_ref) {
422
334
  }
423
335
  }, [handleBranchDirection, isBranched, lastLine, line]);
424
336
  var nextLine = (0, _react.useCallback)(function (choice, reset) {
425
- restTalkingAnimation();
426
- setEdgesHistory([].concat(_toConsumableArray(edgesHistory), [currentLineData.id]));
337
+ setPreviousLineWasDecision(currentLine.decision);
427
338
  setAudioFailed(false);
428
339
 
429
340
  if (isBranched) {
@@ -437,34 +348,19 @@ var DialogComponent = function DialogComponent(_ref) {
437
348
  show: false
438
349
  });
439
350
  changeLine(line + 1);
440
- } else if (currentLineData.decision) {
351
+ } else {
441
352
  finishConversation();
442
353
  }
443
- }, [currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.decision, isBranched, line, lines.length, handleDecisionBranch, handleBranchDirection, finishConversation]);
354
+ }, [currentLine === null || currentLine === void 0 ? void 0 : currentLine.decision, isBranched, line, lines.length, handleDecisionBranch, handleBranchDirection, finishConversation]);
444
355
 
445
356
  var manualBackLine = function manualBackLine() {
446
357
  setAutomatic(false);
447
358
  backLine();
448
359
  };
449
360
 
450
- var isEndNode = function isEndNode() {
451
- if (isBranched) {
452
- return currentLineData && currentLineData.type !== 'conversationalDecision' && !edges.find(function (edge) {
453
- return edge.fromId === currentLineData.id;
454
- });
455
- }
456
-
457
- return line === lines.length - 1;
458
- };
459
-
460
361
  var manualNextLine = function manualNextLine() {
461
- if (isEndNode()) {
462
- startTalking(false);
463
- finishConversation();
464
- } else {
465
- setAutomatic(false);
466
- nextLine();
467
- }
362
+ setAutomatic(false);
363
+ nextLine();
468
364
  }; // Calculate start node
469
365
 
470
366
 
@@ -525,8 +421,8 @@ var DialogComponent = function DialogComponent(_ref) {
525
421
  } else if (isVoiceOver) {
526
422
  resetCameraView();
527
423
  setCurrentMessage({
528
- text: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.text,
529
- name: (currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.alias) || (currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.name) || "[ ".concat(translate('storylines.misc.voiceOver'), " ]"),
424
+ text: currentLine === null || currentLine === void 0 ? void 0 : currentLine.text,
425
+ name: (currentLine === null || currentLine === void 0 ? void 0 : currentLine.alias) || (currentLine === null || currentLine === void 0 ? void 0 : currentLine.name) || "[ ".concat(translate('storylines.misc.voiceOver'), " ]"),
530
426
  left: false,
531
427
  inScene: false,
532
428
  voiceOver: true,
@@ -536,7 +432,10 @@ var DialogComponent = function DialogComponent(_ref) {
536
432
  show: true
537
433
  });
538
434
  } else if (!lastSet.current) {
539
- var slottedCharacters = currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.slots.filter(function (slot) {
435
+ var talkingCharacter = currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots.find(function (slot) {
436
+ return slot.talking;
437
+ });
438
+ var slottedCharacters = currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots.filter(function (slot) {
540
439
  return slot.uid && !slot.talking;
541
440
  });
542
441
  var currentParticipants = [].concat(_toConsumableArray(slottedCharacters.map(function (slot) {
@@ -577,7 +476,6 @@ var DialogComponent = function DialogComponent(_ref) {
577
476
  if (startAction && action && startAction !== action) {
578
477
  mixer.stopAllAction();
579
478
  (0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration);
580
- element.userData.defaultAnim = action.getClip();
581
479
  }
582
480
 
583
481
  if (talkingCharacter.uid === element.uid) {
@@ -589,14 +487,14 @@ var DialogComponent = function DialogComponent(_ref) {
589
487
  }
590
488
 
591
489
  setTimeout(function () {
592
- var _talkingCharacter$cha5;
490
+ var _talkingCharacter$cha;
593
491
 
594
492
  var _moveBubble = moveBubble(element, showArrowTop),
595
493
  distance = _moveBubble.distance;
596
494
 
597
495
  setCurrentMessage({
598
496
  text: talkingCharacter.text,
599
- name: talkingCharacter.alias || ((_talkingCharacter$cha5 = talkingCharacter.character) === null || _talkingCharacter$cha5 === void 0 ? void 0 : _talkingCharacter$cha5.name),
497
+ name: talkingCharacter.alias || ((_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : _talkingCharacter$cha.name),
600
498
  left: true,
601
499
  top: showArrowTop || distance > 70,
602
500
  inScene: true,
@@ -608,12 +506,12 @@ var DialogComponent = function DialogComponent(_ref) {
608
506
  }
609
507
  });
610
508
  } else {
611
- var _talkingCharacter$cha6;
509
+ var _talkingCharacter$cha2;
612
510
 
613
511
  resetCameraView();
614
512
  setCurrentMessage({
615
513
  text: talkingCharacter.text,
616
- name: talkingCharacter.alias || ((_talkingCharacter$cha6 = talkingCharacter.character) === null || _talkingCharacter$cha6 === void 0 ? void 0 : _talkingCharacter$cha6.name) || (object === null || object === void 0 ? void 0 : object.name),
514
+ name: talkingCharacter.alias || ((_talkingCharacter$cha2 = talkingCharacter.character) === null || _talkingCharacter$cha2 === void 0 ? void 0 : _talkingCharacter$cha2.name) || (object === null || object === void 0 ? void 0 : object.name),
617
515
  left: false,
618
516
  top: talkingCharacter.text.length > maxCharacterToSwitch,
619
517
  inScene: false,
@@ -629,31 +527,25 @@ var DialogComponent = function DialogComponent(_ref) {
629
527
  });
630
528
  }
631
529
  }
632
- }, [actors, camera, currentLineData, zoomInActor, getCurrentVisible, translate, getAvatarURL, loadEmotion, resetCameraView, isDecision, isVoiceOver, charactersInvolved]); // Sound logic
530
+ }, [actors, camera, currentLine, zoomInActor, getCurrentVisible, translate, getAvatarURL, loadEmotion, resetCameraView, isDecision, isVoiceOver, charactersInvolved]);
531
+ var autoPlayCond = automatic && !(currentLine !== null && currentLine !== void 0 && currentLine.decision);
532
+ var audio = Object.keys((currentLine === null || currentLine === void 0 ? void 0 : currentLine.audio) || {}).length;
533
+ var voice = Object.keys((currentLine === null || currentLine === void 0 ? void 0 : currentLine.voice) || {}).length; // Sound logic
633
534
 
634
535
  var stopEkho = (0, _useEkho.default)({
635
- audioType: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType,
636
- volume: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioVolume,
637
- voice: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.voice,
536
+ audioType: currentLine === null || currentLine === void 0 ? void 0 : currentLine.audioType,
537
+ volume: currentLine === null || currentLine === void 0 ? void 0 : currentLine.audioVolume,
538
+ voice: currentLine === null || currentLine === void 0 ? void 0 : currentLine.voice,
638
539
  started: currentMessage.show,
639
540
  text: currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.text,
640
- audio: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audio,
541
+ audio: currentLine === null || currentLine === void 0 ? void 0 : currentLine.audio,
641
542
  soundActions: soundActions,
642
543
  emitEvent: emitEvent,
643
- pause: pause,
644
- onStart: function onStart() {
645
- var _talkingCharacter$emo;
646
-
647
- if (talkingCharacter !== null && talkingCharacter !== void 0 && (_talkingCharacter$emo = talkingCharacter.emotion) !== null && _talkingCharacter$emo !== void 0 && _talkingCharacter$emo.includes('think')) return;
648
- startTalking(true);
649
- },
650
544
  onError: function onError() {
651
545
  setAudioFailed(true);
652
546
  },
653
547
  onFinish: function onFinish() {
654
- startTalking(false);
655
-
656
- if (autoPlayCond && !pause) {
548
+ if (autoPlayCond) {
657
549
  nextLine();
658
550
  }
659
551
  }
@@ -663,40 +555,29 @@ var DialogComponent = function DialogComponent(_ref) {
663
555
  return function () {
664
556
  stopEkho();
665
557
  };
666
- }, [line, stopEkho]);
558
+ }, [line, stopEkho]); // Autoplay logic
559
+
667
560
  (0, _react.useEffect)(function () {
668
- if (((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed) && currentMessage !== null && currentMessage !== void 0 && currentMessage.show && (talkingCharacter === null || talkingCharacter === void 0 ? void 0 : talkingCharacter.emotion) !== 'thinkful') {
561
+ if (autoPlayCond && currentMessage.show && ((currentLine === null || currentLine === void 0 ? void 0 : currentLine.audioType) === 'none' || audioFailed)) {
669
562
  var _currentMessage$text;
670
563
 
671
- startTalking(true);
672
564
  var time = characterMs * ((currentMessage === null || currentMessage === void 0 ? void 0 : (_currentMessage$text = currentMessage.text) === null || _currentMessage$text === void 0 ? void 0 : _currentMessage$text.length) || 0);
673
- setTimeout(function () {
674
- startTalking(false);
675
- }, time < minMs ? minMs : time);
676
- }
677
- }, [audioFailed, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, talkingCharacter === null || talkingCharacter === void 0 ? void 0 : talkingCharacter.emotion, currentMessage]); // Autoplay logic
678
-
679
- (0, _react.useEffect)(function () {
680
- if (autoPlayCond && currentMessage.show && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed) && !pause) {
681
- var _currentMessage$text2;
682
-
683
- var time = characterMs * ((currentMessage === null || currentMessage === void 0 ? void 0 : (_currentMessage$text2 = currentMessage.text) === null || _currentMessage$text2 === void 0 ? void 0 : _currentMessage$text2.length) || 0); // if it's not last node
684
-
685
- if (!isEndNode()) {
686
- start(nextLine, time < minMs ? minMs : time);
687
- }
565
+ start(nextLine, time < minMs ? minMs : time);
688
566
  }
689
567
 
690
568
  return function () {
691
569
  stop();
692
570
  };
693
- }, [currentMessage, nextLine, start, stop, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoPlayCond, audio, voice, audioFailed]); // Positioning Bubble Message logic
571
+ }, [currentMessage, nextLine, start, stop, currentLine === null || currentLine === void 0 ? void 0 : currentLine.audioType, autoPlayCond, audio, voice, audioFailed]); // Positioning Bubble Message logic
694
572
 
695
573
  var checkBubbleBounds = (0, _react.useCallback)(function (group, bubble) {
696
574
  groupRef.current = group === null || group === void 0 ? void 0 : group.current;
697
575
  bubbleRef.current = bubble === null || bubble === void 0 ? void 0 : bubble.current;
698
576
 
699
- if (currentLineData !== null && currentLineData !== void 0 && currentLineData.slots && currentMessage.show && bubble !== null && bubble !== void 0 && bubble.current) {
577
+ if (currentLine !== null && currentLine !== void 0 && currentLine.slots && currentMessage.show && bubble !== null && bubble !== void 0 && bubble.current) {
578
+ var talkingCharacter = currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots.find(function (slot) {
579
+ return slot.talking;
580
+ });
700
581
  var bubbleRect = bubble.current.getBoundingClientRect();
701
582
  var x = bubbleRect.x + bubbleRect.width;
702
583
  var y = bubbleRect.y - bubbleRect.height;
@@ -736,7 +617,7 @@ var DialogComponent = function DialogComponent(_ref) {
736
617
  bubble.current.parentNode.style.transform = '';
737
618
  }
738
619
  }
739
- }, [camera.quaternion, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.slots, currentMessage.inScene, getAvatarURL]);
620
+ }, [camera.quaternion, currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots, currentMessage.inScene, getAvatarURL]);
740
621
  (0, _react.useEffect)(function () {
741
622
  if (animationRunning) {
742
623
  var cam = camera;
@@ -807,10 +688,10 @@ var DialogComponent = function DialogComponent(_ref) {
807
688
  height: '100vh',
808
689
  position: 'static'
809
690
  };
810
- var disableBackButton = line === 0 || previousLineWasDecision();
691
+ var disableBackButton = line === 0 || previousLineWasDecision || line > 0 && (lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision);
811
692
 
812
693
  if (isDecision) {
813
- var decisionPayload = _objectSpread(_objectSpread({}, currentLineData.payload), {}, {
694
+ var decisionPayload = _objectSpread(_objectSpread({}, currentLine.payload), {}, {
814
695
  inheritProps: {
815
696
  slots: [],
816
697
  disableBackground: true
@@ -819,7 +700,6 @@ var DialogComponent = function DialogComponent(_ref) {
819
700
  branched: isBranched,
820
701
  onFinish: nextLine,
821
702
  emitEvent: emitEvent,
822
- pause: pause,
823
703
  soundActions: soundActions
824
704
  });
825
705
 
@@ -829,7 +709,6 @@ var DialogComponent = function DialogComponent(_ref) {
829
709
  portal: container ? {
830
710
  current: container
831
711
  } : undefined,
832
- onOcclude: function onOcclude() {},
833
712
  calculatePosition: function calculatePosition() {
834
713
  return [0, 0];
835
714
  }
@@ -869,7 +748,7 @@ var DialogComponent = function DialogComponent(_ref) {
869
748
  type: "button",
870
749
  onClick: manualNextLine,
871
750
  disabled: animationRunning,
872
- className: "gat--btn__round \n ".concat(animationRunning ? 'disabled' : '', "\n ").concat(automatic && isEndNode() ? 'glowing-animation' : '')
751
+ className: "gat--btn__round ".concat(animationRunning ? 'disabled' : '')
873
752
  }, /*#__PURE__*/_react.default.createElement("span", {
874
753
  className: (0, _LangIsRtl.default)() ? 'icon-back' : 'icon-next'
875
754
  })))));
@@ -95,14 +95,15 @@ var FeedbackComponent = function FeedbackComponent(_ref) {
95
95
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
96
96
  className: "feedback-layer ".concat(explain ? 'feedback-layer--withexplain' : '')
97
97
  }, /*#__PURE__*/_react.default.createElement("div", {
98
- className: "feedback-layer__header ".concat(shortText ? 'feedback-layer__header--in-shortText' : '', " ").concat(additionalStyle || '', " ").concat(statusColor())
98
+ // eslint-disable-next-line prettier/prettier
99
+ className: "feedback-layer__header ".concat(additionalStyle || '', " ").concat(statusColor())
99
100
  }, secondText && /*#__PURE__*/_react.default.createElement("span", {
100
101
  className: "puzzle--terminal__visor--file"
101
102
  }, /*#__PURE__*/_react.default.createElement("span", {
102
103
  className: "puzzle--terminal__icon ".concat(additionalStyle || '')
103
104
  }), /*#__PURE__*/_react.default.createElement("span", null, secondText)), /*#__PURE__*/_react.default.createElement("span", {
104
105
  className: "feedback-layer__maintitle"
105
- }, !text || !shortText ? /*#__PURE__*/_react.default.createElement("div", {
106
+ }, !shortText ? /*#__PURE__*/_react.default.createElement("div", {
106
107
  title: translate("tooltip.".concat(success ? 'correct' : 'incorrect')),
107
108
  className: "".concat(statusIcon())
108
109
  }) : text), text && functionOnClose && explain && /*#__PURE__*/_react.default.createElement("button", {
@@ -61,8 +61,7 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
61
61
  firstTryForFrame = _ref.firstTryForFrame,
62
62
  setPuzzlesAutoCompleted = _ref.setPuzzlesAutoCompleted,
63
63
  puzzlesAutoCompleted = _ref.puzzlesAutoCompleted,
64
- emitOpenPopupCounterInfo = _ref.emitOpenPopupCounterInfo,
65
- pause = _ref.pause;
64
+ emitOpenPopupCounterInfo = _ref.emitOpenPopupCounterInfo;
66
65
 
67
66
  var _soundActions = _slicedToArray(soundActions, 1),
68
67
  playSound = _soundActions[0];
@@ -71,7 +70,6 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
71
70
  var info = props.info,
72
71
  specificFeedbacks = props.specificFeedbacks;
73
72
  info.description = description;
74
- var currentSelected = (0, _react.useRef)(0);
75
73
  var correctClicked = (0, _react.useRef)(0);
76
74
  var puzzleId = "frame-image-click-puzzle_".concat(index, "_").concat(nodeId);
77
75
  (0, _react.useEffect)(function () {
@@ -84,7 +82,6 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
84
82
  }, [setInfo, info, puzzleId]);
85
83
  (0, _react.useEffect)(function () {
86
84
  correctClicked.current = 0;
87
- currentSelected.current = 0;
88
85
  }, [index]);
89
86
  var onComplete = (0, _react.useCallback)(function (rw) {
90
87
  var correct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
@@ -98,14 +95,7 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
98
95
  if (specificFeedbacks !== null && specificFeedbacks !== void 0 && (_specificFeedbacks$co = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co !== void 0 && _specificFeedbacks$co.length && !props.hasClickOnce && !finish) {
99
96
  correctClicked.current += 1;
100
97
  } else {
101
- var total = selected;
102
-
103
- if (currentSelected.current) {
104
- total -= currentSelected.current;
105
- }
106
-
107
- correctClicked.current = props.areas.length;
108
- setSelected(total + correctClicked.current);
98
+ correctClicked.current += props.areas.length;
109
99
  }
110
100
 
111
101
  if (correctClicked.current === props.areas.length) {
@@ -156,7 +146,6 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
156
146
  var handleResetPuzzle = (0, _react.useCallback)(function () {
157
147
  setFramesCompleted({});
158
148
  correctClicked.current = 0;
159
- currentSelected.current = 0;
160
149
  emitResetPuzzle();
161
150
  }, [emitResetPuzzle, setFramesCompleted]);
162
151
  (0, _react.useEffect)(function () {
@@ -167,7 +156,6 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
167
156
 
168
157
  var checkSelectedAreas = function checkSelectedAreas() {
169
158
  var areasSelected = props.hasClickOnce ? props.areas.length : 1;
170
- currentSelected.current += areasSelected;
171
159
  setSelected(selected + areasSelected);
172
160
  };
173
161
 
@@ -195,8 +183,7 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
195
183
  emitResetPuzzle: handleResetPuzzle,
196
184
  firstTryForFrame: firstTryForFrame,
197
185
  puzzlesAutoCompleted: puzzlesAutoCompleted,
198
- emitOpenPopupCounterInfo: emitOpenPopupCounterInfo,
199
- pause: pause
186
+ emitOpenPopupCounterInfo: emitOpenPopupCounterInfo
200
187
  }));
201
188
  };
202
189