@sprig-technologies/sprig-bundled 2.39.4 → 2.40.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.
- package/dist/conversational-styles-CWNea3pP.js +4 -0
- package/dist/conversational-styles-CzhxRRD3.cjs +1 -0
- package/dist/conversational-ui-B4Gz-ntg.cjs +658 -0
- package/dist/conversational-ui-B_gqybcU.js +1508 -0
- package/dist/getAttributedUrl-BQOt-2c9.js +192 -0
- package/dist/getAttributedUrl-SO6zrj5v.cjs +12 -0
- package/dist/index-B7XdLO9n.cjs +1 -0
- package/dist/{index-CeYVvXTk.cjs → index-C4jT0KTM.cjs} +2 -2
- package/dist/{index-jIcxLvGB.js → index-gY11yXiE.js} +4 -4
- package/dist/index-rqy70x2s.js +670 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{view-3iDgUEdt.js → view-BjWfEnbU.js} +372 -371
- package/dist/view-D-Rk2_yd.cjs +1 -0
- package/package.json +1 -1
- package/dist/conversational-styles-DHBMIjKf.js +0 -4
- package/dist/conversational-styles-DLzzNPKy.cjs +0 -1
- package/dist/conversational-ui-DaZCww9V.js +0 -1487
- package/dist/conversational-ui-Dspqvepc.cjs +0 -658
- package/dist/getAttributedUrl-BA155WXu.js +0 -180
- package/dist/getAttributedUrl-DdKlh4nZ.cjs +0 -12
- package/dist/index-D8vvXMVb.cjs +0 -1
- package/dist/index-DEhUsrDF.js +0 -655
- package/dist/view-BVsOaM5U.cjs +0 -1
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { a as i, c as g, u as C, F, h as D, p as I, _ as P, o as Z, g as $, r as W, e as X } from "./view-3iDgUEdt.js";
|
|
2
|
-
import { j as Q, k as G, A as J, l as Y, E as H } from "./index-jIcxLvGB.js";
|
|
3
|
-
const ee = (e) => i("button", { ...e, className: g("ul-card-text__button", e.className), id: "ul-card-text__button" }), te = ({ html: e, ...l }) => {
|
|
4
|
-
const s = C((o) => o.enableCspTrustedTypes), t = F(() => Q(e, s), [s, e]);
|
|
5
|
-
return i("div", { ...l, dangerouslySetInnerHTML: { __html: t } });
|
|
6
|
-
}, B = () => {
|
|
7
|
-
const { viewDocument: e } = C((t) => ({ viewDocument: t.viewDocument })), [l, s] = D(!1);
|
|
8
|
-
return I(() => {
|
|
9
|
-
const t = e.querySelector(".sprig-question-body"), o = new ResizeObserver(() => {
|
|
10
|
-
window.requestAnimationFrame(() => {
|
|
11
|
-
s(!!(t && G(t) && t.scrollHeight > t.offsetHeight));
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
return t && o.observe(t), () => {
|
|
15
|
-
t && o.disconnect();
|
|
16
|
-
};
|
|
17
|
-
}, [e]), l;
|
|
18
|
-
}, q = ({ plainText: e, richText: l, id: s, className: t, isHeader: o, showAsterisk: r }) => l ? i(te, { className: t, html: l, id: s }) : e ? o ? i("h1", { className: t, id: s, children: [e, r && "*"] }) : i("p", { className: t, id: s, children: e }) : null, oe = () => {
|
|
19
|
-
const { cards: e, close: l, endCard: s, headers: t, index: o } = C((n) => ({ cards: n.cards, close: n.close, endCard: n.endCard, headers: n.headers, index: n.index, useMobileStyling: n.useMobileStyling })), r = e.length, a = F(() => () => l(J), [l]);
|
|
20
|
-
return ["email", "link"].includes(t["userleap-platform"]) || s && o + 1 === r ? null : i("div", { "aria-label": "Close button", className: "close-btn", onClick: a, onKeyPress: (n) => {
|
|
21
|
-
n.key === "Enter" && a();
|
|
22
|
-
}, role: "button", tabIndex: 0, children: i("svg", { fill: "none", height: "16px", viewBox: "0 0 13 13", width: "16px", xmlns: "http://www.w3.org/2000/svg", children: i("path", { d: "M2.54964 1.78369L1.78369 2.54964L5.73405 6.5L1.78369 10.4504L2.54964 11.2163L6.5 7.26595L10.4504 11.2163L11.2163 10.4504L7.26595 6.5L11.2163 2.54964L10.4504 1.78369L6.5 5.73405L2.54964 1.78369Z", fill: "#262136" }) }) });
|
|
23
|
-
}, me = ({ message: e, properties: l, isRequired: s }) => {
|
|
24
|
-
const t = P(null), o = l == null ? void 0 : l.captionText, r = B();
|
|
25
|
-
return i("div", { className: g("question-header-container", "sprig-header-container", r ? "sprig-border-bottom" : null), ref: t, children: [i("div", { className: "question-header-button-container", children: [i(q, { className: "ul-question", id: "ul-question", isHeader: !0, plainText: e, richText: l == null ? void 0 : l.questionHtml, showAsterisk: s }), i(oe, {})] }), i(q, { className: "ul-caption", id: "ul-caption", plainText: o, richText: l == null ? void 0 : l.captionHtml })] });
|
|
26
|
-
}, ne = () => i("svg", { fill: "none", height: "10", viewBox: "0 0 13 10", width: "13", xmlns: "http://www.w3.org/2000/svg", children: i("path", { d: "M11.5 1.5L4.5 8.5L1 5", stroke: "#FFFFFF", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "1.5" }) }), be = ({ isSubmitDisabled: e, handleSubmit: l }) => i("div", { className: "ul-card-longform__submit-button-container", children: i(ee, { className: "ul-card-longform__submit-button", disabled: e, onClick: l, children: ["OK ", i(ne, {})] }) }), U = ({ buttonText: e = "View Prototype", handleClick: l }) => i("button", { className: "prototype-button", onClick: l, children: e }, "prototype-btn"), ge = ({ defaultBody: e, embeddedType: l = "prototype", properties: s }) => {
|
|
27
|
-
var b;
|
|
28
|
-
const { handleClickEmbedButton: t, hasViewedEmbed: o, headers: r, useDesktopPrototype: a } = C((p) => ({ handleClickEmbedButton: p.handleClickEmbedButton, hasViewedEmbed: p.hasViewedEmbed, headers: p.headers, useDesktopPrototype: p.useDesktopPrototype })), n = (s == null ? void 0 : s.conceptUrl) || ((b = s == null ? void 0 : s.consentDocument) == null ? void 0 : b.url), h = window.innerWidth < Y, u = r["userleap-platform"], d = (p, T) => {
|
|
29
|
-
p.preventDefault(), t(T);
|
|
30
|
-
};
|
|
31
|
-
if (!a && h && !o && n && ["email", "link"].includes(u)) {
|
|
32
|
-
if (l === "prototype") return i(U, { handleClick: (p) => {
|
|
33
|
-
d(p, "question.prototype.click");
|
|
34
|
-
} });
|
|
35
|
-
if (l === "pdf") return i(U, { buttonText: (s == null ? void 0 : s.viewDocumentText) || "View Document", handleClick: (p) => {
|
|
36
|
-
d(p, "question.agreement.click");
|
|
37
|
-
} });
|
|
38
|
-
}
|
|
39
|
-
return e();
|
|
40
|
-
}, R = ({ isSelected: e, id: l, divId: s, themeColor: t, disabled: o = !1 }) => i("div", { "aria-checked": e, "aria-disabled": o, "aria-labelledby": `label-${l}`, className: "select-checkbox", id: s, role: "checkbox", style: { ...e ? { backgroundColor: t, borderColor: t, boxShadow: "none" } : {}, ...o ? { opacity: 0.5 } : {} }, tabIndex: o ? -1 : 0, children: e && i(Z, {}) }), le = (e, l) => {
|
|
41
|
-
const s = P(0);
|
|
42
|
-
return () => {
|
|
43
|
-
if (e.current) {
|
|
44
|
-
const t = e.current;
|
|
45
|
-
t.style.height = "1px";
|
|
46
|
-
const o = t.scrollHeight + (t.offsetHeight - t.clientHeight), r = parseInt(window.getComputedStyle(t).getPropertyValue("max-height")), a = o <= r ? o : r;
|
|
47
|
-
s.current !== a && l(), s.current = a, t.style.height = `${a}px`;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}, ve = ({ ariaLabel: e, border: l, choiceStyle: s = {}, label: t, isSelected: o, value: r, text: a, id: n, isRadio: h, useMobileStyling: u, error: d, allowTextEntry: b, noneOfTheAbove: p, promptText: T, disabled: c = !1, onUserInputChanged: w }) => {
|
|
51
|
-
const { styleNonce: y, viewDocument: v } = C((m) => ({ styleNonce: m.styleNonce, viewDocument: m.viewDocument })), [x, k] = D(!1);
|
|
52
|
-
ie(v, l, y);
|
|
53
|
-
const M = ({ isSelected: m, userText: N }) => {
|
|
54
|
-
w && w({ id: n, selected: m, value: r, userText: N, noneOfTheAbove: p });
|
|
55
|
-
}, _ = (m) => {
|
|
56
|
-
c || (m.stopPropagation(), M({ isSelected: h || !o, userText: a }), k(!1));
|
|
57
|
-
}, j = () => {
|
|
58
|
-
x || k(!0);
|
|
59
|
-
}, L = () => {
|
|
60
|
-
x && k(!1);
|
|
61
|
-
}, f = { onClick: (m) => _(m), onKeyPress: (m) => ((N) => {
|
|
62
|
-
c || N.key !== "Enter" && N.key !== " " || _(N);
|
|
63
|
-
})(m) };
|
|
64
|
-
"ontouchstart" in v.documentElement ? (f.onTouchStart = L, f.onTouchCancel = L, f.onTouchEnd = L) : (f.onMouseDown = j, f.onMouseLeave = L);
|
|
65
|
-
const S = h ? `radio-${n}` : `checkbox-${n}`, O = o || x ? [E] : [], K = [...d ? [V] : [], ...O, ...c ? ["ul-choice-disabled"] : []], z = t ? { "aria-labelledby": `label-${n}` } : { "aria-label": e };
|
|
66
|
-
return i("div", { className: g($("choice", u), ...K), id: `choice-div-${n}`, style: { ...s, ...d ? { borderColor: H } : {}, ...c ? { opacity: 0.5, cursor: "not-allowed" } : {} }, ...c ? {} : f, "aria-disabled": c, children: [i("div", { className: g("choice-label-container"), children: [h ? i("div", { ...z, className: g("select-radio", ...O), id: S, role: "radio", tabIndex: 0 }) : i(R, { disabled: c, divId: S, id: n, isSelected: o, themeColor: l }), t && i("label", { className: g($("select-label", u)), htmlFor: S, id: `label-${n}`, children: t })] }), b && o && i("div", { className: g("choice-text-entry-container", ...O), children: i(se, { onTextChange: (m) => M({ isSelected: o, userText: m }), promptText: T || "Please specify", textValue: a, useMobileStyling: u }) })] });
|
|
67
|
-
}, se = ({ promptText: e, textValue: l, onTextChange: s, useMobileStyling: t }) => {
|
|
68
|
-
const o = P(null), { update: r } = C((n) => ({ update: n.update })), a = le(o, () => r());
|
|
69
|
-
return I(() => (a(), o.current && o.current.focus(), () => {
|
|
70
|
-
r();
|
|
71
|
-
}), []), i("textarea", { "aria-label": e, "aria-multiline": "true", "aria-placeholder": e, className: g($("choice-text-input", t)), "data-gramm": "false", maxLength: 5e3, name: "text", onChange: (n) => {
|
|
72
|
-
a(), n.stopPropagation(), s(n.currentTarget.value);
|
|
73
|
-
}, onClick: (n) => {
|
|
74
|
-
n.stopPropagation();
|
|
75
|
-
}, onKeyPress: (n) => {
|
|
76
|
-
n.stopPropagation();
|
|
77
|
-
}, placeholder: e, ref: o, role: "textbox", rows: 1, value: l });
|
|
78
|
-
}, A = "ul-select-style-element", E = "ul-select-active-dynamic-style", V = "ul-select-error-dynamic-style", ie = (e, l, s) => {
|
|
79
|
-
let t = e.getElementById(A), o = !1;
|
|
80
|
-
t || (t = e.createElement("style"), o = !0), t.tagName.toLowerCase() === "style" && (t.id = A, s && (t.nonce = s), t.textContent = ae(l), o && e.head.appendChild(t));
|
|
81
|
-
}, ae = (e) => `
|
|
82
|
-
.${E} {
|
|
83
|
-
border-color: ${e};
|
|
84
|
-
}
|
|
85
|
-
.${E} .select-radio, .${E}.select-radio {
|
|
86
|
-
border: 6px solid ${e};
|
|
87
|
-
box-shadow: none;
|
|
88
|
-
}
|
|
89
|
-
.${V} {
|
|
90
|
-
border-color: ${H};
|
|
91
|
-
}
|
|
92
|
-
`, xe = ({ children: e }) => i("div", { className: "sprig-question-body", children: e }), we = ({ children: e }) => {
|
|
93
|
-
const l = B(), { isConversationalUI: s } = C((t) => ({ isConversationalUI: t.isConversationalUI }));
|
|
94
|
-
return i("div", { className: g("sprig-question-footer-container", l && !s ? "sprig-border-top" : null), children: e });
|
|
95
|
-
};
|
|
96
|
-
var re = ((e) => (e.CONTINUE = "CONTINUE", e.EXTERNAL = "EXTERNAL", e.NO_BUTTON = "NO_BUTTON", e))(re || {}), ce = ((e) => (e.Unlimited = "Unlimited", e.Maximum = "Maximum", e.Range = "Range", e))(ce || {});
|
|
97
|
-
const de = ({ options: e, selectItem: l, selectedOptions: s, showCheckbox: t, disabledOptions: o, dropdownFooter: r }) => {
|
|
98
|
-
const { themeColor: a } = C((n) => ({ doc: n.viewDocument, themeColor: n.border }));
|
|
99
|
-
return i("div", { className: "select-list", children: [e.map((n) => {
|
|
100
|
-
return i("div", { "aria-disabled": o == null ? void 0 : o.includes(n), className: g("select-option", o != null && o.includes(n) ? "ul-choice-disabled" : ""), onClick: (u) => {
|
|
101
|
-
o != null && o.includes(n) || (l(n), u.stopPropagation());
|
|
102
|
-
}, role: "option", style: { ...o != null && o.includes(n) ? { opacity: 0.5, cursor: "not-allowed" } : {} }, children: [t && i(R, { divId: (h = n.id, `checkbox-div-${h}`), id: n.id, isSelected: s.includes(n), themeColor: a }), n.label] }, n.id);
|
|
103
|
-
var h;
|
|
104
|
-
}), r] });
|
|
105
|
-
}, ye = ({ isMultiSelect: e = !1, multiselectText: l = "choices selected", onChange: s, options: t, placeholderText: o, value: r, disabledOptions: a = [], dropdownFooter: n }) => {
|
|
106
|
-
const [h, u] = D(!1), { viewDocument: d, update: b } = C((c) => ({ viewDocument: c.viewDocument, update: c.update })), p = () => {
|
|
107
|
-
u(!h), b();
|
|
108
|
-
};
|
|
109
|
-
I(() => {
|
|
110
|
-
var w;
|
|
111
|
-
const c = (y) => {
|
|
112
|
-
const v = y.target;
|
|
113
|
-
(v == null ? void 0 : v.closest(".select-option.ul-choice-disabled")) || (u(!1), b());
|
|
114
|
-
};
|
|
115
|
-
d.addEventListener("click", c);
|
|
116
|
-
try {
|
|
117
|
-
(w = window.parent) == null || w.addEventListener("click", c);
|
|
118
|
-
} catch {
|
|
119
|
-
window.addEventListener("click", c);
|
|
120
|
-
}
|
|
121
|
-
return () => {
|
|
122
|
-
var y;
|
|
123
|
-
d.removeEventListener("click", c);
|
|
124
|
-
try {
|
|
125
|
-
(y = window.parent) == null || y.removeEventListener("click", c);
|
|
126
|
-
} catch {
|
|
127
|
-
window.removeEventListener("click", c);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
}, [d, b]);
|
|
131
|
-
const T = r.length === 0 ? ["select-button-placeholder"] : [];
|
|
132
|
-
return i(X, { children: [i("button", { "aria-label": "choice dropdown button", className: g("select-button", ...T), onClick: (c) => {
|
|
133
|
-
c.stopPropagation(), p();
|
|
134
|
-
}, type: "button", children: [i("span", { children: r.length === 0 ? o : r.length === 1 ? r[0].label : `${r.length} ${l}` }), i(W, {})] }), h && i(de, { disabledOptions: a, dropdownFooter: n, options: t, selectedOptions: r, selectItem: (c) => {
|
|
135
|
-
var v;
|
|
136
|
-
const w = r.some((x) => x.id === c.id), y = r.some((x) => {
|
|
137
|
-
var k;
|
|
138
|
-
return (k = x.optionProperties) == null ? void 0 : k.noneOfTheAbove;
|
|
139
|
-
});
|
|
140
|
-
(v = c.optionProperties) != null && v.noneOfTheAbove && !w ? s([c]) : e ? s(w ? r.filter((x) => x.id !== c.id) : y ? [c] : [...r, c]) : w || s([c]), e || p();
|
|
141
|
-
}, showCheckbox: e })] });
|
|
142
|
-
}, ue = { "{{user_id}}": "externalUserId", "{{email}}": "email" }, Ce = (e = void 0, l = {}) => {
|
|
143
|
-
if (!e) return e;
|
|
144
|
-
const s = ["http:", "https:", "itms-apps:", "market:"], t = ((a) => /^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//.test(a) ? a : `http://${a}`)(e);
|
|
145
|
-
if (!t) return;
|
|
146
|
-
try {
|
|
147
|
-
const a = new URL(t);
|
|
148
|
-
if (!a.protocol || !s.includes(a.protocol)) return;
|
|
149
|
-
} catch {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
const o = [], r = ((a, n, h) => {
|
|
153
|
-
let u = a;
|
|
154
|
-
for (const [d, b] of Object.entries(ue)) if (u.toLowerCase().includes(d)) if (n[b]) {
|
|
155
|
-
const p = new RegExp(d, "gi");
|
|
156
|
-
u = u.replace(p, n[b]);
|
|
157
|
-
} else h.push(d);
|
|
158
|
-
return u;
|
|
159
|
-
})(t, l, o);
|
|
160
|
-
return o.length === 0 ? r : ((a, n) => {
|
|
161
|
-
if (!a.includes("?")) return a;
|
|
162
|
-
const h = a.slice(0, a.indexOf("?")), u = a.slice(a.indexOf("?") + 1).split("&").map((d) => d.split("=")).filter((d) => !n.includes(d[1]));
|
|
163
|
-
return u.length === 0 ? h : `${h}?${u.map((d) => d.join("=")).join("&")}`;
|
|
164
|
-
})(r, o);
|
|
165
|
-
};
|
|
166
|
-
export {
|
|
167
|
-
ee as B,
|
|
168
|
-
te as H,
|
|
169
|
-
be as L,
|
|
170
|
-
ge as M,
|
|
171
|
-
ve as O,
|
|
172
|
-
re as P,
|
|
173
|
-
we as Q,
|
|
174
|
-
ye as S,
|
|
175
|
-
xe as a,
|
|
176
|
-
ce as b,
|
|
177
|
-
me as c,
|
|
178
|
-
Ce as g,
|
|
179
|
-
le as u
|
|
180
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./view-BVsOaM5U.cjs"),f=require("./index-CeYVvXTk.cjs"),_=t=>e.u("button",{...t,className:e.cc("ul-card-text__button",t.className),id:"ul-card-text__button"}),$=({html:t,...l})=>{const r=e.useConfig(n=>n.enableCspTrustedTypes),o=e.F(()=>f.getHtml(t,r),[r,t]);return e.u("div",{...l,dangerouslySetInnerHTML:{__html:o}})},I=()=>{const{viewDocument:t}=e.useConfig(o=>({viewDocument:o.viewDocument})),[l,r]=e.h(!1);return e.p(()=>{const o=t.querySelector(".sprig-question-body"),n=new ResizeObserver(()=>{window.requestAnimationFrame(()=>{r(!!(o&&f.isHTMLElement(o)&&o.scrollHeight>o.offsetHeight))})});return o&&n.observe(o),()=>{o&&n.disconnect()}},[t]),l},R=({plainText:t,richText:l,id:r,className:o,isHeader:n,showAsterisk:c})=>l?e.u($,{className:o,html:l,id:r}):t?n?e.u("h1",{className:o,id:r,children:[t,c&&"*"]}):e.u("p",{className:o,id:r,children:t}):null,z=()=>{const{cards:t,close:l,endCard:r,headers:o,index:n}=e.useConfig(i=>({cards:i.cards,close:i.close,endCard:i.endCard,headers:i.headers,index:i.index,useMobileStyling:i.useMobileStyling})),c=t.length,s=e.F(()=>()=>l(f.APP_ID),[l]);return["email","link"].includes(o["userleap-platform"])||r&&n+1===c?null:e.u("div",{"aria-label":"Close button",className:"close-btn",onClick:s,onKeyPress:i=>{i.key==="Enter"&&s()},role:"button",tabIndex:0,children:e.u("svg",{fill:"none",height:"16px",viewBox:"0 0 13 13",width:"16px",xmlns:"http://www.w3.org/2000/svg",children:e.u("path",{d:"M2.54964 1.78369L1.78369 2.54964L5.73405 6.5L1.78369 10.4504L2.54964 11.2163L6.5 7.26595L10.4504 11.2163L11.2163 10.4504L7.26595 6.5L11.2163 2.54964L10.4504 1.78369L6.5 5.73405L2.54964 1.78369Z",fill:"#262136"})})})},K=()=>e.u("svg",{fill:"none",height:"10",viewBox:"0 0 13 10",width:"13",xmlns:"http://www.w3.org/2000/svg",children:e.u("path",{d:"M11.5 1.5L4.5 8.5L1 5",stroke:"#FFFFFF",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})}),M=({buttonText:t="View Prototype",handleClick:l})=>e.u("button",{className:"prototype-button",onClick:l,children:t},"prototype-btn"),B=({isSelected:t,id:l,divId:r,themeColor:o,disabled:n=!1})=>e.u("div",{"aria-checked":t,"aria-disabled":n,"aria-labelledby":`label-${l}`,className:"select-checkbox",id:r,role:"checkbox",style:{...t?{backgroundColor:o,borderColor:o,boxShadow:"none"}:{},...n?{opacity:.5}:{}},tabIndex:n?-1:0,children:t&&e.u(e.SvgCheckmark,{})}),A=(t,l)=>{const r=e._(0);return()=>{if(t.current){const o=t.current;o.style.height="1px";const n=o.scrollHeight+(o.offsetHeight-o.clientHeight),c=parseInt(window.getComputedStyle(o).getPropertyValue("max-height")),s=n<=c?n:c;r.current!==s&&l(),r.current=s,o.style.height=`${s}px`}}},W=({promptText:t,textValue:l,onTextChange:r,useMobileStyling:o})=>{const n=e._(null),{update:c}=e.useConfig(i=>({update:i.update})),s=A(n,()=>c());return e.p(()=>(s(),n.current&&n.current.focus(),()=>{c()}),[]),e.u("textarea",{"aria-label":t,"aria-multiline":"true","aria-placeholder":t,className:e.cc(e.getClasses("choice-text-input",o)),"data-gramm":"false",maxLength:5e3,name:"text",onChange:i=>{s(),i.stopPropagation(),r(i.currentTarget.value)},onClick:i=>{i.stopPropagation()},onKeyPress:i=>{i.stopPropagation()},placeholder:t,ref:n,role:"textbox",rows:1,value:l})},P="ul-select-style-element",E="ul-select-active-dynamic-style",q="ul-select-error-dynamic-style",X=(t,l,r)=>{let o=t.getElementById(P),n=!1;o||(o=t.createElement("style"),n=!0),o.tagName.toLowerCase()==="style"&&(o.id=P,r&&(o.nonce=r),o.textContent=Z(l),n&&t.head.appendChild(o))},Z=t=>`
|
|
2
|
-
.${E} {
|
|
3
|
-
border-color: ${t};
|
|
4
|
-
}
|
|
5
|
-
.${E} .select-radio, .${E}.select-radio {
|
|
6
|
-
border: 6px solid ${t};
|
|
7
|
-
box-shadow: none;
|
|
8
|
-
}
|
|
9
|
-
.${q} {
|
|
10
|
-
border-color: ${f.ERROR_BORDER_COLOR};
|
|
11
|
-
}
|
|
12
|
-
`;var H=(t=>(t.CONTINUE="CONTINUE",t.EXTERNAL="EXTERNAL",t.NO_BUTTON="NO_BUTTON",t))(H||{}),F=(t=>(t.Unlimited="Unlimited",t.Maximum="Maximum",t.Range="Range",t))(F||{});const Q=({options:t,selectItem:l,selectedOptions:r,showCheckbox:o,disabledOptions:n,dropdownFooter:c})=>{const{themeColor:s}=e.useConfig(i=>({doc:i.viewDocument,themeColor:i.border}));return e.u("div",{className:"select-list",children:[t.map(i=>{return e.u("div",{"aria-disabled":n==null?void 0:n.includes(i),className:e.cc("select-option",n!=null&&n.includes(i)?"ul-choice-disabled":""),onClick:u=>{n!=null&&n.includes(i)||(l(i),u.stopPropagation())},role:"option",style:{...n!=null&&n.includes(i)?{opacity:.5,cursor:"not-allowed"}:{}},children:[o&&e.u(B,{divId:(p=i.id,`checkbox-div-${p}`),id:i.id,isSelected:r.includes(i),themeColor:s}),i.label]},i.id);var p}),c]})},G={"{{user_id}}":"externalUserId","{{email}}":"email"};exports.Button=_,exports.Header=({message:t,properties:l,isRequired:r})=>{const o=e._(null),n=l==null?void 0:l.captionText,c=I();return e.u("div",{className:e.cc("question-header-container","sprig-header-container",c?"sprig-border-bottom":null),ref:o,children:[e.u("div",{className:"question-header-button-container",children:[e.u(R,{className:"ul-question",id:"ul-question",isHeader:!0,plainText:t,richText:l==null?void 0:l.questionHtml,showAsterisk:r}),e.u(z,{})]}),e.u(R,{className:"ul-caption",id:"ul-caption",plainText:n,richText:l==null?void 0:l.captionHtml})]})},exports.Html=$,exports.LongformSubmitButton=({isSubmitDisabled:t,handleSubmit:l})=>e.u("div",{className:"ul-card-longform__submit-button-container",children:e.u(_,{className:"ul-card-longform__submit-button",disabled:t,onClick:l,children:["OK ",e.u(K,{})]})}),exports.MaxSelectModes=F,exports.MobileEmbedView=({defaultBody:t,embeddedType:l="prototype",properties:r})=>{var b;const{handleClickEmbedButton:o,hasViewedEmbed:n,headers:c,useDesktopPrototype:s}=e.useConfig(h=>({handleClickEmbedButton:h.handleClickEmbedButton,hasViewedEmbed:h.hasViewedEmbed,headers:h.headers,useDesktopPrototype:h.useDesktopPrototype})),i=(r==null?void 0:r.conceptUrl)||((b=r==null?void 0:r.consentDocument)==null?void 0:b.url),p=window.innerWidth<f.EMBED_MOBILE_MAX_WIDTH,u=c["userleap-platform"],d=(h,k)=>{h.preventDefault(),o(k)};if(!s&&p&&!n&&i&&["email","link"].includes(u)){if(l==="prototype")return e.u(M,{handleClick:h=>{d(h,"question.prototype.click")}});if(l==="pdf")return e.u(M,{buttonText:(r==null?void 0:r.viewDocumentText)||"View Document",handleClick:h=>{d(h,"question.agreement.click")}})}return t()},exports.Option=({ariaLabel:t,border:l,choiceStyle:r={},label:o,isSelected:n,value:c,text:s,id:i,isRadio:p,useMobileStyling:u,error:d,allowTextEntry:b,noneOfTheAbove:h,promptText:k,disabled:a=!1,onUserInputChanged:x})=>{const{styleNonce:w,viewDocument:g}=e.useConfig(m=>({styleNonce:m.styleNonce,viewDocument:m.viewDocument})),[v,y]=e.h(!1);X(g,l,w);const S=({isSelected:m,userText:T})=>{x&&x({id:i,selected:m,value:c,userText:T,noneOfTheAbove:h})},D=m=>{a||(m.stopPropagation(),S({isSelected:p||!n,userText:s}),y(!1))},U=()=>{v||y(!0)},N=()=>{v&&y(!1)},C={onClick:m=>D(m),onKeyPress:m=>(T=>{a||T.key!=="Enter"&&T.key!==" "||D(T)})(m)};"ontouchstart"in g.documentElement?(C.onTouchStart=N,C.onTouchCancel=N,C.onTouchEnd=N):(C.onMouseDown=U,C.onMouseLeave=N);const L=p?`radio-${i}`:`checkbox-${i}`,O=n||v?[E]:[],V=[...d?[q]:[],...O,...a?["ul-choice-disabled"]:[]],j=o?{"aria-labelledby":`label-${i}`}:{"aria-label":t};return e.u("div",{className:e.cc(e.getClasses("choice",u),...V),id:`choice-div-${i}`,style:{...r,...d?{borderColor:f.ERROR_BORDER_COLOR}:{},...a?{opacity:.5,cursor:"not-allowed"}:{}},...a?{}:C,"aria-disabled":a,children:[e.u("div",{className:e.cc("choice-label-container"),children:[p?e.u("div",{...j,className:e.cc("select-radio",...O),id:L,role:"radio",tabIndex:0}):e.u(B,{disabled:a,divId:L,id:i,isSelected:n,themeColor:l}),o&&e.u("label",{className:e.cc(e.getClasses("select-label",u)),htmlFor:L,id:`label-${i}`,children:o})]}),b&&n&&e.u("div",{className:e.cc("choice-text-entry-container",...O),children:e.u(W,{onTextChange:m=>S({isSelected:n,userText:m}),promptText:k||"Please specify",textValue:s,useMobileStyling:u})})]})},exports.PromptActionTypeEnum=H,exports.QuestionBodyFooterContainer=({children:t})=>{const l=I(),{isConversationalUI:r}=e.useConfig(o=>({isConversationalUI:o.isConversationalUI}));return e.u("div",{className:e.cc("sprig-question-footer-container",l&&!r?"sprig-border-top":null),children:t})},exports.QuestionBodyWrapper=({children:t})=>e.u("div",{className:"sprig-question-body",children:t}),exports.Select=({isMultiSelect:t=!1,multiselectText:l="choices selected",onChange:r,options:o,placeholderText:n,value:c,disabledOptions:s=[],dropdownFooter:i})=>{const[p,u]=e.h(!1),{viewDocument:d,update:b}=e.useConfig(a=>({viewDocument:a.viewDocument,update:a.update})),h=()=>{u(!p),b()};e.p(()=>{var x;const a=w=>{const g=w.target;(g==null?void 0:g.closest(".select-option.ul-choice-disabled"))||(u(!1),b())};d.addEventListener("click",a);try{(x=window.parent)==null||x.addEventListener("click",a)}catch{window.addEventListener("click",a)}return()=>{var w;d.removeEventListener("click",a);try{(w=window.parent)==null||w.removeEventListener("click",a)}catch{window.removeEventListener("click",a)}}},[d,b]);const k=c.length===0?["select-button-placeholder"]:[];return e.u(e.g,{children:[e.u("button",{"aria-label":"choice dropdown button",className:e.cc("select-button",...k),onClick:a=>{a.stopPropagation(),h()},type:"button",children:[e.u("span",{children:c.length===0?n:c.length===1?c[0].label:`${c.length} ${l}`}),e.u(e.SvgCaret,{})]}),p&&e.u(Q,{disabledOptions:s,dropdownFooter:i,options:o,selectedOptions:c,selectItem:a=>{var g;const x=c.some(v=>v.id===a.id),w=c.some(v=>{var y;return(y=v.optionProperties)==null?void 0:y.noneOfTheAbove});(g=a.optionProperties)!=null&&g.noneOfTheAbove&&!x?r([a]):t?r(x?c.filter(v=>v.id!==a.id):w?[a]:[...c,a]):x||r([a]),t||h()},showCheckbox:t})]})},exports.getAttributedUrl=(t=void 0,l={})=>{if(!t)return t;const r=["http:","https:","itms-apps:","market:"],o=(s=>/^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//.test(s)?s:`http://${s}`)(t);if(!o)return;try{const s=new URL(o);if(!s.protocol||!r.includes(s.protocol))return}catch{return}const n=[],c=((s,i,p)=>{let u=s;for(const[d,b]of Object.entries(G))if(u.toLowerCase().includes(d))if(i[b]){const h=new RegExp(d,"gi");u=u.replace(h,i[b])}else p.push(d);return u})(o,l,n);return n.length===0?c:((s,i)=>{if(!s.includes("?"))return s;const p=s.slice(0,s.indexOf("?")),u=s.slice(s.indexOf("?")+1).split("&").map(d=>d.split("=")).filter(d=>!i.includes(d[1]));return u.length===0?p:`${p}?${u.map(d=>d.join("=")).join("&")}`})(c,n)},exports.useAutoSize=A;
|
package/dist/index-D8vvXMVb.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./view-BVsOaM5U.cjs"),j=require("./index-CeYVvXTk.cjs"),h=require("./getAttributedUrl-DdKlh4nZ.cjs"),Le=({className:n,message:i,next:u,properties:t,questionId:r,type:l})=>{const{useMobileStyling:b,border:f,isLongFormSurvey:d,focusedQuestionId:v}=e.useConfig(g=>({useMobileStyling:g.useMobileStyling,border:g.border,isLongFormSurvey:j.isLongFormSurvey(g.studyType),focusedQuestionId:g.focusedQuestionId})),[o,p]=e.h(!1),[c,y]=e.h(""),[a,m]=e.h(!1),x=d&&v===r,M=t==null?void 0:t.collectName,N=(t==null?void 0:t.nameLabelText)||"Full Name",R=(t==null?void 0:t.consentText)||"I agree to the stated conditions",B=(t==null?void 0:t.submitButtonText)||"Submit",T=!!c.trim(),D=o&&(!M||T),q=(g,S=!1)=>{g.preventDefault(),g.stopPropagation();let w=null;if(!S){if(!D)return void m(!0);w={submitted:!0},M&&(w.name=c)}u({value:w,questionId:r,type:l},D)},k=g=>{g.preventDefault(),g.stopPropagation(),y(g.currentTarget.value)},_=g=>{g.currentTarget.style.borderColor=a&&!T?j.ERROR_BORDER_COLOR:f},E=g=>{g.currentTarget.style.borderColor=a&&!T?j.ERROR_BORDER_COLOR:j.DEFAULT_BORDER_COLOR},s=()=>e.u(h.QuestionBodyFooterContainer,{children:[e.u("div",{className:"sprig-stretch",children:[e.u(h.Option,{allowTextEntry:!1,border:f,error:a&&!o,id:"consent",isRadio:!1,isSelected:o,label:R,onUserInputChanged:({selected:g})=>{g!==o&&p(!o)},useMobileStyling:b}),M&&e.u("input",{"aria-label":N,"aria-placeholder":N,className:e.cc(e.getClasses("ul-consent-legal__name-input",b)),"data-gramm":"false",maxLength:250,name:"name",onBlur:E,onFocus:_,onInput:k,placeholder:N,style:a&&!T?{borderColor:j.ERROR_BORDER_COLOR}:{},tabIndex:0,value:c})]}),e.u("div",{className:"ul-card__button-wrapper ul-card-vertical__button-wrapper",children:[e.u(h.Button,{className:D?"":"sprig-button-disabled",onClick:q,children:B}),t.required===!1&&!d&&e.u("button",{className:"ul-card-skip__button",onClick:g=>q(g,!0),children:e.getSkipButtonText(t)})]})]});return e.u("div",{className:e.cc(n,d&&!x&&"ul-card--unfocused","ul-card__consent-legal","fade-in-transition"),children:[e.u(h.Header,{isRequired:d&&(t==null?void 0:t.required),message:i,properties:{questionHtml:t.questionHtml}}),e.u(e.g,{children:[t!=null&&t.richTextBody?e.u(h.QuestionBodyWrapper,{children:e.u(h.Html,{className:"ul-rich-text-body",html:t.richTextBody,id:"ul-card__consent-legal-body-container"})}):null,e.u(h.MobileEmbedView,{properties:t,defaultBody:s,embeddedType:"pdf"})]})]},r)},qe=({activeValue:n,border:i,icon:u,isPressed:t,onSubmit:r,range:l,scaleLabelType:b,selectedValue:f,setSelectedValue:d,setActiveValue:v,setIsPressed:o,useMobileStyling:p,value:c,viewDocument:y})=>{const{isLongFormSurvey:a,enableCspTrustedTypes:m}=e.useConfig(_=>({isLongFormSurvey:j.isLongFormSurvey(_.studyType),enableCspTrustedTypes:_.enableCspTrustedTypes})),x=`option-${c}`,M=b==="number",N=b==="star",R=b==="smiley",B=M&&c===n||c===f,[T,D]=(()=>{const _=N&&f!==null&&c<=f;return N&&c<=n||R&&c===n||_||c===n||c===f?[i,t||_||c===f?1:.3]:["",1]})(),q=e.F(()=>{const _={borderColor:B?T:"",fillOpacity:B?"":D,zIndex:B?3:"auto",color:f===c?"#fff":""};return M?{..._,backgroundColor:f===c?T:""}:{..._,color:N||R||f===c?T:""}},[B,T,D,f,c,M,N,R]),k=e.F(()=>j.getHtml((({icon:_,scaleLabelType:E,value:s,selectedValue:g})=>{if(E==="smiley"&&s===g){let S=0;return _.replace(/black/g,()=>++S==1?"black":"white")}return _})({icon:u,scaleLabelType:b,value:c,selectedValue:f}),m),[m,u,b,f,c]);return e.u("button",{"aria-label":M?void 0:String(c),className:(()=>{switch(b){case"star":return e.cc(e.getClasses("likert-star",p),e.getClasses(`likert-star-${c}`,p));case"smiley":return e.cc(e.getClasses("likert-smiley",p),e.getClasses(`likert-smiley-${c}`,p));default:return c===l?e.cc(e.getClasses("likert-number",p),e.getClasses(`likert-number-${c}`,p),e.getClasses("likert-last-option",p)):e.cc(e.getClasses("likert-number",p),e.getClasses(`likert-number-${c}`,p))}})(),dangerouslySetInnerHTML:{__html:k},id:x,onClick:_=>{a&&(_.preventDefault(),_.stopPropagation(),d(c)),r()},onKeyDown:_=>{var g,S;const E=y.querySelectorAll(`.likert-${b??"number"}`),s=c-1;_.key==="ArrowRight"?(g=E[s+1])==null||g.focus():_.key==="ArrowLeft"?(S=E[s-1])==null||S.focus():_.key!=="Enter"&&_.key!==" "||(a&&(_.preventDefault(),_.stopPropagation(),d(c)),r())},onPointerDown:()=>o(!0),onPointerEnter:()=>v(c),onPointerLeave:()=>{v(-1),o(!1)},style:q,tabIndex:0})},Be=({className:n,labels:i,message:u,next:t,properties:r,questionId:l,type:b})=>{const{border:f,useMobileStyling:d,viewDocument:v,isLongFormSurvey:o,focusedQuestionId:p}=e.useConfig(S=>({border:S.border,useMobileStyling:S.useMobileStyling,viewDocument:S.viewDocument,isLongFormSurvey:j.isLongFormSurvey(S.studyType),focusedQuestionId:S.focusedQuestionId})),[c,y]=e.h(-1),[a,m]=e.h(!1),[x,M]=e.h(null),N=o&&p===l,R=i&&i.left,B=i&&i.right;let T;const{range:D,scaleLabelType:q,ratingIcons:k}=r;D&&(T=Number(D));const _=T||5,E=S=>{var w,F;switch(q){case"star":return(w=k[0])==null?void 0:w.svg;case"smiley":return(F=k[S])==null?void 0:F.svg;default:return String(S+1)}},s=[...Array(_)].map((S,w)=>{const F=w+1;return e.u(qe,{activeValue:c,border:f,icon:E(w),isPressed:a,onSubmit:()=>t({value:F,questionId:l,type:b},!0),range:_,scaleLabelType:q,selectedValue:x,setActiveValue:y,setIsPressed:m,setSelectedValue:M,useMobileStyling:d,value:F,viewDocument:v},w)}),g=S=>{S.preventDefault(),S.stopPropagation(),t({value:null,questionId:l,type:b},!0)};return e.u("form",{className:e.cc(n,"ul-card--likert","fade-in-transition",o&&!N&&"ul-card--unfocused"),children:[e.u(h.Header,{isRequired:o&&(r==null?void 0:r.required),message:u,properties:r}),e.u(h.MobileEmbedView,{properties:r,defaultBody:()=>e.u(e.g,{children:[e.u(h.QuestionBodyWrapper,{children:[e.u("div",{"aria-label":`Rating (1 - ${_})`,className:"ul-card--likert__numbers",role:"radiogroup",children:s}),e.u("div",{className:"ul-card--likert__labels",children:[e.u("span",{children:R}),e.u("span",{children:B})]})]}),!r.required&&!o&&e.u(h.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-vertical-centered-container",children:e.u(h.Button,{onClick:g,children:e.getButtonText(r)})})})]})})]},l)},be=n=>n&&(n.scrollHeight>n.offsetHeight?n:be(n.parentElement)),Me=n=>{if(!n||!(u=>u instanceof HTMLElement)(n))return 0;const i=getComputedStyle(n);return parseFloat(i.marginTop)+parseFloat(i.marginBottom)+(parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth))},Re=({columns:n,onSelect:i,options:u,selectedOptions:t})=>{const r=e._([]),{border:l,useMobileStyling:b}=e.useConfig(c=>({border:c.border,useMobileStyling:c.useMobileStyling})),f=u.findIndex(c=>t[c.id]===null),[d,v]=e.h(f),o=e.T((c,y)=>{i(c,y);const a=d+1,m=u[a];if(m&&t[m.id]===null){v(a);const x=r.current[d];if(x!=null&&x.firstElementChild){const M=be(x),N=x.firstElementChild,R=Me(x)+N.clientHeight;M==null||M.scrollTo(0,x.offsetTop+R)}}},[i,u,t,d]),p=e.T((c,y)=>{const a=d===c;return e.u(e.Accordion,{animate:!0,header:y.label,isOpen:a,onClick:()=>{var m;return v(a&&!((m=window.UserLeap)!=null&&m.isMobileSDK)?-1:c)},ref:m=>{m&&(r.current[c]=m)},showHeaderCheck:t[y.id]!==null,children:e.u("div",{style:{paddingTop:"12px"},children:n.map(m=>e.u(h.Option,{allowTextEntry:!1,ariaLabel:`${y.label}-${m.label}`,border:l,error:!1,id:`${y.id}-${m.value}`,isRadio:!0,isSelected:t[y.id]===m.value,label:m.label,onUserInputChanged:()=>o(y.id,m.value),useMobileStyling:b},m.label))})},y.id)},[l,n,d,o,t,b]);return e.u("div",{children:u.map((c,y)=>p(y,c))})},Pe=({columns:n,onSelect:i,options:u,selectedOptions:t})=>{const{border:r,useMobileStyling:l,isLongFormSurvey:b}=e.useConfig(a=>({border:a.border,useMobileStyling:a.useMobileStyling,isLongFormSurvey:j.isLongFormSurvey(a.studyType)})),f=u.length,d=n.length,v=e._(null),[o,p]=e.h(!1),[c,y]=e.h(!1);return e.p(()=>{const a=v.current,m=new ResizeObserver(x=>{window.requestAnimationFrame(()=>{a&&(p(Math.round(x[0].contentRect.width)<a.scrollWidth),y(Math.round(x[0].contentRect.width)<a.scrollWidth))})});return a&&m.observe(a),()=>{a&&m.unobserve(a)}},[]),e.u("div",{className:"ul-card--matrix_question_container",children:[e.u("div",{className:e.cc("ul-card--matrix_container",o&&"ul-matrix-scroll-gradient"),onScroll:()=>{(()=>{const a=v.current;a&&p(a.clientWidth+Math.abs(a.scrollLeft)<a.scrollWidth)})()},ref:v,children:e.u("div",{className:e.cc(b&&"ul-card--matrix_grid_longform","ul-card--matrix_grid"),style:`--numColumns: ${d}; --numRows: ${f+1};`,children:[e.u("div",{})," ",n.map(a=>e.u("div",{className:"ul-matrix-column-label",children:a.label},a.label)),u.map(a=>e.u(e.g,{children:[e.u("div",{"aria-label":a.label,className:"ul-matrix-row-label",children:a.label},a.label),e.u("div",{className:"ul-matrix-row-options",role:"radiogroup",children:n.map((m,x)=>{const M=x===d-1;return e.u("div",{className:e.cc("ul-matrix-option-wrapper",M&&"ul-matrix-last-option"),children:e.u(h.Option,{allowTextEntry:!1,ariaLabel:`${a.label}-${m.label}`,border:r,choiceStyle:{background:"transparent",border:"none",marginBottom:"0",padding:"0"},error:!1,id:`${a.id}-${m.value}`,isRadio:!0,isSelected:t[a.id]===m.value,onUserInputChanged:()=>i(a.id,m.value),useMobileStyling:l})},m.value)})})]}))]})}),(o||c)&&e.u("button",{className:c&&!o?"ul-matrix-scroll-arrow left":"ul-matrix-scroll-arrow",onClick:c&&!o?a=>{a.preventDefault();const m=v.current;if(m){const x=getComputedStyle(m).direction==="rtl";m.scrollTo({left:x?m.scrollWidth-m.clientWidth:0,behavior:"smooth"})}}:a=>{a.preventDefault();const m=v.current;if(m){const x=getComputedStyle(m).direction==="rtl";m.scrollTo({left:x?m.clientWidth-m.scrollWidth:m.scrollWidth,behavior:"smooth"})}},children:c&&!o?e.u(Fe,{}):e.u(De,{})})]})},Fe=()=>e.u("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.u("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"})}),De=()=>e.u("svg",{fill:"currentColor",height:"32",viewBox:"0 0 256 256",width:"32",xmlns:"http://www.w3.org/2000/svg",children:e.u("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"})}),Ee=({className:n,message:i,next:u,options:t,properties:r,questionId:l,type:b,showIndividualSubmit:f=!1,onSubmitButtonClick:d})=>{const{useMobileStyling:v,isLongFormSurvey:o,focusedQuestionId:p,setFocusedQuestionId:c}=e.useConfig(q=>({useMobileStyling:q.useMobileStyling,isLongFormSurvey:j.isLongFormSurvey(q.studyType),focusedQuestionId:q.focusedQuestionId,setFocusedQuestionId:q.setFocusedQuestionId})),y=r.matrixColumn,a=r.required,m=o&&p===l,x=q=>{q.preventDefault(),q.stopPropagation(),u({value:N,questionId:l,type:b},!0),d&&d()},M=t.reduce((q,k)=>(q[k.id]=null,q),{}),[N,R]=e.h(M),B=q=>a&&Object.values(q).every(k=>k==null),T=(q,k)=>{o&&u({value:{...N,[q]:k},questionId:l,type:b},!B({...N,[q]:k})),R(_=>({..._,[q]:k}))},D=r.displayMatrixAsAccordion||v;return e.u("form",{className:e.cc(n,!o&&"ul-card__matrix","fade-in-transition",o&&!m&&"ul-card--unfocused"),id:"text-form",onClick:()=>{m&&c(l)},onSubmit:x,children:[e.u(h.Header,{message:i,properties:r,isRequired:o&&(r==null?void 0:r.required)}),e.u(h.MobileEmbedView,{properties:r,defaultBody:()=>e.u(e.g,{children:[e.u(h.QuestionBodyWrapper,{children:[D?e.u(Re,{columns:y,onSelect:T,options:t,selectedOptions:N}):e.u(Pe,{columns:y,onSelect:T,options:t,selectedOptions:N}),f&&e.u(h.LongformSubmitButton,{handleSubmit:x,isSubmitDisabled:B(N)})]}),!o&&e.u(h.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-card__button-wrapper",children:e.u(h.Button,{disabled:B(N),children:e.getButtonText(r)})})})]})})]},l)},ve=({className:n,message:i,onSubmit:u,options:t=[],properties:r,questionId:l,type:b,showIndividualSubmit:f=!1,onSubmitButtonClick:d})=>{const{border:v,useMobileStyling:o,isLongFormSurvey:p,focusedQuestionId:c,setFocusedQuestionId:y}=e.useConfig(C=>({border:C.border,useMobileStyling:C.useMobileStyling,isLongFormSurvey:j.isLongFormSurvey(C.studyType),focusedQuestionId:C.focusedQuestionId,setFocusedQuestionId:C.setFocusedQuestionId})),a=p&&c===l,m=t.reduce((C,L)=>(C[L.id]={isSelected:!1},C),{}),[x,M]=e.h(m),N=b==="multiplechoice",R=r.required,B=t.find(C=>{var L;return(L=C.optionProperties)==null?void 0:L.noneOfTheAbove}),T=C=>Object.entries(C).some(([L,Q])=>{var Z;const V=t.find(z=>`${z.id}`===L),$=Q.userText===void 0||Q.userText.trim()==="";return((Z=V==null?void 0:V.optionProperties)==null?void 0:Z.allowsTextEntry)&&$&&Q.isSelected}),D=C=>Object.values(C).filter(L=>L.isSelected).length,q=r.minSelect&&r.minSelect>0&&r.maxSelectMode===h.MaxSelectModes.Range&&D(x)<r.minSelect&&(R||D(x)>0),k=C=>T(C)||R&&!D(C)||!(L=>{const{minSelect:Q=0,maxSelect:V=1/0,maxSelectMode:$}=r,Z=D(L);switch($){case h.MaxSelectModes.Maximum:return Z<=V;case h.MaxSelectModes.Range:return Z===0||Z>=Q;default:return!0}})(C),_=Object.entries(x).some(([C,L])=>{var Q,V;return L.isSelected&&((V=(Q=t.find($=>`${$.id}`===C))==null?void 0:Q.optionProperties)==null?void 0:V.allowsTextEntry)}),E=f&&(!N||_),s=C=>{F(C.id,C.selected,C.userText,C.noneOfTheAbove),C.selected&&p&&!N&&!a&&y(l)},g=C=>{var L;return(r==null?void 0:r.maxSelectMode)!==h.MaxSelectModes.Unlimited&&D(x)===(r==null?void 0:r.maxSelect)&&!((L=x[C])!=null&&L.isSelected)},S=t.map(({id:C,label:L,value:Q,optionProperties:V})=>{var Y,X;const $=`${C}`,{allowsTextEntry:Z,noneOfTheAbove:z}={allowsTextEntry:!1,noneOfTheAbove:!1,...V};return e.u(h.Option,{allowTextEntry:Z,border:v,disabled:g($),error:(G=x,T(G)),id:$,isRadio:N,isSelected:!!((Y=x[$])!=null&&Y.isSelected),label:L,noneOfTheAbove:z,onUserInputChanged:s,promptText:"Please specify",text:(X=x[C])==null?void 0:X.userText,useMobileStyling:o,value:Q},$);var G}),w=C=>{C.preventDefault(),C.stopPropagation(),u(x,!0),d&&d()},F=(C,L,Q,V)=>{const $=Object.assign({},x);if((N||V)&&L)for(const G of Object.values($))G.isSelected=!1,delete G.userText;else B&&!V&&x[B.id].isSelected&&($[B.id].isSelected=!1);$[C]={isSelected:L,userText:Q};const Z=N&&Object.entries($).some(([G,Y])=>{var X,te;return Y.isSelected&&((te=(X=t.find(re=>`${re.id}`===G))==null?void 0:X.optionProperties)==null?void 0:te.allowsTextEntry)}),z=!k($);p&&(u($,z),N&&!Z&&z&&d&&d()),M($)};return e.u("form",{className:e.cc(n,"ul-card--multiple","fade-in-transition",p&&!a&&"ul-card--unfocused"),id:"text-form",onClick:b==="multipleselect"?()=>{p&&c!==l&&b==="multipleselect"&&y(l)}:void 0,onSubmit:w,children:[e.u(h.Header,{isRequired:p&&(r==null?void 0:r.required),message:i,properties:r}),e.u(h.MobileEmbedView,{properties:r,defaultBody:()=>e.u(e.g,{children:[e.u(h.QuestionBodyWrapper,{children:[r.isDropdown?e.u(h.Select,{disabledOptions:t.filter(C=>g(C.id)),dropdownFooter:q?e.u("div",{className:"ul-card__min-select-counter",style:{marginLeft:"16px"},children:[D(x),"/",r.minSelect]}):void 0,isMultiSelect:!N,multiselectText:r.dropdownMultiselectedText??"choices selected",onChange:C=>{const L={...x};for(const Q of t)C.includes(Q)?L[Q.id].isSelected=!0:L[Q.id].isSelected=!1;p&&u(L,!k(L)),M(L)},options:t,placeholderText:r.dropdownPlaceholderText??(N?"Select choice":"Select choice(s)"),value:t.filter(C=>x[C.id].isSelected)}):e.u("div",{className:e.cc(e.getClasses("ul-card__choices",o)),role:N?"radiogroup":"group",children:[S,!!q&&e.u("div",{className:"ul-card__min-select-counter",children:[D(x),"/",r.minSelect]})]}),E&&e.u(h.LongformSubmitButton,{handleSubmit:w,isSubmitDisabled:k(x)})]}),!p&&e.u(h.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-card__button-wrapper",children:e.u(h.Button,{disabled:k(x),onClick:w,children:e.getButtonText(r)})})})]})})]},l)},Qe=n=>{const{questionId:i,type:u,next:t,options:r}=n,{setFocusedQuestionId:l}=e.useConfig(b=>({setFocusedQuestionId:b.setFocusedQuestionId}));return e.u(ve,{...n,onSubmit:(b,f)=>{var y;const d=Object.entries(b).find(([,a])=>a.isSelected)||[void 0,void 0],[v,o]=d,p=r.find(a=>`${a.id}`===v);!((y=p==null?void 0:p.optionProperties)!=null&&y.allowsTextEntry)||o!=null&&o.userText&&o.userText.trim()!==""||l(i);const c=o!=null&&o.userText?{[v]:{userText:o.userText}}:null;t({value:p&&v?{[v]:p.value}:{},secondaryValue:c,questionId:i,type:u},f)}})},Oe=n=>{const{questionId:i,type:u,next:t}=n;return e.u(ve,{...n,onSubmit:(r,l)=>{const b=Object.entries(r).reduce((d,[v,o])=>(d[v]=o.isSelected,d),{}),f=Object.entries(r).reduce((d,[v,o])=>{if(!o.userText)return d;const p=d||{};return p[v]={userText:o.userText},p},null);t({value:b,secondaryValue:f,questionId:i,type:u},l)}})},He=({className:n,labels:i,message:u,properties:t,next:r,questionId:l,type:b})=>{const[f,d]=e.h(null),{border:v,useMobileStyling:o,viewDocument:p,isLongFormSurvey:c,focusedQuestionId:y}=e.useConfig(R=>({border:R.border,useMobileStyling:R.useMobileStyling,viewDocument:R.viewDocument,isLongFormSurvey:j.isLongFormSurvey(R.studyType),focusedQuestionId:R.focusedQuestionId})),a=c&&y===l,m=i&&i.left,x=i&&i.right,M=[...Array(11)].map((R,B)=>e.u("button",{className:e.cc(e.getClasses("nps-number",o),e.getClasses(`nps-number-${B}`,o)),id:`option-${B}`,onClick:T=>{c&&(T.preventDefault(),T.stopPropagation(),d(B)),r({value:B,questionId:l,type:b},!0)},onKeyDown:T=>{var q,k;const D=p.querySelectorAll("button.nps-number");T.key==="ArrowRight"?(q=D[B+1])==null||q.focus():T.key==="ArrowLeft"?(k=D[B-1])==null||k.focus():T.key!=="Enter"&&T.key!==" "||(c&&(T.preventDefault(),T.stopPropagation(),d(B)),r({value:B,questionId:l,type:b},!0))},onPointerDown:T=>{T.currentTarget.style.zIndex="2",T.currentTarget.style.borderColor=v},onPointerLeave:T=>{T.currentTarget.style.zIndex="auto",T.currentTarget.style.borderColor=j.DEFAULT_BORDER_COLOR},style:f===B?{backgroundColor:v,color:"#fff"}:void 0,tabIndex:0,children:B},B)),N=R=>{R.preventDefault(),R.stopPropagation(),r({value:null,questionId:l,type:b},!0)};return e.u("form",{className:e.cc(n,"ul-card--nps","fade-in-transition",c&&!a&&"ul-card--unfocused"),children:[e.u(h.Header,{isRequired:c&&(t==null?void 0:t.required),message:u,properties:t}),e.u(h.MobileEmbedView,{properties:t,defaultBody:()=>e.u(e.g,{children:[e.u(h.QuestionBodyWrapper,{children:[e.u("div",{className:"ul-card--nps__numbers",children:M}),e.u("div",{className:"ul-card--nps__labels",children:[e.u("span",{children:m}),e.u("span",{children:x})]})]}),!t.required&&!c&&e.u(h.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-vertical-centered-container",children:e.u(h.Button,{onClick:N,children:e.getButtonText(t)})})})]})})]},l)},$e=({className:n,message:i,next:u,properties:t,questionId:r,type:l,showIndividualSubmit:b=!1,onSubmitButtonClick:f})=>{const{border:d,useMobileStyling:v,update:o,isLongFormSurvey:p,focusedQuestionId:c,setFocusedQuestionId:y,isPreview:a}=e.useConfig(s=>({border:s.border,useMobileStyling:s.useMobileStyling,update:s.update,isLongFormSurvey:j.isLongFormSurvey(s.studyType),focusedQuestionId:s.focusedQuestionId,setFocusedQuestionId:s.setFocusedQuestionId,isPreview:s.isPreview})),[m,x]=e.h(""),M=e._(null),N=p&&c===r;e.p(()=>{var s,g;p&&!a&&(N?(s=M.current)==null||s.focus():(g=M.current)==null||g.blur())},[p,N,a]);const R=m.trim(),B=t.required===!0&&!R,T=h.useAutoSize(M,()=>o()),D=s=>{const{value:g}=s.currentTarget;if(T(),s.preventDefault(),s.stopPropagation(),x(g),p){const S=g.trim().length>0;u({value:g,questionId:r,type:l},S)}},q=s=>{s.preventDefault(),s.stopPropagation(),u({value:m,questionId:r,type:l},!t.required||R.length>0),f&&f()},k=t&&t.openTextPlaceholder?t.openTextPlaceholder:"",_=s=>{s.currentTarget.style.borderColor=d,y(r)},E=s=>{s.currentTarget.style.borderColor=j.DEFAULT_BORDER_COLOR};return e.u("form",{className:e.cc(n,"ul-card-text","fade-in-transition",p&&!N&&"ul-card--unfocused"),id:"text-form",onClick:()=>{p&&c!==r&&y(r)},children:[e.u(h.Header,{isRequired:p&&(t==null?void 0:t.required),message:i,properties:t}),e.u(h.MobileEmbedView,{defaultBody:()=>e.u("div",{className:"ul-card-text",children:e.u(h.QuestionBodyWrapper,{children:[e.u("div",{className:"ul-card-text__container",children:e.u("textarea",{"aria-describedby":"ul-caption","aria-labelledby":"ul-question","aria-multiline":"true","aria-placeholder":k,className:e.cc(e.getClasses("ul-card-text__input",v)),"data-gramm":"false",maxLength:5e3,name:"text",onBlur:E,onChange:D,onFocus:_,placeholder:k,ref:M,role:"textbox",tabIndex:0})}),t.footerHtml&&e.u(h.Html,{className:"footer",html:t.footerHtml}),b&&e.u(h.LongformSubmitButton,{handleSubmit:q,isSubmitDisabled:B}),e.u(h.QuestionBodyFooterContainer,{children:!p&&e.u(h.Button,{disabled:B,onClick:q,children:e.getButtonText(t)})})]})}),properties:t})]},r)},oe=1,fe=2,ye=3,ne=n=>n.type==="av_permission",pe=n=>n.type==="screen_permission",Se=(n,i)=>n===void 0?oe:n?((u,t)=>!(ne(t)?t.permissionDescriptors:[]).includes("camera")||u.getVideoTracks().length>0)(n,i)?ye:oe:fe,me={avStream:null,currentPage:null,mediaRecordingUids:null,nextQuestion:()=>{},passthroughData:void 0,recordingMediaTypes:void 0,screenPermissionRequested:!1,type:void 0},J=e.create(n=>({...me,reset:()=>{n(me)},updatePage:i=>{n(i)}}));function le({currentPage:n,pages:i}){const{avStream:u,recordingMediaTypes:t,updatePage:r}=J.getState(),{recorderEventEmitter:l}=e.useConfig.getState();l.emit("av.permission",{"permission.descriptors":n.permissionDescriptors,"stream.ready":(b,f)=>{if(u===b)return;let d=n;if(b&&!n.permissionDescriptors.includes("camera")){const v=i.indexOf(n),o=f!=null&&f.active?v+2:v+1;f!=null&&f.active&&t&&l.emit("begin.recording",{"recording.media.types":t,"start.recording.callback":p=>r({mediaRecordingUids:p})}),d=i[o]}r({currentPage:d,avStream:b})}})}function ae({status:n}){const{nextQuestion:i,passthroughData:u,mediaRecordingUids:t,reset:r}=J.getState(),{recorderEventEmitter:l,handleUploadUpdate:b,index:f}=e.useConfig.getState(),d={value:{taskStatus:n},type:"recordedtask",questionId:(u==null?void 0:u.questionId)||1};u&&l.emit("finish.task",{"begin.callback":v=>{b({mediaRecordingUid:v,isSubmitted:!0,progressPct:0,isComplete:!1})},"progress.callback":(v,o)=>{b({mediaRecordingUid:v,progressPct:o.detail,isSubmitted:!1,isComplete:!1})},"upload.callback":v=>{v&&b({mediaRecordingUid:v,isComplete:!0,isSubmitted:!0,progressPct:100})},"passthrough.data":u,"current.index":f,"task.response":d,"task.complete.callback":v=>{d.value.taskDurationMillisecond=v,t&&(d.value.mediaRecordingUids=t),r(),i(d)}})}function ue({pages:n,setIsRequestingPermission:i}){const{recorderEventEmitter:u,eventEmitFn:t}=e.useConfig.getState(),{updatePage:r,currentPage:l,recordingMediaTypes:b,screenPermissionRequested:f}=J.getState();if(!l)return;const d=n.indexOf(l);switch(l.type){case"av_permission":{const v=f?d+2:d+1;return f&&b&&u.emit("begin.recording",{"recording.media.types":b,"start.recording.callback":o=>{r({mediaRecordingUids:o})}}),void r({currentPage:n[v]})}case"screen_permission":return void u.emit("screen.permission",{"screen.permission.requested":i,"stream.ready.callback":(v,o)=>{const p=o?n[d+1]:l;o&&b&&u.emit("begin.recording",{"recording.media.types":b,"start.recording.callback":c=>{r({captureStream:o,mediaRecordingUids:c})}}),r({currentPage:p,screenPermissionRequested:!0,captureStream:o})}});case"start_task":return t("recorded.task.start"),u.emit("recorded.task.start"),u.emit("start.task"),void r({currentPage:n[d+1],screenPermissionRequested:!0});case"complete_task":return}}const Ce="ul-permission-graphics-container",xe="ul-permission-body",ke=e.cc(Ce,"ul_recorded-task-inset-spacing"),ie=e.cc("ul-horizontal-button-container","ul-horizontal-button-container-left"),Te=({richTextBody:n})=>e.u(h.Html,{className:"ul-rich-text-body",html:n,id:"ul-task-detail-container"}),se=({required:n,skipButtonText:i,bottom:u=!1})=>n?null:e.u(h.Button,{className:e.cc(u&&"ul-skip-button-below","ul-button-inactive"),onClick:ae.bind(null,{status:"abandoned"}),children:i||"Skip"}),de=n=>{const{avStream:i,captureStream:u,recordingMediaTypes:t,updatePage:r}=J.getState(),l=(t==null?void 0:t.includes("audio"))||(t==null?void 0:t.includes("video"));e.p(()=>{const b=setInterval(()=>{l&&i&&!i.active?r({avStream:null,currentPage:n[0]}):u&&u.active||r({captureStream:void 0,currentPage:n[l?1:0]})},1e3);return()=>clearInterval(b)},[i,u,l,n,t,r])},Ae=({content:n,pages:i,required:u})=>{const{buttonText:t,skipButtonText:r,taskDetail:l}=n;return de(i),e.u("div",{className:"ul-task-page",children:[l&&e.u(Te,{richTextBody:l}),e.u("div",{className:ie,children:[e.u(h.Button,{onClick:ue.bind(null,{pages:i}),children:t}),e.u(se,{required:u,skipButtonText:r})]})]},"start-task")},Ue=({content:n,pages:i,properties:u})=>{const{buttonText:t,skipButtonText:r}=n;de(i);const l=e.u(h.MobileEmbedView,{properties:u,defaultBody:()=>e.u("div",{className:ie,children:[e.u(h.Button,{className:"ul-complete-task-button",onClick:ae.bind(null,{status:"completed"}),children:t}),e.u(h.Button,{className:e.cc("ul-button-inactive"),onClick:ae.bind(null,{status:"given.up"}),children:r})]})});return e.u("div",{className:"ul-task-page",children:[n.taskDetail&&e.u(Te,{richTextBody:n.taskDetail}),l]},"complete-task")},Ve=({content:n,pages:i,required:u})=>{const{buttonText:t,skipButtonText:r}=n,[l]=e.useConfig(d=>[d.tabTitle]),[b,f]=e.h(!1);return e.u("div",{children:[e.u("div",{className:ke,children:[e.u("p",{style:{marginTop:"auto"},children:n.selectTabText}),e.u("div",{className:"ul-select-tab-container",children:e.u("p",{className:xe,children:l})})]}),e.u("div",{className:u?"":ie,children:[e.u(h.Button,{disabled:b,onClick:ue.bind(null,{pages:i,setIsRequestingPermission:f}),children:t}),e.u(se,{required:u,skipButtonText:r})]})]})},We=({content:n})=>e.u(h.Html,{className:e.cc(Ce,"ul_permission_svg_container","ul_recorded-task-inset-spacing","ul-center-horizontally"),html:n.svg},"ul-permission-request-graphic"),je=({content:n,pages:i,required:u})=>{const{permissionDeniedHeadline:t,permissionDeniedBody:r,skipButtonText:l,tryAgainButtonText:b}=n,f=ne(i[0])?i[0]:null;return e.p(()=>{const d=setInterval(()=>{f!==null&&le({currentPage:f,pages:i})},1e3);return()=>clearInterval(d)},[f,i]),f?e.u("div",{children:[e.u("div",{className:ke,children:e.u("p",{className:"ul-av-permission-denied-paragraph",children:[e.u("span",{className:"ul-av-permission-denied-headline",children:t}),e.u("span",{className:xe,children:r})]})}),e.u("div",{className:ie,children:[e.u(h.Button,{onClick:le.bind(null,{currentPage:f,pages:i}),children:b}),e.u(se,{required:u,skipButtonText:l})]})]}):null},Ze=({stream:n})=>e.u("video",{autoPlay:!0,className:e.cc("ul_recorded-task-inset-spacing"),id:"ul-record-task-video-preview",muted:!0,ref:i=>{i&&(i.srcObject=n||null)}}),ze=({content:n,pages:i,required:u})=>{const{skipButtonText:t}=n,{avStream:r}=J.getState();return de(i),e.u("div",{children:[e.u(Ze,{stream:r}),e.u("div",{className:"ul-vertical-button-container-center",children:[e.u(h.Button,{onClick:ue.bind(null,{pages:i}),children:n.buttonText}),e.u(se,{bottom:!0,required:u,skipButtonText:t})]})]})},Ge=({properties:n})=>{const{pages:i,required:u}=n,{avStream:t,currentPage:r}=J.getState();if(r===void 0)return null;switch(r==null?void 0:r.type){case"av_permission":{const l=Se(t,r);return l===oe?e.u(We,{content:r}):l===fe?e.u(je,{content:r,pages:i,required:u}):e.u(ze,{content:r,pages:i,required:u})}case"screen_permission":return e.u(Ve,{content:r,pages:i,required:u});case"start_task":return e.u(Ae,{content:r,pages:i,required:u});case"complete_task":return e.u(Ue,{content:r,pages:i,properties:n});default:return null}},Ye=({className:n,properties:i,next:u,questionId:t})=>{const r=e.useConfig(),{surveyId:l,responseGroupUid:b,userId:f}=r,d=J(),{screenPermissionRequested:v}=d,o=J(m=>m.avStream);let p=J(m=>m.currentPage);p||(p=function({pages:m,userId:x,responseGroupUid:M,surveyId:N,questionId:R,next:B}){const{updatePage:T}=J.getState(),{eventEmitFn:D,recorderEventEmitter:q}=e.useConfig.getState(),k={questionId:R,surveyId:N,visitorId:x,responseGroupUid:M};let _=0;q.emit("recorded.task.permission.screen"),D("recorded.task.permission.screen"),q.emit("permission.status",{"permission.status.callback":(s,g,S,w)=>{const F=m[_],{type:C}=F,L=["screen"];if(ne(F)){const{permissionDescriptors:Q}=F,V=Q==null?void 0:Q.includes("microphone"),$=Q==null?void 0:Q.includes("camera");V&&L.push("audio"),$&&L.push("video"),(s!=null&&s.active&&!$||s!=null&&s.active&&g)&&_++}pe(m[_])&&S&&(_++,q.emit("begin.recording",{"recording.media.types":L,"start.recording.callback":Q=>T({mediaRecordingUids:Q})})),T({currentPage:m[_],avStream:s,screenPermissionRequested:S,nextQuestion:B,type:C,passthroughData:k,recordingMediaTypes:L,captureStream:w})}});const E=m[_];return E.type==="av_permission"&&le({currentPage:E,pages:m}),E}({questionId:t,surveyId:l,next:m=>{u(m,!0)},pages:i.pages,responseGroupUid:b,userId:f}));let c=p.headline,y=p.captionText;const a=Se(o,p);return pe(p)&&v&&(c=p.permissionDeniedHeadline,y=p.permissionDeniedCaptionText),ne(p)&&a===ye&&(c=p.permissionGrantedHeadline,y=p.permissionGrantedCaptionText),e.u("div",{className:e.cc(n,"ul-center-horizontally","fade-in-transition"),children:[e.u(h.Header,{isRequired:i==null?void 0:i.required,message:c,properties:{captionText:y}}),e.u(h.QuestionBodyWrapper,{children:e.u(Ge,{properties:i})})]})},Ke=({className:n,message:i,next:u,properties:t,questionId:r,type:l})=>{const{visitorAttributes:b,isLongFormSurvey:f}=e.useConfig(a=>({visitorAttributes:a.visitorAttributes,isLongFormSurvey:j.isLongFormSurvey(a.studyType)})),d=(a,m=!1)=>{u({value:m?{skipped:!0}:void 0,questionId:r,type:l},!0)},v=a=>{a.key!=="Enter"&&a.key!==" "||u({value:void 0,questionId:r,type:l},!0)},o=h.getAttributedUrl(t&&t.buttonUrl,b),p=f&&t.promptActionType===h.PromptActionTypeEnum.NO_BUTTON?()=>e.u(e.g,{}):()=>e.u(h.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-card-button-group",children:[e.u("a",{className:"ul-card-text__button ul-card__text-url-prompt-button",href:o,id:"ul-card-text__button",onClick:d,onKeyPress:v,rel:"noreferrer",role:o?"link":"button",tabIndex:0,target:"_blank",children:e.getButtonText(t)}),t.required===!1&&e.u("button",{className:"ul-card-skip__button",onClick:a=>d(0,!0),children:e.getSkipButtonText(t)})]})});return e.u("div",{className:e.cc(n,"ul-card__text-url-prompt","fade-in-transition"),children:[e.u(h.Header,{isRequired:f&&(t==null?void 0:t.required),message:i,properties:{questionHtml:t.questionHtml}}),e.u(h.QuestionBodyWrapper,{children:(c=t==null?void 0:t.richTextBody,y=t==null?void 0:t.body,c?e.u(h.Html,{className:"ul-rich-text-body",html:c,id:"ul-card__text-url-body-container"}):y?e.u("div",{className:"ul-rich-text-body",id:"ul-card__text-url-body-container",children:(y?y.split(/\n\s*\n/g):[]).map((a,m)=>e.u("p",{children:a},m))}):null)}),e.u(h.MobileEmbedView,{defaultBody:p,properties:t})]},r);var c,y},Xe=({className:n,questionId:i})=>{const{border:u,destroy:t,endCard:r,forceBrandedLogo:l}=e.useConfig(d=>({border:d.border,destroy:d.destroy,endCard:d.endCard,forceBrandedLogo:d.forceBrandedLogo}));e.p(()=>{setTimeout(()=>{t(j.APP_ID)},l?4e3:2e3)},[t,l]);const b=r&&r.subheader?e.u("p",{className:"ul-caption",children:r.subheader}):null,f=r&&r.headline?r.headline:"";return e.u("div",{className:e.cc(n,"ul-card--thanks","fade-in-transition"),children:e.u("div",{children:e.u("div",{className:"ul-card--thanks-content",children:[e.u("div",{className:"ul-thanks-check",children:e.u("svg",{"aria-labelledby":"title",fill:"none",height:"99",viewBox:"0 0 81 99",width:"81",xmlns:"http://www.w3.org/2000/svg",children:[e.u("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:u,fillRule:"evenodd"}),e.u("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:u,fillRule:"evenodd"}),e.u("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.u(h.Header,{message:f}),b]})})},i)},Je=({className:n})=>{const{uploadProgress:i}=e.useConfig(l=>({uploadProgress:l.uploadProgress}));let u,t;Object.values(i).filter(l=>l.isSubmitted).length>1?(u="Your responses are processing",t="Please keep this tab open until your responses are fully processed."):(u="Your response is processing",t="Please keep this tab open until your response is fully processed.");const r=Math.round(Math.min(99,...Object.values(i).filter(l=>l.isSubmitted).map(l=>l.progressPct||0)));return e.u("div",{className:e.cc(n,"ul-card--uploading","fade-in-transition"),children:[e.u("div",{"aria-busy":"true","aria-label":"Processing...","aria-live":"polite",className:"ul-loading-spinner-container",role:"progressbar",children:e.u("div",{className:"ul-loading-spinner",children:[e.u("div",{className:"first"}),e.u("div",{className:"second"}),e.u("div",{className:"third"}),e.u("div",{className:"fourth"})]})}),e.u(h.Header,{message:`${u} (${r}% complete)`}),e.u("p",{className:"ul-caption",children:t})]})},_e=e.F$1(void 0),et=({value:n,children:i})=>e.u(_e.Provider,{value:n,children:i}),tt=({isRightLabel:n,isLeftLabel:i})=>n?e.MaxDiffChoice.RIGHT:i?e.MaxDiffChoice.LEFT:null,rt="Best",nt="Worst",it=({className:n,labels:i,message:u,properties:t,options:r,questionId:l,type:b,next:f})=>{var B,T,D,q;const[d,v]=e.h(r.map((k,_)=>({...k,label:k.label===""?`Item ${_+1}`:k.label,isRightLabel:!1,isLeftLabel:!1}))),o=(()=>{const k=e.q(_e);if(k===void 0)throw new Error("usePreviousResponses must be used within a PreviousResponsesProvider");return k})(),p={padding:"24px",display:"flex",cursor:"pointer",width:"auto"},[c,y]=e.h(!1);e.p(()=>{const k=d.findIndex(C=>C.isRightLabel),_=d.findIndex(C=>C.isLeftLabel),E=k!==-1&&_!==-1;y(E);const s=!t.required||t.required&&E,g=d.map(C=>({id:C.id,option:C.label,selected:tt(C)})),S=Math.floor(l),w=Object.keys(o).filter(C=>C.startsWith(S.toString())).map(Number).sort((C,L)=>C-L).at(-1),F=[];if(typeof w=="number"){const C=o[w],L=JSON.parse(C);F.push(...L)}F.push(g),setTimeout(()=>{f({value:F,questionId:l,type:b},s,E),y(!1)},E?500:0)},[d]);const{border:a,useMobileStyling:m,enableCspTrustedTypes:x}=e.useConfig(k=>({border:k.border,useMobileStyling:k.useMobileStyling,enableCspTrustedTypes:k.enableCspTrustedTypes})),M=(k,_)=>()=>{c||v(E=>((s,g,S)=>s.map(w=>w.id===g?{...w,isRightLabel:S===e.MaxDiffChoice.RIGHT,isLeftLabel:S===e.MaxDiffChoice.LEFT}:S===e.MaxDiffChoice.RIGHT&&w.isRightLabel||S===e.MaxDiffChoice.LEFT&&w.isLeftLabel?{...w,isRightLabel:!1,isLeftLabel:!1}:w))(E,k,_))},N=(B=t.ratingIcons)==null?void 0:B[0].svg,R=(T=t.ratingIcons)==null?void 0:T[1].svg;return e.u("form",{className:e.cc(n,"ul-card-maxdiff","fade-in-transition"),children:[e.u(h.Header,{isRequired:t==null?void 0:t.required,message:u,properties:t}),e.u(h.QuestionBodyWrapper,{children:e.u("div",{className:"ul-card--maxdiff__question-inner-container",children:[e.u("div",{className:"ul-card-maxdiff__label",children:(i==null?void 0:i.left)||((D=t==null?void 0:t.labels)==null?void 0:D.left)||rt}),e.u("div",{children:" "}),e.u("div",{className:"ul-card-maxdiff__label",children:(i==null?void 0:i.right)||((q=t==null?void 0:t.labels)==null?void 0:q.right)||nt}),d.map(({id:k,label:_,isLeftLabel:E,isRightLabel:s})=>e.u(e.g,{children:[e.u("div",{className:"ul-card-maxdiff__option-control "+(R?"smiley":""),children:R?e.u(ge,{ariaPressed:E,className:E?"ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected good":"ul-card-maxdiff__option-btn",enableCspTrustedTypes:x,html:R,id:`smiley-good-${k}`,onClick:M(k,e.MaxDiffChoice.LEFT)}):e.u(h.Option,{allowTextEntry:!1,ariaLabel:`bestLabel-${_}`,border:a,choiceStyle:p,error:!1,id:`${k}`,isRadio:!0,isSelected:E,onUserInputChanged:M(k,e.MaxDiffChoice.LEFT),useMobileStyling:m})}),e.u("div",{className:"ul-card-maxdiff__option-label",children:_}),e.u("div",{className:"ul-card-maxdiff__option-control "+(N?"smiley":""),children:N?e.u(ge,{ariaPressed:s,className:s?"ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected bad":"ul-card-maxdiff__option-btn",enableCspTrustedTypes:x,html:N,id:`smiley-bad-${k}`,onClick:M(k,e.MaxDiffChoice.RIGHT)}):e.u(h.Option,{allowTextEntry:!1,ariaLabel:`worstLabel-${_}`,border:a,choiceStyle:p,error:!1,id:`${k}`,isRadio:!0,isSelected:s,onUserInputChanged:M(k,e.MaxDiffChoice.RIGHT),useMobileStyling:m})})]}))]})})]},l)},ge=({enableCspTrustedTypes:n,ariaPressed:i,className:u,html:t,id:r,onClick:l})=>{const b=e.F(()=>j.getHtml(t,n),[n,t]);return e.u("span",{"aria-pressed":i,className:u,dangerouslySetInnerHTML:{__html:b},id:r,onClick:l,tabIndex:0,type:"button"})},st=({className:n,labels:i,message:u,next:t,properties:r,questionId:l,type:b,onSubmitButtonClick:f,options:d,showIndividualSubmit:v=!1})=>{const o=e._(null),p=e._(0),c=e._(0),y=e._(null),a=e._(!1),m=e._([]),[x,M]=e.h(()=>(r==null?void 0:r.required)===!0),[N,R]=e.h(()=>d.map(I=>({...I,rank:null}))),B=e.F(()=>Array.from({length:d.length},(I,O)=>O+1),[d.length]),{isLongFormSurvey:T,focusedQuestionId:D,setFocusedQuestionId:q,useMobileStyling:k,isPreview:_,headers:E}=e.useConfig(I=>({useMobileStyling:I.useMobileStyling,isLongFormSurvey:j.isLongFormSurvey(I.studyType),focusedQuestionId:I.focusedQuestionId,setFocusedQuestionId:I.setFocusedQuestionId,isPreview:I.isPreview,headers:I.headers})),s=(E==null?void 0:E["userleap-platform"])==="android",g=k&&!_&&!s,S=!g&&!s,w=T&&D===l,F=I=>{I.preventDefault(),G(N),f&&f()},C=(I,O)=>{R(H=>{const P=parseInt(O),A=H.map(U=>({...U}));A.some(U=>U.rank==null)&&A.forEach((U,ee)=>U.rank=ee+1);const K=A.findIndex(U=>U.id===I);if(K===-1)return H;const W=A[K].rank;return P<W?A.forEach(U=>{U.id!==I&&U.rank>=P&&U.rank<W&&(U.rank=U.rank+1)}):P>W&&A.forEach(U=>{U.id!==I&&U.rank>W&&U.rank<=P&&(U.rank=U.rank-1)}),A[K].rank=P,A.sort((U,ee)=>U.rank-ee.rank),Y(A),A})},L=(I,O)=>{for(let H=0;H<m.current.length;H++){const P=m.current[H];if(!P||P===y.current)continue;const A=P.getBoundingClientRect();if(I>=A.left&&I<=A.right&&O>=A.top&&O<=A.bottom)return{element:P,index:H}}return null},Q=I=>O=>{if(!g)return;O.preventDefault(),O.stopPropagation(),a.current=!0,o.current=I;const H=O.touches[0];p.current=H.clientY,c.current=H.clientY;const P=O.currentTarget.closest(".ul-card-rank__option");P&&(y.current=P,P.classList.add("is-dragging"))},V=I=>{if(!g||!a.current||o.current===null)return;I.preventDefault(),I.stopPropagation();const O=I.touches[0];c.current=O.clientY;const H=c.current-p.current;y.current&&(y.current.style.transform=`translateY(${H}px)`,y.current.style.zIndex="1000"),m.current.forEach(A=>{A&&A!==y.current&&A.classList.remove("is-drop-target")});const P=L(O.clientX,O.clientY);P&&P.element.classList.add("is-drop-target")},$=I=>{if(!g||!a.current||o.current===null)return;I.preventDefault(),I.stopPropagation();const O=I.changedTouches[0],H=L(O.clientX,O.clientY);y.current&&(y.current.style.transform="",y.current.style.zIndex="",y.current.classList.remove("is-dragging")),m.current.forEach(P=>{P&&P.classList.remove("is-drop-target")}),H&&H.index!==o.current&&Z(o.current,H.index),o.current=null,y.current=null,a.current=!1},Z=(I,O)=>{R(H=>{const P=H.map(K=>({...K})),[A]=P.splice(I,1);return P.splice(O,0,A),P.forEach((K,W)=>{K.rank=W+1}),Y(P),P})},z=I=>{I.preventDefault(),I.dataTransfer&&(I.dataTransfer.dropEffect="move")},G=I=>{const O={};I.reduce((H,P)=>(H[P.id]=P.rank,H),O),t({value:O,questionId:l,type:b},!0)},Y=I=>{M(!1),T&&G(I)},{left:X,right:te}=i,re=d.length,Ie=I=>{I.preventDefault(),I.currentTarget.classList.add("is-drop-target")},Ne=I=>{I.currentTarget.classList.remove("is-drop-target")},we=I=>{o.current=null,I.currentTarget.classList.remove("is-dragging")};return e.u("form",{className:e.cc(n,"ul-card-rank","fade-in-transition",T&&!w&&"ul-card--unfocused"),onClick:T?()=>{T&&D!==l&&q(l)}:void 0,onSubmit:F,children:[e.u(h.Header,{isRequired:r==null?void 0:r.required,message:u,properties:r}),e.u(h.MobileEmbedView,{properties:r,defaultBody:()=>s?e.u(e.g,{children:[e.u(h.QuestionBodyWrapper,{children:[e.u("div",{className:"ul-card--rank__question-inner-container",children:[e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:["1 - ",X]})}),e.u("ol",{className:"ul-card-rank__list",children:N.map(({id:I,label:O,rank:H})=>e.u("li",{className:"ul-card-rank__option",children:[e.u("select",{"aria-label":`Rank for ${O}`,className:e.cc("ul-card-rank__select",H==null&&"ul-card-rank__select--placeholder"),name:`rank[${I}]`,onChange:P=>C(I,P.currentTarget.value),value:H??"",children:[H==null&&e.u("option",{className:"ul-card-rank__select-option",disabled:!0,value:"",children:"-"}),B.map(P=>e.u("option",{className:"ul-card-rank__select-option",value:P,children:P},`${P}-${l}`))]}),e.u("span",{children:O})]},I))}),e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:[re," - ",te]})})]}),v&&e.u(h.LongformSubmitButton,{handleSubmit:F,isSubmitDisabled:x})]}),!T&&e.u(h.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-card__button-wrapper",children:e.u(h.Button,{disabled:x,children:e.getButtonText(r)})})})]}):e.u(e.g,{children:[e.u(h.QuestionBodyWrapper,{children:[e.u("div",{className:"ul-card--rank__question-inner-container",children:[e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:["1 - ",X]})}),e.u("ol",{className:"ul-card-rank__list",onDragOver:s?void 0:z,children:N.map(({id:I,label:O,rank:H},P)=>{return e.u("li",{className:"ul-card-rank__option",draggable:!!S||void 0,onDragEnd:S?we:void 0,onDragEnter:S?Ie:void 0,onDragLeave:S?Ne:void 0,onDragStart:S?(K=P,W=>{o.current=K,W.dataTransfer&&(W.dataTransfer.effectAllowed="move",W.dataTransfer.setData("text/plain",String(K)),W.currentTarget.classList.add("is-dragging"))}):void 0,onDrop:S?(A=P,W=>{var ee,ce;W.preventDefault(),W.currentTarget.classList.remove("is-drop-target");const U=o.current;o.current=null,(ce=(ee=W.currentTarget.closest(".ul-card-rank__list"))==null?void 0:ee.querySelector(".is-dragging"))==null||ce.classList.remove("is-dragging"),U!=null&&U!==A&&Z(U,A)}):void 0,ref:W=>m.current[P]=W,children:[e.u("select",{"aria-label":`Rank for ${O}`,className:e.cc("ul-card-rank__select",H==null&&"ul-card-rank__select--placeholder"),name:`rank[${I}]`,onChange:W=>C(I,W.currentTarget.value),value:H??"",children:[H==null&&e.u("option",{className:"ul-card-rank__select-option",disabled:!0,value:"",children:"-"}),B.map(W=>e.u("option",{className:"ul-card-rank__select-option",value:W,children:W},`${W}-${l}`))]}),e.u("span",{children:O}),!s&&e.u("button",{"aria-label":`Drag ${O} to reorder`,className:"ul-card-rank__drag-btn",onTouchEnd:g?$:void 0,onTouchMove:g?V:void 0,onTouchStart:g?Q(P):void 0,title:"Drag to reorder",type:"button",children:e.u("svg",{fill:"none",height:"17",viewBox:"0 0 16 17",width:"16",xmlns:"http://www.w3.org/2000/svg",children:e.u("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);var A,K})}),e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:[re," - ",te]})})]}),v&&e.u(h.LongformSubmitButton,{handleSubmit:F,isSubmitDisabled:x})]}),!T&&e.u(h.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-card__button-wrapper",children:e.u(h.Button,{disabled:x,children:e.getButtonText(r)})})})]})})]},l)},ot=new Set(["open","matrix","multipleselect","multiplechoice","rankorder"]),he=({cardInstance:n,moveToNextQuestion:i,showIndividualSubmit:u,submitQuestion:t,updateCardValues:r})=>{const{isLongFormSurvey:l}=e.useConfig(c=>({isLongFormSurvey:j.isLongFormSurvey(c.studyType)}));if(!n)return null;const{name:b,type:f,props:d}=n,v=u&&ot.has(f),o={className:"ul-card",next:(c,y,a=!0)=>t(c,y&&a),questionId:b,type:f,showIndividualSubmit:u,...v?{next:(c,y)=>{r(c.questionId,c,y??!0)},onSubmitButtonClick:()=>i(b)}:{}},p=(()=>{switch(f){case"consentlegal":return e.u(Le,{...o,...d});case"likert":return e.u(Be,{...o,...d});case"matrix":return e.u(Ee,{...o,...d});case"maxdiff":return e.u(it,{...o,...d});case"multiplechoice":return e.u(Qe,{...o,...d});case"multipleselect":return e.u(Oe,{...o,...d});case"nps":return e.u(He,{...o,...d});case"open":return e.u($e,{...o,...d});case"rankorder":return e.u(st,{...o,...d});case"recordedtask":return e.u(Ye,{...o,...d});case"texturlprompt":return e.u(Ke,{...o,...d});case"thanks":return e.u(Xe,{...o,...d});case"uploading":return e.u(Je,{...o,...d});default:return null}})();return p?l?e.u("div",{className:"ul-card-scroll-wrapper",children:p},b):p:null},lt=({isSubmitDisabled:n=!1,onSubmit:i,buttonText:u})=>{var y;const{cards:t,forceBrandedLogo:r,index:l,marketingUrl:b,showSurveyBrand:f,slugName:d,surveyId:v,useMobileStyling:o}=e.useConfig(a=>({cards:a.cards,forceBrandedLogo:a.forceBrandedLogo,index:a.index,marketingUrl:a.marketingUrl,showSurveyBrand:a.showSurveyBrand,slugName:a.slugName,surveyId:a.surveyId,useMobileStyling:a.useMobileStyling})),p=((y=t[l])==null?void 0:y.type)==="thanks",c=e.buildMarketingUrl({marketingUrl:b,slugName:d,surveyId:v,forceBrandedLogo:r});return e.u("footer",{className:e.cc("long-form-question-footer-container",o&&"long-form-question-footer-container--mobile",p&&"long-form-question-footer-container-center"),children:[p&&r?e.u(e.ThankYouLink,{marketingUrlLink:c}):e.u("div",{className:"long-form-question-footer-container-logo",children:f?e.u(e.SprigBrandLogo,{forceBrandedLogo:r,marketingUrlLink:c}):null}),!p&&e.u("div",{className:e.cc("ul-card__button-wrapper","ul-card-vertical__button-wrapper","long-form-question-footer-container-actions"),children:e.u(h.Button,{className:e.cc("long-form-button",n&&"sprig-button-disabled"),disabled:n,onClick:i,children:e.u("span",{className:"long-form-button-text-container",children:u??e.u(e.Arrow,{stroke:"white"})})})})]})};exports.PageCard=({cards:n,next:i,previousResponses:u})=>{var E;const[t,r]=e.h({}),[l,b]=e.h({}),f=e.F(()=>({...u,...e.buildReadableResponseMap(n.map(s=>{var g,S;return{...s,value:((g=t[s.name])==null?void 0:g.value)??null,secondaryValue:((S=t[s.name])==null?void 0:S.secondaryValue)??null}}))}),[u,t,n]),d=e.pipeReadableResponsesIntoCards(n,f),{isLongFormSurvey:v,focusedQuestionId:o,setFocusedQuestionId:p,update:c}=e.useConfig(s=>({isLongFormSurvey:j.isLongFormSurvey(s.studyType),focusedQuestionId:s.focusedQuestionId,setFocusedQuestionId:s.setFocusedQuestionId,update:s.update})),y=e._(null),a=e._(!1),m=e._(null);e.p(()=>{c()},[c]);const x=e.T(s=>{var F,C;a.current=!0;const g=n.findIndex(L=>L.name===s);if(!v||s===null||g===-1)return void(a.current=!1);const S=(F=y.current)==null?void 0:F.querySelectorAll(".ul-card-scroll-wrapper")[g],w=(C=y.current)==null?void 0:C.closest(".ul-card__container");if(S&&w){if(S&&w){const L=S.getBoundingClientRect(),Q=w.getBoundingClientRect(),V=L.top-Q.top+w.scrollTop,$=V+L.height/2,Z=window.innerHeight-157;let z;L.height>=Z?z=V:z=$-w.clientHeight/2;const G=w.clientHeight,Y=w.scrollHeight-G,X=Math.max(0,Math.min(z,Y));w.scrollTo({top:X,behavior:"smooth"}),setTimeout(()=>{a.current=!1},500)}}else a.current=!1},[v,n]);function M(s,g){return s.map(S=>g[S.name])}e.p(()=>{o!==null&&n.findIndex(s=>s.name===o)!==-1||p(n[0].name)},[n,o,p]);const N=s=>{if(!v)return;const g=n.findIndex(S=>S.name===s)+1;if(g<n.length){const S=n[g].name;p(S)}else p(s)};e.p(()=>{v&&o!==null&&(m.current!==o?x(o):m.current=null)},[o,v,x]);const R=e.T(()=>{var Q,V;if(a.current)return;const s=(Q=y.current)==null?void 0:Q.closest(".ul-card__container");if(!s)return;const g=(V=y.current)==null?void 0:V.querySelectorAll(".ul-card-scroll-wrapper");if(!g||g.length===0)return;const S=s.getBoundingClientRect(),w=S.top+S.height/2;let F=0,C=1/0;g.forEach(($,Z)=>{const z=$.getBoundingClientRect(),G=z.top+z.height/2,Y=Math.abs(w-G);Y<C&&(C=Y,F=Z)});const L=n[F];m.current=L.name,p(L.name)},[n,p]);e.p(()=>{var g;if(!v)return;const s=((g=y.current)==null?void 0:g.closest(".ul-card__container"))||null;return s&&s.addEventListener("scroll",R,{passive:!0}),()=>{s&&s.removeEventListener("scroll",R)}},[R,v]);const B=e.F(()=>Object.values(l).every((s,g)=>{var w;const S=n[g];return!(!(S!=null&&S.props)||!("properties"in S.props)||((w=S.props.properties)==null?void 0:w.required)!==!1)||s}),[l,n]),T=async(s,g,S)=>{return b(F=>({...F,[s]:S})),await(w=F=>({...F,[s]:g}),new Promise(F=>{r(C=>{const L=w(C);return F(L),L})}));var w};e.p(()=>{if(!v)return;const s={};n.forEach(g=>{var w,F;const S=g;(F=(w=S.props)==null?void 0:w.properties)!=null&&F.required||(s[S.name]={value:null,questionId:S.name,type:S.type})}),r(s),b({})},[n,v]);const D=async(s,g)=>{if(v){const S=await T(s.questionId,s,g),w=q(s.type),F=k(s.type);if(w&&N(s.questionId),F&&g){const C=M(n,S);i(C)}}else i([s])},q=s=>new Set(["nps","likert","multiplechoice"]).has(s),k=s=>new Set(["videovoice","consentlegal","texturlprompt","maxdiff"]).has(s),_=((E=n[0])==null?void 0:E.type)==="thanks";return v?e.u("div",{className:"ul-card-list-container--longform","data-testid":"ui-container",ref:y,children:[e.u(et,{value:u,children:d.map((s,g)=>e.u(he,{cardInstance:s,moveToNextQuestion:N,showIndividualSubmit:v&&n.length>1&&g<n.length-1,submitQuestion:D,updateCardValues:T},(s==null?void 0:s.name)||g))}),!_&&e.u(lt,{isSubmitDisabled:Object.keys(t).length<n.length||!B,onSubmit:function(){const s=M(n,t);i(s)}})]}):e.u(e.g,{children:[e.u("div",{"data-testid":"ui-container",style:{display:"none"}}),d.map((s,g)=>e.u(he,{cardInstance:s,moveToNextQuestion:N,showIndividualSubmit:v&&n.length>1&&g<n.length-1,submitQuestion:D,updateCardValues:T},(s==null?void 0:s.name)||g))]})};
|