@sprig-technologies/sprig-browser 2.26.6 → 2.27.0

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