react-native-my-survey-sdk 3.1.2 → 4.0.0

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 (65) hide show
  1. package/dist/components/XeboDropdownView.d.ts +6 -2
  2. package/dist/components/XeboDropdownView.d.ts.map +1 -1
  3. package/dist/components/XeboDropdownView.js +35 -22
  4. package/dist/components/XeboIntroView.d.ts.map +1 -1
  5. package/dist/components/XeboIntroView.js +3 -2
  6. package/dist/components/XeboLanguageView.d.ts +11 -0
  7. package/dist/components/XeboLanguageView.d.ts.map +1 -0
  8. package/dist/components/XeboLanguageView.js +90 -0
  9. package/dist/components/XeboMultiNPSView.d.ts +4 -2
  10. package/dist/components/XeboMultiNPSView.d.ts.map +1 -1
  11. package/dist/components/XeboMultiNPSView.js +32 -23
  12. package/dist/components/XeboMultiRatingView.d.ts +4 -2
  13. package/dist/components/XeboMultiRatingView.d.ts.map +1 -1
  14. package/dist/components/XeboMultiRatingView.js +31 -22
  15. package/dist/components/XeboMultipleChoiceView.d.ts +6 -2
  16. package/dist/components/XeboMultipleChoiceView.d.ts.map +1 -1
  17. package/dist/components/XeboMultipleChoiceView.js +43 -44
  18. package/dist/components/XeboNPSView.d.ts +8 -2
  19. package/dist/components/XeboNPSView.d.ts.map +1 -1
  20. package/dist/components/XeboNPSView.js +315 -55
  21. package/dist/components/XeboPageView.d.ts +33 -0
  22. package/dist/components/XeboPageView.d.ts.map +1 -0
  23. package/dist/components/XeboPageView.js +190 -0
  24. package/dist/components/XeboRatingView.d.ts +20 -2
  25. package/dist/components/XeboRatingView.d.ts.map +1 -1
  26. package/dist/components/XeboRatingView.js +71 -43
  27. package/dist/components/XeboSingleChoiceView.d.ts +8 -2
  28. package/dist/components/XeboSingleChoiceView.d.ts.map +1 -1
  29. package/dist/components/XeboSingleChoiceView.js +50 -46
  30. package/dist/components/XeboSurveyModal.d.ts.map +1 -1
  31. package/dist/components/XeboSurveyModal.js +236 -42
  32. package/dist/components/XeboTextBoxView.d.ts +4 -2
  33. package/dist/components/XeboTextBoxView.d.ts.map +1 -1
  34. package/dist/components/XeboTextBoxView.js +35 -23
  35. package/dist/components/XeboThankYouView.d.ts.map +1 -1
  36. package/dist/components/XeboThankYouView.js +3 -2
  37. package/dist/core/XeboLanguageService.d.ts +28 -0
  38. package/dist/core/XeboLanguageService.d.ts.map +1 -0
  39. package/dist/core/XeboLanguageService.js +267 -0
  40. package/dist/core/XeboNetworkService.d.ts +24 -3
  41. package/dist/core/XeboNetworkService.d.ts.map +1 -1
  42. package/dist/core/XeboNetworkService.js +202 -69
  43. package/dist/core/XeboOfflineQueue.d.ts +2 -1
  44. package/dist/core/XeboOfflineQueue.d.ts.map +1 -1
  45. package/dist/core/XeboOfflineQueue.js +24 -10
  46. package/dist/core/XeboSurveyManager.d.ts +38 -2
  47. package/dist/core/XeboSurveyManager.d.ts.map +1 -1
  48. package/dist/core/XeboSurveyManager.js +246 -72
  49. package/dist/i18n/XeboRtl.d.ts +16 -0
  50. package/dist/i18n/XeboRtl.d.ts.map +1 -0
  51. package/dist/i18n/XeboRtl.js +32 -0
  52. package/dist/i18n/XeboStrings.d.ts +35 -0
  53. package/dist/i18n/XeboStrings.d.ts.map +1 -0
  54. package/dist/i18n/XeboStrings.js +73 -0
  55. package/dist/index.d.ts +3 -1
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/models/XeboAPIModels.d.ts +103 -1
  58. package/dist/models/XeboAPIModels.d.ts.map +1 -1
  59. package/dist/models/XeboLanguageModels.d.ts +62 -0
  60. package/dist/models/XeboLanguageModels.d.ts.map +1 -0
  61. package/dist/models/XeboLanguageModels.js +3 -0
  62. package/dist/models/XeboModels.d.ts +93 -2
  63. package/dist/models/XeboModels.d.ts.map +1 -1
  64. package/dist/models/XeboModels.js +24 -0
  65. package/package.json +5 -5
@@ -6,11 +6,19 @@ exports.buildFeedbackBaseURL = buildFeedbackBaseURL;
6
6
  exports.buildVerifyURL = buildVerifyURL;
7
7
  exports.verifyApiKey = verifyApiKey;
8
8
  exports.stripHTML = stripHTML;
9
+ exports.resolvePlaceholder = resolvePlaceholder;
10
+ exports.primaryButtonLabels = primaryButtonLabels;
9
11
  exports.parseSurvey = parseSurvey;
12
+ exports.resolveSkipRule = resolveSkipRule;
13
+ exports.resolveDelayedBranch = resolveDelayedBranch;
14
+ exports.isQuestionDisplayed = isQuestionDisplayed;
15
+ exports.visibleOptions = visibleOptions;
10
16
  exports.fetchCollector = fetchCollector;
17
+ exports.fetchSurveyRaw = fetchSurveyRaw;
11
18
  exports.fetchSurvey = fetchSurvey;
12
19
  exports.submitResponse = submitResponse;
13
20
  const XeboModels_1 = require("../models/XeboModels");
21
+ const XeboStrings_1 = require("../i18n/XeboStrings");
14
22
  // ─── URL helpers ──────────────────────────────────────────────────────────────
15
23
  function resolveZone(zone) {
16
24
  return zone;
@@ -28,16 +36,11 @@ function buildVerifyURL() {
28
36
  async function verifyApiKey(verifyURL, zone, apiKey) {
29
37
  var _a, _b, _c, _d, _e, _f;
30
38
  const url = `${verifyURL}?zone=${encodeURIComponent(zone)}`;
31
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
32
- console.log('[Xebo Step 0] Verifying API key');
33
- console.log('URL:', url);
34
39
  const res = await fetch(url, {
35
40
  method: 'GET',
36
41
  headers: { 'x-api-key': apiKey },
37
42
  });
38
43
  const json = await res.json();
39
- console.log('[Xebo] Verify response status:', res.status);
40
- console.log('[Xebo] Verify response:', JSON.stringify(json));
41
44
  if (!res.ok) {
42
45
  throw new Error(`[Xebo] verifyApiKey failed — HTTP ${res.status}: ${JSON.stringify(json)}`);
43
46
  }
@@ -45,8 +48,6 @@ async function verifyApiKey(verifyURL, zone, apiKey) {
45
48
  if (!token) {
46
49
  throw new Error(`[Xebo] verifyApiKey — bearer token not found in response: ${JSON.stringify(json)}`);
47
50
  }
48
- console.log('[Xebo] Bearer token obtained successfully');
49
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
50
51
  return token;
51
52
  }
52
53
  // ─── HTML stripping ───────────────────────────────────────────────────────────
@@ -63,6 +64,12 @@ function stripHTML(raw) {
63
64
  .replace(/'/g, "'")
64
65
  .trim();
65
66
  }
67
+ /** Placeholders live on the question or under settings, as an object or a plain string. */
68
+ function resolvePlaceholder(q) {
69
+ var _a, _b, _c;
70
+ const own = typeof q.placeholder === 'string' ? q.placeholder : (_a = q.placeholder) === null || _a === void 0 ? void 0 : _a.text;
71
+ return stripHTML(own || ((_c = (_b = q.settings) === null || _b === void 0 ? void 0 : _b.placeholder) === null || _c === void 0 ? void 0 : _c.text) || undefined);
72
+ }
66
73
  // ─── Question type mapping ────────────────────────────────────────────────────
67
74
  function mapRatingStyle(apiType) {
68
75
  const normalized = (apiType !== null && apiType !== void 0 ? apiType : '').toLowerCase().replace(/^animated_/, '');
@@ -83,7 +90,11 @@ function mapRatingStyle(apiType) {
83
90
  case 'smileys': return 'emoji';
84
91
  case '3d_emoji':
85
92
  case '3d_emojis': return '3d_emoji';
86
- default: return 'star';
93
+ default:
94
+ // Numbered variants such as outline_emojis3 (shown as "Emoji 4" on the platform).
95
+ if (normalized.includes('emoji'))
96
+ return normalized.startsWith('outline') ? 'outline_emoji' : 'emoji';
97
+ return 'star';
87
98
  }
88
99
  }
89
100
  function mapQuestionType(apiType) {
@@ -91,7 +102,8 @@ function mapQuestionType(apiType) {
91
102
  case 'single_choice': return XeboModels_1.XeboQuestionType.singleChoice;
92
103
  case 'multi_choice': return XeboModels_1.XeboQuestionType.multipleChoice;
93
104
  case 'dropdown': return XeboModels_1.XeboQuestionType.dropdown;
94
- case 'single_text': return XeboModels_1.XeboQuestionType.singleTextBox;
105
+ case 'single_text':
106
+ case 'long_text': return XeboModels_1.XeboQuestionType.singleTextBox; // Text Area renders as the multiline box
95
107
  case 'multi_text': return XeboModels_1.XeboQuestionType.multipleTextBox;
96
108
  case 'nps':
97
109
  case 'nps_pro': return XeboModels_1.XeboQuestionType.nps;
@@ -103,8 +115,18 @@ function mapQuestionType(apiType) {
103
115
  }
104
116
  }
105
117
  // ─── Survey parsing ───────────────────────────────────────────────────────────
106
- function parseSurvey(data) {
107
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
118
+ /** A theme button colour, or undefined when the theme leaves it blank. */
119
+ function buttonColor(c) {
120
+ return (c === null || c === void 0 ? void 0 : c.bgColor) ? { background: c.bgColor, text: c.color || undefined } : undefined;
121
+ }
122
+ /** The survey's own button text, used for its primary language. */
123
+ function primaryButtonLabels(data) {
124
+ var _a, _b, _c, _d, _e;
125
+ const b = (_a = data.basicSettings) === null || _a === void 0 ? void 0 : _a.buttons;
126
+ return { next: (_b = b === null || b === void 0 ? void 0 : b.next) === null || _b === void 0 ? void 0 : _b.text, submit: (_c = b === null || b === void 0 ? void 0 : b.submit) === null || _c === void 0 ? void 0 : _c.text, ok: (_d = b === null || b === void 0 ? void 0 : b.okay) === null || _d === void 0 ? void 0 : _d.text, previous: (_e = b === null || b === void 0 ? void 0 : b.prev) === null || _e === void 0 ? void 0 : _e.text };
127
+ }
128
+ function parseSurvey(data, opts = {}) {
129
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38;
108
130
  // Collect all follow-up question IDs (from NPS Pro configScale)
109
131
  const followUpQuestionIds = new Set();
110
132
  for (const block of data.blocks) {
@@ -120,22 +142,22 @@ function parseSurvey(data) {
120
142
  }
121
143
  const questions = [];
122
144
  for (const block of data.blocks) {
145
+ const lastItem = block.questions[block.questions.length - 1];
123
146
  for (const item of block.questions) {
124
147
  const q = item.question;
125
- // Skip follow-up questions (they're embedded inline)
126
- if (followUpQuestionIds.has(q.uuid))
148
+ // Only an explicit `separator: false` joins the next question; a missing flag keeps one per page.
149
+ const pageBreakAfter = item.separator !== false || item === lastItem;
150
+ // Skip follow-up questions (they're embedded inline) and hidden ones, keeping their page break.
151
+ if (followUpQuestionIds.has(q.uuid) || q.isHidden) {
152
+ if (pageBreakAfter && questions.length > 0)
153
+ questions[questions.length - 1].pageBreakAfter = true;
127
154
  continue;
128
- const type = mapQuestionType(q.quesType);
129
- console.log(`[Xebo] Raw API question [${q.quesType}]:`, JSON.stringify(q, null, 2));
130
- if (type === XeboModels_1.XeboQuestionType.dropdown) {
131
- console.log('[Xebo] Dropdown raw options keys:', JSON.stringify(Object.keys((_d = q.options) !== null && _d !== void 0 ? _d : {})));
132
- console.log('[Xebo] Dropdown options.row:', JSON.stringify((_e = q.options) === null || _e === void 0 ? void 0 : _e.row));
133
- console.log('[Xebo] Full dropdown q.options:', JSON.stringify(q.options));
134
155
  }
156
+ const type = mapQuestionType(q.quesType);
135
157
  const rawOptions = q.options;
136
158
  const rowSource = Array.isArray(rawOptions)
137
159
  ? rawOptions
138
- : ((_h = (_g = (_f = rawOptions === null || rawOptions === void 0 ? void 0 : rawOptions.row) !== null && _f !== void 0 ? _f : rawOptions === null || rawOptions === void 0 ? void 0 : rawOptions.items) !== null && _g !== void 0 ? _g : rawOptions === null || rawOptions === void 0 ? void 0 : rawOptions.choices) !== null && _h !== void 0 ? _h : []);
160
+ : ((_f = (_e = (_d = rawOptions === null || rawOptions === void 0 ? void 0 : rawOptions.row) !== null && _d !== void 0 ? _d : rawOptions === null || rawOptions === void 0 ? void 0 : rawOptions.items) !== null && _e !== void 0 ? _e : rawOptions === null || rawOptions === void 0 ? void 0 : rawOptions.choices) !== null && _f !== void 0 ? _f : []);
139
161
  const rows = rowSource.map((r) => {
140
162
  var _a, _b, _c, _d, _e;
141
163
  return ({
@@ -144,7 +166,7 @@ function parseSurvey(data) {
144
166
  value: (_e = r.uuid) !== null && _e !== void 0 ? _e : r.id,
145
167
  });
146
168
  });
147
- const cols = ((_k = (_j = rawOptions === null || rawOptions === void 0 ? void 0 : rawOptions.col) !== null && _j !== void 0 ? _j : rawOptions === null || rawOptions === void 0 ? void 0 : rawOptions.columns) !== null && _k !== void 0 ? _k : []).map((c) => {
169
+ const cols = ((_h = (_g = rawOptions === null || rawOptions === void 0 ? void 0 : rawOptions.col) !== null && _g !== void 0 ? _g : rawOptions === null || rawOptions === void 0 ? void 0 : rawOptions.columns) !== null && _h !== void 0 ? _h : []).map((c) => {
148
170
  var _a, _b, _c, _d;
149
171
  return ({
150
172
  id: (_a = c.uuid) !== null && _a !== void 0 ? _a : c.id,
@@ -154,11 +176,11 @@ function parseSurvey(data) {
154
176
  });
155
177
  // Build conditional follow-ups for NPS Pro
156
178
  const conditionalFollowUps = [];
157
- const scales = (_m = (_l = q.settings) === null || _l === void 0 ? void 0 : _l.configScale) !== null && _m !== void 0 ? _m : [];
179
+ const scales = (_k = (_j = q.settings) === null || _j === void 0 ? void 0 : _j.configScale) !== null && _k !== void 0 ? _k : [];
158
180
  for (const scale of scales) {
159
181
  if (scale.enabled === false)
160
182
  continue;
161
- const followUpQId = (_o = scale.qId) === null || _o === void 0 ? void 0 : _o[0];
183
+ const followUpQId = (_l = scale.qId) === null || _l === void 0 ? void 0 : _l[0];
162
184
  if (!followUpQId)
163
185
  continue;
164
186
  // Find the follow-up question in all blocks
@@ -173,7 +195,7 @@ function parseSurvey(data) {
173
195
  if (followUpApiQ)
174
196
  break;
175
197
  }
176
- const followUpOptions = ((_q = (_p = followUpApiQ === null || followUpApiQ === void 0 ? void 0 : followUpApiQ.options) === null || _p === void 0 ? void 0 : _p.row) !== null && _q !== void 0 ? _q : []).map(r => ({
198
+ const followUpOptions = ((_o = (_m = followUpApiQ === null || followUpApiQ === void 0 ? void 0 : followUpApiQ.options) === null || _m === void 0 ? void 0 : _m.row) !== null && _o !== void 0 ? _o : []).map(r => ({
177
199
  id: r.uuid,
178
200
  text: stripHTML(r.text),
179
201
  value: r.uuid,
@@ -181,50 +203,88 @@ function parseSurvey(data) {
181
203
  conditionalFollowUps.push({
182
204
  minRating: Number(scale.scale.min),
183
205
  maxRating: Number(scale.scale.max),
184
- followUpQuestion: stripHTML((_r = followUpApiQ === null || followUpApiQ === void 0 ? void 0 : followUpApiQ.title) !== null && _r !== void 0 ? _r : ''),
206
+ followUpQuestion: stripHTML((_p = followUpApiQ === null || followUpApiQ === void 0 ? void 0 : followUpApiQ.title) !== null && _p !== void 0 ? _p : ''),
185
207
  followUpType: followUpApiQ ? mapQuestionType(followUpApiQ.quesType) : XeboModels_1.XeboQuestionType.singleTextBox,
186
208
  followUpOptions,
187
209
  questionId: followUpQId,
188
210
  });
189
211
  }
190
- const npsSettings = (_s = q.settings) === null || _s === void 0 ? void 0 : _s.nps;
191
- const ratingSettings = (_t = q.settings) === null || _t === void 0 ? void 0 : _t.rating;
212
+ const skipLogic = [];
213
+ const delayedBranching = [];
214
+ const displayCriteriaIds = [];
215
+ const autoSelectOptionIds = [];
216
+ const optionDisplayRules = [];
217
+ for (const logic of (_q = q.logics) !== null && _q !== void 0 ? _q : []) {
218
+ for (const rule of (_r = logic.data) !== null && _r !== void 0 ? _r : []) {
219
+ const destination = {
220
+ destinationType: ((_s = rule.destination) === null || _s === void 0 ? void 0 : _s.type) || 'default',
221
+ destinationQuestionId: ((_t = rule.destination) === null || _t === void 0 ? void 0 : _t.qId) || undefined,
222
+ };
223
+ if (logic.type === 'skip') {
224
+ skipLogic.push(Object.assign({ rowId: ((_u = rule.answer) === null || _u === void 0 ? void 0 : _u.rowId) || undefined, colId: ((_v = rule.answer) === null || _v === void 0 ? void 0 : _v.colId) || undefined }, destination));
225
+ }
226
+ else if (logic.type === 'delayed_branching') {
227
+ delayedBranching.push(Object.assign({ criteriaId: rule.criteriaId || undefined }, destination));
228
+ }
229
+ else if (logic.type === 'question_display' && rule.criteriaId) {
230
+ displayCriteriaIds.push(rule.criteriaId);
231
+ }
232
+ else if (logic.type === 'auto_select' && ((_w = logic.subType) !== null && _w !== void 0 ? _w : 'simple') === 'simple') {
233
+ autoSelectOptionIds.push(...((_x = rule.optionIds) !== null && _x !== void 0 ? _x : []).filter(id => rows.some(r => r.id === id)));
234
+ }
235
+ else if (logic.type === 'options_display' && rule.criteriaId && ((_y = rule.optionIds) === null || _y === void 0 ? void 0 : _y.length)) {
236
+ optionDisplayRules.push({ criteriaId: rule.criteriaId, optionIds: rule.optionIds });
237
+ }
238
+ }
239
+ }
240
+ const npsSettings = (_z = q.settings) === null || _z === void 0 ? void 0 : _z.nps;
241
+ const ratingSettings = (_0 = q.settings) === null || _0 === void 0 ? void 0 : _0.rating;
192
242
  const parsed = {
193
243
  id: q.uuid,
194
244
  type,
195
245
  title: stripHTML(q.title),
196
- subtitle: stripHTML((_u = q.helperText) === null || _u === void 0 ? void 0 : _u.text),
197
- placeholder: stripHTML((_v = q.placeholder) === null || _v === void 0 ? void 0 : _v.text),
198
- isRequired: (_x = (_w = q.required) === null || _w === void 0 ? void 0 : _w.enabled) !== null && _x !== void 0 ? _x : false,
246
+ subtitle: stripHTML((_1 = q.helperText) === null || _1 === void 0 ? void 0 : _1.text),
247
+ placeholder: resolvePlaceholder(q),
248
+ isRequired: (_3 = (_2 = q.required) === null || _2 === void 0 ? void 0 : _2.enabled) !== null && _3 !== void 0 ? _3 : false,
199
249
  options: rows.length > 0 ? rows : undefined,
200
250
  columns: cols.length > 0 ? cols : undefined,
201
251
  npsLabels: npsSettings
202
252
  ? {
203
253
  lower: npsSettings.leftLabel,
204
254
  upper: npsSettings.rightLabel,
205
- detractorColor: (_y = npsSettings.colors) === null || _y === void 0 ? void 0 : _y.detractor,
206
- passiveColor: (_z = npsSettings.colors) === null || _z === void 0 ? void 0 : _z.passive,
207
- promoterColor: (_0 = npsSettings.colors) === null || _0 === void 0 ? void 0 : _0.promoter,
255
+ detractorColor: (_4 = npsSettings.colors) === null || _4 === void 0 ? void 0 : _4.detractor,
256
+ passiveColor: (_5 = npsSettings.colors) === null || _5 === void 0 ? void 0 : _5.passive,
257
+ promoterColor: (_6 = npsSettings.colors) === null || _6 === void 0 ? void 0 : _6.promoter,
208
258
  }
209
259
  : undefined,
260
+ npsStyle: (npsSettings === null || npsSettings === void 0 ? void 0 : npsSettings.differentForMobile)
261
+ ? (_8 = (_7 = npsSettings.mobile) === null || _7 === void 0 ? void 0 : _7.type) !== null && _8 !== void 0 ? _8 : npsSettings.type
262
+ : npsSettings === null || npsSettings === void 0 ? void 0 : npsSettings.type,
210
263
  followUpQuestion: undefined,
211
264
  conditionalFollowUps: conditionalFollowUps.length > 0 ? conditionalFollowUps : undefined,
265
+ skipLogic: skipLogic.length > 0 ? skipLogic : undefined,
266
+ delayedBranching: delayedBranching.length > 0 ? delayedBranching : undefined,
267
+ displayCriteriaIds: displayCriteriaIds.length > 0 ? displayCriteriaIds : undefined,
268
+ autoSelectOptionIds: autoSelectOptionIds.length > 0 ? autoSelectOptionIds : undefined,
269
+ optionDisplayRules: optionDisplayRules.length > 0 ? optionDisplayRules : undefined,
212
270
  ratingStyle: ratingSettings ? mapRatingStyle(ratingSettings.type) : undefined,
213
271
  showColLabels: ratingSettings === null || ratingSettings === void 0 ? void 0 : ratingSettings.colLabel,
214
272
  ratingColor: ratingSettings === null || ratingSettings === void 0 ? void 0 : ratingSettings.color,
273
+ requiredMessage: opts.localized ? stripHTML((_9 = q.required) === null || _9 === void 0 ? void 0 : _9.errMsg) || undefined : undefined,
274
+ pageBreakAfter,
215
275
  };
216
- console.log(`[Xebo] Parsed question [${type}]:`, JSON.stringify(parsed, null, 2));
217
276
  questions.push(parsed);
218
277
  }
219
278
  }
220
279
  // Append auto thank-you question
280
+ const strings = (0, XeboStrings_1.getStrings)();
221
281
  const tyPage = data.thankYouPage;
222
282
  const tyTitle = (tyPage === null || tyPage === void 0 ? void 0 : tyPage.enabled) && tyPage.content
223
283
  ? stripHTML(tyPage.content)
224
- : 'Thank You!';
284
+ : (opts.localized ? strings.thankYouTitle : 'Thank You!');
225
285
  const tySubtitle = (tyPage === null || tyPage === void 0 ? void 0 : tyPage.enabled) && tyPage.content
226
286
  ? undefined
227
- : 'Your feedback is greatly appreciated.';
287
+ : (opts.localized ? strings.thankYouMessage : 'Your feedback is greatly appreciated.');
228
288
  questions.push({
229
289
  id: 'thank_you_auto',
230
290
  type: XeboModels_1.XeboQuestionType.thankYou,
@@ -235,36 +295,127 @@ function parseSurvey(data) {
235
295
  });
236
296
  const introPageRaw = data.introPage;
237
297
  const thankYouPageRaw = data.thankYouPage;
298
+ const logicMeet = (_10 = data.completionRules) === null || _10 === void 0 ? void 0 : _10.logicMeet;
238
299
  const survey = {
239
300
  id: data.uuid,
240
301
  name: data.displayTitle,
241
302
  projectId: data.projectId,
303
+ langKey: opts.langKey,
304
+ direction: opts.direction,
242
305
  questions,
243
306
  introPage: introPageRaw
244
307
  ? {
245
- enabled: (_1 = introPageRaw.enabled) !== null && _1 !== void 0 ? _1 : false,
308
+ enabled: (_11 = introPageRaw.enabled) !== null && _11 !== void 0 ? _11 : false,
246
309
  content: stripHTML(introPageRaw.content),
247
310
  buttonText: introPageRaw.buttonText,
248
311
  }
249
312
  : undefined,
250
313
  thankYouPage: thankYouPageRaw
251
314
  ? {
252
- enabled: (_2 = thankYouPageRaw.enabled) !== null && _2 !== void 0 ? _2 : false,
315
+ enabled: (_12 = thankYouPageRaw.enabled) !== null && _12 !== void 0 ? _12 : false,
253
316
  content: stripHTML(thankYouPageRaw.content),
254
317
  links: thankYouPageRaw.links,
255
318
  }
256
319
  : undefined,
320
+ disqualifyMessage: (logicMeet === null || logicMeet === void 0 ? void 0 : logicMeet.type) === 'msg' ? stripHTML(logicMeet.value) || undefined : undefined,
321
+ autoAdvance: ((_14 = (_13 = data.basicSettings) === null || _13 === void 0 ? void 0 : _13.questionView) === null || _14 === void 0 ? void 0 : _14.autoAdvance) === true,
322
+ showPrevious: ((_17 = (_16 = (_15 = data.basicSettings) === null || _15 === void 0 ? void 0 : _15.buttons) === null || _16 === void 0 ? void 0 : _16.prev) === null || _17 === void 0 ? void 0 : _17.enabled) !== false
323
+ && ((_20 = (_19 = (_18 = data.basicSettings) === null || _18 === void 0 ? void 0 : _18.buttons) === null || _19 === void 0 ? void 0 : _19.navigations) === null || _20 === void 0 ? void 0 : _20.enabled) !== false,
324
+ // basicSettings isn't translated, so this is the primary text in every language.
325
+ previousIconOnly: !stripHTML((_23 = (_22 = (_21 = data.basicSettings) === null || _21 === void 0 ? void 0 : _21.buttons) === null || _22 === void 0 ? void 0 : _22.prev) === null || _23 === void 0 ? void 0 : _23.text),
326
+ showQuestionNumbers: ((_25 = (_24 = data.basicSettings) === null || _24 === void 0 ? void 0 : _24.questions) === null || _25 === void 0 ? void 0 : _25.numbers) === true,
327
+ buttonColors: {
328
+ primary: buttonColor((_28 = (_27 = (_26 = data.theme) === null || _26 === void 0 ? void 0 : _26.style) === null || _27 === void 0 ? void 0 : _27.btns) === null || _28 === void 0 ? void 0 : _28.primary),
329
+ next: buttonColor((_31 = (_30 = (_29 = data.theme) === null || _29 === void 0 ? void 0 : _29.style) === null || _30 === void 0 ? void 0 : _30.advance) === null || _31 === void 0 ? void 0 : _31.nextButton),
330
+ ok: buttonColor((_34 = (_33 = (_32 = data.theme) === null || _32 === void 0 ? void 0 : _32.style) === null || _33 === void 0 ? void 0 : _33.advance) === null || _34 === void 0 ? void 0 : _34.okButton),
331
+ previous: buttonColor((_37 = (_36 = (_35 = data.theme) === null || _35 === void 0 ? void 0 : _35.style) === null || _36 === void 0 ? void 0 : _36.advance) === null || _37 === void 0 ? void 0 : _37.previousButton),
332
+ },
333
+ criteria: (_38 = data.criteria) === null || _38 === void 0 ? void 0 : _38.map(c => {
334
+ var _a;
335
+ return ({
336
+ id: c.uuid,
337
+ conditions: ((_a = c.condition) !== null && _a !== void 0 ? _a : []).map(cond => {
338
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
339
+ return ({
340
+ type: (_b = (_a = cond.data) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : '',
341
+ questionId: (_e = (_d = (_c = cond.data) === null || _c === void 0 ? void 0 : _c.normal) === null || _d === void 0 ? void 0 : _d.quesId) !== null && _e !== void 0 ? _e : '',
342
+ optionIds: (_j = (_h = (_g = (_f = cond.data) === null || _f === void 0 ? void 0 : _f.normal) === null || _g === void 0 ? void 0 : _g.options) === null || _h === void 0 ? void 0 : _h.opts) !== null && _j !== void 0 ? _j : [],
343
+ selected: (_m = (_l = (_k = cond.data) === null || _k === void 0 ? void 0 : _k.normal) === null || _l === void 0 ? void 0 : _l.selected) !== null && _m !== void 0 ? _m : true,
344
+ operator: cond.operator,
345
+ });
346
+ }),
347
+ });
348
+ }),
257
349
  };
258
- console.log('[Xebo] Full parsed survey:', JSON.stringify(survey, null, 2));
259
350
  return survey;
260
351
  }
352
+ /** The skip rule matching this answer, or the "any other answer" rule. */
353
+ function resolveSkipRule(question, answer) {
354
+ var _a;
355
+ const rules = question === null || question === void 0 ? void 0 : question.skipLogic;
356
+ if (!rules)
357
+ return undefined;
358
+ const values = (_a = answer === null || answer === void 0 ? void 0 : answer.value) !== null && _a !== void 0 ? _a : [];
359
+ const matched = rules.find(r => (r.rowId || r.colId) &&
360
+ values.some(v => (!r.rowId || r.rowId === v.rowId) && (!r.colId || r.colId === v.colId)));
361
+ return matched !== null && matched !== void 0 ? matched : rules.find(r => !r.rowId && !r.colId);
362
+ }
363
+ function isConditionMet(cond, answers) {
364
+ var _a, _b;
365
+ if (cond.type !== 'normal')
366
+ return false;
367
+ const values = (_b = (_a = answers.find(a => a.questionId === cond.questionId)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : [];
368
+ // Choice options are rows; rating/NPS scale points are columns.
369
+ const found = values.some(v => cond.optionIds.includes(v.rowId) || (!!v.colId && cond.optionIds.includes(v.colId)));
370
+ return cond.selected ? found : !found;
371
+ }
372
+ /** Conditions combine left to right using the operator on the preceding condition (default "and"). */
373
+ function isCriteriaMet(criteria, answers) {
374
+ return criteria.conditions.reduce((result, cond, i) => {
375
+ const met = isConditionMet(cond, answers);
376
+ if (i === 0)
377
+ return met;
378
+ return criteria.conditions[i - 1].operator === 'or' ? result || met : result && met;
379
+ }, false);
380
+ }
381
+ /** The delayed-branching rule whose criteria all answers so far meet, or the "otherwise" rule. */
382
+ function resolveDelayedBranch(question, criteria, answers) {
383
+ const rules = question === null || question === void 0 ? void 0 : question.delayedBranching;
384
+ if (!rules)
385
+ return undefined;
386
+ const met = rules.find(r => {
387
+ const c = r.criteriaId ? criteria === null || criteria === void 0 ? void 0 : criteria.find(x => x.id === r.criteriaId) : undefined;
388
+ return !!c && isCriteriaMet(c, answers);
389
+ });
390
+ return met !== null && met !== void 0 ? met : rules.find(r => !r.criteriaId);
391
+ }
392
+ /** False when the question has display logic and none of its criteria is met. */
393
+ function isQuestionDisplayed(question, criteria, answers) {
394
+ const ids = question.displayCriteriaIds;
395
+ if (!ids)
396
+ return true;
397
+ return ids.some(id => {
398
+ const c = criteria === null || criteria === void 0 ? void 0 : criteria.find(x => x.id === id);
399
+ return !!c && isCriteriaMet(c, answers);
400
+ });
401
+ }
402
+ /** The options to show: one named by options display logic needs one of its rules' criteria met. */
403
+ function visibleOptions(question, criteria, answers) {
404
+ const rules = question.optionDisplayRules;
405
+ if (!rules || !question.options)
406
+ return question.options;
407
+ const isMet = (criteriaId) => {
408
+ const c = criteria === null || criteria === void 0 ? void 0 : criteria.find(x => x.id === criteriaId);
409
+ return !!c && isCriteriaMet(c, answers);
410
+ };
411
+ return question.options.filter(o => {
412
+ const own = rules.filter(r => r.optionIds.includes(o.id));
413
+ return own.length === 0 || own.some(r => isMet(r.criteriaId));
414
+ });
415
+ }
261
416
  async function fetchCollector(baseURL, collectorId, bearerToken) {
262
417
  var _a;
263
418
  const url = `${baseURL}/v3/collectors/collect/${collectorId}`;
264
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
265
- console.log('[Xebo Step 1] Fetching collector');
266
- console.log('URL:', url);
267
- console.log('Collector ID:', collectorId);
268
419
  const res = await fetch(url, { headers: { 'Authorization': `Bearer ${bearerToken}` } });
269
420
  const json = await res.json();
270
421
  // The API may return the collector object directly at the root OR wrapped in a `data` key
@@ -278,34 +429,26 @@ async function fetchCollector(baseURL, collectorId, bearerToken) {
278
429
  uuid: payload.uuid,
279
430
  mongoId: payload._id,
280
431
  };
281
- console.log('Collector UUID:', info.uuid);
282
- console.log('Collector MongoId:', info.mongoId);
283
- console.log('Survey ID:', info.surveyId);
284
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
285
432
  return info;
286
433
  }
287
- async function fetchSurvey(baseURL, surveyId, bearerToken) {
288
- var _a, _b, _c;
434
+ /** Returns the unparsed survey JSON so translations can be merged before parsing. */
435
+ async function fetchSurveyRaw(baseURL, surveyId, bearerToken) {
289
436
  const url = `${baseURL}/v3/survey-management/surveys/${surveyId}`;
290
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
291
- console.log('[Xebo Step 2] Fetching survey');
292
- console.log('URL:', url);
293
437
  const res = await fetch(url, { headers: { 'Authorization': `Bearer ${bearerToken}` } });
294
438
  const json = await res.json();
295
- console.log('[Xebo] Survey HTTP status:', res.status);
296
- console.log('[Xebo] Survey data keys:', Object.keys((_a = json === null || json === void 0 ? void 0 : json.data) !== null && _a !== void 0 ? _a : {}));
297
- console.log('[Xebo] blocks:', JSON.stringify((_c = (_b = json === null || json === void 0 ? void 0 : json.data) === null || _b === void 0 ? void 0 : _b.blocks) === null || _c === void 0 ? void 0 : _c.length));
298
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
299
439
  if (!(json === null || json === void 0 ? void 0 : json.data)) {
300
440
  throw new Error(`[Xebo] fetchSurvey — no data in response. HTTP ${res.status}`);
301
441
  }
302
442
  if (!Array.isArray(json.data.blocks)) {
303
443
  throw new Error(`[Xebo] fetchSurvey — 'blocks' missing. Keys: ${Object.keys(json.data)}`);
304
444
  }
305
- return parseSurvey(json.data);
445
+ return json.data;
446
+ }
447
+ async function fetchSurvey(baseURL, surveyId, bearerToken) {
448
+ return parseSurvey(await fetchSurveyRaw(baseURL, surveyId, bearerToken));
306
449
  }
307
450
  async function submitResponse(feedbackBaseURL, surveyId, collectorUUID, bearerToken, answers, meta) {
308
- var _a;
451
+ var _a, _b;
309
452
  const url = `${feedbackBaseURL}/v3/survey-participation/${surveyId}/response/create-response`;
310
453
  // Filter out auto thank-you answer
311
454
  const filteredAnswers = answers.filter(a => a.questionId !== 'thank_you_auto');
@@ -342,7 +485,7 @@ async function submitResponse(feedbackBaseURL, surveyId, collectorUUID, bearerTo
342
485
  const payload = {
343
486
  collector_id: collectorUUID,
344
487
  responses: [
345
- Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ response_status: 'complete', mode: 'React Native SDK', userAgent }, ((meta === null || meta === void 0 ? void 0 : meta.startTime) && { start_time: meta.startTime })), ((meta === null || meta === void 0 ? void 0 : meta.endTime) && { end_time: meta.endTime })), (timeTakenSecs !== undefined && { time_spent: timeTakenSecs })), (Object.keys(customVariables).length > 0 && { custom_variables: customVariables })), ((meta === null || meta === void 0 ? void 0 : meta.qualityFlags) && { qualityFlags: meta.qualityFlags })), ((meta === null || meta === void 0 ? void 0 : meta.deviceInfo) && { deviceInfo: meta.deviceInfo })), ((meta === null || meta === void 0 ? void 0 : meta.geolocation) && { geoLocation: meta.geolocation })), { questions: filteredAnswers.map(a => ({
488
+ Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ response_status: (_b = meta === null || meta === void 0 ? void 0 : meta.status) !== null && _b !== void 0 ? _b : 'complete', mode: 'React Native SDK', userAgent }, ((meta === null || meta === void 0 ? void 0 : meta.startTime) && { start_time: meta.startTime })), ((meta === null || meta === void 0 ? void 0 : meta.endTime) && { end_time: meta.endTime })), (timeTakenSecs !== undefined && { time_spent: timeTakenSecs })), (Object.keys(customVariables).length > 0 && { custom_variables: customVariables })), ((meta === null || meta === void 0 ? void 0 : meta.qualityFlags) && { qualityFlags: meta.qualityFlags })), ((meta === null || meta === void 0 ? void 0 : meta.deviceInfo) && { deviceInfo: meta.deviceInfo })), ((meta === null || meta === void 0 ? void 0 : meta.geolocation) && { geoLocation: meta.geolocation })), { questions: filteredAnswers.map(a => ({
346
489
  uuid: a.questionId,
347
490
  answer: a.value.map(v => ({
348
491
  row_id: v.rowId || null,
@@ -352,13 +495,6 @@ async function submitResponse(feedbackBaseURL, surveyId, collectorUUID, bearerTo
352
495
  })) }),
353
496
  ],
354
497
  };
355
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
356
- console.log('[Xebo Step 3] Submitting response');
357
- console.log('URL:', url);
358
- console.log('Survey ID:', surveyId);
359
- console.log('Collector ID:', collectorUUID);
360
- console.log('Question count:', filteredAnswers.length);
361
- console.log('Payload:', JSON.stringify(payload, null, 2));
362
498
  const res = await fetch(url, {
363
499
  method: 'POST',
364
500
  headers: {
@@ -369,8 +505,5 @@ async function submitResponse(feedbackBaseURL, surveyId, collectorUUID, bearerTo
369
505
  body: JSON.stringify(payload),
370
506
  });
371
507
  const responseJson = await res.json();
372
- console.log('HTTP Status:', res.status);
373
- console.log('Response JSON:', JSON.stringify(responseJson, null, 2));
374
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
375
508
  return { ok: res.ok, status: res.status, responseJson };
376
509
  }
@@ -1,5 +1,6 @@
1
- import { XeboQueuedResponse } from '../models/XeboModels';
1
+ import { XeboQueuedResponse, XeboStorageAdapter } from '../models/XeboModels';
2
2
  export declare const XeboOfflineQueue: {
3
+ setStorage(storage: XeboStorageAdapter | undefined): void;
3
4
  enqueue(response: XeboQueuedResponse): Promise<void>;
4
5
  getAll(): Promise<XeboQueuedResponse[]>;
5
6
  saveAll(responses: XeboQueuedResponse[]): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"XeboOfflineQueue.d.ts","sourceRoot":"","sources":["../../src/core/XeboOfflineQueue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI1D,eAAO,MAAM,gBAAgB;sBACH,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;cAS1C,OAAO,CAAC,kBAAkB,EAAE,CAAC;uBAUpB,kBAAkB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;aAI9C,OAAO,CAAC,IAAI,CAAC;CAG7B,CAAC"}
1
+ {"version":3,"file":"XeboOfflineQueue.d.ts","sourceRoot":"","sources":["../../src/core/XeboOfflineQueue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAuB9E,eAAO,MAAM,gBAAgB;wBACP,kBAAkB,GAAG,SAAS,GAAG,IAAI;sBAIjC,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;cAM1C,OAAO,CAAC,kBAAkB,EAAE,CAAC;uBAUpB,kBAAkB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;aAI9C,OAAO,CAAC,IAAI,CAAC;CAG7B,CAAC"}
@@ -1,23 +1,37 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.XeboOfflineQueue = void 0;
7
- const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
8
4
  const STORAGE_KEY = 'com.xebo.offline_responses';
5
+ let customStorage = null;
6
+ let defaultStorage = null;
7
+ // Without a configured storage, offline responses don't survive an app restart.
8
+ function loadDefaultStorage() {
9
+ const memory = new Map();
10
+ return {
11
+ getItem: (key) => { var _a; return (_a = memory.get(key)) !== null && _a !== void 0 ? _a : null; },
12
+ setItem: (key, value) => void memory.set(key, value),
13
+ removeItem: (key) => void memory.delete(key),
14
+ };
15
+ }
16
+ function getStorage() {
17
+ if (customStorage)
18
+ return customStorage;
19
+ if (!defaultStorage)
20
+ defaultStorage = loadDefaultStorage();
21
+ return defaultStorage;
22
+ }
9
23
  exports.XeboOfflineQueue = {
24
+ setStorage(storage) {
25
+ customStorage = storage !== null && storage !== void 0 ? storage : null;
26
+ },
10
27
  async enqueue(response) {
11
28
  const existing = await this.getAll();
12
29
  existing.push(response);
13
30
  await this.saveAll(existing);
14
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
15
- console.log('[Xebo Offline Queue] Enqueued response:', response.responseId);
16
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
17
31
  },
18
32
  async getAll() {
19
33
  try {
20
- const raw = await async_storage_1.default.getItem(STORAGE_KEY);
34
+ const raw = await getStorage().getItem(STORAGE_KEY);
21
35
  if (!raw)
22
36
  return [];
23
37
  return JSON.parse(raw);
@@ -27,9 +41,9 @@ exports.XeboOfflineQueue = {
27
41
  }
28
42
  },
29
43
  async saveAll(responses) {
30
- await async_storage_1.default.setItem(STORAGE_KEY, JSON.stringify(responses));
44
+ await getStorage().setItem(STORAGE_KEY, JSON.stringify(responses));
31
45
  },
32
46
  async clear() {
33
- await async_storage_1.default.removeItem(STORAGE_KEY);
47
+ await getStorage().removeItem(STORAGE_KEY);
34
48
  },
35
49
  };
@@ -6,12 +6,15 @@ declare class SimpleEventEmitter {
6
6
  off(event: string, listener: Listener): this;
7
7
  removeAllListeners(event?: string): this;
8
8
  }
9
- import { XeboSurvey, XeboAnswer, XeboConfig, XeboThemeConfig, XeboUserData } from '../models/XeboModels';
9
+ import { XeboSurvey, XeboAnswer, XeboConfig, XeboThemeConfig, XeboUserData, XeboQuestion, XeboChoice } from '../models/XeboModels';
10
+ import { XeboLanguagePageModel } from '../models/XeboLanguageModels';
10
11
  export declare const XEBO_EVENTS: {
11
12
  readonly SURVEY_LOADED: "survey_loaded";
12
13
  readonly QUESTION_CHANGED: "question_changed";
13
14
  readonly SURVEY_VISIBLE: "survey_visible";
14
15
  readonly SURVEY_DISMISSED: "survey_dismissed";
16
+ readonly LANGUAGE_PAGE: "language_page";
17
+ readonly LANGUAGE_SELECTED: "language_selected";
15
18
  };
16
19
  declare class XeboSurveyManagerClass extends SimpleEventEmitter {
17
20
  private apiKey;
@@ -27,10 +30,21 @@ declare class XeboSurveyManagerClass extends SimpleEventEmitter {
27
30
  survey: XeboSurvey | null;
28
31
  currentAnswers: XeboAnswer[];
29
32
  currentQuestionIndex: number;
33
+ /** Indices of the questions shown together, starting at currentQuestionIndex. */
34
+ currentPage: number[];
35
+ /** Pages already passed, oldest first, so Previous can return to them. */
36
+ private pageHistory;
30
37
  surveyStartTime: string;
31
38
  resolvedCollectorUUID: string;
32
39
  resolvedCollectorMongoId: string;
33
40
  surveyVisible: boolean;
41
+ disqualified: boolean;
42
+ private rawSurveyData;
43
+ private resolvedSurveyId;
44
+ private onLanguageSelected?;
45
+ languagePage: XeboLanguagePageModel | null;
46
+ /** Bumped on dismiss and on each pick, so a stale translation never opens the survey. */
47
+ private languageLoadToken;
34
48
  private surveyStartEpoch;
35
49
  private questionStartEpoch;
36
50
  private timePerQues;
@@ -43,9 +57,31 @@ declare class XeboSurveyManagerClass extends SimpleEventEmitter {
43
57
  private _startNetworkMonitoring;
44
58
  private _verifyAndGetToken;
45
59
  private _prefetchSurvey;
46
- fetchAndPresentSurvey(): Promise<void>;
60
+ /** Resolves token + collector + raw survey JSON, and parses the primary language. */
61
+ private _loadSurveyData;
62
+ /** Collector-driven flow; `language` (e.g. "ar") skips the language page. */
63
+ fetchAndPresentSurvey(language?: string): Promise<void>;
64
+ /** Same flow for an explicit survey, still using the configured collector to submit. */
65
+ fetchAndPresentSurveyById(surveyId: string, language?: string): Promise<void>;
66
+ private _present;
67
+ private _presentLanguagePage;
68
+ /** Called by the language page; loads the translation then swaps in the first question. */
69
+ selectLanguage(langKey: string): Promise<void>;
70
+ private _presentInLanguage;
71
+ private _resolveDirection;
72
+ private _resetSession;
73
+ /** True when there is an earlier page to go back to. */
74
+ get canGoBack(): boolean;
75
+ /** The question's options left after options display logic, judged on the answers so far. */
76
+ optionsFor(question: XeboQuestion): XeboChoice[] | undefined;
77
+ /** Answers on the path actually taken, so ones left on pages abandoned via Previous aren't used. */
78
+ private _answersOnPath;
79
+ /** Questions from the current one up to the next page break; display logic is checked as the page opens. */
80
+ private _computePage;
47
81
  recordAnswer(answer: XeboAnswer): void;
48
82
  nextQuestion(): void;
83
+ /** Goes back to the page shown before this one; its answers stay recorded. */
84
+ previousPage(): boolean;
49
85
  private _buildQualityFlags;
50
86
  private _buildGeolocation;
51
87
  private _submitCurrentSession;
@@ -1 +1 @@
1
- {"version":3,"file":"XeboSurveyManager.d.ts","sourceRoot":"","sources":["../../src/core/XeboSurveyManager.ts"],"names":[],"mappings":"AAKA,KAAK,QAAQ,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AACzC,cAAM,kBAAkB;IACtB,OAAO,CAAC,UAAU,CAAsC;IACxD,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO;IAK5C,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAI3C,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAI5C,kBAAkB,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