@sprig-technologies/sprig-bundled 1.1.5 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,31 +0,0 @@
1
- var Bo=Object.defineProperty,Wo=(e,t,n)=>t in e?Bo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ee=(e,t,n)=>(Wo(e,typeof t!="symbol"?t+"":t,n),n),zo=Object.create,ir=Object.defineProperty,Vo=Object.getOwnPropertyDescriptor,Go=Object.getOwnPropertyNames,jo=Object.getPrototypeOf,Ho=Object.prototype.hasOwnProperty,it=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ko=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Go(t))!Ho.call(e,i)&&i!==n&&ir(e,i,{get:()=>t[i],enumerable:!(r=Vo(t,i))||r.enumerable});return e},Zo=(e,t,n)=>(n=e!=null?zo(jo(e)):{},Ko(!e||!e.__esModule?ir(n,"default",{value:e,enumerable:!0}):n,e)),qo=it((e,t)=>{var n;typeof window<"u"?n=window:typeof global<"u"?n=global:typeof self<"u"?n=self:n={},t.exports=n}),$o=it((e,t)=>{t.exports=r;var n=Object.prototype.toString;function r(i){if(!i)return!1;var o=n.call(i);return o==="[object Function]"||typeof i=="function"&&o!=="[object RegExp]"||typeof window<"u"&&(i===window.setTimeout||i===window.alert||i===window.confirm||i===window.prompt)}}),Yo=it((e,t)=>{var n=function(i){return i.replace(/^\s+|\s+$/g,"")},r=function(i){return Object.prototype.toString.call(i)==="[object Array]"};t.exports=function(i){if(!i)return{};for(var o={},s=n(i).split(`
2
- `),l=0;l<s.length;l++){var a=s[l],d=a.indexOf(":"),c=n(a.slice(0,d)).toLowerCase(),h=n(a.slice(d+1));typeof o[c]>"u"?o[c]=h:r(o[c])?o[c].push(h):o[c]=[o[c],h]}return o}}),Jo=it((e,t)=>{t.exports=r;var n=Object.prototype.hasOwnProperty;function r(){for(var i={},o=0;o<arguments.length;o++){var s=arguments[o];for(var l in s)n.call(s,l)&&(i[l]=s[l])}return i}}),Qo=it((e,t)=>{var n=qo(),r=$o(),i=Yo(),o=Jo();t.exports=d,t.exports.default=d,d.XMLHttpRequest=n.XMLHttpRequest||g,d.XDomainRequest="withCredentials"in new d.XMLHttpRequest?d.XMLHttpRequest:n.XDomainRequest,s(["get","put","post","patch","head","delete"],function(u){d[u==="delete"?"del":u]=function(p,m,w){return m=a(p,m,w),m.method=u.toUpperCase(),c(m)}});function s(u,p){for(var m=0;m<u.length;m++)p(u[m])}function l(u){for(var p in u)if(u.hasOwnProperty(p))return!1;return!0}function a(u,p,m){var w=u;return r(p)?(m=p,typeof u=="string"&&(w={uri:u})):w=o(p,{uri:u}),w.callback=m,w}function d(u,p,m){return p=a(u,p,m),c(p)}function c(u){if(typeof u.callback>"u")throw new Error("callback argument missing");var p=!1,m=function(S,G,Q){p||(p=!0,u.callback(S,G,Q))};function w(){v.readyState===4&&setTimeout(f,0)}function I(){var S=void 0;if(v.response?S=v.response:S=v.responseText||h(v),Z)try{S=JSON.parse(S)}catch{}return S}function y(S){return clearTimeout(q),S instanceof Error||(S=new Error(""+(S||"Unknown XMLHttpRequest Error"))),S.statusCode=0,m(S,pe)}function f(){if(!M){var S;clearTimeout(q),u.useXDR&&v.status===void 0?S=200:S=v.status===1223?204:v.status;var G=pe,Q=null;return S!==0?(G={body:I(),statusCode:S,method:U,headers:{},url:x,rawRequest:v},v.getAllResponseHeaders&&(G.headers=i(v.getAllResponseHeaders()))):Q=new Error("Internal XMLHttpRequest Error"),m(Q,G,G.body)}}var v=u.xhr||null;v||(u.cors||u.useXDR?v=new d.XDomainRequest:v=new d.XMLHttpRequest);var E,M,x=v.url=u.uri||u.url,U=v.method=u.method||"GET",V=u.body||u.data,O=v.headers=u.headers||{},_=!!u.sync,Z=!1,q,pe={body:void 0,headers:{},statusCode:0,method:U,url:x,rawRequest:v};if("json"in u&&u.json!==!1&&(Z=!0,O.accept||O.Accept||(O.Accept="application/json"),U!=="GET"&&U!=="HEAD"&&(O["content-type"]||O["Content-Type"]||(O["Content-Type"]="application/json"),V=JSON.stringify(u.json===!0?V:u.json))),v.onreadystatechange=w,v.onload=f,v.onerror=y,v.onprogress=function(){},v.onabort=function(){M=!0},v.ontimeout=y,v.open(U,x,!_,u.username,u.password),_||(v.withCredentials=!!u.withCredentials),!_&&u.timeout>0&&(q=setTimeout(function(){if(!M){M=!0,v.abort("timeout");var S=new Error("XMLHttpRequest timeout");S.code="ETIMEDOUT",y(S)}},u.timeout)),v.setRequestHeader)for(E in O)O.hasOwnProperty(E)&&v.setRequestHeader(E,O[E]);else if(u.headers&&!l(u.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in u&&(v.responseType=u.responseType),"beforeSend"in u&&typeof u.beforeSend=="function"&&u.beforeSend(v),v.send(V||null),v}function h(u){try{if(u.responseType==="document")return u.responseXML;var p=u.responseXML&&u.responseXML.documentElement.nodeName==="parsererror";if(u.responseType===""&&!p)return u.responseXML}catch{}return null}function g(){}});function un(e,t,...n){if(!e)throw new TypeError(or(t,n))}function or(e,t){let n=0;return e.replace(/%[os]/gu,()=>sr(t[n++]))}function sr(e){return typeof e!="object"||e===null?String(e):Object.prototype.toString.call(e)}var Sc;function Xo(e){try{let t=e instanceof Error?e:new Error(sr(e));if(typeof dispatchEvent=="function"&&typeof ErrorEvent=="function")dispatchEvent(new ErrorEvent("error",{error:t,message:t.message}));else if(typeof process<"u"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)}catch{}}var fe=typeof window<"u"?window:typeof self<"u"?self:typeof global<"u"?global:typeof globalThis<"u"?globalThis:void 0,Cc,De=class{constructor(e,t){this.code=e,this.message=t}warn(...e){var t;try{let n=((t=new Error().stack)!==null&&t!==void 0?t:"").replace(/^(?:.+?\n){2}/gu,`
3
- `);console.warn(this.message,...e,n)}catch{}}},es=new De("W01","Unable to initialize event under dispatching."),ts=new De("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),ns=new De("W03","Assigning any truthy value to 'returnValue' property has no effect."),rs=new De("W04","Unable to preventDefault on non-cancelable events."),is=new De("W05","Unable to preventDefault inside passive event listener invocation."),os=new De("W06","An event listener wasn't added because it has been added already: %o, %o"),pn=new De("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),ar=new De("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),Le=class{static get NONE(){return lr}static get CAPTURING_PHASE(){return dr}static get AT_TARGET(){return cr}static get BUBBLING_PHASE(){return ur}constructor(e,t){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let n=t??{};hn.set(this,{type:String(e),bubbles:!!n.bubbles,cancelable:!!n.cancelable,composed:!!n.composed,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return K(this).type}get target(){return K(this).target}get srcElement(){return K(this).target}get currentTarget(){return K(this).currentTarget}composedPath(){let e=K(this).currentTarget;return e?[e]:[]}get NONE(){return lr}get CAPTURING_PHASE(){return dr}get AT_TARGET(){return cr}get BUBBLING_PHASE(){return ur}get eventPhase(){return K(this).dispatchFlag?2:0}stopPropagation(){K(this).stopPropagationFlag=!0}get cancelBubble(){return K(this).stopPropagationFlag}set cancelBubble(e){e?K(this).stopPropagationFlag=!0:ts.warn()}stopImmediatePropagation(){let e=K(this);e.stopPropagationFlag=e.stopImmediatePropagationFlag=!0}get bubbles(){return K(this).bubbles}get cancelable(){return K(this).cancelable}get returnValue(){return!K(this).canceledFlag}set returnValue(e){e?ns.warn():pr(K(this))}preventDefault(){pr(K(this))}get defaultPrevented(){return K(this).canceledFlag}get composed(){return K(this).composed}get isTrusted(){return!1}get timeStamp(){return K(this).timeStamp}initEvent(e,t=!1,n=!1){let r=K(this);if(r.dispatchFlag){es.warn();return}hn.set(this,{...r,type:String(e),bubbles:!!t,cancelable:!!n,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}},lr=0,dr=1,cr=2,ur=3,hn=new WeakMap;function K(e,t="this"){let n=hn.get(e);return un(n!=null,"'%s' must be an object that Event constructor created, but got another one: %o",t,e),n}function pr(e){if(e.inPassiveListenerFlag){is.warn();return}if(!e.cancelable){rs.warn();return}e.canceledFlag=!0}Object.defineProperty(Le,"NONE",{enumerable:!0}),Object.defineProperty(Le,"CAPTURING_PHASE",{enumerable:!0}),Object.defineProperty(Le,"AT_TARGET",{enumerable:!0}),Object.defineProperty(Le,"BUBBLING_PHASE",{enumerable:!0});var gn=Object.getOwnPropertyNames(Le.prototype);for(let e=0;e<gn.length;++e)gn[e]!=="constructor"&&Object.defineProperty(Le.prototype,gn[e],{enumerable:!0});typeof fe<"u"&&typeof fe.Event<"u"&&Object.setPrototypeOf(Le.prototype,fe.Event.prototype);function ss(e){return fe.DOMException?new fe.DOMException(e,"InvalidStateError"):($e==null&&($e=class Po extends Error{constructor(n){super(n),Error.captureStackTrace&&Error.captureStackTrace(this,Po)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties($e.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),gr($e),gr($e.prototype)),new $e(e))}var $e,hr={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};function gr(e){let t=Object.keys(hr);for(let n=0;n<t.length;++n){let r=t[n],i=hr[r];Object.defineProperty(e,r,{get(){return i},configurable:!0,enumerable:!0})}}var At=class extends Le{static wrap(e){return new(yr(e))(e)}constructor(e){super(e.type,{bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed}),e.cancelBubble&&super.stopPropagation(),e.defaultPrevented&&super.preventDefault(),mr.set(this,{original:e});let t=Object.keys(e);for(let n=0;n<t.length;++n){let r=t[n];r in this||Object.defineProperty(this,r,fr(e,r))}}stopPropagation(){super.stopPropagation();let{original:e}=xe(this);"stopPropagation"in e&&e.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(e){super.cancelBubble=e;let{original:t}=xe(this);"cancelBubble"in t&&(t.cancelBubble=e)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:e}=xe(this);"stopImmediatePropagation"in e&&e.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(e){super.returnValue=e;let{original:t}=xe(this);"returnValue"in t&&(t.returnValue=e)}preventDefault(){super.preventDefault();let{original:e}=xe(this);"preventDefault"in e&&e.preventDefault()}get timeStamp(){let{original:e}=xe(this);return"timeStamp"in e?e.timeStamp:super.timeStamp}},mr=new WeakMap;function xe(e){let t=mr.get(e);return un(t!=null,"'this' is expected an Event object, but got",e),t}var Et=new WeakMap;Et.set(Object.prototype,At),typeof fe<"u"&&typeof fe.Event<"u"&&Et.set(fe.Event.prototype,At);function yr(e){let t=Object.getPrototypeOf(e);if(t==null)return At;let n=Et.get(t);return n==null&&(n=as(yr(t),t),Et.set(t,n)),n}function as(e,t){class n extends e{}let r=Object.keys(t);for(let i=0;i<r.length;++i)Object.defineProperty(n.prototype,r[i],fr(t,r[i]));return n}function fr(e,t){let n=Object.getOwnPropertyDescriptor(e,t);return{get(){let r=xe(this).original,i=r[t];return typeof i=="function"?i.bind(r):i},set(r){let i=xe(this).original;i[t]=r},configurable:n.configurable,enumerable:n.enumerable}}function ls(e,t,n,r,i,o){return{callback:e,flags:(t?1:0)|(n?2:0)|(r?4:0),signal:i,signalListener:o}}function ds(e){e.flags|=8}function wr(e){return(e.flags&1)===1}function vr(e){return(e.flags&2)===2}function Ir(e){return(e.flags&4)===4}function cs(e){return(e.flags&8)===8}function us({callback:e},t,n){try{typeof e=="function"?e.call(t,n):typeof e.handleEvent=="function"&&e.handleEvent(n)}catch(r){Xo(r)}}function br({listeners:e},t,n){for(let r=0;r<e.length;++r)if(e[r].callback===t&&wr(e[r])===n)return r;return-1}function ps(e,t,n,r,i,o){let s;o&&(s=Sr.bind(null,e,t,n),o.addEventListener("abort",s));let l=ls(t,n,r,i,o,s);return e.cow?(e.cow=!1,e.listeners=[...e.listeners,l]):e.listeners.push(l),l}function Sr(e,t,n){let r=br(e,t,n);return r!==-1?Cr(e,r):!1}function Cr(e,t,n=!1){let r=e.listeners[t];return ds(r),r.signal&&r.signal.removeEventListener("abort",r.signalListener),e.cow&&!n?(e.cow=!1,e.listeners=e.listeners.filter((i,o)=>o!==t),!1):(e.listeners.splice(t,1),!0)}function hs(){return Object.create(null)}function gs(e,t){var n;return(n=e[t])!==null&&n!==void 0?n:e[t]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}var Lt=class{constructor(){kr.set(this,hs())}addEventListener(e,t,n){let r=mn(this),{callback:i,capture:o,once:s,passive:l,signal:a,type:d}=ms(e,t,n);if(i==null||a!=null&&a.aborted)return;let c=gs(r,d),h=br(c,i,o);if(h!==-1){fs(c.listeners[h],l,s,a);return}ps(c,i,o,l,s,a)}removeEventListener(e,t,n){let r=mn(this),{callback:i,capture:o,type:s}=ys(e,t,n),l=r[s];i!=null&&l&&Sr(l,i,o)}dispatchEvent(e){let t=mn(this)[String(e.type)];if(t==null)return!0;let n=e instanceof Le?e:At.wrap(e),r=K(n,"event");if(r.dispatchFlag)throw ss("This event has been in dispatching.");if(r.dispatchFlag=!0,r.target=r.currentTarget=this,!r.stopPropagationFlag){let{cow:i,listeners:o}=t;t.cow=!0;for(let s=0;s<o.length;++s){let l=o[s];if(!cs(l)&&(Ir(l)&&Cr(t,s,!i)&&(s-=1),r.inPassiveListenerFlag=vr(l),us(l,this,n),r.inPassiveListenerFlag=!1,r.stopImmediatePropagationFlag))break}i||(t.cow=!1)}return r.target=null,r.currentTarget=null,r.stopImmediatePropagationFlag=!1,r.stopPropagationFlag=!1,r.dispatchFlag=!1,!r.canceledFlag}},kr=new WeakMap;function mn(e,t="this"){let n=kr.get(e);return un(n!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",t,e),n}function ms(e,t,n){var r;return Ar(t),typeof n=="object"&&n!==null?{type:String(e),callback:t??void 0,capture:!!n.capture,passive:!!n.passive,once:!!n.once,signal:(r=n.signal)!==null&&r!==void 0?r:void 0}:{type:String(e),callback:t??void 0,capture:!!n,passive:!1,once:!1,signal:void 0}}function ys(e,t,n){return Ar(t),typeof n=="object"&&n!==null?{type:String(e),callback:t??void 0,capture:!!n.capture}:{type:String(e),callback:t??void 0,capture:!!n}}function Ar(e){if(!(typeof e=="function"||typeof e=="object"&&e!==null&&typeof e.handleEvent=="function")){if(e==null||typeof e=="object"){ar.warn(e);return}throw new TypeError(or(ar.message,[e]))}}function fs(e,t,n,r){os.warn(wr(e)?"capture":"bubble",e.callback),vr(e)!==t&&pn.warn("passive"),Ir(e)!==n&&pn.warn("once"),e.signal!==r&&pn.warn("signal")}var yn=Object.getOwnPropertyNames(Lt.prototype);for(let e=0;e<yn.length;++e)yn[e]!=="constructor"&&Object.defineProperty(Lt.prototype,yn[e],{enumerable:!0});typeof fe<"u"&&typeof fe.EventTarget<"u"&&Object.setPrototypeOf(Lt.prototype,fe.EventTarget.prototype);var ws=Zo(Qo()),Er=30720,Rt=512e3,Ut=256,fn=(e,{minChunkSize:t=Ut,maxChunkSize:n=Rt}={})=>e==null||typeof e=="number"&&e>=256&&e%256===0&&e>=t&&e<=n,wn=(e,{minChunkSize:t=Ut,maxChunkSize:n=Rt}={})=>new TypeError(`chunkSize ${e} must be a positive number in multiples of 256, between ${t} and ${n}`),vs=class{constructor(e,t={}){this.readableStream=e;var n,r,i;if(!fn(t.defaultChunkSize,t))throw wn(t.defaultChunkSize,t);this.defaultChunkSize=(n=t.defaultChunkSize)!=null?n:Er,this.minChunkSize=(r=t.minChunkSize)!=null?r:Ut,this.maxChunkSize=(i=t.maxChunkSize)!=null?i:Rt}get chunkSize(){var e;return(e=this._chunkSize)!=null?e:this.defaultChunkSize}set chunkSize(e){if(!fn(e,this))throw wn(e,this);this._chunkSize=e}get chunkByteSize(){return this.chunkSize*1024}async*[Symbol.asyncIterator](){let e,t=this.readableStream.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n){if(e){let o=e;e=void 0,yield o}break}let i=r instanceof Uint8Array?new Blob([r],{type:"application/octet-stream"}):r;for(e=e?new Blob([e,i]):i;e;)if(e.size===this.chunkByteSize){let o=e;e=void 0,yield o;break}else{if(e.size<this.chunkByteSize)break;{let o=e.slice(0,this.chunkByteSize);e=e.slice(this.chunkByteSize),yield o}}}}finally{if(e){let n=e;e=void 0,yield n}t.releaseLock();return}}},Is=[200,201,202,204,308],Lr=[408,502,503,504],Rr=(e,t)=>!!e&&Is.includes(e.statusCode),bs=(e,{retryCodes:t=Lr})=>!e||t.includes(e.statusCode),Ss=(e,t)=>t.attemptCount>=t.attempts||!(Rr(e)||bs(e,t)),Ur=class{static createUpload(e){return new Ur(e)}constructor(e){this.endpoint=e.endpoint,this.file=e.file,this.headers=e.headers||{},this.method=e.method||"PUT",this.attempts=e.attempts||5,this.delayBeforeAttempt=e.delayBeforeAttempt||1,this.retryCodes=e.retryCodes||Lr,this.dynamicChunkSize=e.dynamicChunkSize||!1,this.maxFileBytes=(e.maxFileSize||0)*1024,this.chunkCount=0,this.attemptCount=0,this.offline=!1,this._paused=!1,this.success=!1,this.nextChunkRangeStart=0,this.chunkedStreamIterable=new vs(this.file.stream(),{...e,defaultChunkSize:e.chunkSize}),this.chunkedStreamIterator=this.chunkedStreamIterable[Symbol.asyncIterator](),this.totalChunks=Math.ceil(this.file.size/this.chunkByteSize),this.eventTarget=new Lt,this.validateOptions(),this.getEndpoint().then(()=>this.sendChunks()),typeof window<"u"&&(window.addEventListener("online",()=>{!this.offline||(this.offline=!1,this.dispatch("online"),this.sendChunks())}),window.addEventListener("offline",()=>{this.offline=!0,this.dispatch("offline")}))}get maxChunkSize(){var e,t;return(t=(e=this.chunkedStreamIterable)==null?void 0:e.maxChunkSize)!=null?t:Rt}get minChunkSize(){var e,t;return(t=(e=this.chunkedStreamIterable)==null?void 0:e.minChunkSize)!=null?t:Ut}get chunkSize(){var e,t;return(t=(e=this.chunkedStreamIterable)==null?void 0:e.chunkSize)!=null?t:Er}set chunkSize(e){this.chunkedStreamIterable.chunkSize=e}get chunkByteSize(){return this.chunkedStreamIterable.chunkByteSize}get totalChunkSize(){return Math.ceil(this.file.size/this.chunkByteSize)}on(e,t){this.eventTarget.addEventListener(e,t)}once(e,t){this.eventTarget.addEventListener(e,t,{once:!0})}off(e,t){this.eventTarget.removeEventListener(e,t)}get paused(){return this._paused}abort(){var e;this.pause(),(e=this.currentXhr)==null||e.abort()}pause(){this._paused=!0}resume(){this._paused&&(this._paused=!1,this.sendChunks())}dispatch(e,t){let n=new CustomEvent(e,{detail:t});this.eventTarget.dispatchEvent(n)}validateOptions(){if(!this.endpoint||typeof this.endpoint!="function"&&typeof this.endpoint!="string")throw new TypeError("endpoint must be defined as a string or a function that returns a promise");if(!(this.file instanceof File))throw new TypeError("file must be a File object");if(this.headers&&typeof this.headers!="function"&&typeof this.headers!="object")throw new TypeError("headers must be null, an object, or a function that returns an object or a promise");if(!fn(this.chunkSize,{maxChunkSize:this.maxChunkSize,minChunkSize:this.minChunkSize}))throw wn(this.chunkSize,{maxChunkSize:this.maxChunkSize,minChunkSize:this.minChunkSize});if(this.maxChunkSize&&(typeof this.maxChunkSize!="number"||this.maxChunkSize<256||this.maxChunkSize%256!==0||this.maxChunkSize<this.chunkSize||this.maxChunkSize<this.minChunkSize))throw new TypeError(`maxChunkSize must be a positive number in multiples of 256, and larger than or equal to both ${this.minChunkSize} and ${this.chunkSize}`);if(this.minChunkSize&&(typeof this.minChunkSize!="number"||this.minChunkSize<256||this.minChunkSize%256!==0||this.minChunkSize>this.chunkSize||this.minChunkSize>this.maxChunkSize))throw new TypeError(`minChunkSize must be a positive number in multiples of 256, and smaller than ${this.chunkSize} and ${this.maxChunkSize}`);if(this.maxFileBytes>0&&this.maxFileBytes<this.file.size)throw new Error(`file size exceeds maximum (${this.file.size} > ${this.maxFileBytes})`);if(this.attempts&&(typeof this.attempts!="number"||this.attempts<=0))throw new TypeError("retries must be a positive number");if(this.delayBeforeAttempt&&(typeof this.delayBeforeAttempt!="number"||this.delayBeforeAttempt<0))throw new TypeError("delayBeforeAttempt must be a positive number")}getEndpoint(){return typeof this.endpoint=="string"?(this.endpointValue=this.endpoint,Promise.resolve(this.endpoint)):this.endpoint(this.file).then(e=>(this.endpointValue=e,this.endpointValue))}xhrPromise(e){let t=n=>{n.upload.onprogress=r=>{var i;let o=this.totalChunks-this.chunkCount,s=(this.file.size-this.nextChunkRangeStart)/this.file.size/o,l=this.nextChunkRangeStart/this.file.size,a=r.loaded/((i=r.total)!=null?i:this.chunkByteSize)*s;this.dispatch("progress",Math.min((l+a)*100,100))}};return new Promise((n,r)=>{this.currentXhr=(0,ws.default)({...e,beforeSend:t},(i,o)=>(this.currentXhr=void 0,i?r(i):n(o)))})}async sendChunk(e){let t=this.nextChunkRangeStart,n=t+e.size-1,r={...await(typeof this.headers=="function"?this.headers():this.headers),"Content-Type":this.file.type,"Content-Range":`bytes ${t}-${n}/${this.file.size}`};return this.dispatch("attempt",{chunkNumber:this.chunkCount,totalChunks:this.totalChunks,chunkSize:this.chunkSize}),this.xhrPromise({headers:r,url:this.endpointValue,method:this.method,body:e})}async sendChunkWithRetries(e){let t=async(s,l)=>{var a;let d=(new Date().getTime()-this.lastChunkStart.getTime())/1e3;if(this.dispatch("chunkSuccess",{chunk:this.chunkCount,chunkSize:this.chunkSize,attempts:this.attemptCount,timeInterval:d,response:s}),this.attemptCount=0,this.chunkCount=((a=this.chunkCount)!=null?a:0)+1,this.nextChunkRangeStart=this.nextChunkRangeStart+this.chunkByteSize,this.dynamicChunkSize){let c=this.chunkSize;d<10?c=Math.min(this.chunkSize*2,this.maxChunkSize):d>30&&(c=Math.max(this.chunkSize/2,this.minChunkSize)),this.chunkSize=Math.ceil(c/256)*256;let h=(this.file.size-this.nextChunkRangeStart)/this.chunkByteSize;this.totalChunks=Math.ceil(this.chunkCount+h)}return!0},n=async(s,l)=>(this.dispatch("error",{message:`Server responded with ${s.statusCode}. Stopping upload.`,chunk:this.chunkCount,attempts:this.attemptCount}),!1),r=async(s,l)=>(this.dispatch("attemptFailure",{message:`An error occured uploading chunk ${this.chunkCount}. ${this.attempts-this.attemptCount} retries left.`,chunkNumber:this.chunkCount,attemptsLeft:this.attempts-this.attemptCount}),new Promise(a=>{setTimeout(async()=>{if(this._paused||this.offline){this.pendingChunk=e,a(!1);return}let d=await this.sendChunkWithRetries(e);a(d)},this.delayBeforeAttempt*1e3)})),i;try{this.attemptCount=this.attemptCount+1,this.lastChunkStart=new Date,i=await this.sendChunk(e)}catch{}let o={retryCodes:this.retryCodes,attemptCount:this.attemptCount,attempts:this.attempts};return Rr(i)?t(i):Ss(i,o)?n(i):r()}async sendChunks(){if(this.pendingChunk&&!(this._paused||this.offline)){let e=this.pendingChunk;this.pendingChunk=void 0;let t=await this.sendChunkWithRetries(e);this.success&&t&&this.dispatch("success")}for(;!(this.success||this._paused||this.offline);){let{value:e,done:t}=await this.chunkedStreamIterator.next(),n=!e&&t;if(e&&(n=await this.sendChunkWithRetries(e)),this.success=!!t,this.success&&n&&this.dispatch("success"),!n)return}}},Cs=Ur.createUpload,$;(function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"})($||($={}));function ks(e){return e.nodeType===e.ELEMENT_NODE}function ot(e){var t=e?.host;return t?.shadowRoot===e}function st(e){return Object.prototype.toString.call(e)==="[object ShadowRoot]"}function As(e){return e.includes(" background-clip: text;")&&!e.includes(" -webkit-background-clip: text;")&&(e=e.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),e}function Es(e){var t=e.cssText;if(t.split('"').length<3)return t;var n=["@import","url(".concat(JSON.stringify(e.href),")")];return e.layerName===""?n.push("layer"):e.layerName&&n.push("layer(".concat(e.layerName,")")),e.supportsText&&n.push("supports(".concat(e.supportsText,")")),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}function Tt(e){try{var t=e.rules||e.cssRules;return t?As(Array.from(t).map(Tr).join("")):null}catch{return null}}function Tr(e){var t;if(Rs(e))try{t=Tt(e.styleSheet)||Es(e)}catch{}return Ls(t||e.cssText)}function Ls(e){if(e.includes(":")){var t=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return e.replace(t,"$1\\$2")}return e}function Rs(e){return"styleSheet"in e}var Dr=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(t){var n;if(!t)return-1;var r=(n=this.getMeta(t))===null||n===void 0?void 0:n.id;return r??-1},e.prototype.getNode=function(t){return this.idNodeMap.get(t)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(t){return this.nodeMetaMap.get(t)||null},e.prototype.removeNodeFromMap=function(t){var n=this,r=this.getId(t);this.idNodeMap.delete(r),t.childNodes&&t.childNodes.forEach(function(i){return n.removeNodeFromMap(i)})},e.prototype.has=function(t){return this.idNodeMap.has(t)},e.prototype.hasNode=function(t){return this.nodeMetaMap.has(t)},e.prototype.add=function(t,n){var r=n.id;this.idNodeMap.set(r,t),this.nodeMetaMap.set(t,n)},e.prototype.replace=function(t,n){var r=this.getNode(t);if(r){var i=this.nodeMetaMap.get(r);i&&this.nodeMetaMap.set(n,i)}this.idNodeMap.set(t,n)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function Us(){return new Dr}function vn(e){var t=e.element,n=e.maskInputOptions,r=e.tagName,i=e.type,o=e.value,s=e.maskInputFn,l=o||"",a=i&&ze(i);return(n[r.toLowerCase()]||a&&n[a])&&(s?l=s(l,t):l="*".repeat(l.length)),l}function ze(e){return e.toLowerCase()}var xr="__rrweb_original__";function Ts(e){var t=e.getContext("2d");if(!t)return!0;for(var n=50,r=0;r<e.width;r+=n)for(var i=0;i<e.height;i+=n){var o=t.getImageData,s=xr in o?o[xr]:o,l=new Uint32Array(s.call(t,r,i,Math.min(n,e.width-r),Math.min(n,e.height-i)).data.buffer);if(l.some(function(a){return a!==0}))return!1}return!0}function In(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?ze(t):null}var Ds=1,xs=new RegExp("[^a-z0-9-_:]"),at=-2;function Mr(){return Ds++}function Ms(e){if(e instanceof HTMLFormElement)return"form";var t=ze(e.tagName);return xs.test(t)?"div":t}function Os(e){var t="";return e.indexOf("//")>-1?t=e.split("/").slice(0,3).join("/"):t=e.split("/")[0],t=t.split("?")[0],t}var Ye,Or,_s=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Ns=/^(?:[a-z+]+:)?\/\//i,Fs=/^www\..*/i,Ps=/^(data:)([^,]*),(.*)/i;function Dt(e,t){return(e||"").replace(_s,function(n,r,i,o,s,l){var a=i||s||l,d=r||o||"";if(!a)return n;if(Ns.test(a)||Fs.test(a)||Ps.test(a))return"url(".concat(d).concat(a).concat(d,")");if(a[0]==="/")return"url(".concat(d).concat(Os(t)+a).concat(d,")");var c=t.split("/"),h=a.split("/");c.pop();for(var g=0,u=h;g<u.length;g++){var p=u[g];p!=="."&&(p===".."?c.pop():c.push(p))}return"url(".concat(d).concat(c.join("/")).concat(d,")")})}var Bs=/^[^ \t\n\r\u000c]+/,Ws=/^[, \t\n\r\u000c]+/;function zs(e,t){if(t.trim()==="")return t;var n=0;function r(d){var c,h=d.exec(t.substring(n));return h?(c=h[0],n+=c.length,c):""}for(var i=[];r(Ws),!(n>=t.length);){var o=r(Bs);if(o.slice(-1)===",")o=xt(e,o.substring(0,o.length-1)),i.push(o);else{var s="";o=xt(e,o);for(var l=!1;;){var a=t.charAt(n);if(a===""){i.push((o+s).trim());break}else if(l)a===")"&&(l=!1);else if(a===","){n+=1,i.push((o+s).trim());break}else a==="("&&(l=!0);s+=a,n+=1}}}return i.join(", ")}function xt(e,t){if(!t||t.trim()==="")return t;var n=e.createElement("a");return n.href=t,n.href}function Vs(e){return!!(e.tagName==="svg"||e.ownerSVGElement)}function bn(){var e=document.createElement("a");return e.href="",e.href}function _r(e,t,n,r){return r&&(n==="src"||n==="href"&&!(t==="use"&&r[0]==="#")||n==="xlink:href"&&r[0]!=="#"||n==="background"&&(t==="table"||t==="td"||t==="th")?xt(e,r):n==="srcset"?zs(e,r):n==="style"?Dt(r,bn()):t==="object"&&n==="data"?xt(e,r):r)}function Nr(e,t,n){return(e==="video"||e==="audio")&&t==="autoplay"}function Gs(e,t,n){try{if(typeof t=="string"){if(e.classList.contains(t))return!0}else for(var r=e.classList.length;r--;){var i=e.classList[r];if(t.test(i))return!0}if(n)return e.matches(n)}catch{}return!1}function Mt(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return n?Mt(e.parentNode,t,n):!1;for(var r=e.classList.length;r--;){var i=e.classList[r];if(t.test(i))return!0}return n?Mt(e.parentNode,t,n):!1}function Fr(e,t,n){try{var r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(r===null)return!1;if(typeof t=="string"){if(r.classList.contains(t)||r.closest(".".concat(t)))return!0}else if(Mt(r,t,!0))return!0;if(n&&(r.matches(n)||r.closest(n)))return!0}catch{}return!1}function js(e,t,n){var r=e.contentWindow;if(r){var i=!1,o;try{o=r.document.readyState}catch{return}if(o!=="complete"){var s=setTimeout(function(){i||(t(),i=!0)},n);e.addEventListener("load",function(){clearTimeout(s),i=!0,t()});return}var l="about:blank";if(r.location.href!==l||e.src===l||e.src==="")return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}}function Hs(e,t,n){var r=!1,i;try{i=e.sheet}catch{return}if(!i){var o=setTimeout(function(){r||(t(),r=!0)},n);e.addEventListener("load",function(){clearTimeout(o),r=!0,t()})}}function Ks(e,t){var n=t.doc,r=t.mirror,i=t.blockClass,o=t.blockSelector,s=t.maskTextClass,l=t.maskTextSelector,a=t.inlineStylesheet,d=t.maskInputOptions,c=d===void 0?{}:d,h=t.maskTextFn,g=t.maskInputFn,u=t.dataURLOptions,p=u===void 0?{}:u,m=t.inlineImages,w=t.recordCanvas,I=t.keepIframeSrcFn,y=t.newlyAddedElement,f=y===void 0?!1:y,v=Zs(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode!=="CSS1Compat"?{type:$.Document,childNodes:[],compatMode:e.compatMode}:{type:$.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:$.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:v};case e.ELEMENT_NODE:return $s(e,{doc:n,blockClass:i,blockSelector:o,inlineStylesheet:a,maskInputOptions:c,maskInputFn:g,dataURLOptions:p,inlineImages:m,recordCanvas:w,keepIframeSrcFn:I,newlyAddedElement:f,rootId:v});case e.TEXT_NODE:return qs(e,{maskTextClass:s,maskTextSelector:l,maskTextFn:h,rootId:v});case e.CDATA_SECTION_NODE:return{type:$.CDATA,textContent:"",rootId:v};case e.COMMENT_NODE:return{type:$.Comment,textContent:e.textContent||"",rootId:v};default:return!1}}function Zs(e,t){if(t.hasNode(e)){var n=t.getId(e);return n===1?void 0:n}}function qs(e,t){var n,r=t.maskTextClass,i=t.maskTextSelector,o=t.maskTextFn,s=t.rootId,l=e.parentNode&&e.parentNode.tagName,a=e.textContent,d=l==="STYLE"?!0:void 0,c=l==="SCRIPT"?!0:void 0;if(d&&a){try{e.nextSibling||e.previousSibling||!((n=e.parentNode.sheet)===null||n===void 0)&&n.cssRules&&(a=Tt(e.parentNode.sheet))}catch(h){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(h),e)}a=Dt(a,bn())}return c&&(a="SCRIPT_PLACEHOLDER"),!d&&!c&&a&&Fr(e,r,i)&&(a=o?o(a):a.replace(/[\S]/g,"*")),{type:$.Text,textContent:a||"",isStyle:d,rootId:s}}function $s(e,t){for(var n=t.doc,r=t.blockClass,i=t.blockSelector,o=t.inlineStylesheet,s=t.maskInputOptions,l=s===void 0?{}:s,a=t.maskInputFn,d=t.dataURLOptions,c=d===void 0?{}:d,h=t.inlineImages,g=t.recordCanvas,u=t.keepIframeSrcFn,p=t.newlyAddedElement,m=p===void 0?!1:p,w=t.rootId,I=Gs(e,r,i),y=Ms(e),f={},v=e.attributes.length,E=0;E<v;E++){var M=e.attributes[E];Nr(y,M.name,M.value)||(f[M.name]=_r(n,y,ze(M.name),M.value))}if(y==="link"&&o){var x=Array.from(n.styleSheets).find(function(se){return se.href===e.href}),U=null;x&&(U=Tt(x)),U&&(delete f.rel,delete f.href,f._cssText=Dt(U,x.href))}if(y==="style"&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){var U=Tt(e.sheet);U&&(f._cssText=Dt(U,bn()))}if(y==="input"||y==="textarea"||y==="select"){var V=e.value,O=e.checked;if(f.type!=="radio"&&f.type!=="checkbox"&&f.type!=="submit"&&f.type!=="button"&&V){var _=In(e);f.value=vn({element:e,type:_,tagName:y,value:V,maskInputOptions:l,maskInputFn:a})}else O&&(f.checked=O)}if(y==="option"&&(e.selected&&!l.select?f.selected=!0:delete f.selected),y==="canvas"&&g){if(e.__context==="2d")Ts(e)||(f.rr_dataURL=e.toDataURL(c.type,c.quality));else if(!("__context"in e)){var Z=e.toDataURL(c.type,c.quality),q=document.createElement("canvas");q.width=e.width,q.height=e.height;var pe=q.toDataURL(c.type,c.quality);Z!==pe&&(f.rr_dataURL=Z)}}if(y==="img"&&h){Ye||(Ye=n.createElement("canvas"),Or=Ye.getContext("2d"));var S=e,G=S.crossOrigin;S.crossOrigin="anonymous";var Q=function(){S.removeEventListener("load",Q);try{Ye.width=S.naturalWidth,Ye.height=S.naturalHeight,Or.drawImage(S,0,0),f.rr_dataURL=Ye.toDataURL(c.type,c.quality)}catch(se){console.warn("Cannot inline img src=".concat(S.currentSrc,"! Error: ").concat(se))}G?f.crossOrigin=G:S.removeAttribute("crossorigin")};S.complete&&S.naturalWidth!==0?Q():S.addEventListener("load",Q)}if((y==="audio"||y==="video")&&(f.rr_mediaState=e.paused?"paused":"played",f.rr_mediaCurrentTime=e.currentTime),m||(e.scrollLeft&&(f.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(f.rr_scrollTop=e.scrollTop)),I){var ie=e.getBoundingClientRect(),oe=ie.width,re=ie.height;f={class:f.class,rr_width:"".concat(oe,"px"),rr_height:"".concat(re,"px")}}return y==="iframe"&&!u(f.src)&&(e.contentDocument||(f.rr_src=f.src),delete f.src),{type:$.Element,tagName:y,attributes:f,childNodes:[],isSVG:Vs(e)||void 0,needBlock:I,rootId:w}}function P(e){return e==null?"":e.toLowerCase()}function Ys(e,t){return!!(t.comment&&e.type===$.Comment||e.type===$.Element&&(t.script&&(e.tagName==="script"||e.tagName==="link"&&(e.attributes.rel==="preload"||e.attributes.rel==="modulepreload")&&e.attributes.as==="script"||e.tagName==="link"&&e.attributes.rel==="prefetch"&&typeof e.attributes.href=="string"&&e.attributes.href.endsWith(".js"))||t.headFavicon&&(e.tagName==="link"&&e.attributes.rel==="shortcut icon"||e.tagName==="meta"&&(P(e.attributes.name).match(/^msapplication-tile(image|color)$/)||P(e.attributes.name)==="application-name"||P(e.attributes.rel)==="icon"||P(e.attributes.rel)==="apple-touch-icon"||P(e.attributes.rel)==="shortcut icon"))||e.tagName==="meta"&&(t.headMetaDescKeywords&&P(e.attributes.name).match(/^description|keywords$/)||t.headMetaSocial&&(P(e.attributes.property).match(/^(og|twitter|fb):/)||P(e.attributes.name).match(/^(og|twitter):/)||P(e.attributes.name)==="pinterest")||t.headMetaRobots&&(P(e.attributes.name)==="robots"||P(e.attributes.name)==="googlebot"||P(e.attributes.name)==="bingbot")||t.headMetaHttpEquiv&&e.attributes["http-equiv"]!==void 0||t.headMetaAuthorship&&(P(e.attributes.name)==="author"||P(e.attributes.name)==="generator"||P(e.attributes.name)==="framework"||P(e.attributes.name)==="publisher"||P(e.attributes.name)==="progid"||P(e.attributes.property).match(/^article:/)||P(e.attributes.property).match(/^product:/))||t.headMetaVerification&&(P(e.attributes.name)==="google-site-verification"||P(e.attributes.name)==="yandex-verification"||P(e.attributes.name)==="csrf-token"||P(e.attributes.name)==="p:domain_verify"||P(e.attributes.name)==="verify-v1"||P(e.attributes.name)==="verification"||P(e.attributes.name)==="shopify-checkout-api-token"))))}function Je(e,t){var n=t.doc,r=t.mirror,i=t.blockClass,o=t.blockSelector,s=t.maskTextClass,l=t.maskTextSelector,a=t.skipChild,d=a===void 0?!1:a,c=t.inlineStylesheet,h=c===void 0?!0:c,g=t.maskInputOptions,u=g===void 0?{}:g,p=t.maskTextFn,m=t.maskInputFn,w=t.slimDOMOptions,I=t.dataURLOptions,y=I===void 0?{}:I,f=t.inlineImages,v=f===void 0?!1:f,E=t.recordCanvas,M=E===void 0?!1:E,x=t.onSerialize,U=t.onIframeLoad,V=t.iframeLoadTimeout,O=V===void 0?5e3:V,_=t.onStylesheetLoad,Z=t.stylesheetLoadTimeout,q=Z===void 0?5e3:Z,pe=t.keepIframeSrcFn,S=pe===void 0?function(){return!1}:pe,G=t.newlyAddedElement,Q=G===void 0?!1:G,ie=t.preserveWhiteSpace,oe=ie===void 0?!0:ie,re=Ks(e,{doc:n,mirror:r,blockClass:i,blockSelector:o,maskTextClass:s,maskTextSelector:l,inlineStylesheet:h,maskInputOptions:u,maskTextFn:p,maskInputFn:m,dataURLOptions:y,inlineImages:v,recordCanvas:M,keepIframeSrcFn:S,newlyAddedElement:Q});if(!re)return console.warn(e,"not serialized"),null;var se;r.hasNode(e)?se=r.getId(e):Ys(re,w)||!oe&&re.type===$.Text&&!re.isStyle&&!re.textContent.replace(/^\s+|\s+$/gm,"").length?se=at:se=Mr();var F=Object.assign(re,{id:se});if(r.add(e,F),se===at)return null;x&&x(e);var N=!d;if(F.type===$.Element){N=N&&!F.needBlock,delete F.needBlock;var Ee=e.shadowRoot;Ee&&st(Ee)&&(F.isShadowHost=!0)}if((F.type===$.Document||F.type===$.Element)&&N){w.headWhitespace&&F.type===$.Element&&F.tagName==="head"&&(oe=!1);for(var qe={doc:n,mirror:r,blockClass:i,blockSelector:o,maskTextClass:s,maskTextSelector:l,skipChild:d,inlineStylesheet:h,maskInputOptions:u,maskTextFn:p,maskInputFn:m,slimDOMOptions:w,dataURLOptions:y,inlineImages:v,recordCanvas:M,preserveWhiteSpace:oe,onSerialize:x,onIframeLoad:U,iframeLoadTimeout:O,onStylesheetLoad:_,stylesheetLoadTimeout:q,keepIframeSrcFn:S},he=0,be=Array.from(e.childNodes);he<be.length;he++){var Be=be[he],ye=Je(Be,qe);ye&&F.childNodes.push(ye)}if(ks(e)&&e.shadowRoot)for(var C=0,ce=Array.from(e.shadowRoot.childNodes);C<ce.length;C++){var Be=ce[C],ye=Je(Be,qe);ye&&(st(e.shadowRoot)&&(ye.isShadow=!0),F.childNodes.push(ye))}}return e.parentNode&&ot(e.parentNode)&&st(e.parentNode)&&(F.isShadow=!0),F.type===$.Element&&F.tagName==="iframe"&&js(e,function(){var D=e.contentDocument;if(D&&U){var X=Je(D,{doc:D,mirror:r,blockClass:i,blockSelector:o,maskTextClass:s,maskTextSelector:l,skipChild:!1,inlineStylesheet:h,maskInputOptions:u,maskTextFn:p,maskInputFn:m,slimDOMOptions:w,dataURLOptions:y,inlineImages:v,recordCanvas:M,preserveWhiteSpace:oe,onSerialize:x,onIframeLoad:U,iframeLoadTimeout:O,onStylesheetLoad:_,stylesheetLoadTimeout:q,keepIframeSrcFn:S});X&&U(e,X)}},O),F.type===$.Element&&F.tagName==="link"&&F.attributes.rel==="stylesheet"&&Hs(e,function(){if(_){var D=Je(e,{doc:n,mirror:r,blockClass:i,blockSelector:o,maskTextClass:s,maskTextSelector:l,skipChild:!1,inlineStylesheet:h,maskInputOptions:u,maskTextFn:p,maskInputFn:m,slimDOMOptions:w,dataURLOptions:y,inlineImages:v,recordCanvas:M,preserveWhiteSpace:oe,onSerialize:x,onIframeLoad:U,iframeLoadTimeout:O,onStylesheetLoad:_,stylesheetLoadTimeout:q,keepIframeSrcFn:S});D&&_(e,D)}},q),F}function Js(e,t){var n=t||{},r=n.mirror,i=r===void 0?new Dr:r,o=n.blockClass,s=o===void 0?"rr-block":o,l=n.blockSelector,a=l===void 0?null:l,d=n.maskTextClass,c=d===void 0?"rr-mask":d,h=n.maskTextSelector,g=h===void 0?null:h,u=n.inlineStylesheet,p=u===void 0?!0:u,m=n.inlineImages,w=m===void 0?!1:m,I=n.recordCanvas,y=I===void 0?!1:I,f=n.maskAllInputs,v=f===void 0?!1:f,E=n.maskTextFn,M=n.maskInputFn,x=n.slimDOM,U=x===void 0?!1:x,V=n.dataURLOptions,O=n.preserveWhiteSpace,_=n.onSerialize,Z=n.onIframeLoad,q=n.iframeLoadTimeout,pe=n.onStylesheetLoad,S=n.stylesheetLoadTimeout,G=n.keepIframeSrcFn,Q=G===void 0?function(){return!1}:G,ie=v===!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}:v===!1?{password:!0}:v,oe=U===!0||U==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:U==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:U===!1?{}:U;return Je(e,{doc:e,mirror:i,blockClass:s,blockSelector:a,maskTextClass:c,maskTextSelector:g,skipChild:!1,inlineStylesheet:p,maskInputOptions:ie,maskTextFn:E,maskInputFn:M,slimDOMOptions:oe,dataURLOptions:V,inlineImages:w,recordCanvas:y,preserveWhiteSpace:O,onSerialize:_,onIframeLoad:Z,iframeLoadTimeout:q,onStylesheetLoad:pe,stylesheetLoadTimeout:S,keepIframeSrcFn:Q,newlyAddedElement:!1})}function ae(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const Qe=`Please stop import mirror directly. Instead of that,\r
4
- now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
5
- or you can use record.mirror to access the mirror instance during recording.`;let Pr={map:{},getId(){return console.error(Qe),-1},getNode(){return console.error(Qe),null},removeNodeFromMap(){console.error(Qe)},has(){return console.error(Qe),!1},reset(){console.error(Qe)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(Pr=new Proxy(Pr,{get(e,t,n){return t==="map"&&console.error(Qe),Reflect.get(e,t,n)}}));function lt(e,t,n={}){let r=null,i=0;return function(...o){const s=Date.now();!i&&n.leading===!1&&(i=s);const l=t-(s-i),a=this;l<=0||l>t?(r&&(clearTimeout(r),r=null),i=s,e.apply(a,o)):!r&&n.trailing!==!1&&(r=setTimeout(()=>{i=n.leading===!1?0:Date.now(),r=null,e.apply(a,o)},l))}}function Ot(e,t,n,r,i=window){const o=i.Object.getOwnPropertyDescriptor(e,t);return i.Object.defineProperty(e,t,r?n:{set(s){setTimeout(()=>{n.set.call(this,s)},0),o&&o.set&&o.set.call(this,s)}}),()=>Ot(e,t,o||{},!0)}function dt(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],i=n(r);return typeof i=="function"&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}let _t=Date.now;/[1-9][0-9]{12}/.test(Date.now().toString())||(_t=()=>new Date().getTime());function Br(e){var t,n,r,i,o,s;const l=e.document;return{left:l.scrollingElement?l.scrollingElement.scrollLeft:e.pageXOffset!==void 0?e.pageXOffset:l?.documentElement.scrollLeft||((n=(t=l?.body)===null||t===void 0?void 0:t.parentElement)===null||n===void 0?void 0:n.scrollLeft)||((r=l?.body)===null||r===void 0?void 0:r.scrollLeft)||0,top:l.scrollingElement?l.scrollingElement.scrollTop:e.pageYOffset!==void 0?e.pageYOffset:l?.documentElement.scrollTop||((o=(i=l?.body)===null||i===void 0?void 0:i.parentElement)===null||o===void 0?void 0:o.scrollTop)||((s=l?.body)===null||s===void 0?void 0:s.scrollTop)||0}}function Wr(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function zr(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function le(e,t,n,r){if(!e)return!1;const i=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!i)return!1;try{if(typeof t=="string"){if(i.classList.contains(t)||r&&i.closest("."+t)!==null)return!0}else if(Mt(i,t,r))return!0}catch{}return!!(n&&(i.matches(n)||r&&i.closest(n)!==null))}function Qs(e,t){return t.getId(e)!==-1}function Sn(e,t){return t.getId(e)===at}function Vr(e,t){if(ot(e))return!1;const n=t.getId(e);return t.has(n)?e.parentNode&&e.parentNode.nodeType===e.DOCUMENT_NODE?!1:e.parentNode?Vr(e.parentNode,t):!0:!0}function Cn(e){return!!e.changedTouches}function Xs(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...t)=>{let n=t[0];if(!(0 in t))throw new TypeError("1 argument is required");do if(this===n)return!0;while(n=n&&n.parentNode);return!1})}function Gr(e,t){return!!(e.nodeName==="IFRAME"&&t.getMeta(e))}function jr(e,t){return!!(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function kn(e){return!!(e!=null&&e.shadowRoot)}class ea{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(t){var n;return(n=this.styleIDMap.get(t))!==null&&n!==void 0?n:-1}has(t){return this.styleIDMap.has(t)}add(t,n){if(this.has(t))return this.getId(t);let r;return n===void 0?r=this.id++:r=n,this.styleIDMap.set(t,r),this.idStyleMap.set(r,t),r}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 Hr(e){var t,n;let r=null;return((n=(t=e.getRootNode)===null||t===void 0?void 0:t.call(e))===null||n===void 0?void 0:n.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&e.getRootNode().host&&(r=e.getRootNode().host),r}function ta(e){let t=e,n;for(;n=Hr(t);)t=n;return t}function na(e){const t=e.ownerDocument;if(!t)return!1;const n=ta(e);return t.contains(n)}function Kr(e){const t=e.ownerDocument;return t?t.contains(e)||na(e):!1}var R=(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))(R||{}),T=(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))(T||{}),ue=(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))(ue||{}),Re=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Re||{}),Xe=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(Xe||{});function Zr(e){return"__ln"in e}class ra{constructor(){this.length=0,this.head=null,this.tail=null}get(t){if(t>=this.length)throw new Error("Position outside of list range");let n=this.head;for(let r=0;r<t;r++)n=n?.next||null;return n}addNode(t){const n={value:t,previous:null,next:null};if(t.__ln=n,t.previousSibling&&Zr(t.previousSibling)){const r=t.previousSibling.__ln.next;n.next=r,n.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=n,r&&(r.previous=n)}else if(t.nextSibling&&Zr(t.nextSibling)&&t.nextSibling.__ln.previous){const r=t.nextSibling.__ln.previous;n.previous=r,n.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=n,r&&(r.next=n)}else this.head&&(this.head.previous=n),n.next=this.head,this.head=n;n.next===null&&(this.tail=n),this.length++}removeNode(t){const n=t.__ln;this.head&&(n.previous?(n.previous.next=n.next,n.next?n.next.previous=n.previous:this.tail=n.previous):(this.head=n.next,this.head?this.head.previous=null:this.tail=null),t.__ln&&delete t.__ln,this.length--)}}const qr=(e,t)=>`${e}@${t}`;class ia{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=t=>{t.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const t=[],n=new Set,r=new ra,i=a=>{let d=a,c=at;for(;c===at;)d=d&&d.nextSibling,c=d&&this.mirror.getId(d);return c},o=a=>{if(!a.parentNode||!Kr(a))return;const d=ot(a.parentNode)?this.mirror.getId(Hr(a)):this.mirror.getId(a.parentNode),c=i(a);if(d===-1||c===-1)return r.addNode(a);const h=Je(a,{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:g=>{Gr(g,this.mirror)&&this.iframeManager.addIframe(g),jr(g,this.mirror)&&this.stylesheetManager.trackLinkElement(g),kn(a)&&this.shadowDomManager.addShadowRoot(a.shadowRoot,this.doc)},onIframeLoad:(g,u)=>{this.iframeManager.attachIframe(g,u),this.shadowDomManager.observeAttachShadow(g)},onStylesheetLoad:(g,u)=>{this.stylesheetManager.attachLinkElement(g,u)}});h&&(t.push({parentId:d,nextId:c,node:h}),n.add(h.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of this.movedSet)$r(this.removes,a,this.mirror)&&!this.movedSet.has(a.parentNode)||o(a);for(const a of this.addedSet)!Jr(this.droppedSet,a)&&!$r(this.removes,a,this.mirror)||Jr(this.movedSet,a)?o(a):this.droppedSet.add(a);let s=null;for(;r.length;){let a=null;if(s){const d=this.mirror.getId(s.value.parentNode),c=i(s.value);d!==-1&&c!==-1&&(a=s)}if(!a){let d=r.tail;for(;d;){const c=d;if(d=d.previous,c){const h=this.mirror.getId(c.value.parentNode);if(i(c.value)===-1)continue;if(h!==-1){a=c;break}else{const g=c.value;if(g.parentNode&&g.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const u=g.parentNode.host;if(this.mirror.getId(u)!==-1){a=c;break}}}}}}if(!a){for(;r.head;)r.removeNode(r.head.value);break}s=a.previous,r.removeNode(a.value),o(a.value)}const l={texts:this.texts.map(a=>({id:this.mirror.getId(a.node),value:a.value})).filter(a=>!n.has(a.id)).filter(a=>this.mirror.has(a.id)),attributes:this.attributes.map(a=>{const{attributes:d}=a;if(typeof d.style=="string"){const c=JSON.stringify(a.styleDiff),h=JSON.stringify(a._unchangedStyles);c.length<d.style.length&&(c+h).split("var(").length===d.style.split("var(").length&&(d.style=a.styleDiff)}return{id:this.mirror.getId(a.node),attributes:d}}).filter(a=>!n.has(a.id)).filter(a=>this.mirror.has(a.id)),removes:this.removes,adds:t};!l.texts.length&&!l.attributes.length&&!l.removes.length&&!l.adds.length||(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(l))},this.processMutation=t=>{if(Sn(t.target,this.mirror))return;let n;try{n=document.implementation.createHTMLDocument()}catch{n=this.doc}switch(t.type){case"characterData":{const r=t.target.textContent;!le(t.target,this.blockClass,this.blockSelector,!1)&&r!==t.oldValue&&this.texts.push({value:Fr(t.target,this.maskTextClass,this.maskTextSelector)&&r?this.maskTextFn?this.maskTextFn(r):r.replace(/[\S]/g,"*"):r,node:t.target});break}case"attributes":{const r=t.target;let i=t.attributeName,o=t.target.getAttribute(i);if(i==="value"){const l=In(r);o=vn({element:r,maskInputOptions:this.maskInputOptions,tagName:r.tagName,type:l,value:o,maskInputFn:this.maskInputFn})}if(le(t.target,this.blockClass,this.blockSelector,!1)||o===t.oldValue)return;let s=this.attributes.find(l=>l.node===t.target);if(r.tagName==="IFRAME"&&i==="src"&&!this.keepIframeSrcFn(o))if(!r.contentDocument)i="rr_src";else return;if(s||(s={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(s)),i==="type"&&r.tagName==="INPUT"&&(t.oldValue||"").toLowerCase()==="password"&&r.setAttribute("data-rr-is-password","true"),!Nr(r.tagName,i)&&(s.attributes[i]=_r(this.doc,ze(r.tagName),ze(i),o),i==="style")){const l=n.createElement("span");t.oldValue&&l.setAttribute("style",t.oldValue);for(const a of Array.from(r.style)){const d=r.style.getPropertyValue(a),c=r.style.getPropertyPriority(a);d!==l.style.getPropertyValue(a)||c!==l.style.getPropertyPriority(a)?c===""?s.styleDiff[a]=d:s.styleDiff[a]=[d,c]:s._unchangedStyles[a]=[d,c]}for(const a of Array.from(l.style))r.style.getPropertyValue(a)===""&&(s.styleDiff[a]=!1)}break}case"childList":{if(le(t.target,this.blockClass,this.blockSelector,!0))return;t.addedNodes.forEach(r=>this.genAdds(r,t.target)),t.removedNodes.forEach(r=>{const i=this.mirror.getId(r),o=ot(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);le(t.target,this.blockClass,this.blockSelector,!1)||Sn(r,this.mirror)||!Qs(r,this.mirror)||(this.addedSet.has(r)?(An(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&i===-1||Vr(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[qr(i,o)]?An(this.movedSet,r):this.removes.push({parentId:o,id:i,isShadow:ot(t.target)&&st(t.target)?!0:void 0})),this.mapRemoves.push(r))});break}}},this.genAdds=(t,n)=>{if(!this.processedNodeManager.inOtherBuffer(t,this)&&!(this.addedSet.has(t)||this.movedSet.has(t))){if(this.mirror.hasNode(t)){if(Sn(t,this.mirror))return;this.movedSet.add(t);let r=null;n&&this.mirror.hasNode(n)&&(r=this.mirror.getId(n)),r&&r!==-1&&(this.movedMap[qr(this.mirror.getId(t),r)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);le(t,this.blockClass,this.blockSelector,!1)||(t.childNodes.forEach(r=>this.genAdds(r)),kn(t)&&t.shadowRoot.childNodes.forEach(r=>{this.processedNodeManager.add(r,this),this.genAdds(r,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(n=>{this[n]=t[n]})}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 An(e,t){e.delete(t),t.childNodes.forEach(n=>An(e,n))}function $r(e,t,n){return e.length===0?!1:Yr(e,t,n)}function Yr(e,t,n){const{parentNode:r}=t;if(!r)return!1;const i=n.getId(r);return e.some(o=>o.id===i)?!0:Yr(e,r,n)}function Jr(e,t){return e.size===0?!1:Qr(e,t)}function Qr(e,t){const{parentNode:n}=t;return n?e.has(n)?!0:Qr(e,n):!1}let ct;function oa(e){ct=e}function sa(){ct=void 0}const L=e=>ct?(...t)=>{try{return e(...t)}catch(n){if(ct&&ct(n)===!0)return;throw n}}:e,Ve=[];function ut(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 Xr(e,t){var n,r;const i=new ia;Ve.push(i),i.init(e);let o=window.MutationObserver||window.__rrMutationObserver;const s=(r=(n=window?.Zone)===null||n===void 0?void 0:n.__symbol__)===null||r===void 0?void 0:r.call(n,"MutationObserver");s&&window[s]&&(o=window[s]);const l=new o(L(i.processMutations.bind(i)));return l.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),l}function aa({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(t.mousemove===!1)return()=>{};const i=typeof t.mousemove=="number"?t.mousemove:50,o=typeof t.mousemoveCallback=="number"?t.mousemoveCallback:500;let s=[],l;const a=lt(L(h=>{const g=Date.now()-l;e(s.map(u=>(u.timeOffset-=g,u)),h),s=[],l=null}),o),d=L(lt(L(h=>{const g=ut(h),{clientX:u,clientY:p}=Cn(h)?h.changedTouches[0]:h;l||(l=_t()),s.push({x:u,y:p,id:r.getId(g),timeOffset:_t()-l}),a(typeof DragEvent<"u"&&h instanceof DragEvent?T.Drag:h instanceof MouseEvent?T.MouseMove:T.TouchMove)}),i,{trailing:!1})),c=[ae("mousemove",d,n),ae("touchmove",d,n),ae("drag",d,n)];return L(()=>{c.forEach(h=>h())})}function la({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:o}){if(o.mouseInteraction===!1)return()=>{};const s=o.mouseInteraction===!0||o.mouseInteraction===void 0?{}:o.mouseInteraction,l=[];let a=null;const d=c=>h=>{const g=ut(h);if(le(g,r,i,!0))return;let u=null,p=c;if("pointerType"in h){switch(h.pointerType){case"mouse":u=Re.Mouse;break;case"touch":u=Re.Touch;break;case"pen":u=Re.Pen;break}u===Re.Touch?ue[c]===ue.MouseDown?p="TouchStart":ue[c]===ue.MouseUp&&(p="TouchEnd"):Re.Pen}else Cn(h)&&(u=Re.Touch);u!==null?(a=u,(p.startsWith("Touch")&&u===Re.Touch||p.startsWith("Mouse")&&u===Re.Mouse)&&(u=null)):ue[c]===ue.Click&&(u=a,a=null);const m=Cn(h)?h.changedTouches[0]:h;if(!m)return;const w=n.getId(g),{clientX:I,clientY:y}=m;L(e)(Object.assign({type:ue[p],id:w,x:I,y},u!==null&&{pointerType:u}))};return Object.keys(ue).filter(c=>Number.isNaN(Number(c))&&!c.endsWith("_Departed")&&s[c]!==!1).forEach(c=>{let h=ze(c);const g=d(c);if(window.PointerEvent)switch(ue[c]){case ue.MouseDown:case ue.MouseUp:h=h.replace("mouse","pointer");break;case ue.TouchStart:case ue.TouchEnd:return}l.push(ae(h,g,t))}),L(()=>{l.forEach(c=>c())})}function ei({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:o}){const s=L(lt(L(l=>{const a=ut(l);if(!a||le(a,r,i,!0))return;const d=n.getId(a);if(a===t&&t.defaultView){const c=Br(t.defaultView);e({id:d,x:c.left,y:c.top})}else e({id:d,x:a.scrollLeft,y:a.scrollTop})}),o.scroll||100));return ae("scroll",s,t)}function da({viewportResizeCb:e},{win:t}){let n=-1,r=-1;const i=L(lt(L(()=>{const o=Wr(),s=zr();(n!==o||r!==s)&&(e({width:Number(s),height:Number(o)}),n=o,r=s)}),200));return ae("resize",i,t)}function ti(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const ca=["INPUT","TEXTAREA","SELECT"],ni=new WeakMap;function ua({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,ignoreClass:o,ignoreSelector:s,maskInputOptions:l,maskInputFn:a,sampling:d,userTriggeredOnInput:c}){function h(I){let y=ut(I);const f=I.isTrusted,v=y&&y.tagName;if(y&&v==="OPTION"&&(y=y.parentElement),!y||!v||ca.indexOf(v)<0||le(y,r,i,!0)||y.classList.contains(o)||s&&y.matches(s))return;let E=y.value,M=!1;const x=In(y)||"";x==="radio"||x==="checkbox"?M=y.checked:(l[v.toLowerCase()]||l[x])&&(E=vn({element:y,maskInputOptions:l,tagName:v,type:x,value:E,maskInputFn:a})),g(y,L(ti)({text:E,isChecked:M,userTriggered:f},c));const U=y.name;x==="radio"&&U&&M&&t.querySelectorAll(`input[type="radio"][name="${U}"]`).forEach(V=>{V!==y&&g(V,L(ti)({text:V.value,isChecked:!M,userTriggered:!1},c))})}function g(I,y){const f=ni.get(I);if(!f||f.text!==y.text||f.isChecked!==y.isChecked){ni.set(I,y);const v=n.getId(I);L(e)(Object.assign(Object.assign({},y),{id:v}))}}const u=(d.input==="last"?["change"]:["input","change"]).map(I=>ae(I,L(h),t)),p=t.defaultView;if(!p)return()=>{u.forEach(I=>I())};const m=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),w=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&u.push(...w.map(I=>Ot(I[0],I[1],{set(){L(h)({target:this,isTrusted:!1})}},!1,p))),L(()=>{u.forEach(I=>I())})}function Nt(e){const t=[];function n(r,i){if(Ft("CSSGroupingRule")&&r.parentRule instanceof CSSGroupingRule||Ft("CSSMediaRule")&&r.parentRule instanceof CSSMediaRule||Ft("CSSSupportsRule")&&r.parentRule instanceof CSSSupportsRule||Ft("CSSConditionRule")&&r.parentRule instanceof CSSConditionRule){const o=Array.from(r.parentRule.cssRules).indexOf(r);i.unshift(o)}else if(r.parentStyleSheet){const o=Array.from(r.parentStyleSheet.cssRules).indexOf(r);i.unshift(o)}return i}return n(e,t)}function Me(e,t,n){let r,i;return e?(e.ownerNode?r=t.getId(e.ownerNode):i=n.getId(e),{styleId:i,id:r}):{}}function pa({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const i=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(i,{apply:L((c,h,g)=>{const[u,p]=g,{id:m,styleId:w}=Me(h,t,n.styleMirror);return(m&&m!==-1||w&&w!==-1)&&e({id:m,styleId:w,adds:[{rule:u,index:p}]}),c.apply(h,g)})});const o=r.CSSStyleSheet.prototype.deleteRule;r.CSSStyleSheet.prototype.deleteRule=new Proxy(o,{apply:L((c,h,g)=>{const[u]=g,{id:p,styleId:m}=Me(h,t,n.styleMirror);return(p&&p!==-1||m&&m!==-1)&&e({id:p,styleId:m,removes:[{index:u}]}),c.apply(h,g)})});let s;r.CSSStyleSheet.prototype.replace&&(s=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(s,{apply:L((c,h,g)=>{const[u]=g,{id:p,styleId:m}=Me(h,t,n.styleMirror);return(p&&p!==-1||m&&m!==-1)&&e({id:p,styleId:m,replace:u}),c.apply(h,g)})}));let l;r.CSSStyleSheet.prototype.replaceSync&&(l=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(l,{apply:L((c,h,g)=>{const[u]=g,{id:p,styleId:m}=Me(h,t,n.styleMirror);return(p&&p!==-1||m&&m!==-1)&&e({id:p,styleId:m,replaceSync:u}),c.apply(h,g)})}));const a={};Pt("CSSGroupingRule")?a.CSSGroupingRule=r.CSSGroupingRule:(Pt("CSSMediaRule")&&(a.CSSMediaRule=r.CSSMediaRule),Pt("CSSConditionRule")&&(a.CSSConditionRule=r.CSSConditionRule),Pt("CSSSupportsRule")&&(a.CSSSupportsRule=r.CSSSupportsRule));const d={};return Object.entries(a).forEach(([c,h])=>{d[c]={insertRule:h.prototype.insertRule,deleteRule:h.prototype.deleteRule},h.prototype.insertRule=new Proxy(d[c].insertRule,{apply:L((g,u,p)=>{const[m,w]=p,{id:I,styleId:y}=Me(u.parentStyleSheet,t,n.styleMirror);return(I&&I!==-1||y&&y!==-1)&&e({id:I,styleId:y,adds:[{rule:m,index:[...Nt(u),w||0]}]}),g.apply(u,p)})}),h.prototype.deleteRule=new Proxy(d[c].deleteRule,{apply:L((g,u,p)=>{const[m]=p,{id:w,styleId:I}=Me(u.parentStyleSheet,t,n.styleMirror);return(w&&w!==-1||I&&I!==-1)&&e({id:w,styleId:I,removes:[{index:[...Nt(u),m]}]}),g.apply(u,p)})})}),L(()=>{r.CSSStyleSheet.prototype.insertRule=i,r.CSSStyleSheet.prototype.deleteRule=o,s&&(r.CSSStyleSheet.prototype.replace=s),l&&(r.CSSStyleSheet.prototype.replaceSync=l),Object.entries(a).forEach(([c,h])=>{h.prototype.insertRule=d[c].insertRule,h.prototype.deleteRule=d[c].deleteRule})})}function ri({mirror:e,stylesheetManager:t},n){var r,i,o;let s=null;n.nodeName==="#document"?s=e.getId(n):s=e.getId(n.host);const l=n.nodeName==="#document"?(r=n.defaultView)===null||r===void 0?void 0:r.Document:(o=(i=n.ownerDocument)===null||i===void 0?void 0:i.defaultView)===null||o===void 0?void 0:o.ShadowRoot,a=Object.getOwnPropertyDescriptor(l?.prototype,"adoptedStyleSheets");return s===null||s===-1||!l||!a?()=>{}:(Object.defineProperty(n,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get(){var d;return(d=a.get)===null||d===void 0?void 0:d.call(this)},set(d){var c;const h=(c=a.set)===null||c===void 0?void 0:c.call(this,d);if(s!==null&&s!==-1)try{t.adoptStyleSheets(d,s)}catch{}return h}}),L(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})}))}function ha({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:i}){const o=i.CSSStyleDeclaration.prototype.setProperty;i.CSSStyleDeclaration.prototype.setProperty=new Proxy(o,{apply:L((l,a,d)=>{var c;const[h,g,u]=d;if(n.has(h))return o.apply(a,[h,g,u]);const{id:p,styleId:m}=Me((c=a.parentRule)===null||c===void 0?void 0:c.parentStyleSheet,t,r.styleMirror);return(p&&p!==-1||m&&m!==-1)&&e({id:p,styleId:m,set:{property:h,value:g,priority:u},index:Nt(a.parentRule)}),l.apply(a,d)})});const s=i.CSSStyleDeclaration.prototype.removeProperty;return i.CSSStyleDeclaration.prototype.removeProperty=new Proxy(s,{apply:L((l,a,d)=>{var c;const[h]=d;if(n.has(h))return s.apply(a,[h]);const{id:g,styleId:u}=Me((c=a.parentRule)===null||c===void 0?void 0:c.parentStyleSheet,t,r.styleMirror);return(g&&g!==-1||u&&u!==-1)&&e({id:g,styleId:u,remove:{property:h},index:Nt(a.parentRule)}),l.apply(a,d)})}),L(()=>{i.CSSStyleDeclaration.prototype.setProperty=o,i.CSSStyleDeclaration.prototype.removeProperty=s})}function ga({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:i,doc:o}){const s=L(a=>lt(L(d=>{const c=ut(d);if(!c||le(c,t,n,!0))return;const{currentTime:h,volume:g,muted:u,playbackRate:p}=c;e({type:a,id:r.getId(c),currentTime:h,volume:g,muted:u,playbackRate:p})}),i.media||500)),l=[ae("play",s(0),o),ae("pause",s(1),o),ae("seeked",s(2),o),ae("volumechange",s(3),o),ae("ratechange",s(4),o)];return L(()=>{l.forEach(a=>a())})}function ma({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],i=new WeakMap,o=n.FontFace;n.FontFace=function(l,a,d){const c=new o(l,a,d);return i.set(c,{family:l,buffer:typeof a!="string",descriptors:d,fontSource:typeof a=="string"?a:JSON.stringify(Array.from(new Uint8Array(a)))}),c};const s=dt(t.fonts,"add",function(l){return function(a){return setTimeout(L(()=>{const d=i.get(a);d&&(e(d),i.delete(a))}),0),l.apply(this,[a])}});return r.push(()=>{n.FontFace=o}),r.push(s),L(()=>{r.forEach(l=>l())})}function ya(e){const{doc:t,mirror:n,blockClass:r,blockSelector:i,selectionCb:o}=e;let s=!0;const l=L(()=>{const a=t.getSelection();if(!a||s&&a!=null&&a.isCollapsed)return;s=a.isCollapsed||!1;const d=[],c=a.rangeCount||0;for(let h=0;h<c;h++){const g=a.getRangeAt(h),{startContainer:u,startOffset:p,endContainer:m,endOffset:w}=g;le(u,r,i,!0)||le(m,r,i,!0)||d.push({start:n.getId(u),startOffset:p,end:n.getId(m),endOffset:w})}o({ranges:d})});return l(),ae("selectionchange",l)}function fa(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:i,scrollCb:o,viewportResizeCb:s,inputCb:l,mediaInteractionCb:a,styleSheetRuleCb:d,styleDeclarationCb:c,canvasMutationCb:h,fontCb:g,selectionCb:u}=e;e.mutationCb=(...p)=>{t.mutation&&t.mutation(...p),n(...p)},e.mousemoveCb=(...p)=>{t.mousemove&&t.mousemove(...p),r(...p)},e.mouseInteractionCb=(...p)=>{t.mouseInteraction&&t.mouseInteraction(...p),i(...p)},e.scrollCb=(...p)=>{t.scroll&&t.scroll(...p),o(...p)},e.viewportResizeCb=(...p)=>{t.viewportResize&&t.viewportResize(...p),s(...p)},e.inputCb=(...p)=>{t.input&&t.input(...p),l(...p)},e.mediaInteractionCb=(...p)=>{t.mediaInteaction&&t.mediaInteaction(...p),a(...p)},e.styleSheetRuleCb=(...p)=>{t.styleSheetRule&&t.styleSheetRule(...p),d(...p)},e.styleDeclarationCb=(...p)=>{t.styleDeclaration&&t.styleDeclaration(...p),c(...p)},e.canvasMutationCb=(...p)=>{t.canvasMutation&&t.canvasMutation(...p),h(...p)},e.fontCb=(...p)=>{t.font&&t.font(...p),g(...p)},e.selectionCb=(...p)=>{t.selection&&t.selection(...p),u(...p)}}function wa(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};fa(e,t);const r=Xr(e,e.doc),i=aa(e),o=la(e),s=ei(e),l=da(e,{win:n}),a=ua(e),d=ga(e),c=pa(e,{win:n}),h=ri(e,e.doc),g=ha(e,{win:n}),u=e.collectFonts?ma(e):()=>{},p=ya(e),m=[];for(const w of e.plugins)m.push(w.observer(w.callback,n,w.options));return L(()=>{Ve.forEach(w=>w.reset()),r.disconnect(),i(),o(),s(),l(),a(),d(),c(),h(),g(),u(),p(),m.forEach(w=>w())})}function Ft(e){return typeof window[e]<"u"}function Pt(e){return!!(typeof window[e]<"u"&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}class ii{constructor(t){this.generateIdFn=t,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(t,n,r,i){const o=r||this.getIdToRemoteIdMap(t),s=i||this.getRemoteIdToIdMap(t);let l=o.get(n);return l||(l=this.generateIdFn(),o.set(n,l),s.set(l,n)),l}getIds(t,n){const r=this.getIdToRemoteIdMap(t),i=this.getRemoteIdToIdMap(t);return n.map(o=>this.getId(t,o,r,i))}getRemoteId(t,n,r){const i=r||this.getRemoteIdToIdMap(t);return typeof n!="number"?n:i.get(n)||-1}getRemoteIds(t,n){const r=this.getRemoteIdToIdMap(t);return n.map(i=>this.getRemoteId(t,i,r))}reset(t){if(!t){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let n=this.iframeIdToRemoteIdMap.get(t);return n||(n=new Map,this.iframeIdToRemoteIdMap.set(t,n)),n}getRemoteIdToIdMap(t){let n=this.iframeRemoteIdToIdMap.get(t);return n||(n=new Map,this.iframeRemoteIdToIdMap.set(t,n)),n}}class va{constructor(t){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new ii(Mr),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new ii(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,n){var r;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:n}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),(r=this.loadListener)===null||r===void 0||r.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 n=t;if(n.data.type!=="rrweb"||n.origin!==n.data.origin||!t.source)return;const r=this.crossOriginIframeMap.get(t.source);if(!r)return;const i=this.transformCrossOriginEvent(r,n.data.event);i&&this.wrappedEmit(i,n.data.isCheckout)}transformCrossOriginEvent(t,n){var r;switch(n.type){case R.FullSnapshot:{this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(n.data.node,t);const i=n.data.node.id;return this.crossOriginIframeRootIdMap.set(t,i),this.patchRootIdOnNode(n.data.node,i),{timestamp:n.timestamp,type:R.IncrementalSnapshot,data:{source:T.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:n.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case R.Meta:case R.Load:case R.DomContentLoaded:return!1;case R.Plugin:return n;case R.Custom:return this.replaceIds(n.data.payload,t,["id","parentId","previousId","nextId"]),n;case R.IncrementalSnapshot:switch(n.data.source){case T.Mutation:return n.data.adds.forEach(i=>{this.replaceIds(i,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(i.node,t);const o=this.crossOriginIframeRootIdMap.get(t);o&&this.patchRootIdOnNode(i.node,o)}),n.data.removes.forEach(i=>{this.replaceIds(i,t,["parentId","id"])}),n.data.attributes.forEach(i=>{this.replaceIds(i,t,["id"])}),n.data.texts.forEach(i=>{this.replaceIds(i,t,["id"])}),n;case T.Drag:case T.TouchMove:case T.MouseMove:return n.data.positions.forEach(i=>{this.replaceIds(i,t,["id"])}),n;case T.ViewportResize:return!1;case T.MediaInteraction:case T.MouseInteraction:case T.Scroll:case T.CanvasMutation:case T.Input:return this.replaceIds(n.data,t,["id"]),n;case T.StyleSheetRule:case T.StyleDeclaration:return this.replaceIds(n.data,t,["id"]),this.replaceStyleIds(n.data,t,["styleId"]),n;case T.Font:return n;case T.Selection:return n.data.ranges.forEach(i=>{this.replaceIds(i,t,["start","end"])}),n;case T.AdoptedStyleSheet:return this.replaceIds(n.data,t,["id"]),this.replaceStyleIds(n.data,t,["styleIds"]),(r=n.data.styles)===null||r===void 0||r.forEach(i=>{this.replaceStyleIds(i,t,["styleId"])}),n}}}replace(t,n,r,i){for(const o of i)!Array.isArray(n[o])&&typeof n[o]!="number"||(Array.isArray(n[o])?n[o]=t.getIds(r,n[o]):n[o]=t.getId(r,n[o]));return n}replaceIds(t,n,r){return this.replace(this.crossOriginIframeMirror,t,n,r)}replaceStyleIds(t,n,r){return this.replace(this.crossOriginIframeStyleMirror,t,n,r)}replaceIdOnNode(t,n){this.replaceIds(t,n,["id","rootId"]),"childNodes"in t&&t.childNodes.forEach(r=>{this.replaceIdOnNode(r,n)})}patchRootIdOnNode(t,n){t.type!==$.Document&&!t.rootId&&(t.rootId=n),"childNodes"in t&&t.childNodes.forEach(r=>{this.patchRootIdOnNode(r,n)})}}class Ia{constructor(t){this.shadowDoms=new WeakSet,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,n){if(!st(t)||this.shadowDoms.has(t))return;this.shadowDoms.add(t);const r=Xr(Object.assign(Object.assign({},this.bypassOptions),{doc:n,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),t);this.restoreHandlers.push(()=>r.disconnect()),this.restoreHandlers.push(ei(Object.assign(Object.assign({},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(t.host)),this.restoreHandlers.push(ri({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t))},0)}observeAttachShadow(t){!t.contentWindow||!t.contentDocument||this.patchAttachShadow(t.contentWindow.Element,t.contentDocument)}patchAttachShadow(t,n){const r=this;this.restoreHandlers.push(dt(t.prototype,"attachShadow",function(i){return function(o){const s=i.call(this,o);return this.shadowRoot&&Kr(this)&&r.addShadowRoot(this.shadowRoot,n),s}}))}reset(){this.restoreHandlers.forEach(t=>{try{t()}catch{}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}/*! *****************************************************************************
6
- Copyright (c) Microsoft Corporation.
7
-
8
- Permission to use, copy, modify, and/or distribute this software for any
9
- purpose with or without fee is hereby granted.
10
-
11
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
- PERFORMANCE OF THIS SOFTWARE.
18
- ***************************************************************************** */function ba(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Sa(e,t,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function l(c){try{d(r.next(c))}catch(h){s(h)}}function a(c){try{d(r.throw(c))}catch(h){s(h)}}function d(c){c.done?o(c.value):i(c.value).then(l,a)}d((r=r.apply(e,[])).next())})}for(var et="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ca=typeof Uint8Array>"u"?[]:new Uint8Array(256),Bt=0;Bt<et.length;Bt++)Ca[et.charCodeAt(Bt)]=Bt;var ka=function(e){var t=new Uint8Array(e),n,r=t.length,i="";for(n=0;n<r;n+=3)i+=et[t[n]>>2],i+=et[(t[n]&3)<<4|t[n+1]>>4],i+=et[(t[n+1]&15)<<2|t[n+2]>>6],i+=et[t[n+2]&63];return r%3===2?i=i.substring(0,i.length-1)+"=":r%3===1&&(i=i.substring(0,i.length-2)+"=="),i};const oi=new Map;function Aa(e,t){let n=oi.get(e);return n||(n=new Map,oi.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}const si=(e,t,n)=>{if(!e||!(li(e,t)||typeof e=="object"))return;const r=e.constructor.name,i=Aa(n,r);let o=i.indexOf(e);return o===-1&&(o=i.length,i.push(e)),o};function Wt(e,t,n){if(e instanceof Array)return e.map(r=>Wt(r,t,n));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){const r=e.constructor.name,i=ka(e);return{rr_type:r,base64:i}}else{if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Wt(e.buffer,t,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const r=e.constructor.name,{src:i}=e;return{rr_type:r,src:i}}else if(e instanceof HTMLCanvasElement){const r="HTMLImageElement",i=e.toDataURL();return{rr_type:r,src:i}}else{if(e instanceof ImageData)return{rr_type:e.constructor.name,args:[Wt(e.data,t,n),e.width,e.height]};if(li(e,t)||typeof e=="object"){const r=e.constructor.name,i=si(e,t,n);return{rr_type:r,index:i}}}}return e}const ai=(e,t,n)=>[...e].map(r=>Wt(r,t,n)),li=(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 Ea(e,t,n,r){const i=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of o)try{if(typeof t.CanvasRenderingContext2D.prototype[s]!="function")continue;const l=dt(t.CanvasRenderingContext2D.prototype,s,function(a){return function(...d){return le(this.canvas,n,r,!0)||setTimeout(()=>{const c=ai([...d],t,this);e(this.canvas,{type:Xe["2D"],property:s,args:c})},0),a.apply(this,d)}});i.push(l)}catch{const l=Ot(t.CanvasRenderingContext2D.prototype,s,{set(a){e(this.canvas,{type:Xe["2D"],property:s,args:[a],setter:!0})}});i.push(l)}return()=>{i.forEach(s=>s())}}function La(e){return e==="experimental-webgl"?"webgl":e}function di(e,t,n,r){const i=[];try{const o=dt(e.HTMLCanvasElement.prototype,"getContext",function(s){return function(l,...a){if(!le(this,t,n,!0)){const d=La(l);if("__context"in this||(this.__context=d),r&&["webgl","webgl2"].includes(d))if(a[0]&&typeof a[0]=="object"){const c=a[0];c.preserveDrawingBuffer||(c.preserveDrawingBuffer=!0)}else a.splice(0,1,{preserveDrawingBuffer:!0})}return s.apply(this,[l,...a])}});i.push(o)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{i.forEach(o=>o())}}function ci(e,t,n,r,i,o,s){const l=[],a=Object.getOwnPropertyNames(e);for(const d of a)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(d))try{if(typeof e[d]!="function")continue;const c=dt(e,d,function(h){return function(...g){const u=h.apply(this,g);if(si(u,s,this),"tagName"in this.canvas&&!le(this.canvas,r,i,!0)){const p=ai([...g],s,this),m={type:t,property:d,args:p};n(this.canvas,m)}return u}});l.push(c)}catch{const c=Ot(e,d,{set(h){n(this.canvas,{type:t,property:d,args:[h],setter:!0})}});l.push(c)}return l}function Ra(e,t,n,r,i){const o=[];return o.push(...ci(t.WebGLRenderingContext.prototype,Xe.WebGL,e,n,r,i,t)),typeof t.WebGL2RenderingContext<"u"&&o.push(...ci(t.WebGL2RenderingContext.prototype,Xe.WebGL2,e,n,r,i,t)),()=>{o.forEach(s=>s())}}function Ua(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),i=0,o=n.length;i<o;++i)r[i]=n.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}function Ta(e,t,n){var r=t===void 0?null:t,i=n===void 0?!1:n,o=Ua(e,i),s=o.indexOf(`
19
- `,10)+1,l=o.substring(s)+(r?"//# sourceMappingURL="+r:""),a=new Blob([l],{type:"application/javascript"});return URL.createObjectURL(a)}function Da(e,t,n){var r;return function(i){return r=r||Ta(e,t,n),new Worker(r,i)}}var xa=Da("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",null,!1);class Ma{reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(t){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(a,d)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(a)||this.pendingCanvasMutations.set(a,[]),this.pendingCanvasMutations.get(a).push(d)};const{sampling:n="all",win:r,blockClass:i,blockSelector:o,recordCanvas:s,dataURLOptions:l}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,s&&n==="all"&&this.initCanvasMutationObserver(r,i,o),s&&typeof n=="number"&&this.initCanvasFPSObserver(n,r,i,o,{dataURLOptions:l})}initCanvasFPSObserver(t,n,r,i,o){const s=di(n,r,i,!0),l=new Map,a=new xa;a.onmessage=p=>{const{id:m}=p.data;if(l.set(m,!1),!("base64"in p.data))return;const{base64:w,type:I,width:y,height:f}=p.data;this.mutationCb({id:m,type:Xe["2D"],commands:[{property:"clearRect",args:[0,0,y,f]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:w}],type:I}]},0,0]}]})};const d=1e3/t;let c=0,h;const g=()=>{const p=[];return n.document.querySelectorAll("canvas").forEach(m=>{le(m,r,i,!0)||p.push(m)}),p},u=p=>{if(c&&p-c<d){h=requestAnimationFrame(u);return}c=p,g().forEach(m=>Sa(this,void 0,void 0,function*(){var w;const I=this.mirror.getId(m);if(l.get(I))return;if(l.set(I,!0),["webgl","webgl2"].includes(m.__context)){const f=m.getContext(m.__context);((w=f?.getContextAttributes())===null||w===void 0?void 0:w.preserveDrawingBuffer)===!1&&f.clear(f.COLOR_BUFFER_BIT)}const y=yield createImageBitmap(m);a.postMessage({id:I,bitmap:y,width:m.width,height:m.height,dataURLOptions:o.dataURLOptions},[y])})),h=requestAnimationFrame(u)};h=requestAnimationFrame(u),this.resetObservers=()=>{s(),cancelAnimationFrame(h)}}initCanvasMutationObserver(t,n,r){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const i=di(t,n,r,!1),o=Ea(this.processMutation.bind(this),t,n,r),s=Ra(this.processMutation.bind(this),t,n,r,this.mirror);this.resetObservers=()=>{i(),o(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=n=>{this.rafStamps.latestId=n,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,n)=>{const r=this.mirror.getId(n);this.flushPendingCanvasMutationFor(n,r)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,n){if(this.frozen||this.locked)return;const r=this.pendingCanvasMutations.get(t);if(!r||n===-1)return;const i=r.map(s=>ba(s,["type"])),{type:o}=r[0];this.mutationCb({id:n,type:o,commands:i}),this.pendingCanvasMutations.delete(t)}}class Oa{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new ea,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,n){"_cssText"in n.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:n.id,attributes:n.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,n){if(t.length===0)return;const r={id:n,styleIds:[]},i=[];for(const o of t){let s;if(this.styleMirror.has(o))s=this.styleMirror.getId(o);else{s=this.styleMirror.add(o);const l=Array.from(o.rules||CSSRule);i.push({styleId:s,rules:l.map((a,d)=>({rule:Tr(a),index:d}))})}r.styleIds.push(s)}i.length>0&&(r.styles=i),this.adoptedStyleSheetCb(r)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}class _a{constructor(){this.nodeMap=new WeakMap,this.loop=!0,this.periodicallyClear()}periodicallyClear(){requestAnimationFrame(()=>{this.clear(),this.loop&&this.periodicallyClear()})}inOtherBuffer(t,n){const r=this.nodeMap.get(t);return r&&Array.from(r).some(i=>i!==n)}add(t,n){this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(n))}clear(){this.nodeMap=new WeakMap}destroy(){this.loop=!1}}function Y(e){return Object.assign(Object.assign({},e),{timestamp:_t()})}let j,zt,En,Vt=!1;const we=Us();function pt(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:i="rr-block",blockSelector:o=null,ignoreClass:s="rr-ignore",ignoreSelector:l=null,maskTextClass:a="rr-mask",maskTextSelector:d=null,inlineStylesheet:c=!0,maskAllInputs:h,maskInputOptions:g,slimDOMOptions:u,maskInputFn:p,maskTextFn:m,hooks:w,packFn:I,sampling:y={},dataURLOptions:f={},mousemoveWait:v,recordCanvas:E=!1,recordCrossOriginIframes:M=!1,recordAfter:x=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:U=!1,collectFonts:V=!1,inlineImages:O=!1,plugins:_,keepIframeSrcFn:Z=()=>!1,ignoreCSSAttributes:q=new Set([]),errorHandler:pe}=e;oa(pe);const S=M?window.parent===window:!0;let G=!1;if(!S)try{window.parent.document&&(G=!1)}catch{G=!0}if(S&&!t)throw new Error("emit function is required");v!==void 0&&y.mousemove===void 0&&(y.mousemove=v),we.reset();const Q=h===!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}:g!==void 0?g:{password:!0},ie=u===!0||u==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:u==="all",headMetaDescKeywords:u==="all"}:u||{};Xs();let oe,re=0;const se=C=>{for(const ce of _||[])ce.eventProcessor&&(C=ce.eventProcessor(C));return I&&!G&&(C=I(C)),C};j=(C,ce)=>{var D;if(!((D=Ve[0])===null||D===void 0)&&D.isFrozen()&&C.type!==R.FullSnapshot&&!(C.type===R.IncrementalSnapshot&&C.data.source===T.Mutation)&&Ve.forEach(X=>X.unfreeze()),S)t?.(se(C),ce);else if(G){const X={type:"rrweb",event:se(C),origin:window.location.origin,isCheckout:ce};window.parent.postMessage(X,"*")}if(C.type===R.FullSnapshot)oe=C,re=0;else if(C.type===R.IncrementalSnapshot){if(C.data.source===T.Mutation&&C.data.isAttachIframe)return;re++;const X=r&&re>=r,We=n&&C.timestamp-oe.timestamp>n;(X||We)&&zt(!0)}};const F=C=>{j(Y({type:R.IncrementalSnapshot,data:Object.assign({source:T.Mutation},C)}))},N=C=>j(Y({type:R.IncrementalSnapshot,data:Object.assign({source:T.Scroll},C)})),Ee=C=>j(Y({type:R.IncrementalSnapshot,data:Object.assign({source:T.CanvasMutation},C)})),qe=C=>j(Y({type:R.IncrementalSnapshot,data:Object.assign({source:T.AdoptedStyleSheet},C)})),he=new Oa({mutationCb:F,adoptedStyleSheetCb:qe}),be=new va({mirror:we,mutationCb:F,stylesheetManager:he,recordCrossOriginIframes:M,wrappedEmit:j});for(const C of _||[])C.getMirror&&C.getMirror({nodeMirror:we,crossOriginIframeMirror:be.crossOriginIframeMirror,crossOriginIframeStyleMirror:be.crossOriginIframeStyleMirror});const Be=new _a;En=new Ma({recordCanvas:E,mutationCb:Ee,win:window,blockClass:i,blockSelector:o,mirror:we,sampling:y.canvas,dataURLOptions:f});const ye=new Ia({mutationCb:F,scrollCb:N,bypassOptions:{blockClass:i,blockSelector:o,maskTextClass:a,maskTextSelector:d,inlineStylesheet:c,maskInputOptions:Q,dataURLOptions:f,maskTextFn:m,maskInputFn:p,recordCanvas:E,inlineImages:O,sampling:y,slimDOMOptions:ie,iframeManager:be,stylesheetManager:he,canvasManager:En,keepIframeSrcFn:Z,processedNodeManager:Be},mirror:we});zt=(C=!1)=>{j(Y({type:R.Meta,data:{href:window.location.href,width:zr(),height:Wr()}}),C),he.reset(),ye.init(),Ve.forEach(D=>D.lock());const ce=Js(document,{mirror:we,blockClass:i,blockSelector:o,maskTextClass:a,maskTextSelector:d,inlineStylesheet:c,maskAllInputs:Q,maskTextFn:m,slimDOM:ie,dataURLOptions:f,recordCanvas:E,inlineImages:O,onSerialize:D=>{Gr(D,we)&&be.addIframe(D),jr(D,we)&&he.trackLinkElement(D),kn(D)&&ye.addShadowRoot(D.shadowRoot,document)},onIframeLoad:(D,X)=>{be.attachIframe(D,X),ye.observeAttachShadow(D)},onStylesheetLoad:(D,X)=>{he.attachLinkElement(D,X)},keepIframeSrcFn:Z});if(!ce)return console.warn("Failed to snapshot the document");j(Y({type:R.FullSnapshot,data:{node:ce,initialOffset:Br(window)}}),C),Ve.forEach(D=>D.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&he.adoptStyleSheets(document.adoptedStyleSheets,we.getId(document))};try{const C=[],ce=X=>{var We;return L(wa)({mutationCb:F,mousemoveCb:(W,cn)=>j(Y({type:R.IncrementalSnapshot,data:{source:cn,positions:W}})),mouseInteractionCb:W=>j(Y({type:R.IncrementalSnapshot,data:Object.assign({source:T.MouseInteraction},W)})),scrollCb:N,viewportResizeCb:W=>j(Y({type:R.IncrementalSnapshot,data:Object.assign({source:T.ViewportResize},W)})),inputCb:W=>j(Y({type:R.IncrementalSnapshot,data:Object.assign({source:T.Input},W)})),mediaInteractionCb:W=>j(Y({type:R.IncrementalSnapshot,data:Object.assign({source:T.MediaInteraction},W)})),styleSheetRuleCb:W=>j(Y({type:R.IncrementalSnapshot,data:Object.assign({source:T.StyleSheetRule},W)})),styleDeclarationCb:W=>j(Y({type:R.IncrementalSnapshot,data:Object.assign({source:T.StyleDeclaration},W)})),canvasMutationCb:Ee,fontCb:W=>j(Y({type:R.IncrementalSnapshot,data:Object.assign({source:T.Font},W)})),selectionCb:W=>{j(Y({type:R.IncrementalSnapshot,data:Object.assign({source:T.Selection},W)}))},blockClass:i,ignoreClass:s,ignoreSelector:l,maskTextClass:a,maskTextSelector:d,maskInputOptions:Q,inlineStylesheet:c,sampling:y,recordCanvas:E,inlineImages:O,userTriggeredOnInput:U,collectFonts:V,doc:X,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:Z,blockSelector:o,slimDOMOptions:ie,dataURLOptions:f,mirror:we,iframeManager:be,stylesheetManager:he,shadowDomManager:ye,processedNodeManager:Be,canvasManager:En,ignoreCSSAttributes:q,plugins:((We=_?.filter(W=>W.observer))===null||We===void 0?void 0:We.map(W=>({observer:W.observer,options:W.options,callback:cn=>j(Y({type:R.Plugin,data:{plugin:W.name,payload:cn}}))})))||[]},w)};be.addLoadListener(X=>{try{C.push(ce(X.contentDocument))}catch(We){console.warn(We)}});const D=()=>{zt(),C.push(ce(document)),Vt=!0};return document.readyState==="interactive"||document.readyState==="complete"?D():(C.push(ae("DOMContentLoaded",()=>{j(Y({type:R.DomContentLoaded,data:{}})),x==="DOMContentLoaded"&&D()})),C.push(ae("load",()=>{j(Y({type:R.Load,data:{}})),x==="load"&&D()},window))),()=>{C.forEach(X=>X()),Be.destroy(),Vt=!1,sa()}}catch(C){console.warn(C)}}pt.addCustomEvent=(e,t)=>{if(!Vt)throw new Error("please add custom event after start recording");j(Y({type:R.Custom,data:{tag:e,payload:t}}))},pt.freezePage=()=>{Ve.forEach(e=>e.freeze())},pt.takeFullSnapshot=e=>{if(!Vt)throw new Error("please take full snapshot after start recording");zt(e)},pt.mirror=we;var Ue=(e=>(e.Closed="close.click",e.Complete="survey.completed",e.FeedbackClosed="feedback.closed",e.PageChange="page.change",e.API="api",e.Override="override",e))(Ue||{}),k=(e=>(e.ReplayCapture="replay.capture",e.FeedbackButtonLoaded="feedback.button.loaded",e.SDKReady="sdk.ready",e.SurveyAppeared="survey.appeared",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))(k||{});const ht={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 Gt;const Na=new Uint8Array(16);function Fa(){if(!Gt&&(Gt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Gt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Gt(Na)}const te=[];for(let e=0;e<256;++e)te.push((e+256).toString(16).slice(1));function Pa(e,t=0){return te[e[t+0]]+te[e[t+1]]+te[e[t+2]]+te[e[t+3]]+"-"+te[e[t+4]]+te[e[t+5]]+"-"+te[e[t+6]]+te[e[t+7]]+"-"+te[e[t+8]]+te[e[t+9]]+"-"+te[e[t+10]]+te[e[t+11]]+te[e[t+12]]+te[e[t+13]]+te[e[t+14]]+te[e[t+15]]}const Ba=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ui={randomUUID:Ba};function Ge(e,t,n){if(ui.randomUUID&&!t&&!e)return ui.randomUUID();e=e||{};const r=e.random||(e.rng||Fa)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,Pa(r)}const Wa='.ul-loading-spinner-container{font-size:1.8rem;flex-grow:1;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.ul-loading-spinner{display:inline-block;position:relative;width:6rem;height:6rem}.ul-loading-spinner div{box-sizing:border-box;display:block;position:absolute;width:80%;height:80%;margin:5px;border:5px solid #152e3e;border-radius:50%;animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#152e3e transparent transparent transparent}.ul-loading-spinner .first{animation-delay:-.45s}.ul-loading-spinner .second{animation-delay:-.3s}.ul-loading-spinner .third{animation-delay:-.15s}@keyframes lds-ring{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.fade-in-transition{animation:fadeIn .4s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}#sprig-feedback-button{border-left:0;border-radius:0 8px 8px 0;display:grid;padding:8px;text-align:center;transition:all ease-in-out 1s;z-index:inherit}#sprig-feedback-button:hover{cursor:pointer}.sprig-feedback-button-label{writing-mode:vertical-lr;text-orientation:sideways}.sprig-feedback-button-right{transform:rotate(180deg)}.sprig-feedback-button-bottom{align-self:flex-end;margin-bottom:20px}.sprig-feedback-button-light{background:#efefee;color:#000;border:1px solid #e2e3e1}.sprig-feedback-button-dark{background:#000;color:#fff;border:1px solid #000000}#sprig-feedback-container{display:flex;align-items:center;position:fixed;transition:right .2s linear,left .2s linear;z-index:2147483646}.sprig-feedback-container-left{flex-flow:row-reverse}.sprig-feedback-container-center{top:50%;transform:translateY(-50%)}.sprig-feedback-container-bottom{bottom:0%;margin-bottom:15px}.sprig-feedback-loading-container{align-items:center;background-color:#fff;border:2px solid var(--feedback-border);display:flex;max-height:90vh;max-width:90vw;min-width:0px}.sprig-feedback-loading-container-left{border-left:none;border-radius:0 8px 8px 0}.sprig-feedback-loading-container-right{border-right:none;border-radius:8px 0 0 8px}#sprig-feedback-error-container{margin:auto;text-align:center;width:360px}.sprig-feedback-error-text{font-weight:400;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol}#sprig-feedback-loading-container .ul-container{position:relative;max-height:inherit}#sprig-feedback-loading-animation{position:absolute}.sprig-feedback-loading-container-previews iframe{max-height:inherit!important}',pi="360px",za="ul-app",Va="#e6e6e6",Ga="#bd282a",ja=500,Ha=1030,hi=()=>{try{return window.parent.Intercom}catch{return null}},Ka=()=>{const e=hi();e&&(e.ul_wasVisible&&e("update",{hide_default_launcher:!1}),delete e.ul_wasVisible)},Za=()=>{const e=hi();e&&(e.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),e.ul_wasVisible&&e("update",{hide_default_launcher:!0}))},qa=Object.freeze(Object.defineProperty({__proto__:null,disable:Za,enable:Ka},Symbol.toStringTag,{value:"Module"})),gi=[qa];class mi{static disable(){gi.forEach(t=>t.disable())}static enable(){gi.forEach(t=>t.enable())}}var $a=class extends Error{constructor(e,t,n){super(`Possible EventEmitter memory leak detected. ${n} ${t.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=t,this.count=n,this.name="MaxListenersExceededWarning"}},yi=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=yi.defaultMaxListeners,this.hasWarnedAboutPotentialMemoryLeak=!1}_emitInternalEvent(e,t,n){this.emit(e,t,n)}_getListeners(e){return Array.prototype.concat.apply([],this.events.get(e))||[]}_removeListener(e,t){const n=e.indexOf(t);return n>-1&&e.splice(n,1),[]}_wrapOnceListener(e,t){const n=(...r)=>(this.removeListener(e,n),t.apply(this,r));return Object.defineProperty(n,"name",{value:t.name}),n}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}eventNames(){return Array.from(this.events.keys())}emit(e,...t){const n=this._getListeners(e);return n.forEach(r=>{r.apply(this,t)}),n.length>0}addListener(e,t){this._emitInternalEvent("newListener",e,t);const n=this._getListeners(e).concat(t);if(this.events.set(e,n),this.maxListeners>0&&this.listenerCount(e)>this.maxListeners&&!this.hasWarnedAboutPotentialMemoryLeak){this.hasWarnedAboutPotentialMemoryLeak=!0;const r=new $a(this,e,this.listenerCount(e));console.warn(r)}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 n=this._getListeners(e);if(n.length>0){const r=[t].concat(n);this.events.set(e,r)}else this.events.set(e,n.concat(t));return this}prependOnceListener(e,t){return this.prependListener(e,this._wrapOnceListener(e,t))}removeListener(e,t){const n=this._getListeners(e);return n.length>0&&(this._removeListener(n,t),this.events.set(e,n),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)}},fi=yi;fi.defaultMaxListeners=10;const A=new fi,jt=async e=>{await new Promise(t=>{setTimeout(t,e)})},wi=({"userleap-platform":e})=>e!=="web";class vi{constructor(t){ee(this,"storage"),ee(this,"tempStorage",{}),ee(this,"isStorageAvailable"),this.storage=window[t],this.isStorageAvailable=this.checkIfStorageAvailable()}checkIfStorageAvailable(){try{const t="__storage_test__";return this.storage.setItem(t,t),this.storage.removeItem(t),!0}catch{return!1}}setItem(t,n){this.isStorageAvailable?this.storage.setItem(t,n):this.tempStorage[t]=n}getItem(t){return this.isStorageAvailable?this.storage.getItem(t):this.tempStorage[t]}removeItem(t){this.isStorageAvailable?this.storage.removeItem(t):delete this.tempStorage[t]}clear(){this.isStorageAvailable?this.storage.clear():this.tempStorage={}}}const ne=new vi("sessionStorage"),Se=new vi("localStorage");class Ya{constructor(t){ee(this,"payload"),ee(this,"promise"),ee(this,"reject",()=>{}),ee(this,"resolve",()=>{}),this.payload=t,this.promise=new Promise((n,r)=>{this.reject=r,this.resolve=n})}resolveRequest(t){this.resolve(t)}}const J={replay:null},Ja=e=>{J.replay=e},Qa=()=>{const e=[];return J.replay&&e.push("replay"),e.join(",")},Xa={RATELIMIT_RESET_DEFAULT:10};let Ii=!1,bi="",Ht=!1,Si=!1,Kt=[];const el=e=>e._config&&e._config.installationMethod?e._config.installationMethod:e._gtm?"web-gtm":e._segment?"web-segment":"web-snippet",Ci=e=>{var t;(t=e?.blockedURI)!=null&&t.includes(window.UserLeap._API_URL)&&(Si=!0,console.warn(`[Sprig] ${e.blockedURI} is blocked by Content-Security-Policy`))},Ln=(e="")=>{Ii=!0,bi=e};function je(e={}){const t={"Content-Type":"application/json","userleap-platform":"web","x-ul-sdk-version":"2.31.1","x-ul-installation-method":el(e),"sprig-modules":Qa()};if(t["x-ul-package-version"]="1.1.4",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 n=JSON.parse(e.mobileHeadersJSON);Object.assign(t,n)}return e.locale&&(t["accept-language"]=e.locale),window.previewMode&&(t["x-ul-preview-mode"]="1"),t}const ki=async({shouldDropOnRateLimit:e,...t})=>{if(e)return{status:429};{const n=new Ya(t);return Kt.push(n),n.promise}},Te=async(e,t)=>{const{retries:n=0,shouldDropOnRateLimit:r=!1,shouldRetryRequest:i=!1,...o}=t,s={url:e,options:o,retries:n,shouldDropOnRateLimit:r};if(Ht&&!i)return ki(s);const l={ok:!1,reportError:!1};if(Ii)return console.info(`UserLeap - ${bi}`),l;try{const a=await fetch(e,o);if(a.status===429)if(!Ht&&!r||i){Ht=!0;const d=a.headers.has("ratelimit-reset")?Number(a.headers.get("ratelimit-reset")):Xa.RATELIMIT_RESET_DEFAULT;return await jt(d*1e3),Te(e,{...o,shouldDropOnRateLimit:r,shouldRetryRequest:!0})}else return ki(s);if(Ht=!1,Kt.length&&(Kt.map(d=>{const c=d.payload;Te(c.url,{...c.options,retries:c.retries,shouldDropOnRateLimit:c.shouldDropOnRateLimit}).then(h=>{d.resolveRequest(h)})}),Kt=[]),a.ok){if(a.status===249)return Ln(),l;const d=await a.text();try{return d&&d!=="OK"&&(a.json=JSON.parse(d)),a}catch{return{ok:!1,reportError:!1,error:new Error(`failed parsing response json for ${e} - ${d}`)}}}return a}catch(a){const d=n+1;return d>5||Si?{ok:!1,reportError:!1,error:a}:(await jt(Math.pow(2,n)*1e3),Te(e,{...o,retries:d}))}},tt={Error:1,Warn:2,Info:3,Debug:4};let Rn=1e3,Zt=tt.Debug,nt=[];const tl=e=>{const t=Object.entries(tt).find(n=>n[1]===e);return t?.[0]??""},nl=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),rl=(e,t)=>`${nl(t)}:${e}`,il=()=>{nt=nt.filter(e=>e.level<=Zt)},ol=()=>{nt.length>Rn&&nt.shift()},qt=(e,t)=>{e>Zt||(nt.push({level:e,line:rl(t,new Date)}),ol())},gt=e=>{qt(tt.Debug,e)},b=e=>{qt(tt.Info,e)},Un=e=>{qt(tt.Warn,e)},Ai=e=>{qt(tt.Error,e)},sl=()=>nt.map(e=>e.line),al=()=>new TextEncoder().encode(sl().join(`
20
- `)),Ei=async e=>{if(!e)return;const t=al();return Te(e,{body:t,method:"PUT"})},ll=(e,t)=>{e!==void 0&&(Rn=e),t!==void 0&&(Zt=t),gt(`Initializing logger with limit of ${Rn} lines and ${tl(Zt)} level`),il()},Li="ul-view-sdk-script",dl=["ios","android"],Oe="visitors",_e="environments";async function Ce(e,t){var n,r,i;const{shouldDropOnRateLimit:o,...s}=t;s.headers=Object.assign(je(window.UserLeap),s.headers);const l=await Te(e,{...s,shouldDropOnRateLimit:o});if(l.ok){const a=(n=l.headers)==null?void 0:n.get("Authorization"),d=a?a.split(" "):void 0,c=d&&d.length===2?d[1]:void 0,h=(r=l.headers)==null?void 0:r.get("x-ul-visitor-id");c&&h&&(h!==window.UserLeap.visitorId||window.UserLeap.token!==c)&&(ge("token",c),ge("vid",h),A.emit(k.VisitorIDUpdated,{visitorId:h}),window.UserLeap.token=c,window.UserLeap.visitorId=h)}return(i=l.json)!=null&&i.logMessage&&console.warn(`[Sprig] ${l.json.logMessage}`),l}function ge(e,t){const n=Se.getItem("userleap.ids");let r={};if(n)try{r=JSON.parse(n)}catch(o){o instanceof Error&&(o.stack=n,window.UserLeap.reportError("Failed to parse local storage credentials",o)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",o)}let i=r[window.UserLeap.envId];i?i[e]=t:i={[e]:t},r[window.UserLeap.envId]=i;try{Se.setItem("userleap.ids",JSON.stringify(r))}catch(o){o instanceof Error&&console.warn(`[Sprig] (ERR-426) Unable to write to Local Storage:: ${o.message}`)}}function Tn(){return window.previewMode?"0":window.UserLeap.visitorId??""}function ve(e,t,n){const r=[window.UserLeap._API_URL,"sdk",e];return t&&t.forEach(i=>{r.push(i),i===_e?r.push(window.UserLeap.envId):i===Oe&&r.push(Tn())}),n&&r.push(n),r.join("/")}const mt=async(e,t)=>{var n,r,i;const{context:o,delay:s,forceBrandedLogo:l,endCard:a,isFeedback:d=!1,heatmap:c,locale:h,previewMode:g,productConfig:u,questions:p,responseGroupUid:m,surveyId:w,uuid:I,vid:y,sessionReplay:f,studyType:v}=e,E=je(window.UserLeap),M=xn(E),x=Dn(E);if(b(`Attempting to display survey: ${w}`),f)if(b("Survey has replay attached"),M)A.emit(k.ReplayCapture,{responseGroupUid:m,hasQuestions:!!(p!=null&&p.length),surveyId:w,uploadId:f.uploadId,replayType:f.replayDurationType??"before",seconds:f.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:Ge(),mediaType:"screen",questionId:1,responseGroupUid:m,surveyId:w,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}});else{if(!J.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};J.replay.scheduleOrCaptureReplay({responseGroupId:m,surveyId:w,visitorId:y,replayParams:f,completeUploadHeaders:E,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:p.length===0})}if(c){if(!J.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};const{eventId:N,replayParams:Ee,responseGroupUid:qe,surveyId:he}=c;await J.replay.initializeReplay({viewDocument:window.document,maxReplayDurationSeconds:300,replayNonce:window.UserLeap.replayNonce,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0}),J.replay.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:E,eventId:N,isHeatmap:!0,replayParams:Ee,responseGroupId:qe,surveyId:he,triggerTimestamp:Date.now(),visitorId:y})}if(y==null||!(p!=null&&p.length))return b(`Not displaying survey: vid: ${y} / questions: ${p}`),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(cl(p))return{success:!1,message:"[Sprig] bundled version does not support video voice",surveyState:"no survey"};if(window.UserLeap.container){b("Already displaying a survey");const N="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(N),{success:!1,message:N,surveyState:"no survey"}}if(y!==window.UserLeap.visitorId&&I!==window.UserLeap.visitorId&&!window.previewMode){const N="Attempted to display survey to a different visitor";return b(N),window.UserLeap.reportError("DisplaySurvey",new Error(N)),{success:!1,message:N,surveyState:"no survey"}}b(`Showing survey: ${w}`),(n=J.replay)==null||n.RecordSurveyShown({id:w,userAgent:window.navigator.userAgent}),mi.disable(),A.emit(k.SurveyWillPresent,{name:k.SurveyWillPresent,"survey.id":w});let U,V=document.createElement("div"),O,_,Z;const q=N=>{const{"view.version":Ee}=N;Ee!==E["x-ul-sdk-version"]&&Ui(),A.removeListener("verify.view.version",q)};A.on("verify.view.version",q),window.UserLeap.useMobileStyling=x,wi(E)?(U="ul-direct-embeded-frame",O=document.head,_=window,Z=!1,M&&(Ri(d),V.id=U,window.UserLeap.container.appendChild(V),Ti(),A.emit(k.SurveyLifeCycle,{state:"presented"}),A.emit(k.SurveyPresented,{name:k.SurveyPresented,"survey.id":w}))):{frameId:U,contentWinDocHead:O,contentWindow:_,hasOverlay:Z,iframe:V}=ml({productConfig:u,useMobileStyling:x,surveyId:w,isFeedback:d}),window.UserLeap.frameId=U;const pe=N=>{A.once(k.CloseSurveyOnOverlayClick,N)},S={apiURL:window.UserLeap._API_URL,cards:p,configureExitOnOverlayClick:pe,context:o,endCard:a,envId:window.UserLeap.envId,eventEmitFn:A.emit.bind(A),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:l,frame:V,headers:E,locale:h,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:Se.getItem("sprig.previewKey"),previewMode:g,productConfig:{framePosition:u?.framePosition,desktopDisplay:u?.desktopDisplay,placement:u?.placement},responseGroupUid:m,startingQuestionIdx:(r=window.UserLeap.config)==null?void 0:r.startingQuestionIdx,studyType:v,styleNonce:window.UserLeap.styleNonce,surveyId:w,tabTitle:document.title,trackPageViewUrl:t,ulEvents:ht,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:x,userId:I,viewDocument:_?.document,viewWindow:_,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},...window.UserLeap._config};(i=window.UserLeap._config)!=null&&i.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null});const G=(d?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??u.customStyles;S.customStyles=G,_&&(_.__cfg=S);function Q(){const N=document.createElement("script");return window.UserLeap.nonce&&N.setAttribute("nonce",window.UserLeap.nonce),N.id=Li,N}const ie=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:S.path,oe=document.getElementById(Li);oe&&oe.remove();const re=Q(),se=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(S.installationMethod==="web-npm"||S.installationMethod==="web-npm-bundled"){const{default:N}=await import("./view-B7PNPO8b.js");N.configure(S),Z&&window.UserLeap.container&&se()}else ie&&(re.src=ie,Z&&re.addEventListener("load",()=>{window.UserLeap.container&&se()}),_?.addEventListener("error",N=>{N.target instanceof HTMLScriptElement&&N.target.src===ie&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));O?.appendChild(re);const F={success:!0,surveyState:"ready",surveyId:w,responseGroupUid:m};return window.UserLeap.isMobileSDK&&s&&(F.delay=s),F};function Dn(e){var t;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const n=((t=window.UserLeap.windowDimensions)==null?void 0:t.width)??document.body.clientWidth;return xn(e)||n>10&&n<ja}function xn(e){return dl.includes(e["userleap-platform"])}const cl=e=>e.some(t=>t.type==="videovoice"),Mn="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 ul="rgba(255,255,255, 0.95)",pl="rgba(0,0,0,0.9)",On="0px",Ri=(e,t)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className=`ul-container ${e&&"ul-container-feedback"}`;const n=Ni();t&&n&&!window.UserLeap.useMobileStyling?n.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},Ui=(e,t)=>{var n;fl();const r=window.UserLeap.container;if(r)try{(n=r.parentNode)==null||n.removeChild(r),window.UserLeap.container=null,ge("trackStartUrl",null),A.emit(k.SurveyLifeCycle,{state:"dismissed"}),A.emit(k.SurveyClosed,{name:k.SurveyClosed,initiator:e,studyType:t})}catch(i){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${e} `+r),i instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",i)}},Ti=()=>{A.once(k.SurveyWillClose,({initiator:e,studyType:t})=>{A.removeAllListeners(k.CloseSurveyOnOverlayClick),Ui(e,t)})},hl=(e,t)=>{const n={position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646},r=t?e.overlayStyleMobile:e.overlayStyle;n["background-color"]=r==="light"?ul:pl,t||(n.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,n)},gl=(e,t,n,r)=>{var i,o;const s={position:"fixed",bottom:"0px",right:On,border:0,backgroundColor:"rgba(0,0,0,0)",zIndex:2147483646,transition:"width 0.2s ease-in-out, height 0.2s ease-in-out",maxWidth:"100%"},l=Object.assign({},t,window.UserLeap),{desktopDisplay:a}=t||{},d=a==="center-modal";d&&(l.framePosition="center");let c,h=!1;if(n)(i=window.UserLeap.windowDimensions)!=null&&i.width?s.width=`${window.UserLeap.windowDimensions.width}px`:s.width="100%",(o=window.UserLeap.windowDimensions)!=null&&o.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(l.overlayStyleMobile)&&(h=!0);else{s.width=pi,s.maxHeight=window.UserLeap.maxHeight||"66vh";const g=()=>{h=!0,c={margin:"auto",position:"static"}};if(r)d?g():c={position:"relative",height:"300px"};else switch(l.framePosition){case"bottomLeft":c={left:On};break;case"topLeft":c={left:On,top:0};break;case"topRight":c={top:0};break;case"center":g();break}}return h&&hl(l,n),Object.assign(e.style,s,c),h},ml=({productConfig:e,useMobileStyling:t,surveyId:n,isFeedback:r})=>{var i,o;const s=Mn,l=r&&e.desktopDisplay==="slider";Ri(r,l),yl();const a=document.createElement("iframe");a.id=s,a.setAttribute("title","Sprig User Feedback Dialog");const d=gl(a,e,t,r);Ti();let c=!1;a.setHeight=p=>{(parseInt(a.style.height)!=p||!c)&&(c=!0,a.style.height=`${p}px`,A.emit(k.SurveyHeight,{name:k.SurveyHeight,contentFrameHeight:p}))};let h=!1;a.setWidth=p=>{(parseInt(a.style.width)!=p||!h)&&(h=!0,a.style.width=`${p}px`,A.emit(k.SurveyWidth,{name:k.SurveyWidth,contentFrameWidth:p}))},(i=window.UserLeap.container)==null||i.appendChild(a),e&&(t?e.exitOnOverlayClickMobile:e.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{A.emit(k.CloseSurveyOnOverlayClick)}),A.emit(k.SurveyLifeCycle,{state:"presented"}),A.emit(k.SurveyPresented,{name:k.SurveyPresented,"survey.id":n});const g=(o=a.contentWindow)==null?void 0:o.document;if(g&&(g.open("text/html","replace"),g.write("<!doctype html><head></head><body></body></html>"),g.close(),!t)){const p=g.body;p.style.display="flex",p.style.alignItems="center"}const u=g?.head;return{frameId:s,contentWinDocHead:u,contentWindow:a.contentWindow,hasOverlay:d,iframe:a}},Di={[k.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},yl=()=>{Object.entries(Di).forEach(([e,t])=>{A.on(e,t)})},fl=()=>{Object.entries(Di).forEach(([e,t])=>{A.off(e,t)})},xi=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 $t(e,t){const{matchType:n,pattern:r}=e,i=n?xi[n]:xi.legacy;let o=!1;try{o=i(r,t)}catch(s){const l=`[Sprig] (ERR-445) Failed to check url match with pattern ${r}`;s instanceof Error&&(console.warn(l,s),s.stack=JSON.stringify(e),window.UserLeap.reportError(l,s))}return o}const Mi=e=>{const{pageUrlEvents:t}=window.UserLeap._config,n=t?.find(r=>r.id===e);return n?$t(n,window.location.href):!1},wl=1,Oi=e=>e instanceof HTMLElement||e instanceof SVGElement,yt=({document:e,elementId:t,styleString:n,nonce:r})=>{const i=e.getElementById(t);if(i){i.textContent=n;return}const o=e.createElement("style");r&&(o.nonce=r),o.textContent=n,o.id=t,e.head.appendChild(o)},_i=e=>{const t=e.querySelector(".ul-card__container");let n=600,r=360;if(t){n=t.scrollHeight;const i=getComputedStyle(t),o=parseFloat(i.marginTop)+parseFloat(i.marginBottom),s=parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth),l=parseFloat(i.paddingTop)+parseFloat(i.paddingBottom);n+=o+s+l;const a=t.querySelector(".ul-card--matrix_grid");r=a?a.scrollWidth:t.scrollWidth;const d=parseFloat(i.paddingLeft)+parseFloat(i.paddingRight),c=parseFloat(i.marginLeft)+parseFloat(i.marginRight),h=parseFloat(i.borderLeftWidth)+parseFloat(i.borderRightWidth);r+=c+h+d}return[n+wl,r]},vl=e=>{const t=e.querySelector(".ul-card__container");t&&(t.scrollTop=0)},Ni=()=>B,rt=()=>document.getElementById("sprig-feedback-container"),_n=()=>document.getElementById("sprig-feedback-loading-animation"),Il=()=>{if(_n())return;const e=document.createElement("div");return e.className="ul-loading-spinner-container",e.id="sprig-feedback-loading-animation",e.role="progressbar",e.setAttribute("aria-live","polite"),e.setAttribute("aria-busy","true"),e.setAttribute("aria-label","Processing..."),e.innerHTML=`
21
- <div class="ul-loading-spinner">
22
- <div class="first"></div>
23
- <div class="second"></div>
24
- <div class="third"></div>
25
- <div class="fourth"></div>
26
- </div>
27
- `,e},Fi=()=>!!document.getElementById(Mn);let Pi=!1,B=null,ke=null,Nn=!1,ft=null,wt=null;const bl=["bottom-left","bottom-right","center-left","center-right"],Sl=e=>{if(rt()||!bl.includes(e))return;const[t,n]=e.split("-"),r=document.createElement("div");r.id="sprig-feedback-container",r.classList.add(`sprig-feedback-container-${n}`,`sprig-feedback-container-${t}`),document.body.appendChild(r)},Yt=()=>{var e;const t=window.UserLeap.container;return((e=t?.parentElement)==null?void 0:e.id)==="sprig-feedback-loading-container"},Bi=()=>document.getElementById("sprig-feedback-error-container"),Wi=()=>{if(!B)return 0;const e=B?.clientWidth,t=window.getComputedStyle(B),n=parseInt(t.borderRightWidth||"0"),r=parseInt(t.borderLeftWidth||"0");return e+n+r},Jt=e=>{const t=rt();t&&(wt!=null&&wt.endsWith("right")?t.style.right=`${e}px`:wt!=null&&wt.endsWith("left")&&(t.style.left=`${e}px`))},Fn=()=>{if(B&&(Yt()||Bi())){A.off(k.SurveyAppeared,vt),Pn();const e=Wi();return Jt(-e),!0}return!1},vt=()=>{if(!B||!ke)return;const e=_n();e&&e.remove(),B.style.height="auto",B.style.width="auto",ke.disabled=!1,Nn=!1},Pn=()=>{if(B&&!_n()){const e=Il();e&&(B.style.height="300px",B.style.width="360px",B.appendChild(e))}},zi=()=>{!B||!ke||(Jt(0),ke.disabled=!0,Nn=!0)},Cl=async e=>{const t=await Ce(ve("1",[Oe],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:e}),method:"POST"});return t.ok?t.json:null},Vi=async(e,t,n)=>{const{buttonTheme:r,customStyles:i,eventId:o,placement:s,desktopDisplay:l,feedbackLabel:a,surveyUuid:d,surveyId:c}=e;window.UserLeap.feedbackCustomStyles=void 0;let h=rt();if(h){if(!t&&o===ft)return;h.remove(),A.off(ht.SURVEY_FADING_OUT,Fn)}ft=o,yt({document,elementId:"sprig-feedback-style",styleString:Wa,nonce:window.UserLeap.styleNonce}),yt({document,elementId:"ul-custom-style",styleString:i??"",nonce:window.UserLeap.styleNonce}),Pi=l==="center-modal",wt=s;const[g,u]=s.split("-");Sl(s),h=rt(),ke=document.createElement("button");const p=document.createElement("div");p.className="sprig-feedback-button-label",p.innerText=a,ke.appendChild(p),ke.id="sprig-feedback-button",ke.classList.add(`sprig-feedback-button-${u}`,`sprig-feedback-button-${g}`,`sprig-feedback-button-${r}`,"fade-in-transition"),A.on(ht.SURVEY_FADING_OUT,Fn),ke.addEventListener("click",async()=>{const I=document.getElementById("sprig-feedback-error-container");if(Fi()||Bi()){if(Fn()){A.emit(k.SurveyWillClose,{name:k.SurveyWillClose,initiator:Ue.FeedbackClosed,studyType:"feedbackButton"});const v=rt();I&&v&&(v.remove(),ft=null,B=null)}return}const y=je(window.UserLeap);if(!Dn(y)&&!Nn&&zi(),t){B&&B.classList.add("sprig-feedback-loading-container-previews"),await mt(t),vt();return}const f=await Cl(d);if(f)A.once(k.SurveyAppeared,vt),mt({...f,studyType:"feedbackButton"},n);else if(B){const v=Al();B.appendChild(v),vt(),B.style.height="300px",B.style.width="360px"}}),h?.appendChild(ke),A.emit(k.FeedbackButtonLoaded,{name:k.FeedbackButtonLoaded,"survey.id":c});const{useMobileStyling:m,_config:{border:w}}=window.UserLeap;if(!Pi&&!m){const I=document.createElement("div");I.id="sprig-feedback-loading-container",I.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${u}`,I.style.setProperty("--feedback-border",w),B=I,Pn(),h?.appendChild(I);const y=Wi();Jt(-y)}else Jt(0);window.UserLeap._config.isOnQuestionsTab&&t&&!Yt()&&B&&(zi(),Pn(),B&&B.classList.add("sprig-feedback-loading-container-previews"),mt(t),vt())},kl=()=>{if(Yt())return;const e=rt();e&&(Mi(ft)||(e.remove(),ft=null,B=null))},Al=()=>{const e=document.createElement("div");e.id="sprig-feedback-error-container",e.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none">
28
- <circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
29
- <path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
30
- <circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
31
- </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},El="!launch_darkly_";class Ll{constructor(){ee(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(t){try{return!t||typeof t!="object"||Array.isArray(t)?!1:(Object.keys(this._ldData).forEach(n=>{delete this._ldData[n]}),Object.keys(t).forEach(n=>this._ldData[`${El}${n}`]=(t[n]??0)+1),!0)}catch(n){return n instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",n),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}}const Bn=new Ll;Object.freeze(Bn);const Rl="!optimizely_experiments_";class Ul{constructor(){ee(this,"_optimizelyData",{})}setOptimizelyExperiment(t,n=!0){if(!t||typeof t!="object")return!1;const{experiments:r}=t;try{return n&&Object.keys(this._optimizelyData).map(i=>{delete this._optimizelyData[i]}),r&&r.map(i=>{const{id:o,variation:s}=i,l=this.transformExperimentId(o);s&&typeof s=="string"&&(this._optimizelyData[l]=s)}),!0}catch(i){return i instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",i),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(t){return this._optimizelyData[this.transformExperimentId(t)]}transformExperimentId(t){return Rl+t}getAndSetWebOptimizelyExperiments(){var t;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const n=(t=window.optimizely.get("state"))==null?void 0:t.getExperimentStates({isActive:!0});if(n){const r=Object.keys(n).map(i=>{var o,s;return(o=n[i].variation)!=null&&o.name?{id:i,variation:(s=n[i].variation)==null?void 0:s.name}:{id:i,variation:"Original"}});return this.setOptimizelyExperiment({experiments:r},!1),!0}return!1}return!1}catch(n){return n instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",n),!1}}}const Qt=new Ul;Object.freeze(Qt);class Tl{constructor(t,n){ee(this,"paused"),ee(this,"queue"),ee(this,"ul"),this.ul=t,this.paused=!1,this.queue=[],this.flush(n)}flush(t){const n=t.length;if(n)for(let r=0;r<n;r++)this.push(t[r])}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 n=Array.prototype.slice.call(t,1),r=t[0],i=this.ul[r];i instanceof Function?i.apply(this.ul,n):r&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",r)}}perform(t){if(this.paused){let n=()=>{};const r=new Promise(function(i){n=function(){i(t())}});return this.queue.push(n),r}else return t()}empty(){this.queue.length=0}}let Gi=!0,Wn=!1;const Dl=()=>Gi=!1,xl=()=>Wn=!0,Ml=["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 It={},zn;class Ol{constructor(t){ee(this,"_values",[]),ee(this,"_isWebMetric"),this.name=t,this._isWebMetric=Ml.includes(this.name)}report(t){if(Gi&&this._values.push({time:Date.now(),value:t}),Wn||!this._isWebMetric)return;const n=this.findExceededThreshold(t);n&&zn&&zn(t,n)}collect(){const t=this._values;return this._values=[],t}findExceededThreshold(t){const n=It[this.name];if(n)return n.find(r=>this.valueExceedsThreshold(t,r))}valueExceedsThreshold(t,n){return n.type==="max"?t>n.value:n.type==="min"?t<n.value:!1}}const _l=(e,t)=>{It={},Wn=!1,e?.forEach(n=>{var r;n.metric in It||(It[n.metric]=[]),(r=It[n.metric])==null||r.push(n)}),zn=t},bt={},Ae=e=>{const t=new Ol(e);return bt[e]=t,t},ji=(e,t)=>{let n=bt[e];return n||(n=Ae(e)),n.report(t)},Nl=async e=>{const t=Object.values(bt).map(n=>({name:n.name,values:n.collect()}));if(t.some(n=>n.values.length))try{await e(JSON.stringify(t))}catch(n){Un(`Error posting metrics: ${n}`)}},Fl=({reportingIntervalSeconds:e,postMetrics:t})=>{e?setInterval(()=>{Nl(t)},e*1e3):Dl()};let Hi,Ki;const Vn=e=>{let t=0,n=e.firstElementChild;for(;n;)t+=Vn(n),n.shadowRoot&&(t+=Vn(n.shadowRoot)),n=n.nextElementSibling,t++;return t},Pl=()=>document.documentElement.innerHTML.length,Zi=()=>{Hi.report(Vn(document.body)),Ki.report(Pl())},Bl=(e=10*1e3)=>{Hi=Ae("sdk_dom_nodes_count"),Ki=Ae("sdk_page_html_characters"),Zi(),setInterval(Zi,e)},Gn=(e,t)=>{const n=performance.now();document.hidden?setTimeout(()=>Gn(e,t),e):setTimeout(()=>{const r=performance.now()-n;t.report(r/1e3),setTimeout(()=>Gn(e,t),e)},0)},Wl=(e=1e3)=>{const t=Ae("sdk_event_queue_latency_seconds");Gn(e,t)};let Xt,en,tn,nn,He={},qi;const rn=(e,t=1)=>{const{name:n}=e;He[n]=(He[n]||0)+t},$i=e=>{let t=1;return e.childNodes.forEach(n=>{t+=$i(n)}),t},Yi=e=>{let t=0;return e.forEach(n=>{t+=$i(n)}),t},zl=e=>{switch(e.type){case"childList":rn(Xt,Yi(e.addedNodes)),rn(en,Yi(e.removedNodes));return;case"attributes":rn(tn);return;case"characterData":rn(nn);return}},Vl=e=>e.forEach(zl),Gl=()=>{qi=new MutationObserver(Vl),qi.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0})},jl=()=>{Xt.report(He[Xt.name]||0),en.report(He[en.name]||0),tn.report(He[tn.name]||0),nn.report(He[nn.name]||0),He={}},Hl=(e=1*1e3)=>{Xt=Ae("sdk_mutations_nodes_added"),en=Ae("sdk_mutations_nodes_removed"),tn=Ae("sdk_mutations_attributes_changed"),nn=Ae("sdk_mutations_character_data"),Gl(),setInterval(jl,e)},Kl=({webMetricsEnabled:e,reportingIntervalSeconds:t,thresholds:n,postMetrics:r})=>{_l(n,(i,o)=>{var s,l;if((s=J.replay)!=null&&s.isReplayRecording()){const a=`Value: ${i} on ${o.metric} violated threshold of ${o.type} ${o.value}`;(l=J.replay)==null||l.disableRecording("Threshold violated",new Error(a),{reportError:!1}),window.UserLeap.reportError("Sdk Performance Metric threshold violated",new Error("Sdk Performance Metric threshold violated"),{metricName:o.metric,type:o.type,value:o.value},{metricName:o.metric}),xl()}}),Fl({reportingIntervalSeconds:t,postMetrics:r}),e&&(Wl(),Bl(),Hl())},Zl={test:"test"},ql=["popState","pushState","replaceState"],St="!email",Ji="pageUrl";function $l(e,t){const{pageUrlEvents:n,interactiveEvents:r,dismissOnPageChange:i}=window.UserLeap._config;if(!i)return!0;const o=[];n&&n.length&&o.push(...n),r&&r.length&&o.push(...r);const s=e&&o.find(l=>l.id===e);return s?$t(s,window.location.href):t===window.location.href}function Ct(e){var t;const{pageUrlEvents:n,interactiveEvents:r,dismissOnPageChange:i,platform:o}=window.UserLeap._config;if(o&&o!=="web")return;const s=Ke("trackStartUrl"),l=s?String(s):null;n&&to(window.location.href),r&&(Xi(),Yl()),Ni()&&kl(),ne.getItem("sprig.isCapturingHeatmap")&&((t=J.replay)==null||t.checkPendingHeatmapsUrl()),!Yt()&&i&&l&&l!==window.location.href&&e&&ql.includes(e.type)&&window.UserLeap("dismissActiveSurvey",Ue.PageChange)}const Qi={capture:!0},Yl=()=>{const e=window.UserLeap._config.interactiveEvents.filter(n=>$t(n,window.location.href)).map(n=>{const{name:r,properties:i}=n,{selector:o,innerText:s}=i;return o?l=>{if(Oi(l.target))try{l.target.closest(o)&&window.UserLeap("track",r)}catch{}return!1}:l=>(Oi(l.target)&&l.target.innerText===s&&window.UserLeap("track",r),!1)}),t=n=>e.forEach(r=>r(n));window.UserLeap._config.interactiveEventsHandler=t,window.addEventListener("click",t,Qi)},Xi=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,Qi),delete window.UserLeap._config.interactiveEventsHandler};function Jl(){["hashchange","popstate"].forEach(e=>window.addEventListener(e,Ct,!0))}function Ql(){["hashchange","popstate"].forEach(e=>window.removeEventListener(e,Ct,!0)),window.UserLeap._config.interactiveEvents&&Xi()}function Xl(e){const t=new URL(ve("1",[_e],"questions"));return Object.entries(e||{}).forEach(([n,r])=>{r&&t.searchParams.append(n,String(r))}),t.toString()}function Ke(e){const t=Se.getItem("userleap.ids");if(t)try{const n=JSON.parse(t)[window.UserLeap.envId];return n&&n[e]||null}catch(n){n instanceof Error&&(n.stack=t,window.UserLeap.reportError("Failed to parse local storage credentials",n)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",n)}return null}function eo(){window.previewMode||(window.UserLeap.visitorId=Ge(),b(`Generating new vid: ${window.UserLeap.visitorId}`),ge("vid",window.UserLeap.visitorId),A.emit(k.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}))}function to(e,t,n,r){var i,o;try{if(e.endsWith("mock_snippet.html"))return;b(`Tracking page view: ${e}`);const s=window.UserLeap._config.pageUrlEvents;let l=!1;if(s&&s.length)for(let c=0;c<s.length&&(l=$t(s[c],e),!l);c++);if(!l)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",e);const a={url:e};r&&(a.trackPageView=!0),window.UserLeap._queue.push(["track",Ji,t,a,n]);const d=(i=document?.querySelector('meta[name="description"]'))==null?void 0:i.getAttribute("content");(o=J.replay)==null||o.RecordPageView({...d&&{description:d},url:e,referrer:document.referrer,pageTitle:document.title})}catch(s){s instanceof Error&&(s.stack=e,window.UserLeap.reportError("trackPageView",s)),console.warn("[Sprig] (ERR-428) Failed to track page view",s)}}function ed(){const e="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in e&&(e.pushState=(t=>function(...n){const r=t.apply(this,n),i=new Event("pushState");return window.dispatchEvent(i),Ct(i),r})(e.pushState)),"replaceState"in e&&(e.replaceState=(t=>function(...n){const r=t.apply(this,n),i=new Event("replaceState");return window.dispatchEvent(i),Ct(i),r})(e.replaceState)),Jl()}async function jn(e,t){const n=Tn();e&&!t&&(window.UserLeap._config.mode=Zl.test);const r=je(window.UserLeap),i=Dn(r),o=await Ce(Xl({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:i,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:e?.surveyId,surveytemplateid:e?.surveyTemplateId,vid:n}),{shouldDropOnRateLimit:!0});if(!o.ok)return o.reportError&&o.error&&(console.warn("[Sprig] (ERR-414) Failed to request questions from the server",o.error),window.UserLeap.reportError("getQuestions",o.error)),{success:!1,surveyState:"no survey"};if(o.json.delay&&await jt(o.json.delay),o.json.isFeedback){const{feedbackLabel:s,productConfig:l,surveyUuid:a,feedbackCustomStyles:d}=o.json,{buttonTheme:c,placement:h,desktopDisplay:g}=l,u={customStyles:d,buttonTheme:c,desktopDisplay:g,eventId:0,feedbackLabel:s,placement:h,surveyUuid:a,surveyId:e?.surveyId};Vi(u,o.json)}else return mt(o.json)}function td(e){let t=e.length;for(;t;){const n=Math.floor(Math.random()*t);t-=1;const r=e[t];e[t]=e[n],e[n]=r}}function nd(e){if(!e)return;window.UserLeap._config=e,e.mute&&window.UserLeap._queue.pause();const{interactiveEvents:t,pageUrlEvents:n,dismissOnPageChange:r}=e;t&&td(t),(t||n||r)&&(ed(),Ct())}async function rd(e,t){var n,r;let i=!0;return t&&(n=e?.json)!=null&&n.surveyId&&(window.UserLeap.delayingSurvey=!0,i=await t(e.json.surveyId),window.UserLeap.delayingSurvey=!1,!i)?!1:((r=e?.json)!=null&&r.delay&&!window.UserLeap.isMobileSDK&&(window.UserLeap.delayingSurvey=!0,await jt(e.json.delay),window.UserLeap.delayingSurvey=!1),i)}const id=function(e){if(!window.UserLeap)return;const t=async(i={})=>{var o,s,l,a,d;const{userId:c,anonymousId:h,metadata:g={},properties:u,showSurveyCallback:p}=i;let{eventName:m}=i;if(window.UserLeap.debugMode&&m!==Ji&&console.info("[DEBUG] Sprig track",i),e.mode==="test")return;const w=Se.getItem("sprig.previewKey")??void 0;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!c){const E="[Sprig] - Skipping tracking without userId";return console.warn(E),{success:!1,message:E,surveyState:"no survey"}}if(!m||m.trim().length===0){m=m?String(m):"";const E="[Sprig] - Invalid event name "+m;return console.warn(E),{success:!1,message:E,surveyState:"no survey"}}const I=window.location.href;if(g.url||(g.url=I),ge("trackStartUrl",I),(s=(o=window.UserLeap)==null?void 0:o._config)!=null&&s.optimizelyEnabled){const E=je(window.UserLeap);xn(E)||Qt.getAndSetWebOptimizelyExperiments(),g.optimizelyExperiments=Object.assign({},Qt.getAllOptimizelyExperiments())}(a=(l=window.UserLeap)==null?void 0:l._config)!=null&&a.launchDarklyEnabled&&(g.launchDarklyFlags=Bn.getAllLaunchDarklyVariations()),c&&(window.UserLeap.userId=c),h&&(window.UserLeap.partnerAnonymousId=h),u&&(g.eventProperties=u),(d=J.replay)==null||d.RecordEvent({name:m,url:g.url}),b(`Tracking event: ${m}`);const y=window.UserLeap.delayingSurvey||Fi()?await Ce(ve("1",[Oe],"events/batch"),{body:JSON.stringify({events:[{event:m,metadata:g}],previewKey:w}),method:"POST",shouldDropOnRateLimit:!0}):await Ce(ve("1",[Oe],"events"),{body:JSON.stringify({event:m,metadata:g,previewKey:w}),method:"POST",shouldDropOnRateLimit:!0});if(!y.ok){const E="[Sprig] (ERR-421) Failed to track event";return y.reportError&&(console.warn(E,y.error),y.error&&window.UserLeap.reportError("track",y.error)),{success:!1,message:E,error:y.error,surveyState:"no survey"}}c&&ge("uid",c),h&&ge("aid",h);const f=y.json;f.invalidPreviewKey&&Se.removeItem("sprig.previewKey");const v=g.trackPageView?g.url:void 0;return f!=null&&f.feedbackButton&&Vi(f.feedbackButton,void 0,v),await rd(y,p)?$l(f.eventId,I)?mt(f,v):{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"}},n=(i,o)=>{var s;const l=(s=i?.querySelector(`[id="${Mn}"]`))==null?void 0:s.contentDocument;l&&yt({document:l,elementId:"ul-custom-style",styleString:o})},r={async displaySurvey(i){return console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),window.UserLeap("dismissActiveSurvey",Ue.Override),jn({surveyId:i},!0)},_previewSurvey(i){window.UserLeap("dismissActiveSurvey",Ue.Override),jn({surveyTemplateId:i},!1)},_reviewSurvey(i){window.UserLeap("dismissActiveSurvey",Ue.Override),jn({surveyId:i},!1)},previewSurvey(i){r._previewSurvey(i)},reviewSurvey(i){r._reviewSurvey(i)},mute(){window.UserLeap._queue.pause()},unmute(){window.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(i=Ue.API){A.emit(k.SurveyWillClose,{name:k.SurveyWillClose,initiator:i})},async setAttribute(i,o){if(!i||!o&&o!==0&&o!==!1){const s="[Sprig] - Disregarding empty attribute / value provided";return console.warn(s),{success:!1,message:s}}return this.setAttributes({[i]:o})},async setAttributes(i){if(i==null||Object.keys(i).length===0){const o="[Sprig] - Disregarding empty attributes provided";return console.warn(o),{success:!1,message:o}}return this.identifyAndSetAttributes({attributes:i})},async identifyAndSetAttributes(i){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",i),e.mode==="test")return;if(i===null||typeof i!="object"||!(i.userId||i.anonymousId||i.attributes)){const c="[Sprig] - Disregarding empty payload provided";return console.warn(c),{success:!1,message:c}}const{userId:o,anonymousId:s,attributes:l}=i;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!o){const c="[Sprig] - Skipping tracking without userId";return console.warn(c),{success:!1,message:c}}if(!l&&(!o||window.UserLeap.userId===o)&&(!s||window.UserLeap.partnerAnonymousId===s))return{success:!0};const a={};o&&(a.userId=window.UserLeap.userId=o),s&&(a.partnerAnonymousId=window.UserLeap.partnerAnonymousId=s);let d;return l?(l.email&&!Object.prototype.hasOwnProperty.call(l,St)&&(l[St]=l.email,delete l.email),b(`Setting attributes: ${JSON.stringify(l)}`),d=await Ce(ve("1",[_e,Oe],"attributes"),{body:JSON.stringify(l),method:"PUT"}),!d.ok&&d.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",d.error),d.error&&window.UserLeap.reportError("identifyAndSetAttributes",d.error))):d=await Ce(ve("1",[_e,Oe]),{body:JSON.stringify(a),method:"PUT"}),l&&l[St]&&(window.UserLeap.email=l[St]),d.ok&&(o&&ge("uid",o),s&&ge("aid",s)),{success:!!d.ok}},async removeAttributes(i){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",i),e.mode==="test")return;if(i==null||i.length===0){const s="[Sprig] - Disregarding empty attributes provided";return console.warn(s),{success:!1,message:s}}if(e.requireUserIdForTracking&&!window.UserLeap.userId){const s="[Sprig] - Skipping tracking without userId";return console.warn(s),{success:!1,message:s}}const o=await Ce(ve("1",[_e,Oe],"attributes"),{body:JSON.stringify({delete:i}),method:"DELETE"});return!o.ok&&o.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",o.error),o.error&&window.UserLeap.reportError("removeAttributes",o.error)),{success:!!o.ok}},async addSurveyListener(i){A.on(k.SurveyLifeCycle,i)},async removeSurveyListener(i){A.removeListener(k.SurveyLifeCycle,i)},async addListener(i,o){A.on(i,o)},async removeListener(i,o){A.removeListener(i,o)},async removeAllListeners(){A.removeAllListeners()},setPreviewKey(i){!i||typeof i!="string"||Se.isStorageAvailable&&i&&Se.setItem("sprig.previewKey",i)},async setUserId(i){var o;if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",i),i==null){const a=`[Sprig] - Invalid userId ${i}`;return console.warn(a),{success:!1,message:a}}if(e.mode==="test"||i===window.UserLeap.userId)return;window.UserLeap.userId=i;const s=window.UserLeap.visitorId,l=await Ce(ve("1",[_e,Oe]),{body:JSON.stringify({userId:i}),method:"PUT"});if(!l.ok){l.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",l.error),l.error&&window.UserLeap.reportError("setUserId",l.error));return}s!==window.UserLeap.visitorId&&((o=J.replay)==null||o.clearUserReplayData()),ge("uid",i)},async setPartnerAnonymousId(i){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",i),i==null){const o=`[Sprig] - Invalid partnerAnonymousId ${i}`;return console.warn(o),{success:!1,message:o}}return window.UserLeap.partnerAnonymousId=i,ge("aid",i),{success:!0}},async track(i,o,s={},l=void 0){return t({eventName:i,properties:o,metadata:s,showSurveyCallback:l})},async identifyAndTrack(i){return await t(i)},trackPageView(i,o=void 0,s=void 0,l=!0){to(i,o,s,l)},applyFeedbackStyles({button:i="",view:o=""}){window.UserLeap.feedbackCustomStyles=o,document.getElementById("sprig-feedback-style")&&yt({document,elementId:"ul-custom-style",styleString:i,nonce:window.UserLeap.styleNonce}),n(document.querySelector(".ul-container-feedback"),o)},applyStyles(i){window.UserLeap.customStyles=i,n(window.UserLeap.container,i)},setWindowDimensions(i,o){var s,l;const a=typeof i=="string"?parseInt(i,10):i,d=typeof o=="string"?parseInt(o,10):o;if(!isNaN(a)&&!isNaN(d)&&(window.UserLeap.windowDimensions={width:a,height:d}),!window.UserLeap.frameId)return;const c=document.getElementById(window.UserLeap.frameId);c&&(window.UserLeap.useMobileStyling&&((s=window.UserLeap.windowDimensions)!=null&&s.width&&(c.style.width=`${window.UserLeap.windowDimensions.width}px`),(l=window.UserLeap.windowDimensions)!=null&&l.height&&(c.style.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`),c.contentDocument&&(c.style.height=String(_i(c.contentDocument)[0])+"px")),A.emit(k.SurveyDimensions,{name:k.SurveyDimensions,contentFrameWidth:c.clientWidth,contentFrameHeight:c.clientHeight}))},logoutUser(){var i;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),b(`Logging out user: ${window.UserLeap.userId} / vid: ${window.UserLeap.visitorId}`),window.UserLeap.visitorId=null,window.UserLeap.userId=null,window.UserLeap.partnerAnonymousId=null,window.UserLeap.token=null,window.UserLeap.email=null,Se.removeItem("userleap.ids"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),eo(),(i=J.replay)==null||i.clearUserReplayData(),window.UserLeap._queue.unpause()},teardown(){Ql(),window.UserLeap("dismissActiveSurvey",Ue.API),delete window.UserLeap,delete window.Sprig,delete window._Sprig},integrateOptimizely(i,o=!0){var s,l;if(!((l=(s=window.UserLeap)==null?void 0:s._config)!=null&&l.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}try{const a=typeof i=="string"?JSON.parse(i):i;Qt.setOptimizelyExperiment(a,o)}catch(a){console.warn("[Sprig] Error with integrating Optimizely data"),a instanceof Error&&window.UserLeap.reportError("integrateOptimizely",a)}},integrateOptimizelyClient(i){var o,s;if(!((s=(o=window.UserLeap)==null?void 0:o._config)!=null&&s.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}const l=({experiment:a,variation:d})=>{const c={experiments:[{id:a.id,variation:d.key}]};window.UserLeap("integrateOptimizely",c,!1)};i.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",l)},importLaunchDarklyData(i){var o,s;if(!((s=(o=window.UserLeap)==null?void 0:o._config)!=null&&s.launchDarklyEnabled)){console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.");return}Bn.setLDFlagsVariations(i)},setVisitorAttribute(i,o){return console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),r.setAttribute(i,o)},async setEmail(i){return r.setAttribute(St,i)},async setVisitorEmail(i){return console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),r.setEmail(i)},async _generateVideoUploadUrl(i){return ld(i)},_reportMetric(i,o){ji(i,o)},async _completeSessionReplay({surveyId:i,responseGroupUuid:o,eventDigest:s}){var l;return J.replay?(l=J.replay)==null?void 0:l._completeSessionReplay({surveyId:i,responseGroupUuid:o,eventDigest:s,headers:je(window.UserLeap)}):(window.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)}};Object.assign(window.UserLeap,r)};async function od(e){const t=je(window.UserLeap);document.addEventListener("securitypolicyviolation",Ci);const n=await Te(ve("1",[_e],"config"),{headers:t});if(document.removeEventListener("securitypolicyviolation",Ci),!n.ok)return n.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",n.error),n.error&&window.UserLeap.reportError("applyRemoteConfig",n.error)),Ln("Disabled: failed to fetch configuration"),e;const r=n.json;return r!=null&&r.disabled?(Ln(`Disabled: ${r.disabled}`),{disabled:r.disabled}):Object.assign({},r,e)}const sd=e=>typeof e=="object"&&e&&"inner"in e&&!!e.inner&&typeof e.inner=="object";async function ad(e,t,n={},r={}){var i,o;const s=window.__cfg&&window.__cfg.mode,l=Tn(),a=window.UserLeap.envId,d=window.document.documentElement,c=sd(t)?{inner:{message:(i=t.inner)==null?void 0:i.message,stack:(o=t.inner)==null?void 0:o.stack}}:{},h={mode:s,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:d.clientWidth,clientHeight:d.clientHeight,location:window.location.href,language:window.navigator.language,...n,...c},g={action:e,err:{message:t.message,stack:t.stack},meta:h,vid:l,envId:a,...r},u=await Ce(ve("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(g),shouldDropOnRateLimit:!0});if(!u.ok)console.warn("[Sprig] (ERR-444) Failed to report error to API",t);else{const{presignedUrl:p}=u.json;Ei(p)}}async function ld(e){var t;if(!e)return;const n=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const r=await fetch(n,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.ok){const i=await r.json();return(t=i?.upload)==null?void 0:t.url}else return null}catch(r){console.warn("[Sprig] Error with generating video upload url"),r instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",r)}}function dd(e={}){const t=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";window.UserLeap.UPDATES=ht,window.UserLeap("setPreviewKey",t);async function n(){var r;if(window.UserLeap.loaded)return;if(b("Loading sprig on page load"),window.UserLeap.reportError=ad,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 a in window.UserLeap._config)window.UserLeap[a]=window.UserLeap._config[a];if(!window.UserLeap.envId)if(window.UserLeap.appId)window.UserLeap.envId=window.UserLeap.appId;else throw new Error("Missing Environment id");window.UserLeap.debugMode&&console.info("[DEBUG] Sprig debug mode enabled");const i=window.UserLeap.sampleRate;if(i){let a=Ke("sampled");if(a===null&&(a=Math.random()<i,ge("sampled",a)),!a)return}else Ke("sampled")!==null&&ge("sampled",null);window.UserLeap._API_URL||(window.UserLeap._API_URL="https://api.sprig.com");const o=[...window.UserLeap._queue];window.UserLeap._queue=new Tl(window.UserLeap,[]),window.UserLeap._queue.pause();for(let a=0;a<o.length;a++)window.UserLeap._queue.push(o[a]);const s=Ke("token");s?(window.UserLeap.token=s,window.UserLeap.visitorId=Ke("vid"),window.UserLeap.userId=Ke("uid"),window.UserLeap.partnerAnonymousId=Ke("aid")):(Se.removeItem("userleap.ids"),eo());const l=await od(e);Kl({webMetricsEnabled:l.metricsReportingEnabled,reportingIntervalSeconds:l.metricsReportingEnabled||l.mobileMetricsReportingEnabled?l.metricsReportingIntervalSeconds:0,thresholds:l.metricThresholds,postMetrics:async a=>{var d;await Ce(ve("1",[_e],"metrics"),{body:a,method:"POST",headers:{"x-ul-replay-enabled":`${!!((d=J.replay)!=null&&d.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),(r=J.replay)==null||r.initializeReplay({viewDocument:window.document,maxReplayDurationSeconds:l.maxReplayDurationSeconds,replayNonce:window.UserLeap.replayNonce,maxInflightRequests:window.UserLeap.maxInflightReplayRequests??2,replaySettings:l.replaySettings}),ll(l.logBufferLimit,l.logLevel),id(l),await nd(l),window.UserLeap._queue.unpause(),A.emit(k.SDKReady,{mobileMetricsReportingEnabled:!!l.mobileMetricsReportingEnabled,metricsReportingInterval:l.metricsReportingIntervalSeconds||0,metricsThresholds:l.metricThresholds||[],maxMobileReplayDurationSeconds:l.maxMobileReplayDurationSeconds,mobileReplaySettings:l.mobileReplaySettings}),A.emit(k.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}document.readyState==="complete"?n():window.attachEvent?window.attachEvent("onload",n):window.addEventListener("load",()=>{n()},!1)}class Hn{constructor(){ee(this,"UPDATES",ht)}displaySurvey(t){window.Sprig("displaySurvey",t)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(t,n){window.Sprig("setAttribute",t,n)}setAttributes(t){window.Sprig("setAttributes",t)}identifyAndSetAttributes(t){window.Sprig("identifyAndSetAttributes",t)}removeAttributes(t){window.Sprig("removeAttributes",t)}addListener(t,n){window.Sprig("addListener",t,n)}removeListener(t,n){window.Sprig("removeListener",t,n)}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,n={},r={}){window.Sprig("track",t,n,r)}identifyAndTrack(t){window.Sprig("identifyAndTrack",t)}trackPageView(t,n,r){window.Sprig("trackPageView",t,n,r)}applyStyles(t){window.Sprig("applyStyles",t)}setWindowDimensions(t,n){window.Sprig("setWindowDimensions",t,n)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}}const no={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(Hn.prototype).map(n=>{n!=="constructor"&&(window.Sprig[n]=Hn.prototype[n])});const t=window.Sprig;return t.appId=e.envId,t._queue=[],window.UserLeap=t,dd(e),window.Sprig}};no.configure;class cd{constructor(t){ee(this,"awaitingResolvers",[]),ee(this,"activeCount",0),this.capacity=t}async acquire(){if(this.activeCount<this.capacity){this.activeCount++;return}return new Promise(t=>{this.awaitingResolvers.push(t)})}release(){const t=this.awaitingResolvers.shift();t&&this.activeCount<=this.capacity?t():this.activeCount--}async execute(t){try{return await this.acquire(),await t()}finally{this.release()}}setLimit(t){this.capacity=t}}const ro=new cd(2),ud=e=>ro.setLimit(e),pd=async e=>ro.execute(async()=>{var t;b(`Beginning upload of chunk ${e.chunkIndex} for survey: ${e.surveyId}`);const n=await Te(e.uploadUrl,{body:e.data,method:"PUT"});b(`Completed upload of chunk ${e.chunkIndex} for survey: ${e.surveyId}`);const r=(t=n.headers)==null?void 0:t.get("ETag");if(!r)throw new Error(`Upload response did not include etag for upload ${e.uploadId}, part ${e.chunkIndex}`);return r}),io=async({apiUrl:e,surveyId:t,uploadId:n,etags:r,headers:i,responseGroupUuid:o,replayDuration:s,eventDigest:l},a=!1)=>{var d;if(!a&&!n&&!r){b(`Cannot mark upload complete: isMobile: ${a} / uploadId: ${n} / etags: ${r}`);return}b(`Marking upload complete for survey: ${t}`);const c=await Te(`${e}/sdk/1/completeSessionReplay`,{method:"POST",body:JSON.stringify({etags:r,uploadId:n,responseGroupUuid:o,surveyId:t,replayDuration:s,eventDigest:l,userAgent:(d=window?.navigator)==null?void 0:d.userAgent}),headers:i,shouldRetryRequest:!0});return b(`Done marking upload complete for survey: ${t}`),c},Kn=(e,t)=>t.some(n=>e instanceof n);let oo,so;function hd(){return oo||(oo=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function gd(){return so||(so=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Zn=new WeakMap,qn=new WeakMap,on=new WeakMap;function md(e){const t=new Promise((n,r)=>{const i=()=>{n(Ne(e.result))},o=()=>{r(e.error)};e.onsuccess=i,e.onerror=o});return on.set(t,e),t}function yd(e){if(Zn.has(e))return;const t=new Promise((n,r)=>{const i=()=>{n()},o=()=>{r(e.error||new DOMException("AbortError","AbortError"))};e.oncomplete=i,e.onerror=o,e.onabort=o});Zn.set(e,t)}let $n={get(e,t,n){if(e instanceof IDBTransaction){if(t==="done")return Zn.get(e);if(t==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Ne(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function ao(e){$n=e($n)}function fd(e){return gd().includes(e)?function(...t){return e.apply(Yn(this),t),Ne(this.request)}:function(...t){return Ne(e.apply(Yn(this),t))}}function wd(e){return typeof e=="function"?fd(e):(e instanceof IDBTransaction&&yd(e),Kn(e,hd())?new Proxy(e,$n):e)}function Ne(e){if(e instanceof IDBRequest)return md(e);if(qn.has(e))return qn.get(e);const t=wd(e);return t!==e&&(qn.set(e,t),on.set(t,e)),t}const Yn=e=>on.get(e);function vd(e,t,{blocked:n,upgrade:r,blocking:i,terminated:o}={}){const s=indexedDB.open(e,t),l=Ne(s);return r&&(s.onupgradeneeded=a=>{r(Ne(s.result),a.oldVersion,a.newVersion,Ne(s.transaction),a)}),n&&(s.onblocked=a=>n(a.oldVersion,a.newVersion,a)),l.then(a=>{o&&(a.onclose=()=>o()),i&&(a.onversionchange=d=>i(d.oldVersion,d.newVersion,d))}).catch(()=>{}),l}function lo(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&(n.onblocked=r=>t(r.oldVersion,r)),Ne(n).then(()=>{})}const Id=["get","getKey","getAll","getAllKeys","count"],bd=["put","add","delete","clear"],Jn=new Map;function co(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(Jn.get(t))return Jn.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=bd.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||Id.includes(n)))return;const o=async function(s,...l){const a=this.transaction(s,i?"readwrite":"readonly");let d=a.store;return r&&(d=d.index(l.shift())),(await Promise.all([d[n](...l),i&&a.done]))[0]};return Jn.set(t,o),o}ao(e=>({...e,get:(t,n,r)=>co(t,n)||e.get(t,n,r),has:(t,n)=>!!co(t,n)||e.has(t,n)}));const Sd=["continue","continuePrimaryKey","advance"],uo={},Qn=new WeakMap,po=new WeakMap,Cd={get(e,t){if(!Sd.includes(t))return e[t];let n=uo[t];return n||(n=uo[t]=function(...r){Qn.set(this,po.get(this)[t](...r))}),n}};async function*kd(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;const n=new Proxy(t,Cd);for(po.set(n,t),on.set(n,Yn(t));t;)yield n,t=await(Qn.get(n)||t.continue()),Qn.delete(n)}function ho(e,t){return t===Symbol.asyncIterator&&Kn(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&Kn(e,[IDBIndex,IDBObjectStore])}ao(e=>({...e,get(t,n,r){return ho(t,n)?kd:e.get(t,n,r)},has(t,n){return ho(t,n)||e.has(t,n)}}));const Ad=e=>{if(e instanceof Attr)return null;let t=1;for(let n=e.previousSibling;n;n=n.previousSibling)n.nodeName===e.nodeName&&++t;return t},go=e=>{if(e===null)return"";const t=[];if(e instanceof Document)return"/";for(let n=e;n&&!(n instanceof Document)&&n!==null;n=n instanceof Attr?n.ownerElement:n.parentElement){const r=t[t.length]={name:void 0,position:null};switch(n.nodeType){case Node.TEXT_NODE:r.name="text()";break;case Node.ATTRIBUTE_NODE:r.name="@"+n.nodeName;break;case Node.PROCESSING_INSTRUCTION_NODE:r.name="processing-instruction()";break;case Node.COMMENT_NODE:r.name="comment()";break;case Node.ELEMENT_NODE:r.name=n.nodeName;break}r.position=Ad(n)}return"/"+t.reverse().map(n=>n.position!==null?`/${n.name}[${n.position}]`:`/${n.name}`).join("")},Fe={capture:!0,passive:!0},Ed=["a","button","input","option","li","link"],Ld=["Escape","Enter","Backspace","F5","Tab"];let sn=!1;const Rd=["label","type","role","title","placeholder","errormessage","valuetext","href"],mo="aria-",Ud=e=>{if(!e.tagName)return"No tagName";const t=e.getAttribute("type");return t?`${t} ${e.tagName.toLowerCase()}`:e.tagName.toLowerCase()},yo=e=>{var t;if(((t=e.tagName)==null?void 0:t.toLowerCase())==="html")return{element:"html"};const n=e.textContent,r=n?{text:n}:{};r.element=Ud(e);for(const i of e.attributes){let o=i.name;const s=i.value;o.startsWith(mo)&&(o=o.substring(mo.length)),Rd.includes(o)&&(r[o]=s)}return r},Td=e=>{var t;if(!e)return{};const n={...yo(e)},r=e.parentElement;if(r&&Ed.includes((t=r.tagName)==null?void 0:t.toLowerCase())){const i=yo(r);Object.assign(n,i)}return n},fo=(e,t)=>{var n;jd({x:t.x,y:t.y,type:e,elementAttributes:Td(t.target),windowHeight:window.innerHeight,windowWidth:window.innerWidth,...t.target instanceof HTMLElement?{rect:(n=t.target)==null?void 0:n.getBoundingClientRect(),xPath:go(t.target)}:{}})},Dd=e=>t=>fo(e,t),wo=e=>{Ld.includes(e.key)&&Yd({key:e.key})},xd=()=>{window.performance.getEntriesByType("navigation").map(e=>e.type).includes("reload")&&qd({url:window.location.href,currentPageTitle:document.title})},Md=()=>{window.performance.getEntriesByType("navigation").map(e=>e.type).includes("back_forward")&&$d({curUrl:window.location.href,fromUrl:document.referrer,currentPageTitle:document.title})},Od=(e,t)=>{let n;return r=>{clearTimeout(n),n=window.setTimeout(()=>e(r),t)}},_d=e=>{if(!(e.target instanceof HTMLElement||e.target instanceof Document))return;let t=e.target;"scrollTop"in t||(t=t.documentElement),Jd({xPath:go(t),x:t.scrollLeft,y:t.scrollTop,elementAttributes:{targetScrollWidth:t.scrollWidth,targetClientWidth:t.clientWidth,targetScrollHeight:t.scrollHeight,targetClientHeight:t.clientHeight}})},vo=Od(_d,750),Io=Dd("left_click"),bo=e=>{e.button===2&&fo("right_click",e)},Nd=()=>{sn||(window.addEventListener("click",Io,Fe),window.addEventListener("mousedown",bo,Fe),window.addEventListener("keydown",wo,Fe),window.addEventListener("scroll",vo,Fe),sn=!0,xd(),Md())},Fd=()=>{sn&&(window.removeEventListener("click",Io,Fe),window.removeEventListener("mousedown",bo,Fe),window.removeEventListener("keydown",wo,Fe),window.removeEventListener("scroll",vo,Fe),sn=!1)},Pd=3e4;let kt=0;const H={isRecording:!1,scrollEventUuids:{},stopRecording:()=>{}},Bd=()=>{const e=ne.getItem("sprig.sessionId");if(e)return b(`Found saved session id: ${e}`),ne.removeItem("sprig.sessionId"),e;const t=Ge();return b(`Generating new uuid: ${t}`),t},de=Bd(),Wd=async e=>{var t;if((t=window.navigator.storage)!=null&&t.estimate){const{quota:n=0,usage:r=0}=await window.navigator.storage.estimate();return(n-r)/1024**3>=e}return!0},So=()=>{ne.setItem("sprig.disableReplayRecording","disabled")},Ze=()=>!!ne.getItem("sprig.disableReplayRecording");window.addEventListener("beforeunload",()=>{b(`Before page unload saving session id: ${de}`),ne.setItem("sprig.sessionId",de)});const zd=async()=>{const e=(await z.getPendingCaptures({isHeatmap:!0})).map(n=>({eventId:n.captureParams.eventId,uuid:n.uuid})),t=[];e.forEach(({eventId:n,uuid:r})=>{Mi(n)||t.push(r)}),t.length&&me(()=>z.markPendingHeatmapsReady(t),"Error marking pending heatmaps ready")},Vd=e=>{if(e>1){kt=0;return}const t=Date.now();if(!kt){kt=t;return}t-kt>=Pd&&(kt=0,me(()=>z.markPendingHeatmapsReady(),"Error marking pending heatmaps ready"))},Xn=e=>e&&e.trim().substring(0,500).replace(/\s\s+/g," ").replace(/\r?\n|\r/g," ").substring(0,250),Ie=(e,t)=>{var n,r;if(H.isRecording)try{(r=(n=window.rrwebRecord)==null?void 0:n.addCustomEvent)==null||r.call(n,e,t)}catch(i){an("Error recording custom event",i)}},Gd=e=>{e.description&&(e.description=Xn(e.description)),Ie("Sprig_PageView",e)},jd=e=>{var t;(t=e?.elementAttributes)!=null&&t.text&&(e.elementAttributes.text=Xn(e.elementAttributes.text)),Ie("Sprig_Click",e)},Hd=e=>{Ie("Sprig_TrackEvent",e)},Kd=e=>{Ie("Sprig_ShowSurvey",e)},Zd=e=>{Ie("Sprig_SubmitSurvey",e)},qd=e=>{Ie("Sprig_Refresh",e)},$d=e=>{e.currentPageTitle&&(e.currentPageTitle=Xn(e.currentPageTitle)),Ie("Sprig_BackForward",e)},Yd=e=>{Ie("Sprig_Keystroke",e)},Jd=async e=>{const{x:t,xPath:n,y:r}=e,i=H.scrollEventUuids[n];if(i)return me(async()=>{var o,s,l,a;const d=await z.openDB(),c=await d.get("events",i);if(c!=null&&c.event){const h=JSON.parse(c.event),g=t>((s=(o=h.data)==null?void 0:o.payload)==null?void 0:s.x),u=r>((a=(l=h.data)==null?void 0:l.payload)==null?void 0:a.y);if(!(g||u))return null;g&&(h.data.payload.x=t),u&&(h.data.payload.y=r),h.data.payload.elementAttributes=e.elementAttributes,c.event=JSON.stringify(h),await d.put("events",c)}else Ie("Sprig_Scroll",e)},"Error updating scroll event");Ie("Sprig_Scroll",e)},Qd=()=>H.isRecording,Co=()=>{H.stopRecording&&(H.stopRecording(),H.stopRecording=void 0),H.isRecording=!1,["cleanupInterval","noopInterval","pendingCheckInterval"].forEach(e=>{H[e]&&(clearInterval(H[e]),H[e]=void 0)}),Fd()},Xd=["did not allow mutations","called in an invalid security context"],ec=e=>{if(!e)return!0;for(const t of Xd)if(e.toLowerCase().includes(t))return!1;return!0},tc=(e,t,{reportError:n=!0,extraInfo:r})=>{Ze()||t instanceof Error&&(So(),ec(t?.message)&&(n&&window.UserLeap.reportError(e,t,r),z.clearAll()))},nc=async(e,t,{reportError:n}={reportError:!0})=>{var r;let i;try{if(n&&(r=window.navigator.storage)!=null&&r.estimate){const{quota:o=0,usage:s=0}=await window.navigator.storage.estimate();i={availableSpaceInMB:(o-s)/2**20,quota:o,usage:s}}}catch(o){window.UserLeap.reportError("Error getting storage estimate",o,{originalMessage:e,originalError:t})}tc(e,t,{reportError:n,extraInfo:i})},an=(e,t,{reportError:n}={reportError:!0})=>(Co(),Ai(`${e} - ${JSON.stringify(t)}`),nc(e,t,{reportError:n})),me=async(e,t)=>{try{await e()}catch(n){an(t,n)}},rc=()=>{H.isRecording&&me(()=>{var e,t;return(t=(e=window.rrwebRecord)==null?void 0:e.takeFullSnapshot)==null?void 0:t.call(e,!0)},"Error recording full snapshot")},ic=async({surveyId:e,responseGroupUuid:t,eventDigest:n,headers:r})=>{if(!e||!t)return!1;const i=window.UserLeap._API_URL,o=await io({surveyId:e,responseGroupUuid:t,eventDigest:n,apiUrl:i,headers:r},!0);return!(o!=null&&o.error)},ko=30,oc=1;lo("replayStorage").catch(console.error),lo("sprig.replay").catch(console.error);class sc{openDB(){return vd("sprigReplay",oc,{upgrade:(t,n,r)=>{if(r===0&&ne.setItem("sprig.pendingCount","0"),!t.objectStoreNames.contains("events")){const i=t.createObjectStore("events",{keyPath:"uuid"});i.createIndex("sessionId","sessionId"),i.createIndex("timestamp","timestamp"),i.createIndex("[sessionId+timestamp]",["sessionId","timestamp"])}if(!t.objectStoreNames.contains("chunkUploads")){const i=t.createObjectStore("chunkUploads",{keyPath:"uuid"});i.createIndex("sessionId","sessionId"),i.createIndex("timestamp","timestamp"),i.createIndex("[sessionId+status]",["sessionId","status"]),i.createIndex("[uploadId+status]",["uploadId","status"]),i.createIndex("[sessionId+status+uploadId]",["sessionId","status","uploadId"])}if(!t.objectStoreNames.contains("pendingCaptures")){const i=t.createObjectStore("pendingCaptures",{keyPath:"uuid"});i.createIndex("sessionId","sessionId"),i.createIndex("timestamp","timestamp"),i.createIndex("[sessionId+targetTimestamp]",["sessionId","targetTimestamp"])}}}).catch(t=>(Ai(`Error opening replay storage: ${t.message}`),So(),Promise.reject(t)))}constructor(){this.openDB()}async bulkAdd(t,n){const r=(await this.openDB()).transaction(t,"readwrite");return Promise.all([...n.map(i=>r.store.add(i)),r.done])}async clearAll(){const t=(await this.openDB()).transaction(["events","chunkUploads","pendingCaptures"],"readwrite");return Promise.all([t.objectStore("events").clear(),t.objectStore("chunkUploads").clear(),t.objectStore("pendingCaptures").clear()])}async deleteBySessionId(t,n){const r=IDBKeyRange.only(n),i=(await this.openDB()).transaction(t,"readwrite");let o=await i.store.index("sessionId").openCursor(r);for(;o;)o.delete(),o=await o.continue();await i.done}async updatePartial(t,n,r){const i=(await this.openDB()).transaction(t,"readwrite"),o=await i.store.get(n);o&&await i.store.put({...o,...r}),await i.done}async deleteRowsBefore(t,n,r=()=>!0){const i=IDBKeyRange.upperBound(n,!0),o=(await this.openDB()).transaction(t,"readwrite");let s=await o.store.index("timestamp").openCursor(i);for(;s;)r(s.value)&&s.delete(),s=await s.continue();await o.done}async getEventsBetween(t,n=Date.now()){if(t>=n)return Promise.resolve([]);const r=IDBKeyRange.bound([de,t],[de,n],!1,!0);return(await this.openDB()).getAllFromIndex("events","[sessionId+timestamp]",r)}async updateEventsExpiredAt(t,n,r=ko){const i=new Date,o=i.setMinutes(i.getMinutes()+(r??ko)),s=(await this.openDB()).transaction("events","readwrite"),l=s.store.index("[sessionId+timestamp]"),a=IDBKeyRange.bound([de,t],[de,n],!1,!0);let d=await l.openCursor(a);for(;d;)d.update({...d.value,expiredAt:o}),d=await d.continue();await s.done}async deleteChunkUploads(t,n){const r=IDBKeyRange.only([n,t]),i=(await this.openDB()).transaction("chunkUploads","readwrite");let o=await i.store.index("[uploadId+status]").openCursor(r);for(;o;)o.delete(),o=await o.continue();await i.done}async getChunkUploadsByStatus({sessionId:t,status:n,uploadId:r}){const i=(await this.openDB()).transaction("chunkUploads","readonly"),o=r?i.store.index("[uploadId+status]"):i.store.index("[sessionId+status]"),s=r?IDBKeyRange.only([r,n]):IDBKeyRange.only([t,n]);return o.getAll(s)}async getPendingCaptures(t={}){return(await(await this.openDB()).getAllFromIndex("pendingCaptures","sessionId",de)).filter(n=>!t.beforePresent||n.targetTimestamp<Date.now()).filter(n=>!t.isHeatmap||(n.captureParams.isHeatmap??!1))}async markPendingCaptureToCanUpload(t){const n=(await this.openDB()).transaction("pendingCaptures","readwrite");let r=await n.store.index("sessionId").openCursor(de);for(;r;){const i=r.value;i.captureParams.responseGroupId===t&&r.update({...i,canUpload:!0}),r=await r.continue()}await n.done}async markPendingHeatmapsReady(t){if(parseInt(ne.getItem("sprig.pendingCount")??"0")===0)return null;const n=Date.now(),r=(await this.openDB()).transaction("pendingCaptures","readwrite");let i=await r.store.index("sessionId").openCursor(de);for(;i;){const o=i.value;o.captureParams.isHeatmap&&(!t||t.includes(o.uuid))&&i.update({...o,targetTimestamp:n,captureParams:{...o.captureParams,triggerTimestamp:n,replayParams:{...o.captureParams.replayParams,replayDurationSeconds:Math.floor((n-o.timestamp)/1e3)}}}),i=await i.continue()}await r.done}}const z=new sc,Ao=async(e,t)=>{const n=performance.now();let r;try{r=await e()}finally{const i=performance.now()-n;let o=bt[t];o||(o=Ae(t)),o.report(i/1e3)}return r},Eo=(e,t)=>{const n=performance.now();try{e()}finally{const r=performance.now()-n;let i=bt[t];i||(i=Ae(t)),i.report(r/1e3)}};let Lo=1,er=5e3,ln=6e4;const Ro=1e3,ac=5,Uo=30,dn=Uo+ac;let To=Date.now(),Pe,tr=!!ne.getItem("sprig.isCapturingHeatmap"),nr=!1,rr=[];const lc=async({viewDocument:e,maxReplayDurationSeconds:t,replayNonce:n,maxInflightRequests:r=2,replaySettings:i,teardownAfter:o=!1})=>{Pe=ne.getItem("sprig.pendingCount"),!H.isRecording&&(o&&ne.setItem("sprig.teardownAfterCapture","true"),await me(async()=>{if(Ze()){b("Not initializing replay because recording is disabled");return}if(!t){b("Not initializing replay because config didn't specify maxReplayDurationSeconds");return}if(i!=null&&i.minAvailableGb&&(Lo=i.minAvailableGb),!await Wd(Lo)){Un("Minimum storage not available");return}b("Initializing replay"),i!=null&&i.minDuration&&(er=i.minDuration),i!=null&&i.batchDuration&&(ln=i.batchDuration),ud(r),yc(),pc(t+dn,30*60,t+dn),hc();const s=window.rrwebRecord;if(!s){Un("Record script failed to set global function");return}let l=!0,a=0;H.stopRecording=s({checkoutEveryNms:Uo*1e3,sampling:{input:"last",scroll:250,media:800},emit:(d,c)=>{if(Ze())return;if(To=Date.now(),c&&d.type===R.Meta)a=performance.now();else if(c&&a&&d.type===R.FullSnapshot){const g=performance.now()-a;ji("sdk_replay_snapshot_seconds",g/1e3)}const h=l||!!c&&d.type===R.Meta;l=!1,dc({uuid:Ge(),event:JSON.stringify(d),isValidStart:h,timestamp:Date.now()})},...i}),H.isRecording=!!H.stopRecording,H.isRecording&&(H.noopInterval||(H.noopInterval=window.setInterval(()=>{Date.now()-To>Ro&&Ie("Sprig_Noop",{})},Ro)),A.on("survey.complete",d=>{Zd({id:d,userAgent:window.navigator.userAgent})}),Nd())},"Error initializing replay"))},dc=e=>{var t,n,r,i;if((t=e.event)!=null&&t.includes("Sprig_Scroll")){const o=(i=(r=(n=JSON.parse(e.event))==null?void 0:n.data)==null?void 0:r.payload)==null?void 0:i.xPath;if(!o)return;H.scrollEventUuids[o]=e.uuid}rr.push(e),nr||uc()},cc=async e=>{const t=e.map(n=>({...n,sessionId:n.sessionId??de}));if(tr&&Vd(t.length),t.length!==0)return me(()=>z.bulkAdd("events",t),"Error storing replay events")},uc=()=>{nr=!0,setTimeout(async()=>{if(Ze())return;const e=rr;rr=[],nr=!1,Eo(async()=>{await cc(e)},"sdk_replay_add_event_batch_seconds")},500)},pc=(e,t,n)=>{H.cleanupInterval=window.setInterval(()=>{const r=Date.now();Ze()||(gt(`Performing periodic replay data cleanup / Event Seconds ${e} / Chunk Seconds ${t} / Pending Capture Seconds ${n}`),Ao(()=>me(async()=>{await Promise.all([z.deleteRowsBefore("events",r-e*1e3,i=>i.expiredAt===void 0||i.expiredAt<r-e*1e3),z.deleteRowsBefore("chunkUploads",r-t*1e3),z.deleteRowsBefore("pendingCaptures",r-n*1e3,i=>!i.canUpload)])},"Error deleting table rows"),"sdk_replay_cleanup_seconds"),b("Cleanup complete"))},3e4)},hc=()=>{H.pendingCheckInterval=window.setInterval(async()=>{me(async()=>{const e=parseInt(Pe??"0");if(e===0)return;const t=await z.getPendingCaptures({beforePresent:!0}),n=await z.openDB();await Promise.all(t.map(async r=>(await n.delete("pendingCaptures",r.uuid),_o(r.captureParams,r.canUpload)))),Pe=(e-t.length).toString(),ne.setItem("sprig.pendingCount",Pe)},"Error initiating pending captures")},5e3)},gc=async(e,t,n,r,i)=>{const o=Math.min(e+i,n),s=`from: ${new Date(e).toLocaleTimeString()} to ${new Date(o).toLocaleTimeString()}`;b(`Getting event batch ${s}`);const l=await Ao(()=>z.getEventsBetween(e,o),"sdk_replay_get_events_between_seconds");if(!(l!=null&&l.length))return b(`No events found ${s}`),{validStartFound:r,events:[]};if(!r){b(`Searching for valid start in ${l.length} events ${s}`);let a=-1;if(l?.forEach((c,h)=>{if(!c.isValidStart)return;const g=c.timestamp<=t;(a<0||g)&&(a=h)}),a<0)return b(`No valid start found in ${l.length} events ${s}`),{validStartFound:r,events:[]};const d=l[a].timestamp;return b(`Found valid start at: ${new Date(d).toLocaleTimeString()} in events ${s}`),{validStartFound:!0,events:l?.slice(a)}}return{validStartFound:r,events:l}},mc=(e,t,n)=>{const r=e.length,i=t*1024*1024,o=Math.ceil(r/n),s=Math.max(i,o);b(`Total file bytes: ${r} / target chunk size: ${s}`);const l=[];let a=0;for(;a<r;)l.push(e.slice(a,a+s)),a+=s;return l},Do=e=>Promise.all(e.map(async t=>{const n=await pd(t);return await z.updatePartial("chunkUploads",t.uuid,{data:null,etag:n,status:"UploadComplete"}),t.uploadId})),xo=async e=>{b(`Marking upload complete if finished: ${e}`);const t=await z.getChunkUploadsByStatus({status:"UploadComplete",uploadId:e});if(!(t!=null&&t.length)){b(`No finished chunks found for upload: ${e}`);return}const n=t.reduce((o,s)=>(o.find(l=>l.chunkIndex===s.chunkIndex)||o.push(s),o),[]);n.sort((o,s)=>o.chunkIndex-s.chunkIndex);const r=n.map(o=>({ETag:o.etag,PartNumber:o.chunkIndex})).filter(o=>o.ETag!==null),i=n[0];await io({apiUrl:i.apiUrl,surveyId:i.surveyId,uploadId:e,responseGroupUuid:i.responseGroupId,etags:r,headers:i.completeUploadHeaders,replayDuration:i.replayDuration}),b(`Cleaning up chunks for ${e}`),await z.deleteChunkUploads("UploadComplete",e),b(`Done cleaning up chunks for ${e}`)},yc=async()=>{me(async()=>{const e=await z.getChunkUploadsByStatus({sessionId:de,status:"ReadyForUpload"});if(!(e!=null&&e.length))return;const t=await Do(e);b(`Finished uploading unfinished chunks for ${t}`),t!=null&&t.length&&await Promise.all(t.map(n=>{if(n)return xo(n)}))},"Error uploading unfinished chunks")},fc=async(e,t)=>{await Do(t),b(`Done uploading chunks for uploads: ${e.join(",")}`),await Promise.all(e.map(n=>xo(n)))},wc=e=>{let t=0;e.forEach(i=>{t+=i.length});const n=new Uint8Array(t);let r=0;return e.forEach(i=>{n.set(i,r),r+=i.length}),n},Mo=async(e,t,n)=>{const r=new TextEncoder;let i=null,o=null,s=null,l=!1,a=!1,[d,c]=[0,0];const h=e-dn*1e3,g=[];let u=[];b(`Getting events between ${new Date(e).toLocaleTimeString()} and ${new Date(t).toLocaleTimeString()}`),b(`Using batch duration: ${ln}ms`);for(let m=h;m<t;m+=ln){if({validStartFound:a,events:u}=await gc(m,e,t,a,ln),!(u!=null&&u.length)){b("No events found");continue}d===0&&(d=u[0].timestamp),c=u[u.length-1].timestamp,b(`Last event time in batch: ${new Date(c).toLocaleTimeString()}`);const w=`${l?",":"["}${u.map(y=>y.event).join(",")}`,I=r.encode(w);n&&o===null&&(gt("Attempting compression"),s=new window.CompressionStream("gzip"),o=s.writable.getWriter()),Eo(()=>{n&&o?o.write(I):g.push(I)},"sdk_replay_compression_seconds"),l=!0}if(c-d<er)return b(`Replay duration is shorter than minimum of ${er}ms / Start:${d} / End:${c}`),null;const p=r.encode("]");return gt("Writing final close brace"),o&&s?(o.write(p),o.close(),i=new Uint8Array(await new Response(s.readable).arrayBuffer())):(g.push(p),i=wc(g)),b("Finished generating file data"),i},vc=async(e,t)=>{const n=window.CompressionStream!==void 0;let r=null;const i=t??Date.now(),o=i-e;try{r=await Mo(o,i,n)}catch(s){s instanceof Error&&window.UserLeap.reportError("Error compressing replay",s),n&&me(async()=>{await Mo(o,i,!1)},"fileData fallback failed")}return r},Oo=async e=>{const{surveyId:t,responseGroupId:n,visitorId:r,apiUrl:i,completeUploadHeaders:o,replayParams:s,triggerTimestamp:l}=e,a=await vc(s.replayDurationSeconds*1e3,l);if(a!=null&&a.length)b(`Found file data for survey: ${t}`);else{b(`File data is empty for survey: ${t}`);return}const d=mc(a,s.minimumChunkSizeMb,s.signedUrls.length);b(`Got ${d.length} chunks for survey: ${t}`);const c=await Promise.all(d.map(async(h,g)=>{const u=Ge(),p={apiUrl:i,chunkIndex:g+1,completeUploadHeaders:o,etag:null,responseGroupId:n,status:"ReadyForUpload",surveyId:t,timestamp:l,totalChunks:d.length,data:h,uploadId:s.uploadId,uploadUrl:s.signedUrls[g].url,uuid:u,visitorId:r};return b(`Recording chunk upload: ${JSON.stringify({index:p.chunkIndex,surveyId:p.surveyId,uploadId:p.uploadId,size:h.length,id:u},null,2)}`),await(await z.openDB()).add("chunkUploads",{...p,sessionId:p.sessionId??de}),b(`Done creating chunk upload: ${u}`),p}));b(`All chunk records created. Beginning upload for survey: ${t}`),await fc([s.uploadId],c)},_o=async(e,t)=>{if(b(`Attempting replay capture: ${JSON.stringify({isStandalone:e.isStandalone,duration:e.replayParams.replayDurationSeconds,type:e.replayParams.replayDurationType,responseGroupId:e.responseGroupId,surveyId:e.surveyId,triggerTimestamp:e.triggerTimestamp,visitorId:e.visitorId},null,2)}`),Ze())return b(`Replay recording is disabled: ${e.surveyId}`);b(`Replay recording enabled: ${e.surveyId}`);const{isHeatmap:n,isStandalone:r,replayParams:i,triggerTimestamp:o,responseGroupId:s}=e,l=async()=>{setTimeout(()=>A.removeListener(k.QuestionAnswered,l),0),me(async()=>{i.replayDurationType==="before"?await Oo(e):await z.markPendingCaptureToCanUpload(s)},"Error in schedule/capture callback")};me(async()=>{if(i.replayDurationType==="after"||i.replayDurationType==="beforeAndAfter"){!r&&!n&&(b("Attaching QuestionAnswered listener for non-standalone replay"),A.on(k.QuestionAnswered,l)),b(`Scheduling capture for replay of type: ${i.replayDurationType}`),await Fo(e);return}if(r||n||t)b(`Proceeding to capture replay for survey: ${e.surveyId} / standalone? ${r} / canUpload? ${t}`),await Oo(e),n&&Ic();else{const a=dn+i.replayDurationSeconds,d=o-a*1e3,c=o;b(`Setting expiry minutes to ${i.expirationTimeLimitMinutes} for events from ${new Date(d).toLocaleTimeString()} to ${new Date(c).toLocaleTimeString()}`),await z.updateEventsExpiredAt(d,c,i.expirationTimeLimitMinutes),b("Attaching QuestionAnswered listener"),A.on(k.QuestionAnswered,l)}},"Error in scheduling/capturing replay")},Ic=async()=>{parseInt(Pe??"0")||(ne.removeItem("sprig.isCapturingHeatmap"),tr=!1),ne.getItem("sprig.teardownAfterCapture")&&(Co(),No(),ne.removeItem("sprig.teardownAfterCapture"))},No=()=>{if(Ze()){gt("Not clearing user data, replay is disabled");return}return Promise.all([z.deleteBySessionId("events",de),z.deleteBySessionId("pendingCaptures",de)]).catch(e=>{an("Error clearing user replay data",e)})},Fo=async e=>{b(`Scheduling replay capture: ${JSON.stringify(e)}`);const{isHeatmap:t,surveyId:n}=e,r=await z.getPendingCaptures(),i=r?.filter(l=>l.captureParams.surveyId===n);if(i!=null&&i.length){b(`Pending capture exists for survey: ${n}`);return}t&&(rc(),tr=!0,ne.setItem("sprig.isCapturingHeatmap","true"));const o={...e,replayParams:{...e.replayParams}};e.replayParams.replayDurationType==="beforeAndAfter"&&(o.replayParams.replayDurationSeconds*=2),o.replayParams.replayDurationType="before";const s=e.triggerTimestamp+e.replayParams.replayDurationSeconds*1e3;o.triggerTimestamp=s,Pe=(parseInt(Pe??"0")+1).toString(),ne.setItem("sprig.pendingCount",Pe),await(await z.openDB()).add("pendingCaptures",{canUpload:!1,captureParams:o,sessionId:de,targetTimestamp:s,timestamp:Date.now(),uuid:Ge()})},bc=Object.freeze(Object.defineProperty({__proto__:null,RecordEvent:Hd,RecordPageView:Gd,RecordSurveyShown:Kd,_completeSessionReplay:ic,checkPendingHeatmapsUrl:zd,clearUserReplayData:No,disableRecording:an,initializeReplay:lc,isReplayRecording:Qd,scheduleCapture:Fo,scheduleOrCaptureReplay:_o},Symbol.toStringTag,{value:"Module"}));Ja(bc),window.UpChunk={createUpload:Cs},window.rrwebRecord=pt;export{za as A,mi as C,Ue as D,Ha as E,k as S,Te as a,pi as b,_i as c,Ga as d,A as e,Va as f,yt as g,Hn as h,b as i,no as j,vl as r,wi as s,Ei as u,Ge as v};