@sprig-technologies/sprig-bundled 1.1.4 → 1.1.5

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,37 +0,0 @@
1
- "use strict";var vl=Object.defineProperty;var wl=(e,t,n)=>t in e?vl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ee=(e,t,n)=>(wl(e,typeof t!="symbol"?t+"":t,n),n);var bl=Object.create,uo=Object.defineProperty,Il=Object.getOwnPropertyDescriptor,ho=Object.getOwnPropertyNames,Sl=Object.getPrototypeOf,Cl=Object.prototype.hasOwnProperty,Sn=(e,t)=>function(){return t||(0,e[ho(e)[0]])((t={exports:{}}).exports,t),t.exports},kl=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ho(t))!Cl.call(e,i)&&i!==n&&uo(e,i,{get:()=>t[i],enumerable:!(r=Il(t,i))||r.enumerable});return e},_l=(e,t,n)=>(n=e!=null?bl(Sl(e)):{},kl(t||!e||!e.__esModule?uo(n,"default",{value:e,enumerable:!0}):n,e)),El=Sn({"node_modules/global/window.js"(e,t){var n;typeof window<"u"?n=window:typeof global<"u"?n=global:typeof self<"u"?n=self:n={},t.exports=n}}),Al=Sn({"node_modules/is-function/index.js"(e,t){t.exports=r;var n=Object.prototype.toString;function r(i){if(!i)return!1;var s=n.call(i);return s==="[object Function]"||typeof i=="function"&&s!=="[object RegExp]"||typeof window<"u"&&(i===window.setTimeout||i===window.alert||i===window.confirm||i===window.prompt)}}}),Ll=Sn({"node_modules/parse-headers/parse-headers.js"(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 s={},o=n(i).split(`
2
- `),l=0;l<o.length;l++){var a=o[l],c=a.indexOf(":"),u=n(a.slice(0,c)).toLowerCase(),d=n(a.slice(c+1));typeof s[u]>"u"?s[u]=d:r(s[u])?s[u].push(d):s[u]=[s[u],d]}return s}}}),Rl=Sn({"node_modules/xtend/immutable.js"(e,t){t.exports=r;var n=Object.prototype.hasOwnProperty;function r(){for(var i={},s=0;s<arguments.length;s++){var o=arguments[s];for(var l in o)n.call(o,l)&&(i[l]=o[l])}return i}}}),Tl=Sn({"node_modules/xhr/index.js"(e,t){var n=El(),r=Al(),i=Ll(),s=Rl();t.exports=c,t.exports.default=c,c.XMLHttpRequest=n.XMLHttpRequest||p,c.XDomainRequest="withCredentials"in new c.XMLHttpRequest?c.XMLHttpRequest:n.XDomainRequest,o(["get","put","post","patch","head","delete"],function(h){c[h==="delete"?"del":h]=function(f,g,v){return g=a(f,g,v),g.method=h.toUpperCase(),u(g)}});function o(h,f){for(var g=0;g<h.length;g++)f(h[g])}function l(h){for(var f in h)if(h.hasOwnProperty(f))return!1;return!0}function a(h,f,g){var v=h;return r(f)?(g=f,typeof h=="string"&&(v={uri:h})):v=s(f,{uri:h}),v.callback=g,v}function c(h,f,g){return f=a(h,f,g),u(f)}function u(h){if(typeof h.callback>"u")throw new Error("callback argument missing");var f=!1,g=function(O,z,X){f||(f=!0,h.callback(O,z,X))};function v(){b.readyState===4&&setTimeout(w,0)}function y(){var R=void 0;if(b.response?R=b.response:R=b.responseText||d(b),K)try{R=JSON.parse(R)}catch{}return R}function m(R){return clearTimeout(F),R instanceof Error||(R=new Error(""+(R||"Unknown XMLHttpRequest Error"))),R.statusCode=0,g(R,P)}function w(){if(!C){var R;clearTimeout(F),h.useXDR&&b.status===void 0?R=200:R=b.status===1223?204:b.status;var O=P,z=null;return R!==0?(O={body:y(),statusCode:R,method:_,headers:{},url:I,rawRequest:b},b.getAllResponseHeaders&&(O.headers=i(b.getAllResponseHeaders()))):z=new Error("Internal XMLHttpRequest Error"),g(z,O,O.body)}}var b=h.xhr||null;b||(h.cors||h.useXDR?b=new c.XDomainRequest:b=new c.XMLHttpRequest);var S,C,I=b.url=h.uri||h.url,_=b.method=h.method||"GET",k=h.body||h.data,L=b.headers=h.headers||{},x=!!h.sync,K=!1,F,P={body:void 0,headers:{},statusCode:0,method:_,url:I,rawRequest:b};if("json"in h&&h.json!==!1&&(K=!0,L.accept||L.Accept||(L.Accept="application/json"),_!=="GET"&&_!=="HEAD"&&(L["content-type"]||L["Content-Type"]||(L["Content-Type"]="application/json"),k=JSON.stringify(h.json===!0?k:h.json))),b.onreadystatechange=v,b.onload=w,b.onerror=m,b.onprogress=function(){},b.onabort=function(){C=!0},b.ontimeout=m,b.open(_,I,!x,h.username,h.password),x||(b.withCredentials=!!h.withCredentials),!x&&h.timeout>0&&(F=setTimeout(function(){if(!C){C=!0,b.abort("timeout");var R=new Error("XMLHttpRequest timeout");R.code="ETIMEDOUT",m(R)}},h.timeout)),b.setRequestHeader)for(S in L)L.hasOwnProperty(S)&&b.setRequestHeader(S,L[S]);else if(h.headers&&!l(h.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in h&&(b.responseType=h.responseType),"beforeSend"in h&&typeof h.beforeSend=="function"&&h.beforeSend(b),b.send(k||null),b}function d(h){try{if(h.responseType==="document")return h.responseXML;var f=h.responseXML&&h.responseXML.documentElement.nodeName==="parsererror";if(h.responseType===""&&!f)return h.responseXML}catch{}return null}function p(){}}});function Hi(e,t,...n){if(!e)throw new TypeError(po(t,n))}function po(e,t){let n=0;return e.replace(/%[os]/gu,()=>fo(t[n++]))}function fo(e){return typeof e!="object"||e===null?String(e):Object.prototype.toString.call(e)}var xl;function Ol(e){try{const t=e instanceof Error?e:new Error(fo(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 Re=typeof window<"u"?window:typeof self<"u"?self:typeof global<"u"?global:typeof globalThis<"u"?globalThis:void 0,Ul,st=class{constructor(e,t){this.code=e,this.message=t}warn(...e){var t;try{const n=((t=new Error().stack)!==null&&t!==void 0?t:"").replace(/^(?:.+?\n){2}/gu,`
3
- `);console.warn(this.message,...e,n)}catch{}}},Dl=new st("W01","Unable to initialize event under dispatching."),Ml=new st("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),Nl=new st("W03","Assigning any truthy value to 'returnValue' property has no effect."),Pl=new st("W04","Unable to preventDefault on non-cancelable events."),Fl=new st("W05","Unable to preventDefault inside passive event listener invocation."),Bl=new st("W06","An event listener wasn't added because it has been added already: %o, %o"),Mr=new st("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),gs=new st("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),He=class{static get NONE(){return ms}static get CAPTURING_PHASE(){return ys}static get AT_TARGET(){return vs}static get BUBBLING_PHASE(){return ws}constructor(t,n){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});const r=n??{};ei.set(this,{type:String(t),bubbles:!!r.bubbles,cancelable:!!r.cancelable,composed:!!r.composed,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return ne(this).type}get target(){return ne(this).target}get srcElement(){return ne(this).target}get currentTarget(){return ne(this).currentTarget}composedPath(){const t=ne(this).currentTarget;return t?[t]:[]}get NONE(){return ms}get CAPTURING_PHASE(){return ys}get AT_TARGET(){return vs}get BUBBLING_PHASE(){return ws}get eventPhase(){return ne(this).dispatchFlag?2:0}stopPropagation(){ne(this).stopPropagationFlag=!0}get cancelBubble(){return ne(this).stopPropagationFlag}set cancelBubble(t){t?ne(this).stopPropagationFlag=!0:Ml.warn()}stopImmediatePropagation(){const t=ne(this);t.stopPropagationFlag=t.stopImmediatePropagationFlag=!0}get bubbles(){return ne(this).bubbles}get cancelable(){return ne(this).cancelable}get returnValue(){return!ne(this).canceledFlag}set returnValue(t){t?Nl.warn():bs(ne(this))}preventDefault(){bs(ne(this))}get defaultPrevented(){return ne(this).canceledFlag}get composed(){return ne(this).composed}get isTrusted(){return!1}get timeStamp(){return ne(this).timeStamp}initEvent(t,n=!1,r=!1){const i=ne(this);if(i.dispatchFlag){Dl.warn();return}ei.set(this,{...i,type:String(t),bubbles:!!n,cancelable:!!r,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}},ms=0,ys=1,vs=2,ws=3,ei=new WeakMap;function ne(e,t="this"){const n=ei.get(e);return Hi(n!=null,"'%s' must be an object that Event constructor created, but got another one: %o",t,e),n}function bs(e){if(e.inPassiveListenerFlag){Fl.warn();return}if(!e.cancelable){Pl.warn();return}e.canceledFlag=!0}Object.defineProperty(He,"NONE",{enumerable:!0});Object.defineProperty(He,"CAPTURING_PHASE",{enumerable:!0});Object.defineProperty(He,"AT_TARGET",{enumerable:!0});Object.defineProperty(He,"BUBBLING_PHASE",{enumerable:!0});var Nr=Object.getOwnPropertyNames(He.prototype);for(let e=0;e<Nr.length;++e)Nr[e]!=="constructor"&&Object.defineProperty(He.prototype,Nr[e],{enumerable:!0});typeof Re<"u"&&typeof Re.Event<"u"&&Object.setPrototypeOf(He.prototype,Re.Event.prototype);function Wl(e){return Re.DOMException?new Re.DOMException(e,"InvalidStateError"):(_t==null&&(_t=class go extends Error{constructor(n){super(n),Error.captureStackTrace&&Error.captureStackTrace(this,go)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(_t.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),Ss(_t),Ss(_t.prototype)),new _t(e))}var _t,Is={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 Ss(e){const t=Object.keys(Is);for(let n=0;n<t.length;++n){const r=t[n],i=Is[r];Object.defineProperty(e,r,{get(){return i},configurable:!0,enumerable:!0})}}var Sr=class extends He{static wrap(e){return new(yo(e))(e)}constructor(e){super(e.type,{bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed}),e.cancelBubble&&super.stopPropagation(),e.defaultPrevented&&super.preventDefault(),mo.set(this,{original:e});const t=Object.keys(e);for(let n=0;n<t.length;++n){const r=t[n];r in this||Object.defineProperty(this,r,vo(e,r))}}stopPropagation(){super.stopPropagation();const{original:e}=Ze(this);"stopPropagation"in e&&e.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(e){super.cancelBubble=e;const{original:t}=Ze(this);"cancelBubble"in t&&(t.cancelBubble=e)}stopImmediatePropagation(){super.stopImmediatePropagation();const{original:e}=Ze(this);"stopImmediatePropagation"in e&&e.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(e){super.returnValue=e;const{original:t}=Ze(this);"returnValue"in t&&(t.returnValue=e)}preventDefault(){super.preventDefault();const{original:e}=Ze(this);"preventDefault"in e&&e.preventDefault()}get timeStamp(){const{original:e}=Ze(this);return"timeStamp"in e?e.timeStamp:super.timeStamp}},mo=new WeakMap;function Ze(e){const t=mo.get(e);return Hi(t!=null,"'this' is expected an Event object, but got",e),t}var nr=new WeakMap;nr.set(Object.prototype,Sr);typeof Re<"u"&&typeof Re.Event<"u"&&nr.set(Re.Event.prototype,Sr);function yo(e){const t=Object.getPrototypeOf(e);if(t==null)return Sr;let n=nr.get(t);return n==null&&(n=Kl(yo(t),t),nr.set(t,n)),n}function Kl(e,t){class n extends e{}const r=Object.keys(t);for(let i=0;i<r.length;++i)Object.defineProperty(n.prototype,r[i],vo(t,r[i]));return n}function vo(e,t){const n=Object.getOwnPropertyDescriptor(e,t);return{get(){const r=Ze(this).original,i=r[t];return typeof i=="function"?i.bind(r):i},set(r){const i=Ze(this).original;i[t]=r},configurable:n.configurable,enumerable:n.enumerable}}function jl(e,t,n,r,i,s){return{callback:e,flags:(t?1:0)|(n?2:0)|(r?4:0),signal:i,signalListener:s}}function Vl(e){e.flags|=8}function wo(e){return(e.flags&1)===1}function bo(e){return(e.flags&2)===2}function Io(e){return(e.flags&4)===4}function zl(e){return(e.flags&8)===8}function Gl({callback:e},t,n){try{typeof e=="function"?e.call(t,n):typeof e.handleEvent=="function"&&e.handleEvent(n)}catch(r){Ol(r)}}function So({listeners:e},t,n){for(let r=0;r<e.length;++r)if(e[r].callback===t&&wo(e[r])===n)return r;return-1}function Hl(e,t,n,r,i,s){let o;s&&(o=Co.bind(null,e,t,n),s.addEventListener("abort",o));const l=jl(t,n,r,i,s,o);return e.cow?(e.cow=!1,e.listeners=[...e.listeners,l]):e.listeners.push(l),l}function Co(e,t,n){const r=So(e,t,n);return r!==-1?ko(e,r):!1}function ko(e,t,n=!1){const r=e.listeners[t];return Vl(r),r.signal&&r.signal.removeEventListener("abort",r.signalListener),e.cow&&!n?(e.cow=!1,e.listeners=e.listeners.filter((i,s)=>s!==t),!1):(e.listeners.splice(t,1),!0)}function ql(){return Object.create(null)}function $l(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 Cr=class{constructor(){_o.set(this,ql())}addEventListener(e,t,n){const r=Pr(this),{callback:i,capture:s,once:o,passive:l,signal:a,type:c}=Zl(e,t,n);if(i==null||a!=null&&a.aborted)return;const u=$l(r,c),d=So(u,i,s);if(d!==-1){Jl(u.listeners[d],l,o,a);return}Hl(u,i,s,l,o,a)}removeEventListener(e,t,n){const r=Pr(this),{callback:i,capture:s,type:o}=Yl(e,t,n),l=r[o];i!=null&&l&&Co(l,i,s)}dispatchEvent(e){const t=Pr(this)[String(e.type)];if(t==null)return!0;const n=e instanceof He?e:Sr.wrap(e),r=ne(n,"event");if(r.dispatchFlag)throw Wl("This event has been in dispatching.");if(r.dispatchFlag=!0,r.target=r.currentTarget=this,!r.stopPropagationFlag){const{cow:i,listeners:s}=t;t.cow=!0;for(let o=0;o<s.length;++o){const l=s[o];if(!zl(l)&&(Io(l)&&ko(t,o,!i)&&(o-=1),r.inPassiveListenerFlag=bo(l),Gl(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}},_o=new WeakMap;function Pr(e,t="this"){const n=_o.get(e);return Hi(n!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",t,e),n}function Zl(e,t,n){var r;return Eo(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 Yl(e,t,n){return Eo(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 Eo(e){if(!(typeof e=="function"||typeof e=="object"&&e!==null&&typeof e.handleEvent=="function")){if(e==null||typeof e=="object"){gs.warn(e);return}throw new TypeError(po(gs.message,[e]))}}function Jl(e,t,n,r){Bl.warn(wo(e)?"capture":"bubble",e.callback),bo(e)!==t&&Mr.warn("passive"),Io(e)!==n&&Mr.warn("once"),e.signal!==r&&Mr.warn("signal")}var Fr=Object.getOwnPropertyNames(Cr.prototype);for(let e=0;e<Fr.length;++e)Fr[e]!=="constructor"&&Object.defineProperty(Cr.prototype,Fr[e],{enumerable:!0});typeof Re<"u"&&typeof Re.EventTarget<"u"&&Object.setPrototypeOf(Cr.prototype,Re.EventTarget.prototype);var Ql=_l(Tl()),Ao=30720,kr=512e3,_r=256,ti=(e,{minChunkSize:t=_r,maxChunkSize:n=kr}={})=>e==null||typeof e=="number"&&e>=256&&e%256===0&&e>=t&&e<=n,ni=(e,{minChunkSize:t=_r,maxChunkSize:n=kr}={})=>new TypeError(`chunkSize ${e} must be a positive number in multiples of 256, between ${t} and ${n}`),Xl=class{constructor(e,t={}){this.readableStream=e;var n,r,i;if(!ti(t.defaultChunkSize,t))throw ni(t.defaultChunkSize,t);this.defaultChunkSize=(n=t.defaultChunkSize)!=null?n:Ao,this.minChunkSize=(r=t.minChunkSize)!=null?r:_r,this.maxChunkSize=(i=t.maxChunkSize)!=null?i:kr}get chunkSize(){var e;return(e=this._chunkSize)!=null?e:this.defaultChunkSize}set chunkSize(e){if(!ti(e,this))throw ni(e,this);this._chunkSize=e}get chunkByteSize(){return this.chunkSize*1024}async*[Symbol.asyncIterator](){let e;const t=this.readableStream.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n){if(e){const s=e;e=void 0,yield s}break}const 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){const s=e;e=void 0,yield s;break}else{if(e.size<this.chunkByteSize)break;{const s=e.slice(0,this.chunkByteSize);e=e.slice(this.chunkByteSize),yield s}}}}finally{if(e){const n=e;e=void 0,yield n}t.releaseLock();return}}},ec=[200,201,202,204,308],Lo=[408,502,503,504],tc=[308],Ro=(e,t)=>!!e&&ec.includes(e.statusCode),nc=(e,{retryCodes:t=Lo})=>!e||t.includes(e.statusCode),rc=(e,t)=>t.attemptCount>=t.attempts||!(Ro(e)||nc(e,t)),ic=(e,t)=>{if(!e||!tc.includes(e.statusCode)||!e.headers.range)return!1;const n=e.headers.range.match(/bytes=(\d+)-(\d+)/);return n?parseInt(n[2],10)!==t.currentChunkEndByte:!1},To=class{static createUpload(e){return new To(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||Lo,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 Xl(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 Cr,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:kr}get minChunkSize(){var e,t;return(t=(e=this.chunkedStreamIterable)==null?void 0:e.minChunkSize)!=null?t:_r}get chunkSize(){var e,t;return(t=(e=this.chunkedStreamIterable)==null?void 0:e.chunkSize)!=null?t:Ao}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){const 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(!ti(this.chunkSize,{maxChunkSize:this.maxChunkSize,minChunkSize:this.minChunkSize}))throw ni(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){const t=n=>{n.upload.onprogress=r=>{var i;const s=this.totalChunks-this.chunkCount,o=(this.file.size-this.nextChunkRangeStart)/this.file.size/s,l=this.nextChunkRangeStart/this.file.size,c=r.loaded/((i=r.total)!=null?i:this.chunkByteSize)*o;this.dispatch("progress",Math.min((l+c)*100,100))}};return new Promise((n,r)=>{this.currentXhr=(0,Ql.default)({...e,beforeSend:t},(i,s)=>(this.currentXhr=void 0,i?r(i):n(s)))})}async sendChunk(e){const t=this.nextChunkRangeStart,n=t+e.size-1,i={...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:i,url:this.endpointValue,method:this.method,body:e})}async sendChunkWithRetries(e){const t=async(o,l)=>{var a;const u=(new Date().getTime()-this.lastChunkStart.getTime())/1e3;if(this.dispatch("chunkSuccess",{chunk:this.chunkCount,chunkSize:this.chunkSize,attempts:this.attemptCount,timeInterval:u,response:o}),this.attemptCount=0,this.chunkCount=((a=this.chunkCount)!=null?a:0)+1,this.nextChunkRangeStart=this.nextChunkRangeStart+this.chunkByteSize,this.dynamicChunkSize){let d=this.chunkSize;u<10?d=Math.min(this.chunkSize*2,this.maxChunkSize):u>30&&(d=Math.max(this.chunkSize/2,this.minChunkSize)),this.chunkSize=Math.ceil(d/256)*256;const p=(this.file.size-this.nextChunkRangeStart)/this.chunkByteSize;this.totalChunks=Math.ceil(this.chunkCount+p)}return!0},n=async(o,l)=>(this.dispatch("error",{message:`Server responded with ${o.statusCode}. Stopping upload.`,chunk:this.chunkCount,attempts:this.attemptCount,response:o}),!1),r=async(o,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,response:o}),new Promise(a=>{setTimeout(async()=>{if(this._paused||this.offline){this.pendingChunk=e,a(!1);return}const c=await this.sendChunkWithRetries(e);a(c)},this.delayBeforeAttempt*1e3)}));let i;try{this.attemptCount=this.attemptCount+1,this.lastChunkStart=new Date,i=await this.sendChunk(e)}catch{}const s={retryCodes:this.retryCodes,attemptCount:this.attemptCount,attempts:this.attempts,currentChunkEndByte:this.nextChunkRangeStart+e.size-1};return ic(i,s)?r(i):Ro(i)?t(i):rc(i,s)?n(i):r(i)}async sendChunks(){if(this.pendingChunk&&!(this._paused||this.offline)){const e=this.pendingChunk;this.pendingChunk=void 0;const t=await this.sendChunkWithRetries(e);this.success&&t&&this.dispatch("success")}for(;!(this.success||this._paused||this.offline);){const{value:e,done:t}=await this.chunkedStreamIterator.next();let n=!e&&t;if(e&&(n=await this.sendChunkWithRetries(e)),this.success=!!t,this.success&&n&&this.dispatch("success"),!n)return}}};function sc(e){return To.createUpload(e)}var se;(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"})(se||(se={}));function oc(e){return e.nodeType===e.ELEMENT_NODE}function Xt(e){var t=e==null?void 0:e.host;return(t==null?void 0:t.shadowRoot)===e}function en(e){return Object.prototype.toString.call(e)==="[object ShadowRoot]"}function ac(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 lc(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 rr(e){try{var t=e.rules||e.cssRules;return t?ac(Array.from(t).map(xo).join("")):null}catch{return null}}function xo(e){var t;if(uc(e))try{t=rr(e.styleSheet)||lc(e)}catch{}return cc(t||e.cssText)}function cc(e){if(e.includes(":")){var t=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return e.replace(t,"$1\\$2")}return e}function uc(e){return"styleSheet"in e}var Oo=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 dc(){return new Oo}function qi(e){var t=e.element,n=e.maskInputOptions,r=e.tagName,i=e.type,s=e.value,o=e.maskInputFn,l=s||"",a=i&&yt(i);return(n[r.toLowerCase()]||a&&n[a])&&(o?l=o(l,t):l="*".repeat(l.length)),l}function yt(e){return e.toLowerCase()}var Cs="__rrweb_original__";function hc(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 s=t.getImageData,o=Cs in s?s[Cs]:s,l=new Uint32Array(o.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 $i(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?yt(t):null}var pc=1,fc=new RegExp("[^a-z0-9-_:]"),un=-2;function Uo(){return pc++}function gc(e){if(e instanceof HTMLFormElement)return"form";var t=yt(e.tagName);return fc.test(t)?"div":t}function mc(e){var t="";return e.indexOf("//")>-1?t=e.split("/").slice(0,3).join("/"):t=e.split("/")[0],t=t.split("?")[0],t}var Et,ks,yc=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,vc=/^(?:[a-z+]+:)?\/\//i,wc=/^www\..*/i,bc=/^(data:)([^,]*),(.*)/i;function ir(e,t){return(e||"").replace(yc,function(n,r,i,s,o,l){var a=i||o||l,c=r||s||"";if(!a)return n;if(vc.test(a)||wc.test(a)||bc.test(a))return"url(".concat(c).concat(a).concat(c,")");if(a[0]==="/")return"url(".concat(c).concat(mc(t)+a).concat(c,")");var u=t.split("/"),d=a.split("/");u.pop();for(var p=0,h=d;p<h.length;p++){var f=h[p];f!=="."&&(f===".."?u.pop():u.push(f))}return"url(".concat(c).concat(u.join("/")).concat(c,")")})}var Ic=/^[^ \t\n\r\u000c]+/,Sc=/^[, \t\n\r\u000c]+/;function Cc(e,t){if(t.trim()==="")return t;var n=0;function r(c){var u,d=c.exec(t.substring(n));return d?(u=d[0],n+=u.length,u):""}for(var i=[];r(Sc),!(n>=t.length);){var s=r(Ic);if(s.slice(-1)===",")s=xt(e,s.substring(0,s.length-1)),i.push(s);else{var o="";s=xt(e,s);for(var l=!1;;){var a=t.charAt(n);if(a===""){i.push((s+o).trim());break}else if(l)a===")"&&(l=!1);else if(a===","){n+=1,i.push((s+o).trim());break}else a==="("&&(l=!0);o+=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 kc(e){return!!(e.tagName==="svg"||e.ownerSVGElement)}function Zi(){var e=document.createElement("a");return e.href="",e.href}function Do(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"?Cc(e,r):n==="style"?ir(r,Zi()):t==="object"&&n==="data"?xt(e,r):r)}function Mo(e,t,n){return(e==="video"||e==="audio")&&t==="autoplay"}function _c(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 sr(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return n?sr(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?sr(e.parentNode,t,n):!1}function No(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(sr(r,t,!0))return!0;if(n&&(r.matches(n)||r.closest(n)))return!0}catch{}return!1}function Ec(e,t,n){var r=e.contentWindow;if(r){var i=!1,s;try{s=r.document.readyState}catch{return}if(s!=="complete"){var o=setTimeout(function(){i||(t(),i=!0)},n);e.addEventListener("load",function(){clearTimeout(o),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 Ac(e,t,n){var r=!1,i;try{i=e.sheet}catch{return}if(!i){var s=setTimeout(function(){r||(t(),r=!0)},n);e.addEventListener("load",function(){clearTimeout(s),r=!0,t()})}}function Lc(e,t){var n=t.doc,r=t.mirror,i=t.blockClass,s=t.blockSelector,o=t.maskTextClass,l=t.maskTextSelector,a=t.inlineStylesheet,c=t.maskInputOptions,u=c===void 0?{}:c,d=t.maskTextFn,p=t.maskInputFn,h=t.dataURLOptions,f=h===void 0?{}:h,g=t.inlineImages,v=t.recordCanvas,y=t.keepIframeSrcFn,m=t.newlyAddedElement,w=m===void 0?!1:m,b=Rc(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode!=="CSS1Compat"?{type:se.Document,childNodes:[],compatMode:e.compatMode}:{type:se.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:se.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:b};case e.ELEMENT_NODE:return xc(e,{doc:n,blockClass:i,blockSelector:s,inlineStylesheet:a,maskInputOptions:u,maskInputFn:p,dataURLOptions:f,inlineImages:g,recordCanvas:v,keepIframeSrcFn:y,newlyAddedElement:w,rootId:b});case e.TEXT_NODE:return Tc(e,{maskTextClass:o,maskTextSelector:l,maskTextFn:d,rootId:b});case e.CDATA_SECTION_NODE:return{type:se.CDATA,textContent:"",rootId:b};case e.COMMENT_NODE:return{type:se.Comment,textContent:e.textContent||"",rootId:b};default:return!1}}function Rc(e,t){if(t.hasNode(e)){var n=t.getId(e);return n===1?void 0:n}}function Tc(e,t){var n,r=t.maskTextClass,i=t.maskTextSelector,s=t.maskTextFn,o=t.rootId,l=e.parentNode&&e.parentNode.tagName,a=e.textContent,c=l==="STYLE"?!0:void 0,u=l==="SCRIPT"?!0:void 0;if(c&&a){try{e.nextSibling||e.previousSibling||!((n=e.parentNode.sheet)===null||n===void 0)&&n.cssRules&&(a=rr(e.parentNode.sheet))}catch(d){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(d),e)}a=ir(a,Zi())}return u&&(a="SCRIPT_PLACEHOLDER"),!c&&!u&&a&&No(e,r,i)&&(a=s?s(a):a.replace(/[\S]/g,"*")),{type:se.Text,textContent:a||"",isStyle:c,rootId:o}}function xc(e,t){for(var n=t.doc,r=t.blockClass,i=t.blockSelector,s=t.inlineStylesheet,o=t.maskInputOptions,l=o===void 0?{}:o,a=t.maskInputFn,c=t.dataURLOptions,u=c===void 0?{}:c,d=t.inlineImages,p=t.recordCanvas,h=t.keepIframeSrcFn,f=t.newlyAddedElement,g=f===void 0?!1:f,v=t.rootId,y=_c(e,r,i),m=gc(e),w={},b=e.attributes.length,S=0;S<b;S++){var C=e.attributes[S];Mo(m,C.name,C.value)||(w[C.name]=Do(n,m,yt(C.name),C.value))}if(m==="link"&&s){var I=Array.from(n.styleSheets).find(function(ke){return ke.href===e.href}),_=null;I&&(_=rr(I)),_&&(delete w.rel,delete w.href,w._cssText=ir(_,I.href))}if(m==="style"&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){var _=rr(e.sheet);_&&(w._cssText=ir(_,Zi()))}if(m==="input"||m==="textarea"||m==="select"){var k=e.value,L=e.checked;if(w.type!=="radio"&&w.type!=="checkbox"&&w.type!=="submit"&&w.type!=="button"&&k){var x=$i(e);w.value=qi({element:e,type:x,tagName:m,value:k,maskInputOptions:l,maskInputFn:a})}else L&&(w.checked=L)}if(m==="option"&&(e.selected&&!l.select?w.selected=!0:delete w.selected),m==="canvas"&&p){if(e.__context==="2d")hc(e)||(w.rr_dataURL=e.toDataURL(u.type,u.quality));else if(!("__context"in e)){var K=e.toDataURL(u.type,u.quality),F=document.createElement("canvas");F.width=e.width,F.height=e.height;var P=F.toDataURL(u.type,u.quality);K!==P&&(w.rr_dataURL=K)}}if(m==="img"&&d){Et||(Et=n.createElement("canvas"),ks=Et.getContext("2d"));var R=e,O=R.crossOrigin;R.crossOrigin="anonymous";var z=function(){R.removeEventListener("load",z);try{Et.width=R.naturalWidth,Et.height=R.naturalHeight,ks.drawImage(R,0,0),w.rr_dataURL=Et.toDataURL(u.type,u.quality)}catch(ke){console.warn("Cannot inline img src=".concat(R.currentSrc,"! Error: ").concat(ke))}O?w.crossOrigin=O:R.removeAttribute("crossorigin")};R.complete&&R.naturalWidth!==0?z():R.addEventListener("load",z)}if((m==="audio"||m==="video")&&(w.rr_mediaState=e.paused?"paused":"played",w.rr_mediaCurrentTime=e.currentTime),g||(e.scrollLeft&&(w.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(w.rr_scrollTop=e.scrollTop)),y){var X=e.getBoundingClientRect(),ae=X.width,ue=X.height;w={class:w.class,rr_width:"".concat(ae,"px"),rr_height:"".concat(ue,"px")}}return m==="iframe"&&!h(w.src)&&(e.contentDocument||(w.rr_src=w.src),delete w.src),{type:se.Element,tagName:m,attributes:w,childNodes:[],isSVG:kc(e)||void 0,needBlock:y,rootId:v}}function $(e){return e==null?"":e.toLowerCase()}function Oc(e,t){if(t.comment&&e.type===se.Comment)return!0;if(e.type===se.Element){if(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")))return!0;if(t.headFavicon&&(e.tagName==="link"&&e.attributes.rel==="shortcut icon"||e.tagName==="meta"&&($(e.attributes.name).match(/^msapplication-tile(image|color)$/)||$(e.attributes.name)==="application-name"||$(e.attributes.rel)==="icon"||$(e.attributes.rel)==="apple-touch-icon"||$(e.attributes.rel)==="shortcut icon")))return!0;if(e.tagName==="meta"){if(t.headMetaDescKeywords&&$(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&($(e.attributes.property).match(/^(og|twitter|fb):/)||$(e.attributes.name).match(/^(og|twitter):/)||$(e.attributes.name)==="pinterest"))return!0;if(t.headMetaRobots&&($(e.attributes.name)==="robots"||$(e.attributes.name)==="googlebot"||$(e.attributes.name)==="bingbot"))return!0;if(t.headMetaHttpEquiv&&e.attributes["http-equiv"]!==void 0)return!0;if(t.headMetaAuthorship&&($(e.attributes.name)==="author"||$(e.attributes.name)==="generator"||$(e.attributes.name)==="framework"||$(e.attributes.name)==="publisher"||$(e.attributes.name)==="progid"||$(e.attributes.property).match(/^article:/)||$(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&($(e.attributes.name)==="google-site-verification"||$(e.attributes.name)==="yandex-verification"||$(e.attributes.name)==="csrf-token"||$(e.attributes.name)==="p:domain_verify"||$(e.attributes.name)==="verify-v1"||$(e.attributes.name)==="verification"||$(e.attributes.name)==="shopify-checkout-api-token"))return!0}}return!1}function Ot(e,t){var n=t.doc,r=t.mirror,i=t.blockClass,s=t.blockSelector,o=t.maskTextClass,l=t.maskTextSelector,a=t.skipChild,c=a===void 0?!1:a,u=t.inlineStylesheet,d=u===void 0?!0:u,p=t.maskInputOptions,h=p===void 0?{}:p,f=t.maskTextFn,g=t.maskInputFn,v=t.slimDOMOptions,y=t.dataURLOptions,m=y===void 0?{}:y,w=t.inlineImages,b=w===void 0?!1:w,S=t.recordCanvas,C=S===void 0?!1:S,I=t.onSerialize,_=t.onIframeLoad,k=t.iframeLoadTimeout,L=k===void 0?5e3:k,x=t.onStylesheetLoad,K=t.stylesheetLoadTimeout,F=K===void 0?5e3:K,P=t.keepIframeSrcFn,R=P===void 0?function(){return!1}:P,O=t.newlyAddedElement,z=O===void 0?!1:O,X=t.preserveWhiteSpace,ae=X===void 0?!0:X,ue=Lc(e,{doc:n,mirror:r,blockClass:i,blockSelector:s,maskTextClass:o,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:h,maskTextFn:f,maskInputFn:g,dataURLOptions:m,inlineImages:b,recordCanvas:C,keepIframeSrcFn:R,newlyAddedElement:z});if(!ue)return console.warn(e,"not serialized"),null;var ke;r.hasNode(e)?ke=r.getId(e):Oc(ue,v)||!ae&&ue.type===se.Text&&!ue.isStyle&&!ue.textContent.replace(/^\s+|\s+$/gm,"").length?ke=un:ke=Uo();var J=Object.assign(ue,{id:ke});if(r.add(e,J),ke===un)return null;I&&I(e);var kt=!c;if(J.type===se.Element){kt=kt&&!J.needBlock,delete J.needBlock;var Ht=e.shadowRoot;Ht&&en(Ht)&&(J.isShadowHost=!0)}if((J.type===se.Document||J.type===se.Element)&&kt){v.headWhitespace&&J.type===se.Element&&J.tagName==="head"&&(ae=!1);for(var Tn={doc:n,mirror:r,blockClass:i,blockSelector:s,maskTextClass:o,maskTextSelector:l,skipChild:c,inlineStylesheet:d,maskInputOptions:h,maskTextFn:f,maskInputFn:g,slimDOMOptions:v,dataURLOptions:m,inlineImages:b,recordCanvas:C,preserveWhiteSpace:ae,onSerialize:I,onIframeLoad:_,iframeLoadTimeout:L,onStylesheetLoad:x,stylesheetLoadTimeout:F,keepIframeSrcFn:R},_e=0,xe=Array.from(e.childNodes);_e<xe.length;_e++){var ot=xe[_e],Ee=Ot(ot,Tn);Ee&&J.childNodes.push(Ee)}if(oc(e)&&e.shadowRoot)for(var D=0,ve=Array.from(e.shadowRoot.childNodes);D<ve.length;D++){var ot=ve[D],Ee=Ot(ot,Tn);Ee&&(en(e.shadowRoot)&&(Ee.isShadow=!0),J.childNodes.push(Ee))}}return e.parentNode&&Xt(e.parentNode)&&en(e.parentNode)&&(J.isShadow=!0),J.type===se.Element&&J.tagName==="iframe"&&Ec(e,function(){var G=e.contentDocument;if(G&&_){var le=Ot(G,{doc:G,mirror:r,blockClass:i,blockSelector:s,maskTextClass:o,maskTextSelector:l,skipChild:!1,inlineStylesheet:d,maskInputOptions:h,maskTextFn:f,maskInputFn:g,slimDOMOptions:v,dataURLOptions:m,inlineImages:b,recordCanvas:C,preserveWhiteSpace:ae,onSerialize:I,onIframeLoad:_,iframeLoadTimeout:L,onStylesheetLoad:x,stylesheetLoadTimeout:F,keepIframeSrcFn:R});le&&_(e,le)}},L),J.type===se.Element&&J.tagName==="link"&&J.attributes.rel==="stylesheet"&&Ac(e,function(){if(x){var G=Ot(e,{doc:n,mirror:r,blockClass:i,blockSelector:s,maskTextClass:o,maskTextSelector:l,skipChild:!1,inlineStylesheet:d,maskInputOptions:h,maskTextFn:f,maskInputFn:g,slimDOMOptions:v,dataURLOptions:m,inlineImages:b,recordCanvas:C,preserveWhiteSpace:ae,onSerialize:I,onIframeLoad:_,iframeLoadTimeout:L,onStylesheetLoad:x,stylesheetLoadTimeout:F,keepIframeSrcFn:R});G&&x(e,G)}},F),J}function Uc(e,t){var n=t||{},r=n.mirror,i=r===void 0?new Oo:r,s=n.blockClass,o=s===void 0?"rr-block":s,l=n.blockSelector,a=l===void 0?null:l,c=n.maskTextClass,u=c===void 0?"rr-mask":c,d=n.maskTextSelector,p=d===void 0?null:d,h=n.inlineStylesheet,f=h===void 0?!0:h,g=n.inlineImages,v=g===void 0?!1:g,y=n.recordCanvas,m=y===void 0?!1:y,w=n.maskAllInputs,b=w===void 0?!1:w,S=n.maskTextFn,C=n.maskInputFn,I=n.slimDOM,_=I===void 0?!1:I,k=n.dataURLOptions,L=n.preserveWhiteSpace,x=n.onSerialize,K=n.onIframeLoad,F=n.iframeLoadTimeout,P=n.onStylesheetLoad,R=n.stylesheetLoadTimeout,O=n.keepIframeSrcFn,z=O===void 0?function(){return!1}:O,X=b===!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}:b===!1?{password:!0}:b,ae=_===!0||_==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:_==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:_===!1?{}:_;return Ot(e,{doc:e,mirror:i,blockClass:o,blockSelector:a,maskTextClass:u,maskTextSelector:p,skipChild:!1,inlineStylesheet:f,maskInputOptions:X,maskTextFn:S,maskInputFn:C,slimDOMOptions:ae,dataURLOptions:k,inlineImages:v,recordCanvas:m,preserveWhiteSpace:L,onSerialize:x,onIframeLoad:K,iframeLoadTimeout:F,onStylesheetLoad:P,stylesheetLoadTimeout:R,keepIframeSrcFn:z,newlyAddedElement:!1})}function pe(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const Rt=`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 _s={map:{},getId(){return console.error(Rt),-1},getNode(){return console.error(Rt),null},removeNodeFromMap(){console.error(Rt)},has(){return console.error(Rt),!1},reset(){console.error(Rt)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(_s=new Proxy(_s,{get(e,t,n){return t==="map"&&console.error(Rt),Reflect.get(e,t,n)}}));function dn(e,t,n={}){let r=null,i=0;return function(...s){const o=Date.now();!i&&n.leading===!1&&(i=o);const l=t-(o-i),a=this;l<=0||l>t?(r&&(clearTimeout(r),r=null),i=o,e.apply(a,s)):!r&&n.trailing!==!1&&(r=setTimeout(()=>{i=n.leading===!1?0:Date.now(),r=null,e.apply(a,s)},l))}}function Er(e,t,n,r,i=window){const s=i.Object.getOwnPropertyDescriptor(e,t);return i.Object.defineProperty(e,t,r?n:{set(o){setTimeout(()=>{n.set.call(this,o)},0),s&&s.set&&s.set.call(this,o)}}),()=>Er(e,t,s||{},!0)}function Cn(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 or=Date.now;/[1-9][0-9]{12}/.test(Date.now().toString())||(or=()=>new Date().getTime());function Po(e){var t,n,r,i,s,o;const l=e.document;return{left:l.scrollingElement?l.scrollingElement.scrollLeft:e.pageXOffset!==void 0?e.pageXOffset:(l==null?void 0:l.documentElement.scrollLeft)||((n=(t=l==null?void 0:l.body)===null||t===void 0?void 0:t.parentElement)===null||n===void 0?void 0:n.scrollLeft)||((r=l==null?void 0:l.body)===null||r===void 0?void 0:r.scrollLeft)||0,top:l.scrollingElement?l.scrollingElement.scrollTop:e.pageYOffset!==void 0?e.pageYOffset:(l==null?void 0:l.documentElement.scrollTop)||((s=(i=l==null?void 0:l.body)===null||i===void 0?void 0:i.parentElement)===null||s===void 0?void 0:s.scrollTop)||((o=l==null?void 0:l.body)===null||o===void 0?void 0:o.scrollTop)||0}}function Fo(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Bo(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function fe(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(sr(i,t,r))return!0}catch{}return!!(n&&(i.matches(n)||r&&i.closest(n)!==null))}function Dc(e,t){return t.getId(e)!==-1}function Br(e,t){return t.getId(e)===un}function Wo(e,t){if(Xt(e))return!1;const n=t.getId(e);return t.has(n)?e.parentNode&&e.parentNode.nodeType===e.DOCUMENT_NODE?!1:e.parentNode?Wo(e.parentNode,t):!0:!0}function ri(e){return!!e.changedTouches}function Mc(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 Ko(e,t){return!!(e.nodeName==="IFRAME"&&t.getMeta(e))}function jo(e,t){return!!(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function ii(e){return!!(e!=null&&e.shadowRoot)}class Nc{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 Vo(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 Pc(e){let t=e,n;for(;n=Vo(t);)t=n;return t}function Fc(e){const t=e.ownerDocument;if(!t)return!1;const n=Pc(e);return t.contains(n)}function zo(e){const t=e.ownerDocument;return t?t.contains(e)||Fc(e):!1}var j=(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))(j||{}),V=(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))(V||{}),we=(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))(we||{}),Pe=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Pe||{}),Ft=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(Ft||{});function Es(e){return"__ln"in e}class Bc{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==null?void 0:n.next)||null;return n}addNode(t){const n={value:t,previous:null,next:null};if(t.__ln=n,t.previousSibling&&Es(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&&Es(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 As=(e,t)=>`${e}@${t}`;class Wc{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 Bc,i=a=>{let c=a,u=un;for(;u===un;)c=c&&c.nextSibling,u=c&&this.mirror.getId(c);return u},s=a=>{if(!a.parentNode||!zo(a))return;const c=Xt(a.parentNode)?this.mirror.getId(Vo(a)):this.mirror.getId(a.parentNode),u=i(a);if(c===-1||u===-1)return r.addNode(a);const d=Ot(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:p=>{Ko(p,this.mirror)&&this.iframeManager.addIframe(p),jo(p,this.mirror)&&this.stylesheetManager.trackLinkElement(p),ii(a)&&this.shadowDomManager.addShadowRoot(a.shadowRoot,this.doc)},onIframeLoad:(p,h)=>{this.iframeManager.attachIframe(p,h),this.shadowDomManager.observeAttachShadow(p)},onStylesheetLoad:(p,h)=>{this.stylesheetManager.attachLinkElement(p,h)}});d&&(t.push({parentId:c,nextId:u,node:d}),n.add(d.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of this.movedSet)Ls(this.removes,a,this.mirror)&&!this.movedSet.has(a.parentNode)||s(a);for(const a of this.addedSet)!Rs(this.droppedSet,a)&&!Ls(this.removes,a,this.mirror)||Rs(this.movedSet,a)?s(a):this.droppedSet.add(a);let o=null;for(;r.length;){let a=null;if(o){const c=this.mirror.getId(o.value.parentNode),u=i(o.value);c!==-1&&u!==-1&&(a=o)}if(!a){let c=r.tail;for(;c;){const u=c;if(c=c.previous,u){const d=this.mirror.getId(u.value.parentNode);if(i(u.value)===-1)continue;if(d!==-1){a=u;break}else{const h=u.value;if(h.parentNode&&h.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const f=h.parentNode.host;if(this.mirror.getId(f)!==-1){a=u;break}}}}}}if(!a){for(;r.head;)r.removeNode(r.head.value);break}o=a.previous,r.removeNode(a.value),s(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:c}=a;if(typeof c.style=="string"){const u=JSON.stringify(a.styleDiff),d=JSON.stringify(a._unchangedStyles);u.length<c.style.length&&(u+d).split("var(").length===c.style.split("var(").length&&(c.style=a.styleDiff)}return{id:this.mirror.getId(a.node),attributes:c}}).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(Br(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;!fe(t.target,this.blockClass,this.blockSelector,!1)&&r!==t.oldValue&&this.texts.push({value:No(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,s=t.target.getAttribute(i);if(i==="value"){const l=$i(r);s=qi({element:r,maskInputOptions:this.maskInputOptions,tagName:r.tagName,type:l,value:s,maskInputFn:this.maskInputFn})}if(fe(t.target,this.blockClass,this.blockSelector,!1)||s===t.oldValue)return;let o=this.attributes.find(l=>l.node===t.target);if(r.tagName==="IFRAME"&&i==="src"&&!this.keepIframeSrcFn(s))if(!r.contentDocument)i="rr_src";else return;if(o||(o={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(o)),i==="type"&&r.tagName==="INPUT"&&(t.oldValue||"").toLowerCase()==="password"&&r.setAttribute("data-rr-is-password","true"),!Mo(r.tagName,i)&&(o.attributes[i]=Do(this.doc,yt(r.tagName),yt(i),s),i==="style")){const l=n.createElement("span");t.oldValue&&l.setAttribute("style",t.oldValue);for(const a of Array.from(r.style)){const c=r.style.getPropertyValue(a),u=r.style.getPropertyPriority(a);c!==l.style.getPropertyValue(a)||u!==l.style.getPropertyPriority(a)?u===""?o.styleDiff[a]=c:o.styleDiff[a]=[c,u]:o._unchangedStyles[a]=[c,u]}for(const a of Array.from(l.style))r.style.getPropertyValue(a)===""&&(o.styleDiff[a]=!1)}break}case"childList":{if(fe(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),s=Xt(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);fe(t.target,this.blockClass,this.blockSelector,!1)||Br(r,this.mirror)||!Dc(r,this.mirror)||(this.addedSet.has(r)?(si(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&i===-1||Wo(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[As(i,s)]?si(this.movedSet,r):this.removes.push({parentId:s,id:i,isShadow:Xt(t.target)&&en(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(Br(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[As(this.mirror.getId(t),r)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);fe(t,this.blockClass,this.blockSelector,!1)||(t.childNodes.forEach(r=>this.genAdds(r)),ii(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 si(e,t){e.delete(t),t.childNodes.forEach(n=>si(e,n))}function Ls(e,t,n){return e.length===0?!1:Go(e,t,n)}function Go(e,t,n){const{parentNode:r}=t;if(!r)return!1;const i=n.getId(r);return e.some(s=>s.id===i)?!0:Go(e,r,n)}function Rs(e,t){return e.size===0?!1:Ho(e,t)}function Ho(e,t){const{parentNode:n}=t;return n?e.has(n)?!0:Ho(e,n):!1}let tn;function Kc(e){tn=e}function jc(){tn=void 0}const B=e=>tn?(...n)=>{try{return e(...n)}catch(r){if(tn&&tn(r)===!0)return;throw r}}:e,dt=[];function kn(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 qo(e,t){var n,r;const i=new Wc;dt.push(i),i.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const o=(r=(n=window==null?void 0:window.Zone)===null||n===void 0?void 0:n.__symbol__)===null||r===void 0?void 0:r.call(n,"MutationObserver");o&&window[o]&&(s=window[o]);const l=new s(B(i.processMutations.bind(i)));return l.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),l}function Vc({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(t.mousemove===!1)return()=>{};const i=typeof t.mousemove=="number"?t.mousemove:50,s=typeof t.mousemoveCallback=="number"?t.mousemoveCallback:500;let o=[],l;const a=dn(B(d=>{const p=Date.now()-l;e(o.map(h=>(h.timeOffset-=p,h)),d),o=[],l=null}),s),c=B(dn(B(d=>{const p=kn(d),{clientX:h,clientY:f}=ri(d)?d.changedTouches[0]:d;l||(l=or()),o.push({x:h,y:f,id:r.getId(p),timeOffset:or()-l}),a(typeof DragEvent<"u"&&d instanceof DragEvent?V.Drag:d instanceof MouseEvent?V.MouseMove:V.TouchMove)}),i,{trailing:!1})),u=[pe("mousemove",c,n),pe("touchmove",c,n),pe("drag",c,n)];return B(()=>{u.forEach(d=>d())})}function zc({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:s}){if(s.mouseInteraction===!1)return()=>{};const o=s.mouseInteraction===!0||s.mouseInteraction===void 0?{}:s.mouseInteraction,l=[];let a=null;const c=u=>d=>{const p=kn(d);if(fe(p,r,i,!0))return;let h=null,f=u;if("pointerType"in d){switch(d.pointerType){case"mouse":h=Pe.Mouse;break;case"touch":h=Pe.Touch;break;case"pen":h=Pe.Pen;break}h===Pe.Touch?we[u]===we.MouseDown?f="TouchStart":we[u]===we.MouseUp&&(f="TouchEnd"):Pe.Pen}else ri(d)&&(h=Pe.Touch);h!==null?(a=h,(f.startsWith("Touch")&&h===Pe.Touch||f.startsWith("Mouse")&&h===Pe.Mouse)&&(h=null)):we[u]===we.Click&&(h=a,a=null);const g=ri(d)?d.changedTouches[0]:d;if(!g)return;const v=n.getId(p),{clientX:y,clientY:m}=g;B(e)(Object.assign({type:we[f],id:v,x:y,y:m},h!==null&&{pointerType:h}))};return Object.keys(we).filter(u=>Number.isNaN(Number(u))&&!u.endsWith("_Departed")&&o[u]!==!1).forEach(u=>{let d=yt(u);const p=c(u);if(window.PointerEvent)switch(we[u]){case we.MouseDown:case we.MouseUp:d=d.replace("mouse","pointer");break;case we.TouchStart:case we.TouchEnd:return}l.push(pe(d,p,t))}),B(()=>{l.forEach(u=>u())})}function $o({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:s}){const o=B(dn(B(l=>{const a=kn(l);if(!a||fe(a,r,i,!0))return;const c=n.getId(a);if(a===t&&t.defaultView){const u=Po(t.defaultView);e({id:c,x:u.left,y:u.top})}else e({id:c,x:a.scrollLeft,y:a.scrollTop})}),s.scroll||100));return pe("scroll",o,t)}function Gc({viewportResizeCb:e},{win:t}){let n=-1,r=-1;const i=B(dn(B(()=>{const s=Fo(),o=Bo();(n!==s||r!==o)&&(e({width:Number(o),height:Number(s)}),n=s,r=o)}),200));return pe("resize",i,t)}function Ts(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const Hc=["INPUT","TEXTAREA","SELECT"],xs=new WeakMap;function qc({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,ignoreClass:s,ignoreSelector:o,maskInputOptions:l,maskInputFn:a,sampling:c,userTriggeredOnInput:u}){function d(m){let w=kn(m);const b=m.isTrusted,S=w&&w.tagName;if(w&&S==="OPTION"&&(w=w.parentElement),!w||!S||Hc.indexOf(S)<0||fe(w,r,i,!0)||w.classList.contains(s)||o&&w.matches(o))return;let C=w.value,I=!1;const _=$i(w)||"";_==="radio"||_==="checkbox"?I=w.checked:(l[S.toLowerCase()]||l[_])&&(C=qi({element:w,maskInputOptions:l,tagName:S,type:_,value:C,maskInputFn:a})),p(w,B(Ts)({text:C,isChecked:I,userTriggered:b},u));const k=w.name;_==="radio"&&k&&I&&t.querySelectorAll(`input[type="radio"][name="${k}"]`).forEach(L=>{L!==w&&p(L,B(Ts)({text:L.value,isChecked:!I,userTriggered:!1},u))})}function p(m,w){const b=xs.get(m);if(!b||b.text!==w.text||b.isChecked!==w.isChecked){xs.set(m,w);const S=n.getId(m);B(e)(Object.assign(Object.assign({},w),{id:S}))}}const f=(c.input==="last"?["change"]:["input","change"]).map(m=>pe(m,B(d),t)),g=t.defaultView;if(!g)return()=>{f.forEach(m=>m())};const v=g.Object.getOwnPropertyDescriptor(g.HTMLInputElement.prototype,"value"),y=[[g.HTMLInputElement.prototype,"value"],[g.HTMLInputElement.prototype,"checked"],[g.HTMLSelectElement.prototype,"value"],[g.HTMLTextAreaElement.prototype,"value"],[g.HTMLSelectElement.prototype,"selectedIndex"],[g.HTMLOptionElement.prototype,"selected"]];return v&&v.set&&f.push(...y.map(m=>Er(m[0],m[1],{set(){B(d)({target:this,isTrusted:!1})}},!1,g))),B(()=>{f.forEach(m=>m())})}function ar(e){const t=[];function n(r,i){if(xn("CSSGroupingRule")&&r.parentRule instanceof CSSGroupingRule||xn("CSSMediaRule")&&r.parentRule instanceof CSSMediaRule||xn("CSSSupportsRule")&&r.parentRule instanceof CSSSupportsRule||xn("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 Ye(e,t,n){let r,i;return e?(e.ownerNode?r=t.getId(e.ownerNode):i=n.getId(e),{styleId:i,id:r}):{}}function $c({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:B((u,d,p)=>{const[h,f]=p,{id:g,styleId:v}=Ye(d,t,n.styleMirror);return(g&&g!==-1||v&&v!==-1)&&e({id:g,styleId:v,adds:[{rule:h,index:f}]}),u.apply(d,p)})});const s=r.CSSStyleSheet.prototype.deleteRule;r.CSSStyleSheet.prototype.deleteRule=new Proxy(s,{apply:B((u,d,p)=>{const[h]=p,{id:f,styleId:g}=Ye(d,t,n.styleMirror);return(f&&f!==-1||g&&g!==-1)&&e({id:f,styleId:g,removes:[{index:h}]}),u.apply(d,p)})});let o;r.CSSStyleSheet.prototype.replace&&(o=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(o,{apply:B((u,d,p)=>{const[h]=p,{id:f,styleId:g}=Ye(d,t,n.styleMirror);return(f&&f!==-1||g&&g!==-1)&&e({id:f,styleId:g,replace:h}),u.apply(d,p)})}));let l;r.CSSStyleSheet.prototype.replaceSync&&(l=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(l,{apply:B((u,d,p)=>{const[h]=p,{id:f,styleId:g}=Ye(d,t,n.styleMirror);return(f&&f!==-1||g&&g!==-1)&&e({id:f,styleId:g,replaceSync:h}),u.apply(d,p)})}));const a={};On("CSSGroupingRule")?a.CSSGroupingRule=r.CSSGroupingRule:(On("CSSMediaRule")&&(a.CSSMediaRule=r.CSSMediaRule),On("CSSConditionRule")&&(a.CSSConditionRule=r.CSSConditionRule),On("CSSSupportsRule")&&(a.CSSSupportsRule=r.CSSSupportsRule));const c={};return Object.entries(a).forEach(([u,d])=>{c[u]={insertRule:d.prototype.insertRule,deleteRule:d.prototype.deleteRule},d.prototype.insertRule=new Proxy(c[u].insertRule,{apply:B((p,h,f)=>{const[g,v]=f,{id:y,styleId:m}=Ye(h.parentStyleSheet,t,n.styleMirror);return(y&&y!==-1||m&&m!==-1)&&e({id:y,styleId:m,adds:[{rule:g,index:[...ar(h),v||0]}]}),p.apply(h,f)})}),d.prototype.deleteRule=new Proxy(c[u].deleteRule,{apply:B((p,h,f)=>{const[g]=f,{id:v,styleId:y}=Ye(h.parentStyleSheet,t,n.styleMirror);return(v&&v!==-1||y&&y!==-1)&&e({id:v,styleId:y,removes:[{index:[...ar(h),g]}]}),p.apply(h,f)})})}),B(()=>{r.CSSStyleSheet.prototype.insertRule=i,r.CSSStyleSheet.prototype.deleteRule=s,o&&(r.CSSStyleSheet.prototype.replace=o),l&&(r.CSSStyleSheet.prototype.replaceSync=l),Object.entries(a).forEach(([u,d])=>{d.prototype.insertRule=c[u].insertRule,d.prototype.deleteRule=c[u].deleteRule})})}function Zo({mirror:e,stylesheetManager:t},n){var r,i,s;let o=null;n.nodeName==="#document"?o=e.getId(n):o=e.getId(n.host);const l=n.nodeName==="#document"?(r=n.defaultView)===null||r===void 0?void 0:r.Document:(s=(i=n.ownerDocument)===null||i===void 0?void 0:i.defaultView)===null||s===void 0?void 0:s.ShadowRoot,a=Object.getOwnPropertyDescriptor(l==null?void 0:l.prototype,"adoptedStyleSheets");return o===null||o===-1||!l||!a?()=>{}:(Object.defineProperty(n,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get(){var c;return(c=a.get)===null||c===void 0?void 0:c.call(this)},set(c){var u;const d=(u=a.set)===null||u===void 0?void 0:u.call(this,c);if(o!==null&&o!==-1)try{t.adoptStyleSheets(c,o)}catch{}return d}}),B(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})}))}function Zc({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:i}){const s=i.CSSStyleDeclaration.prototype.setProperty;i.CSSStyleDeclaration.prototype.setProperty=new Proxy(s,{apply:B((l,a,c)=>{var u;const[d,p,h]=c;if(n.has(d))return s.apply(a,[d,p,h]);const{id:f,styleId:g}=Ye((u=a.parentRule)===null||u===void 0?void 0:u.parentStyleSheet,t,r.styleMirror);return(f&&f!==-1||g&&g!==-1)&&e({id:f,styleId:g,set:{property:d,value:p,priority:h},index:ar(a.parentRule)}),l.apply(a,c)})});const o=i.CSSStyleDeclaration.prototype.removeProperty;return i.CSSStyleDeclaration.prototype.removeProperty=new Proxy(o,{apply:B((l,a,c)=>{var u;const[d]=c;if(n.has(d))return o.apply(a,[d]);const{id:p,styleId:h}=Ye((u=a.parentRule)===null||u===void 0?void 0:u.parentStyleSheet,t,r.styleMirror);return(p&&p!==-1||h&&h!==-1)&&e({id:p,styleId:h,remove:{property:d},index:ar(a.parentRule)}),l.apply(a,c)})}),B(()=>{i.CSSStyleDeclaration.prototype.setProperty=s,i.CSSStyleDeclaration.prototype.removeProperty=o})}function Yc({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:i,doc:s}){const o=B(a=>dn(B(c=>{const u=kn(c);if(!u||fe(u,t,n,!0))return;const{currentTime:d,volume:p,muted:h,playbackRate:f}=u;e({type:a,id:r.getId(u),currentTime:d,volume:p,muted:h,playbackRate:f})}),i.media||500)),l=[pe("play",o(0),s),pe("pause",o(1),s),pe("seeked",o(2),s),pe("volumechange",o(3),s),pe("ratechange",o(4),s)];return B(()=>{l.forEach(a=>a())})}function Jc({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],i=new WeakMap,s=n.FontFace;n.FontFace=function(a,c,u){const d=new s(a,c,u);return i.set(d,{family:a,buffer:typeof c!="string",descriptors:u,fontSource:typeof c=="string"?c:JSON.stringify(Array.from(new Uint8Array(c)))}),d};const o=Cn(t.fonts,"add",function(l){return function(a){return setTimeout(B(()=>{const c=i.get(a);c&&(e(c),i.delete(a))}),0),l.apply(this,[a])}});return r.push(()=>{n.FontFace=s}),r.push(o),B(()=>{r.forEach(l=>l())})}function Qc(e){const{doc:t,mirror:n,blockClass:r,blockSelector:i,selectionCb:s}=e;let o=!0;const l=B(()=>{const a=t.getSelection();if(!a||o&&(a!=null&&a.isCollapsed))return;o=a.isCollapsed||!1;const c=[],u=a.rangeCount||0;for(let d=0;d<u;d++){const p=a.getRangeAt(d),{startContainer:h,startOffset:f,endContainer:g,endOffset:v}=p;fe(h,r,i,!0)||fe(g,r,i,!0)||c.push({start:n.getId(h),startOffset:f,end:n.getId(g),endOffset:v})}s({ranges:c})});return l(),pe("selectionchange",l)}function Xc(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:i,scrollCb:s,viewportResizeCb:o,inputCb:l,mediaInteractionCb:a,styleSheetRuleCb:c,styleDeclarationCb:u,canvasMutationCb:d,fontCb:p,selectionCb:h}=e;e.mutationCb=(...f)=>{t.mutation&&t.mutation(...f),n(...f)},e.mousemoveCb=(...f)=>{t.mousemove&&t.mousemove(...f),r(...f)},e.mouseInteractionCb=(...f)=>{t.mouseInteraction&&t.mouseInteraction(...f),i(...f)},e.scrollCb=(...f)=>{t.scroll&&t.scroll(...f),s(...f)},e.viewportResizeCb=(...f)=>{t.viewportResize&&t.viewportResize(...f),o(...f)},e.inputCb=(...f)=>{t.input&&t.input(...f),l(...f)},e.mediaInteractionCb=(...f)=>{t.mediaInteaction&&t.mediaInteaction(...f),a(...f)},e.styleSheetRuleCb=(...f)=>{t.styleSheetRule&&t.styleSheetRule(...f),c(...f)},e.styleDeclarationCb=(...f)=>{t.styleDeclaration&&t.styleDeclaration(...f),u(...f)},e.canvasMutationCb=(...f)=>{t.canvasMutation&&t.canvasMutation(...f),d(...f)},e.fontCb=(...f)=>{t.font&&t.font(...f),p(...f)},e.selectionCb=(...f)=>{t.selection&&t.selection(...f),h(...f)}}function eu(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};Xc(e,t);const r=qo(e,e.doc),i=Vc(e),s=zc(e),o=$o(e),l=Gc(e,{win:n}),a=qc(e),c=Yc(e),u=$c(e,{win:n}),d=Zo(e,e.doc),p=Zc(e,{win:n}),h=e.collectFonts?Jc(e):()=>{},f=Qc(e),g=[];for(const v of e.plugins)g.push(v.observer(v.callback,n,v.options));return B(()=>{dt.forEach(v=>v.reset()),r.disconnect(),i(),s(),o(),l(),a(),c(),u(),d(),p(),h(),f(),g.forEach(v=>v())})}function xn(e){return typeof window[e]<"u"}function On(e){return!!(typeof window[e]<"u"&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}class Os{constructor(t){this.generateIdFn=t,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(t,n,r,i){const s=r||this.getIdToRemoteIdMap(t),o=i||this.getRemoteIdToIdMap(t);let l=s.get(n);return l||(l=this.generateIdFn(),s.set(n,l),o.set(l,n)),l}getIds(t,n){const r=this.getIdToRemoteIdMap(t),i=this.getRemoteIdToIdMap(t);return n.map(s=>this.getId(t,s,r,i))}getRemoteId(t,n,r){const i=r||this.getRemoteIdToIdMap(t);if(typeof n!="number")return n;const s=i.get(n);return s||-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 tu{constructor(t){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Os(Uo),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Os(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 i=this.crossOriginIframeMap.get(t.source);if(!i)return;const s=this.transformCrossOriginEvent(i,n.data.event);s&&this.wrappedEmit(s,n.data.isCheckout)}transformCrossOriginEvent(t,n){var r;switch(n.type){case j.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:j.IncrementalSnapshot,data:{source:V.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:n.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case j.Meta:case j.Load:case j.DomContentLoaded:return!1;case j.Plugin:return n;case j.Custom:return this.replaceIds(n.data.payload,t,["id","parentId","previousId","nextId"]),n;case j.IncrementalSnapshot:switch(n.data.source){case V.Mutation:return n.data.adds.forEach(i=>{this.replaceIds(i,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(i.node,t);const s=this.crossOriginIframeRootIdMap.get(t);s&&this.patchRootIdOnNode(i.node,s)}),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 V.Drag:case V.TouchMove:case V.MouseMove:return n.data.positions.forEach(i=>{this.replaceIds(i,t,["id"])}),n;case V.ViewportResize:return!1;case V.MediaInteraction:case V.MouseInteraction:case V.Scroll:case V.CanvasMutation:case V.Input:return this.replaceIds(n.data,t,["id"]),n;case V.StyleSheetRule:case V.StyleDeclaration:return this.replaceIds(n.data,t,["id"]),this.replaceStyleIds(n.data,t,["styleId"]),n;case V.Font:return n;case V.Selection:return n.data.ranges.forEach(i=>{this.replaceIds(i,t,["start","end"])}),n;case V.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 s of i)!Array.isArray(n[s])&&typeof n[s]!="number"||(Array.isArray(n[s])?n[s]=t.getIds(r,n[s]):n[s]=t.getId(r,n[s]));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!==se.Document&&!t.rootId&&(t.rootId=n),"childNodes"in t&&t.childNodes.forEach(r=>{this.patchRootIdOnNode(r,n)})}}class nu{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(!en(t)||this.shadowDoms.has(t))return;this.shadowDoms.add(t);const r=qo(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($o(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(Zo({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(Cn(t.prototype,"attachShadow",function(i){return function(s){const o=i.call(this,s);return this.shadowRoot&&zo(this)&&r.addShadowRoot(this.shadowRoot,n),o}}))}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 ru(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 iu(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function l(u){try{c(r.next(u))}catch(d){o(d)}}function a(u){try{c(r.throw(u))}catch(d){o(d)}}function c(u){u.done?s(u.value):i(u.value).then(l,a)}c((r=r.apply(e,t||[])).next())})}var Ut="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",su=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Un=0;Un<Ut.length;Un++)su[Ut.charCodeAt(Un)]=Un;var ou=function(e){var t=new Uint8Array(e),n,r=t.length,i="";for(n=0;n<r;n+=3)i+=Ut[t[n]>>2],i+=Ut[(t[n]&3)<<4|t[n+1]>>4],i+=Ut[(t[n+1]&15)<<2|t[n+2]>>6],i+=Ut[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 Us=new Map;function au(e,t){let n=Us.get(e);return n||(n=new Map,Us.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}const Yo=(e,t,n)=>{if(!e||!(Qo(e,t)||typeof e=="object"))return;const r=e.constructor.name,i=au(n,r);let s=i.indexOf(e);return s===-1&&(s=i.length,i.push(e)),s};function Vn(e,t,n){if(e instanceof Array)return e.map(r=>Vn(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=ou(e);return{rr_type:r,base64:i}}else{if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Vn(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:[Vn(e.data,t,n),e.width,e.height]};if(Qo(e,t)||typeof e=="object"){const r=e.constructor.name,i=Yo(e,t,n);return{rr_type:r,index:i}}}}return e}const Jo=(e,t,n)=>[...e].map(r=>Vn(r,t,n)),Qo=(e,t)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(i=>typeof t[i]=="function").find(i=>e instanceof t[i]);function lu(e,t,n,r){const i=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const o of s)try{if(typeof t.CanvasRenderingContext2D.prototype[o]!="function")continue;const l=Cn(t.CanvasRenderingContext2D.prototype,o,function(a){return function(...c){return fe(this.canvas,n,r,!0)||setTimeout(()=>{const u=Jo([...c],t,this);e(this.canvas,{type:Ft["2D"],property:o,args:u})},0),a.apply(this,c)}});i.push(l)}catch{const a=Er(t.CanvasRenderingContext2D.prototype,o,{set(c){e(this.canvas,{type:Ft["2D"],property:o,args:[c],setter:!0})}});i.push(a)}return()=>{i.forEach(o=>o())}}function cu(e){return e==="experimental-webgl"?"webgl":e}function Ds(e,t,n,r){const i=[];try{const s=Cn(e.HTMLCanvasElement.prototype,"getContext",function(o){return function(l,...a){if(!fe(this,t,n,!0)){const c=cu(l);if("__context"in this||(this.__context=c),r&&["webgl","webgl2"].includes(c))if(a[0]&&typeof a[0]=="object"){const u=a[0];u.preserveDrawingBuffer||(u.preserveDrawingBuffer=!0)}else a.splice(0,1,{preserveDrawingBuffer:!0})}return o.apply(this,[l,...a])}});i.push(s)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{i.forEach(s=>s())}}function Ms(e,t,n,r,i,s,o){const l=[],a=Object.getOwnPropertyNames(e);for(const c of a)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(c))try{if(typeof e[c]!="function")continue;const u=Cn(e,c,function(d){return function(...p){const h=d.apply(this,p);if(Yo(h,o,this),"tagName"in this.canvas&&!fe(this.canvas,r,i,!0)){const f=Jo([...p],o,this),g={type:t,property:c,args:f};n(this.canvas,g)}return h}});l.push(u)}catch{const d=Er(e,c,{set(p){n(this.canvas,{type:t,property:c,args:[p],setter:!0})}});l.push(d)}return l}function uu(e,t,n,r,i){const s=[];return s.push(...Ms(t.WebGLRenderingContext.prototype,Ft.WebGL,e,n,r,i,t)),typeof t.WebGL2RenderingContext<"u"&&s.push(...Ms(t.WebGL2RenderingContext.prototype,Ft.WebGL2,e,n,r,i,t)),()=>{s.forEach(o=>o())}}function du(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),i=0,s=n.length;i<s;++i)r[i]=n.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}function hu(e,t,n){var r=t===void 0?null:t,i=n===void 0?!1:n,s=du(e,i),o=s.indexOf(`
19
- `,10)+1,l=s.substring(o)+(r?"//# sourceMappingURL="+r:""),a=new Blob([l],{type:"application/javascript"});return URL.createObjectURL(a)}function pu(e,t,n){var r;return function(s){return r=r||hu(e,t,n),new Worker(r,s)}}var fu=pu("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",null,!1);class gu{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,c)=>{(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(c)};const{sampling:n="all",win:r,blockClass:i,blockSelector:s,recordCanvas:o,dataURLOptions:l}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,o&&n==="all"&&this.initCanvasMutationObserver(r,i,s),o&&typeof n=="number"&&this.initCanvasFPSObserver(n,r,i,s,{dataURLOptions:l})}initCanvasFPSObserver(t,n,r,i,s){const o=Ds(n,r,i,!0),l=new Map,a=new fu;a.onmessage=f=>{const{id:g}=f.data;if(l.set(g,!1),!("base64"in f.data))return;const{base64:v,type:y,width:m,height:w}=f.data;this.mutationCb({id:g,type:Ft["2D"],commands:[{property:"clearRect",args:[0,0,m,w]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:v}],type:y}]},0,0]}]})};const c=1e3/t;let u=0,d;const p=()=>{const f=[];return n.document.querySelectorAll("canvas").forEach(g=>{fe(g,r,i,!0)||f.push(g)}),f},h=f=>{if(u&&f-u<c){d=requestAnimationFrame(h);return}u=f,p().forEach(g=>iu(this,void 0,void 0,function*(){var v;const y=this.mirror.getId(g);if(l.get(y))return;if(l.set(y,!0),["webgl","webgl2"].includes(g.__context)){const w=g.getContext(g.__context);((v=w==null?void 0:w.getContextAttributes())===null||v===void 0?void 0:v.preserveDrawingBuffer)===!1&&w.clear(w.COLOR_BUFFER_BIT)}const m=yield createImageBitmap(g);a.postMessage({id:y,bitmap:m,width:g.width,height:g.height,dataURLOptions:s.dataURLOptions},[m])})),d=requestAnimationFrame(h)};d=requestAnimationFrame(h),this.resetObservers=()=>{o(),cancelAnimationFrame(d)}}initCanvasMutationObserver(t,n,r){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const i=Ds(t,n,r,!1),s=lu(this.processMutation.bind(this),t,n,r),o=uu(this.processMutation.bind(this),t,n,r,this.mirror);this.resetObservers=()=>{i(),s(),o()}}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(o=>ru(o,["type"])),{type:s}=r[0];this.mutationCb({id:n,type:s,commands:i}),this.pendingCanvasMutations.delete(t)}}class mu{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new Nc,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 s of t){let o;if(this.styleMirror.has(s))o=this.styleMirror.getId(s);else{o=this.styleMirror.add(s);const l=Array.from(s.rules||CSSRule);i.push({styleId:o,rules:l.map((a,c)=>({rule:xo(a),index:c}))})}r.styleIds.push(o)}i.length>0&&(r.styles=i),this.adoptedStyleSheetCb(r)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}class yu{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 ie(e){return Object.assign(Object.assign({},e),{timestamp:or()})}let te,zn,Wr,lr=!1;const Ae=dc();function _n(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:i="rr-block",blockSelector:s=null,ignoreClass:o="rr-ignore",ignoreSelector:l=null,maskTextClass:a="rr-mask",maskTextSelector:c=null,inlineStylesheet:u=!0,maskAllInputs:d,maskInputOptions:p,slimDOMOptions:h,maskInputFn:f,maskTextFn:g,hooks:v,packFn:y,sampling:m={},dataURLOptions:w={},mousemoveWait:b,recordCanvas:S=!1,recordCrossOriginIframes:C=!1,recordAfter:I=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:_=!1,collectFonts:k=!1,inlineImages:L=!1,plugins:x,keepIframeSrcFn:K=()=>!1,ignoreCSSAttributes:F=new Set([]),errorHandler:P}=e;Kc(P);const R=C?window.parent===window:!0;let O=!1;if(!R)try{window.parent.document&&(O=!1)}catch{O=!0}if(R&&!t)throw new Error("emit function is required");b!==void 0&&m.mousemove===void 0&&(m.mousemove=b),Ae.reset();const z=d===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:p!==void 0?p:{password:!0},X=h===!0||h==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:h==="all",headMetaDescKeywords:h==="all"}:h||{};Mc();let ae,ue=0;const ke=D=>{for(const ve of x||[])ve.eventProcessor&&(D=ve.eventProcessor(D));return y&&!O&&(D=y(D)),D};te=(D,ve)=>{var G;if(!((G=dt[0])===null||G===void 0)&&G.isFrozen()&&D.type!==j.FullSnapshot&&!(D.type===j.IncrementalSnapshot&&D.data.source===V.Mutation)&&dt.forEach(le=>le.unfreeze()),R)t==null||t(ke(D),ve);else if(O){const le={type:"rrweb",event:ke(D),origin:window.location.origin,isCheckout:ve};window.parent.postMessage(le,"*")}if(D.type===j.FullSnapshot)ae=D,ue=0;else if(D.type===j.IncrementalSnapshot){if(D.data.source===V.Mutation&&D.data.isAttachIframe)return;ue++;const le=r&&ue>=r,at=n&&D.timestamp-ae.timestamp>n;(le||at)&&zn(!0)}};const J=D=>{te(ie({type:j.IncrementalSnapshot,data:Object.assign({source:V.Mutation},D)}))},kt=D=>te(ie({type:j.IncrementalSnapshot,data:Object.assign({source:V.Scroll},D)})),Ht=D=>te(ie({type:j.IncrementalSnapshot,data:Object.assign({source:V.CanvasMutation},D)})),Tn=D=>te(ie({type:j.IncrementalSnapshot,data:Object.assign({source:V.AdoptedStyleSheet},D)})),_e=new mu({mutationCb:J,adoptedStyleSheetCb:Tn}),xe=new tu({mirror:Ae,mutationCb:J,stylesheetManager:_e,recordCrossOriginIframes:C,wrappedEmit:te});for(const D of x||[])D.getMirror&&D.getMirror({nodeMirror:Ae,crossOriginIframeMirror:xe.crossOriginIframeMirror,crossOriginIframeStyleMirror:xe.crossOriginIframeStyleMirror});const ot=new yu;Wr=new gu({recordCanvas:S,mutationCb:Ht,win:window,blockClass:i,blockSelector:s,mirror:Ae,sampling:m.canvas,dataURLOptions:w});const Ee=new nu({mutationCb:J,scrollCb:kt,bypassOptions:{blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:u,maskInputOptions:z,dataURLOptions:w,maskTextFn:g,maskInputFn:f,recordCanvas:S,inlineImages:L,sampling:m,slimDOMOptions:X,iframeManager:xe,stylesheetManager:_e,canvasManager:Wr,keepIframeSrcFn:K,processedNodeManager:ot},mirror:Ae});zn=(D=!1)=>{te(ie({type:j.Meta,data:{href:window.location.href,width:Bo(),height:Fo()}}),D),_e.reset(),Ee.init(),dt.forEach(G=>G.lock());const ve=Uc(document,{mirror:Ae,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:u,maskAllInputs:z,maskTextFn:g,slimDOM:X,dataURLOptions:w,recordCanvas:S,inlineImages:L,onSerialize:G=>{Ko(G,Ae)&&xe.addIframe(G),jo(G,Ae)&&_e.trackLinkElement(G),ii(G)&&Ee.addShadowRoot(G.shadowRoot,document)},onIframeLoad:(G,le)=>{xe.attachIframe(G,le),Ee.observeAttachShadow(G)},onStylesheetLoad:(G,le)=>{_e.attachLinkElement(G,le)},keepIframeSrcFn:K});if(!ve)return console.warn("Failed to snapshot the document");te(ie({type:j.FullSnapshot,data:{node:ve,initialOffset:Po(window)}}),D),dt.forEach(G=>G.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&_e.adoptStyleSheets(document.adoptedStyleSheets,Ae.getId(document))};try{const D=[],ve=le=>{var at;return B(eu)({mutationCb:J,mousemoveCb:(Q,Dr)=>te(ie({type:j.IncrementalSnapshot,data:{source:Dr,positions:Q}})),mouseInteractionCb:Q=>te(ie({type:j.IncrementalSnapshot,data:Object.assign({source:V.MouseInteraction},Q)})),scrollCb:kt,viewportResizeCb:Q=>te(ie({type:j.IncrementalSnapshot,data:Object.assign({source:V.ViewportResize},Q)})),inputCb:Q=>te(ie({type:j.IncrementalSnapshot,data:Object.assign({source:V.Input},Q)})),mediaInteractionCb:Q=>te(ie({type:j.IncrementalSnapshot,data:Object.assign({source:V.MediaInteraction},Q)})),styleSheetRuleCb:Q=>te(ie({type:j.IncrementalSnapshot,data:Object.assign({source:V.StyleSheetRule},Q)})),styleDeclarationCb:Q=>te(ie({type:j.IncrementalSnapshot,data:Object.assign({source:V.StyleDeclaration},Q)})),canvasMutationCb:Ht,fontCb:Q=>te(ie({type:j.IncrementalSnapshot,data:Object.assign({source:V.Font},Q)})),selectionCb:Q=>{te(ie({type:j.IncrementalSnapshot,data:Object.assign({source:V.Selection},Q)}))},blockClass:i,ignoreClass:o,ignoreSelector:l,maskTextClass:a,maskTextSelector:c,maskInputOptions:z,inlineStylesheet:u,sampling:m,recordCanvas:S,inlineImages:L,userTriggeredOnInput:_,collectFonts:k,doc:le,maskInputFn:f,maskTextFn:g,keepIframeSrcFn:K,blockSelector:s,slimDOMOptions:X,dataURLOptions:w,mirror:Ae,iframeManager:xe,stylesheetManager:_e,shadowDomManager:Ee,processedNodeManager:ot,canvasManager:Wr,ignoreCSSAttributes:F,plugins:((at=x==null?void 0:x.filter(Q=>Q.observer))===null||at===void 0?void 0:at.map(Q=>({observer:Q.observer,options:Q.options,callback:Dr=>te(ie({type:j.Plugin,data:{plugin:Q.name,payload:Dr}}))})))||[]},v)};xe.addLoadListener(le=>{try{D.push(ve(le.contentDocument))}catch(at){console.warn(at)}});const G=()=>{zn(),D.push(ve(document)),lr=!0};return document.readyState==="interactive"||document.readyState==="complete"?G():(D.push(pe("DOMContentLoaded",()=>{te(ie({type:j.DomContentLoaded,data:{}})),I==="DOMContentLoaded"&&G()})),D.push(pe("load",()=>{te(ie({type:j.Load,data:{}})),I==="load"&&G()},window))),()=>{D.forEach(le=>le()),ot.destroy(),lr=!1,jc()}}catch(D){console.warn(D)}}_n.addCustomEvent=(e,t)=>{if(!lr)throw new Error("please add custom event after start recording");te(ie({type:j.Custom,data:{tag:e,payload:t}}))};_n.freezePage=()=>{dt.forEach(e=>e.freeze())};_n.takeFullSnapshot=e=>{if(!lr)throw new Error("please take full snapshot after start recording");zn(e)};_n.mirror=Ae;var Be=(e=>(e.Closed="close.click",e.Complete="survey.completed",e.FeedbackClosed="feedback.closed",e.PageChange="page.change",e.API="api",e.Override="override",e))(Be||{}),N=(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))(N||{});const hn={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 Dn;const vu=new Uint8Array(16);function wu(){if(!Dn&&(Dn=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Dn))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Dn(vu)}const ce=[];for(let e=0;e<256;++e)ce.push((e+256).toString(16).slice(1));function bu(e,t=0){return ce[e[t+0]]+ce[e[t+1]]+ce[e[t+2]]+ce[e[t+3]]+"-"+ce[e[t+4]]+ce[e[t+5]]+"-"+ce[e[t+6]]+ce[e[t+7]]+"-"+ce[e[t+8]]+ce[e[t+9]]+"-"+ce[e[t+10]]+ce[e[t+11]]+ce[e[t+12]]+ce[e[t+13]]+ce[e[t+14]]+ce[e[t+15]]}const Iu=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ns={randomUUID:Iu};function St(e,t,n){if(Ns.randomUUID&&!t&&!e)return Ns.randomUUID();e=e||{};const r=e.random||(e.rng||wu)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n=n||0;for(let i=0;i<16;++i)t[n+i]=r[i];return t}return bu(r)}const Su='.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}',Xo="360px",Cu="ul-app",ku="#e6e6e6",_u="#bd282a",Eu=500,Au=1030,ea=()=>{try{return window.parent.Intercom}catch{return null}},Lu=()=>{const e=ea();e&&(e.ul_wasVisible&&e("update",{hide_default_launcher:!1}),delete e.ul_wasVisible)},Ru=()=>{const e=ea();e&&(e.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),e.ul_wasVisible&&e("update",{hide_default_launcher:!0}))},Tu=Object.freeze(Object.defineProperty({__proto__:null,disable:Ru,enable:Lu},Symbol.toStringTag,{value:"Module"})),Ps=[Tu];class ta{static disable(){Ps.forEach(t=>t.disable())}static enable(){Ps.forEach(t=>t.enable())}}var xu=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"}},na=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=na.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 xu(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)}},ra=na;ra.defaultMaxListeners=10;const M=new ra,cr=e=>new Promise(t=>{setTimeout(()=>{t()},e)}),ia=({"userleap-platform":e})=>e!=="web";class sa{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 tt=new sa("sessionStorage"),Se=new sa("localStorage");class Ou{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 Uu={RATELIMIT_RESET_DEFAULT:10};let oa=!1,aa="",Mn=!1,la=!1,Gn=[];const Du=e=>e._config&&e._config.installationMethod?e._config.installationMethod:e._gtm?"web-gtm":e._segment?"web-segment":"web-snippet",oi=e=>{var t;(t=e==null?void 0:e.blockedURI)!=null&&t.includes(window.UserLeap._API_URL)&&(la=!0,console.warn(`[Sprig] ${e.blockedURI} is blocked by Content-Security-Policy`),document.removeEventListener("securitypolicyviolation",oi))},ai=(e="")=>{oa=!0,aa=e};function vt(e={}){const t={"Content-Type":"application/json","userleap-platform":"web","x-ul-sdk-version":"2.28.0","x-ul-installation-method":Du(e)};if(t["x-ul-package-version"]="1.1.3",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 Fs=async({shouldDropOnRateLimit:e,...t})=>{if(e)return{status:429};{const n=new Ou(t);return Gn.push(n),n.promise}},je=async(e,t)=>{const{retries:n=0,shouldDropOnRateLimit:r=!1,shouldRetryRequest:i=!1,...s}=t,o={url:e,options:s,retries:n,shouldDropOnRateLimit:r};if(Mn&&!i)return Fs(o);const l={ok:!1,reportError:!1};if(oa)return console.info(`UserLeap - ${aa}`),l;try{const a=await fetch(e,s);if(a.status===429)if(!Mn&&!r||i){Mn=!0;const u=a.headers.has("ratelimit-reset")?Number(a.headers.get("ratelimit-reset")):Uu.RATELIMIT_RESET_DEFAULT;return await cr(u*1e3),je(e,{...s,shouldDropOnRateLimit:r,shouldRetryRequest:!0})}else return Fs(o);if(Mn=!1,Gn.length&&(Gn.map(c=>{const u=c.payload;je(u.url,{...u.options,retries:u.retries,shouldDropOnRateLimit:u.shouldDropOnRateLimit}).then(d=>{c.resolveRequest(d)})}),Gn=[]),a.ok){if(a.status===249)return ai(),l;const c=await a.text();try{return c&&c!=="OK"&&(a.json=JSON.parse(c)),a}catch{return{ok:!1,reportError:!1,error:new Error(`failed parsing response json for ${e} - ${c}`)}}}return a}catch(a){const c=n+1;return c>5||la?{ok:!1,reportError:!1,error:a}:(await cr(Math.pow(2,n)*1e3),je(e,{...s,retries:c}))}},jt={Error:1,Warn:2,Info:3,Debug:4};let li=1e3,ur=jt.Debug,Bt=[];const Mu=e=>{const t=Object.entries(jt).find(n=>n[1]===e);return(t==null?void 0:t[0])??""},Nu=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),Pu=(e,t)=>`${Nu(t)}:${e}`,Fu=()=>{Bt=Bt.filter(e=>e.level<=ur)},Bu=()=>{Bt.length>li&&Bt.shift()},Ar=(e,t)=>{e>ur||(Bt.push({level:e,line:Pu(t,new Date)}),Bu())},pn=e=>{Ar(jt.Debug,e)},A=e=>{Ar(jt.Info,e)},ci=e=>{Ar(jt.Warn,e)},ca=e=>{Ar(jt.Error,e)},Wu=()=>Bt.map(e=>e.line),Ku=()=>new TextEncoder().encode(Wu().join(`
20
- `)),ua=async e=>{if(!e)return;const t=Ku();return je(e,{body:t,method:"PUT"})},ju=(e,t)=>{e!==void 0&&(li=e),t!==void 0&&(ur=t),pn(`Initializing logger with limit of ${li} lines and ${Mu(ur)} level`),Fu()};class Vu{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 da=new Vu(2),zu=e=>da.setLimit(e),Gu=async e=>da.execute(async()=>{var r;A(`Beginning upload of chunk ${e.chunkIndex} for survey: ${e.surveyId}`);const t=await je(e.uploadUrl,{body:e.data,method:"PUT"});A(`Completed upload of chunk ${e.chunkIndex} for survey: ${e.surveyId}`);const n=(r=t.headers)==null?void 0:r.get("ETag");if(!n)throw new Error(`Upload response did not include etag for upload ${e.uploadId}, part ${e.chunkIndex}`);return n}),ha=async({apiUrl:e,surveyId:t,uploadId:n,etags:r,headers:i,responseGroupUuid:s,replayDuration:o,eventDigest:l},a=!1)=>{var u;if(!a&&!n&&!r){A(`Cannot mark upload complete: isMobile: ${a} / uploadId: ${n} / etags: ${r}`);return}A(`Marking upload complete for survey: ${t}`);const c=await je(`${e}/sdk/1/completeSessionReplay`,{method:"POST",body:JSON.stringify({etags:r,uploadId:n,responseGroupUuid:s,surveyId:t,replayDuration:o,eventDigest:l,userAgent:(u=window==null?void 0:window.navigator)==null?void 0:u.userAgent}),headers:i,shouldRetryRequest:!0});return A(`Done marking upload complete for survey: ${t}`),c},Z=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,re=Object.keys,he=Array.isArray;function me(e,t){return typeof t!="object"||re(t).forEach(function(n){e[n]=t[n]}),e}typeof Promise>"u"||Z.Promise||(Z.Promise=Promise);const fn=Object.getPrototypeOf,Hu={}.hasOwnProperty;function Ce(e,t){return Hu.call(e,t)}function Wt(e,t){typeof t=="function"&&(t=t(fn(e))),(typeof Reflect>"u"?re:Reflect.ownKeys)(t).forEach(n=>{Ve(e,n,t[n])})}const pa=Object.defineProperty;function Ve(e,t,n,r){pa(e,t,me(n&&Ce(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function Dt(e){return{from:function(t){return e.prototype=Object.create(t.prototype),Ve(e.prototype,"constructor",e),{extend:Wt.bind(null,e.prototype)}}}}const qu=Object.getOwnPropertyDescriptor;function Yi(e,t){let n;return qu(e,t)||(n=fn(e))&&Yi(n,t)}const $u=[].slice;function dr(e,t,n){return $u.call(e,t,n)}function fa(e,t){return t(e)}function Zt(e){if(!e)throw new Error("Assertion Failed")}function ga(e){Z.setImmediate?setImmediate(e):setTimeout(e,0)}function ma(e,t){return e.reduce((n,r,i)=>{var s=t(r,i);return s&&(n[s[0]]=s[1]),n},{})}function ze(e,t){if(typeof t=="string"&&Ce(e,t))return e[t];if(!t)return e;if(typeof t!="string"){for(var n=[],r=0,i=t.length;r<i;++r){var s=ze(e,t[r]);n.push(s)}return n}var o=t.indexOf(".");if(o!==-1){var l=e[t.substr(0,o)];return l==null?void 0:ze(l,t.substr(o+1))}}function Te(e,t,n){if(e&&t!==void 0&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if(typeof t!="string"&&"length"in t){Zt(typeof n!="string"&&"length"in n);for(var r=0,i=t.length;r<i;++r)Te(e,t[r],n[r])}else{var s=t.indexOf(".");if(s!==-1){var o=t.substr(0,s),l=t.substr(s+1);if(l==="")n===void 0?he(e)&&!isNaN(parseInt(o))?e.splice(o,1):delete e[o]:e[o]=n;else{var a=e[o];a&&Ce(e,o)||(a=e[o]={}),Te(a,l,n)}}else n===void 0?he(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function ya(e){var t={};for(var n in e)Ce(e,n)&&(t[n]=e[n]);return t}const Zu=[].concat;function va(e){return Zu.apply([],e)}const wa="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(va([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>Z[e]),Yu=wa.map(e=>Z[e]);ma(wa,e=>[e,!0]);let Je=null;function En(e){Je=typeof WeakMap<"u"&&new WeakMap;const t=ui(e);return Je=null,t}function ui(e){if(!e||typeof e!="object")return e;let t=Je&&Je.get(e);if(t)return t;if(he(e)){t=[],Je&&Je.set(e,t);for(var n=0,r=e.length;n<r;++n)t.push(ui(e[n]))}else if(Yu.indexOf(e.constructor)>=0)t=e;else{const s=fn(e);for(var i in t=s===Object.prototype?{}:Object.create(s),Je&&Je.set(e,t),e)Ce(e,i)&&(t[i]=ui(e[i]))}return t}const{toString:Ju}={};function di(e){return Ju.call(e).slice(8,-1)}const hi=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Qu=typeof hi=="symbol"?function(e){var t;return e!=null&&(t=e[hi])&&t.apply(e)}:function(){return null},Tt={};function We(e){var t,n,r,i;if(arguments.length===1){if(he(e))return e.slice();if(this===Tt&&typeof e=="string")return[e];if(i=Qu(e)){for(n=[];!(r=i.next()).done;)n.push(r.value);return n}if(e==null)return[e];if(typeof(t=e.length)=="number"){for(n=new Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}const Ji=typeof Symbol<"u"?e=>e[Symbol.toStringTag]==="AsyncFunction":()=>!1;var Me=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function ba(e,t){Me=e,Ia=t}var Ia=()=>!0;const Xu=!new Error("").stack;function Ct(){if(Xu)try{throw Ct.arguments,new Error}catch(e){return e}return new Error}function pi(e,t){var n=e.stack;return n?(t=t||0,n.indexOf(e.name)===0&&(t+=(e.name+e.message).split(`
21
- `).length),n.split(`
22
- `).slice(t).filter(Ia).map(r=>`
23
- `+r).join("")):""}var Sa=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Qi=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Sa),ed={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function Mt(e,t){this._e=Ct(),this.name=e,this.message=t}function Ca(e,t){return e+". Errors: "+Object.keys(t).map(n=>t[n].toString()).filter((n,r,i)=>i.indexOf(n)===r).join(`
24
- `)}function hr(e,t,n,r){this._e=Ct(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=Ca(e,t)}function nn(e,t){this._e=Ct(),this.name="BulkError",this.failures=Object.keys(t).map(n=>t[n]),this.failuresByPos=t,this.message=Ca(e,t)}Dt(Mt).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+pi(this._e,2))}},toString:function(){return this.name+": "+this.message}}),Dt(hr).from(Mt),Dt(nn).from(Mt);var Xi=Qi.reduce((e,t)=>(e[t]=t+"Error",e),{});const td=Mt;var U=Qi.reduce((e,t)=>{var n=t+"Error";function r(i,s){this._e=Ct(),this.name=n,i?typeof i=="string"?(this.message=`${i}${s?`
25
- `+s:""}`,this.inner=s||null):typeof i=="object"&&(this.message=`${i.name} ${i.message}`,this.inner=i):(this.message=ed[t]||n,this.inner=null)}return Dt(r).from(td),e[t]=r,e},{});U.Syntax=SyntaxError,U.Type=TypeError,U.Range=RangeError;var Bs=Sa.reduce((e,t)=>(e[t+"Error"]=U[t],e),{}),Hn=Qi.reduce((e,t)=>(["Syntax","Type","Range"].indexOf(t)===-1&&(e[t+"Error"]=U[t]),e),{});function q(){}function gn(e){return e}function nd(e,t){return e==null||e===gn?t:function(n){return t(e(n))}}function wt(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function rd(e,t){return e===q?t:function(){var n=e.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var s=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?wt(r,this.onsuccess):r),i&&(this.onerror=this.onerror?wt(i,this.onerror):i),s!==void 0?s:n}}function id(e,t){return e===q?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?wt(n,this.onsuccess):n),r&&(this.onerror=this.onerror?wt(r,this.onerror):r)}}function sd(e,t){return e===q?t:function(n){var r=e.apply(this,arguments);me(n,r);var i=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?wt(i,this.onsuccess):i),s&&(this.onerror=this.onerror?wt(s,this.onerror):s),r===void 0?o===void 0?void 0:o:me(r,o)}}function od(e,t){return e===q?t:function(){return t.apply(this,arguments)!==!1&&e.apply(this,arguments)}}function es(e,t){return e===q?t:function(){var n=e.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,i=arguments.length,s=new Array(i);i--;)s[i]=arguments[i];return n.then(function(){return t.apply(r,s)})}return t.apply(this,arguments)}}Hn.ModifyError=hr,Hn.DexieError=Mt,Hn.BulkError=nn;var mn={};const ka=100,[fi,pr,gi]=typeof Promise>"u"?[]:(()=>{let e=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[e,fn(e),e];const t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,fn(t),e]})(),_a=pr&&pr.then,qn=fi&&fi.constructor,ts=!!gi;var mi=!1,ad=gi?()=>{gi.then(Nn)}:Z.setImmediate?setImmediate.bind(null,Nn):Z.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{Nn(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(Nn,0)},rn=function(e,t){Yt.push([e,t]),fr&&(ad(),fr=!1)},yi=!0,fr=!0,ft=[],$n=[],vi=null,wi=gn,Nt={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:js,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{js(e[0],e[1])}catch{}})}},T=Nt,Yt=[],gt=0,Zn=[];function E(e){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=q,this._lib=!1;var t=this._PSD=T;if(Me&&(this._stackHolder=Ct(),this._prev=null,this._numPrev=0),typeof e!="function"){if(e!==mn)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Ii(this,this._value))}this._state=null,this._value=null,++t.ref,Aa(this,e)}const bi={get:function(){var e=T,t=gr;function n(r,i){var s=!e.global&&(e!==T||t!==gr);const o=s&&!Ge();var l=new E((a,c)=>{ns(this,new Ea(mr(r,e,s,o),mr(i,e,s,o),a,c,e))});return Me&&Ta(l,this),l}return n.prototype=mn,n},set:function(e){Ve(this,"then",e&&e.prototype===mn?bi:{get:function(){return e},set:bi.set})}};function Ea(e,t,n,r,i){this.onFulfilled=typeof e=="function"?e:null,this.onRejected=typeof t=="function"?t:null,this.resolve=n,this.reject=r,this.psd=i}function Aa(e,t){try{t(n=>{if(e._state===null){if(n===e)throw new TypeError("A promise cannot be resolved with itself.");var r=e._lib&&An();n&&typeof n.then=="function"?Aa(e,(i,s)=>{n instanceof E?n._then(i,s):n.then(i,s)}):(e._state=!0,e._value=n,La(e)),r&&Ln()}},Ii.bind(null,e))}catch(n){Ii(e,n)}}function Ii(e,t){if($n.push(t),e._state===null){var n=e._lib&&An();t=wi(t),e._state=!1,e._value=t,Me&&t!==null&&typeof t=="object"&&!t._promise&&function(r,i,s){try{r.apply(null,s)}catch(o){i&&i(o)}}(()=>{var r=Yi(t,"stack");t._promise=e,Ve(t,"stack",{get:()=>mi?r&&(r.get?r.get.apply(t):r.value):e.stack})}),function(r){ft.some(i=>i._value===r._value)||ft.push(r)}(e),La(e),n&&Ln()}}function La(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)ns(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),gt===0&&(++gt,rn(()=>{--gt==0&&rs()},[]))}function ns(e,t){if(e._state!==null){var n=e._state?t.onFulfilled:t.onRejected;if(n===null)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++gt,rn(ld,[n,e,t])}else e._listeners.push(t)}function ld(e,t,n){try{vi=t;var r,i=t._value;t._state?r=e(i):($n.length&&($n=[]),r=e(i),$n.indexOf(i)===-1&&function(s){for(var o=ft.length;o;)if(ft[--o]._value===s._value)return void ft.splice(o,1)}(t)),n.resolve(r)}catch(s){n.reject(s)}finally{vi=null,--gt==0&&rs(),--n.psd.ref||n.psd.finalize()}}function Ra(e,t,n){if(t.length===n)return t;var r="";if(e._state===!1){var i,s,o=e._value;o!=null?(i=o.name||"Error",s=o.message||o,r=pi(o,0)):(i=o,s=""),t.push(i+(s?": "+s:"")+r)}return Me&&((r=pi(e._stackHolder,2))&&t.indexOf(r)===-1&&t.push(r),e._prev&&Ra(e._prev,t,n)),t}function Ta(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function Nn(){An()&&Ln()}function An(){var e=yi;return yi=!1,fr=!1,e}function Ln(){var e,t,n;do for(;Yt.length>0;)for(e=Yt,Yt=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}while(Yt.length>0);yi=!0,fr=!0}function rs(){var e=ft;ft=[],e.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var t=Zn.slice(0),n=t.length;n;)t[--n]()}function Pn(e){return new E(mn,!1,e)}function Y(e,t){var n=T;return function(){var r=An(),i=T;try{return rt(n,!0),e.apply(this,arguments)}catch(s){t&&t(s)}finally{rt(i,!1),r&&Ln()}}}Wt(E.prototype,{then:bi,_then:function(e,t){ns(this,new Ea(null,null,e,t,T))},catch:function(e){if(arguments.length===1)return this.then(null,e);var t=arguments[0],n=arguments[1];return typeof t=="function"?this.then(null,r=>r instanceof t?n(r):Pn(r)):this.then(null,r=>r&&r.name===t?n(r):Pn(r))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),Pn(t)))},stack:{get:function(){if(this._stack)return this._stack;try{mi=!0;var e=Ra(this,[],20).join(`
26
- From previous: `);return this._state!==null&&(this._stack=e),e}finally{mi=!1}}},timeout:function(e,t){return e<1/0?new E((n,r)=>{var i=setTimeout(()=>r(new U.Timeout(t)),e);this.then(n,r).finally(clearTimeout.bind(null,i))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&Ve(E.prototype,Symbol.toStringTag,"Dexie.Promise"),Nt.env=xa(),Wt(E,{all:function(){var e=We.apply(null,arguments).map(Fn);return new E(function(t,n){e.length===0&&t([]);var r=e.length;e.forEach((i,s)=>E.resolve(i).then(o=>{e[s]=o,--r||t(e)},n))})},resolve:e=>{if(e instanceof E)return e;if(e&&typeof e.then=="function")return new E((n,r)=>{e.then(n,r)});var t=new E(mn,!0,e);return Ta(t,vi),t},reject:Pn,race:function(){var e=We.apply(null,arguments).map(Fn);return new E((t,n)=>{e.map(r=>E.resolve(r).then(t,n))})},PSD:{get:()=>T,set:e=>T=e},totalEchoes:{get:()=>gr},newPSD:nt,usePSD:zt,scheduler:{get:()=>rn,set:e=>{rn=e}},rejectionMapper:{get:()=>wi,set:e=>{wi=e}},follow:(e,t)=>new E((n,r)=>nt((i,s)=>{var o=T;o.unhandleds=[],o.onunhandled=s,o.finalize=wt(function(){(function(l){function a(){l(),Zn.splice(Zn.indexOf(a),1)}Zn.push(a),++gt,rn(()=>{--gt==0&&rs()},[])})(()=>{this.unhandleds.length===0?i():s(this.unhandleds[0])})},o.finalize),e()},t,n,r))}),qn&&(qn.allSettled&&Ve(E,"allSettled",function(){const e=We.apply(null,arguments).map(Fn);return new E(t=>{e.length===0&&t([]);let n=e.length;const r=new Array(n);e.forEach((i,s)=>E.resolve(i).then(o=>r[s]={status:"fulfilled",value:o},o=>r[s]={status:"rejected",reason:o}).then(()=>--n||t(r)))})}),qn.any&&typeof AggregateError<"u"&&Ve(E,"any",function(){const e=We.apply(null,arguments).map(Fn);return new E((t,n)=>{e.length===0&&n(new AggregateError([]));let r=e.length;const i=new Array(r);e.forEach((s,o)=>E.resolve(s).then(l=>t(l),l=>{i[o]=l,--r||n(new AggregateError(i))}))})}));const de={awaits:0,echoes:0,id:0};var cd=0,Yn=[],Kr=0,gr=0,ud=0;function nt(e,t,n,r){var i=T,s=Object.create(i);s.parent=i,s.ref=0,s.global=!1,s.id=++ud;var o=Nt.env;s.env=ts?{Promise:E,PromiseProp:{value:E,configurable:!0,writable:!0},all:E.all,race:E.race,allSettled:E.allSettled,any:E.any,resolve:E.resolve,reject:E.reject,nthen:Ws(o.nthen,s),gthen:Ws(o.gthen,s)}:{},t&&me(s,t),++i.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var l=zt(s,e,n,r);return s.ref===0&&s.finalize(),l}function Vt(){return de.id||(de.id=++cd),++de.awaits,de.echoes+=ka,de.id}function Ge(){return!!de.awaits&&(--de.awaits==0&&(de.id=0),de.echoes=de.awaits*ka,!0)}function Fn(e){return de.echoes&&e&&e.constructor===qn?(Vt(),e.then(t=>(Ge(),t),t=>(Ge(),oe(t)))):e}function dd(e){++gr,de.echoes&&--de.echoes!=0||(de.echoes=de.id=0),Yn.push(T),rt(e,!0)}function hd(){var e=Yn[Yn.length-1];Yn.pop(),rt(e,!1)}function rt(e,t){var n=T;if((t?!de.echoes||Kr++&&e===T:!Kr||--Kr&&e===T)||Oa(t?dd.bind(null,e):hd),e!==T&&(T=e,n===Nt&&(Nt.env=xa()),ts)){var r=Nt.env.Promise,i=e.env;pr.then=i.nthen,r.prototype.then=i.gthen,(n.global||e.global)&&(Object.defineProperty(Z,"Promise",i.PromiseProp),r.all=i.all,r.race=i.race,r.resolve=i.resolve,r.reject=i.reject,i.allSettled&&(r.allSettled=i.allSettled),i.any&&(r.any=i.any))}}function xa(){var e=Z.Promise;return ts?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(Z,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:pr.then,gthen:e.prototype.then}:{}}function zt(e,t,n,r,i){var s=T;try{return rt(e,!0),t(n,r,i)}finally{rt(s,!1)}}function Oa(e){_a.call(fi,e)}function mr(e,t,n,r){return typeof e!="function"?e:function(){var i=T;n&&Vt(),rt(t,!0);try{return e.apply(this,arguments)}finally{rt(i,!1),r&&Oa(Ge)}}}function Ws(e,t){return function(n,r){return e.call(this,mr(n,t),mr(r,t))}}(""+_a).indexOf("[native code]")===-1&&(Vt=Ge=q);const Ks="unhandledrejection";function js(e,t){var n;try{n=t.onuncatched(e)}catch{}if(n!==!1)try{var r,i={promise:t,reason:e};if(Z.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(Ks,!0,!0),me(r,i)):Z.CustomEvent&&me(r=new CustomEvent(Ks,{detail:i}),i),r&&Z.dispatchEvent&&(dispatchEvent(r),!Z.PromiseRejectionEvent&&Z.onunhandledrejection))try{Z.onunhandledrejection(r)}catch{}Me&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch{}}var oe=E.reject;function Si(e,t,n,r){if(e.idbdb&&(e._state.openComplete||T.letThrough||e._vip)){var i=e._createTransaction(t,n,e._dbSchema);try{i.create(),e._state.PR1398_maxLoop=3}catch(s){return s.name===Xi.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then(()=>Si(e,t,n,r))):oe(s)}return i._promise(t,(s,o)=>nt(()=>(T.trans=i,r(s,o,i)))).then(s=>i._completion.then(()=>s))}if(e._state.openComplete)return oe(new U.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._options.autoOpen)return oe(new U.DatabaseClosed);e.open().catch(q)}return e._state.dbReadyPromise.then(()=>Si(e,t,n,r))}const Vs="3.2.7",ht="￿",Ci=-1/0,Ne="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Ua="String expected.",sn=[],Lr=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),pd=Lr,fd=Lr,Da=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),Rr="__dbnames",jr="readonly",Vr="readwrite";function bt(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}const Ma={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Bn(e){return typeof e!="string"||/\./.test(e)?t=>t:t=>(t[e]===void 0&&e in t&&delete(t=En(t))[e],t)}class gd{_trans(t,n,r){const i=this._tx||T.trans,s=this.name;function o(a,c,u){if(!u.schema[s])throw new U.NotFound("Table "+s+" not part of transaction");return n(u.idbtrans,u)}const l=An();try{return i&&i.db===this.db?i===T.trans?i._promise(t,o,r):nt(()=>i._promise(t,o,r),{trans:i,transless:T.transless||T}):Si(this.db,t,[this.name],o)}finally{l&&Ln()}}get(t,n){return t&&t.constructor===Object?this.where(t).first(n):this._trans("readonly",r=>this.core.get({trans:r,key:t}).then(i=>this.hook.reading.fire(i))).then(n)}where(t){if(typeof t=="string")return new this.db.WhereClause(this,t);if(he(t))return new this.db.WhereClause(this,`[${t.join("+")}]`);const n=re(t);if(n.length===1)return this.where(n[0]).equals(t[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(c=>{if(c.compound&&n.every(u=>c.keyPath.indexOf(u)>=0)){for(let u=0;u<n.length;++u)if(n.indexOf(c.keyPath[u])===-1)return!1;return!0}return!1}).sort((c,u)=>c.keyPath.length-u.keyPath.length)[0];if(r&&this.db._maxKey!==ht){const c=r.keyPath.slice(0,n.length);return this.where(c).equals(c.map(u=>t[u]))}!r&&Me&&console.warn(`The query ${JSON.stringify(t)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:i}=this.schema,s=this.db._deps.indexedDB;function o(c,u){try{return s.cmp(c,u)===0}catch{return!1}}const[l,a]=n.reduce(([c,u],d)=>{const p=i[d],h=t[d];return[c||p,c||!p?bt(u,p&&p.multi?f=>{const g=ze(f,d);return he(g)&&g.some(v=>o(h,v))}:f=>o(h,ze(f,d))):u]},[null,null]);return l?this.where(l.name).equals(t[l.keyPath]).filter(a):r?this.filter(a):this.where(n).equals("")}filter(t){return this.toCollection().and(t)}count(t){return this.toCollection().count(t)}offset(t){return this.toCollection().offset(t)}limit(t){return this.toCollection().limit(t)}each(t){return this.toCollection().each(t)}toArray(t){return this.toCollection().toArray(t)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(t){return new this.db.Collection(new this.db.WhereClause(this,he(t)?`[${t.join("+")}]`:t))}reverse(){return this.toCollection().reverse()}mapToClass(t){this.schema.mappedClass=t;const n=r=>{if(!r)return r;const i=Object.create(t.prototype);for(var s in r)if(Ce(r,s))try{i[s]=r[s]}catch{}return i};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),t}defineClass(){return this.mapToClass(function(t){me(this,t)})}add(t,n){const{auto:r,keyPath:i}=this.schema.primKey;let s=t;return i&&r&&(s=Bn(i)(t)),this._trans("readwrite",o=>this.core.mutate({trans:o,type:"add",keys:n!=null?[n]:null,values:[s]})).then(o=>o.numFailures?E.reject(o.failures[0]):o.lastResult).then(o=>{if(i)try{Te(t,i,o)}catch{}return o})}update(t,n){if(typeof t!="object"||he(t))return this.where(":id").equals(t).modify(n);{const r=ze(t,this.schema.primKey.keyPath);if(r===void 0)return oe(new U.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?re(n).forEach(i=>{Te(t,i,n[i])}):n(t,{value:t,primKey:r})}catch{}return this.where(":id").equals(r).modify(n)}}put(t,n){const{auto:r,keyPath:i}=this.schema.primKey;let s=t;return i&&r&&(s=Bn(i)(t)),this._trans("readwrite",o=>this.core.mutate({trans:o,type:"put",values:[s],keys:n!=null?[n]:null})).then(o=>o.numFailures?E.reject(o.failures[0]):o.lastResult).then(o=>{if(i)try{Te(t,i,o)}catch{}return o})}delete(t){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[t]})).then(n=>n.numFailures?E.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"deleteRange",range:Ma})).then(t=>t.numFailures?E.reject(t.failures[0]):void 0)}bulkGet(t){return this._trans("readonly",n=>this.core.getMany({keys:t,trans:n}).then(r=>r.map(i=>this.hook.reading.fire(i))))}bulkAdd(t,n,r){const i=Array.isArray(n)?n:void 0,s=(r=r||(i?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",o=>{const{auto:l,keyPath:a}=this.schema.primKey;if(a&&i)throw new U.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==t.length)throw new U.InvalidArgument("Arguments objects and keys must have the same length");const c=t.length;let u=a&&l?t.map(Bn(a)):t;return this.core.mutate({trans:o,type:"add",keys:i,values:u,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:f})=>{if(d===0)return s?p:h;throw new nn(`${this.name}.bulkAdd(): ${d} of ${c} operations failed`,f)})})}bulkPut(t,n,r){const i=Array.isArray(n)?n:void 0,s=(r=r||(i?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",o=>{const{auto:l,keyPath:a}=this.schema.primKey;if(a&&i)throw new U.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==t.length)throw new U.InvalidArgument("Arguments objects and keys must have the same length");const c=t.length;let u=a&&l?t.map(Bn(a)):t;return this.core.mutate({trans:o,type:"put",keys:i,values:u,wantResults:s}).then(({numFailures:d,results:p,lastResult:h,failures:f})=>{if(d===0)return s?p:h;throw new nn(`${this.name}.bulkPut(): ${d} of ${c} operations failed`,f)})})}bulkDelete(t){const n=t.length;return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:t})).then(({numFailures:r,lastResult:i,failures:s})=>{if(r===0)return i;throw new nn(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,s)})}}function on(e){var t={},n=function(o,l){if(l){for(var a=arguments.length,c=new Array(a-1);--a;)c[a-1]=arguments[a];return t[o].subscribe.apply(null,c),e}if(typeof o=="string")return t[o]};n.addEventType=s;for(var r=1,i=arguments.length;r<i;++r)s(arguments[r]);return n;function s(o,l,a){if(typeof o!="object"){var c;l||(l=od),a||(a=q);var u={subscribers:[],fire:a,subscribe:function(d){u.subscribers.indexOf(d)===-1&&(u.subscribers.push(d),u.fire=l(u.fire,d))},unsubscribe:function(d){u.subscribers=u.subscribers.filter(function(p){return p!==d}),u.fire=u.subscribers.reduce(l,a)}};return t[o]=n[o]=u,u}re(c=o).forEach(function(d){var p=c[d];if(he(p))s(d,c[d][0],c[d][1]);else{if(p!=="asap")throw new U.InvalidArgument("Invalid event config");var h=s(d,gn,function(){for(var f=arguments.length,g=new Array(f);f--;)g[f]=arguments[f];h.subscribers.forEach(function(v){ga(function(){v.apply(null,g)})})})}})}}function qt(e,t){return Dt(t).from({prototype:e}),t}function At(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function zr(e,t){e.filter=bt(e.filter,t)}function Gr(e,t,n){var r=e.replayFilter;e.replayFilter=r?()=>bt(r(),t()):t,e.justLimit=n&&!r}function Jn(e,t){if(e.isPrimKey)return t.primaryKey;const n=t.getIndexByKeyPath(e.index);if(!n)throw new U.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function zs(e,t,n){const r=Jn(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:e.dir==="prev",unique:!!e.unique,query:{index:r,range:e.range}})}function Wn(e,t,n,r){const i=e.replayFilter?bt(e.filter,e.replayFilter()):e.filter;if(e.or){const s={},o=(l,a,c)=>{if(!i||i(a,c,p=>a.stop(p),p=>a.fail(p))){var u=a.primaryKey,d=""+u;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(u)),Ce(s,d)||(s[d]=!0,t(l,a,c))}};return Promise.all([e.or._iterate(o,n),Gs(zs(e,r,n),e.algorithm,o,!e.keysOnly&&e.valueMapper)])}return Gs(zs(e,r,n),bt(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function Gs(e,t,n,r){var i=Y(r?(s,o,l)=>n(r(s),o,l):n);return e.then(s=>{if(s)return s.start(()=>{var o=()=>s.continue();t&&!t(s,l=>o=l,l=>{s.stop(l),o=q},l=>{s.fail(l),o=q})||i(s.value,s,l=>o=l),o()})})}function ge(e,t){try{const n=Hs(e),r=Hs(t);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(i,s){const o=i.length,l=s.length,a=o<l?o:l;for(let c=0;c<a;++c)if(i[c]!==s[c])return i[c]<s[c]?-1:1;return o===l?0:o<l?-1:1}(qs(e),qs(t));case"Array":return function(i,s){const o=i.length,l=s.length,a=o<l?o:l;for(let c=0;c<a;++c){const u=ge(i[c],s[c]);if(u!==0)return u}return o===l?0:o<l?-1:1}(e,t)}}catch{}return NaN}function Hs(e){const t=typeof e;if(t!=="object")return t;if(ArrayBuffer.isView(e))return"binary";const n=di(e);return n==="ArrayBuffer"?"binary":n}function qs(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class md{_read(t,n){var r=this._ctx;return r.error?r.table._trans(null,oe.bind(null,r.error)):r.table._trans("readonly",t).then(n)}_write(t){var n=this._ctx;return n.error?n.table._trans(null,oe.bind(null,n.error)):n.table._trans("readwrite",t,"locked")}_addAlgorithm(t){var n=this._ctx;n.algorithm=bt(n.algorithm,t)}_iterate(t,n){return Wn(this._ctx,t,n,this._ctx.table.core)}clone(t){var n=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return t&&me(r,t),n._ctx=r,n}raw(){return this._ctx.valueMapper=null,this}each(t){var n=this._ctx;return this._read(r=>Wn(n,t,r,n.table.core))}count(t){return this._read(n=>{const r=this._ctx,i=r.table.core;if(At(r,!0))return i.count({trans:n,query:{index:Jn(r,i.schema),range:r.range}}).then(o=>Math.min(o,r.limit));var s=0;return Wn(r,()=>(++s,!1),n,i).then(()=>s)}).then(t)}sortBy(t,n){const r=t.split(".").reverse(),i=r[0],s=r.length-1;function o(c,u){return u?o(c[r[u]],u-1):c[i]}var l=this._ctx.dir==="next"?1:-1;function a(c,u){var d=o(c,s),p=o(u,s);return d<p?-l:d>p?l:0}return this.toArray(function(c){return c.sort(a)}).then(n)}toArray(t){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&At(r,!0)&&r.limit>0){const{valueMapper:i}=r,s=Jn(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:s,range:r.range}}).then(({result:o})=>i?o.map(i):o)}{const i=[];return Wn(r,s=>i.push(s),n,r.table.core).then(()=>i)}},t)}offset(t){var n=this._ctx;return t<=0||(n.offset+=t,At(n)?Gr(n,()=>{var r=t;return(i,s)=>r===0||(r===1?(--r,!1):(s(()=>{i.advance(r),r=0}),!1))}):Gr(n,()=>{var r=t;return()=>--r<0})),this}limit(t){return this._ctx.limit=Math.min(this._ctx.limit,t),Gr(this._ctx,()=>{var n=t;return function(r,i,s){return--n<=0&&i(s),n>=0}},!0),this}until(t,n){return zr(this._ctx,function(r,i,s){return!t(r.value)||(i(s),n)}),this}first(t){return this.limit(1).toArray(function(n){return n[0]}).then(t)}last(t){return this.reverse().first(t)}filter(t){var n,r;return zr(this._ctx,function(i){return t(i.value)}),n=this._ctx,r=t,n.isMatch=bt(n.isMatch,r),this}and(t){return this.filter(t)}or(t){return new this.db.WhereClause(this._ctx.table,t,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(t){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,i){t(i.key,i)})}eachUniqueKey(t){return this._ctx.unique="unique",this.eachKey(t)}eachPrimaryKey(t){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,i){t(i.primaryKey,i)})}keys(t){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(i,s){r.push(s.key)}).then(function(){return r}).then(t)}primaryKeys(t){var n=this._ctx;if(n.dir==="next"&&At(n,!0)&&n.limit>0)return this._read(i=>{var s=Jn(n,n.table.core.schema);return n.table.core.query({trans:i,values:!1,limit:n.limit,query:{index:s,range:n.range}})}).then(({result:i})=>i).then(t);n.keysOnly=!n.isMatch;var r=[];return this.each(function(i,s){r.push(s.primaryKey)}).then(function(){return r}).then(t)}uniqueKeys(t){return this._ctx.unique="unique",this.keys(t)}firstKey(t){return this.limit(1).keys(function(n){return n[0]}).then(t)}lastKey(t){return this.reverse().firstKey(t)}distinct(){var t=this._ctx,n=t.index&&t.table.schema.idxByName[t.index];if(!n||!n.multi)return this;var r={};return zr(this._ctx,function(i){var s=i.primaryKey.toString(),o=Ce(r,s);return r[s]=!0,!o}),this}modify(t){var n=this._ctx;return this._write(r=>{var i;if(typeof t=="function")i=t;else{var s=re(t),o=s.length;i=function(g){for(var v=!1,y=0;y<o;++y){var m=s[y],w=t[m];ze(g,m)!==w&&(Te(g,m,w),v=!0)}return v}}const l=n.table.core,{outbound:a,extractKey:c}=l.schema.primaryKey,u=this.db._options.modifyChunkSize||200,d=[];let p=0;const h=[],f=(g,v)=>{const{failures:y,numFailures:m}=v;p+=g-m;for(let w of re(y))d.push(y[w])};return this.clone().primaryKeys().then(g=>{const v=y=>{const m=Math.min(u,g.length-y);return l.getMany({trans:r,keys:g.slice(y,y+m),cache:"immutable"}).then(w=>{const b=[],S=[],C=a?[]:null,I=[];for(let k=0;k<m;++k){const L=w[k],x={value:En(L),primKey:g[y+k]};i.call(x,x.value,x)!==!1&&(x.value==null?I.push(g[y+k]):a||ge(c(L),c(x.value))===0?(S.push(x.value),a&&C.push(g[y+k])):(I.push(g[y+k]),b.push(x.value)))}const _=At(n)&&n.limit===1/0&&(typeof t!="function"||t===Hr)&&{index:n.index,range:n.range};return Promise.resolve(b.length>0&&l.mutate({trans:r,type:"add",values:b}).then(k=>{for(let L in k.failures)I.splice(parseInt(L),1);f(b.length,k)})).then(()=>(S.length>0||_&&typeof t=="object")&&l.mutate({trans:r,type:"put",keys:C,values:S,criteria:_,changeSpec:typeof t!="function"&&t}).then(k=>f(S.length,k))).then(()=>(I.length>0||_&&t===Hr)&&l.mutate({trans:r,type:"delete",keys:I,criteria:_}).then(k=>f(I.length,k))).then(()=>g.length>y+m&&v(y+u))})};return v(0).then(()=>{if(d.length>0)throw new hr("Error modifying one or more objects",d,p,h);return g.length})})})}delete(){var t=this._ctx,n=t.range;return At(t)&&(t.isPrimKey&&!fd||n.type===3)?this._write(r=>{const{primaryKey:i}=t.table.core.schema,s=n;return t.table.core.count({trans:r,query:{index:i,range:s}}).then(o=>t.table.core.mutate({trans:r,type:"deleteRange",range:s}).then(({failures:l,lastResult:a,results:c,numFailures:u})=>{if(u)throw new hr("Could not delete some values",Object.keys(l).map(d=>l[d]),o-u);return o-u}))}):this.modify(Hr)}}const Hr=(e,t)=>t.value=null;function yd(e,t){return e<t?-1:e===t?0:1}function vd(e,t){return e>t?-1:e===t?0:1}function be(e,t,n){var r=e instanceof Pa?new e.Collection(e):e;return r._ctx.error=n?new n(t):new TypeError(t),r}function Lt(e){return new e.Collection(e,()=>Na("")).limit(0)}function wd(e,t,n,r,i,s){for(var o=Math.min(e.length,r.length),l=-1,a=0;a<o;++a){var c=t[a];if(c!==r[a])return i(e[a],n[a])<0?e.substr(0,a)+n[a]+n.substr(a+1):i(e[a],r[a])<0?e.substr(0,a)+r[a]+n.substr(a+1):l>=0?e.substr(0,l)+t[l]+n.substr(l+1):null;i(e[a],c)<0&&(l=a)}return o<r.length&&s==="next"?e+n.substr(e.length):o<e.length&&s==="prev"?e.substr(0,n.length):l<0?null:e.substr(0,l)+r[l]+n.substr(l+1)}function Kn(e,t,n,r){var i,s,o,l,a,c,u,d=n.length;if(!n.every(g=>typeof g=="string"))return be(e,Ua);function p(g){i=function(y){return y==="next"?m=>m.toUpperCase():m=>m.toLowerCase()}(g),s=function(y){return y==="next"?m=>m.toLowerCase():m=>m.toUpperCase()}(g),o=g==="next"?yd:vd;var v=n.map(function(y){return{lower:s(y),upper:i(y)}}).sort(function(y,m){return o(y.lower,m.lower)});l=v.map(function(y){return y.upper}),a=v.map(function(y){return y.lower}),c=g,u=g==="next"?"":r}p("next");var h=new e.Collection(e,()=>$e(l[0],a[d-1]+r));h._ondirectionchange=function(g){p(g)};var f=0;return h._addAlgorithm(function(g,v,y){var m=g.key;if(typeof m!="string")return!1;var w=s(m);if(t(w,a,f))return!0;for(var b=null,S=f;S<d;++S){var C=wd(m,w,l[S],a[S],o,c);C===null&&b===null?f=S+1:(b===null||o(b,C)>0)&&(b=C)}return v(b!==null?function(){g.continue(b+u)}:y),!1}),h}function $e(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Na(e){return{type:1,lower:e,upper:e}}class Pa{get Collection(){return this._ctx.table.db.Collection}between(t,n,r,i){r=r!==!1,i=i===!0;try{return this._cmp(t,n)>0||this._cmp(t,n)===0&&(r||i)&&(!r||!i)?Lt(this):new this.Collection(this,()=>$e(t,n,!r,!i))}catch{return be(this,Ne)}}equals(t){return t==null?be(this,Ne):new this.Collection(this,()=>Na(t))}above(t){return t==null?be(this,Ne):new this.Collection(this,()=>$e(t,void 0,!0))}aboveOrEqual(t){return t==null?be(this,Ne):new this.Collection(this,()=>$e(t,void 0,!1))}below(t){return t==null?be(this,Ne):new this.Collection(this,()=>$e(void 0,t,!1,!0))}belowOrEqual(t){return t==null?be(this,Ne):new this.Collection(this,()=>$e(void 0,t))}startsWith(t){return typeof t!="string"?be(this,Ua):this.between(t,t+ht,!0,!0)}startsWithIgnoreCase(t){return t===""?this.startsWith(t):Kn(this,(n,r)=>n.indexOf(r[0])===0,[t],ht)}equalsIgnoreCase(t){return Kn(this,(n,r)=>n===r[0],[t],"")}anyOfIgnoreCase(){var t=We.apply(Tt,arguments);return t.length===0?Lt(this):Kn(this,(n,r)=>r.indexOf(n)!==-1,t,"")}startsWithAnyOfIgnoreCase(){var t=We.apply(Tt,arguments);return t.length===0?Lt(this):Kn(this,(n,r)=>r.some(i=>n.indexOf(i)===0),t,ht)}anyOf(){const t=We.apply(Tt,arguments);let n=this._cmp;try{t.sort(n)}catch{return be(this,Ne)}if(t.length===0)return Lt(this);const r=new this.Collection(this,()=>$e(t[0],t[t.length-1]));r._ondirectionchange=s=>{n=s==="next"?this._ascending:this._descending,t.sort(n)};let i=0;return r._addAlgorithm((s,o,l)=>{const a=s.key;for(;n(a,t[i])>0;)if(++i,i===t.length)return o(l),!1;return n(a,t[i])===0||(o(()=>{s.continue(t[i])}),!1)}),r}notEqual(t){return this.inAnyRange([[Ci,t],[t,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const t=We.apply(Tt,arguments);if(t.length===0)return new this.Collection(this);try{t.sort(this._ascending)}catch{return be(this,Ne)}const n=t.reduce((r,i)=>r?r.concat([[r[r.length-1][1],i]]):[[Ci,i]],null);return n.push([t[t.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(t,n){const r=this._cmp,i=this._ascending,s=this._descending,o=this._min,l=this._max;if(t.length===0)return Lt(this);if(!t.every(m=>m[0]!==void 0&&m[1]!==void 0&&i(m[0],m[1])<=0))return be(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",U.InvalidArgument);const a=!n||n.includeLowers!==!1,c=n&&n.includeUppers===!0;let u,d=i;function p(m,w){return d(m[0],w[0])}try{u=t.reduce(function(m,w){let b=0,S=m.length;for(;b<S;++b){const C=m[b];if(r(w[0],C[1])<0&&r(w[1],C[0])>0){C[0]=o(C[0],w[0]),C[1]=l(C[1],w[1]);break}}return b===S&&m.push(w),m},[]),u.sort(p)}catch{return be(this,Ne)}let h=0;const f=c?m=>i(m,u[h][1])>0:m=>i(m,u[h][1])>=0,g=a?m=>s(m,u[h][0])>0:m=>s(m,u[h][0])>=0;let v=f;const y=new this.Collection(this,()=>$e(u[0][0],u[u.length-1][1],!a,!c));return y._ondirectionchange=m=>{m==="next"?(v=f,d=i):(v=g,d=s),u.sort(p)},y._addAlgorithm((m,w,b)=>{for(var S=m.key;v(S);)if(++h,h===u.length)return w(b),!1;return!!function(C){return!f(C)&&!g(C)}(S)||(this._cmp(S,u[h][1])===0||this._cmp(S,u[h][0])===0||w(()=>{d===i?m.continue(u[h][0]):m.continue(u[h][1])}),!1)}),y}startsWithAnyOf(){const t=We.apply(Tt,arguments);return t.every(n=>typeof n=="string")?t.length===0?Lt(this):this.inAnyRange(t.map(n=>[n,n+ht])):be(this,"startsWithAnyOf() only works with strings")}}function Oe(e){return Y(function(t){return yn(t),e(t.target.error),!1})}function yn(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}const vn="storagemutated",Xe="x-storagemutated-1",it=on(null,vn);class bd{_lock(){return Zt(!T.global),++this._reculock,this._reculock!==1||T.global||(T.lockOwnerFor=this),this}_unlock(){if(Zt(!T.global),--this._reculock==0)for(T.global||(T.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var t=this._blockedFuncs.shift();try{zt(t[1],t[0])}catch{}}return this}_locked(){return this._reculock&&T.lockOwnerFor!==this}create(t){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(Zt(!this.idbtrans),!t&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new U.DatabaseClosed(r);case"MissingAPIError":throw new U.MissingAPI(r.message,r);default:throw new U.OpenFailed(r)}if(!this.active)throw new U.TransactionInactive;return Zt(this._completion._state===null),(t=this.idbtrans=t||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=Y(i=>{yn(i),this._reject(t.error)}),t.onabort=Y(i=>{yn(i),this.active&&this._reject(new U.Abort(t.error)),this.active=!1,this.on("abort").fire(i)}),t.oncomplete=Y(()=>{this.active=!1,this._resolve(),"mutatedParts"in t&&it.storagemutated.fire(t.mutatedParts)}),this}_promise(t,n,r){if(t==="readwrite"&&this.mode!=="readwrite")return oe(new U.ReadOnly("Transaction is readonly"));if(!this.active)return oe(new U.TransactionInactive);if(this._locked())return new E((s,o)=>{this._blockedFuncs.push([()=>{this._promise(t,n,r).then(s,o)},T])});if(r)return nt(()=>{var s=new E((o,l)=>{this._lock();const a=n(o,l,this);a&&a.then&&a.then(o,l)});return s.finally(()=>this._unlock()),s._lib=!0,s});var i=new E((s,o)=>{var l=n(s,o,this);l&&l.then&&l.then(s,o)});return i._lib=!0,i}_root(){return this.parent?this.parent._root():this}waitFor(t){var n=this._root();const r=E.resolve(t);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>r);else{n._waitingFor=r,n._waitingQueue=[];var i=n.idbtrans.objectStore(n.storeNames[0]);(function o(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(i.get(-1/0).onsuccess=o)})()}var s=n._waitingFor;return new E((o,l)=>{r.then(a=>n._waitingQueue.push(Y(o.bind(null,a))),a=>n._waitingQueue.push(Y(l.bind(null,a)))).finally(()=>{n._waitingFor===s&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new U.Abort))}table(t){const n=this._memoizedTables||(this._memoizedTables={});if(Ce(n,t))return n[t];const r=this.schema[t];if(!r)throw new U.NotFound("Table "+t+" not part of transaction");const i=new this.db.Table(t,r,this);return i.core=this.db.core.table(t),n[t]=i,i}}function ki(e,t,n,r,i,s,o){return{name:e,keyPath:t,unique:n,multi:r,auto:i,compound:s,src:(n&&!o?"&":"")+(r?"*":"")+(i?"++":"")+Fa(t)}}function Fa(e){return typeof e=="string"?e:e?"["+[].join.call(e,"+")+"]":""}function Ba(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:ma(n,r=>[r.name,r])}}let wn=e=>{try{return e.only([[]]),wn=()=>[[]],[[]]}catch{return wn=()=>ht,ht}};function _i(e){return e==null?()=>{}:typeof e=="string"?function(t){return t.split(".").length===1?r=>r[t]:r=>ze(r,t)}(e):t=>ze(t,e)}function $s(e){return[].slice.call(e)}let Id=0;function an(e){return e==null?":id":typeof e=="string"?e:`[${e.join("+")}]`}function Sd(e,t,n){function r(a){if(a.type===3)return null;if(a.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:c,upper:u,lowerOpen:d,upperOpen:p}=a;return c===void 0?u===void 0?null:t.upperBound(u,!!p):u===void 0?t.lowerBound(c,!!d):t.bound(c,u,!!d,!!p)}const{schema:i,hasGetAll:s}=function(a,c){const u=$s(a.objectStoreNames);return{schema:{name:a.name,tables:u.map(d=>c.objectStore(d)).map(d=>{const{keyPath:p,autoIncrement:h}=d,f=he(p),g=p==null,v={},y={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:g,compound:f,keyPath:p,autoIncrement:h,unique:!0,extractKey:_i(p)},indexes:$s(d.indexNames).map(m=>d.index(m)).map(m=>{const{name:w,unique:b,multiEntry:S,keyPath:C}=m,I={name:w,compound:he(C),keyPath:C,unique:b,multiEntry:S,extractKey:_i(C)};return v[an(C)]=I,I}),getIndexByKeyPath:m=>v[an(m)]};return v[":id"]=y.primaryKey,p!=null&&(v[an(p)]=y.primaryKey),y})},hasGetAll:u.length>0&&"getAll"in c.objectStore(u[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(e,n),o=i.tables.map(a=>function(c){const u=c.name;return{name:u,schema:c,mutate:function({trans:d,type:p,keys:h,values:f,range:g}){return new Promise((v,y)=>{v=Y(v);const m=d.objectStore(u),w=m.keyPath==null,b=p==="put"||p==="add";if(!b&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);const{length:S}=h||f||{length:1};if(h&&f&&h.length!==f.length)throw new Error("Given keys array must have same length as given values array.");if(S===0)return v({numFailures:0,failures:{},results:[],lastResult:void 0});let C;const I=[],_=[];let k=0;const L=K=>{++k,yn(K)};if(p==="deleteRange"){if(g.type===4)return v({numFailures:k,failures:_,results:[],lastResult:void 0});g.type===3?I.push(C=m.clear()):I.push(C=m.delete(r(g)))}else{const[K,F]=b?w?[f,h]:[f,null]:[h,null];if(b)for(let P=0;P<S;++P)I.push(C=F&&F[P]!==void 0?m[p](K[P],F[P]):m[p](K[P])),C.onerror=L;else for(let P=0;P<S;++P)I.push(C=m[p](K[P])),C.onerror=L}const x=K=>{const F=K.target.result;I.forEach((P,R)=>P.error!=null&&(_[R]=P.error)),v({numFailures:k,failures:_,results:p==="delete"?h:I.map(P=>P.result),lastResult:F})};C.onerror=K=>{L(K),x(K)},C.onsuccess=x})},getMany:({trans:d,keys:p})=>new Promise((h,f)=>{h=Y(h);const g=d.objectStore(u),v=p.length,y=new Array(v);let m,w=0,b=0;const S=I=>{const _=I.target;y[_._pos]=_.result,++b===w&&h(y)},C=Oe(f);for(let I=0;I<v;++I)p[I]!=null&&(m=g.get(p[I]),m._pos=I,m.onsuccess=S,m.onerror=C,++w);w===0&&h(y)}),get:({trans:d,key:p})=>new Promise((h,f)=>{h=Y(h);const g=d.objectStore(u).get(p);g.onsuccess=v=>h(v.target.result),g.onerror=Oe(f)}),query:function(d){return p=>new Promise((h,f)=>{h=Y(h);const{trans:g,values:v,limit:y,query:m}=p,w=y===1/0?void 0:y,{index:b,range:S}=m,C=g.objectStore(u),I=b.isPrimaryKey?C:C.index(b.name),_=r(S);if(y===0)return h({result:[]});if(d){const k=v?I.getAll(_,w):I.getAllKeys(_,w);k.onsuccess=L=>h({result:L.target.result}),k.onerror=Oe(f)}else{let k=0;const L=v||!("openKeyCursor"in I)?I.openCursor(_):I.openKeyCursor(_),x=[];L.onsuccess=K=>{const F=L.result;return F?(x.push(v?F.value:F.primaryKey),++k===y?h({result:x}):void F.continue()):h({result:x})},L.onerror=Oe(f)}})}(s),openCursor:function({trans:d,values:p,query:h,reverse:f,unique:g}){return new Promise((v,y)=>{v=Y(v);const{index:m,range:w}=h,b=d.objectStore(u),S=m.isPrimaryKey?b:b.index(m.name),C=f?g?"prevunique":"prev":g?"nextunique":"next",I=p||!("openKeyCursor"in S)?S.openCursor(r(w),C):S.openKeyCursor(r(w),C);I.onerror=Oe(y),I.onsuccess=Y(_=>{const k=I.result;if(!k)return void v(null);k.___id=++Id,k.done=!1;const L=k.continue.bind(k);let x=k.continuePrimaryKey;x&&(x=x.bind(k));const K=k.advance.bind(k),F=()=>{throw new Error("Cursor not stopped")};k.trans=d,k.stop=k.continue=k.continuePrimaryKey=k.advance=()=>{throw new Error("Cursor not started")},k.fail=Y(y),k.next=function(){let P=1;return this.start(()=>P--?this.continue():this.stop()).then(()=>this)},k.start=P=>{const R=new Promise((z,X)=>{z=Y(z),I.onerror=Oe(X),k.fail=X,k.stop=ae=>{k.stop=k.continue=k.continuePrimaryKey=k.advance=F,z(ae)}}),O=()=>{if(I.result)try{P()}catch(z){k.fail(z)}else k.done=!0,k.start=()=>{throw new Error("Cursor behind last entry")},k.stop()};return I.onsuccess=Y(z=>{I.onsuccess=O,O()}),k.continue=L,k.continuePrimaryKey=x,k.advance=K,O(),R},v(k)},y)})},count({query:d,trans:p}){const{index:h,range:f}=d;return new Promise((g,v)=>{const y=p.objectStore(u),m=h.isPrimaryKey?y:y.index(h.name),w=r(f),b=w?m.count(w):m.count();b.onsuccess=Y(S=>g(S.target.result)),b.onerror=Oe(v)})}}}(a)),l={};return o.forEach(a=>l[a.name]=a),{stack:"dbcore",transaction:e.transaction.bind(e),table(a){if(!l[a])throw new Error(`Table '${a}' not found`);return l[a]},MIN_KEY:-1/0,MAX_KEY:wn(t),schema:i}}function Ei({_novip:e},t){const n=t.db,r=function(i,s,{IDBKeyRange:o,indexedDB:l},a){return{dbcore:function(u,d){return d.reduce((p,{create:h})=>({...p,...h(p)}),u)}(Sd(s,o,a),i.dbcore)}}(e._middlewares,n,e._deps,t);e.core=r.dbcore,e.tables.forEach(i=>{const s=i.name;e.core.schema.tables.some(o=>o.name===s)&&(i.core=e.core.table(s),e[s]instanceof e.Table&&(e[s].core=i.core))})}function yr({_novip:e},t,n,r){n.forEach(i=>{const s=r[i];t.forEach(o=>{const l=Yi(o,i);(!l||"value"in l&&l.value===void 0)&&(o===e.Transaction.prototype||o instanceof e.Transaction?Ve(o,i,{get(){return this.table(i)},set(a){pa(this,i,{value:a,writable:!0,configurable:!0,enumerable:!0})}}):o[i]=new e.Table(i,s))})})}function Ai({_novip:e},t){t.forEach(n=>{for(let r in n)n[r]instanceof e.Table&&delete n[r]})}function Cd(e,t){return e._cfg.version-t._cfg.version}function kd(e,t,n,r){const i=e._dbSchema,s=e._createTransaction("readwrite",e._storeNames,i);s.create(n),s._completion.catch(r);const o=s._reject.bind(s),l=T.transless||T;nt(()=>{T.trans=s,T.transless=l,t===0?(re(i).forEach(a=>{qr(n,a,i[a].primKey,i[a].indexes)}),Ei(e,n),E.follow(()=>e.on.populate.fire(s)).catch(o)):function({_novip:a},c,u,d){const p=[],h=a._versions;let f=a._dbSchema=Ri(a,a.idbdb,d),g=!1;const v=h.filter(m=>m._cfg.version>=c);function y(){return p.length?E.resolve(p.shift()(u.idbtrans)).then(y):E.resolve()}return v.forEach(m=>{p.push(()=>{const w=f,b=m._cfg.dbschema;Ti(a,w,d),Ti(a,b,d),f=a._dbSchema=b;const S=Wa(w,b);S.add.forEach(I=>{qr(d,I[0],I[1].primKey,I[1].indexes)}),S.change.forEach(I=>{if(I.recreate)throw new U.Upgrade("Not yet support for changing primary key");{const _=d.objectStore(I.name);I.add.forEach(k=>Li(_,k)),I.change.forEach(k=>{_.deleteIndex(k.name),Li(_,k)}),I.del.forEach(k=>_.deleteIndex(k))}});const C=m._cfg.contentUpgrade;if(C&&m._cfg.version>c){Ei(a,d),u._memoizedTables={},g=!0;let I=ya(b);S.del.forEach(x=>{I[x]=w[x]}),Ai(a,[a.Transaction.prototype]),yr(a,[a.Transaction.prototype],re(I),I),u.schema=I;const _=Ji(C);let k;_&&Vt();const L=E.follow(()=>{if(k=C(u),k&&_){var x=Ge.bind(null,null);k.then(x,x)}});return k&&typeof k.then=="function"?E.resolve(k):L.then(()=>k)}}),p.push(w=>{(!g||!pd)&&function(b,S){[].slice.call(S.db.objectStoreNames).forEach(C=>b[C]==null&&S.db.deleteObjectStore(C))}(m._cfg.dbschema,w),Ai(a,[a.Transaction.prototype]),yr(a,[a.Transaction.prototype],a._storeNames,a._dbSchema),u.schema=a._dbSchema})}),y().then(()=>{var m,w;w=d,re(m=f).forEach(b=>{w.db.objectStoreNames.contains(b)||qr(w,b,m[b].primKey,m[b].indexes)})})}(e,t,s,n).catch(o)})}function Wa(e,t){const n={del:[],add:[],change:[]};let r;for(r in e)t[r]||n.del.push(r);for(r in t){const i=e[r],s=t[r];if(i){const o={name:r,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||i.primKey.auto!==s.primKey.auto&&!Lr)o.recreate=!0,n.change.push(o);else{const l=i.idxByName,a=s.idxByName;let c;for(c in l)a[c]||o.del.push(c);for(c in a){const u=l[c],d=a[c];u?u.src!==d.src&&o.change.push(d):o.add.push(d)}(o.del.length>0||o.add.length>0||o.change.length>0)&&n.change.push(o)}}else n.add.push([r,s])}return n}function qr(e,t,n,r){const i=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(s=>Li(i,s)),i}function Li(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function Ri(e,t,n){const r={};return dr(t.objectStoreNames,0).forEach(i=>{const s=n.objectStore(i);let o=s.keyPath;const l=ki(Fa(o),o||"",!1,!1,!!s.autoIncrement,o&&typeof o!="string",!0),a=[];for(let u=0;u<s.indexNames.length;++u){const d=s.index(s.indexNames[u]);o=d.keyPath;var c=ki(d.name,o,!!d.unique,!!d.multiEntry,!1,o&&typeof o!="string",!1);a.push(c)}r[i]=Ba(i,l,a)}),r}function Ti({_novip:e},t,n){const r=n.db.objectStoreNames;for(let i=0;i<r.length;++i){const s=r[i],o=n.objectStore(s);e._hasGetAll="getAll"in o;for(let l=0;l<o.indexNames.length;++l){const a=o.indexNames[l],c=o.index(a).keyPath,u=typeof c=="string"?c:"["+dr(c).join("+")+"]";if(t[s]){const d=t[s].idxByName[u];d&&(d.name=a,delete t[s].idxByName[u],t[s].idxByName[a]=d)}}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&Z.WorkerGlobalScope&&Z instanceof Z.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class _d{_parseStoresSpec(t,n){re(t).forEach(r=>{if(t[r]!==null){var i=t[r].split(",").map((o,l)=>{const a=(o=o.trim()).replace(/([&*]|\+\+)/g,""),c=/^\[/.test(a)?a.match(/^\[(.*)\]$/)[1].split("+"):a;return ki(a,c||null,/\&/.test(o),/\*/.test(o),/\+\+/.test(o),he(c),l===0)}),s=i.shift();if(s.multi)throw new U.Schema("Primary key cannot be multi-valued");i.forEach(o=>{if(o.auto)throw new U.Schema("Only primary key can be marked as autoIncrement (++)");if(!o.keyPath)throw new U.Schema("Index must have a name and cannot be an empty string")}),n[r]=Ba(r,s,i)}})}stores(t){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?me(this._cfg.storesSource,t):t;const r=n._versions,i={};let s={};return r.forEach(o=>{me(i,o._cfg.storesSource),s=o._cfg.dbschema={},o._parseStoresSpec(i,s)}),n._dbSchema=s,Ai(n,[n._allTables,n,n.Transaction.prototype]),yr(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],re(s),s),n._storeNames=re(s),this}upgrade(t){return this._cfg.contentUpgrade=es(this._cfg.contentUpgrade||q,t),this}}function is(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new mt(Rr,{addons:[],indexedDB:e,IDBKeyRange:t}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function ss(e){return e&&typeof e.databases=="function"}function xi(e){return nt(function(){return T.letThrough=!0,e()})}function Ed(){var e;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(t){var n=function(){return indexedDB.databases().finally(t)};e=setInterval(n,100),n()}).finally(function(){return clearInterval(e)}):Promise.resolve()}function Ad(e){const t=e._state,{indexedDB:n}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?oe(t.dbOpenError):e);Me&&(t.openCanceller._stackHolder=Ct()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;const r=t.openCanceller;function i(){if(t.openCanceller!==r)throw new U.DatabaseClosed("db.open() was cancelled")}let s=t.dbReadyResolve,o=null,l=!1;const a=()=>new E((c,u)=>{if(i(),!n)throw new U.MissingAPI;const d=e.name,p=t.autoSchema?n.open(d):n.open(d,Math.round(10*e.verno));if(!p)throw new U.MissingAPI;p.onerror=Oe(u),p.onblocked=Y(e._fireOnBlocked),p.onupgradeneeded=Y(h=>{if(o=p.transaction,t.autoSchema&&!e._options.allowEmptyDB){p.onerror=yn,o.abort(),p.result.close();const g=n.deleteDatabase(d);g.onsuccess=g.onerror=Y(()=>{u(new U.NoSuchDatabase(`Database ${d} doesnt exist`))})}else{o.onerror=Oe(u);var f=h.oldVersion>Math.pow(2,62)?0:h.oldVersion;l=f<1,e._novip.idbdb=p.result,kd(e,f/10,o,u)}},u),p.onsuccess=Y(()=>{o=null;const h=e._novip.idbdb=p.result,f=dr(h.objectStoreNames);if(f.length>0)try{const v=h.transaction((g=f).length===1?g[0]:g,"readonly");t.autoSchema?function({_novip:y},m,w){y.verno=m.version/10;const b=y._dbSchema=Ri(0,m,w);y._storeNames=dr(m.objectStoreNames,0),yr(y,[y._allTables],re(b),b)}(e,h,v):(Ti(e,e._dbSchema,v),function(y,m){const w=Wa(Ri(0,y.idbdb,m),y._dbSchema);return!(w.add.length||w.change.some(b=>b.add.length||b.change.length))}(e,v)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Ei(e,v)}catch{}var g;sn.push(e),h.onversionchange=Y(v=>{t.vcFired=!0,e.on("versionchange").fire(v)}),h.onclose=Y(v=>{e.on("close").fire(v)}),l&&function({indexedDB:v,IDBKeyRange:y},m){!ss(v)&&m!==Rr&&is(v,y).put({name:m}).catch(q)}(e._deps,d),c()},u)}).catch(c=>c&&c.name==="UnknownError"&&t.PR1398_maxLoop>0?(t.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),a()):E.reject(c));return E.race([r,(typeof navigator>"u"?E.resolve():Ed()).then(a)]).then(()=>(i(),t.onReadyBeingFired=[],E.resolve(xi(()=>e.on.ready.fire(e.vip))).then(function c(){if(t.onReadyBeingFired.length>0){let u=t.onReadyBeingFired.reduce(es,q);return t.onReadyBeingFired=[],E.resolve(xi(()=>u(e.vip))).then(c)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(c=>{t.dbOpenError=c;try{o&&o.abort()}catch{}return r===t.openCanceller&&e._close(),oe(c)}).finally(()=>{t.openComplete=!0,s()})}function Oi(e){var t=s=>e.next(s),n=i(t),r=i(s=>e.throw(s));function i(s){return o=>{var l=s(o),a=l.value;return l.done?a:a&&typeof a.then=="function"?a.then(n,r):he(a)?Promise.all(a).then(n,r):n(a)}}return i(t)()}function Ld(e,t,n){var r=arguments.length;if(r<2)throw new U.InvalidArgument("Too few arguments");for(var i=new Array(r-1);--r;)i[r-1]=arguments[r];return n=i.pop(),[e,va(i),n]}function Ka(e,t,n,r,i){return E.resolve().then(()=>{const s=T.transless||T,o=e._createTransaction(t,n,e._dbSchema,r),l={trans:o,transless:s};if(r)o.idbtrans=r.idbtrans;else try{o.create(),e._state.PR1398_maxLoop=3}catch(d){return d.name===Xi.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then(()=>Ka(e,t,n,null,i))):oe(d)}const a=Ji(i);let c;a&&Vt();const u=E.follow(()=>{if(c=i.call(o,o),c)if(a){var d=Ge.bind(null,null);c.then(d,d)}else typeof c.next=="function"&&typeof c.throw=="function"&&(c=Oi(c))},l);return(c&&typeof c.then=="function"?E.resolve(c).then(d=>o.active?d:oe(new U.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>c)).then(d=>(r&&o._resolve(),o._completion.then(()=>d))).catch(d=>(o._reject(d),oe(d)))})}function jn(e,t,n){const r=he(e)?e.slice():[e];for(let i=0;i<n;++i)r.push(t);return r}const Rd={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){const n=e.table(t),{schema:r}=n,i={},s=[];function o(u,d,p){const h=an(u),f=i[h]=i[h]||[],g=u==null?0:typeof u=="string"?1:u.length,v=d>0,y={...p,isVirtual:v,keyTail:d,keyLength:g,extractKey:_i(u),unique:!v&&p.unique};return f.push(y),y.isPrimaryKey||s.push(y),g>1&&o(g===2?u[0]:u.slice(0,g-1),d+1,p),f.sort((m,w)=>m.keyTail-w.keyTail),y}const l=o(r.primaryKey.keyPath,0,r.primaryKey);i[":id"]=[l];for(const u of r.indexes)o(u.keyPath,0,u);function a(u){const d=u.query.index;return d.isVirtual?{...u,query:{index:d,range:(p=u.query.range,h=d.keyTail,{type:p.type===1?2:p.type,lower:jn(p.lower,p.lowerOpen?e.MAX_KEY:e.MIN_KEY,h),lowerOpen:!0,upper:jn(p.upper,p.upperOpen?e.MIN_KEY:e.MAX_KEY,h),upperOpen:!0})}}:u;var p,h}return{...n,schema:{...r,primaryKey:l,indexes:s,getIndexByKeyPath:function(u){const d=i[an(u)];return d&&d[0]}},count:u=>n.count(a(u)),query:u=>n.query(a(u)),openCursor(u){const{keyTail:d,isVirtual:p,keyLength:h}=u.query.index;return p?n.openCursor(a(u)).then(f=>f&&function(g){return Object.create(g,{continue:{value:function(y){y!=null?g.continue(jn(y,u.reverse?e.MAX_KEY:e.MIN_KEY,d)):u.unique?g.continue(g.key.slice(0,h).concat(u.reverse?e.MIN_KEY:e.MAX_KEY,d)):g.continue()}},continuePrimaryKey:{value(y,m){g.continuePrimaryKey(jn(y,e.MAX_KEY,d),m)}},primaryKey:{get:()=>g.primaryKey},key:{get(){const y=g.key;return h===1?y[0]:y.slice(0,h)}},value:{get:()=>g.value}})}(f)):n.openCursor(u)}}}}}};function os(e,t,n,r){return n=n||{},r=r||"",re(e).forEach(i=>{if(Ce(t,i)){var s=e[i],o=t[i];if(typeof s=="object"&&typeof o=="object"&&s&&o){const l=di(s);l!==di(o)?n[r+i]=t[i]:l==="Object"?os(s,o,n,r+i+"."):s!==o&&(n[r+i]=t[i])}else s!==o&&(n[r+i]=t[i])}else n[r+i]=void 0}),re(t).forEach(i=>{Ce(e,i)||(n[r+i]=t[i])}),n}const Td={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){const n=e.table(t),{primaryKey:r}=n.schema;return{...n,mutate(s){const o=T.trans,{deleting:l,creating:a,updating:c}=o.table(t).hook;switch(s.type){case"add":if(a.fire===q)break;return o._promise("readwrite",()=>u(s),!0);case"put":if(a.fire===q&&c.fire===q)break;return o._promise("readwrite",()=>u(s),!0);case"delete":if(l.fire===q)break;return o._promise("readwrite",()=>u(s),!0);case"deleteRange":if(l.fire===q)break;return o._promise("readwrite",()=>function(p){return d(p.trans,p.range,1e4)}(s),!0)}return n.mutate(s);function u(p){const h=T.trans,f=p.keys||function(g,v){return v.type==="delete"?v.keys:v.keys||v.values.map(g.extractKey)}(r,p);if(!f)throw new Error("Keys missing");return(p=p.type==="add"||p.type==="put"?{...p,keys:f}:{...p}).type!=="delete"&&(p.values=[...p.values]),p.keys&&(p.keys=[...p.keys]),function(g,v,y){return v.type==="add"?Promise.resolve([]):g.getMany({trans:v.trans,keys:y,cache:"immutable"})}(n,p,f).then(g=>{const v=f.map((y,m)=>{const w=g[m],b={onerror:null,onsuccess:null};if(p.type==="delete")l.fire.call(b,y,w,h);else if(p.type==="add"||w===void 0){const S=a.fire.call(b,y,p.values[m],h);y==null&&S!=null&&(y=S,p.keys[m]=y,r.outbound||Te(p.values[m],r.keyPath,y))}else{const S=os(w,p.values[m]),C=c.fire.call(b,S,y,w,h);if(C){const I=p.values[m];Object.keys(C).forEach(_=>{Ce(I,_)?I[_]=C[_]:Te(I,_,C[_])})}}return b});return n.mutate(p).then(({failures:y,results:m,numFailures:w,lastResult:b})=>{for(let S=0;S<f.length;++S){const C=m?m[S]:f[S],I=v[S];C==null?I.onerror&&I.onerror(y[S]):I.onsuccess&&I.onsuccess(p.type==="put"&&g[S]?p.values[S]:C)}return{failures:y,results:m,numFailures:w,lastResult:b}}).catch(y=>(v.forEach(m=>m.onerror&&m.onerror(y)),Promise.reject(y)))})}function d(p,h,f){return n.query({trans:p,values:!1,query:{index:r,range:h},limit:f}).then(({result:g})=>u({type:"delete",keys:g,trans:p}).then(v=>v.numFailures>0?Promise.reject(v.failures[0]):g.length<f?{failures:[],numFailures:0,lastResult:void 0}:d(p,{...h,lower:g[g.length-1],lowerOpen:!0},f)))}}}}})};function ja(e,t,n){try{if(!t||t.keys.length<e.length)return null;const r=[];for(let i=0,s=0;i<t.keys.length&&s<e.length;++i)ge(t.keys[i],e[s])===0&&(r.push(n?En(t.values[i]):t.values[i]),++s);return r.length===e.length?r:null}catch{return null}}const xd={stack:"dbcore",level:-1,create:e=>({table:t=>{const n=e.table(t);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const i=ja(r.keys,r.trans._cache,r.cache==="clone");return i?E.resolve(i):n.getMany(r).then(s=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?En(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function as(e){return!("from"in e)}const Fe=function(e,t){if(!this){const n=new Fe;return e&&"d"in e&&me(n,e),n}me(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function bn(e,t,n){const r=ge(t,n);if(isNaN(r))return;if(r>0)throw RangeError();if(as(e))return me(e,{from:t,to:n,d:1});const i=e.l,s=e.r;if(ge(n,e.from)<0)return i?bn(i,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Zs(e);if(ge(t,e.to)>0)return s?bn(s,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Zs(e);ge(t,e.from)<0&&(e.from=t,e.l=null,e.d=s?s.d+1:1),ge(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);const o=!e.r;i&&!e.l&&vr(e,i),s&&o&&vr(e,s)}function vr(e,t){as(t)||function n(r,{from:i,to:s,l:o,r:l}){bn(r,i,s),o&&n(r,o),l&&n(r,l)}(e,t)}function Od(e,t){const n=Ui(t);let r=n.next();if(r.done)return!1;let i=r.value;const s=Ui(e);let o=s.next(i.from),l=o.value;for(;!r.done&&!o.done;){if(ge(l.from,i.to)<=0&&ge(l.to,i.from)>=0)return!0;ge(i.from,l.from)<0?i=(r=n.next(l.from)).value:l=(o=s.next(i.from)).value}return!1}function Ui(e){let t=as(e)?null:{s:0,n:e};return{next(n){const r=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,r)for(;t.n.l&&ge(n,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!r||ge(n,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function Zs(e){var t,n;const r=(((t=e.r)===null||t===void 0?void 0:t.d)||0)-(((n=e.l)===null||n===void 0?void 0:n.d)||0),i=r>1?"r":r<-1?"l":"";if(i){const s=i==="r"?"l":"r",o={...e},l=e[i];e.from=l.from,e.to=l.to,e[i]=l[i],o[i]=l[s],e[s]=o,o.d=Ys(o)}e.d=Ys(e)}function Ys({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}Wt(Fe.prototype,{add(e){return vr(this,e),this},addKey(e){return bn(this,e,e),this},addKeys(e){return e.forEach(t=>bn(this,t,t)),this},[hi](){return Ui(this)}});const Ud={stack:"dbcore",level:0,create:e=>{const t=e.schema.name,n=new Fe(e.MIN_KEY,e.MAX_KEY);return{...e,table:r=>{const i=e.table(r),{schema:s}=i,{primaryKey:o}=s,{extractKey:l,outbound:a}=o,c={...i,mutate:p=>{const h=p.trans,f=h.mutatedParts||(h.mutatedParts={}),g=C=>{const I=`idb://${t}/${r}/${C}`;return f[I]||(f[I]=new Fe)},v=g(""),y=g(":dels"),{type:m}=p;let[w,b]=p.type==="deleteRange"?[p.range]:p.type==="delete"?[p.keys]:p.values.length<50?[[],p.values]:[];const S=p.trans._cache;return i.mutate(p).then(C=>{if(he(w)){m!=="delete"&&(w=C.results),v.addKeys(w);const I=ja(w,S);I||m==="add"||y.addKeys(w),(I||b)&&function(_,k,L,x){function K(F){const P=_(F.name||"");function R(z){return z!=null?F.extractKey(z):null}const O=z=>F.multiEntry&&he(z)?z.forEach(X=>P.addKey(X)):P.addKey(z);(L||x).forEach((z,X)=>{const ae=L&&R(L[X]),ue=x&&R(x[X]);ge(ae,ue)!==0&&(ae!=null&&O(ae),ue!=null&&O(ue))})}k.indexes.forEach(K)}(g,s,I,b)}else if(w){const I={from:w.lower,to:w.upper};y.add(I),v.add(I)}else v.add(n),y.add(n),s.indexes.forEach(I=>g(I.name).add(n));return C})}},u=({query:{index:p,range:h}})=>{var f,g;return[p,new Fe((f=h.lower)!==null&&f!==void 0?f:e.MIN_KEY,(g=h.upper)!==null&&g!==void 0?g:e.MAX_KEY)]},d={get:p=>[o,new Fe(p.key)],getMany:p=>[o,new Fe().addKeys(p.keys)],count:u,query:u,openCursor:u};return re(d).forEach(p=>{c[p]=function(h){const{subscr:f}=T;if(f){const g=b=>{const S=`idb://${t}/${r}/${b}`;return f[S]||(f[S]=new Fe)},v=g(""),y=g(":dels"),[m,w]=d[p](h);if(g(m.name||"").add(w),!m.isPrimaryKey){if(p!=="count"){const b=p==="query"&&a&&h.values&&i.query({...h,values:!1});return i[p].apply(this,arguments).then(S=>{if(p==="query"){if(a&&h.values)return b.then(({result:I})=>(v.addKeys(I),S));const C=h.values?S.result.map(l):S.result;h.values?v.addKeys(C):y.addKeys(C)}else if(p==="openCursor"){const C=S,I=h.values;return C&&Object.create(C,{key:{get:()=>(y.addKey(C.primaryKey),C.key)},primaryKey:{get(){const _=C.primaryKey;return y.addKey(_),_}},value:{get:()=>(I&&v.addKey(C.primaryKey),C.value)}})}return S})}y.add(n)}}return i[p].apply(this,arguments)}}),c}}}};class mt{constructor(t,n){this._middlewares={},this.verno=0;const r=mt.dependencies;this._options=n={addons:mt.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:i}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:q,dbReadyPromise:null,cancelOpen:q,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var o;s.dbReadyPromise=new E(l=>{s.dbReadyResolve=l}),s.openCanceller=new E((l,a)=>{s.cancelOpen=a}),this._state=s,this.name=t,this.on=on(this,"populate","blocked","versionchange","close",{ready:[es,q]}),this.on.ready.subscribe=fa(this.on.ready.subscribe,l=>(a,c)=>{mt.vip(()=>{const u=this._state;if(u.openComplete)u.dbOpenError||E.resolve().then(a),c&&l(a);else if(u.onReadyBeingFired)u.onReadyBeingFired.push(a),c&&l(a);else{l(a);const d=this;c||l(function p(){d.on.ready.unsubscribe(a),d.on.ready.unsubscribe(p)})}})}),this.Collection=(o=this,qt(md.prototype,function(l,a){this.db=o;let c=Ma,u=null;if(a)try{c=a()}catch(f){u=f}const d=l._ctx,p=d.table,h=p.hook.reading.fire;this._ctx={table:p,index:d.index,isPrimKey:!d.index||p.schema.primKey.keyPath&&d.index===p.schema.primKey.name,range:c,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:u,or:d.or,valueMapper:h!==gn?h:null}})),this.Table=function(l){return qt(gd.prototype,function(a,c,u){this.db=l,this._tx=u,this.name=a,this.schema=c,this.hook=l._allTables[a]?l._allTables[a].hook:on(null,{creating:[rd,q],reading:[nd,gn],updating:[sd,q],deleting:[id,q]})})}(this),this.Transaction=function(l){return qt(bd.prototype,function(a,c,u,d,p){this.db=l,this.mode=a,this.storeNames=c,this.schema=u,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=on(this,"complete","error","abort"),this.parent=p||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new E((h,f)=>{this._resolve=h,this._reject=f}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},h=>{var f=this.active;return this.active=!1,this.on.error.fire(h),this.parent?this.parent._reject(h):f&&this.idbtrans&&this.idbtrans.abort(),oe(h)})})}(this),this.Version=function(l){return qt(_d.prototype,function(a){this.db=l,this._cfg={version:a,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(l){return qt(Pa.prototype,function(a,c,u){this.db=l,this._ctx={table:a,index:c===":id"?null:c,or:u};const d=l._deps.indexedDB;if(!d)throw new U.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(p,h)=>d.cmp(h,p),this._max=(p,h)=>d.cmp(p,h)>0?p:h,this._min=(p,h)=>d.cmp(p,h)<0?p:h,this._IDBKeyRange=l._deps.IDBKeyRange})}(this),this.on("versionchange",l=>{l.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",l=>{!l.newVersion||l.newVersion<l.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${l.oldVersion/10}`)}),this._maxKey=wn(n.IDBKeyRange),this._createTransaction=(l,a,c,u)=>new this.Transaction(l,a,c,this._options.chromeTransactionDurability,u),this._fireOnBlocked=l=>{this.on("blocked").fire(l),sn.filter(a=>a.name===this.name&&a!==this&&!a._state.vcFired).map(a=>a.on("versionchange").fire(l))},this.use(Rd),this.use(Td),this.use(Ud),this.use(xd),this.vip=Object.create(this,{_vip:{value:!0}}),i.forEach(l=>l(this))}version(t){if(isNaN(t)||t<.1)throw new U.Type("Given version is not a positive number");if(t=Math.round(10*t)/10,this.idbdb||this._state.isBeingOpened)throw new U.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,t);const n=this._versions;var r=n.filter(i=>i._cfg.version===t)[0];return r||(r=new this.Version(t),n.push(r),n.sort(Cd),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(t){return this.idbdb&&(this._state.openComplete||T.letThrough||this._vip)?t():new E((n,r)=>{if(this._state.openComplete)return r(new U.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new U.DatabaseClosed);this.open().catch(q)}this._state.dbReadyPromise.then(n,r)}).then(t)}use({stack:t,create:n,level:r,name:i}){i&&this.unuse({stack:t,name:i});const s=this._middlewares[t]||(this._middlewares[t]=[]);return s.push({stack:t,create:n,level:r??10,name:i}),s.sort((o,l)=>o.level-l.level),this}unuse({stack:t,name:n,create:r}){return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(i=>r?i.create!==r:!!n&&i.name!==n)),this}open(){return Ad(this)}_close(){const t=this._state,n=sn.indexOf(this);if(n>=0&&sn.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}t.dbReadyPromise=new E(r=>{t.dbReadyResolve=r}),t.openCanceller=new E((r,i)=>{t.cancelOpen=i})}close(){this._close();const t=this._state;this._options.autoOpen=!1,t.dbOpenError=new U.DatabaseClosed,t.isBeingOpened&&t.cancelOpen(t.dbOpenError)}delete(){const t=arguments.length>0,n=this._state;return new E((r,i)=>{const s=()=>{this.close();var o=this._deps.indexedDB.deleteDatabase(this.name);o.onsuccess=Y(()=>{(function({indexedDB:l,IDBKeyRange:a},c){!ss(l)&&c!==Rr&&is(l,a).delete(c).catch(q)})(this._deps,this.name),r()}),o.onerror=Oe(i),o.onblocked=this._fireOnBlocked};if(t)throw new U.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(s):s()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){const t=this._state.dbOpenError;return t&&t.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return re(this._allTables).map(t=>this._allTables[t])}transaction(){const t=Ld.apply(this,arguments);return this._transaction.apply(this,t)}_transaction(t,n,r){let i=T.trans;i&&i.db===this&&t.indexOf("!")===-1||(i=null);const s=t.indexOf("?")!==-1;let o,l;t=t.replace("!","").replace("?","");try{if(l=n.map(c=>{var u=c instanceof this.Table?c.name:c;if(typeof u!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return u}),t=="r"||t===jr)o=jr;else{if(t!="rw"&&t!=Vr)throw new U.InvalidArgument("Invalid transaction mode: "+t);o=Vr}if(i){if(i.mode===jr&&o===Vr){if(!s)throw new U.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&l.forEach(c=>{if(i&&i.storeNames.indexOf(c)===-1){if(!s)throw new U.SubTransaction("Table "+c+" not included in parent transaction.");i=null}}),s&&i&&!i.active&&(i=null)}}catch(c){return i?i._promise(null,(u,d)=>{d(c)}):oe(c)}const a=Ka.bind(null,this,o,l,i,r);return i?i._promise(o,a,"lock"):T.trans?zt(T.transless,()=>this._whenReady(a)):this._whenReady(a)}table(t){if(!Ce(this._allTables,t))throw new U.InvalidTable(`Table ${t} does not exist`);return this._allTables[t]}}const Dd=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class Md{constructor(t){this._subscribe=t}subscribe(t,n,r){return this._subscribe(t&&typeof t!="function"?t:{next:t,error:n,complete:r})}[Dd](){return this}}function Va(e,t){return re(t).forEach(n=>{vr(e[n]||(e[n]=new Fe),t[n])}),e}function Nd(e){let t,n=!1;const r=new Md(i=>{const s=Ji(e);let o=!1,l={},a={};const c={get closed(){return o},unsubscribe:()=>{o=!0,it.storagemutated.unsubscribe(h)}};i.start&&i.start(c);let u=!1,d=!1;function p(){return re(a).some(g=>l[g]&&Od(l[g],a[g]))}const h=g=>{Va(l,g),p()&&f()},f=()=>{if(u||o)return;l={};const g={},v=function(y){s&&Vt();const m=()=>nt(e,{subscr:y,trans:null}),w=T.trans?zt(T.transless,m):m();return s&&w.then(Ge,Ge),w}(g);d||(it(vn,h),d=!0),u=!0,Promise.resolve(v).then(y=>{n=!0,t=y,u=!1,o||(p()?f():(l={},a=g,i.next&&i.next(y)))},y=>{u=!1,n=!1,i.error&&i.error(y),c.unsubscribe()})};return f(),c});return r.hasValue=()=>n,r.getValue=()=>t,r}let Di;try{Di={indexedDB:Z.indexedDB||Z.mozIndexedDB||Z.webkitIndexedDB||Z.msIndexedDB,IDBKeyRange:Z.IDBKeyRange||Z.webkitIDBKeyRange}}catch{Di={indexedDB:null,IDBKeyRange:null}}const lt=mt;function Qn(e){let t=Ke;try{Ke=!0,it.storagemutated.fire(e)}finally{Ke=t}}Wt(lt,{...Hn,delete:e=>new lt(e,{addons:[]}).delete(),exists:e=>new lt(e,{addons:[]}).open().then(t=>(t.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return function({indexedDB:t,IDBKeyRange:n}){return ss(t)?Promise.resolve(t.databases()).then(r=>r.map(i=>i.name).filter(i=>i!==Rr)):is(t,n).toCollection().primaryKeys()}(lt.dependencies).then(e)}catch{return oe(new U.MissingAPI)}},defineClass:()=>function(e){me(this,e)},ignoreTransaction:e=>T.trans?zt(T.transless,e):e(),vip:xi,async:function(e){return function(){try{var t=Oi(e.apply(this,arguments));return t&&typeof t.then=="function"?t:E.resolve(t)}catch(n){return oe(n)}}},spawn:function(e,t,n){try{var r=Oi(e.apply(n,t||[]));return r&&typeof r.then=="function"?r:E.resolve(r)}catch(i){return oe(i)}},currentTransaction:{get:()=>T.trans||null},waitFor:function(e,t){const n=E.resolve(typeof e=="function"?lt.ignoreTransaction(e):e).timeout(t||6e4);return T.trans?T.trans.waitFor(n):n},Promise:E,debug:{get:()=>Me,set:e=>{ba(e,e==="dexie"?()=>!0:Da)}},derive:Dt,extend:me,props:Wt,override:fa,Events:on,on:it,liveQuery:Nd,extendObservabilitySet:Va,getByKeyPath:ze,setByKeyPath:Te,delByKeyPath:function(e,t){typeof t=="string"?Te(e,t,void 0):"length"in t&&[].map.call(t,function(n){Te(e,n,void 0)})},shallowClone:ya,deepClone:En,getObjectDiff:os,cmp:ge,asap:ga,minKey:Ci,addons:[],connections:sn,errnames:Xi,dependencies:Di,semVer:Vs,version:Vs.split(".").map(e=>parseInt(e)).reduce((e,t,n)=>e+t/Math.pow(10,2*n))}),lt.maxKey=wn(lt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(it(vn,e=>{if(!Ke){let t;Lr?(t=document.createEvent("CustomEvent"),t.initCustomEvent(Xe,!0,!0,e)):t=new CustomEvent(Xe,{detail:e}),Ke=!0,dispatchEvent(t),Ke=!1}}),addEventListener(Xe,({detail:e})=>{Ke||Qn(e)}));let Ke=!1;if(typeof BroadcastChannel<"u"){const e=new BroadcastChannel(Xe);typeof e.unref=="function"&&e.unref(),it(vn,t=>{Ke||e.postMessage(t)}),e.onmessage=t=>{t.data&&Qn(t.data)}}else if(typeof self<"u"&&typeof navigator<"u"){it(vn,t=>{try{Ke||(typeof localStorage<"u"&&localStorage.setItem(Xe,JSON.stringify({trig:Math.random(),changedParts:t})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:Xe,changedParts:t})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",t=>{if(t.key===Xe){const n=JSON.parse(t.newValue);n&&Qn(n.changedParts)}});const e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:t}){t&&t.type===Xe&&Qn(t.changedParts)})}E.rejectionMapper=function(e,t){if(!e||e instanceof Mt||e instanceof TypeError||e instanceof SyntaxError||!e.name||!Bs[e.name])return e;var n=new Bs[e.name](t||e.message,e);return"stack"in e&&Ve(n,"stack",{get:function(){return this.inner.stack}}),n},ba(Me,Da);let za=!0,ls=!1;const Pd=()=>za=!1,Fd=()=>ls=!0,Bd=["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"];let Jt={},Mi;class Wd{constructor(t){ee(this,"_values",[]);ee(this,"_isWebMetric");this.name=t,this._isWebMetric=Bd.includes(this.name)}report(t){if(za&&this._values.push({time:Date.now(),value:t}),ls||!this._isWebMetric)return;const n=this.findExceededThreshold(t);n&&Mi&&Mi(t,n)}collect(){const t=this._values;return this._values=[],t}findExceededThreshold(t){const n=Jt[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 Kd=(e,t)=>{Jt={},ls=!1,e==null||e.forEach(n=>{var r;n.metric in Jt||(Jt[n.metric]=[]),(r=Jt[n.metric])==null||r.push(n)}),Mi=t},Rn={},Tr=e=>{const t=new Wd(e);return Rn[e]=t,t},Ga=(e,t)=>{let n=Rn[e];return n||(n=Tr(e)),n.report(t)},jd=async e=>{const t=Object.values(Rn).map(n=>({name:n.name,values:n.collect()}));if(t.some(n=>n.values.length))try{await e(JSON.stringify(t))}catch(n){ci(`Error posting metrics: ${n}`)}},Vd=({reportingIntervalSeconds:e,postMetrics:t})=>{e?setInterval(()=>{jd(t)},e*1e3):Pd()},Ha=async(e,t)=>{const n=performance.now();try{await e()}finally{const r=performance.now()-n;let i=Rn[t];i||(i=Tr(t)),i.report(r/1e3)}},qa=(e,t)=>{const n=performance.now();try{e()}finally{const r=performance.now()-n;let i=Rn[t];i||(i=Tr(t)),i.report(r/1e3)}},zd=30,$a=()=>{tt.setItem("sprig.disableReplayRecording","disabled")},It=()=>!!tt.getItem("sprig.disableReplayRecording"),Gd=["did not allow mutations","called in an invalid security context"],Hd=e=>{if(!e)return!0;for(const t of Gd)if(e.toLowerCase().includes(t))return!1;return!0},qd=(e,t,{reportError:n=!0,extraInfo:r})=>{It()||t instanceof Error&&($a(),Hd(t==null?void 0:t.message)&&(n&&window.UserLeap.reportError(e,t,r),Yd()))},$d=async(e,t,{reportError:n}={reportError:!0})=>{var i;let r;try{if(n&&((i=window.navigator.storage)!=null&&i.estimate)){const{quota:s,usage:o}=await window.navigator.storage.estimate();r={availableSpaceInMB:s&&o?(s-o)/(1024*1024):void 0,quota:s,usage:o}}}catch(s){window.UserLeap.reportError("Error getting storage estimate",s,{originalMessage:e,originalError:t})}qd(e,t,{reportError:n,extraInfo:r})},Zd=()=>{const e=tt.getItem("sprig.sessionId");if(e)return A(`Found saved session id: ${e}`),tt.removeItem("sprig.sessionId"),e;const t=St();return A(`Generating new uuid: ${t}`),t},ye=Zd();window.addEventListener("beforeunload",()=>{A(`Before page unload saving session id: ${ye}`),tt.setItem("sprig.sessionId",ye)});const Yd=async()=>{W.transaction("rw",W.events,W.chunkUploads,W.pendingCaptures,()=>{W.events.clear(),W.chunkUploads.clear(),W.pendingCaptures.clear()}).catch(()=>{})},$r=(e,t,n=()=>!0)=>W.table(t).where("timestamp").below(e).and(n).delete(),Jd=async(e,t)=>{let n=[];return await Ha(async()=>{n=await W.events.where("[sessionId+timestamp]").between([ye,e],[ye,t??Date.now()]).toArray()},"sdk_replay_get_events_between_seconds"),n},Qd=(e,t,n)=>{const r=new Date,i=r.setMinutes(r.getMinutes()+(n??zd));return W.events.where("[sessionId+timestamp]").between([ye,e],[ye,t]).modify({expiredAt:i})},Xd=e=>W.chunkUploads.add({...e,sessionId:e.sessionId??ye}),eh=(e,t)=>W.chunkUploads.update(e,{data:null,etag:t,status:"UploadComplete"}),th=({status:e,uploadId:t})=>t?W.chunkUploads.where({uploadId:t,status:e}).toArray():W.chunkUploads.where({sessionId:ye,status:e}).toArray(),nh=e=>W.chunkUploads.where({uploadId:e,status:"UploadComplete"}).toArray(),rh=e=>W.chunkUploads.where({uploadId:e,status:"UploadComplete"}).delete(),ih=e=>W.pendingCaptures.add({...e,sessionId:e.sessionId??ye,canUpload:!1}),sh=()=>W.pendingCaptures.where("sessionId").equals(ye).and(e=>e.targetTimestamp<Date.now()).toArray(),oh=()=>W.pendingCaptures.where("sessionId").equals(ye).toArray(),ah=e=>W.pendingCaptures.where("sessionId").equals(ye).and(t=>t.captureParams.responseGroupId===e).modify({canUpload:!0}),lh=async e=>{var t;if((t=window.navigator.storage)!=null&&t.estimate){const{quota:n,usage:r}=await window.navigator.storage.estimate();if(n&&r&&(n-r)/1073741824<e)return!1}return!0};class ch extends mt{constructor(){super("replayStorage",{autoOpen:!1});ee(this,"events");ee(this,"chunkUploads");ee(this,"pendingCaptures")}}const W=new ch;W.version(1).stores({events:"uuid, timestamp, [sessionId+timestamp]",chunkUploads:"uuid, timestamp, [sessionId+status], [uploadId+status], [sessionId+status+uploadId]",pendingCaptures:"uuid, timestamp, [sessionId+targetTimestamp]"});W.open().catch(e=>{ca(`Error opening replay storage: ${JSON.stringify(e)}`),$a()});let Js=1,Ni=5e3,Xn=6e4;const uh=5,Qs=1e3,Za=30,wr=Za+uh,dh="sprig.pendingCount";let Pi,Fi,Ya,Xs=Date.now(),xr=!1,er;const hh=async(e,t,n,r=2,i)=>{await Kt(async()=>{if(It()){A("Not initializing replay because recording is disabled");return}if(!t){A("Not initializing replay because config didn't specify maxReplayDurationSeconds");return}if(i!=null&&i.minAvailableGb&&(Js=i.minAvailableGb),!await lh(Js)){ci("Minimum storage not available");return}A("Initializing replay"),i!=null&&i.minDuration&&(Ni=i.minDuration),i!=null&&i.batchDuration&&(Xn=i.batchDuration),zu(r),bh(),mh(t+wr,30*60,t+wr),yh();const s=window.rrwebRecord;if(!s){ci("Record script failed to set global function");return}let o=!0,l=0;er=s({checkoutEveryNms:Za*1e3,sampling:{input:"last",scroll:250,media:800},emit:(a,c)=>{if(It())return;if(Xs=Date.now(),c&&a.type===j.Meta)l=performance.now();else if(c&&l&&a.type===j.FullSnapshot){const d=performance.now()-l;Ga("sdk_replay_snapshot_seconds",d/1e3)}const u=o||!!c;o=!1,ph({uuid:St(),event:JSON.stringify(a),isValidStart:u,timestamp:Date.now()})},...i}),xr=!0,Fi||(Fi=window.setInterval(()=>{Date.now()-Xs>Qs&&qe("Sprig_Noop",{})},Qs)),M.on("survey.complete",a=>{Ah({id:a,userAgent:window.navigator.userAgent})})},"Error initializing replay")};let Bi=!1,Wi=[];const ph=e=>{Wi.push(e),Bi||gh()},fh=e=>{const t=e.map(n=>({...n,sessionId:n.sessionId??ye}));if(t.length!==0)return W.transaction("rw",W.events,()=>{W.events.bulkAdd(t)}).catch(n=>{Gt("Error storing replay events",n)})},gh=()=>{Bi=!0,setTimeout(async()=>{if(It())return;const e=Wi;Wi=[],Bi=!1,qa(async()=>{await fh(e)},"sdk_replay_add_event_batch_seconds")},500)},mh=(e=6*60,t=30*60,n=4*60)=>{Pi=window.setInterval(()=>{const r=Date.now();It()||(pn(`Performing periodic replay data cleanup / Event Seconds ${e} / Chunk Seconds ${t} / Pending Capture Seconds ${n}`),Ha(()=>W.transaction("rw!",W.events,W.chunkUploads,W.pendingCaptures,()=>{$r(r-e*1e3,"events",i=>i.expiredAt===void 0||i.expiredAt<r-e*1e3),$r(r-t*1e3,"chunkUploads"),$r(r-n*1e3,"pendingCaptures",i=>i.canUpload===void 0||i.canUpload===!1)}).catch(i=>{clearInterval(Pi),Gt("Error deleting table rows",i)}),"sdk_replay_cleanup_seconds"),A("Cleanup complete"))},30*1e3)},yh=(e=5)=>{Ya=window.setInterval(async()=>{Kt(async()=>{const t=parseInt(pt??"0");if(t===0)return;const n=await sh();n!=null&&n.length&&(await Promise.all(n.map(async r=>(await W.pendingCaptures.delete(r.uuid),Xa(r.captureParams,r.canUpload)))),pt=(t-n.length).toString(),tt.setItem(dh,pt))},"Error initiating pending captures")},e*1e3)},vh=async(e,t,n,r,i)=>{const s=Math.min(e+i,n),o=`from: ${new Date(e).toLocaleTimeString()} to ${new Date(s).toLocaleTimeString()}`;A(`Getting event batch ${o}`);const l=await Jd(e,s);if(!(l!=null&&l.length))return A(`No events found ${o}`),{validStartFound:r,events:[]};if(!r){A(`Searching for valid start in ${l.length} events ${o}`);let a=-1;if(l==null||l.forEach((u,d)=>{if(!u.isValidStart)return;const p=u.timestamp<=t;(a<0||p)&&(a=d)}),a<0)return A(`No valid start found in ${l.length} events ${o}`),{validStartFound:r,events:[]};const c=l[a].timestamp;return A(`Found valid start at: ${new Date(c).toLocaleTimeString()} in events ${o}`),{validStartFound:!0,events:l==null?void 0:l.slice(a)}}return{validStartFound:r,events:l}},wh=(e,t,n)=>{const r=e.length,i=t*1024*1024,s=Math.ceil(r/n),o=Math.max(i,s);A(`Total file bytes: ${r} / target chunk size: ${o}`);const l=[];let a=0;for(;a<r;)l.push(e.slice(a,a+o)),a+=o;return l},Ja=e=>Promise.all(e.map(async t=>{const n=await Gu(t);return await eh(t.uuid,n),t.uploadId})),Qa=async e=>{A(`Marking upload complete if finished: ${e}`);const t=await nh(e);if(!(t!=null&&t.length)){A(`No finished chunks found for upload: ${e}`);return}const n=t.reduce((s,o)=>(s.find(l=>l.chunkIndex===o.chunkIndex)||s.push(o),s),[]);n.sort((s,o)=>s.chunkIndex-o.chunkIndex);const r=n.map(s=>({ETag:s.etag,PartNumber:s.chunkIndex})).filter(s=>s.ETag!==null),i=n[0];await ha({apiUrl:i.apiUrl,surveyId:i.surveyId,uploadId:e,responseGroupUuid:i.responseGroupId,etags:r,headers:i.completeUploadHeaders,replayDuration:i.replayDuration}),A(`Cleaning up chunks for ${e}`),await rh(e),A(`Done cleaning up chunks for ${e}`)},bh=async()=>{Kt(async()=>{const e=await th({status:"ReadyForUpload"});if(!(e!=null&&e.length))return;const t=await Ja(e);A(`Finished uploading unfinished chunks for ${t}`),t!=null&&t.length&&await Promise.all(t.map(n=>{if(n)return Qa(n)}))},"Error uploading unfinished chunks")},Ih=async(e,t)=>{await Ja(t),A(`Done uploading chunks for uploads: ${e.join(",")}`),await Promise.all(e.map(n=>Qa(n)))},Sh=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},eo=async(e,t,n)=>{const r=new TextEncoder;let i=null,s=null,o=null,l=!1,a=!1,[c,u]=[0,0];const d=e-wr*1e3,p=[];let h=[];A(`Getting events between ${new Date(e).toLocaleTimeString()} and ${new Date(t).toLocaleTimeString()}`),A(`Using batch duration: ${Xn}ms`);for(let g=d;g<t;g+=Xn){if({validStartFound:a,events:h}=await vh(g,e,t,a,Xn),!(h!=null&&h.length)){A("No events found");continue}c===0&&(c=h[0].timestamp),u=h[h.length-1].timestamp,A(`Last event time in batch: ${new Date(u).toLocaleTimeString()}`);const v=`${l?",":"["}${h.map(m=>m.event).join(",")}`,y=r.encode(v);n&&s===null&&(pn("Attempting compression"),o=new window.CompressionStream("gzip"),s=o.writable.getWriter()),qa(()=>{n&&s?s.write(y):p.push(y)},"sdk_replay_compression_seconds"),l=!0}if(u-c<Ni)return A(`Replay duration is shorter than minimum of ${Ni}ms / Start:${c} / End:${u}`),null;const f=r.encode("]");return pn("Writing final close brace"),s&&o?(s.write(f),s.close(),i=new Uint8Array(await new Response(o.readable).arrayBuffer())):(p.push(f),i=Sh(p)),A("Finished generating file data"),i},Ch=async(e,t)=>{const n=window.CompressionStream!==void 0;let r=null;const i=t??Date.now(),s=i-e;try{r=await eo(s,i,n)}catch(o){o instanceof Error&&window.UserLeap.reportError("Error compressing replay",o),n&&Kt(async()=>{await eo(s,i,!1)},"fileData fallback failed")}return r},to=async e=>{const{surveyId:t,responseGroupId:n,visitorId:r,apiUrl:i,completeUploadHeaders:s,replayParams:o,triggerTimestamp:l}=e,a=await Ch(o.replayDurationSeconds*1e3,l);if(a!=null&&a.length)A(`Found file data for survey: ${t}`);else{A(`File data is empty for survey: ${t}`);return}const c=wh(a,o.minimumChunkSizeMb,o.signedUrls.length);A(`Got ${c.length} chunks for survey: ${t}`);const u=await Promise.all(c.map(async(d,p)=>{const h=St(),f={apiUrl:i,chunkIndex:p+1,completeUploadHeaders:s,etag:null,responseGroupId:n,status:"ReadyForUpload",surveyId:t,timestamp:l,totalChunks:c.length,data:d,uploadId:o.uploadId,uploadUrl:o.signedUrls[p].url,uuid:h,visitorId:r};return A(`Recording chunk upload: ${JSON.stringify({index:f.chunkIndex,surveyId:f.surveyId,uploadId:f.uploadId,size:d.length,id:h},null,2)}`),await Xd(f),A(`Done creating chunk upload: ${h}`),f}));A(`All chunk records created. Beginning upload for survey: ${t}`),await Ih([o.uploadId],u)},Xa=async(e,t)=>{if(A(`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)}`),It()){A(`Replay recording is disabled: ${e.surveyId}`);return}A(`Replay recording enabled: ${e.surveyId}`);const{isStandalone:n,replayParams:r,triggerTimestamp:i,responseGroupId:s}=e,o=async()=>{setTimeout(()=>M.removeListener(N.QuestionAnswered,o),0),Kt(async()=>{r.replayDurationType==="before"?await to(e):await ah(s)},"Error in schedule/capture callback")};Kt(async()=>{if(r.replayDurationType==="after"||r.replayDurationType==="beforeAndAfter"){n||(A("Attaching QuestionAnswered listener for non-standalone replay"),M.on(N.QuestionAnswered,o)),A(`Scheduling capture for replay of type: ${r.replayDurationType}`),await kh(e);return}if(n||t)A(`Proceeding to capture replay for survey: ${e.surveyId} / standalone? ${n} / canUpload? ${t}`),await to(e);else{const l=wr+r.replayDurationSeconds,a=i-l*1e3,c=i;A(`Setting expiry minutes to ${r.expirationTimeLimitMinutes} for events from ${new Date(a).toLocaleTimeString()} to ${new Date(c).toLocaleTimeString()}`),await Qd(a,c,r.expirationTimeLimitMinutes),A("Attaching QuestionAnswered listener"),M.on(N.QuestionAnswered,o)}},"Error in scheduling/capturing replay")},no=()=>{if(It()){pn("Not clearing user data, replay is disabled");return}return W.transaction("rw",W.events,W.pendingCaptures,()=>{W.events.where("sessionId").equals(ye).delete(),W.pendingCaptures.where("sessionId").equals(ye).delete()}).catch(e=>{Gt("Error clearing session event data",e)})};let pt=tt.getItem("sprig.pendingCount");const kh=async e=>{A(`Scheduling replay capture: ${JSON.stringify(e)}`);const{surveyId:t}=e,n=await oh(),r=n==null?void 0:n.filter(o=>o.captureParams.surveyId===t);if(r!=null&&r.length){A(`Pending capture exists for survey: ${t}`);return}const i={...e,replayParams:{...e.replayParams}};e.replayParams.replayDurationType==="beforeAndAfter"&&(i.replayParams.replayDurationSeconds*=2),i.replayParams.replayDurationType="before";const s=e.triggerTimestamp+e.replayParams.replayDurationSeconds*1e3;return i.triggerTimestamp=s,pt=pt?(parseInt(pt)+1).toString():"1",tt.setItem("sprig.pendingCount",pt),ih({uuid:St(),targetTimestamp:s,timestamp:Date.now(),captureParams:i})},qe=(e,t)=>{var n,r;if(xr)try{(r=(n=window.rrwebRecord)==null?void 0:n.addCustomEvent)==null||r.call(n,e,t)}catch(i){Gt("Error recording custom event",i)}},Kt=async(e,t)=>{try{await e()}catch(n){Gt(t,n)}},ro=e=>{e.description&&(e.description=cs(e.description)),qe("Sprig_PageView",e)},_h=e=>{qe("Sprig_TrackEvent",e)},Eh=e=>{qe("Sprig_ShowSurvey",e)},Ah=e=>{qe("Sprig_SubmitSurvey",e)},Lh=e=>{var t;(t=e==null?void 0:e.elementAttributes)!=null&&t.text&&(e.elementAttributes.text=cs(e.elementAttributes.text)),qe("Sprig_Click",e)},Rh=e=>{qe("Sprig_Refresh",e)},Th=e=>{e.currentPageTitle&&(e.currentPageTitle=cs(e.currentPageTitle)),qe("Sprig_BackForward",e)},xh=e=>{qe("Sprig_Keystroke",e)},Gt=(e,t,{reportError:n}={reportError:!0})=>(er&&(er(),er=void 0),xr=!1,[Pi,Fi,Ya].forEach(r=>{r&&clearInterval(r)}),ca(`${e} - ${JSON.stringify(t)}`),$d(e,t,{reportError:n})),el=()=>xr,cs=e=>e&&e.trim().substring(0,500).replace(/\s\s+/g," ").replace(/\r?\n|\r/g," ").substring(0,250),io="ul-view-sdk-script",Oh=["ios","android"],Qe="visitors",et="environments",so=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 Or(e,t){const{matchType:n,pattern:r}=e,i=n?so[n]:so.legacy;let s=!1;try{s=i(r,t)}catch(o){const l=`[Sprig] (ERR-445) Failed to check url match with pattern ${r}`;o instanceof Error&&(console.warn(l,o),o.stack=JSON.stringify(e),window.UserLeap.reportError(l,o))}return s}async function Ue(e,t){var s,o,l;const{shouldDropOnRateLimit:n,...r}=t;r.headers=Object.assign(vt(window.UserLeap),r.headers);const i=await je(e,{...r,shouldDropOnRateLimit:n});if(i.ok){const a=(s=i.headers)==null?void 0:s.get("Authorization"),c=a?a.split(" "):void 0,u=c&&c.length===2?c[1]:void 0,d=(o=i.headers)==null?void 0:o.get("x-ul-visitor-id");u&&d&&(d!==window.UserLeap.visitorId||window.UserLeap.token!==u)&&(Ie("token",u),Ie("vid",d),M.emit(N.VisitorIDUpdated,{visitorId:d}),window.UserLeap.token=u,window.UserLeap.visitorId=d)}return(l=i.json)!=null&&l.logMessage&&console.warn(`[Sprig] ${i.json.logMessage}`),i}function Ie(e,t){const n=Se.getItem("userleap.ids");let r={};if(n)try{r=JSON.parse(n)}catch(s){s instanceof Error&&(s.stack=n,window.UserLeap.reportError("Failed to parse local storage credentials",s)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",s)}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(s){s instanceof Error&&console.warn(`[Sprig] (ERR-426) Unable to write to Local Storage:: ${s.message}`)}}function us(){return window.previewMode?"0":window.UserLeap.visitorId??""}function Le(e,t,n){const r=[window.UserLeap._API_URL,"sdk",e];return t&&t.forEach(i=>{r.push(i),i===et?r.push(window.UserLeap.envId):i===Qe&&r.push(us())}),n&&r.push(n),r.join("/")}const ln=async e=>{var P,R;const{context:t,forceBrandedLogo:n,endCard:r,isFeedback:i=!1,locale:s,productConfig:o,questions:l,responseGroupUid:a,surveyId:c,uuid:u,vid:d,sessionReplay:p,studyType:h}=e,f=vt(window.UserLeap),g=hs(f),v=ds(f);if(A(`Attempting to display survey: ${c}`),p&&(A("Survey has replay attached"),g?M.emit(N.ReplayCapture,{responseGroupUid:a,hasQuestions:!!(l!=null&&l.length),surveyId:c,uploadId:p.uploadId,replayType:p.replayDurationType??"before",seconds:p.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:St(),mediaType:"screen",questionId:1,responseGroupUid:a,surveyId:c,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}}):Xa({responseGroupId:a,surveyId:c,visitorId:d,replayParams:p,completeUploadHeaders:f,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:l.length===0})),d==null||!(l!=null&&l.length))return A(`Not displaying survey: vid: ${d} / questions: ${l}`),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(Uh(l))return{success:!1,message:"[Sprig] bundled version does not support video voice",surveyState:"no survey"};if(window.UserLeap.container){A("Already displaying a survey");const O="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(O),{success:!1,message:O,surveyState:"no survey"}}if(d!==window.UserLeap.visitorId&&u!==window.UserLeap.visitorId&&!window.previewMode){const O="Attempted to display survey to a different visitor";return A(O),window.UserLeap.reportError("DisplaySurvey",new Error(O)),{success:!1,message:O,surveyState:"no survey"}}A(`Showing survey: ${c}`),Eh({id:c,userAgent:window.navigator.userAgent}),ta.disable(),M.emit(N.SurveyWillPresent,{name:N.SurveyWillPresent,"survey.id":c});let y,m=document.createElement("div"),w,b,S;const C=O=>{const{"view.version":z}=O;z!==f["x-ul-sdk-version"]&&rl(),M.removeListener("verify.view.version",C)};M.on("verify.view.version",C),window.UserLeap.useMobileStyling=v,ia(f)?(y="ul-direct-embeded-frame",w=document.head,b=window,S=!1,g&&(nl(),m.id=y,window.UserLeap.container.appendChild(m),il(),M.emit(N.SurveyLifeCycle,{state:"presented"}),M.emit(N.SurveyPresented,{name:N.SurveyPresented,"survey.id":c}))):{frameId:y,contentWinDocHead:w,contentWindow:b,hasOverlay:S,iframe:m}=Fh({productConfig:o,useMobileStyling:v,surveyId:c,isFeedback:i}),window.UserLeap.frameId=y;const I=O=>{M.once(N.CloseSurveyOnOverlayClick,O)},_={apiURL:window.UserLeap._API_URL,cards:l,configureExitOnOverlayClick:I,context:t,endCard:r,envId:window.UserLeap.envId,eventEmitFn:M.emit.bind(M),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:n,frame:m,headers:f,locale:s,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:Se.getItem("sprig.previewKey"),productConfig:{framePosition:o==null?void 0:o.framePosition,desktopDisplay:o==null?void 0:o.desktopDisplay,placement:o==null?void 0:o.placement},responseGroupUid:a,startingQuestionIdx:(P=window.UserLeap.config)==null?void 0:P.startingQuestionIdx,studyType:h,styleNonce:window.UserLeap.styleNonce,surveyId:c,tabTitle:document.title,ulEvents:hn,useMobileStyling:v,userId:u,viewDocument:b==null?void 0:b.document,viewWindow:b,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},...window.UserLeap._config};(R=window.UserLeap._config)!=null&&R.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null}),window.UserLeap.customStyles&&(_.customStyles=window.UserLeap.customStyles),b&&(b.__cfg=_);function k(){const O=document.createElement("script");return window.UserLeap.nonce&&O.setAttribute("nonce",window.UserLeap.nonce),O.id=io,O}const L=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:_.path,x=document.getElementById(io);x&&x.remove();const K=k(),F=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(_.installationMethod==="web-npm"||_.installationMethod==="web-npm-bundled"){const{default:O}=await Promise.resolve().then(()=>require("./view-DqFVd4zL.cjs"));O.configure(_),S&&window.UserLeap.container&&F()}else L&&(K.src=L,S&&K.addEventListener("load",()=>{window.UserLeap.container&&F()}),b==null||b.addEventListener("error",O=>{O.target instanceof HTMLScriptElement&&O.target.src===L&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));return w==null||w.appendChild(K),{success:!0,surveyState:"ready",surveyId:c,responseGroupUid:a}};function ds(e){var n;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const t=((n=window.UserLeap.windowDimensions)==null?void 0:n.width)??document.body.clientWidth;return hs(e)||t>10&&t<Eu}function hs(e){return Oh.includes(e["userleap-platform"])}const Uh=e=>e.some(t=>t.type==="videovoice"),tl="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 Dh="rgba(255,255,255, 0.95)",Mh="rgba(0,0,0,0.9)",Zr="0px",nl=e=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className="ul-container";const t=ol();e&&t&&!window.UserLeap.useMobileStyling?t.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},rl=(e,t)=>{var r;Wh();const n=window.UserLeap.container;if(n)try{(r=n.parentNode)==null||r.removeChild(n),window.UserLeap.container=null,Ie("trackStartUrl",null),M.emit(N.SurveyLifeCycle,{state:"dismissed"}),M.emit(N.SurveyClosed,{name:N.SurveyClosed,initiator:e,studyType:t})}catch(i){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${e} `+n),i instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",i)}},il=()=>{M.once(N.SurveyWillClose,({initiator:e,studyType:t})=>{M.removeAllListeners(N.CloseSurveyOnOverlayClick),rl(e,t)})},Nh=(e,t)=>{const r={...{position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646}},i=t?e.overlayStyleMobile:e.overlayStyle;r["background-color"]=i==="light"?Dh:Mh,t||(r.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,r)},Ph=(e,t,n,r)=>{var u,d;const i={position:"fixed",bottom:"0px",right:Zr,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%"},s=Object.assign({},t,window.UserLeap),{desktopDisplay:o}=t||{},l=o==="center-modal";l&&(s.framePosition="center");let a,c=!1;if(n)(u=window.UserLeap.windowDimensions)!=null&&u.width?i.width=`${window.UserLeap.windowDimensions.width}px`:i.width="100%",(d=window.UserLeap.windowDimensions)!=null&&d.height?i.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`:window.UserLeap.maxHeight?i.maxHeight=window.UserLeap.maxHeight:i.maxHeight=`${document.body.clientHeight-20}px`,["light","dark"].includes(s.overlayStyleMobile)&&(c=!0);else{i.width=Xo,i.maxHeight=window.UserLeap.maxHeight||"66vh";const p=()=>{c=!0,a={margin:"auto",position:"static"}};if(r)l?p():a={position:"relative",height:"300px"};else switch(s.framePosition){case"bottomLeft":a={left:Zr};break;case"topLeft":a={left:Zr,top:0};break;case"topRight":a={top:0};break;case"center":p();break}}return c&&Nh(s,n),Object.assign(e.style,i,a),c},Fh=({productConfig:e,useMobileStyling:t,surveyId:n,isFeedback:r})=>{var d,p;const i=tl,s=r&&e.desktopDisplay==="slider";nl(s),Bh();const o=document.createElement("iframe");o.id=i,o.setAttribute("title","Sprig User Feedback Dialog");const l=Ph(o,e,t,r);il(),o.setHeight=h=>{parseInt(o.style.height)!=h&&(o.style.height=`${h}px`,M.emit(N.SurveyHeight,{name:N.SurveyHeight,contentFrameHeight:h}))};let a=!1;o.setWidth=h=>{(parseInt(o.style.width)!=h||!a)&&(a=!0,o.style.width=`${h}px`,M.emit(N.SurveyWidth,{name:N.SurveyWidth,contentFrameWidth:h}))},(d=window.UserLeap.container)==null||d.appendChild(o),e&&(t?e.exitOnOverlayClickMobile:e.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{M.emit(N.CloseSurveyOnOverlayClick)}),M.emit(N.SurveyLifeCycle,{state:"presented"}),M.emit(N.SurveyPresented,{name:N.SurveyPresented,"survey.id":n});const c=(p=o.contentWindow)==null?void 0:p.document;if(c&&(c.open("text/html","replace"),c.write("<!doctype html><head></head><body></body></html>"),c.close(),!t)){const h=c.body;h.style.display="flex",h.style.alignItems="center"}const u=c==null?void 0:c.head;return{frameId:i,contentWinDocHead:u,contentWindow:o.contentWindow,hasOverlay:l,iframe:o}},sl={[N.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},Bh=()=>{Object.entries(sl).forEach(([e,t])=>{M.on(e,t)})},Wh=()=>{Object.entries(sl).forEach(([e,t])=>{M.off(e,t)})},ol=()=>H,Pt=()=>document.getElementById("sprig-feedback-container"),ps=()=>document.getElementById("sprig-feedback-loading-animation"),Kh=()=>{if(ps())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=`
27
- <div class="ul-loading-spinner">
28
- <div class="first"></div>
29
- <div class="second"></div>
30
- <div class="third"></div>
31
- <div class="fourth"></div>
32
- </div>
33
- `,e},al=()=>!!document.getElementById(tl);let Yr=!1,H=null,De=null,fs=!1,cn=null,ct=null;const jh=["bottom-left","bottom-right","center-left","center-right"],Vh=e=>{if(Pt()||!jh.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)},Ur=()=>{var t;const e=window.UserLeap.container;return((t=e==null?void 0:e.parentElement)==null?void 0:t.id)==="sprig-feedback-loading-container"},ll=()=>document.getElementById("sprig-feedback-error-container"),cl=()=>{if(!H)return 0;const e=H==null?void 0:H.clientWidth,t=window.getComputedStyle(H),n=parseInt(t.borderRightWidth||"0"),r=parseInt(t.borderLeftWidth||"0");return e+n+r},br=e=>{const t=Pt();t&&(ct!=null&&ct.endsWith("right")?t.style.right=`${e}px`:ct!=null&&ct.endsWith("left")&&(t.style.left=`${e}px`))},Jr=()=>{if(H&&(Ur()||ll())){M.off(N.SurveyAppeared,Qt),Ki();const e=cl();return br(-e),!0}return!1},Qt=()=>{if(!H||!De)return;const e=ps();e&&e.remove(),H.style.height="auto",H.style.width="auto",De.disabled=!1,fs=!1},Ki=()=>{if(!H)return;if(!ps()){const t=Kh();t&&(H.style.height="300px",H.style.width="360px",H.appendChild(t))}},oo=()=>{!H||!De||(br(0),De.disabled=!0,fs=!0)},zh=async e=>{const t=await Ue(Le("1",[Qe],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:e}),method:"POST"});return t.ok?t.json:null},ul=async(e,t)=>{const{buttonTheme:n,eventId:r,placement:i,desktopDisplay:s,feedbackLabel:o,surveyUuid:l,surveyId:a}=e;let c=Pt();if(c){if(!t&&r===cn)return;c.remove(),M.off(hn.SURVEY_FADING_OUT,Jr)}if(cn=r,!document.getElementById("sprig-feedback-style")){const{head:v}=document,y=document.createElement("style");y.id="sprig-feedback-style",y.textContent=Su,y.nonce=window.UserLeap.styleNonce,v.appendChild(y)}Yr=s==="center-modal",ct=i;const[d,p]=i.split("-");Vh(i),c=Pt(),De=document.createElement("button");const h=document.createElement("div");h.className="sprig-feedback-button-label",h.innerText=o,De.appendChild(h),De.id="sprig-feedback-button",De.classList.add(`sprig-feedback-button-${p}`,`sprig-feedback-button-${d}`,`sprig-feedback-button-${n}`,"fade-in-transition"),M.on(hn.SURVEY_FADING_OUT,Jr),De.addEventListener("click",async()=>{const v=document.getElementById("sprig-feedback-error-container");if(al()||ll()){if(Jr()){M.emit(N.SurveyWillClose,{name:N.SurveyWillClose,initiator:Be.FeedbackClosed,studyType:"feedbackButton"});const b=Pt();v&&b&&(b.remove(),cn=null,H=null)}return}const y=vt(window.UserLeap);if(!ds(y)&&!fs&&oo(),t){H&&H.classList.add("sprig-feedback-loading-container-previews"),await ln(t),Qt();return}const w=await zh(l);if(w)M.once(N.SurveyAppeared,Qt),ln({...w,studyType:"feedbackButton"});else if(H){const b=Hh();H.appendChild(b),Qt(),H.style.height="300px",H.style.width="360px"}}),c==null||c.appendChild(De),M.emit(N.FeedbackButtonLoaded,{name:N.FeedbackButtonLoaded,"survey.id":a});const{useMobileStyling:f,_config:{border:g}}=window.UserLeap;if(!Yr&&!f){const v=document.createElement("div");v.id="sprig-feedback-loading-container",v.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${p}`,v.style.setProperty("--feedback-border",g),H=v,Ki(),c==null||c.appendChild(v);const y=cl();br(-y)}else Yr&&br(0);window.UserLeap._config.isOnQuestionsTab&&t&&!Ur()&&H&&(oo(),Ki(),H&&H.classList.add("sprig-feedback-loading-container-previews"),ln(t),Qt())},Gh=e=>{if(Ur())return;const t=Pt();if(!t)return;const{pageUrlEvents:n}=window.UserLeap._config,r=n==null?void 0:n.find(s=>s.id===cn);if(!r)return;Or(r,e)||(t.remove(),cn=null,H=null)},Hh=()=>{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">
34
- <circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
35
- <path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
36
- <circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
37
- </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},qh="!launch_darkly_";class $h{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[`${qh}${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 ji=new $h;Object.freeze(ji);const Zh="!optimizely_experiments_";class Yh{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:s,variation:o}=i,l=this.transformExperimentId(s);o&&typeof o=="string"&&(this._optimizelyData[l]=o)}),!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 Zh+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 s,o;return(s=n[i].variation)!=null&&s.name?{id:i,variation:(o=n[i].variation)==null?void 0:o.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 tr=new Yh;Object.freeze(tr);class Jh{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}}const Qh=1,ao=e=>e instanceof HTMLElement||e instanceof SVGElement,dl=(e,t,n)=>{const r=e.createElement("style");n&&(r.nonce=n),r.textContent=t,r.id="ul-custom-style",e.head.appendChild(r)},hl=e=>{const t=e.querySelector(".ul-card__container");let n=600,r=360;if(t){n=t.scrollHeight;const i=getComputedStyle(t),s=parseFloat(i.marginTop)+parseFloat(i.marginBottom),o=parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth);n+=s+o;const l=t.querySelector(".ul-card--matrix_grid");r=l?l.scrollWidth:t.scrollWidth;const a=parseFloat(i.paddingLeft)+parseFloat(i.paddingRight),c=parseFloat(i.marginLeft)+parseFloat(i.marginRight),u=parseFloat(i.borderLeftWidth)+parseFloat(i.borderRightWidth);r+=c+u+a}return[n+Qh,r]},Xh=e=>{const t=e.querySelector(".ul-card__container");t&&(t.scrollTop=0)},Vi=(e,t)=>{const n=performance.now();document.hidden?setTimeout(()=>Vi(e,t),e):setTimeout(()=>{const r=performance.now()-n;t.report(r/1e3),setTimeout(()=>Vi(e,t),e)},0)},ep=(e=1e3)=>{const t=Tr("sdk_event_queue_latency_seconds");Vi(e,t)},tp=({webMetricsEnabled:e,reportingIntervalSeconds:t,thresholds:n,postMetrics:r})=>{Kd(n,(i,s)=>{if(el()){const o=`Value: ${i} on ${s.metric} violated threshold of ${s.type} ${s.value}`;Gt("Threshold violated",new Error(o),{reportError:!1}),Fd()}}),Vd({reportingIntervalSeconds:t,postMetrics:r}),e&&ep()},Qr={capture:!0},np=["a","button","input","option","li","link"],rp=["Escape","Enter","Backspace","F5","Tab"],ip=["label","type","role","title","placeholder","errormessage","valuetext","href"],lo="aria-",sp=e=>{if(!e.tagName)return"No tagName";const t=e.getAttribute("type");return t?`${t} ${e.tagName.toLowerCase()}`:e.tagName.toLowerCase()},co=e=>{var r;if(((r=e.tagName)==null?void 0:r.toLowerCase())==="html")return{element:"html"};const t=e.textContent,n=t?{text:t}:{};n.element=sp(e);for(const i of e.attributes){let s=i.name;const o=i.value;s.startsWith(lo)&&(s=s.substring(lo.length)),ip.includes(s)&&(n[s]=o)}return n},op=e=>{var i;if(!e)return{};const n={...co(e)},r=e.parentElement;if(r&&np.includes((i=r.tagName)==null?void 0:i.toLowerCase())){const s=co(r);Object.assign(n,s)}return n},pl=(e,t)=>{Lh({x:t.x,y:t.y,type:e,elementAttributes:op(t.target)})},ap=e=>t=>pl(e,t),lp=e=>{rp.includes(e.key)&&xh({key:e.key})},cp=()=>{window.performance.getEntriesByType("navigation").map(t=>t.type).includes("reload")&&Rh({url:window.location.href,currentPageTitle:document.title})},up=()=>{window.performance.getEntriesByType("navigation").map(t=>t.type).includes("back_forward")&&Th({curUrl:window.location.href,fromUrl:document.referrer,currentPageTitle:document.title})},dp=()=>{window.addEventListener("click",ap("left_click"),Qr),window.addEventListener("mousedown",e=>{e.button===2&&pl("right_click",e)},Qr),window.addEventListener("keydown",lp,Qr),cp(),up()},hp={test:"test"},pp=["popState","pushState","replaceState"],$t="!email",zi="pageUrl";function fp(e,t){const{pageUrlEvents:n,interactiveEvents:r,dismissOnPageChange:i}=window.UserLeap._config;if(!i)return!0;const s=[];n&&n.length&&s.push(...n),r&&r.length&&s.push(...r);const o=e&&s.find(l=>l.id===e);return o?Or(o,window.location.href):t===window.location.href}function In(e){const{pageUrlEvents:t,interactiveEvents:n,dismissOnPageChange:r,platform:i}=window.UserLeap._config;if(i&&i!=="web")return;const s=ut("trackStartUrl"),o=s?String(s):null;t&&yl(window.location.href),n&&(gl(),gp()),ol()&&Gh(window.location.href),!Ur()&&r&&o&&o!==window.location.href&&e&&pp.includes(e.type)&&window.UserLeap("dismissActiveSurvey",Be.PageChange)}const fl={capture:!0},gp=()=>{const t=window.UserLeap._config.interactiveEvents.filter(r=>Or(r,window.location.href)).map(r=>{const{name:i,properties:s}=r,{selector:o,innerText:l}=s;return o?a=>{if(ao(a.target))try{a.target.closest(o)&&window.UserLeap("track",i)}catch{}return!1}:a=>(ao(a.target)&&a.target.innerText===l&&window.UserLeap("track",i),!1)}),n=r=>t.forEach(i=>i(r));window.UserLeap._config.interactiveEventsHandler=n,window.addEventListener("click",n,fl)},gl=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,fl),delete window.UserLeap._config.interactiveEventsHandler};function mp(){["hashchange","popstate"].forEach(e=>window.addEventListener(e,In,!0))}function yp(){["hashchange","popstate"].forEach(e=>window.removeEventListener(e,In,!0)),window.UserLeap._config.interactiveEvents&&gl()}function vp(e,t){let n=Le("1",[et],"questions?");return e!=null&&(n+=`&vid=${e}`),t&&(t.surveyId&&(n+=`&surveyid=${t.surveyId}`),t.surveyTemplateId&&(n+=`&surveytemplateid=${t.surveyTemplateId}`),t.previewLanguage&&(n+=`&previewLanguage=${encodeURIComponent(t.previewLanguage)}`),t.useMobileStyling&&(n+=`&isMobile=${t.useMobileStyling}`)),n}function ut(e){const t=Se.getItem("userleap.ids");if(t)try{const r=JSON.parse(t)[window.UserLeap.envId];return r&&r[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 ml(){window.previewMode||(window.UserLeap.visitorId=St(),A(`Generating new vid: ${window.UserLeap.visitorId}`),Ie("vid",window.UserLeap.visitorId),M.emit(N.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}))}function yl(e,t,n){var u;if(e.endsWith("mock_snippet.html"))return;A(`Tracking page view: ${e}`);const r=window.UserLeap._config.pageUrlEvents;let i=!1;if(r&&r.length)for(let d=0;d<r.length&&(i=Or(r[d],e),!i);d++);if(!i)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",e);const s=10,o=1;let l=[];const a={viewedAt:Date.now(),location:e},c=Se.getItem("userleap.pageviews");try{if(l=c?JSON.parse(c):[],Array.isArray(l)||(l=[]),l.length>0){const d=l[l.length-1],p=(Date.now()-d.viewedAt)/1e3;if(d.location!=e&&p>o){const h=(u=document==null?void 0:document.querySelector('meta[name="description"]'))==null?void 0:u.getAttribute("content");ro({...h&&{description:h},url:e,referrer:document.referrer,pageTitle:document.title})}(d.location!=e&&p>o||p>s)&&(window.UserLeap._queue.push(["track",zi,t,{url:e},n]),l.push(a))}else window.UserLeap._queue.push(["track",zi,t,{url:e},n]),l.push(a),ro({url:e});l.length>5&&l.splice(0,l.length-5),Se.setItem("userleap.pageviews",JSON.stringify(l))}catch(d){d instanceof Error&&window.UserLeap.reportError("trackPageView",d,{pageViewsStorage:c}),console.warn("[Sprig] (ERR-425) Failed to update page views in local storage")}}function wp(){const e="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in e&&(e.pushState=(t=>function(...r){const i=t.apply(this,r),s=new Event("pushState");return window.dispatchEvent(s),In(s),i})(e.pushState)),"replaceState"in e&&(e.replaceState=(t=>function(...r){const i=t.apply(this,r),s=new Event("replaceState");return window.dispatchEvent(s),In(s),i})(e.replaceState)),mp()}async function Xr(e,t){const n=us();e&&!t&&(window.UserLeap._config.mode=hp.test);const r=vt(window.UserLeap),i=ds(r),s=await Ue(vp(n,{...e,previewLanguage:window.UserLeap._config.previewLanguage,useMobileStyling:i}),{shouldDropOnRateLimit:!0});if(!s.ok)return s.reportError&&s.error&&(console.warn("[Sprig] (ERR-414) Failed to request questions from the server",s.error),window.UserLeap.reportError("getQuestions",s.error)),{success:!1,surveyState:"no survey"};if(s.json.delay&&await cr(s.json.delay),s.json.isFeedback){const{feedbackLabel:o,productConfig:l,surveyUuid:a}=s.json,{buttonTheme:c,placement:u,desktopDisplay:d}=l,p={buttonTheme:c,desktopDisplay:d,eventId:0,feedbackLabel:o,placement:u,surveyUuid:a,surveyId:e==null?void 0:e.surveyId};ul(p,s.json)}else return ln(s.json)}function bp(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 Ip(e){if(!e)return;window.UserLeap._config=e,e.mute&&window.UserLeap._queue.pause();const{interactiveEvents:t,pageUrlEvents:n,dismissOnPageChange:r}=e;t&&bp(t),(t||n||r)&&(wp(),In())}async function Sp(e,t){var r,i;let n=!0;return t&&((r=e==null?void 0:e.json)!=null&&r.surveyId)&&(window.UserLeap.delayingSurvey=!0,n=await t(e.json.surveyId),window.UserLeap.delayingSurvey=!1,!n)?!1:((i=e==null?void 0:e.json)!=null&&i.delay&&(window.UserLeap.delayingSurvey=!0,await cr(e.json.delay),window.UserLeap.delayingSurvey=!1),n)}const Cp=function(e){if(!window.UserLeap)return;const t=async(r={})=>{var v,y,m,w;const{userId:i,anonymousId:s,metadata:o={},properties:l,showSurveyCallback:a}=r;let{eventName:c}=r;if(window.UserLeap.debugMode&&c!==zi&&console.info("[DEBUG] Sprig track",r),e.mode==="test")return;const u=Se.getItem("sprig.previewKey")??void 0;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!i){const b="[Sprig] - Skipping tracking without userId";return console.warn(b),{success:!1,message:b,surveyState:"no survey"}}if(!c||c.trim().length===0){c=c?String(c):"";const b="[Sprig] - Invalid event name "+c;return console.warn(b),{success:!1,message:b,surveyState:"no survey"}}const d=window.location.href;if(o.url||(o.url=d),Ie("trackStartUrl",d),(y=(v=window.UserLeap)==null?void 0:v._config)!=null&&y.optimizelyEnabled){const b=vt(window.UserLeap);hs(b)||tr.getAndSetWebOptimizelyExperiments(),o.optimizelyExperiments=Object.assign({},tr.getAllOptimizelyExperiments())}(w=(m=window.UserLeap)==null?void 0:m._config)!=null&&w.launchDarklyEnabled&&(o.launchDarklyFlags=ji.getAllLaunchDarklyVariations()),i&&(window.UserLeap.userId=i),s&&(window.UserLeap.partnerAnonymousId=s),l&&(o.eventProperties=l),_h({name:c,url:o.url}),A(`Tracking event: ${c}`);const p=window.UserLeap.delayingSurvey||al()?await Ue(Le("1",[Qe],"events/batch"),{body:JSON.stringify({events:[{event:c,metadata:o}],previewKey:u}),method:"POST",shouldDropOnRateLimit:!0}):await Ue(Le("1",[Qe],"events"),{body:JSON.stringify({event:c,metadata:o,previewKey:u}),method:"POST",shouldDropOnRateLimit:!0});if(!p.ok){const b="[Sprig] (ERR-421) Failed to track event";return p.reportError&&(console.warn(b,p.error),p.error&&window.UserLeap.reportError("track",p.error)),{success:!1,message:b,error:p.error,surveyState:"no survey"}}i&&Ie("uid",i),s&&Ie("aid",s);const h=p.json;return h.invalidPreviewKey&&Se.removeItem("sprig.previewKey"),!!(h!=null&&h.feedbackButton)&&ul(h.feedbackButton),await Sp(p,a)?fp(h.eventId,d)?ln(h):{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={async displaySurvey(r){return console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),window.UserLeap("dismissActiveSurvey",Be.Override),Xr({surveyId:r},!0)},_previewSurvey(r){window.UserLeap("dismissActiveSurvey",Be.Override),Xr({surveyTemplateId:r},!1)},_reviewSurvey(r){window.UserLeap("dismissActiveSurvey",Be.Override),Xr({surveyId:r},!1)},previewSurvey(r){n._previewSurvey(r)},reviewSurvey(r){n._reviewSurvey(r)},mute(){window.UserLeap._queue.pause()},unmute(){window.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(r=Be.API){M.emit(N.SurveyWillClose,{name:N.SurveyWillClose,initiator:r})},async setAttribute(r,i){if(!r||!i&&i!==0&&i!==!1){const s="[Sprig] - Disregarding empty attribute / value provided";return console.warn(s),{success:!1,message:s}}return this.setAttributes({[r]:i})},async setAttributes(r){if(r==null||Object.keys(r).length===0){const i="[Sprig] - Disregarding empty attributes provided";return console.warn(i),{success:!1,message:i}}return this.identifyAndSetAttributes({attributes:r})},async identifyAndSetAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",r),e.mode==="test")return;if(r===null||typeof r!="object"||!(r.userId||r.anonymousId||r.attributes)){const c="[Sprig] - Disregarding empty payload provided";return console.warn(c),{success:!1,message:c}}const{userId:i,anonymousId:s,attributes:o}=r;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!i){const c="[Sprig] - Skipping tracking without userId";return console.warn(c),{success:!1,message:c}}if(!o&&(!i||window.UserLeap.userId===i)&&(!s||window.UserLeap.partnerAnonymousId===s))return{success:!0};const l={};i&&(l.userId=window.UserLeap.userId=i),s&&(l.partnerAnonymousId=window.UserLeap.partnerAnonymousId=s);let a;return o?(o.email&&!Object.prototype.hasOwnProperty.call(o,$t)&&(o[$t]=o.email,delete o.email),A(`Setting attributes: ${JSON.stringify(o)}`),a=await Ue(Le("1",[et,Qe],"attributes"),{body:JSON.stringify(o),method:"PUT"}),!a.ok&&a.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",a.error),a.error&&window.UserLeap.reportError("identifyAndSetAttributes",a.error))):a=await Ue(Le("1",[et,Qe]),{body:JSON.stringify(l),method:"PUT"}),o&&o[$t]&&(window.UserLeap.email=o[$t]),a.ok&&(i&&Ie("uid",i),s&&Ie("aid",s)),{success:!!a.ok}},async removeAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",r),e.mode==="test")return;if(r==null||r.length===0){const s="[Sprig] - Disregarding empty attributes provided";return console.warn(s),{success:!1,message:s}}if(e.requireUserIdForTracking&&!window.UserLeap.userId){const s="[Sprig] - Skipping tracking without userId";return console.warn(s),{success:!1,message:s}}const i=await Ue(Le("1",[et,Qe],"attributes"),{body:JSON.stringify({delete:r}),method:"DELETE"});return!i.ok&&i.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",i.error),i.error&&window.UserLeap.reportError("removeAttributes",i.error)),{success:!!i.ok}},async addSurveyListener(r){M.on(N.SurveyLifeCycle,r)},async removeSurveyListener(r){M.removeListener(N.SurveyLifeCycle,r)},async addListener(r,i){M.on(r,i)},async removeListener(r,i){M.removeListener(r,i)},async removeAllListeners(){M.removeAllListeners()},setPreviewKey(r){!r||typeof r!="string"||Se.isStorageAvailable&&r&&Se.setItem("sprig.previewKey",r)},async setUserId(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",r),r==null){const o=`[Sprig] - Invalid userId ${r}`;return console.warn(o),{success:!1,message:o}}if(e.mode==="test"||r===window.UserLeap.userId)return;window.UserLeap.userId=r;const i=window.UserLeap.visitorId,s=await Ue(Le("1",[et,Qe]),{body:JSON.stringify({userId:r}),method:"PUT"});if(!s.ok){s.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",s.error),s.error&&window.UserLeap.reportError("setUserId",s.error));return}i!==window.UserLeap.visitorId&&no(),Ie("uid",r)},async setPartnerAnonymousId(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",r),r==null){const i=`[Sprig] - Invalid partnerAnonymousId ${r}`;return console.warn(i),{success:!1,message:i}}return window.UserLeap.partnerAnonymousId=r,Ie("aid",r),{success:!0}},async track(r,i,s={},o=void 0){return t({eventName:r,properties:i,metadata:s,showSurveyCallback:o})},async identifyAndTrack(r){return await t(r)},trackPageView(r,i=void 0,s=void 0){yl(r,i,s)},applyStyles(r){if(window.UserLeap.customStyles=r,window.UserLeap.container){const i=window.UserLeap.container.children[0].contentDocument;if(i){const s=i.getElementById("ul-custom-style");s?s.textContent=r:dl(i,r,window.UserLeap.styleNonce)}}},setWindowDimensions(r,i){var a,c;const s=typeof r=="string"?parseInt(r,10):r,o=typeof i=="string"?parseInt(i,10):i;if(!isNaN(s)&&!isNaN(o)&&(window.UserLeap.windowDimensions={width:s,height:o}),!window.UserLeap.frameId)return;const l=document.getElementById(window.UserLeap.frameId);l&&(window.UserLeap.useMobileStyling&&((a=window.UserLeap.windowDimensions)!=null&&a.width&&(l.style.width=`${window.UserLeap.windowDimensions.width}px`),(c=window.UserLeap.windowDimensions)!=null&&c.height&&(l.style.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`),l.contentDocument&&(l.style.height=String(hl(l.contentDocument)[0])+"px")),M.emit(N.SurveyDimensions,{name:N.SurveyDimensions,contentFrameWidth:l.clientWidth,contentFrameHeight:l.clientHeight}))},logoutUser(){window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),A(`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"),Se.removeItem("userleap.pageviews"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),ml(),no(),window.UserLeap._queue.unpause()},teardown(){yp(),window.UserLeap("dismissActiveSurvey",Be.API),delete window.UserLeap,delete window.Sprig,delete window._Sprig},integrateOptimizely(r,i=!0){var s,o;if(!((o=(s=window.UserLeap)==null?void 0:s._config)!=null&&o.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}try{const l=typeof r=="string"?JSON.parse(r):r;tr.setOptimizelyExperiment(l,i)}catch(l){console.warn("[Sprig] Error with integrating Optimizely data"),l instanceof Error&&window.UserLeap.reportError("integrateOptimizely",l)}},integrateOptimizelyClient(r){var s,o;if(!((o=(s=window.UserLeap)==null?void 0:s._config)!=null&&o.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}const i=({experiment:l,variation:a})=>{const c={experiments:[{id:l.id,variation:a.key}]};window.UserLeap("integrateOptimizely",c,!1)};r.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",i)},importLaunchDarklyData(r){var i,s;if(!((s=(i=window.UserLeap)==null?void 0:i._config)!=null&&s.launchDarklyEnabled)){console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.");return}ji.setLDFlagsVariations(r)},setVisitorAttribute(r,i){return console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),n.setAttribute(r,i)},async setEmail(r){return n.setAttribute($t,r)},async setVisitorEmail(r){return console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),n.setEmail(r)},async _generateVideoUploadUrl(r){return Ap(r)},_reportMetric(r,i){Ga(r,i)},async _completeSessionReplay({surveyId:r,responseGroupUuid:i,eventDigest:s}){if(!r||!i)return!1;const o=window.UserLeap._API_URL;try{const l=await ha({surveyId:r,responseGroupUuid:i,eventDigest:s,apiUrl:o,headers:vt(window.UserLeap)},!0);return!(l!=null&&l.error)}catch(l){return console.warn("[Sprig] Error with completing session replay"),l instanceof Error&&window.UserLeap.reportError("completeSessionReplay",l),!1}}};Object.assign(window.UserLeap,n)};async function kp(e){const t=vt(window.UserLeap);document.addEventListener("securitypolicyviolation",oi);const n=await je(Le("1",[et],"config"),{headers:t}),r="TypeError";if(window.UserLeap.error=n.error,!n.ok&&n.error&&n.error.name===r?(window.UserLeap._API_URL="https://api.sprig.com",window.UserLeap.reportError("sprigDomainRequest",n.error)):document.removeEventListener("securitypolicyviolation",oi),!n.ok)return n.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",n.error),n.error&&window.UserLeap.reportError("applyRemoteConfig",n.error)),ai("Disabled: failed to fetch configuration"),e;const i=n.json;return i!=null&&i.disabled?(ai(`Disabled: ${i.disabled}`),{disabled:i.disabled}):Object.assign({},i,e)}const _p=e=>typeof e=="object"&&e&&"inner"in e&&!!e.inner&&typeof e.inner=="object";async function Ep(e,t,n={}){var d,p;const r=window.__cfg&&window.__cfg.mode,i=us(),s=window.UserLeap.envId,o=window.document.documentElement,l=_p(t)?{inner:{message:(d=t.inner)==null?void 0:d.message,stack:(p=t.inner)==null?void 0:p.stack}}:{},a={mode:r,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:o.clientWidth,clientHeight:o.clientHeight,location:window.location.href,language:window.navigator.language,...n,...l},c={action:e,err:{message:t.message,stack:t.stack},meta:a,vid:i,envId:s},u=await Ue(Le("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(c),shouldDropOnRateLimit:!0});if(!u.ok)console.warn("[Sprig] (ERR-444) Failed to report error to API",t);else{const{presignedUrl:h}=u.json;ua(h)}}async function Ap(e){var n;if(!e)return;const t=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const r=await fetch(t,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.ok){const i=await r.json();return(n=i==null?void 0:i.upload)==null?void 0:n.url}else return null}catch(r){console.warn("[Sprig] Error with generating video upload url"),r instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",r)}}function Lp(e={}){const t=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";window.UserLeap.UPDATES=hn,window.UserLeap("setPreviewKey",t);async function n(){if(window.UserLeap.loaded)return;if(A("Loading sprig on page load"),window.UserLeap.reportError=Ep,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 l in window.UserLeap._config)window.UserLeap[l]=window.UserLeap._config[l];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 r=window.UserLeap.sampleRate;if(r){let l=ut("sampled");if(l===null&&(l=Math.random()<r,Ie("sampled",l)),!l)return}else ut("sampled")!==null&&Ie("sampled",null);window.UserLeap._API_URL||(window.UserLeap._API_URL="https://api.sprig.com");const i=[...window.UserLeap._queue];window.UserLeap._queue=new Jh(window.UserLeap,[]),window.UserLeap._queue.pause();for(let l=0;l<i.length;l++)window.UserLeap._queue.push(i[l]);const s=ut("token");s?(window.UserLeap.token=s,window.UserLeap.visitorId=ut("vid"),window.UserLeap.userId=ut("uid"),window.UserLeap.partnerAnonymousId=ut("aid")):(Se.removeItem("userleap.ids"),ml());const o=await kp(e);tp({webMetricsEnabled:o.metricsReportingEnabled,reportingIntervalSeconds:o.metricsReportingEnabled||o.mobileMetricsReportingEnabled?o.metricsReportingIntervalSeconds:0,thresholds:o.metricThresholds,postMetrics:async l=>{await Ue(Le("1",[et],"metrics"),{body:l,method:"POST",headers:{"x-ul-replay-enabled":`${el()}`},shouldDropOnRateLimit:!0})}}),hh(window.document,o.maxReplayDurationSeconds,window.UserLeap.replayNonce,window.UserLeap.maxInflightReplayRequests,o.replaySettings).then(()=>{dp()}),ju(o.logBufferLimit,o.logLevel),Cp(o),await Ip(o),window.UserLeap._queue.unpause(),M.emit(N.SDKReady,{mobileMetricsReportingEnabled:!!o.mobileMetricsReportingEnabled,metricsReportingInterval:o.metricsReportingIntervalSeconds||0,metricsThresholds:o.metricThresholds||[],maxMobileReplayDurationSeconds:o.maxMobileReplayDurationSeconds,mobileReplaySettings:o.mobileReplaySettings}),M.emit(N.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}document.readyState==="complete"?n():window.attachEvent?window.attachEvent("onload",n):window.addEventListener("load",()=>{n()},!1)}class Ir{constructor(){ee(this,"UPDATES",hn)}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 Gi={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(Ir.prototype).map(n=>{n!=="constructor"&&(window.Sprig[n]=Ir.prototype[n])});const t=window.Sprig;return t.appId=e.envId,t._queue=[],window.UserLeap=t,Lp(e),window.Sprig}};Gi.configure;window.UpChunk={createUpload:sc};window.rrwebRecord=_n;exports.APP_ID=Cu;exports.ConflictingWidgets=ta;exports.DEFAULT_BORDER_COLOR=ku;exports.DEFAULT_WIDTH=Xo;exports.DismissReason=Be;exports.EMBED_MOBILE_MAX_WIDTH=Au;exports.ERROR_BORDER_COLOR=_u;exports.SprigAPI=Ir;exports.SprigEvent=N;exports.calculateFrameDimensions=hl;exports.eventEmitter=M;exports.info=A;exports.overrideStyles=dl;exports.resetScrollPosition=Xh;exports.shouldDirectEmbed=ia;exports.sprig=Gi;exports.sprigFetch=je;exports.uploadLogfile=ua;exports.v4=St;