@sprig-technologies/sprig-bundled 2.40.1 → 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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./view-CRNTl40s.cjs"),W=require("./index-D7xIZ9_C.cjs"),E=require("./getAttributedUrl-B2AD3-f7.cjs"),re="https://cdn.sprig.com",I={document:void 0,videojs:void 0},xe=n=>n+"-loading-spiner",Z="hidden",je=".m3u8",ve="questionId",me="ul-video-recorder-camera-off-button",ge="ul-recording-in-session",Ye=[{type:"link",content:`${re}/dependencies/videojs-record-4.5.0.min.css`},{type:"script",content:`${re}/dependencies/RecordRTC-5.6.2.js`},{type:"script",content:`${re}/dependencies/adapter.8.0.0.min.js`},{type:"script",content:`${re}/dependencies/videojs-record-4.5.0.min.js`},{type:"script",content:`${re}/userleap-web-upchunk-v2.2.2.js`}],Me=[{type:"link",content:`${re}/dependencies/video-js-7.18.0.min.css`},{type:"script",content:`${re}/dependencies/video-js-7.18.0.min.js`},{type:"style",content:`/* progress control styles */
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./view-CdZUxdsw.cjs"),W=require("./index-psiaNxU5.cjs"),E=require("./getAttributedUrl-B6G-AN3n.cjs"),re="https://cdn.sprig.com",_={document:void 0,videojs:void 0},xe=n=>n+"-loading-spiner",Z="hidden",je=".m3u8",ve="questionId",me="ul-video-recorder-camera-off-button",ge="ul-recording-in-session",Ye=[{type:"link",content:`${re}/dependencies/videojs-record-4.5.0.min.css`},{type:"script",content:`${re}/dependencies/RecordRTC-5.6.2.js`},{type:"script",content:`${re}/dependencies/adapter.8.0.0.min.js`},{type:"script",content:`${re}/dependencies/videojs-record-4.5.0.min.js`},{type:"script",content:`${re}/userleap-web-upchunk-v2.2.2.js`}],Me=[{type:"link",content:`${re}/dependencies/video-js-7.18.0.min.css`},{type:"script",content:`${re}/dependencies/video-js-7.18.0.min.js`},{type:"style",content:`/* progress control styles */
2
2
  .video-js .vjs-control {
3
3
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
4
4
  }
@@ -655,4 +655,4 @@ span.ul-button-text {
655
655
  .vjs-poster {
656
656
  background-size: cover;
657
657
  }
658
- `}],Be="-video-player",Te="-secondary-video-player",_e="-video-recorder";let X,Ie;const te=async({event:n,apiBase:o,headers:t,visitorId:r,envId:i,metadata:a})=>{const d=I.document.documentElement;if(!r||!i)return;const u={event:`SDK - ${n}`,visitorId:r,environmentId:i,metadata:{...a||{},screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:d.clientWidth,clientHeight:d.clientHeight,location:window.location.href,language:navigator.language}};(await fetch(`${o}/sdk/1/visitors/${r}/analytics`,{method:"POST",cache:"no-cache",headers:t,body:JSON.stringify(u)})).ok||console.warn("[Sprig] (ERR-444) Failed to track analytics",n)},ne=async(n,o,t,r,i,a)=>{te({event:`Video Error ${o}`,apiBase:t,headers:r,visitorId:i,envId:a,metadata:{errorMessage:n.message}});const d=I.document.documentElement,u={screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:d.clientWidth,clientHeight:d.clientHeight,location:window.location.href,language:navigator.language},s={action:o,err:{message:n.message,stack:n.stack},meta:u,vid:i,envId:a};(await fetch(`${t}/sdk/1/errors`,{method:"POST",cache:"no-cache",headers:{...r,"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",n)},Ne=(n,o)=>{if(n.length===0)return o&&o();Promise.all(n.reduce((t,r)=>(t.push(((i,{type:a,content:d})=>new Promise(function(u,s){let p;a==="script"?(p=I.document.createElement("script"),p.src=d):a==="link"?(p=I.document.createElement("link"),p.rel="stylesheet",p.href=d,p.type="text/css"):(p=I.document.createElement("style"),p.innerHTML=d),p.onload=function(){u(d)},p.onerror=function(){s(d)},p.async=!1,p.id=btoa(d),i.appendChild(p)}))(I.document.head,r)),t),[])).then(()=>{I.videojs=I.document.defaultView.videojs,o&&o()}).catch(function(t){console.log(t+" failed to load")})},De=(n,o,t)=>{if(o==="start"&&(n.style.visibility="visible"),o==="none")n.style.visibility=Z;else if(o==="success")n.style.visibility=Z,n.innerHTML="Upload succeeded!";else{const r=Math.round(parseFloat(t));n.innerHTML=`Uploading <span class="ul-upload-progress-label__time">${r}%</span>`,n.style.background=`linear-gradient(to right, #E0E0EB 0%, #E0E0EB ${r}%, #FCFCFD ${r}%, #FCFCFD 100%)`}},he=(n,o)=>{const t=I.videojs(n.id());return t==null?void 0:t.payload[o]},Oe=(n,o)=>{const t=new(I.videojs.getComponent("Component"))(n);return t.addClass("ul-buttons-panel"),o.map(r=>{t.addChild(r)}),Ke(t),t},Ke=n=>{n.children().forEach(o=>{if(K[o.name_]){const t=le(K[o.name_],`ul-${K[o.name_]}`);o.el_.appendChild(t)}})},le=(n,o="")=>{const t=I.document.createElement("span");return t.className="ul-button-text",t.innerHTML=n,t.id=o,t},qe=(n,o,t,r,i=!1,a)=>{n.addClass("ul-video-player");const d=new(I.videojs.getComponent("Component"))(n);d.addClass("ul-control-panel"),n.progressBar=d.addChild("ProgressControl"),t&&n.src(t),n.audioPlayerPlaceholder=new(I.videojs.getComponent("Component"))(n),n.audioPlayerPlaceholder.addClass("ul-audio-recorder-placeholder");const u=t&&t.src?nn(t.src):null;!t||!i&&u?(n.audioPlayerPlaceholder.hide(),I.document.getElementById(`${n.id()}_html5_api`).style.height="100%",u&&n.poster(u)):(n.children()[0].classList.add("vjs-hidden"),I.document.getElementById(`${n.id()}_html5_api`).style.height="0px"),n.on("play",()=>{i||!t||u||Xe(n),a==null||a.play()}),n.on("pause",()=>{a==null||a.pause()}),n.on("seeked",()=>{a==null||a.currentTime(n.currentTime())}),n.on("ratechange",()=>{a==null||a.playbackRate(n.playbackRate())}),n.addChild(n.audioPlayerPlaceholder,{},1),d.addChild(o),n.addChild(d),r&&r(n)},Je=(n,o,t,r,i,a,d,u=!1)=>{Ie=Date.now();const s=de(o,{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=t;const{surveyId:p,questionId:b,responseGroupUid:c,visitorId:m,envId:x}=t;let y;const v=l=>{const g=me,T=me+"-audio-only";De(s.uploadProgressLabel,"none"),X&&X.startTime>=Ie&&X.abort();const A=I.document.getElementById("ul-camera-button");l?(s.children()[0].classList.add("vjs-hidden"),w.removeClass(g),w.addClass(T),A.innerHTML=K.TurnOnCamera,s.audioPlayerPlaceholder.removeClass("vjs-hidden"),y==null||y.getTracks().forEach(R=>{R.stop()}),window.navigator.mediaDevices.getUserMedia({video:!0,audio:!0}).then(R=>{y=R,R.getVideoTracks().forEach(q=>{q.enabled=!1}),s.record().onDeviceReady(R)}).catch(s.record().onDeviceError.bind(s.record()))):(y==null||y.getVideoTracks().forEach(R=>{R.enabled=!0}),s.children()[0].classList.remove("vjs-hidden"),s.record().getDevice(),w.removeClass(T),w.addClass(g),A.innerHTML=K.TurnOffCamera,s.audioPlayerPlaceholder.addClass("vjs-hidden"))},h=new(I.videojs.getComponent("Button"))(s,{clickHandler:()=>{h.hasClass(Z)||(te({event:"Video Delete Button Clicked",apiBase:r,headers:d,visitorId:m,envId:x,metadata:{questionId:b,responseGroupUid:c,surveyId:p}}),v(s.cameraOff),i(N.DELETE,{}),w.removeClass(Z),h.addClass(Z))}});h.addClass("ul-video-recorder-delete-button"),h.el_.appendChild(le(K.DeleteButton,"ul-delete-button"));const S=I.document.getElementById(o),f=()=>{S.classList.contains("vjs-fullscreen")&&s.cameraOff?S.style.display="table":S.style.display="flex"};f();const w=new(I.videojs.getComponent("Button"))(s,{clickHandler:()=>{s.record().isRecording()||(s.cameraOff=!s.cameraOff,te({event:"Video Camera Button Clicked",apiBase:r,headers:d,visitorId:t.visitorId,envId:t.envId,metadata:{questionId:b,responseGroupUid:c,surveyId:p,cameraOff:s.cameraOff}}),v(s.cameraOff),!h.hasClass(Z)&&h.addClass(Z),i(N.DELETE,{}),f())}});w.addClass(me),w.el_.appendChild(le(K.TurnOffCamera,"ul-camera-button"));const k=new(I.videojs.getComponent("Button"))(s,{clickHandler:()=>{const l=I.document.getElementById("ul-recorder-toggle");if(s.record().isRecording())s.record().stop(),l&&(l.innerHTML=K.RecordButton),k.removeClass(ge),h.removeClass(Z);else{const g=I.document.getElementById("ul-recording-countdown-screen");if(g)g.remove(),l&&(l.innerHTML=K.RecordButton),v(s.cameraOff),i(N.DELETE,{}),w.removeClass(Z),h.addClass(Z),k.removeClass(ge),_.show();else{k.addClass(ge),_.hide(),w.addClass(Z),h.addClass(Z),l&&(l.innerHTML=K.StopButton);const T=I.document.createElement("div");T.id="ul-recording-countdown-screen",S.insertBefore(T,S.children[1]),T.style.height=`${S.offsetHeight}px`,Ue(s,3)}}}});k.addClass("ul-video-recorder-toggle-button"),k.el_.appendChild(le(K.RecordButton,"ul-recorder-toggle"));const L=I.document.createElement("p");L.style.visibility="hidden",L.className="ul-upload-progress-label",n.appendChild(L),s.uploadProgressLabel=L;const M=Oe(s,[h,w,"PlayToggle",k,"FullscreenToggle"]),_=M.children().find(l=>l.name_==="FullscreenToggle");_.hasClass("vjs-disabled")&&_.hide();const C=M.children().find(l=>l.name_==="PlayToggle");C.hide(),h.addClass(Z),qe(s,M,a,!1,u),s.on("stopRecord",()=>{k.hide(),C.show(),_.show(),h.removeClass(Z)}),s.on("deviceReady",()=>{k.show(),C.hide(),h.addClass(Z)}),((l,g,T,A,R)=>{const{surveyId:q,responseGroupUid:Q,visitorId:H,envId:U}=l.payload;l.on("deviceError",function(){console.warn("device error: ",l.deviceErrorCode),l.deviceErrorCode.message==="Permission denied"?(l.deviceButton.addClass("permission-denied"),T&&T(N.ERROR,{type:N.PERMISSION_DENIED}),te({event:"Video Permission Denied",apiBase:g,headers:R,visitorId:H,envId:U,metadata:{questionId:he(l,ve),responseGroupUid:Q,surveyId:q}})):(T&&T(N.ERROR,{type:N.OTHER}),ne(new Error(l.deviceErrorCode.message),"recorderDeviceError",g,R,H,U))}),l.on("error",function(z,G){ne(G||l.error(),"recorderError",g,R,H,U)}),l.on("startRecord",function(z,G){A(l.uploadProgressLabel,"none"),te({event:"Video Record Start",apiBase:g,headers:R,visitorId:H,envId:U,metadata:{questionId:he(l,ve),responseGroupUid:Q,surveyId:q}})}),l.on("finishRecord",async function(){A(l.uploadProgressLabel,"start",0);const z=he(l,ve);if(!q){const P="internal error: missing fields in payload";return T&&T(N.ERROR,{type:N.OTHER}),ne(new Error(P),"finishRecord",g,R,H,U),null}l.record().stopDevice();const G=l.cameraOff?N.MEDIA_TYPE_AUDIO:N.MEDIA_TYPE_VIDEO,J=W.v4();te({event:"Video Record Finish",apiBase:g,headers:R,visitorId:H,envId:U,metadata:{mediaRecordingUid:J,questionId:z,responseGroupUid:Q,surveyId:q,mediaType:G}});const ie={surveyId:q,updatedAt:new Date().toISOString(),mediaType:G,mediaRecordingUid:J};z&&(ie.questionId=z),Q&&(ie.responseGroupUid=Q),H&&(ie.visitorId=H);const j=await(async()=>{const P=await fetch(`${g}/2/environments/integrations/upload`,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie)});if(P.ok){const O=await P.json();return T&&T(N.UPLOAD_STARTED,{[N.UPLOAD_ID]:O.upload.id,[N.MEDIA_TYPE]:G,[N.MEDIA_RECORDING_UID]:J}),O.upload.url}return T&&T(N.ERROR,{type:N.OTHER,response:P}),ne(new Error("failed to get upload response with url"),"finishRecord",g,R,H,U),null})();j&&(X=I.document.defaultView.UpChunk.createUpload({endpoint:j,file:new I.document.defaultView.File([l.recordedData],`recording ${G} ${Date.now()}`),chunkSize:5120}),X.startTime=Date.now(),te({event:"Video Upload Start",apiBase:g,headers:R,visitorId:H,envId:U,metadata:{mediaRecordingUid:J,questionId:z,responseGroupUid:Q,surveyId:q,mediaType:G,url:j}}),X.on("error",P=>{A(l.uploadProgressLabel,"none"),T&&T(N.UPLOAD_FINISHED,{[N.MEDIA_RECORDING_UID]:J}),ne(P,"finishRecord",g,R,H,U)}),X.on("progress",P=>{T&&T(N.UPLOAD_PROGRESS,{[N.MEDIA_RECORDING_UID]:J,[N.UPLOAD_PROGRESS_PCT]:P.detail}),A(l.uploadProgressLabel,"progress",P.detail)}),X.on("success",()=>{A(l.uploadProgressLabel,"success"),T&&T(N.UPLOAD_FINISHED,{[N.MEDIA_RECORDING_UID]:J}),te({event:"Video Upload Success",apiBase:g,headers:R,visitorId:H,envId:U,metadata:{mediaRecordingUid:J,questionId:z,responseGroupUid:Q,surveyId:q,mediaType:G,url:j,elapsedMs:X.startTime&&Date.now()-X.startTime}})}))})})(s,r,i,De,d);const D=[{name:"microphone"}];!s.cameraOff&&D.push({name:"camera"}),Promise.all(D.map(l=>{var g;return(g=navigator==null?void 0:navigator.permissions)==null?void 0:g.query(l)})).then(l=>{l.reduce((g,T)=>g&T.state==="granted",!0)&&s&&(s.deviceButton&&s.deviceButton.hide(),s.record().getDevice())}).catch(l=>{})},Ue=(n,o=3)=>{const t=I.document.getElementById("ul-recording-countdown-screen");t&&o===0?(t.remove(),n.record().start()):t&&(t.innerHTML=`<span class='ul-countdown-text'>Recording in... ${o}</span>`,setTimeout(()=>{Ue(n,o-1)},1e3))},Ae=n=>{const o=I.document.createElement("div");return o.className="ul-video-container",o.appendChild((t=>{const r=I.document.createElement("div");return r.className="ul-video-player-loading",r.id=xe(t),["first","second","third","fourth"].map(i=>{const a=I.document.createElement("div");a.className=i,r.appendChild(a)}),r})(n)),o},be=(n,o)=>{const t=I.document.createElement("video");t.id=n,t.className="video-js vjs-default-skin ul-video-player-video";const r=I.document.createElement("p");r.className="vjs-no-js",r.innerHTML="To view this video please enable JavaScript, and consider upgrading to a web browser that";const i=I.document.createElement("a");return i.href="https://videojs.com/html5-video-support/",i.target="_blank",i.innerHTML="supports HTML5 video",r.appendChild(i),t.appendChild(r),o.appendChild(t),o},Xe=(n,o)=>{n.children()[0].classList.remove("vjs-hidden"),n.audioPlayerPlaceholder.hide(),I.document.getElementById(`${n.id()}_html5_api`).style.height="100%"},de=(n,o)=>I.document.getElementById(n)?o?I.videojs(n,o):I.videojs(n):(console.error(`Error in finding player element with ID, ${n}`),null),en=(n,o,t,r=!1,i="https://api.sprig.com",a=document,d=null,u=null)=>{I.document=a;const s=n+Be,p=Ae(s);return I.document.addEventListener("securitypolicyviolation",b=>{ne(new Error(`Voice & Video feature violates ${b.violatedDirective} web page CSP policies for the question player.`),"playerDeviceError",i,{})}),Ne(Me,()=>{I.document.getElementById(xe(s)).remove(),be(s,p);const b={playsinline:!0,playbackRates:[.5,1,1.5,2],fill:!0};try{const c=n+Te;be(c,p);const m=de(s,b),x=de(c,{muted:!0,...b});if(!m||!x)return;((h,S,f)=>{h.addClass(`ul${Te}`);const w=new(I.videojs.getComponent("Component"))(h);S&&h.src(S),h.addChild(w),f&&f(h)})(x,d,u),d||x.addClass(Z);const y=Oe(m,["PlaybackRateMenuButton","PlayToggle","FullscreenToggle"]),v=y.children().find(h=>h.name_==="FullscreenToggle");v.hasClass("vjs-disabled")&&v.hide(),qe(m,y,o,t,r,x)}catch(c){return void ne(new Error(`Error when creating video player object ${c}`),"playerDeviceError",i,{})}}),p},nn=n=>{if(!n)return null;const o=n.match(/https:\/\/stream.mux.com\/(.*)/);let t=o?o[1]:null;return t.includes(je)&&(t=t.replace(je,"")),t?`https://image.mux.com/${t}/thumbnail.jpg?time=0`:null},N={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"},K={PlaybackRateMenuButton:"Speed",PlayToggle:"Play",FullscreenToggle:"Expand",TurnOnCamera:"Turn on",TurnOffCamera:"Turn off",DeleteButton:"Delete",RecordButton:"Record",StopButton:"Stop",PauseButton:"Pause"},tn=({properties:n,surveyVideoUrl:o,questionId:t})=>{const r=`ul-card-video__question_player-q${t}`,{apiURL:i,viewDocument:a}=e.useConfig(d=>({apiURL:d.apiURL,viewDocument:d.viewDocument}));return e.u("div",{id:r,ref:d=>{if(d&&d.children.length===0&&!n.properties.hideRecordedPrompt){const u=en(r,{src:o,type:"application/x-mpegURL"},void 0,n.properties.mediaType===N.MEDIA_TYPE_AUDIO,i,a);d.appendChild(u)}}})},oe=({isDisabled:n,onClick:o,children:t})=>e.u(E.Button,{className:"ul-card__button-checkmark",disabled:n,onClick:o,type:"button",children:[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"})}),t||"Ok"]}),rn=({className:n,next:o,properties:t,questionId:r,type:i})=>{const{useMobileStyling:a,border:d}=e.useConfig(k=>({useMobileStyling:k.useMobileStyling,border:k.border})),[u,s]=e.h(!1),[p,b]=e.h(""),[c,m]=e.h(!1),x=t==null?void 0:t.collectName,y=(t==null?void 0:t.nameLabelText)||"Full Name",v=(t==null?void 0:t.consentText)||"I agree to the stated conditions",h=(t==null?void 0:t.submitButtonText)||"Submit",S=!!p.trim(),f=u&&(!x||S),w=(k,L=!1)=>{k.preventDefault(),k.stopPropagation();let M=null;if(!L){if(!f)return void m(!0);M={submitted:!0},x&&(M.name=p)}o({value:M,questionId:r,type:i},!!L||f)};return e.u("div",{className:e.cc(n,"ul-card__consent-legal","fade-in-transition"),children:e.u(E.MobileEmbedView,{embeddedType:"pdf",properties:t,children:e.u(E.QuestionBodyFooterContainer,{children:[e.u("div",{className:"sprig-stretch",children:[e.u(E.Option,{allowTextEntry:!1,border:d,error:c&&!u,id:"consent",isRadio:!1,isSelected:u,label:v,onUserInputChanged:({selected:k})=>{k!==u&&s(!u)},useMobileStyling:a}),x&&e.u("input",{"aria-label":y,"aria-placeholder":y,className:e.cc(e.getClasses("ul-consent-legal__name-input",a)),"data-gramm":"false",maxLength:250,name:"name",onBlur:k=>{k.currentTarget.style.borderColor=c&&!S?W.ERROR_BORDER_COLOR:W.DEFAULT_BORDER_COLOR},onFocus:k=>{k.currentTarget.style.borderColor=c&&!S?W.ERROR_BORDER_COLOR:d},onInput:k=>{k.preventDefault(),k.stopPropagation(),b(k.currentTarget.value)},placeholder:y,style:c&&!S?{borderColor:W.ERROR_BORDER_COLOR}:{},tabIndex:0,value:p})]}),e.u("div",{className:"ul-card__button-wrapper ul-card-vertical__button-wrapper",children:[e.u(oe,{isDisabled:!f,onClick:k=>w(new SubmitEvent(k.type)),children:e.getButtonText({buttonText:h})}),t.required===!1&&e.u("button",{className:"ul-card-skip__button",onClick:k=>w(new SubmitEvent(k.type),!0),children:e.getSkipButtonText(t)})]})]})})},r)},on=()=>{const{destroy:n,forceBrandedLogo:o}=e.useConfig(t=>({destroy:t.destroy,forceBrandedLogo:t.forceBrandedLogo}));return e.p(()=>{setTimeout(()=>{n(W.APP_ID)},o?4e3:2e3)},[n,o]),e.u("div",{className:"end-of-survey-text",children:"End of survey"})},sn=({activeValue:n,border:o,icon:t,enableCspTrustedTypes:r,isPressed:i,range:a,scaleLabelType:d,selectedValue:u,setSelectedValue:s,setActiveValue:p,setIsPressed:b,useMobileStyling:c,value:m,viewDocument:x})=>{const y=`option-${m}`,v=d==="number",h=d==="star",S=d==="smiley",f=v&&m===n||m===u,[w,k]=(()=>{const _=h&&u!==null&&m<=u;return h&&m<=n||S&&m===n||_||m===n||m===u?[o,i||_||m===u?1:.3]:["",1]})(),L=e.F(()=>{const _={borderColor:f?w:"",fillOpacity:f?"":k,zIndex:f?3:"auto",color:u===m?"#fff":""};return v?{..._,backgroundColor:u===m?w:""}:{..._,color:h||S||u===m?w:""}},[f,w,k,u,m,v,h,S]),M=e.F(()=>W.getHtml((({icon:_,scaleLabelType:C,value:D,selectedValue:l})=>{if(C==="smiley"&&D===l){let g=0;return _.replace(/black/g,()=>++g==1?"black":"white")}return _})({icon:t,scaleLabelType:d,value:m,selectedValue:u}),r),[r,t,d,u,m]);return e.u("button",{"aria-label":v?void 0:String(m),className:(()=>{switch(d){case"star":return e.cc(e.getClasses("likert-star",c),e.getClasses(`likert-star-${m}`,c));case"smiley":return e.cc(e.getClasses("likert-smiley",c),e.getClasses(`likert-smiley-${m}`,c));default:return m===a?e.cc(e.getClasses("likert-number",c),e.getClasses(`likert-number-${m}`,c),e.getClasses("likert-last-option",c)):e.cc(e.getClasses("likert-number",c),e.getClasses(`likert-number-${m}`,c))}})(),dangerouslySetInnerHTML:{__html:M},id:y,onClick:_=>{_.preventDefault(),_.stopPropagation(),s(m)},onKeyDown:_=>{var l,g;const C=x.querySelectorAll(`.likert-${d??"number"}`),D=m-1;_.key==="ArrowRight"?(l=C[D+1])==null||l.focus():_.key==="ArrowLeft"?(g=C[D-1])==null||g.focus():_.key!=="Enter"&&_.key!==" "||(_.preventDefault(),_.stopPropagation(),s(m))},onPointerDown:()=>b(!0),onPointerEnter:()=>p(m),onPointerLeave:()=>{p(-1),b(!1)},style:L,tabIndex:0})},an=({className:n,labels:o,next:t,properties:r,questionId:i,type:a})=>{const{border:d,useMobileStyling:u,viewDocument:s,enableCspTrustedTypes:p}=e.useConfig(C=>({border:C.border,useMobileStyling:C.useMobileStyling,viewDocument:C.viewDocument,enableCspTrustedTypes:C.enableCspTrustedTypes})),[b,c]=e.h(-1),[m,x]=e.h(!1),[y,v]=e.h(null),h=o&&o.left,S=o&&o.right;let f;const{range:w,scaleLabelType:k,ratingIcons:L}=r;w&&(f=Number(w));const M=f||5,_=C=>{var D,l;switch(k){case"star":return(D=L[0])==null?void 0:D.svg;case"smiley":return(l=L[C])==null?void 0:l.svg;default:return String(C+1)}};return e.u("form",{className:e.cc(n,"ul-card--likert","fade-in-transition"),children:e.u(E.MobileEmbedView,{properties:r,children:[e.u(E.QuestionBodyWrapper,{children:[e.u("div",{"aria-label":`Rating (1 - ${M})`,className:"ul-card--likert__numbers",role:"radiogroup",children:[...Array(M)].map((C,D)=>{const l=D+1;return e.u(sn,{activeValue:b,border:d,enableCspTrustedTypes:p,icon:_(D),isPressed:m,range:M,scaleLabelType:k,selectedValue:y,setActiveValue:c,setIsPressed:x,setSelectedValue:v,useMobileStyling:u,value:l,viewDocument:s},D)})}),e.u("div",{className:"ul-card--likert__labels",children:[e.u("span",{children:h}),e.u("span",{children:S})]})]}),e.u(E.QuestionBodyFooterContainer,{children:e.u(oe,{isDisabled:y===null&&r.required,onClick:()=>t({value:y,questionId:i,type:a},!0),children:e.getButtonText(r)})})]})},i)},ln=({columns:n,onSelect:o,options:t,selectedOptions:r})=>{const i=e._([]),{border:a,useMobileStyling:d}=e.useConfig(m=>({border:m.border,useMobileStyling:m.useMobileStyling})),u=t.findIndex(m=>r[m.id]===null),[s,p]=e.h(u),b=e.T((m,x)=>{o(m,x);const y=s+1,v=t[y];v&&r[v.id]===null&&p(y)},[o,t,r,s]),c=e.T((m,x)=>{const y=s===m;return e.u(e.Accordion,{animate:!0,header:x.label,isOpen:y,onClick:()=>{var v;return p(y&&!((v=window.UserLeap)!=null&&v.isMobileSDK)?-1:m)},ref:v=>{v&&(i.current[m]=v)},showHeaderCheck:r[x.id]!==null,children:e.u("div",{style:{paddingTop:"12px"},children:n.map(v=>e.u(E.Option,{allowTextEntry:!1,ariaLabel:`${x.label}-${v.label}`,border:a,error:!1,id:`${x.id}-${v.value}`,isRadio:!0,isSelected:r[x.id]===v.value,label:v.label,onUserInputChanged:()=>b(x.id,v.value),useMobileStyling:d},v.label))})},x.id)},[a,n,s,b,r,d]);return e.u("div",{children:t.map((m,x)=>c(x,m))})},dn=({className:n,next:o,options:t,properties:r,questionId:i,type:a,onSubmitButtonClick:d})=>{const u=r.matrixColumn,s=r.required,p=y=>{y.preventDefault(),y.stopPropagation(),o({value:c,questionId:i,type:a},!0),d&&d()},b=t.reduce((y,v)=>(y[v.id]=null,y),{}),[c,m]=e.h(b);return e.u("form",{className:e.cc(n,"ul-card__matrix","fade-in-transition"),id:"text-form",onSubmit:p,children:e.u(E.MobileEmbedView,{properties:r,children:[e.u(E.QuestionBodyWrapper,{children:e.u(ln,{columns:u,onSelect:(y,v)=>{m(h=>({...h,[y]:v}))},options:t,selectedOptions:c})}),e.u(E.QuestionBodyFooterContainer,{children:e.u(oe,{isDisabled:(x=c,s&&Object.values(x).every(y=>y==null)),onClick:()=>p(new SubmitEvent("submit")),children:e.getButtonText(r)})})]})},i);var x},He=({className:n,onSubmit:o,options:t=[],properties:r,questionId:i,type:a,showIndividualSubmit:d=!1,onSubmitButtonClick:u})=>{const{border:s,useMobileStyling:p}=e.useConfig(l=>({border:l.border,useMobileStyling:l.useMobileStyling})),b=t.reduce((l,g)=>(l[g.id]={isSelected:!1},l),{}),[c,m]=e.h(b),x=a==="multiplechoice",y=r.required,v=t.find(l=>{var g;return(g=l.optionProperties)==null?void 0:g.noneOfTheAbove}),h=l=>Object.entries(l).some(([g,T])=>{var q;const A=t.find(Q=>`${Q.id}`===g),R=T.userText===void 0||T.userText.trim()==="";return((q=A==null?void 0:A.optionProperties)==null?void 0:q.allowsTextEntry)&&R&&T.isSelected}),S=l=>Object.values(l).filter(g=>g.isSelected).length,f=r.minSelect&&r.minSelect>0&&r.maxSelectMode===E.MaxSelectModes.Range&&S(c)<r.minSelect&&(y||S(c)>0),w=l=>h(l)||y&&!S(l)||!(g=>{const{minSelect:T=0,maxSelect:A=1/0,maxSelectMode:R}=r,q=S(g);switch(R){case E.MaxSelectModes.Maximum:return q<=A;case E.MaxSelectModes.Range:return q===0||q>=T;default:return!0}})(l),k=Object.entries(c).some(([l,g])=>{var T,A;return g.isSelected&&((A=(T=t.find(R=>`${R.id}`===l))==null?void 0:T.optionProperties)==null?void 0:A.allowsTextEntry)}),L=d&&(!x||k),M=l=>{D(l.id,l.selected,l.userText,l.noneOfTheAbove)},_=l=>{var g;return(r==null?void 0:r.maxSelectMode)!==E.MaxSelectModes.Unlimited&&S(c)===(r==null?void 0:r.maxSelect)&&!((g=c[l])!=null&&g.isSelected)},C=()=>{o(c,!0),u&&u()},D=(l,g,T,A)=>{const R=Object.assign({},c);if((x||A)&&g)for(const q of Object.values(R))q.isSelected=!1,delete q.userText;else v&&!A&&c[v.id].isSelected&&(R[v.id].isSelected=!1);R[l]={isSelected:g,userText:T},m(R)};return e.u("form",{className:e.cc(n,"ul-card--multiple","fade-in-transition"),id:"text-form",onSubmit:C,children:e.u(E.MobileEmbedView,{properties:r,children:[e.u(E.QuestionBodyWrapper,{children:[r.isDropdown?e.u(E.Select,{disabledOptions:t.filter(l=>_(l.id)),dropdownFooter:f?e.u("div",{className:"ul-card__min-select-counter",style:{marginLeft:"16px"},children:[S(c),"/",r.minSelect]}):void 0,isMultiSelect:!x,multiselectText:r.dropdownMultiselectedText??"choices selected",onChange:l=>{const g={...c};for(const T of t)l.includes(T)?g[T.id].isSelected=!0:g[T.id].isSelected=!1;m(g)},options:t,placeholderText:r.dropdownPlaceholderText??(x?"Select choice":"Select choice(s)"),value:t.filter(l=>c[l.id].isSelected)}):e.u("div",{className:e.cc(e.getClasses("ul-card__choices",p)),role:x?"radiogroup":"group",children:[t.map(({id:l,label:g,value:T,optionProperties:A})=>{var U,z;const R=`${l}`,{allowsTextEntry:q,noneOfTheAbove:Q}={allowsTextEntry:!1,noneOfTheAbove:!1,...A};return e.u(E.Option,{allowTextEntry:q,border:s,disabled:_(R),error:(H=c,h(H)),id:R,isRadio:x,isSelected:!!((U=c[R])!=null&&U.isSelected),label:g,noneOfTheAbove:Q,onUserInputChanged:M,promptText:"Please specify",text:(z=c[l])==null?void 0:z.userText,useMobileStyling:p,value:T},R);var H}),!!f&&e.u("div",{className:"ul-card__min-select-counter",children:[S(c),"/",r.minSelect]})]}),L&&e.u(E.LongformSubmitButton,{handleSubmit:C,isSubmitDisabled:w(c)})]}),e.u(E.QuestionBodyFooterContainer,{children:e.u(oe,{isDisabled:w(c),onClick:C,children:e.getButtonText(r)})})]})},i)},cn=n=>{const{questionId:o,type:t,next:r,options:i}=n;return e.u(He,{...n,onSubmit:(a,d)=>{const u=Object.entries(a).find(([,m])=>m.isSelected)||[void 0,void 0],[s,p]=u,b=i.find(m=>`${m.id}`===s),c=p!=null&&p.userText?{[s]:{userText:p.userText}}:null;r({value:b&&s?{[s]:b.value}:{},secondaryValue:c,questionId:o,type:t},d)}})},un=n=>{const{questionId:o,type:t,next:r}=n;return e.u(He,{...n,onSubmit:(i,a)=>{const d=Object.entries(i).reduce((s,[p,b])=>(s[p]=b.isSelected,s),{}),u=Object.entries(i).reduce((s,[p,b])=>{if(!b.userText)return s;const c=s||{};return c[p]={userText:b.userText},c},null);r({value:d,secondaryValue:u,questionId:o,type:t},a)}})},pn=({className:n,labels:o,properties:t,next:r,questionId:i,type:a})=>{const[d,u]=e.h(null),{border:s,useMobileStyling:p,viewDocument:b}=e.useConfig(x=>({border:x.border,useMobileStyling:x.useMobileStyling,viewDocument:x.viewDocument})),c=o&&o.left,m=o&&o.right;return e.u("form",{className:e.cc(n,"ul-card--nps","fade-in-transition"),children:e.u(E.MobileEmbedView,{properties:t,children:[e.u(E.QuestionBodyWrapper,{children:[e.u("div",{className:"ul-card--nps__numbers",children:[...Array(11)].map((x,y)=>e.u("button",{className:e.cc(e.getClasses("nps-number",p),e.getClasses(`nps-number-${y}`,p)),id:`option-${y}`,onClick:v=>{v.preventDefault(),v.stopPropagation(),u(y)},onKeyDown:v=>{var S,f;const h=b.querySelectorAll("button.nps-number");v.key==="ArrowRight"?(S=h[y+1])==null||S.focus():v.key==="ArrowLeft"?(f=h[y-1])==null||f.focus():v.key!=="Enter"&&v.key!==" "||(v.preventDefault(),v.stopPropagation(),u(y))},onPointerDown:v=>{v.currentTarget.style.zIndex="2",v.currentTarget.style.borderColor=s},onPointerLeave:v=>{v.currentTarget.style.zIndex="auto",v.currentTarget.style.borderColor=W.DEFAULT_BORDER_COLOR},style:d===y?{backgroundColor:s,color:"#fff"}:void 0,tabIndex:0,children:y},y))}),e.u("div",{className:"ul-card--nps__labels",children:[e.u("span",{children:c}),e.u("span",{children:m})]})]}),e.u(E.QuestionBodyFooterContainer,{children:e.u(oe,{isDisabled:d===null&&t.required,onClick:()=>r({value:d,questionId:i,type:a},!0),children:e.getButtonText(t)})})]})},i)},vn=({className:n,next:o,properties:t,questionId:r,type:i,onSubmitButtonClick:a})=>{const{border:d,useMobileStyling:u,update:s}=e.useConfig(h=>({border:h.border,useMobileStyling:h.useMobileStyling,update:h.update})),[p,b]=e.h(""),c=e._(null),m=p.trim(),x=t.required===!0&&!m,y=E.useAutoSize(c,()=>s()),v=t&&t.openTextPlaceholder?t.openTextPlaceholder:"";return e.u("form",{className:e.cc(n,"ul-card-text","fade-in-transition"),id:"text-form",children:e.u(E.MobileEmbedView,{properties:t,children:e.u("div",{className:"ul-card-text",children:[e.u(E.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":v,className:e.cc(e.getClasses("ul-card-text__input",u)),"data-gramm":"false",maxLength:5e3,name:"text",onBlur:h=>{h.currentTarget.style.borderColor=W.DEFAULT_BORDER_COLOR},onChange:h=>{const{value:S}=h.currentTarget;y(),h.preventDefault(),h.stopPropagation(),b(S)},onFocus:h=>{h.currentTarget.style.borderColor=d},placeholder:v,ref:c,role:"textbox",tabIndex:0})}),t.footerHtml&&e.u(E.Html,{className:"footer",html:t.footerHtml})]}),e.u(E.QuestionBodyFooterContainer,{children:e.u(oe,{isDisabled:x,onClick:h=>{h.preventDefault(),h.stopPropagation();const S=t.required!==!0||m.length>0;o({value:p,questionId:r,type:i},S),a&&a()},children:e.getButtonText(t)})})]})})},r)},mn=({className:n,labels:o,next:t,properties:r,questionId:i,type:a,onSubmitButtonClick:d,options:u})=>{const s=e._(null),p=e._(0),b=e._(0),c=e._(null),m=e._(!1),x=e._([]),[y,v]=e.h(()=>(r==null?void 0:r.required)===!0),[h,S]=e.h(()=>u.map(j=>({...j,rank:null}))),f=e.F(()=>Array.from({length:u.length},(j,P)=>P+1),[u.length]),{useMobileStyling:w,isPreview:k,headers:L}=e.useConfig(j=>({useMobileStyling:j.useMobileStyling,isPreview:j.isPreview,headers:j.headers})),M=(L==null?void 0:L["userleap-platform"])==="android",_=w&&!k&&!M,C=!_&&!M,D=(j,P)=>{S(O=>{const B=parseInt(P),V=O.map($=>({...$}));V.some($=>$.rank==null)&&V.forEach(($,se)=>$.rank=se+1);const Y=V.findIndex($=>$.id===j);if(Y===-1)return O;const F=V[Y].rank;return B<F?V.forEach($=>{$.id!==j&&$.rank>=B&&$.rank<F&&($.rank=$.rank+1)}):B>F&&V.forEach($=>{$.id!==j&&$.rank>F&&$.rank<=B&&($.rank=$.rank-1)}),V[Y].rank=B,V.sort(($,se)=>$.rank-se.rank),Q(),V})},l=(j,P)=>{for(let O=0;O<x.current.length;O++){const B=x.current[O];if(!B||B===c.current)continue;const V=B.getBoundingClientRect();if(j>=V.left&&j<=V.right&&P>=V.top&&P<=V.bottom)return{element:B,index:O}}return null},g=j=>P=>{if(!_)return;P.preventDefault(),P.stopPropagation(),m.current=!0,s.current=j;const O=P.touches[0];p.current=O.clientY,b.current=O.clientY;const B=P.currentTarget.closest(".ul-card-rank__option");B&&(c.current=B,B.classList.add("is-dragging"))},T=j=>{if(!_||!m.current||s.current===null)return;j.preventDefault(),j.stopPropagation();const P=j.touches[0];b.current=P.clientY;const O=b.current-p.current;c.current&&(c.current.style.transform=`translateY(${O}px)`,c.current.style.zIndex="1000"),x.current.forEach(V=>{V&&V!==c.current&&V.classList.remove("is-drop-target")});const B=l(P.clientX,P.clientY);B&&B.element.classList.add("is-drop-target")},A=j=>{if(!_||!m.current||s.current===null)return;j.preventDefault(),j.stopPropagation();const P=j.changedTouches[0],O=l(P.clientX,P.clientY);c.current&&(c.current.style.transform="",c.current.style.zIndex="",c.current.classList.remove("is-dragging")),x.current.forEach(B=>{B&&B.classList.remove("is-drop-target")}),O&&O.index!==s.current&&R(s.current,O.index),s.current=null,c.current=null,m.current=!1},R=(j,P)=>{S(O=>{const B=O.map(Y=>({...Y})),[V]=B.splice(j,1);return B.splice(P,0,V),B.forEach((Y,F)=>{Y.rank=F+1}),Q(),B})},q=j=>{const P={};j.reduce((O,B)=>(O[B.id]=B.rank,O),P),t({value:P,questionId:i,type:a},!0)},Q=()=>{v(!1)},{left:H,right:U}=o,z=u.length,G=j=>{j.preventDefault(),j.currentTarget.classList.add("is-drop-target")},J=j=>{j.currentTarget.classList.remove("is-drop-target")},ie=j=>{s.current=null,j.currentTarget.classList.remove("is-dragging")};return e.u("form",{className:e.cc(n,"ul-card-rank","fade-in-transition"),onSubmit:j=>{j.preventDefault(),q(h),d&&d()},children:e.u(E.MobileEmbedView,{properties:r,children:M?e.u(E.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 - ",H]})}),e.u("ol",{className:"ul-card-rank__list",children:h.map(({id:j,label:P,rank:O})=>e.u("li",{className:"ul-card-rank__option",children:[e.u("select",{"aria-label":`Rank for ${P}`,className:e.cc("ul-card-rank__select",O==null&&"ul-card-rank__select--placeholder"),name:`rank[${j}]`,onChange:B=>D(j,B.currentTarget.value),value:O??"",children:[O==null&&e.u("option",{className:"ul-card-rank__select-option",disabled:!0,value:"",children:"-"}),f.map(B=>e.u("option",{className:"ul-card-rank__select-option",value:B,children:B},`${B}-${i}`))]}),e.u("span",{children:P})]},j))}),e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:[z," - ",U]})})]})}):e.u(e.g,{children:[e.u(E.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 - ",H]})}),e.u("ol",{className:"ul-card-rank__list",onDragOver:M?void 0:j=>{j.preventDefault(),j.dataTransfer&&(j.dataTransfer.dropEffect="move")},children:h.map(({id:j,label:P,rank:O},B)=>{return e.u("li",{className:"ul-card-rank__option",draggable:!!C||void 0,onDragEnd:C?ie:void 0,onDragEnter:C?G:void 0,onDragLeave:C?J:void 0,onDragStart:C?(Y=B,F=>{s.current=Y,F.dataTransfer&&(F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/plain",String(Y)),F.currentTarget.classList.add("is-dragging"))}):void 0,onDrop:C?(V=B,F=>{var se,Ee;F.preventDefault(),F.currentTarget.classList.remove("is-drop-target");const $=s.current;s.current=null,(Ee=(se=F.currentTarget.closest(".ul-card-rank__list"))==null?void 0:se.querySelector(".is-dragging"))==null||Ee.classList.remove("is-dragging"),$!=null&&$!==V&&R($,V)}):void 0,ref:F=>x.current[B]=F,children:[e.u("select",{"aria-label":`Rank for ${P}`,className:e.cc("ul-card-rank__select",O==null&&"ul-card-rank__select--placeholder"),name:`rank[${j}]`,onChange:F=>D(j,F.currentTarget.value),value:O??"",children:[O==null&&e.u("option",{className:"ul-card-rank__select-option",disabled:!0,value:"",children:"-"}),f.map(F=>e.u("option",{className:"ul-card-rank__select-option",value:F,children:F},F))]}),e.u("span",{children:P}),!M&&e.u("button",{"aria-label":`Drag ${P} to reorder`,className:"ul-card-rank__drag-btn",onTouchEnd:_?A:void 0,onTouchMove:_?T:void 0,onTouchStart:_?g(B):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"})})})]},j);var V,Y})}),e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:[z," - ",U]})})]})}),e.u(E.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-card__button-wrapper",children:e.u(E.Button,{disabled:y,children:e.getButtonText(r)})})})]})})},i)},fe=1,$e=2,Ve=3,ce=n=>n.type==="av_permission",Se=n=>n.type==="screen_permission",Fe=(n,o)=>n===void 0?fe:n?((t,r)=>!(ce(r)?r.permissionDescriptors:[]).includes("camera")||t.getVideoTracks().length>0)(n,o)?Ve:fe:$e,Re={avStream:null,currentPage:null,mediaRecordingUids:null,nextQuestion:()=>{},passthroughData:void 0,recordingMediaTypes:void 0,screenPermissionRequested:!1,type:void 0},ee=e.create(n=>({...Re,reset:()=>{n(Re)},updatePage:o=>{n(o)}}));function ye({currentPage:n,pages:o}){const{avStream:t,recordingMediaTypes:r,updatePage:i}=ee.getState(),{recorderEventEmitter:a}=e.useConfig.getState();a.emit("av.permission",{"permission.descriptors":n.permissionDescriptors,"stream.ready":(d,u)=>{if(t===d)return;let s=n;if(d&&!n.permissionDescriptors.includes("camera")){const p=o.indexOf(n),b=u!=null&&u.active?p+2:p+1;u!=null&&u.active&&r&&a.emit("begin.recording",{"recording.media.types":r,"start.recording.callback":c=>i({mediaRecordingUids:c})}),s=o[b]}i({currentPage:s,avStream:d})}})}function Ce({status:n}){const{nextQuestion:o,passthroughData:t,mediaRecordingUids:r,reset:i}=ee.getState(),{recorderEventEmitter:a,handleUploadUpdate:d,index:u}=e.useConfig.getState(),s={value:{taskStatus:n},type:"recordedtask",questionId:(t==null?void 0:t.questionId)||1};t&&a.emit("finish.task",{"begin.callback":p=>{d({mediaRecordingUid:p,isSubmitted:!0,progressPct:0,isComplete:!1})},"progress.callback":(p,b)=>{d({mediaRecordingUid:p,progressPct:b.detail,isSubmitted:!1,isComplete:!1})},"upload.callback":p=>{p&&d({mediaRecordingUid:p,isComplete:!0,isSubmitted:!0,progressPct:100})},"passthrough.data":t,"current.index":u,"task.response":s,"task.complete.callback":p=>{s.value.taskDurationMillisecond=p,r&&(s.value.mediaRecordingUids=r),i(),o(s)}})}function ke({pages:n,setIsRequestingPermission:o}){const{recorderEventEmitter:t,eventEmitFn:r}=e.useConfig.getState(),{updatePage:i,currentPage:a,recordingMediaTypes:d,screenPermissionRequested:u}=ee.getState();if(!a)return;const s=n.indexOf(a);switch(a.type){case"av_permission":{const p=u?s+2:s+1;return u&&d&&t.emit("begin.recording",{"recording.media.types":d,"start.recording.callback":b=>{i({mediaRecordingUids:b})}}),void i({currentPage:n[p]})}case"screen_permission":return void t.emit("screen.permission",{"screen.permission.requested":o,"stream.ready.callback":(p,b)=>{const c=b?n[s+1]:a;b&&d&&t.emit("begin.recording",{"recording.media.types":d,"start.recording.callback":m=>{i({captureStream:b,mediaRecordingUids:m})}}),i({currentPage:c,screenPermissionRequested:!0,captureStream:b})}});case"start_task":return r("recorded.task.start"),t.emit("recorded.task.start"),t.emit("start.task"),void i({currentPage:n[s+1],screenPermissionRequested:!0});case"complete_task":return}}const ze="ul-permission-graphics-container",Qe="ul-permission-body",Ge=e.cc(ze,"ul_recorded-task-inset-spacing"),ue=e.cc("ul-horizontal-button-container","ul-horizontal-button-container-left"),Ze=({richTextBody:n})=>e.u(E.Html,{className:"ul-rich-text-body",html:n,id:"ul-task-detail-container"}),pe=({required:n,skipButtonText:o,bottom:t=!1})=>n?null:e.u(E.Button,{className:e.cc(t&&"ul-skip-button-below","ul-button-inactive"),onClick:Ce.bind(null,{status:"abandoned"}),children:o||"Skip"}),we=n=>{const{avStream:o,captureStream:t,recordingMediaTypes:r,updatePage:i}=ee.getState(),a=(r==null?void 0:r.includes("audio"))||(r==null?void 0:r.includes("video"));e.p(()=>{const d=setInterval(()=>{a&&o&&!o.active?i({avStream:null,currentPage:n[0]}):t&&t.active||i({captureStream:void 0,currentPage:n[a?1:0]})},1e3);return()=>clearInterval(d)},[o,t,a,n,r,i])},gn=({content:n,pages:o,required:t})=>{const{buttonText:r,skipButtonText:i,taskDetail:a}=n;return we(o),e.u("div",{className:"ul-task-page",children:[a&&e.u(Ze,{richTextBody:a}),e.u("div",{className:ue,children:[e.u(E.Button,{onClick:ke.bind(null,{pages:o}),children:r}),e.u(pe,{required:t,skipButtonText:i})]})]},"start-task")},hn=({content:n,pages:o,properties:t})=>{const{buttonText:r,skipButtonText:i}=n;return we(o),e.u("div",{className:"ul-task-page",children:[n.taskDetail&&e.u(Ze,{richTextBody:n.taskDetail}),e.u(E.MobileEmbedView,{properties:t,children:e.u("div",{className:ue,children:[e.u(E.Button,{className:"ul-complete-task-button",onClick:Ce.bind(null,{status:"completed"}),children:r}),e.u(E.Button,{className:e.cc("ul-button-inactive"),onClick:Ce.bind(null,{status:"given.up"}),children:i})]})})]},"complete-task")},bn=({content:n,pages:o,required:t})=>{const{buttonText:r,skipButtonText:i}=n,[a]=e.useConfig(s=>[s.tabTitle]),[d,u]=e.h(!1);return e.u("div",{children:[e.u("div",{className:Ge,children:[e.u("p",{style:{marginTop:"auto"},children:n.selectTabText}),e.u("div",{className:"ul-select-tab-container",children:e.u("p",{className:Qe,children:a})})]}),e.u("div",{className:t?"":ue,children:[e.u(E.Button,{disabled:d,onClick:ke.bind(null,{pages:o,setIsRequestingPermission:u}),children:r}),e.u(pe,{required:t,skipButtonText:i})]})]})},fn=({content:n})=>e.u(E.Html,{className:e.cc(ze,"ul_permission_svg_container","ul_recorded-task-inset-spacing","ul-center-horizontally"),html:n.svg},"ul-permission-request-graphic"),yn=({content:n,pages:o,required:t})=>{const{permissionDeniedHeadline:r,permissionDeniedBody:i,skipButtonText:a,tryAgainButtonText:d}=n,u=ce(o[0])?o[0]:null;return e.p(()=>{const s=setInterval(()=>{u!==null&&ye({currentPage:u,pages:o})},1e3);return()=>clearInterval(s)},[u,o]),u?e.u("div",{children:[e.u("div",{className:Ge,children:e.u("p",{className:"ul-av-permission-denied-paragraph",children:[e.u("span",{className:"ul-av-permission-denied-headline",children:r}),e.u("span",{className:Qe,children:i})]})}),e.u("div",{className:ue,children:[e.u(E.Button,{onClick:ye.bind(null,{currentPage:u,pages:o}),children:d}),e.u(pe,{required:t,skipButtonText:a})]})]}):null},Cn=({stream:n})=>e.u("video",{autoPlay:!0,className:e.cc("ul_recorded-task-inset-spacing"),id:"ul-record-task-video-preview",muted:!0,ref:o=>{o&&(o.srcObject=n||null)}}),xn=({content:n,pages:o,required:t})=>{const{skipButtonText:r}=n,{avStream:i}=ee.getState();return we(o),e.u("div",{children:[e.u(Cn,{stream:i}),e.u("div",{className:"ul-vertical-button-container-center",children:[e.u(E.Button,{onClick:ke.bind(null,{pages:o}),children:n.buttonText}),e.u(pe,{bottom:!0,required:t,skipButtonText:r})]})]})},kn=({properties:n})=>{const{pages:o,required:t}=n,{avStream:r,currentPage:i}=ee.getState();if(i===void 0)return null;switch(i==null?void 0:i.type){case"av_permission":{const a=Fe(r,i);return a===fe?e.u(fn,{content:i}):a===$e?e.u(yn,{content:i,pages:o,required:t}):e.u(xn,{content:i,pages:o,required:t})}case"screen_permission":return e.u(bn,{content:i,pages:o,required:t});case"start_task":return e.u(gn,{content:i,pages:o,required:t});case"complete_task":return e.u(hn,{content:i,pages:o,properties:n});default:return null}},wn=({className:n,properties:o,next:t,questionId:r})=>{const i=e.useConfig(),{surveyId:a,responseGroupUid:d,userId:u}=i,s=ee(),{screenPermissionRequested:p}=s,b=ee(v=>v.avStream);let c=ee(v=>v.currentPage);c||(c=function({pages:v,userId:h,responseGroupUid:S,surveyId:f,questionId:w,next:k}){const{updatePage:L}=ee.getState(),{eventEmitFn:M,recorderEventEmitter:_}=e.useConfig.getState(),C={questionId:w,surveyId:f,visitorId:h,responseGroupUid:S};let D=0;_.emit("recorded.task.permission.screen"),M("recorded.task.permission.screen"),_.emit("permission.status",{"permission.status.callback":(g,T,A,R)=>{const q=v[D],{type:Q}=q,H=["screen"];if(ce(q)){const{permissionDescriptors:U}=q,z=U==null?void 0:U.includes("microphone"),G=U==null?void 0:U.includes("camera");z&&H.push("audio"),G&&H.push("video"),(g!=null&&g.active&&!G||g!=null&&g.active&&T)&&D++}Se(v[D])&&A&&(D++,_.emit("begin.recording",{"recording.media.types":H,"start.recording.callback":U=>L({mediaRecordingUids:U})})),L({currentPage:v[D],avStream:g,screenPermissionRequested:A,nextQuestion:k,type:Q,passthroughData:C,recordingMediaTypes:H,captureStream:R})}});const l=v[D];return l.type==="av_permission"&&ye({currentPage:l,pages:v}),l}({questionId:r,surveyId:a,next:v=>{t(v,!0)},pages:o.pages,responseGroupUid:d,userId:u}));let m=c.headline,x=c.captionText;const y=Fe(b,c);return Se(c)&&p&&(m=c.permissionDeniedHeadline,x=c.permissionDeniedCaptionText),ce(c)&&y===Ve&&(m=c.permissionGrantedHeadline,x=c.permissionGrantedCaptionText),e.u("div",{className:e.cc(n,"ul-center-horizontally","fade-in-transition"),children:[e.u(E.Header,{isRequired:o==null?void 0:o.required,message:m,properties:{captionText:x}}),e.u(E.QuestionBodyWrapper,{children:e.u(kn,{properties:o})})]})},En=({className:n,next:o,properties:t,questionId:r,type:i})=>{const{visitorAttributes:a,isLongFormSurvey:d}=e.useConfig(b=>({visitorAttributes:b.visitorAttributes,isLongFormSurvey:W.isLongFormSurvey(b.studyType)})),u=(b,c=!1)=>{o({value:c?{skipped:!0}:void 0,questionId:r,type:i},!0)},s=E.getAttributedUrl(t&&t.buttonUrl,a),p=d&&t.promptActionType===E.PromptActionTypeEnum.NO_BUTTON;return e.u("div",{className:e.cc(n,"ul-card__text-url-prompt","fade-in-transition"),children:e.u(E.MobileEmbedView,{properties:t,children:!p&&e.u("div",{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:u,onKeyPress:b=>{b.key!=="Enter"&&b.key!==" "||o({value:void 0,questionId:r,type:i},!0)},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:b=>u(0,!0),children:e.getSkipButtonText(t)})]})})})},r)},jn=({className:n,questionId:o})=>{const{border:t,destroy:r,endCard:i,forceBrandedLogo:a}=e.useConfig(s=>({border:s.border,destroy:s.destroy,endCard:s.endCard,forceBrandedLogo:s.forceBrandedLogo}));e.p(()=>{setTimeout(()=>{r(W.APP_ID)},a?4e3:2e3)},[r,a]);const d=i&&i.subheader?e.u("p",{className:"ul-caption",children:i.subheader}):null,u=i&&i.headline?i.headline:"";return e.u("div",{className:e.cc(n,"ul-card--thanks","fade-in-transition"),children:e.u("div",{children:e.u("div",{className:"ul-card--thanks-content",children:[e.u("div",{className:"ul-thanks-check",children:e.u("svg",{"aria-labelledby":"title",fill:"none",height:"99",viewBox:"0 0 81 99",width:"81",xmlns:"http://www.w3.org/2000/svg",children:[e.u("path",{clipRule:"evenodd",d:"M40.5 77C60.9345 77 77.5 60.4345 77.5 40C77.5 19.5655 60.9345 3 40.5 3C20.0655 3 3.5 19.5655 3.5 40C3.5 60.4345 20.0655 77 40.5 77ZM80.5 40C80.5 62.0914 62.5914 80 40.5 80C18.4086 80 0.5 62.0914 0.5 40C0.5 17.9086 18.4086 0 40.5 0C62.5914 0 80.5 17.9086 80.5 40Z",fill:t,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:t,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(E.Header,{message:u}),d]})})},o)},Tn=()=>e.u("div",{className:"thinking-dots-container",children:e.u("div",{className:"thinking-dot"})}),_n=({className:n})=>{const{uploadProgress:o}=e.useConfig(a=>({uploadProgress:a.uploadProgress}));let t,r;Object.values(o).filter(a=>a.isSubmitted).length>1?(t="Your responses are processing",r="Please keep this tab open until your responses are fully processed."):(t="Your response is processing",r="Please keep this tab open until your response is fully processed.");const i=Math.round(Math.min(99,...Object.values(o).filter(a=>a.isSubmitted).map(a=>a.progressPct||0)));return e.u("div",{className:e.cc(n,"ul-card--uploading","fade-in-transition"),children:[e.u("div",{"aria-busy":"true","aria-label":"Processing...","aria-live":"polite",className:"ul-loading-spinner-container",role:"progressbar",children:e.u("div",{className:"ul-loading-spinner",children:[e.u("div",{className:"first"}),e.u("div",{className:"second"}),e.u("div",{className:"third"}),e.u("div",{className:"fourth"})]})}),e.u(E.Header,{message:`${t} (${i}% complete)`}),e.u("p",{className:"ul-caption",children:r})]})},Pe=0,Le=1,In=({className:n,next:o,properties:t,questionId:r,type:i})=>{const a=`ul-card-video__player_recorder-q${r}`,{apiURL:d,envId:u,handleUploadUpdate:s,headers:p,responseGroupUid:b,surveyId:c,viewDocument:m,visitorId:x}=e.useConfig(C=>({apiURL:C.apiURL,envId:C.envId,handleUploadUpdate:C.handleUploadUpdate,headers:C.headers,responseGroupUid:C.responseGroupUid,surveyId:C.surveyId,viewDocument:C.viewDocument,visitorId:C.userId})),[y,v]=e.h(!1),[h,S]=e.h(null),[f,w]=e.h(null),[k,L]=e.h(Pe),M=(C,D)=>{C===N.UPLOAD_STARTED?(S(D[N.UPLOAD_ID]),w(D[N.MEDIA_RECORDING_UID]),v(!0)):C===N.DELETE?(S(null),w(null),v(!1)):C===N.UPLOAD_PROGRESS?isNaN(D[N.UPLOAD_PROGRESS_PCT])?s({mediaRecordingUid:D[N.MEDIA_RECORDING_UID],isComplete:!0}):s({mediaRecordingUid:D[N.MEDIA_RECORDING_UID],progressPct:D[N.UPLOAD_PROGRESS_PCT]}):C===N.UPLOAD_FINISHED&&s({mediaRecordingUid:D[N.MEDIA_RECORDING_UID],isComplete:!0})},_=C=>{C.preventDefault(),C.stopPropagation(),document.getElementById(a)&&(D=>{const l=D+_e;if(I.document.getElementById(l)&&I.videojs){try{if(!I.videojs(l).record().stream)return}catch{return}I.videojs(l).record().stop(),I.videojs(l).record().stopDevice()}})(a),h&&f?(s({mediaRecordingUid:f,isSubmitted:!0}),o({value:{mediaRecordingUid:f},questionId:r,type:i},!0)):o({value:null,questionId:r,type:i},!0)};return e.u("form",{className:e.cc(n,"ul-card--video","fade-in-transition"),id:"ul-video-interview-form",children:[e.u(E.QuestionBodyWrapper,{children:[e.u("div",{id:"ul-question-player-container",style:{display:k===Pe?"":"none"},children:e.u(E.MobileEmbedView,{properties:t,children:e.u("button",{className:"ul-video-btn ul-record-response-btn",onClick:C=>{C.preventDefault(),C.stopPropagation(),document.getElementById(a)&&(D=>{const l=de(D+Be);l==null||l.pause()})(a),L(Le)}})})}),e.u("div",{style:{display:k===Le?"block":"none"},children:e.u("div",{id:"ul-recorder-player-container",ref:C=>{if(C&&C.children.length===0){const D=((l,g={},T="https://api.userleap.com",A,R,q,Q=!1,H=document)=>{I.document=H;const U=l+_e,z=Ae(U);return I.document.addEventListener("securitypolicyviolation",G=>{ne(new Error(`Voice & Video feature violates ${G.violatedDirective} web page CSP policies for the recorder player.`),"recorderDeviceError",T,q,g.visitorId,g.envId)}),Ne(Me.concat(Ye),()=>{be(U,z),I.document.getElementById(xe(U)).remove();try{Je(z,U,g,T,A,R,q,Q)}catch(G){return void ne(new Error(`Error when creating video recorder player object ${G}`),"recorderDeviceError",T,q,g.visitorId,g.envId)}}),z})(a,{surveyId:c,responseGroupUid:b,questionId:r,visitorId:x,envId:u},d,M,void 0,{...p,"x-ul-video-recorder-origin":"sdk"},t.mediaType===N.MEDIA_TYPE_AUDIO,m);C.appendChild(D)}}})})]}),e.u(E.QuestionBodyFooterContainer,{children:[e.u(oe,{isDisabled:!!t.required&&!y,onClick:_,children:e.getButtonText(t)}),e.u("button",{className:"ul-card-text__button ul-button-inactive ul-card-skip__button",id:"ul-card-video__skip_button",onClick:_,style:{...t.required?{display:"none"}:{},...y?{display:"none"}:{}},children:e.getSkipButtonText(t)})]})]})},We=n=>n.type==="thanks"||n.type==="uploading",Dn=({card:n,avatars:o,isThinking:t,isCurrentQuestion:r,currentQuestionBubbleRef:i})=>{const a=(d=>"properties"in d.props&&d.props.properties&&"questionHtml"in d.props.properties&&d.props.properties.questionHtml?{content:d.props.properties.questionHtml,isHtml:!0}:"message"in d.props?{content:d.props.message,isHtml:!1}:{content:"Question",isHtml:!1})(n);return e.u(ae,{avatars:o,isLeft:!0,message:{id:`question-${n.name}`,type:"question",content:a.content},ref:r?i:null,children:t?e.u(Tn,{}):e.u(e.g,{children:[a.isHtml?e.u(E.Html,{className:"chat-message-text",html:a.content}):e.u("div",{className:"chat-message-text",children:a.content}),n.type==="videovoice"&&e.u(tn,{properties:n.props,questionId:n.name,surveyVideoUrl:n.props.properties.videoUrl})]})})},Sn=({card:n,avatars:o})=>{const t=(r=>{if(!("properties"in r.props)||!r.props.properties||typeof r.props.properties!="object")return null;const i=r.props.properties,a=[{key:"captionHtml",isHtml:!0},{key:"captionText",isHtml:!1},{key:"richTextBody",isHtml:!0},{key:"body",isHtml:!1}];for(const{key:d,isHtml:u}of a){const s=i[d];if(typeof s!="string")continue;const p=s.trim();if(p){if(u&&!p.replaceAll(/<[^>]*>/g,"").trim())continue;return{content:p,isHtml:u}}}return null})(n);return t?e.u(ae,{avatars:o,hideAvatar:!0,isLeft:!0,message:{id:`caption-${n.name}`,type:"question",content:t.content},children:t.isHtml?e.u(E.Html,{className:"chat-message-text",html:t.content}):e.u("div",{className:"chat-message-text",children:t.content})}):null},Rn=({card:n,userResponse:o,avatars:t})=>{const r=((i,a)=>{if(i.type==="open"&&a&&typeof a=="object"&&"value"in a)return a.value})(n,o);return e.u("div",{className:"chat-bubble-container chat-right",children:[e.u("div",{className:"chat-bubble chat-bubble-right chat-bubble-text-only",children:e.u("div",{className:"chat-message-text",children:r||e.u("div",{className:"chat-message-no-response",children:"No response"})})}),e.u("img",{alt:"User Avatar",className:"chat-avatar chat-avatar-right",srcSet:`${t.respondentAvatar["1x"]} 1x, ${t.respondentAvatar["2x"]} 2x`})]})},Pn=({card:n,avatars:o,isCurrentQuestion:t,currentQuestionBubbleRef:r})=>{const{endCard:i}=e.useConfig(a=>({endCard:a.endCard}));return e.u(e.g,{children:[e.u(ae,{avatars:o,isLeft:!0,message:{id:`thanks-${n.name}`,type:"question",content:(i==null?void 0:i.headline)??"Great! Thank you for your participation."},ref:t?r:null}),(i==null?void 0:i.subheader)&&e.u(ae,{avatars:o,hideAvatar:!0,isLeft:!0,message:{id:`caption-${n.name}`,type:"question",content:i.subheader}}),e.u(on,{})]})},Ln=({card:n,cardIndex:o,index:t,avatars:r,cardResponses:i,questionThinkingStates:a,startingQuestionIdx:d,currentQuestionBubbleRef:u,handleCardResponse:s})=>{const p=o===t,b=o<t,c=We(n);if(c)return e.u(Pn,{avatars:r,card:n,currentQuestionBubbleRef:u,isCurrentQuestion:p});const m=`${n.name}`,x=i.get(m),y=n.type==="open",v=a.get(m),h=o>(d??0)&&n.type!=="thanks"&&n.type!=="uploading"&&(v===!0||v===void 0);return e.u(e.wn.Fragment,{children:[e.u(Dn,{avatars:r,card:n,currentQuestionBubbleRef:u,isCurrentQuestion:p,isThinking:h}),!h&&e.u(Sn,{avatars:r,card:n}),b&&y?e.u(Rn,{avatars:r,card:n,userResponse:x}):(!b||!y)&&!h&&e.u(ae,{avatars:r,isLeft:!1,message:{id:`card-${n.name}`,type:"card",content:""},children:e.u("div",{className:"chat-card-container",children:e.u(Bn,{card:n,className:c?"chat-thanks-card":"chat-card",isAnswered:b,next:p?s:()=>{}})})})]},`question-card-${n.name}`)},ae=e.wn.forwardRef(({message:n,isLeft:o=!1,children:t,avatars:r,hideAvatar:i=!1},a)=>{const d=o?"chat-bubble-left":"chat-bubble-right";return e.u("div",{className:`chat-bubble-container ${o?"chat-left":"chat-right"}${o&&i?" chat-no-avatar":""}`,ref:a,children:[o&&!i&&e.u("img",{alt:"AI Avatar",className:"chat-avatar chat-avatar-left",srcSet:`${r.agentAvatar["1x"]} 1x, ${r.agentAvatar["2x"]} 2x`}),e.u("div",{className:`chat-bubble ${d}`,children:t||e.u("div",{className:"chat-message-text",children:n.content})}),!o&&!i&&e.u("img",{alt:"User Avatar",className:"chat-avatar chat-avatar-right",srcSet:`${r.respondentAvatar["1x"]} 1x, ${r.respondentAvatar["2x"]} 2x`})]})});ae.displayName="ChatBubble";const Mn=()=>{const n=e.useConfig(t=>t.close),o=e.F(()=>()=>n(W.APP_ID),[n]);return e.u("div",{"aria-label":"Close button",className:"conversational-close-btn",onClick:o,onKeyPress:t=>{t.key==="Enter"&&o()},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"})})})},Bn=({card:n,next:o,className:t="",isAnswered:r=!1})=>{const i={className:r?`${t} answered-card`:t,next:r?()=>{}:o,questionId:n.name,type:n.type,isAnswered:r};switch(n.type){case"consentlegal":return e.u(rn,{...i,...n.props});case"likert":return e.u(an,{...i,...n.props});case"matrix":return e.u(dn,{...i,...n.props});case"multiplechoice":return e.u(cn,{...i,...n.props});case"multipleselect":return e.u(un,{...i,...n.props});case"nps":return e.u(pn,{...i,...n.props});case"open":return e.u(vn,{...i,...n.props});case"rankorder":return e.u(mn,{...i,...n.props});case"recordedtask":return e.u(wn,{...i,...n.props});case"texturlprompt":return e.u(En,{...i,...n.props});case"thanks":return e.u(jn,{...i,...n.props});case"uploading":return e.u(_n,{...i,...n.props});case"videovoice":return e.u(In,{...i,...n.props});default:return null}};exports.default=({cards:n,next:o,previousResponses:t})=>{const{cardResponses:r,setCardResponse:i}=(()=>{const[f,w]=e.h(new Map);return{cardResponses:f,setCardResponse:e.T((k,L)=>{w(M=>new Map(M).set(k,L))},[])}})(),{index:a,isLongFormSurvey:d,avatars:u,startingQuestionIdx:s,viewDocument:p}=e.useConfig(f=>({index:f.index,isLongFormSurvey:W.isLongFormSurvey(f.studyType),avatars:f.avatars,startingQuestionIdx:f.startingQuestionIdx,viewDocument:f.viewDocument})),{currentQuestionBubbleRef:b,scrollToCurrentQuestion:c}=(({viewDocument:f})=>{const w=e._(null),k=e.T(()=>{const L=f.querySelector(".ul-card-main-content");if(w.current&&L&&L instanceof HTMLElement){const M=w.current.offsetTop-L.offsetTop-16;L.scrollTo({top:Math.max(0,M),behavior:"smooth"})}},[]);return{currentQuestionBubbleRef:w,scrollToCurrentQuestion:k}})({viewDocument:p}),m=((f,w,k)=>{const[L,M]=e.h(new Map);return e.p(()=>{if(f.length>0&&w<f.length){const _=f[w],C=`${_.name}`;if(w<=(k??0)||We(_))return void M(l=>new Map(l).set(C,!1));M(l=>new Map(l).set(C,!0));const D=setTimeout(()=>{M(l=>new Map(l).set(C,!1))},1e3);return()=>clearTimeout(D)}},[w,f,k]),L})(n,a,s),x=((f,w)=>{const[k,L]=e.h(new Set([0]));return e.p(()=>{L(M=>new Set(M).add(f))},[f]),e.p(()=>{const M=w??0;M>0&&L(_=>{const C=new Set(_);for(let D=0;D<=M;D++)C.add(D);return C})},[w]),k})(a,s),y=e.F(()=>({...t,...e.buildReadableResponseMap(n.map((f,w)=>{var k,L;return{...f,value:w<a?((k=r.get(`${f.name}`))==null?void 0:k.value)??null:null,secondaryValue:w<a?((L=r.get(`${f.name}`))==null?void 0:L.secondaryValue)??null:null}}))}),[t,r,n,a]),v=e.pipeReadableResponsesIntoCards(n,y);e.p(()=>{requestAnimationFrame(()=>{c()})},[a,c,m]);const h=e.T((f,w)=>{if(!w)return;const k=v[a];if(!k)return;const L=`${k.name}`;i(L,f);const M={...f,questionText:e.getProcessedQuestionText(k)};o([M])},[v,a,o,i]),S=v.map((f,w)=>({card:f,cardIndex:w})).filter(({cardIndex:f})=>x.has(f));return e.u("div",{className:"conversational-ui ul-conversational-ui","data-testid":"ui-container",children:[!d&&e.u(Mn,{}),e.u("div",{className:"chat-container",children:e.u("div",{className:"chat-messages",children:S.map(({card:f,cardIndex:w})=>e.u(Ln,{avatars:u,card:f,cardIndex:w,cardResponses:r,currentQuestionBubbleRef:b,handleCardResponse:h,index:a,questionThinkingStates:m,startingQuestionIdx:s},`question-card-${f.name}`))})})]})};
658
+ `}],Be="-video-player",Te="-secondary-video-player",_e="-video-recorder";let X,Ie;const te=async({event:n,apiBase:o,headers:t,visitorId:r,envId:i,metadata:a})=>{const d=_.document.documentElement;if(!r||!i)return;const u={event:`SDK - ${n}`,visitorId:r,environmentId:i,metadata:{...a||{},screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:d.clientWidth,clientHeight:d.clientHeight,location:window.location.href,language:navigator.language}};(await fetch(`${o}/sdk/1/visitors/${r}/analytics`,{method:"POST",cache:"no-cache",headers:t,body:JSON.stringify(u)})).ok||console.warn("[Sprig] (ERR-444) Failed to track analytics",n)},ne=async(n,o,t,r,i,a)=>{te({event:`Video Error ${o}`,apiBase:t,headers:r,visitorId:i,envId:a,metadata:{errorMessage:n.message}});const d=_.document.documentElement,u={screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:d.clientWidth,clientHeight:d.clientHeight,location:window.location.href,language:navigator.language},s={action:o,err:{message:n.message,stack:n.stack},meta:u,vid:i,envId:a};(await fetch(`${t}/sdk/1/errors`,{method:"POST",cache:"no-cache",headers:{...r,"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",n)},Ne=(n,o)=>{if(n.length===0)return o&&o();Promise.all(n.reduce((t,r)=>(t.push(((i,{type:a,content:d})=>new Promise(function(u,s){let p;a==="script"?(p=_.document.createElement("script"),p.src=d):a==="link"?(p=_.document.createElement("link"),p.rel="stylesheet",p.href=d,p.type="text/css"):(p=_.document.createElement("style"),p.innerHTML=d),p.onload=function(){u(d)},p.onerror=function(){s(d)},p.async=!1,p.id=btoa(d),i.appendChild(p)}))(_.document.head,r)),t),[])).then(()=>{_.videojs=_.document.defaultView.videojs,o&&o()}).catch(function(t){console.log(t+" failed to load")})},De=(n,o,t)=>{if(o==="start"&&(n.style.visibility="visible"),o==="none")n.style.visibility=Z;else if(o==="success")n.style.visibility=Z,n.innerHTML="Upload succeeded!";else{const r=Math.round(parseFloat(t));n.innerHTML=`Uploading <span class="ul-upload-progress-label__time">${r}%</span>`,n.style.background=`linear-gradient(to right, #E0E0EB 0%, #E0E0EB ${r}%, #FCFCFD ${r}%, #FCFCFD 100%)`}},he=(n,o)=>{const t=_.videojs(n.id());return t==null?void 0:t.payload[o]},Oe=(n,o)=>{const t=new(_.videojs.getComponent("Component"))(n);return t.addClass("ul-buttons-panel"),o.map(r=>{t.addChild(r)}),Ke(t),t},Ke=n=>{n.children().forEach(o=>{if(K[o.name_]){const t=le(K[o.name_],`ul-${K[o.name_]}`);o.el_.appendChild(t)}})},le=(n,o="")=>{const t=_.document.createElement("span");return t.className="ul-button-text",t.innerHTML=n,t.id=o,t},qe=(n,o,t,r,i=!1,a)=>{n.addClass("ul-video-player");const d=new(_.videojs.getComponent("Component"))(n);d.addClass("ul-control-panel"),n.progressBar=d.addChild("ProgressControl"),t&&n.src(t),n.audioPlayerPlaceholder=new(_.videojs.getComponent("Component"))(n),n.audioPlayerPlaceholder.addClass("ul-audio-recorder-placeholder");const u=t&&t.src?nn(t.src):null;!t||!i&&u?(n.audioPlayerPlaceholder.hide(),_.document.getElementById(`${n.id()}_html5_api`).style.height="100%",u&&n.poster(u)):(n.children()[0].classList.add("vjs-hidden"),_.document.getElementById(`${n.id()}_html5_api`).style.height="0px"),n.on("play",()=>{i||!t||u||Xe(n),a==null||a.play()}),n.on("pause",()=>{a==null||a.pause()}),n.on("seeked",()=>{a==null||a.currentTime(n.currentTime())}),n.on("ratechange",()=>{a==null||a.playbackRate(n.playbackRate())}),n.addChild(n.audioPlayerPlaceholder,{},1),d.addChild(o),n.addChild(d),r&&r(n)},Je=(n,o,t,r,i,a,d,u=!1)=>{Ie=Date.now();const s=de(o,{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=t;const{surveyId:p,questionId:b,responseGroupUid:c,visitorId:v,envId:x}=t;let C;const m=l=>{const g=me,T=me+"-audio-only";De(s.uploadProgressLabel,"none"),X&&X.startTime>=Ie&&X.abort();const A=_.document.getElementById("ul-camera-button");l?(s.children()[0].classList.add("vjs-hidden"),f.removeClass(g),f.addClass(T),A.innerHTML=K.TurnOnCamera,s.audioPlayerPlaceholder.removeClass("vjs-hidden"),C==null||C.getTracks().forEach(R=>{R.stop()}),window.navigator.mediaDevices.getUserMedia({video:!0,audio:!0}).then(R=>{C=R,R.getVideoTracks().forEach(q=>{q.enabled=!1}),s.record().onDeviceReady(R)}).catch(s.record().onDeviceError.bind(s.record()))):(C==null||C.getVideoTracks().forEach(R=>{R.enabled=!0}),s.children()[0].classList.remove("vjs-hidden"),s.record().getDevice(),f.removeClass(T),f.addClass(g),A.innerHTML=K.TurnOffCamera,s.audioPlayerPlaceholder.addClass("vjs-hidden"))},h=new(_.videojs.getComponent("Button"))(s,{clickHandler:()=>{h.hasClass(Z)||(te({event:"Video Delete Button Clicked",apiBase:r,headers:d,visitorId:v,envId:x,metadata:{questionId:b,responseGroupUid:c,surveyId:p}}),m(s.cameraOff),i(B.DELETE,{}),f.removeClass(Z),h.addClass(Z))}});h.addClass("ul-video-recorder-delete-button"),h.el_.appendChild(le(K.DeleteButton,"ul-delete-button"));const D=_.document.getElementById(o),N=()=>{D.classList.contains("vjs-fullscreen")&&s.cameraOff?D.style.display="table":D.style.display="flex"};N();const f=new(_.videojs.getComponent("Button"))(s,{clickHandler:()=>{s.record().isRecording()||(s.cameraOff=!s.cameraOff,te({event:"Video Camera Button Clicked",apiBase:r,headers:d,visitorId:t.visitorId,envId:t.envId,metadata:{questionId:b,responseGroupUid:c,surveyId:p,cameraOff:s.cameraOff}}),m(s.cameraOff),!h.hasClass(Z)&&h.addClass(Z),i(B.DELETE,{}),N())}});f.addClass(me),f.el_.appendChild(le(K.TurnOffCamera,"ul-camera-button"));const y=new(_.videojs.getComponent("Button"))(s,{clickHandler:()=>{const l=_.document.getElementById("ul-recorder-toggle");if(s.record().isRecording())s.record().stop(),l&&(l.innerHTML=K.RecordButton),y.removeClass(ge),h.removeClass(Z);else{const g=_.document.getElementById("ul-recording-countdown-screen");if(g)g.remove(),l&&(l.innerHTML=K.RecordButton),m(s.cameraOff),i(B.DELETE,{}),f.removeClass(Z),h.addClass(Z),y.removeClass(ge),k.show();else{y.addClass(ge),k.hide(),f.addClass(Z),h.addClass(Z),l&&(l.innerHTML=K.StopButton);const T=_.document.createElement("div");T.id="ul-recording-countdown-screen",D.insertBefore(T,D.children[1]),T.style.height=`${D.offsetHeight}px`,Ue(s,3)}}}});y.addClass("ul-video-recorder-toggle-button"),y.el_.appendChild(le(K.RecordButton,"ul-recorder-toggle"));const L=_.document.createElement("p");L.style.visibility="hidden",L.className="ul-upload-progress-label",n.appendChild(L),s.uploadProgressLabel=L;const S=Oe(s,[h,f,"PlayToggle",y,"FullscreenToggle"]),k=S.children().find(l=>l.name_==="FullscreenToggle");k.hasClass("vjs-disabled")&&k.hide();const w=S.children().find(l=>l.name_==="PlayToggle");w.hide(),h.addClass(Z),qe(s,S,a,!1,u),s.on("stopRecord",()=>{y.hide(),w.show(),k.show(),h.removeClass(Z)}),s.on("deviceReady",()=>{y.show(),w.hide(),h.addClass(Z)}),((l,g,T,A,R)=>{const{surveyId:q,responseGroupUid:Q,visitorId:H,envId:U}=l.payload;l.on("deviceError",function(){console.warn("device error: ",l.deviceErrorCode),l.deviceErrorCode.message==="Permission denied"?(l.deviceButton.addClass("permission-denied"),T&&T(B.ERROR,{type:B.PERMISSION_DENIED}),te({event:"Video Permission Denied",apiBase:g,headers:R,visitorId:H,envId:U,metadata:{questionId:he(l,ve),responseGroupUid:Q,surveyId:q}})):(T&&T(B.ERROR,{type:B.OTHER}),ne(new Error(l.deviceErrorCode.message),"recorderDeviceError",g,R,H,U))}),l.on("error",function(z,G){ne(G||l.error(),"recorderError",g,R,H,U)}),l.on("startRecord",function(z,G){A(l.uploadProgressLabel,"none"),te({event:"Video Record Start",apiBase:g,headers:R,visitorId:H,envId:U,metadata:{questionId:he(l,ve),responseGroupUid:Q,surveyId:q}})}),l.on("finishRecord",async function(){A(l.uploadProgressLabel,"start",0);const z=he(l,ve);if(!q){const P="internal error: missing fields in payload";return T&&T(B.ERROR,{type:B.OTHER}),ne(new Error(P),"finishRecord",g,R,H,U),null}l.record().stopDevice();const G=l.cameraOff?B.MEDIA_TYPE_AUDIO:B.MEDIA_TYPE_VIDEO,J=W.v4();te({event:"Video Record Finish",apiBase:g,headers:R,visitorId:H,envId:U,metadata:{mediaRecordingUid:J,questionId:z,responseGroupUid:Q,surveyId:q,mediaType:G}});const ie={surveyId:q,updatedAt:new Date().toISOString(),mediaType:G,mediaRecordingUid:J};z&&(ie.questionId=z),Q&&(ie.responseGroupUid=Q),H&&(ie.visitorId=H);const j=await(async()=>{const P=await fetch(`${g}/2/environments/integrations/upload`,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie)});if(P.ok){const O=await P.json();return T&&T(B.UPLOAD_STARTED,{[B.UPLOAD_ID]:O.upload.id,[B.MEDIA_TYPE]:G,[B.MEDIA_RECORDING_UID]:J}),O.upload.url}return T&&T(B.ERROR,{type:B.OTHER,response:P}),ne(new Error("failed to get upload response with url"),"finishRecord",g,R,H,U),null})();j&&(X=_.document.defaultView.UpChunk.createUpload({endpoint:j,file:new _.document.defaultView.File([l.recordedData],`recording ${G} ${Date.now()}`),chunkSize:5120}),X.startTime=Date.now(),te({event:"Video Upload Start",apiBase:g,headers:R,visitorId:H,envId:U,metadata:{mediaRecordingUid:J,questionId:z,responseGroupUid:Q,surveyId:q,mediaType:G,url:j}}),X.on("error",P=>{A(l.uploadProgressLabel,"none"),T&&T(B.UPLOAD_FINISHED,{[B.MEDIA_RECORDING_UID]:J}),ne(P,"finishRecord",g,R,H,U)}),X.on("progress",P=>{T&&T(B.UPLOAD_PROGRESS,{[B.MEDIA_RECORDING_UID]:J,[B.UPLOAD_PROGRESS_PCT]:P.detail}),A(l.uploadProgressLabel,"progress",P.detail)}),X.on("success",()=>{A(l.uploadProgressLabel,"success"),T&&T(B.UPLOAD_FINISHED,{[B.MEDIA_RECORDING_UID]:J}),te({event:"Video Upload Success",apiBase:g,headers:R,visitorId:H,envId:U,metadata:{mediaRecordingUid:J,questionId:z,responseGroupUid:Q,surveyId:q,mediaType:G,url:j,elapsedMs:X.startTime&&Date.now()-X.startTime}})}))})})(s,r,i,De,d);const I=[{name:"microphone"}];!s.cameraOff&&I.push({name:"camera"}),Promise.all(I.map(l=>{var g;return(g=navigator==null?void 0:navigator.permissions)==null?void 0:g.query(l)})).then(l=>{l.reduce((g,T)=>g&T.state==="granted",!0)&&s&&(s.deviceButton&&s.deviceButton.hide(),s.record().getDevice())}).catch(l=>{})},Ue=(n,o=3)=>{const t=_.document.getElementById("ul-recording-countdown-screen");t&&o===0?(t.remove(),n.record().start()):t&&(t.innerHTML=`<span class='ul-countdown-text'>Recording in... ${o}</span>`,setTimeout(()=>{Ue(n,o-1)},1e3))},Ae=n=>{const o=_.document.createElement("div");return o.className="ul-video-container",o.appendChild((t=>{const r=_.document.createElement("div");return r.className="ul-video-player-loading",r.id=xe(t),["first","second","third","fourth"].map(i=>{const a=_.document.createElement("div");a.className=i,r.appendChild(a)}),r})(n)),o},be=(n,o)=>{const t=_.document.createElement("video");t.id=n,t.className="video-js vjs-default-skin ul-video-player-video";const r=_.document.createElement("p");r.className="vjs-no-js",r.innerHTML="To view this video please enable JavaScript, and consider upgrading to a web browser that";const i=_.document.createElement("a");return i.href="https://videojs.com/html5-video-support/",i.target="_blank",i.innerHTML="supports HTML5 video",r.appendChild(i),t.appendChild(r),o.appendChild(t),o},Xe=(n,o)=>{n.children()[0].classList.remove("vjs-hidden"),n.audioPlayerPlaceholder.hide(),_.document.getElementById(`${n.id()}_html5_api`).style.height="100%"},de=(n,o)=>_.document.getElementById(n)?o?_.videojs(n,o):_.videojs(n):(console.error(`Error in finding player element with ID, ${n}`),null),en=(n,o,t,r=!1,i="https://api.sprig.com",a=document,d=null,u=null)=>{_.document=a;const s=n+Be,p=Ae(s);return _.document.addEventListener("securitypolicyviolation",b=>{ne(new Error(`Voice & Video feature violates ${b.violatedDirective} web page CSP policies for the question player.`),"playerDeviceError",i,{})}),Ne(Me,()=>{_.document.getElementById(xe(s)).remove(),be(s,p);const b={playsinline:!0,playbackRates:[.5,1,1.5,2],fill:!0};try{const c=n+Te;be(c,p);const v=de(s,b),x=de(c,{muted:!0,...b});if(!v||!x)return;((h,D,N)=>{h.addClass(`ul${Te}`);const f=new(_.videojs.getComponent("Component"))(h);D&&h.src(D),h.addChild(f),N&&N(h)})(x,d,u),d||x.addClass(Z);const C=Oe(v,["PlaybackRateMenuButton","PlayToggle","FullscreenToggle"]),m=C.children().find(h=>h.name_==="FullscreenToggle");m.hasClass("vjs-disabled")&&m.hide(),qe(v,C,o,t,r,x)}catch(c){return void ne(new Error(`Error when creating video player object ${c}`),"playerDeviceError",i,{})}}),p},nn=n=>{if(!n)return null;const o=n.match(/https:\/\/stream.mux.com\/(.*)/);let t=o?o[1]:null;return t.includes(je)&&(t=t.replace(je,"")),t?`https://image.mux.com/${t}/thumbnail.jpg?time=0`:null},B={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"},K={PlaybackRateMenuButton:"Speed",PlayToggle:"Play",FullscreenToggle:"Expand",TurnOnCamera:"Turn on",TurnOffCamera:"Turn off",DeleteButton:"Delete",RecordButton:"Record",StopButton:"Stop",PauseButton:"Pause"},tn=({properties:n,surveyVideoUrl:o,questionId:t})=>{const r=`ul-card-video__question_player-q${t}`,{apiURL:i,viewDocument:a}=e.useConfig(d=>({apiURL:d.apiURL,viewDocument:d.viewDocument}));return e.u("div",{id:r,ref:d=>{if(d&&d.children.length===0&&!n.properties.hideRecordedPrompt){const u=en(r,{src:o,type:"application/x-mpegURL"},void 0,n.properties.mediaType===B.MEDIA_TYPE_AUDIO,i,a);d.appendChild(u)}}})},oe=({isDisabled:n,onClick:o,children:t})=>e.u(E.Button,{className:"ul-card__button-checkmark",disabled:n,onClick:o,type:"button",children:[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"})}),t||"Ok"]}),rn=({className:n,next:o,properties:t,questionId:r,type:i})=>{const{useMobileStyling:a,border:d}=e.useConfig(y=>({useMobileStyling:y.useMobileStyling,border:y.border})),[u,s]=e.h(!1),[p,b]=e.h(""),[c,v]=e.h(!1),x=t==null?void 0:t.collectName,C=(t==null?void 0:t.nameLabelText)||"Full Name",m=(t==null?void 0:t.consentText)||"I agree to the stated conditions",h=(t==null?void 0:t.submitButtonText)||"Submit",D=!!p.trim(),N=u&&(!x||D),f=(y,L=!1)=>{y.preventDefault(),y.stopPropagation();let S=null;if(!L){if(!N)return void v(!0);S={submitted:!0},x&&(S.name=p)}o({value:S,questionId:r,type:i},!!L||N)};return e.u("div",{className:e.cc(n,"ul-card__consent-legal","fade-in-transition"),children:e.u(E.MobileEmbedView,{embeddedType:"pdf",properties:t,children:e.u(E.QuestionBodyFooterContainer,{children:[e.u("div",{className:"sprig-stretch",children:[e.u(E.Option,{allowTextEntry:!1,border:d,error:c&&!u,id:"consent",isRadio:!1,isSelected:u,label:m,onUserInputChanged:({selected:y})=>{y!==u&&s(!u)},useMobileStyling:a}),x&&e.u("input",{"aria-label":C,"aria-placeholder":C,className:e.cc(e.getClasses("ul-consent-legal__name-input",a)),"data-gramm":"false",maxLength:250,name:"name",onBlur:y=>{y.currentTarget.style.borderColor=c&&!D?W.ERROR_BORDER_COLOR:W.DEFAULT_BORDER_COLOR},onFocus:y=>{y.currentTarget.style.borderColor=c&&!D?W.ERROR_BORDER_COLOR:d},onInput:y=>{y.preventDefault(),y.stopPropagation(),b(y.currentTarget.value)},placeholder:C,style:c&&!D?{borderColor:W.ERROR_BORDER_COLOR}:{},tabIndex:0,value:p})]}),e.u("div",{className:"ul-card__button-wrapper ul-card-vertical__button-wrapper",children:[e.u(oe,{isDisabled:!N,onClick:y=>f(new SubmitEvent(y.type)),children:e.getButtonText({buttonText:h})}),t.required===!1&&e.u("button",{className:"ul-card-skip__button",onClick:y=>f(new SubmitEvent(y.type),!0),children:e.getSkipButtonText(t)})]})]})})},r)},on=()=>{const{destroy:n,forceBrandedLogo:o}=e.useConfig(t=>({destroy:t.destroy,forceBrandedLogo:t.forceBrandedLogo}));return e.p(()=>{setTimeout(()=>{n(W.APP_ID)},o?4e3:2e3)},[n,o]),e.u("div",{className:"end-of-survey-text",children:"End of survey"})},sn=({activeValue:n,border:o,icon:t,enableCspTrustedTypes:r,isPressed:i,range:a,scaleLabelType:d,selectedValue:u,setSelectedValue:s,setActiveValue:p,setIsPressed:b,useMobileStyling:c,value:v,viewDocument:x})=>{const C=`option-${v}`,m=d==="number",h=d==="star",D=d==="smiley",N=m&&v===n||v===u,[f,y]=(()=>{const k=h&&u!==null&&v<=u;return h&&v<=n||D&&v===n||k||v===n||v===u?[o,i||k||v===u?1:.3]:["",1]})(),L=e.F(()=>{const k={borderColor:N?f:"",fillOpacity:N?"":y,zIndex:N?3:"auto",color:u===v?"#fff":""};return m?{...k,backgroundColor:u===v?f:""}:{...k,color:h||D||u===v?f:""}},[N,f,y,u,v,m,h,D]),S=e.F(()=>W.getHtml((({icon:k,scaleLabelType:w,value:I,selectedValue:l})=>{if(w==="smiley"&&I===l){let g=0;return k.replace(/black/g,()=>++g==1?"black":"white")}return k})({icon:t,scaleLabelType:d,value:v,selectedValue:u}),r),[r,t,d,u,v]);return e.u("button",{"aria-label":m?void 0:String(v),className:(()=>{switch(d){case"star":return e.cc(e.getClasses("likert-star",c),e.getClasses(`likert-star-${v}`,c));case"smiley":return e.cc(e.getClasses("likert-smiley",c),e.getClasses(`likert-smiley-${v}`,c));default:return v===a?e.cc(e.getClasses("likert-number",c),e.getClasses(`likert-number-${v}`,c),e.getClasses("likert-last-option",c)):e.cc(e.getClasses("likert-number",c),e.getClasses(`likert-number-${v}`,c))}})(),dangerouslySetInnerHTML:{__html:S},id:C,onClick:k=>{k.preventDefault(),k.stopPropagation(),s(v)},onKeyDown:k=>{var l,g;const w=x.querySelectorAll(`.likert-${d??"number"}`),I=v-1;k.key==="ArrowRight"?(l=w[I+1])==null||l.focus():k.key==="ArrowLeft"?(g=w[I-1])==null||g.focus():k.key!=="Enter"&&k.key!==" "||(k.preventDefault(),k.stopPropagation(),s(v))},onPointerDown:()=>b(!0),onPointerEnter:()=>p(v),onPointerLeave:()=>{p(-1),b(!1)},style:L,tabIndex:0})},an=({className:n,labels:o,next:t,properties:r,questionId:i,type:a})=>{const{border:d,useMobileStyling:u,viewDocument:s,enableCspTrustedTypes:p}=e.useConfig(w=>({border:w.border,useMobileStyling:w.useMobileStyling,viewDocument:w.viewDocument,enableCspTrustedTypes:w.enableCspTrustedTypes})),[b,c]=e.h(-1),[v,x]=e.h(!1),[C,m]=e.h(null),h=o&&o.left,D=o&&o.right;let N;const{range:f,scaleLabelType:y,ratingIcons:L}=r;f&&(N=Number(f));const S=N||5,k=w=>{var I,l;switch(y){case"star":return(I=L[0])==null?void 0:I.svg;case"smiley":return(l=L[w])==null?void 0:l.svg;default:return String(w+1)}};return e.u("form",{className:e.cc(n,"ul-card--likert","fade-in-transition"),children:e.u(E.MobileEmbedView,{properties:r,children:[e.u(E.QuestionBodyWrapper,{children:[e.u("div",{"aria-label":`Rating (1 - ${S})`,className:"ul-card--likert__numbers",role:"radiogroup",children:[...Array(S)].map((w,I)=>{const l=I+1;return e.u(sn,{activeValue:b,border:d,enableCspTrustedTypes:p,icon:k(I),isPressed:v,range:S,scaleLabelType:y,selectedValue:C,setActiveValue:c,setIsPressed:x,setSelectedValue:m,useMobileStyling:u,value:l,viewDocument:s},I)})}),e.u("div",{className:"ul-card--likert__labels",children:[e.u("span",{children:h}),e.u("span",{children:D})]})]}),e.u(E.QuestionBodyFooterContainer,{children:e.u(oe,{isDisabled:C===null&&r.required,onClick:()=>t({value:C,questionId:i,type:a},!0),children:e.getButtonText(r)})})]})},i)},ln=({columns:n,onSelect:o,options:t,selectedOptions:r})=>{const i=e._([]),{border:a,useMobileStyling:d}=e.useConfig(v=>({border:v.border,useMobileStyling:v.useMobileStyling})),u=t.findIndex(v=>r[v.id]===null),[s,p]=e.h(u),b=e.T((v,x)=>{o(v,x);const C=s+1,m=t[C];m&&r[m.id]===null&&p(C)},[o,t,r,s]),c=e.T((v,x)=>{const C=s===v;return e.u(e.Accordion,{animate:!0,header:x.label,isOpen:C,onClick:()=>{var m;return p(C&&!((m=window.UserLeap)!=null&&m.isMobileSDK)?-1:v)},ref:m=>{m&&(i.current[v]=m)},showHeaderCheck:r[x.id]!==null,children:e.u("div",{style:{paddingTop:"12px"},children:n.map(m=>e.u(E.Option,{allowTextEntry:!1,ariaLabel:`${x.label}-${m.label}`,border:a,error:!1,id:`${x.id}-${m.value}`,isRadio:!0,isSelected:r[x.id]===m.value,label:m.label,onUserInputChanged:()=>b(x.id,m.value),useMobileStyling:d},m.label))})},x.id)},[a,n,s,b,r,d]);return e.u("div",{children:t.map((v,x)=>c(x,v))})},dn=({className:n,next:o,options:t,properties:r,questionId:i,type:a,onSubmitButtonClick:d})=>{const u=r.matrixColumn,s=r.required,p=C=>{C.preventDefault(),C.stopPropagation(),o({value:c,questionId:i,type:a},!0),d&&d()},b=t.reduce((C,m)=>(C[m.id]=null,C),{}),[c,v]=e.h(b);return e.u("form",{className:e.cc(n,"ul-card__matrix","fade-in-transition"),id:"text-form",onSubmit:p,children:e.u(E.MobileEmbedView,{properties:r,children:[e.u(E.QuestionBodyWrapper,{children:e.u(ln,{columns:u,onSelect:(C,m)=>{v(h=>({...h,[C]:m}))},options:t,selectedOptions:c})}),e.u(E.QuestionBodyFooterContainer,{children:e.u(oe,{isDisabled:(x=c,s&&Object.values(x).every(C=>C==null)),onClick:()=>p(new SubmitEvent("submit")),children:e.getButtonText(r)})})]})},i);var x},He=({className:n,onSubmit:o,options:t=[],properties:r,questionId:i,type:a,showIndividualSubmit:d=!1,onSubmitButtonClick:u})=>{const{border:s,useMobileStyling:p}=e.useConfig(l=>({border:l.border,useMobileStyling:l.useMobileStyling})),b=t.reduce((l,g)=>(l[g.id]={isSelected:!1},l),{}),[c,v]=e.h(b),x=a==="multiplechoice",C=r.required,m=t.find(l=>{var g;return(g=l.optionProperties)==null?void 0:g.noneOfTheAbove}),h=l=>Object.entries(l).some(([g,T])=>{var q;const A=t.find(Q=>`${Q.id}`===g),R=T.userText===void 0||T.userText.trim()==="";return((q=A==null?void 0:A.optionProperties)==null?void 0:q.allowsTextEntry)&&R&&T.isSelected}),D=l=>Object.values(l).filter(g=>g.isSelected).length,N=r.minSelect&&r.minSelect>0&&r.maxSelectMode===E.MaxSelectModes.Range&&D(c)<r.minSelect&&(C||D(c)>0),f=l=>h(l)||C&&!D(l)||!(g=>{const{minSelect:T=0,maxSelect:A=1/0,maxSelectMode:R}=r,q=D(g);switch(R){case E.MaxSelectModes.Maximum:return q<=A;case E.MaxSelectModes.Range:return q===0||q>=T;default:return!0}})(l),y=Object.entries(c).some(([l,g])=>{var T,A;return g.isSelected&&((A=(T=t.find(R=>`${R.id}`===l))==null?void 0:T.optionProperties)==null?void 0:A.allowsTextEntry)}),L=d&&(!x||y),S=l=>{I(l.id,l.selected,l.userText,l.noneOfTheAbove)},k=l=>{var g;return(r==null?void 0:r.maxSelectMode)!==E.MaxSelectModes.Unlimited&&D(c)===(r==null?void 0:r.maxSelect)&&!((g=c[l])!=null&&g.isSelected)},w=()=>{o(c,!0),u&&u()},I=(l,g,T,A)=>{const R=Object.assign({},c);if((x||A)&&g)for(const q of Object.values(R))q.isSelected=!1,delete q.userText;else m&&!A&&c[m.id].isSelected&&(R[m.id].isSelected=!1);R[l]={isSelected:g,userText:T},v(R)};return e.u("form",{className:e.cc(n,"ul-card--multiple","fade-in-transition"),id:"text-form",onSubmit:w,children:e.u(E.MobileEmbedView,{properties:r,children:[e.u(E.QuestionBodyWrapper,{children:[r.isDropdown?e.u(E.Select,{disabledOptions:t.filter(l=>k(l.id)),dropdownFooter:N?e.u("div",{className:"ul-card__min-select-counter",style:{marginLeft:"16px"},children:[D(c),"/",r.minSelect]}):void 0,isMultiSelect:!x,multiselectText:r.dropdownMultiselectedText??"choices selected",onChange:l=>{const g={...c};for(const T of t)l.includes(T)?g[T.id].isSelected=!0:g[T.id].isSelected=!1;v(g)},options:t,placeholderText:r.dropdownPlaceholderText??(x?"Select choice":"Select choice(s)"),value:t.filter(l=>c[l.id].isSelected)}):e.u("div",{className:e.cc(e.getClasses("ul-card__choices",p)),role:x?"radiogroup":"group",children:[t.map(({id:l,label:g,value:T,optionProperties:A})=>{var U,z;const R=`${l}`,{allowsTextEntry:q,noneOfTheAbove:Q}={allowsTextEntry:!1,noneOfTheAbove:!1,...A};return e.u(E.Option,{allowTextEntry:q,border:s,disabled:k(R),error:(H=c,h(H)),id:R,isRadio:x,isSelected:!!((U=c[R])!=null&&U.isSelected),label:g,noneOfTheAbove:Q,onUserInputChanged:S,promptText:"Please specify",text:(z=c[l])==null?void 0:z.userText,useMobileStyling:p,value:T},R);var H}),!!N&&e.u("div",{className:"ul-card__min-select-counter",children:[D(c),"/",r.minSelect]})]}),L&&e.u(E.LongformSubmitButton,{handleSubmit:w,isSubmitDisabled:f(c)})]}),e.u(E.QuestionBodyFooterContainer,{children:e.u(oe,{isDisabled:f(c),onClick:w,children:e.getButtonText(r)})})]})},i)},cn=n=>{const{questionId:o,type:t,next:r,options:i}=n;return e.u(He,{...n,onSubmit:(a,d)=>{const u=Object.entries(a).find(([,v])=>v.isSelected)||[void 0,void 0],[s,p]=u,b=i.find(v=>`${v.id}`===s),c=p!=null&&p.userText?{[s]:{userText:p.userText}}:null;r({value:b&&s?{[s]:b.value}:{},secondaryValue:c,questionId:o,type:t},d)}})},un=n=>{const{questionId:o,type:t,next:r}=n;return e.u(He,{...n,onSubmit:(i,a)=>{const d=Object.entries(i).reduce((s,[p,b])=>(s[p]=b.isSelected,s),{}),u=Object.entries(i).reduce((s,[p,b])=>{if(!b.userText)return s;const c=s||{};return c[p]={userText:b.userText},c},null);r({value:d,secondaryValue:u,questionId:o,type:t},a)}})},pn=({className:n,labels:o,properties:t,next:r,questionId:i,type:a})=>{const[d,u]=e.h(null),{border:s,useMobileStyling:p,viewDocument:b}=e.useConfig(x=>({border:x.border,useMobileStyling:x.useMobileStyling,viewDocument:x.viewDocument})),c=o&&o.left,v=o&&o.right;return e.u("form",{className:e.cc(n,"ul-card--nps","fade-in-transition"),children:e.u(E.MobileEmbedView,{properties:t,children:[e.u(E.QuestionBodyWrapper,{children:[e.u("div",{className:"ul-card--nps__numbers",children:[...Array(11)].map((x,C)=>e.u("button",{className:e.cc(e.getClasses("nps-number",p),e.getClasses(`nps-number-${C}`,p)),id:`option-${C}`,onClick:m=>{m.preventDefault(),m.stopPropagation(),u(C)},onKeyDown:m=>{var D,N;const h=b.querySelectorAll("button.nps-number");m.key==="ArrowRight"?(D=h[C+1])==null||D.focus():m.key==="ArrowLeft"?(N=h[C-1])==null||N.focus():m.key!=="Enter"&&m.key!==" "||(m.preventDefault(),m.stopPropagation(),u(C))},onPointerDown:m=>{m.currentTarget.style.zIndex="2",m.currentTarget.style.borderColor=s},onPointerLeave:m=>{m.currentTarget.style.zIndex="auto",m.currentTarget.style.borderColor=W.DEFAULT_BORDER_COLOR},style:d===C?{backgroundColor:s,color:"#fff"}:void 0,tabIndex:0,children:C},C))}),e.u("div",{className:"ul-card--nps__labels",children:[e.u("span",{children:c}),e.u("span",{children:v})]})]}),e.u(E.QuestionBodyFooterContainer,{children:e.u(oe,{isDisabled:d===null&&t.required,onClick:()=>r({value:d,questionId:i,type:a},!0),children:e.getButtonText(t)})})]})},i)},vn=({className:n,next:o,properties:t,questionId:r,type:i,onSubmitButtonClick:a})=>{const{border:d,useMobileStyling:u,update:s}=e.useConfig(h=>({border:h.border,useMobileStyling:h.useMobileStyling,update:h.update})),[p,b]=e.h(""),c=e._(null),v=p.trim(),x=t.required===!0&&!v,C=E.useAutoSize(c,()=>s()),m=t&&t.openTextPlaceholder?t.openTextPlaceholder:"";return e.u("form",{className:e.cc(n,"ul-card-text","fade-in-transition"),id:"text-form",children:e.u(E.MobileEmbedView,{properties:t,children:e.u("div",{className:"ul-card-text",children:[e.u(E.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":m,className:e.cc(e.getClasses("ul-card-text__input",u)),"data-gramm":"false",maxLength:5e3,name:"text",onBlur:h=>{h.currentTarget.style.borderColor=W.DEFAULT_BORDER_COLOR},onChange:h=>{const{value:D}=h.currentTarget;C(),h.preventDefault(),h.stopPropagation(),b(D)},onFocus:h=>{h.currentTarget.style.borderColor=d},placeholder:m,ref:c,role:"textbox",tabIndex:0})}),t.footerHtml&&e.u(E.Html,{className:"footer",html:t.footerHtml})]}),e.u(E.QuestionBodyFooterContainer,{children:e.u(oe,{isDisabled:x,onClick:h=>{h.preventDefault(),h.stopPropagation();const D=t.required!==!0||v.length>0;o({value:p,questionId:r,type:i},D),a&&a()},children:e.getButtonText(t)})})]})})},r)},mn=({className:n,labels:o,next:t,properties:r,questionId:i,type:a,onSubmitButtonClick:d,options:u})=>{const s=e._(null),p=e._(0),b=e._(0),c=e._(null),v=e._(!1),x=e._([]),[C,m]=e.h(()=>(r==null?void 0:r.required)===!0),[h,D]=e.h(()=>u.map(j=>({...j,rank:null}))),N=e.F(()=>Array.from({length:u.length},(j,P)=>P+1),[u.length]),{useMobileStyling:f,isPreview:y,headers:L}=e.useConfig(j=>({useMobileStyling:j.useMobileStyling,isPreview:j.isPreview,headers:j.headers})),S=(L==null?void 0:L["userleap-platform"])==="android",k=f&&!y&&!S,w=!k&&!S,I=(j,P)=>{D(O=>{const M=parseInt(P),V=O.map($=>({...$}));V.some($=>$.rank==null)&&V.forEach(($,se)=>$.rank=se+1);const Y=V.findIndex($=>$.id===j);if(Y===-1)return O;const F=V[Y].rank;return M<F?V.forEach($=>{$.id!==j&&$.rank>=M&&$.rank<F&&($.rank=$.rank+1)}):M>F&&V.forEach($=>{$.id!==j&&$.rank>F&&$.rank<=M&&($.rank=$.rank-1)}),V[Y].rank=M,V.sort(($,se)=>$.rank-se.rank),Q(),V})},l=(j,P)=>{for(let O=0;O<x.current.length;O++){const M=x.current[O];if(!M||M===c.current)continue;const V=M.getBoundingClientRect();if(j>=V.left&&j<=V.right&&P>=V.top&&P<=V.bottom)return{element:M,index:O}}return null},g=j=>P=>{if(!k)return;P.preventDefault(),P.stopPropagation(),v.current=!0,s.current=j;const O=P.touches[0];p.current=O.clientY,b.current=O.clientY;const M=P.currentTarget.closest(".ul-card-rank__option");M&&(c.current=M,M.classList.add("is-dragging"))},T=j=>{if(!k||!v.current||s.current===null)return;j.preventDefault(),j.stopPropagation();const P=j.touches[0];b.current=P.clientY;const O=b.current-p.current;c.current&&(c.current.style.transform=`translateY(${O}px)`,c.current.style.zIndex="1000"),x.current.forEach(V=>{V&&V!==c.current&&V.classList.remove("is-drop-target")});const M=l(P.clientX,P.clientY);M&&M.element.classList.add("is-drop-target")},A=j=>{if(!k||!v.current||s.current===null)return;j.preventDefault(),j.stopPropagation();const P=j.changedTouches[0],O=l(P.clientX,P.clientY);c.current&&(c.current.style.transform="",c.current.style.zIndex="",c.current.classList.remove("is-dragging")),x.current.forEach(M=>{M&&M.classList.remove("is-drop-target")}),O&&O.index!==s.current&&R(s.current,O.index),s.current=null,c.current=null,v.current=!1},R=(j,P)=>{D(O=>{const M=O.map(Y=>({...Y})),[V]=M.splice(j,1);return M.splice(P,0,V),M.forEach((Y,F)=>{Y.rank=F+1}),Q(),M})},q=j=>{const P={};j.reduce((O,M)=>(O[M.id]=M.rank,O),P),t({value:P,questionId:i,type:a},!0)},Q=()=>{m(!1)},{left:H,right:U}=o,z=u.length,G=j=>{j.preventDefault(),j.currentTarget.classList.add("is-drop-target")},J=j=>{j.currentTarget.classList.remove("is-drop-target")},ie=j=>{s.current=null,j.currentTarget.classList.remove("is-dragging")};return e.u("form",{className:e.cc(n,"ul-card-rank","fade-in-transition"),onSubmit:j=>{j.preventDefault(),q(h),d&&d()},children:e.u(E.MobileEmbedView,{properties:r,children:S?e.u(E.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 - ",H]})}),e.u("ol",{className:"ul-card-rank__list",children:h.map(({id:j,label:P,rank:O})=>e.u("li",{className:"ul-card-rank__option",children:[e.u("select",{"aria-label":`Rank for ${P}`,className:e.cc("ul-card-rank__select",O==null&&"ul-card-rank__select--placeholder"),name:`rank[${j}]`,onChange:M=>I(j,M.currentTarget.value),value:O??"",children:[O==null&&e.u("option",{className:"ul-card-rank__select-option",disabled:!0,value:"",children:"-"}),N.map(M=>e.u("option",{className:"ul-card-rank__select-option",value:M,children:M},`${M}-${i}`))]}),e.u("span",{children:P})]},j))}),e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:[z," - ",U]})})]})}):e.u(e.g,{children:[e.u(E.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 - ",H]})}),e.u("ol",{className:"ul-card-rank__list",onDragOver:S?void 0:j=>{j.preventDefault(),j.dataTransfer&&(j.dataTransfer.dropEffect="move")},children:h.map(({id:j,label:P,rank:O},M)=>{return e.u("li",{className:"ul-card-rank__option",draggable:!!w||void 0,onDragEnd:w?ie:void 0,onDragEnter:w?G:void 0,onDragLeave:w?J:void 0,onDragStart:w?(Y=M,F=>{s.current=Y,F.dataTransfer&&(F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/plain",String(Y)),F.currentTarget.classList.add("is-dragging"))}):void 0,onDrop:w?(V=M,F=>{var se,Ee;F.preventDefault(),F.currentTarget.classList.remove("is-drop-target");const $=s.current;s.current=null,(Ee=(se=F.currentTarget.closest(".ul-card-rank__list"))==null?void 0:se.querySelector(".is-dragging"))==null||Ee.classList.remove("is-dragging"),$!=null&&$!==V&&R($,V)}):void 0,ref:F=>x.current[M]=F,children:[e.u("select",{"aria-label":`Rank for ${P}`,className:e.cc("ul-card-rank__select",O==null&&"ul-card-rank__select--placeholder"),name:`rank[${j}]`,onChange:F=>I(j,F.currentTarget.value),value:O??"",children:[O==null&&e.u("option",{className:"ul-card-rank__select-option",disabled:!0,value:"",children:"-"}),N.map(F=>e.u("option",{className:"ul-card-rank__select-option",value:F,children:F},F))]}),e.u("span",{children:P}),!S&&e.u("button",{"aria-label":`Drag ${P} to reorder`,className:"ul-card-rank__drag-btn",onTouchEnd:k?A:void 0,onTouchMove:k?T:void 0,onTouchStart:k?g(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"})})})]},j);var V,Y})}),e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:[z," - ",U]})})]})}),e.u(E.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-card__button-wrapper",children:e.u(E.Button,{disabled:C,children:e.getButtonText(r)})})})]})})},i)},fe=1,$e=2,Ve=3,ce=n=>n.type==="av_permission",Se=n=>n.type==="screen_permission",Fe=(n,o)=>n===void 0?fe:n?((t,r)=>!(ce(r)?r.permissionDescriptors:[]).includes("camera")||t.getVideoTracks().length>0)(n,o)?Ve:fe:$e,Re={avStream:null,currentPage:null,mediaRecordingUids:null,nextQuestion:()=>{},passthroughData:void 0,recordingMediaTypes:void 0,screenPermissionRequested:!1,type:void 0},ee=e.create(n=>({...Re,reset:()=>{n(Re)},updatePage:o=>{n(o)}}));function ye({currentPage:n,pages:o}){const{avStream:t,recordingMediaTypes:r,updatePage:i}=ee.getState(),{recorderEventEmitter:a}=e.useConfig.getState();a.emit("av.permission",{"permission.descriptors":n.permissionDescriptors,"stream.ready":(d,u)=>{if(t===d)return;let s=n;if(d&&!n.permissionDescriptors.includes("camera")){const p=o.indexOf(n),b=u!=null&&u.active?p+2:p+1;u!=null&&u.active&&r&&a.emit("begin.recording",{"recording.media.types":r,"start.recording.callback":c=>i({mediaRecordingUids:c})}),s=o[b]}i({currentPage:s,avStream:d})}})}function Ce({status:n}){const{nextQuestion:o,passthroughData:t,mediaRecordingUids:r,reset:i}=ee.getState(),{recorderEventEmitter:a,handleUploadUpdate:d,index:u}=e.useConfig.getState(),s={value:{taskStatus:n},type:"recordedtask",questionId:(t==null?void 0:t.questionId)||1};t&&a.emit("finish.task",{"begin.callback":p=>{d({mediaRecordingUid:p,isSubmitted:!0,progressPct:0,isComplete:!1})},"progress.callback":(p,b)=>{d({mediaRecordingUid:p,progressPct:b.detail,isSubmitted:!1,isComplete:!1})},"upload.callback":p=>{p&&d({mediaRecordingUid:p,isComplete:!0,isSubmitted:!0,progressPct:100})},"passthrough.data":t,"current.index":u,"task.response":s,"task.complete.callback":p=>{s.value.taskDurationMillisecond=p,r&&(s.value.mediaRecordingUids=r),i(),o(s)}})}function ke({pages:n,setIsRequestingPermission:o}){const{recorderEventEmitter:t,eventEmitFn:r}=e.useConfig.getState(),{updatePage:i,currentPage:a,recordingMediaTypes:d,screenPermissionRequested:u}=ee.getState();if(!a)return;const s=n.indexOf(a);switch(a.type){case"av_permission":{const p=u?s+2:s+1;return u&&d&&t.emit("begin.recording",{"recording.media.types":d,"start.recording.callback":b=>{i({mediaRecordingUids:b})}}),void i({currentPage:n[p]})}case"screen_permission":return void t.emit("screen.permission",{"screen.permission.requested":o,"stream.ready.callback":(p,b)=>{const c=b?n[s+1]:a;b&&d&&t.emit("begin.recording",{"recording.media.types":d,"start.recording.callback":v=>{i({captureStream:b,mediaRecordingUids:v})}}),i({currentPage:c,screenPermissionRequested:!0,captureStream:b})}});case"start_task":return r("recorded.task.start"),t.emit("recorded.task.start"),t.emit("start.task"),void i({currentPage:n[s+1],screenPermissionRequested:!0});case"complete_task":return}}const ze="ul-permission-graphics-container",Qe="ul-permission-body",Ge=e.cc(ze,"ul_recorded-task-inset-spacing"),ue=e.cc("ul-horizontal-button-container","ul-horizontal-button-container-left"),Ze=({richTextBody:n})=>e.u(E.Html,{className:"ul-rich-text-body",html:n,id:"ul-task-detail-container"}),pe=({required:n,skipButtonText:o,bottom:t=!1})=>n?null:e.u(E.Button,{className:e.cc(t&&"ul-skip-button-below","ul-button-inactive"),onClick:Ce.bind(null,{status:"abandoned"}),children:o||"Skip"}),we=n=>{const{avStream:o,captureStream:t,recordingMediaTypes:r,updatePage:i}=ee.getState(),a=(r==null?void 0:r.includes("audio"))||(r==null?void 0:r.includes("video"));e.p(()=>{const d=setInterval(()=>{a&&o&&!o.active?i({avStream:null,currentPage:n[0]}):t&&t.active||i({captureStream:void 0,currentPage:n[a?1:0]})},1e3);return()=>clearInterval(d)},[o,t,a,n,r,i])},gn=({content:n,pages:o,required:t})=>{const{buttonText:r,skipButtonText:i,taskDetail:a}=n;return we(o),e.u("div",{className:"ul-task-page",children:[a&&e.u(Ze,{richTextBody:a}),e.u("div",{className:ue,children:[e.u(E.Button,{onClick:ke.bind(null,{pages:o}),children:r}),e.u(pe,{required:t,skipButtonText:i})]})]},"start-task")},hn=({content:n,pages:o,properties:t})=>{const{buttonText:r,skipButtonText:i}=n;return we(o),e.u("div",{className:"ul-task-page",children:[n.taskDetail&&e.u(Ze,{richTextBody:n.taskDetail}),e.u(E.MobileEmbedView,{properties:t,children:e.u("div",{className:ue,children:[e.u(E.Button,{className:"ul-complete-task-button",onClick:Ce.bind(null,{status:"completed"}),children:r}),e.u(E.Button,{className:e.cc("ul-button-inactive"),onClick:Ce.bind(null,{status:"given.up"}),children:i})]})})]},"complete-task")},bn=({content:n,pages:o,required:t})=>{const{buttonText:r,skipButtonText:i}=n,[a]=e.useConfig(s=>[s.tabTitle]),[d,u]=e.h(!1);return e.u("div",{children:[e.u("div",{className:Ge,children:[e.u("p",{style:{marginTop:"auto"},children:n.selectTabText}),e.u("div",{className:"ul-select-tab-container",children:e.u("p",{className:Qe,children:a})})]}),e.u("div",{className:t?"":ue,children:[e.u(E.Button,{disabled:d,onClick:ke.bind(null,{pages:o,setIsRequestingPermission:u}),children:r}),e.u(pe,{required:t,skipButtonText:i})]})]})},fn=({content:n})=>e.u(E.Html,{className:e.cc(ze,"ul_permission_svg_container","ul_recorded-task-inset-spacing","ul-center-horizontally"),html:n.svg},"ul-permission-request-graphic"),yn=({content:n,pages:o,required:t})=>{const{permissionDeniedHeadline:r,permissionDeniedBody:i,skipButtonText:a,tryAgainButtonText:d}=n,u=ce(o[0])?o[0]:null;return e.p(()=>{const s=setInterval(()=>{u!==null&&ye({currentPage:u,pages:o})},1e3);return()=>clearInterval(s)},[u,o]),u?e.u("div",{children:[e.u("div",{className:Ge,children:e.u("p",{className:"ul-av-permission-denied-paragraph",children:[e.u("span",{className:"ul-av-permission-denied-headline",children:r}),e.u("span",{className:Qe,children:i})]})}),e.u("div",{className:ue,children:[e.u(E.Button,{onClick:ye.bind(null,{currentPage:u,pages:o}),children:d}),e.u(pe,{required:t,skipButtonText:a})]})]}):null},Cn=({stream:n})=>e.u("video",{autoPlay:!0,className:e.cc("ul_recorded-task-inset-spacing"),id:"ul-record-task-video-preview",muted:!0,ref:o=>{o&&(o.srcObject=n||null)}}),xn=({content:n,pages:o,required:t})=>{const{skipButtonText:r}=n,{avStream:i}=ee.getState();return we(o),e.u("div",{children:[e.u(Cn,{stream:i}),e.u("div",{className:"ul-vertical-button-container-center",children:[e.u(E.Button,{onClick:ke.bind(null,{pages:o}),children:n.buttonText}),e.u(pe,{bottom:!0,required:t,skipButtonText:r})]})]})},kn=({properties:n})=>{const{pages:o,required:t}=n,{avStream:r,currentPage:i}=ee.getState();if(i===void 0)return null;switch(i==null?void 0:i.type){case"av_permission":{const a=Fe(r,i);return a===fe?e.u(fn,{content:i}):a===$e?e.u(yn,{content:i,pages:o,required:t}):e.u(xn,{content:i,pages:o,required:t})}case"screen_permission":return e.u(bn,{content:i,pages:o,required:t});case"start_task":return e.u(gn,{content:i,pages:o,required:t});case"complete_task":return e.u(hn,{content:i,pages:o,properties:n});default:return null}},wn=({className:n,properties:o,next:t,questionId:r})=>{const i=e.useConfig(),{surveyId:a,responseGroupUid:d,userId:u}=i,s=ee(),{screenPermissionRequested:p}=s,b=ee(m=>m.avStream);let c=ee(m=>m.currentPage);c||(c=function({pages:m,userId:h,responseGroupUid:D,surveyId:N,questionId:f,next:y}){const{updatePage:L}=ee.getState(),{eventEmitFn:S,recorderEventEmitter:k}=e.useConfig.getState(),w={questionId:f,surveyId:N,visitorId:h,responseGroupUid:D};let I=0;k.emit("recorded.task.permission.screen"),S("recorded.task.permission.screen"),k.emit("permission.status",{"permission.status.callback":(g,T,A,R)=>{const q=m[I],{type:Q}=q,H=["screen"];if(ce(q)){const{permissionDescriptors:U}=q,z=U==null?void 0:U.includes("microphone"),G=U==null?void 0:U.includes("camera");z&&H.push("audio"),G&&H.push("video"),(g!=null&&g.active&&!G||g!=null&&g.active&&T)&&I++}Se(m[I])&&A&&(I++,k.emit("begin.recording",{"recording.media.types":H,"start.recording.callback":U=>L({mediaRecordingUids:U})})),L({currentPage:m[I],avStream:g,screenPermissionRequested:A,nextQuestion:y,type:Q,passthroughData:w,recordingMediaTypes:H,captureStream:R})}});const l=m[I];return l.type==="av_permission"&&ye({currentPage:l,pages:m}),l}({questionId:r,surveyId:a,next:m=>{t(m,!0)},pages:o.pages,responseGroupUid:d,userId:u}));let v=c.headline,x=c.captionText;const C=Fe(b,c);return Se(c)&&p&&(v=c.permissionDeniedHeadline,x=c.permissionDeniedCaptionText),ce(c)&&C===Ve&&(v=c.permissionGrantedHeadline,x=c.permissionGrantedCaptionText),e.u("div",{className:e.cc(n,"ul-center-horizontally","fade-in-transition"),children:[e.u(E.Header,{isRequired:o==null?void 0:o.required,message:v,properties:{captionText:x}}),e.u(E.QuestionBodyWrapper,{children:e.u(kn,{properties:o})})]})},En=({className:n,next:o,properties:t,questionId:r,type:i})=>{const{visitorAttributes:a,isLongFormSurvey:d}=e.useConfig(b=>({visitorAttributes:b.visitorAttributes,isLongFormSurvey:W.isLongFormSurvey(b.studyType)})),u=(b,c=!1)=>{o({value:c?{skipped:!0}:void 0,questionId:r,type:i},!0)},s=E.getAttributedUrl(t&&t.buttonUrl,a),p=d&&t.promptActionType===E.PromptActionTypeEnum.NO_BUTTON;return e.u("div",{className:e.cc(n,"ul-card__text-url-prompt","fade-in-transition"),children:e.u(E.MobileEmbedView,{properties:t,children:!p&&e.u("div",{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:u,onKeyPress:b=>{b.key!=="Enter"&&b.key!==" "||o({value:void 0,questionId:r,type:i},!0)},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:b=>u(0,!0),children:e.getSkipButtonText(t)})]})})})},r)},jn=({className:n,questionId:o})=>{const{border:t,destroy:r,endCard:i,forceBrandedLogo:a}=e.useConfig(s=>({border:s.border,destroy:s.destroy,endCard:s.endCard,forceBrandedLogo:s.forceBrandedLogo}));e.p(()=>{setTimeout(()=>{r(W.APP_ID)},a?4e3:2e3)},[r,a]);const d=i&&i.subheader?e.u("p",{className:"ul-caption",children:i.subheader}):null,u=i&&i.headline?i.headline:"";return e.u("div",{className:e.cc(n,"ul-card--thanks","fade-in-transition"),children:e.u("div",{children:e.u("div",{className:"ul-card--thanks-content",children:[e.u("div",{className:"ul-thanks-check",children:e.u("svg",{"aria-labelledby":"title",fill:"none",height:"99",viewBox:"0 0 81 99",width:"81",xmlns:"http://www.w3.org/2000/svg",children:[e.u("path",{clipRule:"evenodd",d:"M40.5 77C60.9345 77 77.5 60.4345 77.5 40C77.5 19.5655 60.9345 3 40.5 3C20.0655 3 3.5 19.5655 3.5 40C3.5 60.4345 20.0655 77 40.5 77ZM80.5 40C80.5 62.0914 62.5914 80 40.5 80C18.4086 80 0.5 62.0914 0.5 40C0.5 17.9086 18.4086 0 40.5 0C62.5914 0 80.5 17.9086 80.5 40Z",fill:t,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:t,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(E.Header,{message:u}),d]})})},o)},Tn=()=>e.u("div",{className:"thinking-dots-container",children:e.u("div",{className:"thinking-dot"})}),_n=({className:n})=>{const{uploadProgress:o}=e.useConfig(a=>({uploadProgress:a.uploadProgress}));let t,r;Object.values(o).filter(a=>a.isSubmitted).length>1?(t="Your responses are processing",r="Please keep this tab open until your responses are fully processed."):(t="Your response is processing",r="Please keep this tab open until your response is fully processed.");const i=Math.round(Math.min(99,...Object.values(o).filter(a=>a.isSubmitted).map(a=>a.progressPct||0)));return e.u("div",{className:e.cc(n,"ul-card--uploading","fade-in-transition"),children:[e.u("div",{"aria-busy":"true","aria-label":"Processing...","aria-live":"polite",className:"ul-loading-spinner-container",role:"progressbar",children:e.u("div",{className:"ul-loading-spinner",children:[e.u("div",{className:"first"}),e.u("div",{className:"second"}),e.u("div",{className:"third"}),e.u("div",{className:"fourth"})]})}),e.u(E.Header,{message:`${t} (${i}% complete)`}),e.u("p",{className:"ul-caption",children:r})]})},Pe=0,Le=1,In=({className:n,next:o,properties:t,questionId:r,type:i})=>{const a=`ul-card-video__player_recorder-q${r}`,{apiURL:d,envId:u,handleUploadUpdate:s,headers:p,responseGroupUid:b,surveyId:c,viewDocument:v,visitorId:x}=e.useConfig(w=>({apiURL:w.apiURL,envId:w.envId,handleUploadUpdate:w.handleUploadUpdate,headers:w.headers,responseGroupUid:w.responseGroupUid,surveyId:w.surveyId,viewDocument:w.viewDocument,visitorId:w.userId})),[C,m]=e.h(!1),[h,D]=e.h(null),[N,f]=e.h(null),[y,L]=e.h(Pe),S=(w,I)=>{w===B.UPLOAD_STARTED?(D(I[B.UPLOAD_ID]),f(I[B.MEDIA_RECORDING_UID]),m(!0)):w===B.DELETE?(D(null),f(null),m(!1)):w===B.UPLOAD_PROGRESS?isNaN(I[B.UPLOAD_PROGRESS_PCT])?s({mediaRecordingUid:I[B.MEDIA_RECORDING_UID],isComplete:!0}):s({mediaRecordingUid:I[B.MEDIA_RECORDING_UID],progressPct:I[B.UPLOAD_PROGRESS_PCT]}):w===B.UPLOAD_FINISHED&&s({mediaRecordingUid:I[B.MEDIA_RECORDING_UID],isComplete:!0})},k=w=>{w.preventDefault(),w.stopPropagation(),document.getElementById(a)&&(I=>{const l=I+_e;if(_.document.getElementById(l)&&_.videojs){try{if(!_.videojs(l).record().stream)return}catch{return}_.videojs(l).record().stop(),_.videojs(l).record().stopDevice()}})(a),h&&N?(s({mediaRecordingUid:N,isSubmitted:!0}),o({value:{mediaRecordingUid:N},questionId:r,type:i},!0)):o({value:null,questionId:r,type:i},!0)};return e.u("form",{className:e.cc(n,"ul-card--video","fade-in-transition"),id:"ul-video-interview-form",children:[e.u(E.QuestionBodyWrapper,{children:[e.u("div",{id:"ul-question-player-container",style:{display:y===Pe?"":"none"},children:e.u(E.MobileEmbedView,{properties:t,children:e.u("button",{className:"ul-video-btn ul-record-response-btn",onClick:w=>{w.preventDefault(),w.stopPropagation(),document.getElementById(a)&&(I=>{const l=de(I+Be);l==null||l.pause()})(a),L(Le)}})})}),e.u("div",{style:{display:y===Le?"block":"none"},children:e.u("div",{id:"ul-recorder-player-container",ref:w=>{if(w&&w.children.length===0){const I=((l,g={},T="https://api.userleap.com",A,R,q,Q=!1,H=document)=>{_.document=H;const U=l+_e,z=Ae(U);return _.document.addEventListener("securitypolicyviolation",G=>{ne(new Error(`Voice & Video feature violates ${G.violatedDirective} web page CSP policies for the recorder player.`),"recorderDeviceError",T,q,g.visitorId,g.envId)}),Ne(Me.concat(Ye),()=>{be(U,z),_.document.getElementById(xe(U)).remove();try{Je(z,U,g,T,A,R,q,Q)}catch(G){return void ne(new Error(`Error when creating video recorder player object ${G}`),"recorderDeviceError",T,q,g.visitorId,g.envId)}}),z})(a,{surveyId:c,responseGroupUid:b,questionId:r,visitorId:x,envId:u},d,S,void 0,{...p,"x-ul-video-recorder-origin":"sdk"},t.mediaType===B.MEDIA_TYPE_AUDIO,v);w.appendChild(I)}}})})]}),e.u(E.QuestionBodyFooterContainer,{children:[e.u(oe,{isDisabled:!!t.required&&!C,onClick:k,children:e.getButtonText(t)}),e.u("button",{className:"ul-card-text__button ul-button-inactive ul-card-skip__button",id:"ul-card-video__skip_button",onClick:k,style:{...t.required?{display:"none"}:{},...C?{display:"none"}:{}},children:e.getSkipButtonText(t)})]})]})},We=n=>n.type==="thanks"||n.type==="uploading",Dn=({card:n,avatars:o,isThinking:t,isCurrentQuestion:r,currentQuestionBubbleRef:i})=>{const a=(d=>"properties"in d.props&&d.props.properties&&"questionHtml"in d.props.properties&&d.props.properties.questionHtml?{content:d.props.properties.questionHtml,isHtml:!0}:"message"in d.props?{content:d.props.message,isHtml:!1}:{content:"Question",isHtml:!1})(n);return e.u(ae,{avatars:o,isLeft:!0,message:{id:`question-${n.name}`,type:"question",content:a.content},ref:r?i:null,children:t?e.u(Tn,{}):e.u(e.g,{children:[a.isHtml?e.u(E.Html,{className:"chat-message-text",html:a.content}):e.u("div",{className:"chat-message-text",children:a.content}),n.type==="videovoice"&&e.u(tn,{properties:n.props,questionId:n.name,surveyVideoUrl:n.props.properties.videoUrl})]})})},Sn=({card:n,avatars:o})=>{const t=(r=>{if(!("properties"in r.props)||!r.props.properties||typeof r.props.properties!="object")return null;const i=r.props.properties,a=[{key:"captionHtml",isHtml:!0},{key:"captionText",isHtml:!1},{key:"richTextBody",isHtml:!0},{key:"body",isHtml:!1}];for(const{key:d,isHtml:u}of a){const s=i[d];if(typeof s!="string")continue;const p=s.trim();if(p){if(u&&!p.replaceAll(/<[^>]*>/g,"").trim())continue;return{content:p,isHtml:u}}}return null})(n);return t?e.u(ae,{avatars:o,hideAvatar:!0,isLeft:!0,message:{id:`caption-${n.name}`,type:"question",content:t.content},children:t.isHtml?e.u(E.Html,{className:"chat-message-text",html:t.content}):e.u("div",{className:"chat-message-text",children:t.content})}):null},Rn=({card:n,userResponse:o,avatars:t})=>{const r=((i,a)=>{if(i.type==="open"&&a&&typeof a=="object"&&"value"in a)return a.value})(n,o);return e.u("div",{className:"chat-bubble-container chat-right",children:[e.u("div",{className:"chat-bubble chat-bubble-right chat-bubble-text-only",children:e.u("div",{className:"chat-message-text",children:r||e.u("div",{className:"chat-message-no-response",children:"No response"})})}),e.u("img",{alt:"User Avatar",className:"chat-avatar chat-avatar-right",srcSet:`${t.respondentAvatar["1x"]} 1x, ${t.respondentAvatar["2x"]} 2x`})]})},Pn=({card:n,avatars:o,isCurrentQuestion:t,currentQuestionBubbleRef:r})=>{const{endCard:i}=e.useConfig(a=>({endCard:a.endCard}));return e.u(e.g,{children:[e.u(ae,{avatars:o,isLeft:!0,message:{id:`thanks-${n.name}`,type:"question",content:(i==null?void 0:i.headline)??"Great! Thank you for your participation."},ref:t?r:null}),(i==null?void 0:i.subheader)&&e.u(ae,{avatars:o,hideAvatar:!0,isLeft:!0,message:{id:`caption-${n.name}`,type:"question",content:i.subheader}}),e.u(on,{})]})},Ln=({card:n,cardIndex:o,index:t,avatars:r,cardResponses:i,questionThinkingStates:a,startingQuestionIdx:d,currentQuestionBubbleRef:u,handleCardResponse:s})=>{const p=o===t,b=o<t,c=We(n);if(c)return e.u(Pn,{avatars:r,card:n,currentQuestionBubbleRef:u,isCurrentQuestion:p});const v=`${n.name}`,x=i.get(v),C=n.type==="open",m=a.get(v),h=o>(d??0)&&n.type!=="thanks"&&n.type!=="uploading"&&(m===!0||m===void 0);return e.u(e.wn.Fragment,{children:[e.u(Dn,{avatars:r,card:n,currentQuestionBubbleRef:u,isCurrentQuestion:p,isThinking:h}),!h&&e.u(Sn,{avatars:r,card:n}),b&&C?e.u(Rn,{avatars:r,card:n,userResponse:x}):(!b||!C)&&!h&&e.u(ae,{avatars:r,isLeft:!1,message:{id:`card-${n.name}`,type:"card",content:""},children:e.u("div",{className:"chat-card-container",children:e.u(Bn,{card:n,className:c?"chat-thanks-card":"chat-card",isAnswered:b,next:p?s:()=>{}})})})]},`question-card-${n.name}`)},ae=e.wn.forwardRef(({message:n,isLeft:o=!1,children:t,avatars:r,hideAvatar:i=!1},a)=>{const d=o?"chat-bubble-left":"chat-bubble-right";return e.u("div",{className:`chat-bubble-container ${o?"chat-left":"chat-right"}${o&&i?" chat-no-avatar":""}`,ref:a,children:[o&&!i&&e.u("img",{alt:"AI Avatar",className:"chat-avatar chat-avatar-left",srcSet:`${r.agentAvatar["1x"]} 1x, ${r.agentAvatar["2x"]} 2x`}),e.u("div",{className:`chat-bubble ${d}`,children:t||e.u("div",{className:"chat-message-text",children:n.content})}),!o&&!i&&e.u("img",{alt:"User Avatar",className:"chat-avatar chat-avatar-right",srcSet:`${r.respondentAvatar["1x"]} 1x, ${r.respondentAvatar["2x"]} 2x`})]})});ae.displayName="ChatBubble";const Mn=()=>{const n=e.useConfig(t=>t.close),o=e.F(()=>()=>n(W.APP_ID),[n]);return e.u("div",{"aria-label":"Close button",className:"conversational-close-btn",onClick:o,onKeyPress:t=>{t.key==="Enter"&&o()},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"})})})},Bn=({card:n,next:o,className:t="",isAnswered:r=!1})=>{const i={className:r?`${t} answered-card`:t,next:r?()=>{}:o,questionId:n.name,type:n.type,isAnswered:r};switch(n.type){case"consentlegal":return e.u(rn,{...i,...n.props});case"likert":return e.u(an,{...i,...n.props});case"matrix":return e.u(dn,{...i,...n.props});case"multiplechoice":return e.u(cn,{...i,...n.props});case"multipleselect":return e.u(un,{...i,...n.props});case"nps":return e.u(pn,{...i,...n.props});case"open":return e.u(vn,{...i,...n.props});case"rankorder":return e.u(mn,{...i,...n.props});case"recordedtask":return e.u(wn,{...i,...n.props});case"texturlprompt":return e.u(En,{...i,...n.props});case"thanks":return e.u(jn,{...i,...n.props});case"uploading":return e.u(_n,{...i,...n.props});case"videovoice":return e.u(In,{...i,...n.props});default:return null}};exports.default=({cards:n,next:o,previousResponses:t})=>{const{cardResponses:r,setCardResponse:i}=(()=>{const[f,y]=e.h(new Map);return{cardResponses:f,setCardResponse:e.T((L,S)=>{y(k=>new Map(k).set(L,S))},[])}})(),{index:a,isLongFormSurvey:d,avatars:u,startingQuestionIdx:s,viewDocument:p,update:b}=e.useConfig(f=>({index:f.index,isLongFormSurvey:W.isLongFormSurvey(f.studyType),avatars:f.avatars,startingQuestionIdx:f.startingQuestionIdx,viewDocument:f.viewDocument,update:f.update})),{currentQuestionBubbleRef:c,scrollToCurrentQuestion:v}=(({viewDocument:f})=>{const y=e._(null),L=e.T(()=>{const S=f.querySelector(".ul-card-main-content");if(y.current&&S&&S instanceof HTMLElement){const k=y.current.offsetTop-S.offsetTop-16;S.scrollTo({top:Math.max(0,k),behavior:"smooth"})}},[]);return{currentQuestionBubbleRef:y,scrollToCurrentQuestion:L}})({viewDocument:p}),x=((f,y,L)=>{const[S,k]=e.h(new Map);return e.p(()=>{if(f.length>0&&y<f.length){const w=f[y],I=`${w.name}`;if(y<=(L??0)||We(w))return void k(g=>new Map(g).set(I,!1));k(g=>new Map(g).set(I,!0));const l=setTimeout(()=>{k(g=>new Map(g).set(I,!1))},1e3);return()=>clearTimeout(l)}},[y,f,L]),S})(n,a,s),C=((f,y)=>{const[L,S]=e.h(new Set([0]));return e.p(()=>{S(k=>new Set(k).add(f))},[f]),e.p(()=>{const k=y??0;k>0&&S(w=>{const I=new Set(w);for(let l=0;l<=k;l++)I.add(l);return I})},[y]),L})(a,s),m=e.F(()=>({...t,...e.buildReadableResponseMap(n.map((f,y)=>{var L,S;return{...f,value:y<a?((L=r.get(`${f.name}`))==null?void 0:L.value)??null:null,secondaryValue:y<a?((S=r.get(`${f.name}`))==null?void 0:S.secondaryValue)??null:null}}))}),[t,r,n,a]),h=e.pipeReadableResponsesIntoCards(n,m);e.p(()=>{requestAnimationFrame(()=>{v()}),b()},[a,v,x,b]);const D=e.T((f,y)=>{if(!y)return;const L=h[a];if(!L)return;const S=`${L.name}`;i(S,f);const k={...f,questionText:e.getProcessedQuestionText(L)};o([k])},[h,a,o,i]),N=h.map((f,y)=>({card:f,cardIndex:y})).filter(({cardIndex:f})=>C.has(f));return e.u("div",{className:"conversational-ui ul-conversational-ui","data-testid":"ui-container",children:[!d&&e.u(Mn,{}),e.u("div",{className:"chat-container",children:e.u("div",{className:"chat-messages",children:N.map(({card:f,cardIndex:y})=>e.u(Ln,{avatars:u,card:f,cardIndex:y,cardResponses:r,currentQuestionBubbleRef:c,handleCardResponse:D,index:a,questionThinkingStates:x,startingQuestionIdx:s},`question-card-${f.name}`))})})]})};