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