@sprig-technologies/sprig-browser 2.33.3 → 2.34.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{core-DLrmR9wp.js → core-9nFfVPj6.js} +466 -452
- package/dist/core-B84vH8bq.cjs +12 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +72 -15
- package/dist/core.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +72 -15
- package/dist/index.js +2 -2
- package/dist/{metricsReporter-qetrFwEv.js → metricsReporter-BzXI6BiM.js} +26 -21
- package/dist/{metricsReporter-DNdFkQ0C.cjs → metricsReporter-Dy3EDEs8.cjs} +1 -1
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +369 -345
- package/dist/view-CDp4O3a5.js +2979 -0
- package/dist/view-DJLfkjCB.cjs +669 -0
- package/package.json +1 -1
- package/dist/core-nhbrlHf1.cjs +0 -12
- package/dist/view-Bd-x6oh5.cjs +0 -669
- package/dist/view-Bml35A_s.js +0 -2752
package/package.json
CHANGED
package/dist/core-nhbrlHf1.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";var pt=Object.defineProperty;var ut=(t,e,o)=>e in t?pt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var M=(t,e,o)=>ut(t,typeof e!="symbol"?e+"":e,o);const i=require("./metricsReporter-DNdFkQ0C.cjs"),Pe=()=>{try{return window.parent.Intercom}catch{return null}},He=[Object.freeze(Object.defineProperty({__proto__:null,disable:()=>{const t=Pe();t&&(t.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),t.ul_wasVisible&&t("update",{hide_default_launcher:!0}))},enable:()=>{const t=Pe();t&&(t.ul_wasVisible&&t("update",{hide_default_launcher:!1}),delete t.ul_wasVisible)}},Symbol.toStringTag,{value:"Module"}))];class We{static disable(){He.forEach(e=>e.disable())}static enable(){He.forEach(e=>e.enable())}}const Te="ul-view-sdk-script",wt=["ios","android"],C="visitors",P="environments";async function x(t,e){var n,s,d;const{shouldDropOnRateLimit:o,...a}=e;a.headers=Object.assign(i.getHttpHeaders(window.UserLeap),a.headers);const r=await i.sprigFetch(t,{...a,shouldDropOnRateLimit:o});if(r.ok){const c=(n=r.headers)==null?void 0:n.get("Authorization"),u=c?c.split(" "):void 0,l=u&&u.length===2?u[1]:void 0,p=(s=r.headers)==null?void 0:s.get("x-ul-visitor-id");if(window.UserLeap.userId&&p===window.UserLeap.visitorId){const g=i.localStorageHelper.getItemObject("sprig.anon.env.vid.map");g&&g[window.UserLeap.envId]===p&&(delete g[window.UserLeap.envId],i.localStorageHelper.setItemObject("sprig.anon.env.vid.map",g))}l&&p&&(p!==window.UserLeap.visitorId||window.UserLeap.token!==l)&&(k("token",l),k("vid",p),i.eventEmitter.emit(i.SprigEvent.VisitorIDUpdated,{visitorId:p}),window.UserLeap.token=l,window.UserLeap.visitorId=p)}return(d=r.json)!=null&&d.logMessage&&console.warn(`[Sprig] ${r.json.logMessage}`),r}function k(t,e){const o=i.localStorageHelper.getItemObject("userleap.ids");let a=o[window.UserLeap.envId];a?a[t]=e:a={[t]:e},o[window.UserLeap.envId]=a,i.localStorageHelper.setItemObject("userleap.ids",o)}function Le(){return window.previewMode?"0":window.UserLeap.visitorId??""}function R(t,e,o){const a=[window.UserLeap._API_URL,"sdk",t];return e&&e.forEach(r=>{a.push(r),r===P?a.push(window.UserLeap.envId):r===C&&a.push(Le())}),o&&a.push(o),a.join("/")}const z=async(t,e,o)=>{var xe,Ae,Oe;const{context:a,delay:r,forceBrandedLogo:n,endCard:s,isFeedback:d=!1,heatmap:c,locale:u,previewMode:l,productConfig:p,questions:g,responseGroupUid:y,surveyId:w,uuid:E,vid:I,sessionReplay:m,studyType:b}=t,h=i.getHttpHeaders(window.UserLeap),L=J(h),O=ae(h);if(m)if(L)i.eventEmitter.emit(i.SprigEvent.ReplayCapture,{responseGroupUid:y,hasQuestions:!!(g!=null&&g.length),surveyId:w,uploadId:m.uploadId,replayType:m.replayDurationType??"before",seconds:m.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:i.v4(),mediaType:"screen",questionId:1,responseGroupUid:y,surveyId:w,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}});else{if(!i.modules.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};i.modules.replay.scheduleOrCaptureReplay({responseGroupId:y,surveyId:w,visitorId:I,replayParams:m,completeUploadHeaders:h,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:g.length===0})}if(c){if(!i.modules.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};const{eventId:S,replayParams:N,responseGroupUid:ce,surveyId:pe}=c;await i.modules.replay.initializeReplay({maxReplayDurationSeconds:300,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0,apiUrl:window.UserLeap._API_URL,replaySettings:o}),i.modules.replay.tryReplayAction(()=>{var Ce;return(Ce=i.modules.replay)==null?void 0:Ce.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:h,eventId:S,isHeatmap:!0,replayParams:N,responseGroupId:ce,surveyId:pe,triggerTimestamp:Date.now(),visitorId:I})},"Error in scheduling/capturing replay")}if(I==null||!(g!=null&&g.length))return i.breadcrumbsLogger.info("CannotDisplaySurvey",{vid:I}),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(window.UserLeap.container){i.breadcrumbsLogger.info("AlreadyDisplayingSurvey");const S="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(S),{success:!1,message:S,surveyState:"no survey"}}if(I!==window.UserLeap.visitorId&&E!==window.UserLeap.visitorId&&!window.previewMode){const S="Attempted to display survey to a different visitor";return window.UserLeap.reportError("DisplaySurvey",new Error(S)),{success:!1,message:S,surveyState:"no survey"}}i.breadcrumbsLogger.info("ShowingSurvey",{surveyId:w}),(xe=i.modules.replay)==null||xe.RecordSurveyShown({id:w,userAgent:window.navigator.userAgent}),We.disable(),i.eventEmitter.emit(i.SprigEvent.SurveyWillPresent,{name:i.SprigEvent.SurveyWillPresent,"survey.id":w});let v,_,U,H,T=document.createElement("div");const ke=S=>{const{"view.version":N}=S;N!==h["x-ul-sdk-version"]&&$e(),i.eventEmitter.removeListener("verify.view.version",ke)};i.eventEmitter.on("verify.view.version",ke),window.UserLeap.useMobileStyling=O,i.shouldDirectEmbed(h)?(v="ul-direct-embeded-frame",_=document.head,U=window,H=!1,(()=>{const S=i.getHttpHeaders(window.UserLeap),N=J(S),ce=window.UserLeap.forceDirectEmbed,pe=S["userleap-platform"]==="web";return N||ce&&pe})()&&(ze(w,d),T.id=v,window.UserLeap.container.appendChild(T),Ge(),i.eventEmitter.emit(i.SprigEvent.SurveyLifeCycle,{state:"presented"}),i.eventEmitter.emit(i.SprigEvent.SurveyPresented,{name:i.SprigEvent.SurveyPresented,"survey.id":w}))):{frameId:v,contentWinDocHead:_,contentWindow:U,hasOverlay:H,iframe:T}=mt({productConfig:p,useMobileStyling:O,surveyId:w,isFeedback:d}),window.UserLeap.frameId=v;const F={apiURL:window.UserLeap._API_URL,cards:g,configureExitOnOverlayClick:S=>{i.eventEmitter.once(i.SprigEvent.CloseSurveyOnOverlayClick,S)},context:a,endCard:s,envId:window.UserLeap.envId,eventEmitFn:i.eventEmitter.emit.bind(i.eventEmitter),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:n,frame:T,headers:h,locale:u,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:i.localStorageHelper.getItem("sprig.previewKey"),previewMode:l,productConfig:{framePosition:p==null?void 0:p.framePosition,desktopDisplay:p==null?void 0:p.desktopDisplay,placement:p==null?void 0:p.placement},responseGroupUid:y,startingQuestionIdx:(Ae=window.UserLeap.config)==null?void 0:Ae.startingQuestionIdx,studyType:b,styleNonce:window.UserLeap.styleNonce,surveyId:w,tabTitle:document.title,trackPageViewUrl:e,ulEvents:i.EVENTS,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:O,userId:E,viewDocument:U==null?void 0:U.document,viewWindow:U,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},...window.UserLeap._config};(Oe=window.UserLeap._config)!=null&&Oe.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null});const ct=(d?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??p.customStyles;F.customStyles=ct,U&&(U.__cfg=F);const de=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:F.path,_e=document.getElementById(Te);_e&&_e.remove();const le=function(){const S=document.createElement("script");return window.UserLeap.nonce&&S.setAttribute("nonce",window.UserLeap.nonce),S.id=Te,S}(),Re=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(F.installationMethod==="web-npm"||F.installationMethod==="web-npm-bundled"){const{default:S}=await Promise.resolve().then(()=>require("./view-Bd-x6oh5.cjs"));S.configure(F),H&&window.UserLeap.container&&Re()}else de&&(le.src=de,H&&le.addEventListener("load",()=>{window.UserLeap.container&&Re()}),U==null||U.addEventListener("error",S=>{S.target instanceof HTMLScriptElement&&S.target.src===de&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));_==null||_.appendChild(le);const De={success:!0,surveyState:"ready",surveyId:w,responseGroupUid:y};return window.UserLeap.isMobileSDK&&r&&(De.delay=r),De};function ae(t){var o;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const e=((o=window.UserLeap.windowDimensions)==null?void 0:o.width)??document.body.clientWidth;return J(t)||e>10&&e<500}function J(t){return wt.includes(t["userleap-platform"])}const Ue="ul-frame";window.UserLeap&&window.Sprig&&(window.Sprig._gtm?window.Sprig=window.UserLeap:window.UserLeap=window.Sprig),window.UserLeap||(window.UserLeap=window.Sprig),window.Sprig||(window.Sprig=window.UserLeap);const ue="0px",ze=(t,e,o)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className="ul-container"+(e?" ul-container-feedback":""),t&&(window.UserLeap.container.dataset.studyId=t.toString());const a=Qe();o&&a&&!window.UserLeap.useMobileStyling?a.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},$e=(t,e)=>{var a;vt();const o=window.UserLeap.container;if(o)try{(a=o.parentNode)==null||a.removeChild(o),window.UserLeap.container=null,k("trackStartUrl",null),i.eventEmitter.emit(i.SprigEvent.SurveyLifeCycle,{state:"dismissed"}),i.eventEmitter.emit(i.SprigEvent.SurveyClosed,{name:i.SprigEvent.SurveyClosed,initiator:t,"survey.id":parseInt(o.dataset.studyId),...e&&{studyType:e}})}catch(r){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${t} `+o),r instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",r)}},Ge=()=>{i.eventEmitter.once(i.SprigEvent.SurveyWillClose,({initiator:t,studyType:e})=>{i.eventEmitter.removeAllListeners(i.SprigEvent.CloseSurveyOnOverlayClick),$e(t,e)})},gt=(t,e,o,a)=>{var l,p;const r={position:"fixed",bottom:"0px",right:ue,border:0,backgroundColor:"rgba(0,0,0,0)",zIndex:2147483646,transition:"height 0.2s ease-in-out",maxWidth:"100%"},n=Object.assign({},e,window.UserLeap),{desktopDisplay:s}=e||{},d=s==="center-modal";let c;d&&(n.framePosition="center");let u=!1;if(o)(l=window.UserLeap.windowDimensions)!=null&&l.width?r.width=`${window.UserLeap.windowDimensions.width}px`:r.width="100%",(p=window.UserLeap.windowDimensions)!=null&&p.height?r.maxHeight=window.UserLeap.windowDimensions.height-20+"px":window.UserLeap.maxHeight?r.maxHeight=window.UserLeap.maxHeight:r.maxHeight=document.body.clientHeight-20+"px",["light","dark"].includes(n.overlayStyleMobile)&&(u=!0);else{r.width="360px",r.maxHeight=window.UserLeap.maxHeight||"66vh";const g=()=>{u=!0,c={margin:"auto",position:"static"}};if(a)d?g():c={position:"relative",height:"300px"};else switch(n.framePosition){case"bottomLeft":c={left:ue};break;case"topLeft":c={left:ue,top:0};break;case"topRight":c={top:0};break;case"center":g()}}return u&&((g,y)=>{const w={position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646},E=y?g.overlayStyleMobile:g.overlayStyle;w["background-color"]=E==="light"?"rgba(255,255,255, 0.95)":"rgba(0,0,0,0.9)",y||(w.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,w)})(n,o),Object.assign(t.style,r,c),u},mt=({productConfig:t,useMobileStyling:e,surveyId:o,isFeedback:a})=>{var g,y;const r=Ue,n=a&&t.desktopDisplay==="slider";ze(o,a,n),yt();const s=document.createElement("iframe");s.id=r,s.setAttribute("title","Sprig User Feedback Dialog");const d=gt(s,t,e,a);Ge();let c=!1;s.setHeight=w=>{parseInt(s.style.height)==w&&c||(c=!0,s.style.height=`${w}px`,i.eventEmitter.emit(i.SprigEvent.SurveyHeight,{name:i.SprigEvent.SurveyHeight,contentFrameHeight:w,"survey.id":o}))};let u=!1;s.setWidth=w=>{parseInt(s.style.width)==w&&u||(u=!0,s.style.width=`${w}px`,i.eventEmitter.emit(i.SprigEvent.SurveyWidth,{name:i.SprigEvent.SurveyWidth,contentFrameWidth:w,"survey.id":o}))},(g=window.UserLeap.container)==null||g.appendChild(s),t&&(e?t.exitOnOverlayClickMobile:t.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{i.eventEmitter.emit(i.SprigEvent.CloseSurveyOnOverlayClick)}),i.eventEmitter.emit(i.SprigEvent.SurveyLifeCycle,{state:"presented"}),i.eventEmitter.emit(i.SprigEvent.SurveyPresented,{name:i.SprigEvent.SurveyPresented,"survey.id":o});const l=(y=s.contentWindow)==null?void 0:y.document;if(l&&(l.open("text/html","replace"),l.write("<!doctype html><head></head><body></body></html>"),l.close(),!e)){const w=l.body;w.style.display="flex",w.style.alignItems="center"}const p=l==null?void 0:l.head;return{frameId:r,contentWinDocHead:p,contentWindow:s.contentWindow,hasOverlay:d,iframe:s}},Ke={[i.SprigEvent.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},yt=()=>{Object.entries(Ke).forEach(([t,e])=>{i.eventEmitter.on(t,e)})},vt=()=>{Object.entries(Ke).forEach(([t,e])=>{i.eventEmitter.off(t,e)})},D=t=>!!t&&t.nodeType===Node.ELEMENT_NODE,Me=t=>t instanceof HTMLElement||t instanceof SVGElement,Q=({document:t,elementId:e,styleString:o,nonce:a})=>{const r=t.getElementById(e);if(r)return void(r.textContent=o);const n=t.createElement("style");a&&(n.nonce=a),n.textContent=o,n.id=e,t.head.appendChild(n)},ft=(t,e)=>{const o=e.querySelector(".sprig-question-body");if(!D(o))return t;const a=o.scrollHeight;return a<100?t:t-(a-100)},qe=(t,e)=>{const o=e.querySelector(t);if(!D(o))return 0;const a=getComputedStyle(o);return parseFloat(a.paddingLeft)+parseFloat(a.paddingRight)+(parseFloat(a.marginLeft)+parseFloat(a.marginRight))+(parseFloat(a.borderLeftWidth)+parseFloat(a.borderRightWidth))},Je=(t,e,o)=>{const a=t.querySelector(".ul-card__container"),r=t.querySelector(".ul-app");let n=600,s=360,d=0;if(D(a)&&D(r)){const c=a.querySelector(".ul-card--matrix_grid"),u=!c&&e&&o;try{u&&(r.style.width="360px"),n=a.clientHeight,n+=(g=>{const y=g.querySelector(".sprig-question-body"),w=g.querySelector(".ul-card"),E=g.querySelector(".ul-card-main-content"),I=g.querySelector(".ul-footer"),m=g.querySelector(".sprig-container");let b=0;return D(w)&&(b+=w.scrollHeight-w.clientHeight),D(E)&&(b+=E.scrollHeight-E.clientHeight),D(y)&&(b+=y.scrollHeight-y.clientHeight),D(I)&&D(m)&&m.clientHeight===0&&(b+=I.clientHeight),b})(t);const l=getComputedStyle(a);d=n;const p=parseFloat(l.marginTop)+parseFloat(l.marginBottom);n+=p+(parseFloat(l.borderTopWidth)+parseFloat(l.borderBottomWidth)),c&&(s=c.scrollWidth,s+=qe(".ul-card__container",t),s+=qe(".sprig-question-body",t))}finally{u&&r.style.removeProperty("width")}}return[n+1,s,ft(d,t)]},Qe=()=>f,V=()=>document.getElementById("sprig-feedback-container"),ye=()=>document.getElementById("sprig-feedback-loading-animation"),Ye=()=>!!document.getElementById(Ue);let je=!1,f=null,A=null,Ee=!1,$=null,q=null;const ht=["bottom-left","bottom-right","center-left","center-right"],Z=()=>{var e;const t=window.UserLeap.container;return((e=t==null?void 0:t.parentElement)==null?void 0:e.id)==="sprig-feedback-loading-container"},Xe=()=>document.getElementById("sprig-feedback-error-container"),Ze=()=>{if(!f)return 0;const t=f==null?void 0:f.clientWidth,e=window.getComputedStyle(f);return t+parseInt(e.borderRightWidth||"0")+parseInt(e.borderLeftWidth||"0")},ee=t=>{const e=V();e&&(q!=null&&q.endsWith("right")?e.style.right=`${t}px`:q!=null&&q.endsWith("left")&&(e.style.left=`${t}px`))},we=()=>{if(f&&(Z()||Xe())){i.eventEmitter.off(i.SprigEvent.SurveyAppeared,W),ve();const t=Ze();return ee(-t),!0}return!1},W=()=>{if(!f||!A)return;const t=ye();t&&t.remove(),f.style.height="auto",f.style.width="auto",A.disabled=!1,Ee=!1},ve=()=>{if(f&&!ye()){const t=(()=>{if(ye())return;const e=document.createElement("div");return e.className="ul-loading-spinner-container",e.id="sprig-feedback-loading-animation",e.role="progressbar",e.setAttribute("aria-live","polite"),e.setAttribute("aria-busy","true"),e.setAttribute("aria-label","Processing..."),e.innerHTML=`
|
|
2
|
-
<div class="ul-loading-spinner">
|
|
3
|
-
<div class="first"></div>
|
|
4
|
-
<div class="second"></div>
|
|
5
|
-
<div class="third"></div>
|
|
6
|
-
<div class="fourth"></div>
|
|
7
|
-
</div>
|
|
8
|
-
`,e})();t&&(f.style.height="300px",f.style.width="360px",f.appendChild(t))}},Fe=()=>{f&&A&&(ee(0),A.disabled=!0,Ee=!0)},et=async(t,e,o)=>{const{buttonTheme:a,customStyles:r,eventId:n,placement:s,desktopDisplay:d,feedbackLabel:c,surveyUuid:u,surveyId:l}=t;window.UserLeap.feedbackCustomStyles=void 0;let p=V();if(p){if(!e&&n===$)return;p.remove(),i.eventEmitter.off(i.EVENTS.SURVEY_FADING_OUT,we)}$=n,Q({document,elementId:"sprig-feedback-style",styleString:'.ul-loading-spinner-container{font-size:1.8rem;flex-grow:1;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.ul-loading-spinner{display:inline-block;position:relative;width:6rem;height:6rem}.ul-loading-spinner div{box-sizing:border-box;display:block;position:absolute;width:80%;height:80%;margin:5px;border:5px solid #152e3e;border-radius:50%;animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#152e3e transparent transparent transparent}.ul-loading-spinner .first{animation-delay:-.45s}.ul-loading-spinner .second{animation-delay:-.3s}.ul-loading-spinner .third{animation-delay:-.15s}@keyframes lds-ring{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.fade-in-transition{animation:fadeIn .4s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}#sprig-feedback-button{border-left:0;border-radius:0 8px 8px 0;display:grid;padding:8px;text-align:center;transition:all ease-in-out 1s;z-index:inherit}#sprig-feedback-button:hover{cursor:pointer}.sprig-feedback-button-label{writing-mode:vertical-lr;text-orientation:sideways}.sprig-feedback-button-right{transform:rotate(180deg)}.sprig-feedback-button-bottom{align-self:flex-end;margin-bottom:20px}.sprig-feedback-button-light{background:#efefee;color:#000;border:1px solid #e2e3e1}.sprig-feedback-button-dark{background:#000;color:#fff;border:1px solid #000000}#sprig-feedback-container{display:flex;align-items:center;position:fixed;transition:right .2s linear,left .2s linear;z-index:2147483646}.sprig-feedback-container-left{flex-flow:row-reverse}.sprig-feedback-container-center{top:50%;transform:translateY(-50%)}.sprig-feedback-container-bottom{bottom:0%;margin-bottom:15px}.sprig-feedback-loading-container{align-items:center;background-color:#fff;border:2px solid var(--feedback-border);display:flex;max-height:90vh;max-width:90vw;min-width:0px}.sprig-feedback-loading-container-left{border-left:none;border-radius:0 8px 8px 0}.sprig-feedback-loading-container-right{border-right:none;border-radius:8px 0 0 8px}#sprig-feedback-error-container{margin:auto;text-align:center;width:360px}.sprig-feedback-error-text{font-weight:400;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol}#sprig-feedback-loading-container .ul-container{position:relative;max-height:inherit}#sprig-feedback-loading-animation{position:absolute}.sprig-feedback-loading-container-previews iframe{max-height:inherit!important}',nonce:window.UserLeap.styleNonce}),Q({document,elementId:"ul-custom-style",styleString:r??"",nonce:window.UserLeap.styleNonce}),je=d==="center-modal",q=s;const[g,y]=s.split("-");(m=>{if(V()||!ht.includes(m))return;const[b,h]=m.split("-"),L=document.createElement("div");L.id="sprig-feedback-container",L.classList.add(`sprig-feedback-container-${h}`,`sprig-feedback-container-${b}`),document.body.appendChild(L)})(s),p=V(),A=document.createElement("button");const w=document.createElement("div");w.className="sprig-feedback-button-label",w.innerText=c,A.appendChild(w),A.id="sprig-feedback-button",A.classList.add(`sprig-feedback-button-${y}`,`sprig-feedback-button-${g}`,`sprig-feedback-button-${a}`,"fade-in-transition"),i.eventEmitter.on(i.EVENTS.SURVEY_FADING_OUT,we),A.addEventListener("click",async()=>{const m=document.getElementById("sprig-feedback-error-container");if(Ye()||Xe()){if(we()){i.eventEmitter.emit(i.SprigEvent.SurveyCloseRequested,{name:i.SprigEvent.SurveyCloseRequested,initiator:i.DismissReason.FeedbackClosed,studyType:"feedbackButton","survey.id":l}),i.eventEmitter.emit(i.SprigEvent.SurveyWillClose,{name:i.SprigEvent.SurveyWillClose,initiator:i.DismissReason.FeedbackClosed,studyType:"feedbackButton","survey.id":l});const h=V();m&&h&&(h.remove(),$=null,f=null)}return}if(ae(i.getHttpHeaders(window.UserLeap))||Ee||Fe(),e)return f&&f.classList.add("sprig-feedback-loading-container-previews"),await z(e),void W();const b=await(async h=>{const L=await x(R("1",[C],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:h}),method:"POST"});return L.ok?L.json:null})(u);if(b)i.eventEmitter.once(i.SprigEvent.SurveyAppeared,W),z({...b,studyType:"feedbackButton"},o);else if(f){const h=St();f.appendChild(h),W(),f.style.height="300px",f.style.width="360px"}}),p==null||p.appendChild(A),i.eventEmitter.emit(i.SprigEvent.FeedbackButtonLoaded,{name:i.SprigEvent.FeedbackButtonLoaded,"survey.id":l});const{useMobileStyling:E,_config:{border:I}}=window.UserLeap;if(je||E)ee(0);else{const m=document.createElement("div");m.id="sprig-feedback-loading-container",m.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${y}`,m.style.setProperty("--feedback-border",I),f=m,ve(),p==null||p.appendChild(m);const b=Ze();ee(-b)}window.UserLeap._config.isOnQuestionsTab&&e&&!Z()&&f&&(Fe(),ve(),f&&f.classList.add("sprig-feedback-loading-container-previews"),z(e),W())},St=()=>{const t=document.createElement("div");t.id="sprig-feedback-error-container",t.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none">
|
|
9
|
-
<circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
|
|
10
|
-
<path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
|
|
11
|
-
<circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
|
|
12
|
-
</svg>`;const e=document.createElement("h3");return e.className="sprig-feedback-error-text",e.innerText="There was an error while loading the survey",t.appendChild(e),t},fe=new class{constructor(){M(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(t){try{return!(!t||typeof t!="object"||Array.isArray(t))&&(Object.keys(this._ldData).forEach(e=>{delete this._ldData[e]}),Object.keys(t).forEach(e=>this._ldData[`!launch_darkly_${e}`]=(t[e]??0)+1),!0)}catch(e){return e instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",e),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}};Object.freeze(fe);const X=new class{constructor(){M(this,"_optimizelyData",{})}setOptimizelyExperiment(t,e=!0){if(!t||typeof t!="object")return!1;const{experiments:o}=t;try{return e&&Object.keys(this._optimizelyData).map(a=>{delete this._optimizelyData[a]}),o&&o.map(a=>{const{id:r,variation:n}=a,s=this.transformExperimentId(r);n&&typeof n=="string"&&(this._optimizelyData[s]=n)}),!0}catch(a){return a instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",a),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(t){return this._optimizelyData[this.transformExperimentId(t)]}transformExperimentId(t){return"!optimizely_experiments_"+t}getAndSetWebOptimizelyExperiments(){var t;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const e=(t=window.optimizely.get("state"))==null?void 0:t.getExperimentStates({isActive:!0});if(e){const o=Object.keys(e).map(a=>{var r,n;return(r=e[a].variation)!=null&&r.name?{id:a,variation:(n=e[a].variation)==null?void 0:n.name}:{id:a,variation:"Original"}});return this.setOptimizelyExperiment({experiments:o},!1),!0}return!1}return!1}catch(e){return e instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",e),!1}}};Object.freeze(X);class bt{constructor(e,o){M(this,"paused");M(this,"queue");M(this,"ul");this.ul=e,this.paused=!1,this.queue=[],this.flush(o)}flush(e){const o=e.length;if(o)for(let a=0;a<o;a++)this.push(e[a])}isPaused(){return this.paused}pause(){this.paused=!0}unpause(){this.paused=!1;const e=this.queue.slice();this.empty(),this.flush(e)}push(e){if(this.paused)this.queue.push(e);else if(e instanceof Function)e();else{const o=Array.prototype.slice.call(e,1),a=e[0],r=this.ul[a];r instanceof Function?r.apply(this.ul,o):a&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",a)}}perform(e){if(this.paused){let o=()=>{};const a=new Promise(function(r){o=function(){r(e())}});return this.queue.push(o),a}return e()}empty(){this.queue.length=0}}let tt,rt;const he=t=>{let e=0,o=t.firstElementChild;for(;o;)e+=he(o),o.shadowRoot&&(e+=he(o.shadowRoot)),o=o.nextElementSibling,e++;return e},Ve=()=>{tt.report(he(document.body)),rt.report(document.documentElement.innerHTML.length)},Se=(t,e)=>{const o=performance.now();document.hidden?setTimeout(()=>Se(t,e),t):setTimeout(()=>{const a=performance.now()-o;e.report(a/1e3),setTimeout(()=>Se(t,e),t)},0)};let te,re,ie,ne,Ne,j={};const Y=(t,e=1)=>{const{name:o}=t;j[o]=(j[o]||0)+e},it=t=>{let e=1;return t.childNodes.forEach(o=>{e+=it(o)}),e},Be=t=>{let e=0;return t.forEach(o=>{e+=it(o)}),e},Lt=t=>{switch(t.type){case"childList":return Y(te,Be(t.addedNodes)),void Y(re,Be(t.removedNodes));case"attributes":return void Y(ie);case"characterData":return void Y(ne)}},Ut=t=>t.forEach(Lt),Et=()=>{te.report(j[te.name]||0),re.report(j[re.name]||0),ie.report(j[ie.name]||0),ne.report(j[ne.name]||0),j={}},It=(t=1e3)=>{te=i.registerMetric("sdk_mutations_nodes_added"),re=i.registerMetric("sdk_mutations_nodes_removed"),ie=i.registerMetric("sdk_mutations_attributes_changed"),ne=i.registerMetric("sdk_mutations_character_data"),Ne=new MutationObserver(Ut),Ne.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),setInterval(Et,t)},kt=({isWeb:t,reportingIntervalSeconds:e,thresholds:o,postMetrics:a})=>{i.registerThresholds(o,(r,n)=>{var s,d;if((s=i.modules.replay)!=null&&s.isReplayRecording()){const c=`Value: ${r} on ${n.metric} violated threshold of ${n.type} ${n.value}`;(d=i.modules.replay)==null||d.disableRecording("Threshold violated",new Error(c),{reportError:!1}),window.UserLeap.reportError("Sdk Performance Metric threshold violated",new Error("Sdk Performance Metric threshold violated"),{metricName:n.metric,type:n.type,value:n.value},{metricName:n.metric}),i.disableThresholdChecking()}}),i.initPerformanceReporting({reportingIntervalSeconds:e,postMetrics:a}),t&&(((r=1e3)=>{const n=i.registerMetric("sdk_event_queue_latency_seconds");Se(r,n)})(),((r=1e4)=>{tt=i.registerMetric("sdk_dom_nodes_count"),rt=i.registerMetric("sdk_page_html_characters"),Ve(),setInterval(Ve,r)})(),It())},_t="test",Rt=["popState","pushState","replaceState"];let Ie,G;const oe={},B="!email",nt="pageUrl";let ge=window.location.href;function K(t){var d,c;const{pageUrlEvents:e,interactiveEvents:o,dismissOnPageChange:a,platform:r}=window.UserLeap._config;if(r&&r!=="web")return;ge!==window.location.href&&i.breadcrumbsLogger.navigation("LocationChange",{from:ge,to:window.location.href}),ge=window.location.href;const n=at().trackStartUrl,s=n?String(n):null;e&<(window.location.href),o&&(st(),Dt()),Qe()&&(()=>{if(Z())return;const u=V();u&&(i.checkUrlStillMatching($)||(u.remove(),$=null,f=null))})(),i.sessionStorageHelper.getItem("sprig.isCapturingHeatmap")&&((c=(d=i.modules.replay)==null?void 0:d.checkPendingHeatmapsUrl())==null||c.then(u=>{var l;u&&((l=i.modules.replay)==null||l.uploadReadyPendingCaptures(!0))})),!Z()&&a&&s&&s!==window.location.href&&t&&Rt.includes(t.type)&&window.UserLeap("dismissActiveSurvey",i.DismissReason.PageChange)}const ot={capture:!0},Dt=()=>{const t=window.UserLeap._config.interactiveEvents.filter(o=>i.checkUrlMatch(o,window.location.href)).map(o=>{const{name:a,properties:r}=o,{selector:n,innerText:s}=r;return n?d=>{if(Me(d.target))try{d.target.closest(n)&&window.UserLeap("track",a)}catch{}return!1}:d=>(Me(d.target)&&d.target.innerText===s&&window.UserLeap("track",a),!1)}),e=o=>t.forEach(a=>a(o));window.UserLeap._config.interactiveEventsHandler=e,window.addEventListener("click",e,ot)},st=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,ot),delete window.UserLeap._config.interactiveEventsHandler};function at(){const t=i.localStorageHelper.getItemObject("userleap.ids");return t&&t[window.UserLeap.envId]||{}}function dt(){if(window.previewMode)return;const t=i.localStorageHelper.getItemObject("sprig.anon.env.vid.map")||{},e=t[window.UserLeap.envId];window.UserLeap.visitorId=e||i.v4(),i.breadcrumbsLogger.info("NewVid",{vid:window.UserLeap.visitorId}),k("vid",window.UserLeap.visitorId),e||(t[window.UserLeap.envId]=window.UserLeap.visitorId,i.localStorageHelper.setItemObject("sprig.anon.env.vid.map",t)),i.eventEmitter.emit(i.SprigEvent.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}function lt(t,e,o,a){var r,n;try{if(t.endsWith("mock_snippet.html"))return;i.breadcrumbsLogger.info("PageView",{url:t});const s=(r=document==null?void 0:document.querySelector('meta[name="description"]'))==null?void 0:r.getAttribute("content");(n=i.modules.replay)==null||n.RecordPageView({...s&&{description:s},url:t,referrer:document.referrer,pageTitle:document.title});const d=window.UserLeap._config.pageUrlEvents;let c=!1;if(d&&d.length)for(let l=0;l<d.length&&(c=i.checkUrlMatch(d[l],t),!c);l++);if(!c)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",t);const u={url:t};a&&(u.trackPageView=!0),window.UserLeap._queue.push(["track",nt,e,u,o])}catch(s){s instanceof Error&&(s.stack=t,window.UserLeap.reportError("trackPageView",s)),console.warn("[Sprig] (ERR-428) Failed to track page view",s)}}function xt(){const t="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in t&&(t.pushState=(e=>function(...o){const a=e.apply(this,o),r=new Event("pushState");return window.dispatchEvent(r),K(r),a})(t.pushState)),"replaceState"in t&&(t.replaceState=(e=>function(...o){const a=e.apply(this,o),r=new Event("replaceState");return window.dispatchEvent(r),K(r),a})(t.replaceState)),["hashchange","popstate"].forEach(e=>window.addEventListener(e,K,!0))}async function me(t,e){const o=Le();t&&!e&&(window.UserLeap._config.mode=_t);const a=ae(i.getHttpHeaders(window.UserLeap)),r=await x(function(n){const s=new URL(R("1",[P],"questions"));return Object.entries(n||{}).forEach(([d,c])=>{c&&s.searchParams.append(d,String(c))}),s.toString()}({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:a,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:t==null?void 0:t.surveyId,surveytemplateid:t==null?void 0:t.surveyTemplateId,vid:o}),{shouldDropOnRateLimit:!0});if(!r.ok)return r.reportError&&r.error&&(console.warn("[Sprig] (ERR-414) Failed to request questions from the server",r.error),window.UserLeap.reportError("getQuestions",r.error)),{success:!1,surveyState:"no survey"};if(r.json.delay&&await i.delay(r.json.delay),!r.json.isFeedback)return z(r.json,G,Ie);{const{feedbackLabel:n,productConfig:s,surveyUuid:d,feedbackCustomStyles:c}=r.json,{buttonTheme:u,placement:l,desktopDisplay:p}=s;et({customStyles:c,buttonTheme:u,desktopDisplay:p,eventId:0,feedbackLabel:n,placement:l,surveyUuid:d,surveyId:t==null?void 0:t.surveyId},r.json)}}function At(t){if(!t)return;window.UserLeap._config=t,t.mute&&window.UserLeap._queue.pause();const{interactiveEvents:e,pageUrlEvents:o,dismissOnPageChange:a}=t;e&&function(r){let n=r.length;for(;n;){const s=Math.floor(Math.random()*n);n-=1;const d=r[n];r[n]=r[s],r[s]=d}}(e),(e||o||a)&&(xt(),K())}const Ot=function(t){if(!window.UserLeap)return;const e=async(r={})=>{var m,b,h,L,O;const{userId:n,anonymousId:s,metadata:d={},properties:c,showSurveyCallback:u}=r;let{eventName:l}=r;if(window.UserLeap.debugMode&&l!==nt&&console.info("[DEBUG] Sprig track",r),t.mode==="test")return;const p=i.localStorageHelper.getItem("sprig.previewKey")??void 0;if(t.requireUserIdForTracking&&!window.UserLeap.userId&&!n){const v="[Sprig] - Skipping tracking without userId";return console.warn(v),{success:!1,message:v,surveyState:"no survey"}}if(!l||l.trim().length===0){l=l?String(l):"";const v="[Sprig] - Invalid event name "+l;return console.warn(v),{success:!1,message:v,surveyState:"no survey"}}const g=G??window.location.href;d.url||(d.url=g),k("trackStartUrl",g),(b=(m=window.UserLeap)==null?void 0:m._config)!=null&&b.optimizelyEnabled&&(J(i.getHttpHeaders(window.UserLeap))||X.getAndSetWebOptimizelyExperiments(),d.optimizelyExperiments=Object.assign({},X.getAllOptimizelyExperiments())),(L=(h=window.UserLeap)==null?void 0:h._config)!=null&&L.launchDarklyEnabled&&(d.launchDarklyFlags=fe.getAllLaunchDarklyVariations()),n&&(window.UserLeap.userId=n),s&&(window.UserLeap.partnerAnonymousId=s),c&&(d.eventProperties=c),(O=i.modules.replay)==null||O.RecordEvent({name:l,url:d.url}),i.breadcrumbsLogger.info("TrackEvent",{eventName:l});const y=window.UserLeap.delayingSurvey||Ye()?await x(R("1",[C],"events/batch"),{body:JSON.stringify({events:[{event:l,metadata:d}],previewKey:p}),method:"POST",shouldDropOnRateLimit:!0}):await x(R("1",[C],"events"),{body:JSON.stringify({event:l,metadata:d,previewKey:p}),method:"POST",shouldDropOnRateLimit:!0});if(!y.ok){const v="[Sprig] (ERR-421) Failed to track event";return y.reportError&&(console.warn(v,y.error),y.error&&window.UserLeap.reportError("track",y.error)),{success:!1,message:v,error:y.error,surveyState:"no survey"}}n&&k("uid",n),s&&k("aid",s);const w=y.json;w.invalidPreviewKey&&i.localStorageHelper.removeItem("sprig.previewKey");const E=d.trackPageView?d.url:void 0;return w!=null&&w.feedbackButton&&et(w.feedbackButton,void 0,E),await async function(v,_){var H,T;let U=!0;return!(_&&((H=v==null?void 0:v.json)!=null&&H.surveyId)&&(window.UserLeap.delayingSurvey=!0,U=await _(v.json.surveyId),window.UserLeap.delayingSurvey=!1,!U))&&((T=v==null?void 0:v.json)!=null&&T.delay&&!window.UserLeap.isMobileSDK&&(window.UserLeap.delayingSurvey=!0,await i.delay(v.json.delay),window.UserLeap.delayingSurvey=!1),U)}(y,u)?function(v){if(!window.UserLeap._config.dismissOnPageChange)return!0;const _=new URL(v),U=new URL(G??window.location.href);return _.hostname===U.hostname&&_.pathname===U.pathname}(g)?z(w,E,Ie):{success:!1,message:"Study should not be displayed after page navigation",surveyState:"no survey"}:{success:!1,message:"[Sprig] Callback returned false, aborting rendering of survey",surveyState:"no survey"}},o=(r,n)=>{var d;const s=(d=r==null?void 0:r.querySelector(`[id="${Ue}"]`))==null?void 0:d.contentDocument;s&&Q({document:s,elementId:"ul-custom-style",styleString:n})},a={displaySurvey:async r=>(console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),window.UserLeap("dismissActiveSurvey",i.DismissReason.Override),me({surveyId:r},!0)),_previewSurvey(r){window.UserLeap("dismissActiveSurvey",i.DismissReason.Override),me({surveyTemplateId:r},!1)},_reviewSurvey(r){window.UserLeap("dismissActiveSurvey",i.DismissReason.Override),me({surveyId:r},!1)},previewSurvey(r){a._previewSurvey(r)},reviewSurvey(r){a._reviewSurvey(r)},mute(){window.UserLeap._queue.pause()},unmute(){window.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(r=i.DismissReason.API){window.UserLeap.container&&(r===i.DismissReason.Closed&&window.Sprig.trackHistory&&window.Sprig.trackHistory({event:"closed"}),i.eventEmitter.emit(i.SprigEvent.SurveyCloseRequested,{name:i.SprigEvent.SurveyCloseRequested,initiator:r,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}),i.eventEmitter.emit(i.SprigEvent.SurveyWillClose,{name:i.SprigEvent.SurveyWillClose,initiator:r,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}))},async setAttribute(r,n){if(!r||!n&&n!==0&&n!==!1){const s="[Sprig] - Disregarding empty attribute / value provided";return console.warn(s),{success:!1,message:s}}return this.setAttributes({[r]:n})},async setAttributes(r){if(r==null||Object.keys(r).length===0){const n="[Sprig] - Disregarding empty attributes provided";return console.warn(n),{success:!1,message:n}}return this.identifyAndSetAttributes({attributes:r})},async identifyAndSetAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",r),t.mode==="test")return;if(r===null||typeof r!="object"||!(r.userId||r.anonymousId||r.attributes)){const l="[Sprig] - Disregarding empty payload provided";return console.warn(l),{success:!1,message:l}}const{userId:n,anonymousId:s,attributes:d}=r;if(t.requireUserIdForTracking&&!window.UserLeap.userId&&!n){const l="[Sprig] - Skipping tracking without userId";return console.warn(l),{success:!1,message:l}}if(d){d.email&&!d[B]&&(d[B]=d.email,delete d.email);const l=Object.keys(d);for(const p of l)d[p]===oe[p]&&delete d[p]}if(!(d&&Object.keys(d).length!==0||n&&window.UserLeap.userId!==n||s&&window.UserLeap.partnerAnonymousId!==s))return{success:!0};const c={};let u;return n&&(c.userId=window.UserLeap.userId=n),s&&(c.partnerAnonymousId=window.UserLeap.partnerAnonymousId=s),d&&Object.keys(d).length>0?(u=await x(R("1",[P,C],"attributes"),{body:JSON.stringify(d),method:"PUT"}),u.ok?Object.assign(oe,d):u.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",u.error),u.error&&window.UserLeap.reportError("identifyAndSetAttributes",u.error))):u=await x(R("1",[P,C]),{body:JSON.stringify(c),method:"PUT"}),d&&d[B]&&(window.UserLeap.email=d[B]),u.ok&&(n&&k("uid",n),s&&k("aid",s)),{success:!!u.ok}},async removeAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",r),t.mode==="test")return;if(r==null||r.length===0){const s="[Sprig] - Disregarding empty attributes provided";return console.warn(s),{success:!1,message:s}}if(t.requireUserIdForTracking&&!window.UserLeap.userId){const s="[Sprig] - Skipping tracking without userId";return console.warn(s),{success:!1,message:s}}const n=await x(R("1",[P,C],"attributes"),{body:JSON.stringify({delete:r}),method:"DELETE"});return!n.ok&&n.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",n.error),n.error&&window.UserLeap.reportError("removeAttributes",n.error)),{success:!!n.ok}},async addSurveyListener(r){i.eventEmitter.on(i.SprigEvent.SurveyLifeCycle,r)},async removeSurveyListener(r){i.eventEmitter.removeListener(i.SprigEvent.SurveyLifeCycle,r)},async addListener(r,n){i.eventEmitter.on(r,n)},async removeListener(r,n){i.eventEmitter.removeListener(r,n)},async removeAllListeners(){i.eventEmitter.removeAllListeners()},setPreviewKey(r){r&&typeof r=="string"&&i.localStorageHelper.isStorageAvailable&&r&&i.localStorageHelper.setItem("sprig.previewKey",r)},async setUserId(r){var d;if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",r),r==null){const c=`[Sprig] - Invalid userId ${r}`;return console.warn(c),{success:!1,message:c}}if(t.mode==="test"||r===window.UserLeap.userId)return;window.UserLeap.userId=r;const n=window.UserLeap.visitorId,s=await x(R("1",[P,C]),{body:JSON.stringify({userId:r}),method:"PUT"});s.ok?(n!==window.UserLeap.visitorId&&((d=i.modules.replay)==null||d.clearUserReplayData()),k("uid",r)):s.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",s.error),s.error&&window.UserLeap.reportError("setUserId",s.error))},async setPartnerAnonymousId(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",r),r==null){const n=`[Sprig] - Invalid partnerAnonymousId ${r}`;return console.warn(n),{success:!1,message:n}}return window.UserLeap.partnerAnonymousId=r,k("aid",r),{success:!0}},track:async(r,n,s={},d=void 0)=>e({eventName:r,properties:n,metadata:s,showSurveyCallback:d}),identifyAndTrack:async r=>await e(r),trackPageView(r,n=void 0,s=void 0,d=!0){G=r,lt(r,n,s,d)},applyFeedbackStyles({button:r="",view:n=""}){window.UserLeap.feedbackCustomStyles=n,document.getElementById("sprig-feedback-style")&&Q({document,elementId:"ul-custom-style",styleString:r,nonce:window.UserLeap.styleNonce}),o(document.querySelector(".ul-container-feedback"),n)},applyStyles(r){window.UserLeap.customStyles=r,o(window.UserLeap.container,r)},setWindowDimensions(r,n){var g,y;const s=typeof r=="string"?parseInt(r,10):r,d=typeof n=="string"?parseInt(n,10):n;isNaN(s)||isNaN(d)||(window.UserLeap.windowDimensions={width:s,height:d});const c=i.getHttpHeaders(window.UserLeap),u=ae(c),l=c["userleap-platform"]==="web";if(!window.UserLeap.frameId)return;const p=document.getElementById(window.UserLeap.frameId);p&&(window.UserLeap.useMobileStyling&&((g=window.UserLeap.windowDimensions)!=null&&g.width&&(p.style.width=`${window.UserLeap.windowDimensions.width}px`),(y=window.UserLeap.windowDimensions)!=null&&y.height&&(p.style.maxHeight=window.UserLeap.windowDimensions.height-20+"px"),p.contentDocument&&(p.style.height=String(Je(p.contentDocument,l&&!u,i.shouldDirectEmbed(c))[0])+"px")),i.eventEmitter.emit(i.SprigEvent.SurveyDimensions,{name:i.SprigEvent.SurveyDimensions,contentFrameWidth:p.clientWidth,contentFrameHeight:p.clientHeight,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}))},logoutUser(){var r;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),i.breadcrumbsLogger.info("LogOut",{vid:window.UserLeap.visitorId,userId:window.UserLeap.userId}),window.UserLeap.visitorId=null,window.UserLeap.userId=null,window.UserLeap.partnerAnonymousId=null,window.UserLeap.token=null,window.UserLeap.email=null,i.localStorageHelper.removeItem("userleap.ids"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),dt(),(r=i.modules.replay)==null||r.clearUserReplayData(),window.UserLeap._queue.unpause()},teardown(){["hashchange","popstate"].forEach(r=>window.removeEventListener(r,K,!0)),window.UserLeap._config.interactiveEvents&&st(),window.UserLeap("dismissActiveSurvey",i.DismissReason.API),delete window.UserLeap,delete window.Sprig,delete window._Sprig},integrateOptimizely(r,n=!0){var s,d;if((d=(s=window.UserLeap)==null?void 0:s._config)!=null&&d.optimizelyEnabled)try{const c=typeof r=="string"?JSON.parse(r):r;X.setOptimizelyExperiment(c,n)}catch(c){console.warn("[Sprig] Error with integrating Optimizely data"),c instanceof Error&&window.UserLeap.reportError("integrateOptimizely",c)}else console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.")},integrateOptimizelyClient(r){var n,s;if(!((s=(n=window.UserLeap)==null?void 0:n._config)!=null&&s.optimizelyEnabled))return void console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");r.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",({experiment:d,variation:c})=>{const u={experiments:[{id:d.id,variation:c.key}]};window.UserLeap("integrateOptimizely",u,!1)})},importLaunchDarklyData(r){var n,s;(s=(n=window.UserLeap)==null?void 0:n._config)!=null&&s.launchDarklyEnabled?fe.setLDFlagsVariations(r):console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.")},setVisitorAttribute:(r,n)=>(console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),a.setAttribute(r,n)),setEmail:async r=>a.setAttribute(B,r),setVisitorEmail:async r=>(console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),a.setEmail(r)),_generateVideoUploadUrl:async r=>async function(n){var d;if(!n)return;const s=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const c=await fetch(s,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(c.ok){const u=await c.json();return(d=u==null?void 0:u.upload)==null?void 0:d.url}return null}catch(c){console.warn("[Sprig] Error with generating video upload url"),c instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",c)}}(r),_reportMetric(r,n){i.reportAndRegister(r,n)},_completeSessionReplay:async({surveyId:r,responseGroupUuid:n,eventDigest:s})=>{var d;return i.modules.replay?(d=i.modules.replay)==null?void 0:d._completeSessionReplay({surveyId:r,responseGroupUuid:n,eventDigest:s,headers:i.getHttpHeaders(window.UserLeap)}):(window.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)}};Object.assign(window.UserLeap,a)};async function Ct(t,e,o={},a={}){const r=window.__cfg&&window.__cfg.mode,n=Le(),s=window.UserLeap.envId,d=window.document.documentElement,c={mode:r,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:d.clientWidth,clientHeight:d.clientHeight,location:G??window.location.href,language:window.navigator.language,...o},u={action:t,breadcrumbs:i.breadcrumbsLogger.breadcrumbs,err:{message:`${e==null?void 0:e.name} - ${e==null?void 0:e.message}`,stack:e==null?void 0:e.stack},meta:c,vid:n,envId:s,...a};(await x(R("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(u),shouldDropOnRateLimit:!0})).ok||console.warn("[Sprig] (ERR-444) Failed to report error to API",e)}function Pt(t={}){var a;(a=window.SprigLoggerCallback)==null||a.call(window,"Initializing Sprig");const e=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";async function o(){var g,y,w,E,I;if(window.UserLeap.loaded)return;if((g=window.SprigLoggerCallback)==null||g.call(window,"Loading Sprig"),window.UserLeap.reportError=Ct,window.UserLeap.loaded=!0,window.UserLeap._config=Object.assign({},t,window.UserLeap.config),window.UserLeap.delayingSurvey=!1,window.UserLeap._config&&typeof window.UserLeap._config=="object")for(const m in window.UserLeap._config)window.UserLeap[m]=window.UserLeap._config[m];if(!window.UserLeap.envId){if(!window.UserLeap.appId)throw new Error("Missing Environment id");window.UserLeap.envId=window.UserLeap.appId}window.UserLeap.debugMode&&console.info("[DEBUG] Sprig debug mode enabled");const r=at(),n=window.UserLeap.sampleRate;let s=r.sampled;if(n){if(s===null&&(s=Math.random()<n,k("sampled",s)),!s)return}else s!==null&&k("sampled",null);window.UserLeap._API_URL||(window.UserLeap._API_URL="https://api.sprig.com");const d=[...window.UserLeap._queue];window.UserLeap._queue=new bt(window.UserLeap,[]),window.UserLeap._queue.pause();for(let m=0;m<d.length;m++)window.UserLeap._queue.push(d[m]);const c=r.token;c?(window.UserLeap.token=c,window.UserLeap.visitorId=r.vid??null,window.UserLeap.userId=r.uid??null,window.UserLeap.partnerAnonymousId=r.aid??null):dt();const u=J(i.getHttpHeaders(window.UserLeap));(y=window.SprigLoggerCallback)==null||y.call(window,"Sprig fetching config");const l=await async function(m){var O,v;const b=i.getHttpHeaders(window.UserLeap);document.addEventListener("securitypolicyviolation",i.cspViolationHandler);const h=await i.sprigFetch(R("1",[P],"config"),{headers:b});if(document.removeEventListener("securitypolicyviolation",i.cspViolationHandler),!h.ok)return(O=window.SprigLoggerCallback)==null||O.call(window,"Sprig config fetch failed"),h.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",h.error),h.error&&window.UserLeap.reportError("applyRemoteConfig",h.error)),i.killNetworkRequests("Disabled: failed to fetch configuration"),m;const L=h.json;return L!=null&&L.disabled?((v=window.SprigLoggerCallback)==null||v.call(window,"Sprig config fetch disabled"),i.killNetworkRequests(`Disabled: ${L.disabled}`),{disabled:L.disabled}):Object.assign({},L,m)}(t);(w=window.SprigLoggerCallback)==null||w.call(window,"Sprig fetched config"),kt({isWeb:!u,reportingIntervalSeconds:l.metricsReportingEnabled||l.mobileMetricsReportingEnabled?l.metricsReportingIntervalSeconds:0,thresholds:l.metricThresholds,postMetrics:async m=>{var b;await x(R("1",[P],"metrics"),{body:m,method:"POST",headers:{"x-ul-replay-enabled":`${!!((b=i.modules.replay)!=null&&b.isReplayRecording())}`},shouldDropOnRateLimit:!0})}});const p=l.alwaysOnReplay?{userAgent:window.navigator.userAgent,surveyId:l.alwaysOnReplay.surveyId,responseGroupUuid:l.alwaysOnReplay.responseGroupUuid,sdkVersion:"2.33.3",maxDurationSeconds:l.alwaysOnReplay.maxDurationSeconds}:void 0;await((E=i.modules.replay)==null?void 0:E.initializeReplay({maxReplayDurationSeconds:l.maxReplayDurationSeconds,maxInflightRequests:window.UserLeap.maxInflightReplayRequests??2,replaySettings:l.replaySettings,apiUrl:window.UserLeap._API_URL,alwaysOnConfig:p})),Ie=l.replaySettings,Ot(l),await At(l),window.UserLeap._queue.unpause(),(I=window.SprigLoggerCallback)==null||I.call(window,"SdkReady"),i.eventEmitter.emit(i.SprigEvent.SDKReady,{mobileMetricsReportingEnabled:!!l.mobileMetricsReportingEnabled,metricsReportingInterval:l.metricsReportingIntervalSeconds||0,metricsThresholds:l.metricThresholds||[],maxMobileReplayDurationSeconds:l.maxMobileReplayDurationSeconds,mobileReplaySettings:l.mobileReplaySettings}),i.eventEmitter.emit(i.SprigEvent.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}),i.eventEmitter.on(i.SprigEvent.VisitorIDUpdated,()=>{for(const m in oe)delete oe[m]})}window.UserLeap.UPDATES=i.EVENTS,window.UserLeap("setPreviewKey",e),document.readyState==="complete"?o():window.attachEvent?window.attachEvent("onload",o):window.addEventListener("load",()=>{o()},!1)}class se{constructor(){M(this,"UPDATES",i.EVENTS)}displaySurvey(e){window.Sprig("displaySurvey",e)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(e,o){window.Sprig("setAttribute",e,o)}setAttributes(e){window.Sprig("setAttributes",e)}identifyAndSetAttributes(e){window.Sprig("identifyAndSetAttributes",e)}removeAttributes(e){window.Sprig("removeAttributes",e)}addListener(e,o){window.Sprig("addListener",e,o)}removeListener(e,o){window.Sprig("removeListener",e,o)}removeAllListeners(){window.Sprig("removeAllListeners")}setEmail(e){window.Sprig("setAttribute","!email",e)}setUserId(e){window.Sprig("setUserId",e)}setPartnerAnonymousId(e){window.Sprig("setPartnerAnonymousId",e)}track(e,o={},a={}){window.Sprig("track",e,o,a)}identifyAndTrack(e){window.Sprig("identifyAndTrack",e)}trackPageView(e,o,a){window.Sprig("trackPageView",e,o,a)}applyStyles(e){window.Sprig("applyStyles",e)}setWindowDimensions(e,o){window.Sprig("setWindowDimensions",e,o)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}}const be={configure:t=>{if(!t.envId&&!t.environmentId)throw new Error("Initialization Error: Sprig configure requires an environmentId");if(t.envId||(t.envId=t.environmentId??""),t.installationMethod="web-npm",window.Sprig)return window.Sprig;window.Sprig=function(){window.Sprig._queue.push(arguments)},Object.getOwnPropertyNames(se.prototype).map(o=>{o!=="constructor"&&(window.Sprig[o]=se.prototype[o])});const e=window.Sprig;return e.appId=t.envId,e._queue=[],window.UserLeap=e,Pt(t),window.Sprig}},Ht={sprig:be,SprigAPI:se,configure:be.configure};exports.APP_ID="ul-app",exports.ConflictingWidgets=We,exports.DEFAULT_BORDER_COLOR="#e6e6e6",exports.DEFAULT_WIDTH_PX=360,exports.EMBED_MOBILE_MAX_WIDTH=1030,exports.ERROR_BORDER_COLOR="#bd282a",exports.SprigAPI=se,exports.calculateFrameDimensions=Je,exports.core=Ht,exports.isHTMLElement=D,exports.resetScrollPosition=t=>{const e=t.querySelector(".ul-card__container");e&&(e.scrollTop=0)},exports.setSurveyStyles=Q,exports.sprig=be;
|