@sprig-technologies/sprig-bundled 2.36.1 → 2.37.1

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.
@@ -58,7 +58,7 @@ You tried to parse Less with the standard CSS parser; try again with the postcss
58
58
  https://evilmartians.com/chronicles/postcss-8-plugin-migration`),process.env.LANG&&process.env.LANG.startsWith("cn")&&console.warn(e+`: 里面 postcss.plugin 被弃用. 迁移指南:
59
59
  https://www.w3ctech.com/topic/2226`));let a=t(...i);return a.postcssPlugin=e,a.postcssVersion=new ii().version,a}return Object.defineProperty(s,"postcss",{get:()=>(r||(r=s()),r)}),s.process=function(i,a,o){return X([s(o)]).process(i,a)},s},X.stringify=df,X.parse=gf,X.fromJSON=pf,X.list=yf,X.comment=e=>new Ca(e),X.atRule=e=>new ka(e),X.decl=e=>new Sa(e),X.rule=e=>new Ea(e),X.root=e=>new xa(e),X.document=e=>new Ia(e),X.CssSyntaxError=lf,X.Declaration=Sa,X.Container=uf,X.Processor=ii,X.Document=Ia,X.Comment=Ca,X.Warning=hf,X.AtRule=ka,X.Result=mf,X.Input=ff,X.Rule=Ea,X.Root=xa,X.Node=wf,cf.registerPostcss(X);var vf=X;X.default=X;const ae=Bh(vf);ae.stringify,ae.fromJSON,ae.plugin,ae.parse,ae.list,ae.document,ae.comment,ae.atRule,ae.rule,ae.decl,ae.root,ae.CssSyntaxError,ae.Declaration,ae.Container,ae.Processor,ae.Document,ae.Comment,ae.Warning,ae.AtRule,ae.Result,ae.Input,ae.Rule,ae.Root,ae.Node;class Zi{constructor(...t){Re(this,"parentElement",null),Re(this,"parentNode",null),Re(this,"ownerDocument"),Re(this,"firstChild",null),Re(this,"lastChild",null),Re(this,"previousSibling",null),Re(this,"nextSibling",null),Re(this,"ELEMENT_NODE",1),Re(this,"TEXT_NODE",3),Re(this,"nodeType"),Re(this,"nodeName"),Re(this,"RRNodeType")}get childNodes(){const t=[];let r=this.firstChild;for(;r;)t.push(r),r=r.nextSibling;return t}contains(t){if(!(t instanceof Zi)||t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}appendChild(t){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(t,r){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(t){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}}const Ra={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},La={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},zr={};function Qi(e){if(zr[e])return zr[e];const t=globalThis[e],r=t.prototype,n=e in Ra?Ra[e]:void 0,s=!!(n&&n.every(o=>{var l,c;return!!((c=(l=Object.getOwnPropertyDescriptor(r,o))==null?void 0:l.get)!=null&&c.toString().includes("[native code]"))})),i=e in La?La[e]:void 0,a=!!(i&&i.every(o=>{var l;return typeof r[o]=="function"&&((l=r[o])==null?void 0:l.toString().includes("[native code]"))}));if(s&&a)return zr[e]=t.prototype,t.prototype;try{const o=document.createElement("iframe");document.body.appendChild(o);const l=o.contentWindow;if(!l)return t.prototype;const c=l[e].prototype;return document.body.removeChild(o),c?zr[e]=c:r}catch{return r}}const us={};function et(e,t,r){var n;const s=`${e}.${String(r)}`;if(us[s])return us[s].call(t);const i=Qi(e),a=(n=Object.getOwnPropertyDescriptor(i,r))==null?void 0:n.get;return a?(us[s]=a,a.call(t)):t[r]}const ds={};function Oa(e,t,r){const n=`${e}.${String(r)}`;if(ds[n])return ds[n].bind(t);const s=Qi(e)[r];return typeof s!="function"?t[r]:(ds[n]=s,s.bind(t))}function Nc(){return Qi("MutationObserver").constructor}const V={childNodes:function(e){return et("Node",e,"childNodes")},parentNode:function(e){return et("Node",e,"parentNode")},parentElement:function(e){return et("Node",e,"parentElement")},textContent:function(e){return et("Node",e,"textContent")},contains:function(e,t){return Oa("Node",e,"contains")(t)},getRootNode:function(e){return Oa("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?et("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?et("Element",e,"shadowRoot"):null},querySelector:function(e,t){return et("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return et("Element",e,"querySelectorAll")(t)},mutationObserver:Nc};function ye(e,t,r=document){const n={capture:!0,passive:!0};return r.addEventListener(e,t,n),()=>r.removeEventListener(e,t,n)}const St=`Please stop import mirror directly. Instead of that,\r
60
60
  now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
61
- or you can use record.mirror to access the mirror instance during recording.`;let Aa={map:{},getId:()=>(console.error(St),-1),getNode:()=>(console.error(St),null),removeNodeFromMap(){console.error(St)},has:()=>(console.error(St),!1),reset(){console.error(St)}};function Gt(e,t,r={}){let n=null,s=0;return function(...i){const a=Date.now();s||r.leading!==!1||(s=a);const o=t-(a-s),l=this;o<=0||o>t?(n&&(clearTimeout(n),n=null),s=a,e.apply(l,i)):n||r.trailing===!1||(n=setTimeout(()=>{s=r.leading===!1?0:Date.now(),n=null,e.apply(l,i)},o))}}function Yn(e,t,r,n,s=window){const i=s.Object.getOwnPropertyDescriptor(e,t);return s.Object.defineProperty(e,t,n?r:{set(a){setTimeout(()=>{r.set.call(this,a)},0),i&&i.set&&i.set.call(this,a)}}),()=>Yn(e,t,i||{},!0)}function At(e,t,r){try{if(!(t in e))return()=>{};const n=e[t],s=r(n);return typeof s=="function"&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=s,()=>{e[t]=n}}catch{return()=>{}}}typeof window<"u"&&window.Proxy&&window.Reflect&&(Aa=new Proxy(Aa,{get:(e,t,r)=>(t==="map"&&console.error(St),Reflect.get(e,t,r))}));let vn=Date.now;function Fc(e){var t,r,n,s;const i=e.document;return{left:i.scrollingElement?i.scrollingElement.scrollLeft:e.pageXOffset!==void 0?e.pageXOffset:i.documentElement.scrollLeft||(i==null?void 0:i.body)&&((t=V.parentElement(i.body))==null?void 0:t.scrollLeft)||((r=i==null?void 0:i.body)==null?void 0:r.scrollLeft)||0,top:i.scrollingElement?i.scrollingElement.scrollTop:e.pageYOffset!==void 0?e.pageYOffset:(i==null?void 0:i.documentElement.scrollTop)||(i==null?void 0:i.body)&&((n=V.parentElement(i.body))==null?void 0:n.scrollTop)||((s=i==null?void 0:i.body)==null?void 0:s.scrollTop)||0}}function Bc(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function zc(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function jc(e){return e?e.nodeType===e.ELEMENT_NODE?e:V.parentElement(e):null}function ve(e,t,r,n){if(!e)return!1;const s=jc(e);if(!s)return!1;try{if(typeof t=="string"){if(s.classList.contains(t)||n&&s.closest("."+t)!==null)return!0}else if(wn(s,t,n))return!0}catch{}return!!(r&&(s.matches(r)||n&&s.closest(r)!==null))}function ps(e,t,r){return!(e.tagName!=="TITLE"||!r.headTitleMutations)||t.getId(e)===-2}function Wc(e,t){if(Jt(e))return!1;const r=t.getId(e);if(!t.has(r))return!0;const n=V.parentNode(e);return(!n||n.nodeType!==e.DOCUMENT_NODE)&&(!n||Wc(n,t))}function oi(e){return!!e.changedTouches}function Vc(e,t){return!!(e.nodeName==="IFRAME"&&t.getMeta(e))}function Gc(e,t){return!!(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function ai(e){return!!e&&(e instanceof Zi&&"shadowRoot"in e?!!e.shadowRoot:!!V.shadowRoot(e))}/[1-9][0-9]{12}/.test(Date.now().toString())||(vn=()=>new Date().getTime());class bf{constructor(){R(this,"id",1),R(this,"styleIDMap",new WeakMap),R(this,"idStyleMap",new Map)}getId(t){return this.styleIDMap.get(t)??-1}has(t){return this.styleIDMap.has(t)}add(t,r){if(this.has(t))return this.getId(t);let n;return n=r===void 0?this.id++:r,this.styleIDMap.set(t,n),this.idStyleMap.set(n,t),n}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function Hc(e){var t;let r=null;return"getRootNode"in e&&((t=V.getRootNode(e))==null?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&V.host(V.getRootNode(e))&&(r=V.host(V.getRootNode(e))),r}function Sf(e){const t=e.ownerDocument;if(!t)return!1;const r=function(n){let s,i=n;for(;s=Hc(i);)i=s;return i}(e);return V.contains(t,r)}function Yc(e){const t=e.ownerDocument;return!!t&&(V.contains(t,e)||Sf(e))}var Y=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(Y||{}),G=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(G||{}),be=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(be||{}),Ye=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Ye||{}),It=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(It||{}),Ct=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(Ct||{});function Ma(e){return"__ln"in e}class If{constructor(){R(this,"length",0),R(this,"head",null),R(this,"tail",null)}get(t){if(t>=this.length)throw new Error("Position outside of list range");let r=this.head;for(let n=0;n<t;n++)r=(r==null?void 0:r.next)||null;return r}addNode(t){const r={value:t,previous:null,next:null};if(t.__ln=r,t.previousSibling&&Ma(t.previousSibling)){const n=t.previousSibling.__ln.next;r.next=n,r.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=r,n&&(n.previous=r)}else if(t.nextSibling&&Ma(t.nextSibling)&&t.nextSibling.__ln.previous){const n=t.nextSibling.__ln.previous;r.previous=n,r.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=r,n&&(n.next=r)}else this.head&&(this.head.previous=r),r.next=this.head,this.head=r;r.next===null&&(this.tail=r),this.length++}removeNode(t){const r=t.__ln;this.head&&(r.previous?(r.previous.next=r.next,r.next?r.next.previous=r.previous:this.tail=r.previous):(this.head=r.next,this.head?this.head.previous=null:this.tail=null),t.__ln&&delete t.__ln,this.length--)}}const Ua=(e,t)=>`${e}@${t}`;class Cf{constructor(){R(this,"frozen",!1),R(this,"locked",!1),R(this,"texts",[]),R(this,"attributes",[]),R(this,"attributeMap",new WeakMap),R(this,"removes",[]),R(this,"mapRemoves",[]),R(this,"movedMap",{}),R(this,"addedSet",new Set),R(this,"movedSet",new Set),R(this,"droppedSet",new Set),R(this,"mutationCb"),R(this,"blockClass"),R(this,"blockSelector"),R(this,"maskTextClass"),R(this,"maskTextSelector"),R(this,"inlineStylesheet"),R(this,"maskInputOptions"),R(this,"maskTextFn"),R(this,"maskInputFn"),R(this,"keepIframeSrcFn"),R(this,"recordCanvas"),R(this,"inlineImages"),R(this,"slimDOMOptions"),R(this,"dataURLOptions"),R(this,"doc"),R(this,"mirror"),R(this,"iframeManager"),R(this,"stylesheetManager"),R(this,"shadowDomManager"),R(this,"canvasManager"),R(this,"processedNodeManager"),R(this,"unattachedDoc"),R(this,"processMutations",t=>{t.forEach(this.processMutation),this.emit()}),R(this,"emit",()=>{if(this.frozen||this.locked)return;const t=[],r=new Set,n=new If,s=l=>{let c=l,u=-2;for(;u===-2;)c=c&&c.nextSibling,u=c&&this.mirror.getId(c);return u},i=l=>{const c=V.parentNode(l);if(!c||!Yc(l)||c.tagName==="TEXTAREA")return;const u=Jt(c)?this.mirror.getId(Hc(l)):this.mirror.getId(c),d=s(l);if(u===-1||d===-1)return n.addNode(l);const p=kt(l,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:f=>{Vc(f,this.mirror)&&this.iframeManager.addIframe(f),Gc(f,this.mirror)&&this.stylesheetManager.trackLinkElement(f),ai(l)&&this.shadowDomManager.addShadowRoot(V.shadowRoot(l),this.doc)},onIframeLoad:(f,y)=>{this.iframeManager.attachIframe(f,y),this.shadowDomManager.observeAttachShadow(f)},onStylesheetLoad:(f,y)=>{this.stylesheetManager.attachLinkElement(f,y)}});p&&(t.push({parentId:u,nextId:d,node:p}),r.add(p.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const l of this.movedSet)Ta(this.removes,l,this.mirror)&&!this.movedSet.has(V.parentNode(l))||i(l);for(const l of this.addedSet)Da(this.droppedSet,l)||Ta(this.removes,l,this.mirror)?Da(this.movedSet,l)?i(l):this.droppedSet.add(l):i(l);let a=null;for(;n.length;){let l=null;if(a){const c=this.mirror.getId(V.parentNode(a.value)),u=s(a.value);c!==-1&&u!==-1&&(l=a)}if(!l){let c=n.tail;for(;c;){const u=c;if(c=c.previous,u){const d=this.mirror.getId(V.parentNode(u.value));if(s(u.value)===-1)continue;if(d!==-1){l=u;break}{const p=u.value,f=V.parentNode(p);if(f&&f.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const y=V.host(f);if(this.mirror.getId(y)!==-1){l=u;break}}}}}}if(!l){for(;n.head;)n.removeNode(n.head.value);break}a=l.previous,n.removeNode(l.value),i(l.value)}const o={texts:this.texts.map(l=>{const c=l.node,u=V.parentNode(c);return u&&u.tagName==="TEXTAREA"&&this.genTextAreaValueMutation(u),{id:this.mirror.getId(c),value:l.value}}).filter(l=>!r.has(l.id)).filter(l=>this.mirror.has(l.id)),attributes:this.attributes.map(l=>{const{attributes:c}=l;if(typeof c.style=="string"){const u=JSON.stringify(l.styleDiff),d=JSON.stringify(l._unchangedStyles);u.length<c.style.length&&(u+d).split("var(").length===c.style.split("var(").length&&(c.style=l.styleDiff)}return{id:this.mirror.getId(l.node),attributes:c}}).filter(l=>!r.has(l.id)).filter(l=>this.mirror.has(l.id)),removes:this.removes,adds:t};(o.texts.length||o.attributes.length||o.removes.length||o.adds.length)&&(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(o))}),R(this,"genTextAreaValueMutation",t=>{let r=this.attributeMap.get(t);r||(r={node:t,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(r),this.attributeMap.set(t,r)),r.attributes.value=Array.from(V.childNodes(t),n=>V.textContent(n)||"").join("")}),R(this,"processMutation",t=>{if(!ps(t.target,this.mirror,this.slimDOMOptions))switch(t.type){case"characterData":{const r=V.textContent(t.target);ve(t.target,this.blockClass,this.blockSelector,!1)||r===t.oldValue||this.texts.push({value:Al(t.target,this.maskTextClass,this.maskTextSelector,!0)&&r?this.maskTextFn?this.maskTextFn(r,jc(t.target)):r.replace(/[\S]/g,"*"):r,node:t.target});break}case"attributes":{const r=t.target;let n=t.attributeName,s=t.target.getAttribute(n);if(n==="value"){const a=Di(r);s=Ti({element:r,maskInputOptions:this.maskInputOptions,tagName:r.tagName,type:a,value:s,maskInputFn:this.maskInputFn})}if(ve(t.target,this.blockClass,this.blockSelector,!1)||s===t.oldValue)return;let i=this.attributeMap.get(t.target);if(r.tagName==="IFRAME"&&n==="src"&&!this.keepIframeSrcFn(s)){if(r.contentDocument)return;n="rr_src"}if(i||(i={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(i),this.attributeMap.set(t.target,i)),n==="type"&&r.tagName==="INPUT"&&(t.oldValue||"").toLowerCase()==="password"&&r.setAttribute("data-rr-is-password","true"),!Ol(r.tagName,n))if(i.attributes[n]=Ll(this.doc,ht(r.tagName),ht(n),s),n==="style"){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch{this.unattachedDoc=this.doc}const a=this.unattachedDoc.createElement("span");t.oldValue&&a.setAttribute("style",t.oldValue);for(const o of Array.from(r.style)){const l=r.style.getPropertyValue(o),c=r.style.getPropertyPriority(o);l!==a.style.getPropertyValue(o)||c!==a.style.getPropertyPriority(o)?i.styleDiff[o]=c===""?l:[l,c]:i._unchangedStyles[o]=[l,c]}for(const o of Array.from(a.style))r.style.getPropertyValue(o)===""&&(i.styleDiff[o]=!1)}else n==="open"&&r.tagName==="DIALOG"&&(r.matches("dialog:modal")?i.attributes.rr_open_mode="modal":i.attributes.rr_open_mode="non-modal");break}case"childList":if(ve(t.target,this.blockClass,this.blockSelector,!0))return;if(t.target.tagName==="TEXTAREA")return void this.genTextAreaValueMutation(t.target);t.addedNodes.forEach(r=>this.genAdds(r,t.target)),t.removedNodes.forEach(r=>{const n=this.mirror.getId(r),s=Jt(t.target)?this.mirror.getId(V.host(t.target)):this.mirror.getId(t.target);ve(t.target,this.blockClass,this.blockSelector,!1)||ps(r,this.mirror,this.slimDOMOptions)||!function(i,a){return a.getId(i)!==-1}(r,this.mirror)||(this.addedSet.has(r)?(li(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&n===-1||Wc(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[Ua(n,s)]?li(this.movedSet,r):this.removes.push({parentId:s,id:n,isShadow:!(!Jt(t.target)||!Xt(t.target))||void 0})),this.mapRemoves.push(r))})}}),R(this,"genAdds",(t,r)=>{if(!this.processedNodeManager.inOtherBuffer(t,this)&&!this.addedSet.has(t)&&!this.movedSet.has(t)){if(this.mirror.hasNode(t)){if(ps(t,this.mirror,this.slimDOMOptions))return;this.movedSet.add(t);let n=null;r&&this.mirror.hasNode(r)&&(n=this.mirror.getId(r)),n&&n!==-1&&(this.movedMap[Ua(this.mirror.getId(t),n)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);ve(t,this.blockClass,this.blockSelector,!1)||(V.childNodes(t).forEach(n=>this.genAdds(n)),ai(t)&&V.childNodes(V.shadowRoot(t)).forEach(n=>{this.processedNodeManager.add(n,this),this.genAdds(n,t)}))}})}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(r=>{this[r]=t[r]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function li(e,t){e.delete(t),V.childNodes(t).forEach(r=>li(e,r))}function Ta(e,t,r){return e.length!==0&&function(n,s,i){let a=V.parentNode(s);for(;a;){const o=i.getId(a);if(n.some(l=>l.id===o))return!0;a=V.parentNode(a)}return!1}(e,t,r)}function Da(e,t){return e.size!==0&&$c(e,t)}function $c(e,t){const r=V.parentNode(t);return!!r&&(!!e.has(r)||$c(e,r))}let Kt;const H=e=>Kt?(...t)=>{try{return e(...t)}catch(r){if(Kt&&Kt(r)===!0)return;throw r}}:e,pt=[];function Zt(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch{}return e&&e.target}function qc(e,t){const r=new Cf;pt.push(r),r.init(e);const n=new(Nc())(H(r.processMutations.bind(r)));return n.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),n}function kf({mouseInteractionCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,sampling:i}){if(i.mouseInteraction===!1)return()=>{};const a=i.mouseInteraction===!0||i.mouseInteraction===void 0?{}:i.mouseInteraction,o=[];let l=null;return Object.keys(be).filter(c=>Number.isNaN(Number(c))&&!c.endsWith("_Departed")&&a[c]!==!1).forEach(c=>{let u=ht(c);const d=(p=>f=>{const y=Zt(f);if(ve(y,n,s,!0))return;let h=null,k=p;if("pointerType"in f){switch(f.pointerType){case"mouse":h=Ye.Mouse;break;case"touch":h=Ye.Touch;break;case"pen":h=Ye.Pen}h===Ye.Touch?be[p]===be.MouseDown?k="TouchStart":be[p]===be.MouseUp&&(k="TouchEnd"):Ye.Pen}else oi(f)&&(h=Ye.Touch);h!==null?(l=h,(k.startsWith("Touch")&&h===Ye.Touch||k.startsWith("Mouse")&&h===Ye.Mouse)&&(h=null)):be[p]===be.Click&&(h=l,l=null);const m=oi(f)?f.changedTouches[0]:f;if(!m)return;const g=r.getId(y),{clientX:v,clientY:I}=m;H(e)({type:be[k],id:g,x:v,y:I,...h!==null&&{pointerType:h}})})(c);if(window.PointerEvent)switch(be[c]){case be.MouseDown:case be.MouseUp:u=u.replace("mouse","pointer");break;case be.TouchStart:case be.TouchEnd:return}o.push(ye(u,d,t))}),H(()=>{o.forEach(c=>c())})}function Jc({scrollCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,sampling:i}){return ye("scroll",H(Gt(H(a=>{const o=Zt(a);if(!o||ve(o,n,s,!0))return;const l=r.getId(o);if(o===t&&t.defaultView){const c=Fc(t.defaultView);e({id:l,x:c.left,y:c.top})}else e({id:l,x:o.scrollLeft,y:o.scrollTop})}),i.scroll||100)),t)}const Ef=["INPUT","TEXTAREA","SELECT"],Pa=new WeakMap;function jr(e){return function(t,r){if(Wr("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||Wr("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||Wr("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||Wr("CSSConditionRule")&&t.parentRule instanceof CSSConditionRule){const n=Array.from(t.parentRule.cssRules).indexOf(t);r.unshift(n)}else if(t.parentStyleSheet){const n=Array.from(t.parentStyleSheet.cssRules).indexOf(t);r.unshift(n)}return r}(e,[])}function tt(e,t,r){let n,s;return e?(e.ownerNode?n=t.getId(e.ownerNode):s=r.getId(e),{styleId:s,id:n}):{}}function Xc({mirror:e,stylesheetManager:t},r){var n,s,i;let a=null;a=r.nodeName==="#document"?e.getId(r):e.getId(V.host(r));const o=r.nodeName==="#document"?(n=r.defaultView)==null?void 0:n.Document:(i=(s=r.ownerDocument)==null?void 0:s.defaultView)==null?void 0:i.ShadowRoot,l=o!=null&&o.prototype?Object.getOwnPropertyDescriptor(o==null?void 0:o.prototype,"adoptedStyleSheets"):void 0;return a!==null&&a!==-1&&o&&l?(Object.defineProperty(r,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var c;return(c=l.get)==null?void 0:c.call(this)},set(c){var u;const d=(u=l.set)==null?void 0:u.call(this,c);if(a!==null&&a!==-1)try{t.adoptStyleSheets(c,a)}catch{}return d}}),H(()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})})):()=>{}}function xf(e,t={}){const r=e.doc.defaultView;if(!r)return()=>{};let n;(function(m,g){const{mutationCb:v,mousemoveCb:I,mouseInteractionCb:M,scrollCb:x,viewportResizeCb:U,inputCb:A,mediaInteractionCb:E,styleSheetRuleCb:L,styleDeclarationCb:O,canvasMutationCb:S,fontCb:N,selectionCb:P,customElementCb:b}=m;m.mutationCb=(...w)=>{g.mutation&&g.mutation(...w),v(...w)},m.mousemoveCb=(...w)=>{g.mousemove&&g.mousemove(...w),I(...w)},m.mouseInteractionCb=(...w)=>{g.mouseInteraction&&g.mouseInteraction(...w),M(...w)},m.scrollCb=(...w)=>{g.scroll&&g.scroll(...w),x(...w)},m.viewportResizeCb=(...w)=>{g.viewportResize&&g.viewportResize(...w),U(...w)},m.inputCb=(...w)=>{g.input&&g.input(...w),A(...w)},m.mediaInteractionCb=(...w)=>{g.mediaInteaction&&g.mediaInteaction(...w),E(...w)},m.styleSheetRuleCb=(...w)=>{g.styleSheetRule&&g.styleSheetRule(...w),L(...w)},m.styleDeclarationCb=(...w)=>{g.styleDeclaration&&g.styleDeclaration(...w),O(...w)},m.canvasMutationCb=(...w)=>{g.canvasMutation&&g.canvasMutation(...w),S(...w)},m.fontCb=(...w)=>{g.font&&g.font(...w),N(...w)},m.selectionCb=(...w)=>{g.selection&&g.selection(...w),P(...w)},m.customElementCb=(...w)=>{g.customElement&&g.customElement(...w),b(...w)}})(e,t),e.recordDOM&&(n=qc(e,e.doc));const s=function({mousemoveCb:m,sampling:g,doc:v,mirror:I}){if(g.mousemove===!1)return()=>{};const M=typeof g.mousemove=="number"?g.mousemove:50,x=typeof g.mousemoveCallback=="number"?g.mousemoveCallback:500;let U,A=[];const E=Gt(H(S=>{const N=Date.now()-U;m(A.map(P=>(P.timeOffset-=N,P)),S),A=[],U=null}),x),L=H(Gt(H(S=>{const N=Zt(S),{clientX:P,clientY:b}=oi(S)?S.changedTouches[0]:S;U||(U=vn()),A.push({x:P,y:b,id:I.getId(N),timeOffset:vn()-U}),E(typeof DragEvent<"u"&&S instanceof DragEvent?G.Drag:S instanceof MouseEvent?G.MouseMove:G.TouchMove)}),M,{trailing:!1})),O=[ye("mousemove",L,v),ye("touchmove",L,v),ye("drag",L,v)];return H(()=>{O.forEach(S=>S())})}(e),i=kf(e),a=Jc(e),o=function({viewportResizeCb:m},{win:g}){let v=-1,I=-1;return ye("resize",H(Gt(H(()=>{const M=Bc(),x=zc();v===M&&I===x||(m({width:Number(x),height:Number(M)}),v=M,I=x)}),200)),g)}(e,{win:r}),l=function({inputCb:m,doc:g,mirror:v,blockClass:I,blockSelector:M,ignoreClass:x,ignoreSelector:U,maskInputOptions:A,maskInputFn:E,sampling:L,userTriggeredOnInput:O}){function S(B){let j=Zt(B);const C=B.isTrusted,D=j&&j.tagName;if(j&&D==="OPTION"&&(j=V.parentElement(j)),!j||!D||Ef.indexOf(D)<0||ve(j,I,M,!0)||j.classList.contains(x)||U&&j.matches(U))return;let K=j.value,$=!1;const he=Di(j)||"";he==="radio"||he==="checkbox"?$=j.checked:(A[D.toLowerCase()]||A[he])&&(K=Ti({element:j,maskInputOptions:A,tagName:D,type:he,value:K,maskInputFn:E})),N(j,O?{text:K,isChecked:$,userTriggered:C}:{text:K,isChecked:$});const ct=j.name;he==="radio"&&ct&&$&&g.querySelectorAll(`input[type="radio"][name="${ct}"]`).forEach(Se=>{if(Se!==j){const _e=Se.value;N(Se,O?{text:_e,isChecked:!$,userTriggered:!1}:{text:_e,isChecked:!$})}})}function N(B,j){const C=Pa.get(B);if(!C||C.text!==j.text||C.isChecked!==j.isChecked){Pa.set(B,j);const D=v.getId(B);H(m)({...j,id:D})}}const P=(L.input==="last"?["change"]:["input","change"]).map(B=>ye(B,H(S),g)),b=g.defaultView;if(!b)return()=>{P.forEach(B=>B())};const w=b.Object.getOwnPropertyDescriptor(b.HTMLInputElement.prototype,"value"),T=[[b.HTMLInputElement.prototype,"value"],[b.HTMLInputElement.prototype,"checked"],[b.HTMLSelectElement.prototype,"value"],[b.HTMLTextAreaElement.prototype,"value"],[b.HTMLSelectElement.prototype,"selectedIndex"],[b.HTMLOptionElement.prototype,"selected"]];return w&&w.set&&P.push(...T.map(B=>Yn(B[0],B[1],{set(){H(S)({target:this,isTrusted:!1})}},!1,b))),H(()=>{P.forEach(B=>B())})}(e),c=function({mediaInteractionCb:m,blockClass:g,blockSelector:v,mirror:I,sampling:M,doc:x}){const U=H(E=>Gt(H(L=>{const O=Zt(L);if(!O||ve(O,g,v,!0))return;const{currentTime:S,volume:N,muted:P,playbackRate:b,loop:w}=O;m({type:E,id:I.getId(O),currentTime:S,volume:N,muted:P,playbackRate:b,loop:w})}),M.media||500)),A=[ye("play",U(Ct.Play),x),ye("pause",U(Ct.Pause),x),ye("seeked",U(Ct.Seeked),x),ye("volumechange",U(Ct.VolumeChange),x),ye("ratechange",U(Ct.RateChange),x)];return H(()=>{A.forEach(E=>E())})}(e);let u=()=>{},d=()=>{},p=()=>{},f=()=>{};e.recordDOM&&(u=function({styleSheetRuleCb:m,mirror:g,stylesheetManager:v},{win:I}){if(!I.CSSStyleSheet||!I.CSSStyleSheet.prototype)return()=>{};const M=I.CSSStyleSheet.prototype.insertRule;I.CSSStyleSheet.prototype.insertRule=new Proxy(M,{apply:H((O,S,N)=>{const[P,b]=N,{id:w,styleId:T}=tt(S,g,v.styleMirror);return(w&&w!==-1||T&&T!==-1)&&m({id:w,styleId:T,adds:[{rule:P,index:b}]}),O.apply(S,N)})}),I.CSSStyleSheet.prototype.addRule=function(O,S,N=this.cssRules.length){const P=`${O} { ${S} }`;return I.CSSStyleSheet.prototype.insertRule.apply(this,[P,N])};const x=I.CSSStyleSheet.prototype.deleteRule;let U,A;I.CSSStyleSheet.prototype.deleteRule=new Proxy(x,{apply:H((O,S,N)=>{const[P]=N,{id:b,styleId:w}=tt(S,g,v.styleMirror);return(b&&b!==-1||w&&w!==-1)&&m({id:b,styleId:w,removes:[{index:P}]}),O.apply(S,N)})}),I.CSSStyleSheet.prototype.removeRule=function(O){return I.CSSStyleSheet.prototype.deleteRule.apply(this,[O])},I.CSSStyleSheet.prototype.replace&&(U=I.CSSStyleSheet.prototype.replace,I.CSSStyleSheet.prototype.replace=new Proxy(U,{apply:H((O,S,N)=>{const[P]=N,{id:b,styleId:w}=tt(S,g,v.styleMirror);return(b&&b!==-1||w&&w!==-1)&&m({id:b,styleId:w,replace:P}),O.apply(S,N)})})),I.CSSStyleSheet.prototype.replaceSync&&(A=I.CSSStyleSheet.prototype.replaceSync,I.CSSStyleSheet.prototype.replaceSync=new Proxy(A,{apply:H((O,S,N)=>{const[P]=N,{id:b,styleId:w}=tt(S,g,v.styleMirror);return(b&&b!==-1||w&&w!==-1)&&m({id:b,styleId:w,replaceSync:P}),O.apply(S,N)})}));const E={};Vr("CSSGroupingRule")?E.CSSGroupingRule=I.CSSGroupingRule:(Vr("CSSMediaRule")&&(E.CSSMediaRule=I.CSSMediaRule),Vr("CSSConditionRule")&&(E.CSSConditionRule=I.CSSConditionRule),Vr("CSSSupportsRule")&&(E.CSSSupportsRule=I.CSSSupportsRule));const L={};return Object.entries(E).forEach(([O,S])=>{L[O]={insertRule:S.prototype.insertRule,deleteRule:S.prototype.deleteRule},S.prototype.insertRule=new Proxy(L[O].insertRule,{apply:H((N,P,b)=>{const[w,T]=b,{id:B,styleId:j}=tt(P.parentStyleSheet,g,v.styleMirror);return(B&&B!==-1||j&&j!==-1)&&m({id:B,styleId:j,adds:[{rule:w,index:[...jr(P),T||0]}]}),N.apply(P,b)})}),S.prototype.deleteRule=new Proxy(L[O].deleteRule,{apply:H((N,P,b)=>{const[w]=b,{id:T,styleId:B}=tt(P.parentStyleSheet,g,v.styleMirror);return(T&&T!==-1||B&&B!==-1)&&m({id:T,styleId:B,removes:[{index:[...jr(P),w]}]}),N.apply(P,b)})})}),H(()=>{I.CSSStyleSheet.prototype.insertRule=M,I.CSSStyleSheet.prototype.deleteRule=x,U&&(I.CSSStyleSheet.prototype.replace=U),A&&(I.CSSStyleSheet.prototype.replaceSync=A),Object.entries(E).forEach(([O,S])=>{S.prototype.insertRule=L[O].insertRule,S.prototype.deleteRule=L[O].deleteRule})})}(e,{win:r}),d=Xc(e,e.doc),p=function({styleDeclarationCb:m,mirror:g,ignoreCSSAttributes:v,stylesheetManager:I},{win:M}){const x=M.CSSStyleDeclaration.prototype.setProperty;M.CSSStyleDeclaration.prototype.setProperty=new Proxy(x,{apply:H((A,E,L)=>{var O;const[S,N,P]=L;if(v.has(S))return x.apply(E,[S,N,P]);const{id:b,styleId:w}=tt((O=E.parentRule)==null?void 0:O.parentStyleSheet,g,I.styleMirror);return(b&&b!==-1||w&&w!==-1)&&m({id:b,styleId:w,set:{property:S,value:N,priority:P},index:jr(E.parentRule)}),A.apply(E,L)})});const U=M.CSSStyleDeclaration.prototype.removeProperty;return M.CSSStyleDeclaration.prototype.removeProperty=new Proxy(U,{apply:H((A,E,L)=>{var O;const[S]=L;if(v.has(S))return U.apply(E,[S]);const{id:N,styleId:P}=tt((O=E.parentRule)==null?void 0:O.parentStyleSheet,g,I.styleMirror);return(N&&N!==-1||P&&P!==-1)&&m({id:N,styleId:P,remove:{property:S},index:jr(E.parentRule)}),A.apply(E,L)})}),H(()=>{M.CSSStyleDeclaration.prototype.setProperty=x,M.CSSStyleDeclaration.prototype.removeProperty=U})}(e,{win:r}),e.collectFonts&&(f=function({fontCb:m,doc:g}){const v=g.defaultView;if(!v)return()=>{};const I=[],M=new WeakMap,x=v.FontFace;v.FontFace=function(A,E,L){const O=new x(A,E,L);return M.set(O,{family:A,buffer:typeof E!="string",descriptors:L,fontSource:typeof E=="string"?E:JSON.stringify(Array.from(new Uint8Array(E)))}),O};const U=At(g.fonts,"add",function(A){return function(E){return setTimeout(H(()=>{const L=M.get(E);L&&(m(L),M.delete(E))}),0),A.apply(this,[E])}});return I.push(()=>{v.FontFace=x}),I.push(U),H(()=>{I.forEach(A=>A())})}(e)));const y=function(m){const{doc:g,mirror:v,blockClass:I,blockSelector:M,selectionCb:x}=m;let U=!0;const A=H(()=>{const E=g.getSelection();if(!E||U&&(E!=null&&E.isCollapsed))return;U=E.isCollapsed||!1;const L=[],O=E.rangeCount||0;for(let S=0;S<O;S++){const N=E.getRangeAt(S),{startContainer:P,startOffset:b,endContainer:w,endOffset:T}=N;ve(P,I,M,!0)||ve(w,I,M,!0)||L.push({start:v.getId(P),startOffset:b,end:v.getId(w),endOffset:T})}x({ranges:L})});return A(),ye("selectionchange",A)}(e),h=function({doc:m,customElementCb:g}){const v=m.defaultView;return v&&v.customElements?At(v.customElements,"define",function(I){return function(M,x,U){try{g({define:{name:M}})}catch{console.warn(`Custom element callback failed for ${M}`)}return I.apply(this,[M,x,U])}}):()=>{}}(e),k=[];for(const m of e.plugins)k.push(m.observer(m.callback,r,m.options));return H(()=>{pt.forEach(m=>m.reset()),n==null||n.disconnect(),s(),i(),a(),o(),l(),c(),u(),d(),p(),f(),y(),h(),k.forEach(m=>m())})}function Wr(e){return window[e]!==void 0}function Vr(e){return!!(window[e]!==void 0&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}class _a{constructor(t){R(this,"iframeIdToRemoteIdMap",new WeakMap),R(this,"iframeRemoteIdToIdMap",new WeakMap),this.generateIdFn=t}getId(t,r,n,s){const i=n||this.getIdToRemoteIdMap(t),a=s||this.getRemoteIdToIdMap(t);let o=i.get(r);return o||(o=this.generateIdFn(),i.set(r,o),a.set(o,r)),o}getIds(t,r){const n=this.getIdToRemoteIdMap(t),s=this.getRemoteIdToIdMap(t);return r.map(i=>this.getId(t,i,n,s))}getRemoteId(t,r,n){const s=n||this.getRemoteIdToIdMap(t);return typeof r!="number"?r:s.get(r)||-1}getRemoteIds(t,r){const n=this.getRemoteIdToIdMap(t);return r.map(s=>this.getRemoteId(t,s,n))}reset(t){if(!t)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let r=this.iframeIdToRemoteIdMap.get(t);return r||(r=new Map,this.iframeIdToRemoteIdMap.set(t,r)),r}getRemoteIdToIdMap(t){let r=this.iframeRemoteIdToIdMap.get(t);return r||(r=new Map,this.iframeRemoteIdToIdMap.set(t,r)),r}}class Rf{constructor(t){R(this,"iframes",new WeakMap),R(this,"crossOriginIframeMap",new WeakMap),R(this,"crossOriginIframeMirror",new _a(Rl)),R(this,"crossOriginIframeStyleMirror"),R(this,"crossOriginIframeRootIdMap",new WeakMap),R(this,"mirror"),R(this,"mutationCb"),R(this,"wrappedEmit"),R(this,"loadListener"),R(this,"stylesheetManager"),R(this,"recordCrossOriginIframes"),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new _a(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,r){var n,s;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:r}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&((n=t.contentWindow)==null||n.addEventListener("message",this.handleMessage.bind(this))),(s=this.loadListener)==null||s.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){const r=t;if(r.data.type!=="rrweb"||r.origin!==r.data.origin||!t.source)return;const n=this.crossOriginIframeMap.get(t.source);if(!n)return;const s=this.transformCrossOriginEvent(n,r.data.event);s&&this.wrappedEmit(s,r.data.isCheckout)}transformCrossOriginEvent(t,r){var n;switch(r.type){case Y.FullSnapshot:{this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(r.data.node,t);const s=r.data.node.id;return this.crossOriginIframeRootIdMap.set(t,s),this.patchRootIdOnNode(r.data.node,s),{timestamp:r.timestamp,type:Y.IncrementalSnapshot,data:{source:G.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:r.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case Y.Meta:case Y.Load:case Y.DomContentLoaded:return!1;case Y.Plugin:return r;case Y.Custom:return this.replaceIds(r.data.payload,t,["id","parentId","previousId","nextId"]),r;case Y.IncrementalSnapshot:switch(r.data.source){case G.Mutation:return r.data.adds.forEach(s=>{this.replaceIds(s,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(s.node,t);const i=this.crossOriginIframeRootIdMap.get(t);i&&this.patchRootIdOnNode(s.node,i)}),r.data.removes.forEach(s=>{this.replaceIds(s,t,["parentId","id"])}),r.data.attributes.forEach(s=>{this.replaceIds(s,t,["id"])}),r.data.texts.forEach(s=>{this.replaceIds(s,t,["id"])}),r;case G.Drag:case G.TouchMove:case G.MouseMove:return r.data.positions.forEach(s=>{this.replaceIds(s,t,["id"])}),r;case G.ViewportResize:return!1;case G.MediaInteraction:case G.MouseInteraction:case G.Scroll:case G.CanvasMutation:case G.Input:return this.replaceIds(r.data,t,["id"]),r;case G.StyleSheetRule:case G.StyleDeclaration:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleId"]),r;case G.Font:return r;case G.Selection:return r.data.ranges.forEach(s=>{this.replaceIds(s,t,["start","end"])}),r;case G.AdoptedStyleSheet:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleIds"]),(n=r.data.styles)==null||n.forEach(s=>{this.replaceStyleIds(s,t,["styleId"])}),r}}return!1}replace(t,r,n,s){for(const i of s)(Array.isArray(r[i])||typeof r[i]=="number")&&(Array.isArray(r[i])?r[i]=t.getIds(n,r[i]):r[i]=t.getId(n,r[i]));return r}replaceIds(t,r,n){return this.replace(this.crossOriginIframeMirror,t,r,n)}replaceStyleIds(t,r,n){return this.replace(this.crossOriginIframeStyleMirror,t,r,n)}replaceIdOnNode(t,r){this.replaceIds(t,r,["id","rootId"]),"childNodes"in t&&t.childNodes.forEach(n=>{this.replaceIdOnNode(n,r)})}patchRootIdOnNode(t,r){t.type===me.Document||t.rootId||(t.rootId=r),"childNodes"in t&&t.childNodes.forEach(n=>{this.patchRootIdOnNode(n,r)})}}class Lf{constructor(t){R(this,"shadowDoms",new WeakSet),R(this,"mutationCb"),R(this,"scrollCb"),R(this,"bypassOptions"),R(this,"mirror"),R(this,"restoreHandlers",[]),this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(t,r){if(!Xt(t)||this.shadowDoms.has(t))return;this.shadowDoms.add(t);const n=qc({...this.bypassOptions,doc:r,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},t);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(Jc({...this.bypassOptions,scrollCb:this.scrollCb,doc:t,mirror:this.mirror})),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(V.host(t))),this.restoreHandlers.push(Xc({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t))},0)}observeAttachShadow(t){t.contentWindow&&t.contentDocument&&this.patchAttachShadow(t.contentWindow.Element,t.contentDocument)}patchAttachShadow(t,r){const n=this;this.restoreHandlers.push(At(t.prototype,"attachShadow",function(s){return function(i){const a=s.call(this,i),o=V.shadowRoot(this);return o&&Yc(this)&&n.addShadowRoot(o,r),a}}))}reset(){this.restoreHandlers.forEach(t=>{try{t()}catch{}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}for(var Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Of=typeof Uint8Array>"u"?[]:new Uint8Array(256),Gr=0;Gr<64;Gr++)Of[Ht.charCodeAt(Gr)]=Gr;const Na=new Map,Kc=(e,t,r)=>{if(!e||!Qc(e,t)&&typeof e!="object")return;const n=function(i,a){let o=Na.get(i);return o||(o=new Map,Na.set(i,o)),o.has(a)||o.set(a,[]),o.get(a)}(r,e.constructor.name);let s=n.indexOf(e);return s===-1&&(s=n.length,n.push(e)),s};function ln(e,t,r){if(e instanceof Array)return e.map(n=>ln(n,t,r));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:function(n){var s,i=new Uint8Array(n),a=i.length,o="";for(s=0;s<a;s+=3)o+=Ht[i[s]>>2],o+=Ht[(3&i[s])<<4|i[s+1]>>4],o+=Ht[(15&i[s+1])<<2|i[s+2]>>6],o+=Ht[63&i[s+2]];return a%3==2?o=o.substring(0,o.length-1)+"=":a%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[ln(e.buffer,t,r),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const n=e.constructor.name,{src:s}=e;return{rr_type:n,src:s}}return e instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:e.toDataURL()}:e instanceof ImageData?{rr_type:e.constructor.name,args:[ln(e.data,t,r),e.width,e.height]}:Qc(e,t)||typeof e=="object"?{rr_type:e.constructor.name,index:Kc(e,t,r)}:e}const Zc=(e,t,r)=>e.map(n=>ln(n,t,r)),Qc=(e,t)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(n=>typeof t[n]=="function").find(n=>e instanceof t[n]);function Fa(e,t,r,n){const s=[];try{const i=At(e.HTMLCanvasElement.prototype,"getContext",function(a){return function(o,...l){if(!ve(this,t,r,!0)){const c=function(u){return u==="experimental-webgl"?"webgl":u}(o);if("__context"in this||(this.__context=c),n&&["webgl","webgl2"].includes(c))if(l[0]&&typeof l[0]=="object"){const u=l[0];u.preserveDrawingBuffer||(u.preserveDrawingBuffer=!0)}else l.splice(0,1,{preserveDrawingBuffer:!0})}return a.apply(this,[o,...l])}});s.push(i)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{s.forEach(i=>i())}}function Ba(e,t,r,n,s,i){const a=[],o=Object.getOwnPropertyNames(e);for(const l of o)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(l))try{if(typeof e[l]!="function")continue;const c=At(e,l,function(u){return function(...d){const p=u.apply(this,d);if(Kc(p,i,this),"tagName"in this.canvas&&!ve(this.canvas,n,s,!0)){const f=Zc(d,i,this),y={type:t,property:l,args:f};r(this.canvas,y)}return p}});a.push(c)}catch{const c=Yn(e,l,{set(u){r(this.canvas,{type:t,property:l,args:[u],setter:!0})}});a.push(c)}return a}const eu="KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=",za=typeof window<"u"&&window.Blob&&new Blob([(ja=eu,Uint8Array.from(atob(ja),e=>e.charCodeAt(0)))],{type:"text/javascript;charset=utf-8"});var ja;function Af(e){let t;try{if(t=za&&(window.URL||window.webkitURL).createObjectURL(za),!t)throw"";const r=new Worker(t,{name:e==null?void 0:e.name});return r.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;base64,"+eu,{name:e==null?void 0:e.name})}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}class Mf{constructor(t){R(this,"pendingCanvasMutations",new Map),R(this,"rafStamps",{latestId:0,invokeId:null}),R(this,"mirror"),R(this,"mutationCb"),R(this,"resetObservers"),R(this,"frozen",!1),R(this,"locked",!1),R(this,"processMutation",(l,c)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(l)||this.pendingCanvasMutations.set(l,[]),this.pendingCanvasMutations.get(l).push(c)});const{sampling:r="all",win:n,blockClass:s,blockSelector:i,recordCanvas:a,dataURLOptions:o}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,a&&r==="all"&&this.initCanvasMutationObserver(n,s,i),a&&typeof r=="number"&&this.initCanvasFPSObserver(r,n,s,i,{dataURLOptions:o})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,r,n,s,i){const a=Fa(r,n,s,!0),o=new Map,l=new Af;l.onmessage=f=>{const{id:y}=f.data;if(o.set(y,!1),!("base64"in f.data))return;const{base64:h,type:k,width:m,height:g}=f.data;this.mutationCb({id:y,type:It["2D"],commands:[{property:"clearRect",args:[0,0,m,g]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:h}],type:k}]},0,0]}]})};const c=1e3/t;let u,d=0;const p=f=>{d&&f-d<c||(d=f,(()=>{const y=[];return r.document.querySelectorAll("canvas").forEach(h=>{ve(h,n,s,!0)||y.push(h)}),y})().forEach(async y=>{var h;const k=this.mirror.getId(y);if(o.get(k)||y.width===0||y.height===0)return;if(o.set(k,!0),["webgl","webgl2"].includes(y.__context)){const g=y.getContext(y.__context);((h=g==null?void 0:g.getContextAttributes())==null?void 0:h.preserveDrawingBuffer)===!1&&g.clear(g.COLOR_BUFFER_BIT)}const m=await createImageBitmap(y);l.postMessage({id:k,bitmap:m,width:y.width,height:y.height,dataURLOptions:i.dataURLOptions},[m])})),u=requestAnimationFrame(p)};u=requestAnimationFrame(p),this.resetObservers=()=>{a(),cancelAnimationFrame(u)}}initCanvasMutationObserver(t,r,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const s=Fa(t,r,n,!1),i=function(o,l,c,u){const d=[],p=Object.getOwnPropertyNames(l.CanvasRenderingContext2D.prototype);for(const f of p)try{if(typeof l.CanvasRenderingContext2D.prototype[f]!="function")continue;const y=At(l.CanvasRenderingContext2D.prototype,f,function(h){return function(...k){return ve(this.canvas,c,u,!0)||setTimeout(()=>{const m=Zc(k,l,this);o(this.canvas,{type:It["2D"],property:f,args:m})},0),h.apply(this,k)}});d.push(y)}catch{const y=Yn(l.CanvasRenderingContext2D.prototype,f,{set(h){o(this.canvas,{type:It["2D"],property:f,args:[h],setter:!0})}});d.push(y)}return()=>{d.forEach(f=>f())}}(this.processMutation.bind(this),t,r,n),a=function(o,l,c,u){const d=[];return d.push(...Ba(l.WebGLRenderingContext.prototype,It.WebGL,o,c,u,l)),l.WebGL2RenderingContext!==void 0&&d.push(...Ba(l.WebGL2RenderingContext.prototype,It.WebGL2,o,c,u,l)),()=>{d.forEach(p=>p())}}(this.processMutation.bind(this),t,r,n);this.resetObservers=()=>{s(),i(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{const n=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(t);if(!n||r===-1)return;const s=n.map(a=>{const{type:o,...l}=a;return l}),{type:i}=n[0];this.mutationCb({id:r,type:i,commands:s}),this.pendingCanvasMutations.delete(t)}}class Uf{constructor(t){R(this,"trackedLinkElements",new WeakSet),R(this,"mutationCb"),R(this,"adoptedStyleSheetCb"),R(this,"styleMirror",new bf),this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;const n={id:r,styleIds:[]},s=[];for(const i of t){let a;this.styleMirror.has(i)?a=this.styleMirror.getId(i):(a=this.styleMirror.add(i),s.push({styleId:a,rules:Array.from(i.rules||CSSRule,(o,l)=>({rule:El(o,i.href),index:l}))})),n.styleIds.push(a)}s.length>0&&(n.styles=s),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}class Tf{constructor(){R(this,"nodeMap",new WeakMap),R(this,"active",!1)}inOtherBuffer(t,r){const n=this.nodeMap.get(t);return n&&Array.from(n).some(s=>s!==r)}add(t,r){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(r))}destroy(){}}let le,cn,hs,bn=!1;try{if(Array.from([1],e=>2*e)[0]!==2){const e=document.createElement("iframe");document.body.appendChild(e),Array.from=((ko=e.contentWindow)==null?void 0:ko.Array.from)||Array.from,document.body.removeChild(e)}}catch(e){console.debug("Unable to override Array.from",e)}const Oe=new xl;function Yt(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:n,blockClass:s="rr-block",blockSelector:i=null,ignoreClass:a="rr-ignore",ignoreSelector:o=null,maskTextClass:l="rr-mask",maskTextSelector:c=null,inlineStylesheet:u=!0,maskAllInputs:d,maskInputOptions:p,slimDOMOptions:f,maskInputFn:y,maskTextFn:h,hooks:k,packFn:m,sampling:g={},dataURLOptions:v={},mousemoveWait:I,recordDOM:M=!0,recordCanvas:x=!1,recordCrossOriginIframes:U=!1,recordAfter:A=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:E=!1,collectFonts:L=!1,inlineImages:O=!1,plugins:S,keepIframeSrcFn:N=()=>!1,ignoreCSSAttributes:P=new Set([]),errorHandler:b}=e;Kt=b;const w=!U||window.parent===window;let T=!1;if(!w)try{window.parent.document&&(T=!1)}catch{T=!0}if(w&&!t)throw new Error("emit function is required");if(!w&&!T)return()=>{};I!==void 0&&g.mousemove===void 0&&(g.mousemove=I),Oe.reset();const B=d===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:p!==void 0?p:{password:!0},j=f===!0||f==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:f==="all",headMetaDescKeywords:f==="all",headTitleMutations:f==="all"}:f||{};let C;(function(W=window){"NodeList"in W&&!W.NodeList.prototype.forEach&&(W.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in W&&!W.DOMTokenList.prototype.forEach&&(W.DOMTokenList.prototype.forEach=Array.prototype.forEach)})();let D=0;const K=W=>{for(const Le of S||[])Le.eventProcessor&&(W=Le.eventProcessor(W));return m&&!T&&(W=m(W)),W};le=(W,Le)=>{var re;const ie=W;if(ie.timestamp=vn(),!((re=pt[0])!=null&&re.isFrozen())||ie.type===Y.FullSnapshot||ie.type===Y.IncrementalSnapshot&&ie.data.source===G.Mutation||pt.forEach(xe=>xe.unfreeze()),w)t==null||t(K(ie),Le);else if(T){const xe={type:"rrweb",event:K(ie),origin:window.location.origin,isCheckout:Le};window.parent.postMessage(xe,"*")}if(ie.type===Y.FullSnapshot)C=ie,D=0;else if(ie.type===Y.IncrementalSnapshot){if(ie.data.source===G.Mutation&&ie.data.isAttachIframe)return;D++;const xe=n&&D>=n,q=r&&ie.timestamp-C.timestamp>r;(xe||q)&&cn(!0)}};const $=W=>{le({type:Y.IncrementalSnapshot,data:{source:G.Mutation,...W}})},he=W=>le({type:Y.IncrementalSnapshot,data:{source:G.Scroll,...W}}),ct=W=>le({type:Y.IncrementalSnapshot,data:{source:G.CanvasMutation,...W}}),Se=new Uf({mutationCb:$,adoptedStyleSheetCb:W=>le({type:Y.IncrementalSnapshot,data:{source:G.AdoptedStyleSheet,...W}})}),_e=new Rf({mirror:Oe,mutationCb:$,stylesheetManager:Se,recordCrossOriginIframes:U,wrappedEmit:le});for(const W of S||[])W.getMirror&&W.getMirror({nodeMirror:Oe,crossOriginIframeMirror:_e.crossOriginIframeMirror,crossOriginIframeStyleMirror:_e.crossOriginIframeStyleMirror});const qn=new Tf;hs=new Mf({recordCanvas:x,mutationCb:ct,win:window,blockClass:s,blockSelector:i,mirror:Oe,sampling:g.canvas,dataURLOptions:v});const br=new Lf({mutationCb:$,scrollCb:he,bypassOptions:{blockClass:s,blockSelector:i,maskTextClass:l,maskTextSelector:c,inlineStylesheet:u,maskInputOptions:B,dataURLOptions:v,maskTextFn:h,maskInputFn:y,recordCanvas:x,inlineImages:O,sampling:g,slimDOMOptions:j,iframeManager:_e,stylesheetManager:Se,canvasManager:hs,keepIframeSrcFn:N,processedNodeManager:qn},mirror:Oe});cn=(W=!1)=>{if(!M)return;le({type:Y.Meta,data:{href:window.location.href,width:zc(),height:Bc()}},W),Se.reset(),br.init(),pt.forEach(re=>re.lock());const Le=function(re,ie){const{mirror:xe=new xl,blockClass:q="rr-block",blockSelector:Dt=null,maskTextClass:od="rr-mask",maskTextSelector:ad=null,inlineStylesheet:ld=!0,inlineImages:cd=!1,recordCanvas:ud=!1,maskAllInputs:Jn=!1,maskTextFn:dd,maskInputFn:pd,slimDOM:Pt=!1,dataURLOptions:hd,preserveWhiteSpace:md,onSerialize:fd,onIframeLoad:gd,iframeLoadTimeout:yd,onStylesheetLoad:wd,stylesheetLoadTimeout:vd,keepIframeSrcFn:bd=()=>!1}=ie||{};return kt(re,{doc:re,mirror:xe,blockClass:q,blockSelector:Dt,maskTextClass:od,maskTextSelector:ad,skipChild:!1,inlineStylesheet:ld,maskInputOptions:Jn===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:Jn===!1?{password:!0}:Jn,maskTextFn:dd,maskInputFn:pd,slimDOMOptions:Pt===!0||Pt==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:Pt==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:Pt===!1?{}:Pt,dataURLOptions:hd,inlineImages:cd,recordCanvas:ud,preserveWhiteSpace:md,onSerialize:fd,onIframeLoad:gd,iframeLoadTimeout:yd,onStylesheetLoad:wd,stylesheetLoadTimeout:vd,keepIframeSrcFn:bd,newlyAddedElement:!1})}(document,{mirror:Oe,blockClass:s,blockSelector:i,maskTextClass:l,maskTextSelector:c,inlineStylesheet:u,maskAllInputs:B,maskTextFn:h,maskInputFn:y,slimDOM:j,dataURLOptions:v,recordCanvas:x,inlineImages:O,onSerialize:re=>{Vc(re,Oe)&&_e.addIframe(re),Gc(re,Oe)&&Se.trackLinkElement(re),ai(re)&&br.addShadowRoot(V.shadowRoot(re),document)},onIframeLoad:(re,ie)=>{_e.attachIframe(re,ie),br.observeAttachShadow(re)},onStylesheetLoad:(re,ie)=>{Se.attachLinkElement(re,ie)},keepIframeSrcFn:N});if(!Le)return console.warn("Failed to snapshot the document");le({type:Y.FullSnapshot,data:{node:Le,initialOffset:Fc(window)}},W),pt.forEach(re=>re.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&Se.adoptStyleSheets(document.adoptedStyleSheets,Oe.getId(document))};try{const W=[],Le=ie=>{var xe;return H(xf)({mutationCb:$,mousemoveCb:(q,Dt)=>le({type:Y.IncrementalSnapshot,data:{source:Dt,positions:q}}),mouseInteractionCb:q=>le({type:Y.IncrementalSnapshot,data:{source:G.MouseInteraction,...q}}),scrollCb:he,viewportResizeCb:q=>le({type:Y.IncrementalSnapshot,data:{source:G.ViewportResize,...q}}),inputCb:q=>le({type:Y.IncrementalSnapshot,data:{source:G.Input,...q}}),mediaInteractionCb:q=>le({type:Y.IncrementalSnapshot,data:{source:G.MediaInteraction,...q}}),styleSheetRuleCb:q=>le({type:Y.IncrementalSnapshot,data:{source:G.StyleSheetRule,...q}}),styleDeclarationCb:q=>le({type:Y.IncrementalSnapshot,data:{source:G.StyleDeclaration,...q}}),canvasMutationCb:ct,fontCb:q=>le({type:Y.IncrementalSnapshot,data:{source:G.Font,...q}}),selectionCb:q=>{le({type:Y.IncrementalSnapshot,data:{source:G.Selection,...q}})},customElementCb:q=>{le({type:Y.IncrementalSnapshot,data:{source:G.CustomElement,...q}})},blockClass:s,ignoreClass:a,ignoreSelector:o,maskTextClass:l,maskTextSelector:c,maskInputOptions:B,inlineStylesheet:u,sampling:g,recordDOM:M,recordCanvas:x,inlineImages:O,userTriggeredOnInput:E,collectFonts:L,doc:ie,maskInputFn:y,maskTextFn:h,keepIframeSrcFn:N,blockSelector:i,slimDOMOptions:j,dataURLOptions:v,mirror:Oe,iframeManager:_e,stylesheetManager:Se,shadowDomManager:br,processedNodeManager:qn,canvasManager:hs,ignoreCSSAttributes:P,plugins:((xe=S==null?void 0:S.filter(q=>q.observer))==null?void 0:xe.map(q=>({observer:q.observer,options:q.options,callback:Dt=>le({type:Y.Plugin,data:{plugin:q.name,payload:Dt}})})))||[]},k)};_e.addLoadListener(ie=>{try{W.push(Le(ie.contentDocument))}catch(xe){console.warn(xe)}});const re=()=>{cn(),W.push(Le(document)),bn=!0};return document.readyState==="interactive"||document.readyState==="complete"?re():(W.push(ye("DOMContentLoaded",()=>{le({type:Y.DomContentLoaded,data:{}}),A==="DOMContentLoaded"&&re()})),W.push(ye("load",()=>{le({type:Y.Load,data:{}}),A==="load"&&re()},window))),()=>{W.forEach(ie=>ie()),qn.destroy(),bn=!1,Kt=void 0}}catch(W){console.warn(W)}}var Wa,bt;Yt.addCustomEvent=(e,t)=>{if(!bn)throw new Error("please add custom event after start recording");le({type:Y.Custom,data:{tag:e,payload:t}})},Yt.freezePage=()=>{pt.forEach(e=>e.freeze())},Yt.takeFullSnapshot=e=>{if(!bn)throw new Error("please take full snapshot after start recording");cn(e)},Yt.mirror=Oe,(bt=Wa||(Wa={}))[bt.NotStarted=0]="NotStarted",bt[bt.Running=1]="Running",bt[bt.Stopped=2]="Stopped";var Ae=(e=>(e.Closed="close.click",e.Complete="survey.completed",e.FeedbackClosed="feedback.closed",e.PageChange="page.change",e.API="api",e.Override="override",e))(Ae||{}),F=(e=>(e.ReplayCapture="replay.capture",e.ReplayPaused="replay.paused",e.ReplayResumed="replay.resumed",e.FeedbackButtonLoaded="feedback.button.loaded",e.SDKReady="sdk.ready",e.SurveyAppeared="survey.appeared",e.SurveyCloseRequested="survey.closeRequested",e.SurveyClosed="survey.closed",e.SurveyDimensions="survey.dimensions",e.SurveyFadingOut="survey.fadingOut",e.SurveyHeight="survey.height",e.SurveyPresented="survey.presented",e.SurveyLifeCycle="survey.lifeCycle",e.SurveyWidth="survey.width",e.SurveyWillClose="survey.willClose",e.SurveyWillPresent="survey.will.present",e.CloseSurveyOnOverlayClick="close.survey.overlayClick",e.VisitorIDUpdated="visitor.id.updated",e.QuestionAnswered="question.answered",e))(F||{});const dr={FEEDBACK_BUTTON_LOADED:"feedback.button.loaded",SDK_READY:"sdk.ready",SURVEY_APPEARED:"survey.appeared",SURVEY_CLOSED:"survey.closed",SURVEY_DIMENSIONS:"survey.dimensions",SURVEY_FADING_OUT:"survey.fadingOut",SURVEY_HEIGHT:"survey.height",SURVEY_WIDTH:"survey.width",SURVEY_PRESENTED:"survey.presented",SURVEY_LIFE_CYCLE:"survey.lifeCycle",SURVEY_WILL_CLOSE:"survey.willClose",SURVEY_WILL_PRESENT:"survey.will.present",QUESTION_ANSWERED:"question.answered",REPLAY_CAPTURE:"replay.capture",CLOSE_SURVEY_ON_OVERLAY_CLICK:"close.survey.overlayClick",VISITOR_ID_UPDATED:"visitor.id.updated",DATA:{DISMISS_REASONS:{API:"api",CLOSED:"close.click",COMPLETE:"survey.completed",PAGE_CHANGE:"page.change",OVERRIDE:"override"},SURVEY_ID:"survey.id"}};let Hr;const Df=new Uint8Array(16);function Pf(){if(!Hr&&(Hr=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Hr))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Hr(Df)}const fe=[];for(let e=0;e<256;++e)fe.push((e+256).toString(16).slice(1));const Va={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function yt(e,t,r){if(Va.randomUUID&&!e)return Va.randomUUID();const n=(e=e||{}).random||(e.rng||Pf)();return n[6]=15&n[6]|64,n[8]=63&n[8]|128,function(s,i=0){return fe[s[i+0]]+fe[s[i+1]]+fe[s[i+2]]+fe[s[i+3]]+"-"+fe[s[i+4]]+fe[s[i+5]]+"-"+fe[s[i+6]]+fe[s[i+7]]+"-"+fe[s[i+8]]+fe[s[i+9]]+"-"+fe[s[i+10]]+fe[s[i+11]]+fe[s[i+12]]+fe[s[i+13]]+fe[s[i+14]]+fe[s[i+15]]}(n)}const _=new class{constructor(){ue(this,"breadcrumbs",[])}getTimeStamp(){return new Date().toISOString()}addBreadcrumb(e){{const{data:t,message:r}=e,n=t&&Object.keys(t).length?t:null;n?console.info(r,n):console.info(r)}this.breadcrumbs.push(e),this.breadcrumbs.length>300&&this.breadcrumbs.shift()}debug(e,t="debug"){this.addBreadcrumb({category:t,level:"info",message:e,timestamp:this.getTimeStamp(),type:"debug"})}error(e,t={}){this.addBreadcrumb({category:"error",data:t,level:"error",message:e,timestamp:this.getTimeStamp(),type:"error"})}http(e,t){this.addBreadcrumb({category:"xhr",data:t,message:e,timestamp:this.getTimeStamp(),type:"http"})}info(e,t={}){this.addBreadcrumb({category:"info",data:t,level:"info",message:e,timestamp:this.getTimeStamp(),type:"info"})}navigation(e,t){this.addBreadcrumb({category:"navigation",data:t,message:e,timestamp:this.getTimeStamp(),type:"navigation"})}},Ga=()=>{try{return window.parent.Intercom}catch{return null}},Ha=[Object.freeze(Object.defineProperty({__proto__:null,disable:()=>{const e=Ga();e&&(e.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),e.ul_wasVisible&&e("update",{hide_default_launcher:!0}))},enable:()=>{const e=Ga();e&&(e.ul_wasVisible&&e("update",{hide_default_launcher:!1}),delete e.ul_wasVisible)}},Symbol.toStringTag,{value:"Module"}))];class tu{static disable(){Ha.forEach(t=>t.disable())}static enable(){Ha.forEach(t=>t.enable())}}var _f=class extends Error{constructor(e,t,r){super(`Possible EventEmitter memory leak detected. ${r} ${t.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=t,this.count=r,this.name="MaxListenersExceededWarning"}},ru=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=ru.defaultMaxListeners,this.hasWarnedAboutPotentialMemoryLeak=!1}_emitInternalEvent(e,t,r){this.emit(e,t,r)}_getListeners(e){return Array.prototype.concat.apply([],this.events.get(e))||[]}_removeListener(e,t){const r=e.indexOf(t);return r>-1&&e.splice(r,1),[]}_wrapOnceListener(e,t){const r=(...n)=>(this.removeListener(e,r),t.apply(this,n));return Object.defineProperty(r,"name",{value:t.name}),r}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}eventNames(){return Array.from(this.events.keys())}emit(e,...t){const r=this._getListeners(e);return r.forEach(n=>{n.apply(this,t)}),r.length>0}addListener(e,t){this._emitInternalEvent("newListener",e,t);const r=this._getListeners(e).concat(t);if(this.events.set(e,r),this.maxListeners>0&&this.listenerCount(e)>this.maxListeners&&!this.hasWarnedAboutPotentialMemoryLeak){this.hasWarnedAboutPotentialMemoryLeak=!0;const n=new _f(this,e,this.listenerCount(e));console.warn(n)}return this}on(e,t){return this.addListener(e,t)}once(e,t){return this.addListener(e,this._wrapOnceListener(e,t))}prependListener(e,t){const r=this._getListeners(e);if(r.length>0){const n=[t].concat(r);this.events.set(e,n)}else this.events.set(e,r.concat(t));return this}prependOnceListener(e,t){return this.prependListener(e,this._wrapOnceListener(e,t))}removeListener(e,t){const r=this._getListeners(e);return r.length>0&&(this._removeListener(r,t),this.events.set(e,r),this._emitInternalEvent("removeListener",e,t)),this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){return e?this.events.delete(e):this.events.clear(),this}listeners(e){return Array.from(this._getListeners(e))}listenerCount(e){return this._getListeners(e).length}rawListeners(e){return this.listeners(e)}},nu=ru;nu.defaultMaxListeners=10;const z=new nu,Sn=async e=>{await new Promise(t=>{setTimeout(t,e)})},eo=({"userleap-platform":e})=>{var t;return((t=window.UserLeap)==null?void 0:t.forceDirectEmbed)||e!=="web"};class su{constructor(t){ue(this,"storage");ue(this,"tempStorage",{});ue(this,"isStorageAvailable");try{this.storage=window[t];const r="__storage_test__";this.storage.setItem(r,r),this.storage.removeItem(r),this.isStorageAvailable=!0}catch{this.isStorageAvailable=!1}}setItem(t,r){this.isStorageAvailable&&this.storage?this.storage.setItem(t,r):this.tempStorage[t]=r}setItemObject(t,r){try{this.setItem(t,JSON.stringify(r))}catch(n){n instanceof Error&&(n.stack=t+": "+r,window.UserLeap.reportError("Failed to save to local storage",n))}}getItem(t){return this.isStorageAvailable&&this.storage?this.storage.getItem(t):this.tempStorage[t]}getItemObject(t){const r=this.getItem(t);if(r)try{return JSON.parse(r)}catch(n){n instanceof Error&&(n.stack=t+": "+r,window.UserLeap.reportError("Failed to parse local storage",n))}return{}}removeItem(t){this.isStorageAvailable&&this.storage?this.storage.removeItem(t):delete this.tempStorage[t]}clear(){this.isStorageAvailable&&this.storage?this.storage.clear():this.tempStorage={}}}const ce=new su("sessionStorage"),Ce=new su("localStorage");class Nf{constructor(t){ue(this,"payload");ue(this,"promise");ue(this,"reject",()=>{});ue(this,"resolve",()=>{});this.payload=t,this.promise=new Promise((r,n)=>{this.reject=n,this.resolve=r})}resolveRequest(t){this.resolve(t)}}const te={replay:null},Ff=()=>{const e=[];return te.replay&&e.push("replay"),e.join(",")},Bf=10;let iu=!1,ou="",Yr=!1,au=!1,un=[];const zf=e=>e._config&&e._config.installationMethod?e._config.installationMethod:e._gtm?"web-gtm":e._segment?"web-segment":"web-snippet",Ya=e=>{var t;(t=e==null?void 0:e.blockedURI)!=null&&t.includes(window.UserLeap._API_URL)&&(au=!0,console.warn(`[Sprig] ${e.blockedURI} is blocked by Content-Security-Policy`))},ci=(e="")=>{iu=!0,ou=e};function Te(e={}){const t={"Content-Type":"application/json","userleap-platform":"web","x-ul-sdk-version":"2.36.1","x-ul-installation-method":zf(e),"sprig-modules":Ff(),"x-ul-package-version":"2.36.1"};if(e.envId&&(t["x-ul-environment-id"]=e.envId),e.token&&(t.Authorization="Bearer "+e.token),e.userId&&(t["x-ul-user-id"]=e.userId),e.visitorId&&(t["x-ul-visitor-id"]=e.visitorId),e.partnerAnonymousId&&(t["x-ul-anonymous-id"]=e.partnerAnonymousId),e.mobileHeadersJSON){const r=JSON.parse(e.mobileHeadersJSON);Object.assign(t,r)}return e.locale&&(t["accept-language"]=e.locale),window.previewMode&&(t["x-ul-preview-mode"]="1"),t}const $a=async({shouldDropOnRateLimit:e,...t})=>{if(e)return{status:429};{const r=new Nf(t);return un.push(r),r.promise}},Ge=async(e,t)=>{const{retries:r=0,shouldDropOnRateLimit:n=!1,shouldRetryRequest:s=!1,...i}=t,a={url:e,options:i,retries:r,shouldDropOnRateLimit:n};if(Yr&&!s)return $a(a);const o={ok:!1,reportError:!1};if(iu)return console.info(`UserLeap - ${ou}`),o;try{const l=await fetch(e,i);if(l.status===429){if(!Yr&&!n||s){Yr=!0;const c=l.headers.has("ratelimit-reset")?Number(l.headers.get("ratelimit-reset")):Bf;return await Sn(1e3*c),Ge(e,{...i,shouldDropOnRateLimit:n,shouldRetryRequest:!0})}return $a(a)}if(Yr=!1,un.length&&(un.map(c=>{const u=c.payload;Ge(u.url,{...u.options,retries:u.retries,shouldDropOnRateLimit:u.shouldDropOnRateLimit}).then(d=>{c.resolveRequest(d)})}),un=[]),l.ok){if(l.status===249)return ci(),o;const c=await l.text();try{return c&&c!=="OK"&&(l.json=JSON.parse(c)),l}catch{return{ok:!1,reportError:!1,error:new Error(`failed parsing response json for ${e} - ${c}`)}}}return l}catch(l){const c=r+1;return c>5||au?{ok:!1,reportError:!1,error:l}:(await Sn(1e3*Math.pow(2,r)),Ge(e,{...i,retries:c}))}},qa="ul-view-sdk-script",jf=["ios","android"],nt="visitors",st="environments";async function ze(e,t){var i,a,o;const{shouldDropOnRateLimit:r,...n}=t;n.headers=Object.assign(Te(window.UserLeap),n.headers);const s=await Ge(e,{...n,shouldDropOnRateLimit:r});if(s.ok){const l=(i=s.headers)==null?void 0:i.get("Authorization"),c=l?l.split(" "):void 0,u=c&&c.length===2?c[1]:void 0,d=(a=s.headers)==null?void 0:a.get("x-ul-visitor-id");if(window.UserLeap.userId&&d===window.UserLeap.visitorId){const p=Ce.getItemObject("sprig.anon.env.vid.map");p&&p[window.UserLeap.envId]===d&&(delete p[window.UserLeap.envId],Ce.setItemObject("sprig.anon.env.vid.map",p))}u&&d&&(d!==window.UserLeap.visitorId||window.UserLeap.token!==u)&&(Ie("token",u),Ie("vid",d),z.emit(F.VisitorIDUpdated,{visitorId:d}),window.UserLeap.token=u,window.UserLeap.visitorId=d)}return(o=s.json)!=null&&o.logMessage&&console.warn(`[Sprig] ${s.json.logMessage}`),s}function Ie(e,t){const r=Ce.getItemObject("userleap.ids");let n=r[window.UserLeap.envId];n?n[e]=t:n={[e]:t},r[window.UserLeap.envId]=n,Ce.setItemObject("userleap.ids",r)}function to(){return window.previewMode?"0":window.UserLeap.visitorId??""}function Me(e,t,r){const n=[window.UserLeap._API_URL,"sdk",e];return t&&t.forEach(s=>{n.push(s),s===st?n.push(window.UserLeap.envId):s===nt&&n.push(to())}),r&&n.push(r),n.join("/")}const Qt=async(e,t,r)=>{var T,B,j;const{context:n,delay:s,forceBrandedLogo:i,endCard:a,isFeedback:o=!1,heatmap:l,locale:c,previewMode:u,productConfig:d,questions:p,responseGroupUid:f,surveyId:y,uuid:h,vid:k,sessionReplay:m,studyType:g}=e,v=Te(window.UserLeap),I=pr(v),M=$n(v);if(m)if(I)z.emit(F.ReplayCapture,{responseGroupUid:f,hasQuestions:!!(p!=null&&p.length),surveyId:y,uploadId:m.uploadId,replayType:m.replayDurationType??"before",seconds:m.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:yt(),mediaType:"screen",questionId:1,responseGroupUid:f,surveyId:y,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}});else{if(!te.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};te.replay.scheduleOrCaptureReplay({responseGroupId:f,surveyId:y,visitorId:k,replayParams:m,completeUploadHeaders:v,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:p.length===0})}if(l){if(!te.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};const{eventId:C,replayParams:D,responseGroupUid:K,surveyId:$}=l;await te.replay.initializeReplay({maxReplayDurationSeconds:300,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0,apiUrl:window.UserLeap._API_URL,replaySettings:r}),te.replay.tryReplayAction(()=>{var he;return(he=te.replay)==null?void 0:he.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:v,eventId:C,isHeatmap:!0,replayParams:D,responseGroupId:K,surveyId:$,triggerTimestamp:Date.now(),visitorId:k})},"Error in scheduling/capturing replay")}if(k==null||!(p!=null&&p.length))return _.info("CannotDisplaySurvey",{vid:k}),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(Wf(p))return{success:!1,message:"[Sprig] bundled version does not support video voice",surveyState:"no survey"};if(window.UserLeap.container){_.info("AlreadyDisplayingSurvey");const C="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(C),{success:!1,message:C,surveyState:"no survey"}}if(k!==window.UserLeap.visitorId&&h!==window.UserLeap.visitorId&&!window.previewMode){const C="Attempted to display survey to a different visitor";return window.UserLeap.reportError("DisplaySurvey",new Error(C)),{success:!1,message:C,surveyState:"no survey"}}_.info("ShowingSurvey",{surveyId:y}),(T=te.replay)==null||T.RecordSurveyShown({id:y,userAgent:window.navigator.userAgent}),tu.disable(),z.emit(F.SurveyWillPresent,{name:F.SurveyWillPresent,"survey.id":y});let x,U,A,E,L=document.createElement("div");const O=C=>{const{"view.version":D}=C;D!==v["x-ul-sdk-version"]&&cu(),z.removeListener("verify.view.version",O)};z.on("verify.view.version",O),window.UserLeap.useMobileStyling=M,eo(v)?(x="ul-direct-embeded-frame",U=document.head,A=window,E=!1,(()=>{const C=Te(window.UserLeap),D=pr(C),K=window.UserLeap.forceDirectEmbed,$=C["userleap-platform"]==="web";return D||K&&$})()&&(lu(y,o),L.id=x,window.UserLeap.container.appendChild(L),uu(),z.emit(F.SurveyLifeCycle,{state:"presented"}),z.emit(F.SurveyPresented,{name:F.SurveyPresented,"survey.id":y}))):{frameId:x,contentWinDocHead:U,contentWindow:A,hasOverlay:E,iframe:L}=Gf({productConfig:d,useMobileStyling:M,surveyId:y,isFeedback:o}),window.UserLeap.frameId=x;const S={apiURL:window.UserLeap._API_URL,cards:p,configureExitOnOverlayClick:C=>{z.once(F.CloseSurveyOnOverlayClick,C)},context:n,endCard:a,envId:window.UserLeap.envId,eventEmitFn:z.emit.bind(z),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:i,frame:L,headers:v,locale:c,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:Ce.getItem("sprig.previewKey"),previewMode:u,productConfig:{framePosition:d==null?void 0:d.framePosition,desktopDisplay:d==null?void 0:d.desktopDisplay,placement:d==null?void 0:d.placement},responseGroupUid:f,startingQuestionIdx:(B=window.UserLeap.config)==null?void 0:B.startingQuestionIdx,studyType:g,styleNonce:window.UserLeap.styleNonce,surveyId:y,tabTitle:document.title,trackPageViewUrl:t,ulEvents:dr,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:M,userId:h,viewDocument:A==null?void 0:A.document,viewWindow:A,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},...window.UserLeap._config};(j=window.UserLeap._config)!=null&&j.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null});const N=(o?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??d.customStyles;S.customStyles=N,A&&(A.__cfg=S),window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:S.path;const P=document.getElementById(qa);P&&P.remove();const b=function(){const C=document.createElement("script");return window.UserLeap.nonce&&C.setAttribute("nonce",window.UserLeap.nonce),C.id=qa,C}();S.installationMethod==="web-npm"||S.installationMethod;{const{default:C}=await Promise.resolve().then(()=>require("./view-Qe_1uCI8.cjs"));C.configure(S),E&&window.UserLeap.container&&window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})}U==null||U.appendChild(b);const w={success:!0,surveyState:"ready",surveyId:y,responseGroupUid:f};return window.UserLeap.isMobileSDK&&s&&(w.delay=s),w};function $n(e){var r;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const t=((r=window.UserLeap.windowDimensions)==null?void 0:r.width)??document.body.clientWidth;return pr(e)||t>10&&t<500}function pr(e){return jf.includes(e["userleap-platform"])}const Wf=e=>e.some(t=>t.type==="videovoice"),ro="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 ms="0px",lu=(e,t,r)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className="ul-container"+(t?" ul-container-feedback":""),e&&(window.UserLeap.container.dataset.studyId=e.toString());const n=mu();r&&n&&!window.UserLeap.useMobileStyling?n.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},cu=(e,t)=>{var n;Yf();const r=window.UserLeap.container;if(r)try{(n=r.parentNode)==null||n.removeChild(r),window.UserLeap.container=null,Ie("trackStartUrl",null),z.emit(F.SurveyLifeCycle,{state:"dismissed"}),z.emit(F.SurveyClosed,{name:F.SurveyClosed,initiator:e,"survey.id":parseInt(r.dataset.studyId),...t&&{studyType:t}})}catch(s){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${e} `+r),s instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",s)}},uu=()=>{z.once(F.SurveyWillClose,({initiator:e,studyType:t})=>{z.removeAllListeners(F.CloseSurveyOnOverlayClick),cu(e,t)})},Vf=(e,t,r,n)=>{var u,d;const s={position:"fixed",bottom:"0px",right:ms,border:0,backgroundColor:"rgba(0,0,0,0)",zIndex:2147483646,transition:"height 0.2s ease-in-out",maxWidth:"100%"},i=Object.assign({},t,window.UserLeap),{desktopDisplay:a}=t||{},o=a==="center-modal";let l;o&&(i.framePosition="center");let c=!1;if(r)(u=window.UserLeap.windowDimensions)!=null&&u.width?s.width=`${window.UserLeap.windowDimensions.width}px`:s.width="100%",(d=window.UserLeap.windowDimensions)!=null&&d.height?s.maxHeight=window.UserLeap.windowDimensions.height-20+"px":window.UserLeap.maxHeight?s.maxHeight=window.UserLeap.maxHeight:s.maxHeight=document.body.clientHeight-20+"px",["light","dark"].includes(i.overlayStyleMobile)&&(c=!0);else{s.width="360px",s.maxHeight=window.UserLeap.maxHeight||"66vh";const p=()=>{c=!0,l={margin:"auto",position:"static"}};if(n)o?p():l={position:"relative",height:"300px"};else switch(i.framePosition){case"bottomLeft":l={left:ms};break;case"topLeft":l={left:ms,top:0};break;case"topRight":l={top:0};break;case"center":p()}}return c&&((p,f)=>{const y={position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646},h=f?p.overlayStyleMobile:p.overlayStyle;y["background-color"]=h==="light"?"rgba(255,255,255, 0.95)":"rgba(0,0,0,0.9)",f||(y.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,y)})(i,r),Object.assign(e.style,s,l),c},Gf=({productConfig:e,useMobileStyling:t,surveyId:r,isFeedback:n})=>{var p,f;const s=ro,i=n&&e.desktopDisplay==="slider";lu(r,n,i),Hf();const a=document.createElement("iframe");a.id=s,a.setAttribute("title","Sprig User Feedback Dialog");const o=Vf(a,e,t,n);uu();let l=!1;a.setHeight=y=>{parseInt(a.style.height)==y&&l||(l=!0,a.style.height=`${y}px`,z.emit(F.SurveyHeight,{name:F.SurveyHeight,contentFrameHeight:y,"survey.id":r}))};let c=!1;a.setWidth=y=>{parseInt(a.style.width)==y&&c||(c=!0,a.style.width=`${y}px`,z.emit(F.SurveyWidth,{name:F.SurveyWidth,contentFrameWidth:y,"survey.id":r}))},(p=window.UserLeap.container)==null||p.appendChild(a),e&&(t?e.exitOnOverlayClickMobile:e.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{z.emit(F.CloseSurveyOnOverlayClick)}),z.emit(F.SurveyLifeCycle,{state:"presented"}),z.emit(F.SurveyPresented,{name:F.SurveyPresented,"survey.id":r});const u=(f=a.contentWindow)==null?void 0:f.document;if(u&&(u.open("text/html","replace"),u.write("<!doctype html><head></head><body></body></html>"),u.close(),!t)){const y=u.body;y.style.display="flex",y.style.alignItems="center"}const d=u==null?void 0:u.head;return{frameId:s,contentWinDocHead:d,contentWindow:a.contentWindow,hasOverlay:o,iframe:a}},du={[F.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},Hf=()=>{Object.entries(du).forEach(([e,t])=>{z.on(e,t)})},Yf=()=>{Object.entries(du).forEach(([e,t])=>{z.off(e,t)})},Ja=Object.freeze({contains:(e,t)=>t.includes(e),notContains:(e,t)=>!t.includes(e),exactly:(e,t)=>t===e,notExactly:(e,t)=>t!==e,startsWith:(e,t)=>t.startsWith(e),endsWith:(e,t)=>t.endsWith(e),regex:(e,t)=>new RegExp(e).test(t),legacy:(e,t)=>new RegExp(e,"i").test(t)});function no(e,t){const{matchType:r,pattern:n}=e,s=r?Ja[r]:Ja.legacy;let i=!1;try{i=s(n,t)}catch(a){const o=`[Sprig] (ERR-445) Failed to check url match with pattern ${n}`;a instanceof Error&&(console.warn(o,a),a.stack=JSON.stringify(e),window.UserLeap.reportError(o,a))}return i}const pu=e=>{const{pageUrlEvents:t}=window.UserLeap._config,r=t==null?void 0:t.find(n=>n.id===e);return!!r&&no(r,window.location.href)},Be=e=>!!e&&e.nodeType===Node.ELEMENT_NODE,Xa=e=>e instanceof HTMLElement||e instanceof SVGElement,hr=({document:e,elementId:t,styleString:r,nonce:n})=>{const s=e.getElementById(t);if(s)return void(s.textContent=r);const i=e.createElement("style");n&&(i.nonce=n),i.textContent=r,i.id=t,e.head.appendChild(i)},$f=(e,t)=>{const r=t.querySelector(".sprig-question-body");if(!Be(r))return e;const n=r.scrollHeight;return n<100?e:e-(n-100)},Ka=(e,t)=>{const r=t.querySelector(e);if(!Be(r))return 0;const n=getComputedStyle(r);return parseFloat(n.paddingLeft)+parseFloat(n.paddingRight)+(parseFloat(n.marginLeft)+parseFloat(n.marginRight))+(parseFloat(n.borderLeftWidth)+parseFloat(n.borderRightWidth))},hu=(e,t,r)=>{const n=e.querySelector(".ul-card__container"),s=e.querySelector(".ul-app");let i=600,a=360,o=0;if(Be(n)&&Be(s)){const l=n.querySelector(".ul-card--matrix_grid"),c=!l&&t&&r;try{c&&(s.style.width="360px"),i=n.clientHeight,i+=(p=>{const f=p.querySelector(".sprig-question-body"),y=p.querySelector(".ul-card"),h=p.querySelector(".ul-card-main-content"),k=p.querySelector(".ul-footer"),m=p.querySelector(".sprig-container");let g=0;return Be(y)&&(g+=y.scrollHeight-y.clientHeight),Be(h)&&(g+=h.scrollHeight-h.clientHeight),Be(f)&&(g+=f.scrollHeight-f.clientHeight),Be(k)&&Be(m)&&m.clientHeight===0&&(g+=k.clientHeight),g})(e);const u=getComputedStyle(n);o=i;const d=parseFloat(u.marginTop)+parseFloat(u.marginBottom);i+=d+(parseFloat(u.borderTopWidth)+parseFloat(u.borderBottomWidth)),l&&(a=l.scrollWidth,a+=Ka(".ul-card__container",e),a+=Ka(".sprig-question-body",e))}finally{c&&s.style.removeProperty("width")}}return[i+1,a,$f(o,e)]},mu=()=>Z,Rt=()=>document.getElementById("sprig-feedback-container"),ui=()=>document.getElementById("sprig-feedback-loading-animation"),fu=()=>!!document.getElementById(ro);let Za=!1,Z=null,je=null,so=!1,er=null,ut=null;const qf=["bottom-left","bottom-right","center-left","center-right"],In=()=>{var t;const e=window.UserLeap.container;return((t=e==null?void 0:e.parentElement)==null?void 0:t.id)==="sprig-feedback-loading-container"},gu=()=>document.getElementById("sprig-feedback-error-container"),yu=()=>{if(!Z)return 0;const e=Z==null?void 0:Z.clientWidth,t=window.getComputedStyle(Z);return e+parseInt(t.borderRightWidth||"0")+parseInt(t.borderLeftWidth||"0")},Cn=e=>{const t=Rt();t&&(ut!=null&&ut.endsWith("right")?t.style.right=`${e}px`:ut!=null&&ut.endsWith("left")&&(t.style.left=`${e}px`))},fs=()=>{if(Z&&(In()||gu())){z.off(F.SurveyAppeared,$t),di();const e=yu();return Cn(-e),!0}return!1},$t=()=>{if(!Z||!je)return;const e=ui();e&&e.remove(),Z.style.height="auto",Z.style.width="auto",je.disabled=!1,so=!1},di=()=>{if(Z&&!ui()){const e=(()=>{if(ui())return;const t=document.createElement("div");return t.className="ul-loading-spinner-container",t.id="sprig-feedback-loading-animation",t.role="progressbar",t.setAttribute("aria-live","polite"),t.setAttribute("aria-busy","true"),t.setAttribute("aria-label","Processing..."),t.innerHTML=`
61
+ or you can use record.mirror to access the mirror instance during recording.`;let Aa={map:{},getId:()=>(console.error(St),-1),getNode:()=>(console.error(St),null),removeNodeFromMap(){console.error(St)},has:()=>(console.error(St),!1),reset(){console.error(St)}};function Gt(e,t,r={}){let n=null,s=0;return function(...i){const a=Date.now();s||r.leading!==!1||(s=a);const o=t-(a-s),l=this;o<=0||o>t?(n&&(clearTimeout(n),n=null),s=a,e.apply(l,i)):n||r.trailing===!1||(n=setTimeout(()=>{s=r.leading===!1?0:Date.now(),n=null,e.apply(l,i)},o))}}function Yn(e,t,r,n,s=window){const i=s.Object.getOwnPropertyDescriptor(e,t);return s.Object.defineProperty(e,t,n?r:{set(a){setTimeout(()=>{r.set.call(this,a)},0),i&&i.set&&i.set.call(this,a)}}),()=>Yn(e,t,i||{},!0)}function At(e,t,r){try{if(!(t in e))return()=>{};const n=e[t],s=r(n);return typeof s=="function"&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=s,()=>{e[t]=n}}catch{return()=>{}}}typeof window<"u"&&window.Proxy&&window.Reflect&&(Aa=new Proxy(Aa,{get:(e,t,r)=>(t==="map"&&console.error(St),Reflect.get(e,t,r))}));let vn=Date.now;function Fc(e){var t,r,n,s;const i=e.document;return{left:i.scrollingElement?i.scrollingElement.scrollLeft:e.pageXOffset!==void 0?e.pageXOffset:i.documentElement.scrollLeft||(i==null?void 0:i.body)&&((t=V.parentElement(i.body))==null?void 0:t.scrollLeft)||((r=i==null?void 0:i.body)==null?void 0:r.scrollLeft)||0,top:i.scrollingElement?i.scrollingElement.scrollTop:e.pageYOffset!==void 0?e.pageYOffset:(i==null?void 0:i.documentElement.scrollTop)||(i==null?void 0:i.body)&&((n=V.parentElement(i.body))==null?void 0:n.scrollTop)||((s=i==null?void 0:i.body)==null?void 0:s.scrollTop)||0}}function Bc(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function zc(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function jc(e){return e?e.nodeType===e.ELEMENT_NODE?e:V.parentElement(e):null}function ve(e,t,r,n){if(!e)return!1;const s=jc(e);if(!s)return!1;try{if(typeof t=="string"){if(s.classList.contains(t)||n&&s.closest("."+t)!==null)return!0}else if(wn(s,t,n))return!0}catch{}return!!(r&&(s.matches(r)||n&&s.closest(r)!==null))}function ps(e,t,r){return!(e.tagName!=="TITLE"||!r.headTitleMutations)||t.getId(e)===-2}function Wc(e,t){if(Jt(e))return!1;const r=t.getId(e);if(!t.has(r))return!0;const n=V.parentNode(e);return(!n||n.nodeType!==e.DOCUMENT_NODE)&&(!n||Wc(n,t))}function oi(e){return!!e.changedTouches}function Vc(e,t){return!!(e.nodeName==="IFRAME"&&t.getMeta(e))}function Gc(e,t){return!!(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function ai(e){return!!e&&(e instanceof Zi&&"shadowRoot"in e?!!e.shadowRoot:!!V.shadowRoot(e))}/[1-9][0-9]{12}/.test(Date.now().toString())||(vn=()=>new Date().getTime());class bf{constructor(){R(this,"id",1),R(this,"styleIDMap",new WeakMap),R(this,"idStyleMap",new Map)}getId(t){return this.styleIDMap.get(t)??-1}has(t){return this.styleIDMap.has(t)}add(t,r){if(this.has(t))return this.getId(t);let n;return n=r===void 0?this.id++:r,this.styleIDMap.set(t,n),this.idStyleMap.set(n,t),n}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function Hc(e){var t;let r=null;return"getRootNode"in e&&((t=V.getRootNode(e))==null?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&V.host(V.getRootNode(e))&&(r=V.host(V.getRootNode(e))),r}function Sf(e){const t=e.ownerDocument;if(!t)return!1;const r=function(n){let s,i=n;for(;s=Hc(i);)i=s;return i}(e);return V.contains(t,r)}function Yc(e){const t=e.ownerDocument;return!!t&&(V.contains(t,e)||Sf(e))}var Y=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(Y||{}),G=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(G||{}),be=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(be||{}),Ye=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Ye||{}),It=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(It||{}),Ct=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(Ct||{});function Ma(e){return"__ln"in e}class If{constructor(){R(this,"length",0),R(this,"head",null),R(this,"tail",null)}get(t){if(t>=this.length)throw new Error("Position outside of list range");let r=this.head;for(let n=0;n<t;n++)r=(r==null?void 0:r.next)||null;return r}addNode(t){const r={value:t,previous:null,next:null};if(t.__ln=r,t.previousSibling&&Ma(t.previousSibling)){const n=t.previousSibling.__ln.next;r.next=n,r.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=r,n&&(n.previous=r)}else if(t.nextSibling&&Ma(t.nextSibling)&&t.nextSibling.__ln.previous){const n=t.nextSibling.__ln.previous;r.previous=n,r.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=r,n&&(n.next=r)}else this.head&&(this.head.previous=r),r.next=this.head,this.head=r;r.next===null&&(this.tail=r),this.length++}removeNode(t){const r=t.__ln;this.head&&(r.previous?(r.previous.next=r.next,r.next?r.next.previous=r.previous:this.tail=r.previous):(this.head=r.next,this.head?this.head.previous=null:this.tail=null),t.__ln&&delete t.__ln,this.length--)}}const Ua=(e,t)=>`${e}@${t}`;class Cf{constructor(){R(this,"frozen",!1),R(this,"locked",!1),R(this,"texts",[]),R(this,"attributes",[]),R(this,"attributeMap",new WeakMap),R(this,"removes",[]),R(this,"mapRemoves",[]),R(this,"movedMap",{}),R(this,"addedSet",new Set),R(this,"movedSet",new Set),R(this,"droppedSet",new Set),R(this,"mutationCb"),R(this,"blockClass"),R(this,"blockSelector"),R(this,"maskTextClass"),R(this,"maskTextSelector"),R(this,"inlineStylesheet"),R(this,"maskInputOptions"),R(this,"maskTextFn"),R(this,"maskInputFn"),R(this,"keepIframeSrcFn"),R(this,"recordCanvas"),R(this,"inlineImages"),R(this,"slimDOMOptions"),R(this,"dataURLOptions"),R(this,"doc"),R(this,"mirror"),R(this,"iframeManager"),R(this,"stylesheetManager"),R(this,"shadowDomManager"),R(this,"canvasManager"),R(this,"processedNodeManager"),R(this,"unattachedDoc"),R(this,"processMutations",t=>{t.forEach(this.processMutation),this.emit()}),R(this,"emit",()=>{if(this.frozen||this.locked)return;const t=[],r=new Set,n=new If,s=l=>{let c=l,u=-2;for(;u===-2;)c=c&&c.nextSibling,u=c&&this.mirror.getId(c);return u},i=l=>{const c=V.parentNode(l);if(!c||!Yc(l)||c.tagName==="TEXTAREA")return;const u=Jt(c)?this.mirror.getId(Hc(l)):this.mirror.getId(c),d=s(l);if(u===-1||d===-1)return n.addNode(l);const p=kt(l,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:f=>{Vc(f,this.mirror)&&this.iframeManager.addIframe(f),Gc(f,this.mirror)&&this.stylesheetManager.trackLinkElement(f),ai(l)&&this.shadowDomManager.addShadowRoot(V.shadowRoot(l),this.doc)},onIframeLoad:(f,y)=>{this.iframeManager.attachIframe(f,y),this.shadowDomManager.observeAttachShadow(f)},onStylesheetLoad:(f,y)=>{this.stylesheetManager.attachLinkElement(f,y)}});p&&(t.push({parentId:u,nextId:d,node:p}),r.add(p.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const l of this.movedSet)Ta(this.removes,l,this.mirror)&&!this.movedSet.has(V.parentNode(l))||i(l);for(const l of this.addedSet)Da(this.droppedSet,l)||Ta(this.removes,l,this.mirror)?Da(this.movedSet,l)?i(l):this.droppedSet.add(l):i(l);let a=null;for(;n.length;){let l=null;if(a){const c=this.mirror.getId(V.parentNode(a.value)),u=s(a.value);c!==-1&&u!==-1&&(l=a)}if(!l){let c=n.tail;for(;c;){const u=c;if(c=c.previous,u){const d=this.mirror.getId(V.parentNode(u.value));if(s(u.value)===-1)continue;if(d!==-1){l=u;break}{const p=u.value,f=V.parentNode(p);if(f&&f.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const y=V.host(f);if(this.mirror.getId(y)!==-1){l=u;break}}}}}}if(!l){for(;n.head;)n.removeNode(n.head.value);break}a=l.previous,n.removeNode(l.value),i(l.value)}const o={texts:this.texts.map(l=>{const c=l.node,u=V.parentNode(c);return u&&u.tagName==="TEXTAREA"&&this.genTextAreaValueMutation(u),{id:this.mirror.getId(c),value:l.value}}).filter(l=>!r.has(l.id)).filter(l=>this.mirror.has(l.id)),attributes:this.attributes.map(l=>{const{attributes:c}=l;if(typeof c.style=="string"){const u=JSON.stringify(l.styleDiff),d=JSON.stringify(l._unchangedStyles);u.length<c.style.length&&(u+d).split("var(").length===c.style.split("var(").length&&(c.style=l.styleDiff)}return{id:this.mirror.getId(l.node),attributes:c}}).filter(l=>!r.has(l.id)).filter(l=>this.mirror.has(l.id)),removes:this.removes,adds:t};(o.texts.length||o.attributes.length||o.removes.length||o.adds.length)&&(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(o))}),R(this,"genTextAreaValueMutation",t=>{let r=this.attributeMap.get(t);r||(r={node:t,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(r),this.attributeMap.set(t,r)),r.attributes.value=Array.from(V.childNodes(t),n=>V.textContent(n)||"").join("")}),R(this,"processMutation",t=>{if(!ps(t.target,this.mirror,this.slimDOMOptions))switch(t.type){case"characterData":{const r=V.textContent(t.target);ve(t.target,this.blockClass,this.blockSelector,!1)||r===t.oldValue||this.texts.push({value:Al(t.target,this.maskTextClass,this.maskTextSelector,!0)&&r?this.maskTextFn?this.maskTextFn(r,jc(t.target)):r.replace(/[\S]/g,"*"):r,node:t.target});break}case"attributes":{const r=t.target;let n=t.attributeName,s=t.target.getAttribute(n);if(n==="value"){const a=Di(r);s=Ti({element:r,maskInputOptions:this.maskInputOptions,tagName:r.tagName,type:a,value:s,maskInputFn:this.maskInputFn})}if(ve(t.target,this.blockClass,this.blockSelector,!1)||s===t.oldValue)return;let i=this.attributeMap.get(t.target);if(r.tagName==="IFRAME"&&n==="src"&&!this.keepIframeSrcFn(s)){if(r.contentDocument)return;n="rr_src"}if(i||(i={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(i),this.attributeMap.set(t.target,i)),n==="type"&&r.tagName==="INPUT"&&(t.oldValue||"").toLowerCase()==="password"&&r.setAttribute("data-rr-is-password","true"),!Ol(r.tagName,n))if(i.attributes[n]=Ll(this.doc,ht(r.tagName),ht(n),s),n==="style"){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch{this.unattachedDoc=this.doc}const a=this.unattachedDoc.createElement("span");t.oldValue&&a.setAttribute("style",t.oldValue);for(const o of Array.from(r.style)){const l=r.style.getPropertyValue(o),c=r.style.getPropertyPriority(o);l!==a.style.getPropertyValue(o)||c!==a.style.getPropertyPriority(o)?i.styleDiff[o]=c===""?l:[l,c]:i._unchangedStyles[o]=[l,c]}for(const o of Array.from(a.style))r.style.getPropertyValue(o)===""&&(i.styleDiff[o]=!1)}else n==="open"&&r.tagName==="DIALOG"&&(r.matches("dialog:modal")?i.attributes.rr_open_mode="modal":i.attributes.rr_open_mode="non-modal");break}case"childList":if(ve(t.target,this.blockClass,this.blockSelector,!0))return;if(t.target.tagName==="TEXTAREA")return void this.genTextAreaValueMutation(t.target);t.addedNodes.forEach(r=>this.genAdds(r,t.target)),t.removedNodes.forEach(r=>{const n=this.mirror.getId(r),s=Jt(t.target)?this.mirror.getId(V.host(t.target)):this.mirror.getId(t.target);ve(t.target,this.blockClass,this.blockSelector,!1)||ps(r,this.mirror,this.slimDOMOptions)||!function(i,a){return a.getId(i)!==-1}(r,this.mirror)||(this.addedSet.has(r)?(li(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&n===-1||Wc(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[Ua(n,s)]?li(this.movedSet,r):this.removes.push({parentId:s,id:n,isShadow:!(!Jt(t.target)||!Xt(t.target))||void 0})),this.mapRemoves.push(r))})}}),R(this,"genAdds",(t,r)=>{if(!this.processedNodeManager.inOtherBuffer(t,this)&&!this.addedSet.has(t)&&!this.movedSet.has(t)){if(this.mirror.hasNode(t)){if(ps(t,this.mirror,this.slimDOMOptions))return;this.movedSet.add(t);let n=null;r&&this.mirror.hasNode(r)&&(n=this.mirror.getId(r)),n&&n!==-1&&(this.movedMap[Ua(this.mirror.getId(t),n)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);ve(t,this.blockClass,this.blockSelector,!1)||(V.childNodes(t).forEach(n=>this.genAdds(n)),ai(t)&&V.childNodes(V.shadowRoot(t)).forEach(n=>{this.processedNodeManager.add(n,this),this.genAdds(n,t)}))}})}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(r=>{this[r]=t[r]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function li(e,t){e.delete(t),V.childNodes(t).forEach(r=>li(e,r))}function Ta(e,t,r){return e.length!==0&&function(n,s,i){let a=V.parentNode(s);for(;a;){const o=i.getId(a);if(n.some(l=>l.id===o))return!0;a=V.parentNode(a)}return!1}(e,t,r)}function Da(e,t){return e.size!==0&&$c(e,t)}function $c(e,t){const r=V.parentNode(t);return!!r&&(!!e.has(r)||$c(e,r))}let Kt;const H=e=>Kt?(...t)=>{try{return e(...t)}catch(r){if(Kt&&Kt(r)===!0)return;throw r}}:e,pt=[];function Zt(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch{}return e&&e.target}function qc(e,t){const r=new Cf;pt.push(r),r.init(e);const n=new(Nc())(H(r.processMutations.bind(r)));return n.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),n}function kf({mouseInteractionCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,sampling:i}){if(i.mouseInteraction===!1)return()=>{};const a=i.mouseInteraction===!0||i.mouseInteraction===void 0?{}:i.mouseInteraction,o=[];let l=null;return Object.keys(be).filter(c=>Number.isNaN(Number(c))&&!c.endsWith("_Departed")&&a[c]!==!1).forEach(c=>{let u=ht(c);const d=(p=>f=>{const y=Zt(f);if(ve(y,n,s,!0))return;let h=null,k=p;if("pointerType"in f){switch(f.pointerType){case"mouse":h=Ye.Mouse;break;case"touch":h=Ye.Touch;break;case"pen":h=Ye.Pen}h===Ye.Touch?be[p]===be.MouseDown?k="TouchStart":be[p]===be.MouseUp&&(k="TouchEnd"):Ye.Pen}else oi(f)&&(h=Ye.Touch);h!==null?(l=h,(k.startsWith("Touch")&&h===Ye.Touch||k.startsWith("Mouse")&&h===Ye.Mouse)&&(h=null)):be[p]===be.Click&&(h=l,l=null);const m=oi(f)?f.changedTouches[0]:f;if(!m)return;const g=r.getId(y),{clientX:v,clientY:I}=m;H(e)({type:be[k],id:g,x:v,y:I,...h!==null&&{pointerType:h}})})(c);if(window.PointerEvent)switch(be[c]){case be.MouseDown:case be.MouseUp:u=u.replace("mouse","pointer");break;case be.TouchStart:case be.TouchEnd:return}o.push(ye(u,d,t))}),H(()=>{o.forEach(c=>c())})}function Jc({scrollCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,sampling:i}){return ye("scroll",H(Gt(H(a=>{const o=Zt(a);if(!o||ve(o,n,s,!0))return;const l=r.getId(o);if(o===t&&t.defaultView){const c=Fc(t.defaultView);e({id:l,x:c.left,y:c.top})}else e({id:l,x:o.scrollLeft,y:o.scrollTop})}),i.scroll||100)),t)}const Ef=["INPUT","TEXTAREA","SELECT"],Pa=new WeakMap;function jr(e){return function(t,r){if(Wr("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||Wr("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||Wr("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||Wr("CSSConditionRule")&&t.parentRule instanceof CSSConditionRule){const n=Array.from(t.parentRule.cssRules).indexOf(t);r.unshift(n)}else if(t.parentStyleSheet){const n=Array.from(t.parentStyleSheet.cssRules).indexOf(t);r.unshift(n)}return r}(e,[])}function tt(e,t,r){let n,s;return e?(e.ownerNode?n=t.getId(e.ownerNode):s=r.getId(e),{styleId:s,id:n}):{}}function Xc({mirror:e,stylesheetManager:t},r){var n,s,i;let a=null;a=r.nodeName==="#document"?e.getId(r):e.getId(V.host(r));const o=r.nodeName==="#document"?(n=r.defaultView)==null?void 0:n.Document:(i=(s=r.ownerDocument)==null?void 0:s.defaultView)==null?void 0:i.ShadowRoot,l=o!=null&&o.prototype?Object.getOwnPropertyDescriptor(o==null?void 0:o.prototype,"adoptedStyleSheets"):void 0;return a!==null&&a!==-1&&o&&l?(Object.defineProperty(r,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var c;return(c=l.get)==null?void 0:c.call(this)},set(c){var u;const d=(u=l.set)==null?void 0:u.call(this,c);if(a!==null&&a!==-1)try{t.adoptStyleSheets(c,a)}catch{}return d}}),H(()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})})):()=>{}}function xf(e,t={}){const r=e.doc.defaultView;if(!r)return()=>{};let n;(function(m,g){const{mutationCb:v,mousemoveCb:I,mouseInteractionCb:M,scrollCb:x,viewportResizeCb:U,inputCb:A,mediaInteractionCb:E,styleSheetRuleCb:L,styleDeclarationCb:O,canvasMutationCb:S,fontCb:N,selectionCb:P,customElementCb:b}=m;m.mutationCb=(...w)=>{g.mutation&&g.mutation(...w),v(...w)},m.mousemoveCb=(...w)=>{g.mousemove&&g.mousemove(...w),I(...w)},m.mouseInteractionCb=(...w)=>{g.mouseInteraction&&g.mouseInteraction(...w),M(...w)},m.scrollCb=(...w)=>{g.scroll&&g.scroll(...w),x(...w)},m.viewportResizeCb=(...w)=>{g.viewportResize&&g.viewportResize(...w),U(...w)},m.inputCb=(...w)=>{g.input&&g.input(...w),A(...w)},m.mediaInteractionCb=(...w)=>{g.mediaInteaction&&g.mediaInteaction(...w),E(...w)},m.styleSheetRuleCb=(...w)=>{g.styleSheetRule&&g.styleSheetRule(...w),L(...w)},m.styleDeclarationCb=(...w)=>{g.styleDeclaration&&g.styleDeclaration(...w),O(...w)},m.canvasMutationCb=(...w)=>{g.canvasMutation&&g.canvasMutation(...w),S(...w)},m.fontCb=(...w)=>{g.font&&g.font(...w),N(...w)},m.selectionCb=(...w)=>{g.selection&&g.selection(...w),P(...w)},m.customElementCb=(...w)=>{g.customElement&&g.customElement(...w),b(...w)}})(e,t),e.recordDOM&&(n=qc(e,e.doc));const s=function({mousemoveCb:m,sampling:g,doc:v,mirror:I}){if(g.mousemove===!1)return()=>{};const M=typeof g.mousemove=="number"?g.mousemove:50,x=typeof g.mousemoveCallback=="number"?g.mousemoveCallback:500;let U,A=[];const E=Gt(H(S=>{const N=Date.now()-U;m(A.map(P=>(P.timeOffset-=N,P)),S),A=[],U=null}),x),L=H(Gt(H(S=>{const N=Zt(S),{clientX:P,clientY:b}=oi(S)?S.changedTouches[0]:S;U||(U=vn()),A.push({x:P,y:b,id:I.getId(N),timeOffset:vn()-U}),E(typeof DragEvent<"u"&&S instanceof DragEvent?G.Drag:S instanceof MouseEvent?G.MouseMove:G.TouchMove)}),M,{trailing:!1})),O=[ye("mousemove",L,v),ye("touchmove",L,v),ye("drag",L,v)];return H(()=>{O.forEach(S=>S())})}(e),i=kf(e),a=Jc(e),o=function({viewportResizeCb:m},{win:g}){let v=-1,I=-1;return ye("resize",H(Gt(H(()=>{const M=Bc(),x=zc();v===M&&I===x||(m({width:Number(x),height:Number(M)}),v=M,I=x)}),200)),g)}(e,{win:r}),l=function({inputCb:m,doc:g,mirror:v,blockClass:I,blockSelector:M,ignoreClass:x,ignoreSelector:U,maskInputOptions:A,maskInputFn:E,sampling:L,userTriggeredOnInput:O}){function S(B){let j=Zt(B);const C=B.isTrusted,D=j&&j.tagName;if(j&&D==="OPTION"&&(j=V.parentElement(j)),!j||!D||Ef.indexOf(D)<0||ve(j,I,M,!0)||j.classList.contains(x)||U&&j.matches(U))return;let K=j.value,$=!1;const he=Di(j)||"";he==="radio"||he==="checkbox"?$=j.checked:(A[D.toLowerCase()]||A[he])&&(K=Ti({element:j,maskInputOptions:A,tagName:D,type:he,value:K,maskInputFn:E})),N(j,O?{text:K,isChecked:$,userTriggered:C}:{text:K,isChecked:$});const ct=j.name;he==="radio"&&ct&&$&&g.querySelectorAll(`input[type="radio"][name="${ct}"]`).forEach(Se=>{if(Se!==j){const _e=Se.value;N(Se,O?{text:_e,isChecked:!$,userTriggered:!1}:{text:_e,isChecked:!$})}})}function N(B,j){const C=Pa.get(B);if(!C||C.text!==j.text||C.isChecked!==j.isChecked){Pa.set(B,j);const D=v.getId(B);H(m)({...j,id:D})}}const P=(L.input==="last"?["change"]:["input","change"]).map(B=>ye(B,H(S),g)),b=g.defaultView;if(!b)return()=>{P.forEach(B=>B())};const w=b.Object.getOwnPropertyDescriptor(b.HTMLInputElement.prototype,"value"),T=[[b.HTMLInputElement.prototype,"value"],[b.HTMLInputElement.prototype,"checked"],[b.HTMLSelectElement.prototype,"value"],[b.HTMLTextAreaElement.prototype,"value"],[b.HTMLSelectElement.prototype,"selectedIndex"],[b.HTMLOptionElement.prototype,"selected"]];return w&&w.set&&P.push(...T.map(B=>Yn(B[0],B[1],{set(){H(S)({target:this,isTrusted:!1})}},!1,b))),H(()=>{P.forEach(B=>B())})}(e),c=function({mediaInteractionCb:m,blockClass:g,blockSelector:v,mirror:I,sampling:M,doc:x}){const U=H(E=>Gt(H(L=>{const O=Zt(L);if(!O||ve(O,g,v,!0))return;const{currentTime:S,volume:N,muted:P,playbackRate:b,loop:w}=O;m({type:E,id:I.getId(O),currentTime:S,volume:N,muted:P,playbackRate:b,loop:w})}),M.media||500)),A=[ye("play",U(Ct.Play),x),ye("pause",U(Ct.Pause),x),ye("seeked",U(Ct.Seeked),x),ye("volumechange",U(Ct.VolumeChange),x),ye("ratechange",U(Ct.RateChange),x)];return H(()=>{A.forEach(E=>E())})}(e);let u=()=>{},d=()=>{},p=()=>{},f=()=>{};e.recordDOM&&(u=function({styleSheetRuleCb:m,mirror:g,stylesheetManager:v},{win:I}){if(!I.CSSStyleSheet||!I.CSSStyleSheet.prototype)return()=>{};const M=I.CSSStyleSheet.prototype.insertRule;I.CSSStyleSheet.prototype.insertRule=new Proxy(M,{apply:H((O,S,N)=>{const[P,b]=N,{id:w,styleId:T}=tt(S,g,v.styleMirror);return(w&&w!==-1||T&&T!==-1)&&m({id:w,styleId:T,adds:[{rule:P,index:b}]}),O.apply(S,N)})}),I.CSSStyleSheet.prototype.addRule=function(O,S,N=this.cssRules.length){const P=`${O} { ${S} }`;return I.CSSStyleSheet.prototype.insertRule.apply(this,[P,N])};const x=I.CSSStyleSheet.prototype.deleteRule;let U,A;I.CSSStyleSheet.prototype.deleteRule=new Proxy(x,{apply:H((O,S,N)=>{const[P]=N,{id:b,styleId:w}=tt(S,g,v.styleMirror);return(b&&b!==-1||w&&w!==-1)&&m({id:b,styleId:w,removes:[{index:P}]}),O.apply(S,N)})}),I.CSSStyleSheet.prototype.removeRule=function(O){return I.CSSStyleSheet.prototype.deleteRule.apply(this,[O])},I.CSSStyleSheet.prototype.replace&&(U=I.CSSStyleSheet.prototype.replace,I.CSSStyleSheet.prototype.replace=new Proxy(U,{apply:H((O,S,N)=>{const[P]=N,{id:b,styleId:w}=tt(S,g,v.styleMirror);return(b&&b!==-1||w&&w!==-1)&&m({id:b,styleId:w,replace:P}),O.apply(S,N)})})),I.CSSStyleSheet.prototype.replaceSync&&(A=I.CSSStyleSheet.prototype.replaceSync,I.CSSStyleSheet.prototype.replaceSync=new Proxy(A,{apply:H((O,S,N)=>{const[P]=N,{id:b,styleId:w}=tt(S,g,v.styleMirror);return(b&&b!==-1||w&&w!==-1)&&m({id:b,styleId:w,replaceSync:P}),O.apply(S,N)})}));const E={};Vr("CSSGroupingRule")?E.CSSGroupingRule=I.CSSGroupingRule:(Vr("CSSMediaRule")&&(E.CSSMediaRule=I.CSSMediaRule),Vr("CSSConditionRule")&&(E.CSSConditionRule=I.CSSConditionRule),Vr("CSSSupportsRule")&&(E.CSSSupportsRule=I.CSSSupportsRule));const L={};return Object.entries(E).forEach(([O,S])=>{L[O]={insertRule:S.prototype.insertRule,deleteRule:S.prototype.deleteRule},S.prototype.insertRule=new Proxy(L[O].insertRule,{apply:H((N,P,b)=>{const[w,T]=b,{id:B,styleId:j}=tt(P.parentStyleSheet,g,v.styleMirror);return(B&&B!==-1||j&&j!==-1)&&m({id:B,styleId:j,adds:[{rule:w,index:[...jr(P),T||0]}]}),N.apply(P,b)})}),S.prototype.deleteRule=new Proxy(L[O].deleteRule,{apply:H((N,P,b)=>{const[w]=b,{id:T,styleId:B}=tt(P.parentStyleSheet,g,v.styleMirror);return(T&&T!==-1||B&&B!==-1)&&m({id:T,styleId:B,removes:[{index:[...jr(P),w]}]}),N.apply(P,b)})})}),H(()=>{I.CSSStyleSheet.prototype.insertRule=M,I.CSSStyleSheet.prototype.deleteRule=x,U&&(I.CSSStyleSheet.prototype.replace=U),A&&(I.CSSStyleSheet.prototype.replaceSync=A),Object.entries(E).forEach(([O,S])=>{S.prototype.insertRule=L[O].insertRule,S.prototype.deleteRule=L[O].deleteRule})})}(e,{win:r}),d=Xc(e,e.doc),p=function({styleDeclarationCb:m,mirror:g,ignoreCSSAttributes:v,stylesheetManager:I},{win:M}){const x=M.CSSStyleDeclaration.prototype.setProperty;M.CSSStyleDeclaration.prototype.setProperty=new Proxy(x,{apply:H((A,E,L)=>{var O;const[S,N,P]=L;if(v.has(S))return x.apply(E,[S,N,P]);const{id:b,styleId:w}=tt((O=E.parentRule)==null?void 0:O.parentStyleSheet,g,I.styleMirror);return(b&&b!==-1||w&&w!==-1)&&m({id:b,styleId:w,set:{property:S,value:N,priority:P},index:jr(E.parentRule)}),A.apply(E,L)})});const U=M.CSSStyleDeclaration.prototype.removeProperty;return M.CSSStyleDeclaration.prototype.removeProperty=new Proxy(U,{apply:H((A,E,L)=>{var O;const[S]=L;if(v.has(S))return U.apply(E,[S]);const{id:N,styleId:P}=tt((O=E.parentRule)==null?void 0:O.parentStyleSheet,g,I.styleMirror);return(N&&N!==-1||P&&P!==-1)&&m({id:N,styleId:P,remove:{property:S},index:jr(E.parentRule)}),A.apply(E,L)})}),H(()=>{M.CSSStyleDeclaration.prototype.setProperty=x,M.CSSStyleDeclaration.prototype.removeProperty=U})}(e,{win:r}),e.collectFonts&&(f=function({fontCb:m,doc:g}){const v=g.defaultView;if(!v)return()=>{};const I=[],M=new WeakMap,x=v.FontFace;v.FontFace=function(A,E,L){const O=new x(A,E,L);return M.set(O,{family:A,buffer:typeof E!="string",descriptors:L,fontSource:typeof E=="string"?E:JSON.stringify(Array.from(new Uint8Array(E)))}),O};const U=At(g.fonts,"add",function(A){return function(E){return setTimeout(H(()=>{const L=M.get(E);L&&(m(L),M.delete(E))}),0),A.apply(this,[E])}});return I.push(()=>{v.FontFace=x}),I.push(U),H(()=>{I.forEach(A=>A())})}(e)));const y=function(m){const{doc:g,mirror:v,blockClass:I,blockSelector:M,selectionCb:x}=m;let U=!0;const A=H(()=>{const E=g.getSelection();if(!E||U&&(E!=null&&E.isCollapsed))return;U=E.isCollapsed||!1;const L=[],O=E.rangeCount||0;for(let S=0;S<O;S++){const N=E.getRangeAt(S),{startContainer:P,startOffset:b,endContainer:w,endOffset:T}=N;ve(P,I,M,!0)||ve(w,I,M,!0)||L.push({start:v.getId(P),startOffset:b,end:v.getId(w),endOffset:T})}x({ranges:L})});return A(),ye("selectionchange",A)}(e),h=function({doc:m,customElementCb:g}){const v=m.defaultView;return v&&v.customElements?At(v.customElements,"define",function(I){return function(M,x,U){try{g({define:{name:M}})}catch{console.warn(`Custom element callback failed for ${M}`)}return I.apply(this,[M,x,U])}}):()=>{}}(e),k=[];for(const m of e.plugins)k.push(m.observer(m.callback,r,m.options));return H(()=>{pt.forEach(m=>m.reset()),n==null||n.disconnect(),s(),i(),a(),o(),l(),c(),u(),d(),p(),f(),y(),h(),k.forEach(m=>m())})}function Wr(e){return window[e]!==void 0}function Vr(e){return!!(window[e]!==void 0&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}class _a{constructor(t){R(this,"iframeIdToRemoteIdMap",new WeakMap),R(this,"iframeRemoteIdToIdMap",new WeakMap),this.generateIdFn=t}getId(t,r,n,s){const i=n||this.getIdToRemoteIdMap(t),a=s||this.getRemoteIdToIdMap(t);let o=i.get(r);return o||(o=this.generateIdFn(),i.set(r,o),a.set(o,r)),o}getIds(t,r){const n=this.getIdToRemoteIdMap(t),s=this.getRemoteIdToIdMap(t);return r.map(i=>this.getId(t,i,n,s))}getRemoteId(t,r,n){const s=n||this.getRemoteIdToIdMap(t);return typeof r!="number"?r:s.get(r)||-1}getRemoteIds(t,r){const n=this.getRemoteIdToIdMap(t);return r.map(s=>this.getRemoteId(t,s,n))}reset(t){if(!t)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let r=this.iframeIdToRemoteIdMap.get(t);return r||(r=new Map,this.iframeIdToRemoteIdMap.set(t,r)),r}getRemoteIdToIdMap(t){let r=this.iframeRemoteIdToIdMap.get(t);return r||(r=new Map,this.iframeRemoteIdToIdMap.set(t,r)),r}}class Rf{constructor(t){R(this,"iframes",new WeakMap),R(this,"crossOriginIframeMap",new WeakMap),R(this,"crossOriginIframeMirror",new _a(Rl)),R(this,"crossOriginIframeStyleMirror"),R(this,"crossOriginIframeRootIdMap",new WeakMap),R(this,"mirror"),R(this,"mutationCb"),R(this,"wrappedEmit"),R(this,"loadListener"),R(this,"stylesheetManager"),R(this,"recordCrossOriginIframes"),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new _a(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,r){var n,s;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:r}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&((n=t.contentWindow)==null||n.addEventListener("message",this.handleMessage.bind(this))),(s=this.loadListener)==null||s.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){const r=t;if(r.data.type!=="rrweb"||r.origin!==r.data.origin||!t.source)return;const n=this.crossOriginIframeMap.get(t.source);if(!n)return;const s=this.transformCrossOriginEvent(n,r.data.event);s&&this.wrappedEmit(s,r.data.isCheckout)}transformCrossOriginEvent(t,r){var n;switch(r.type){case Y.FullSnapshot:{this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(r.data.node,t);const s=r.data.node.id;return this.crossOriginIframeRootIdMap.set(t,s),this.patchRootIdOnNode(r.data.node,s),{timestamp:r.timestamp,type:Y.IncrementalSnapshot,data:{source:G.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:r.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case Y.Meta:case Y.Load:case Y.DomContentLoaded:return!1;case Y.Plugin:return r;case Y.Custom:return this.replaceIds(r.data.payload,t,["id","parentId","previousId","nextId"]),r;case Y.IncrementalSnapshot:switch(r.data.source){case G.Mutation:return r.data.adds.forEach(s=>{this.replaceIds(s,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(s.node,t);const i=this.crossOriginIframeRootIdMap.get(t);i&&this.patchRootIdOnNode(s.node,i)}),r.data.removes.forEach(s=>{this.replaceIds(s,t,["parentId","id"])}),r.data.attributes.forEach(s=>{this.replaceIds(s,t,["id"])}),r.data.texts.forEach(s=>{this.replaceIds(s,t,["id"])}),r;case G.Drag:case G.TouchMove:case G.MouseMove:return r.data.positions.forEach(s=>{this.replaceIds(s,t,["id"])}),r;case G.ViewportResize:return!1;case G.MediaInteraction:case G.MouseInteraction:case G.Scroll:case G.CanvasMutation:case G.Input:return this.replaceIds(r.data,t,["id"]),r;case G.StyleSheetRule:case G.StyleDeclaration:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleId"]),r;case G.Font:return r;case G.Selection:return r.data.ranges.forEach(s=>{this.replaceIds(s,t,["start","end"])}),r;case G.AdoptedStyleSheet:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleIds"]),(n=r.data.styles)==null||n.forEach(s=>{this.replaceStyleIds(s,t,["styleId"])}),r}}return!1}replace(t,r,n,s){for(const i of s)(Array.isArray(r[i])||typeof r[i]=="number")&&(Array.isArray(r[i])?r[i]=t.getIds(n,r[i]):r[i]=t.getId(n,r[i]));return r}replaceIds(t,r,n){return this.replace(this.crossOriginIframeMirror,t,r,n)}replaceStyleIds(t,r,n){return this.replace(this.crossOriginIframeStyleMirror,t,r,n)}replaceIdOnNode(t,r){this.replaceIds(t,r,["id","rootId"]),"childNodes"in t&&t.childNodes.forEach(n=>{this.replaceIdOnNode(n,r)})}patchRootIdOnNode(t,r){t.type===me.Document||t.rootId||(t.rootId=r),"childNodes"in t&&t.childNodes.forEach(n=>{this.patchRootIdOnNode(n,r)})}}class Lf{constructor(t){R(this,"shadowDoms",new WeakSet),R(this,"mutationCb"),R(this,"scrollCb"),R(this,"bypassOptions"),R(this,"mirror"),R(this,"restoreHandlers",[]),this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(t,r){if(!Xt(t)||this.shadowDoms.has(t))return;this.shadowDoms.add(t);const n=qc({...this.bypassOptions,doc:r,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},t);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(Jc({...this.bypassOptions,scrollCb:this.scrollCb,doc:t,mirror:this.mirror})),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(V.host(t))),this.restoreHandlers.push(Xc({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t))},0)}observeAttachShadow(t){t.contentWindow&&t.contentDocument&&this.patchAttachShadow(t.contentWindow.Element,t.contentDocument)}patchAttachShadow(t,r){const n=this;this.restoreHandlers.push(At(t.prototype,"attachShadow",function(s){return function(i){const a=s.call(this,i),o=V.shadowRoot(this);return o&&Yc(this)&&n.addShadowRoot(o,r),a}}))}reset(){this.restoreHandlers.forEach(t=>{try{t()}catch{}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}for(var Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Of=typeof Uint8Array>"u"?[]:new Uint8Array(256),Gr=0;Gr<64;Gr++)Of[Ht.charCodeAt(Gr)]=Gr;const Na=new Map,Kc=(e,t,r)=>{if(!e||!Qc(e,t)&&typeof e!="object")return;const n=function(i,a){let o=Na.get(i);return o||(o=new Map,Na.set(i,o)),o.has(a)||o.set(a,[]),o.get(a)}(r,e.constructor.name);let s=n.indexOf(e);return s===-1&&(s=n.length,n.push(e)),s};function ln(e,t,r){if(e instanceof Array)return e.map(n=>ln(n,t,r));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:function(n){var s,i=new Uint8Array(n),a=i.length,o="";for(s=0;s<a;s+=3)o+=Ht[i[s]>>2],o+=Ht[(3&i[s])<<4|i[s+1]>>4],o+=Ht[(15&i[s+1])<<2|i[s+2]>>6],o+=Ht[63&i[s+2]];return a%3==2?o=o.substring(0,o.length-1)+"=":a%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[ln(e.buffer,t,r),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const n=e.constructor.name,{src:s}=e;return{rr_type:n,src:s}}return e instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:e.toDataURL()}:e instanceof ImageData?{rr_type:e.constructor.name,args:[ln(e.data,t,r),e.width,e.height]}:Qc(e,t)||typeof e=="object"?{rr_type:e.constructor.name,index:Kc(e,t,r)}:e}const Zc=(e,t,r)=>e.map(n=>ln(n,t,r)),Qc=(e,t)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(n=>typeof t[n]=="function").find(n=>e instanceof t[n]);function Fa(e,t,r,n){const s=[];try{const i=At(e.HTMLCanvasElement.prototype,"getContext",function(a){return function(o,...l){if(!ve(this,t,r,!0)){const c=function(u){return u==="experimental-webgl"?"webgl":u}(o);if("__context"in this||(this.__context=c),n&&["webgl","webgl2"].includes(c))if(l[0]&&typeof l[0]=="object"){const u=l[0];u.preserveDrawingBuffer||(u.preserveDrawingBuffer=!0)}else l.splice(0,1,{preserveDrawingBuffer:!0})}return a.apply(this,[o,...l])}});s.push(i)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{s.forEach(i=>i())}}function Ba(e,t,r,n,s,i){const a=[],o=Object.getOwnPropertyNames(e);for(const l of o)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(l))try{if(typeof e[l]!="function")continue;const c=At(e,l,function(u){return function(...d){const p=u.apply(this,d);if(Kc(p,i,this),"tagName"in this.canvas&&!ve(this.canvas,n,s,!0)){const f=Zc(d,i,this),y={type:t,property:l,args:f};r(this.canvas,y)}return p}});a.push(c)}catch{const c=Yn(e,l,{set(u){r(this.canvas,{type:t,property:l,args:[u],setter:!0})}});a.push(c)}return a}const eu="KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=",za=typeof window<"u"&&window.Blob&&new Blob([(ja=eu,Uint8Array.from(atob(ja),e=>e.charCodeAt(0)))],{type:"text/javascript;charset=utf-8"});var ja;function Af(e){let t;try{if(t=za&&(window.URL||window.webkitURL).createObjectURL(za),!t)throw"";const r=new Worker(t,{name:e==null?void 0:e.name});return r.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;base64,"+eu,{name:e==null?void 0:e.name})}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}class Mf{constructor(t){R(this,"pendingCanvasMutations",new Map),R(this,"rafStamps",{latestId:0,invokeId:null}),R(this,"mirror"),R(this,"mutationCb"),R(this,"resetObservers"),R(this,"frozen",!1),R(this,"locked",!1),R(this,"processMutation",(l,c)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(l)||this.pendingCanvasMutations.set(l,[]),this.pendingCanvasMutations.get(l).push(c)});const{sampling:r="all",win:n,blockClass:s,blockSelector:i,recordCanvas:a,dataURLOptions:o}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,a&&r==="all"&&this.initCanvasMutationObserver(n,s,i),a&&typeof r=="number"&&this.initCanvasFPSObserver(r,n,s,i,{dataURLOptions:o})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,r,n,s,i){const a=Fa(r,n,s,!0),o=new Map,l=new Af;l.onmessage=f=>{const{id:y}=f.data;if(o.set(y,!1),!("base64"in f.data))return;const{base64:h,type:k,width:m,height:g}=f.data;this.mutationCb({id:y,type:It["2D"],commands:[{property:"clearRect",args:[0,0,m,g]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:h}],type:k}]},0,0]}]})};const c=1e3/t;let u,d=0;const p=f=>{d&&f-d<c||(d=f,(()=>{const y=[];return r.document.querySelectorAll("canvas").forEach(h=>{ve(h,n,s,!0)||y.push(h)}),y})().forEach(async y=>{var h;const k=this.mirror.getId(y);if(o.get(k)||y.width===0||y.height===0)return;if(o.set(k,!0),["webgl","webgl2"].includes(y.__context)){const g=y.getContext(y.__context);((h=g==null?void 0:g.getContextAttributes())==null?void 0:h.preserveDrawingBuffer)===!1&&g.clear(g.COLOR_BUFFER_BIT)}const m=await createImageBitmap(y);l.postMessage({id:k,bitmap:m,width:y.width,height:y.height,dataURLOptions:i.dataURLOptions},[m])})),u=requestAnimationFrame(p)};u=requestAnimationFrame(p),this.resetObservers=()=>{a(),cancelAnimationFrame(u)}}initCanvasMutationObserver(t,r,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const s=Fa(t,r,n,!1),i=function(o,l,c,u){const d=[],p=Object.getOwnPropertyNames(l.CanvasRenderingContext2D.prototype);for(const f of p)try{if(typeof l.CanvasRenderingContext2D.prototype[f]!="function")continue;const y=At(l.CanvasRenderingContext2D.prototype,f,function(h){return function(...k){return ve(this.canvas,c,u,!0)||setTimeout(()=>{const m=Zc(k,l,this);o(this.canvas,{type:It["2D"],property:f,args:m})},0),h.apply(this,k)}});d.push(y)}catch{const y=Yn(l.CanvasRenderingContext2D.prototype,f,{set(h){o(this.canvas,{type:It["2D"],property:f,args:[h],setter:!0})}});d.push(y)}return()=>{d.forEach(f=>f())}}(this.processMutation.bind(this),t,r,n),a=function(o,l,c,u){const d=[];return d.push(...Ba(l.WebGLRenderingContext.prototype,It.WebGL,o,c,u,l)),l.WebGL2RenderingContext!==void 0&&d.push(...Ba(l.WebGL2RenderingContext.prototype,It.WebGL2,o,c,u,l)),()=>{d.forEach(p=>p())}}(this.processMutation.bind(this),t,r,n);this.resetObservers=()=>{s(),i(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{const n=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(t);if(!n||r===-1)return;const s=n.map(a=>{const{type:o,...l}=a;return l}),{type:i}=n[0];this.mutationCb({id:r,type:i,commands:s}),this.pendingCanvasMutations.delete(t)}}class Uf{constructor(t){R(this,"trackedLinkElements",new WeakSet),R(this,"mutationCb"),R(this,"adoptedStyleSheetCb"),R(this,"styleMirror",new bf),this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;const n={id:r,styleIds:[]},s=[];for(const i of t){let a;this.styleMirror.has(i)?a=this.styleMirror.getId(i):(a=this.styleMirror.add(i),s.push({styleId:a,rules:Array.from(i.rules||CSSRule,(o,l)=>({rule:El(o,i.href),index:l}))})),n.styleIds.push(a)}s.length>0&&(n.styles=s),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}class Tf{constructor(){R(this,"nodeMap",new WeakMap),R(this,"active",!1)}inOtherBuffer(t,r){const n=this.nodeMap.get(t);return n&&Array.from(n).some(s=>s!==r)}add(t,r){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(r))}destroy(){}}let le,cn,hs,bn=!1;try{if(Array.from([1],e=>2*e)[0]!==2){const e=document.createElement("iframe");document.body.appendChild(e),Array.from=((ko=e.contentWindow)==null?void 0:ko.Array.from)||Array.from,document.body.removeChild(e)}}catch(e){console.debug("Unable to override Array.from",e)}const Oe=new xl;function Yt(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:n,blockClass:s="rr-block",blockSelector:i=null,ignoreClass:a="rr-ignore",ignoreSelector:o=null,maskTextClass:l="rr-mask",maskTextSelector:c=null,inlineStylesheet:u=!0,maskAllInputs:d,maskInputOptions:p,slimDOMOptions:f,maskInputFn:y,maskTextFn:h,hooks:k,packFn:m,sampling:g={},dataURLOptions:v={},mousemoveWait:I,recordDOM:M=!0,recordCanvas:x=!1,recordCrossOriginIframes:U=!1,recordAfter:A=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:E=!1,collectFonts:L=!1,inlineImages:O=!1,plugins:S,keepIframeSrcFn:N=()=>!1,ignoreCSSAttributes:P=new Set([]),errorHandler:b}=e;Kt=b;const w=!U||window.parent===window;let T=!1;if(!w)try{window.parent.document&&(T=!1)}catch{T=!0}if(w&&!t)throw new Error("emit function is required");if(!w&&!T)return()=>{};I!==void 0&&g.mousemove===void 0&&(g.mousemove=I),Oe.reset();const B=d===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:p!==void 0?p:{password:!0},j=f===!0||f==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:f==="all",headMetaDescKeywords:f==="all",headTitleMutations:f==="all"}:f||{};let C;(function(W=window){"NodeList"in W&&!W.NodeList.prototype.forEach&&(W.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in W&&!W.DOMTokenList.prototype.forEach&&(W.DOMTokenList.prototype.forEach=Array.prototype.forEach)})();let D=0;const K=W=>{for(const Le of S||[])Le.eventProcessor&&(W=Le.eventProcessor(W));return m&&!T&&(W=m(W)),W};le=(W,Le)=>{var re;const ie=W;if(ie.timestamp=vn(),!((re=pt[0])!=null&&re.isFrozen())||ie.type===Y.FullSnapshot||ie.type===Y.IncrementalSnapshot&&ie.data.source===G.Mutation||pt.forEach(xe=>xe.unfreeze()),w)t==null||t(K(ie),Le);else if(T){const xe={type:"rrweb",event:K(ie),origin:window.location.origin,isCheckout:Le};window.parent.postMessage(xe,"*")}if(ie.type===Y.FullSnapshot)C=ie,D=0;else if(ie.type===Y.IncrementalSnapshot){if(ie.data.source===G.Mutation&&ie.data.isAttachIframe)return;D++;const xe=n&&D>=n,q=r&&ie.timestamp-C.timestamp>r;(xe||q)&&cn(!0)}};const $=W=>{le({type:Y.IncrementalSnapshot,data:{source:G.Mutation,...W}})},he=W=>le({type:Y.IncrementalSnapshot,data:{source:G.Scroll,...W}}),ct=W=>le({type:Y.IncrementalSnapshot,data:{source:G.CanvasMutation,...W}}),Se=new Uf({mutationCb:$,adoptedStyleSheetCb:W=>le({type:Y.IncrementalSnapshot,data:{source:G.AdoptedStyleSheet,...W}})}),_e=new Rf({mirror:Oe,mutationCb:$,stylesheetManager:Se,recordCrossOriginIframes:U,wrappedEmit:le});for(const W of S||[])W.getMirror&&W.getMirror({nodeMirror:Oe,crossOriginIframeMirror:_e.crossOriginIframeMirror,crossOriginIframeStyleMirror:_e.crossOriginIframeStyleMirror});const qn=new Tf;hs=new Mf({recordCanvas:x,mutationCb:ct,win:window,blockClass:s,blockSelector:i,mirror:Oe,sampling:g.canvas,dataURLOptions:v});const br=new Lf({mutationCb:$,scrollCb:he,bypassOptions:{blockClass:s,blockSelector:i,maskTextClass:l,maskTextSelector:c,inlineStylesheet:u,maskInputOptions:B,dataURLOptions:v,maskTextFn:h,maskInputFn:y,recordCanvas:x,inlineImages:O,sampling:g,slimDOMOptions:j,iframeManager:_e,stylesheetManager:Se,canvasManager:hs,keepIframeSrcFn:N,processedNodeManager:qn},mirror:Oe});cn=(W=!1)=>{if(!M)return;le({type:Y.Meta,data:{href:window.location.href,width:zc(),height:Bc()}},W),Se.reset(),br.init(),pt.forEach(re=>re.lock());const Le=function(re,ie){const{mirror:xe=new xl,blockClass:q="rr-block",blockSelector:Dt=null,maskTextClass:od="rr-mask",maskTextSelector:ad=null,inlineStylesheet:ld=!0,inlineImages:cd=!1,recordCanvas:ud=!1,maskAllInputs:Jn=!1,maskTextFn:dd,maskInputFn:pd,slimDOM:Pt=!1,dataURLOptions:hd,preserveWhiteSpace:md,onSerialize:fd,onIframeLoad:gd,iframeLoadTimeout:yd,onStylesheetLoad:wd,stylesheetLoadTimeout:vd,keepIframeSrcFn:bd=()=>!1}=ie||{};return kt(re,{doc:re,mirror:xe,blockClass:q,blockSelector:Dt,maskTextClass:od,maskTextSelector:ad,skipChild:!1,inlineStylesheet:ld,maskInputOptions:Jn===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:Jn===!1?{password:!0}:Jn,maskTextFn:dd,maskInputFn:pd,slimDOMOptions:Pt===!0||Pt==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:Pt==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:Pt===!1?{}:Pt,dataURLOptions:hd,inlineImages:cd,recordCanvas:ud,preserveWhiteSpace:md,onSerialize:fd,onIframeLoad:gd,iframeLoadTimeout:yd,onStylesheetLoad:wd,stylesheetLoadTimeout:vd,keepIframeSrcFn:bd,newlyAddedElement:!1})}(document,{mirror:Oe,blockClass:s,blockSelector:i,maskTextClass:l,maskTextSelector:c,inlineStylesheet:u,maskAllInputs:B,maskTextFn:h,maskInputFn:y,slimDOM:j,dataURLOptions:v,recordCanvas:x,inlineImages:O,onSerialize:re=>{Vc(re,Oe)&&_e.addIframe(re),Gc(re,Oe)&&Se.trackLinkElement(re),ai(re)&&br.addShadowRoot(V.shadowRoot(re),document)},onIframeLoad:(re,ie)=>{_e.attachIframe(re,ie),br.observeAttachShadow(re)},onStylesheetLoad:(re,ie)=>{Se.attachLinkElement(re,ie)},keepIframeSrcFn:N});if(!Le)return console.warn("Failed to snapshot the document");le({type:Y.FullSnapshot,data:{node:Le,initialOffset:Fc(window)}},W),pt.forEach(re=>re.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&Se.adoptStyleSheets(document.adoptedStyleSheets,Oe.getId(document))};try{const W=[],Le=ie=>{var xe;return H(xf)({mutationCb:$,mousemoveCb:(q,Dt)=>le({type:Y.IncrementalSnapshot,data:{source:Dt,positions:q}}),mouseInteractionCb:q=>le({type:Y.IncrementalSnapshot,data:{source:G.MouseInteraction,...q}}),scrollCb:he,viewportResizeCb:q=>le({type:Y.IncrementalSnapshot,data:{source:G.ViewportResize,...q}}),inputCb:q=>le({type:Y.IncrementalSnapshot,data:{source:G.Input,...q}}),mediaInteractionCb:q=>le({type:Y.IncrementalSnapshot,data:{source:G.MediaInteraction,...q}}),styleSheetRuleCb:q=>le({type:Y.IncrementalSnapshot,data:{source:G.StyleSheetRule,...q}}),styleDeclarationCb:q=>le({type:Y.IncrementalSnapshot,data:{source:G.StyleDeclaration,...q}}),canvasMutationCb:ct,fontCb:q=>le({type:Y.IncrementalSnapshot,data:{source:G.Font,...q}}),selectionCb:q=>{le({type:Y.IncrementalSnapshot,data:{source:G.Selection,...q}})},customElementCb:q=>{le({type:Y.IncrementalSnapshot,data:{source:G.CustomElement,...q}})},blockClass:s,ignoreClass:a,ignoreSelector:o,maskTextClass:l,maskTextSelector:c,maskInputOptions:B,inlineStylesheet:u,sampling:g,recordDOM:M,recordCanvas:x,inlineImages:O,userTriggeredOnInput:E,collectFonts:L,doc:ie,maskInputFn:y,maskTextFn:h,keepIframeSrcFn:N,blockSelector:i,slimDOMOptions:j,dataURLOptions:v,mirror:Oe,iframeManager:_e,stylesheetManager:Se,shadowDomManager:br,processedNodeManager:qn,canvasManager:hs,ignoreCSSAttributes:P,plugins:((xe=S==null?void 0:S.filter(q=>q.observer))==null?void 0:xe.map(q=>({observer:q.observer,options:q.options,callback:Dt=>le({type:Y.Plugin,data:{plugin:q.name,payload:Dt}})})))||[]},k)};_e.addLoadListener(ie=>{try{W.push(Le(ie.contentDocument))}catch(xe){console.warn(xe)}});const re=()=>{cn(),W.push(Le(document)),bn=!0};return document.readyState==="interactive"||document.readyState==="complete"?re():(W.push(ye("DOMContentLoaded",()=>{le({type:Y.DomContentLoaded,data:{}}),A==="DOMContentLoaded"&&re()})),W.push(ye("load",()=>{le({type:Y.Load,data:{}}),A==="load"&&re()},window))),()=>{W.forEach(ie=>ie()),qn.destroy(),bn=!1,Kt=void 0}}catch(W){console.warn(W)}}var Wa,bt;Yt.addCustomEvent=(e,t)=>{if(!bn)throw new Error("please add custom event after start recording");le({type:Y.Custom,data:{tag:e,payload:t}})},Yt.freezePage=()=>{pt.forEach(e=>e.freeze())},Yt.takeFullSnapshot=e=>{if(!bn)throw new Error("please take full snapshot after start recording");cn(e)},Yt.mirror=Oe,(bt=Wa||(Wa={}))[bt.NotStarted=0]="NotStarted",bt[bt.Running=1]="Running",bt[bt.Stopped=2]="Stopped";var Ae=(e=>(e.Closed="close.click",e.Complete="survey.completed",e.FeedbackClosed="feedback.closed",e.PageChange="page.change",e.API="api",e.Override="override",e))(Ae||{}),F=(e=>(e.ReplayCapture="replay.capture",e.ReplayPaused="replay.paused",e.ReplayResumed="replay.resumed",e.FeedbackButtonLoaded="feedback.button.loaded",e.SDKReady="sdk.ready",e.SurveyAppeared="survey.appeared",e.SurveyCloseRequested="survey.closeRequested",e.SurveyClosed="survey.closed",e.SurveyDimensions="survey.dimensions",e.SurveyFadingOut="survey.fadingOut",e.SurveyHeight="survey.height",e.SurveyPresented="survey.presented",e.SurveyLifeCycle="survey.lifeCycle",e.SurveyWidth="survey.width",e.SurveyWillClose="survey.willClose",e.SurveyWillPresent="survey.will.present",e.CloseSurveyOnOverlayClick="close.survey.overlayClick",e.VisitorIDUpdated="visitor.id.updated",e.QuestionAnswered="question.answered",e))(F||{});const dr={FEEDBACK_BUTTON_LOADED:"feedback.button.loaded",SDK_READY:"sdk.ready",SURVEY_APPEARED:"survey.appeared",SURVEY_CLOSED:"survey.closed",SURVEY_DIMENSIONS:"survey.dimensions",SURVEY_FADING_OUT:"survey.fadingOut",SURVEY_HEIGHT:"survey.height",SURVEY_WIDTH:"survey.width",SURVEY_PRESENTED:"survey.presented",SURVEY_LIFE_CYCLE:"survey.lifeCycle",SURVEY_WILL_CLOSE:"survey.willClose",SURVEY_WILL_PRESENT:"survey.will.present",QUESTION_ANSWERED:"question.answered",REPLAY_CAPTURE:"replay.capture",CLOSE_SURVEY_ON_OVERLAY_CLICK:"close.survey.overlayClick",VISITOR_ID_UPDATED:"visitor.id.updated",DATA:{DISMISS_REASONS:{API:"api",CLOSED:"close.click",COMPLETE:"survey.completed",PAGE_CHANGE:"page.change",OVERRIDE:"override"},SURVEY_ID:"survey.id"}};let Hr;const Df=new Uint8Array(16);function Pf(){if(!Hr&&(Hr=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Hr))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Hr(Df)}const fe=[];for(let e=0;e<256;++e)fe.push((e+256).toString(16).slice(1));const Va={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function yt(e,t,r){if(Va.randomUUID&&!e)return Va.randomUUID();const n=(e=e||{}).random||(e.rng||Pf)();return n[6]=15&n[6]|64,n[8]=63&n[8]|128,function(s,i=0){return fe[s[i+0]]+fe[s[i+1]]+fe[s[i+2]]+fe[s[i+3]]+"-"+fe[s[i+4]]+fe[s[i+5]]+"-"+fe[s[i+6]]+fe[s[i+7]]+"-"+fe[s[i+8]]+fe[s[i+9]]+"-"+fe[s[i+10]]+fe[s[i+11]]+fe[s[i+12]]+fe[s[i+13]]+fe[s[i+14]]+fe[s[i+15]]}(n)}const _=new class{constructor(){ue(this,"breadcrumbs",[])}getTimeStamp(){return new Date().toISOString()}addBreadcrumb(e){{const{data:t,message:r}=e,n=t&&Object.keys(t).length?t:null;n?console.info(r,n):console.info(r)}this.breadcrumbs.push(e),this.breadcrumbs.length>300&&this.breadcrumbs.shift()}debug(e,t="debug"){this.addBreadcrumb({category:t,level:"info",message:e,timestamp:this.getTimeStamp(),type:"debug"})}error(e,t={}){this.addBreadcrumb({category:"error",data:t,level:"error",message:e,timestamp:this.getTimeStamp(),type:"error"})}http(e,t){this.addBreadcrumb({category:"xhr",data:t,message:e,timestamp:this.getTimeStamp(),type:"http"})}info(e,t={}){this.addBreadcrumb({category:"info",data:t,level:"info",message:e,timestamp:this.getTimeStamp(),type:"info"})}navigation(e,t){this.addBreadcrumb({category:"navigation",data:t,message:e,timestamp:this.getTimeStamp(),type:"navigation"})}},Ga=()=>{try{return window.parent.Intercom}catch{return null}},Ha=[Object.freeze(Object.defineProperty({__proto__:null,disable:()=>{const e=Ga();e&&(e.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),e.ul_wasVisible&&e("update",{hide_default_launcher:!0}))},enable:()=>{const e=Ga();e&&(e.ul_wasVisible&&e("update",{hide_default_launcher:!1}),delete e.ul_wasVisible)}},Symbol.toStringTag,{value:"Module"}))];class tu{static disable(){Ha.forEach(t=>t.disable())}static enable(){Ha.forEach(t=>t.enable())}}var _f=class extends Error{constructor(e,t,r){super(`Possible EventEmitter memory leak detected. ${r} ${t.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=t,this.count=r,this.name="MaxListenersExceededWarning"}},ru=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=ru.defaultMaxListeners,this.hasWarnedAboutPotentialMemoryLeak=!1}_emitInternalEvent(e,t,r){this.emit(e,t,r)}_getListeners(e){return Array.prototype.concat.apply([],this.events.get(e))||[]}_removeListener(e,t){const r=e.indexOf(t);return r>-1&&e.splice(r,1),[]}_wrapOnceListener(e,t){const r=(...n)=>(this.removeListener(e,r),t.apply(this,n));return Object.defineProperty(r,"name",{value:t.name}),r}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}eventNames(){return Array.from(this.events.keys())}emit(e,...t){const r=this._getListeners(e);return r.forEach(n=>{n.apply(this,t)}),r.length>0}addListener(e,t){this._emitInternalEvent("newListener",e,t);const r=this._getListeners(e).concat(t);if(this.events.set(e,r),this.maxListeners>0&&this.listenerCount(e)>this.maxListeners&&!this.hasWarnedAboutPotentialMemoryLeak){this.hasWarnedAboutPotentialMemoryLeak=!0;const n=new _f(this,e,this.listenerCount(e));console.warn(n)}return this}on(e,t){return this.addListener(e,t)}once(e,t){return this.addListener(e,this._wrapOnceListener(e,t))}prependListener(e,t){const r=this._getListeners(e);if(r.length>0){const n=[t].concat(r);this.events.set(e,n)}else this.events.set(e,r.concat(t));return this}prependOnceListener(e,t){return this.prependListener(e,this._wrapOnceListener(e,t))}removeListener(e,t){const r=this._getListeners(e);return r.length>0&&(this._removeListener(r,t),this.events.set(e,r),this._emitInternalEvent("removeListener",e,t)),this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){return e?this.events.delete(e):this.events.clear(),this}listeners(e){return Array.from(this._getListeners(e))}listenerCount(e){return this._getListeners(e).length}rawListeners(e){return this.listeners(e)}},nu=ru;nu.defaultMaxListeners=10;const z=new nu,Sn=async e=>{await new Promise(t=>{setTimeout(t,e)})},eo=({"userleap-platform":e})=>{var t;return((t=window.UserLeap)==null?void 0:t.forceDirectEmbed)||e!=="web"};class su{constructor(t){ue(this,"storage");ue(this,"tempStorage",{});ue(this,"isStorageAvailable");try{this.storage=window[t];const r="__storage_test__";this.storage.setItem(r,r),this.storage.removeItem(r),this.isStorageAvailable=!0}catch{this.isStorageAvailable=!1}}setItem(t,r){this.isStorageAvailable&&this.storage?this.storage.setItem(t,r):this.tempStorage[t]=r}setItemObject(t,r){try{this.setItem(t,JSON.stringify(r))}catch(n){n instanceof Error&&(n.stack=t+": "+r,window.UserLeap.reportError("Failed to save to local storage",n))}}getItem(t){return this.isStorageAvailable&&this.storage?this.storage.getItem(t):this.tempStorage[t]}getItemObject(t){const r=this.getItem(t);if(r)try{return JSON.parse(r)}catch(n){n instanceof Error&&(n.stack=t+": "+r,window.UserLeap.reportError("Failed to parse local storage",n))}return{}}removeItem(t){this.isStorageAvailable&&this.storage?this.storage.removeItem(t):delete this.tempStorage[t]}clear(){this.isStorageAvailable&&this.storage?this.storage.clear():this.tempStorage={}}}const ce=new su("sessionStorage"),Ce=new su("localStorage");class Nf{constructor(t){ue(this,"payload");ue(this,"promise");ue(this,"reject",()=>{});ue(this,"resolve",()=>{});this.payload=t,this.promise=new Promise((r,n)=>{this.reject=n,this.resolve=r})}resolveRequest(t){this.resolve(t)}}const te={replay:null},Ff=()=>{const e=[];return te.replay&&e.push("replay"),e.join(",")},Bf=10;let iu=!1,ou="",Yr=!1,au=!1,un=[];const zf=e=>e._config&&e._config.installationMethod?e._config.installationMethod:e._gtm?"web-gtm":e._segment?"web-segment":"web-snippet",Ya=e=>{var t;(t=e==null?void 0:e.blockedURI)!=null&&t.includes(window.UserLeap._API_URL)&&(au=!0,console.warn(`[Sprig] ${e.blockedURI} is blocked by Content-Security-Policy`))},ci=(e="")=>{iu=!0,ou=e};function Te(e={}){const t={"Content-Type":"application/json","userleap-platform":"web","x-ul-sdk-version":"2.37.1","x-ul-installation-method":zf(e),"sprig-modules":Ff(),"x-ul-package-version":"2.37.1"};if(e.envId&&(t["x-ul-environment-id"]=e.envId),e.token&&(t.Authorization="Bearer "+e.token),e.userId&&(t["x-ul-user-id"]=e.userId),e.visitorId&&(t["x-ul-visitor-id"]=e.visitorId),e.partnerAnonymousId&&(t["x-ul-anonymous-id"]=e.partnerAnonymousId),e.mobileHeadersJSON){const r=JSON.parse(e.mobileHeadersJSON);Object.assign(t,r)}return e.locale&&(t["accept-language"]=e.locale),window.previewMode&&(t["x-ul-preview-mode"]="1"),t}const $a=async({shouldDropOnRateLimit:e,...t})=>{if(e)return{status:429};{const r=new Nf(t);return un.push(r),r.promise}},Ge=async(e,t)=>{const{retries:r=0,shouldDropOnRateLimit:n=!1,shouldRetryRequest:s=!1,...i}=t,a={url:e,options:i,retries:r,shouldDropOnRateLimit:n};if(Yr&&!s)return $a(a);const o={ok:!1,reportError:!1};if(iu)return console.info(`UserLeap - ${ou}`),o;try{const l=await fetch(e,i);if(l.status===429){if(!Yr&&!n||s){Yr=!0;const c=l.headers.has("ratelimit-reset")?Number(l.headers.get("ratelimit-reset")):Bf;return await Sn(1e3*c),Ge(e,{...i,shouldDropOnRateLimit:n,shouldRetryRequest:!0})}return $a(a)}if(Yr=!1,un.length&&(un.map(c=>{const u=c.payload;Ge(u.url,{...u.options,retries:u.retries,shouldDropOnRateLimit:u.shouldDropOnRateLimit}).then(d=>{c.resolveRequest(d)})}),un=[]),l.ok){if(l.status===249)return ci(),o;const c=await l.text();try{return c&&c!=="OK"&&(l.json=JSON.parse(c)),l}catch{return{ok:!1,reportError:!1,error:new Error(`failed parsing response json for ${e} - ${c}`)}}}return l}catch(l){const c=r+1;return c>5||au?{ok:!1,reportError:!1,error:l}:(await Sn(1e3*Math.pow(2,r)),Ge(e,{...i,retries:c}))}},qa="ul-view-sdk-script",jf=new Set(["ios","android"]),nt="visitors",st="environments";async function ze(e,t){var i,a,o;const{shouldDropOnRateLimit:r,...n}=t;n.headers=Object.assign(Te(window.UserLeap),n.headers);const s=await Ge(e,{...n,shouldDropOnRateLimit:r});if(s.ok){const l=(i=s.headers)==null?void 0:i.get("Authorization"),c=l?l.split(" "):void 0,u=c&&c.length===2?c[1]:void 0,d=(a=s.headers)==null?void 0:a.get("x-ul-visitor-id");if(window.UserLeap.userId&&d===window.UserLeap.visitorId){const p=Ce.getItemObject("sprig.anon.env.vid.map");p&&p[window.UserLeap.envId]===d&&(delete p[window.UserLeap.envId],Ce.setItemObject("sprig.anon.env.vid.map",p))}u&&d&&(d!==window.UserLeap.visitorId||window.UserLeap.token!==u)&&(Ie("token",u),Ie("vid",d),z.emit(F.VisitorIDUpdated,{visitorId:d}),window.UserLeap.token=u,window.UserLeap.visitorId=d)}return(o=s.json)!=null&&o.logMessage&&console.warn(`[Sprig] ${s.json.logMessage}`),s}function Ie(e,t){const r=Ce.getItemObject("userleap.ids");let n=r[window.UserLeap.envId];n?n[e]=t:n={[e]:t},r[window.UserLeap.envId]=n,Ce.setItemObject("userleap.ids",r)}function to(){return window.previewMode?"0":window.UserLeap.visitorId??""}function Me(e,t,r){const n=[window.UserLeap._API_URL,"sdk",e];return t&&t.forEach(s=>{n.push(s),s===st?n.push(window.UserLeap.envId):s===nt&&n.push(to())}),r&&n.push(r),n.join("/")}const Qt=async(e,t,r)=>{var T,B,j;const{context:n,delay:s,forceBrandedLogo:i,endCard:a,isFeedback:o=!1,heatmap:l,locale:c,previewMode:u,productConfig:d,questions:p,responseGroupUid:f,surveyId:y,uuid:h,vid:k,sessionReplay:m,studyType:g}=e,v=Te(window.UserLeap),I=pr(v),M=$n(v);if(m)if(I)z.emit(F.ReplayCapture,{responseGroupUid:f,hasQuestions:!!(p!=null&&p.length),surveyId:y,uploadId:m.uploadId,replayType:m.replayDurationType??"before",seconds:m.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:yt(),mediaType:"screen",questionId:1,responseGroupUid:f,surveyId:y,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}});else{if(!te.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};te.replay.scheduleOrCaptureReplay({responseGroupId:f,surveyId:y,visitorId:k,replayParams:m,completeUploadHeaders:v,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:p.length===0})}if(l){if(!te.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};const{eventId:C,replayParams:D,responseGroupUid:K,surveyId:$}=l;await te.replay.initializeReplay({maxReplayDurationSeconds:300,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0,apiUrl:window.UserLeap._API_URL,replaySettings:r}),te.replay.tryReplayAction(()=>{var he;return(he=te.replay)==null?void 0:he.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:v,eventId:C,isHeatmap:!0,replayParams:D,responseGroupId:K,surveyId:$,triggerTimestamp:Date.now(),visitorId:k})},"Error in scheduling/capturing replay")}if(k==null||!(p!=null&&p.length))return _.info("CannotDisplaySurvey",{vid:k}),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(Wf(p))return{success:!1,message:"[Sprig] bundled version does not support video voice",surveyState:"no survey"};if(window.UserLeap.container){_.info("AlreadyDisplayingSurvey");const C="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(C),{success:!1,message:C,surveyState:"no survey"}}if(k!==window.UserLeap.visitorId&&h!==window.UserLeap.visitorId&&!window.previewMode){const C="Attempted to display survey to a different visitor";return window.UserLeap.reportError("DisplaySurvey",new Error(C)),{success:!1,message:C,surveyState:"no survey"}}_.info("ShowingSurvey",{surveyId:y}),(T=te.replay)==null||T.RecordSurveyShown({id:y,userAgent:window.navigator.userAgent}),tu.disable(),z.emit(F.SurveyWillPresent,{name:F.SurveyWillPresent,"survey.id":y});let x,U,A,E,L=document.createElement("div");const O=C=>{const{"view.version":D}=C;D!==v["x-ul-sdk-version"]&&cu(),z.removeListener("verify.view.version",O)};z.on("verify.view.version",O),window.UserLeap.useMobileStyling=M,eo(v)?(x="ul-direct-embeded-frame",U=document.head,A=window,E=!1,(()=>{const C=Te(window.UserLeap),D=pr(C),K=window.UserLeap.forceDirectEmbed,$=C["userleap-platform"]==="web";return D||K&&$})()&&(lu(y,o),L.id=x,window.UserLeap.container.appendChild(L),uu(),z.emit(F.SurveyLifeCycle,{state:"presented"}),z.emit(F.SurveyPresented,{name:F.SurveyPresented,"survey.id":y}))):{frameId:x,contentWinDocHead:U,contentWindow:A,hasOverlay:E,iframe:L}=Gf({productConfig:d,useMobileStyling:M,surveyId:y,isFeedback:o}),window.UserLeap.frameId=x;const S={apiURL:window.UserLeap._API_URL,cards:p,configureExitOnOverlayClick:C=>{z.once(F.CloseSurveyOnOverlayClick,C)},context:n,endCard:a,envId:window.UserLeap.envId,eventEmitFn:z.emit.bind(z),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:i,frame:L,headers:v,locale:c,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:Ce.getItem("sprig.previewKey"),previewMode:u,productConfig:{framePosition:d==null?void 0:d.framePosition,desktopDisplay:d==null?void 0:d.desktopDisplay,placement:d==null?void 0:d.placement},responseGroupUid:f,startingQuestionIdx:(B=window.UserLeap.config)==null?void 0:B.startingQuestionIdx,studyType:g,styleNonce:window.UserLeap.styleNonce,surveyId:y,tabTitle:document.title,trackPageViewUrl:t,ulEvents:dr,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:M,userId:h,viewDocument:A==null?void 0:A.document,viewWindow:A,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},...window.UserLeap._config};(j=window.UserLeap._config)!=null&&j.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null});const N=(o?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??d.customStyles;S.customStyles=N,A&&(A.__cfg=S),window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:S.path;const P=document.getElementById(qa);P&&P.remove();const b=function(){const C=document.createElement("script");return window.UserLeap.nonce&&C.setAttribute("nonce",window.UserLeap.nonce),C.id=qa,C}();S.installationMethod==="web-npm"||S.installationMethod;{const{default:C}=await Promise.resolve().then(()=>require("./view-DpdkQw3G.cjs"));C.configure(S),E&&window.UserLeap.container&&window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})}U==null||U.appendChild(b);const w={success:!0,surveyState:"ready",surveyId:y,responseGroupUid:f};return window.UserLeap.isMobileSDK&&s&&(w.delay=s),w};function $n(e){var r;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const t=((r=window.UserLeap.windowDimensions)==null?void 0:r.width)??document.body.clientWidth;return pr(e)||t>10&&t<500}function pr(e){return jf.has(e["userleap-platform"])}const Wf=e=>e.some(t=>t.type==="videovoice"),ro="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 ms="0px",lu=(e,t,r)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className="ul-container"+(t?" ul-container-feedback":""),e&&(window.UserLeap.container.dataset.studyId=e.toString());const n=mu();r&&n&&!window.UserLeap.useMobileStyling?n.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},cu=(e,t)=>{var n;Yf();const r=window.UserLeap.container;if(r)try{(n=r.parentNode)==null||n.removeChild(r),window.UserLeap.container=null,Ie("trackStartUrl",null),z.emit(F.SurveyLifeCycle,{state:"dismissed"}),z.emit(F.SurveyClosed,{name:F.SurveyClosed,initiator:e,"survey.id":parseInt(r.dataset.studyId),...t&&{studyType:t}})}catch(s){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${e} `+r),s instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",s)}},uu=()=>{z.once(F.SurveyWillClose,({initiator:e,studyType:t})=>{z.removeAllListeners(F.CloseSurveyOnOverlayClick),cu(e,t)})},Vf=(e,t,r,n)=>{var u,d;const s={position:"fixed",bottom:"0px",right:ms,border:0,backgroundColor:"rgba(0,0,0,0)",zIndex:2147483646,transition:"height 0.2s ease-in-out",maxWidth:"100%"},i=Object.assign({},t,window.UserLeap),{desktopDisplay:a}=t||{},o=a==="center-modal";let l;o&&(i.framePosition="center");let c=!1;if(r)(u=window.UserLeap.windowDimensions)!=null&&u.width?s.width=`${window.UserLeap.windowDimensions.width}px`:s.width="100%",(d=window.UserLeap.windowDimensions)!=null&&d.height?s.maxHeight=window.UserLeap.windowDimensions.height-20+"px":window.UserLeap.maxHeight?s.maxHeight=window.UserLeap.maxHeight:s.maxHeight=document.body.clientHeight-20+"px",["light","dark"].includes(i.overlayStyleMobile)&&(c=!0);else{s.width="360px",s.maxHeight=window.UserLeap.maxHeight||"66vh";const p=()=>{c=!0,l={margin:"auto",position:"static"}};if(n)o?p():l={position:"relative",height:"300px"};else switch(i.framePosition){case"bottomLeft":l={left:ms};break;case"topLeft":l={left:ms,top:0};break;case"topRight":l={top:0};break;case"center":p()}}return c&&((p,f)=>{const y={position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646},h=f?p.overlayStyleMobile:p.overlayStyle;y["background-color"]=h==="light"?"rgba(255,255,255, 0.95)":"rgba(0,0,0,0.9)",f||(y.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,y)})(i,r),Object.assign(e.style,s,l),c},Gf=({productConfig:e,useMobileStyling:t,surveyId:r,isFeedback:n})=>{var p,f;const s=ro,i=n&&e.desktopDisplay==="slider";lu(r,n,i),Hf();const a=document.createElement("iframe");a.id=s,a.setAttribute("title","Sprig User Feedback Dialog");const o=Vf(a,e,t,n);uu();let l=!1;a.setHeight=y=>{parseInt(a.style.height)==y&&l||(l=!0,a.style.height=`${y}px`,z.emit(F.SurveyHeight,{name:F.SurveyHeight,contentFrameHeight:y,"survey.id":r}))};let c=!1;a.setWidth=y=>{parseInt(a.style.width)==y&&c||(c=!0,a.style.width=`${y}px`,z.emit(F.SurveyWidth,{name:F.SurveyWidth,contentFrameWidth:y,"survey.id":r}))},(p=window.UserLeap.container)==null||p.appendChild(a),e&&(t?e.exitOnOverlayClickMobile:e.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{z.emit(F.CloseSurveyOnOverlayClick)}),z.emit(F.SurveyLifeCycle,{state:"presented"}),z.emit(F.SurveyPresented,{name:F.SurveyPresented,"survey.id":r});const u=(f=a.contentWindow)==null?void 0:f.document;if(u&&(u.open("text/html","replace"),u.write("<!doctype html><head></head><body></body></html>"),u.close(),!t)){const y=u.body;y.style.display="flex",y.style.alignItems="center"}const d=u==null?void 0:u.head;return{frameId:s,contentWinDocHead:d,contentWindow:a.contentWindow,hasOverlay:o,iframe:a}},du={[F.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},Hf=()=>{Object.entries(du).forEach(([e,t])=>{z.on(e,t)})},Yf=()=>{Object.entries(du).forEach(([e,t])=>{z.off(e,t)})},Ja=Object.freeze({contains:(e,t)=>t.includes(e),notContains:(e,t)=>!t.includes(e),exactly:(e,t)=>t===e,notExactly:(e,t)=>t!==e,startsWith:(e,t)=>t.startsWith(e),endsWith:(e,t)=>t.endsWith(e),regex:(e,t)=>new RegExp(e).test(t),legacy:(e,t)=>new RegExp(e,"i").test(t)});function no(e,t){const{matchType:r,pattern:n}=e,s=r?Ja[r]:Ja.legacy;let i=!1;try{i=s(n,t)}catch(a){const o=`[Sprig] (ERR-445) Failed to check url match with pattern ${n}`;a instanceof Error&&(console.warn(o,a),a.stack=JSON.stringify(e),window.UserLeap.reportError(o,a))}return i}const pu=e=>{const{pageUrlEvents:t}=window.UserLeap._config,r=t==null?void 0:t.find(n=>n.id===e);return!!r&&no(r,window.location.href)},Be=e=>!!e&&e.nodeType===Node.ELEMENT_NODE,Xa=e=>e instanceof HTMLElement||e instanceof SVGElement,hr=({document:e,elementId:t,styleString:r,nonce:n})=>{const s=e.getElementById(t);if(s)return void(s.textContent=r);const i=e.createElement("style");n&&(i.nonce=n),i.textContent=r,i.id=t,e.head.appendChild(i)},$f=(e,t)=>{const r=t.querySelector(".sprig-question-body");if(!Be(r))return e;const n=r.scrollHeight;return n<100?e:e-(n-100)},Ka=(e,t)=>{const r=t.querySelector(e);if(!Be(r))return 0;const n=getComputedStyle(r);return parseFloat(n.paddingLeft)+parseFloat(n.paddingRight)+(parseFloat(n.marginLeft)+parseFloat(n.marginRight))+(parseFloat(n.borderLeftWidth)+parseFloat(n.borderRightWidth))},hu=(e,t,r)=>{const n=e.querySelector(".ul-card__container"),s=e.querySelector(".ul-app");let i=600,a=360,o=0;if(Be(n)&&Be(s)){const l=n.querySelector(".ul-card--matrix_grid"),c=!l&&t&&r;try{c&&(s.style.width="360px"),i=n.clientHeight,i+=(p=>{const f=p.querySelector(".sprig-question-body"),y=p.querySelector(".ul-card"),h=p.querySelector(".ul-card-main-content"),k=p.querySelector(".ul-footer"),m=p.querySelector(".sprig-container");let g=0;return Be(y)&&(g+=y.scrollHeight-y.clientHeight),Be(h)&&(g+=h.scrollHeight-h.clientHeight),Be(f)&&(g+=f.scrollHeight-f.clientHeight),Be(k)&&Be(m)&&m.clientHeight===0&&(g+=k.clientHeight),g})(e);const u=getComputedStyle(n);o=i;const d=parseFloat(u.marginTop)+parseFloat(u.marginBottom);i+=d+(parseFloat(u.borderTopWidth)+parseFloat(u.borderBottomWidth)),l&&(a=l.scrollWidth,a+=Ka(".ul-card__container",e),a+=Ka(".sprig-question-body",e))}finally{c&&s.style.removeProperty("width")}}return[i+1,a,$f(o,e)]},mu=()=>Z,Rt=()=>document.getElementById("sprig-feedback-container"),ui=()=>document.getElementById("sprig-feedback-loading-animation"),fu=()=>!!document.getElementById(ro);let Za=!1,Z=null,je=null,so=!1,er=null,ut=null;const qf=["bottom-left","bottom-right","center-left","center-right"],In=()=>{var t;const e=window.UserLeap.container;return((t=e==null?void 0:e.parentElement)==null?void 0:t.id)==="sprig-feedback-loading-container"},gu=()=>document.getElementById("sprig-feedback-error-container"),yu=()=>{if(!Z)return 0;const e=Z==null?void 0:Z.clientWidth,t=window.getComputedStyle(Z);return e+parseInt(t.borderRightWidth||"0")+parseInt(t.borderLeftWidth||"0")},Cn=e=>{const t=Rt();t&&(ut!=null&&ut.endsWith("right")?t.style.right=`${e}px`:ut!=null&&ut.endsWith("left")&&(t.style.left=`${e}px`))},fs=()=>{if(Z&&(In()||gu())){z.off(F.SurveyAppeared,$t),di();const e=yu();return Cn(-e),!0}return!1},$t=()=>{if(!Z||!je)return;const e=ui();e&&e.remove(),Z.style.height="auto",Z.style.width="auto",je.disabled=!1,so=!1},di=()=>{if(Z&&!ui()){const e=(()=>{if(ui())return;const t=document.createElement("div");return t.className="ul-loading-spinner-container",t.id="sprig-feedback-loading-animation",t.role="progressbar",t.setAttribute("aria-live","polite"),t.setAttribute("aria-busy","true"),t.setAttribute("aria-label","Processing..."),t.innerHTML=`
62
62
  <div class="ul-loading-spinner">
63
63
  <div class="first"></div>
64
64
  <div class="second"></div>
@@ -69,4 +69,4 @@ or you can use record.mirror to access the mirror instance during recording.`;le
69
69
  <circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
70
70
  <path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
71
71
  <circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
72
- </svg>`;const t=document.createElement("h3");return t.className="sprig-feedback-error-text",t.innerText="There was an error while loading the survey",e.appendChild(t),e},pi=new class{constructor(){ue(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(e){try{return!(!e||typeof e!="object"||Array.isArray(e))&&(Object.keys(this._ldData).forEach(t=>{delete this._ldData[t]}),Object.keys(e).forEach(t=>this._ldData[`!launch_darkly_${t}`]=(e[t]??0)+1),!0)}catch(t){return t instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",t),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}};Object.freeze(pi);const dn=new class{constructor(){ue(this,"_optimizelyData",{})}setOptimizelyExperiment(e,t=!0){if(!e||typeof e!="object")return!1;const{experiments:r}=e;try{return t&&Object.keys(this._optimizelyData).map(n=>{delete this._optimizelyData[n]}),r&&r.map(n=>{const{id:s,variation:i}=n,a=this.transformExperimentId(s);i&&typeof i=="string"&&(this._optimizelyData[a]=i)}),!0}catch(n){return n instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",n),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(e){return this._optimizelyData[this.transformExperimentId(e)]}transformExperimentId(e){return"!optimizely_experiments_"+e}getAndSetWebOptimizelyExperiments(){var e;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const t=(e=window.optimizely.get("state"))==null?void 0:e.getExperimentStates({isActive:!0});if(t){const r=Object.keys(t).map(n=>{var s,i;return(s=t[n].variation)!=null&&s.name?{id:n,variation:(i=t[n].variation)==null?void 0:i.name}:{id:n,variation:"Original"}});return this.setOptimizelyExperiment({experiments:r},!1),!0}return!1}return!1}catch(t){return t instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",t),!1}}};Object.freeze(dn);class Xf{constructor(t,r){ue(this,"paused");ue(this,"queue");ue(this,"ul");this.ul=t,this.paused=!1,this.queue=[],this.flush(r)}flush(t){const r=t.length;if(r)for(let n=0;n<r;n++)this.push(t[n])}isPaused(){return this.paused}pause(){this.paused=!0}unpause(){this.paused=!1;const t=this.queue.slice();this.empty(),this.flush(t)}push(t){if(this.paused)this.queue.push(t);else if(t instanceof Function)t();else{const r=Array.prototype.slice.call(t,1),n=t[0],s=this.ul[n];s instanceof Function?s.apply(this.ul,r):n&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",n)}}perform(t){if(this.paused){let r=()=>{};const n=new Promise(function(s){r=function(){s(t())}});return this.queue.push(r),n}return t()}empty(){this.queue.length=0}}let vu=!0,hi=!1;const Kf=["sdk_event_queue_latency_seconds","sdk_replay_add_event_batch_seconds","sdk_replay_cleanup_seconds","sdk_replay_compression_seconds","sdk_replay_get_events_between_seconds","sdk_replay_snapshot_seconds","sdk_mutations_nodes_added","sdk_mutations_nodes_removed","sdk_mutations_attributes_changed","sdk_mutations_character_data","sdk_dom_nodes_count","sdk_page_html_characters"];let mi,qt={};class Zf{constructor(t){ue(this,"_values",[]);ue(this,"_isWebMetric");this.name=t,this._isWebMetric=Kf.includes(this.name)}report(t){if(vu&&this._values.push({time:Date.now(),value:t}),hi||!this._isWebMetric)return;const r=this.findExceededThreshold(t);r&&mi&&mi(t,r)}collect(){const t=this._values;return this._values=[],t}findExceededThreshold(t){const r=qt[this.name];if(r)return r.find(n=>this.valueExceedsThreshold(t,n))}valueExceedsThreshold(t,r){return r.type==="max"?t>r.value:r.type==="min"&&t<r.value}}const yr={},Ve=e=>{const t=new Zf(e);return yr[e]=t,t},bu=(e,t)=>{let r=yr[e];return r||(r=Ve(e)),r.report(t)},Qf=({reportingIntervalSeconds:e,postMetrics:t})=>{e?setInterval(()=>{(async r=>{const n=Object.values(yr).map(s=>({name:s.name,values:s.collect()}));if(n.some(s=>s.values.length))try{await r(JSON.stringify(n))}catch(s){s instanceof Error&&_.error("MetricsErr",{error:{message:s.message,name:s.name}})}})(t)},1e3*e):vu=!1};let Su,Iu;const fi=e=>{let t=0,r=e.firstElementChild;for(;r;)t+=fi(r),r.shadowRoot&&(t+=fi(r.shadowRoot)),r=r.nextElementSibling,t++;return t},el=()=>{Su.report(fi(document.body)),Iu.report(document.documentElement.innerHTML.length)},gi=(e,t)=>{const r=performance.now();document.hidden?setTimeout(()=>gi(e,t),e):setTimeout(()=>{const n=performance.now()-r;t.report(n/1e3),setTimeout(()=>gi(e,t),e)},0)};let kn,En,xn,Rn,tl,dt={};const $r=(e,t=1)=>{const{name:r}=e;dt[r]=(dt[r]||0)+t},Cu=e=>{let t=1;return e.childNodes.forEach(r=>{t+=Cu(r)}),t},rl=e=>{let t=0;return e.forEach(r=>{t+=Cu(r)}),t},eg=e=>{switch(e.type){case"childList":return $r(kn,rl(e.addedNodes)),void $r(En,rl(e.removedNodes));case"attributes":return void $r(xn);case"characterData":return void $r(Rn)}},tg=e=>e.forEach(eg),rg=()=>{kn.report(dt[kn.name]||0),En.report(dt[En.name]||0),xn.report(dt[xn.name]||0),Rn.report(dt[Rn.name]||0),dt={}},ng=(e=1e3)=>{kn=Ve("sdk_mutations_nodes_added"),En=Ve("sdk_mutations_nodes_removed"),xn=Ve("sdk_mutations_attributes_changed"),Rn=Ve("sdk_mutations_character_data"),tl=new MutationObserver(tg),tl.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),setInterval(rg,e)},sg=({isWeb:e,reportingIntervalSeconds:t,thresholds:r,postMetrics:n})=>{((s,i)=>{qt={},hi=!1,s==null||s.forEach(a=>{var o;a.metric in qt||(qt[a.metric]=[]),(o=qt[a.metric])==null||o.push(a)}),mi=i})(r,(s,i)=>{var a,o;if((a=te.replay)!=null&&a.isReplayRecording()){const l=`Value: ${s} on ${i.metric} violated threshold of ${i.type} ${i.value}`;(o=te.replay)==null||o.disableRecording("Threshold violated",new Error(l),{reportError:!1}),window.UserLeap.reportError("Sdk Performance Metric threshold violated",new Error("Sdk Performance Metric threshold violated"),{metricName:i.metric,type:i.type,value:i.value},{metricName:i.metric}),hi=!0}}),Qf({reportingIntervalSeconds:t,postMetrics:n}),e&&(((s=1e3)=>{const i=Ve("sdk_event_queue_latency_seconds");gi(s,i)})(),((s=1e4)=>{Su=Ve("sdk_dom_nodes_count"),Iu=Ve("sdk_page_html_characters"),el(),setInterval(el,s)})(),ng())},ig="test",og=["popState","pushState","replaceState"];let io,tr;const Ln={},jt="!email",ku="pageUrl";let gs=window.location.href;function rr(e){var o,l;const{pageUrlEvents:t,interactiveEvents:r,dismissOnPageChange:n,platform:s}=window.UserLeap._config;if(s&&s!=="web")return;gs!==window.location.href&&_.navigation("LocationChange",{from:gs,to:window.location.href}),gs=window.location.href;const i=Ru().trackStartUrl,a=i?String(i):null;t&&Ou(window.location.href),r&&(xu(),ag()),mu()&&(()=>{if(In())return;const c=Rt();c&&(pu(er)||(c.remove(),er=null,Z=null))})(),ce.getItem("sprig.isCapturingHeatmap")&&((l=(o=te.replay)==null?void 0:o.checkPendingHeatmapsUrl())==null||l.then(c=>{var u;c&&((u=te.replay)==null||u.uploadReadyPendingCaptures(!0))})),!In()&&n&&a&&a!==window.location.href&&e&&og.includes(e.type)&&window.UserLeap("dismissActiveSurvey",Ae.PageChange)}const Eu={capture:!0},ag=()=>{const e=window.UserLeap._config.interactiveEvents.filter(r=>no(r,window.location.href)).map(r=>{const{name:n,properties:s}=r,{selector:i,innerText:a}=s;return i?o=>{if(Xa(o.target))try{o.target.closest(i)&&window.UserLeap("track",n)}catch{}return!1}:o=>(Xa(o.target)&&o.target.innerText===a&&window.UserLeap("track",n),!1)}),t=r=>e.forEach(n=>n(r));window.UserLeap._config.interactiveEventsHandler=t,window.addEventListener("click",t,Eu)},xu=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,Eu),delete window.UserLeap._config.interactiveEventsHandler};function Ru(){const e=Ce.getItemObject("userleap.ids");return e&&e[window.UserLeap.envId]||{}}function Lu(){if(window.previewMode)return;const e=Ce.getItemObject("sprig.anon.env.vid.map")||{},t=e[window.UserLeap.envId];window.UserLeap.visitorId=t||yt(),_.info("NewVid",{vid:window.UserLeap.visitorId}),Ie("vid",window.UserLeap.visitorId),t||(e[window.UserLeap.envId]=window.UserLeap.visitorId,Ce.setItemObject("sprig.anon.env.vid.map",e)),z.emit(F.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}function Ou(e,t,r,n){var s,i;try{if(e.endsWith("mock_snippet.html"))return;_.info("PageView",{url:e});const a=(s=document==null?void 0:document.querySelector('meta[name="description"]'))==null?void 0:s.getAttribute("content");(i=te.replay)==null||i.RecordPageView({...a&&{description:a},url:e,referrer:document.referrer,pageTitle:document.title});const o=window.UserLeap._config.pageUrlEvents;let l=!1;if(o&&o.length)for(let u=0;u<o.length&&(l=no(o[u],e),!l);u++);if(!l)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",e);const c={url:e};n&&(c.trackPageView=!0),window.UserLeap._queue.push(["track",ku,t,c,r])}catch(a){a instanceof Error&&(a.stack=e,window.UserLeap.reportError("trackPageView",a)),console.warn("[Sprig] (ERR-428) Failed to track page view",a)}}function lg(){const e="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in e&&(e.pushState=(t=>function(...r){const n=t.apply(this,r),s=new Event("pushState");return window.dispatchEvent(s),rr(s),n})(e.pushState)),"replaceState"in e&&(e.replaceState=(t=>function(...r){const n=t.apply(this,r),s=new Event("replaceState");return window.dispatchEvent(s),rr(s),n})(e.replaceState)),["hashchange","popstate"].forEach(t=>window.addEventListener(t,rr,!0))}async function ys(e,t){const r=to();e&&!t&&(window.UserLeap._config.mode=ig);const n=$n(Te(window.UserLeap)),s=await ze(function(i){const a=new URL(Me("1",[st],"questions"));return Object.entries(i||{}).forEach(([o,l])=>{l&&a.searchParams.append(o,String(l))}),a.toString()}({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:n,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:e==null?void 0:e.surveyId,surveytemplateid:e==null?void 0:e.surveyTemplateId,vid:r}),{shouldDropOnRateLimit:!0});if(!s.ok)return s.reportError&&s.error&&(console.warn("[Sprig] (ERR-414) Failed to request questions from the server",s.error),window.UserLeap.reportError("getQuestions",s.error)),{success:!1,surveyState:"no survey"};if(s.json.delay&&await Sn(s.json.delay),!s.json.isFeedback)return Qt(s.json,tr,io);{const{feedbackLabel:i,productConfig:a,surveyUuid:o,feedbackCustomStyles:l}=s.json,{buttonTheme:c,placement:u,desktopDisplay:d}=a;wu({customStyles:l,buttonTheme:c,desktopDisplay:d,eventId:0,feedbackLabel:i,placement:u,surveyUuid:o,surveyId:e==null?void 0:e.surveyId},s.json)}}function cg(e){if(!e)return;window.UserLeap._config=e,e.mute&&window.UserLeap._queue.pause();const{interactiveEvents:t,pageUrlEvents:r,dismissOnPageChange:n}=e;t&&function(s){let i=s.length;for(;i;){const a=Math.floor(Math.random()*i);i-=1;const o=s[i];s[i]=s[a],s[a]=o}}(t),(t||r||n)&&(lg(),rr())}const ug=function(e){if(!window.UserLeap)return;const t=async(s={})=>{var m,g,v,I,M;const{userId:i,anonymousId:a,metadata:o={},properties:l,showSurveyCallback:c}=s;let{eventName:u}=s;if(window.UserLeap.debugMode&&u!==ku&&console.info("[DEBUG] Sprig track",s),e.mode==="test")return;const d=Ce.getItem("sprig.previewKey")??void 0;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!i){const x="[Sprig] - Skipping tracking without userId";return console.warn(x),{success:!1,message:x,surveyState:"no survey"}}if(!u||u.trim().length===0){u=u?String(u):"";const x="[Sprig] - Invalid event name "+u;return console.warn(x),{success:!1,message:x,surveyState:"no survey"}}const p=tr??window.location.href;o.url||(o.url=p),Ie("trackStartUrl",p),(g=(m=window.UserLeap)==null?void 0:m._config)!=null&&g.optimizelyEnabled&&(pr(Te(window.UserLeap))||dn.getAndSetWebOptimizelyExperiments(),o.optimizelyExperiments=Object.assign({},dn.getAllOptimizelyExperiments())),(I=(v=window.UserLeap)==null?void 0:v._config)!=null&&I.launchDarklyEnabled&&(o.launchDarklyFlags=pi.getAllLaunchDarklyVariations()),i&&(window.UserLeap.userId=i),a&&(window.UserLeap.partnerAnonymousId=a),l&&(o.eventProperties=l),(M=te.replay)==null||M.RecordEvent({name:u,url:o.url}),_.info("TrackEvent",{eventName:u});const f=window.UserLeap.delayingSurvey||fu()?await ze(Me("1",[nt],"events/batch"),{body:JSON.stringify({events:[{event:u,metadata:o}],previewKey:d}),method:"POST",shouldDropOnRateLimit:!0}):await ze(Me("1",[nt],"events"),{body:JSON.stringify({event:u,metadata:o,previewKey:d}),method:"POST",shouldDropOnRateLimit:!0});if(!f.ok){const x="[Sprig] (ERR-421) Failed to track event";return f.reportError&&(console.warn(x,f.error),f.error&&window.UserLeap.reportError("track",f.error)),{success:!1,message:x,error:f.error,surveyState:"no survey"}}i&&Ie("uid",i),a&&Ie("aid",a);const y=f.json;y.invalidPreviewKey&&Ce.removeItem("sprig.previewKey");const h=o.trackPageView?o.url:void 0;return y!=null&&y.feedbackButton&&wu(y.feedbackButton,void 0,h),await async function(x,U){var E,L;let A=!0;return!(U&&((E=x==null?void 0:x.json)!=null&&E.surveyId)&&(window.UserLeap.delayingSurvey=!0,A=await U(x.json.surveyId),window.UserLeap.delayingSurvey=!1,!A))&&((L=x==null?void 0:x.json)!=null&&L.delay&&!window.UserLeap.isMobileSDK&&(window.UserLeap.delayingSurvey=!0,await Sn(x.json.delay),window.UserLeap.delayingSurvey=!1),A)}(f,c)?function(x){if(!window.UserLeap._config.dismissOnPageChange)return!0;const U=new URL(x),A=new URL(tr??window.location.href);return U.hostname===A.hostname&&U.pathname===A.pathname}(p)?Qt(y,h,io):{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"}},r=(s,i)=>{var o;const a=(o=s==null?void 0:s.querySelector(`[id="${ro}"]`))==null?void 0:o.contentDocument;a&&hr({document:a,elementId:"ul-custom-style",styleString:i})},n={displaySurvey:async s=>(console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),window.UserLeap("dismissActiveSurvey",Ae.Override),ys({surveyId:s},!0)),_previewSurvey(s){window.UserLeap("dismissActiveSurvey",Ae.Override),ys({surveyTemplateId:s},!1)},_reviewSurvey(s){window.UserLeap("dismissActiveSurvey",Ae.Override),ys({surveyId:s},!1)},previewSurvey(s){n._previewSurvey(s)},reviewSurvey(s){n._reviewSurvey(s)},mute(){window.UserLeap._queue.pause()},unmute(){window.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(s=Ae.API){window.UserLeap.container&&(s===Ae.Closed&&window.Sprig.trackHistory&&window.Sprig.trackHistory({event:"closed"}),z.emit(F.SurveyCloseRequested,{name:F.SurveyCloseRequested,initiator:s,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}),z.emit(F.SurveyWillClose,{name:F.SurveyWillClose,initiator:s,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}))},async setAttribute(s,i){if(!s||!i&&i!==0&&i!==!1){const a="[Sprig] - Disregarding empty attribute / value provided";return console.warn(a),{success:!1,message:a}}return this.setAttributes({[s]:i})},async setAttributes(s){if(s==null||Object.keys(s).length===0){const i="[Sprig] - Disregarding empty attributes provided";return console.warn(i),{success:!1,message:i}}return this.identifyAndSetAttributes({attributes:s})},async identifyAndSetAttributes(s){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",s),e.mode==="test")return;if(s===null||typeof s!="object"||!(s.userId||s.anonymousId||s.attributes)){const u="[Sprig] - Disregarding empty payload provided";return console.warn(u),{success:!1,message:u}}const{userId:i,anonymousId:a,attributes:o}=s;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!i){const u="[Sprig] - Skipping tracking without userId";return console.warn(u),{success:!1,message:u}}if(o){o.email&&!o[jt]&&(o[jt]=o.email,delete o.email);const u=Object.keys(o);for(const d of u)o[d]===Ln[d]&&delete o[d]}if(!(o&&Object.keys(o).length!==0||i&&window.UserLeap.userId!==i||a&&window.UserLeap.partnerAnonymousId!==a))return{success:!0};const l={};let c;return i&&(l.userId=window.UserLeap.userId=i),a&&(l.partnerAnonymousId=window.UserLeap.partnerAnonymousId=a),o&&Object.keys(o).length>0?(c=await ze(Me("1",[st,nt],"attributes"),{body:JSON.stringify(o),method:"PUT"}),c.ok?Object.assign(Ln,o):c.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",c.error),c.error&&window.UserLeap.reportError("identifyAndSetAttributes",c.error))):c=await ze(Me("1",[st,nt]),{body:JSON.stringify(l),method:"PUT"}),o&&o[jt]&&(window.UserLeap.email=o[jt]),c.ok&&(i&&Ie("uid",i),a&&Ie("aid",a)),{success:!!c.ok}},async removeAttributes(s){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",s),e.mode==="test")return;if(s==null||s.length===0){const a="[Sprig] - Disregarding empty attributes provided";return console.warn(a),{success:!1,message:a}}if(e.requireUserIdForTracking&&!window.UserLeap.userId){const a="[Sprig] - Skipping tracking without userId";return console.warn(a),{success:!1,message:a}}const i=await ze(Me("1",[st,nt],"attributes"),{body:JSON.stringify({delete:s}),method:"DELETE"});return!i.ok&&i.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",i.error),i.error&&window.UserLeap.reportError("removeAttributes",i.error)),{success:!!i.ok}},async addSurveyListener(s){z.on(F.SurveyLifeCycle,s)},async removeSurveyListener(s){z.removeListener(F.SurveyLifeCycle,s)},async addListener(s,i){z.on(s,i)},async removeListener(s,i){z.removeListener(s,i)},async removeAllListeners(){z.removeAllListeners()},setPreviewKey(s){s&&typeof s=="string"&&Ce.isStorageAvailable&&s&&Ce.setItem("sprig.previewKey",s)},async setUserId(s){var o;if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",s),s==null){const l=`[Sprig] - Invalid userId ${s}`;return console.warn(l),{success:!1,message:l}}if(e.mode==="test"||s===window.UserLeap.userId)return;window.UserLeap.userId=s;const i=window.UserLeap.visitorId,a=await ze(Me("1",[st,nt]),{body:JSON.stringify({userId:s}),method:"PUT"});a.ok?(i!==window.UserLeap.visitorId&&((o=te.replay)==null||o.clearUserReplayData()),Ie("uid",s)):a.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",a.error),a.error&&window.UserLeap.reportError("setUserId",a.error))},async setPartnerAnonymousId(s){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",s),s==null){const i=`[Sprig] - Invalid partnerAnonymousId ${s}`;return console.warn(i),{success:!1,message:i}}return window.UserLeap.partnerAnonymousId=s,Ie("aid",s),{success:!0}},track:async(s,i,a={},o=void 0)=>t({eventName:s,properties:i,metadata:a,showSurveyCallback:o}),identifyAndTrack:async s=>await t(s),trackPageView(s,i=void 0,a=void 0,o=!0){tr=s,Ou(s,i,a,o)},applyFeedbackStyles({button:s="",view:i=""}){window.UserLeap.feedbackCustomStyles=i,document.getElementById("sprig-feedback-style")&&hr({document,elementId:"ul-custom-style",styleString:s,nonce:window.UserLeap.styleNonce}),r(document.querySelector(".ul-container-feedback"),i)},applyStyles(s){window.UserLeap.customStyles=s,r(window.UserLeap.container,s)},setWindowDimensions(s,i){var p,f;const a=typeof s=="string"?parseInt(s,10):s,o=typeof i=="string"?parseInt(i,10):i;isNaN(a)||isNaN(o)||(window.UserLeap.windowDimensions={width:a,height:o});const l=Te(window.UserLeap),c=$n(l),u=l["userleap-platform"]==="web";if(!window.UserLeap.frameId)return;const d=document.getElementById(window.UserLeap.frameId);d&&(window.UserLeap.useMobileStyling&&((p=window.UserLeap.windowDimensions)!=null&&p.width&&(d.style.width=`${window.UserLeap.windowDimensions.width}px`),(f=window.UserLeap.windowDimensions)!=null&&f.height&&(d.style.maxHeight=window.UserLeap.windowDimensions.height-20+"px"),d.contentDocument&&(d.style.height=String(hu(d.contentDocument,u&&!c,eo(l))[0])+"px")),z.emit(F.SurveyDimensions,{name:F.SurveyDimensions,contentFrameWidth:d.clientWidth,contentFrameHeight:d.clientHeight,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}))},logoutUser(){var s;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),_.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,Ce.removeItem("userleap.ids"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),Lu(),(s=te.replay)==null||s.clearUserReplayData(),window.UserLeap._queue.unpause()},teardown(){["hashchange","popstate"].forEach(s=>window.removeEventListener(s,rr,!0)),window.UserLeap._config.interactiveEvents&&xu(),window.UserLeap("dismissActiveSurvey",Ae.API),delete window.UserLeap,delete window.Sprig,delete window._Sprig},integrateOptimizely(s,i=!0){var a,o;if((o=(a=window.UserLeap)==null?void 0:a._config)!=null&&o.optimizelyEnabled)try{const l=typeof s=="string"?JSON.parse(s):s;dn.setOptimizelyExperiment(l,i)}catch(l){console.warn("[Sprig] Error with integrating Optimizely data"),l instanceof Error&&window.UserLeap.reportError("integrateOptimizely",l)}else console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.")},integrateOptimizelyClient(s){var i,a;if(!((a=(i=window.UserLeap)==null?void 0:i._config)!=null&&a.optimizelyEnabled))return void console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");s.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",({experiment:o,variation:l})=>{const c={experiments:[{id:o.id,variation:l.key}]};window.UserLeap("integrateOptimizely",c,!1)})},importLaunchDarklyData(s){var i,a;(a=(i=window.UserLeap)==null?void 0:i._config)!=null&&a.launchDarklyEnabled?pi.setLDFlagsVariations(s):console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.")},setVisitorAttribute:(s,i)=>(console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),n.setAttribute(s,i)),setEmail:async s=>n.setAttribute(jt,s),setVisitorEmail:async s=>(console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),n.setEmail(s)),_generateVideoUploadUrl:async s=>async function(i){var o;if(!i)return;const a=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const l=await fetch(a,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(l.ok){const c=await l.json();return(o=c==null?void 0:c.upload)==null?void 0:o.url}return null}catch(l){console.warn("[Sprig] Error with generating video upload url"),l instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",l)}}(s),_reportMetric(s,i){bu(s,i)},_completeSessionReplay:async({surveyId:s,responseGroupUuid:i,eventDigest:a})=>{var o;return te.replay?(o=te.replay)==null?void 0:o._completeSessionReplay({surveyId:s,responseGroupUuid:i,eventDigest:a,headers:Te(window.UserLeap)}):(window.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)},pauseReplayRecording(){var s,i,a,o;(i=(s=te.replay)==null?void 0:s.isReplayPaused)!=null&&i.call(s)||((o=(a=te.replay)==null?void 0:a.recordReplayPaused)==null||o.call(a))},resumeReplayRecording(){var s,i,a,o,l,c;(i=(s=te.replay)==null?void 0:s.isReplayPaused)!=null&&i.call(s)&&((o=(a=te.replay)==null?void 0:a.recordReplayResumed)==null||o.call(a),(c=(l=te.replay)==null?void 0:l.recordFullSnapshot)==null||c.call(l))}};Object.assign(window.UserLeap,n)};async function dg(e,t,r={},n={}){const s=window.__cfg&&window.__cfg.mode,i=to(),a=window.UserLeap.envId,o=window.document.documentElement,l={mode:s,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:o.clientWidth,clientHeight:o.clientHeight,location:tr??window.location.href,language:window.navigator.language,...r},c={action:e,breadcrumbs:_.breadcrumbs,err:{message:`${t==null?void 0:t.name} - ${t==null?void 0:t.message}`,stack:t==null?void 0:t.stack},meta:l,vid:i,envId:a,...n};(await ze(Me("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(c),shouldDropOnRateLimit:!0})).ok||console.warn("[Sprig] (ERR-444) Failed to report error to API",t)}function pg(e={}){var n;(n=window.SprigLoggerCallback)==null||n.call(window,"Initializing Sprig");const t=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";async function r(){var d,p,f,y,h;if(window.UserLeap.loaded)return;if((d=window.SprigLoggerCallback)==null||d.call(window,"Loading Sprig"),window.UserLeap.reportError=dg,window.UserLeap.loaded=!0,window.UserLeap._config=Object.assign({},e,window.UserLeap.config),window.UserLeap.delayingSurvey=!1,window.UserLeap._config&&typeof window.UserLeap._config=="object")for(const k in window.UserLeap._config)window.UserLeap[k]=window.UserLeap._config[k];if(window.Sprig.outstandingTransactionLimit!==void 0&&(e.outstandingTransactionLimit=window.Sprig.outstandingTransactionLimit),!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 s=Ru(),i=window.UserLeap.sampleRate;let a=s.sampled;if(i){if(a===null&&(a=Math.random()<i,Ie("sampled",a)),!a)return}else a!==null&&Ie("sampled",null);window.UserLeap._API_URL||(window.UserLeap._API_URL="https://api.sprig.com");const o=[...window.UserLeap._queue];window.UserLeap._queue=new Xf(window.UserLeap,[]),window.UserLeap._queue.pause();for(let k=0;k<o.length;k++)window.UserLeap._queue.push(o[k]);const l=s.token;l?(window.UserLeap.token=l,window.UserLeap.visitorId=s.vid??null,window.UserLeap.userId=s.uid??null,window.UserLeap.partnerAnonymousId=s.aid??null):Lu();const c=pr(Te(window.UserLeap));(p=window.SprigLoggerCallback)==null||p.call(window,"Sprig fetching config");const u=await async function(k){var I,M;const m=Te(window.UserLeap);document.addEventListener("securitypolicyviolation",Ya);const g=await Ge(Me("1",[st],"config"),{headers:m});if(document.removeEventListener("securitypolicyviolation",Ya),!g.ok)return(I=window.SprigLoggerCallback)==null||I.call(window,"Sprig config fetch failed"),g.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",g.error),g.error&&window.UserLeap.reportError("applyRemoteConfig",g.error)),ci("Disabled: failed to fetch configuration"),k;const v=g.json;return v!=null&&v.disabled?((M=window.SprigLoggerCallback)==null||M.call(window,"Sprig config fetch disabled"),ci(`Disabled: ${v.disabled}`),{disabled:v.disabled}):Object.assign({},v,k)}(e);if((f=window.SprigLoggerCallback)==null||f.call(window,"Sprig fetched config"),sg({isWeb:!c,reportingIntervalSeconds:u.metricsReportingEnabled||u.mobileMetricsReportingEnabled?u.metricsReportingIntervalSeconds:0,thresholds:u.metricThresholds,postMetrics:async k=>{var m;await ze(Me("1",[st],"metrics"),{body:k,method:"POST",headers:{"x-ul-replay-enabled":`${!!((m=te.replay)!=null&&m.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),!c){const k=u.alwaysOnReplay?{userAgent:window.navigator.userAgent,surveyId:u.alwaysOnReplay.surveyId,responseGroupUuid:u.alwaysOnReplay.responseGroupUuid,sdkVersion:"2.36.1",maxDurationSeconds:u.alwaysOnReplay.maxDurationSeconds}:void 0;await((y=te.replay)==null?void 0:y.initializeReplay({maxReplayDurationSeconds:u.maxReplayDurationSeconds,maxInflightRequests:window.UserLeap.maxInflightReplayRequests??2,replaySettings:u.replaySettings,apiUrl:window.UserLeap._API_URL,alwaysOnConfig:k})),io=u.replaySettings}ug(u),await cg(u),window.UserLeap._queue.unpause(),(h=window.SprigLoggerCallback)==null||h.call(window,"SdkReady"),z.emit(F.SDKReady,{mobileMetricsReportingEnabled:!!u.mobileMetricsReportingEnabled,metricsReportingInterval:u.metricsReportingIntervalSeconds||0,metricsThresholds:u.metricThresholds||[],maxMobileReplayDurationSeconds:u.maxMobileReplayDurationSeconds,mobileReplaySettings:u.mobileReplaySettings}),z.emit(F.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}),z.on(F.VisitorIDUpdated,()=>{for(const k in Ln)delete Ln[k]})}window.UserLeap.UPDATES=dr,window.UserLeap("setPreviewKey",t),document.readyState==="complete"?r():window.attachEvent?window.attachEvent("onload",r):window.addEventListener("load",()=>{r()},!1)}class yi{constructor(){ue(this,"UPDATES",dr)}displaySurvey(t){window.Sprig("displaySurvey",t)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(t,r){window.Sprig("setAttribute",t,r)}setAttributes(t){window.Sprig("setAttributes",t)}identifyAndSetAttributes(t){window.Sprig("identifyAndSetAttributes",t)}removeAttributes(t){window.Sprig("removeAttributes",t)}addListener(t,r){window.Sprig("addListener",t,r)}removeListener(t,r){window.Sprig("removeListener",t,r)}removeAllListeners(){window.Sprig("removeAllListeners")}setEmail(t){window.Sprig("setAttribute","!email",t)}setUserId(t){window.Sprig("setUserId",t)}setPartnerAnonymousId(t){window.Sprig("setPartnerAnonymousId",t)}track(t,r={},n={}){window.Sprig("track",t,r,n)}identifyAndTrack(t){window.Sprig("identifyAndTrack",t)}trackPageView(t,r,n){window.Sprig("trackPageView",t,r,n)}applyStyles(t){window.Sprig("applyStyles",t)}setWindowDimensions(t,r){window.Sprig("setWindowDimensions",t,r)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}pauseReplayRecording(){window.Sprig("pauseReplayRecording")}resumeReplayRecording(){window.Sprig("resumeReplayRecording")}}const hg={configure:e=>{if(!e.envId&&!e.environmentId)throw new Error("Initialization Error: Sprig configure requires an environmentId");if(e.envId||(e.envId=e.environmentId??""),e.installationMethod="web-npm-bundled",window.Sprig)return window.Sprig;window.Sprig=function(){window.Sprig._queue.push(arguments)},Object.getOwnPropertyNames(yi.prototype).map(r=>{r!=="constructor"&&(window.Sprig[r]=yi.prototype[r])});const t=window.Sprig;return t.appId=e.envId,t._queue=[],window.UserLeap=t,pg(e),window.Sprig}};var it=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(it||{}),$e=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))($e||{});const wi=(e,t)=>t.some(r=>e instanceof r);let nl,sl;const vi=new WeakMap,ws=new WeakMap,On=new WeakMap;let bi={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return vi.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return ot(e[t])},set:(e,t,r)=>(e[t]=r,!0),has:(e,t)=>e instanceof IDBTransaction&&(t==="done"||t==="store")||t in e};function Au(e){bi=e(bi)}function mg(e){return(sl||(sl=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Si(this),t),ot(this.request)}:function(...t){return ot(e.apply(Si(this),t))}}function fg(e){return typeof e=="function"?mg(e):(e instanceof IDBTransaction&&function(t){if(vi.has(t))return;const r=new Promise((n,s)=>{const i=()=>{s(t.error||new DOMException("AbortError","AbortError"))};t.oncomplete=()=>{n()},t.onerror=i,t.onabort=i});vi.set(t,r)}(e),wi(e,nl||(nl=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,bi):e)}function ot(e){if(e instanceof IDBRequest)return function(r){const n=new Promise((s,i)=>{r.onsuccess=()=>{s(ot(r.result))},r.onerror=()=>{i(r.error)}});return On.set(n,r),n}(e);if(ws.has(e))return ws.get(e);const t=fg(e);return t!==e&&(ws.set(e,t),On.set(t,e)),t}const Si=e=>On.get(e);function Ii(e,{blocked:t}={}){const r=indexedDB.deleteDatabase(e);return t&&(r.onblocked=n=>t(n.oldVersion,n)),ot(r).then(()=>{})}const gg=["get","getKey","getAll","getAllKeys","count"],yg=["put","add","delete","clear"],vs=new Map;function il(e,t){if(!(e instanceof IDBDatabase)||t in e||typeof t!="string")return;if(vs.get(t))return vs.get(t);const r=t.replace(/FromIndex$/,""),n=t!==r,s=yg.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!s&&!gg.includes(r))return;const i=async function(a,...o){const l=this.transaction(a,s?"readwrite":"readonly");let c=l.store;return n&&(c=c.index(o.shift())),(await Promise.all([c[r](...o),s&&l.done]))[0]};return vs.set(t,i),i}Au(e=>({...e,get:(t,r,n)=>il(t,r)||e.get(t,r,n),has:(t,r)=>!!il(t,r)||e.has(t,r)}));const wg=["continue","continuePrimaryKey","advance"],ol={},Ci=new WeakMap,Mu=new WeakMap,vg={get(e,t){if(!wg.includes(t))return e[t];let r=ol[t];return r||(r=ol[t]=function(...n){Ci.set(this,Mu.get(this)[t](...n))}),r}};async function*bg(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const r=new Proxy(t,vg);for(Mu.set(r,t),On.set(r,Si(t));t;)yield r,t=await(Ci.get(r)||t.continue()),Ci.delete(r)}function al(e,t){return t===Symbol.asyncIterator&&wi(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&wi(e,[IDBIndex,IDBObjectStore])}Au(e=>({...e,get:(t,r,n)=>al(t,r)?bg:e.get(t,r,n),has:(t,r)=>al(t,r)||e.has(t,r)}));const Sg="sprigReplayIframeLoaded",Ig="sprigReplayIframeSettings",Cg="sprigReplayIframeTakeFullSnapshot",kg="sprigReplayTeardown",oo=[],Uu=new class{constructor(e){ue(this,"awaitingResolvers",[]);ue(this,"activeCount",0);this.capacity=e}async acquire(){if(!(this.activeCount<this.capacity))return new Promise(e=>{this.awaitingResolvers.push(e)});this.activeCount++}release(){const e=this.awaitingResolvers.shift();e&&this.activeCount<=this.capacity?e():this.activeCount--}async execute(e){try{return await this.acquire(),await e()}finally{this.release()}}setLimit(e){this.capacity=e}}(2),Tu=async({apiUrl:e,surveyId:t,uploadId:r,etags:n,headers:s,responseGroupUuid:i,replayDuration:a,eventDigest:o},l=!1)=>{var u;if(!l&&!r&&!n)return void _.error("UploadErr",{isMobile:l,uploadId:r,etags:n});_.info("MarkUploadComplete",{surveyId:t});const c=await Ge(`${e}/sdk/1/completeSessionReplay`,{method:"POST",body:JSON.stringify({etags:n,uploadId:r,responseGroupUuid:i,surveyId:t,replayDuration:a,eventDigest:o,userAgent:(u=window==null?void 0:window.navigator)==null?void 0:u.userAgent}),headers:s,shouldRetryRequest:!0});return _.info("MarkUploadDone",{surveyId:t}),c},Eg=e=>{if(e instanceof Attr)return null;let t=1;for(let r=e.previousSibling;r;r=r.previousSibling)r.nodeName===e.nodeName&&++t;return t},Du=e=>{if(e===null)return"";const t=[];if(e instanceof Document)return"/";for(let r=e;r&&!(r instanceof Document)&&r!==null;r=r instanceof Attr?r.ownerElement:r.parentElement){const n=t[t.length]={name:void 0,position:null};switch(r.nodeType){case Node.TEXT_NODE:n.name="text()";break;case Node.ATTRIBUTE_NODE:n.name="@"+r.nodeName;break;case Node.PROCESSING_INSTRUCTION_NODE:n.name="processing-instruction()";break;case Node.COMMENT_NODE:n.name="comment()";break;case Node.ELEMENT_NODE:n.name=r.nodeName}n.position=Eg(r)}return"/"+t.reverse().map(r=>r.position!==null?`/${r.name}[${r.position}]`:`/${r.name}`).join("")},ao=e=>e&&e.trim().substring(0,500).replace(/\s\s+/g," ").replace(/\r?\n|\r/g," ").substring(0,250),We={capture:!0,passive:!0},xg=["a","button","input","option","li","link"],Rg=["Escape","Enter","Backspace","F5","Tab"];let An=!1,Ee=null,pn=null;const ll=e=>{var r;if(((r=e.tagName)==null?void 0:r.toLowerCase())==="html")return{element:"html"};const t={};return t.element=(n=>{if(!n.tagName)return"No tagName";const s=n.getAttribute("type");return s?`${s} ${n.tagName.toLowerCase()}`:n.tagName.toLowerCase()})(e),t},Lg=e=>{var n;if(!e)return{};const t={...ll(e)},r=e.parentElement;if(r&&xg.includes((n=r.tagName)==null?void 0:n.toLowerCase())){const s=ll(r);Object.assign(t,s)}return t},Pu=(e,t)=>{var s,i;let r=t.target;var n;t.target===((s=window.document)==null?void 0:s.body)&&window.Sprig.pointerDownTarget&&(r=window.Sprig.pointerDownTarget),n={x:t.x,y:t.y,type:e,elementAttributes:Lg(r),windowHeight:window.innerHeight,windowWidth:window.innerWidth,...r instanceof HTMLElement||r instanceof SVGElement||r instanceof MathMLElement?{rect:r==null?void 0:r.getBoundingClientRect(),xPath:Du(r)}:{}},(i=n==null?void 0:n.elementAttributes)!=null&&i.text&&(n.elementAttributes.text=ao(n.elementAttributes.text)),Ee==null||Ee("Sprig_Click",n)},_u=e=>{var t;Rg.includes(e.key)&&(t={key:e.key},Ee==null||Ee("Sprig_Keystroke",t))},Og=()=>{var e;window.performance.getEntriesByType("navigation").map(t=>t.type).includes("reload")&&(e={url:window.location.href,currentPageTitle:document.title},Ee==null||Ee("Sprig_Refresh",e))},Ag=()=>{var e;window.performance.getEntriesByType("navigation").map(t=>t.type).includes("back_forward")&&((e={curUrl:window.location.href,fromUrl:document.referrer,currentPageTitle:document.title}).currentPageTitle&&(e.currentPageTitle=ao(e.currentPageTitle)),Ee==null||Ee("Sprig_BackForward",e))},Nu=((e,t)=>{let r;return n=>{clearTimeout(r),r=window.setTimeout(()=>e(n),t)}})(e=>{if(!(e.target instanceof HTMLElement||e.target instanceof Document))return;let t=e.target;"scrollTop"in t||(t=t.documentElement),pn==null||pn({xPath:Du(t),x:t.scrollLeft,y:t.scrollTop,elementAttributes:{targetScrollWidth:t.scrollWidth,targetClientWidth:t.clientWidth,targetScrollHeight:t.scrollHeight,targetClientHeight:t.clientHeight}})},750),Fu=(cl="left_click",e=>Pu(cl,e));var cl;const Bu=e=>{e.button===2&&Pu("right_click",e)},zu=e=>{window.Sprig&&(window.Sprig.pointerDownTarget=e.target)},de={isRecording:!1,scrollEventUuids:{},stopRecording:()=>{}},ju=()=>window.indexedDB&&window.IDBKeyRange&&window.CompressionStream,we=(()=>{const e=ce.getItem("sprig.sessionId");if(e)return _.info("SessionIDFound",{savedSessionId:e}),ce.removeItem("sprig.sessionId"),e;const t=yt();return _.info("GeneratedSessionID",{uuid:t}),t})(),ki=()=>{ce.setItem("sprig.disableReplayRecording","disabled")},He=()=>!!ce.getItem("sprig.disableReplayRecording"),Mn=()=>!!ce.getItem("sprig.isReplayPaused");window.addEventListener("beforeunload",()=>{_.info("BeforeUnload",{sessionId:we}),ce.setItem("sprig.sessionId",we)});const qe=(e,t)=>{var r,n;if(!He()&&de.isRecording&&!Mn())try{(n=(r=window.rrwebRecord)==null?void 0:r.addCustomEvent)==null||n.call(r,e,t)}catch(s){wr("Error recording custom event",s)}},Mg=async e=>{const{x:t,xPath:r,y:n}=e,s=de.scrollEventUuids[r];if(s)return ke(async()=>{var o,l,c,u;const i=await Q.openDB(),a=await i.get("events",s);if(a!=null&&a.event){const d=JSON.parse(a.event),p=t>((l=(o=d.data)==null?void 0:o.payload)==null?void 0:l.x),f=n>((u=(c=d.data)==null?void 0:c.payload)==null?void 0:u.y);if(!p&&!f)return null;p&&(d.data.payload.x=t),f&&(d.data.payload.y=n),d.data.payload.elementAttributes=e.elementAttributes,a.event=JSON.stringify(d),await i.put("events",a)}else qe("Sprig_Scroll",e)},"Error updating scroll event");qe("Sprig_Scroll",e)},Wu=()=>{de.stopRecording&&(de.stopRecording(),de.stopRecording=void 0),de.isRecording=!1,["cleanupInterval","inactivityInterval","pendingCheckInterval"].forEach(e=>{de[e]&&(clearInterval(de[e]),de[e]=void 0)}),An&&(window.removeEventListener("click",Fu,We),window.removeEventListener("pointerdown",zu,We),window.removeEventListener("mousedown",Bu,We),window.removeEventListener("keydown",_u,We),window.removeEventListener("scroll",Nu,We),An=!1),oo.forEach(e=>{var t;(t=e.source)==null||t.postMessage({type:kg},{targetOrigin:e.origin})})},Ug=["did not allow mutations","called in an invalid security context"],Tg=(e,t,{reportError:r=!0,extraInfo:n={}})=>{if(!He()&&t instanceof Error){if(ki(),t.name==="VersionError")return _.error("VersionErr",{message:e}),void Q.deleteDB();(s=>{if(!s)return!0;for(const i of Ug)if(s.toLowerCase().includes(i))return!1;return!0})(t==null?void 0:t.message)&&(r&&window.UserLeap.reportError(e,t,n),Q.clearAll())}},wr=(e,t,{reportError:r}={reportError:!0})=>{Wu(),_.error("ReplayErr",{code:t.code,name:t.name}),Tg(e,t,{reportError:r})},ke=async(e,t)=>{try{return await e()}catch(r){wr(t,r)}},Ei=()=>{de.isRecording&&(ke(()=>{var e,t;return(t=(e=window.rrwebRecord)==null?void 0:e.takeFullSnapshot)==null?void 0:t.call(e,!0)},"Error recording full snapshot"),oo.forEach(e=>{var t;(t=e.source)==null||t.postMessage({type:Cg},{targetOrigin:e.origin})}))};let bs=0;(async()=>ju()&&Promise.allSettled([Ii("replayStorage"),Ii("sprig.replay")]))();const Q=new class{constructor(){ue(this,"wrapTransactionWithCounter",e=>{var n,s;const t=(s=(n=window.Sprig)==null?void 0:n._config)==null?void 0:s.outstandingTransactionLimit,r=t===void 0?100:t;if(r&&bs>r){const i="Too many outstanding transactions";wr(i,new Error(i),{reportError:!1})}bs++,e.done.finally(()=>{bs--})});ue(this,"getTransaction",async e=>{const t=(await this.openDB()).transaction(e,"readwrite");return this.wrapTransactionWithCounter(t),t})}openDB(){return function(e,t,{blocked:r,upgrade:n,blocking:s,terminated:i}={}){const a=indexedDB.open(e,t),o=ot(a);return n&&(a.onupgradeneeded=l=>{n(ot(a.result),l.oldVersion,l.newVersion,ot(a.transaction),l)}),r&&(a.onblocked=l=>r(l.oldVersion,l.newVersion,l)),o.then(l=>{i&&(l.onclose=()=>i()),s&&(l.onversionchange=c=>s(c.oldVersion,c.newVersion,c))}).catch(()=>{}),o}("sprigReplay",1,{upgrade:(e,t,r)=>{if(r===0&&ce.setItem("sprig.pendingCount","0"),!e.objectStoreNames.contains("events")){const n=e.createObjectStore("events",{keyPath:"uuid"});n.createIndex("sessionId","sessionId"),n.createIndex("timestamp","timestamp"),n.createIndex("[sessionId+timestamp]",["sessionId","timestamp"])}if(!e.objectStoreNames.contains("chunkUploads")){const n=e.createObjectStore("chunkUploads",{keyPath:"uuid"});n.createIndex("sessionId","sessionId"),n.createIndex("timestamp","timestamp"),n.createIndex("[sessionId+status]",["sessionId","status"]),n.createIndex("[uploadId+status]",["uploadId","status"]),n.createIndex("[sessionId+status+uploadId]",["sessionId","status","uploadId"])}if(!e.objectStoreNames.contains("pendingCaptures")){const n=e.createObjectStore("pendingCaptures",{keyPath:"uuid"});n.createIndex("sessionId","sessionId"),n.createIndex("timestamp","timestamp"),n.createIndex("[sessionId+targetTimestamp]",["sessionId","targetTimestamp"])}}})}async deleteDB(){try{await Ii("sprigReplay")}catch{}}async bulkAdd(e,t){const r=await this.getTransaction(e);return Promise.all([...t.map(n=>r.store.add(n)),r.done])}async clearAll(){const e=(await this.openDB()).transaction(["events","chunkUploads","pendingCaptures"],"readwrite");return this.wrapTransactionWithCounter(e),Promise.all([e.objectStore("events").clear(),e.objectStore("chunkUploads").clear(),e.objectStore("pendingCaptures").clear()])}async deleteBySessionId(e,t){const r=IDBKeyRange.only(t),n=await this.getTransaction(e),s=n.store.index("sessionId");for await(const i of s.iterate(r))await i.delete();await n.done}async updatePartial(e,t,r){const n=await this.getTransaction(e),s=await n.store.get(t);s&&await n.store.put({...s,...r}),await n.done}async deleteRowsBefore(e,t,r=()=>!0){const n=IDBKeyRange.upperBound(t,!0),s=await this.getTransaction(e),i=s.store.index("timestamp");for await(const a of i.iterate(n))r(a.value)&&await a.delete();await s.done}async getEventsBetween(e,t=Date.now()){if(e>=t)return Promise.resolve([]);const r=IDBKeyRange.bound([we,e],[we,t],!1,!0);return(await this.openDB()).getAllFromIndex("events","[sessionId+timestamp]",r)}async updateEventsExpiredAt(e,t,r=30){const n=new Date,s=n.setMinutes(n.getMinutes()+(r??30)),i=await this.getTransaction("events"),a=i.store.index("[sessionId+timestamp]"),o=IDBKeyRange.bound([we,e],[we,t],!1,!0);for await(const l of a.iterate(o))await l.update({...l.value,expiredAt:s});await i.done}async deleteChunkUploads(e,t){const r=IDBKeyRange.only([t,e]),n=await this.getTransaction("chunkUploads");let i=await n.store.index("[uploadId+status]").openCursor(r);for(;i;)i.delete(),i=await i.continue();await n.done}async getChunkUploadsByStatus({sessionId:e,status:t,uploadId:r}){const n=(await this.openDB()).transaction("chunkUploads","readonly");this.wrapTransactionWithCounter(n);const s=r?n.store.index("[uploadId+status]"):n.store.index("[sessionId+status]"),i=r?IDBKeyRange.only([r,t]):IDBKeyRange.only([e,t]);return s.getAll(i)}async getPendingCaptures(e={}){return(await(await this.openDB()).getAllFromIndex("pendingCaptures","sessionId",we)).filter(r=>!e.beforePresent||r.targetTimestamp<Date.now()).filter(r=>!e.isBeforeType||r.captureParams.replayParams.replayDurationType==="before").filter(r=>!e.isHeatmap||(r.captureParams.isHeatmap??!1))}async markPendingCaptureToCanUpload(e){const t=await this.getTransaction("pendingCaptures"),r=t.store.index("sessionId");for await(const n of r.iterate(we)){const s=n.value;s.captureParams.responseGroupId===e&&await n.update({...s,canUpload:!0})}await t.done}async markPendingHeatmapsReady(e){if(parseInt(ce.getItem("sprig.pendingCount")??"0")===0)return null;const t=Date.now(),r=await this.getTransaction("pendingCaptures"),n=r.store.index("sessionId");for await(const s of n.iterate(we)){const i=s.value;!i.captureParams.isHeatmap||e&&!e.includes(i.uuid)||await s.update({...i,targetTimestamp:t,captureParams:{...i.captureParams,triggerTimestamp:t,replayParams:{...i.captureParams.replayParams,replayDurationSeconds:Math.floor((t-i.timestamp)/1e3)}}})}await r.done}},Ze=[];let vr,Vu,Un,Gu,hn,Hu,mt=[],Ut=!1,Mt=0,mn=!1,Yu=!1,lo=[],Ss=!1;const Tt=()=>mn&&!Ut&&Date.now()<=Un,Dg=({apiUrl:e,config:t,triggerSnapshot:r,forceInit:n=!1})=>{mn&&!n||(ce.isStorageAvailable?(mt=[],lo.splice(0),Ze.splice(0),Mt=0,hn=r,Vu=e,vr={responseGroupUuid:t.responseGroupUuid,surveyId:t.surveyId,userAgent:t.userAgent,sdkVersion:t.sdkVersion},Gu=t.maxDurationSeconds,Fg(),mn||(Hu=window.setInterval(Ng,500)),mn=!0):Ut=!0)},Pg=[$e.Drag,$e.Input,$e.MediaInteraction,$e.MouseInteraction,$e.MouseMove,$e.Scroll,$e.Selection,$e.TouchMove],_g=e=>e.type===it.Custom||e.type===it.IncrementalSnapshot&&Pg.includes(e.data.source),co=e=>e.some(_g),Ng=async()=>{if(!Tt())return void window.clearInterval(Hu);if($u(),!co(Ze))return;const e=Ze[0].timestamp;Date.now()-e>35e3&&(hn==null||hn())},$u=async()=>{if(mt.length||Ss)return;Ss=!0;const e=await zg();if(!e)return void(Ut=!0);lo.splice(0,e.length).forEach(t=>t(e.shift())),e.forEach(t=>mt.push(t)),Ss=!1},Fg=()=>{const e=ce.getItem("sprig.alwayson.info");if(e){_.info("Read stored session state",e);const t=JSON.parse(e);Ut=t.disabled,vr=t.metadata,mt=t.uploadUrls,Mt=t.currentIndex,Un=t.expirationTimestamp,t.pendingEventTimestamp&&(_.info(`Uploading with pending timestamp: ${t.pendingEventTimestamp}`),Bg(t.pendingEventTimestamp))}else Un=1e3*Gu+Date.now()},Bg=async e=>{const t=Date.now(),r=(await Q.getEventsBetween(e,t)).map(s=>JSON.parse(s.event));if(!co(r))return;Ku(r);const n=await Xu();n&&await Ju(n,r)},qu=async(e,t)=>{try{const r=await e();if(!r.ok)throw new Error(`Error ${t}`);return r}catch{Ut=!0}},Ju=async(e,t)=>{if(!Tt()||!e)return;const r=await(async n=>{const s=new TextEncoder,i=new CompressionStream("gzip"),a=i.writable.getWriter(),o=s.encode(JSON.stringify(n));return a.write(o),a.close(),new Uint8Array(await new Response(i.readable).arrayBuffer())})(t);_.info("Uploading always-on events with presigned url"),await qu(()=>Ge(e,{body:r,method:"PUT"}),"uploading always-on with presigned url")},zg=async()=>{if(!Tt())return;const{surveyId:e,responseGroupUuid:t}=vr,r={responseGroupUuid:t,surveyId:e,index:Mt+1};_.info("Fetching always-on upload urls",r);const n=await qu(()=>Ge(`${Vu}/sdk/1/replayUrls`,{method:"POST",body:JSON.stringify(r),headers:Te(window.UserLeap)}),"fetching always-on signed urls");if(!n)return;const s=n.json.signedUrls;return _.info("Fetched more always-on upload urls",{body:r,urls:s}),s},Xu=async()=>{if(mt.length)return mt.shift();const e=new Promise(t=>{lo.push(t)});return $u(),e},Ku=e=>{var s,i,a;const t=e.length?e[e.length-1].timestamp:Date.now(),r=Mt,n=((i=(s=window.UserLeap)==null?void 0:s.config)==null?void 0:i.customMetadata)??((a=window.__cfg)==null?void 0:a.customMetadata);Mt++,e.push({timestamp:t,type:it.Custom,data:{tag:"Sprig_Meta",payload:{...vr,index:r,visitorId:window.UserLeap.visitorId??"",timestamp:t,customMetadata:n}}})},jg=(e,t)=>{Tt()&&!Yu&&(e||Ze.length)&&(e&&Ze.length&&(async()=>{const r=Ze.splice(0);if(!co(r))return;_.info("Capturing always-on event array to upload"),Ku(r);const n=await Xu();n&&await Ju(n,r)})(),Ze.push(t))};window.addEventListener("beforeunload",async()=>{Yu=!0,Tt()&&(_.info("Always On handle page unload"),(()=>{let e;Ze.length&&(e=Ze[0].timestamp);const t={disabled:Ut,metadata:vr,uploadUrls:mt,currentIndex:Mt,pendingEventTimestamp:e,expirationTimestamp:Un};_.info("Storing session state on unload",t),ce.setItem("sprig.alwayson.info",JSON.stringify(t))})())});const Zu=async(e,t)=>{const r=performance.now();let n;try{n=await e()}finally{const s=performance.now()-r;let i=yr[t];i||(i=Ve(t)),i.report(s/1e3)}return n},Qu=(e,t)=>{const r=performance.now();try{e()}finally{const n=performance.now()-r;let s=yr[t];s||(s=Ve(t)),s.report(n/1e3)}};let ed=5e3,xi=6e4,Ri=0,at,Li=!1,Oi=[];const Wg=e=>{var t,r,n,s;if((t=e.event)!=null&&t.includes("Sprig_Scroll")){const i=(s=(n=(r=JSON.parse(e.event))==null?void 0:r.data)==null?void 0:n.payload)==null?void 0:s.xPath;if(!i)return;de.scrollEventUuids[i]=e.uuid}Oi.push(e),Li||Vg()},Vg=()=>{Li=!0,setTimeout(async()=>{if(He()||Mn())return;const e=Oi;Oi=[],Li=!1,Qu(async()=>{await(async t=>{const r=t.map(n=>({...n,sessionId:n.sessionId??we}));if(r.length!==0)return ke(()=>Q.bulkAdd("events",r),"Error storing replay events")})(e)},"sdk_replay_add_event_batch_seconds")},500)},Gg=(e,t,r)=>{de.cleanupInterval=window.setInterval(()=>{const n=Date.now();Zu(()=>ke(async()=>{He()||await Promise.all([Q.deleteRowsBefore("events",n-1e3*e,s=>s.expiredAt===void 0||s.expiredAt<n-1e3*e),Q.deleteRowsBefore("chunkUploads",n-1e3*t),Q.deleteRowsBefore("pendingCaptures",n-1e3*r,s=>!s.canUpload)])},"Error deleting table rows"),"sdk_replay_cleanup_seconds"),_.debug("CleanupComplete")},3e4)},Hg=()=>{de.pendingCheckInterval=window.setInterval(async()=>{ke(async()=>{await Ai()},"Error initiating pending captures")},5e3)};let Is=!1;const Ai=async(e=!1)=>{if(!Is)try{Is=!0;const t=parseInt(at??"0");if(t===0)return;const r=await Q.getPendingCaptures({beforePresent:!0,isBeforeType:e}),n=await Q.openDB();await Promise.all(r.map(async s=>(await n.delete("pendingCaptures",s.uuid),nd(s.captureParams,s.canUpload)))),at=(t-r.length).toString(),ce.setItem("sprig.pendingCount",at)}finally{Is=!1}},Yg=async(e,t,r,n,s)=>{const i=Math.min(e+s,r),a=await Zu(()=>Q.getEventsBetween(e,i),"sdk_replay_get_events_between_seconds");if(!(a!=null&&a.length))return _.debug("NoEventsFound"),{validStartFound:n,events:[]};if(!n){_.debug("ValidStartSearch");let o=-1;return a==null||a.forEach((l,c)=>{if(!l.isValidStart)return;const u=l.timestamp<=t;(o<0||u)&&(o=c)}),o<0?(_.debug("ValidStartNotFound"),{validStartFound:n,events:[]}):{validStartFound:!0,events:a==null?void 0:a.slice(o)}}return{validStartFound:n,events:a}},td=e=>Promise.all(e.map(async t=>{const r=await(async n=>Uu.execute(async()=>{var a;_.info("UploadChunkStart",{chunkIndex:n.chunkIndex,surveyId:n.surveyId});const s=await Ge(n.uploadUrl,{body:n.data,method:"PUT"});_.http("UploadChunkEnd",{url:n.uploadUrl,method:"PUT",status_code:s.status,reason:s.statusText??"OK",chunkIndex:n.chunkIndex,surveyId:n.surveyId});const i=(a=s.headers)==null?void 0:a.get("ETag");if(!i)throw new Error(`Upload response did not include etag for upload ${n.uploadId}, part ${n.chunkIndex}`);return i}))(t);return await Q.updatePartial("chunkUploads",t.uuid,{data:null,etag:r,status:"UploadComplete"}),t.uploadId})),rd=async e=>{const t=await Q.getChunkUploadsByStatus({status:"UploadComplete",uploadId:e});if(!(t!=null&&t.length))return void _.info("NoChunksForUpload",{uploadId:e});const r=t.reduce((i,a)=>(i.find(o=>o.chunkIndex===a.chunkIndex)||i.push(a),i),[]);r.sort((i,a)=>i.chunkIndex-a.chunkIndex);const n=r.map(i=>({ETag:i.etag,PartNumber:i.chunkIndex})).filter(i=>i.ETag!==null),s=r[0];await Tu({apiUrl:s.apiUrl,surveyId:s.surveyId,uploadId:e,responseGroupUuid:s.responseGroupId,etags:n,headers:s.completeUploadHeaders,replayDuration:s.replayDuration}),await Q.deleteChunkUploads("UploadComplete",e)},$g=()=>{ke(async()=>{const e=await Q.getChunkUploadsByStatus({sessionId:we,status:"ReadyForUpload"});if(!(e!=null&&e.length))return;const t=await td(e);t!=null&&t.length&&await Promise.all(t.map(r=>{if(r)return rd(r)}))},"Error uploading unfinished chunks")},qg=async(e,t)=>{const r=t??Date.now();return(async(n,s)=>{const i=new TextEncoder;let a=null;const o=new CompressionStream("gzip"),l=o.writable.getWriter();let c=!1,u=!1,[d,p]=[0,0],f=[];for(let h=n-35e3;h<s;h+=xi){if({validStartFound:u,events:f}=await Yg(h,n,s,u,xi),!(f!=null&&f.length)){_.debug("NoEventsFound");continue}d===0&&(d=f[0].timestamp),p=f[f.length-1].timestamp;const k=f.map(v=>v.event);k.push(`{"timestamp":${s}}`);const m=`${c?",":"["}${k}`,g=i.encode(m);Qu(()=>{l.write(g)},"sdk_replay_compression_seconds"),c=!0}if(p-d<ed)return _.debug("ReplayTooShort"),null;const y=i.encode("]");return l.write(y),l.close(),a=new Uint8Array(await new Response(o.readable).arrayBuffer()),a})(r-e,r)},ul=async e=>{const{surveyId:t,responseGroupId:r,visitorId:n,apiUrl:s,completeUploadHeaders:i,replayParams:a,triggerTimestamp:o}=e,l=await qg(1e3*a.replayDurationSeconds,o);if(!(l!=null&&l.length))return void _.info("FileDataEmpty",{surveyId:t});const c=((d,p,f)=>{const y=d.length,h=1024*p*1024,k=Math.ceil(y/f),m=Math.max(h,k),g=[];let v=0;for(;v<y;)g.push(d.slice(v,v+m)),v+=m;return g})(l,a.minimumChunkSizeMb,a.signedUrls.length),u=await Promise.all(c.map(async(d,p)=>{const f=yt(),y={apiUrl:s,chunkIndex:p+1,completeUploadHeaders:i,etag:null,responseGroupId:r,status:"ReadyForUpload",surveyId:t,timestamp:o,totalChunks:c.length,data:d,uploadId:a.uploadId,uploadUrl:a.signedUrls[p].url,uuid:f,visitorId:n};return await(await Q.openDB()).add("chunkUploads",{...y,sessionId:y.sessionId??we}),y}));await(async(d,p)=>{await td(p),await Promise.all(d.map(f=>rd(f)))})([a.uploadId],u)},nd=async(e,t)=>{if(He())return _.debug("ReplayDisabled-ScheduleOrCapture");const{isHeatmap:r,isStandalone:n,replayParams:s,triggerTimestamp:i,responseGroupId:a}=e,o=async()=>{setTimeout(()=>z.removeListener(F.QuestionAnswered,o),0),ke(async()=>{s.replayDurationType==="before"?await ul(e):await Q.markPendingCaptureToCanUpload(a)},"Error in schedule/capture callback")};ke(async()=>{if(s.replayDurationType==="after"||s.replayDurationType==="beforeAndAfter")return!n&&!r&&z.on(F.QuestionAnswered,o),void await id(e);if(n||r||t)await ul(e),r&&Jg();else{const l=35+s.replayDurationSeconds,c=i-1e3*l,u=i;await Q.updateEventsExpiredAt(c,u,s.expirationTimeLimitMinutes),z.on(F.QuestionAnswered,o)}},"Error in scheduling/capturing replay")},Jg=async()=>{parseInt(at??"0")||ce.removeItem("sprig.isCapturingHeatmap"),ce.getItem("sprig.teardownAfterCapture")&&(Wu(),sd(),ce.removeItem("sprig.teardownAfterCapture"))},sd=async()=>He()?_.debug("ReplayDisabled-ClearData"):Promise.all([Q.deleteBySessionId("events",we),Q.deleteBySessionId("pendingCaptures",we)]).catch(e=>{wr("Error clearing user replay data",e)}),id=async e=>{if(He())return;const{isHeatmap:t,surveyId:r}=e,n=await Q.getPendingCaptures(),s=n==null?void 0:n.filter(l=>l.captureParams.surveyId===r);if(s!=null&&s.length)return void _.info("PendingCaptureExists",{surveyId:r});t&&(Ei(),ce.setItem("sprig.isCapturingHeatmap","true"),Ri=Date.now(),de.inactivityInterval||(de.inactivityInterval=window.setInterval(()=>{var l;l=Ri,Date.now()-l>=3e4&&ke(()=>Q.markPendingHeatmapsReady(),"Error in heatmap inactivity")},1e3)));const i={...e,replayParams:{...e.replayParams}};e.replayParams.replayDurationType==="beforeAndAfter"&&(i.replayParams.replayDurationSeconds*=2),i.replayParams.replayDurationType="before";const a=e.triggerTimestamp+1e3*e.replayParams.replayDurationSeconds;i.triggerTimestamp=a,at=(parseInt(at??"0")+1).toString(),ce.setItem("sprig.pendingCount",at),await(await Q.openDB()).add("pendingCaptures",{canUpload:!1,captureParams:i,sessionId:we,targetTimestamp:a,timestamp:Date.now(),uuid:yt()})},Xg=Object.freeze(Object.defineProperty({__proto__:null,RecordEvent:e=>{qe("Sprig_TrackEvent",e)},RecordPageView:e=>{e.description&&(e.description=ao(e.description)),qe("Sprig_PageView",e)},RecordSurveyShown:e=>{qe("Sprig_ShowSurvey",e)},_completeSessionReplay:async({surveyId:e,responseGroupUuid:t,eventDigest:r,headers:n})=>{if(!e||!t)return!1;const s=window.UserLeap._API_URL,i=await Tu({surveyId:e,responseGroupUuid:t,eventDigest:r,apiUrl:s,headers:n},!0);return!(i!=null&&i.error)},checkPendingHeatmapsUrl:()=>He()?_.debug("ReplayDisabled-PendingHeatmaps"):ke(async()=>{const e=(await Q.getPendingCaptures({isHeatmap:!0})).map(t=>({eventId:t.captureParams.eventId,uuid:t.uuid})).filter(({eventId:t})=>!pu(t)).map(({uuid:t})=>t);return _.info("PendingHeatmapsToComplete",{count:e.length}),e.length&&(await Q.markPendingHeatmapsReady(e),_.info("MarkedPendingHeatmapsReady")),e.length},"Error marking pending heatmaps ready"),clearUserReplayData:sd,disableRecording:wr,initializeReplay:async({maxReplayDurationSeconds:e,maxInflightRequests:t=2,replaySettings:r,teardownAfter:n=!1,apiUrl:s,alwaysOnConfig:i})=>{if(i&&Dg({apiUrl:s,config:i,triggerSnapshot:()=>{Ei()}}),at=ce.getItem("sprig.pendingCount"),de.isRecording)return;if(n&&ce.setItem("sprig.teardownAfterCapture","true"),He())return _.debug("ReplayDisabled");if(await(async()=>{var l;if(!ju())return!0;if((l=window.navigator.storage)!=null&&l.estimate)try{const{quota:c=0,usage:u=0}=await window.navigator.storage.estimate(),d=(c-u)/1024**3;return _.info("Storage",{availableGb:d}),d<.5}catch{return!0}return!1})())return _.debug("IDBNotSupported"),ki();try{const l=await Q.openDB();_.info("DBVersion",{version:l.version})}catch(l){return _.error("ReplayOpenErr",{name:l.name}),l.name==="VersionError"&&Q.deleteDB(),ki()}ke(async()=>{await Ai(!0)},"Error uploading ready pending captures");const a=Tt()?30:0,o=Math.max(e??0,a);if(!o)return _.debug("MissingDuration");_.debug("ReplayInit"),await ke(async()=>{var l;r!=null&&r.minDuration&&(ed=r.minDuration),r!=null&&r.batchDuration&&(xi=r.batchDuration),l=t,Uu.setLimit(l),$g(),Gg(o+35,1800,o+35),Hg();const c=window.UserLeap.replayLibraryURL??"https://cdn.sprig.com/dependencies/record-2.0.0-alpha.17.min.js",u=window.rrwebRecord;if(!u)return _.error("RecordScriptFailed");let d=!0,p=0;const f={checkoutEveryNms:3e4,sampling:{input:"last",scroll:250,media:800},...r};var y,h;de.stopRecording=u({emit:(k,m)=>{if(k.type===it.Custom&&(Ri=Date.now()),He()||Mn())return;if(m&&k.type===it.Meta)p=performance.now();else if(m&&p&&k.type===it.FullSnapshot){const v=performance.now()-p;bu("sdk_replay_snapshot_seconds",v/1e3)}const g=d||!!m&&k.type===it.Meta;d=!1,jg(g,k),Wg({uuid:yt(),event:JSON.stringify(k),isValidStart:g,timestamp:Date.now()})},...f}),de.isRecording=!!de.stopRecording,de.isRecording&&(((k,m)=>{window.addEventListener("message",g=>{var v;g.data.type===Sg&&(oo.push({source:g.source,origin:g.origin}),(v=g.source)==null||v.postMessage({type:Ig,settings:k,replayLibraryUrl:m},{targetOrigin:g.origin}))})})(f,c),z.on("survey.complete",k=>{var m;m={id:k,userAgent:window.navigator.userAgent},qe("Sprig_SubmitSurvey",m)}),y=qe,h=Mg,An||(Ee=y,pn=h,window.addEventListener("click",Fu,We),window.addEventListener("pointerdown",zu,We),window.addEventListener("mousedown",Bu,We),window.addEventListener("keydown",_u,We),window.addEventListener("scroll",Nu,We),An=!0,Og(),Ag()))},"Error initializing replay")},isReplayPaused:Mn,isReplayRecording:()=>de.isRecording,recordFullSnapshot:Ei,recordReplayPaused:()=>{qe("Sprig_ReplayPaused",{timestamp:Date.now()}),ce.setItem("sprig.isReplayPaused","true")},recordReplayResumed:()=>{ce.removeItem("sprig.isReplayPaused"),qe("Sprig_ReplayResumed",{timestamp:Date.now()})},scheduleCapture:id,scheduleOrCaptureReplay:nd,tryReplayAction:ke,uploadReadyPendingCaptures:Ai},Symbol.toStringTag,{value:"Module"}));(e=>{te.replay=e})(Xg),window.UpChunk={createUpload:Hd},window.rrwebRecord=Yt,exports.APP_ID="ul-app",exports.ConflictingWidgets=tu,exports.DEFAULT_BORDER_COLOR="#e6e6e6",exports.DEFAULT_WIDTH_PX=360,exports.DismissReason=Ae,exports.EMBED_MOBILE_MAX_WIDTH=1030,exports.ERROR_BORDER_COLOR="#bd282a",exports.SprigAPI=yi,exports.SprigEvent=F,exports.breadcrumbsLogger=_,exports.calculateFrameDimensions=hu,exports.eventEmitter=z,exports.groupCards=(e,t)=>{const r=[e[t]],n=e[t].groupId;return n?e.slice(t).reduce((s,i)=>(i.groupId===n&&s.push(i),s),[]):r},exports.isHTMLElement=Be,exports.isLongFormSurvey=e=>e==="longFormSurvey",exports.resetScrollPosition=e=>{const t=e.querySelector(".ul-card__container");t&&(t.scrollTop=0)},exports.setSurveyStyles=hr,exports.shouldDirectEmbed=eo,exports.sprig=hg,exports.sprigFetch=Ge,exports.v4=yt;
72
+ </svg>`;const t=document.createElement("h3");return t.className="sprig-feedback-error-text",t.innerText="There was an error while loading the survey",e.appendChild(t),e},pi=new class{constructor(){ue(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(e){try{return!(!e||typeof e!="object"||Array.isArray(e))&&(Object.keys(this._ldData).forEach(t=>{delete this._ldData[t]}),Object.keys(e).forEach(t=>this._ldData[`!launch_darkly_${t}`]=(e[t]??0)+1),!0)}catch(t){return t instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",t),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}};Object.freeze(pi);const dn=new class{constructor(){ue(this,"_optimizelyData",{})}setOptimizelyExperiment(e,t=!0){if(!e||typeof e!="object")return!1;const{experiments:r}=e;try{return t&&Object.keys(this._optimizelyData).map(n=>{delete this._optimizelyData[n]}),r&&r.map(n=>{const{id:s,variation:i}=n,a=this.transformExperimentId(s);i&&typeof i=="string"&&(this._optimizelyData[a]=i)}),!0}catch(n){return n instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",n),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(e){return this._optimizelyData[this.transformExperimentId(e)]}transformExperimentId(e){return"!optimizely_experiments_"+e}getAndSetWebOptimizelyExperiments(){var e;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const t=(e=window.optimizely.get("state"))==null?void 0:e.getExperimentStates({isActive:!0});if(t){const r=Object.keys(t).map(n=>{var s,i;return(s=t[n].variation)!=null&&s.name?{id:n,variation:(i=t[n].variation)==null?void 0:i.name}:{id:n,variation:"Original"}});return this.setOptimizelyExperiment({experiments:r},!1),!0}return!1}return!1}catch(t){return t instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",t),!1}}};Object.freeze(dn);class Xf{constructor(t,r){ue(this,"paused");ue(this,"queue");ue(this,"ul");this.ul=t,this.paused=!1,this.queue=[],this.flush(r)}flush(t){const r=t.length;if(r)for(let n=0;n<r;n++)this.push(t[n])}isPaused(){return this.paused}pause(){this.paused=!0}unpause(){this.paused=!1;const t=this.queue.slice();this.empty(),this.flush(t)}push(t){if(this.paused)this.queue.push(t);else if(t instanceof Function)t();else{const r=Array.prototype.slice.call(t,1),n=t[0],s=this.ul[n];s instanceof Function?s.apply(this.ul,r):n&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",n)}}perform(t){if(this.paused){let r=()=>{};const n=new Promise(function(s){r=function(){s(t())}});return this.queue.push(r),n}return t()}empty(){this.queue.length=0}}let vu=!0,hi=!1;const Kf=["sdk_event_queue_latency_seconds","sdk_replay_add_event_batch_seconds","sdk_replay_cleanup_seconds","sdk_replay_compression_seconds","sdk_replay_get_events_between_seconds","sdk_replay_snapshot_seconds","sdk_mutations_nodes_added","sdk_mutations_nodes_removed","sdk_mutations_attributes_changed","sdk_mutations_character_data","sdk_dom_nodes_count","sdk_page_html_characters"];let mi,qt={};class Zf{constructor(t){ue(this,"_values",[]);ue(this,"_isWebMetric");this.name=t,this._isWebMetric=Kf.includes(this.name)}report(t){if(vu&&this._values.push({time:Date.now(),value:t}),hi||!this._isWebMetric)return;const r=this.findExceededThreshold(t);r&&mi&&mi(t,r)}collect(){const t=this._values;return this._values=[],t}findExceededThreshold(t){const r=qt[this.name];if(r)return r.find(n=>this.valueExceedsThreshold(t,n))}valueExceedsThreshold(t,r){return r.type==="max"?t>r.value:r.type==="min"&&t<r.value}}const yr={},Ve=e=>{const t=new Zf(e);return yr[e]=t,t},bu=(e,t)=>{let r=yr[e];return r||(r=Ve(e)),r.report(t)},Qf=({reportingIntervalSeconds:e,postMetrics:t})=>{e?setInterval(()=>{(async r=>{const n=Object.values(yr).map(s=>({name:s.name,values:s.collect()}));if(n.some(s=>s.values.length))try{await r(JSON.stringify(n))}catch(s){s instanceof Error&&_.error("MetricsErr",{error:{message:s.message,name:s.name}})}})(t)},1e3*e):vu=!1};let Su,Iu;const fi=e=>{let t=0,r=e.firstElementChild;for(;r;)t+=fi(r),r.shadowRoot&&(t+=fi(r.shadowRoot)),r=r.nextElementSibling,t++;return t},el=()=>{Su.report(fi(document.body)),Iu.report(document.documentElement.innerHTML.length)},gi=(e,t)=>{const r=performance.now();document.hidden?setTimeout(()=>gi(e,t),e):setTimeout(()=>{const n=performance.now()-r;t.report(n/1e3),setTimeout(()=>gi(e,t),e)},0)};let kn,En,xn,Rn,tl,dt={};const $r=(e,t=1)=>{const{name:r}=e;dt[r]=(dt[r]||0)+t},Cu=e=>{let t=1;return e.childNodes.forEach(r=>{t+=Cu(r)}),t},rl=e=>{let t=0;return e.forEach(r=>{t+=Cu(r)}),t},eg=e=>{switch(e.type){case"childList":return $r(kn,rl(e.addedNodes)),void $r(En,rl(e.removedNodes));case"attributes":return void $r(xn);case"characterData":return void $r(Rn)}},tg=e=>e.forEach(eg),rg=()=>{kn.report(dt[kn.name]||0),En.report(dt[En.name]||0),xn.report(dt[xn.name]||0),Rn.report(dt[Rn.name]||0),dt={}},ng=(e=1e3)=>{kn=Ve("sdk_mutations_nodes_added"),En=Ve("sdk_mutations_nodes_removed"),xn=Ve("sdk_mutations_attributes_changed"),Rn=Ve("sdk_mutations_character_data"),tl=new MutationObserver(tg),tl.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),setInterval(rg,e)},sg=({isWeb:e,reportingIntervalSeconds:t,thresholds:r,postMetrics:n})=>{((s,i)=>{qt={},hi=!1,s==null||s.forEach(a=>{var o;a.metric in qt||(qt[a.metric]=[]),(o=qt[a.metric])==null||o.push(a)}),mi=i})(r,(s,i)=>{var a,o;if((a=te.replay)!=null&&a.isReplayRecording()){const l=`Value: ${s} on ${i.metric} violated threshold of ${i.type} ${i.value}`;(o=te.replay)==null||o.disableRecording("Threshold violated",new Error(l),{reportError:!1}),window.UserLeap.reportError("Sdk Performance Metric threshold violated",new Error("Sdk Performance Metric threshold violated"),{metricName:i.metric,type:i.type,value:i.value},{metricName:i.metric}),hi=!0}}),Qf({reportingIntervalSeconds:t,postMetrics:n}),e&&(((s=1e3)=>{const i=Ve("sdk_event_queue_latency_seconds");gi(s,i)})(),((s=1e4)=>{Su=Ve("sdk_dom_nodes_count"),Iu=Ve("sdk_page_html_characters"),el(),setInterval(el,s)})(),ng())},ig="test",og=["popState","pushState","replaceState"];let io,tr;const Ln={},jt="!email",ku="pageUrl";let gs=window.location.href;function rr(e){var o,l;const{pageUrlEvents:t,interactiveEvents:r,dismissOnPageChange:n,platform:s}=window.UserLeap._config;if(s&&s!=="web")return;gs!==window.location.href&&_.navigation("LocationChange",{from:gs,to:window.location.href}),gs=window.location.href;const i=Ru().trackStartUrl,a=i?String(i):null;t&&Ou(window.location.href),r&&(xu(),ag()),mu()&&(()=>{if(In())return;const c=Rt();c&&(pu(er)||(c.remove(),er=null,Z=null))})(),ce.getItem("sprig.isCapturingHeatmap")&&((l=(o=te.replay)==null?void 0:o.checkPendingHeatmapsUrl())==null||l.then(c=>{var u;c&&((u=te.replay)==null||u.uploadReadyPendingCaptures(!0))})),!In()&&n&&a&&a!==window.location.href&&e&&og.includes(e.type)&&window.UserLeap("dismissActiveSurvey",Ae.PageChange)}const Eu={capture:!0},ag=()=>{const e=window.UserLeap._config.interactiveEvents.filter(r=>no(r,window.location.href)).map(r=>{const{name:n,properties:s}=r,{selector:i,innerText:a}=s;return i?o=>{if(Xa(o.target))try{o.target.closest(i)&&window.UserLeap("track",n)}catch{}return!1}:o=>(Xa(o.target)&&o.target.innerText===a&&window.UserLeap("track",n),!1)}),t=r=>e.forEach(n=>n(r));window.UserLeap._config.interactiveEventsHandler=t,window.addEventListener("click",t,Eu)},xu=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,Eu),delete window.UserLeap._config.interactiveEventsHandler};function Ru(){const e=Ce.getItemObject("userleap.ids");return e&&e[window.UserLeap.envId]||{}}function Lu(){if(window.previewMode)return;const e=Ce.getItemObject("sprig.anon.env.vid.map")||{},t=e[window.UserLeap.envId];window.UserLeap.visitorId=t||yt(),_.info("NewVid",{vid:window.UserLeap.visitorId}),Ie("vid",window.UserLeap.visitorId),t||(e[window.UserLeap.envId]=window.UserLeap.visitorId,Ce.setItemObject("sprig.anon.env.vid.map",e)),z.emit(F.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}function Ou(e,t,r,n){var s,i;try{if(e.endsWith("mock_snippet.html"))return;_.info("PageView",{url:e});const a=(s=document==null?void 0:document.querySelector('meta[name="description"]'))==null?void 0:s.getAttribute("content");(i=te.replay)==null||i.RecordPageView({...a&&{description:a},url:e,referrer:document.referrer,pageTitle:document.title});const o=window.UserLeap._config.pageUrlEvents;let l=!1;if(o&&o.length)for(let u=0;u<o.length&&(l=no(o[u],e),!l);u++);if(!l)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",e);const c={url:e};n&&(c.trackPageView=!0),window.UserLeap._queue.push(["track",ku,t,c,r])}catch(a){a instanceof Error&&(a.stack=e,window.UserLeap.reportError("trackPageView",a)),console.warn("[Sprig] (ERR-428) Failed to track page view",a)}}function lg(){const e="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in e&&(e.pushState=(t=>function(...r){const n=t.apply(this,r),s=new Event("pushState");return window.dispatchEvent(s),rr(s),n})(e.pushState)),"replaceState"in e&&(e.replaceState=(t=>function(...r){const n=t.apply(this,r),s=new Event("replaceState");return window.dispatchEvent(s),rr(s),n})(e.replaceState)),["hashchange","popstate"].forEach(t=>window.addEventListener(t,rr,!0))}async function ys(e,t){const r=to();e&&!t&&(window.UserLeap._config.mode=ig);const n=$n(Te(window.UserLeap)),s=await ze(function(i){const a=new URL(Me("1",[st],"questions"));return Object.entries(i||{}).forEach(([o,l])=>{l&&a.searchParams.append(o,String(l))}),a.toString()}({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:n,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:e==null?void 0:e.surveyId,surveytemplateid:e==null?void 0:e.surveyTemplateId,vid:r}),{shouldDropOnRateLimit:!0});if(!s.ok)return s.reportError&&s.error&&(console.warn("[Sprig] (ERR-414) Failed to request questions from the server",s.error),window.UserLeap.reportError("getQuestions",s.error)),{success:!1,surveyState:"no survey"};if(s.json.delay&&await Sn(s.json.delay),!s.json.isFeedback)return Qt(s.json,tr,io);{const{feedbackLabel:i,productConfig:a,surveyUuid:o,feedbackCustomStyles:l}=s.json,{buttonTheme:c,placement:u,desktopDisplay:d}=a;wu({customStyles:l,buttonTheme:c,desktopDisplay:d,eventId:0,feedbackLabel:i,placement:u,surveyUuid:o,surveyId:e==null?void 0:e.surveyId},s.json)}}function cg(e){if(!e)return;window.UserLeap._config=e,e.mute&&window.UserLeap._queue.pause();const{interactiveEvents:t,pageUrlEvents:r,dismissOnPageChange:n}=e;t&&function(s){let i=s.length;for(;i;){const a=Math.floor(Math.random()*i);i-=1;const o=s[i];s[i]=s[a],s[a]=o}}(t),(t||r||n)&&(lg(),rr())}const ug=function(e){if(!window.UserLeap)return;const t=async(s={})=>{var m,g,v,I,M;const{userId:i,anonymousId:a,metadata:o={},properties:l,showSurveyCallback:c}=s;let{eventName:u}=s;if(window.UserLeap.debugMode&&u!==ku&&console.info("[DEBUG] Sprig track",s),e.mode==="test")return;const d=Ce.getItem("sprig.previewKey")??void 0;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!i){const x="[Sprig] - Skipping tracking without userId";return console.warn(x),{success:!1,message:x,surveyState:"no survey"}}if(!u||u.trim().length===0){u=u?String(u):"";const x="[Sprig] - Invalid event name "+u;return console.warn(x),{success:!1,message:x,surveyState:"no survey"}}const p=tr??window.location.href;o.url||(o.url=p),Ie("trackStartUrl",p),(g=(m=window.UserLeap)==null?void 0:m._config)!=null&&g.optimizelyEnabled&&(pr(Te(window.UserLeap))||dn.getAndSetWebOptimizelyExperiments(),o.optimizelyExperiments=Object.assign({},dn.getAllOptimizelyExperiments())),(I=(v=window.UserLeap)==null?void 0:v._config)!=null&&I.launchDarklyEnabled&&(o.launchDarklyFlags=pi.getAllLaunchDarklyVariations()),i&&(window.UserLeap.userId=i),a&&(window.UserLeap.partnerAnonymousId=a),l&&(o.eventProperties=l),(M=te.replay)==null||M.RecordEvent({name:u,url:o.url}),_.info("TrackEvent",{eventName:u});const f=window.UserLeap.delayingSurvey||fu()?await ze(Me("1",[nt],"events/batch"),{body:JSON.stringify({events:[{event:u,metadata:o}],previewKey:d}),method:"POST",shouldDropOnRateLimit:!0}):await ze(Me("1",[nt],"events"),{body:JSON.stringify({event:u,metadata:o,previewKey:d}),method:"POST",shouldDropOnRateLimit:!0});if(!f.ok){const x="[Sprig] (ERR-421) Failed to track event";return f.reportError&&(console.warn(x,f.error),f.error&&window.UserLeap.reportError("track",f.error)),{success:!1,message:x,error:f.error,surveyState:"no survey"}}i&&Ie("uid",i),a&&Ie("aid",a);const y=f.json;y.invalidPreviewKey&&Ce.removeItem("sprig.previewKey");const h=o.trackPageView?o.url:void 0;return y!=null&&y.feedbackButton&&wu(y.feedbackButton,void 0,h),await async function(x,U){var E,L;let A=!0;return!(U&&((E=x==null?void 0:x.json)!=null&&E.surveyId)&&(window.UserLeap.delayingSurvey=!0,A=await U(x.json.surveyId),window.UserLeap.delayingSurvey=!1,!A))&&((L=x==null?void 0:x.json)!=null&&L.delay&&!window.UserLeap.isMobileSDK&&(window.UserLeap.delayingSurvey=!0,await Sn(x.json.delay),window.UserLeap.delayingSurvey=!1),A)}(f,c)?function(x){if(!window.UserLeap._config.dismissOnPageChange)return!0;const U=new URL(x),A=new URL(tr??window.location.href);return U.hostname===A.hostname&&U.pathname===A.pathname}(p)?Qt(y,h,io):{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"}},r=(s,i)=>{var o;const a=(o=s==null?void 0:s.querySelector(`[id="${ro}"]`))==null?void 0:o.contentDocument;a&&hr({document:a,elementId:"ul-custom-style",styleString:i})},n={displaySurvey:async s=>(console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),window.UserLeap("dismissActiveSurvey",Ae.Override),ys({surveyId:s},!0)),_previewSurvey(s){window.UserLeap("dismissActiveSurvey",Ae.Override),ys({surveyTemplateId:s},!1)},_reviewSurvey(s){window.UserLeap("dismissActiveSurvey",Ae.Override),ys({surveyId:s},!1)},previewSurvey(s){n._previewSurvey(s)},reviewSurvey(s){n._reviewSurvey(s)},mute(){window.UserLeap._queue.pause()},unmute(){window.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(s=Ae.API){window.UserLeap.container&&(s===Ae.Closed&&window.Sprig.trackHistory&&window.Sprig.trackHistory({event:"closed"}),z.emit(F.SurveyCloseRequested,{name:F.SurveyCloseRequested,initiator:s,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}),z.emit(F.SurveyWillClose,{name:F.SurveyWillClose,initiator:s,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}))},async setAttribute(s,i){if(!s||!i&&i!==0&&i!==!1){const a="[Sprig] - Disregarding empty attribute / value provided";return console.warn(a),{success:!1,message:a}}return this.setAttributes({[s]:i})},async setAttributes(s){if(s==null||Object.keys(s).length===0){const i="[Sprig] - Disregarding empty attributes provided";return console.warn(i),{success:!1,message:i}}return this.identifyAndSetAttributes({attributes:s})},async identifyAndSetAttributes(s){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",s),e.mode==="test")return;if(s===null||typeof s!="object"||!(s.userId||s.anonymousId||s.attributes)){const u="[Sprig] - Disregarding empty payload provided";return console.warn(u),{success:!1,message:u}}const{userId:i,anonymousId:a,attributes:o}=s;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!i){const u="[Sprig] - Skipping tracking without userId";return console.warn(u),{success:!1,message:u}}if(o){o.email&&!o[jt]&&(o[jt]=o.email,delete o.email);const u=Object.keys(o);for(const d of u)o[d]===Ln[d]&&delete o[d]}if(!(o&&Object.keys(o).length!==0||i&&window.UserLeap.userId!==i||a&&window.UserLeap.partnerAnonymousId!==a))return{success:!0};const l={};let c;return i&&(l.userId=window.UserLeap.userId=i),a&&(l.partnerAnonymousId=window.UserLeap.partnerAnonymousId=a),o&&Object.keys(o).length>0?(c=await ze(Me("1",[st,nt],"attributes"),{body:JSON.stringify(o),method:"PUT"}),c.ok?Object.assign(Ln,o):c.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",c.error),c.error&&window.UserLeap.reportError("identifyAndSetAttributes",c.error))):c=await ze(Me("1",[st,nt]),{body:JSON.stringify(l),method:"PUT"}),o&&o[jt]&&(window.UserLeap.email=o[jt]),c.ok&&(i&&Ie("uid",i),a&&Ie("aid",a)),{success:!!c.ok}},async removeAttributes(s){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",s),e.mode==="test")return;if(s==null||s.length===0){const a="[Sprig] - Disregarding empty attributes provided";return console.warn(a),{success:!1,message:a}}if(e.requireUserIdForTracking&&!window.UserLeap.userId){const a="[Sprig] - Skipping tracking without userId";return console.warn(a),{success:!1,message:a}}const i=await ze(Me("1",[st,nt],"attributes"),{body:JSON.stringify({delete:s}),method:"DELETE"});return!i.ok&&i.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",i.error),i.error&&window.UserLeap.reportError("removeAttributes",i.error)),{success:!!i.ok}},async addSurveyListener(s){z.on(F.SurveyLifeCycle,s)},async removeSurveyListener(s){z.removeListener(F.SurveyLifeCycle,s)},async addListener(s,i){z.on(s,i)},async removeListener(s,i){z.removeListener(s,i)},async removeAllListeners(){z.removeAllListeners()},setPreviewKey(s){s&&typeof s=="string"&&Ce.isStorageAvailable&&s&&Ce.setItem("sprig.previewKey",s)},async setUserId(s){var o;if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",s),s==null){const l=`[Sprig] - Invalid userId ${s}`;return console.warn(l),{success:!1,message:l}}if(e.mode==="test"||s===window.UserLeap.userId)return;window.UserLeap.userId=s;const i=window.UserLeap.visitorId,a=await ze(Me("1",[st,nt]),{body:JSON.stringify({userId:s}),method:"PUT"});a.ok?(i!==window.UserLeap.visitorId&&((o=te.replay)==null||o.clearUserReplayData()),Ie("uid",s)):a.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",a.error),a.error&&window.UserLeap.reportError("setUserId",a.error))},async setPartnerAnonymousId(s){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",s),s==null){const i=`[Sprig] - Invalid partnerAnonymousId ${s}`;return console.warn(i),{success:!1,message:i}}return window.UserLeap.partnerAnonymousId=s,Ie("aid",s),{success:!0}},track:async(s,i,a={},o=void 0)=>t({eventName:s,properties:i,metadata:a,showSurveyCallback:o}),identifyAndTrack:async s=>await t(s),trackPageView(s,i=void 0,a=void 0,o=!0){tr=s,Ou(s,i,a,o)},applyFeedbackStyles({button:s="",view:i=""}){window.UserLeap.feedbackCustomStyles=i,document.getElementById("sprig-feedback-style")&&hr({document,elementId:"ul-custom-style",styleString:s,nonce:window.UserLeap.styleNonce}),r(document.querySelector(".ul-container-feedback"),i)},applyStyles(s){window.UserLeap.customStyles=s,r(window.UserLeap.container,s)},setWindowDimensions(s,i){var p,f;const a=typeof s=="string"?parseInt(s,10):s,o=typeof i=="string"?parseInt(i,10):i;isNaN(a)||isNaN(o)||(window.UserLeap.windowDimensions={width:a,height:o});const l=Te(window.UserLeap),c=$n(l),u=l["userleap-platform"]==="web";if(!window.UserLeap.frameId)return;const d=document.getElementById(window.UserLeap.frameId);d&&(window.UserLeap.useMobileStyling&&((p=window.UserLeap.windowDimensions)!=null&&p.width&&(d.style.width=`${window.UserLeap.windowDimensions.width}px`),(f=window.UserLeap.windowDimensions)!=null&&f.height&&(d.style.maxHeight=window.UserLeap.windowDimensions.height-20+"px"),d.contentDocument&&(d.style.height=String(hu(d.contentDocument,u&&!c,eo(l))[0])+"px")),z.emit(F.SurveyDimensions,{name:F.SurveyDimensions,contentFrameWidth:d.clientWidth,contentFrameHeight:d.clientHeight,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}))},logoutUser(){var s;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),_.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,Ce.removeItem("userleap.ids"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),Lu(),(s=te.replay)==null||s.clearUserReplayData(),window.UserLeap._queue.unpause()},teardown(){["hashchange","popstate"].forEach(s=>window.removeEventListener(s,rr,!0)),window.UserLeap._config.interactiveEvents&&xu(),window.UserLeap("dismissActiveSurvey",Ae.API),delete window.UserLeap,delete window.Sprig,delete window._Sprig},integrateOptimizely(s,i=!0){var a,o;if((o=(a=window.UserLeap)==null?void 0:a._config)!=null&&o.optimizelyEnabled)try{const l=typeof s=="string"?JSON.parse(s):s;dn.setOptimizelyExperiment(l,i)}catch(l){console.warn("[Sprig] Error with integrating Optimizely data"),l instanceof Error&&window.UserLeap.reportError("integrateOptimizely",l)}else console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.")},integrateOptimizelyClient(s){var i,a;if(!((a=(i=window.UserLeap)==null?void 0:i._config)!=null&&a.optimizelyEnabled))return void console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");s.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",({experiment:o,variation:l})=>{const c={experiments:[{id:o.id,variation:l.key}]};window.UserLeap("integrateOptimizely",c,!1)})},importLaunchDarklyData(s){var i,a;(a=(i=window.UserLeap)==null?void 0:i._config)!=null&&a.launchDarklyEnabled?pi.setLDFlagsVariations(s):console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.")},setVisitorAttribute:(s,i)=>(console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),n.setAttribute(s,i)),setEmail:async s=>n.setAttribute(jt,s),setVisitorEmail:async s=>(console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),n.setEmail(s)),_generateVideoUploadUrl:async s=>async function(i){var o;if(!i)return;const a=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const l=await fetch(a,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(l.ok){const c=await l.json();return(o=c==null?void 0:c.upload)==null?void 0:o.url}return null}catch(l){console.warn("[Sprig] Error with generating video upload url"),l instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",l)}}(s),_reportMetric(s,i){bu(s,i)},_completeSessionReplay:async({surveyId:s,responseGroupUuid:i,eventDigest:a})=>{var o;return te.replay?(o=te.replay)==null?void 0:o._completeSessionReplay({surveyId:s,responseGroupUuid:i,eventDigest:a,headers:Te(window.UserLeap)}):(window.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)},pauseReplayRecording(){var s,i,a,o;(i=(s=te.replay)==null?void 0:s.isReplayPaused)!=null&&i.call(s)||((o=(a=te.replay)==null?void 0:a.recordReplayPaused)==null||o.call(a))},resumeReplayRecording(){var s,i,a,o,l,c;(i=(s=te.replay)==null?void 0:s.isReplayPaused)!=null&&i.call(s)&&((o=(a=te.replay)==null?void 0:a.recordReplayResumed)==null||o.call(a),(c=(l=te.replay)==null?void 0:l.recordFullSnapshot)==null||c.call(l))}};Object.assign(window.UserLeap,n)};async function dg(e,t,r={},n={}){const s=window.__cfg&&window.__cfg.mode,i=to(),a=window.UserLeap.envId,o=window.document.documentElement,l={mode:s,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:o.clientWidth,clientHeight:o.clientHeight,location:tr??window.location.href,language:window.navigator.language,...r},c={action:e,breadcrumbs:_.breadcrumbs,err:{message:`${t==null?void 0:t.name} - ${t==null?void 0:t.message}`,stack:t==null?void 0:t.stack},meta:l,vid:i,envId:a,...n};(await ze(Me("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(c),shouldDropOnRateLimit:!0})).ok||console.warn("[Sprig] (ERR-444) Failed to report error to API",t)}function pg(e={}){var n;(n=window.SprigLoggerCallback)==null||n.call(window,"Initializing Sprig");const t=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";async function r(){var d,p,f,y,h;if(window.UserLeap.loaded)return;if((d=window.SprigLoggerCallback)==null||d.call(window,"Loading Sprig"),window.UserLeap.reportError=dg,window.UserLeap.loaded=!0,window.UserLeap._config=Object.assign({},e,window.UserLeap.config),window.UserLeap.delayingSurvey=!1,window.UserLeap._config&&typeof window.UserLeap._config=="object")for(const k in window.UserLeap._config)window.UserLeap[k]=window.UserLeap._config[k];if(window.Sprig.outstandingTransactionLimit!==void 0&&(e.outstandingTransactionLimit=window.Sprig.outstandingTransactionLimit),!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 s=Ru(),i=window.UserLeap.sampleRate;let a=s.sampled;if(i){if(a===null&&(a=Math.random()<i,Ie("sampled",a)),!a)return}else a!==null&&Ie("sampled",null);window.UserLeap._API_URL||(window.UserLeap._API_URL="https://api.sprig.com");const o=[...window.UserLeap._queue];window.UserLeap._queue=new Xf(window.UserLeap,[]),window.UserLeap._queue.pause();for(let k=0;k<o.length;k++)window.UserLeap._queue.push(o[k]);const l=s.token;l?(window.UserLeap.token=l,window.UserLeap.visitorId=s.vid??null,window.UserLeap.userId=s.uid??null,window.UserLeap.partnerAnonymousId=s.aid??null):Lu();const c=pr(Te(window.UserLeap));(p=window.SprigLoggerCallback)==null||p.call(window,"Sprig fetching config");const u=await async function(k){var I,M;const m=Te(window.UserLeap);document.addEventListener("securitypolicyviolation",Ya);const g=await Ge(Me("1",[st],"config"),{headers:m});if(document.removeEventListener("securitypolicyviolation",Ya),!g.ok)return(I=window.SprigLoggerCallback)==null||I.call(window,"Sprig config fetch failed"),g.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",g.error),g.error&&window.UserLeap.reportError("applyRemoteConfig",g.error)),ci("Disabled: failed to fetch configuration"),k;const v=g.json;return v!=null&&v.disabled?((M=window.SprigLoggerCallback)==null||M.call(window,"Sprig config fetch disabled"),ci(`Disabled: ${v.disabled}`),{disabled:v.disabled}):Object.assign({},v,k)}(e);if((f=window.SprigLoggerCallback)==null||f.call(window,"Sprig fetched config"),sg({isWeb:!c,reportingIntervalSeconds:u.metricsReportingEnabled||u.mobileMetricsReportingEnabled?u.metricsReportingIntervalSeconds:0,thresholds:u.metricThresholds,postMetrics:async k=>{var m;await ze(Me("1",[st],"metrics"),{body:k,method:"POST",headers:{"x-ul-replay-enabled":`${!!((m=te.replay)!=null&&m.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),!c){const k=u.alwaysOnReplay?{userAgent:window.navigator.userAgent,surveyId:u.alwaysOnReplay.surveyId,responseGroupUuid:u.alwaysOnReplay.responseGroupUuid,sdkVersion:"2.37.1",maxDurationSeconds:u.alwaysOnReplay.maxDurationSeconds}:void 0;await((y=te.replay)==null?void 0:y.initializeReplay({maxReplayDurationSeconds:u.maxReplayDurationSeconds,maxInflightRequests:window.UserLeap.maxInflightReplayRequests??2,replaySettings:u.replaySettings,apiUrl:window.UserLeap._API_URL,alwaysOnConfig:k})),io=u.replaySettings}ug(u),await cg(u),window.UserLeap._queue.unpause(),(h=window.SprigLoggerCallback)==null||h.call(window,"SdkReady"),z.emit(F.SDKReady,{mobileMetricsReportingEnabled:!!u.mobileMetricsReportingEnabled,metricsReportingInterval:u.metricsReportingIntervalSeconds||0,metricsThresholds:u.metricThresholds||[],maxMobileReplayDurationSeconds:u.maxMobileReplayDurationSeconds,mobileReplaySettings:u.mobileReplaySettings}),z.emit(F.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}),z.on(F.VisitorIDUpdated,()=>{for(const k in Ln)delete Ln[k]})}window.UserLeap.UPDATES=dr,window.UserLeap("setPreviewKey",t),document.readyState==="complete"?r():window.attachEvent?window.attachEvent("onload",r):window.addEventListener("load",()=>{r()},!1)}class yi{constructor(){ue(this,"UPDATES",dr)}displaySurvey(t){window.Sprig("displaySurvey",t)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(t,r){window.Sprig("setAttribute",t,r)}setAttributes(t){window.Sprig("setAttributes",t)}identifyAndSetAttributes(t){window.Sprig("identifyAndSetAttributes",t)}removeAttributes(t){window.Sprig("removeAttributes",t)}addListener(t,r){window.Sprig("addListener",t,r)}removeListener(t,r){window.Sprig("removeListener",t,r)}removeAllListeners(){window.Sprig("removeAllListeners")}setEmail(t){window.Sprig("setAttribute","!email",t)}setUserId(t){window.Sprig("setUserId",t)}setPartnerAnonymousId(t){window.Sprig("setPartnerAnonymousId",t)}track(t,r={},n={}){window.Sprig("track",t,r,n)}identifyAndTrack(t){window.Sprig("identifyAndTrack",t)}trackPageView(t,r,n){window.Sprig("trackPageView",t,r,n)}applyStyles(t){window.Sprig("applyStyles",t)}setWindowDimensions(t,r){window.Sprig("setWindowDimensions",t,r)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}pauseReplayRecording(){window.Sprig("pauseReplayRecording")}resumeReplayRecording(){window.Sprig("resumeReplayRecording")}}const hg={configure:e=>{if(!e.envId&&!e.environmentId)throw new Error("Initialization Error: Sprig configure requires an environmentId");if(e.envId||(e.envId=e.environmentId??""),e.installationMethod="web-npm-bundled",window.Sprig)return window.Sprig;window.Sprig=function(){window.Sprig._queue.push(arguments)},Object.getOwnPropertyNames(yi.prototype).map(r=>{r!=="constructor"&&(window.Sprig[r]=yi.prototype[r])});const t=window.Sprig;return t.appId=e.envId,t._queue=[],window.UserLeap=t,pg(e),window.Sprig}};var it=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(it||{}),$e=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))($e||{});const wi=(e,t)=>t.some(r=>e instanceof r);let nl,sl;const vi=new WeakMap,ws=new WeakMap,On=new WeakMap;let bi={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return vi.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return ot(e[t])},set:(e,t,r)=>(e[t]=r,!0),has:(e,t)=>e instanceof IDBTransaction&&(t==="done"||t==="store")||t in e};function Au(e){bi=e(bi)}function mg(e){return(sl||(sl=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Si(this),t),ot(this.request)}:function(...t){return ot(e.apply(Si(this),t))}}function fg(e){return typeof e=="function"?mg(e):(e instanceof IDBTransaction&&function(t){if(vi.has(t))return;const r=new Promise((n,s)=>{const i=()=>{s(t.error||new DOMException("AbortError","AbortError"))};t.oncomplete=()=>{n()},t.onerror=i,t.onabort=i});vi.set(t,r)}(e),wi(e,nl||(nl=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,bi):e)}function ot(e){if(e instanceof IDBRequest)return function(r){const n=new Promise((s,i)=>{r.onsuccess=()=>{s(ot(r.result))},r.onerror=()=>{i(r.error)}});return On.set(n,r),n}(e);if(ws.has(e))return ws.get(e);const t=fg(e);return t!==e&&(ws.set(e,t),On.set(t,e)),t}const Si=e=>On.get(e);function Ii(e,{blocked:t}={}){const r=indexedDB.deleteDatabase(e);return t&&(r.onblocked=n=>t(n.oldVersion,n)),ot(r).then(()=>{})}const gg=["get","getKey","getAll","getAllKeys","count"],yg=["put","add","delete","clear"],vs=new Map;function il(e,t){if(!(e instanceof IDBDatabase)||t in e||typeof t!="string")return;if(vs.get(t))return vs.get(t);const r=t.replace(/FromIndex$/,""),n=t!==r,s=yg.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!s&&!gg.includes(r))return;const i=async function(a,...o){const l=this.transaction(a,s?"readwrite":"readonly");let c=l.store;return n&&(c=c.index(o.shift())),(await Promise.all([c[r](...o),s&&l.done]))[0]};return vs.set(t,i),i}Au(e=>({...e,get:(t,r,n)=>il(t,r)||e.get(t,r,n),has:(t,r)=>!!il(t,r)||e.has(t,r)}));const wg=["continue","continuePrimaryKey","advance"],ol={},Ci=new WeakMap,Mu=new WeakMap,vg={get(e,t){if(!wg.includes(t))return e[t];let r=ol[t];return r||(r=ol[t]=function(...n){Ci.set(this,Mu.get(this)[t](...n))}),r}};async function*bg(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const r=new Proxy(t,vg);for(Mu.set(r,t),On.set(r,Si(t));t;)yield r,t=await(Ci.get(r)||t.continue()),Ci.delete(r)}function al(e,t){return t===Symbol.asyncIterator&&wi(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&wi(e,[IDBIndex,IDBObjectStore])}Au(e=>({...e,get:(t,r,n)=>al(t,r)?bg:e.get(t,r,n),has:(t,r)=>al(t,r)||e.has(t,r)}));const Sg="sprigReplayIframeLoaded",Ig="sprigReplayIframeSettings",Cg="sprigReplayIframeTakeFullSnapshot",kg="sprigReplayTeardown",oo=[],Uu=new class{constructor(e){ue(this,"awaitingResolvers",[]);ue(this,"activeCount",0);this.capacity=e}async acquire(){if(!(this.activeCount<this.capacity))return new Promise(e=>{this.awaitingResolvers.push(e)});this.activeCount++}release(){const e=this.awaitingResolvers.shift();e&&this.activeCount<=this.capacity?e():this.activeCount--}async execute(e){try{return await this.acquire(),await e()}finally{this.release()}}setLimit(e){this.capacity=e}}(2),Tu=async({apiUrl:e,surveyId:t,uploadId:r,etags:n,headers:s,responseGroupUuid:i,replayDuration:a,eventDigest:o},l=!1)=>{var u;if(!l&&!r&&!n)return void _.error("UploadErr",{isMobile:l,uploadId:r,etags:n});_.info("MarkUploadComplete",{surveyId:t});const c=await Ge(`${e}/sdk/1/completeSessionReplay`,{method:"POST",body:JSON.stringify({etags:n,uploadId:r,responseGroupUuid:i,surveyId:t,replayDuration:a,eventDigest:o,userAgent:(u=window==null?void 0:window.navigator)==null?void 0:u.userAgent}),headers:s,shouldRetryRequest:!0});return _.info("MarkUploadDone",{surveyId:t}),c},Eg=e=>{if(e instanceof Attr)return null;let t=1;for(let r=e.previousSibling;r;r=r.previousSibling)r.nodeName===e.nodeName&&++t;return t},Du=e=>{if(e===null)return"";const t=[];if(e instanceof Document)return"/";for(let r=e;r&&!(r instanceof Document)&&r!==null;r=r instanceof Attr?r.ownerElement:r.parentElement){const n=t[t.length]={name:void 0,position:null};switch(r.nodeType){case Node.TEXT_NODE:n.name="text()";break;case Node.ATTRIBUTE_NODE:n.name="@"+r.nodeName;break;case Node.PROCESSING_INSTRUCTION_NODE:n.name="processing-instruction()";break;case Node.COMMENT_NODE:n.name="comment()";break;case Node.ELEMENT_NODE:n.name=r.nodeName}n.position=Eg(r)}return"/"+t.reverse().map(r=>r.position!==null?`/${r.name}[${r.position}]`:`/${r.name}`).join("")},ao=e=>e&&e.trim().substring(0,500).replace(/\s\s+/g," ").replace(/\r?\n|\r/g," ").substring(0,250),We={capture:!0,passive:!0},xg=["a","button","input","option","li","link"],Rg=["Escape","Enter","Backspace","F5","Tab"];let An=!1,Ee=null,pn=null;const ll=e=>{var r;if(((r=e.tagName)==null?void 0:r.toLowerCase())==="html")return{element:"html"};const t={};return t.element=(n=>{if(!n.tagName)return"No tagName";const s=n.getAttribute("type");return s?`${s} ${n.tagName.toLowerCase()}`:n.tagName.toLowerCase()})(e),t},Lg=e=>{var n;if(!e)return{};const t={...ll(e)},r=e.parentElement;if(r&&xg.includes((n=r.tagName)==null?void 0:n.toLowerCase())){const s=ll(r);Object.assign(t,s)}return t},Pu=(e,t)=>{var s,i;let r=t.target;var n;t.target===((s=window.document)==null?void 0:s.body)&&window.Sprig.pointerDownTarget&&(r=window.Sprig.pointerDownTarget),n={x:t.x,y:t.y,type:e,elementAttributes:Lg(r),windowHeight:window.innerHeight,windowWidth:window.innerWidth,...r instanceof HTMLElement||r instanceof SVGElement||r instanceof MathMLElement?{rect:r==null?void 0:r.getBoundingClientRect(),xPath:Du(r)}:{}},(i=n==null?void 0:n.elementAttributes)!=null&&i.text&&(n.elementAttributes.text=ao(n.elementAttributes.text)),Ee==null||Ee("Sprig_Click",n)},_u=e=>{var t;Rg.includes(e.key)&&(t={key:e.key},Ee==null||Ee("Sprig_Keystroke",t))},Og=()=>{var e;window.performance.getEntriesByType("navigation").map(t=>t.type).includes("reload")&&(e={url:window.location.href,currentPageTitle:document.title},Ee==null||Ee("Sprig_Refresh",e))},Ag=()=>{var e;window.performance.getEntriesByType("navigation").map(t=>t.type).includes("back_forward")&&((e={curUrl:window.location.href,fromUrl:document.referrer,currentPageTitle:document.title}).currentPageTitle&&(e.currentPageTitle=ao(e.currentPageTitle)),Ee==null||Ee("Sprig_BackForward",e))},Nu=((e,t)=>{let r;return n=>{clearTimeout(r),r=window.setTimeout(()=>e(n),t)}})(e=>{if(!(e.target instanceof HTMLElement||e.target instanceof Document))return;let t=e.target;"scrollTop"in t||(t=t.documentElement),pn==null||pn({xPath:Du(t),x:t.scrollLeft,y:t.scrollTop,elementAttributes:{targetScrollWidth:t.scrollWidth,targetClientWidth:t.clientWidth,targetScrollHeight:t.scrollHeight,targetClientHeight:t.clientHeight}})},750),Fu=(cl="left_click",e=>Pu(cl,e));var cl;const Bu=e=>{e.button===2&&Pu("right_click",e)},zu=e=>{window.Sprig&&(window.Sprig.pointerDownTarget=e.target)},de={isRecording:!1,scrollEventUuids:{},stopRecording:()=>{}},ju=()=>window.indexedDB&&window.IDBKeyRange&&window.CompressionStream,we=(()=>{const e=ce.getItem("sprig.sessionId");if(e)return _.info("SessionIDFound",{savedSessionId:e}),ce.removeItem("sprig.sessionId"),e;const t=yt();return _.info("GeneratedSessionID",{uuid:t}),t})(),ki=()=>{ce.setItem("sprig.disableReplayRecording","disabled")},He=()=>!!ce.getItem("sprig.disableReplayRecording"),Mn=()=>!!ce.getItem("sprig.isReplayPaused");window.addEventListener("beforeunload",()=>{_.info("BeforeUnload",{sessionId:we}),ce.setItem("sprig.sessionId",we)});const qe=(e,t)=>{var r,n;if(!He()&&de.isRecording&&!Mn())try{(n=(r=window.rrwebRecord)==null?void 0:r.addCustomEvent)==null||n.call(r,e,t)}catch(s){wr("Error recording custom event",s)}},Mg=async e=>{const{x:t,xPath:r,y:n}=e,s=de.scrollEventUuids[r];if(s)return ke(async()=>{var o,l,c,u;const i=await Q.openDB(),a=await i.get("events",s);if(a!=null&&a.event){const d=JSON.parse(a.event),p=t>((l=(o=d.data)==null?void 0:o.payload)==null?void 0:l.x),f=n>((u=(c=d.data)==null?void 0:c.payload)==null?void 0:u.y);if(!p&&!f)return null;p&&(d.data.payload.x=t),f&&(d.data.payload.y=n),d.data.payload.elementAttributes=e.elementAttributes,a.event=JSON.stringify(d),await i.put("events",a)}else qe("Sprig_Scroll",e)},"Error updating scroll event");qe("Sprig_Scroll",e)},Wu=()=>{de.stopRecording&&(de.stopRecording(),de.stopRecording=void 0),de.isRecording=!1,["cleanupInterval","inactivityInterval","pendingCheckInterval"].forEach(e=>{de[e]&&(clearInterval(de[e]),de[e]=void 0)}),An&&(window.removeEventListener("click",Fu,We),window.removeEventListener("pointerdown",zu,We),window.removeEventListener("mousedown",Bu,We),window.removeEventListener("keydown",_u,We),window.removeEventListener("scroll",Nu,We),An=!1),oo.forEach(e=>{var t;(t=e.source)==null||t.postMessage({type:kg},{targetOrigin:e.origin})})},Ug=["did not allow mutations","called in an invalid security context"],Tg=(e,t,{reportError:r=!0,extraInfo:n={}})=>{if(!He()&&t instanceof Error){if(ki(),t.name==="VersionError")return _.error("VersionErr",{message:e}),void Q.deleteDB();(s=>{if(!s)return!0;for(const i of Ug)if(s.toLowerCase().includes(i))return!1;return!0})(t==null?void 0:t.message)&&(r&&window.UserLeap.reportError(e,t,n),Q.clearAll())}},wr=(e,t,{reportError:r}={reportError:!0})=>{Wu(),_.error("ReplayErr",{code:t.code,name:t.name}),Tg(e,t,{reportError:r})},ke=async(e,t)=>{try{return await e()}catch(r){wr(t,r)}},Ei=()=>{de.isRecording&&(ke(()=>{var e,t;return(t=(e=window.rrwebRecord)==null?void 0:e.takeFullSnapshot)==null?void 0:t.call(e,!0)},"Error recording full snapshot"),oo.forEach(e=>{var t;(t=e.source)==null||t.postMessage({type:Cg},{targetOrigin:e.origin})}))};let bs=0;(async()=>ju()&&Promise.allSettled([Ii("replayStorage"),Ii("sprig.replay")]))();const Q=new class{constructor(){ue(this,"wrapTransactionWithCounter",e=>{var n,s;const t=(s=(n=window.Sprig)==null?void 0:n._config)==null?void 0:s.outstandingTransactionLimit,r=t===void 0?100:t;if(r&&bs>r){const i="Too many outstanding transactions";wr(i,new Error(i),{reportError:!1})}bs++,e.done.finally(()=>{bs--})});ue(this,"getTransaction",async e=>{const t=(await this.openDB()).transaction(e,"readwrite");return this.wrapTransactionWithCounter(t),t})}openDB(){return function(e,t,{blocked:r,upgrade:n,blocking:s,terminated:i}={}){const a=indexedDB.open(e,t),o=ot(a);return n&&(a.onupgradeneeded=l=>{n(ot(a.result),l.oldVersion,l.newVersion,ot(a.transaction),l)}),r&&(a.onblocked=l=>r(l.oldVersion,l.newVersion,l)),o.then(l=>{i&&(l.onclose=()=>i()),s&&(l.onversionchange=c=>s(c.oldVersion,c.newVersion,c))}).catch(()=>{}),o}("sprigReplay",1,{upgrade:(e,t,r)=>{if(r===0&&ce.setItem("sprig.pendingCount","0"),!e.objectStoreNames.contains("events")){const n=e.createObjectStore("events",{keyPath:"uuid"});n.createIndex("sessionId","sessionId"),n.createIndex("timestamp","timestamp"),n.createIndex("[sessionId+timestamp]",["sessionId","timestamp"])}if(!e.objectStoreNames.contains("chunkUploads")){const n=e.createObjectStore("chunkUploads",{keyPath:"uuid"});n.createIndex("sessionId","sessionId"),n.createIndex("timestamp","timestamp"),n.createIndex("[sessionId+status]",["sessionId","status"]),n.createIndex("[uploadId+status]",["uploadId","status"]),n.createIndex("[sessionId+status+uploadId]",["sessionId","status","uploadId"])}if(!e.objectStoreNames.contains("pendingCaptures")){const n=e.createObjectStore("pendingCaptures",{keyPath:"uuid"});n.createIndex("sessionId","sessionId"),n.createIndex("timestamp","timestamp"),n.createIndex("[sessionId+targetTimestamp]",["sessionId","targetTimestamp"])}}})}async deleteDB(){try{await Ii("sprigReplay")}catch{}}async bulkAdd(e,t){const r=await this.getTransaction(e);return Promise.all([...t.map(n=>r.store.add(n)),r.done])}async clearAll(){const e=(await this.openDB()).transaction(["events","chunkUploads","pendingCaptures"],"readwrite");return this.wrapTransactionWithCounter(e),Promise.all([e.objectStore("events").clear(),e.objectStore("chunkUploads").clear(),e.objectStore("pendingCaptures").clear()])}async deleteBySessionId(e,t){const r=IDBKeyRange.only(t),n=await this.getTransaction(e),s=n.store.index("sessionId");for await(const i of s.iterate(r))await i.delete();await n.done}async updatePartial(e,t,r){const n=await this.getTransaction(e),s=await n.store.get(t);s&&await n.store.put({...s,...r}),await n.done}async deleteRowsBefore(e,t,r=()=>!0){const n=IDBKeyRange.upperBound(t,!0),s=await this.getTransaction(e),i=s.store.index("timestamp");for await(const a of i.iterate(n))r(a.value)&&await a.delete();await s.done}async getEventsBetween(e,t=Date.now()){if(e>=t)return Promise.resolve([]);const r=IDBKeyRange.bound([we,e],[we,t],!1,!0);return(await this.openDB()).getAllFromIndex("events","[sessionId+timestamp]",r)}async updateEventsExpiredAt(e,t,r=30){const n=new Date,s=n.setMinutes(n.getMinutes()+(r??30)),i=await this.getTransaction("events"),a=i.store.index("[sessionId+timestamp]"),o=IDBKeyRange.bound([we,e],[we,t],!1,!0);for await(const l of a.iterate(o))await l.update({...l.value,expiredAt:s});await i.done}async deleteChunkUploads(e,t){const r=IDBKeyRange.only([t,e]),n=await this.getTransaction("chunkUploads");let i=await n.store.index("[uploadId+status]").openCursor(r);for(;i;)i.delete(),i=await i.continue();await n.done}async getChunkUploadsByStatus({sessionId:e,status:t,uploadId:r}){const n=(await this.openDB()).transaction("chunkUploads","readonly");this.wrapTransactionWithCounter(n);const s=r?n.store.index("[uploadId+status]"):n.store.index("[sessionId+status]"),i=r?IDBKeyRange.only([r,t]):IDBKeyRange.only([e,t]);return s.getAll(i)}async getPendingCaptures(e={}){return(await(await this.openDB()).getAllFromIndex("pendingCaptures","sessionId",we)).filter(r=>!e.beforePresent||r.targetTimestamp<Date.now()).filter(r=>!e.isBeforeType||r.captureParams.replayParams.replayDurationType==="before").filter(r=>!e.isHeatmap||(r.captureParams.isHeatmap??!1))}async markPendingCaptureToCanUpload(e){const t=await this.getTransaction("pendingCaptures"),r=t.store.index("sessionId");for await(const n of r.iterate(we)){const s=n.value;s.captureParams.responseGroupId===e&&await n.update({...s,canUpload:!0})}await t.done}async markPendingHeatmapsReady(e){if(parseInt(ce.getItem("sprig.pendingCount")??"0")===0)return null;const t=Date.now(),r=await this.getTransaction("pendingCaptures"),n=r.store.index("sessionId");for await(const s of n.iterate(we)){const i=s.value;!i.captureParams.isHeatmap||e&&!e.includes(i.uuid)||await s.update({...i,targetTimestamp:t,captureParams:{...i.captureParams,triggerTimestamp:t,replayParams:{...i.captureParams.replayParams,replayDurationSeconds:Math.floor((t-i.timestamp)/1e3)}}})}await r.done}},Ze=[];let vr,Vu,mt=[],Ut=!1,Mt=0,hn=!1,Gu=!1;const lo=[];let Un,Hu,mn,Yu,Ss=!1;const Tt=()=>hn&&!Ut&&Date.now()<=Un,Dg=({apiUrl:e,config:t,triggerSnapshot:r,forceInit:n=!1})=>{hn&&!n||(ce.isStorageAvailable?(mt=[],lo.splice(0),Ze.splice(0),Mt=0,mn=r,Vu=e,vr={responseGroupUuid:t.responseGroupUuid,surveyId:t.surveyId,userAgent:t.userAgent,sdkVersion:t.sdkVersion},Hu=t.maxDurationSeconds,Fg(),hn||(Yu=window.setInterval(Ng,500)),hn=!0):Ut=!0)},Pg=[$e.Drag,$e.Input,$e.MediaInteraction,$e.MouseInteraction,$e.MouseMove,$e.Scroll,$e.Selection,$e.TouchMove],_g=e=>e.type===it.Custom||e.type===it.IncrementalSnapshot&&Pg.includes(e.data.source),co=e=>e.some(_g),Ng=async()=>{if(!Tt())return void window.clearInterval(Yu);if($u(),!co(Ze))return;const e=Ze[0].timestamp;Date.now()-e>35e3&&(mn==null||mn())},$u=async()=>{if(mt.length||Ss)return;Ss=!0;const e=await zg();if(!e)return void(Ut=!0);lo.splice(0,e.length).forEach(t=>t(e.shift())),e.forEach(t=>mt.push(t)),Ss=!1},Fg=()=>{const e=ce.getItem("sprig.alwayson.info");if(e){_.info("Read stored session state",e);const t=JSON.parse(e);Ut=t.disabled,vr=t.metadata,mt=t.uploadUrls,Mt=t.currentIndex,Un=t.expirationTimestamp,t.pendingEventTimestamp&&(_.info(`Uploading with pending timestamp: ${t.pendingEventTimestamp}`),Bg(t.pendingEventTimestamp))}else Un=1e3*Hu+Date.now()},Bg=async e=>{const t=Date.now(),r=(await Q.getEventsBetween(e,t)).map(s=>JSON.parse(s.event));if(!co(r))return;Ku(r);const n=await Xu();n&&await Ju(n,r)},qu=async(e,t)=>{try{const r=await e();if(!r.ok)throw new Error(`Error ${t}`);return r}catch{Ut=!0}},Ju=async(e,t)=>{if(!Tt()||!e)return;const r=await(async n=>{const s=new TextEncoder,i=new CompressionStream("gzip"),a=i.writable.getWriter(),o=s.encode(JSON.stringify(n));return a.write(o),a.close(),new Uint8Array(await new Response(i.readable).arrayBuffer())})(t);_.info("Uploading always-on events with presigned url"),await qu(()=>Ge(e,{body:r,method:"PUT"}),"uploading always-on with presigned url")},zg=async()=>{if(!Tt())return;const{surveyId:e,responseGroupUuid:t}=vr,r={responseGroupUuid:t,surveyId:e,index:Mt+1};_.info("Fetching always-on upload urls",r);const n=await qu(()=>Ge(`${Vu}/sdk/1/replayUrls`,{method:"POST",body:JSON.stringify(r),headers:Te(window.UserLeap)}),"fetching always-on signed urls");if(!n)return;const s=n.json.signedUrls;return _.info("Fetched more always-on upload urls",{body:r,urls:s}),s},Xu=async()=>{if(mt.length)return mt.shift();const e=new Promise(t=>{lo.push(t)});return $u(),e},Ku=e=>{var s,i,a;const t=e.length?e[e.length-1].timestamp:Date.now(),r=Mt,n=((i=(s=window.UserLeap)==null?void 0:s.config)==null?void 0:i.customMetadata)??((a=window.__cfg)==null?void 0:a.customMetadata);Mt++,e.push({timestamp:t,type:it.Custom,data:{tag:"Sprig_Meta",payload:{...vr,index:r,visitorId:window.UserLeap.visitorId??"",timestamp:t,customMetadata:n}}})},jg=(e,t)=>{Tt()&&!Gu&&(e||Ze.length)&&(e&&Ze.length&&(async()=>{const r=Ze.splice(0);if(!co(r))return;_.info("Capturing always-on event array to upload"),Ku(r);const n=await Xu();n&&await Ju(n,r)})(),Ze.push(t))};window.addEventListener("beforeunload",async()=>{Gu=!0,Tt()&&(_.info("Always On handle page unload"),(()=>{let e;Ze.length&&(e=Ze[0].timestamp);const t={disabled:Ut,metadata:vr,uploadUrls:mt,currentIndex:Mt,pendingEventTimestamp:e,expirationTimestamp:Un};_.info("Storing session state on unload",t),ce.setItem("sprig.alwayson.info",JSON.stringify(t))})())});const Zu=async(e,t)=>{const r=performance.now();let n;try{n=await e()}finally{const s=performance.now()-r;let i=yr[t];i||(i=Ve(t)),i.report(s/1e3)}return n},Qu=(e,t)=>{const r=performance.now();try{e()}finally{const n=performance.now()-r;let s=yr[t];s||(s=Ve(t)),s.report(n/1e3)}};let ed=5e3,xi=6e4,Ri=0,at,Li=!1,Oi=[];const Wg=e=>{var t,r,n,s;if((t=e.event)!=null&&t.includes("Sprig_Scroll")){const i=(s=(n=(r=JSON.parse(e.event))==null?void 0:r.data)==null?void 0:n.payload)==null?void 0:s.xPath;if(!i)return;de.scrollEventUuids[i]=e.uuid}Oi.push(e),Li||Vg()},Vg=()=>{Li=!0,setTimeout(async()=>{if(He()||Mn())return;const e=Oi;Oi=[],Li=!1,Qu(async()=>{await(async t=>{const r=t.map(n=>({...n,sessionId:n.sessionId??we}));if(r.length!==0)return ke(()=>Q.bulkAdd("events",r),"Error storing replay events")})(e)},"sdk_replay_add_event_batch_seconds")},500)},Gg=(e,t,r)=>{de.cleanupInterval=window.setInterval(()=>{const n=Date.now();Zu(()=>ke(async()=>{He()||await Promise.all([Q.deleteRowsBefore("events",n-1e3*e,s=>s.expiredAt===void 0||s.expiredAt<n-1e3*e),Q.deleteRowsBefore("chunkUploads",n-1e3*t),Q.deleteRowsBefore("pendingCaptures",n-1e3*r,s=>!s.canUpload)])},"Error deleting table rows"),"sdk_replay_cleanup_seconds"),_.debug("CleanupComplete")},3e4)},Hg=()=>{de.pendingCheckInterval=window.setInterval(async()=>{ke(async()=>{await Ai()},"Error initiating pending captures")},5e3)};let Is=!1;const Ai=async(e=!1)=>{if(!Is)try{Is=!0;const t=parseInt(at??"0");if(t===0)return;const r=await Q.getPendingCaptures({beforePresent:!0,isBeforeType:e}),n=await Q.openDB();await Promise.all(r.map(async s=>(await n.delete("pendingCaptures",s.uuid),nd(s.captureParams,s.canUpload)))),at=(t-r.length).toString(),ce.setItem("sprig.pendingCount",at)}finally{Is=!1}},Yg=async(e,t,r,n,s)=>{const i=Math.min(e+s,r),a=await Zu(()=>Q.getEventsBetween(e,i),"sdk_replay_get_events_between_seconds");if(!(a!=null&&a.length))return _.debug("NoEventsFound"),{validStartFound:n,events:[]};if(!n){_.debug("ValidStartSearch");let o=-1;return a==null||a.forEach((l,c)=>{if(!l.isValidStart)return;const u=l.timestamp<=t;(o<0||u)&&(o=c)}),o<0?(_.debug("ValidStartNotFound"),{validStartFound:n,events:[]}):{validStartFound:!0,events:a==null?void 0:a.slice(o)}}return{validStartFound:n,events:a}},td=e=>Promise.all(e.map(async t=>{const r=await(async n=>Uu.execute(async()=>{var a;_.info("UploadChunkStart",{chunkIndex:n.chunkIndex,surveyId:n.surveyId});const s=await Ge(n.uploadUrl,{body:n.data,method:"PUT"});_.http("UploadChunkEnd",{url:n.uploadUrl,method:"PUT",status_code:s.status,reason:s.statusText??"OK",chunkIndex:n.chunkIndex,surveyId:n.surveyId});const i=(a=s.headers)==null?void 0:a.get("ETag");if(!i)throw new Error(`Upload response did not include etag for upload ${n.uploadId}, part ${n.chunkIndex}`);return i}))(t);return await Q.updatePartial("chunkUploads",t.uuid,{data:null,etag:r,status:"UploadComplete"}),t.uploadId})),rd=async e=>{const t=await Q.getChunkUploadsByStatus({status:"UploadComplete",uploadId:e});if(!(t!=null&&t.length))return void _.info("NoChunksForUpload",{uploadId:e});const r=t.reduce((i,a)=>(i.find(o=>o.chunkIndex===a.chunkIndex)||i.push(a),i),[]);r.sort((i,a)=>i.chunkIndex-a.chunkIndex);const n=r.map(i=>({ETag:i.etag,PartNumber:i.chunkIndex})).filter(i=>i.ETag!==null),s=r[0];await Tu({apiUrl:s.apiUrl,surveyId:s.surveyId,uploadId:e,responseGroupUuid:s.responseGroupId,etags:n,headers:s.completeUploadHeaders,replayDuration:s.replayDuration}),await Q.deleteChunkUploads("UploadComplete",e)},$g=()=>{ke(async()=>{const e=await Q.getChunkUploadsByStatus({sessionId:we,status:"ReadyForUpload"});if(!(e!=null&&e.length))return;const t=await td(e);t!=null&&t.length&&await Promise.all(t.map(r=>{if(r)return rd(r)}))},"Error uploading unfinished chunks")},qg=async(e,t)=>{const r=t??Date.now();return(async(n,s)=>{const i=new TextEncoder;let a=null;const o=new CompressionStream("gzip"),l=o.writable.getWriter();let c=!1,u=!1,[d,p]=[0,0],f=[];for(let h=n-35e3;h<s;h+=xi){if({validStartFound:u,events:f}=await Yg(h,n,s,u,xi),!(f!=null&&f.length)){_.debug("NoEventsFound");continue}d===0&&(d=f[0].timestamp),p=f[f.length-1].timestamp;const k=f.map(v=>v.event);k.push(`{"timestamp":${s}}`);const m=`${c?",":"["}${k}`,g=i.encode(m);Qu(()=>{l.write(g)},"sdk_replay_compression_seconds"),c=!0}if(p-d<ed)return _.debug("ReplayTooShort"),null;const y=i.encode("]");return l.write(y),l.close(),a=new Uint8Array(await new Response(o.readable).arrayBuffer()),a})(r-e,r)},ul=async e=>{const{surveyId:t,responseGroupId:r,visitorId:n,apiUrl:s,completeUploadHeaders:i,replayParams:a,triggerTimestamp:o}=e,l=await qg(1e3*a.replayDurationSeconds,o);if(!(l!=null&&l.length))return void _.info("FileDataEmpty",{surveyId:t});const c=((d,p,f)=>{const y=d.length,h=1024*p*1024,k=Math.ceil(y/f),m=Math.max(h,k),g=[];let v=0;for(;v<y;)g.push(d.slice(v,v+m)),v+=m;return g})(l,a.minimumChunkSizeMb,a.signedUrls.length),u=await Promise.all(c.map(async(d,p)=>{const f=yt(),y={apiUrl:s,chunkIndex:p+1,completeUploadHeaders:i,etag:null,responseGroupId:r,status:"ReadyForUpload",surveyId:t,timestamp:o,totalChunks:c.length,data:d,uploadId:a.uploadId,uploadUrl:a.signedUrls[p].url,uuid:f,visitorId:n};return await(await Q.openDB()).add("chunkUploads",{...y,sessionId:y.sessionId??we}),y}));await(async(d,p)=>{await td(p),await Promise.all(d.map(f=>rd(f)))})([a.uploadId],u)},nd=async(e,t)=>{if(He())return _.debug("ReplayDisabled-ScheduleOrCapture");const{isHeatmap:r,isStandalone:n,replayParams:s,triggerTimestamp:i,responseGroupId:a}=e,o=async()=>{setTimeout(()=>z.removeListener(F.QuestionAnswered,o),0),ke(async()=>{s.replayDurationType==="before"?await ul(e):await Q.markPendingCaptureToCanUpload(a)},"Error in schedule/capture callback")};ke(async()=>{if(s.replayDurationType==="after"||s.replayDurationType==="beforeAndAfter")return!n&&!r&&z.on(F.QuestionAnswered,o),void await id(e);if(n||r||t)await ul(e),r&&Jg();else{const l=35+s.replayDurationSeconds,c=i-1e3*l,u=i;await Q.updateEventsExpiredAt(c,u,s.expirationTimeLimitMinutes),z.on(F.QuestionAnswered,o)}},"Error in scheduling/capturing replay")},Jg=async()=>{parseInt(at??"0")||ce.removeItem("sprig.isCapturingHeatmap"),ce.getItem("sprig.teardownAfterCapture")&&(Wu(),sd(),ce.removeItem("sprig.teardownAfterCapture"))},sd=async()=>He()?_.debug("ReplayDisabled-ClearData"):Promise.all([Q.deleteBySessionId("events",we),Q.deleteBySessionId("pendingCaptures",we)]).catch(e=>{wr("Error clearing user replay data",e)}),id=async e=>{if(He())return;const{isHeatmap:t,surveyId:r}=e,n=await Q.getPendingCaptures(),s=n==null?void 0:n.filter(l=>l.captureParams.surveyId===r);if(s!=null&&s.length)return void _.info("PendingCaptureExists",{surveyId:r});t&&(Ei(),ce.setItem("sprig.isCapturingHeatmap","true"),Ri=Date.now(),de.inactivityInterval||(de.inactivityInterval=window.setInterval(()=>{var l;l=Ri,Date.now()-l>=3e4&&ke(()=>Q.markPendingHeatmapsReady(),"Error in heatmap inactivity")},1e3)));const i={...e,replayParams:{...e.replayParams}};e.replayParams.replayDurationType==="beforeAndAfter"&&(i.replayParams.replayDurationSeconds*=2),i.replayParams.replayDurationType="before";const a=e.triggerTimestamp+1e3*e.replayParams.replayDurationSeconds;i.triggerTimestamp=a,at=(parseInt(at??"0")+1).toString(),ce.setItem("sprig.pendingCount",at),await(await Q.openDB()).add("pendingCaptures",{canUpload:!1,captureParams:i,sessionId:we,targetTimestamp:a,timestamp:Date.now(),uuid:yt()})},Xg=Object.freeze(Object.defineProperty({__proto__:null,RecordEvent:e=>{qe("Sprig_TrackEvent",e)},RecordPageView:e=>{e.description&&(e.description=ao(e.description)),qe("Sprig_PageView",e)},RecordSurveyShown:e=>{qe("Sprig_ShowSurvey",e)},_completeSessionReplay:async({surveyId:e,responseGroupUuid:t,eventDigest:r,headers:n})=>{if(!e||!t)return!1;const s=window.UserLeap._API_URL,i=await Tu({surveyId:e,responseGroupUuid:t,eventDigest:r,apiUrl:s,headers:n},!0);return!(i!=null&&i.error)},checkPendingHeatmapsUrl:()=>He()?_.debug("ReplayDisabled-PendingHeatmaps"):ke(async()=>{const e=(await Q.getPendingCaptures({isHeatmap:!0})).map(t=>({eventId:t.captureParams.eventId,uuid:t.uuid})).filter(({eventId:t})=>!pu(t)).map(({uuid:t})=>t);return _.info("PendingHeatmapsToComplete",{count:e.length}),e.length&&(await Q.markPendingHeatmapsReady(e),_.info("MarkedPendingHeatmapsReady")),e.length},"Error marking pending heatmaps ready"),clearUserReplayData:sd,disableRecording:wr,initializeReplay:async({maxReplayDurationSeconds:e,maxInflightRequests:t=2,replaySettings:r,teardownAfter:n=!1,apiUrl:s,alwaysOnConfig:i})=>{if(i&&Dg({apiUrl:s,config:i,triggerSnapshot:()=>{Ei()}}),at=ce.getItem("sprig.pendingCount"),de.isRecording)return;if(n&&ce.setItem("sprig.teardownAfterCapture","true"),He())return _.debug("ReplayDisabled");if(await(async()=>{var l;if(!ju())return!0;if((l=window.navigator.storage)!=null&&l.estimate)try{const{quota:c=0,usage:u=0}=await window.navigator.storage.estimate(),d=(c-u)/1024**3;return _.info("Storage",{availableGb:d}),d<.5}catch{return!0}return!1})())return _.debug("IDBNotSupported"),ki();try{const l=await Q.openDB();_.info("DBVersion",{version:l.version})}catch(l){return _.error("ReplayOpenErr",{name:l.name}),l.name==="VersionError"&&Q.deleteDB(),ki()}ke(async()=>{await Ai(!0)},"Error uploading ready pending captures");const a=Tt()?30:0,o=Math.max(e??0,a);if(!o)return _.debug("MissingDuration");_.debug("ReplayInit"),await ke(async()=>{var l;r!=null&&r.minDuration&&(ed=r.minDuration),r!=null&&r.batchDuration&&(xi=r.batchDuration),l=t,Uu.setLimit(l),$g(),Gg(o+35,1800,o+35),Hg();const c=window.UserLeap.replayLibraryURL??"https://cdn.sprig.com/dependencies/record.min.js",u=window.rrwebRecord;if(!u)return _.error("RecordScriptFailed");let d=!0,p=0;const f={checkoutEveryNms:3e4,sampling:{input:"last",scroll:250,media:800},...r,mutationQueueEnabled:r==null?void 0:r.enableMutationQueue};var y,h;de.stopRecording=u({emit:(k,m)=>{if(k.type===it.Custom&&(Ri=Date.now()),He()||Mn())return;if(m&&k.type===it.Meta)p=performance.now();else if(m&&p&&k.type===it.FullSnapshot){const v=performance.now()-p;bu("sdk_replay_snapshot_seconds",v/1e3)}const g=d||!!m&&k.type===it.Meta;d=!1,jg(g,k),Wg({uuid:yt(),event:JSON.stringify(k),isValidStart:g,timestamp:Date.now()})},...f}),de.isRecording=!!de.stopRecording,de.isRecording&&(((k,m)=>{window.addEventListener("message",g=>{var v;g.data.type===Sg&&(oo.push({source:g.source,origin:g.origin}),(v=g.source)==null||v.postMessage({type:Ig,settings:k,replayLibraryUrl:m},{targetOrigin:g.origin}))})})(f,c),z.on("survey.complete",k=>{var m;m={id:k,userAgent:window.navigator.userAgent},qe("Sprig_SubmitSurvey",m)}),y=qe,h=Mg,An||(Ee=y,pn=h,window.addEventListener("click",Fu,We),window.addEventListener("pointerdown",zu,We),window.addEventListener("mousedown",Bu,We),window.addEventListener("keydown",_u,We),window.addEventListener("scroll",Nu,We),An=!0,Og(),Ag()))},"Error initializing replay")},isReplayPaused:Mn,isReplayRecording:()=>de.isRecording,recordFullSnapshot:Ei,recordReplayPaused:()=>{qe("Sprig_ReplayPaused",{timestamp:Date.now()}),ce.setItem("sprig.isReplayPaused","true")},recordReplayResumed:()=>{ce.removeItem("sprig.isReplayPaused"),qe("Sprig_ReplayResumed",{timestamp:Date.now()})},scheduleCapture:id,scheduleOrCaptureReplay:nd,tryReplayAction:ke,uploadReadyPendingCaptures:Ai},Symbol.toStringTag,{value:"Module"}));(e=>{te.replay=e})(Xg),window.UpChunk={createUpload:Hd},window.rrwebRecord=Yt,exports.APP_ID="ul-app",exports.ConflictingWidgets=tu,exports.DEFAULT_BORDER_COLOR="#e6e6e6",exports.DEFAULT_WIDTH_PX=360,exports.DismissReason=Ae,exports.EMBED_MOBILE_MAX_WIDTH=1030,exports.ERROR_BORDER_COLOR="#bd282a",exports.SprigAPI=yi,exports.SprigEvent=F,exports.breadcrumbsLogger=_,exports.calculateFrameDimensions=hu,exports.eventEmitter=z,exports.groupCards=(e,t)=>{const r=[e[t]],n=e[t].groupId;return n?e.slice(t).reduce((s,i)=>(i.groupId===n&&s.push(i),s),[]):r},exports.isHTMLElement=Be,exports.isLongFormSurvey=e=>e==="longFormSurvey",exports.isiOS=e=>e["userleap-platform"]==="ios",exports.resetScrollPosition=e=>{const t=e.querySelector(".ul-card__container");t&&(t.scrollTop=0)},exports.setSurveyStyles=hr,exports.shouldDirectEmbed=eo,exports.sprig=hg,exports.sprigFetch=Ge,exports.v4=yt;