@sprig-technologies/sprig-browser 2.40.0 → 2.40.2
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-BiL7hMhj.js +4 -0
- package/dist/conversational-styles-DlhTFTL6.cjs +1 -0
- package/dist/conversational-ui-BYWN-x1R.js +579 -0
- package/dist/conversational-ui-N_aaTzqd.cjs +1 -0
- package/dist/core-Br8FqGd4.cjs +12 -0
- package/dist/{core-CzqULo6b.js → core-Cyu7gofl.js} +451 -458
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +11 -0
- package/dist/core.js +2 -2
- package/dist/debounce-CMb8f7wh.js +9 -0
- package/dist/debounce-DsC7462b.cjs +1 -0
- package/dist/{getAttributedUrl-C1AsMcwH.cjs → getAttributedUrl-CJJ96Ihj.cjs} +6 -6
- package/dist/{getAttributedUrl-DUesmkhh.js → getAttributedUrl-C_5gL6aZ.js} +241 -244
- package/dist/index-BSk-C5b7.js +695 -0
- package/dist/index-MWKreg7C.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +2 -2
- package/dist/{metricsReporter-BChkCOLD.js → metricsReporter-B-oKhuWk.js} +1 -1
- package/dist/{metricsReporter-Bqy_vLyq.cjs → metricsReporter-Dc4CZlRc.cjs} +1 -1
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +134 -138
- package/dist/view-BGlLLPXB.js +1503 -0
- package/dist/view-BGzeHt4l.cjs +1 -0
- package/package.json +1 -1
- package/dist/conversational-styles-CWNea3pP.js +0 -4
- package/dist/conversational-styles-CzhxRRD3.cjs +0 -1
- package/dist/conversational-ui-D2Y5H9To.js +0 -610
- package/dist/conversational-ui-DJlCFQ-6.cjs +0 -1
- package/dist/core-CvM2f3CD.cjs +0 -12
- package/dist/index-D1_q2uph.cjs +0 -1
- package/dist/index-mshAF3wp.js +0 -709
- package/dist/view-C7XtFlCN.cjs +0 -1
- package/dist/view-afp9mz2J.js +0 -1491
package/dist/core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("./metricsReporter-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("./metricsReporter-Dc4CZlRc.cjs"),e=require("./core-Br8FqGd4.cjs");exports.DismissReason=i.DismissReason,exports.SprigEvent=i.SprigEvent,exports.SprigAPI=e.SprigAPI,exports.default=e.core,exports.sprig=e.sprig;
|
package/dist/core.d.ts
CHANGED
|
@@ -1081,6 +1081,7 @@ interface TextUrlPromptCard extends BaseCard {
|
|
|
1081
1081
|
richTextBody: RichTextBody;
|
|
1082
1082
|
questionHtml?: string;
|
|
1083
1083
|
};
|
|
1084
|
+
displayLogic: RoutingOptions;
|
|
1084
1085
|
routingOptions: RoutingOptions;
|
|
1085
1086
|
};
|
|
1086
1087
|
type: "texturlprompt";
|
|
@@ -1107,6 +1108,7 @@ interface ConsentLegalCard extends BaseCard {
|
|
|
1107
1108
|
submitButtonText: string;
|
|
1108
1109
|
questionHtml?: string;
|
|
1109
1110
|
};
|
|
1111
|
+
displayLogic: RoutingOptions;
|
|
1110
1112
|
routingOptions: RoutingOptions;
|
|
1111
1113
|
};
|
|
1112
1114
|
type: "consentlegal";
|
|
@@ -1164,6 +1166,7 @@ interface RecordedTaskCard extends BaseCard {
|
|
|
1164
1166
|
message: string;
|
|
1165
1167
|
options: [];
|
|
1166
1168
|
properties: RecordedTaskCardProperties;
|
|
1169
|
+
displayLogic: RoutingOptions;
|
|
1167
1170
|
routingOptions: RoutingOptions<"given_up">;
|
|
1168
1171
|
};
|
|
1169
1172
|
type: "recordedtask";
|
|
@@ -1192,6 +1195,7 @@ interface LikertCard extends BaseCard {
|
|
|
1192
1195
|
scaleLabelType: ScaleLabelType;
|
|
1193
1196
|
required: boolean;
|
|
1194
1197
|
};
|
|
1198
|
+
displayLogic: RoutingOptions;
|
|
1195
1199
|
routingOptions: RoutingOptions<"eq" | "given_up" | "gt" | "gte" | "lt" | "lte" | "neq">;
|
|
1196
1200
|
};
|
|
1197
1201
|
type: "likert";
|
|
@@ -1211,6 +1215,7 @@ interface OpenTextCard extends BaseCard {
|
|
|
1211
1215
|
richTextBody: RichTextBody;
|
|
1212
1216
|
skipButtonText?: string;
|
|
1213
1217
|
};
|
|
1218
|
+
displayLogic: RoutingOptions;
|
|
1214
1219
|
routingOptions: RoutingOptions<"contains" | "notcontains">;
|
|
1215
1220
|
};
|
|
1216
1221
|
type: "open";
|
|
@@ -1262,6 +1267,7 @@ declare enum MaxSelectModes {
|
|
|
1262
1267
|
}
|
|
1263
1268
|
interface MultiChoiceCard<C extends Comparator = DefaultComparator> extends BaseCard {
|
|
1264
1269
|
props: CommonMultipleChoiceProps & {
|
|
1270
|
+
displayLogic: RoutingOptions;
|
|
1265
1271
|
routingOptions: RoutingOptions<C>;
|
|
1266
1272
|
};
|
|
1267
1273
|
}
|
|
@@ -1276,6 +1282,7 @@ interface MatrixCard extends BaseCard {
|
|
|
1276
1282
|
options: MultipleChoiceOption[];
|
|
1277
1283
|
message: string;
|
|
1278
1284
|
routingOptions: RoutingOptions<"skipped" | "partial" | "answered">;
|
|
1285
|
+
displayLogic: RoutingOptions;
|
|
1279
1286
|
properties: {
|
|
1280
1287
|
buttonText?: string;
|
|
1281
1288
|
captionText: string;
|
|
@@ -1303,6 +1310,7 @@ interface NPSCard extends BaseCard {
|
|
|
1303
1310
|
labels: Labels;
|
|
1304
1311
|
required: boolean;
|
|
1305
1312
|
};
|
|
1313
|
+
displayLogic: RoutingOptions;
|
|
1306
1314
|
routingOptions: RoutingOptions<"eq" | "gt" | "gte" | "lt" | "lte" | "neq">;
|
|
1307
1315
|
};
|
|
1308
1316
|
type: "nps";
|
|
@@ -1332,6 +1340,7 @@ interface RankOrderType extends BaseCard {
|
|
|
1332
1340
|
required: boolean;
|
|
1333
1341
|
randomize: Randomize;
|
|
1334
1342
|
};
|
|
1343
|
+
displayLogic: RoutingOptions;
|
|
1335
1344
|
routingOptions: RoutingOptions<"eq" | "gt" | "gte" | "lt" | "lte" | "neq">;
|
|
1336
1345
|
};
|
|
1337
1346
|
type: "rankorder";
|
|
@@ -1348,6 +1357,7 @@ interface MaxDiffType extends BaseCard {
|
|
|
1348
1357
|
};
|
|
1349
1358
|
message: string;
|
|
1350
1359
|
options: MaxDiffOption[];
|
|
1360
|
+
displayLogic: RoutingOptions;
|
|
1351
1361
|
routingOptions: RoutingOptions<"skipped" | "answered">;
|
|
1352
1362
|
properties: {
|
|
1353
1363
|
ratingIcons?: {
|
|
@@ -1388,6 +1398,7 @@ interface VideoVoiceCard extends BaseCard {
|
|
|
1388
1398
|
videoUrl: string;
|
|
1389
1399
|
};
|
|
1390
1400
|
routingOptions: RoutingOptions;
|
|
1401
|
+
displayLogic: RoutingOptions;
|
|
1391
1402
|
};
|
|
1392
1403
|
type: "videovoice";
|
|
1393
1404
|
}
|
package/dist/core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as r, S as e } from "./metricsReporter-
|
|
2
|
-
import { S as o, c as p, s as t } from "./core-
|
|
1
|
+
import { D as r, S as e } from "./metricsReporter-B-oKhuWk.js";
|
|
2
|
+
import { S as o, c as p, s as t } from "./core-Cyu7gofl.js";
|
|
3
3
|
export {
|
|
4
4
|
r as DismissReason,
|
|
5
5
|
o as SprigAPI,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.debounce=(t,o)=>{let e;return u=>{clearTimeout(e),e=window.setTimeout(()=>t(u),o)}};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";const
|
|
2
|
-
.${
|
|
1
|
+
"use strict";const i=require("./view-BGzeHt4l.cjs"),W=require("./core-Br8FqGd4.cjs"),Le=require("./debounce-DsC7462b.cjs"),_e=require("./metricsReporter-Dc4CZlRc.cjs"),le=e=>i.u("button",{...e,className:i.cc("ul-card-text__button",e.className),id:"ul-card-text__button"}),ye=({html:e,...n})=>{const{enableCspTrustedTypes:o}=i.useConfig(r=>({enableCspTrustedTypes:r.enableCspTrustedTypes})),t=i.F(()=>W.getHtml(e,o),[o,e]);return i.u("div",{...n,dangerouslySetInnerHTML:{__html:t}})},ae=()=>{const{viewDocument:e}=i.useConfig(t=>({viewDocument:t.viewDocument})),[n,o]=i.h(!1);return i.p(()=>{const t=e.querySelector(".sprig-question-body"),r=new ResizeObserver(()=>{window.requestAnimationFrame(()=>{o(!!(t&&W.isHTMLElement(t)&&t.scrollHeight>t.offsetHeight))})});return t&&r.observe(t),()=>{t&&r.disconnect()}},[e]),n},de=({plainText:e,richText:n,id:o,className:t,isHeader:r,showAsterisk:l})=>n?i.u(ye,{className:t,html:n,id:o}):e?r?i.u("h1",{className:t,id:o,children:[e,l&&"*"]}):i.u("p",{className:t,id:o,children:e}):null,Pe=()=>i.u("svg",{fill:"none",height:"10",viewBox:"0 0 13 10",width:"13",xmlns:"http://www.w3.org/2000/svg",children:i.u("path",{d:"M11.5 1.5L4.5 8.5L1 5",stroke:"#FFFFFF",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})}),Ee=(e,n)=>{const o=i._(0);return()=>{if(e.current){const t=e.current;t.style.height="1px";const r=t.scrollHeight+(t.offsetHeight-t.clientHeight),l=parseInt(window.getComputedStyle(t).getPropertyValue("max-height")),a=r<=l?r:l;o.current!==a&&requestAnimationFrame(()=>{n()}),o.current=a,t.style.height=`${a}px`}}},ce=({buttonText:e="View Prototype",handleClick:n})=>i.u("button",{className:"prototype-button",onClick:n,children:e},"prototype-btn"),xe=({isSelected:e,id:n,divId:o,themeColor:t,disabled:r=!1})=>i.u("div",{"aria-checked":e,"aria-disabled":r,"aria-labelledby":`label-${n}`,className:"select-checkbox",id:o,role:"checkbox",style:{...e?{backgroundColor:t,borderColor:t,boxShadow:"none"}:{},...r?{opacity:.5}:{}},tabIndex:r?-1:0,children:e&&i.u(i.SvgCheckmark,{})}),Oe=({promptText:e,textValue:n,onTextChange:o,useMobileStyling:t})=>{const r=i._(null),{update:l}=i.useConfig(d=>({update:d.update})),a=Ee(r,()=>l());return i.p(()=>(a(),r.current&&r.current.focus(),()=>{l()}),[]),i.u("textarea",{"aria-label":e,"aria-multiline":"true","aria-placeholder":e,className:i.cc(i.getClasses("choice-text-input",t)),"data-gramm":"false",maxLength:5e3,name:"text",onChange:d=>{a(),d.stopPropagation(),o(d.currentTarget.value)},onClick:d=>{d.stopPropagation()},onKeyPress:d=>{d.stopPropagation()},placeholder:e,ref:r,role:"textbox",rows:1,value:n})},ue="ul-select-style-element",K="ul-select-active-dynamic-style",je="ul-select-error-dynamic-style",Me=(e,n,o)=>{let t=e.getElementById(ue),r=!1;t||(t=e.createElement("style"),r=!0),t.tagName.toLowerCase()==="style"&&(t.id=ue,o&&(t.nonce=o),t.textContent=Be(n),r&&e.head.appendChild(t))},Be=e=>`
|
|
2
|
+
.${K} {
|
|
3
3
|
border-color: ${e};
|
|
4
4
|
}
|
|
5
|
-
.${
|
|
5
|
+
.${K} .select-radio, .${K}.select-radio {
|
|
6
6
|
border: 6px solid ${e};
|
|
7
7
|
box-shadow: none;
|
|
8
8
|
}
|
|
9
9
|
.${je} {
|
|
10
|
-
border-color: ${
|
|
10
|
+
border-color: ${W.ERROR_BORDER_COLOR};
|
|
11
11
|
}
|
|
12
|
-
`,q="https://cdn.sprig.com",c={document:void 0,videojs:void 0},ie=e=>e+"-loading-spiner",
|
|
12
|
+
`,q="https://cdn.sprig.com",c={document:void 0,videojs:void 0},ie=e=>e+"-loading-spiner",T="hidden",pe=".m3u8",ee="questionId",ne="ul-video-recorder-camera-off-button",oe="ul-recording-in-session",He=[{type:"link",content:`${q}/dependencies/videojs-record-4.5.0.min.css`},{type:"script",content:`${q}/dependencies/RecordRTC-5.6.2.js`},{type:"script",content:`${q}/dependencies/adapter.8.0.0.min.js`},{type:"script",content:`${q}/dependencies/videojs-record-4.5.0.min.js`},{type:"script",content:`${q}/userleap-web-upchunk-v2.2.2.js`}],ve=[{type:"link",content:`${q}/dependencies/video-js-7.18.0.min.css`},{type:"script",content:`${q}/dependencies/video-js-7.18.0.min.js`},{type:"style",content:`/* progress control styles */
|
|
13
13
|
.video-js .vjs-control {
|
|
14
14
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
|
|
15
15
|
}
|
|
@@ -666,4 +666,4 @@ span.ul-button-text {
|
|
|
666
666
|
.vjs-poster {
|
|
667
667
|
background-size: cover;
|
|
668
668
|
}
|
|
669
|
-
`}],he="-video-player",me="-secondary-video-player",ge="-video-recorder";let H,be;const F=async({event:e,apiBase:n,headers:o,visitorId:t,envId:i,metadata:l})=>{const d=c.document.documentElement;if(!t||!i)return;const a={event:`SDK - ${e}`,visitorId:t,environmentId:i,metadata:{...l||{},screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:d.clientWidth,clientHeight:d.clientHeight,location:window.location.href,language:navigator.language}};(await fetch(`${n}/sdk/1/visitors/${t}/analytics`,{method:"POST",cache:"no-cache",headers:o,body:JSON.stringify(a)})).ok||console.warn("[Sprig] (ERR-444) Failed to track analytics",e)},N=async(e,n,o,t,i,l)=>{F({event:`Video Error ${n}`,apiBase:o,headers:t,visitorId:i,envId:l,metadata:{errorMessage:e.message}});const d=c.document.documentElement,a={screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:d.clientWidth,clientHeight:d.clientHeight,location:window.location.href,language:navigator.language},s={action:n,err:{message:e.message,stack:e.stack},meta:a,vid:i,envId:l};(await fetch(`${o}/sdk/1/errors`,{method:"POST",cache:"no-cache",headers:{...t,"userleap-platform":"video_recorder","x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(s)})).ok||console.warn("[Sprig] (ERR-444) Failed to report error to API",e)},fe=(e,n)=>{if(e.length===0)return n&&n();Promise.all(e.reduce((o,t)=>(o.push(((i,{type:l,content:d})=>new Promise(function(a,s){let u;l==="script"?(u=c.document.createElement("script"),u.src=d):l==="link"?(u=c.document.createElement("link"),u.rel="stylesheet",u.href=d,u.type="text/css"):(u=c.document.createElement("style"),u.innerHTML=d),u.onload=function(){a(d)},u.onerror=function(){s(d)},u.async=!1,u.id=btoa(d),i.appendChild(u)}))(c.document.head,t)),o),[])).then(()=>{c.videojs=c.document.defaultView.videojs,n&&n()}).catch(function(o){console.log(o+" failed to load")})},Ce=(e,n,o)=>{if(n==="start"&&(e.style.visibility="visible"),n==="none")e.style.visibility=I;else if(n==="success")e.style.visibility=I,e.innerHTML="Upload succeeded!";else{const t=Math.round(parseFloat(o));e.innerHTML=`Uploading <span class="ul-upload-progress-label__time">${t}%</span>`,e.style.background=`linear-gradient(to right, #E0E0EB 0%, #E0E0EB ${t}%, #FCFCFD ${t}%, #FCFCFD 100%)`}},te=(e,n)=>{const o=c.videojs(e.id());return o==null?void 0:o.payload[n]},ke=(e,n)=>{const o=new(c.videojs.getComponent("Component"))(e);return o.addClass("ul-buttons-panel"),n.map(t=>{o.addChild(t)}),Se(o),o},Se=e=>{e.children().forEach(n=>{if(P[n.name_]){const o=Q(P[n.name_],`ul-${P[n.name_]}`);n.el_.appendChild(o)}})},Q=(e,n="")=>{const o=c.document.createElement("span");return o.className="ul-button-text",o.innerHTML=e,o.id=n,o},Ie=(e,n,o,t,i=!1,l)=>{e.addClass("ul-video-player");const d=new(c.videojs.getComponent("Component"))(e);d.addClass("ul-control-panel"),e.progressBar=d.addChild("ProgressControl"),o&&e.src(o),e.audioPlayerPlaceholder=new(c.videojs.getComponent("Component"))(e),e.audioPlayerPlaceholder.addClass("ul-audio-recorder-placeholder");const a=o&&o.src?Ve(o.src):null;!o||!i&&a?(e.audioPlayerPlaceholder.hide(),c.document.getElementById(`${e.id()}_html5_api`).style.height="100%",a&&e.poster(a)):(e.children()[0].classList.add("vjs-hidden"),c.document.getElementById(`${e.id()}_html5_api`).style.height="0px"),e.on("play",()=>{i||!o||a||Ne(e),l==null||l.play()}),e.on("pause",()=>{l==null||l.pause()}),e.on("seeked",()=>{l==null||l.currentTime(e.currentTime())}),e.on("ratechange",()=>{l==null||l.playbackRate(e.playbackRate())}),e.addChild(e.audioPlayerPlaceholder,{},1),d.addChild(n),e.addChild(d),t&&t(e)},Ue=(e,n,o,t,i,l,d,a=!1)=>{be=Date.now();const s=X(n,{controls:!1,bigPlayButton:!1,fluid:!1,width:1280,height:720,playsinline:!0,plugins:{record:{audio:!0,video:{mandatory:{minWidth:1280,minHeight:720}},frameWidth:1280,frameHeight:720,maxLength:600,autoMuteDevice:!0}}});if(!s)return;s.payload=o;const{surveyId:u,questionId:m,responseGroupUid:j,visitorId:D,envId:T}=o;let v;const h=p=>{const C=ne,b=ne+"-audio-only";Ce(s.uploadProgressLabel,"none"),H&&H.startTime>=be&&H.abort();const E=c.document.getElementById("ul-camera-button");p?(s.children()[0].classList.add("vjs-hidden"),y.removeClass(C),y.addClass(b),E.innerHTML=P.TurnOnCamera,s.audioPlayerPlaceholder.removeClass("vjs-hidden"),v==null||v.getTracks().forEach(w=>{w.stop()}),window.navigator.mediaDevices.getUserMedia({video:!0,audio:!0}).then(w=>{v=w,w.getVideoTracks().forEach(S=>{S.enabled=!1}),s.record().onDeviceReady(w)}).catch(s.record().onDeviceError.bind(s.record()))):(v==null||v.getVideoTracks().forEach(w=>{w.enabled=!0}),s.children()[0].classList.remove("vjs-hidden"),s.record().getDevice(),y.removeClass(b),y.addClass(C),E.innerHTML=P.TurnOffCamera,s.audioPlayerPlaceholder.addClass("vjs-hidden"))},g=new(c.videojs.getComponent("Button"))(s,{clickHandler:()=>{g.hasClass(I)||(F({event:"Video Delete Button Clicked",apiBase:t,headers:d,visitorId:D,envId:T,metadata:{questionId:m,responseGroupUid:j,surveyId:u}}),h(s.cameraOff),i(f.DELETE,{}),y.removeClass(I),g.addClass(I))}});g.addClass("ul-video-recorder-delete-button"),g.el_.appendChild(Q(P.DeleteButton,"ul-delete-button"));const x=c.document.getElementById(n),k=()=>{x.classList.contains("vjs-fullscreen")&&s.cameraOff?x.style.display="table":x.style.display="flex"};k();const y=new(c.videojs.getComponent("Button"))(s,{clickHandler:()=>{s.record().isRecording()||(s.cameraOff=!s.cameraOff,F({event:"Video Camera Button Clicked",apiBase:t,headers:d,visitorId:o.visitorId,envId:o.envId,metadata:{questionId:m,responseGroupUid:j,surveyId:u,cameraOff:s.cameraOff}}),h(s.cameraOff),!g.hasClass(I)&&g.addClass(I),i(f.DELETE,{}),k())}});y.addClass(ne),y.el_.appendChild(Q(P.TurnOffCamera,"ul-camera-button"));const L=new(c.videojs.getComponent("Button"))(s,{clickHandler:()=>{const p=c.document.getElementById("ul-recorder-toggle");if(s.record().isRecording())s.record().stop(),p&&(p.innerHTML=P.RecordButton),L.removeClass(oe),g.removeClass(I);else{const C=c.document.getElementById("ul-recording-countdown-screen");if(C)C.remove(),p&&(p.innerHTML=P.RecordButton),h(s.cameraOff),i(f.DELETE,{}),y.removeClass(I),g.addClass(I),L.removeClass(oe),_.show();else{L.addClass(oe),_.hide(),y.addClass(I),g.addClass(I),p&&(p.innerHTML=P.StopButton);const b=c.document.createElement("div");b.id="ul-recording-countdown-screen",x.insertBefore(b,x.children[1]),b.style.height=`${x.offsetHeight}px`,De(s,3)}}}});L.addClass("ul-video-recorder-toggle-button"),L.el_.appendChild(Q(P.RecordButton,"ul-recorder-toggle"));const A=c.document.createElement("p");A.style.visibility="hidden",A.className="ul-upload-progress-label",e.appendChild(A),s.uploadProgressLabel=A;const W=ke(s,[g,y,"PlayToggle",L,"FullscreenToggle"]),_=W.children().find(p=>p.name_==="FullscreenToggle");_.hasClass("vjs-disabled")&&_.hide();const M=W.children().find(p=>p.name_==="PlayToggle");M.hide(),g.addClass(I),Ie(s,W,l,!1,a),s.on("stopRecord",()=>{L.hide(),M.show(),_.show(),g.removeClass(I)}),s.on("deviceReady",()=>{L.show(),M.hide(),g.addClass(I)}),((p,C,b,E,w)=>{const{surveyId:S,responseGroupUid:$,visitorId:R,envId:O}=p.payload;p.on("deviceError",function(){console.warn("device error: ",p.deviceErrorCode),p.deviceErrorCode.message==="Permission denied"?(p.deviceButton.addClass("permission-denied"),b&&b(f.ERROR,{type:f.PERMISSION_DENIED}),F({event:"Video Permission Denied",apiBase:C,headers:w,visitorId:R,envId:O,metadata:{questionId:te(p,ee),responseGroupUid:$,surveyId:S}})):(b&&b(f.ERROR,{type:f.OTHER}),N(new Error(p.deviceErrorCode.message),"recorderDeviceError",C,w,R,O))}),p.on("error",function(z,U){N(U||p.error(),"recorderError",C,w,R,O)}),p.on("startRecord",function(z,U){E(p.uploadProgressLabel,"none"),F({event:"Video Record Start",apiBase:C,headers:w,visitorId:R,envId:O,metadata:{questionId:te(p,ee),responseGroupUid:$,surveyId:S}})}),p.on("finishRecord",async function(){E(p.uploadProgressLabel,"start",0);const z=te(p,ee);if(!S){const B="internal error: missing fields in payload";return b&&b(f.ERROR,{type:f.OTHER}),N(new Error(B),"finishRecord",C,w,R,O),null}p.record().stopDevice();const U=p.cameraOff?f.MEDIA_TYPE_AUDIO:f.MEDIA_TYPE_VIDEO,V=Re.v4();F({event:"Video Record Finish",apiBase:C,headers:w,visitorId:R,envId:O,metadata:{mediaRecordingUid:V,questionId:z,responseGroupUid:$,surveyId:S,mediaType:U}});const Y={surveyId:S,updatedAt:new Date().toISOString(),mediaType:U,mediaRecordingUid:V};z&&(Y.questionId=z),$&&(Y.responseGroupUid=$),R&&(Y.visitorId=R);const K=await(async()=>{const B=await fetch(`${C}/2/environments/integrations/upload`,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(Y)});if(B.ok){const se=await B.json();return b&&b(f.UPLOAD_STARTED,{[f.UPLOAD_ID]:se.upload.id,[f.MEDIA_TYPE]:U,[f.MEDIA_RECORDING_UID]:V}),se.upload.url}return b&&b(f.ERROR,{type:f.OTHER,response:B}),N(new Error("failed to get upload response with url"),"finishRecord",C,w,R,O),null})();K&&(H=c.document.defaultView.UpChunk.createUpload({endpoint:K,file:new c.document.defaultView.File([p.recordedData],`recording ${U} ${Date.now()}`),chunkSize:5120}),H.startTime=Date.now(),F({event:"Video Upload Start",apiBase:C,headers:w,visitorId:R,envId:O,metadata:{mediaRecordingUid:V,questionId:z,responseGroupUid:$,surveyId:S,mediaType:U,url:K}}),H.on("error",B=>{E(p.uploadProgressLabel,"none"),b&&b(f.UPLOAD_FINISHED,{[f.MEDIA_RECORDING_UID]:V}),N(B,"finishRecord",C,w,R,O)}),H.on("progress",B=>{b&&b(f.UPLOAD_PROGRESS,{[f.MEDIA_RECORDING_UID]:V,[f.UPLOAD_PROGRESS_PCT]:B.detail}),E(p.uploadProgressLabel,"progress",B.detail)}),H.on("success",()=>{E(p.uploadProgressLabel,"success"),b&&b(f.UPLOAD_FINISHED,{[f.MEDIA_RECORDING_UID]:V}),F({event:"Video Upload Success",apiBase:C,headers:w,visitorId:R,envId:O,metadata:{mediaRecordingUid:V,questionId:z,responseGroupUid:$,surveyId:S,mediaType:U,url:K,elapsedMs:H.startTime&&Date.now()-H.startTime}})}))})})(s,t,i,Ce,d);const Z=[{name:"microphone"}];!s.cameraOff&&Z.push({name:"camera"}),Promise.all(Z.map(p=>{var C;return(C=navigator==null?void 0:navigator.permissions)==null?void 0:C.query(p)})).then(p=>{p.reduce((C,b)=>C&b.state==="granted",!0)&&s&&(s.deviceButton&&s.deviceButton.hide(),s.record().getDevice())}).catch(p=>{})},De=(e,n=3)=>{const o=c.document.getElementById("ul-recording-countdown-screen");o&&n===0?(o.remove(),e.record().start()):o&&(o.innerHTML=`<span class='ul-countdown-text'>Recording in... ${n}</span>`,setTimeout(()=>{De(e,n-1)},1e3))},we=e=>{const n=c.document.createElement("div");return n.className="ul-video-container",n.appendChild((o=>{const t=c.document.createElement("div");return t.className="ul-video-player-loading",t.id=ie(o),["first","second","third","fourth"].map(i=>{const l=c.document.createElement("div");l.className=i,t.appendChild(l)}),t})(e)),n},re=(e,n)=>{const o=c.document.createElement("video");o.id=e,o.className="video-js vjs-default-skin ul-video-player-video";const t=c.document.createElement("p");t.className="vjs-no-js",t.innerHTML="To view this video please enable JavaScript, and consider upgrading to a web browser that";const i=c.document.createElement("a");return i.href="https://videojs.com/html5-video-support/",i.target="_blank",i.innerHTML="supports HTML5 video",t.appendChild(i),o.appendChild(t),n.appendChild(o),n},Ne=(e,n)=>{e.children()[0].classList.remove("vjs-hidden"),e.audioPlayerPlaceholder.hide(),c.document.getElementById(`${e.id()}_html5_api`).style.height="100%"},X=(e,n)=>c.document.getElementById(e)?n?c.videojs(e,n):c.videojs(e):(console.error(`Error in finding player element with ID, ${e}`),null),Ve=e=>{if(!e)return null;const n=e.match(/https:\/\/stream.mux.com\/(.*)/);let o=n?n[1]:null;return o.includes(pe)&&(o=o.replace(pe,"")),o?`https://image.mux.com/${o}/thumbnail.jpg?time=0`:null},f={UPLOAD_STARTED:"upload.started",UPLOAD_PROGRESS:"upload.progress",UPLOAD_FINISHED:"upload.finished",DELETE:"delete",ERROR:"error",MEDIA_TYPE:"media.type",PERMISSION_DENIED:"permission_denied",OTHER:"other",UPLOAD_ID:"upload.id",UPLOAD_PROGRESS_PCT:"upload.progress.pct",MEDIA_RECORDING_UID:"media.recording.uid",MEDIA_TYPE_VIDEO:"video",MEDIA_TYPE_AUDIO:"audio"},P={PlaybackRateMenuButton:"Speed",PlayToggle:"Play",FullscreenToggle:"Expand",TurnOnCamera:"Turn on",TurnOffCamera:"Turn off",DeleteButton:"Delete",RecordButton:"Record",StopButton:"Stop",PauseButton:"Pause"};var Te=(e=>(e.CONTINUE="CONTINUE",e.EXTERNAL="EXTERNAL",e.NO_BUTTON="NO_BUTTON",e))(Te||{}),Le=(e=>(e.Unlimited="Unlimited",e.Maximum="Maximum",e.Range="Range",e))(Le||{});const Fe=({options:e,selectItem:n,selectedOptions:o,showCheckbox:t,disabledOptions:i,dropdownFooter:l})=>{const{themeColor:d}=r.useConfig(a=>({doc:a.viewDocument,themeColor:a.border}));return r.u("div",{className:"select-list",children:[e.map(a=>{return r.u("div",{"aria-disabled":i==null?void 0:i.includes(a),className:r.cc("select-option",i!=null&&i.includes(a)?"ul-choice-disabled":""),onClick:u=>{i!=null&&i.includes(a)||(n(a),u.stopPropagation())},role:"option",style:{...i!=null&&i.includes(a)?{opacity:.5,cursor:"not-allowed"}:{}},children:[t&&r.u(Ee,{divId:(s=a.id,`checkbox-div-${s}`),id:a.id,isSelected:o.includes(a),themeColor:d}),a.label]},a.id);var s}),l]})},Ae={"{{user_id}}":"externalUserId","{{email}}":"email"};exports.Button=le,exports.Header=({message:e,properties:n,isRequired:o})=>{const t=r._(null),i=n==null?void 0:n.captionText,l=ae();return r.u("div",{className:r.cc("question-header-container","sprig-header-container",l?"sprig-border-bottom":null),ref:t,children:[r.u("div",{className:"question-header-button-container",children:[r.u(de,{className:"ul-question",id:"ul-question",isHeader:!0,plainText:e,richText:n==null?void 0:n.questionHtml,showAsterisk:o}),r.u(Pe,{})]}),r.u(de,{className:"ul-caption",id:"ul-caption",plainText:i,richText:n==null?void 0:n.captionHtml})]})},exports.Html=ye,exports.LongformSubmitButton=({isSubmitDisabled:e,handleSubmit:n})=>r.u("div",{className:"ul-card-longform__submit-button-container",children:r.u(le,{className:"ul-card-longform__submit-button",disabled:e,onClick:n,children:["OK ",r.u(_e,{})]})}),exports.MaxSelectModes=Le,exports.MobileEmbedView=({embeddedType:e="prototype",properties:n,children:o})=>{var T;const{handleClickEmbedButton:t,hasViewedEmbed:i,headers:l,useDesktopPrototype:d,update:a,isConversationalUI:s}=r.useConfig(v=>({handleClickEmbedButton:v.handleClickEmbedButton,hasViewedEmbed:v.hasViewedEmbed,headers:v.headers,useDesktopPrototype:v.useDesktopPrototype,update:v.update,isConversationalUI:v.isConversationalUI})),u=(n==null?void 0:n.conceptUrl)||((T=n==null?void 0:n.consentDocument)==null?void 0:T.url),m=window.innerWidth<G.EMBED_MOBILE_MAX_WIDTH,j=l["userleap-platform"],D=(v,h)=>{v.preventDefault(),t(h)};if(r.p(()=>{s||requestAnimationFrame(()=>{a()})},[a,s]),!d&&m&&!i&&u&&["email","link"].includes(j)){if(e==="prototype")return r.u(ce,{handleClick:v=>{D(v,"question.prototype.click")}});if(e==="pdf")return r.u(ce,{buttonText:(n==null?void 0:n.viewDocumentText)||"View Document",handleClick:v=>{D(v,"question.agreement.click")}})}return r.u(r.g,{children:o})},exports.Option=({ariaLabel:e,border:n,choiceStyle:o={},label:t,isSelected:i,value:l,text:d,id:a,isRadio:s,useMobileStyling:u,error:m,allowTextEntry:j,noneOfTheAbove:D,promptText:T,disabled:v=!1,onUserInputChanged:h})=>{const{styleNonce:g,viewDocument:x}=r.useConfig(E=>({styleNonce:E.styleNonce,viewDocument:E.viewDocument})),[k,y]=r.h(!1);Oe(x,n,g);const L=({isSelected:E,userText:w})=>{h&&h({id:a,selected:E,value:l,userText:w,noneOfTheAbove:D})},A=E=>{v||(E.stopPropagation(),L({isSelected:s||!i,userText:d}),y(!1))},W=()=>{k||y(!0)},_=()=>{k&&y(!1)},M={onClick:E=>A(E),onKeyPress:E=>(w=>{v||w.key!=="Enter"&&w.key!==" "||A(w)})(E)};"ontouchstart"in x.documentElement?(M.onTouchStart=_,M.onTouchCancel=_,M.onTouchEnd=_):(M.onMouseDown=W,M.onMouseLeave=_);const Z=s?`radio-${a}`:`checkbox-${a}`,p=i||k?[J]:[],C=[...m?[je]:[],...p,...v?["ul-choice-disabled"]:[]],b=t?{"aria-labelledby":`label-${a}`}:{"aria-label":e};return r.u("div",{className:r.cc(r.getClasses("choice",u),...C),id:`choice-div-${a}`,style:{...o,...m?{borderColor:G.ERROR_BORDER_COLOR}:{},...v?{opacity:.5,cursor:"not-allowed"}:{}},...v?{}:M,"aria-disabled":v,children:[r.u("div",{className:r.cc("choice-label-container"),children:[s?r.u("div",{...b,className:r.cc("select-radio",...p),id:Z,role:"radio",tabIndex:0}):r.u(Ee,{disabled:v,divId:Z,id:a,isSelected:i,themeColor:n}),t&&r.u("label",{className:r.cc(r.getClasses("select-label",u)),htmlFor:Z,id:`label-${a}`,children:t})]}),j&&i&&r.u("div",{className:r.cc("choice-text-entry-container",...p),children:r.u(Me,{onTextChange:E=>L({isSelected:i,userText:E}),promptText:T||"Please specify",textValue:d,useMobileStyling:u})})]})},exports.PromptActionTypeEnum=Te,exports.QuestionBodyFooterContainer=({children:e})=>{const n=ae(),{isConversationalUI:o}=r.useConfig(t=>({isConversationalUI:t.isConversationalUI}));return r.u("div",{className:r.cc("sprig-question-footer-container",n&&!o?"sprig-border-top":null),children:e})},exports.QuestionBodyWrapper=({children:e})=>r.u("div",{className:"sprig-question-body",children:e}),exports.RECORDER=f,exports.Select=({isMultiSelect:e=!1,multiselectText:n="choices selected",onChange:o,options:t,placeholderText:i,value:l,disabledOptions:d=[],dropdownFooter:a})=>{const[s,u]=r.h(!1),{viewDocument:m,update:j,isConversationalUI:D}=r.useConfig(h=>({viewDocument:h.viewDocument,update:h.update,isConversationalUI:h.isConversationalUI})),T=()=>{u(!s)};r.y(()=>{D||j()},[s,D,j]),r.p(()=>{var g;const h=x=>{const k=x.target;(k==null?void 0:k.closest(".select-option.ul-choice-disabled"))||u(!1)};m.addEventListener("click",h);try{(g=window.parent)==null||g.addEventListener("click",h)}catch{window.addEventListener("click",h)}return()=>{var x;m.removeEventListener("click",h);try{(x=window.parent)==null||x.removeEventListener("click",h)}catch{window.removeEventListener("click",h)}}},[m]);const v=l.length===0?["select-button-placeholder"]:[];return r.u(r.g,{children:[r.u("button",{"aria-label":"choice dropdown button",className:r.cc("select-button",...v),onClick:h=>{h.stopPropagation(),T()},type:"button",children:[r.u("span",{children:l.length===0?i:l.length===1?l[0].label:`${l.length} ${n}`}),r.u(r.SvgCaret,{})]}),s&&r.u(Fe,{disabledOptions:d,dropdownFooter:a,options:t,selectedOptions:l,selectItem:h=>{var k;const g=l.some(y=>y.id===h.id),x=l.some(y=>{var L;return(L=y.optionProperties)==null?void 0:L.noneOfTheAbove});(k=h.optionProperties)!=null&&k.noneOfTheAbove&&!g?o([h]):e?o(g?l.filter(y=>y.id!==h.id):x?[h]:[...l,h]):g||o([h]),e||T()},showCheckbox:e})]})},exports.getAttributedUrl=(e=void 0,n={})=>{if(!e)return e;const o=["http:","https:","itms-apps:","market:"],t=(d=>/^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//.test(d)?d:`http://${d}`)(e);if(!t)return;try{const d=new URL(t);if(!d.protocol||!o.includes(d.protocol))return}catch{return}const i=[],l=((d,a,s)=>{let u=d;for(const[m,j]of Object.entries(Ae))if(u.toLowerCase().includes(m))if(a[j]){const D=new RegExp(m,"gi");u=u.replace(D,a[j])}else s.push(m);return u})(t,n,i);return i.length===0?l:((d,a)=>{if(!d.includes("?"))return d;const s=d.slice(0,d.indexOf("?")),u=d.slice(d.indexOf("?")+1).split("&").map(m=>m.split("=")).filter(m=>!a.includes(m[1]));return u.length===0?s:`${s}?${u.map(m=>m.join("=")).join("&")}`})(l,i)},exports.pauseQuestionPlayer=e=>{const n=X(e+he);n==null||n.pause()},exports.stopRecording=e=>{const n=e+ge;if(c.document.getElementById(n)&&c.videojs){try{if(!c.videojs(n).record().stream)return}catch{return}c.videojs(n).record().stop(),c.videojs(n).record().stopDevice()}},exports.useAutoSize=xe,exports.videoPlayer=(e,n,o,t=!1,i="https://api.sprig.com",l=document,d=null,a=null)=>{c.document=l;const s=e+he,u=we(s);return c.document.addEventListener("securitypolicyviolation",m=>{N(new Error(`Voice & Video feature violates ${m.violatedDirective} web page CSP policies for the question player.`),"playerDeviceError",i,{})}),fe(ve,()=>{c.document.getElementById(ie(s)).remove(),re(s,u);const m={playsinline:!0,playbackRates:[.5,1,1.5,2],fill:!0};try{const j=e+me;re(j,u);const D=X(s,m),T=X(j,{muted:!0,...m});if(!D||!T)return;((g,x,k)=>{g.addClass(`ul${me}`);const y=new(c.videojs.getComponent("Component"))(g);x&&g.src(x),g.addChild(y),k&&k(g)})(T,d,a),d||T.addClass(I);const v=ke(D,["PlaybackRateMenuButton","PlayToggle","FullscreenToggle"]),h=v.children().find(g=>g.name_==="FullscreenToggle");h.hasClass("vjs-disabled")&&h.hide(),Ie(D,v,n,o,t,T)}catch(j){return void N(new Error(`Error when creating video player object ${j}`),"playerDeviceError",i,{})}}),u},exports.videoRecorderPlayer=(e,n={},o="https://api.userleap.com",t,i,l,d=!1,a=document)=>{c.document=a;const s=e+ge,u=we(s);return c.document.addEventListener("securitypolicyviolation",m=>{N(new Error(`Voice & Video feature violates ${m.violatedDirective} web page CSP policies for the recorder player.`),"recorderDeviceError",o,l,n.visitorId,n.envId)}),fe(ve.concat(He),()=>{re(s,u),c.document.getElementById(ie(s)).remove();try{Ue(u,s,n,o,t,i,l,d)}catch(m){return void N(new Error(`Error when creating video recorder player object ${m}`),"recorderDeviceError",o,l,n.visitorId,n.envId)}}),u};
|
|
669
|
+
`}],he="-video-player",me="-secondary-video-player",ge="-video-recorder";let H,be;const F=async({event:e,apiBase:n,headers:o,visitorId:t,envId:r,metadata:l})=>{const a=c.document.documentElement;if(!t||!r)return;const d={event:`SDK - ${e}`,visitorId:t,environmentId:r,metadata:{...l||{},screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:a.clientWidth,clientHeight:a.clientHeight,location:window.location.href,language:navigator.language}};(await fetch(`${n}/sdk/1/visitors/${t}/analytics`,{method:"POST",cache:"no-cache",headers:o,body:JSON.stringify(d)})).ok||console.warn("[Sprig] (ERR-444) Failed to track analytics",e)},N=async(e,n,o,t,r,l)=>{F({event:`Video Error ${n}`,apiBase:o,headers:t,visitorId:r,envId:l,metadata:{errorMessage:e.message}});const a=c.document.documentElement,d={screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:a.clientWidth,clientHeight:a.clientHeight,location:window.location.href,language:navigator.language},s={action:n,err:{message:e.message,stack:e.stack},meta:d,vid:r,envId:l};(await fetch(`${o}/sdk/1/errors`,{method:"POST",cache:"no-cache",headers:{...t,"userleap-platform":"video_recorder","x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(s)})).ok||console.warn("[Sprig] (ERR-444) Failed to report error to API",e)},fe=(e,n)=>{if(e.length===0)return n&&n();Promise.all(e.reduce((o,t)=>(o.push(((r,{type:l,content:a})=>new Promise(function(d,s){let u;l==="script"?(u=c.document.createElement("script"),u.src=a):l==="link"?(u=c.document.createElement("link"),u.rel="stylesheet",u.href=a,u.type="text/css"):(u=c.document.createElement("style"),u.innerHTML=a),u.onload=function(){d(a)},u.onerror=function(){s(a)},u.async=!1,u.id=btoa(a),r.appendChild(u)}))(c.document.head,t)),o),[])).then(()=>{c.videojs=c.document.defaultView.videojs,n&&n()}).catch(function(o){console.log(o+" failed to load")})},Ce=(e,n,o)=>{if(n==="start"&&(e.style.visibility="visible"),n==="none")e.style.visibility=T;else if(n==="success")e.style.visibility=T,e.innerHTML="Upload succeeded!";else{const t=Math.round(parseFloat(o));e.innerHTML=`Uploading <span class="ul-upload-progress-label__time">${t}%</span>`,e.style.background=`linear-gradient(to right, #E0E0EB 0%, #E0E0EB ${t}%, #FCFCFD ${t}%, #FCFCFD 100%)`}},te=(e,n)=>{const o=c.videojs(e.id());return o==null?void 0:o.payload[n]},ke=(e,n)=>{const o=new(c.videojs.getComponent("Component"))(e);return o.addClass("ul-buttons-panel"),n.map(t=>{o.addChild(t)}),Se(o),o},Se=e=>{e.children().forEach(n=>{if(_[n.name_]){const o=Q(_[n.name_],`ul-${_[n.name_]}`);n.el_.appendChild(o)}})},Q=(e,n="")=>{const o=c.document.createElement("span");return o.className="ul-button-text",o.innerHTML=e,o.id=n,o},Ie=(e,n,o,t,r=!1,l)=>{e.addClass("ul-video-player");const a=new(c.videojs.getComponent("Component"))(e);a.addClass("ul-control-panel"),e.progressBar=a.addChild("ProgressControl"),o&&e.src(o),e.audioPlayerPlaceholder=new(c.videojs.getComponent("Component"))(e),e.audioPlayerPlaceholder.addClass("ul-audio-recorder-placeholder");const d=o&&o.src?Ve(o.src):null;!o||!r&&d?(e.audioPlayerPlaceholder.hide(),c.document.getElementById(`${e.id()}_html5_api`).style.height="100%",d&&e.poster(d)):(e.children()[0].classList.add("vjs-hidden"),c.document.getElementById(`${e.id()}_html5_api`).style.height="0px"),e.on("play",()=>{r||!o||d||Ne(e),l==null||l.play()}),e.on("pause",()=>{l==null||l.pause()}),e.on("seeked",()=>{l==null||l.currentTime(e.currentTime())}),e.on("ratechange",()=>{l==null||l.playbackRate(e.playbackRate())}),e.addChild(e.audioPlayerPlaceholder,{},1),a.addChild(n),e.addChild(a),t&&t(e)},Ue=(e,n,o,t,r,l,a,d=!1)=>{be=Date.now();const s=X(n,{controls:!1,bigPlayButton:!1,fluid:!1,width:1280,height:720,playsinline:!0,plugins:{record:{audio:!0,video:{mandatory:{minWidth:1280,minHeight:720}},frameWidth:1280,frameHeight:720,maxLength:600,autoMuteDevice:!0}}});if(!s)return;s.payload=o;const{surveyId:u,questionId:m,responseGroupUid:I,visitorId:b,envId:R}=o;let x;const v=p=>{const y=ne,g=ne+"-audio-only";Ce(s.uploadProgressLabel,"none"),H&&H.startTime>=be&&H.abort();const k=c.document.getElementById("ul-camera-button");p?(s.children()[0].classList.add("vjs-hidden"),C.removeClass(y),C.addClass(g),k.innerHTML=_.TurnOnCamera,s.audioPlayerPlaceholder.removeClass("vjs-hidden"),x==null||x.getTracks().forEach(E=>{E.stop()}),window.navigator.mediaDevices.getUserMedia({video:!0,audio:!0}).then(E=>{x=E,E.getVideoTracks().forEach(S=>{S.enabled=!1}),s.record().onDeviceReady(E)}).catch(s.record().onDeviceError.bind(s.record()))):(x==null||x.getVideoTracks().forEach(E=>{E.enabled=!0}),s.children()[0].classList.remove("vjs-hidden"),s.record().getDevice(),C.removeClass(g),C.addClass(y),k.innerHTML=_.TurnOffCamera,s.audioPlayerPlaceholder.addClass("vjs-hidden"))},h=new(c.videojs.getComponent("Button"))(s,{clickHandler:()=>{h.hasClass(T)||(F({event:"Video Delete Button Clicked",apiBase:t,headers:a,visitorId:b,envId:R,metadata:{questionId:m,responseGroupUid:I,surveyId:u}}),v(s.cameraOff),r(w.DELETE,{}),C.removeClass(T),h.addClass(T))}});h.addClass("ul-video-recorder-delete-button"),h.el_.appendChild(Q(_.DeleteButton,"ul-delete-button"));const f=c.document.getElementById(n),j=()=>{f.classList.contains("vjs-fullscreen")&&s.cameraOff?f.style.display="table":f.style.display="flex"};j();const C=new(c.videojs.getComponent("Button"))(s,{clickHandler:()=>{s.record().isRecording()||(s.cameraOff=!s.cameraOff,F({event:"Video Camera Button Clicked",apiBase:t,headers:a,visitorId:o.visitorId,envId:o.envId,metadata:{questionId:m,responseGroupUid:I,surveyId:u,cameraOff:s.cameraOff}}),v(s.cameraOff),!h.hasClass(T)&&h.addClass(T),r(w.DELETE,{}),j())}});C.addClass(ne),C.el_.appendChild(Q(_.TurnOffCamera,"ul-camera-button"));const D=new(c.videojs.getComponent("Button"))(s,{clickHandler:()=>{const p=c.document.getElementById("ul-recorder-toggle");if(s.record().isRecording())s.record().stop(),p&&(p.innerHTML=_.RecordButton),D.removeClass(oe),h.removeClass(T);else{const y=c.document.getElementById("ul-recording-countdown-screen");if(y)y.remove(),p&&(p.innerHTML=_.RecordButton),v(s.cameraOff),r(w.DELETE,{}),C.removeClass(T),h.addClass(T),D.removeClass(oe),P.show();else{D.addClass(oe),P.hide(),C.addClass(T),h.addClass(T),p&&(p.innerHTML=_.StopButton);const g=c.document.createElement("div");g.id="ul-recording-countdown-screen",f.insertBefore(g,f.children[1]),g.style.height=`${f.offsetHeight}px`,De(s,3)}}}});D.addClass("ul-video-recorder-toggle-button"),D.el_.appendChild(Q(_.RecordButton,"ul-recorder-toggle"));const A=c.document.createElement("p");A.style.visibility="hidden",A.className="ul-upload-progress-label",e.appendChild(A),s.uploadProgressLabel=A;const G=ke(s,[h,C,"PlayToggle",D,"FullscreenToggle"]),P=G.children().find(p=>p.name_==="FullscreenToggle");P.hasClass("vjs-disabled")&&P.hide();const O=G.children().find(p=>p.name_==="PlayToggle");O.hide(),h.addClass(T),Ie(s,G,l,!1,d),s.on("stopRecord",()=>{D.hide(),O.show(),P.show(),h.removeClass(T)}),s.on("deviceReady",()=>{D.show(),O.hide(),h.addClass(T)}),((p,y,g,k,E)=>{const{surveyId:S,responseGroupUid:$,visitorId:L,envId:M}=p.payload;p.on("deviceError",function(){console.warn("device error: ",p.deviceErrorCode),p.deviceErrorCode.message==="Permission denied"?(p.deviceButton.addClass("permission-denied"),g&&g(w.ERROR,{type:w.PERMISSION_DENIED}),F({event:"Video Permission Denied",apiBase:y,headers:E,visitorId:L,envId:M,metadata:{questionId:te(p,ee),responseGroupUid:$,surveyId:S}})):(g&&g(w.ERROR,{type:w.OTHER}),N(new Error(p.deviceErrorCode.message),"recorderDeviceError",y,E,L,M))}),p.on("error",function(z,U){N(U||p.error(),"recorderError",y,E,L,M)}),p.on("startRecord",function(z,U){k(p.uploadProgressLabel,"none"),F({event:"Video Record Start",apiBase:y,headers:E,visitorId:L,envId:M,metadata:{questionId:te(p,ee),responseGroupUid:$,surveyId:S}})}),p.on("finishRecord",async function(){k(p.uploadProgressLabel,"start",0);const z=te(p,ee);if(!S){const B="internal error: missing fields in payload";return g&&g(w.ERROR,{type:w.OTHER}),N(new Error(B),"finishRecord",y,E,L,M),null}p.record().stopDevice();const U=p.cameraOff?w.MEDIA_TYPE_AUDIO:w.MEDIA_TYPE_VIDEO,V=_e.v4();F({event:"Video Record Finish",apiBase:y,headers:E,visitorId:L,envId:M,metadata:{mediaRecordingUid:V,questionId:z,responseGroupUid:$,surveyId:S,mediaType:U}});const Y={surveyId:S,updatedAt:new Date().toISOString(),mediaType:U,mediaRecordingUid:V};z&&(Y.questionId=z),$&&(Y.responseGroupUid=$),L&&(Y.visitorId=L);const J=await(async()=>{const B=await fetch(`${y}/2/environments/integrations/upload`,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(Y)});if(B.ok){const se=await B.json();return g&&g(w.UPLOAD_STARTED,{[w.UPLOAD_ID]:se.upload.id,[w.MEDIA_TYPE]:U,[w.MEDIA_RECORDING_UID]:V}),se.upload.url}return g&&g(w.ERROR,{type:w.OTHER,response:B}),N(new Error("failed to get upload response with url"),"finishRecord",y,E,L,M),null})();J&&(H=c.document.defaultView.UpChunk.createUpload({endpoint:J,file:new c.document.defaultView.File([p.recordedData],`recording ${U} ${Date.now()}`),chunkSize:5120}),H.startTime=Date.now(),F({event:"Video Upload Start",apiBase:y,headers:E,visitorId:L,envId:M,metadata:{mediaRecordingUid:V,questionId:z,responseGroupUid:$,surveyId:S,mediaType:U,url:J}}),H.on("error",B=>{k(p.uploadProgressLabel,"none"),g&&g(w.UPLOAD_FINISHED,{[w.MEDIA_RECORDING_UID]:V}),N(B,"finishRecord",y,E,L,M)}),H.on("progress",B=>{g&&g(w.UPLOAD_PROGRESS,{[w.MEDIA_RECORDING_UID]:V,[w.UPLOAD_PROGRESS_PCT]:B.detail}),k(p.uploadProgressLabel,"progress",B.detail)}),H.on("success",()=>{k(p.uploadProgressLabel,"success"),g&&g(w.UPLOAD_FINISHED,{[w.MEDIA_RECORDING_UID]:V}),F({event:"Video Upload Success",apiBase:y,headers:E,visitorId:L,envId:M,metadata:{mediaRecordingUid:V,questionId:z,responseGroupUid:$,surveyId:S,mediaType:U,url:J,elapsedMs:H.startTime&&Date.now()-H.startTime}})}))})})(s,t,r,Ce,a);const Z=[{name:"microphone"}];!s.cameraOff&&Z.push({name:"camera"}),Promise.all(Z.map(p=>{var y;return(y=navigator==null?void 0:navigator.permissions)==null?void 0:y.query(p)})).then(p=>{p.reduce((y,g)=>y&g.state==="granted",!0)&&s&&(s.deviceButton&&s.deviceButton.hide(),s.record().getDevice())}).catch(p=>{})},De=(e,n=3)=>{const o=c.document.getElementById("ul-recording-countdown-screen");o&&n===0?(o.remove(),e.record().start()):o&&(o.innerHTML=`<span class='ul-countdown-text'>Recording in... ${n}</span>`,setTimeout(()=>{De(e,n-1)},1e3))},we=e=>{const n=c.document.createElement("div");return n.className="ul-video-container",n.appendChild((o=>{const t=c.document.createElement("div");return t.className="ul-video-player-loading",t.id=ie(o),["first","second","third","fourth"].map(r=>{const l=c.document.createElement("div");l.className=r,t.appendChild(l)}),t})(e)),n},re=(e,n)=>{const o=c.document.createElement("video");o.id=e,o.className="video-js vjs-default-skin ul-video-player-video";const t=c.document.createElement("p");t.className="vjs-no-js",t.innerHTML="To view this video please enable JavaScript, and consider upgrading to a web browser that";const r=c.document.createElement("a");return r.href="https://videojs.com/html5-video-support/",r.target="_blank",r.innerHTML="supports HTML5 video",t.appendChild(r),o.appendChild(t),n.appendChild(o),n},Ne=(e,n)=>{e.children()[0].classList.remove("vjs-hidden"),e.audioPlayerPlaceholder.hide(),c.document.getElementById(`${e.id()}_html5_api`).style.height="100%"},X=(e,n)=>c.document.getElementById(e)?n?c.videojs(e,n):c.videojs(e):(console.error(`Error in finding player element with ID, ${e}`),null),Ve=e=>{if(!e)return null;const n=e.match(/https:\/\/stream.mux.com\/(.*)/);let o=n?n[1]:null;return o.includes(pe)&&(o=o.replace(pe,"")),o?`https://image.mux.com/${o}/thumbnail.jpg?time=0`:null},w={UPLOAD_STARTED:"upload.started",UPLOAD_PROGRESS:"upload.progress",UPLOAD_FINISHED:"upload.finished",DELETE:"delete",ERROR:"error",MEDIA_TYPE:"media.type",PERMISSION_DENIED:"permission_denied",OTHER:"other",UPLOAD_ID:"upload.id",UPLOAD_PROGRESS_PCT:"upload.progress.pct",MEDIA_RECORDING_UID:"media.recording.uid",MEDIA_TYPE_VIDEO:"video",MEDIA_TYPE_AUDIO:"audio"},_={PlaybackRateMenuButton:"Speed",PlayToggle:"Play",FullscreenToggle:"Expand",TurnOnCamera:"Turn on",TurnOffCamera:"Turn off",DeleteButton:"Delete",RecordButton:"Record",StopButton:"Stop",PauseButton:"Pause"};var Te=(e=>(e.CONTINUE="CONTINUE",e.EXTERNAL="EXTERNAL",e.NO_BUTTON="NO_BUTTON",e))(Te||{}),Re=(e=>(e.Unlimited="Unlimited",e.Maximum="Maximum",e.Range="Range",e))(Re||{});const Fe=({options:e,selectItem:n,selectedOptions:o,showCheckbox:t,disabledOptions:r,dropdownFooter:l})=>{const{themeColor:a}=i.useConfig(d=>({doc:d.viewDocument,themeColor:d.border}));return i.u("div",{className:"select-list",children:[e.map(d=>{return i.u("div",{"aria-disabled":r==null?void 0:r.includes(d),className:i.cc("select-option",r!=null&&r.includes(d)?"ul-choice-disabled":""),onClick:u=>{r!=null&&r.includes(d)||(n(d),u.stopPropagation())},role:"option",style:{...r!=null&&r.includes(d)?{opacity:.5,cursor:"not-allowed"}:{}},children:[t&&i.u(xe,{divId:(s=d.id,`checkbox-div-${s}`),id:d.id,isSelected:o.includes(d),themeColor:a}),d.label]},d.id);var s}),l]})},Ae={"{{user_id}}":"externalUserId","{{email}}":"email"};exports.Button=le,exports.Header=({message:e,properties:n,isRequired:o})=>{const t=i._(null),r=n==null?void 0:n.captionText,l=ae();return i.u("div",{className:i.cc("question-header-container","sprig-header-container",l?"sprig-border-bottom":null),ref:t,children:[i.u("div",{className:"question-header-button-container",children:i.u(de,{className:"ul-question",id:"ul-question",isHeader:!0,plainText:e,richText:n==null?void 0:n.questionHtml,showAsterisk:o})}),i.u(de,{className:"ul-caption",id:"ul-caption",plainText:r,richText:n==null?void 0:n.captionHtml})]})},exports.Html=ye,exports.LongformSubmitButton=({isSubmitDisabled:e,handleSubmit:n})=>i.u("div",{className:"ul-card-longform__submit-button-container",children:i.u(le,{className:"ul-card-longform__submit-button",disabled:e,onClick:n,children:["OK ",i.u(Pe,{})]})}),exports.MaxSelectModes=Re,exports.MobileEmbedView=({embeddedType:e="prototype",properties:n,children:o})=>{var I;const{handleClickEmbedButton:t,hasViewedEmbed:r,headers:l,useDesktopPrototype:a}=i.useConfig(b=>({handleClickEmbedButton:b.handleClickEmbedButton,hasViewedEmbed:b.hasViewedEmbed,headers:b.headers,useDesktopPrototype:b.useDesktopPrototype})),d=(n==null?void 0:n.conceptUrl)||((I=n==null?void 0:n.consentDocument)==null?void 0:I.url),s=window.innerWidth<W.EMBED_MOBILE_MAX_WIDTH,u=l["userleap-platform"],m=(b,R)=>{b.preventDefault(),t(R)};if((()=>{const{update:b,index:R,isConversationalUI:x,viewDocument:v}=i.useConfig(({update:f,index:j,isConversationalUI:C,viewDocument:D})=>({update:f,index:j,isConversationalUI:C,viewDocument:D})),h=Le.debounce(b,100);i.p(()=>{if(x)return;const f=new ResizeObserver(h),j=v.querySelector(".ul-card__container");return j&&f.observe(j,{box:"border-box"}),()=>{f.disconnect()}},[h,b,R,x,v])})(),!a&&s&&!r&&d&&["email","link"].includes(u)){if(e==="prototype")return i.u(ce,{handleClick:b=>{m(b,"question.prototype.click")}});if(e==="pdf")return i.u(ce,{buttonText:(n==null?void 0:n.viewDocumentText)||"View Document",handleClick:b=>{m(b,"question.agreement.click")}})}return i.u(i.g,{children:o})},exports.Option=({ariaLabel:e,border:n,choiceStyle:o={},label:t,isSelected:r,value:l,text:a,id:d,isRadio:s,useMobileStyling:u,error:m,allowTextEntry:I,noneOfTheAbove:b,promptText:R,disabled:x=!1,onUserInputChanged:v})=>{const{styleNonce:h,viewDocument:f}=i.useConfig(k=>({styleNonce:k.styleNonce,viewDocument:k.viewDocument})),[j,C]=i.h(!1);Me(f,n,h);const D=({isSelected:k,userText:E})=>{v&&v({id:d,selected:k,value:l,userText:E,noneOfTheAbove:b})},A=k=>{x||(k.stopPropagation(),D({isSelected:s||!r,userText:a}),C(!1))},G=()=>{j||C(!0)},P=()=>{j&&C(!1)},O={onClick:k=>A(k),onKeyPress:k=>(E=>{x||E.key!=="Enter"&&E.key!==" "||A(E)})(k)};"ontouchstart"in f.documentElement?(O.onTouchStart=P,O.onTouchCancel=P,O.onTouchEnd=P):(O.onMouseDown=G,O.onMouseLeave=P);const Z=s?`radio-${d}`:`checkbox-${d}`,p=r||j?[K]:[],y=[...m?[je]:[],...p,...x?["ul-choice-disabled"]:[]],g=t?{"aria-labelledby":`label-${d}`}:{"aria-label":e};return i.u("div",{className:i.cc(i.getClasses("choice",u),...y),id:`choice-div-${d}`,style:{...o,...m?{borderColor:W.ERROR_BORDER_COLOR}:{},...x?{opacity:.5,cursor:"not-allowed"}:{}},...x?{}:O,"aria-disabled":x,children:[i.u("div",{className:i.cc("choice-label-container"),children:[s?i.u("div",{...g,className:i.cc("select-radio",...p),id:Z,role:"radio",tabIndex:0}):i.u(xe,{disabled:x,divId:Z,id:d,isSelected:r,themeColor:n}),t&&i.u("label",{className:i.cc(i.getClasses("select-label",u)),htmlFor:Z,id:`label-${d}`,children:t})]}),I&&r&&i.u("div",{className:i.cc("choice-text-entry-container",...p),children:i.u(Oe,{onTextChange:k=>D({isSelected:r,userText:k}),promptText:R||"Please specify",textValue:a,useMobileStyling:u})})]})},exports.PromptActionTypeEnum=Te,exports.QuestionBodyFooterContainer=({children:e})=>{const n=ae(),{isConversationalUI:o}=i.useConfig(t=>({isConversationalUI:t.isConversationalUI}));return i.u("div",{className:i.cc("sprig-question-footer-container",n&&!o?"sprig-border-top":null),children:e})},exports.QuestionBodyWrapper=({children:e})=>i.u("div",{className:"sprig-question-body",children:e}),exports.RECORDER=w,exports.Select=({isMultiSelect:e=!1,multiselectText:n="choices selected",onChange:o,options:t,placeholderText:r,value:l,disabledOptions:a=[],dropdownFooter:d})=>{const[s,u]=i.h(!1),{viewDocument:m,update:I,isConversationalUI:b}=i.useConfig(v=>({viewDocument:v.viewDocument,update:v.update,isConversationalUI:v.isConversationalUI})),R=()=>{u(!s)};i.y(()=>{b||I()},[s,b,I]),i.p(()=>{var h;const v=f=>{const j=f.target;(j==null?void 0:j.closest(".select-option.ul-choice-disabled"))||u(!1)};m.addEventListener("click",v);try{(h=window.parent)==null||h.addEventListener("click",v)}catch{window.addEventListener("click",v)}return()=>{var f;m.removeEventListener("click",v);try{(f=window.parent)==null||f.removeEventListener("click",v)}catch{window.removeEventListener("click",v)}}},[m]);const x=l.length===0?["select-button-placeholder"]:[];return i.u(i.g,{children:[i.u("button",{"aria-label":"choice dropdown button",className:i.cc("select-button",...x),onClick:v=>{v.stopPropagation(),R()},type:"button",children:[i.u("span",{children:l.length===0?r:l.length===1?l[0].label:`${l.length} ${n}`}),i.u(i.SvgCaret,{})]}),s&&i.u(Fe,{disabledOptions:a,dropdownFooter:d,options:t,selectedOptions:l,selectItem:v=>{var j;const h=l.some(C=>C.id===v.id),f=l.some(C=>{var D;return(D=C.optionProperties)==null?void 0:D.noneOfTheAbove});(j=v.optionProperties)!=null&&j.noneOfTheAbove&&!h?o([v]):e?o(h?l.filter(C=>C.id!==v.id):f?[v]:[...l,v]):h||o([v]),e||R()},showCheckbox:e})]})},exports.getAttributedUrl=(e=void 0,n={})=>{if(!e)return e;const o=["http:","https:","itms-apps:","market:"],t=(a=>/^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//.test(a)?a:`http://${a}`)(e);if(!t)return;try{const a=new URL(t);if(!a.protocol||!o.includes(a.protocol))return}catch{return}const r=[],l=((a,d,s)=>{let u=a;for(const[m,I]of Object.entries(Ae))if(u.toLowerCase().includes(m))if(d[I]){const b=new RegExp(m,"gi");u=u.replace(b,d[I])}else s.push(m);return u})(t,n,r);return r.length===0?l:((a,d)=>{if(!a.includes("?"))return a;const s=a.slice(0,a.indexOf("?")),u=a.slice(a.indexOf("?")+1).split("&").map(m=>m.split("=")).filter(m=>!d.includes(m[1]));return u.length===0?s:`${s}?${u.map(m=>m.join("=")).join("&")}`})(l,r)},exports.pauseQuestionPlayer=e=>{const n=X(e+he);n==null||n.pause()},exports.stopRecording=e=>{const n=e+ge;if(c.document.getElementById(n)&&c.videojs){try{if(!c.videojs(n).record().stream)return}catch{return}c.videojs(n).record().stop(),c.videojs(n).record().stopDevice()}},exports.useAutoSize=Ee,exports.videoPlayer=(e,n,o,t=!1,r="https://api.sprig.com",l=document,a=null,d=null)=>{c.document=l;const s=e+he,u=we(s);return c.document.addEventListener("securitypolicyviolation",m=>{N(new Error(`Voice & Video feature violates ${m.violatedDirective} web page CSP policies for the question player.`),"playerDeviceError",r,{})}),fe(ve,()=>{c.document.getElementById(ie(s)).remove(),re(s,u);const m={playsinline:!0,playbackRates:[.5,1,1.5,2],fill:!0};try{const I=e+me;re(I,u);const b=X(s,m),R=X(I,{muted:!0,...m});if(!b||!R)return;((h,f,j)=>{h.addClass(`ul${me}`);const C=new(c.videojs.getComponent("Component"))(h);f&&h.src(f),h.addChild(C),j&&j(h)})(R,a,d),a||R.addClass(T);const x=ke(b,["PlaybackRateMenuButton","PlayToggle","FullscreenToggle"]),v=x.children().find(h=>h.name_==="FullscreenToggle");v.hasClass("vjs-disabled")&&v.hide(),Ie(b,x,n,o,t,R)}catch(I){return void N(new Error(`Error when creating video player object ${I}`),"playerDeviceError",r,{})}}),u},exports.videoRecorderPlayer=(e,n={},o="https://api.userleap.com",t,r,l,a=!1,d=document)=>{c.document=d;const s=e+ge,u=we(s);return c.document.addEventListener("securitypolicyviolation",m=>{N(new Error(`Voice & Video feature violates ${m.violatedDirective} web page CSP policies for the recorder player.`),"recorderDeviceError",o,l,n.visitorId,n.envId)}),fe(ve.concat(He),()=>{re(s,u),c.document.getElementById(ie(s)).remove();try{Ue(u,s,n,o,t,r,l,a)}catch(m){return void N(new Error(`Error when creating video recorder player object ${m}`),"recorderDeviceError",o,l,n.visitorId,n.envId)}}),u};
|