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