@sprig-technologies/sprig-browser 2.32.4 → 2.32.6
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-DNNKcB-C.cjs +12 -0
- package/dist/{core-DX7Qkopv.js → core-GM5ainPn.js} +217 -220
- package/dist/core.cjs +1 -1
- package/dist/core.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/{metricsReporter-Dh_342TQ.js → metricsReporter-IUVTL7s6.js} +1 -1
- package/dist/{metricsReporter-CHOlWEKF.cjs → metricsReporter-hJoXXbKC.cjs} +1 -1
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +1 -1
- package/dist/{view-BkqDP9V8.js → view-BC8pDITD.js} +70 -70
- package/dist/{view-CZBsyFUR.cjs → view-D-38xPZ5.cjs} +3 -3
- package/package.json +1 -1
- package/dist/core-BuTAnr1A.cjs +0 -12
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";var ct=Object.defineProperty;var pt=(t,e,o)=>e in t?ct(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var F=(t,e,o)=>(pt(t,typeof e!="symbol"?e+"":e,o),o);const i=require("./metricsReporter-hJoXXbKC.cjs"),qe="360px",xe=()=>{try{return window.parent.Intercom}catch{return null}},Ae=[Object.freeze(Object.defineProperty({__proto__:null,disable:()=>{const t=xe();t&&(t.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),t.ul_wasVisible&&t("update",{hide_default_launcher:!0}))},enable:()=>{const t=xe();t&&(t.ul_wasVisible&&t("update",{hide_default_launcher:!1}),delete t.ul_wasVisible)}},Symbol.toStringTag,{value:"Module"}))];class Ve{static disable(){Ae.forEach(e=>e.disable())}static enable(){Ae.forEach(e=>e.enable())}}const Oe="ul-view-sdk-script",ut=["ios","android"],O="visitors",C="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"),p=c?c.split(" "):void 0,l=p&&p.length===2?p[1]:void 0,u=(s=r.headers)==null?void 0:s.get("x-ul-visitor-id");if(window.UserLeap.userId&&u===window.UserLeap.visitorId){const m=i.localStorageHelper.getItemObject("sprig.anon.env.vid.map");m&&m[window.UserLeap.envId]===u&&(delete m[window.UserLeap.envId],i.localStorageHelper.setItemObject("sprig.anon.env.vid.map",m))}l&&u&&(u!==window.UserLeap.visitorId||window.UserLeap.token!==l)&&(k("token",l),k("vid",u),i.eventEmitter.emit(i.SprigEvent.VisitorIDUpdated,{visitorId:u}),window.UserLeap.token=l,window.UserLeap.visitorId=u)}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 he(){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===C?a.push(window.UserLeap.envId):r===O&&a.push(he())}),o&&a.push(o),a.join("/")}const z=async(t,e)=>{var ke,_e,Re;const{context:o,delay:a,forceBrandedLogo:r,endCard:n,isFeedback:s=!1,heatmap:d,locale:c,previewMode:p,productConfig:l,questions:u,responseGroupUid:m,surveyId:w,uuid:g,vid:I,sessionReplay:h,studyType:S}=t,f=i.getHttpHeaders(window.UserLeap),b=oe(f),E=be(f);if(h)if(b)i.eventEmitter.emit(i.SprigEvent.ReplayCapture,{responseGroupUid:m,hasQuestions:!!(u!=null&&u.length),surveyId:w,uploadId:h.uploadId,replayType:h.replayDurationType??"before",seconds:h.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:i.v4(),mediaType:"screen",questionId:1,responseGroupUid:m,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:m,surveyId:w,visitorId:I,replayParams:h,completeUploadHeaders:f,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:u.length===0})}if(d){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:L,replayParams:de,responseGroupUid:dt,surveyId:lt}=d;await i.modules.replay.initializeReplay({maxReplayDurationSeconds:300,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0}),i.modules.replay.tryReplayAction(()=>{var De;return(De=i.modules.replay)==null?void 0:De.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:f,eventId:L,isHeatmap:!0,replayParams:de,responseGroupId:dt,surveyId:lt,triggerTimestamp:Date.now(),visitorId:I})},"Error in scheduling/capturing replay")}if(I==null||!(u!=null&&u.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 L="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(L),{success:!1,message:L,surveyState:"no survey"}}if(I!==window.UserLeap.visitorId&&g!==window.UserLeap.visitorId&&!window.previewMode){const L="Attempted to display survey to a different visitor";return window.UserLeap.reportError("DisplaySurvey",new Error(L)),{success:!1,message:L,surveyState:"no survey"}}i.breadcrumbsLogger.info("ShowingSurvey",{surveyId:w}),(ke=i.modules.replay)==null||ke.RecordSurveyShown({id:w,userAgent:window.navigator.userAgent}),Ve.disable(),i.eventEmitter.emit(i.SprigEvent.SurveyWillPresent,{name:i.SprigEvent.SurveyWillPresent,"survey.id":w});let D,v,U,_,P=document.createElement("div");const V=L=>{const{"view.version":de}=L;de!==f["x-ul-sdk-version"]&&Ne(),i.eventEmitter.removeListener("verify.view.version",V)};i.eventEmitter.on("verify.view.version",V),window.UserLeap.useMobileStyling=E,i.shouldDirectEmbed(f)?(D="ul-direct-embeded-frame",v=document.head,U=window,_=!1,b&&(We(w,s),P.id=D,window.UserLeap.container.appendChild(P),ze(),i.eventEmitter.emit(i.SprigEvent.SurveyLifeCycle,{state:"presented"}),i.eventEmitter.emit(i.SprigEvent.SurveyPresented,{name:i.SprigEvent.SurveyPresented,"survey.id":w}))):{frameId:D,contentWinDocHead:v,contentWindow:U,hasOverlay:_,iframe:P}=gt({productConfig:l,useMobileStyling:E,surveyId:w,isFeedback:s}),window.UserLeap.frameId=D;const j={apiURL:window.UserLeap._API_URL,cards:u,configureExitOnOverlayClick:L=>{i.eventEmitter.once(i.SprigEvent.CloseSurveyOnOverlayClick,L)},context:o,endCard:n,envId:window.UserLeap.envId,eventEmitFn:i.eventEmitter.emit.bind(i.eventEmitter),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:r,frame:P,headers:f,locale:c,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:i.localStorageHelper.getItem("sprig.previewKey"),previewMode:p,productConfig:{framePosition:l==null?void 0:l.framePosition,desktopDisplay:l==null?void 0:l.desktopDisplay,placement:l==null?void 0:l.placement},responseGroupUid:m,startingQuestionIdx:(_e=window.UserLeap.config)==null?void 0:_e.startingQuestionIdx,studyType:S,styleNonce:window.UserLeap.styleNonce,surveyId:w,tabTitle:document.title,trackPageViewUrl:e,ulEvents:i.EVENTS,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:E,userId:g,viewDocument:U==null?void 0:U.document,viewWindow:U,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},...window.UserLeap._config};(Re=window.UserLeap._config)!=null&&Re.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null});const at=(s?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??l.customStyles;j.customStyles=at,U&&(U.__cfg=j);const se=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:j.path,Ue=document.getElementById(Oe);Ue&&Ue.remove();const ae=function(){const L=document.createElement("script");return window.UserLeap.nonce&&L.setAttribute("nonce",window.UserLeap.nonce),L.id=Oe,L}(),Ee=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(j.installationMethod==="web-npm"||j.installationMethod==="web-npm-bundled"){const{default:L}=await Promise.resolve().then(()=>require("./view-D-38xPZ5.cjs"));L.configure(j),_&&window.UserLeap.container&&Ee()}else se&&(ae.src=se,_&&ae.addEventListener("load",()=>{window.UserLeap.container&&Ee()}),U==null||U.addEventListener("error",L=>{L.target instanceof HTMLScriptElement&&L.target.src===se&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));v==null||v.appendChild(ae);const Ie={success:!0,surveyState:"ready",surveyId:w,responseGroupUid:m};return window.UserLeap.isMobileSDK&&a&&(Ie.delay=a),Ie};function be(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 oe(t)||e>10&&e<500}function oe(t){return ut.includes(t["userleap-platform"])}const Se="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 le="0px",We=(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=Ge();o&&a&&!window.UserLeap.useMobileStyling?a.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},Ne=(t,e)=>{var a;yt();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)}},ze=()=>{i.eventEmitter.once(i.SprigEvent.SurveyWillClose,({initiator:t,studyType:e})=>{i.eventEmitter.removeAllListeners(i.SprigEvent.CloseSurveyOnOverlayClick),Ne(t,e)})},wt=(t,e,o,a)=>{var l,u;const r={position:"fixed",bottom:"0px",right:le,border:0,backgroundColor:"rgba(0,0,0,0)",zIndex:2147483646,transition:"width 0.2s ease-in-out, 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 p=!1;if(o)(l=window.UserLeap.windowDimensions)!=null&&l.width?r.width=`${window.UserLeap.windowDimensions.width}px`:r.width="100%",(u=window.UserLeap.windowDimensions)!=null&&u.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)&&(p=!0);else{r.width=qe,r.maxHeight=window.UserLeap.maxHeight||"66vh";const m=()=>{p=!0,c={margin:"auto",position:"static"}};if(a)d?m():c={position:"relative",height:"300px"};else switch(n.framePosition){case"bottomLeft":c={left:le};break;case"topLeft":c={left:le,top:0};break;case"topRight":c={top:0};break;case"center":m()}}return p&&((m,w)=>{const g={position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646},I=w?m.overlayStyleMobile:m.overlayStyle;g["background-color"]=I==="light"?"rgba(255,255,255, 0.95)":"rgba(0,0,0,0.9)",w||(g.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,g)})(n,o),Object.assign(t.style,r,c),p},gt=({productConfig:t,useMobileStyling:e,surveyId:o,isFeedback:a})=>{var m,w;const r=Se,n=a&&t.desktopDisplay==="slider";We(o,a,n),mt();const s=document.createElement("iframe");s.id=r,s.setAttribute("title","Sprig User Feedback Dialog");const d=wt(s,t,e,a);ze();let c=!1;s.setHeight=g=>{parseInt(s.style.height)==g&&c||(c=!0,s.style.height=`${g}px`,i.eventEmitter.emit(i.SprigEvent.SurveyHeight,{name:i.SprigEvent.SurveyHeight,contentFrameHeight:g,"survey.id":o}))};let p=!1;s.setWidth=g=>{parseInt(s.style.width)==g&&p||(p=!0,s.style.width=`${g}px`,i.eventEmitter.emit(i.SprigEvent.SurveyWidth,{name:i.SprigEvent.SurveyWidth,contentFrameWidth:g,"survey.id":o}))},(m=window.UserLeap.container)==null||m.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=(w=s.contentWindow)==null?void 0:w.document;if(l&&(l.open("text/html","replace"),l.write("<!doctype html><head></head><body></body></html>"),l.close(),!e)){const g=l.body;g.style.display="flex",g.style.alignItems="center"}const u=l==null?void 0:l.head;return{frameId:r,contentWinDocHead:u,contentWindow:s.contentWindow,hasOverlay:d,iframe:s}},Be={[i.SprigEvent.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},mt=()=>{Object.entries(Be).forEach(([t,e])=>{i.eventEmitter.on(t,e)})},yt=()=>{Object.entries(Be).forEach(([t,e])=>{i.eventEmitter.off(t,e)})},M=t=>!!t&&t.nodeType===Node.ELEMENT_NODE,Ce=t=>t instanceof HTMLElement||t instanceof SVGElement,K=({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)},vt=(t,e)=>{const o=e.querySelector(".sprig-question-body");if(!M(o))return t;const a=o.scrollHeight;return a<100?t:t-(a-100)},Pe=(t,e)=>{const o=e.querySelector(t);if(!M(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))},$e=t=>{const e=t.querySelector(".ul-card__container");let o=600,a=360,r=0;if(M(e)){o=e.clientHeight,o+=(d=>{const c=d.querySelector(".sprig-question-body"),p=d.querySelector(".ul-card"),l=d.querySelector(".ul-card-main-content");let u=0;return M(p)&&(u+=p.scrollHeight-p.clientHeight),M(l)&&(u+=l.scrollHeight-l.clientHeight),M(c)&&(u+=c.scrollHeight-c.clientHeight),u})(t);const n=getComputedStyle(e);r=o,o+=parseFloat(n.marginTop)+parseFloat(n.marginBottom)+(parseFloat(n.borderTopWidth)+parseFloat(n.borderBottomWidth));const s=e.querySelector(".ul-card--matrix_grid");a=s?s.scrollWidth:e.scrollWidth,a+=Pe(".ul-card__container",t),a+=Pe(".sprig-question-body",t)}return[o+1,a,vt(r,t)]},Ge=()=>y,q=()=>document.getElementById("sprig-feedback-container"),we=()=>document.getElementById("sprig-feedback-loading-animation"),Ke=()=>!!document.getElementById(Se);let Te=!1,y=null,A=null,Le=!1,B=null,T=null;const ft=["bottom-left","bottom-right","center-left","center-right"],Y=()=>{var e;const t=window.UserLeap.container;return((e=t==null?void 0:t.parentElement)==null?void 0:e.id)==="sprig-feedback-loading-container"},Je=()=>document.getElementById("sprig-feedback-error-container"),Qe=()=>{if(!y)return 0;const t=y==null?void 0:y.clientWidth,e=window.getComputedStyle(y);return t+parseInt(e.borderRightWidth||"0")+parseInt(e.borderLeftWidth||"0")},X=t=>{const e=q();e&&(T!=null&&T.endsWith("right")?e.style.right=`${t}px`:T!=null&&T.endsWith("left")&&(e.style.left=`${t}px`))},ce=()=>{if(y&&(Y()||Je())){i.eventEmitter.off(i.SprigEvent.SurveyAppeared,N),ge();const t=Qe();return X(-t),!0}return!1},N=()=>{if(!y||!A)return;const t=we();t&&t.remove(),y.style.height="auto",y.style.width="auto",A.disabled=!1,Le=!1},ge=()=>{if(y&&!we()){const t=(()=>{if(we())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&&(y.style.height="300px",y.style.width="360px",y.appendChild(t))}},He=()=>{y&&A&&(X(0),A.disabled=!0,Le=!0)},Ye=async(t,e,o)=>{const{buttonTheme:a,customStyles:r,eventId:n,placement:s,desktopDisplay:d,feedbackLabel:c,surveyUuid:p,surveyId:l}=t;window.UserLeap.feedbackCustomStyles=void 0;let u=q();if(u){if(!e&&n===B)return;u.remove(),i.eventEmitter.off(i.EVENTS.SURVEY_FADING_OUT,ce)}B=n,K({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}),K({document,elementId:"ul-custom-style",styleString:r??"",nonce:window.UserLeap.styleNonce}),Te=d==="center-modal",T=s;const[m,w]=s.split("-");(S=>{if(q()||!ft.includes(S))return;const[f,b]=S.split("-"),E=document.createElement("div");E.id="sprig-feedback-container",E.classList.add(`sprig-feedback-container-${b}`,`sprig-feedback-container-${f}`),document.body.appendChild(E)})(s),u=q(),A=document.createElement("button");const g=document.createElement("div");g.className="sprig-feedback-button-label",g.innerText=c,A.appendChild(g),A.id="sprig-feedback-button",A.classList.add(`sprig-feedback-button-${w}`,`sprig-feedback-button-${m}`,`sprig-feedback-button-${a}`,"fade-in-transition"),i.eventEmitter.on(i.EVENTS.SURVEY_FADING_OUT,ce),A.addEventListener("click",async()=>{const S=document.getElementById("sprig-feedback-error-container");if(Ke()||Je()){if(ce()){i.eventEmitter.emit(i.SprigEvent.SurveyWillClose,{name:i.SprigEvent.SurveyWillClose,initiator:i.DismissReason.FeedbackClosed,studyType:"feedbackButton","survey.id":l});const b=q();S&&b&&(b.remove(),B=null,y=null)}return}if(be(i.getHttpHeaders(window.UserLeap))||Le||He(),e)return y&&y.classList.add("sprig-feedback-loading-container-previews"),await z(e),void N();const f=await(async b=>{const E=await x(R("1",[O],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:b}),method:"POST"});return E.ok?E.json:null})(p);if(f)i.eventEmitter.once(i.SprigEvent.SurveyAppeared,N),z({...f,studyType:"feedbackButton"},o);else if(y){const b=ht();y.appendChild(b),N(),y.style.height="300px",y.style.width="360px"}}),u==null||u.appendChild(A),i.eventEmitter.emit(i.SprigEvent.FeedbackButtonLoaded,{name:i.SprigEvent.FeedbackButtonLoaded,"survey.id":l});const{useMobileStyling:I,_config:{border:h}}=window.UserLeap;if(Te||I)X(0);else{const S=document.createElement("div");S.id="sprig-feedback-loading-container",S.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${w}`,S.style.setProperty("--feedback-border",h),y=S,ge(),u==null||u.appendChild(S);const f=Qe();X(-f)}window.UserLeap._config.isOnQuestionsTab&&e&&!Y()&&y&&(He(),ge(),y&&y.classList.add("sprig-feedback-loading-container-previews"),z(e),N())},ht=()=>{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},me=new class{constructor(){F(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(me);const Q=new class{constructor(){F(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(Q);class bt{constructor(e,o){F(this,"paused");F(this,"queue");F(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 Xe,Ze;const ye=t=>{let e=0,o=t.firstElementChild;for(;o;)e+=ye(o),o.shadowRoot&&(e+=ye(o.shadowRoot)),o=o.nextElementSibling,e++;return e},Me=()=>{Xe.report(ye(document.body)),Ze.report(document.documentElement.innerHTML.length)},ve=(t,e)=>{const o=performance.now();document.hidden?setTimeout(()=>ve(t,e),t):setTimeout(()=>{const a=performance.now()-o;e.report(a/1e3),setTimeout(()=>ve(t,e),t)},0)};let Z,ee,te,re,je,H={};const J=(t,e=1)=>{const{name:o}=t;H[o]=(H[o]||0)+e},et=t=>{let e=1;return t.childNodes.forEach(o=>{e+=et(o)}),e},Fe=t=>{let e=0;return t.forEach(o=>{e+=et(o)}),e},St=t=>{switch(t.type){case"childList":return J(Z,Fe(t.addedNodes)),void J(ee,Fe(t.removedNodes));case"attributes":return void J(te);case"characterData":return void J(re)}},Lt=t=>t.forEach(St),Ut=()=>{Z.report(H[Z.name]||0),ee.report(H[ee.name]||0),te.report(H[te.name]||0),re.report(H[re.name]||0),H={}},Et=(t=1e3)=>{Z=i.registerMetric("sdk_mutations_nodes_added"),ee=i.registerMetric("sdk_mutations_nodes_removed"),te=i.registerMetric("sdk_mutations_attributes_changed"),re=i.registerMetric("sdk_mutations_character_data"),je=new MutationObserver(Lt),je.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),setInterval(Ut,t)},It=({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");ve(r,n)})(),((r=1e4)=>{Xe=i.registerMetric("sdk_dom_nodes_count"),Ze=i.registerMetric("sdk_page_html_characters"),Me(),setInterval(Me,r)})(),Et())},kt="test",_t=["popState","pushState","replaceState"];let $;const ie={},W="!email",tt="pageUrl";let pe=window.location.href;function G(t){var d;const{pageUrlEvents:e,interactiveEvents:o,dismissOnPageChange:a,platform:r}=window.UserLeap._config;if(r&&r!=="web")return;pe!==window.location.href&&i.breadcrumbsLogger.navigation("LocationChange",{from:pe,to:window.location.href}),pe=window.location.href;const n=nt().trackStartUrl,s=n?String(n):null;e&&st(window.location.href),o&&(it(),Rt()),Ge()&&(()=>{if(Y())return;const c=q();c&&(i.checkUrlStillMatching(B)||(c.remove(),B=null,y=null))})(),i.sessionStorageHelper.getItem("sprig.isCapturingHeatmap")&&((d=i.modules.replay)==null||d.checkPendingHeatmapsUrl()),!Y()&&a&&s&&s!==window.location.href&&t&&_t.includes(t.type)&&window.UserLeap("dismissActiveSurvey",i.DismissReason.PageChange)}const rt={capture:!0},Rt=()=>{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(Ce(d.target))try{d.target.closest(n)&&window.UserLeap("track",a)}catch{}return!1}:d=>(Ce(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,rt)},it=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,rt),delete window.UserLeap._config.interactiveEventsHandler};function nt(){const t=i.localStorageHelper.getItemObject("userleap.ids");return t&&t[window.UserLeap.envId]||{}}function ot(){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 st(t,e,o,a){var r,n;try{if(t.endsWith("mock_snippet.html"))return;i.breadcrumbsLogger.info("PageView",{url:t});const s=window.UserLeap._config.pageUrlEvents;let d=!1;if(s&&s.length)for(let l=0;l<s.length&&(d=i.checkUrlMatch(s[l],t),!d);l++);if(!d)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",t);const c={url:t};a&&(c.trackPageView=!0),window.UserLeap._queue.push(["track",tt,e,c,o]);const p=(r=document==null?void 0:document.querySelector('meta[name="description"]'))==null?void 0:r.getAttribute("content");(n=i.modules.replay)==null||n.RecordPageView({...p&&{description:p},url:t,referrer:document.referrer,pageTitle:document.title})}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 Dt(){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),G(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),G(r),a})(t.replaceState)),["hashchange","popstate"].forEach(e=>window.addEventListener(e,G,!0))}async function ue(t,e){const o=he();t&&!e&&(window.UserLeap._config.mode=kt);const a=be(i.getHttpHeaders(window.UserLeap)),r=await x(function(n){const s=new URL(R("1",[C],"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,$);{const{feedbackLabel:n,productConfig:s,surveyUuid:d,feedbackCustomStyles:c}=r.json,{buttonTheme:p,placement:l,desktopDisplay:u}=s;Ye({customStyles:c,buttonTheme:p,desktopDisplay:u,eventId:0,feedbackLabel:n,placement:l,surveyUuid:d,surveyId:t==null?void 0:t.surveyId},r.json)}}function xt(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)&&(Dt(),G())}const At=function(t){if(!window.UserLeap)return;const e=async(r={})=>{var S,f,b,E,D;const{userId:n,anonymousId:s,metadata:d={},properties:c,showSurveyCallback:p}=r;let{eventName:l}=r;if(window.UserLeap.debugMode&&l!==tt&&console.info("[DEBUG] Sprig track",r),t.mode==="test")return;const u=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 m=$??window.location.href;d.url||(d.url=m),k("trackStartUrl",m),(f=(S=window.UserLeap)==null?void 0:S._config)!=null&&f.optimizelyEnabled&&(oe(i.getHttpHeaders(window.UserLeap))||Q.getAndSetWebOptimizelyExperiments(),d.optimizelyExperiments=Object.assign({},Q.getAllOptimizelyExperiments())),(E=(b=window.UserLeap)==null?void 0:b._config)!=null&&E.launchDarklyEnabled&&(d.launchDarklyFlags=me.getAllLaunchDarklyVariations()),n&&(window.UserLeap.userId=n),s&&(window.UserLeap.partnerAnonymousId=s),c&&(d.eventProperties=c),(D=i.modules.replay)==null||D.RecordEvent({name:l,url:d.url}),i.breadcrumbsLogger.info("TrackEvent",{eventName:l});const w=window.UserLeap.delayingSurvey||Ke()?await x(R("1",[O],"events/batch"),{body:JSON.stringify({events:[{event:l,metadata:d}],previewKey:u}),method:"POST",shouldDropOnRateLimit:!0}):await x(R("1",[O],"events"),{body:JSON.stringify({event:l,metadata:d,previewKey:u}),method:"POST",shouldDropOnRateLimit:!0});if(!w.ok){const v="[Sprig] (ERR-421) Failed to track event";return w.reportError&&(console.warn(v,w.error),w.error&&window.UserLeap.reportError("track",w.error)),{success:!1,message:v,error:w.error,surveyState:"no survey"}}n&&k("uid",n),s&&k("aid",s);const g=w.json;g.invalidPreviewKey&&i.localStorageHelper.removeItem("sprig.previewKey");const I=d.trackPageView?d.url:void 0;return g!=null&&g.feedbackButton&&Ye(g.feedbackButton,void 0,I),await async function(v,U){var P,V;let _=!0;return!(U&&((P=v==null?void 0:v.json)!=null&&P.surveyId)&&(window.UserLeap.delayingSurvey=!0,_=await U(v.json.surveyId),window.UserLeap.delayingSurvey=!1,!_))&&((V=v==null?void 0:v.json)!=null&&V.delay&&!window.UserLeap.isMobileSDK&&(window.UserLeap.delayingSurvey=!0,await i.delay(v.json.delay),window.UserLeap.delayingSurvey=!1),_)}(w,p)?function(v){if(!window.UserLeap._config.dismissOnPageChange)return!0;const U=new URL(v),_=new URL($??window.location.href);return U.hostname===_.hostname&&U.pathname===_.pathname}(m)?z(g,I):{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="${Se}"]`))==null?void 0:d.contentDocument;s&&K({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),ue({surveyId:r},!0)),_previewSurvey(r){window.UserLeap("dismissActiveSurvey",i.DismissReason.Override),ue({surveyTemplateId:r},!1)},_reviewSurvey(r){window.UserLeap("dismissActiveSurvey",i.DismissReason.Override),ue({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&&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[W]&&(d[W]=d.email,delete d.email);const l=Object.keys(d);for(const u of l)d[u]===ie[u]&&delete d[u]}if(!(d&&Object.keys(d).length!==0||n&&window.UserLeap.userId!==n||s&&window.UserLeap.partnerAnonymousId!==s))return{success:!0};const c={};let p;return n&&(c.userId=window.UserLeap.userId=n),s&&(c.partnerAnonymousId=window.UserLeap.partnerAnonymousId=s),d&&Object.keys(d).length>0?(p=await x(R("1",[C,O],"attributes"),{body:JSON.stringify(d),method:"PUT"}),p.ok?Object.assign(ie,d):p.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",p.error),p.error&&window.UserLeap.reportError("identifyAndSetAttributes",p.error))):p=await x(R("1",[C,O]),{body:JSON.stringify(c),method:"PUT"}),d&&d[W]&&(window.UserLeap.email=d[W]),p.ok&&(n&&k("uid",n),s&&k("aid",s)),{success:!!p.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",[C,O],"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",[C,O]),{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){$=r,st(r,n,s,d)},applyFeedbackStyles({button:r="",view:n=""}){window.UserLeap.feedbackCustomStyles=n,document.getElementById("sprig-feedback-style")&&K({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 p,l;const s=typeof r=="string"?parseInt(r,10):r,d=typeof n=="string"?parseInt(n,10):n;if(isNaN(s)||isNaN(d)||(window.UserLeap.windowDimensions={width:s,height:d}),!window.UserLeap.frameId)return;const c=document.getElementById(window.UserLeap.frameId);c&&(window.UserLeap.useMobileStyling&&((p=window.UserLeap.windowDimensions)!=null&&p.width&&(c.style.width=`${window.UserLeap.windowDimensions.width}px`),(l=window.UserLeap.windowDimensions)!=null&&l.height&&(c.style.maxHeight=window.UserLeap.windowDimensions.height-20+"px"),c.contentDocument&&(c.style.height=String($e(c.contentDocument)[0])+"px")),i.eventEmitter.emit(i.SprigEvent.SurveyDimensions,{name:i.SprigEvent.SurveyDimensions,contentFrameWidth:c.clientWidth,contentFrameHeight:c.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(),ot(),(r=i.modules.replay)==null||r.clearUserReplayData(),window.UserLeap._queue.unpause()},teardown(){["hashchange","popstate"].forEach(r=>window.removeEventListener(r,G,!0)),window.UserLeap._config.interactiveEvents&&it(),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;Q.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 p={experiments:[{id:d.id,variation:c.key}]};window.UserLeap("integrateOptimizely",p,!1)})},importLaunchDarklyData(r){var n,s;(s=(n=window.UserLeap)==null?void 0:n._config)!=null&&s.launchDarklyEnabled?me.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(W,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 p=await c.json();return(d=p==null?void 0:p.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 Ot(t,e,o={},a={}){const r=window.__cfg&&window.__cfg.mode,n=he(),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:$??window.location.href,language:window.navigator.language,...o},p={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(p),shouldDropOnRateLimit:!0})).ok||console.warn("[Sprig] (ERR-444) Failed to report error to API",e)}function Ct(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 u,m,w,g,I;if(window.UserLeap.loaded)return;if((u=window.SprigLoggerCallback)==null||u.call(window,"Loading Sprig"),window.UserLeap.reportError=Ot,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 h in window.UserLeap._config)window.UserLeap[h]=window.UserLeap._config[h];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=nt(),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 h=0;h<d.length;h++)window.UserLeap._queue.push(d[h]);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):ot();const p=oe(i.getHttpHeaders(window.UserLeap));(m=window.SprigLoggerCallback)==null||m.call(window,"Sprig fetching config");const l=await async function(h){var E,D;const S=i.getHttpHeaders(window.UserLeap);document.addEventListener("securitypolicyviolation",i.cspViolationHandler);const f=await i.sprigFetch(R("1",[C],"config"),{headers:S});if(document.removeEventListener("securitypolicyviolation",i.cspViolationHandler),!f.ok)return(E=window.SprigLoggerCallback)==null||E.call(window,"Sprig config fetch failed"),f.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",f.error),f.error&&window.UserLeap.reportError("applyRemoteConfig",f.error)),i.killNetworkRequests("Disabled: failed to fetch configuration"),h;const b=f.json;return b!=null&&b.disabled?((D=window.SprigLoggerCallback)==null||D.call(window,"Sprig config fetch disabled"),i.killNetworkRequests(`Disabled: ${b.disabled}`),{disabled:b.disabled}):Object.assign({},b,h)}(t);(w=window.SprigLoggerCallback)==null||w.call(window,"Sprig fetched config"),It({isWeb:!p,reportingIntervalSeconds:l.metricsReportingEnabled||l.mobileMetricsReportingEnabled?l.metricsReportingIntervalSeconds:0,thresholds:l.metricThresholds,postMetrics:async h=>{var S;await x(R("1",[C],"metrics"),{body:h,method:"POST",headers:{"x-ul-replay-enabled":`${!!((S=i.modules.replay)!=null&&S.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),await((g=i.modules.replay)==null?void 0:g.initializeReplay({maxReplayDurationSeconds:l.maxReplayDurationSeconds,maxInflightRequests:window.UserLeap.maxInflightReplayRequests??2,replaySettings:l.replaySettings})),At(l),await xt(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 h in ie)delete ie[h]})}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 ne{constructor(){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 fe={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(ne.prototype).map(o=>{o!=="constructor"&&(window.Sprig[o]=ne.prototype[o])});const e=window.Sprig;return e.appId=t.envId,e._queue=[],window.UserLeap=e,Ct(t),window.Sprig}},Pt={sprig:fe,SprigAPI:ne,configure:fe.configure};exports.APP_ID="ul-app",exports.ConflictingWidgets=Ve,exports.DEFAULT_BORDER_COLOR="#e6e6e6",exports.DEFAULT_WIDTH=qe,exports.EMBED_MOBILE_MAX_WIDTH=1030,exports.ERROR_BORDER_COLOR="#bd282a",exports.SprigAPI=ne,exports.calculateFrameDimensions=$e,exports.core=Pt,exports.isHTMLElement=M,exports.resetScrollPosition=t=>{const e=t.querySelector(".ul-card__container");e&&(e.scrollTop=0)},exports.setSurveyStyles=K,exports.sprig=fe;
|