@sprig-technologies/sprig-bundled 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,706 @@
1
+ import { u as G, h as J, a as e, c as O, g as re, d as Oe, F as me, e as be, b as ge, _ as te, T as Te, A as er, p as ne, f as rr, n as tr, q as nr, M as oe, s as Ue, o as sr, i as ir, S as ar, r as lr, j as Fe, k as or, l as dr, t as cr, m as Be } from "./view-CocVngjw.js";
2
+ import { i as se, E as Ne, h as Pe, j as Ve, A as ur } from "./index-Dm5Q2JaO.js";
3
+ import { c as ie, a as le, H as Se, M as pe, Q as ue, O as ye, B as ee, L as xe, b as ke, S as pr, u as mr, g as gr, P as hr, d as br } from "./getAttributedUrl-BCuq8noY.js";
4
+ const vr = ({ className: t, message: s, next: o, properties: n, questionId: r, type: a }) => {
5
+ const { useMobileStyling: m, border: g, isLongFormSurvey: c, focusedQuestionId: p } = G((v) => ({ useMobileStyling: v.useMobileStyling, border: v.border, isLongFormSurvey: se(v.studyType), focusedQuestionId: v.focusedQuestionId })), [d, y] = J(!1), [i, f] = J(""), [u, h] = J(!1), b = c && p === r, S = n == null ? void 0 : n.collectName, C = (n == null ? void 0 : n.nameLabelText) || "Full Name", k = (n == null ? void 0 : n.consentText) || "I agree to the stated conditions", E = (n == null ? void 0 : n.submitButtonText) || "Submit", P = !!i.trim(), D = d && (!S || P), F = (v, N = !1) => {
6
+ v.preventDefault(), v.stopPropagation();
7
+ let B = null;
8
+ if (!N) {
9
+ if (!D) return void h(!0);
10
+ B = { submitted: !0 }, S && (B.name = i);
11
+ }
12
+ o({ value: B, questionId: r, type: a }, D);
13
+ };
14
+ return e("div", { className: O(t, c && !b && "ul-card--unfocused", "ul-card__consent-legal", "fade-in-transition"), children: [e(ie, { isRequired: c && (n == null ? void 0 : n.required), message: s, properties: { questionHtml: n.questionHtml } }), n != null && n.richTextBody ? e(le, { children: e(Se, { className: "ul-rich-text-body", html: n.richTextBody, id: "ul-card__consent-legal-body-container" }) }) : null, e(pe, { embeddedType: "pdf", properties: n, children: e(ue, { children: [e("div", { className: "sprig-stretch", children: [e(ye, { allowTextEntry: !1, border: g, error: u && !d, id: "consent", isRadio: !1, isSelected: d, label: k, onUserInputChanged: ({ selected: v }) => {
15
+ v !== d && y(!d);
16
+ }, useMobileStyling: m }), S && e("input", { "aria-label": C, "aria-placeholder": C, className: O(re("ul-consent-legal__name-input", m)), "data-gramm": "false", maxLength: 250, name: "name", onBlur: (v) => {
17
+ v.currentTarget.style.borderColor = u && !P ? Ne : Pe;
18
+ }, onFocus: (v) => {
19
+ v.currentTarget.style.borderColor = u && !P ? Ne : g;
20
+ }, onInput: (v) => {
21
+ v.preventDefault(), v.stopPropagation(), f(v.currentTarget.value);
22
+ }, placeholder: C, style: u && !P ? { borderColor: Ne } : {}, tabIndex: 0, value: i })] }), e("div", { className: "ul-card__button-wrapper ul-card-vertical__button-wrapper", children: [e(ee, { className: D ? "" : "sprig-button-disabled", onClick: F, children: E }), n.required === !1 && !c && e("button", { className: "ul-card-skip__button", onClick: (v) => F(v, !0), children: Oe(n) })] })] }) })] }, r);
23
+ }, yr = ({ activeValue: t, border: s, icon: o, isPressed: n, onSubmit: r, range: a, scaleLabelType: m, selectedValue: g, setSelectedValue: c, setActiveValue: p, setIsPressed: d, useMobileStyling: y, value: i, viewDocument: f }) => {
24
+ const { isLongFormSurvey: u, enableCspTrustedTypes: h } = G((N) => ({ isLongFormSurvey: se(N.studyType), enableCspTrustedTypes: N.enableCspTrustedTypes })), b = `option-${i}`, S = m === "number", C = m === "star", k = m === "smiley", E = S && i === t || i === g, [P, D] = (() => {
25
+ const N = C && g !== null && i <= g;
26
+ return C && i <= t || k && i === t || N || i === t || i === g ? [s, n || N || i === g ? 1 : 0.3] : ["", 1];
27
+ })(), F = me(() => {
28
+ const N = { borderColor: E ? P : "", fillOpacity: E ? "" : D, zIndex: E ? 3 : "auto", color: g === i ? "#fff" : "" };
29
+ return S ? { ...N, backgroundColor: g === i ? P : "" } : { ...N, color: C || k || g === i ? P : "" };
30
+ }, [E, P, D, g, i, S, C, k]), v = me(() => Ve((({ icon: N, scaleLabelType: B, value: T, selectedValue: L }) => {
31
+ if (B === "smiley" && T === L) {
32
+ let A = 0;
33
+ return N.replace(/black/g, () => ++A == 1 ? "black" : "white");
34
+ }
35
+ return N;
36
+ })({ icon: o, scaleLabelType: m, value: i, selectedValue: g }), h), [h, o, m, g, i]);
37
+ return e("button", { "aria-label": S ? void 0 : String(i), className: (() => {
38
+ switch (m) {
39
+ case "star":
40
+ return O(re("likert-star", y), re(`likert-star-${i}`, y));
41
+ case "smiley":
42
+ return O(re("likert-smiley", y), re(`likert-smiley-${i}`, y));
43
+ default:
44
+ return i === a ? O(re("likert-number", y), re(`likert-number-${i}`, y), re("likert-last-option", y)) : O(re("likert-number", y), re(`likert-number-${i}`, y));
45
+ }
46
+ })(), dangerouslySetInnerHTML: { __html: v }, id: b, onClick: (N) => {
47
+ u && (N.preventDefault(), N.stopPropagation(), c(i)), r();
48
+ }, onKeyDown: (N) => {
49
+ var L, A;
50
+ const B = f.querySelectorAll(`.likert-${m ?? "number"}`), T = i - 1;
51
+ N.key === "ArrowRight" ? (L = B[T + 1]) == null || L.focus() : N.key === "ArrowLeft" ? (A = B[T - 1]) == null || A.focus() : N.key !== "Enter" && N.key !== " " || (u && (N.preventDefault(), N.stopPropagation(), c(i)), r());
52
+ }, onPointerDown: () => d(!0), onPointerEnter: () => p(i), onPointerLeave: () => {
53
+ p(-1), d(!1);
54
+ }, style: F, tabIndex: 0 });
55
+ }, fr = ({ className: t, labels: s, message: o, next: n, properties: r, questionId: a, type: m }) => {
56
+ const { border: g, useMobileStyling: c, viewDocument: p, isLongFormSurvey: d, focusedQuestionId: y } = G((T) => ({ border: T.border, useMobileStyling: T.useMobileStyling, viewDocument: T.viewDocument, isLongFormSurvey: se(T.studyType), focusedQuestionId: T.focusedQuestionId })), [i, f] = J(-1), [u, h] = J(!1), [b, S] = J(null), C = d && y === a, k = s && s.left, E = s && s.right;
57
+ let P;
58
+ const { range: D, scaleLabelType: F, ratingIcons: v } = r;
59
+ D && (P = Number(D));
60
+ const N = P || 5, B = (T) => {
61
+ var L, A;
62
+ switch (F) {
63
+ case "star":
64
+ return (L = v[0]) == null ? void 0 : L.svg;
65
+ case "smiley":
66
+ return (A = v[T]) == null ? void 0 : A.svg;
67
+ default:
68
+ return String(T + 1);
69
+ }
70
+ };
71
+ return e("form", { className: O(t, "ul-card--likert", "fade-in-transition", d && !C && "ul-card--unfocused"), children: [e(ie, { isRequired: d && (r == null ? void 0 : r.required), message: o, properties: r }), e(pe, { properties: r, children: e(be, { children: [e(le, { children: [e("div", { "aria-label": `Rating (1 - ${N})`, className: "ul-card--likert__numbers", role: "radiogroup", children: [...Array(N)].map((T, L) => {
72
+ const A = L + 1;
73
+ return e(yr, { activeValue: i, border: g, icon: B(L), isPressed: u, onSubmit: () => n({ value: A, questionId: a, type: m }, !0), range: N, scaleLabelType: F, selectedValue: b, setActiveValue: f, setIsPressed: h, setSelectedValue: S, useMobileStyling: c, value: A, viewDocument: p }, L);
74
+ }) }), e("div", { className: "ul-card--likert__labels", children: [e("span", { children: k }), e("span", { children: E })] })] }), !r.required && !d && e(ue, { children: e("div", { className: "ul-vertical-centered-container", children: e(ee, { onClick: (T) => {
75
+ T.preventDefault(), T.stopPropagation(), n({ value: null, questionId: a, type: m }, !0);
76
+ }, children: ge(r) }) }) })] }) })] }, a);
77
+ }, He = (t) => t && (t.scrollHeight > t.offsetHeight ? t : He(t.parentElement)), xr = (t) => {
78
+ if (!t || !((o) => o instanceof HTMLElement)(t)) return 0;
79
+ const s = getComputedStyle(t);
80
+ return parseFloat(s.marginTop) + parseFloat(s.marginBottom) + (parseFloat(s.borderTopWidth) + parseFloat(s.borderBottomWidth));
81
+ }, Sr = ({ columns: t, onSelect: s, options: o, selectedOptions: n }) => {
82
+ const r = te([]), { border: a, useMobileStyling: m } = G((i) => ({ border: i.border, useMobileStyling: i.useMobileStyling })), g = o.findIndex((i) => n[i.id] === null), [c, p] = J(g), d = Te((i, f) => {
83
+ s(i, f);
84
+ const u = c + 1, h = o[u];
85
+ if (h && n[h.id] === null) {
86
+ p(u);
87
+ const b = r.current[c];
88
+ if (b != null && b.firstElementChild) {
89
+ const S = He(b), C = b.firstElementChild, k = xr(b) + C.clientHeight;
90
+ S == null || S.scrollTo(0, b.offsetTop + k);
91
+ }
92
+ }
93
+ }, [s, o, n, c]), y = Te((i, f) => {
94
+ const u = c === i;
95
+ return e(er, { animate: !0, header: f.label, isOpen: u, onClick: () => {
96
+ var h;
97
+ return p(u && !((h = window.UserLeap) != null && h.isMobileSDK) ? -1 : i);
98
+ }, ref: (h) => {
99
+ h && (r.current[i] = h);
100
+ }, showHeaderCheck: n[f.id] !== null, children: e("div", { style: { paddingTop: "12px" }, children: t.map((h) => e(ye, { allowTextEntry: !1, ariaLabel: `${f.label}-${h.label}`, border: a, error: !1, id: `${f.id}-${h.value}`, isRadio: !0, isSelected: n[f.id] === h.value, label: h.label, onUserInputChanged: () => d(f.id, h.value), useMobileStyling: m }, h.label)) }) }, f.id);
101
+ }, [a, t, c, d, n, m]);
102
+ return e("div", { children: o.map((i, f) => y(f, i)) });
103
+ }, kr = ({ columns: t, onSelect: s, options: o, selectedOptions: n }) => {
104
+ const { border: r, useMobileStyling: a, isLongFormSurvey: m } = G((u) => ({ border: u.border, useMobileStyling: u.useMobileStyling, isLongFormSurvey: se(u.studyType) })), g = o.length, c = t.length, p = te(null), [d, y] = J(!1), [i, f] = J(!1);
105
+ return ne(() => {
106
+ const u = p.current, h = new ResizeObserver((b) => {
107
+ window.requestAnimationFrame(() => {
108
+ u && (y(Math.round(b[0].contentRect.width) < u.scrollWidth), f(Math.round(b[0].contentRect.width) < u.scrollWidth));
109
+ });
110
+ });
111
+ return u && h.observe(u), () => {
112
+ u && h.unobserve(u);
113
+ };
114
+ }, []), e("div", { className: "ul-card--matrix_question_container", children: [e("div", { className: O("ul-card--matrix_container", d && "ul-matrix-scroll-gradient"), onScroll: () => {
115
+ (() => {
116
+ const u = p.current;
117
+ u && y(u.clientWidth + Math.abs(u.scrollLeft) < u.scrollWidth);
118
+ })();
119
+ }, ref: p, children: e("div", { className: O(m && "ul-card--matrix_grid_longform", "ul-card--matrix_grid"), style: `--numColumns: ${c}; --numRows: ${g + 1};`, children: [e("div", {}), " ", t.map((u) => e("div", { className: "ul-matrix-column-label", children: u.label }, u.label)), o.map((u) => e(be, { children: [e("div", { "aria-label": u.label, className: "ul-matrix-row-label", children: u.label }, u.label), e("div", { className: "ul-matrix-row-options", role: "radiogroup", children: t.map((h, b) => e("div", { className: O("ul-matrix-option-wrapper", b === c - 1 && "ul-matrix-last-option"), children: e(ye, { allowTextEntry: !1, ariaLabel: `${u.label}-${h.label}`, border: r, choiceStyle: { background: "transparent", border: "none", marginBottom: "0", padding: "0" }, error: !1, id: `${u.id}-${h.value}`, isRadio: !0, isSelected: n[u.id] === h.value, onUserInputChanged: () => s(u.id, h.value), useMobileStyling: a }) }, h.value)) })] }))] }) }), (d || i) && e("button", { className: i && !d ? "ul-matrix-scroll-arrow left" : "ul-matrix-scroll-arrow", onClick: i && !d ? (u) => {
120
+ u.preventDefault();
121
+ const h = p.current;
122
+ if (h) {
123
+ const b = getComputedStyle(h).direction === "rtl";
124
+ h.scrollTo({ left: b ? h.scrollWidth - h.clientWidth : 0, behavior: "smooth" });
125
+ }
126
+ } : (u) => {
127
+ u.preventDefault();
128
+ const h = p.current;
129
+ if (h) {
130
+ const b = getComputedStyle(h).direction === "rtl";
131
+ h.scrollTo({ left: b ? h.clientWidth - h.scrollWidth : h.scrollWidth, behavior: "smooth" });
132
+ }
133
+ }, children: e(i && !d ? Tr : Cr, {}) })] });
134
+ }, Tr = () => 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" }) }), Cr = () => 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" }) }), Ir = ({ className: t, message: s, next: o, options: n, properties: r, questionId: a, type: m, showIndividualSubmit: g = !1, onSubmitButtonClick: c }) => {
135
+ const { useMobileStyling: p, isLongFormSurvey: d, focusedQuestionId: y, setFocusedQuestionId: i } = G((F) => ({ useMobileStyling: F.useMobileStyling, isLongFormSurvey: se(F.studyType), focusedQuestionId: F.focusedQuestionId, setFocusedQuestionId: F.setFocusedQuestionId })), f = r.matrixColumn, u = r.required, h = d && y === a, b = (F) => {
136
+ F.preventDefault(), F.stopPropagation(), o({ value: C, questionId: a, type: m }, !0), c && c();
137
+ }, S = n.reduce((F, v) => (F[v.id] = null, F), {}), [C, k] = J(S), E = (F) => u && Object.values(F).every((v) => v == null), P = (F, v) => {
138
+ d && o({ value: { ...C, [F]: v }, questionId: a, type: m }, !E({ ...C, [F]: v })), k((N) => ({ ...N, [F]: v }));
139
+ }, D = r.displayMatrixAsAccordion || p;
140
+ return e("form", { className: O(t, !d && "ul-card__matrix", "fade-in-transition", d && !h && "ul-card--unfocused"), id: "text-form", onClick: () => {
141
+ h && i(a);
142
+ }, onSubmit: b, children: [e(ie, { isRequired: d && (r == null ? void 0 : r.required), message: s, properties: r }), e(pe, { properties: r, children: [e(le, { children: [e(D ? Sr : kr, { columns: f, onSelect: P, options: n, selectedOptions: C }), g && e(xe, { handleSubmit: b, isSubmitDisabled: E(C) })] }), !d && e(ue, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: E(C), children: ge(r) }) }) })] })] }, a);
143
+ }, je = ({ className: t, message: s, onSubmit: o, options: n = [], properties: r, questionId: a, type: m, showIndividualSubmit: g = !1, onSubmitButtonClick: c }) => {
144
+ const { border: p, useMobileStyling: d, isLongFormSurvey: y, focusedQuestionId: i, setFocusedQuestionId: f } = G((_) => ({ border: _.border, useMobileStyling: _.useMobileStyling, isLongFormSurvey: se(_.studyType), focusedQuestionId: _.focusedQuestionId, setFocusedQuestionId: _.setFocusedQuestionId })), u = y && i === a, h = n.reduce((_, q) => (_[q.id] = { isSelected: !1 }, _), {}), [b, S] = J(h), C = m === "multiplechoice", k = r.required, E = n.find((_) => {
145
+ var q;
146
+ return (q = _.optionProperties) == null ? void 0 : q.noneOfTheAbove;
147
+ }), P = (_) => Object.entries(_).some(([q, H]) => {
148
+ var l;
149
+ const K = n.find((x) => `${x.id}` === q), V = H.userText === void 0 || H.userText.trim() === "";
150
+ return ((l = K == null ? void 0 : K.optionProperties) == null ? void 0 : l.allowsTextEntry) && V && H.isSelected;
151
+ }), D = (_) => Object.values(_).filter((q) => q.isSelected).length, F = r.minSelect && r.minSelect > 0 && r.maxSelectMode === ke.Range && D(b) < r.minSelect && (k || D(b) > 0), v = (_) => P(_) || k && !D(_) || !((q) => {
152
+ const { minSelect: H = 0, maxSelect: K = 1 / 0, maxSelectMode: V } = r, l = D(q);
153
+ switch (V) {
154
+ case ke.Maximum:
155
+ return l <= K;
156
+ case ke.Range:
157
+ return l === 0 || l >= H;
158
+ default:
159
+ return !0;
160
+ }
161
+ })(_), N = Object.entries(b).some(([_, q]) => {
162
+ var H, K;
163
+ return q.isSelected && ((K = (H = n.find((V) => `${V.id}` === _)) == null ? void 0 : H.optionProperties) == null ? void 0 : K.allowsTextEntry);
164
+ }), B = g && (!C || N), T = (_) => {
165
+ X(_.id, _.selected, _.userText, _.noneOfTheAbove), _.selected && y && !C && !u && f(a);
166
+ }, L = (_) => {
167
+ var q;
168
+ return (r == null ? void 0 : r.maxSelectMode) !== ke.Unlimited && D(b) === (r == null ? void 0 : r.maxSelect) && !((q = b[_]) != null && q.isSelected);
169
+ }, A = (_) => {
170
+ _.preventDefault(), _.stopPropagation(), o(b, !0), c && c();
171
+ }, X = (_, q, H, K) => {
172
+ const V = Object.assign({}, b);
173
+ if ((C || K) && q) for (const w of Object.values(V)) w.isSelected = !1, delete w.userText;
174
+ else E && !K && b[E.id].isSelected && (V[E.id].isSelected = !1);
175
+ V[_] = { isSelected: q, userText: H };
176
+ const l = C && Object.entries(V).some(([w, Q]) => {
177
+ var R, j;
178
+ return Q.isSelected && ((j = (R = n.find((z) => `${z.id}` === w)) == null ? void 0 : R.optionProperties) == null ? void 0 : j.allowsTextEntry);
179
+ }), x = !v(V);
180
+ y && (o(V, x), C && !l && x && c && c()), S(V);
181
+ };
182
+ return e("form", { className: O(t, "ul-card--multiple", "fade-in-transition", y && !u && "ul-card--unfocused"), id: "text-form", onClick: m === "multipleselect" ? () => {
183
+ y && i !== a && m === "multipleselect" && f(a);
184
+ } : void 0, onSubmit: A, children: [e(ie, { isRequired: y && (r == null ? void 0 : r.required), message: s, properties: r }), e(pe, { properties: r, children: e(be, { children: [e(le, { children: [r.isDropdown ? e(pr, { disabledOptions: n.filter((_) => L(_.id)), dropdownFooter: F ? e("div", { className: "ul-card__min-select-counter", style: { marginLeft: "16px" }, children: [D(b), "/", r.minSelect] }) : void 0, isMultiSelect: !C, multiselectText: r.dropdownMultiselectedText ?? "choices selected", onChange: (_) => {
185
+ const q = { ...b };
186
+ for (const H of n) _.includes(H) ? q[H.id].isSelected = !0 : q[H.id].isSelected = !1;
187
+ y && o(q, !v(q)), S(q);
188
+ }, options: n, placeholderText: r.dropdownPlaceholderText ?? (C ? "Select choice" : "Select choice(s)"), value: n.filter((_) => b[_.id].isSelected) }) : e("div", { className: O(re("ul-card__choices", d)), role: C ? "radiogroup" : "group", children: [n.map(({ id: _, label: q, value: H, optionProperties: K }) => {
189
+ var Q, R;
190
+ const V = `${_}`, { allowsTextEntry: l, noneOfTheAbove: x } = { allowsTextEntry: !1, noneOfTheAbove: !1, ...K };
191
+ return e(ye, { allowTextEntry: l, border: p, disabled: L(V), error: (w = b, P(w)), id: V, isRadio: C, isSelected: !!((Q = b[V]) != null && Q.isSelected), label: q, noneOfTheAbove: x, onUserInputChanged: T, promptText: "Please specify", text: (R = b[_]) == null ? void 0 : R.userText, useMobileStyling: d, value: H }, V);
192
+ var w;
193
+ }), !!F && e("div", { className: "ul-card__min-select-counter", children: [D(b), "/", r.minSelect] })] }), B && e(xe, { handleSubmit: A, isSubmitDisabled: v(b) })] }), !y && e(ue, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: v(b), onClick: A, children: ge(r) }) }) })] }) })] }, a);
194
+ }, _r = (t) => {
195
+ const { questionId: s, type: o, next: n, options: r } = t, { setFocusedQuestionId: a } = G((m) => ({ setFocusedQuestionId: m.setFocusedQuestionId }));
196
+ return e(je, { ...t, onSubmit: (m, g) => {
197
+ var f;
198
+ const c = Object.entries(m).find(([, u]) => u.isSelected) || [void 0, void 0], [p, d] = c, y = r.find((u) => `${u.id}` === p);
199
+ !((f = y == null ? void 0 : y.optionProperties) != null && f.allowsTextEntry) || d != null && d.userText && d.userText.trim() !== "" || a(s);
200
+ const i = d != null && d.userText ? { [p]: { userText: d.userText } } : null;
201
+ n({ value: y && p ? { [p]: y.value } : {}, secondaryValue: i, questionId: s, type: o }, g);
202
+ } });
203
+ }, Nr = (t) => {
204
+ const { questionId: s, type: o, next: n } = t;
205
+ return e(je, { ...t, onSubmit: (r, a) => {
206
+ const m = Object.entries(r).reduce((c, [p, d]) => (c[p] = d.isSelected, c), {}), g = Object.entries(r).reduce((c, [p, d]) => {
207
+ if (!d.userText) return c;
208
+ const y = c || {};
209
+ return y[p] = { userText: d.userText }, y;
210
+ }, null);
211
+ n({ value: m, secondaryValue: g, questionId: s, type: o }, a);
212
+ } });
213
+ }, wr = ({ className: t, labels: s, message: o, properties: n, next: r, questionId: a, type: m }) => {
214
+ const [g, c] = J(null), { border: p, useMobileStyling: d, viewDocument: y, isLongFormSurvey: i, focusedQuestionId: f } = G((S) => ({ border: S.border, useMobileStyling: S.useMobileStyling, viewDocument: S.viewDocument, isLongFormSurvey: se(S.studyType), focusedQuestionId: S.focusedQuestionId })), u = i && f === a, h = s && s.left, b = s && s.right;
215
+ return e("form", { className: O(t, "ul-card--nps", "fade-in-transition", i && !u && "ul-card--unfocused"), children: [e(ie, { isRequired: i && (n == null ? void 0 : n.required), message: o, properties: n }), e(pe, { properties: n, children: [e(le, { children: [e("div", { className: "ul-card--nps__numbers", children: [...Array(11)].map((S, C) => e("button", { className: O(re("nps-number", d), re(`nps-number-${C}`, d)), id: `option-${C}`, onClick: (k) => {
216
+ i && (k.preventDefault(), k.stopPropagation(), c(C)), r({ value: C, questionId: a, type: m }, !0);
217
+ }, onKeyDown: (k) => {
218
+ var P, D;
219
+ const E = y.querySelectorAll("button.nps-number");
220
+ k.key === "ArrowRight" ? (P = E[C + 1]) == null || P.focus() : k.key === "ArrowLeft" ? (D = E[C - 1]) == null || D.focus() : k.key !== "Enter" && k.key !== " " || (i && (k.preventDefault(), k.stopPropagation(), c(C)), r({ value: C, questionId: a, type: m }, !0));
221
+ }, onPointerDown: (k) => {
222
+ k.currentTarget.style.zIndex = "2", k.currentTarget.style.borderColor = p;
223
+ }, onPointerLeave: (k) => {
224
+ k.currentTarget.style.zIndex = "auto", k.currentTarget.style.borderColor = Pe;
225
+ }, style: g === C ? { backgroundColor: p, color: "#fff" } : void 0, tabIndex: 0, children: C }, C)) }), e("div", { className: "ul-card--nps__labels", children: [e("span", { children: h }), e("span", { children: b })] })] }), !n.required && !i && e(ue, { children: e("div", { className: "ul-vertical-centered-container", children: e(ee, { onClick: (S) => {
226
+ S.preventDefault(), S.stopPropagation(), r({ value: null, questionId: a, type: m }, !0);
227
+ }, children: ge(n) }) }) })] })] }, a);
228
+ }, qr = (t) => {
229
+ const { className: s, message: o, next: n, properties: r, questionId: a, type: m, showIndividualSubmit: g = !1, onSubmitButtonClick: c } = t, p = m === "aidynamicfollowup" ? t.loading : void 0, { border: d, useMobileStyling: y, update: i, isLongFormSurvey: f, focusedQuestionId: u, setFocusedQuestionId: h, isPreview: b } = G((T) => ({ border: T.border, useMobileStyling: T.useMobileStyling, update: T.update, isLongFormSurvey: se(T.studyType), focusedQuestionId: T.focusedQuestionId, setFocusedQuestionId: T.setFocusedQuestionId, isPreview: T.isPreview })), [S, C] = J(""), k = te(null), E = f && u === a;
230
+ ne(() => {
231
+ var T, L;
232
+ f && !b && (E ? (T = k.current) == null || T.focus() : (L = k.current) == null || L.blur());
233
+ }, [f, E, b]);
234
+ const P = S.trim(), D = r.required === !0 && !P, F = mr(k, () => i()), v = (T) => {
235
+ T.preventDefault(), T.stopPropagation();
236
+ const L = P.length > 0, A = !r.required || L;
237
+ n({ value: S, questionId: a, type: m }, A), c && c(L);
238
+ }, N = r && r.openTextPlaceholder ? r.openTextPlaceholder : "";
239
+ if (p == null && m === "aidynamicfollowup") return e(be, {});
240
+ const B = p ? "Preparing your next question" : o;
241
+ return e("form", { className: O(s, "ul-card-text", "fade-in-transition", f && !E && "ul-card--unfocused"), id: "text-form", onClick: () => {
242
+ f && u !== a && h(a);
243
+ }, children: [e(ie, { isRequired: f && (r == null ? void 0 : r.required), message: B, properties: r }), e(pe, { properties: r, children: e("div", { className: "ul-card-text", children: e(le, { children: [e("div", { className: "ul-card-text__container", children: e("textarea", { "aria-describedby": "ul-caption", "aria-labelledby": "ul-question", "aria-multiline": "true", "aria-placeholder": N, className: O(!!p && "ul-card-text__input__loading", re("ul-card-text__input", y)), "data-gramm": "false", disabled: !!p, maxLength: 5e3, name: "text", onBlur: (T) => {
244
+ T.currentTarget.style.borderColor = Pe;
245
+ }, onChange: (T) => {
246
+ const { value: L } = T.currentTarget;
247
+ if (F(), T.preventDefault(), T.stopPropagation(), C(L), f) {
248
+ const A = L.trim().length > 0;
249
+ n({ value: L, questionId: a, type: m }, A);
250
+ }
251
+ }, onFocus: (T) => {
252
+ T.currentTarget.style.borderColor = d, h(a);
253
+ }, placeholder: N, ref: k, role: "textbox", tabIndex: 0 }) }), r.footerHtml && e(Se, { className: "footer", html: r.footerHtml }), g && e(xe, { handleSubmit: v, isSubmitDisabled: D }), e(ue, { children: !f && e(ee, { disabled: D || !!p, onClick: v, children: ge(r) }) })] }) }) })] }, a);
254
+ }, we = 1, Ze = 2, We = 3, Ce = (t) => t.type === "av_permission", Qe = (t) => t.type === "screen_permission", Ge = (t, s) => t === void 0 ? we : t ? ((o, n) => !(Ce(n) ? n.permissionDescriptors : []).includes("camera") || o.getVideoTracks().length > 0)(t, s) ? We : we : Ze, Ee = { avStream: null, currentPage: null, mediaRecordingUids: null, nextQuestion: () => {
255
+ }, passthroughData: void 0, recordingMediaTypes: void 0, screenPermissionRequested: !1, type: void 0 }, de = rr((t) => ({ ...Ee, reset: () => {
256
+ t(Ee);
257
+ }, updatePage: (s) => {
258
+ t(s);
259
+ } }));
260
+ function qe({ currentPage: t, pages: s }) {
261
+ const { avStream: o, recordingMediaTypes: n, updatePage: r } = de.getState(), { recorderEventEmitter: a } = G.getState();
262
+ a.emit("av.permission", { "permission.descriptors": t.permissionDescriptors, "stream.ready": (m, g) => {
263
+ if (o === m) return;
264
+ let c = t;
265
+ if (m && !t.permissionDescriptors.includes("camera")) {
266
+ const p = s.indexOf(t), d = g != null && g.active ? p + 2 : p + 1;
267
+ g != null && g.active && n && a.emit("begin.recording", { "recording.media.types": n, "start.recording.callback": (y) => r({ mediaRecordingUids: y }) }), c = s[d];
268
+ }
269
+ r({ currentPage: c, avStream: m });
270
+ } });
271
+ }
272
+ function Le({ status: t }) {
273
+ const { nextQuestion: s, passthroughData: o, mediaRecordingUids: n, reset: r } = de.getState(), { recorderEventEmitter: a, handleUploadUpdate: m, index: g } = G.getState(), c = { value: { taskStatus: t }, type: "recordedtask", questionId: (o == null ? void 0 : o.questionId) || 1 };
274
+ o && a.emit("finish.task", { "begin.callback": (p) => {
275
+ m({ mediaRecordingUid: p, isSubmitted: !0, progressPct: 0, isComplete: !1 });
276
+ }, "progress.callback": (p, d) => {
277
+ m({ mediaRecordingUid: p, progressPct: d.detail, isSubmitted: !1, isComplete: !1 });
278
+ }, "upload.callback": (p) => {
279
+ p && m({ mediaRecordingUid: p, isComplete: !0, isSubmitted: !0, progressPct: 100 });
280
+ }, "passthrough.data": o, "current.index": g, "task.response": c, "task.complete.callback": (p) => {
281
+ c.value.taskDurationMillisecond = p, n && (c.value.mediaRecordingUids = n), r(), s(c);
282
+ } });
283
+ }
284
+ function Me({ pages: t, setIsRequestingPermission: s }) {
285
+ const { recorderEventEmitter: o, eventEmitFn: n } = G.getState(), { updatePage: r, currentPage: a, recordingMediaTypes: m, screenPermissionRequested: g } = de.getState();
286
+ if (!a) return;
287
+ const c = t.indexOf(a);
288
+ switch (a.type) {
289
+ case "av_permission": {
290
+ const p = g ? c + 2 : c + 1;
291
+ return g && m && o.emit("begin.recording", { "recording.media.types": m, "start.recording.callback": (d) => {
292
+ r({ mediaRecordingUids: d });
293
+ } }), void r({ currentPage: t[p] });
294
+ }
295
+ case "screen_permission":
296
+ return void o.emit("screen.permission", { "screen.permission.requested": s, "stream.ready.callback": (p, d) => {
297
+ const y = d ? t[c + 1] : a;
298
+ d && m && o.emit("begin.recording", { "recording.media.types": m, "start.recording.callback": (i) => {
299
+ r({ captureStream: d, mediaRecordingUids: i });
300
+ } }), r({ currentPage: y, screenPermissionRequested: !0, captureStream: d });
301
+ } });
302
+ case "start_task":
303
+ return n("recorded.task.start"), o.emit("recorded.task.start"), o.emit("start.task"), void r({ currentPage: t[c + 1], screenPermissionRequested: !0 });
304
+ case "complete_task":
305
+ return;
306
+ }
307
+ }
308
+ const ze = "ul-permission-graphics-container", Ye = "ul-permission-body", Ke = O(ze, "ul_recorded-task-inset-spacing"), Ie = O("ul-horizontal-button-container", "ul-horizontal-button-container-left"), Xe = ({ richTextBody: t }) => e(Se, { className: "ul-rich-text-body", html: t, id: "ul-task-detail-container" }), _e = ({ required: t, skipButtonText: s, bottom: o = !1 }) => t ? null : e(ee, { className: O(o && "ul-skip-button-below", "ul-button-inactive"), onClick: Le.bind(null, { status: "abandoned" }), children: s || "Skip" }), Re = (t) => {
309
+ const { avStream: s, captureStream: o, recordingMediaTypes: n, updatePage: r } = de.getState(), a = (n == null ? void 0 : n.includes("audio")) || (n == null ? void 0 : n.includes("video"));
310
+ ne(() => {
311
+ const m = setInterval(() => {
312
+ a && s && !s.active ? r({ avStream: null, currentPage: t[0] }) : o && o.active || r({ captureStream: void 0, currentPage: t[a ? 1 : 0] });
313
+ }, 1e3);
314
+ return () => clearInterval(m);
315
+ }, [s, o, a, t, n, r]);
316
+ }, Lr = ({ content: t, pages: s, required: o }) => {
317
+ const { buttonText: n, skipButtonText: r, taskDetail: a } = t;
318
+ return Re(s), e("div", { className: "ul-task-page", children: [a && e(Xe, { richTextBody: a }), e("div", { className: Ie, children: [e(ee, { onClick: Me.bind(null, { pages: s }), children: n }), e(_e, { required: o, skipButtonText: r })] })] }, "start-task");
319
+ }, Pr = ({ content: t, pages: s, properties: o }) => {
320
+ const { buttonText: n, skipButtonText: r } = t;
321
+ return Re(s), e("div", { className: "ul-task-page", children: [t.taskDetail && e(Xe, { richTextBody: t.taskDetail }), e(pe, { properties: o, children: e("div", { className: Ie, children: [e(ee, { className: "ul-complete-task-button", onClick: Le.bind(null, { status: "completed" }), children: n }), e(ee, { className: O("ul-button-inactive"), onClick: Le.bind(null, { status: "given.up" }), children: r })] }) })] }, "complete-task");
322
+ }, Mr = ({ content: t, pages: s, required: o }) => {
323
+ const { buttonText: n, skipButtonText: r } = t, [a] = G((c) => [c.tabTitle]), [m, g] = J(!1);
324
+ return e("div", { children: [e("div", { className: Ke, children: [e("p", { style: { marginTop: "auto" }, children: t.selectTabText }), e("div", { className: "ul-select-tab-container", children: e("p", { className: Ye, children: a }) })] }), e("div", { className: o ? "" : Ie, children: [e(ee, { disabled: m, onClick: Me.bind(null, { pages: s, setIsRequestingPermission: g }), children: n }), e(_e, { required: o, skipButtonText: r })] })] });
325
+ }, Rr = ({ content: t }) => e(Se, { className: O(ze, "ul_permission_svg_container", "ul_recorded-task-inset-spacing", "ul-center-horizontally"), html: t.svg }, "ul-permission-request-graphic"), Dr = ({ content: t, pages: s, required: o }) => {
326
+ const { permissionDeniedHeadline: n, permissionDeniedBody: r, skipButtonText: a, tryAgainButtonText: m } = t, g = Ce(s[0]) ? s[0] : null;
327
+ return ne(() => {
328
+ const c = setInterval(() => {
329
+ g !== null && qe({ currentPage: g, pages: s });
330
+ }, 1e3);
331
+ return () => clearInterval(c);
332
+ }, [g, s]), g ? e("div", { children: [e("div", { className: Ke, children: e("p", { className: "ul-av-permission-denied-paragraph", children: [e("span", { className: "ul-av-permission-denied-headline", children: n }), e("span", { className: Ye, children: r })] }) }), e("div", { className: Ie, children: [e(ee, { onClick: qe.bind(null, { currentPage: g, pages: s }), children: m }), e(_e, { required: o, skipButtonText: a })] })] }) : null;
333
+ }, Fr = ({ stream: t }) => e("video", { autoPlay: !0, className: O("ul_recorded-task-inset-spacing"), id: "ul-record-task-video-preview", muted: !0, ref: (s) => {
334
+ s && (s.srcObject = t || null);
335
+ } }), Br = ({ content: t, pages: s, required: o }) => {
336
+ const { skipButtonText: n } = t, { avStream: r } = de.getState();
337
+ return Re(s), e("div", { children: [e(Fr, { stream: r }), e("div", { className: "ul-vertical-button-container-center", children: [e(ee, { onClick: Me.bind(null, { pages: s }), children: t.buttonText }), e(_e, { bottom: !0, required: o, skipButtonText: n })] })] });
338
+ }, Qr = ({ properties: t }) => {
339
+ const { pages: s, required: o } = t, { avStream: n, currentPage: r } = de.getState();
340
+ if (r === void 0) return null;
341
+ switch (r == null ? void 0 : r.type) {
342
+ case "av_permission": {
343
+ const a = Ge(n, r);
344
+ return a === we ? e(Rr, { content: r }) : e(a === Ze ? Dr : Br, { content: r, pages: s, required: o });
345
+ }
346
+ case "screen_permission":
347
+ return e(Mr, { content: r, pages: s, required: o });
348
+ case "start_task":
349
+ return e(Lr, { content: r, pages: s, required: o });
350
+ case "complete_task":
351
+ return e(Pr, { content: r, pages: s, properties: t });
352
+ default:
353
+ return null;
354
+ }
355
+ }, Er = ({ className: t, properties: s, next: o, questionId: n }) => {
356
+ const r = G(), { surveyId: a, responseGroupUid: m, userId: g, update: c } = r, p = de(), { screenPermissionRequested: d } = p, y = de((b) => b.avStream);
357
+ let i = de((b) => b.currentPage);
358
+ i || (i = function({ pages: b, userId: S, responseGroupUid: C, surveyId: k, questionId: E, next: P }) {
359
+ const { updatePage: D } = de.getState(), { eventEmitFn: F, recorderEventEmitter: v } = G.getState(), N = { questionId: E, surveyId: k, visitorId: S, responseGroupUid: C };
360
+ let B = 0;
361
+ v.emit("recorded.task.permission.screen"), F("recorded.task.permission.screen"), v.emit("permission.status", { "permission.status.callback": (L, A, X, _) => {
362
+ const q = b[B], { type: H } = q, K = ["screen"];
363
+ if (Ce(q)) {
364
+ const { permissionDescriptors: V } = q, l = V == null ? void 0 : V.includes("microphone"), x = V == null ? void 0 : V.includes("camera");
365
+ l && K.push("audio"), x && K.push("video"), (L != null && L.active && !x || L != null && L.active && A) && B++;
366
+ }
367
+ Qe(b[B]) && X && (B++, v.emit("begin.recording", { "recording.media.types": K, "start.recording.callback": (V) => D({ mediaRecordingUids: V }) })), D({ currentPage: b[B], avStream: L, screenPermissionRequested: X, nextQuestion: P, type: H, passthroughData: N, recordingMediaTypes: K, captureStream: _ });
368
+ } });
369
+ const T = b[B];
370
+ return T.type === "av_permission" && qe({ currentPage: T, pages: b }), T;
371
+ }({ questionId: n, surveyId: a, next: (b) => {
372
+ o(b, !0);
373
+ }, pages: s.pages, responseGroupUid: m, userId: g }));
374
+ let f = i.headline, u = i.captionText;
375
+ const h = Ge(y, i);
376
+ return Qe(i) && d && (f = i.permissionDeniedHeadline, u = i.permissionDeniedCaptionText), Ce(i) && h === We && (f = i.permissionGrantedHeadline, u = i.permissionGrantedCaptionText), ne(() => {
377
+ c();
378
+ }, [c]), e("div", { className: O(t, "ul-center-horizontally", "fade-in-transition"), children: [e(ie, { isRequired: s == null ? void 0 : s.required, message: f, properties: { captionText: u } }), e(le, { children: e(Qr, { properties: s }) })] });
379
+ }, $r = ({ richTextBody: t, plaintextBody: s }) => t ? e(Se, { className: "ul-rich-text-body", html: t, 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, n) => e("p", { children: o }, n)) }) : null, Ar = ({ className: t, message: s, next: o, properties: n, questionId: r, type: a }) => {
380
+ const { visitorAttributes: m, isLongFormSurvey: g } = G((y) => ({ visitorAttributes: y.visitorAttributes, isLongFormSurvey: se(y.studyType) })), c = (y, i = !1) => {
381
+ o({ value: i ? { skipped: !0 } : void 0, questionId: r, type: a }, !0);
382
+ }, p = gr(n && n.buttonUrl, m), d = g && n.promptActionType === hr.NO_BUTTON;
383
+ return e("div", { className: O(t, "ul-card__text-url-prompt", "fade-in-transition"), children: [e(ie, { isRequired: g && (n == null ? void 0 : n.required), message: s, properties: { questionHtml: n.questionHtml } }), e(le, { children: e($r, { plaintextBody: n == null ? void 0 : n.body, richTextBody: n == null ? void 0 : n.richTextBody }) }), e(pe, { properties: n, children: !d && 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: p, id: "ul-card-text__button", onClick: c, onKeyPress: (y) => {
384
+ y.key !== "Enter" && y.key !== " " || o({ value: void 0, questionId: r, type: a }, !0);
385
+ }, rel: "noreferrer", role: p ? "link" : "button", tabIndex: 0, target: "_blank", children: ge(n) }), n.required === !1 && e("button", { className: "ul-card-skip__button", onClick: (y) => c(0, !0), children: Oe(n) })] }) }) })] }, r);
386
+ }, Or = ({ className: t, questionId: s }) => {
387
+ const { border: o, destroy: n, endCard: r, forceBrandedLogo: a, update: m } = G((p) => ({ border: p.border, destroy: p.destroy, endCard: p.endCard, forceBrandedLogo: p.forceBrandedLogo, update: p.update }));
388
+ ne(() => {
389
+ setTimeout(() => {
390
+ n(ur);
391
+ }, a ? 4e3 : 2e3);
392
+ }, [n, a]);
393
+ const g = r && r.subheader ? e("p", { className: "ul-caption", children: r.subheader }) : null, c = r && r.headline ? r.headline : "";
394
+ return ne(() => {
395
+ m();
396
+ }, [m]), e("div", { className: O(t, "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: c }), g] }) }) }, s);
397
+ }, Ur = ({ className: t }) => {
398
+ const { uploadProgress: s } = G((a) => ({ uploadProgress: a.uploadProgress }));
399
+ let o, n;
400
+ Object.values(s).filter((a) => a.isSubmitted).length > 1 ? (o = "Your responses are processing", n = "Please keep this tab open until your responses are fully processed.") : (o = "Your response is processing", n = "Please keep this tab open until your response is fully processed.");
401
+ const r = Math.round(Math.min(99, ...Object.values(s).filter((a) => a.isSubmitted).map((a) => a.progressPct || 0)));
402
+ return e("div", { className: O(t, "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} (${r}% complete)` }), e("p", { className: "ul-caption", children: n })] });
403
+ }, Je = tr(void 0), Vr = ({ value: t, children: s }) => e(Je.Provider, { value: t, children: s }), Hr = ({ isRightLabel: t, isLeftLabel: s }) => t ? oe.RIGHT : s ? oe.LEFT : null, jr = "Best", Zr = "Worst", Wr = ({ className: t, labels: s, message: o, properties: n, options: r, questionId: a, type: m, next: g }) => {
404
+ var E, P, D, F;
405
+ const [c, p] = J(r.map((v, N) => ({ ...v, label: v.label === "" ? `Item ${N + 1}` : v.label, isRightLabel: !1, isLeftLabel: !1 }))), d = (() => {
406
+ const v = nr(Je);
407
+ if (v === void 0) throw new Error("usePreviousResponses must be used within a PreviousResponsesProvider");
408
+ return v;
409
+ })(), y = { padding: "24px", display: "flex", cursor: "pointer", width: "auto" }, [i, f] = J(!1);
410
+ ne(() => {
411
+ const v = c.findIndex((q) => q.isRightLabel), N = c.findIndex((q) => q.isLeftLabel), B = v !== -1 && N !== -1;
412
+ f(B);
413
+ const T = !n.required || n.required && B, L = c.map((q) => ({ id: q.id, option: q.label, selected: Hr(q) })), A = Math.floor(a), X = Object.keys(d).filter((q) => q.startsWith(A.toString())).map(Number).sort((q, H) => q - H).at(-1), _ = [];
414
+ if (typeof X == "number") {
415
+ const q = d[X], H = JSON.parse(q);
416
+ _.push(...H);
417
+ }
418
+ _.push(L), setTimeout(() => {
419
+ g({ value: _, questionId: a, type: m }, T, B), f(!1);
420
+ }, B ? 500 : 0);
421
+ }, [c]);
422
+ const { border: u, useMobileStyling: h, enableCspTrustedTypes: b } = G((v) => ({ border: v.border, useMobileStyling: v.useMobileStyling, enableCspTrustedTypes: v.enableCspTrustedTypes })), S = (v, N) => () => {
423
+ i || p((B) => ((T, L, A) => T.map((X) => X.id === L ? { ...X, isRightLabel: A === oe.RIGHT, isLeftLabel: A === oe.LEFT } : A === oe.RIGHT && X.isRightLabel || A === oe.LEFT && X.isLeftLabel ? { ...X, isRightLabel: !1, isLeftLabel: !1 } : X))(B, v, N));
424
+ }, C = (E = n.ratingIcons) == null ? void 0 : E[0].svg, k = (P = n.ratingIcons) == null ? void 0 : P[1].svg;
425
+ return e("form", { className: O(t, "ul-card-maxdiff", "fade-in-transition"), children: [e(ie, { isRequired: n == null ? void 0 : n.required, message: o, properties: n }), e(le, { 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) || ((D = n == null ? void 0 : n.labels) == null ? void 0 : D.left) || jr }), e("div", { children: " " }), e("div", { className: "ul-card-maxdiff__label", children: (s == null ? void 0 : s.right) || ((F = n == null ? void 0 : n.labels) == null ? void 0 : F.right) || Zr }), c.map(({ id: v, label: N, isLeftLabel: B, isRightLabel: T }) => e(be, { children: [e("div", { className: "ul-card-maxdiff__option-control " + (k ? "smiley" : ""), children: k ? e($e, { 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: S(v, oe.LEFT) }) : e(ye, { allowTextEntry: !1, ariaLabel: `bestLabel-${N}`, border: u, choiceStyle: y, error: !1, id: `${v}`, isRadio: !0, isSelected: B, onUserInputChanged: S(v, oe.LEFT), useMobileStyling: h }) }), e("div", { className: "ul-card-maxdiff__option-label", children: N }), e("div", { className: "ul-card-maxdiff__option-control " + (C ? "smiley" : ""), children: C ? e($e, { ariaPressed: T, className: T ? "ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected bad" : "ul-card-maxdiff__option-btn", enableCspTrustedTypes: b, html: C, id: `smiley-bad-${v}`, onClick: S(v, oe.RIGHT) }) : e(ye, { allowTextEntry: !1, ariaLabel: `worstLabel-${N}`, border: u, choiceStyle: y, error: !1, id: `${v}`, isRadio: !0, isSelected: T, onUserInputChanged: S(v, oe.RIGHT), useMobileStyling: h }) })] }))] }) })] }, a);
426
+ }, $e = ({ enableCspTrustedTypes: t, ariaPressed: s, className: o, html: n, id: r, onClick: a }) => {
427
+ const m = me(() => Ve(n, t), [t, n]);
428
+ return e("span", { "aria-pressed": s, className: o, dangerouslySetInnerHTML: { __html: m }, id: r, onClick: a, tabIndex: 0, type: "button" });
429
+ }, Gr = ({ className: t, labels: s, message: o, next: n, properties: r, questionId: a, type: m, onSubmitButtonClick: g, options: c, showIndividualSubmit: p = !1 }) => {
430
+ const d = te(null), y = te(0), i = te(0), f = te(null), u = te(!1), h = te([]), [b, S] = J(() => (r == null ? void 0 : r.required) === !0), [C, k] = J(() => c.map((I) => ({ ...I, rank: null }))), E = me(() => Array.from({ length: c.length }, (I, $) => $ + 1), [c.length]), { isLongFormSurvey: P, focusedQuestionId: D, setFocusedQuestionId: F, useMobileStyling: v, isPreview: N, headers: B } = G((I) => ({ useMobileStyling: I.useMobileStyling, isLongFormSurvey: se(I.studyType), focusedQuestionId: I.focusedQuestionId, setFocusedQuestionId: I.setFocusedQuestionId, isPreview: I.isPreview, headers: I.headers })), T = (B == null ? void 0 : B["userleap-platform"]) === "android", L = v && !N && !T, A = !L && !T, X = P && D === a, _ = (I) => {
431
+ I.preventDefault(), w(C), g && g();
432
+ }, q = (I, $) => {
433
+ k((U) => {
434
+ const M = parseInt($), Z = U.map((W) => ({ ...W }));
435
+ Z.some((W) => W.rank == null) && Z.forEach((W, ve) => W.rank = ve + 1);
436
+ const ae = Z.findIndex((W) => W.id === I);
437
+ if (ae === -1) return U;
438
+ const Y = Z[ae].rank;
439
+ return M < Y ? Z.forEach((W) => {
440
+ W.id !== I && W.rank >= M && W.rank < Y && (W.rank = W.rank + 1);
441
+ }) : M > Y && Z.forEach((W) => {
442
+ W.id !== I && W.rank > Y && W.rank <= M && (W.rank = W.rank - 1);
443
+ }), Z[ae].rank = M, Z.sort((W, ve) => W.rank - ve.rank), Q(Z), Z;
444
+ });
445
+ }, H = (I, $) => {
446
+ for (let U = 0; U < h.current.length; U++) {
447
+ const M = h.current[U];
448
+ if (!M || M === f.current) continue;
449
+ const Z = M.getBoundingClientRect();
450
+ if (I >= Z.left && I <= Z.right && $ >= Z.top && $ <= Z.bottom) return { element: M, index: U };
451
+ }
452
+ return null;
453
+ }, K = (I) => ($) => {
454
+ if (!L) return;
455
+ $.preventDefault(), $.stopPropagation(), u.current = !0, d.current = I;
456
+ const U = $.touches[0];
457
+ y.current = U.clientY, i.current = U.clientY;
458
+ const M = $.currentTarget.closest(".ul-card-rank__option");
459
+ M && (f.current = M, M.classList.add("is-dragging"));
460
+ }, V = (I) => {
461
+ if (!L || !u.current || d.current === null) return;
462
+ I.preventDefault(), I.stopPropagation();
463
+ const $ = I.touches[0];
464
+ i.current = $.clientY;
465
+ const U = i.current - y.current;
466
+ f.current && (f.current.style.transform = `translateY(${U}px)`, f.current.style.zIndex = "1000"), h.current.forEach((Z) => {
467
+ Z && Z !== f.current && Z.classList.remove("is-drop-target");
468
+ });
469
+ const M = H($.clientX, $.clientY);
470
+ M && M.element.classList.add("is-drop-target");
471
+ }, l = (I) => {
472
+ if (!L || !u.current || d.current === null) return;
473
+ I.preventDefault(), I.stopPropagation();
474
+ const $ = I.changedTouches[0], U = H($.clientX, $.clientY);
475
+ f.current && (f.current.style.transform = "", f.current.style.zIndex = "", f.current.classList.remove("is-dragging")), h.current.forEach((M) => {
476
+ M && M.classList.remove("is-drop-target");
477
+ }), U && U.index !== d.current && x(d.current, U.index), d.current = null, f.current = null, u.current = !1;
478
+ }, x = (I, $) => {
479
+ k((U) => {
480
+ const M = U.map((ae) => ({ ...ae })), [Z] = M.splice(I, 1);
481
+ return M.splice($, 0, Z), M.forEach((ae, Y) => {
482
+ ae.rank = Y + 1;
483
+ }), Q(M), M;
484
+ });
485
+ }, w = (I) => {
486
+ const $ = {};
487
+ I.reduce((U, M) => (U[M.id] = M.rank, U), $), n({ value: $, questionId: a, type: m }, !0);
488
+ }, Q = (I) => {
489
+ S(!1), P && w(I);
490
+ }, { left: R, right: j } = s, z = c.length, ce = (I) => {
491
+ I.preventDefault(), I.currentTarget.classList.add("is-drop-target");
492
+ }, he = (I) => {
493
+ I.currentTarget.classList.remove("is-drop-target");
494
+ }, fe = (I) => {
495
+ d.current = null, I.currentTarget.classList.remove("is-dragging");
496
+ };
497
+ return e("form", { className: O(t, "ul-card-rank", "fade-in-transition", P && !X && "ul-card--unfocused"), onClick: P ? () => {
498
+ P && D !== a && F(a);
499
+ } : void 0, onSubmit: _, children: [e(ie, { isRequired: r == null ? void 0 : r.required, message: o, properties: r }), e(pe, { properties: r, children: e(be, T ? { children: [e(le, { children: [e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", R] }) }), e("ol", { className: "ul-card-rank__list", children: C.map(({ id: I, label: $, rank: U }) => e("li", { className: "ul-card-rank__option", children: [e("select", { "aria-label": `Rank for ${$}`, className: O("ul-card-rank__select", U == null && "ul-card-rank__select--placeholder"), name: `rank[${I}]`, onChange: (M) => q(I, M.currentTarget.value), value: U ?? "", children: [U == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), E.map((M) => e("option", { className: "ul-card-rank__select-option", value: M, children: M }, `${M}-${a}`))] }), e("span", { children: $ })] }, I)) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [z, " - ", j] }) })] }), p && e(xe, { handleSubmit: _, isSubmitDisabled: b })] }), !P && e(ue, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: b, children: ge(r) }) }) })] } : { children: [e(le, { children: [e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", R] }) }), e("ol", { className: "ul-card-rank__list", onDragOver: T ? void 0 : (I) => {
500
+ I.preventDefault(), I.dataTransfer && (I.dataTransfer.dropEffect = "move");
501
+ }, children: C.map(({ id: I, label: $, rank: U }, M) => {
502
+ return e("li", { className: "ul-card-rank__option", draggable: !!A || void 0, onDragEnd: A ? fe : void 0, onDragEnter: A ? ce : void 0, onDragLeave: A ? he : void 0, onDragStart: A ? (ae = M, (Y) => {
503
+ d.current = ae, Y.dataTransfer && (Y.dataTransfer.effectAllowed = "move", Y.dataTransfer.setData("text/plain", String(ae)), Y.currentTarget.classList.add("is-dragging"));
504
+ }) : void 0, onDrop: A ? (Z = M, (Y) => {
505
+ var ve, De;
506
+ Y.preventDefault(), Y.currentTarget.classList.remove("is-drop-target");
507
+ const W = d.current;
508
+ d.current = null, (De = (ve = Y.currentTarget.closest(".ul-card-rank__list")) == null ? void 0 : ve.querySelector(".is-dragging")) == null || De.classList.remove("is-dragging"), W != null && W !== Z && x(W, Z);
509
+ }) : void 0, ref: (Y) => h.current[M] = Y, children: [e("select", { "aria-label": `Rank for ${$}`, className: O("ul-card-rank__select", U == null && "ul-card-rank__select--placeholder"), name: `rank[${I}]`, onChange: (Y) => q(I, Y.currentTarget.value), value: U ?? "", children: [U == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), E.map((Y) => e("option", { className: "ul-card-rank__select-option", value: Y, children: Y }, `${Y}-${a}`))] }), e("span", { children: $ }), !T && e("button", { "aria-label": `Drag ${$} to reorder`, className: "ul-card-rank__drag-btn", onTouchEnd: L ? l : void 0, onTouchMove: L ? V : void 0, onTouchStart: L ? K(M) : 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" }) }) })] }, I);
510
+ var Z, ae;
511
+ }) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [z, " - ", j] }) })] }), p && e(xe, { handleSubmit: _, isSubmitDisabled: b })] }), !P && e(ue, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: b, children: ge(r) }) }) })] }) })] }, a);
512
+ }, zr = /* @__PURE__ */ new Set(["aidynamicfollowup", "open", "matrix", "multipleselect", "multiplechoice", "rankorder"]), Ae = ({ cardInstance: t, moveToNextQuestion: s, showIndividualSubmit: o, submitQuestion: n, updateCardValues: r, allResponsesArray: a }) => {
513
+ const { isLongFormSurvey: m, createDynamicQuestion: g, cards: c, surveyVisitorAttributes: p } = G((k) => ({ isLongFormSurvey: se(k.studyType), createDynamicQuestion: k.createDynamicQuestion, cards: k.cards, surveyVisitorAttributes: k.surveyVisitorAttributes }));
514
+ if (!t) return null;
515
+ const { name: d, type: y, props: i, childId: f } = t, u = o && zr.has(y), h = i == null ? void 0 : i.displayLogic, b = h == null ? void 0 : Ue({ displayLogic: h, allResponses: a, cards: c, surveyVisitorAttributes: p ?? {} });
516
+ if (h && h.length > 0 && !b) return null;
517
+ const S = { className: "ul-card", next: (k, E, P = !0) => n(k, E && P), questionId: d, type: y, showIndividualSubmit: o, ...u ? { next: (k, E) => {
518
+ r(k.questionId, k, E ?? !0);
519
+ }, onSubmitButtonClick: (k = !1) => {
520
+ f ? k ? (s(d), g({ parentQuestionId: d })) : s(f) : s(d);
521
+ } } : {} }, C = (() => {
522
+ switch (y) {
523
+ case "consentlegal":
524
+ return e(vr, { ...S, ...i });
525
+ case "likert":
526
+ return e(fr, { ...S, ...i });
527
+ case "matrix":
528
+ return e(Ir, { ...S, ...i });
529
+ case "maxdiff":
530
+ return e(Wr, { ...S, ...i });
531
+ case "multiplechoice":
532
+ return e(_r, { ...S, ...i });
533
+ case "multipleselect":
534
+ return e(Nr, { ...S, ...i });
535
+ case "nps":
536
+ return e(wr, { ...S, ...i });
537
+ case "open":
538
+ case "aidynamicfollowup":
539
+ return e(qr, { ...S, type: t.type, ...i });
540
+ case "rankorder":
541
+ return e(Gr, { ...S, ...i });
542
+ case "recordedtask":
543
+ return e(Er, { ...S, ...i });
544
+ case "texturlprompt":
545
+ return e(Ar, { ...S, ...i });
546
+ case "thanks":
547
+ return e(Or, { ...S, ...i });
548
+ case "uploading":
549
+ return e(Ur, { ...S, ...i });
550
+ default:
551
+ return null;
552
+ }
553
+ })();
554
+ return C ? m ? e("div", { className: "ul-card-scroll-wrapper", children: C }, d) : C : null;
555
+ }, Yr = ({ isSubmitDisabled: t = !1, onSubmit: s, buttonText: o }) => {
556
+ var f;
557
+ const { cards: n, forceBrandedLogo: r, index: a, marketingUrl: m, showSurveyBrand: g, slugName: c, surveyId: p, useMobileStyling: d } = G((u) => ({ cards: u.cards, forceBrandedLogo: u.forceBrandedLogo, index: u.index, marketingUrl: u.marketingUrl, showSurveyBrand: u.showSurveyBrand, slugName: u.slugName, surveyId: u.surveyId, useMobileStyling: u.useMobileStyling })), y = ((f = n[a]) == null ? void 0 : f.type) === "thanks", i = ir({ marketingUrl: m, slugName: c, surveyId: p, forceBrandedLogo: r });
558
+ return e("footer", { className: O("long-form-question-footer-container", d && "long-form-question-footer-container--mobile", y && "long-form-question-footer-container-center"), children: [y && r ? e(sr, { marketingUrlLink: i }) : e("div", { className: "long-form-question-footer-container-logo", children: g ? e(ar, { forceBrandedLogo: r, marketingUrlLink: i }) : null }), !y && 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", t && "sprig-button-disabled"), disabled: t, onClick: s, children: e("span", { className: "long-form-button-text-container", children: o ?? e(lr, { stroke: "white" }) }) }) })] });
559
+ }, et = ({ cards: t, next: s, previousResponses: o }) => {
560
+ var V;
561
+ const n = te(null), [r, a] = J({}), [m, g] = J({}), { isLongFormSurvey: c, focusedQuestionId: p, setFocusedQuestionId: d, createDynamicQuestion: y, allResponses: i, cardIndexByName: f, surveyVisitorAttributes: u, cards: h } = G((l) => ({ isLongFormSurvey: se(l.studyType), focusedQuestionId: l.focusedQuestionId, setFocusedQuestionId: l.setFocusedQuestionId, createDynamicQuestion: l.createDynamicQuestion, allResponses: l.allResponses, cardIndexByName: l.cardIndexByName, surveyVisitorAttributes: l.surveyVisitorAttributes, cards: l.cards })), b = me(() => ({ ...o, ...Fe(t.map((l) => {
562
+ var x, w;
563
+ return { ...l, value: ((x = r[l.name]) == null ? void 0 : x.value) ?? null, secondaryValue: ((w = r[l.name]) == null ? void 0 : w.secondaryValue) ?? null };
564
+ })) }), [o, r, t]);
565
+ or(b);
566
+ const S = dr(t, b), C = me(() => cr({ storeAllResponses: i, cards: t, cardValues: r, cardIndexByName: f }), [i, t, r, f]), k = me(() => {
567
+ const l = /* @__PURE__ */ new Set();
568
+ return t.forEach((x) => {
569
+ var Q;
570
+ const w = (Q = x.props) == null ? void 0 : Q.displayLogic;
571
+ if (!w || w.length === 0) return void l.add(x.name);
572
+ Ue({ displayLogic: w, allResponses: C, cards: h, surveyVisitorAttributes: u ?? {} }) && l.add(x.name);
573
+ }), l;
574
+ }, [t, C, u, h]), E = te(null);
575
+ ne(() => {
576
+ const l = k, x = E.current;
577
+ if (x !== null) for (const w of x) l.has(w) || (a((Q) => {
578
+ const R = { ...Q };
579
+ return delete R[w], R;
580
+ }), g((Q) => {
581
+ const R = { ...Q };
582
+ return delete R[w], R;
583
+ }));
584
+ E.current = new Set(l);
585
+ }, [k]);
586
+ const P = te(null), D = te(!1), F = te(null), v = Te((l) => {
587
+ var R, j;
588
+ D.current = !0;
589
+ const x = t.findIndex((z) => z.name === l);
590
+ if (!c || l === null || x === -1) return void (D.current = !1);
591
+ const w = (R = P.current) == null ? void 0 : R.querySelectorAll(".ul-card-scroll-wrapper")[x], Q = (j = P.current) == null ? void 0 : j.closest(".ul-card-main-content");
592
+ if (w && Q) {
593
+ if (w && Q) {
594
+ const z = w.getBoundingClientRect(), ce = Q.getBoundingClientRect(), he = z.top - ce.top + Q.scrollTop, fe = he + z.height / 2, I = window.innerHeight - 157;
595
+ let $;
596
+ z.height >= I ? $ = he : $ = fe - Q.clientHeight / 2;
597
+ const U = Q.clientHeight, M = Q.scrollHeight - U, Z = Math.max(0, Math.min($, M));
598
+ Q.scrollTo({ top: Z, behavior: "smooth" }), setTimeout(() => {
599
+ D.current = !1;
600
+ }, 500);
601
+ }
602
+ } else D.current = !1;
603
+ }, [c, t]);
604
+ ne(() => {
605
+ p !== null && t.findIndex((l) => l.name === p) !== -1 || d(t[0].name);
606
+ }, [t, p, d]);
607
+ const N = ({ displayCard: l, response: x }) => {
608
+ if (l && ((l == null ? void 0 : l.childId) ?? 0) > 0) {
609
+ const w = Fe([l].map((Q) => ({ ...Q, value: (x == null ? void 0 : x.value) ?? null, secondaryValue: (x == null ? void 0 : x.secondaryValue) ?? null })));
610
+ y({ parentQuestionId: l == null ? void 0 : l.name, parentResponseConfig: w });
611
+ }
612
+ };
613
+ function B(l, x) {
614
+ return l.filter((w) => k.has(w.name)).map((w) => {
615
+ const Q = x[w.name], R = S.find((j) => j.name === w.name);
616
+ return { ...Q, questionText: R ? Be(R) : void 0 };
617
+ });
618
+ }
619
+ const T = (l) => {
620
+ if (!c) return;
621
+ let x = t.findIndex((w) => w.name === l) + 1;
622
+ for (; x < t.length && !k.has(t[x].name); ) x++;
623
+ x < t.length ? d(t[x].name) : d(l);
624
+ };
625
+ ne(() => {
626
+ c && p !== null && (F.current !== p ? v(p) : F.current = null);
627
+ }, [p, c, v]);
628
+ const L = Te(() => {
629
+ var ce, he;
630
+ if (D.current) return;
631
+ const l = (ce = P.current) == null ? void 0 : ce.closest(".ul-card-main-content");
632
+ if (!l) return;
633
+ const x = (he = P.current) == null ? void 0 : he.querySelectorAll(".ul-card-scroll-wrapper");
634
+ if (!x || x.length === 0) return;
635
+ const w = l.getBoundingClientRect(), Q = w.top + w.height / 2;
636
+ let R = 0, j = 1 / 0;
637
+ x.forEach((fe, I) => {
638
+ const $ = fe.getBoundingClientRect(), U = $.top + $.height / 2, M = Math.abs(Q - U);
639
+ M < j && (j = M, R = I);
640
+ });
641
+ const z = t[R];
642
+ F.current = z.name, d(z.name);
643
+ }, [t, d]);
644
+ ne(() => {
645
+ var x;
646
+ if (!c) return;
647
+ const l = ((x = P.current) == null ? void 0 : x.closest(".ul-card__container")) || null;
648
+ return l && l.addEventListener("scroll", L, { passive: !0 }), () => {
649
+ l && l.removeEventListener("scroll", L);
650
+ };
651
+ }, [L, c]);
652
+ const A = me(() => t.every((l) => {
653
+ var x;
654
+ return !k.has(l.name) || !(!(l != null && l.props) || !("properties" in l.props) || ((x = l.props.properties) == null ? void 0 : x.required) !== !1) || m[l.name];
655
+ }), [m, t, k]), X = async (l, x, w) => {
656
+ return g((R) => ({ ...R, [l]: w })), await (Q = (R) => ({ ...R, [l]: x }), new Promise((R) => {
657
+ a((j) => {
658
+ const z = Q(j);
659
+ return R(z), z;
660
+ });
661
+ }));
662
+ var Q;
663
+ };
664
+ ne(() => {
665
+ var Q;
666
+ if (!c) return;
667
+ const l = n.current, x = (Q = t == null ? void 0 : t[0]) == null ? void 0 : Q.groupId;
668
+ n.current = x;
669
+ const w = {};
670
+ if (t.forEach((R) => {
671
+ var j, z;
672
+ br(R) && (R.props.properties.required || (w[R.name] = { value: ((j = r[R.name]) == null ? void 0 : j.value) ?? null, secondaryValue: ((z = r[R.name]) == null ? void 0 : z.secondaryValue) ?? null, questionId: R.name, type: R.type }));
673
+ }), l == null || l !== x) a(w), g({});
674
+ else {
675
+ a((j) => ({ ...j, ...w }));
676
+ const R = t.reduce((j, z) => {
677
+ var ce;
678
+ return z.type === "aidynamicfollowup" && ((ce = z.props) == null ? void 0 : ce.loading) === null && (j[z.name] = !0), j;
679
+ }, {});
680
+ g((j) => ({ ...j, ...R }));
681
+ }
682
+ }, [t, c]);
683
+ const _ = async (l, x) => {
684
+ if (c) {
685
+ const w = await X(l.questionId, l, x), Q = q(l.type), R = H(l.type);
686
+ if (Q && T(l.questionId), R && x) {
687
+ const j = B(t, w);
688
+ s(j);
689
+ }
690
+ } else {
691
+ const w = S.find((R) => R.name === l.questionId), Q = { ...l, questionText: w ? Be(w) : void 0 };
692
+ N({ displayCard: w, response: l }), s([Q]);
693
+ }
694
+ }, q = (l) => (/* @__PURE__ */ new Set(["nps", "likert", "multiplechoice"])).has(l), H = (l) => (/* @__PURE__ */ new Set(["videovoice", "consentlegal", "texturlprompt", "maxdiff"])).has(l), K = ((V = t[0]) == null ? void 0 : V.type) === "thanks";
695
+ return c ? e("div", { className: "ul-card-list-container--longform", "data-testid": "ui-container", ref: P, children: [e(Vr, { value: o, children: S.map((l, x) => e(Ae, { allResponsesArray: C, cardInstance: l, moveToNextQuestion: T, showIndividualSubmit: c && t.length > 1 && x < t.length - 1, submitQuestion: _, updateCardValues: X }, (l == null ? void 0 : l.name) || x)) }), !K && e(Yr, { isSubmitDisabled: !A, onSubmit: function() {
696
+ const l = B(t, r);
697
+ if ((S == null ? void 0 : S.length) === 1 && (l == null ? void 0 : l.length) === 1) {
698
+ const x = S[0], w = l[0];
699
+ N({ displayCard: x, response: w });
700
+ }
701
+ s(l);
702
+ } })] }) : e(be, { children: [e("div", { "data-testid": "ui-container", style: { display: "none" } }), S.map((l, x) => e(Ae, { allResponsesArray: C, cardInstance: l, moveToNextQuestion: T, showIndividualSubmit: c && t.length > 1 && x < t.length - 1, submitQuestion: _, updateCardValues: X }, (l == null ? void 0 : l.name) || x))] });
703
+ };
704
+ export {
705
+ et as PageCard
706
+ };