@sprig-technologies/sprig-browser 2.38.0 → 2.39.0

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