@sprig-technologies/sprig-browser 2.41.0 → 2.41.1

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.
@@ -0,0 +1,743 @@
1
+ import { a as z, h as Z, u as e, c as O, b as re, f as Me, F as he, g as ye, e as ge, _ as te, T as ke, A as ir, p as ne, i as ar, q as lr, r as or, M as de, s as Ze, t as dr, j as cr, n as ur, v as pr, k as Ae, l as mr, m as gr, x as hr, o as Qe } from "./view-Bvmj0wxW.js";
2
+ import { t as le } from "./metricsReporter-CJzT7qY-.js";
3
+ import { a as qe, D as Ee, g as We, A as br } from "./core-DE_-33ff.js";
4
+ import { c as ie, a as ae, H as _e, M as pe, Q as ue, O as Se, B as ee, L as Ie, b as Te, S as vr, u as yr, g as fr, P as Sr, p as xr, v as kr, R as se, d as Ir, s as _r, e as Tr } from "./getAttributedUrl-DBTn-NUH.js";
5
+ const Cr = ({ className: n, message: s, next: o, properties: r, questionId: t, type: a }) => {
6
+ const { useMobileStyling: m, border: y, isLongFormSurvey: d, focusedQuestionId: g } = z((v) => ({ useMobileStyling: v.useMobileStyling, border: v.border, isLongFormSurvey: le(v.studyType), focusedQuestionId: v.focusedQuestionId })), [c, f] = Z(!1), [i, S] = Z(""), [p, h] = Z(!1), b = d && g === t, x = r == null ? void 0 : r.collectName, _ = (r == null ? void 0 : r.nameLabelText) || "Full Name", k = (r == null ? void 0 : r.consentText) || "I agree to the stated conditions", U = (r == null ? void 0 : r.submitButtonText) || "Submit", P = !!i.trim(), M = c && (!x || P), D = (v, w = !1) => {
7
+ v.preventDefault(), v.stopPropagation();
8
+ let B = null;
9
+ if (!w) {
10
+ if (!M) return void h(!0);
11
+ B = { submitted: !0 }, x && (B.name = i);
12
+ }
13
+ o({ value: B, questionId: t, type: a }, M);
14
+ };
15
+ return e("div", { className: O(n, d && !b && "ul-card--unfocused", "ul-card__consent-legal", "fade-in-transition"), children: [e(ie, { isRequired: d && (r == null ? void 0 : r.required), message: s, properties: { questionHtml: r.questionHtml } }), r != null && r.richTextBody ? e(ae, { children: e(_e, { className: "ul-rich-text-body", html: r.richTextBody, id: "ul-card__consent-legal-body-container" }) }) : null, e(pe, { embeddedType: "pdf", properties: r, children: e(ue, { children: [e("div", { className: "sprig-stretch", children: [e(Se, { allowTextEntry: !1, border: y, error: p && !c, id: "consent", isRadio: !1, isSelected: c, label: k, onUserInputChanged: ({ selected: v }) => {
16
+ v !== c && f(!c);
17
+ }, useMobileStyling: m }), x && e("input", { "aria-label": _, "aria-placeholder": _, className: O(re("ul-consent-legal__name-input", m)), "data-gramm": "false", maxLength: 250, name: "name", onBlur: (v) => {
18
+ v.currentTarget.style.borderColor = p && !P ? qe : Ee;
19
+ }, onFocus: (v) => {
20
+ v.currentTarget.style.borderColor = p && !P ? qe : y;
21
+ }, onInput: (v) => {
22
+ v.preventDefault(), v.stopPropagation(), S(v.currentTarget.value);
23
+ }, placeholder: _, style: p && !P ? { borderColor: qe } : {}, tabIndex: 0, value: i })] }), e("div", { className: "ul-card__button-wrapper ul-card-vertical__button-wrapper", children: [e(ee, { className: M ? "" : "sprig-button-disabled", onClick: D, children: U }), r.required === !1 && !d && e("button", { className: "ul-card-skip__button", onClick: (v) => D(v, !0), children: Me(r) })] })] }) })] }, t);
24
+ }, Nr = ({ activeValue: n, border: s, icon: o, isPressed: r, onSubmit: t, range: a, scaleLabelType: m, selectedValue: y, setSelectedValue: d, setActiveValue: g, setIsPressed: c, useMobileStyling: f, value: i, viewDocument: S }) => {
25
+ const { isLongFormSurvey: p, enableCspTrustedTypes: h } = z((w) => ({ isLongFormSurvey: le(w.studyType), enableCspTrustedTypes: w.enableCspTrustedTypes })), b = `option-${i}`, x = m === "number", _ = m === "star", k = m === "smiley", U = x && i === n || i === y, [P, M] = (() => {
26
+ const w = _ && y !== null && i <= y;
27
+ return _ && i <= n || k && i === n || w || i === n || i === y ? [s, r || w || i === y ? 1 : 0.3] : ["", 1];
28
+ })(), D = he(() => {
29
+ const w = { borderColor: U ? P : "", fillOpacity: U ? "" : M, zIndex: U ? 3 : "auto", color: y === i ? "#fff" : "" };
30
+ return x ? { ...w, backgroundColor: y === i ? P : "" } : { ...w, color: _ || k || y === i ? P : "" };
31
+ }, [U, P, M, y, i, x, _, k]), v = he(() => We((({ icon: w, scaleLabelType: B, value: T, selectedValue: L }) => {
32
+ if (B === "smiley" && T === L) {
33
+ let A = 0;
34
+ return w.replace(/black/g, () => ++A == 1 ? "black" : "white");
35
+ }
36
+ return w;
37
+ })({ icon: o, scaleLabelType: m, value: i, selectedValue: y }), h), [h, o, m, y, i]);
38
+ return e("button", { "aria-label": x ? void 0 : String(i), className: (() => {
39
+ switch (m) {
40
+ case "star":
41
+ return O(re("likert-star", f), re(`likert-star-${i}`, f));
42
+ case "smiley":
43
+ return O(re("likert-smiley", f), re(`likert-smiley-${i}`, f));
44
+ default:
45
+ return i === a ? O(re("likert-number", f), re(`likert-number-${i}`, f), re("likert-last-option", f)) : O(re("likert-number", f), re(`likert-number-${i}`, f));
46
+ }
47
+ })(), dangerouslySetInnerHTML: { __html: v }, id: b, onClick: (w) => {
48
+ p && (w.preventDefault(), w.stopPropagation(), d(i)), t();
49
+ }, onKeyDown: (w) => {
50
+ var L, A;
51
+ const B = S.querySelectorAll(`.likert-${m ?? "number"}`), T = i - 1;
52
+ w.key === "ArrowRight" ? (L = B[T + 1]) == null || L.focus() : w.key === "ArrowLeft" ? (A = B[T - 1]) == null || A.focus() : w.key !== "Enter" && w.key !== " " || (p && (w.preventDefault(), w.stopPropagation(), d(i)), t());
53
+ }, onPointerDown: () => c(!0), onPointerEnter: () => g(i), onPointerLeave: () => {
54
+ g(-1), c(!1);
55
+ }, style: D, tabIndex: 0 });
56
+ }, wr = ({ className: n, labels: s, message: o, next: r, properties: t, questionId: a, type: m }) => {
57
+ const { border: y, useMobileStyling: d, viewDocument: g, isLongFormSurvey: c, focusedQuestionId: f } = z((T) => ({ border: T.border, useMobileStyling: T.useMobileStyling, viewDocument: T.viewDocument, isLongFormSurvey: le(T.studyType), focusedQuestionId: T.focusedQuestionId })), [i, S] = Z(-1), [p, h] = Z(!1), [b, x] = Z(null), _ = c && f === a, k = s && s.left, U = s && s.right;
58
+ let P;
59
+ const { range: M, scaleLabelType: D, ratingIcons: v } = t;
60
+ M && (P = Number(M));
61
+ const w = P || 5, B = (T) => {
62
+ var L, A;
63
+ switch (D) {
64
+ case "star":
65
+ return (L = v[0]) == null ? void 0 : L.svg;
66
+ case "smiley":
67
+ return (A = v[T]) == null ? void 0 : A.svg;
68
+ default:
69
+ return String(T + 1);
70
+ }
71
+ };
72
+ return e("form", { className: O(n, "ul-card--likert", "fade-in-transition", c && !_ && "ul-card--unfocused"), children: [e(ie, { isRequired: c && (t == null ? void 0 : t.required), message: o, properties: t }), e(pe, { properties: t, children: e(ye, { children: [e(ae, { children: [e("div", { "aria-label": `Rating (1 - ${w})`, className: "ul-card--likert__numbers", role: "radiogroup", children: [...Array(w)].map((T, L) => {
73
+ const A = L + 1;
74
+ return e(Nr, { activeValue: i, border: y, icon: B(L), isPressed: p, onSubmit: () => r({ value: A, questionId: a, type: m }, !0), range: w, scaleLabelType: D, selectedValue: b, setActiveValue: S, setIsPressed: h, setSelectedValue: x, useMobileStyling: d, value: A, viewDocument: g }, L);
75
+ }) }), e("div", { className: "ul-card--likert__labels", children: [e("span", { children: k }), e("span", { children: U })] })] }), !t.required && !c && e(ue, { children: e("div", { className: "ul-vertical-centered-container", children: e(ee, { onClick: (T) => {
76
+ T.preventDefault(), T.stopPropagation(), r({ value: null, questionId: a, type: m }, !0);
77
+ }, children: ge(t) }) }) })] }) })] }, a);
78
+ }, ze = (n) => n && (n.scrollHeight > n.offsetHeight ? n : ze(n.parentElement)), qr = (n) => {
79
+ if (!n || !((o) => o instanceof HTMLElement)(n)) return 0;
80
+ const s = getComputedStyle(n);
81
+ return parseFloat(s.marginTop) + parseFloat(s.marginBottom) + (parseFloat(s.borderTopWidth) + parseFloat(s.borderBottomWidth));
82
+ }, Lr = ({ columns: n, onSelect: s, options: o, selectedOptions: r }) => {
83
+ const t = te([]), { border: a, useMobileStyling: m } = z((i) => ({ border: i.border, useMobileStyling: i.useMobileStyling })), y = o.findIndex((i) => r[i.id] === null), [d, g] = Z(y), c = ke((i, S) => {
84
+ s(i, S);
85
+ const p = d + 1, h = o[p];
86
+ if (h && r[h.id] === null) {
87
+ g(p);
88
+ const b = t.current[d];
89
+ if (b != null && b.firstElementChild) {
90
+ const x = ze(b), _ = b.firstElementChild, k = qr(b) + _.clientHeight;
91
+ x == null || x.scrollTo(0, b.offsetTop + k);
92
+ }
93
+ }
94
+ }, [s, o, r, d]), f = ke((i, S) => {
95
+ const p = d === i;
96
+ return e(ir, { animate: !0, header: S.label, isOpen: p, onClick: () => {
97
+ var h;
98
+ return g(p && !((h = window.UserLeap) != null && h.isMobileSDK) ? -1 : i);
99
+ }, ref: (h) => {
100
+ h && (t.current[i] = h);
101
+ }, showHeaderCheck: r[S.id] !== null, children: e("div", { style: { paddingTop: "12px" }, children: n.map((h) => e(Se, { allowTextEntry: !1, ariaLabel: `${S.label}-${h.label}`, border: a, error: !1, id: `${S.id}-${h.value}`, isRadio: !0, isSelected: r[S.id] === h.value, label: h.label, onUserInputChanged: () => c(S.id, h.value), useMobileStyling: m }, h.label)) }) }, S.id);
102
+ }, [a, n, d, c, r, m]);
103
+ return e("div", { children: o.map((i, S) => f(S, i)) });
104
+ }, Pr = ({ columns: n, onSelect: s, options: o, selectedOptions: r }) => {
105
+ const { border: t, useMobileStyling: a, isLongFormSurvey: m } = z((p) => ({ border: p.border, useMobileStyling: p.useMobileStyling, isLongFormSurvey: le(p.studyType) })), y = o.length, d = n.length, g = te(null), [c, f] = Z(!1), [i, S] = Z(!1);
106
+ return ne(() => {
107
+ const p = g.current, h = new ResizeObserver((b) => {
108
+ window.requestAnimationFrame(() => {
109
+ p && (f(Math.round(b[0].contentRect.width) < p.scrollWidth), S(Math.round(b[0].contentRect.width) < p.scrollWidth));
110
+ });
111
+ });
112
+ return p && h.observe(p), () => {
113
+ p && h.unobserve(p);
114
+ };
115
+ }, []), e("div", { className: "ul-card--matrix_question_container", children: [e("div", { className: O("ul-card--matrix_container", c && "ul-matrix-scroll-gradient"), onScroll: () => {
116
+ (() => {
117
+ const p = g.current;
118
+ p && f(p.clientWidth + Math.abs(p.scrollLeft) < p.scrollWidth);
119
+ })();
120
+ }, ref: g, children: e("div", { className: O(m && "ul-card--matrix_grid_longform", "ul-card--matrix_grid"), style: `--numColumns: ${d}; --numRows: ${y + 1};`, children: [e("div", {}), " ", n.map((p) => e("div", { className: "ul-matrix-column-label", children: p.label }, p.label)), o.map((p) => e(ye, { children: [e("div", { "aria-label": p.label, className: "ul-matrix-row-label", children: p.label }, p.label), e("div", { className: "ul-matrix-row-options", role: "radiogroup", children: n.map((h, b) => e("div", { className: O("ul-matrix-option-wrapper", b === d - 1 && "ul-matrix-last-option"), children: e(Se, { allowTextEntry: !1, ariaLabel: `${p.label}-${h.label}`, border: t, choiceStyle: { background: "transparent", border: "none", marginBottom: "0", padding: "0" }, error: !1, id: `${p.id}-${h.value}`, isRadio: !0, isSelected: r[p.id] === h.value, onUserInputChanged: () => s(p.id, h.value), useMobileStyling: a }) }, h.value)) })] }))] }) }), (c || i) && e("button", { className: i && !c ? "ul-matrix-scroll-arrow left" : "ul-matrix-scroll-arrow", onClick: i && !c ? (p) => {
121
+ p.preventDefault();
122
+ const h = g.current;
123
+ if (h) {
124
+ const b = getComputedStyle(h).direction === "rtl";
125
+ h.scrollTo({ left: b ? h.scrollWidth - h.clientWidth : 0, behavior: "smooth" });
126
+ }
127
+ } : (p) => {
128
+ p.preventDefault();
129
+ const h = g.current;
130
+ if (h) {
131
+ const b = getComputedStyle(h).direction === "rtl";
132
+ h.scrollTo({ left: b ? h.clientWidth - h.scrollWidth : h.scrollWidth, behavior: "smooth" });
133
+ }
134
+ }, children: e(i && !c ? Rr : Dr, {}) })] });
135
+ }, Rr = () => e("svg", { fill: "currentColor", height: "32", transform: "matrix(-1,0,0,1,0,0)", version: "1.1", viewBox: "0 0 256 256", width: "32", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z" }) }), Dr = () => e("svg", { fill: "currentColor", height: "32", viewBox: "0 0 256 256", width: "32", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z" }) }), Mr = ({ className: n, message: s, next: o, options: r, properties: t, questionId: a, type: m, showIndividualSubmit: y = !1, onSubmitButtonClick: d }) => {
136
+ const { useMobileStyling: g, isLongFormSurvey: c, focusedQuestionId: f, setFocusedQuestionId: i } = z((D) => ({ useMobileStyling: D.useMobileStyling, isLongFormSurvey: le(D.studyType), focusedQuestionId: D.focusedQuestionId, setFocusedQuestionId: D.setFocusedQuestionId })), S = t.matrixColumn, p = t.required, h = c && f === a, b = (D) => {
137
+ D.preventDefault(), D.stopPropagation(), o({ value: _, questionId: a, type: m }, !0), d && d();
138
+ }, x = r.reduce((D, v) => (D[v.id] = null, D), {}), [_, k] = Z(x), U = (D) => p && Object.values(D).every((v) => v == null), P = (D, v) => {
139
+ c && o({ value: { ..._, [D]: v }, questionId: a, type: m }, !U({ ..._, [D]: v })), k((w) => ({ ...w, [D]: v }));
140
+ }, M = t.displayMatrixAsAccordion || g;
141
+ return e("form", { className: O(n, !c && "ul-card__matrix", "fade-in-transition", c && !h && "ul-card--unfocused"), id: "text-form", onClick: () => {
142
+ h && i(a);
143
+ }, onSubmit: b, children: [e(ie, { isRequired: c && (t == null ? void 0 : t.required), message: s, properties: t }), e(pe, { properties: t, children: [e(ae, { children: [e(M ? Lr : Pr, { columns: S, onSelect: P, options: r, selectedOptions: _ }), y && e(Ie, { handleSubmit: b, isSubmitDisabled: U(_) })] }), !c && e(ue, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: U(_), children: ge(t) }) }) })] })] }, a);
144
+ }, Ye = ({ className: n, message: s, onSubmit: o, options: r = [], properties: t, questionId: a, type: m, showIndividualSubmit: y = !1, onSubmitButtonClick: d }) => {
145
+ const { border: g, useMobileStyling: c, isLongFormSurvey: f, focusedQuestionId: i, setFocusedQuestionId: S } = z((u) => ({ border: u.border, useMobileStyling: u.useMobileStyling, isLongFormSurvey: le(u.studyType), focusedQuestionId: u.focusedQuestionId, setFocusedQuestionId: u.setFocusedQuestionId })), p = f && i === a, h = r.reduce((u, C) => (u[C.id] = { isSelected: !1 }, u), {}), [b, x] = Z(h), _ = m === "multiplechoice", k = t.required, U = r.find((u) => {
146
+ var C;
147
+ return (C = u.optionProperties) == null ? void 0 : C.noneOfTheAbove;
148
+ }), P = (u) => Object.entries(u).some(([C, V]) => {
149
+ var l;
150
+ const J = r.find((I) => `${I.id}` === C), H = V.userText === void 0 || V.userText.trim() === "";
151
+ return ((l = J == null ? void 0 : J.optionProperties) == null ? void 0 : l.allowsTextEntry) && H && V.isSelected;
152
+ }), M = (u) => Object.values(u).filter((C) => C.isSelected).length, D = t.minSelect && t.minSelect > 0 && t.maxSelectMode === Te.Range && M(b) < t.minSelect && (k || M(b) > 0), v = (u) => P(u) || k && !M(u) || !((C) => {
153
+ const { minSelect: V = 0, maxSelect: J = 1 / 0, maxSelectMode: H } = t, l = M(C);
154
+ switch (H) {
155
+ case Te.Maximum:
156
+ return l <= J;
157
+ case Te.Range:
158
+ return l === 0 || l >= V;
159
+ default:
160
+ return !0;
161
+ }
162
+ })(u), w = Object.entries(b).some(([u, C]) => {
163
+ var V, J;
164
+ return C.isSelected && ((J = (V = r.find((H) => `${H.id}` === u)) == null ? void 0 : V.optionProperties) == null ? void 0 : J.allowsTextEntry);
165
+ }), B = y && (!_ || w), T = (u) => {
166
+ Y(u.id, u.selected, u.userText, u.noneOfTheAbove), u.selected && f && !_ && !p && S(a);
167
+ }, L = (u) => {
168
+ var C;
169
+ return (t == null ? void 0 : t.maxSelectMode) !== Te.Unlimited && M(b) === (t == null ? void 0 : t.maxSelect) && !((C = b[u]) != null && C.isSelected);
170
+ }, A = (u) => {
171
+ u.preventDefault(), u.stopPropagation(), o(b, !0), d && d();
172
+ }, Y = (u, C, V, J) => {
173
+ const H = Object.assign({}, b);
174
+ if ((_ || J) && C) for (const q of Object.values(H)) q.isSelected = !1, delete q.userText;
175
+ else U && !J && b[U.id].isSelected && (H[U.id].isSelected = !1);
176
+ H[u] = { isSelected: C, userText: V };
177
+ const l = _ && Object.entries(H).some(([q, F]) => {
178
+ var E, G;
179
+ return F.isSelected && ((G = (E = r.find((K) => `${K.id}` === q)) == null ? void 0 : E.optionProperties) == null ? void 0 : G.allowsTextEntry);
180
+ }), I = !v(H);
181
+ f && (o(H, I), _ && !l && I && d && d()), x(H);
182
+ };
183
+ return e("form", { className: O(n, "ul-card--multiple", "fade-in-transition", f && !p && "ul-card--unfocused"), id: "text-form", onClick: m === "multipleselect" ? () => {
184
+ f && i !== a && m === "multipleselect" && S(a);
185
+ } : void 0, onSubmit: A, children: [e(ie, { isRequired: f && (t == null ? void 0 : t.required), message: s, properties: t }), e(pe, { properties: t, children: e(ye, { children: [e(ae, { children: [t.isDropdown ? e(vr, { disabledOptions: r.filter((u) => L(u.id)), dropdownFooter: D ? e("div", { className: "ul-card__min-select-counter", style: { marginLeft: "16px" }, children: [M(b), "/", t.minSelect] }) : void 0, isMultiSelect: !_, multiselectText: t.dropdownMultiselectedText ?? "choices selected", onChange: (u) => {
186
+ const C = { ...b };
187
+ for (const V of r) u.includes(V) ? C[V.id].isSelected = !0 : C[V.id].isSelected = !1;
188
+ f && o(C, !v(C)), x(C);
189
+ }, options: r, placeholderText: t.dropdownPlaceholderText ?? (_ ? "Select choice" : "Select choice(s)"), value: r.filter((u) => b[u.id].isSelected) }) : e("div", { className: O(re("ul-card__choices", c)), role: _ ? "radiogroup" : "group", children: [r.map(({ id: u, label: C, value: V, optionProperties: J }) => {
190
+ var F, E;
191
+ const H = `${u}`, { allowsTextEntry: l, noneOfTheAbove: I } = { allowsTextEntry: !1, noneOfTheAbove: !1, ...J };
192
+ return e(Se, { allowTextEntry: l, border: g, disabled: L(H), error: (q = b, P(q)), id: H, isRadio: _, isSelected: !!((F = b[H]) != null && F.isSelected), label: C, noneOfTheAbove: I, onUserInputChanged: T, promptText: "Please specify", text: (E = b[u]) == null ? void 0 : E.userText, useMobileStyling: c, value: V }, H);
193
+ var q;
194
+ }), !!D && e("div", { className: "ul-card__min-select-counter", children: [M(b), "/", t.minSelect] })] }), B && e(Ie, { handleSubmit: A, isSubmitDisabled: v(b) })] }), !f && e(ue, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: v(b), onClick: A, children: ge(t) }) }) })] }) })] }, a);
195
+ }, Er = (n) => {
196
+ const { questionId: s, type: o, next: r, options: t } = n, { setFocusedQuestionId: a } = z((m) => ({ setFocusedQuestionId: m.setFocusedQuestionId }));
197
+ return e(Ye, { ...n, onSubmit: (m, y) => {
198
+ var S;
199
+ const d = Object.entries(m).find(([, p]) => p.isSelected) || [void 0, void 0], [g, c] = d, f = t.find((p) => `${p.id}` === g);
200
+ !((S = f == null ? void 0 : f.optionProperties) != null && S.allowsTextEntry) || c != null && c.userText && c.userText.trim() !== "" || a(s);
201
+ const i = c != null && c.userText ? { [g]: { userText: c.userText } } : null;
202
+ r({ value: f && g ? { [g]: f.value } : {}, secondaryValue: i, questionId: s, type: o }, y);
203
+ } });
204
+ }, Br = (n) => {
205
+ const { questionId: s, type: o, next: r } = n;
206
+ return e(Ye, { ...n, onSubmit: (t, a) => {
207
+ const m = Object.entries(t).reduce((d, [g, c]) => (d[g] = c.isSelected, d), {}), y = Object.entries(t).reduce((d, [g, c]) => {
208
+ if (!c.userText) return d;
209
+ const f = d || {};
210
+ return f[g] = { userText: c.userText }, f;
211
+ }, null);
212
+ r({ value: m, secondaryValue: y, questionId: s, type: o }, a);
213
+ } });
214
+ }, Ur = ({ className: n, labels: s, message: o, properties: r, next: t, questionId: a, type: m }) => {
215
+ const [y, d] = Z(null), { border: g, useMobileStyling: c, viewDocument: f, isLongFormSurvey: i, focusedQuestionId: S } = z((x) => ({ border: x.border, useMobileStyling: x.useMobileStyling, viewDocument: x.viewDocument, isLongFormSurvey: le(x.studyType), focusedQuestionId: x.focusedQuestionId })), p = i && S === a, h = s && s.left, b = s && s.right;
216
+ return e("form", { className: O(n, "ul-card--nps", "fade-in-transition", i && !p && "ul-card--unfocused"), children: [e(ie, { isRequired: i && (r == null ? void 0 : r.required), message: o, properties: r }), e(pe, { properties: r, children: [e(ae, { children: [e("div", { className: "ul-card--nps__numbers", children: [...Array(11)].map((x, _) => e("button", { className: O(re("nps-number", c), re(`nps-number-${_}`, c)), id: `option-${_}`, onClick: (k) => {
217
+ i && (k.preventDefault(), k.stopPropagation(), d(_)), t({ value: _, questionId: a, type: m }, !0);
218
+ }, onKeyDown: (k) => {
219
+ var P, M;
220
+ const U = f.querySelectorAll("button.nps-number");
221
+ k.key === "ArrowRight" ? (P = U[_ + 1]) == null || P.focus() : k.key === "ArrowLeft" ? (M = U[_ - 1]) == null || M.focus() : k.key !== "Enter" && k.key !== " " || (i && (k.preventDefault(), k.stopPropagation(), d(_)), t({ value: _, questionId: a, type: m }, !0));
222
+ }, onPointerDown: (k) => {
223
+ k.currentTarget.style.zIndex = "2", k.currentTarget.style.borderColor = g;
224
+ }, onPointerLeave: (k) => {
225
+ k.currentTarget.style.zIndex = "auto", k.currentTarget.style.borderColor = Ee;
226
+ }, style: y === _ ? { backgroundColor: g, color: "#fff" } : void 0, tabIndex: 0, children: _ }, _)) }), e("div", { className: "ul-card--nps__labels", children: [e("span", { children: h }), e("span", { children: b })] })] }), !r.required && !i && e(ue, { children: e("div", { className: "ul-vertical-centered-container", children: e(ee, { onClick: (x) => {
227
+ x.preventDefault(), x.stopPropagation(), t({ value: null, questionId: a, type: m }, !0);
228
+ }, children: ge(r) }) }) })] })] }, a);
229
+ }, Fr = (n) => {
230
+ const { className: s, message: o, next: r, properties: t, questionId: a, type: m, showIndividualSubmit: y = !1, onSubmitButtonClick: d } = n, g = m === "aidynamicfollowup" ? n.loading : void 0, { border: c, useMobileStyling: f, update: i, isLongFormSurvey: S, focusedQuestionId: p, setFocusedQuestionId: h, isPreview: b } = z((T) => ({ border: T.border, useMobileStyling: T.useMobileStyling, update: T.update, isLongFormSurvey: le(T.studyType), focusedQuestionId: T.focusedQuestionId, setFocusedQuestionId: T.setFocusedQuestionId, isPreview: T.isPreview })), [x, _] = Z(""), k = te(null), U = S && p === a;
231
+ ne(() => {
232
+ var T, L;
233
+ S && !b && (U ? (T = k.current) == null || T.focus() : (L = k.current) == null || L.blur());
234
+ }, [S, U, b]);
235
+ const P = x.trim(), M = t.required === !0 && !P, D = yr(k, () => i()), v = (T) => {
236
+ T.preventDefault(), T.stopPropagation();
237
+ const L = P.length > 0, A = !t.required || L;
238
+ r({ value: x, questionId: a, type: m }, A), d && d(L);
239
+ }, w = t && t.openTextPlaceholder ? t.openTextPlaceholder : "";
240
+ if (g == null && m === "aidynamicfollowup") return e(ye, {});
241
+ const B = g ? "Preparing your next question" : o;
242
+ return e("form", { className: O(s, "ul-card-text", "fade-in-transition", S && !U && "ul-card--unfocused"), id: "text-form", onClick: () => {
243
+ S && p !== a && h(a);
244
+ }, children: [e(ie, { isRequired: S && (t == null ? void 0 : t.required), message: B, properties: t }), e(pe, { properties: t, children: e("div", { className: "ul-card-text", children: e(ae, { children: [e("div", { className: "ul-card-text__container", children: e("textarea", { "aria-describedby": "ul-caption", "aria-labelledby": "ul-question", "aria-multiline": "true", "aria-placeholder": w, className: O(!!g && "ul-card-text__input__loading", re("ul-card-text__input", f)), "data-gramm": "false", disabled: !!g, maxLength: 5e3, name: "text", onBlur: (T) => {
245
+ T.currentTarget.style.borderColor = Ee;
246
+ }, onChange: (T) => {
247
+ const { value: L } = T.currentTarget;
248
+ if (D(), T.preventDefault(), T.stopPropagation(), _(L), S) {
249
+ const A = L.trim().length > 0;
250
+ r({ value: L, questionId: a, type: m }, A);
251
+ }
252
+ }, onFocus: (T) => {
253
+ T.currentTarget.style.borderColor = c, h(a);
254
+ }, placeholder: w, ref: k, role: "textbox", tabIndex: 0 }) }), t.footerHtml && e(_e, { className: "footer", html: t.footerHtml }), y && e(Ie, { handleSubmit: v, isSubmitDisabled: M }), e(ue, { children: !S && e(ee, { disabled: M || !!g, onClick: v, children: ge(t) }) })] }) }) })] }, a);
255
+ }, Pe = 1, Ke = 2, Xe = 3, Ce = (n) => n.type === "av_permission", Oe = (n) => n.type === "screen_permission", Je = (n, s) => n === void 0 ? Pe : n ? ((o, r) => !(Ce(r) ? r.permissionDescriptors : []).includes("camera") || o.getVideoTracks().length > 0)(n, s) ? Xe : Pe : Ke, $e = { avStream: null, currentPage: null, mediaRecordingUids: null, nextQuestion: () => {
256
+ }, passthroughData: void 0, recordingMediaTypes: void 0, screenPermissionRequested: !1, type: void 0 }, ce = ar((n) => ({ ...$e, reset: () => {
257
+ n($e);
258
+ }, updatePage: (s) => {
259
+ n(s);
260
+ } }));
261
+ function Re({ currentPage: n, pages: s }) {
262
+ const { avStream: o, recordingMediaTypes: r, updatePage: t } = ce.getState(), { recorderEventEmitter: a } = z.getState();
263
+ a.emit("av.permission", { "permission.descriptors": n.permissionDescriptors, "stream.ready": (m, y) => {
264
+ if (o === m) return;
265
+ let d = n;
266
+ if (m && !n.permissionDescriptors.includes("camera")) {
267
+ const g = s.indexOf(n), c = y != null && y.active ? g + 2 : g + 1;
268
+ y != null && y.active && r && a.emit("begin.recording", { "recording.media.types": r, "start.recording.callback": (f) => t({ mediaRecordingUids: f }) }), d = s[c];
269
+ }
270
+ t({ currentPage: d, avStream: m });
271
+ } });
272
+ }
273
+ function De({ status: n }) {
274
+ const { nextQuestion: s, passthroughData: o, mediaRecordingUids: r, reset: t } = ce.getState(), { recorderEventEmitter: a, handleUploadUpdate: m, index: y } = z.getState(), d = { value: { taskStatus: n }, type: "recordedtask", questionId: (o == null ? void 0 : o.questionId) || 1 };
275
+ o && a.emit("finish.task", { "begin.callback": (g) => {
276
+ m({ mediaRecordingUid: g, isSubmitted: !0, progressPct: 0, isComplete: !1 });
277
+ }, "progress.callback": (g, c) => {
278
+ m({ mediaRecordingUid: g, progressPct: c.detail, isSubmitted: !1, isComplete: !1 });
279
+ }, "upload.callback": (g) => {
280
+ g && m({ mediaRecordingUid: g, isComplete: !0, isSubmitted: !0, progressPct: 100 });
281
+ }, "passthrough.data": o, "current.index": y, "task.response": d, "task.complete.callback": (g) => {
282
+ d.value.taskDurationMillisecond = g, r && (d.value.mediaRecordingUids = r), t(), s(d);
283
+ } });
284
+ }
285
+ function Be({ pages: n, setIsRequestingPermission: s }) {
286
+ const { recorderEventEmitter: o, eventEmitFn: r } = z.getState(), { updatePage: t, currentPage: a, recordingMediaTypes: m, screenPermissionRequested: y } = ce.getState();
287
+ if (!a) return;
288
+ const d = n.indexOf(a);
289
+ switch (a.type) {
290
+ case "av_permission": {
291
+ const g = y ? d + 2 : d + 1;
292
+ return y && m && o.emit("begin.recording", { "recording.media.types": m, "start.recording.callback": (c) => {
293
+ t({ mediaRecordingUids: c });
294
+ } }), void t({ currentPage: n[g] });
295
+ }
296
+ case "screen_permission":
297
+ return void o.emit("screen.permission", { "screen.permission.requested": s, "stream.ready.callback": (g, c) => {
298
+ const f = c ? n[d + 1] : a;
299
+ c && m && o.emit("begin.recording", { "recording.media.types": m, "start.recording.callback": (i) => {
300
+ t({ captureStream: c, mediaRecordingUids: i });
301
+ } }), t({ currentPage: f, screenPermissionRequested: !0, captureStream: c });
302
+ } });
303
+ case "start_task":
304
+ return r("recorded.task.start"), o.emit("recorded.task.start"), o.emit("start.task"), void t({ currentPage: n[d + 1], screenPermissionRequested: !0 });
305
+ case "complete_task":
306
+ return;
307
+ }
308
+ }
309
+ const er = "ul-permission-graphics-container", rr = "ul-permission-body", tr = O(er, "ul_recorded-task-inset-spacing"), Ne = O("ul-horizontal-button-container", "ul-horizontal-button-container-left"), nr = ({ richTextBody: n }) => e(_e, { className: "ul-rich-text-body", html: n, id: "ul-task-detail-container" }), we = ({ required: n, skipButtonText: s, bottom: o = !1 }) => n ? null : e(ee, { className: O(o && "ul-skip-button-below", "ul-button-inactive"), onClick: De.bind(null, { status: "abandoned" }), children: s || "Skip" }), Ue = (n) => {
310
+ const { avStream: s, captureStream: o, recordingMediaTypes: r, updatePage: t } = ce.getState(), a = (r == null ? void 0 : r.includes("audio")) || (r == null ? void 0 : r.includes("video"));
311
+ ne(() => {
312
+ const m = setInterval(() => {
313
+ a && s && !s.active ? t({ avStream: null, currentPage: n[0] }) : o && o.active || t({ captureStream: void 0, currentPage: n[a ? 1 : 0] });
314
+ }, 1e3);
315
+ return () => clearInterval(m);
316
+ }, [s, o, a, n, r, t]);
317
+ }, Ar = ({ content: n, pages: s, required: o }) => {
318
+ const { buttonText: r, skipButtonText: t, taskDetail: a } = n;
319
+ return Ue(s), e("div", { className: "ul-task-page", children: [a && e(nr, { richTextBody: a }), e("div", { className: Ne, children: [e(ee, { onClick: Be.bind(null, { pages: s }), children: r }), e(we, { required: o, skipButtonText: t })] })] }, "start-task");
320
+ }, Qr = ({ content: n, pages: s, properties: o }) => {
321
+ const { buttonText: r, skipButtonText: t } = n;
322
+ return Ue(s), e("div", { className: "ul-task-page", children: [n.taskDetail && e(nr, { richTextBody: n.taskDetail }), e(pe, { properties: o, children: e("div", { className: Ne, children: [e(ee, { className: "ul-complete-task-button", onClick: De.bind(null, { status: "completed" }), children: r }), e(ee, { className: O("ul-button-inactive"), onClick: De.bind(null, { status: "given.up" }), children: t })] }) })] }, "complete-task");
323
+ }, Or = ({ content: n, pages: s, required: o }) => {
324
+ const { buttonText: r, skipButtonText: t } = n, [a] = z((d) => [d.tabTitle]), [m, y] = Z(!1);
325
+ return e("div", { children: [e("div", { className: tr, children: [e("p", { style: { marginTop: "auto" }, children: n.selectTabText }), e("div", { className: "ul-select-tab-container", children: e("p", { className: rr, children: a }) })] }), e("div", { className: o ? "" : Ne, children: [e(ee, { disabled: m, onClick: Be.bind(null, { pages: s, setIsRequestingPermission: y }), children: r }), e(we, { required: o, skipButtonText: t })] })] });
326
+ }, $r = ({ content: n }) => e(_e, { className: O(er, "ul_permission_svg_container", "ul_recorded-task-inset-spacing", "ul-center-horizontally"), html: n.svg }, "ul-permission-request-graphic"), Hr = ({ content: n, pages: s, required: o }) => {
327
+ const { permissionDeniedHeadline: r, permissionDeniedBody: t, skipButtonText: a, tryAgainButtonText: m } = n, y = Ce(s[0]) ? s[0] : null;
328
+ return ne(() => {
329
+ const d = setInterval(() => {
330
+ y !== null && Re({ currentPage: y, pages: s });
331
+ }, 1e3);
332
+ return () => clearInterval(d);
333
+ }, [y, s]), y ? e("div", { children: [e("div", { className: tr, children: e("p", { className: "ul-av-permission-denied-paragraph", children: [e("span", { className: "ul-av-permission-denied-headline", children: r }), e("span", { className: rr, children: t })] }) }), e("div", { className: Ne, children: [e(ee, { onClick: Re.bind(null, { currentPage: y, pages: s }), children: m }), e(we, { required: o, skipButtonText: a })] })] }) : null;
334
+ }, Vr = ({ stream: n }) => e("video", { autoPlay: !0, className: O("ul_recorded-task-inset-spacing"), id: "ul-record-task-video-preview", muted: !0, ref: (s) => {
335
+ s && (s.srcObject = n || null);
336
+ } }), Gr = ({ content: n, pages: s, required: o }) => {
337
+ const { skipButtonText: r } = n, { avStream: t } = ce.getState();
338
+ return Ue(s), e("div", { children: [e(Vr, { stream: t }), e("div", { className: "ul-vertical-button-container-center", children: [e(ee, { onClick: Be.bind(null, { pages: s }), children: n.buttonText }), e(we, { bottom: !0, required: o, skipButtonText: r })] })] });
339
+ }, jr = ({ properties: n }) => {
340
+ const { pages: s, required: o } = n, { avStream: r, currentPage: t } = ce.getState();
341
+ if (t === void 0) return null;
342
+ switch (t == null ? void 0 : t.type) {
343
+ case "av_permission": {
344
+ const a = Je(r, t);
345
+ return a === Pe ? e($r, { content: t }) : e(a === Ke ? Hr : Gr, { content: t, pages: s, required: o });
346
+ }
347
+ case "screen_permission":
348
+ return e(Or, { content: t, pages: s, required: o });
349
+ case "start_task":
350
+ return e(Ar, { content: t, pages: s, required: o });
351
+ case "complete_task":
352
+ return e(Qr, { content: t, pages: s, properties: n });
353
+ default:
354
+ return null;
355
+ }
356
+ }, Zr = ({ className: n, properties: s, next: o, questionId: r }) => {
357
+ const t = z(), { surveyId: a, responseGroupUid: m, userId: y, update: d } = t, g = ce(), { screenPermissionRequested: c } = g, f = ce((b) => b.avStream);
358
+ let i = ce((b) => b.currentPage);
359
+ i || (i = function({ pages: b, userId: x, responseGroupUid: _, surveyId: k, questionId: U, next: P }) {
360
+ const { updatePage: M } = ce.getState(), { eventEmitFn: D, recorderEventEmitter: v } = z.getState(), w = { questionId: U, surveyId: k, visitorId: x, responseGroupUid: _ };
361
+ let B = 0;
362
+ v.emit("recorded.task.permission.screen"), D("recorded.task.permission.screen"), v.emit("permission.status", { "permission.status.callback": (L, A, Y, u) => {
363
+ const C = b[B], { type: V } = C, J = ["screen"];
364
+ if (Ce(C)) {
365
+ const { permissionDescriptors: H } = C, l = H == null ? void 0 : H.includes("microphone"), I = H == null ? void 0 : H.includes("camera");
366
+ l && J.push("audio"), I && J.push("video"), (L != null && L.active && !I || L != null && L.active && A) && B++;
367
+ }
368
+ Oe(b[B]) && Y && (B++, v.emit("begin.recording", { "recording.media.types": J, "start.recording.callback": (H) => M({ mediaRecordingUids: H }) })), M({ currentPage: b[B], avStream: L, screenPermissionRequested: Y, nextQuestion: P, type: V, passthroughData: w, recordingMediaTypes: J, captureStream: u });
369
+ } });
370
+ const T = b[B];
371
+ return T.type === "av_permission" && Re({ currentPage: T, pages: b }), T;
372
+ }({ questionId: r, surveyId: a, next: (b) => {
373
+ o(b, !0);
374
+ }, pages: s.pages, responseGroupUid: m, userId: y }));
375
+ let S = i.headline, p = i.captionText;
376
+ const h = Je(f, i);
377
+ return Oe(i) && c && (S = i.permissionDeniedHeadline, p = i.permissionDeniedCaptionText), Ce(i) && h === Xe && (S = i.permissionGrantedHeadline, p = i.permissionGrantedCaptionText), ne(() => {
378
+ d();
379
+ }, [d]), e("div", { className: O(n, "ul-center-horizontally", "fade-in-transition"), children: [e(ie, { isRequired: s == null ? void 0 : s.required, message: S, properties: { captionText: p } }), e(ae, { children: e(jr, { properties: s }) })] });
380
+ }, Wr = ({ richTextBody: n, plaintextBody: s }) => n ? e(_e, { className: "ul-rich-text-body", html: n, id: "ul-card__text-url-body-container" }) : s ? e("div", { className: "ul-rich-text-body", id: "ul-card__text-url-body-container", children: (s ? s.split(/\n\s*\n/g) : []).map((o, r) => e("p", { children: o }, r)) }) : null, zr = ({ className: n, message: s, next: o, properties: r, questionId: t, type: a }) => {
381
+ const { visitorAttributes: m, isLongFormSurvey: y } = z((f) => ({ visitorAttributes: f.visitorAttributes, isLongFormSurvey: le(f.studyType) })), d = (f, i = !1) => {
382
+ o({ value: i ? { skipped: !0 } : void 0, questionId: t, type: a }, !0);
383
+ }, g = fr(r && r.buttonUrl, m), c = y && r.promptActionType === Sr.NO_BUTTON;
384
+ return e("div", { className: O(n, "ul-card__text-url-prompt", "fade-in-transition"), children: [e(ie, { isRequired: y && (r == null ? void 0 : r.required), message: s, properties: { questionHtml: r.questionHtml } }), e(ae, { children: e(Wr, { plaintextBody: r == null ? void 0 : r.body, richTextBody: r == null ? void 0 : r.richTextBody }) }), e(pe, { properties: r, children: !c && e(ue, { children: e("div", { className: "ul-card-button-group", children: [e("a", { className: "ul-card-text__button ul-card__text-url-prompt-button", href: g, id: "ul-card-text__button", onClick: d, onKeyPress: (f) => {
385
+ f.key !== "Enter" && f.key !== " " || o({ value: void 0, questionId: t, type: a }, !0);
386
+ }, rel: "noreferrer", role: g ? "link" : "button", tabIndex: 0, target: "_blank", children: ge(r) }), r.required === !1 && e("button", { className: "ul-card-skip__button", onClick: (f) => d(0, !0), children: Me(r) })] }) }) })] }, t);
387
+ }, Yr = ({ className: n, questionId: s }) => {
388
+ const { border: o, destroy: r, endCard: t, forceBrandedLogo: a, update: m } = z((g) => ({ border: g.border, destroy: g.destroy, endCard: g.endCard, forceBrandedLogo: g.forceBrandedLogo, update: g.update }));
389
+ ne(() => {
390
+ setTimeout(() => {
391
+ r(br);
392
+ }, a ? 4e3 : 2e3);
393
+ }, [r, a]);
394
+ const y = t && t.subheader ? e("p", { className: "ul-caption", children: t.subheader }) : null, d = t && t.headline ? t.headline : "";
395
+ return ne(() => {
396
+ m();
397
+ }, [m]), e("div", { className: O(n, "ul-card--thanks", "fade-in-transition"), children: e("div", { children: e("div", { className: "ul-card--thanks-content", children: [e("div", { className: "ul-thanks-check", children: e("svg", { "aria-labelledby": "title", fill: "none", height: "99", viewBox: "0 0 81 99", width: "81", xmlns: "http://www.w3.org/2000/svg", children: [e("path", { clipRule: "evenodd", d: "M40.5 77C60.9345 77 77.5 60.4345 77.5 40C77.5 19.5655 60.9345 3 40.5 3C20.0655 3 3.5 19.5655 3.5 40C3.5 60.4345 20.0655 77 40.5 77ZM80.5 40C80.5 62.0914 62.5914 80 40.5 80C18.4086 80 0.5 62.0914 0.5 40C0.5 17.9086 18.4086 0 40.5 0C62.5914 0 80.5 17.9086 80.5 40Z", fill: o, fillRule: "evenodd" }), e("path", { clipRule: "evenodd", d: "M55.025 22.9046C55.6299 23.4705 55.6616 24.4198 55.0956 25.0247C54.8724 25.2634 54.6109 25.5285 54.3157 25.8277C52.2547 27.9168 48.5549 31.667 44.8135 39.6658C43.2818 42.9406 42.0864 45.8386 41.0823 48.2729C40.6539 49.3116 40.2603 50.2659 39.8902 51.129C39.287 52.5359 38.7248 53.7508 38.1744 54.625C37.8997 55.0613 37.5806 55.4905 37.2017 55.8245C36.8201 56.1607 36.2613 56.5 35.5457 56.5C34.6742 56.5 34.0892 55.9692 33.7774 55.6083C33.4502 55.2296 33.1752 54.7511 32.9396 54.301C32.7305 53.9013 32.5088 53.4367 32.2797 52.9565C32.2429 52.8794 32.2059 52.8019 32.1688 52.7243C31.8942 52.1499 31.5959 51.534 31.2537 50.8868C29.8886 48.305 27.8539 45.2878 24.2343 43.1382C23.522 42.7152 23.2875 41.7949 23.7105 41.0826C24.1335 40.3703 25.0539 40.1358 25.7662 40.5588C30.0556 43.1062 32.4149 46.6647 33.9058 49.4845C34.2776 50.1876 34.5973 50.8487 34.8753 51.4302C34.9147 51.5124 34.9529 51.5926 34.9902 51.6707C35.2222 52.1567 35.4164 52.5637 35.5978 52.9102C35.6151 52.9434 35.6321 52.9754 35.6485 53.0061C36.0565 52.3531 36.5341 51.3434 37.133 49.9468C37.4781 49.1418 37.8572 48.2229 38.2761 47.2074C39.2886 44.7532 40.5339 41.7347 42.0961 38.3948C46.0591 29.9221 50.0641 25.8648 52.1535 23.7482C52.4423 23.4556 52.6944 23.2002 52.9048 22.9753C53.4708 22.3703 54.42 22.3387 55.025 22.9046ZM35.1994 53.5892C35.1994 53.5892 35.2 53.5888 35.2012 53.5879C35.2 53.5889 35.1994 53.5893 35.1994 53.5892ZM36.0666 53.6682C36.0732 53.674 36.0765 53.6775 36.0765 53.6777C36.0765 53.678 36.0732 53.6751 36.0666 53.6682Z", fill: o, fillRule: "evenodd" }), e("path", { d: "M69.5 97C69.5 98.1046 56.2924 99 40 99C23.7076 99 10.5 98.1046 10.5 97C10.5 95.8954 23.7076 95 40 95C56.2924 95 69.5 95.8954 69.5 97Z", fill: "black", fillOpacity: "0.2" })] }) }), e(ie, { message: d }), y] }) }) }, s);
398
+ }, ve = "ul-card-video__player_recorder", He = "ul-video-btn", Le = 0, Ve = 1, Kr = ({ className: n, message: s, next: o, properties: r, questionId: t, type: a }) => {
399
+ const { apiURL: m, envId: y, handleUploadUpdate: d, headers: g, responseGroupUid: c, surveyId: f, update: i, viewDocument: S, visitorId: p } = z((u) => ({ apiURL: u.apiURL, envId: u.envId, handleUploadUpdate: u.handleUploadUpdate, headers: u.headers, responseGroupUid: u.responseGroupUid, surveyId: u.surveyId, update: u.update, viewDocument: u.viewDocument, visitorId: u.userId })), [h, b] = Z(!1), [x, _] = Z(null), [k, U] = Z(null), [P, M] = Z(Le), [D, v] = Z(null), [w, B] = Z(null), T = r && r.videoUrl, L = ke((u) => {
400
+ u && v(u);
401
+ }, [v]);
402
+ ne(() => {
403
+ const u = new ResizeObserver(() => {
404
+ setTimeout(i, 0);
405
+ });
406
+ return w && u.observe(w), D && u.observe(D), () => {
407
+ u.disconnect();
408
+ };
409
+ }, [i, w, D]);
410
+ const A = (u, C) => {
411
+ u === se.UPLOAD_STARTED ? (_(C[se.UPLOAD_ID]), U(C[se.MEDIA_RECORDING_UID]), b(!0)) : u === se.DELETE ? (_(null), U(null), b(!1)) : u === se.UPLOAD_PROGRESS ? isNaN(C[se.UPLOAD_PROGRESS_PCT]) ? d({ mediaRecordingUid: C[se.MEDIA_RECORDING_UID], isComplete: !0 }) : d({ mediaRecordingUid: C[se.MEDIA_RECORDING_UID], progressPct: C[se.UPLOAD_PROGRESS_PCT] }) : u === se.UPLOAD_FINISHED && d({ mediaRecordingUid: C[se.MEDIA_RECORDING_UID], isComplete: !0 });
412
+ }, Y = (u) => {
413
+ u.preventDefault(), u.stopPropagation(), document.getElementById(ve) && _r(ve), x && k ? (d({ mediaRecordingUid: k, isSubmitted: !0 }), o({ value: { mediaRecordingUid: k }, questionId: t, type: a }, !0)) : o({ value: null, questionId: t, type: a }, !0);
414
+ };
415
+ return e("form", { className: O(n, "ul-card--video", "fade-in-transition"), id: "ul-video-interview-form", children: [e(ie, { isRequired: r == null ? void 0 : r.required, message: s, properties: r }), e(ae, { children: [e("div", { id: "ul-question-player-container", ref: L, style: { display: P === Le ? "" : "none" }, children: [e("div", { id: ve, ref: (u) => {
416
+ if (u && u.children.length === 0 && !r.hideRecordedPrompt) {
417
+ B(u);
418
+ const C = kr(ve, { src: T, type: "application/x-mpegURL" }, void 0, r.mediaType === se.MEDIA_TYPE_AUDIO, m, S);
419
+ u.appendChild(C);
420
+ }
421
+ } }), e(pe, { properties: r, children: e("button", { className: `${He} ul-record-response-btn`, onClick: (u) => {
422
+ u.preventDefault(), u.stopPropagation(), document.getElementById(ve) && xr(ve), M(Ve);
423
+ } }) })] }), e("div", { style: { display: P === Ve ? "block" : "none" }, children: [e("button", { className: `${He} ul-back-question-btn`, onClick: (u) => {
424
+ u.preventDefault(), u.stopPropagation(), M(Le);
425
+ }, style: { display: r.hideRecordedPrompt ? "none" : "block" } }), e("div", { id: "ul-recorder-player-container", ref: (u) => {
426
+ if (u && u.children.length === 0) {
427
+ B(u);
428
+ const C = Ir(ve, { surveyId: f, responseGroupUid: c, questionId: t, visitorId: p, envId: y }, m, A, void 0, { ...g, "x-ul-video-recorder-origin": "sdk" }, r.mediaType === se.MEDIA_TYPE_AUDIO, S);
429
+ u.appendChild(C);
430
+ }
431
+ } })] })] }), e(ue, { children: [e(ee, { disabled: !h, onClick: Y, children: ge(r) }), e("button", { className: "ul-card-text__button ul-button-inactive ul-card-skip__button", id: "ul-card-video__skip_button", onClick: Y, style: { display: r.required ? "none" : "block", ...h ? { display: "none" } : {} }, children: Me(r) })] })] });
432
+ }, Xr = ({ className: n }) => {
433
+ const { uploadProgress: s } = z((a) => ({ uploadProgress: a.uploadProgress }));
434
+ let o, r;
435
+ Object.values(s).filter((a) => a.isSubmitted).length > 1 ? (o = "Your responses are processing", r = "Please keep this tab open until your responses are fully processed.") : (o = "Your response is processing", r = "Please keep this tab open until your response is fully processed.");
436
+ const t = Math.round(Math.min(99, ...Object.values(s).filter((a) => a.isSubmitted).map((a) => a.progressPct || 0)));
437
+ return e("div", { className: O(n, "ul-card--uploading", "fade-in-transition"), children: [e("div", { "aria-busy": "true", "aria-label": "Processing...", "aria-live": "polite", className: "ul-loading-spinner-container", role: "progressbar", children: e("div", { className: "ul-loading-spinner", children: [e("div", { className: "first" }), e("div", { className: "second" }), e("div", { className: "third" }), e("div", { className: "fourth" })] }) }), e(ie, { message: `${o} (${t}% complete)` }), e("p", { className: "ul-caption", children: r })] });
438
+ }, sr = lr(void 0), Jr = ({ value: n, children: s }) => e(sr.Provider, { value: n, children: s }), et = ({ isRightLabel: n, isLeftLabel: s }) => n ? de.RIGHT : s ? de.LEFT : null, rt = "Best", tt = "Worst", nt = ({ className: n, labels: s, message: o, properties: r, options: t, questionId: a, type: m, next: y }) => {
439
+ var U, P, M, D;
440
+ const [d, g] = Z(t.map((v, w) => ({ ...v, label: v.label === "" ? `Item ${w + 1}` : v.label, isRightLabel: !1, isLeftLabel: !1 }))), c = (() => {
441
+ const v = or(sr);
442
+ if (v === void 0) throw new Error("usePreviousResponses must be used within a PreviousResponsesProvider");
443
+ return v;
444
+ })(), f = { padding: "24px", display: "flex", cursor: "pointer", width: "auto" }, [i, S] = Z(!1);
445
+ ne(() => {
446
+ const v = d.findIndex((C) => C.isRightLabel), w = d.findIndex((C) => C.isLeftLabel), B = v !== -1 && w !== -1;
447
+ S(B);
448
+ const T = !r.required || r.required && B, L = d.map((C) => ({ id: C.id, option: C.label, selected: et(C) })), A = Math.floor(a), Y = Object.keys(c).filter((C) => C.startsWith(A.toString())).map(Number).sort((C, V) => C - V).at(-1), u = [];
449
+ if (typeof Y == "number") {
450
+ const C = c[Y], V = JSON.parse(C);
451
+ u.push(...V);
452
+ }
453
+ u.push(L), setTimeout(() => {
454
+ y({ value: u, questionId: a, type: m }, T, B), S(!1);
455
+ }, B ? 500 : 0);
456
+ }, [d]);
457
+ const { border: p, useMobileStyling: h, enableCspTrustedTypes: b } = z((v) => ({ border: v.border, useMobileStyling: v.useMobileStyling, enableCspTrustedTypes: v.enableCspTrustedTypes })), x = (v, w) => () => {
458
+ i || g((B) => ((T, L, A) => T.map((Y) => Y.id === L ? { ...Y, isRightLabel: A === de.RIGHT, isLeftLabel: A === de.LEFT } : A === de.RIGHT && Y.isRightLabel || A === de.LEFT && Y.isLeftLabel ? { ...Y, isRightLabel: !1, isLeftLabel: !1 } : Y))(B, v, w));
459
+ }, _ = (U = r.ratingIcons) == null ? void 0 : U[0].svg, k = (P = r.ratingIcons) == null ? void 0 : P[1].svg;
460
+ return e("form", { className: O(n, "ul-card-maxdiff", "fade-in-transition"), children: [e(ie, { isRequired: r == null ? void 0 : r.required, message: o, properties: r }), e(ae, { children: e("div", { className: "ul-card--maxdiff__question-inner-container", children: [e("div", { className: "ul-card-maxdiff__label", children: (s == null ? void 0 : s.left) || ((M = r == null ? void 0 : r.labels) == null ? void 0 : M.left) || rt }), e("div", { children: " " }), e("div", { className: "ul-card-maxdiff__label", children: (s == null ? void 0 : s.right) || ((D = r == null ? void 0 : r.labels) == null ? void 0 : D.right) || tt }), d.map(({ id: v, label: w, isLeftLabel: B, isRightLabel: T }) => e(ye, { children: [e("div", { className: "ul-card-maxdiff__option-control " + (k ? "smiley" : ""), children: k ? e(Ge, { ariaPressed: B, className: B ? "ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected good" : "ul-card-maxdiff__option-btn", enableCspTrustedTypes: b, html: k, id: `smiley-good-${v}`, onClick: x(v, de.LEFT) }) : e(Se, { allowTextEntry: !1, ariaLabel: `bestLabel-${w}`, border: p, choiceStyle: f, error: !1, id: `${v}`, isRadio: !0, isSelected: B, onUserInputChanged: x(v, de.LEFT), useMobileStyling: h }) }), e("div", { className: "ul-card-maxdiff__option-label", children: w }), e("div", { className: "ul-card-maxdiff__option-control " + (_ ? "smiley" : ""), children: _ ? e(Ge, { ariaPressed: T, className: T ? "ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected bad" : "ul-card-maxdiff__option-btn", enableCspTrustedTypes: b, html: _, id: `smiley-bad-${v}`, onClick: x(v, de.RIGHT) }) : e(Se, { allowTextEntry: !1, ariaLabel: `worstLabel-${w}`, border: p, choiceStyle: f, error: !1, id: `${v}`, isRadio: !0, isSelected: T, onUserInputChanged: x(v, de.RIGHT), useMobileStyling: h }) })] }))] }) })] }, a);
461
+ }, Ge = ({ enableCspTrustedTypes: n, ariaPressed: s, className: o, html: r, id: t, onClick: a }) => {
462
+ const m = he(() => We(r, n), [n, r]);
463
+ return e("span", { "aria-pressed": s, className: o, dangerouslySetInnerHTML: { __html: m }, id: t, onClick: a, tabIndex: 0, type: "button" });
464
+ }, st = ({ className: n, labels: s, message: o, next: r, properties: t, questionId: a, type: m, onSubmitButtonClick: y, options: d, showIndividualSubmit: g = !1 }) => {
465
+ const c = te(null), f = te(0), i = te(0), S = te(null), p = te(!1), h = te([]), [b, x] = Z(() => (t == null ? void 0 : t.required) === !0), [_, k] = Z(() => d.map((N) => ({ ...N, rank: null }))), U = he(() => Array.from({ length: d.length }, (N, Q) => Q + 1), [d.length]), { isLongFormSurvey: P, focusedQuestionId: M, setFocusedQuestionId: D, useMobileStyling: v, isPreview: w, headers: B } = z((N) => ({ useMobileStyling: N.useMobileStyling, isLongFormSurvey: le(N.studyType), focusedQuestionId: N.focusedQuestionId, setFocusedQuestionId: N.setFocusedQuestionId, isPreview: N.isPreview, headers: N.headers })), T = (B == null ? void 0 : B["userleap-platform"]) === "android", L = v && !w && !T, A = !L && !T, Y = P && M === a, u = (N) => {
466
+ N.preventDefault(), q(_), y && y();
467
+ }, C = (N, Q) => {
468
+ k(($) => {
469
+ const R = parseInt(Q), j = $.map((W) => ({ ...W }));
470
+ j.some((W) => W.rank == null) && j.forEach((W, fe) => W.rank = fe + 1);
471
+ const oe = j.findIndex((W) => W.id === N);
472
+ if (oe === -1) return $;
473
+ const X = j[oe].rank;
474
+ return R < X ? j.forEach((W) => {
475
+ W.id !== N && W.rank >= R && W.rank < X && (W.rank = W.rank + 1);
476
+ }) : R > X && j.forEach((W) => {
477
+ W.id !== N && W.rank > X && W.rank <= R && (W.rank = W.rank - 1);
478
+ }), j[oe].rank = R, j.sort((W, fe) => W.rank - fe.rank), F(j), j;
479
+ });
480
+ }, V = (N, Q) => {
481
+ for (let $ = 0; $ < h.current.length; $++) {
482
+ const R = h.current[$];
483
+ if (!R || R === S.current) continue;
484
+ const j = R.getBoundingClientRect();
485
+ if (N >= j.left && N <= j.right && Q >= j.top && Q <= j.bottom) return { element: R, index: $ };
486
+ }
487
+ return null;
488
+ }, J = (N) => (Q) => {
489
+ if (!L) return;
490
+ Q.preventDefault(), Q.stopPropagation(), p.current = !0, c.current = N;
491
+ const $ = Q.touches[0];
492
+ f.current = $.clientY, i.current = $.clientY;
493
+ const R = Q.currentTarget.closest(".ul-card-rank__option");
494
+ R && (S.current = R, R.classList.add("is-dragging"));
495
+ }, H = (N) => {
496
+ if (!L || !p.current || c.current === null) return;
497
+ N.preventDefault(), N.stopPropagation();
498
+ const Q = N.touches[0];
499
+ i.current = Q.clientY;
500
+ const $ = i.current - f.current;
501
+ S.current && (S.current.style.transform = `translateY(${$}px)`, S.current.style.zIndex = "1000"), h.current.forEach((j) => {
502
+ j && j !== S.current && j.classList.remove("is-drop-target");
503
+ });
504
+ const R = V(Q.clientX, Q.clientY);
505
+ R && R.element.classList.add("is-drop-target");
506
+ }, l = (N) => {
507
+ if (!L || !p.current || c.current === null) return;
508
+ N.preventDefault(), N.stopPropagation();
509
+ const Q = N.changedTouches[0], $ = V(Q.clientX, Q.clientY);
510
+ S.current && (S.current.style.transform = "", S.current.style.zIndex = "", S.current.classList.remove("is-dragging")), h.current.forEach((R) => {
511
+ R && R.classList.remove("is-drop-target");
512
+ }), $ && $.index !== c.current && I(c.current, $.index), c.current = null, S.current = null, p.current = !1;
513
+ }, I = (N, Q) => {
514
+ k(($) => {
515
+ const R = $.map((oe) => ({ ...oe })), [j] = R.splice(N, 1);
516
+ return R.splice(Q, 0, j), R.forEach((oe, X) => {
517
+ oe.rank = X + 1;
518
+ }), F(R), R;
519
+ });
520
+ }, q = (N) => {
521
+ const Q = {};
522
+ N.reduce(($, R) => ($[R.id] = R.rank, $), Q), r({ value: Q, questionId: a, type: m }, !0);
523
+ }, F = (N) => {
524
+ x(!1), P && q(N);
525
+ }, { left: E, right: G } = s, K = d.length, me = (N) => {
526
+ N.preventDefault(), N.currentTarget.classList.add("is-drop-target");
527
+ }, be = (N) => {
528
+ N.currentTarget.classList.remove("is-drop-target");
529
+ }, xe = (N) => {
530
+ c.current = null, N.currentTarget.classList.remove("is-dragging");
531
+ };
532
+ return e("form", { className: O(n, "ul-card-rank", "fade-in-transition", P && !Y && "ul-card--unfocused"), onClick: P ? () => {
533
+ P && M !== a && D(a);
534
+ } : void 0, onSubmit: u, children: [e(ie, { isRequired: t == null ? void 0 : t.required, message: o, properties: t }), e(pe, { properties: t, children: e(ye, T ? { children: [e(ae, { children: [e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", E] }) }), e("ol", { className: "ul-card-rank__list", children: _.map(({ id: N, label: Q, rank: $ }) => e("li", { className: "ul-card-rank__option", children: [e("select", { "aria-label": `Rank for ${Q}`, className: O("ul-card-rank__select", $ == null && "ul-card-rank__select--placeholder"), name: `rank[${N}]`, onChange: (R) => C(N, R.currentTarget.value), value: $ ?? "", children: [$ == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), U.map((R) => e("option", { className: "ul-card-rank__select-option", value: R, children: R }, `${R}-${a}`))] }), e("span", { children: Q })] }, N)) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [K, " - ", G] }) })] }), g && e(Ie, { handleSubmit: u, isSubmitDisabled: b })] }), !P && e(ue, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: b, children: ge(t) }) }) })] } : { children: [e(ae, { children: [e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", E] }) }), e("ol", { className: "ul-card-rank__list", onDragOver: T ? void 0 : (N) => {
535
+ N.preventDefault(), N.dataTransfer && (N.dataTransfer.dropEffect = "move");
536
+ }, children: _.map(({ id: N, label: Q, rank: $ }, R) => {
537
+ return e("li", { className: "ul-card-rank__option", draggable: !!A || void 0, onDragEnd: A ? xe : void 0, onDragEnter: A ? me : void 0, onDragLeave: A ? be : void 0, onDragStart: A ? (oe = R, (X) => {
538
+ c.current = oe, X.dataTransfer && (X.dataTransfer.effectAllowed = "move", X.dataTransfer.setData("text/plain", String(oe)), X.currentTarget.classList.add("is-dragging"));
539
+ }) : void 0, onDrop: A ? (j = R, (X) => {
540
+ var fe, Fe;
541
+ X.preventDefault(), X.currentTarget.classList.remove("is-drop-target");
542
+ const W = c.current;
543
+ c.current = null, (Fe = (fe = X.currentTarget.closest(".ul-card-rank__list")) == null ? void 0 : fe.querySelector(".is-dragging")) == null || Fe.classList.remove("is-dragging"), W != null && W !== j && I(W, j);
544
+ }) : void 0, ref: (X) => h.current[R] = X, children: [e("select", { "aria-label": `Rank for ${Q}`, className: O("ul-card-rank__select", $ == null && "ul-card-rank__select--placeholder"), name: `rank[${N}]`, onChange: (X) => C(N, X.currentTarget.value), value: $ ?? "", children: [$ == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), U.map((X) => e("option", { className: "ul-card-rank__select-option", value: X, children: X }, `${X}-${a}`))] }), e("span", { children: Q }), !T && e("button", { "aria-label": `Drag ${Q} to reorder`, className: "ul-card-rank__drag-btn", onTouchEnd: L ? l : void 0, onTouchMove: L ? H : void 0, onTouchStart: L ? J(R) : void 0, title: "Drag to reorder", type: "button", children: e("svg", { fill: "none", height: "17", viewBox: "0 0 16 17", width: "16", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M5.75 11.625C6.37132 11.625 6.875 12.1287 6.875 12.75C6.875 13.3713 6.37132 13.875 5.75 13.875C5.12868 13.875 4.625 13.3713 4.625 12.75C4.625 12.1287 5.12868 11.625 5.75 11.625ZM10.25 11.625C10.8713 11.625 11.375 12.1287 11.375 12.75C11.375 13.3713 10.8713 13.875 10.25 13.875C9.62868 13.875 9.125 13.3713 9.125 12.75C9.125 12.1287 9.62868 11.625 10.25 11.625ZM5.75 7.375C6.37132 7.375 6.875 7.87868 6.875 8.5C6.875 9.12132 6.37132 9.625 5.75 9.625C5.12868 9.625 4.625 9.12132 4.625 8.5C4.625 7.87868 5.12868 7.375 5.75 7.375ZM10.25 7.375C10.8713 7.375 11.375 7.87868 11.375 8.5C11.375 9.12132 10.8713 9.625 10.25 9.625C9.62868 9.625 9.125 9.12132 9.125 8.5C9.125 7.87868 9.62868 7.375 10.25 7.375ZM5.75 3.125C6.37132 3.125 6.875 3.62868 6.875 4.25C6.875 4.87132 6.37132 5.375 5.75 5.375C5.12868 5.375 4.625 4.87132 4.625 4.25C4.625 3.62868 5.12868 3.125 5.75 3.125ZM10.25 3.125C10.8713 3.125 11.375 3.62868 11.375 4.25C11.375 4.87132 10.8713 5.375 10.25 5.375C9.62868 5.375 9.125 4.87132 9.125 4.25C9.125 3.62868 9.62868 3.125 10.25 3.125Z", fill: "currentColor" }) }) })] }, N);
545
+ var j, oe;
546
+ }) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [K, " - ", G] }) })] }), g && e(Ie, { handleSubmit: u, isSubmitDisabled: b })] }), !P && e(ue, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: b, children: ge(t) }) }) })] }) })] }, a);
547
+ }, it = /* @__PURE__ */ new Set(["aidynamicfollowup", "open", "matrix", "multipleselect", "multiplechoice", "rankorder"]), je = ({ cardInstance: n, moveToNextQuestion: s, showIndividualSubmit: o, submitQuestion: r, updateCardValues: t, allResponsesArray: a }) => {
548
+ const { isLongFormSurvey: m, createDynamicQuestion: y, cards: d, surveyVisitorAttributes: g } = z((k) => ({ isLongFormSurvey: le(k.studyType), createDynamicQuestion: k.createDynamicQuestion, cards: k.cards, surveyVisitorAttributes: k.surveyVisitorAttributes }));
549
+ if (!n) return null;
550
+ const { name: c, type: f, props: i, childId: S } = n, p = o && it.has(f), h = i == null ? void 0 : i.displayLogic, b = h == null ? void 0 : Ze({ displayLogic: h, allResponses: a, cards: d, surveyVisitorAttributes: g ?? {} });
551
+ if (h && h.length > 0 && !b) return null;
552
+ const x = { className: "ul-card", next: (k, U, P = !0) => r(k, U && P), questionId: c, type: f, showIndividualSubmit: o, ...p ? { next: (k, U) => {
553
+ t(k.questionId, k, U ?? !0);
554
+ }, onSubmitButtonClick: (k = !1) => {
555
+ S ? k ? (s(c), y({ parentQuestionId: c })) : s(S) : s(c);
556
+ } } : {} }, _ = (() => {
557
+ switch (f) {
558
+ case "consentlegal":
559
+ return e(Cr, { ...x, ...i });
560
+ case "likert":
561
+ return e(wr, { ...x, ...i });
562
+ case "matrix":
563
+ return e(Mr, { ...x, ...i });
564
+ case "maxdiff":
565
+ return e(nt, { ...x, ...i });
566
+ case "multiplechoice":
567
+ return e(Er, { ...x, ...i });
568
+ case "multipleselect":
569
+ return e(Br, { ...x, ...i });
570
+ case "nps":
571
+ return e(Ur, { ...x, ...i });
572
+ case "open":
573
+ case "aidynamicfollowup":
574
+ return e(Fr, { ...x, type: n.type, ...i });
575
+ case "rankorder":
576
+ return e(st, { ...x, ...i });
577
+ case "recordedtask":
578
+ return e(Zr, { ...x, ...i });
579
+ case "texturlprompt":
580
+ return e(zr, { ...x, ...i });
581
+ case "thanks":
582
+ return e(Yr, { ...x, ...i });
583
+ case "uploading":
584
+ return e(Xr, { ...x, ...i });
585
+ case "videovoice":
586
+ return e(Kr, { ...x, ...i });
587
+ default:
588
+ return null;
589
+ }
590
+ })();
591
+ return _ ? m ? e("div", { className: "ul-card-scroll-wrapper", children: _ }, c) : _ : null;
592
+ }, at = ({ isSubmitDisabled: n = !1, onSubmit: s, buttonText: o }) => {
593
+ var S;
594
+ const { cards: r, forceBrandedLogo: t, index: a, marketingUrl: m, showSurveyBrand: y, slugName: d, surveyId: g, useMobileStyling: c } = z((p) => ({ cards: p.cards, forceBrandedLogo: p.forceBrandedLogo, index: p.index, marketingUrl: p.marketingUrl, showSurveyBrand: p.showSurveyBrand, slugName: p.slugName, surveyId: p.surveyId, useMobileStyling: p.useMobileStyling })), f = ((S = r[a]) == null ? void 0 : S.type) === "thanks", i = cr({ marketingUrl: m, slugName: d, surveyId: g, forceBrandedLogo: t });
595
+ return e("footer", { className: O("long-form-question-footer-container", c && "long-form-question-footer-container--mobile", f && "long-form-question-footer-container-center"), children: [f && t ? e(dr, { marketingUrlLink: i }) : e("div", { className: "long-form-question-footer-container-logo", children: y ? e(ur, { forceBrandedLogo: t, marketingUrlLink: i }) : null }), !f && e("div", { className: O("ul-card__button-wrapper", "ul-card-vertical__button-wrapper", "long-form-question-footer-container-actions"), children: e(ee, { className: O("long-form-button", n && "sprig-button-disabled"), disabled: n, onClick: s, children: e("span", { className: "long-form-button-text-container", children: o ?? e(pr, { stroke: "white" }) }) }) })] });
596
+ }, ut = ({ cards: n, next: s, previousResponses: o }) => {
597
+ var H;
598
+ const r = te(null), [t, a] = Z({}), [m, y] = Z({}), { isLongFormSurvey: d, focusedQuestionId: g, setFocusedQuestionId: c, createDynamicQuestion: f, allResponses: i, cardIndexByName: S, surveyVisitorAttributes: p, cards: h } = z((l) => ({ isLongFormSurvey: le(l.studyType), focusedQuestionId: l.focusedQuestionId, setFocusedQuestionId: l.setFocusedQuestionId, createDynamicQuestion: l.createDynamicQuestion, allResponses: l.allResponses, cardIndexByName: l.cardIndexByName, surveyVisitorAttributes: l.surveyVisitorAttributes, cards: l.cards })), b = he(() => ({ ...o, ...Ae(n.map((l) => {
599
+ var I, q;
600
+ return { ...l, value: ((I = t[l.name]) == null ? void 0 : I.value) ?? null, secondaryValue: ((q = t[l.name]) == null ? void 0 : q.secondaryValue) ?? null };
601
+ })) }), [o, t, n]);
602
+ mr(b);
603
+ const x = gr(n, b), _ = he(() => hr({ storeAllResponses: i, cards: n, cardValues: t, cardIndexByName: S }), [i, n, t, S]), k = he(() => {
604
+ const l = /* @__PURE__ */ new Set();
605
+ return n.forEach((I) => {
606
+ var F;
607
+ const q = (F = I.props) == null ? void 0 : F.displayLogic;
608
+ if (!q || q.length === 0) return void l.add(I.name);
609
+ Ze({ displayLogic: q, allResponses: _, cards: h, surveyVisitorAttributes: p ?? {} }) && l.add(I.name);
610
+ }), l;
611
+ }, [n, _, p, h]), U = te(null);
612
+ ne(() => {
613
+ const l = k, I = U.current;
614
+ if (I !== null) for (const q of I) l.has(q) || (a((F) => {
615
+ const E = { ...F };
616
+ return delete E[q], E;
617
+ }), y((F) => {
618
+ const E = { ...F };
619
+ return delete E[q], E;
620
+ }));
621
+ U.current = new Set(l);
622
+ }, [k]);
623
+ const P = te(null), M = te(!1), D = te(null), v = ke((l) => {
624
+ var E, G;
625
+ M.current = !0;
626
+ const I = n.findIndex((K) => K.name === l);
627
+ if (!d || l === null || I === -1) return void (M.current = !1);
628
+ const q = (E = P.current) == null ? void 0 : E.querySelectorAll(".ul-card-scroll-wrapper")[I], F = (G = P.current) == null ? void 0 : G.closest(".ul-card-main-content");
629
+ if (q && F) {
630
+ if (q && F) {
631
+ const K = q.getBoundingClientRect(), me = F.getBoundingClientRect(), be = K.top - me.top + F.scrollTop, xe = be + K.height / 2, N = window.innerHeight - 157;
632
+ let Q;
633
+ K.height >= N ? Q = be : Q = xe - F.clientHeight / 2;
634
+ const $ = F.clientHeight, R = F.scrollHeight - $, j = Math.max(0, Math.min(Q, R));
635
+ F.scrollTo({ top: j, behavior: "smooth" }), setTimeout(() => {
636
+ M.current = !1;
637
+ }, 500);
638
+ }
639
+ } else M.current = !1;
640
+ }, [d, n]);
641
+ ne(() => {
642
+ g !== null && n.findIndex((l) => l.name === g) !== -1 || c(n[0].name);
643
+ }, [n, g, c]);
644
+ const w = ({ displayCard: l, response: I }) => {
645
+ if (l && ((l == null ? void 0 : l.childId) ?? 0) > 0) {
646
+ const q = Ae([l].map((F) => ({ ...F, value: (I == null ? void 0 : I.value) ?? null, secondaryValue: (I == null ? void 0 : I.secondaryValue) ?? null })));
647
+ f({ parentQuestionId: l == null ? void 0 : l.name, parentResponseConfig: q });
648
+ }
649
+ };
650
+ function B(l, I) {
651
+ return l.filter((q) => k.has(q.name)).map((q) => {
652
+ const F = I[q.name], E = x.find((G) => G.name === q.name);
653
+ return { ...F, questionText: E ? Qe(E) : void 0 };
654
+ });
655
+ }
656
+ const T = (l) => {
657
+ if (!d) return;
658
+ let I = n.findIndex((q) => q.name === l) + 1;
659
+ for (; I < n.length && !k.has(n[I].name); ) I++;
660
+ I < n.length ? c(n[I].name) : c(l);
661
+ };
662
+ ne(() => {
663
+ d && g !== null && (D.current !== g ? v(g) : D.current = null);
664
+ }, [g, d, v]);
665
+ const L = ke(() => {
666
+ var me, be;
667
+ if (M.current) return;
668
+ const l = (me = P.current) == null ? void 0 : me.closest(".ul-card-main-content");
669
+ if (!l) return;
670
+ const I = (be = P.current) == null ? void 0 : be.querySelectorAll(".ul-card-scroll-wrapper");
671
+ if (!I || I.length === 0) return;
672
+ const q = l.getBoundingClientRect(), F = q.top + q.height / 2;
673
+ let E = 0, G = 1 / 0;
674
+ I.forEach((xe, N) => {
675
+ const Q = xe.getBoundingClientRect(), $ = Q.top + Q.height / 2, R = Math.abs(F - $);
676
+ R < G && (G = R, E = N);
677
+ });
678
+ const K = n[E];
679
+ D.current = K.name, c(K.name);
680
+ }, [n, c]);
681
+ ne(() => {
682
+ var I;
683
+ if (!d) return;
684
+ const l = ((I = P.current) == null ? void 0 : I.closest(".ul-card__container")) || null;
685
+ return l && l.addEventListener("scroll", L, { passive: !0 }), () => {
686
+ l && l.removeEventListener("scroll", L);
687
+ };
688
+ }, [L, d]);
689
+ const A = he(() => n.every((l) => {
690
+ var I;
691
+ return !k.has(l.name) || !(!(l != null && l.props) || !("properties" in l.props) || ((I = l.props.properties) == null ? void 0 : I.required) !== !1) || m[l.name];
692
+ }), [m, n, k]), Y = async (l, I, q) => {
693
+ return y((E) => ({ ...E, [l]: q })), await (F = (E) => ({ ...E, [l]: I }), new Promise((E) => {
694
+ a((G) => {
695
+ const K = F(G);
696
+ return E(K), K;
697
+ });
698
+ }));
699
+ var F;
700
+ };
701
+ ne(() => {
702
+ var F;
703
+ if (!d) return;
704
+ const l = r.current, I = (F = n == null ? void 0 : n[0]) == null ? void 0 : F.groupId;
705
+ r.current = I;
706
+ const q = {};
707
+ if (n.forEach((E) => {
708
+ var G, K;
709
+ Tr(E) && (E.props.properties.required || (q[E.name] = { value: ((G = t[E.name]) == null ? void 0 : G.value) ?? null, secondaryValue: ((K = t[E.name]) == null ? void 0 : K.secondaryValue) ?? null, questionId: E.name, type: E.type }));
710
+ }), l == null || l !== I) a(q), y({});
711
+ else {
712
+ a((G) => ({ ...G, ...q }));
713
+ const E = n.reduce((G, K) => {
714
+ var me;
715
+ return K.type === "aidynamicfollowup" && ((me = K.props) == null ? void 0 : me.loading) === null && (G[K.name] = !0), G;
716
+ }, {});
717
+ y((G) => ({ ...G, ...E }));
718
+ }
719
+ }, [n, d]);
720
+ const u = async (l, I) => {
721
+ if (d) {
722
+ const q = await Y(l.questionId, l, I), F = C(l.type), E = V(l.type);
723
+ if (F && T(l.questionId), E && I) {
724
+ const G = B(n, q);
725
+ s(G);
726
+ }
727
+ } else {
728
+ const q = x.find((E) => E.name === l.questionId), F = { ...l, questionText: q ? Qe(q) : void 0 };
729
+ w({ displayCard: q, response: l }), s([F]);
730
+ }
731
+ }, C = (l) => (/* @__PURE__ */ new Set(["nps", "likert", "multiplechoice"])).has(l), V = (l) => (/* @__PURE__ */ new Set(["videovoice", "consentlegal", "texturlprompt", "maxdiff"])).has(l), J = ((H = n[0]) == null ? void 0 : H.type) === "thanks";
732
+ return d ? e("div", { className: "ul-card-list-container--longform", "data-testid": "ui-container", ref: P, children: [e(Jr, { value: o, children: x.map((l, I) => e(je, { allResponsesArray: _, cardInstance: l, moveToNextQuestion: T, showIndividualSubmit: d && n.length > 1 && I < n.length - 1, submitQuestion: u, updateCardValues: Y }, (l == null ? void 0 : l.name) || I)) }), !J && e(at, { isSubmitDisabled: !A, onSubmit: function() {
733
+ const l = B(n, t);
734
+ if ((x == null ? void 0 : x.length) === 1 && (l == null ? void 0 : l.length) === 1) {
735
+ const I = x[0], q = l[0];
736
+ w({ displayCard: I, response: q });
737
+ }
738
+ s(l);
739
+ } })] }) : e(ye, { children: [e("div", { "data-testid": "ui-container", style: { display: "none" } }), x.map((l, I) => e(je, { allResponsesArray: _, cardInstance: l, moveToNextQuestion: T, showIndividualSubmit: d && n.length > 1 && I < n.length - 1, submitQuestion: u, updateCardValues: Y }, (l == null ? void 0 : l.name) || I))] });
740
+ };
741
+ export {
742
+ ut as PageCard
743
+ };