@sprig-technologies/sprig-browser 2.26.6 → 2.28.0

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.
@@ -0,0 +1,19 @@
1
+ var Ps=Object.defineProperty,Cs=(e,t,n)=>t in e?Ps(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,F=(e,t,n)=>(Cs(e,typeof t!="symbol"?t+"":t,n),n),ce=(e=>(e.Closed="close.click",e.Complete="survey.completed",e.FeedbackClosed="feedback.closed",e.PageChange="page.change",e.API="api",e.Override="override",e))(ce||{}),A=(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))(A||{});const it={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 Pt;const Rs=new Uint8Array(16);function Ts(){if(!Pt&&(Pt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Pt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Pt(Rs)}const z=[];for(let e=0;e<256;++e)z.push((e+256).toString(16).slice(1));function js(e,t=0){return z[e[t+0]]+z[e[t+1]]+z[e[t+2]]+z[e[t+3]]+"-"+z[e[t+4]]+z[e[t+5]]+"-"+z[e[t+6]]+z[e[t+7]]+"-"+z[e[t+8]]+z[e[t+9]]+"-"+z[e[t+10]]+z[e[t+11]]+z[e[t+12]]+z[e[t+13]]+z[e[t+14]]+z[e[t+15]]}const Ks=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),$r={randomUUID:Ks};function De(e,t,n){if($r.randomUUID&&!t&&!e)return $r.randomUUID();e=e||{};const r=e.random||(e.rng||Ts)();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 js(r)}const Ms='.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}',Br="360px",$s="ul-app",Bs="#e6e6e6",Fs="#bd282a",Ns=500,qs=1030,Fr=()=>{try{return window.parent.Intercom}catch{return null}},Ws=()=>{const e=Fr();e&&(e.ul_wasVisible&&e("update",{hide_default_launcher:!1}),delete e.ul_wasVisible)},Vs=()=>{const e=Fr();e&&(e.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),e.ul_wasVisible&&e("update",{hide_default_launcher:!0}))},zs=Object.freeze(Object.defineProperty({__proto__:null,disable:Vs,enable:Ws},Symbol.toStringTag,{value:"Module"})),Nr=[zs];class qr{static disable(){Nr.forEach(t=>t.disable())}static enable(){Nr.forEach(t=>t.enable())}}var Gs=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"}},Wr=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=Wr.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 Gs(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)}},Vr=Wr;Vr.defaultMaxListeners=10;const D=new Vr,Ct=e=>new Promise(t=>{setTimeout(()=>{t()},e)}),zr=({"userleap-platform":e})=>e!=="web";class Gr{constructor(t){F(this,"storage"),F(this,"tempStorage",{}),F(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 be=new Gr("sessionStorage"),Z=new Gr("localStorage");class Hs{constructor(t){F(this,"payload"),F(this,"promise"),F(this,"reject",()=>{}),F(this,"resolve",()=>{}),this.payload=t,this.promise=new Promise((n,r)=>{this.reject=r,this.resolve=n})}resolveRequest(t){this.resolve(t)}}const Ys={RATELIMIT_RESET_DEFAULT:10};let Hr=!1,Yr="",Rt=!1,Jr=!1,Tt=[];const Js=e=>e._config&&e._config.installationMethod?e._config.installationMethod:e._gtm?"web-gtm":e._segment?"web-segment":"web-snippet",bn=e=>{var t;(t=e?.blockedURI)!=null&&t.includes(window.UserLeap._API_URL)&&(Jr=!0,console.warn(`[Sprig] ${e.blockedURI} is blocked by Content-Security-Policy`),document.removeEventListener("securitypolicyviolation",bn))},_n=(e="")=>{Hr=!0,Yr=e};function Oe(e={}){const t={"Content-Type":"application/json","userleap-platform":"web","x-ul-sdk-version":"2.28.0","x-ul-installation-method":Js(e)};if(e.envId&&(t["x-ul-environment-id"]=e.envId),e.token&&(t.Authorization="Bearer "+e.token),e.userId&&(t["x-ul-user-id"]=e.userId),e.visitorId&&(t["x-ul-visitor-id"]=e.visitorId),e.partnerAnonymousId&&(t["x-ul-anonymous-id"]=e.partnerAnonymousId),e.mobileHeadersJSON){const 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 Qr=async({shouldDropOnRateLimit:e,...t})=>{if(e)return{status:429};{const n=new Hs(t);return Tt.push(n),n.promise}},de=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(Rt&&!i)return Qr(o);const l={ok:!1,reportError:!1};if(Hr)return console.info(`UserLeap - ${Yr}`),l;try{const a=await fetch(e,s);if(a.status===429)if(!Rt&&!r||i){Rt=!0;const u=a.headers.has("ratelimit-reset")?Number(a.headers.get("ratelimit-reset")):Ys.RATELIMIT_RESET_DEFAULT;return await Ct(u*1e3),de(e,{...s,shouldDropOnRateLimit:r,shouldRetryRequest:!0})}else return Qr(o);if(Rt=!1,Tt.length&&(Tt.map(u=>{const d=u.payload;de(d.url,{...d.options,retries:d.retries,shouldDropOnRateLimit:d.shouldDropOnRateLimit}).then(c=>{u.resolveRequest(c)})}),Tt=[]),a.ok){if(a.status===249)return _n(),l;const u=await a.text();try{return u&&u!=="OK"&&(a.json=JSON.parse(u)),a}catch{return{ok:!1,reportError:!1,error:new Error(`failed parsing response json for ${e} - ${u}`)}}}return a}catch(a){const u=n+1;return u>5||Jr?{ok:!1,reportError:!1,error:a}:(await Ct(Math.pow(2,n)*1e3),de(e,{...s,retries:u}))}},qe={Error:1,Warn:2,Info:3,Debug:4};let Sn=1e3,jt=qe.Debug,We=[];const Qs=e=>{const t=Object.entries(qe).find(n=>n[1]===e);return t?.[0]??""},Xs=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),Zs=(e,t)=>`${Xs(t)}:${e}`,eo=()=>{We=We.filter(e=>e.level<=jt)},to=()=>{We.length>Sn&&We.shift()},Kt=(e,t)=>{e>jt||(We.push({level:e,line:Zs(t,new Date)}),to())},st=e=>{Kt(qe.Debug,e)},L=e=>{Kt(qe.Info,e)},kn=e=>{Kt(qe.Warn,e)},Xr=e=>{Kt(qe.Error,e)},no=()=>We.map(e=>e.line),ro=()=>new TextEncoder().encode(no().join(`
2
+ `)),Zr=async e=>{if(!e)return;const t=ro();return de(e,{body:t,method:"PUT"})},io=(e,t)=>{e!==void 0&&(Sn=e),t!==void 0&&(jt=t),st(`Initializing logger with limit of ${Sn} lines and ${Qs(jt)} level`),eo()};var En=(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))(En||{});class so{constructor(t){F(this,"awaitingResolvers",[]),F(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 ei=new so(2),oo=e=>ei.setLimit(e),ao=async e=>ei.execute(async()=>{var t;L(`Beginning upload of chunk ${e.chunkIndex} for survey: ${e.surveyId}`);const n=await de(e.uploadUrl,{body:e.data,method:"PUT"});L(`Completed upload of chunk ${e.chunkIndex} for survey: ${e.surveyId}`);const r=(t=n.headers)==null?void 0:t.get("ETag");if(!r)throw new Error(`Upload response did not include etag for upload ${e.uploadId}, part ${e.chunkIndex}`);return r}),ti=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){L(`Cannot mark upload complete: isMobile: ${a} / uploadId: ${n} / etags: ${r}`);return}L(`Marking upload complete for survey: ${t}`);const d=await de(`${e}/sdk/1/completeSessionReplay`,{method:"POST",body:JSON.stringify({etags:r,uploadId:n,responseGroupUuid:s,surveyId:t,replayDuration:o,eventDigest:l,userAgent:(u=window?.navigator)==null?void 0:u.userAgent}),headers:i,shouldRetryRequest:!0});return L(`Done marking upload complete for survey: ${t}`),d},$=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,N=Object.keys,H=Array.isArray;function J(e,t){return typeof t!="object"||N(t).forEach(function(n){e[n]=t[n]}),e}typeof Promise>"u"||$.Promise||($.Promise=Promise);const ot=Object.getPrototypeOf,lo={}.hasOwnProperty;function ee(e,t){return lo.call(e,t)}function Ve(e,t){typeof t=="function"&&(t=t(ot(e))),(typeof Reflect>"u"?N:Reflect.ownKeys)(t).forEach(n=>{pe(e,n,t[n])})}const ni=Object.defineProperty;function pe(e,t,n,r){ni(e,t,J(n&&ee(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function ze(e){return{from:function(t){return e.prototype=Object.create(t.prototype),pe(e.prototype,"constructor",e),{extend:Ve.bind(null,e.prototype)}}}}const uo=Object.getOwnPropertyDescriptor;function In(e,t){let n;return uo(e,t)||(n=ot(e))&&In(n,t)}const co=[].slice;function Mt(e,t,n){return co.call(e,t,n)}function ri(e,t){return t(e)}function at(e){if(!e)throw new Error("Assertion Failed")}function ii(e){$.setImmediate?setImmediate(e):setTimeout(e,0)}function si(e,t){return e.reduce((n,r,i)=>{var s=t(r,i);return s&&(n[s[0]]=s[1]),n},{})}function he(e,t){if(typeof t=="string"&&ee(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=he(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:he(l,t.substr(o+1))}}function re(e,t,n){if(e&&t!==void 0&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if(typeof t!="string"&&"length"in t){at(typeof n!="string"&&"length"in n);for(var r=0,i=t.length;r<i;++r)re(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?H(e)&&!isNaN(parseInt(o))?e.splice(o,1):delete e[o]:e[o]=n;else{var a=e[o];a&&ee(e,o)||(a=e[o]={}),re(a,l,n)}}else n===void 0?H(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function oi(e){var t={};for(var n in e)ee(e,n)&&(t[n]=e[n]);return t}const po=[].concat;function ai(e){return po.apply([],e)}const li="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(ai([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>$[e]),ho=li.map(e=>$[e]);si(li,e=>[e,!0]);let _e=null;function lt(e){_e=typeof WeakMap<"u"&&new WeakMap;const t=Ln(e);return _e=null,t}function Ln(e){if(!e||typeof e!="object")return e;let t=_e&&_e.get(e);if(t)return t;if(H(e)){t=[],_e&&_e.set(e,t);for(var n=0,r=e.length;n<r;++n)t.push(Ln(e[n]))}else if(ho.indexOf(e.constructor)>=0)t=e;else{const s=ot(e);for(var i in t=s===Object.prototype?{}:Object.create(s),_e&&_e.set(e,t),e)ee(e,i)&&(t[i]=Ln(e[i]))}return t}const{toString:fo}={};function Un(e){return fo.call(e).slice(8,-1)}const xn=typeof Symbol<"u"?Symbol.iterator:"@@iterator",mo=typeof xn=="symbol"?function(e){var t;return e!=null&&(t=e[xn])&&t.apply(e)}:function(){return null},Ge={};function fe(e){var t,n,r,i;if(arguments.length===1){if(H(e))return e.slice();if(this===Ge&&typeof e=="string")return[e];if(i=mo(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 An=typeof Symbol<"u"?e=>e[Symbol.toStringTag]==="AsyncFunction":()=>!1;var se=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function ui(e,t){se=e,ci=t}var ci=()=>!0;const yo=!new Error("").stack;function Pe(){if(yo)try{throw Pe.arguments,new Error}catch(e){return e}return new Error}function Dn(e,t){var n=e.stack;return n?(t=t||0,n.indexOf(e.name)===0&&(t+=(e.name+e.message).split(`
3
+ `).length),n.split(`
4
+ `).slice(t).filter(ci).map(r=>`
5
+ `+r).join("")):""}var di=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],On=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(di),go={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 He(e,t){this._e=Pe(),this.name=e,this.message=t}function pi(e,t){return e+". Errors: "+Object.keys(t).map(n=>t[n].toString()).filter((n,r,i)=>i.indexOf(n)===r).join(`
6
+ `)}function $t(e,t,n,r){this._e=Pe(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=pi(e,t)}function ut(e,t){this._e=Pe(),this.name="BulkError",this.failures=Object.keys(t).map(n=>t[n]),this.failuresByPos=t,this.message=pi(e,t)}ze(He).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Dn(this._e,2))}},toString:function(){return this.name+": "+this.message}}),ze($t).from(He),ze(ut).from(He);var Pn=On.reduce((e,t)=>(e[t]=t+"Error",e),{});const wo=He;var x=On.reduce((e,t)=>{var n=t+"Error";function r(i,s){this._e=Pe(),this.name=n,i?typeof i=="string"?(this.message=`${i}${s?`
7
+ `+s:""}`,this.inner=s||null):typeof i=="object"&&(this.message=`${i.name} ${i.message}`,this.inner=i):(this.message=go[t]||n,this.inner=null)}return ze(r).from(wo),e[t]=r,e},{});x.Syntax=SyntaxError,x.Type=TypeError,x.Range=RangeError;var hi=di.reduce((e,t)=>(e[t+"Error"]=x[t],e),{}),Bt=On.reduce((e,t)=>(["Syntax","Type","Range"].indexOf(t)===-1&&(e[t+"Error"]=x[t]),e),{});function T(){}function ct(e){return e}function vo(e,t){return e==null||e===ct?t:function(n){return t(e(n))}}function Ce(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function bo(e,t){return e===T?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?Ce(r,this.onsuccess):r),i&&(this.onerror=this.onerror?Ce(i,this.onerror):i),s!==void 0?s:n}}function _o(e,t){return e===T?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?Ce(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Ce(r,this.onerror):r)}}function So(e,t){return e===T?t:function(n){var r=e.apply(this,arguments);J(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?Ce(i,this.onsuccess):i),s&&(this.onerror=this.onerror?Ce(s,this.onerror):s),r===void 0?o===void 0?void 0:o:J(r,o)}}function ko(e,t){return e===T?t:function(){return t.apply(this,arguments)!==!1&&e.apply(this,arguments)}}function Cn(e,t){return e===T?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)}}Bt.ModifyError=$t,Bt.DexieError=He,Bt.BulkError=ut;var dt={};const fi=100,[Rn,Ft,Tn]=typeof Promise>"u"?[]:(()=>{let e=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[e,ot(e),e];const t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,ot(t),e]})(),mi=Ft&&Ft.then,Nt=Rn&&Rn.constructor,jn=!!Tn;var Kn=!1,Eo=Tn?()=>{Tn.then(zt)}:$.setImmediate?setImmediate.bind(null,zt):$.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{zt(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(zt,0)},pt=function(e,t){ht.push([e,t]),qt&&(Eo(),qt=!1)},Mn=!0,qt=!0,Re=[],Wt=[],$n=null,Bn=ct,Ye={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:Ii,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{Ii(e[0],e[1])}catch{}})}},U=Ye,ht=[],Te=0,Vt=[];function E(e){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=T,this._lib=!1;var t=this._PSD=U;if(se&&(this._stackHolder=Pe(),this._prev=null,this._numPrev=0),typeof e!="function"){if(e!==dt)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Nn(this,this._value))}this._state=null,this._value=null,++t.ref,gi(this,e)}const Fn={get:function(){var e=U,t=Yt;function n(r,i){var s=!e.global&&(e!==U||t!==Yt);const o=s&&!me();var l=new E((a,u)=>{qn(this,new yi(Qt(r,e,s,o),Qt(i,e,s,o),a,u,e))});return se&&bi(l,this),l}return n.prototype=dt,n},set:function(e){pe(this,"then",e&&e.prototype===dt?Fn:{get:function(){return e},set:Fn.set})}};function yi(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 gi(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&&ft();n&&typeof n.then=="function"?gi(e,(i,s)=>{n instanceof E?n._then(i,s):n.then(i,s)}):(e._state=!0,e._value=n,wi(e)),r&&mt()}},Nn.bind(null,e))}catch(n){Nn(e,n)}}function Nn(e,t){if(Wt.push(t),e._state===null){var n=e._lib&&ft();t=Bn(t),e._state=!1,e._value=t,se&&t!==null&&typeof t=="object"&&!t._promise&&function(r,i,s){try{r.apply(null,s)}catch(o){i&&i(o)}}(()=>{var r=In(t,"stack");t._promise=e,pe(t,"stack",{get:()=>Kn?r&&(r.get?r.get.apply(t):r.value):e.stack})}),function(r){Re.some(i=>i._value===r._value)||Re.push(r)}(e),wi(e),n&&mt()}}function wi(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)qn(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),Te===0&&(++Te,pt(()=>{--Te==0&&Wn()},[]))}function qn(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,++Te,pt(Io,[n,e,t])}else e._listeners.push(t)}function Io(e,t,n){try{$n=t;var r,i=t._value;t._state?r=e(i):(Wt.length&&(Wt=[]),r=e(i),Wt.indexOf(i)===-1&&function(s){for(var o=Re.length;o;)if(Re[--o]._value===s._value)return void Re.splice(o,1)}(t)),n.resolve(r)}catch(s){n.reject(s)}finally{$n=null,--Te==0&&Wn(),--n.psd.ref||n.psd.finalize()}}function vi(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=Dn(o,0)):(i=o,s=""),t.push(i+(s?": "+s:"")+r)}return se&&((r=Dn(e._stackHolder,2))&&t.indexOf(r)===-1&&t.push(r),e._prev&&vi(e._prev,t,n)),t}function bi(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function zt(){ft()&&mt()}function ft(){var e=Mn;return Mn=!1,qt=!1,e}function mt(){var e,t,n;do for(;ht.length>0;)for(e=ht,ht=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}while(ht.length>0);Mn=!0,qt=!0}function Wn(){var e=Re;Re=[],e.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var t=Vt.slice(0),n=t.length;n;)t[--n]()}function Gt(e){return new E(dt,!1,e)}function B(e,t){var n=U;return function(){var r=ft(),i=U;try{return ke(n,!0),e.apply(this,arguments)}catch(s){t&&t(s)}finally{ke(i,!1),r&&mt()}}}Ve(E.prototype,{then:Fn,_then:function(e,t){qn(this,new yi(null,null,e,t,U))},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):Gt(r)):this.then(null,r=>r&&r.name===t?n(r):Gt(r))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),Gt(t)))},stack:{get:function(){if(this._stack)return this._stack;try{Kn=!0;var e=vi(this,[],20).join(`
8
+ From previous: `);return this._state!==null&&(this._stack=e),e}finally{Kn=!1}}},timeout:function(e,t){return e<1/0?new E((n,r)=>{var i=setTimeout(()=>r(new x.Timeout(t)),e);this.then(n,r).finally(clearTimeout.bind(null,i))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&pe(E.prototype,Symbol.toStringTag,"Dexie.Promise"),Ye.env=_i(),Ve(E,{all:function(){var e=fe.apply(null,arguments).map(Jt);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(dt,!0,e);return bi(t,$n),t},reject:Gt,race:function(){var e=fe.apply(null,arguments).map(Jt);return new E((t,n)=>{e.map(r=>E.resolve(r).then(t,n))})},PSD:{get:()=>U,set:e=>U=e},totalEchoes:{get:()=>Yt},newPSD:Se,usePSD:Qe,scheduler:{get:()=>pt,set:e=>{pt=e}},rejectionMapper:{get:()=>Bn,set:e=>{Bn=e}},follow:(e,t)=>new E((n,r)=>Se((i,s)=>{var o=U;o.unhandleds=[],o.onunhandled=s,o.finalize=Ce(function(){(function(l){function a(){l(),Vt.splice(Vt.indexOf(a),1)}Vt.push(a),++Te,pt(()=>{--Te==0&&Wn()},[])})(()=>{this.unhandleds.length===0?i():s(this.unhandleds[0])})},o.finalize),e()},t,n,r))}),Nt&&(Nt.allSettled&&pe(E,"allSettled",function(){const e=fe.apply(null,arguments).map(Jt);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)))})}),Nt.any&&typeof AggregateError<"u"&&pe(E,"any",function(){const e=fe.apply(null,arguments).map(Jt);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 Y={awaits:0,echoes:0,id:0};var Lo=0,Ht=[],Vn=0,Yt=0,Uo=0;function Se(e,t,n,r){var i=U,s=Object.create(i);s.parent=i,s.ref=0,s.global=!1,s.id=++Uo;var o=Ye.env;s.env=jn?{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:ki(o.nthen,s),gthen:ki(o.gthen,s)}:{},t&&J(s,t),++i.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var l=Qe(s,e,n,r);return s.ref===0&&s.finalize(),l}function Je(){return Y.id||(Y.id=++Lo),++Y.awaits,Y.echoes+=fi,Y.id}function me(){return!!Y.awaits&&(--Y.awaits==0&&(Y.id=0),Y.echoes=Y.awaits*fi,!0)}function Jt(e){return Y.echoes&&e&&e.constructor===Nt?(Je(),e.then(t=>(me(),t),t=>(me(),V(t)))):e}function xo(e){++Yt,Y.echoes&&--Y.echoes!=0||(Y.echoes=Y.id=0),Ht.push(U),ke(e,!0)}function Ao(){var e=Ht[Ht.length-1];Ht.pop(),ke(e,!1)}function ke(e,t){var n=U;if((t?!Y.echoes||Vn++&&e===U:!Vn||--Vn&&e===U)||Si(t?xo.bind(null,e):Ao),e!==U&&(U=e,n===Ye&&(Ye.env=_i()),jn)){var r=Ye.env.Promise,i=e.env;Ft.then=i.nthen,r.prototype.then=i.gthen,(n.global||e.global)&&(Object.defineProperty($,"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 _i(){var e=$.Promise;return jn?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor($,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:Ft.then,gthen:e.prototype.then}:{}}function Qe(e,t,n,r,i){var s=U;try{return ke(e,!0),t(n,r,i)}finally{ke(s,!1)}}function Si(e){mi.call(Rn,e)}function Qt(e,t,n,r){return typeof e!="function"?e:function(){var i=U;n&&Je(),ke(t,!0);try{return e.apply(this,arguments)}finally{ke(i,!1),r&&Si(me)}}}function ki(e,t){return function(n,r){return e.call(this,Qt(n,t),Qt(r,t))}}(""+mi).indexOf("[native code]")===-1&&(Je=me=T);const Ei="unhandledrejection";function Ii(e,t){var n;try{n=t.onuncatched(e)}catch{}if(n!==!1)try{var r,i={promise:t,reason:e};if($.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(Ei,!0,!0),J(r,i)):$.CustomEvent&&J(r=new CustomEvent(Ei,{detail:i}),i),r&&$.dispatchEvent&&(dispatchEvent(r),!$.PromiseRejectionEvent&&$.onunhandledrejection))try{$.onunhandledrejection(r)}catch{}se&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch{}}var V=E.reject;function zn(e,t,n,r){if(e.idbdb&&(e._state.openComplete||U.letThrough||e._vip)){var i=e._createTransaction(t,n,e._dbSchema);try{i.create(),e._state.PR1398_maxLoop=3}catch(s){return s.name===Pn.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then(()=>zn(e,t,n,r))):V(s)}return i._promise(t,(s,o)=>Se(()=>(U.trans=i,r(s,o,i)))).then(s=>i._completion.then(()=>s))}if(e._state.openComplete)return V(new x.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._options.autoOpen)return V(new x.DatabaseClosed);e.open().catch(T)}return e._state.dbReadyPromise.then(()=>zn(e,t,n,r))}const Li="3.2.7",je="\uFFFF",Gn=-1/0,ye="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Ui="String expected.",yt=[],Xt=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Do=Xt,Oo=Xt,xi=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),Zt="__dbnames",Hn="readonly",Yn="readwrite";function Ke(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}const Ai={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function en(e){return typeof e!="string"||/\./.test(e)?t=>t:t=>(t[e]===void 0&&e in t&&delete(t=lt(t))[e],t)}class Po{_trans(t,n,r){const i=this._tx||U.trans,s=this.name;function o(a,u,d){if(!d.schema[s])throw new x.NotFound("Table "+s+" not part of transaction");return n(d.idbtrans,d)}const l=ft();try{return i&&i.db===this.db?i===U.trans?i._promise(t,o,r):Se(()=>i._promise(t,o,r),{trans:i,transless:U.transless||U}):zn(this.db,t,[this.name],o)}finally{l&&mt()}}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(H(t))return new this.db.WhereClause(this,`[${t.join("+")}]`);const n=N(t);if(n.length===1)return this.where(n[0]).equals(t[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(u=>{if(u.compound&&n.every(d=>u.keyPath.indexOf(d)>=0)){for(let d=0;d<n.length;++d)if(n.indexOf(u.keyPath[d])===-1)return!1;return!0}return!1}).sort((u,d)=>u.keyPath.length-d.keyPath.length)[0];if(r&&this.db._maxKey!==je){const u=r.keyPath.slice(0,n.length);return this.where(u).equals(u.map(d=>t[d]))}!r&&se&&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(u,d){try{return s.cmp(u,d)===0}catch{return!1}}const[l,a]=n.reduce(([u,d],c)=>{const p=i[c],h=t[c];return[u||p,u||!p?Ke(d,p&&p.multi?y=>{const m=he(y,c);return H(m)&&m.some(g=>o(h,g))}:y=>o(h,he(y,c))):d]},[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,H(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(ee(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){J(this,t)})}add(t,n){const{auto:r,keyPath:i}=this.schema.primKey;let s=t;return i&&r&&(s=en(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{re(t,i,o)}catch{}return o})}update(t,n){if(typeof t!="object"||H(t))return this.where(":id").equals(t).modify(n);{const r=he(t,this.schema.primKey.keyPath);if(r===void 0)return V(new x.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?N(n).forEach(i=>{re(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=en(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{re(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:Ai})).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 x.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==t.length)throw new x.InvalidArgument("Arguments objects and keys must have the same length");const u=t.length;let d=a&&l?t.map(en(a)):t;return this.core.mutate({trans:o,type:"add",keys:i,values:d,wantResults:s}).then(({numFailures:c,results:p,lastResult:h,failures:y})=>{if(c===0)return s?p:h;throw new ut(`${this.name}.bulkAdd(): ${c} of ${u} operations failed`,y)})})}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 x.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==t.length)throw new x.InvalidArgument("Arguments objects and keys must have the same length");const u=t.length;let d=a&&l?t.map(en(a)):t;return this.core.mutate({trans:o,type:"put",keys:i,values:d,wantResults:s}).then(({numFailures:c,results:p,lastResult:h,failures:y})=>{if(c===0)return s?p:h;throw new ut(`${this.name}.bulkPut(): ${c} of ${u} operations failed`,y)})})}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 ut(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,s)})}}function gt(e){var t={},n=function(o,l){if(l){for(var a=arguments.length,u=new Array(a-1);--a;)u[a-1]=arguments[a];return t[o].subscribe.apply(null,u),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 u;l||(l=ko),a||(a=T);var d={subscribers:[],fire:a,subscribe:function(c){d.subscribers.indexOf(c)===-1&&(d.subscribers.push(c),d.fire=l(d.fire,c))},unsubscribe:function(c){d.subscribers=d.subscribers.filter(function(p){return p!==c}),d.fire=d.subscribers.reduce(l,a)}};return t[o]=n[o]=d,d}N(u=o).forEach(function(c){var p=u[c];if(H(p))s(c,u[c][0],u[c][1]);else{if(p!=="asap")throw new x.InvalidArgument("Invalid event config");var h=s(c,ct,function(){for(var y=arguments.length,m=new Array(y);y--;)m[y]=arguments[y];h.subscribers.forEach(function(g){ii(function(){g.apply(null,m)})})})}})}}function wt(e,t){return ze(t).from({prototype:e}),t}function Xe(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Jn(e,t){e.filter=Ke(e.filter,t)}function Qn(e,t,n){var r=e.replayFilter;e.replayFilter=r?()=>Ke(r(),t()):t,e.justLimit=n&&!r}function tn(e,t){if(e.isPrimKey)return t.primaryKey;const n=t.getIndexByKeyPath(e.index);if(!n)throw new x.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Di(e,t,n){const r=tn(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 nn(e,t,n,r){const i=e.replayFilter?Ke(e.filter,e.replayFilter()):e.filter;if(e.or){const s={},o=(l,a,u)=>{if(!i||i(a,u,p=>a.stop(p),p=>a.fail(p))){var d=a.primaryKey,c=""+d;c==="[object ArrayBuffer]"&&(c=""+new Uint8Array(d)),ee(s,c)||(s[c]=!0,t(l,a,u))}};return Promise.all([e.or._iterate(o,n),Oi(Di(e,r,n),e.algorithm,o,!e.keysOnly&&e.valueMapper)])}return Oi(Di(e,r,n),Ke(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function Oi(e,t,n,r){var i=B(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=T},l=>{s.fail(l),o=T})||i(s.value,s,l=>o=l),o()})})}function Q(e,t){try{const n=Pi(e),r=Pi(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 u=0;u<a;++u)if(i[u]!==s[u])return i[u]<s[u]?-1:1;return o===l?0:o<l?-1:1}(Ci(e),Ci(t));case"Array":return function(i,s){const o=i.length,l=s.length,a=o<l?o:l;for(let u=0;u<a;++u){const d=Q(i[u],s[u]);if(d!==0)return d}return o===l?0:o<l?-1:1}(e,t)}}catch{}return NaN}function Pi(e){const t=typeof e;if(t!=="object")return t;if(ArrayBuffer.isView(e))return"binary";const n=Un(e);return n==="ArrayBuffer"?"binary":n}function Ci(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class Co{_read(t,n){var r=this._ctx;return r.error?r.table._trans(null,V.bind(null,r.error)):r.table._trans("readonly",t).then(n)}_write(t){var n=this._ctx;return n.error?n.table._trans(null,V.bind(null,n.error)):n.table._trans("readwrite",t,"locked")}_addAlgorithm(t){var n=this._ctx;n.algorithm=Ke(n.algorithm,t)}_iterate(t,n){return nn(this._ctx,t,n,this._ctx.table.core)}clone(t){var n=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return t&&J(r,t),n._ctx=r,n}raw(){return this._ctx.valueMapper=null,this}each(t){var n=this._ctx;return this._read(r=>nn(n,t,r,n.table.core))}count(t){return this._read(n=>{const r=this._ctx,i=r.table.core;if(Xe(r,!0))return i.count({trans:n,query:{index:tn(r,i.schema),range:r.range}}).then(o=>Math.min(o,r.limit));var s=0;return nn(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(u,d){return d?o(u[r[d]],d-1):u[i]}var l=this._ctx.dir==="next"?1:-1;function a(u,d){var c=o(u,s),p=o(d,s);return c<p?-l:c>p?l:0}return this.toArray(function(u){return u.sort(a)}).then(n)}toArray(t){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&Xe(r,!0)&&r.limit>0){const{valueMapper:i}=r,s=tn(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 nn(r,s=>i.push(s),n,r.table.core).then(()=>i)}},t)}offset(t){var n=this._ctx;return t<=0||(n.offset+=t,Xe(n)?Qn(n,()=>{var r=t;return(i,s)=>r===0||(r===1?(--r,!1):(s(()=>{i.advance(r),r=0}),!1))}):Qn(n,()=>{var r=t;return()=>--r<0})),this}limit(t){return this._ctx.limit=Math.min(this._ctx.limit,t),Qn(this._ctx,()=>{var n=t;return function(r,i,s){return--n<=0&&i(s),n>=0}},!0),this}until(t,n){return Jn(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 Jn(this._ctx,function(i){return t(i.value)}),n=this._ctx,r=t,n.isMatch=Ke(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"&&Xe(n,!0)&&n.limit>0)return this._read(i=>{var s=tn(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 Jn(this._ctx,function(i){var s=i.primaryKey.toString(),o=ee(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=N(t),o=s.length;i=function(m){for(var g=!1,w=0;w<o;++w){var f=s[w],S=t[f];he(m,f)!==S&&(re(m,f,S),g=!0)}return g}}const l=n.table.core,{outbound:a,extractKey:u}=l.schema.primaryKey,d=this.db._options.modifyChunkSize||200,c=[];let p=0;const h=[],y=(m,g)=>{const{failures:w,numFailures:f}=g;p+=m-f;for(let S of N(w))c.push(w[S])};return this.clone().primaryKeys().then(m=>{const g=w=>{const f=Math.min(d,m.length-w);return l.getMany({trans:r,keys:m.slice(w,w+f),cache:"immutable"}).then(S=>{const _=[],I=[],v=a?[]:null,b=[];for(let k=0;k<f;++k){const R=S[k],C={value:lt(R),primKey:m[w+k]};i.call(C,C.value,C)!==!1&&(C.value==null?b.push(m[w+k]):a||Q(u(R),u(C.value))===0?(I.push(C.value),a&&v.push(m[w+k])):(b.push(m[w+k]),_.push(C.value)))}const P=Xe(n)&&n.limit===1/0&&(typeof t!="function"||t===Xn)&&{index:n.index,range:n.range};return Promise.resolve(_.length>0&&l.mutate({trans:r,type:"add",values:_}).then(k=>{for(let R in k.failures)b.splice(parseInt(R),1);y(_.length,k)})).then(()=>(I.length>0||P&&typeof t=="object")&&l.mutate({trans:r,type:"put",keys:v,values:I,criteria:P,changeSpec:typeof t!="function"&&t}).then(k=>y(I.length,k))).then(()=>(b.length>0||P&&t===Xn)&&l.mutate({trans:r,type:"delete",keys:b,criteria:P}).then(k=>y(b.length,k))).then(()=>m.length>w+f&&g(w+d))})};return g(0).then(()=>{if(c.length>0)throw new $t("Error modifying one or more objects",c,p,h);return m.length})})})}delete(){var t=this._ctx,n=t.range;return Xe(t)&&(t.isPrimKey&&!Oo||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:u,numFailures:d})=>{if(d)throw new $t("Could not delete some values",Object.keys(l).map(c=>l[c]),o-d);return o-d}))}):this.modify(Xn)}}const Xn=(e,t)=>t.value=null;function Ro(e,t){return e<t?-1:e===t?0:1}function To(e,t){return e>t?-1:e===t?0:1}function te(e,t,n){var r=e instanceof Ti?new e.Collection(e):e;return r._ctx.error=n?new n(t):new TypeError(t),r}function Ze(e){return new e.Collection(e,()=>Ri("")).limit(0)}function jo(e,t,n,r,i,s){for(var o=Math.min(e.length,r.length),l=-1,a=0;a<o;++a){var u=t[a];if(u!==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],u)<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 rn(e,t,n,r){var i,s,o,l,a,u,d,c=n.length;if(!n.every(m=>typeof m=="string"))return te(e,Ui);function p(m){i=function(w){return w==="next"?f=>f.toUpperCase():f=>f.toLowerCase()}(m),s=function(w){return w==="next"?f=>f.toLowerCase():f=>f.toUpperCase()}(m),o=m==="next"?Ro:To;var g=n.map(function(w){return{lower:s(w),upper:i(w)}}).sort(function(w,f){return o(w.lower,f.lower)});l=g.map(function(w){return w.upper}),a=g.map(function(w){return w.lower}),u=m,d=m==="next"?"":r}p("next");var h=new e.Collection(e,()=>Ee(l[0],a[c-1]+r));h._ondirectionchange=function(m){p(m)};var y=0;return h._addAlgorithm(function(m,g,w){var f=m.key;if(typeof f!="string")return!1;var S=s(f);if(t(S,a,y))return!0;for(var _=null,I=y;I<c;++I){var v=jo(f,S,l[I],a[I],o,u);v===null&&_===null?y=I+1:(_===null||o(_,v)>0)&&(_=v)}return g(_!==null?function(){m.continue(_+d)}:w),!1}),h}function Ee(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Ri(e){return{type:1,lower:e,upper:e}}class Ti{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)?Ze(this):new this.Collection(this,()=>Ee(t,n,!r,!i))}catch{return te(this,ye)}}equals(t){return t==null?te(this,ye):new this.Collection(this,()=>Ri(t))}above(t){return t==null?te(this,ye):new this.Collection(this,()=>Ee(t,void 0,!0))}aboveOrEqual(t){return t==null?te(this,ye):new this.Collection(this,()=>Ee(t,void 0,!1))}below(t){return t==null?te(this,ye):new this.Collection(this,()=>Ee(void 0,t,!1,!0))}belowOrEqual(t){return t==null?te(this,ye):new this.Collection(this,()=>Ee(void 0,t))}startsWith(t){return typeof t!="string"?te(this,Ui):this.between(t,t+je,!0,!0)}startsWithIgnoreCase(t){return t===""?this.startsWith(t):rn(this,(n,r)=>n.indexOf(r[0])===0,[t],je)}equalsIgnoreCase(t){return rn(this,(n,r)=>n===r[0],[t],"")}anyOfIgnoreCase(){var t=fe.apply(Ge,arguments);return t.length===0?Ze(this):rn(this,(n,r)=>r.indexOf(n)!==-1,t,"")}startsWithAnyOfIgnoreCase(){var t=fe.apply(Ge,arguments);return t.length===0?Ze(this):rn(this,(n,r)=>r.some(i=>n.indexOf(i)===0),t,je)}anyOf(){const t=fe.apply(Ge,arguments);let n=this._cmp;try{t.sort(n)}catch{return te(this,ye)}if(t.length===0)return Ze(this);const r=new this.Collection(this,()=>Ee(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([[Gn,t],[t,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const t=fe.apply(Ge,arguments);if(t.length===0)return new this.Collection(this);try{t.sort(this._ascending)}catch{return te(this,ye)}const n=t.reduce((r,i)=>r?r.concat([[r[r.length-1][1],i]]):[[Gn,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 Ze(this);if(!t.every(f=>f[0]!==void 0&&f[1]!==void 0&&i(f[0],f[1])<=0))return te(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",x.InvalidArgument);const a=!n||n.includeLowers!==!1,u=n&&n.includeUppers===!0;let d,c=i;function p(f,S){return c(f[0],S[0])}try{d=t.reduce(function(f,S){let _=0,I=f.length;for(;_<I;++_){const v=f[_];if(r(S[0],v[1])<0&&r(S[1],v[0])>0){v[0]=o(v[0],S[0]),v[1]=l(v[1],S[1]);break}}return _===I&&f.push(S),f},[]),d.sort(p)}catch{return te(this,ye)}let h=0;const y=u?f=>i(f,d[h][1])>0:f=>i(f,d[h][1])>=0,m=a?f=>s(f,d[h][0])>0:f=>s(f,d[h][0])>=0;let g=y;const w=new this.Collection(this,()=>Ee(d[0][0],d[d.length-1][1],!a,!u));return w._ondirectionchange=f=>{f==="next"?(g=y,c=i):(g=m,c=s),d.sort(p)},w._addAlgorithm((f,S,_)=>{for(var I=f.key;g(I);)if(++h,h===d.length)return S(_),!1;return!!function(v){return!y(v)&&!m(v)}(I)||(this._cmp(I,d[h][1])===0||this._cmp(I,d[h][0])===0||S(()=>{c===i?f.continue(d[h][0]):f.continue(d[h][1])}),!1)}),w}startsWithAnyOf(){const t=fe.apply(Ge,arguments);return t.every(n=>typeof n=="string")?t.length===0?Ze(this):this.inAnyRange(t.map(n=>[n,n+je])):te(this,"startsWithAnyOf() only works with strings")}}function oe(e){return B(function(t){return vt(t),e(t.target.error),!1})}function vt(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}const bt="storagemutated",Ie="x-storagemutated-1",Le=gt(null,bt);class Ko{_lock(){return at(!U.global),++this._reculock,this._reculock!==1||U.global||(U.lockOwnerFor=this),this}_unlock(){if(at(!U.global),--this._reculock==0)for(U.global||(U.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var t=this._blockedFuncs.shift();try{Qe(t[1],t[0])}catch{}}return this}_locked(){return this._reculock&&U.lockOwnerFor!==this}create(t){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(at(!this.idbtrans),!t&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new x.DatabaseClosed(r);case"MissingAPIError":throw new x.MissingAPI(r.message,r);default:throw new x.OpenFailed(r)}if(!this.active)throw new x.TransactionInactive;return at(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=B(i=>{vt(i),this._reject(t.error)}),t.onabort=B(i=>{vt(i),this.active&&this._reject(new x.Abort(t.error)),this.active=!1,this.on("abort").fire(i)}),t.oncomplete=B(()=>{this.active=!1,this._resolve(),"mutatedParts"in t&&Le.storagemutated.fire(t.mutatedParts)}),this}_promise(t,n,r){if(t==="readwrite"&&this.mode!=="readwrite")return V(new x.ReadOnly("Transaction is readonly"));if(!this.active)return V(new x.TransactionInactive);if(this._locked())return new E((s,o)=>{this._blockedFuncs.push([()=>{this._promise(t,n,r).then(s,o)},U])});if(r)return Se(()=>{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(B(o.bind(null,a))),a=>n._waitingQueue.push(B(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 x.Abort))}table(t){const n=this._memoizedTables||(this._memoizedTables={});if(ee(n,t))return n[t];const r=this.schema[t];if(!r)throw new x.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 Zn(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?"++":"")+ji(t)}}function ji(e){return typeof e=="string"?e:e?"["+[].join.call(e,"+")+"]":""}function Ki(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:si(n,r=>[r.name,r])}}let _t=e=>{try{return e.only([[]]),_t=()=>[[]],[[]]}catch{return _t=()=>je,je}};function er(e){return e==null?()=>{}:typeof e=="string"?function(t){return t.split(".").length===1?n=>n[t]:n=>he(n,t)}(e):t=>he(t,e)}function Mi(e){return[].slice.call(e)}let Mo=0;function St(e){return e==null?":id":typeof e=="string"?e:`[${e.join("+")}]`}function $o(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:u,upper:d,lowerOpen:c,upperOpen:p}=a;return u===void 0?d===void 0?null:t.upperBound(d,!!p):d===void 0?t.lowerBound(u,!!c):t.bound(u,d,!!c,!!p)}const{schema:i,hasGetAll:s}=function(a,u){const d=Mi(a.objectStoreNames);return{schema:{name:a.name,tables:d.map(c=>u.objectStore(c)).map(c=>{const{keyPath:p,autoIncrement:h}=c,y=H(p),m=p==null,g={},w={name:c.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:m,compound:y,keyPath:p,autoIncrement:h,unique:!0,extractKey:er(p)},indexes:Mi(c.indexNames).map(f=>c.index(f)).map(f=>{const{name:S,unique:_,multiEntry:I,keyPath:v}=f,b={name:S,compound:H(v),keyPath:v,unique:_,multiEntry:I,extractKey:er(v)};return g[St(v)]=b,b}),getIndexByKeyPath:f=>g[St(f)]};return g[":id"]=w.primaryKey,p!=null&&(g[St(p)]=w.primaryKey),w})},hasGetAll:d.length>0&&"getAll"in u.objectStore(d[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(u){const d=u.name;return{name:d,schema:u,mutate:function({trans:c,type:p,keys:h,values:y,range:m}){return new Promise((g,w)=>{g=B(g);const f=c.objectStore(d),S=f.keyPath==null,_=p==="put"||p==="add";if(!_&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);const{length:I}=h||y||{length:1};if(h&&y&&h.length!==y.length)throw new Error("Given keys array must have same length as given values array.");if(I===0)return g({numFailures:0,failures:{},results:[],lastResult:void 0});let v;const b=[],P=[];let k=0;const R=q=>{++k,vt(q)};if(p==="deleteRange"){if(m.type===4)return g({numFailures:k,failures:P,results:[],lastResult:void 0});m.type===3?b.push(v=f.clear()):b.push(v=f.delete(r(m)))}else{const[q,W]=_?S?[y,h]:[y,null]:[h,null];if(_)for(let j=0;j<I;++j)b.push(v=W&&W[j]!==void 0?f[p](q[j],W[j]):f[p](q[j])),v.onerror=R;else for(let j=0;j<I;++j)b.push(v=f[p](q[j])),v.onerror=R}const C=q=>{const W=q.target.result;b.forEach((j,ue)=>j.error!=null&&(P[ue]=j.error)),g({numFailures:k,failures:P,results:p==="delete"?h:b.map(j=>j.result),lastResult:W})};v.onerror=q=>{R(q),C(q)},v.onsuccess=C})},getMany:({trans:c,keys:p})=>new Promise((h,y)=>{h=B(h);const m=c.objectStore(d),g=p.length,w=new Array(g);let f,S=0,_=0;const I=b=>{const P=b.target;w[P._pos]=P.result,++_===S&&h(w)},v=oe(y);for(let b=0;b<g;++b)p[b]!=null&&(f=m.get(p[b]),f._pos=b,f.onsuccess=I,f.onerror=v,++S);S===0&&h(w)}),get:({trans:c,key:p})=>new Promise((h,y)=>{h=B(h);const m=c.objectStore(d).get(p);m.onsuccess=g=>h(g.target.result),m.onerror=oe(y)}),query:function(c){return p=>new Promise((h,y)=>{h=B(h);const{trans:m,values:g,limit:w,query:f}=p,S=w===1/0?void 0:w,{index:_,range:I}=f,v=m.objectStore(d),b=_.isPrimaryKey?v:v.index(_.name),P=r(I);if(w===0)return h({result:[]});if(c){const k=g?b.getAll(P,S):b.getAllKeys(P,S);k.onsuccess=R=>h({result:R.target.result}),k.onerror=oe(y)}else{let k=0;const R=g||!("openKeyCursor"in b)?b.openCursor(P):b.openKeyCursor(P),C=[];R.onsuccess=q=>{const W=R.result;return W?(C.push(g?W.value:W.primaryKey),++k===w?h({result:C}):void W.continue()):h({result:C})},R.onerror=oe(y)}})}(s),openCursor:function({trans:c,values:p,query:h,reverse:y,unique:m}){return new Promise((g,w)=>{g=B(g);const{index:f,range:S}=h,_=c.objectStore(d),I=f.isPrimaryKey?_:_.index(f.name),v=y?m?"prevunique":"prev":m?"nextunique":"next",b=p||!("openKeyCursor"in I)?I.openCursor(r(S),v):I.openKeyCursor(r(S),v);b.onerror=oe(w),b.onsuccess=B(P=>{const k=b.result;if(!k)return void g(null);k.___id=++Mo,k.done=!1;const R=k.continue.bind(k);let C=k.continuePrimaryKey;C&&(C=C.bind(k));const q=k.advance.bind(k),W=()=>{throw new Error("Cursor not stopped")};k.trans=c,k.stop=k.continue=k.continuePrimaryKey=k.advance=()=>{throw new Error("Cursor not started")},k.fail=B(w),k.next=function(){let j=1;return this.start(()=>j--?this.continue():this.stop()).then(()=>this)},k.start=j=>{const ue=new Promise((G,Ae)=>{G=B(G),b.onerror=oe(Ae),k.fail=Ae,k.stop=rt=>{k.stop=k.continue=k.continuePrimaryKey=k.advance=W,G(rt)}}),K=()=>{if(b.result)try{j()}catch(G){k.fail(G)}else k.done=!0,k.start=()=>{throw new Error("Cursor behind last entry")},k.stop()};return b.onsuccess=B(G=>{b.onsuccess=K,K()}),k.continue=R,k.continuePrimaryKey=C,k.advance=q,K(),ue},g(k)},w)})},count({query:c,trans:p}){const{index:h,range:y}=c;return new Promise((m,g)=>{const w=p.objectStore(d),f=h.isPrimaryKey?w:w.index(h.name),S=r(y),_=S?f.count(S):f.count();_.onsuccess=B(I=>m(I.target.result)),_.onerror=oe(g)})}}}(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:_t(t),schema:i}}function tr({_novip:e},t){const n=t.db,r=function(i,s,{IDBKeyRange:o,indexedDB:l},a){return{dbcore:function(u,d){return d.reduce((c,{create:p})=>({...c,...p(c)}),u)}($o(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 sn({_novip:e},t,n,r){n.forEach(i=>{const s=r[i];t.forEach(o=>{const l=In(o,i);(!l||"value"in l&&l.value===void 0)&&(o===e.Transaction.prototype||o instanceof e.Transaction?pe(o,i,{get(){return this.table(i)},set(a){ni(this,i,{value:a,writable:!0,configurable:!0,enumerable:!0})}}):o[i]=new e.Table(i,s))})})}function nr({_novip:e},t){t.forEach(n=>{for(let r in n)n[r]instanceof e.Table&&delete n[r]})}function Bo(e,t){return e._cfg.version-t._cfg.version}function Fo(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=U.transless||U;Se(()=>{U.trans=s,U.transless=l,t===0?(N(i).forEach(a=>{rr(n,a,i[a].primKey,i[a].indexes)}),tr(e,n),E.follow(()=>e.on.populate.fire(s)).catch(o)):function({_novip:a},u,d,c){const p=[],h=a._versions;let y=a._dbSchema=sr(a,a.idbdb,c),m=!1;const g=h.filter(f=>f._cfg.version>=u);function w(){return p.length?E.resolve(p.shift()(d.idbtrans)).then(w):E.resolve()}return g.forEach(f=>{p.push(()=>{const S=y,_=f._cfg.dbschema;or(a,S,c),or(a,_,c),y=a._dbSchema=_;const I=$i(S,_);I.add.forEach(b=>{rr(c,b[0],b[1].primKey,b[1].indexes)}),I.change.forEach(b=>{if(b.recreate)throw new x.Upgrade("Not yet support for changing primary key");{const P=c.objectStore(b.name);b.add.forEach(k=>ir(P,k)),b.change.forEach(k=>{P.deleteIndex(k.name),ir(P,k)}),b.del.forEach(k=>P.deleteIndex(k))}});const v=f._cfg.contentUpgrade;if(v&&f._cfg.version>u){tr(a,c),d._memoizedTables={},m=!0;let b=oi(_);I.del.forEach(C=>{b[C]=S[C]}),nr(a,[a.Transaction.prototype]),sn(a,[a.Transaction.prototype],N(b),b),d.schema=b;const P=An(v);let k;P&&Je();const R=E.follow(()=>{if(k=v(d),k&&P){var C=me.bind(null,null);k.then(C,C)}});return k&&typeof k.then=="function"?E.resolve(k):R.then(()=>k)}}),p.push(S=>{(!m||!Do)&&function(_,I){[].slice.call(I.db.objectStoreNames).forEach(v=>_[v]==null&&I.db.deleteObjectStore(v))}(f._cfg.dbschema,S),nr(a,[a.Transaction.prototype]),sn(a,[a.Transaction.prototype],a._storeNames,a._dbSchema),d.schema=a._dbSchema})}),w().then(()=>{var f,S;S=c,N(f=y).forEach(_=>{S.db.objectStoreNames.contains(_)||rr(S,_,f[_].primKey,f[_].indexes)})})}(e,t,s,n).catch(o)})}function $i(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&&!Xt)o.recreate=!0,n.change.push(o);else{const l=i.idxByName,a=s.idxByName;let u;for(u in l)a[u]||o.del.push(u);for(u in a){const d=l[u],c=a[u];d?d.src!==c.src&&o.change.push(c):o.add.push(c)}(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 rr(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=>ir(i,s)),i}function ir(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function sr(e,t,n){const r={};return Mt(t.objectStoreNames,0).forEach(i=>{const s=n.objectStore(i);let o=s.keyPath;const l=Zn(ji(o),o||"",!1,!1,!!s.autoIncrement,o&&typeof o!="string",!0),a=[];for(let d=0;d<s.indexNames.length;++d){const c=s.index(s.indexNames[d]);o=c.keyPath;var u=Zn(c.name,o,!!c.unique,!!c.multiEntry,!1,o&&typeof o!="string",!1);a.push(u)}r[i]=Ki(i,l,a)}),r}function or({_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],u=o.index(a).keyPath,d=typeof u=="string"?u:"["+Mt(u).join("+")+"]";if(t[s]){const c=t[s].idxByName[d];c&&(c.name=a,delete t[s].idxByName[d],t[s].idxByName[a]=c)}}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&$.WorkerGlobalScope&&$ instanceof $.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class No{_parseStoresSpec(t,n){N(t).forEach(r=>{if(t[r]!==null){var i=t[r].split(",").map((o,l)=>{const a=(o=o.trim()).replace(/([&*]|\+\+)/g,""),u=/^\[/.test(a)?a.match(/^\[(.*)\]$/)[1].split("+"):a;return Zn(a,u||null,/\&/.test(o),/\*/.test(o),/\+\+/.test(o),H(u),l===0)}),s=i.shift();if(s.multi)throw new x.Schema("Primary key cannot be multi-valued");i.forEach(o=>{if(o.auto)throw new x.Schema("Only primary key can be marked as autoIncrement (++)");if(!o.keyPath)throw new x.Schema("Index must have a name and cannot be an empty string")}),n[r]=Ki(r,s,i)}})}stores(t){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?J(this._cfg.storesSource,t):t;const r=n._versions,i={};let s={};return r.forEach(o=>{J(i,o._cfg.storesSource),s=o._cfg.dbschema={},o._parseStoresSpec(i,s)}),n._dbSchema=s,nr(n,[n._allTables,n,n.Transaction.prototype]),sn(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],N(s),s),n._storeNames=N(s),this}upgrade(t){return this._cfg.contentUpgrade=Cn(this._cfg.contentUpgrade||T,t),this}}function ar(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new Ne(Zt,{addons:[],indexedDB:e,IDBKeyRange:t}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function lr(e){return e&&typeof e.databases=="function"}function ur(e){return Se(function(){return U.letThrough=!0,e()})}function qo(){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 Wo(e){const t=e._state,{indexedDB:n}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?V(t.dbOpenError):e);se&&(t.openCanceller._stackHolder=Pe()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;const r=t.openCanceller;function i(){if(t.openCanceller!==r)throw new x.DatabaseClosed("db.open() was cancelled")}let s=t.dbReadyResolve,o=null,l=!1;const a=()=>new E((u,d)=>{if(i(),!n)throw new x.MissingAPI;const c=e.name,p=t.autoSchema?n.open(c):n.open(c,Math.round(10*e.verno));if(!p)throw new x.MissingAPI;p.onerror=oe(d),p.onblocked=B(e._fireOnBlocked),p.onupgradeneeded=B(h=>{if(o=p.transaction,t.autoSchema&&!e._options.allowEmptyDB){p.onerror=vt,o.abort(),p.result.close();const m=n.deleteDatabase(c);m.onsuccess=m.onerror=B(()=>{d(new x.NoSuchDatabase(`Database ${c} doesnt exist`))})}else{o.onerror=oe(d);var y=h.oldVersion>Math.pow(2,62)?0:h.oldVersion;l=y<1,e._novip.idbdb=p.result,Fo(e,y/10,o,d)}},d),p.onsuccess=B(()=>{o=null;const h=e._novip.idbdb=p.result,y=Mt(h.objectStoreNames);if(y.length>0)try{const g=h.transaction((m=y).length===1?m[0]:m,"readonly");t.autoSchema?function({_novip:w},f,S){w.verno=f.version/10;const _=w._dbSchema=sr(0,f,S);w._storeNames=Mt(f.objectStoreNames,0),sn(w,[w._allTables],N(_),_)}(e,h,g):(or(e,e._dbSchema,g),function(w,f){const S=$i(sr(0,w.idbdb,f),w._dbSchema);return!(S.add.length||S.change.some(_=>_.add.length||_.change.length))}(e,g)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),tr(e,g)}catch{}var m;yt.push(e),h.onversionchange=B(g=>{t.vcFired=!0,e.on("versionchange").fire(g)}),h.onclose=B(g=>{e.on("close").fire(g)}),l&&function({indexedDB:g,IDBKeyRange:w},f){!lr(g)&&f!==Zt&&ar(g,w).put({name:f}).catch(T)}(e._deps,c),u()},d)}).catch(u=>u&&u.name==="UnknownError"&&t.PR1398_maxLoop>0?(t.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),a()):E.reject(u));return E.race([r,(typeof navigator>"u"?E.resolve():qo()).then(a)]).then(()=>(i(),t.onReadyBeingFired=[],E.resolve(ur(()=>e.on.ready.fire(e.vip))).then(function u(){if(t.onReadyBeingFired.length>0){let d=t.onReadyBeingFired.reduce(Cn,T);return t.onReadyBeingFired=[],E.resolve(ur(()=>d(e.vip))).then(u)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(u=>{t.dbOpenError=u;try{o&&o.abort()}catch{}return r===t.openCanceller&&e._close(),V(u)}).finally(()=>{t.openComplete=!0,s()})}function cr(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):H(a)?Promise.all(a).then(n,r):n(a)}}return i(t)()}function Vo(e,t,n){var r=arguments.length;if(r<2)throw new x.InvalidArgument("Too few arguments");for(var i=new Array(r-1);--r;)i[r-1]=arguments[r];return n=i.pop(),[e,ai(i),n]}function Bi(e,t,n,r,i){return E.resolve().then(()=>{const s=U.transless||U,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(c){return c.name===Pn.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then(()=>Bi(e,t,n,null,i))):V(c)}const a=An(i);let u;a&&Je();const d=E.follow(()=>{if(u=i.call(o,o),u)if(a){var c=me.bind(null,null);u.then(c,c)}else typeof u.next=="function"&&typeof u.throw=="function"&&(u=cr(u))},l);return(u&&typeof u.then=="function"?E.resolve(u).then(c=>o.active?c:V(new x.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):d.then(()=>u)).then(c=>(r&&o._resolve(),o._completion.then(()=>c))).catch(c=>(o._reject(c),V(c)))})}function on(e,t,n){const r=H(e)?e.slice():[e];for(let i=0;i<n;++i)r.push(t);return r}const zo={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,c){const p=St(u),h=i[p]=i[p]||[],y=u==null?0:typeof u=="string"?1:u.length,m=d>0,g={...c,isVirtual:m,keyTail:d,keyLength:y,extractKey:er(u),unique:!m&&c.unique};return h.push(g),g.isPrimaryKey||s.push(g),y>1&&o(y===2?u[0]:u.slice(0,y-1),d+1,c),h.sort((w,f)=>w.keyTail-f.keyTail),g}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:(c=u.query.range,p=d.keyTail,{type:c.type===1?2:c.type,lower:on(c.lower,c.lowerOpen?e.MAX_KEY:e.MIN_KEY,p),lowerOpen:!0,upper:on(c.upper,c.upperOpen?e.MIN_KEY:e.MAX_KEY,p),upperOpen:!0})}}:u;var c,p}return{...n,schema:{...r,primaryKey:l,indexes:s,getIndexByKeyPath:function(u){const d=i[St(u)];return d&&d[0]}},count:u=>n.count(a(u)),query:u=>n.query(a(u)),openCursor(u){const{keyTail:d,isVirtual:c,keyLength:p}=u.query.index;return c?n.openCursor(a(u)).then(h=>h&&function(y){return Object.create(y,{continue:{value:function(m){m!=null?y.continue(on(m,u.reverse?e.MAX_KEY:e.MIN_KEY,d)):u.unique?y.continue(y.key.slice(0,p).concat(u.reverse?e.MIN_KEY:e.MAX_KEY,d)):y.continue()}},continuePrimaryKey:{value(m,g){y.continuePrimaryKey(on(m,e.MAX_KEY,d),g)}},primaryKey:{get:()=>y.primaryKey},key:{get(){const m=y.key;return p===1?m[0]:m.slice(0,p)}},value:{get:()=>y.value}})}(h)):n.openCursor(u)}}}}}};function dr(e,t,n,r){return n=n||{},r=r||"",N(e).forEach(i=>{if(ee(t,i)){var s=e[i],o=t[i];if(typeof s=="object"&&typeof o=="object"&&s&&o){const l=Un(s);l!==Un(o)?n[r+i]=t[i]:l==="Object"?dr(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}),N(t).forEach(i=>{ee(e,i)||(n[r+i]=t[i])}),n}const Go={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){const n=e.table(t),{primaryKey:r}=n.schema;return{...n,mutate(i){const s=U.trans,{deleting:o,creating:l,updating:a}=s.table(t).hook;switch(i.type){case"add":if(l.fire===T)break;return s._promise("readwrite",()=>u(i),!0);case"put":if(l.fire===T&&a.fire===T)break;return s._promise("readwrite",()=>u(i),!0);case"delete":if(o.fire===T)break;return s._promise("readwrite",()=>u(i),!0);case"deleteRange":if(o.fire===T)break;return s._promise("readwrite",()=>function(c){return d(c.trans,c.range,1e4)}(i),!0)}return n.mutate(i);function u(c){const p=U.trans,h=c.keys||function(y,m){return m.type==="delete"?m.keys:m.keys||m.values.map(y.extractKey)}(r,c);if(!h)throw new Error("Keys missing");return(c=c.type==="add"||c.type==="put"?{...c,keys:h}:{...c}).type!=="delete"&&(c.values=[...c.values]),c.keys&&(c.keys=[...c.keys]),function(y,m,g){return m.type==="add"?Promise.resolve([]):y.getMany({trans:m.trans,keys:g,cache:"immutable"})}(n,c,h).then(y=>{const m=h.map((g,w)=>{const f=y[w],S={onerror:null,onsuccess:null};if(c.type==="delete")o.fire.call(S,g,f,p);else if(c.type==="add"||f===void 0){const _=l.fire.call(S,g,c.values[w],p);g==null&&_!=null&&(g=_,c.keys[w]=g,r.outbound||re(c.values[w],r.keyPath,g))}else{const _=dr(f,c.values[w]),I=a.fire.call(S,_,g,f,p);if(I){const v=c.values[w];Object.keys(I).forEach(b=>{ee(v,b)?v[b]=I[b]:re(v,b,I[b])})}}return S});return n.mutate(c).then(({failures:g,results:w,numFailures:f,lastResult:S})=>{for(let _=0;_<h.length;++_){const I=w?w[_]:h[_],v=m[_];I==null?v.onerror&&v.onerror(g[_]):v.onsuccess&&v.onsuccess(c.type==="put"&&y[_]?c.values[_]:I)}return{failures:g,results:w,numFailures:f,lastResult:S}}).catch(g=>(m.forEach(w=>w.onerror&&w.onerror(g)),Promise.reject(g)))})}function d(c,p,h){return n.query({trans:c,values:!1,query:{index:r,range:p},limit:h}).then(({result:y})=>u({type:"delete",keys:y,trans:c}).then(m=>m.numFailures>0?Promise.reject(m.failures[0]):y.length<h?{failures:[],numFailures:0,lastResult:void 0}:d(c,{...p,lower:y[y.length-1],lowerOpen:!0},h)))}}}}})};function Fi(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)Q(t.keys[i],e[s])===0&&(r.push(n?lt(t.values[i]):t.values[i]),++s);return r.length===e.length?r:null}catch{return null}}const Ho={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=Fi(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"?lt(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function pr(e){return!("from"in e)}const ge=function(e,t){if(!this){const n=new ge;return e&&"d"in e&&J(n,e),n}J(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function kt(e,t,n){const r=Q(t,n);if(isNaN(r))return;if(r>0)throw RangeError();if(pr(e))return J(e,{from:t,to:n,d:1});const i=e.l,s=e.r;if(Q(n,e.from)<0)return i?kt(i,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Ni(e);if(Q(t,e.to)>0)return s?kt(s,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Ni(e);Q(t,e.from)<0&&(e.from=t,e.l=null,e.d=s?s.d+1:1),Q(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&&an(e,i),s&&o&&an(e,s)}function an(e,t){pr(t)||function n(r,{from:i,to:s,l:o,r:l}){kt(r,i,s),o&&n(r,o),l&&n(r,l)}(e,t)}function Yo(e,t){const n=hr(t);let r=n.next();if(r.done)return!1;let i=r.value;const s=hr(e);let o=s.next(i.from),l=o.value;for(;!r.done&&!o.done;){if(Q(l.from,i.to)<=0&&Q(l.to,i.from)>=0)return!0;Q(i.from,l.from)<0?i=(r=n.next(l.from)).value:l=(o=s.next(i.from)).value}return!1}function hr(e){let t=pr(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&&Q(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||Q(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 Ni(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=qi(o)}e.d=qi(e)}function qi({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}Ve(ge.prototype,{add(e){return an(this,e),this},addKey(e){return kt(this,e,e),this},addKeys(e){return e.forEach(t=>kt(this,t,t)),this},[xn](){return hr(this)}});const Jo={stack:"dbcore",level:0,create:e=>{const t=e.schema.name,n=new ge(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,u={...i,mutate:p=>{const h=p.trans,y=h.mutatedParts||(h.mutatedParts={}),m=v=>{const b=`idb://${t}/${r}/${v}`;return y[b]||(y[b]=new ge)},g=m(""),w=m(":dels"),{type:f}=p;let[S,_]=p.type==="deleteRange"?[p.range]:p.type==="delete"?[p.keys]:p.values.length<50?[[],p.values]:[];const I=p.trans._cache;return i.mutate(p).then(v=>{if(H(S)){f!=="delete"&&(S=v.results),g.addKeys(S);const b=Fi(S,I);b||f==="add"||w.addKeys(S),(b||_)&&function(P,k,R,C){function q(W){const j=P(W.name||"");function ue(G){return G!=null?W.extractKey(G):null}const K=G=>W.multiEntry&&H(G)?G.forEach(Ae=>j.addKey(Ae)):j.addKey(G);(R||C).forEach((G,Ae)=>{const rt=R&&ue(R[Ae]),vn=C&&ue(C[Ae]);Q(rt,vn)!==0&&(rt!=null&&K(rt),vn!=null&&K(vn))})}k.indexes.forEach(q)}(m,s,b,_)}else if(S){const b={from:S.lower,to:S.upper};w.add(b),g.add(b)}else g.add(n),w.add(n),s.indexes.forEach(b=>m(b.name).add(n));return v})}},d=({query:{index:p,range:h}})=>{var y,m;return[p,new ge((y=h.lower)!==null&&y!==void 0?y:e.MIN_KEY,(m=h.upper)!==null&&m!==void 0?m:e.MAX_KEY)]},c={get:p=>[o,new ge(p.key)],getMany:p=>[o,new ge().addKeys(p.keys)],count:d,query:d,openCursor:d};return N(c).forEach(p=>{u[p]=function(h){const{subscr:y}=U;if(y){const m=_=>{const I=`idb://${t}/${r}/${_}`;return y[I]||(y[I]=new ge)},g=m(""),w=m(":dels"),[f,S]=c[p](h);if(m(f.name||"").add(S),!f.isPrimaryKey){if(p!=="count"){const _=p==="query"&&a&&h.values&&i.query({...h,values:!1});return i[p].apply(this,arguments).then(I=>{if(p==="query"){if(a&&h.values)return _.then(({result:b})=>(g.addKeys(b),I));const v=h.values?I.result.map(l):I.result;h.values?g.addKeys(v):w.addKeys(v)}else if(p==="openCursor"){const v=I,b=h.values;return v&&Object.create(v,{key:{get:()=>(w.addKey(v.primaryKey),v.key)},primaryKey:{get(){const P=v.primaryKey;return w.addKey(P),P}},value:{get:()=>(b&&g.addKey(v.primaryKey),v.value)}})}return I})}w.add(n)}}return i[p].apply(this,arguments)}}),u}}}};class Ne{constructor(t,n){this._middlewares={},this.verno=0;const r=Ne.dependencies;this._options=n={addons:Ne.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:T,dbReadyPromise:null,cancelOpen:T,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=gt(this,"populate","blocked","versionchange","close",{ready:[Cn,T]}),this.on.ready.subscribe=ri(this.on.ready.subscribe,l=>(a,u)=>{Ne.vip(()=>{const d=this._state;if(d.openComplete)d.dbOpenError||E.resolve().then(a),u&&l(a);else if(d.onReadyBeingFired)d.onReadyBeingFired.push(a),u&&l(a);else{l(a);const c=this;u||l(function p(){c.on.ready.unsubscribe(a),c.on.ready.unsubscribe(p)})}})}),this.Collection=(o=this,wt(Co.prototype,function(l,a){this.db=o;let u=Ai,d=null;if(a)try{u=a()}catch(y){d=y}const c=l._ctx,p=c.table,h=p.hook.reading.fire;this._ctx={table:p,index:c.index,isPrimKey:!c.index||p.schema.primKey.keyPath&&c.index===p.schema.primKey.name,range:u,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:d,or:c.or,valueMapper:h!==ct?h:null}})),this.Table=function(l){return wt(Po.prototype,function(a,u,d){this.db=l,this._tx=d,this.name=a,this.schema=u,this.hook=l._allTables[a]?l._allTables[a].hook:gt(null,{creating:[bo,T],reading:[vo,ct],updating:[So,T],deleting:[_o,T]})})}(this),this.Transaction=function(l){return wt(Ko.prototype,function(a,u,d,c,p){this.db=l,this.mode=a,this.storeNames=u,this.schema=d,this.chromeTransactionDurability=c,this.idbtrans=null,this.on=gt(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,y)=>{this._resolve=h,this._reject=y}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},h=>{var y=this.active;return this.active=!1,this.on.error.fire(h),this.parent?this.parent._reject(h):y&&this.idbtrans&&this.idbtrans.abort(),V(h)})})}(this),this.Version=function(l){return wt(No.prototype,function(a){this.db=l,this._cfg={version:a,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(l){return wt(Ti.prototype,function(a,u,d){this.db=l,this._ctx={table:a,index:u===":id"?null:u,or:d};const c=l._deps.indexedDB;if(!c)throw new x.MissingAPI;this._cmp=this._ascending=c.cmp.bind(c),this._descending=(p,h)=>c.cmp(h,p),this._max=(p,h)=>c.cmp(p,h)>0?p:h,this._min=(p,h)=>c.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=_t(n.IDBKeyRange),this._createTransaction=(l,a,u,d)=>new this.Transaction(l,a,u,this._options.chromeTransactionDurability,d),this._fireOnBlocked=l=>{this.on("blocked").fire(l),yt.filter(a=>a.name===this.name&&a!==this&&!a._state.vcFired).map(a=>a.on("versionchange").fire(l))},this.use(zo),this.use(Go),this.use(Jo),this.use(Ho),this.vip=Object.create(this,{_vip:{value:!0}}),i.forEach(l=>l(this))}version(t){if(isNaN(t)||t<.1)throw new x.Type("Given version is not a positive number");if(t=Math.round(10*t)/10,this.idbdb||this._state.isBeingOpened)throw new x.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(Bo),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(t){return this.idbdb&&(this._state.openComplete||U.letThrough||this._vip)?t():new E((n,r)=>{if(this._state.openComplete)return r(new x.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new x.DatabaseClosed);this.open().catch(T)}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 Wo(this)}_close(){const t=this._state,n=yt.indexOf(this);if(n>=0&&yt.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 x.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=B(()=>{(function({indexedDB:l,IDBKeyRange:a},u){!lr(l)&&u!==Zt&&ar(l,a).delete(u).catch(T)})(this._deps,this.name),r()}),o.onerror=oe(i),o.onblocked=this._fireOnBlocked};if(t)throw new x.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 N(this._allTables).map(t=>this._allTables[t])}transaction(){const t=Vo.apply(this,arguments);return this._transaction.apply(this,t)}_transaction(t,n,r){let i=U.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(u=>{var d=u instanceof this.Table?u.name:u;if(typeof d!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return d}),t=="r"||t===Hn)o=Hn;else{if(t!="rw"&&t!=Yn)throw new x.InvalidArgument("Invalid transaction mode: "+t);o=Yn}if(i){if(i.mode===Hn&&o===Yn){if(!s)throw new x.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&l.forEach(u=>{if(i&&i.storeNames.indexOf(u)===-1){if(!s)throw new x.SubTransaction("Table "+u+" not included in parent transaction.");i=null}}),s&&i&&!i.active&&(i=null)}}catch(u){return i?i._promise(null,(d,c)=>{c(u)}):V(u)}const a=Bi.bind(null,this,o,l,i,r);return i?i._promise(o,a,"lock"):U.trans?Qe(U.transless,()=>this._whenReady(a)):this._whenReady(a)}table(t){if(!ee(this._allTables,t))throw new x.InvalidTable(`Table ${t} does not exist`);return this._allTables[t]}}const Qo=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class Xo{constructor(t){this._subscribe=t}subscribe(t,n,r){return this._subscribe(t&&typeof t!="function"?t:{next:t,error:n,complete:r})}[Qo](){return this}}function Wi(e,t){return N(t).forEach(n=>{an(e[n]||(e[n]=new ge),t[n])}),e}function Zo(e){let t,n=!1;const r=new Xo(i=>{const s=An(e);let o=!1,l={},a={};const u={get closed(){return o},unsubscribe:()=>{o=!0,Le.storagemutated.unsubscribe(h)}};i.start&&i.start(u);let d=!1,c=!1;function p(){return N(a).some(m=>l[m]&&Yo(l[m],a[m]))}const h=m=>{Wi(l,m),p()&&y()},y=()=>{if(d||o)return;l={};const m={},g=function(w){s&&Je();const f=()=>Se(e,{subscr:w,trans:null}),S=U.trans?Qe(U.transless,f):f();return s&&S.then(me,me),S}(m);c||(Le(bt,h),c=!0),d=!0,Promise.resolve(g).then(w=>{n=!0,t=w,d=!1,o||(p()?y():(l={},a=m,i.next&&i.next(w)))},w=>{d=!1,n=!1,i.error&&i.error(w),u.unsubscribe()})};return y(),u});return r.hasValue=()=>n,r.getValue=()=>t,r}let fr;try{fr={indexedDB:$.indexedDB||$.mozIndexedDB||$.webkitIndexedDB||$.msIndexedDB,IDBKeyRange:$.IDBKeyRange||$.webkitIDBKeyRange}}catch{fr={indexedDB:null,IDBKeyRange:null}}const Me=Ne;function ln(e){let t=we;try{we=!0,Le.storagemutated.fire(e)}finally{we=t}}Ve(Me,{...Bt,delete:e=>new Me(e,{addons:[]}).delete(),exists:e=>new Me(e,{addons:[]}).open().then(t=>(t.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return function({indexedDB:t,IDBKeyRange:n}){return lr(t)?Promise.resolve(t.databases()).then(r=>r.map(i=>i.name).filter(i=>i!==Zt)):ar(t,n).toCollection().primaryKeys()}(Me.dependencies).then(e)}catch{return V(new x.MissingAPI)}},defineClass:()=>function(e){J(this,e)},ignoreTransaction:e=>U.trans?Qe(U.transless,e):e(),vip:ur,async:function(e){return function(){try{var t=cr(e.apply(this,arguments));return t&&typeof t.then=="function"?t:E.resolve(t)}catch(n){return V(n)}}},spawn:function(e,t,n){try{var r=cr(e.apply(n,t||[]));return r&&typeof r.then=="function"?r:E.resolve(r)}catch(i){return V(i)}},currentTransaction:{get:()=>U.trans||null},waitFor:function(e,t){const n=E.resolve(typeof e=="function"?Me.ignoreTransaction(e):e).timeout(t||6e4);return U.trans?U.trans.waitFor(n):n},Promise:E,debug:{get:()=>se,set:e=>{ui(e,e==="dexie"?()=>!0:xi)}},derive:ze,extend:J,props:Ve,override:ri,Events:gt,on:Le,liveQuery:Zo,extendObservabilitySet:Wi,getByKeyPath:he,setByKeyPath:re,delByKeyPath:function(e,t){typeof t=="string"?re(e,t,void 0):"length"in t&&[].map.call(t,function(n){re(e,n,void 0)})},shallowClone:oi,deepClone:lt,getObjectDiff:dr,cmp:Q,asap:ii,minKey:Gn,addons:[],connections:yt,errnames:Pn,dependencies:fr,semVer:Li,version:Li.split(".").map(e=>parseInt(e)).reduce((e,t,n)=>e+t/Math.pow(10,2*n))}),Me.maxKey=_t(Me.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(Le(bt,e=>{if(!we){let t;Xt?(t=document.createEvent("CustomEvent"),t.initCustomEvent(Ie,!0,!0,e)):t=new CustomEvent(Ie,{detail:e}),we=!0,dispatchEvent(t),we=!1}}),addEventListener(Ie,({detail:e})=>{we||ln(e)}));let we=!1;if(typeof BroadcastChannel<"u"){const e=new BroadcastChannel(Ie);typeof e.unref=="function"&&e.unref(),Le(bt,t=>{we||e.postMessage(t)}),e.onmessage=t=>{t.data&&ln(t.data)}}else if(typeof self<"u"&&typeof navigator<"u"){Le(bt,t=>{try{we||(typeof localStorage<"u"&&localStorage.setItem(Ie,JSON.stringify({trig:Math.random(),changedParts:t})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:Ie,changedParts:t})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",t=>{if(t.key===Ie){const n=JSON.parse(t.newValue);n&&ln(n.changedParts)}});const e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:t}){t&&t.type===Ie&&ln(t.changedParts)})}E.rejectionMapper=function(e,t){if(!e||e instanceof He||e instanceof TypeError||e instanceof SyntaxError||!e.name||!hi[e.name])return e;var n=new hi[e.name](t||e.message,e);return"stack"in e&&pe(n,"stack",{get:function(){return this.inner.stack}}),n},ui(se,xi);let Vi=!0,mr=!1;const ea=()=>Vi=!1,ta=()=>mr=!0,na=["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 Et={},yr;class ra{constructor(t){F(this,"_values",[]),F(this,"_isWebMetric"),this.name=t,this._isWebMetric=na.includes(this.name)}report(t){if(Vi&&this._values.push({time:Date.now(),value:t}),mr||!this._isWebMetric)return;const n=this.findExceededThreshold(t);n&&yr&&yr(t,n)}collect(){const t=this._values;return this._values=[],t}findExceededThreshold(t){const n=Et[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 ia=(e,t)=>{Et={},mr=!1,e?.forEach(n=>{var r;n.metric in Et||(Et[n.metric]=[]),(r=Et[n.metric])==null||r.push(n)}),yr=t},It={},un=e=>{const t=new ra(e);return It[e]=t,t},zi=(e,t)=>{let n=It[e];return n||(n=un(e)),n.report(t)},sa=async e=>{const t=Object.values(It).map(n=>({name:n.name,values:n.collect()}));if(t.some(n=>n.values.length))try{await e(JSON.stringify(t))}catch(n){kn(`Error posting metrics: ${n}`)}},oa=({reportingIntervalSeconds:e,postMetrics:t})=>{e?setInterval(()=>{sa(t)},e*1e3):ea()},Gi=async(e,t)=>{const n=performance.now();try{await e()}finally{const r=performance.now()-n;let i=It[t];i||(i=un(t)),i.report(r/1e3)}},Hi=(e,t)=>{const n=performance.now();try{e()}finally{const r=performance.now()-n;let i=It[t];i||(i=un(t)),i.report(r/1e3)}},aa=30,Yi=()=>{be.setItem("sprig.disableReplayRecording","disabled")},$e=()=>!!be.getItem("sprig.disableReplayRecording"),la=["did not allow mutations","called in an invalid security context"],ua=e=>{if(!e)return!0;for(const t of la)if(e.toLowerCase().includes(t))return!1;return!0},ca=(e,t,{reportError:n=!0,extraInfo:r})=>{$e()||t instanceof Error&&(Yi(),ua(t?.message)&&(n&&window.UserLeap.reportError(e,t,r),ha()))},da=async(e,t,{reportError:n}={reportError:!0})=>{var r;let i;try{if(n&&(r=window.navigator.storage)!=null&&r.estimate){const{quota:s,usage:o}=await window.navigator.storage.estimate();i={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})}ca(e,t,{reportError:n,extraInfo:i})},pa=()=>{const e=be.getItem("sprig.sessionId");if(e)return L(`Found saved session id: ${e}`),be.removeItem("sprig.sessionId"),e;const t=De();return L(`Generating new uuid: ${t}`),t},X=pa();window.addEventListener("beforeunload",()=>{L(`Before page unload saving session id: ${X}`),be.setItem("sprig.sessionId",X)});const ha=async()=>{O.transaction("rw",O.events,O.chunkUploads,O.pendingCaptures,()=>{O.events.clear(),O.chunkUploads.clear(),O.pendingCaptures.clear()}).catch(()=>{})},gr=(e,t,n=()=>!0)=>O.table(t).where("timestamp").below(e).and(n).delete(),fa=async(e,t)=>{let n=[];return await Gi(async()=>{n=await O.events.where("[sessionId+timestamp]").between([X,e],[X,t??Date.now()]).toArray()},"sdk_replay_get_events_between_seconds"),n},ma=(e,t,n)=>{const r=new Date,i=r.setMinutes(r.getMinutes()+(n??aa));return O.events.where("[sessionId+timestamp]").between([X,e],[X,t]).modify({expiredAt:i})},ya=e=>O.chunkUploads.add({...e,sessionId:e.sessionId??X}),ga=(e,t)=>O.chunkUploads.update(e,{data:null,etag:t,status:"UploadComplete"}),wa=({status:e,uploadId:t})=>t?O.chunkUploads.where({uploadId:t,status:e}).toArray():O.chunkUploads.where({sessionId:X,status:e}).toArray(),va=e=>O.chunkUploads.where({uploadId:e,status:"UploadComplete"}).toArray(),ba=e=>O.chunkUploads.where({uploadId:e,status:"UploadComplete"}).delete(),_a=e=>O.pendingCaptures.add({...e,sessionId:e.sessionId??X,canUpload:!1}),Sa=()=>O.pendingCaptures.where("sessionId").equals(X).and(e=>e.targetTimestamp<Date.now()).toArray(),ka=()=>O.pendingCaptures.where("sessionId").equals(X).toArray(),Ea=e=>O.pendingCaptures.where("sessionId").equals(X).and(t=>t.captureParams.responseGroupId===e).modify({canUpload:!0}),Ia=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 La extends Ne{constructor(){super("replayStorage",{autoOpen:!1}),F(this,"events"),F(this,"chunkUploads"),F(this,"pendingCaptures")}}const O=new La;O.version(1).stores({events:"uuid, timestamp, [sessionId+timestamp]",chunkUploads:"uuid, timestamp, [sessionId+status], [uploadId+status], [sessionId+status+uploadId]",pendingCaptures:"uuid, timestamp, [sessionId+targetTimestamp]"}),O.open().catch(e=>{Xr(`Error opening replay storage: ${JSON.stringify(e)}`),Yi()});const Ua=async(e,t,n)=>new Promise((r,i)=>{const s=e.createElement("script");s.src=t,s.onload=r,s.onerror=i,n&&(s.nonce=n),e.head.appendChild(s)});let Ji=1,wr=5e3,cn=6e4;const xa=5,Qi=1e3,Xi=30,dn=Xi+xa,Aa="sprig.pendingCount";let vr,br,Zi,es=Date.now(),pn=!1,hn;const Da=async(e,t,n,r=2,i)=>{await et(async()=>{if($e()){L("Not initializing replay because recording is disabled");return}if(!t){L("Not initializing replay because config didn't specify maxReplayDurationSeconds");return}if(i!=null&&i.minAvailableGb&&(Ji=i.minAvailableGb),!await Ia(Ji)){kn("Minimum storage not available");return}L("Initializing replay"),i!=null&&i.minDuration&&(wr=i.minDuration),i!=null&&i.batchDuration&&(cn=i.batchDuration),oo(r),Ma(),Ra(t+dn,30*60,t+dn),Ta(),window.rrwebRecord||(L("Loading recording script"),await Ua(e,"https://cdn.sprig.com/dependencies/record-2.0.0-alpha.6.min.js",n),L("Recording script finished loading"));const s=window.rrwebRecord;if(!s){kn("Record script failed to set global function");return}let o=!0,l=0;hn=s({checkoutEveryNms:Xi*1e3,sampling:{input:"last",scroll:250,media:800},emit:(a,u)=>{if($e())return;if(es=Date.now(),u&&a.type===En.Meta)l=performance.now();else if(u&&l&&a.type===En.FullSnapshot){const c=performance.now()-l;zi("sdk_replay_snapshot_seconds",c/1e3)}const d=o||!!u;o=!1,Oa({uuid:De(),event:JSON.stringify(a),isValidStart:d,timestamp:Date.now()})},...i}),pn=!0,br||(br=window.setInterval(()=>{Date.now()-es>Qi&&ve("Sprig_Noop",{})},Qi)),D.on("survey.complete",a=>{Va({id:a,userAgent:window.navigator.userAgent})})},"Error initializing replay")};let _r=!1,Sr=[];const Oa=e=>{Sr.push(e),_r||Ca()},Pa=e=>{const t=e.map(n=>({...n,sessionId:n.sessionId??X}));if(t.length!==0)return O.transaction("rw",O.events,()=>{O.events.bulkAdd(t)}).catch(n=>{tt("Error storing replay events",n)})},Ca=()=>{_r=!0,setTimeout(async()=>{if($e())return;const e=Sr;Sr=[],_r=!1,Hi(async()=>{await Pa(e)},"sdk_replay_add_event_batch_seconds")},500)},Ra=(e=6*60,t=30*60,n=4*60)=>{vr=window.setInterval(()=>{const r=Date.now();$e()||(st(`Performing periodic replay data cleanup / Event Seconds ${e} / Chunk Seconds ${t} / Pending Capture Seconds ${n}`),Gi(()=>O.transaction("rw!",O.events,O.chunkUploads,O.pendingCaptures,()=>{gr(r-e*1e3,"events",i=>i.expiredAt===void 0||i.expiredAt<r-e*1e3),gr(r-t*1e3,"chunkUploads"),gr(r-n*1e3,"pendingCaptures",i=>i.canUpload===void 0||i.canUpload===!1)}).catch(i=>{clearInterval(vr),tt("Error deleting table rows",i)}),"sdk_replay_cleanup_seconds"),L("Cleanup complete"))},30*1e3)},Ta=(e=5)=>{Zi=window.setInterval(async()=>{et(async()=>{const t=parseInt(Be??"0");if(t===0)return;const n=await Sa();n!=null&&n.length&&(await Promise.all(n.map(async r=>(await O.pendingCaptures.delete(r.uuid),ss(r.captureParams,r.canUpload)))),Be=(t-n.length).toString(),be.setItem(Aa,Be))},"Error initiating pending captures")},e*1e3)},ja=async(e,t,n,r,i)=>{const s=Math.min(e+i,n),o=`from: ${new Date(e).toLocaleTimeString()} to ${new Date(s).toLocaleTimeString()}`;L(`Getting event batch ${o}`);const l=await fa(e,s);if(!(l!=null&&l.length))return L(`No events found ${o}`),{validStartFound:r,events:[]};if(!r){L(`Searching for valid start in ${l.length} events ${o}`);let a=-1;if(l?.forEach((d,c)=>{if(!d.isValidStart)return;const p=d.timestamp<=t;(a<0||p)&&(a=c)}),a<0)return L(`No valid start found in ${l.length} events ${o}`),{validStartFound:r,events:[]};const u=l[a].timestamp;return L(`Found valid start at: ${new Date(u).toLocaleTimeString()} in events ${o}`),{validStartFound:!0,events:l?.slice(a)}}return{validStartFound:r,events:l}},Ka=(e,t,n)=>{const r=e.length,i=t*1024*1024,s=Math.ceil(r/n),o=Math.max(i,s);L(`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},ts=e=>Promise.all(e.map(async t=>{const n=await ao(t);return await ga(t.uuid,n),t.uploadId})),ns=async e=>{L(`Marking upload complete if finished: ${e}`);const t=await va(e);if(!(t!=null&&t.length)){L(`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 ti({apiUrl:i.apiUrl,surveyId:i.surveyId,uploadId:e,responseGroupUuid:i.responseGroupId,etags:r,headers:i.completeUploadHeaders,replayDuration:i.replayDuration}),L(`Cleaning up chunks for ${e}`),await ba(e),L(`Done cleaning up chunks for ${e}`)},Ma=async()=>{et(async()=>{const e=await wa({status:"ReadyForUpload"});if(!(e!=null&&e.length))return;const t=await ts(e);L(`Finished uploading unfinished chunks for ${t}`),t!=null&&t.length&&await Promise.all(t.map(n=>{if(n)return ns(n)}))},"Error uploading unfinished chunks")},$a=async(e,t)=>{await ts(t),L(`Done uploading chunks for uploads: ${e.join(",")}`),await Promise.all(e.map(n=>ns(n)))},Ba=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},rs=async(e,t,n)=>{const r=new TextEncoder;let i=null,s=null,o=null,l=!1,a=!1,[u,d]=[0,0];const c=e-dn*1e3,p=[];let h=[];L(`Getting events between ${new Date(e).toLocaleTimeString()} and ${new Date(t).toLocaleTimeString()}`),L(`Using batch duration: ${cn}ms`);for(let m=c;m<t;m+=cn){if({validStartFound:a,events:h}=await ja(m,e,t,a,cn),!(h!=null&&h.length)){L("No events found");continue}u===0&&(u=h[0].timestamp),d=h[h.length-1].timestamp,L(`Last event time in batch: ${new Date(d).toLocaleTimeString()}`);const g=`${l?",":"["}${h.map(f=>f.event).join(",")}`,w=r.encode(g);n&&s===null&&(st("Attempting compression"),o=new window.CompressionStream("gzip"),s=o.writable.getWriter()),Hi(()=>{n&&s?s.write(w):p.push(w)},"sdk_replay_compression_seconds"),l=!0}if(d-u<wr)return L(`Replay duration is shorter than minimum of ${wr}ms / Start:${u} / End:${d}`),null;const y=r.encode("]");return st("Writing final close brace"),s&&o?(s.write(y),s.close(),i=new Uint8Array(await new Response(o.readable).arrayBuffer())):(p.push(y),i=Ba(p)),L("Finished generating file data"),i},Fa=async(e,t)=>{const n=window.CompressionStream!==void 0;let r=null;const i=t??Date.now(),s=i-e;try{r=await rs(s,i,n)}catch(o){o instanceof Error&&window.UserLeap.reportError("Error compressing replay",o),n&&et(async()=>{await rs(s,i,!1)},"fileData fallback failed")}return r},is=async e=>{const{surveyId:t,responseGroupId:n,visitorId:r,apiUrl:i,completeUploadHeaders:s,replayParams:o,triggerTimestamp:l}=e,a=await Fa(o.replayDurationSeconds*1e3,l);if(a!=null&&a.length)L(`Found file data for survey: ${t}`);else{L(`File data is empty for survey: ${t}`);return}const u=Ka(a,o.minimumChunkSizeMb,o.signedUrls.length);L(`Got ${u.length} chunks for survey: ${t}`);const d=await Promise.all(u.map(async(c,p)=>{const h=De(),y={apiUrl:i,chunkIndex:p+1,completeUploadHeaders:s,etag:null,responseGroupId:n,status:"ReadyForUpload",surveyId:t,timestamp:l,totalChunks:u.length,data:c,uploadId:o.uploadId,uploadUrl:o.signedUrls[p].url,uuid:h,visitorId:r};return L(`Recording chunk upload: ${JSON.stringify({index:y.chunkIndex,surveyId:y.surveyId,uploadId:y.uploadId,size:c.length,id:h},null,2)}`),await ya(y),L(`Done creating chunk upload: ${h}`),y}));L(`All chunk records created. Beginning upload for survey: ${t}`),await $a([o.uploadId],d)},ss=async(e,t)=>{if(L(`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)}`),$e()){L(`Replay recording is disabled: ${e.surveyId}`);return}L(`Replay recording enabled: ${e.surveyId}`);const{isStandalone:n,replayParams:r,triggerTimestamp:i,responseGroupId:s}=e,o=async()=>{setTimeout(()=>D.removeListener(A.QuestionAnswered,o),0),et(async()=>{r.replayDurationType==="before"?await is(e):await Ea(s)},"Error in schedule/capture callback")};et(async()=>{if(r.replayDurationType==="after"||r.replayDurationType==="beforeAndAfter"){n||(L("Attaching QuestionAnswered listener for non-standalone replay"),D.on(A.QuestionAnswered,o)),L(`Scheduling capture for replay of type: ${r.replayDurationType}`),await Na(e);return}if(n||t)L(`Proceeding to capture replay for survey: ${e.surveyId} / standalone? ${n} / canUpload? ${t}`),await is(e);else{const l=dn+r.replayDurationSeconds,a=i-l*1e3,u=i;L(`Setting expiry minutes to ${r.expirationTimeLimitMinutes} for events from ${new Date(a).toLocaleTimeString()} to ${new Date(u).toLocaleTimeString()}`),await ma(a,u,r.expirationTimeLimitMinutes),L("Attaching QuestionAnswered listener"),D.on(A.QuestionAnswered,o)}},"Error in scheduling/capturing replay")},os=()=>{if($e()){st("Not clearing user data, replay is disabled");return}return O.transaction("rw",O.events,O.pendingCaptures,()=>{O.events.where("sessionId").equals(X).delete(),O.pendingCaptures.where("sessionId").equals(X).delete()}).catch(e=>{tt("Error clearing session event data",e)})};let Be=be.getItem("sprig.pendingCount");const Na=async e=>{L(`Scheduling replay capture: ${JSON.stringify(e)}`);const{surveyId:t}=e,n=await ka(),r=n?.filter(o=>o.captureParams.surveyId===t);if(r!=null&&r.length){L(`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,Be=Be?(parseInt(Be)+1).toString():"1",be.setItem("sprig.pendingCount",Be),_a({uuid:De(),targetTimestamp:s,timestamp:Date.now(),captureParams:i})},ve=(e,t)=>{var n,r;if(pn)try{(r=(n=window.rrwebRecord)==null?void 0:n.addCustomEvent)==null||r.call(n,e,t)}catch(i){tt("Error recording custom event",i)}},et=async(e,t)=>{try{await e()}catch(n){tt(t,n)}},as=e=>{e.description&&(e.description=kr(e.description)),ve("Sprig_PageView",e)},qa=e=>{ve("Sprig_TrackEvent",e)},Wa=e=>{ve("Sprig_ShowSurvey",e)},Va=e=>{ve("Sprig_SubmitSurvey",e)},za=e=>{var t;(t=e?.elementAttributes)!=null&&t.text&&(e.elementAttributes.text=kr(e.elementAttributes.text)),ve("Sprig_Click",e)},Ga=e=>{ve("Sprig_Refresh",e)},Ha=e=>{e.currentPageTitle&&(e.currentPageTitle=kr(e.currentPageTitle)),ve("Sprig_BackForward",e)},Ya=e=>{ve("Sprig_Keystroke",e)},tt=(e,t,{reportError:n}={reportError:!0})=>(hn&&(hn(),hn=void 0),pn=!1,[vr,br,Zi].forEach(r=>{r&&clearInterval(r)}),Xr(`${e} - ${JSON.stringify(t)}`),da(e,t,{reportError:n})),ls=()=>pn,kr=e=>e&&e.trim().substring(0,500).replace(/\s\s+/g," ").replace(/\r?\n|\r/g," ").substring(0,250),us="ul-view-sdk-script",Ja=["ios","android"],Ue="visitors",xe="environments",cs=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 fn(e,t){const{matchType:n,pattern:r}=e,i=n?cs[n]:cs.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 ae(e,t){var n,r,i;const{shouldDropOnRateLimit:s,...o}=t;o.headers=Object.assign(Oe(window.UserLeap),o.headers);const l=await de(e,{...o,shouldDropOnRateLimit:s});if(l.ok){const a=(n=l.headers)==null?void 0:n.get("Authorization"),u=a?a.split(" "):void 0,d=u&&u.length===2?u[1]:void 0,c=(r=l.headers)==null?void 0:r.get("x-ul-visitor-id");d&&c&&(c!==window.UserLeap.visitorId||window.UserLeap.token!==d)&&(ne("token",d),ne("vid",c),D.emit(A.VisitorIDUpdated,{visitorId:c}),window.UserLeap.token=d,window.UserLeap.visitorId=c)}return(i=l.json)!=null&&i.logMessage&&console.warn(`[Sprig] ${l.json.logMessage}`),l}function ne(e,t){const n=Z.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{Z.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 Er(){return window.previewMode?"0":window.UserLeap.visitorId??""}function ie(e,t,n){const r=[window.UserLeap._API_URL,"sdk",e];return t&&t.forEach(i=>{r.push(i),i===xe?r.push(window.UserLeap.envId):i===Ue&&r.push(Er())}),n&&r.push(n),r.join("/")}const Lt=async e=>{var t,n;const{context:r,forceBrandedLogo:i,endCard:s,isFeedback:o=!1,locale:l,productConfig:a,questions:u,responseGroupUid:d,surveyId:c,uuid:p,vid:h,sessionReplay:y,studyType:m}=e,g=Oe(window.UserLeap),w=Lr(g),f=Ir(g);if(L(`Attempting to display survey: ${c}`),y&&(L("Survey has replay attached"),w?D.emit(A.ReplayCapture,{responseGroupUid:d,hasQuestions:!!(u!=null&&u.length),surveyId:c,uploadId:y.uploadId,replayType:y.replayDurationType??"before",seconds:y.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:De(),mediaType:"screen",questionId:1,responseGroupUid:d,surveyId:c,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}}):ss({responseGroupId:d,surveyId:c,visitorId:h,replayParams:y,completeUploadHeaders:g,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:u.length===0})),h==null||!(u!=null&&u.length))return L(`Not displaying survey: vid: ${h} / questions: ${u}`),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(window.UserLeap.container){L("Already displaying a survey");const K="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(K),{success:!1,message:K,surveyState:"no survey"}}if(h!==window.UserLeap.visitorId&&p!==window.UserLeap.visitorId&&!window.previewMode){const K="Attempted to display survey to a different visitor";return L(K),window.UserLeap.reportError("DisplaySurvey",new Error(K)),{success:!1,message:K,surveyState:"no survey"}}L(`Showing survey: ${c}`),Wa({id:c,userAgent:window.navigator.userAgent}),qr.disable(),D.emit(A.SurveyWillPresent,{name:A.SurveyWillPresent,"survey.id":c});let S,_=document.createElement("div"),I,v,b;const P=K=>{const{"view.version":G}=K;G!==g["x-ul-sdk-version"]&&hs(),D.removeListener("verify.view.version",P)};D.on("verify.view.version",P),window.UserLeap.useMobileStyling=f,zr(g)?(S="ul-direct-embeded-frame",I=document.head,v=window,b=!1,w&&(ps(),_.id=S,window.UserLeap.container.appendChild(_),fs(),D.emit(A.SurveyLifeCycle,{state:"presented"}),D.emit(A.SurveyPresented,{name:A.SurveyPresented,"survey.id":c}))):{frameId:S,contentWinDocHead:I,contentWindow:v,hasOverlay:b,iframe:_}=tl({productConfig:a,useMobileStyling:f,surveyId:c,isFeedback:o}),window.UserLeap.frameId=S;const k=K=>{D.once(A.CloseSurveyOnOverlayClick,K)},R={apiURL:window.UserLeap._API_URL,cards:u,configureExitOnOverlayClick:k,context:r,endCard:s,envId:window.UserLeap.envId,eventEmitFn:D.emit.bind(D),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:i,frame:_,headers:g,locale:l,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:Z.getItem("sprig.previewKey"),productConfig:{framePosition:a?.framePosition,desktopDisplay:a?.desktopDisplay,placement:a?.placement},responseGroupUid:d,startingQuestionIdx:(t=window.UserLeap.config)==null?void 0:t.startingQuestionIdx,studyType:m,styleNonce:window.UserLeap.styleNonce,surveyId:c,tabTitle:document.title,ulEvents:it,useMobileStyling:f,userId:p,viewDocument:v?.document,viewWindow:v,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},...window.UserLeap._config};(n=window.UserLeap._config)!=null&&n.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null}),window.UserLeap.customStyles&&(R.customStyles=window.UserLeap.customStyles),v&&(v.__cfg=R);function C(){const K=document.createElement("script");return window.UserLeap.nonce&&K.setAttribute("nonce",window.UserLeap.nonce),K.id=us,K}const q=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:R.path,W=document.getElementById(us);W&&W.remove();const j=C(),ue=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(R.installationMethod==="web-npm"||R.installationMethod==="web-npm-bundled"){const{default:K}=await import("./view-z8d1iIP5.js");K.configure(R),b&&window.UserLeap.container&&ue()}else q&&(j.src=q,b&&j.addEventListener("load",()=>{window.UserLeap.container&&ue()}),v?.addEventListener("error",K=>{K.target instanceof HTMLScriptElement&&K.target.src===q&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));return I?.appendChild(j),{success:!0,surveyState:"ready",surveyId:c,responseGroupUid:d}};function Ir(e){var t;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const n=((t=window.UserLeap.windowDimensions)==null?void 0:t.width)??document.body.clientWidth;return Lr(e)||n>10&&n<Ns}function Lr(e){return Ja.includes(e["userleap-platform"])}const ds="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 Qa="rgba(255,255,255, 0.95)",Xa="rgba(0,0,0,0.9)",Ur="0px",ps=e=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className="ul-container";const t=ys();e&&t&&!window.UserLeap.useMobileStyling?t.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},hs=(e,t)=>{var n;rl();const r=window.UserLeap.container;if(r)try{(n=r.parentNode)==null||n.removeChild(r),window.UserLeap.container=null,ne("trackStartUrl",null),D.emit(A.SurveyLifeCycle,{state:"dismissed"}),D.emit(A.SurveyClosed,{name:A.SurveyClosed,initiator:e,studyType:t})}catch(i){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${e} `+r),i instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",i)}},fs=()=>{D.once(A.SurveyWillClose,({initiator:e,studyType:t})=>{D.removeAllListeners(A.CloseSurveyOnOverlayClick),hs(e,t)})},Za=(e,t)=>{const n={position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646},r=t?e.overlayStyleMobile:e.overlayStyle;n["background-color"]=r==="light"?Qa:Xa,t||(n.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,n)},el=(e,t,n,r)=>{var i,s;const o={position:"fixed",bottom:"0px",right:Ur,border:0,backgroundColor:"rgba(0,0,0,0)",zIndex:2147483646,transition:"width 0.2s ease-in-out, height 0.2s ease-in-out",maxWidth:"100%"},l=Object.assign({},t,window.UserLeap),{desktopDisplay:a}=t||{},u=a==="center-modal";u&&(l.framePosition="center");let d,c=!1;if(n)(i=window.UserLeap.windowDimensions)!=null&&i.width?o.width=`${window.UserLeap.windowDimensions.width}px`:o.width="100%",(s=window.UserLeap.windowDimensions)!=null&&s.height?o.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`:window.UserLeap.maxHeight?o.maxHeight=window.UserLeap.maxHeight:o.maxHeight=`${document.body.clientHeight-20}px`,["light","dark"].includes(l.overlayStyleMobile)&&(c=!0);else{o.width=Br,o.maxHeight=window.UserLeap.maxHeight||"66vh";const p=()=>{c=!0,d={margin:"auto",position:"static"}};if(r)u?p():d={position:"relative",height:"300px"};else switch(l.framePosition){case"bottomLeft":d={left:Ur};break;case"topLeft":d={left:Ur,top:0};break;case"topRight":d={top:0};break;case"center":p();break}}return c&&Za(l,n),Object.assign(e.style,o,d),c},tl=({productConfig:e,useMobileStyling:t,surveyId:n,isFeedback:r})=>{var i,s;const o=ds,l=r&&e.desktopDisplay==="slider";ps(l),nl();const a=document.createElement("iframe");a.id=o,a.setAttribute("title","Sprig User Feedback Dialog");const u=el(a,e,t,r);fs(),a.setHeight=h=>{parseInt(a.style.height)!=h&&(a.style.height=`${h}px`,D.emit(A.SurveyHeight,{name:A.SurveyHeight,contentFrameHeight:h}))};let d=!1;a.setWidth=h=>{(parseInt(a.style.width)!=h||!d)&&(d=!0,a.style.width=`${h}px`,D.emit(A.SurveyWidth,{name:A.SurveyWidth,contentFrameWidth:h}))},(i=window.UserLeap.container)==null||i.appendChild(a),e&&(t?e.exitOnOverlayClickMobile:e.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{D.emit(A.CloseSurveyOnOverlayClick)}),D.emit(A.SurveyLifeCycle,{state:"presented"}),D.emit(A.SurveyPresented,{name:A.SurveyPresented,"survey.id":n});const c=(s=a.contentWindow)==null?void 0:s.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 p=c?.head;return{frameId:o,contentWinDocHead:p,contentWindow:a.contentWindow,hasOverlay:u,iframe:a}},ms={[A.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},nl=()=>{Object.entries(ms).forEach(([e,t])=>{D.on(e,t)})},rl=()=>{Object.entries(ms).forEach(([e,t])=>{D.off(e,t)})},ys=()=>M,nt=()=>document.getElementById("sprig-feedback-container"),xr=()=>document.getElementById("sprig-feedback-loading-animation"),il=()=>{if(xr())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=`
9
+ <div class="ul-loading-spinner">
10
+ <div class="first"></div>
11
+ <div class="second"></div>
12
+ <div class="third"></div>
13
+ <div class="fourth"></div>
14
+ </div>
15
+ `,e},gs=()=>!!document.getElementById(ds);let Ar=!1,M=null,le=null,Dr=!1,Ut=null,xt=null;const sl=["bottom-left","bottom-right","center-left","center-right"],ol=e=>{if(nt()||!sl.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)},mn=()=>{var e;const t=window.UserLeap.container;return((e=t?.parentElement)==null?void 0:e.id)==="sprig-feedback-loading-container"},ws=()=>document.getElementById("sprig-feedback-error-container"),vs=()=>{if(!M)return 0;const e=M?.clientWidth,t=window.getComputedStyle(M),n=parseInt(t.borderRightWidth||"0"),r=parseInt(t.borderLeftWidth||"0");return e+n+r},yn=e=>{const t=nt();t&&(xt!=null&&xt.endsWith("right")?t.style.right=`${e}px`:xt!=null&&xt.endsWith("left")&&(t.style.left=`${e}px`))},Or=()=>{if(M&&(mn()||ws())){D.off(A.SurveyAppeared,At),Pr();const e=vs();return yn(-e),!0}return!1},At=()=>{if(!M||!le)return;const e=xr();e&&e.remove(),M.style.height="auto",M.style.width="auto",le.disabled=!1,Dr=!1},Pr=()=>{if(M&&!xr()){const e=il();e&&(M.style.height="300px",M.style.width="360px",M.appendChild(e))}},bs=()=>{!M||!le||(yn(0),le.disabled=!0,Dr=!0)},al=async e=>{const t=await ae(ie("1",[Ue],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:e}),method:"POST"});return t.ok?t.json:null},_s=async(e,t)=>{const{buttonTheme:n,eventId:r,placement:i,desktopDisplay:s,feedbackLabel:o,surveyUuid:l,surveyId:a}=e;let u=nt();if(u){if(!t&&r===Ut)return;u.remove(),D.off(it.SURVEY_FADING_OUT,Or)}if(Ut=r,!document.getElementById("sprig-feedback-style")){const{head:m}=document,g=document.createElement("style");g.id="sprig-feedback-style",g.textContent=Ms,g.nonce=window.UserLeap.styleNonce,m.appendChild(g)}Ar=s==="center-modal",xt=i;const[d,c]=i.split("-");ol(i),u=nt(),le=document.createElement("button");const p=document.createElement("div");p.className="sprig-feedback-button-label",p.innerText=o,le.appendChild(p),le.id="sprig-feedback-button",le.classList.add(`sprig-feedback-button-${c}`,`sprig-feedback-button-${d}`,`sprig-feedback-button-${n}`,"fade-in-transition"),D.on(it.SURVEY_FADING_OUT,Or),le.addEventListener("click",async()=>{const m=document.getElementById("sprig-feedback-error-container");if(gs()||ws()){if(Or()){D.emit(A.SurveyWillClose,{name:A.SurveyWillClose,initiator:ce.FeedbackClosed,studyType:"feedbackButton"});const f=nt();m&&f&&(f.remove(),Ut=null,M=null)}return}const g=Oe(window.UserLeap);if(!Ir(g)&&!Dr&&bs(),t){M&&M.classList.add("sprig-feedback-loading-container-previews"),await Lt(t),At();return}const w=await al(l);if(w)D.once(A.SurveyAppeared,At),Lt({...w,studyType:"feedbackButton"});else if(M){const f=ul();M.appendChild(f),At(),M.style.height="300px",M.style.width="360px"}}),u?.appendChild(le),D.emit(A.FeedbackButtonLoaded,{name:A.FeedbackButtonLoaded,"survey.id":a});const{useMobileStyling:h,_config:{border:y}}=window.UserLeap;if(!Ar&&!h){const m=document.createElement("div");m.id="sprig-feedback-loading-container",m.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${c}`,m.style.setProperty("--feedback-border",y),M=m,Pr(),u?.appendChild(m);const g=vs();yn(-g)}else Ar&&yn(0);window.UserLeap._config.isOnQuestionsTab&&t&&!mn()&&M&&(bs(),Pr(),M&&M.classList.add("sprig-feedback-loading-container-previews"),Lt(t),At())},ll=e=>{if(mn())return;const t=nt();if(!t)return;const{pageUrlEvents:n}=window.UserLeap._config,r=n?.find(i=>i.id===Ut);r&&(fn(r,e)||(t.remove(),Ut=null,M=null))},ul=()=>{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">
16
+ <circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
17
+ <path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
18
+ <circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
19
+ </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},cl="!launch_darkly_";class dl{constructor(){F(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[`${cl}${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 Cr=new dl;Object.freeze(Cr);const pl="!optimizely_experiments_";class hl{constructor(){F(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 pl+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 gn=new hl;Object.freeze(gn);class fl{constructor(t,n){F(this,"paused"),F(this,"queue"),F(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 ml=1,Ss=e=>e instanceof HTMLElement||e instanceof SVGElement,ks=(e,t,n)=>{const r=e.createElement("style");n&&(r.nonce=n),r.textContent=t,r.id="ul-custom-style",e.head.appendChild(r)},Es=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),u=parseFloat(i.marginLeft)+parseFloat(i.marginRight),d=parseFloat(i.borderLeftWidth)+parseFloat(i.borderRightWidth);r+=u+d+a}return[n+ml,r]},yl=e=>{const t=e.querySelector(".ul-card__container");t&&(t.scrollTop=0)},Rr=(e,t)=>{const n=performance.now();document.hidden?setTimeout(()=>Rr(e,t),e):setTimeout(()=>{const r=performance.now()-n;t.report(r/1e3),setTimeout(()=>Rr(e,t),e)},0)},gl=(e=1e3)=>{const t=un("sdk_event_queue_latency_seconds");Rr(e,t)},wl=({webMetricsEnabled:e,reportingIntervalSeconds:t,thresholds:n,postMetrics:r})=>{ia(n,(i,s)=>{if(ls()){const o=`Value: ${i} on ${s.metric} violated threshold of ${s.type} ${s.value}`;tt("Threshold violated",new Error(o),{reportError:!1}),ta()}}),oa({reportingIntervalSeconds:t,postMetrics:r}),e&&gl()},Tr={capture:!0},vl=["a","button","input","option","li","link"],bl=["Escape","Enter","Backspace","F5","Tab"],_l=["label","type","role","title","placeholder","errormessage","valuetext","href"],Is="aria-",Sl=e=>{if(!e.tagName)return"No tagName";const t=e.getAttribute("type");return t?`${t} ${e.tagName.toLowerCase()}`:e.tagName.toLowerCase()},Ls=e=>{var t;if(((t=e.tagName)==null?void 0:t.toLowerCase())==="html")return{element:"html"};const n=e.textContent,r=n?{text:n}:{};r.element=Sl(e);for(const i of e.attributes){let s=i.name;const o=i.value;s.startsWith(Is)&&(s=s.substring(Is.length)),_l.includes(s)&&(r[s]=o)}return r},kl=e=>{var t;if(!e)return{};const n={...Ls(e)},r=e.parentElement;if(r&&vl.includes((t=r.tagName)==null?void 0:t.toLowerCase())){const i=Ls(r);Object.assign(n,i)}return n},Us=(e,t)=>{za({x:t.x,y:t.y,type:e,elementAttributes:kl(t.target)})},El=e=>t=>Us(e,t),Il=e=>{bl.includes(e.key)&&Ya({key:e.key})},Ll=()=>{window.performance.getEntriesByType("navigation").map(e=>e.type).includes("reload")&&Ga({url:window.location.href,currentPageTitle:document.title})},Ul=()=>{window.performance.getEntriesByType("navigation").map(e=>e.type).includes("back_forward")&&Ha({curUrl:window.location.href,fromUrl:document.referrer,currentPageTitle:document.title})},xl=()=>{window.addEventListener("click",El("left_click"),Tr),window.addEventListener("mousedown",e=>{e.button===2&&Us("right_click",e)},Tr),window.addEventListener("keydown",Il,Tr),Ll(),Ul()},Al={test:"test"},Dl=["popState","pushState","replaceState"],Dt="!email",jr="pageUrl";function Ol(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?fn(o,window.location.href):t===window.location.href}function Ot(e){const{pageUrlEvents:t,interactiveEvents:n,dismissOnPageChange:r,platform:i}=window.UserLeap._config;if(i&&i!=="web")return;const s=Fe("trackStartUrl"),o=s?String(s):null;t&&Os(window.location.href),n&&(As(),Pl()),ys()&&ll(window.location.href),!mn()&&r&&o&&o!==window.location.href&&e&&Dl.includes(e.type)&&window.UserLeap("dismissActiveSurvey",ce.PageChange)}const xs={capture:!0},Pl=()=>{const e=window.UserLeap._config.interactiveEvents.filter(n=>fn(n,window.location.href)).map(n=>{const{name:r,properties:i}=n,{selector:s,innerText:o}=i;return s?l=>{if(Ss(l.target))try{l.target.closest(s)&&window.UserLeap("track",r)}catch{}return!1}:l=>(Ss(l.target)&&l.target.innerText===o&&window.UserLeap("track",r),!1)}),t=n=>e.forEach(r=>r(n));window.UserLeap._config.interactiveEventsHandler=t,window.addEventListener("click",t,xs)},As=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,xs),delete window.UserLeap._config.interactiveEventsHandler};function Cl(){["hashchange","popstate"].forEach(e=>window.addEventListener(e,Ot,!0))}function Rl(){["hashchange","popstate"].forEach(e=>window.removeEventListener(e,Ot,!0)),window.UserLeap._config.interactiveEvents&&As()}function Tl(e,t){let n=ie("1",[xe],"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 Fe(e){const t=Z.getItem("userleap.ids");if(t)try{const n=JSON.parse(t)[window.UserLeap.envId];return n&&n[e]||null}catch(n){n instanceof Error&&(n.stack=t,window.UserLeap.reportError("Failed to parse local storage credentials",n)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",n)}return null}function Ds(){window.previewMode||(window.UserLeap.visitorId=De(),L(`Generating new vid: ${window.UserLeap.visitorId}`),ne("vid",window.UserLeap.visitorId),D.emit(A.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}))}function Os(e,t,n){var r;if(e.endsWith("mock_snippet.html"))return;L(`Tracking page view: ${e}`);const i=window.UserLeap._config.pageUrlEvents;let s=!1;if(i&&i.length)for(let c=0;c<i.length&&(s=fn(i[c],e),!s);c++);if(!s)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",e);const o=10,l=1;let a=[];const u={viewedAt:Date.now(),location:e},d=Z.getItem("userleap.pageviews");try{if(a=d?JSON.parse(d):[],Array.isArray(a)||(a=[]),a.length>0){const c=a[a.length-1],p=(Date.now()-c.viewedAt)/1e3;if(c.location!=e&&p>l){const h=(r=document?.querySelector('meta[name="description"]'))==null?void 0:r.getAttribute("content");as({...h&&{description:h},url:e,referrer:document.referrer,pageTitle:document.title})}(c.location!=e&&p>l||p>o)&&(window.UserLeap._queue.push(["track",jr,t,{url:e},n]),a.push(u))}else window.UserLeap._queue.push(["track",jr,t,{url:e},n]),a.push(u),as({url:e});a.length>5&&a.splice(0,a.length-5),Z.setItem("userleap.pageviews",JSON.stringify(a))}catch(c){c instanceof Error&&window.UserLeap.reportError("trackPageView",c,{pageViewsStorage:d}),console.warn("[Sprig] (ERR-425) Failed to update page views in local storage")}}function jl(){const e="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in e&&(e.pushState=(t=>function(...n){const r=t.apply(this,n),i=new Event("pushState");return window.dispatchEvent(i),Ot(i),r})(e.pushState)),"replaceState"in e&&(e.replaceState=(t=>function(...n){const r=t.apply(this,n),i=new Event("replaceState");return window.dispatchEvent(i),Ot(i),r})(e.replaceState)),Cl()}async function Kr(e,t){const n=Er();e&&!t&&(window.UserLeap._config.mode=Al.test);const r=Oe(window.UserLeap),i=Ir(r),s=await ae(Tl(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 Ct(s.json.delay),s.json.isFeedback){const{feedbackLabel:o,productConfig:l,surveyUuid:a}=s.json,{buttonTheme:u,placement:d,desktopDisplay:c}=l,p={buttonTheme:u,desktopDisplay:c,eventId:0,feedbackLabel:o,placement:d,surveyUuid:a,surveyId:e?.surveyId};_s(p,s.json)}else return Lt(s.json)}function Kl(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 Ml(e){if(!e)return;window.UserLeap._config=e,e.mute&&window.UserLeap._queue.pause();const{interactiveEvents:t,pageUrlEvents:n,dismissOnPageChange:r}=e;t&&Kl(t),(t||n||r)&&(jl(),Ot())}async function $l(e,t){var n,r;let i=!0;return t&&(n=e?.json)!=null&&n.surveyId&&(window.UserLeap.delayingSurvey=!0,i=await t(e.json.surveyId),window.UserLeap.delayingSurvey=!1,!i)?!1:((r=e?.json)!=null&&r.delay&&(window.UserLeap.delayingSurvey=!0,await Ct(e.json.delay),window.UserLeap.delayingSurvey=!1),i)}const Bl=function(e){if(!window.UserLeap)return;const t=async(r={})=>{var i,s,o,l;const{userId:a,anonymousId:u,metadata:d={},properties:c,showSurveyCallback:p}=r;let{eventName:h}=r;if(window.UserLeap.debugMode&&h!==jr&&console.info("[DEBUG] Sprig track",r),e.mode==="test")return;const y=Z.getItem("sprig.previewKey")??void 0;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!a){const f="[Sprig] - Skipping tracking without userId";return console.warn(f),{success:!1,message:f,surveyState:"no survey"}}if(!h||h.trim().length===0){h=h?String(h):"";const f="[Sprig] - Invalid event name "+h;return console.warn(f),{success:!1,message:f,surveyState:"no survey"}}const m=window.location.href;if(d.url||(d.url=m),ne("trackStartUrl",m),(s=(i=window.UserLeap)==null?void 0:i._config)!=null&&s.optimizelyEnabled){const f=Oe(window.UserLeap);Lr(f)||gn.getAndSetWebOptimizelyExperiments(),d.optimizelyExperiments=Object.assign({},gn.getAllOptimizelyExperiments())}(l=(o=window.UserLeap)==null?void 0:o._config)!=null&&l.launchDarklyEnabled&&(d.launchDarklyFlags=Cr.getAllLaunchDarklyVariations()),a&&(window.UserLeap.userId=a),u&&(window.UserLeap.partnerAnonymousId=u),c&&(d.eventProperties=c),qa({name:h,url:d.url}),L(`Tracking event: ${h}`);const g=window.UserLeap.delayingSurvey||gs()?await ae(ie("1",[Ue],"events/batch"),{body:JSON.stringify({events:[{event:h,metadata:d}],previewKey:y}),method:"POST",shouldDropOnRateLimit:!0}):await ae(ie("1",[Ue],"events"),{body:JSON.stringify({event:h,metadata:d,previewKey:y}),method:"POST",shouldDropOnRateLimit:!0});if(!g.ok){const f="[Sprig] (ERR-421) Failed to track event";return g.reportError&&(console.warn(f,g.error),g.error&&window.UserLeap.reportError("track",g.error)),{success:!1,message:f,error:g.error,surveyState:"no survey"}}a&&ne("uid",a),u&&ne("aid",u);const w=g.json;return w.invalidPreviewKey&&Z.removeItem("sprig.previewKey"),w!=null&&w.feedbackButton&&_s(w.feedbackButton),await $l(g,p)?Ol(w.eventId,m)?Lt(w):{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",ce.Override),Kr({surveyId:r},!0)},_previewSurvey(r){window.UserLeap("dismissActiveSurvey",ce.Override),Kr({surveyTemplateId:r},!1)},_reviewSurvey(r){window.UserLeap("dismissActiveSurvey",ce.Override),Kr({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=ce.API){D.emit(A.SurveyWillClose,{name:A.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 u="[Sprig] - Disregarding empty payload provided";return console.warn(u),{success:!1,message:u}}const{userId:i,anonymousId:s,attributes:o}=r;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!i){const u="[Sprig] - Skipping tracking without userId";return console.warn(u),{success:!1,message:u}}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,Dt)&&(o[Dt]=o.email,delete o.email),L(`Setting attributes: ${JSON.stringify(o)}`),a=await ae(ie("1",[xe,Ue],"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 ae(ie("1",[xe,Ue]),{body:JSON.stringify(l),method:"PUT"}),o&&o[Dt]&&(window.UserLeap.email=o[Dt]),a.ok&&(i&&ne("uid",i),s&&ne("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 ae(ie("1",[xe,Ue],"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){D.on(A.SurveyLifeCycle,r)},async removeSurveyListener(r){D.removeListener(A.SurveyLifeCycle,r)},async addListener(r,i){D.on(r,i)},async removeListener(r,i){D.removeListener(r,i)},async removeAllListeners(){D.removeAllListeners()},setPreviewKey(r){!r||typeof r!="string"||Z.isStorageAvailable&&r&&Z.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 ae(ie("1",[xe,Ue]),{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&&os(),ne("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,ne("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){Os(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:ks(i,r,window.UserLeap.styleNonce)}}},setWindowDimensions(r,i){var s,o;const l=typeof r=="string"?parseInt(r,10):r,a=typeof i=="string"?parseInt(i,10):i;if(!isNaN(l)&&!isNaN(a)&&(window.UserLeap.windowDimensions={width:l,height:a}),!window.UserLeap.frameId)return;const u=document.getElementById(window.UserLeap.frameId);u&&(window.UserLeap.useMobileStyling&&((s=window.UserLeap.windowDimensions)!=null&&s.width&&(u.style.width=`${window.UserLeap.windowDimensions.width}px`),(o=window.UserLeap.windowDimensions)!=null&&o.height&&(u.style.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`),u.contentDocument&&(u.style.height=String(Es(u.contentDocument)[0])+"px")),D.emit(A.SurveyDimensions,{name:A.SurveyDimensions,contentFrameWidth:u.clientWidth,contentFrameHeight:u.clientHeight}))},logoutUser(){window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),L(`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,Z.removeItem("userleap.ids"),Z.removeItem("userleap.pageviews"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),Ds(),os(),window.UserLeap._queue.unpause()},teardown(){Rl(),window.UserLeap("dismissActiveSurvey",ce.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;gn.setOptimizelyExperiment(l,i)}catch(l){console.warn("[Sprig] Error with integrating Optimizely data"),l instanceof Error&&window.UserLeap.reportError("integrateOptimizely",l)}},integrateOptimizelyClient(r){var i,s;if(!((s=(i=window.UserLeap)==null?void 0:i._config)!=null&&s.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}const o=({experiment:l,variation:a})=>{const u={experiments:[{id:l.id,variation:a.key}]};window.UserLeap("integrateOptimizely",u,!1)};r.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",o)},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}Cr.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(Dt,r)},async setVisitorEmail(r){return console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),n.setEmail(r)},async _generateVideoUploadUrl(r){return Wl(r)},_reportMetric(r,i){zi(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 ti({surveyId:r,responseGroupUuid:i,eventDigest:s,apiUrl:o,headers:Oe(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 Fl(e){const t=Oe(window.UserLeap);document.addEventListener("securitypolicyviolation",bn);const n=await de(ie("1",[xe],"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",bn),!n.ok)return n.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",n.error),n.error&&window.UserLeap.reportError("applyRemoteConfig",n.error)),_n("Disabled: failed to fetch configuration"),e;const i=n.json;return i!=null&&i.disabled?(_n(`Disabled: ${i.disabled}`),{disabled:i.disabled}):Object.assign({},i,e)}const Nl=e=>typeof e=="object"&&e&&"inner"in e&&!!e.inner&&typeof e.inner=="object";async function ql(e,t,n={}){var r,i;const s=window.__cfg&&window.__cfg.mode,o=Er(),l=window.UserLeap.envId,a=window.document.documentElement,u=Nl(t)?{inner:{message:(r=t.inner)==null?void 0:r.message,stack:(i=t.inner)==null?void 0:i.stack}}:{},d={mode:s,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:a.clientWidth,clientHeight:a.clientHeight,location:window.location.href,language:window.navigator.language,...n,...u},c={action:e,err:{message:t.message,stack:t.stack},meta:d,vid:o,envId:l},p=await ae(ie("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(c),shouldDropOnRateLimit:!0});if(!p.ok)console.warn("[Sprig] (ERR-444) Failed to report error to API",t);else{const{presignedUrl:h}=p.json;Zr(h)}}async function Wl(e){var t;if(!e)return;const n=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const r=await fetch(n,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.ok){const i=await r.json();return(t=i?.upload)==null?void 0:t.url}else return null}catch(r){console.warn("[Sprig] Error with generating video upload url"),r instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",r)}}function Vl(e={}){const t=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";window.UserLeap.UPDATES=it,window.UserLeap("setPreviewKey",t);async function n(){if(window.UserLeap.loaded)return;if(L("Loading sprig on page load"),window.UserLeap.reportError=ql,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=Fe("sampled");if(l===null&&(l=Math.random()<r,ne("sampled",l)),!l)return}else Fe("sampled")!==null&&ne("sampled",null);window.UserLeap._API_URL||(window.UserLeap._API_URL="https://api.sprig.com");const i=[...window.UserLeap._queue];window.UserLeap._queue=new fl(window.UserLeap,[]),window.UserLeap._queue.pause();for(let l=0;l<i.length;l++)window.UserLeap._queue.push(i[l]);const s=Fe("token");s?(window.UserLeap.token=s,window.UserLeap.visitorId=Fe("vid"),window.UserLeap.userId=Fe("uid"),window.UserLeap.partnerAnonymousId=Fe("aid")):(Z.removeItem("userleap.ids"),Ds());const o=await Fl(e);wl({webMetricsEnabled:o.metricsReportingEnabled,reportingIntervalSeconds:o.metricsReportingEnabled||o.mobileMetricsReportingEnabled?o.metricsReportingIntervalSeconds:0,thresholds:o.metricThresholds,postMetrics:async l=>{await ae(ie("1",[xe],"metrics"),{body:l,method:"POST",headers:{"x-ul-replay-enabled":`${ls()}`},shouldDropOnRateLimit:!0})}}),Da(window.document,o.maxReplayDurationSeconds,window.UserLeap.replayNonce,window.UserLeap.maxInflightReplayRequests,o.replaySettings).then(()=>{xl()}),io(o.logBufferLimit,o.logLevel),Bl(o),await Ml(o),window.UserLeap._queue.unpause(),D.emit(A.SDKReady,{mobileMetricsReportingEnabled:!!o.mobileMetricsReportingEnabled,metricsReportingInterval:o.metricsReportingIntervalSeconds||0,metricsThresholds:o.metricThresholds||[],maxMobileReplayDurationSeconds:o.maxMobileReplayDurationSeconds,mobileReplaySettings:o.mobileReplaySettings}),D.emit(A.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}document.readyState==="complete"?n():window.attachEvent?window.attachEvent("onload",n):window.addEventListener("load",()=>{n()},!1)}class wn{constructor(){F(this,"UPDATES",it)}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 Mr={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",window.Sprig)return window.Sprig;window.Sprig=function(){window.Sprig._queue.push(arguments)},Object.getOwnPropertyNames(wn.prototype).map(n=>{n!=="constructor"&&(window.Sprig[n]=wn.prototype[n])});const t=window.Sprig;return t.appId=e.envId,t._queue=[],window.UserLeap=t,Vl(e),window.Sprig}},zl={sprig:Mr,SprigAPI:wn,configure:Mr.configure};export{$s as A,qr as C,ce as D,qs as E,A as S,de as a,Br as b,Es as c,Fs as d,D as e,Bs as f,wn as g,Mr as h,L as i,zl as j,ks as o,yl as r,zr as s,Zr as u,De as v};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-CqSba42x.cjs");exports.DismissReason=e.DismissReason;exports.SprigAPI=e.SprigAPI;exports.SprigEvent=e.SprigEvent;exports.default=e.index;exports.sprig=e.sprig;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-2qdxS4eg.cjs");exports.DismissReason=e.DismissReason;exports.SprigAPI=e.SprigAPI;exports.SprigEvent=e.SprigEvent;exports.default=e.index;exports.sprig=e.sprig;