@sidebandai/sideband-core 1.4.5-rc.3 → 1.4.5-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -22,7 +22,14 @@ export type SurveySessionState = {
|
|
|
22
22
|
isBusy: boolean;
|
|
23
23
|
sentimentSelectionLocked: boolean;
|
|
24
24
|
isCompleting: boolean;
|
|
25
|
+
/** The renderer drew the compact entry (`confirmEntryDisplayed`, or a compact `confirmPresentation`). */
|
|
25
26
|
presentationConfirmed: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The compact entry's presentation was reported (`confirmPresentation`
|
|
29
|
+
* with `expanded_fab`): a person can see it. The expiry timer and a
|
|
30
|
+
* snackbar or bar countdown start only after this.
|
|
31
|
+
*/
|
|
32
|
+
presentationReported: boolean;
|
|
26
33
|
fabEntranceCompleted: boolean;
|
|
27
34
|
};
|
|
28
35
|
export type SnackbarState = {
|
|
@@ -96,6 +103,15 @@ export declare class SurveySessionStore {
|
|
|
96
103
|
advance(): Promise<void>;
|
|
97
104
|
handleCompletionAction(action: PulseCompletionAction): Promise<void>;
|
|
98
105
|
confirmPresentation(kind: SurveyPresentationKind, presentationId?: number): void;
|
|
106
|
+
/**
|
|
107
|
+
* The renderer drew the compact entry (FAB, snackbar or bar). This lets the
|
|
108
|
+
* entrance complete (answers enable) without a presentation report. The
|
|
109
|
+
* expiry timer and the countdown still wait for the report.
|
|
110
|
+
* A renderer that reports a presentation only when a person can see the
|
|
111
|
+
* entry calls this at the end of the entrance, and `confirmPresentation`
|
|
112
|
+
* when the entry is seen.
|
|
113
|
+
*/
|
|
114
|
+
confirmEntryDisplayed(presentationId?: number): void;
|
|
99
115
|
confirmFabEntranceCompleted(presentationId?: number): void;
|
|
100
116
|
answerSnackbar(presentationId: number, choiceId: string): boolean;
|
|
101
117
|
/** Keep the bar's visible countdown and expiry in sync while a mouse hovers it. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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mBAAmB,CAAC,IAAI,EAAE,sBAAsB,EAAE,cAAc,CAAC,EAAE,MAAM;IA2BzE;;;;;;;OAOG;IACH,qBAAqB,CAAC,cAAc,CAAC,EAAE,MAAM;IAO7C,2BAA2B,CAAC,cAAc,CAAC,EAAE,MAAM;IAwBnD,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAoCjE,mFAAmF;IACnF,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;IAgBzD,iFAAiF;IACjF,2BAA2B,CAAC,cAAc,EAAE,MAAM;YAgBpC,2BAA2B;YAoB3B,uBAAuB;IAarC,OAAO,CAAC,mBAAmB;YAqDb,WAAW;YAkGX,gBAAgB;YAYhB,OAAO;YAIP,gBAAgB;YAyBhB,gBAAgB;IAS9B,OAAO,CAAC,qBAAqB;IAiB7B,OAAO,CAAC,kBAAkB;IAuC1B,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,6BAA6B;IAWrC,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,oBAAoB;IAkB5B,OAAO,CAAC,uBAAuB;IAqB/B,OAAO,CAAC,OAAO;IAkBf,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,kBAAkB;CAU3B"}
|
package/dist/index.js
CHANGED
|
@@ -52,7 +52,7 @@ function d() {
|
|
|
52
52
|
r("local")?.removeItem(e);
|
|
53
53
|
} catch {}
|
|
54
54
|
}
|
|
55
|
-
function ee(e, t = "1.4.5-rc.
|
|
55
|
+
function ee(e, t = "1.4.5-rc.5") {
|
|
56
56
|
let n = {
|
|
57
57
|
device_id: s(),
|
|
58
58
|
platform: "web",
|
|
@@ -210,21 +210,21 @@ function T(e) {
|
|
|
210
210
|
}
|
|
211
211
|
//#endregion
|
|
212
212
|
//#region src/core/pending-interactions.ts
|
|
213
|
-
var fe = "sideband:pending_interactions:", pe = 1440 * 60 * 1e3,
|
|
213
|
+
var fe = "sideband:pending_interactions:", pe = 1440 * 60 * 1e3, me = /* @__PURE__ */ new Set([
|
|
214
214
|
"completed",
|
|
215
215
|
"partial",
|
|
216
216
|
"not_now",
|
|
217
217
|
"never"
|
|
218
|
-
]),
|
|
218
|
+
]), E = class extends Error {
|
|
219
219
|
reason;
|
|
220
220
|
constructor(e, t, n) {
|
|
221
221
|
super(t, n === void 0 ? void 0 : { cause: n }), this.name = "PendingInteractionStorageError", this.reason = e;
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
|
-
function
|
|
225
|
-
return `${fe}${
|
|
224
|
+
function D(e, t) {
|
|
225
|
+
return `${fe}${O(`${t}\n${e}`)}`;
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function O(e) {
|
|
228
228
|
let t = 3735928559, n = 1103547991;
|
|
229
229
|
for (let r = 0; r < e.length; r += 1) {
|
|
230
230
|
let i = e.charCodeAt(r);
|
|
@@ -232,82 +232,82 @@ function k(e) {
|
|
|
232
232
|
}
|
|
233
233
|
return t = Math.imul(t ^ t >>> 16, 2246822507) ^ Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507) ^ Math.imul(t ^ t >>> 13, 3266489909), (4294967296 * (2097151 & n) + (t >>> 0)).toString(36);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function k() {
|
|
236
236
|
if (typeof window > "u") return null;
|
|
237
237
|
try {
|
|
238
238
|
return window.sessionStorage;
|
|
239
239
|
} catch (e) {
|
|
240
|
-
throw new
|
|
240
|
+
throw new E("storage_unavailable", "Sideband cannot use sessionStorage; pending answers are kept for this page only.", e);
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function A(e) {
|
|
244
244
|
return e === void 0 || typeof e == "string";
|
|
245
245
|
}
|
|
246
|
-
function
|
|
246
|
+
function j(e) {
|
|
247
247
|
return !!e && typeof e == "object" && !Array.isArray(e) && Object.values(e).every((e) => {
|
|
248
248
|
if (!e || typeof e != "object") return !1;
|
|
249
249
|
let t = e;
|
|
250
|
-
return typeof t.answered_at == "string" &&
|
|
250
|
+
return typeof t.answered_at == "string" && A(t.answer_key) && A(t.value);
|
|
251
251
|
});
|
|
252
252
|
}
|
|
253
|
-
function
|
|
253
|
+
function M(e) {
|
|
254
254
|
if (!e || typeof e != "object") return !1;
|
|
255
255
|
let t = e;
|
|
256
|
-
return typeof t.pulse_id != "string" || typeof t.action != "string" || !
|
|
256
|
+
return typeof t.pulse_id != "string" || typeof t.action != "string" || !me.has(t.action) || t.pulse_version !== void 0 && typeof t.pulse_version != "number" || !A(t.impression_id) || !A(t.responded_at) ? !1 : t.action === "completed" || t.action === "partial" ? j(t.answers) && A(t.completion_action_id) : !0;
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function N(e) {
|
|
259
259
|
if (!e || typeof e != "object") return !1;
|
|
260
260
|
let t = e;
|
|
261
|
-
return typeof t.stored_at == "number" && (t.user_id === null || typeof t.user_id == "string") &&
|
|
261
|
+
return typeof t.stored_at == "number" && (t.user_id === null || typeof t.user_id == "string") && M(t.interaction);
|
|
262
262
|
}
|
|
263
|
-
function
|
|
264
|
-
let n =
|
|
263
|
+
function P(e, t = Date.now()) {
|
|
264
|
+
let n = k(), r;
|
|
265
265
|
try {
|
|
266
266
|
r = n?.getItem(e) ?? null;
|
|
267
267
|
} catch (e) {
|
|
268
|
-
throw new
|
|
268
|
+
throw new E("storage_unavailable", "Sideband could not read pending answers.", e);
|
|
269
269
|
}
|
|
270
270
|
if (!r) return [];
|
|
271
271
|
try {
|
|
272
272
|
let e = JSON.parse(r);
|
|
273
|
-
return Array.isArray(e) ? e.filter(
|
|
273
|
+
return Array.isArray(e) ? e.filter(N).filter((e) => t - e.stored_at < pe).slice(-10) : [];
|
|
274
274
|
} catch {
|
|
275
275
|
return [];
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
|
-
function
|
|
279
|
-
let n =
|
|
278
|
+
function F(e, t) {
|
|
279
|
+
let n = k();
|
|
280
280
|
if (!n) return;
|
|
281
281
|
let r = t.slice(-10);
|
|
282
282
|
try {
|
|
283
283
|
r.length ? n.setItem(e, JSON.stringify(r)) : n.removeItem(e);
|
|
284
284
|
} catch (e) {
|
|
285
|
-
throw new
|
|
285
|
+
throw new E("storage_write_failed", "Sideband could not save pending answers to sessionStorage (it may be full); they are kept for this page only.", e);
|
|
286
286
|
}
|
|
287
|
-
if (r.length < t.length) throw new
|
|
287
|
+
if (r.length < t.length) throw new E("queue_full", "Sideband keeps at most 10 pending answers across page loads; the oldest were not saved.");
|
|
288
288
|
}
|
|
289
289
|
//#endregion
|
|
290
290
|
//#region src/core/sync-engine.ts
|
|
291
|
-
var
|
|
292
|
-
function
|
|
291
|
+
var I = 20, L = 50, R = 1, z = 15, he = 1e3, ge = 300 * 1e3, _e = 2147483647, ve = 1e4;
|
|
292
|
+
function ye(e, t, n) {
|
|
293
293
|
return Math.min(Math.max(e, t), n);
|
|
294
294
|
}
|
|
295
|
-
function
|
|
295
|
+
function be(e) {
|
|
296
296
|
let t = e?.status;
|
|
297
297
|
return typeof t == "number" ? t : void 0;
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function xe(e) {
|
|
300
300
|
let t = e?.status;
|
|
301
301
|
return typeof t != "number" || t === 408 || t === 425 || t === 429 || t >= 500;
|
|
302
302
|
}
|
|
303
|
-
function
|
|
303
|
+
function B(e) {
|
|
304
304
|
let t = e?.retryAfterSeconds;
|
|
305
305
|
return typeof t == "number" && Number.isFinite(t) ? Math.max(t, 0) * 1e3 : void 0;
|
|
306
306
|
}
|
|
307
|
-
function
|
|
308
|
-
return e?.status === 503 &&
|
|
307
|
+
function Se(e) {
|
|
308
|
+
return e?.status === 503 && B(e) !== void 0 ? "server_retry" : b(e) ? "network" : "server_error";
|
|
309
309
|
}
|
|
310
|
-
var
|
|
310
|
+
var V = class {
|
|
311
311
|
deps;
|
|
312
312
|
maxBatchSize;
|
|
313
313
|
flushIntervalMs;
|
|
@@ -347,7 +347,7 @@ var H = class {
|
|
|
347
347
|
syncAttempts = 0;
|
|
348
348
|
detachLifecycle = null;
|
|
349
349
|
constructor(e, t = {}) {
|
|
350
|
-
this.deps = e, this.maxBatchSize =
|
|
350
|
+
this.deps = e, this.maxBatchSize = ye(t.maxBatchSize ?? I, 1, L), this.flushIntervalMs = Math.max(t.flushIntervalSeconds ?? R, 1) * 1e3, this.retryIntervalMs = Math.max(t.retryIntervalSeconds ?? z, 1) * 1e3, this.maxQueuedEvents = Math.max(t.maxQueuedEvents ?? he, this.maxBatchSize);
|
|
351
351
|
}
|
|
352
352
|
start() {
|
|
353
353
|
this.started || this.destroyed || (this.started = !0, this.restoreInteractions(), this.attachLifecycle(), this.track("system_app_launch"));
|
|
@@ -527,16 +527,16 @@ var H = class {
|
|
|
527
527
|
this.hasWork() && !this.manualFlushPromise && this.requestRegular();
|
|
528
528
|
}
|
|
529
529
|
handleFailure(e, t) {
|
|
530
|
-
if (this.lastAttemptAccepted = !1, t.interaction &&
|
|
530
|
+
if (this.lastAttemptAccepted = !1, t.interaction && be(e) === 404) {
|
|
531
531
|
this.dropInteraction(t.interaction), this.clearRetryState(), this.reportError(e), this.regularDueAt = null, this.urgentDueAt = null, this.requestRegular();
|
|
532
532
|
return;
|
|
533
533
|
}
|
|
534
|
-
if (!
|
|
534
|
+
if (!xe(e)) {
|
|
535
535
|
t.interaction && (this.unpersistedInteractions.add(t.interaction), this.persistInteractions()), this.retrySnapshot = null, this.automaticRetrySuspended = !0, this.regularDueAt = null, this.reportError(e);
|
|
536
536
|
return;
|
|
537
537
|
}
|
|
538
|
-
this.failureStreak += 1, t.attempt = Math.min(t.attempt + 1, 1e3), t.retryReason =
|
|
539
|
-
let n =
|
|
538
|
+
this.failureStreak += 1, t.attempt = Math.min(t.attempt + 1, 1e3), t.retryReason = Se(e), this.retrySnapshot = t;
|
|
539
|
+
let n = B(e), r = Math.min(this.retryIntervalMs * 2 ** (this.failureStreak - 1), ge) * (.5 + Math.random() * .5), i = Math.max(r, n ?? 0);
|
|
540
540
|
this.retryUntil = Date.now() + i, this.regularDueAt = this.retryUntil, t.trigger !== "regular" && (this.pendingForcedRetry = t.trigger), this.failureStreak === 1 && this.reportError(e);
|
|
541
541
|
}
|
|
542
542
|
clearRetryState() {
|
|
@@ -597,7 +597,7 @@ var H = class {
|
|
|
597
597
|
}
|
|
598
598
|
this.pendingForcedRetry = null, this.beginAttempt(t);
|
|
599
599
|
}
|
|
600
|
-
}, Math.min(Math.max(e - Date.now(), 0),
|
|
600
|
+
}, Math.min(Math.max(e - Date.now(), 0), _e)));
|
|
601
601
|
}
|
|
602
602
|
clearTimer() {
|
|
603
603
|
this.timerId !== null && (clearTimeout(this.timerId), this.timerId = null), this.timerDueAt = null;
|
|
@@ -664,7 +664,7 @@ var H = class {
|
|
|
664
664
|
storedAt: e.storedAt
|
|
665
665
|
}), this.replayedInteractions.add(e.interaction), e.interaction)), this.restoredInteractions.length && (this.restoreReleaseTimer = setTimeout(() => {
|
|
666
666
|
this.restoreReleaseTimer = null, !(this.destroyed || !this.restoredInteractions.length) && (this.releaseRestoredInteractions(), this.requestRegular());
|
|
667
|
-
},
|
|
667
|
+
}, ve));
|
|
668
668
|
}
|
|
669
669
|
releaseRestoredInteractions() {
|
|
670
670
|
this.restoreReleaseTimer !== null && (clearTimeout(this.restoreReleaseTimer), this.restoreReleaseTimer = null), this.restoredInteractions.length && (this.queuedInteractions = [...this.restoredInteractions, ...this.queuedInteractions], this.restoredInteractions = []);
|
|
@@ -709,9 +709,9 @@ var H = class {
|
|
|
709
709
|
};
|
|
710
710
|
//#endregion
|
|
711
711
|
//#region src/core/create-sideband-runtime.ts
|
|
712
|
-
function
|
|
712
|
+
function Ce(e) {
|
|
713
713
|
m(e.appVersion);
|
|
714
|
-
let t =
|
|
714
|
+
let t = we(e.onError), n = p(e.appVersion, e.context, e.libraryVersion), r = e.context && typeof e.context == "object" ? e.context.user_id ?? null : null, i = async () => {
|
|
715
715
|
let e = await n();
|
|
716
716
|
return r = e.user_id ?? null, t === null ? e : {
|
|
717
717
|
...e,
|
|
@@ -724,19 +724,19 @@ function Se(e) {
|
|
|
724
724
|
context: i,
|
|
725
725
|
headers: e.headers,
|
|
726
726
|
fetch: e.fetch
|
|
727
|
-
}), o =
|
|
727
|
+
}), o = D(e.apiKey, C(e)), c = new V({
|
|
728
728
|
sendSync: (e, t) => a.sync(e, t),
|
|
729
729
|
resolveContext: i,
|
|
730
730
|
onSyncResponse: e.onSyncResponse,
|
|
731
731
|
onError: e.onError,
|
|
732
732
|
interactionPersistence: {
|
|
733
|
-
restore: () =>
|
|
733
|
+
restore: () => P(o).map((e) => ({
|
|
734
734
|
interaction: e.interaction,
|
|
735
735
|
owner: e.user_id,
|
|
736
736
|
storedAt: e.stored_at
|
|
737
737
|
})),
|
|
738
738
|
save: (e) => {
|
|
739
|
-
|
|
739
|
+
F(o, e.map((e) => ({
|
|
740
740
|
interaction: e.interaction,
|
|
741
741
|
user_id: e.owner,
|
|
742
742
|
stored_at: e.storedAt
|
|
@@ -776,13 +776,13 @@ function Se(e) {
|
|
|
776
776
|
destroy: () => c.destroy()
|
|
777
777
|
};
|
|
778
778
|
}
|
|
779
|
-
function
|
|
779
|
+
function we(e) {
|
|
780
780
|
let t = l();
|
|
781
781
|
return t === null || !_(t) ? t : (d(), e?.(/* @__PURE__ */ Error("Sideband cleared a stored user ID longer than 256 characters.")), null);
|
|
782
782
|
}
|
|
783
783
|
//#endregion
|
|
784
784
|
//#region src/core/snackbar-presentation.ts
|
|
785
|
-
function
|
|
785
|
+
function Te(e) {
|
|
786
786
|
if (!e || typeof e != "object") return !1;
|
|
787
787
|
let t = e;
|
|
788
788
|
return [
|
|
@@ -796,52 +796,52 @@ function we(e) {
|
|
|
796
796
|
return typeof r == "number" && Number.isFinite(r) && typeof i == "number" && Number.isFinite(i) && (e !== "offset" || Number.isInteger(r) && Number.isInteger(i));
|
|
797
797
|
});
|
|
798
798
|
}
|
|
799
|
-
function
|
|
799
|
+
function Ee(e, t) {
|
|
800
800
|
return {
|
|
801
801
|
imageUrl: e.imageUrl ?? t?.imageUrl,
|
|
802
|
-
placement:
|
|
802
|
+
placement: Te(e.placement) ? e.placement : t?.placement
|
|
803
803
|
};
|
|
804
804
|
}
|
|
805
805
|
//#endregion
|
|
806
806
|
//#region src/core/survey-session-store.ts
|
|
807
|
-
var
|
|
807
|
+
var H = {
|
|
808
808
|
destroyed: !1,
|
|
809
809
|
state: null
|
|
810
|
-
},
|
|
811
|
-
function
|
|
810
|
+
}, De = 0;
|
|
811
|
+
function Oe(e) {
|
|
812
812
|
return e.fab?.title ?? e.title;
|
|
813
813
|
}
|
|
814
|
-
function
|
|
814
|
+
function ke(e) {
|
|
815
815
|
return e.id;
|
|
816
816
|
}
|
|
817
|
-
function
|
|
817
|
+
function U(e) {
|
|
818
818
|
return typeof e.impression_id == "string" ? `${e.pulse_id}:${e.version}:${e.impression_id}` : `${e.pulse_id}:${e.version}`;
|
|
819
819
|
}
|
|
820
|
-
function
|
|
820
|
+
function W(e) {
|
|
821
821
|
return typeof e.impression_id == "string" ? { impression_id: e.impression_id } : {};
|
|
822
822
|
}
|
|
823
|
-
function
|
|
823
|
+
function G(e, t) {
|
|
824
824
|
return t ? e.questions[t] ?? null : null;
|
|
825
825
|
}
|
|
826
|
-
function
|
|
826
|
+
function K(e, t) {
|
|
827
827
|
return t ? e.completions[t] ?? null : null;
|
|
828
828
|
}
|
|
829
|
-
function
|
|
829
|
+
function q(e) {
|
|
830
830
|
return e.id === "system_other";
|
|
831
831
|
}
|
|
832
|
-
function
|
|
832
|
+
function J(e) {
|
|
833
833
|
let t = `${e.id} ${e.label}`.toLowerCase();
|
|
834
834
|
return !t.includes("no") && !t.includes("down") && !t.includes("bad");
|
|
835
835
|
}
|
|
836
|
-
function
|
|
836
|
+
function Y(e) {
|
|
837
837
|
return e.type === "yes_no" || e.type === "multiple_choice";
|
|
838
838
|
}
|
|
839
|
-
function
|
|
840
|
-
return !!(
|
|
839
|
+
function X(e, t) {
|
|
840
|
+
return !!(G(e, t) || K(e, t));
|
|
841
841
|
}
|
|
842
|
-
function
|
|
842
|
+
function Z(e) {
|
|
843
843
|
if (!e.pulse_id || !Number.isFinite(e.version) || !e.root_node_id) return "Pulse is missing a usable id, version, or root node.";
|
|
844
|
-
if (!
|
|
844
|
+
if (!X(e, e.root_node_id)) return "Pulse root node does not exist.";
|
|
845
845
|
if (!Object.keys(e.questions).length) return "Pulse must include at least one question.";
|
|
846
846
|
for (let t of Object.keys(e.questions)) if (e.completions[t]) return `Pulse node ${t} is both a question and completion.`;
|
|
847
847
|
for (let [t, n] of Object.entries(e.questions)) {
|
|
@@ -851,14 +851,14 @@ function Q(e) {
|
|
|
851
851
|
"multiple_choice",
|
|
852
852
|
"free_text"
|
|
853
853
|
].includes(n.type)) return `Question ${n.node_id} has unsupported type ${n.type}.`;
|
|
854
|
-
if (
|
|
854
|
+
if (Y(n) && !n.answers?.length) return `Choice question ${n.node_id} has no answers.`;
|
|
855
855
|
let r = /* @__PURE__ */ new Set();
|
|
856
856
|
for (let t of n.answers ?? []) {
|
|
857
857
|
if (!t.id) return `Choice question ${n.node_id} has an answer without id.`;
|
|
858
858
|
if (r.has(t.id)) return `Choice question ${n.node_id} has duplicate answer id ${t.id}.`;
|
|
859
|
-
if (r.add(t.id), t.next_node_id !== void 0 && !
|
|
859
|
+
if (r.add(t.id), t.next_node_id !== void 0 && !X(e, t.next_node_id)) return `Choice ${t.id} references missing node ${t.next_node_id}.`;
|
|
860
860
|
}
|
|
861
|
-
if (n.next_node_id !== void 0 && !
|
|
861
|
+
if (n.next_node_id !== void 0 && !X(e, n.next_node_id)) return `Question ${n.node_id} references missing node ${n.next_node_id}.`;
|
|
862
862
|
}
|
|
863
863
|
for (let [t, n] of Object.entries(e.completions)) {
|
|
864
864
|
if (n.node_id !== t) return `Completion map key ${t} does not match node_id ${n.node_id}.`;
|
|
@@ -866,15 +866,15 @@ function Q(e) {
|
|
|
866
866
|
}
|
|
867
867
|
return null;
|
|
868
868
|
}
|
|
869
|
-
function
|
|
869
|
+
function Q(e, t) {
|
|
870
870
|
if (t?.answer_key) {
|
|
871
871
|
let n = e.answers?.find((e) => e.id === t.answer_key);
|
|
872
872
|
if (n?.next_node_id) return n.next_node_id;
|
|
873
873
|
}
|
|
874
874
|
return e.next_node_id ?? null;
|
|
875
875
|
}
|
|
876
|
-
var
|
|
877
|
-
snapshot =
|
|
876
|
+
var Ae = class {
|
|
877
|
+
snapshot = H;
|
|
878
878
|
listeners = /* @__PURE__ */ new Set();
|
|
879
879
|
deps;
|
|
880
880
|
fabTimeoutId = null;
|
|
@@ -894,7 +894,7 @@ var ke = class {
|
|
|
894
894
|
return this.snapshot;
|
|
895
895
|
}
|
|
896
896
|
getServerSnapshot() {
|
|
897
|
-
return
|
|
897
|
+
return H;
|
|
898
898
|
}
|
|
899
899
|
subscribe(e) {
|
|
900
900
|
return this.destroyed ? () => {} : (this.listeners.add(e), () => this.listeners.delete(e));
|
|
@@ -904,7 +904,7 @@ var ke = class {
|
|
|
904
904
|
}
|
|
905
905
|
currentQuestion() {
|
|
906
906
|
let e = this.snapshot.state;
|
|
907
|
-
return e ?
|
|
907
|
+
return e ? G(e.survey, e.currentNodeId) : null;
|
|
908
908
|
}
|
|
909
909
|
currentAnswer() {
|
|
910
910
|
let e = this.snapshot.state, t = this.currentQuestion();
|
|
@@ -925,8 +925,8 @@ var ke = class {
|
|
|
925
925
|
sentimentChoices() {
|
|
926
926
|
let e = this.currentQuestion();
|
|
927
927
|
return !e || !this.isSentimentStep() ? [] : [...e.answers ?? []].sort((e, t) => {
|
|
928
|
-
let n =
|
|
929
|
-
return n ===
|
|
928
|
+
let n = J(e);
|
|
929
|
+
return n === J(t) ? 0 : n ? -1 : 1;
|
|
930
930
|
});
|
|
931
931
|
}
|
|
932
932
|
shouldShowContinue() {
|
|
@@ -936,7 +936,7 @@ var ke = class {
|
|
|
936
936
|
let e = this.snapshot.state;
|
|
937
937
|
if (!e) return 0;
|
|
938
938
|
if (e.completion || e.isCompleting) return 1;
|
|
939
|
-
let t = Math.max(this.projectedQuestionIds(e).length, 1), n =
|
|
939
|
+
let t = Math.max(this.projectedQuestionIds(e).length, 1), n = G(e.survey, e.survey.root_node_id), r = n && !this.rendersAsSentiment(e, n) ? 1 : 0;
|
|
940
940
|
return Math.min((Object.keys(e.answers).length + r) / t, 1);
|
|
941
941
|
}
|
|
942
942
|
canContinue() {
|
|
@@ -946,17 +946,17 @@ var ke = class {
|
|
|
946
946
|
let n = e.drafts[t.node_id];
|
|
947
947
|
if (!n?.answer_key) return !t.required;
|
|
948
948
|
let r = t.answers?.find((e) => e.id === n.answer_key);
|
|
949
|
-
return !!(r && (!
|
|
949
|
+
return !!(r && (!q(r) || !t.required || n.value?.trim()));
|
|
950
950
|
}
|
|
951
951
|
async handleSyncResponse(e) {
|
|
952
952
|
let t = e.pending_pulse;
|
|
953
953
|
if (!t || this.destroyed) return;
|
|
954
|
-
let n =
|
|
954
|
+
let n = Z(t);
|
|
955
955
|
if (n) {
|
|
956
956
|
this.reportError(Error(n));
|
|
957
957
|
return;
|
|
958
958
|
}
|
|
959
|
-
let r =
|
|
959
|
+
let r = U(t);
|
|
960
960
|
if (this.seenPulseKeys.has(r)) return;
|
|
961
961
|
this.seenPulseKeys.add(r);
|
|
962
962
|
let i = ++this.decisionGeneration, a = await this.resolvePresentationDecision(t);
|
|
@@ -976,13 +976,13 @@ var ke = class {
|
|
|
976
976
|
}
|
|
977
977
|
presentLocalPulse(e, t, n) {
|
|
978
978
|
if (this.destroyed) return !1;
|
|
979
|
-
let r =
|
|
979
|
+
let r = Z(e);
|
|
980
980
|
return r ? (this.reportError(Error(r)), !1) : (this.decisionGeneration += 1, this.beginPulse(e, t, n), !0);
|
|
981
981
|
}
|
|
982
982
|
beginPulse(e, t, n) {
|
|
983
|
-
let r =
|
|
983
|
+
let r = G(e, e.root_node_id), i = K(e, e.root_node_id), a = e.sentimentPresentation === "toolbar", o = e.sentimentPresentation === void 0 ? r?.isSnackBar === !0 || r?.isSnackBar !== !1 && t === "snackbar" && !!e.fab : e.sentimentPresentation === "snackbar", s = (a || o) && r?.type === "yes_no" && r.answers?.length === 2 && !r.answers.some(q);
|
|
984
984
|
this.clearSurveyTransitionTimeouts(), this.publish({
|
|
985
|
-
presentationId: ++
|
|
985
|
+
presentationId: ++De,
|
|
986
986
|
sentimentPresentation: s ? a ? "bar" : "snackbar" : "sheet",
|
|
987
987
|
barPosition: "bottom",
|
|
988
988
|
barBehavior: "dismiss",
|
|
@@ -1007,6 +1007,7 @@ var ke = class {
|
|
|
1007
1007
|
sentimentSelectionLocked: !1,
|
|
1008
1008
|
isCompleting: !1,
|
|
1009
1009
|
presentationConfirmed: !1,
|
|
1010
|
+
presentationReported: !1,
|
|
1010
1011
|
fabEntranceCompleted: !1
|
|
1011
1012
|
}, "transition");
|
|
1012
1013
|
}
|
|
@@ -1030,12 +1031,12 @@ var ke = class {
|
|
|
1030
1031
|
}
|
|
1031
1032
|
async selectChoice(e) {
|
|
1032
1033
|
let t = this.snapshot.state, n = this.currentQuestion();
|
|
1033
|
-
if (!t || !n || t.isBusy || t.sentimentSelectionLocked || t.snackbar && t.snackbar.phase !== "journey" || !
|
|
1034
|
+
if (!t || !n || t.isBusy || t.sentimentSelectionLocked || t.snackbar && t.snackbar.phase !== "journey" || !Y(n)) return;
|
|
1034
1035
|
let r = n.answers?.find((t) => t.id === e.id);
|
|
1035
1036
|
if (!r) return;
|
|
1036
1037
|
let i = t.drafts[n.node_id], a = {
|
|
1037
1038
|
answer_key: r.id,
|
|
1038
|
-
...
|
|
1039
|
+
...q(r) && i?.answer_key === r.id && i.value ? { value: i.value } : {}
|
|
1039
1040
|
}, o = {
|
|
1040
1041
|
...t,
|
|
1041
1042
|
drafts: {
|
|
@@ -1044,13 +1045,13 @@ var ke = class {
|
|
|
1044
1045
|
},
|
|
1045
1046
|
sentimentSelectionLocked: this.isSentimentStep()
|
|
1046
1047
|
};
|
|
1047
|
-
if (this.publish(o, "select"), this.isSentimentStep() && !
|
|
1048
|
+
if (this.publish(o, "select"), this.isSentimentStep() && !q(r)) {
|
|
1048
1049
|
this.sentimentAdvanceTimeoutId !== null && clearTimeout(this.sentimentAdvanceTimeoutId);
|
|
1049
|
-
let e = r.comment?.trim() ? 1400 :
|
|
1050
|
+
let e = r.comment?.trim() ? 1400 : J(r) ? 700 : 500, i = U(t.survey);
|
|
1050
1051
|
this.sentimentAdvanceTimeoutId = setTimeout(() => {
|
|
1051
1052
|
this.sentimentAdvanceTimeoutId = null;
|
|
1052
1053
|
let e = this.snapshot.state;
|
|
1053
|
-
e &&
|
|
1054
|
+
e && U(e.survey) === i && e.currentNodeId === n.node_id && e.drafts[n.node_id]?.answer_key === r.id && this.advance();
|
|
1054
1055
|
}, e);
|
|
1055
1056
|
}
|
|
1056
1057
|
}
|
|
@@ -1079,7 +1080,7 @@ var ke = class {
|
|
|
1079
1080
|
let n = {
|
|
1080
1081
|
pulse_id: t.survey.pulse_id,
|
|
1081
1082
|
pulse_version: t.survey.version,
|
|
1082
|
-
...
|
|
1083
|
+
...W(t.survey),
|
|
1083
1084
|
action: "completed",
|
|
1084
1085
|
responded_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1085
1086
|
answers: t.answers,
|
|
@@ -1093,27 +1094,39 @@ var ke = class {
|
|
|
1093
1094
|
}
|
|
1094
1095
|
confirmPresentation(e, t) {
|
|
1095
1096
|
let n = this.snapshot.state;
|
|
1096
|
-
!n || this.destroyed || t !== void 0 && n.presentationId !== t
|
|
1097
|
-
|
|
1097
|
+
if (!(!n || this.destroyed || t !== void 0 && n.presentationId !== t) && !(e === "sheet" && !n.isOpen) && !(e === "expanded_fab" && n.fabState !== "expanded") && (this.emitPresentationEvent(n, e), e === "expanded_fab" && !n.presentationReported)) {
|
|
1098
|
+
let e = n.snackbar && n.fabEntranceCompleted && n.snackbar.phase === "question" && n.snackbar.deadline === null && n.snackbar.pausedRemainingMs === null ? {
|
|
1099
|
+
...n.snackbar,
|
|
1100
|
+
...$(Date.now(), n.survey.fab?.expandedTimeout)
|
|
1101
|
+
} : n.snackbar;
|
|
1102
|
+
this.publish({
|
|
1103
|
+
...n,
|
|
1104
|
+
presentationConfirmed: !0,
|
|
1105
|
+
presentationReported: !0,
|
|
1106
|
+
snackbar: e
|
|
1107
|
+
}, "transition");
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
confirmEntryDisplayed(e) {
|
|
1111
|
+
let t = this.snapshot.state;
|
|
1112
|
+
!t || this.destroyed || t.fabState !== "expanded" || t.presentationConfirmed || e !== void 0 && t.presentationId !== e || this.publish({
|
|
1113
|
+
...t,
|
|
1098
1114
|
presentationConfirmed: !0
|
|
1099
|
-
}, "transition")
|
|
1115
|
+
}, "transition");
|
|
1100
1116
|
}
|
|
1101
1117
|
confirmFabEntranceCompleted(e) {
|
|
1102
1118
|
let t = this.snapshot.state;
|
|
1103
|
-
|
|
1104
|
-
let n = Date.now(), r = t.survey.fab?.expandedTimeout, i = typeof r == "number" && Number.isFinite(r) && r >= 0 ? n + r : null;
|
|
1105
|
-
this.publish({
|
|
1119
|
+
!t || t.fabState !== "expanded" || !t.presentationConfirmed || t.fabEntranceCompleted || e !== void 0 && t.presentationId !== e || this.destroyed || this.publish({
|
|
1106
1120
|
...t,
|
|
1107
1121
|
fabEntranceCompleted: !0,
|
|
1108
|
-
snackbar: t.snackbar ? {
|
|
1122
|
+
snackbar: t.snackbar && t.presentationReported ? {
|
|
1109
1123
|
...t.snackbar,
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
} : null
|
|
1124
|
+
...$(Date.now(), t.survey.fab?.expandedTimeout)
|
|
1125
|
+
} : t.snackbar
|
|
1113
1126
|
}, "transition");
|
|
1114
1127
|
}
|
|
1115
1128
|
answerSnackbar(e, t) {
|
|
1116
|
-
let n = this.snapshot.state, r = n?.snackbar, i = this.currentQuestion(), a = i?.answers?.find((e) => e.id === t && !
|
|
1129
|
+
let n = this.snapshot.state, r = n?.snackbar, i = this.currentQuestion(), a = i?.answers?.find((e) => e.id === t && !q(e)), o = Date.now();
|
|
1117
1130
|
if (!n || !r || !i || !a || n.presentationId !== e || n.isOpen || !n.fabEntranceCompleted || r.phase !== "question" || r.deadline !== null && o >= r.deadline) return !1;
|
|
1118
1131
|
let s = {
|
|
1119
1132
|
answer_key: a.id,
|
|
@@ -1201,7 +1214,7 @@ var ke = class {
|
|
|
1201
1214
|
phase: "dwelling"
|
|
1202
1215
|
}
|
|
1203
1216
|
}, "transition");
|
|
1204
|
-
let i = r.comment?.trim() ? 1400 :
|
|
1217
|
+
let i = r.comment?.trim() ? 1400 : J(r) ? 700 : 500;
|
|
1205
1218
|
this.sentimentAdvanceTimeoutId = setTimeout(() => {
|
|
1206
1219
|
this.sentimentAdvanceTimeoutId = null;
|
|
1207
1220
|
let t = this.snapshot.state;
|
|
@@ -1231,7 +1244,7 @@ var ke = class {
|
|
|
1231
1244
|
await this.queueInteraction({
|
|
1232
1245
|
pulse_id: e.pulse_id,
|
|
1233
1246
|
pulse_version: e.version,
|
|
1234
|
-
...
|
|
1247
|
+
...W(e),
|
|
1235
1248
|
action: t === "never" ? "never" : "not_now",
|
|
1236
1249
|
responded_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1237
1250
|
});
|
|
@@ -1255,7 +1268,7 @@ var ke = class {
|
|
|
1255
1268
|
let r = t.answers?.find((e) => e.id === n.answer_key);
|
|
1256
1269
|
if (!r) return e.answers;
|
|
1257
1270
|
let i = n.value?.trim();
|
|
1258
|
-
return
|
|
1271
|
+
return q(r) && !t.required && !i ? {
|
|
1259
1272
|
...e.answers,
|
|
1260
1273
|
[t.node_id]: { answered_at: (/* @__PURE__ */ new Date()).toISOString() }
|
|
1261
1274
|
} : {
|
|
@@ -1263,17 +1276,17 @@ var ke = class {
|
|
|
1263
1276
|
[t.node_id]: {
|
|
1264
1277
|
answered_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1265
1278
|
answer_key: r.id,
|
|
1266
|
-
...
|
|
1279
|
+
...q(r) && i ? { value: i } : {}
|
|
1267
1280
|
}
|
|
1268
1281
|
};
|
|
1269
1282
|
}
|
|
1270
1283
|
async advanceFrom(e, t, n) {
|
|
1271
|
-
let r =
|
|
1284
|
+
let r = Q(t, n[t.node_id]);
|
|
1272
1285
|
if (!r) {
|
|
1273
1286
|
await this.completeTerminal(e, n);
|
|
1274
1287
|
return;
|
|
1275
1288
|
}
|
|
1276
|
-
let i =
|
|
1289
|
+
let i = G(e.survey, r);
|
|
1277
1290
|
if (i) {
|
|
1278
1291
|
if (e.history.includes(i.node_id)) {
|
|
1279
1292
|
this.reportError(/* @__PURE__ */ Error(`Pulse graph cycle detected at ${i.node_id}.`)), await this.dismissOrPartial(e, n);
|
|
@@ -1291,7 +1304,7 @@ var ke = class {
|
|
|
1291
1304
|
}, "transition");
|
|
1292
1305
|
return;
|
|
1293
1306
|
}
|
|
1294
|
-
let a =
|
|
1307
|
+
let a = K(e.survey, r);
|
|
1295
1308
|
if (a) {
|
|
1296
1309
|
if (!(!this.rendersAsSentiment(e, t) && this.progress() < 1)) {
|
|
1297
1310
|
this.publish({
|
|
@@ -1314,11 +1327,11 @@ var ke = class {
|
|
|
1314
1327
|
fabState: "hidden",
|
|
1315
1328
|
isOpen: !0
|
|
1316
1329
|
}, "transition");
|
|
1317
|
-
let r =
|
|
1330
|
+
let r = U(e.survey);
|
|
1318
1331
|
this.completionTransitionTimeoutId = setTimeout(() => {
|
|
1319
1332
|
this.completionTransitionTimeoutId = null;
|
|
1320
1333
|
let e = this.snapshot.state;
|
|
1321
|
-
!e ||
|
|
1334
|
+
!e || U(e.survey) !== r || !e.isCompleting || this.publish({
|
|
1322
1335
|
...e,
|
|
1323
1336
|
completion: a,
|
|
1324
1337
|
currentNodeId: null,
|
|
@@ -1333,7 +1346,7 @@ var ke = class {
|
|
|
1333
1346
|
this.publish(null, "transition"), await this.queueInteraction({
|
|
1334
1347
|
pulse_id: e.survey.pulse_id,
|
|
1335
1348
|
pulse_version: e.survey.version,
|
|
1336
|
-
...
|
|
1349
|
+
...W(e.survey),
|
|
1337
1350
|
action: "completed",
|
|
1338
1351
|
responded_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1339
1352
|
answers: t
|
|
@@ -1348,14 +1361,14 @@ var ke = class {
|
|
|
1348
1361
|
this.publish(null, "transition"), await this.queueInteraction(n ? {
|
|
1349
1362
|
pulse_id: e.survey.pulse_id,
|
|
1350
1363
|
pulse_version: e.survey.version,
|
|
1351
|
-
...
|
|
1364
|
+
...W(e.survey),
|
|
1352
1365
|
action: "partial",
|
|
1353
1366
|
responded_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1354
1367
|
answers: t
|
|
1355
1368
|
} : {
|
|
1356
1369
|
pulse_id: e.survey.pulse_id,
|
|
1357
1370
|
pulse_version: e.survey.version,
|
|
1358
|
-
...
|
|
1371
|
+
...W(e.survey),
|
|
1359
1372
|
action: "not_now",
|
|
1360
1373
|
responded_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1361
1374
|
}, e.isSimulated);
|
|
@@ -1369,22 +1382,22 @@ var ke = class {
|
|
|
1369
1382
|
}
|
|
1370
1383
|
emitPresentationEvent(e, t) {
|
|
1371
1384
|
if (e.isSimulated) return;
|
|
1372
|
-
let n = `${
|
|
1385
|
+
let n = `${U(e.survey)}:${t}`;
|
|
1373
1386
|
this.presentedKeys.has(n) || (this.presentedKeys.add(n), this.deps.trackEvent?.("system_did_present_pulse", {
|
|
1374
1387
|
kind: t,
|
|
1375
1388
|
pulse_id: e.survey.pulse_id,
|
|
1376
1389
|
pulse_version: String(e.survey.version),
|
|
1377
|
-
...
|
|
1390
|
+
...W(e.survey)
|
|
1378
1391
|
}));
|
|
1379
1392
|
}
|
|
1380
1393
|
scheduleFabTimeout(e) {
|
|
1381
|
-
if (this.clearFabTimeout(), !e || e.fabState !== "expanded" || !e.
|
|
1394
|
+
if (this.clearFabTimeout(), !e || e.fabState !== "expanded" || !e.presentationReported || !e.fabEntranceCompleted || e.snackbar && e.snackbar.phase !== "question" || e.snackbar?.pausedRemainingMs != null) return;
|
|
1382
1395
|
let t = e.survey.fab?.expandedTimeout;
|
|
1383
1396
|
if (typeof t != "number" || !Number.isFinite(t) || t < 0) return;
|
|
1384
|
-
let n =
|
|
1397
|
+
let n = U(e.survey);
|
|
1385
1398
|
this.fabTimeoutId = setTimeout(() => {
|
|
1386
1399
|
let e = this.snapshot.state;
|
|
1387
|
-
this.destroyed || !e ||
|
|
1400
|
+
this.destroyed || !e || U(e.survey) !== n || e.fabState !== "expanded" || this.dismissOrPartial(e, e.answers);
|
|
1388
1401
|
}, e.snackbar?.deadline !== null && e.snackbar?.deadline !== void 0 ? Math.max(0, e.snackbar.deadline - Date.now()) : t);
|
|
1389
1402
|
}
|
|
1390
1403
|
clearFabTimeout() {
|
|
@@ -1397,9 +1410,9 @@ var ke = class {
|
|
|
1397
1410
|
return t.node_id === e.survey.root_node_id && t.type === "yes_no" && t.answers?.length === 2;
|
|
1398
1411
|
}
|
|
1399
1412
|
projectedQuestionIds(e) {
|
|
1400
|
-
let t = [], n = /* @__PURE__ */ new Set(), r =
|
|
1413
|
+
let t = [], n = /* @__PURE__ */ new Set(), r = G(e.survey, e.survey.root_node_id)?.node_id ?? null;
|
|
1401
1414
|
for (; r;) {
|
|
1402
|
-
let i =
|
|
1415
|
+
let i = G(e.survey, r);
|
|
1403
1416
|
if (!i || n.has(r)) break;
|
|
1404
1417
|
t.push(r), n.add(r), r = this.projectedNextQuestionId(e, i);
|
|
1405
1418
|
}
|
|
@@ -1408,15 +1421,15 @@ var ke = class {
|
|
|
1408
1421
|
projectedNextQuestionId(e, t) {
|
|
1409
1422
|
let n = e.answers[t.node_id];
|
|
1410
1423
|
if (n) {
|
|
1411
|
-
let r =
|
|
1412
|
-
return r &&
|
|
1424
|
+
let r = Q(t, n);
|
|
1425
|
+
return r && G(e.survey, r) ? r : null;
|
|
1413
1426
|
}
|
|
1414
1427
|
if (!t.required) {
|
|
1415
1428
|
let n = t.next_node_id ?? null;
|
|
1416
|
-
return n &&
|
|
1429
|
+
return n && G(e.survey, n) ? n : null;
|
|
1417
1430
|
}
|
|
1418
1431
|
let r = new Set((t.answers ?? []).map((e) => e.next_node_id).filter(Boolean)), i = r.size === 0 ? t.next_node_id ?? null : r.size === 1 ? [...r][0] ?? t.next_node_id ?? null : null;
|
|
1419
|
-
return i &&
|
|
1432
|
+
return i && G(e.survey, i) ? i : null;
|
|
1420
1433
|
}
|
|
1421
1434
|
publish(e, t, n = !1) {
|
|
1422
1435
|
this.clearFabTimeout(), this.snapshot = {
|
|
@@ -1436,8 +1449,14 @@ var ke = class {
|
|
|
1436
1449
|
}
|
|
1437
1450
|
isSystemOtherDraft(e) {
|
|
1438
1451
|
let t = this.snapshot.state?.drafts[e.node_id];
|
|
1439
|
-
return !!(t?.answer_key && e.answers?.some((e) => e.id === t.answer_key &&
|
|
1452
|
+
return !!(t?.answer_key && e.answers?.some((e) => e.id === t.answer_key && q(e)));
|
|
1440
1453
|
}
|
|
1441
1454
|
};
|
|
1455
|
+
function $(e, t) {
|
|
1456
|
+
return {
|
|
1457
|
+
startedAt: e,
|
|
1458
|
+
deadline: typeof t == "number" && Number.isFinite(t) && t >= 0 ? e + t : null
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1442
1461
|
//#endregion
|
|
1443
|
-
export {
|
|
1462
|
+
export { E as PendingInteractionStorageError, w as SidebandApiError, Ae as SurveySessionStore, V as SyncEngine, Oe as buildFabTitle, p as createContextResolver, T as createSidebandClient, Ce as createSidebandRuntime, ke as getChoiceValue, s as getDeviceId, c as getSessionId, J as isPositiveSentimentChoice, q as isSystemOtherChoice, Ee as resolveSnackbarPresentation };
|