@amplitude/plugin-session-replay-browser 1.19.2 → 1.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/scripts/index-min.js +1 -1
- package/lib/scripts/index-min.js.gz +0 -0
- package/lib/scripts/index-min.js.map +1 -1
- package/lib/scripts/plugin-session-replay-browser-min.js +1 -1
- package/lib/scripts/plugin-session-replay-browser-min.js.gz +0 -0
- package/lib/scripts/plugin-session-replay-browser-min.js.map +1 -1
- package/package.json +5 -5
package/lib/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.19.
|
|
1
|
+
export declare const VERSION = "1.19.3";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/cjs/version.js
CHANGED
package/lib/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AACvC,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.19.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AACvC,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.19.3';\n"]}
|
package/lib/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.19.
|
|
1
|
+
export declare const VERSION = "1.19.3";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/esm/version.js
CHANGED
package/lib/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.19.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.19.3';\n"]}
|
package/lib/scripts/index-min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function i(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function a(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var u,c="".concat("AMP","_unsent"),l="https://api2.amplitude.com/2/httpapi";!function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(u||(u={}));var d,f=function(){var e="ampIntegrationContext";return"undefined"!=typeof globalThis&&void 0!==globalThis[e]?globalThis[e]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},v=function(e){return{promise:e||Promise.resolve()}};!function(e){e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warn=2]="Warn",e[e.Verbose=3]="Verbose",e[e.Debug=4]="Debug"}(d||(d={}));var h="Amplitude Logger ",p=function(){function e(){this.logLevel=d.None}return e.prototype.disable=function(){this.logLevel=d.None},e.prototype.enable=function(e){void 0===e&&(e=d.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<d.Verbose||console.log("".concat(h,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<d.Warn||console.warn("".concat(h,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<d.Error||console.error("".concat(h,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<d.Debug||console.log("".concat(h,"[Debug]: ").concat(e.join(" ")))},e}(),g=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:"$default_instance",logLevel:d.Warn,loggerProvider:new p,offline:!1,optOut:!1,serverUrl:l,serverZone:"US",useBatch:!1}},y=function(){function e(e){var t,n,r,o;this._optOut=!1;var i=g();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:i.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||i.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||i.flushQueueSize,this.instanceName=e.instanceName||i.instanceName,this.loggerProvider=e.loggerProvider||i.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:i.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=void 0!==e.offline?e.offline:i.offline,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:i.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||i.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(o=e.useBatch)&&void 0!==o?o:i.useBatch,this.loggerProvider.enable(this.logLevel);var s=b(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=s.serverZone,this.serverUrl=s.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),m=function(e,t){return"EU"===e?t?"https://api.eu.amplitude.com/batch":"https://api.eu.amplitude.com/2/httpapi":t?"https://api2.amplitude.com/batch":l},b=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=g().serverZone),void 0===n&&(n=g().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:g().serverZone;return{serverZone:r,serverUrl:m(r,n)}},S=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:w(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),w=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},I=function(){function e(){this.queue=[]}return e.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},e.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach((function(t){e(t)})),this.queue=[])},e}(),C=function(){return C=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},C.apply(this,arguments)};function E(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function k(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}"function"==typeof SuppressedError&&SuppressedError;var x=function(e,t){var n,r,o=typeof e;if(o!==typeof t)return!1;try{for(var i=E(["string","number","boolean","undefined"]),s=i.next();!s.done;s=i.next()){if(s.value===o)return e===t}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var a=Array.isArray(e),u=Array.isArray(t);if(a!==u)return!1;if(!a||!u){var c=Object.keys(e).sort(),l=Object.keys(t).sort();if(!x(c,l))return!1;var d=!0;return Object.keys(e).forEach((function(n){x(e[n],t[n])||(d=!1)})),d}for(var f=0;f<e.length;f++)if(!x(e[f],t[f]))return!1;return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var P,R=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=C({},this.identity.userProperties),n=C(C({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){var t,r,o,i,s,a,u=n.userProperties||{};try{for(var c=E(Object.entries(e)),l=c.next();!l.done;l=c.next()){var d=k(l.value,2),f=d[0],v=d[1];switch(f){case"$set":try{for(var h=(o=void 0,E(Object.entries(v))),p=h.next();!p.done;p=h.next()){var g=k(p.value,2),y=g[0],m=g[1];u[y]=m}}catch(e){o={error:e}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(o)throw o.error}}break;case"$unset":try{for(var b=(s=void 0,E(Object.keys(v))),S=b.next();!S.done;S=b.next()){delete u[y=S.value]}}catch(e){s={error:e}}finally{try{S&&!S.done&&(a=b.return)&&a.call(b)}finally{if(s)throw s.error}}break;case"$clearAll":u={}}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}return n.userProperties=u,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return C({},this.identity)},e.prototype.setIdentity=function(e){var t=C({},this.identity);this.identity=C({},e),x(t,this.identity)||this.listeners.forEach((function(t){t(e)}))},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),_="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,T=function(){function e(){this.identityStore=new R,this.eventBridge=new I,this.applicationContextProvider=new S}return e.getInstance=function(t){return _.analyticsConnectorInstances||(_.analyticsConnectorInstances={}),_.analyticsConnectorInstances[t]||(_.analyticsConnectorInstances[t]=new e),_.analyticsConnectorInstances[t]},e}(),O=function(e,t,n,r,o){return void 0===o&&(o=null),function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];var a=n(),u=a.logger,c=a.logLevel;if(c&&c<d.Debug||!c||!u)return e.apply(o,i);var l,f={type:"invoke public method",name:t,args:i,stacktrace:(l=1,void 0===l&&(l=0),((new Error).stack||"").split("\n").slice(2+l).map((function(e){return e.trim()}))),time:{start:(new Date).toISOString()},states:{}};r&&f.states&&(f.states.before=r());var v=e.apply(o,i);return v&&v.promise?v.promise.then((function(){r&&f.states&&(f.states.after=r()),f.time&&(f.time.end=(new Date).toISOString()),u.debug(JSON.stringify(f,null,2))})):(r&&f.states&&(f.states.after=r()),f.time&&(f.time.end=(new Date).toISOString()),u.debug(JSON.stringify(f,null,2))),v}},q=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,o,i,s,a,c,l,d,f,v,h,p,g,y,m,b,S,w,I,C;if("object"!=typeof e)return null;var E=e.code||0,k=this.buildStatus(E);switch(k){case u.Success:return{status:k,statusCode:E,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case u.Invalid:return{status:k,statusCode:E,body:{error:null!==(o=e.error)&&void 0!==o?o:"",missingField:null!==(i=e.missing_field)&&void 0!==i?i:"",eventsWithInvalidFields:null!==(s=e.events_with_invalid_fields)&&void 0!==s?s:{},eventsWithMissingFields:null!==(a=e.events_with_missing_fields)&&void 0!==a?a:{},eventsWithInvalidIdLengths:null!==(c=e.events_with_invalid_id_lengths)&&void 0!==c?c:{},epsThreshold:null!==(l=e.eps_threshold)&&void 0!==l?l:0,exceededDailyQuotaDevices:null!==(d=e.exceeded_daily_quota_devices)&&void 0!==d?d:{},silencedDevices:null!==(f=e.silenced_devices)&&void 0!==f?f:[],silencedEvents:null!==(v=e.silenced_events)&&void 0!==v?v:[],throttledDevices:null!==(h=e.throttled_devices)&&void 0!==h?h:{},throttledEvents:null!==(p=e.throttled_events)&&void 0!==p?p:[]}};case u.PayloadTooLarge:return{status:k,statusCode:E,body:{error:null!==(g=e.error)&&void 0!==g?g:""}};case u.RateLimit:return{status:k,statusCode:E,body:{error:null!==(y=e.error)&&void 0!==y?y:"",epsThreshold:null!==(m=e.eps_threshold)&&void 0!==m?m:0,throttledDevices:null!==(b=e.throttled_devices)&&void 0!==b?b:{},throttledUsers:null!==(S=e.throttled_users)&&void 0!==S?S:{},exceededDailyQuotaDevices:null!==(w=e.exceeded_daily_quota_devices)&&void 0!==w?w:{},exceededDailyQuotaUsers:null!==(I=e.exceeded_daily_quota_users)&&void 0!==I?I:{},throttledEvents:null!==(C=e.throttled_events)&&void 0!==C?C:[]}};case u.Timeout:default:return{status:k,statusCode:E}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?u.Success:429===e?u.RateLimit:413===e?u.PayloadTooLarge:408===e?u.Timeout:e>=400&&e<500?u.Invalid:e>=500?u.Failed:u.Unknown},e}(),M=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.send=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return n={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(t),method:"POST"},[4,fetch(e,n)];case 1:return[4,(r=o.sent()).text()];case 2:i=o.sent();try{return[2,this.buildResponse(JSON.parse(i))]}catch(e){return[2,this.buildResponse({code:r.status})]}return[2]}}))}))},n}(q);!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(P||(P={}));var L,D="[Amplitude]",N="".concat(D," Session Replay ID"),j=P.US,U="".concat(D," Session Replay Debug"),B="amp-mask";!function(e){e.GET_SR_PROPS="get-sr-props",e.DEBUG_INFO="debug-info",e.FETCH_REQUEST="fetch-request",e.METADATA="metadata"}(L||(L={}));var F=function(){function e(e){this.logger=e,this.log=this.getSafeMethod("log"),this.warn=this.getSafeMethod("warn"),this.error=this.getSafeMethod("error"),this.debug=this.getSafeMethod("debug")}return e.prototype.getSafeMethod=function(e){var t;if(!this.logger)return function(){};var n=this.logger[e];return"function"==typeof n?(null!==(t=n.__rrweb_original__)&&void 0!==t?t:n).bind(this.logger):function(){}},e.prototype.enable=function(e){this.logger.enable(e)},e.prototype.disable=function(){this.logger.disable()},e}(),A="medium";var K,W,z=function(e,t,n){switch(t){case"light":if("input"!==e)return!0;var r=n?function(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?t.toLowerCase():null}(n):"";return!!r&&(!!["password","hidden","email","tel"].includes(r)||!!n.autocomplete.startsWith("cc-"));case"medium":case"conservative":return!0;default:return z(e,A,n)}},G=function(e,t){return function(n,r){return function(e,t,n){var r,o,i;if(void 0===t&&(t={defaultMaskLevel:A}),n){if(n.closest("."+B))return!0;var s=(null!==(r=t.maskSelector)&&void 0!==r?r:[]).some((function(e){return n.closest(e)}));if(s)return!0;if(n.closest(".amp-unmask"))return!1;var a=(null!==(o=t.unmaskSelector)&&void 0!==o?o:[]).some((function(e){return n.closest(e)}));if(a)return!1}return z(e,null!==(i=t.defaultMaskLevel)&&void 0!==i?i:A,n)}(e,t,r)?n.replace(/[^\s]/g,"*"):n}},Q=function(e){var t=0;if(0===e.length)return t;for(var n=0;n<e.length;n++){t=(t<<5)-t+e.charCodeAt(n),t|=0}return t},$=function(e,t){return t||(e===P.STAGING?"https://api-sr.stag2.amplitude.com/sessions/v2/track":e===P.EU?"https://api-sr.eu.amplitude.com/sessions/v2/track":"https://api-sr.amplitude.com/sessions/v2/track")},H=function(e,t){var n,r,o,s;try{for(var a=i(t),u=a.next();!u.done;u=a.next()){var c=u.value,l=(o=c.selector,s=void 0,s=o.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,"."),new RegExp("^".concat(s,"$")));if(l.test(e))return e.replace(l,c.replacement)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return e},J=function(){return r(void 0,void 0,void 0,(function(){var e,t,n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),(e=f())?[4,e.navigator.storage.estimate()]:[3,2];case 1:return t=o.sent(),n=t.usage,r=t.quota,i=t.usageDetails,s=n?Math.round(n/1024):0,a=n&&r?Math.round(1e3*(n/r+Number.EPSILON))/1e3:0,[2,{totalStorageSize:s,percentOfQuota:a,usageDetails:JSON.stringify(i)}];case 2:return[3,4];case 3:return o.sent(),[3,4];case 4:return[2,{totalStorageSize:0,percentOfQuota:0,usageDetails:""}]}}))}))},V=function(e){var t=n({},e),r=t.apiKey;return t.apiKey="****".concat(r.substring(r.length-4)),t},Z=function(){return{flushMaxRetries:2,logLevel:d.Warn,loggerProvider:new p,transportProvider:new M}},X=function(e){function r(t,r){var o,i,s=this,a=Z();return(s=e.call(this,n(n({transportProvider:a.transportProvider,loggerProvider:new F(r.loggerProvider||a.loggerProvider)},r),{apiKey:t}))||this).flushMaxRetries=void 0!==r.flushMaxRetries&&r.flushMaxRetries<=a.flushMaxRetries?r.flushMaxRetries:a.flushMaxRetries,s.apiKey=t,s.sampleRate=r.sampleRate||0,s.serverZone=r.serverZone||j,s.configServerUrl=r.configServerUrl,s.trackServerUrl=r.trackServerUrl,s.shouldInlineStylesheet=r.shouldInlineStylesheet,s.version=r.version,s.performanceConfig=r.performanceConfig,s.storeType=null!==(o=r.storeType)&&void 0!==o?o:"idb",s.applyBackgroundColorToBlockedElements=null!==(i=r.applyBackgroundColorToBlockedElements)&&void 0!==i&&i,r.privacyConfig&&(s.privacyConfig=r.privacyConfig),r.interactionConfig&&(s.interactionConfig=r.interactionConfig,s.interactionConfig.ugcFilterRules&&function(e){if(!e.every((function(e){return"string"==typeof e.selector&&"string"==typeof e.replacement})))throw new Error("ugcFilterRules must be an array of objects with selector and replacement properties");if(!e.every((function(e){return"string"==typeof(t=e.selector)&&""!==t.trim()&&!!/^\/|^https?:\/\/[^\s]+$/.test(t);var t})))throw new Error("ugcFilterRules must be an array of objects with valid globs")}(s.interactionConfig.ugcFilterRules)),r.debugMode&&(s.debugMode=r.debugMode),r.experimental&&(s.experimental=r.experimental),s}return t(r,e),r}(y),Y=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(Y||{}),ee=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(ee||{});!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(K||(K={})),function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(W||(W={}));var te=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,o,i,s,a,u,c,l,d,f,v,h,p,g,y,m,b,S,w,I;if("object"!=typeof e)return null;var C=e.code||0,E=this.buildStatus(C);switch(E){case W.Success:return{status:E,statusCode:C,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case W.Invalid:return{status:E,statusCode:C,body:{error:null!==(o=e.error)&&void 0!==o?o:"",missingField:null!==(i=e.missing_field)&&void 0!==i?i:"",eventsWithInvalidFields:null!==(s=e.events_with_invalid_fields)&&void 0!==s?s:{},eventsWithMissingFields:null!==(a=e.events_with_missing_fields)&&void 0!==a?a:{},eventsWithInvalidIdLengths:null!==(u=e.events_with_invalid_id_lengths)&&void 0!==u?u:{},epsThreshold:null!==(c=e.eps_threshold)&&void 0!==c?c:0,exceededDailyQuotaDevices:null!==(l=e.exceeded_daily_quota_devices)&&void 0!==l?l:{},silencedDevices:null!==(d=e.silenced_devices)&&void 0!==d?d:[],silencedEvents:null!==(f=e.silenced_events)&&void 0!==f?f:[],throttledDevices:null!==(v=e.throttled_devices)&&void 0!==v?v:{},throttledEvents:null!==(h=e.throttled_events)&&void 0!==h?h:[]}};case W.PayloadTooLarge:return{status:E,statusCode:C,body:{error:null!==(p=e.error)&&void 0!==p?p:""}};case W.RateLimit:return{status:E,statusCode:C,body:{error:null!==(g=e.error)&&void 0!==g?g:"",epsThreshold:null!==(y=e.eps_threshold)&&void 0!==y?y:0,throttledDevices:null!==(m=e.throttled_devices)&&void 0!==m?m:{},throttledUsers:null!==(b=e.throttled_users)&&void 0!==b?b:{},exceededDailyQuotaDevices:null!==(S=e.exceeded_daily_quota_devices)&&void 0!==S?S:{},exceededDailyQuotaUsers:null!==(w=e.exceeded_daily_quota_users)&&void 0!==w?w:{},throttledEvents:null!==(I=e.throttled_events)&&void 0!==I?I:[]}};case W.Timeout:default:return{status:E,statusCode:C}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?W.Success:429===e?W.RateLimit:413===e?W.PayloadTooLarge:408===e?W.Timeout:e>=400&&e<500?W.Invalid:e>=500?W.Failed:W.Unknown},e}(),ne="Remote config fetch rejected due to timeout after 5 seconds",re="Unexpected error occurred",oe=function(){function e(e){var t=e.localConfig,s=e.configKeys,a=this;this.retryTimeout=1e3,this.attempts=0,this.sessionTargetingMatch=!1,this.metrics={},this.getRemoteConfig=function(e,t,n){return r(a,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return r=Date.now(),[4,this.fetchWithTimeout(n)];case 1:return(i=o.sent())&&(s=i.configs&&i.configs[e])?(this.metrics.fetchTimeAPISuccess=Date.now()-r,[2,s[t]]):(this.metrics.fetchTimeAPIFail=Date.now()-r,[2,void 0])}}))}))},this.fetchWithTimeout=function(e){return r(a,void 0,void 0,(function(){var t,n,r;return o(this,(function(o){switch(o.label){case 0:return t=new AbortController,n=setTimeout((function(){return t.abort()}),5e3),[4,this.fetchRemoteConfig(t.signal,e)];case 1:return r=o.sent(),clearTimeout(n),[2,r]}}))}))},this.fetchRemoteConfig=function(e,t){return r(a,void 0,void 0,(function(){var r,s,a,u,c,l,d,f,v,h,p,g;return o(this,(function(o){switch(o.label){case 0:if(t===this.lastFetchedSessionId&&this.attempts>=this.localConfig.flushMaxRetries)return[2,this.completeRequest({err:"Remote config fetch rejected due to exceeded retry count"})];if(e.aborted)return[2,this.completeRequest({err:ne})];t!==this.lastFetchedSessionId&&(this.lastFetchedSessionId=t,this.attempts=0),o.label=1;case 1:o.trys.push([1,3,,4]),r=new URLSearchParams({api_key:this.localConfig.apiKey});try{for(s=i(this.configKeys),a=s.next();!a.done;a=s.next())u=a.value,r.append("config_keys",u)}catch(e){h={error:e}}finally{try{a&&!a.done&&(p=s.return)&&p.call(s)}finally{if(h)throw h.error}}return t&&r.set("session_id",String(t)),c={headers:{Accept:"*/*"},method:"GET"},l="".concat(this.getServerUrl(),"?").concat(r.toString()),this.attempts+=1,[4,fetch(l,n(n({},c),{signal:e}))];case 2:if(null===(d=o.sent()))return[2,this.completeRequest({err:re})];switch((new te).buildStatus(d.status)){case W.Success:return this.attempts=0,[2,this.parseAndStoreConfig(d)];case W.Failed:return[2,this.retryFetch(e,t)];default:return[2,this.completeRequest({err:"Network error occurred, remote config fetch failed"})]}case 3:return f=o.sent(),v=f,e.aborted?[2,this.completeRequest({err:ne})]:[2,this.completeRequest({err:null!==(g=v.message)&&void 0!==g?g:re})];case 4:return[2]}}))}))},this.retryFetch=function(e,t){return r(a,void 0,void 0,(function(){var n=this;return o(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(e){return setTimeout(e,n.attempts*n.retryTimeout)}))];case 1:return r.sent(),[2,this.fetchRemoteConfig(e,t)]}}))}))},this.parseAndStoreConfig=function(e){return r(a,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return[4,e.json()];case 1:return t=n.sent(),this.completeRequest({success:"Remote config successfully fetched"}),[2,t]}}))}))},this.localConfig=t,this.configKeys=s}return e.prototype.getServerUrl=function(){return this.localConfig.configServerUrl?this.localConfig.configServerUrl:this.localConfig.serverZone===K.STAGING?"https://sr-client-cfg.stag2.amplitude.com/config":this.localConfig.serverZone===K.EU?"https://sr-client-cfg.eu.amplitude.com/config":"https://sr-client-cfg.amplitude.com/config"},e.prototype.completeRequest=function(e){var t=e.err,n=e.success;if(t)throw new Error(t);n&&this.localConfig.loggerProvider.log(n)},e}(),ie=function(e){var t=e.localConfig,n=e.configKeys;return r(void 0,void 0,void 0,(function(){return o(this,(function(e){return[2,new oe({localConfig:t,configKeys:n})]}))}))},se=function(){function e(e,t){this.localConfig=t,this.remoteConfigFetch=e}return e.prototype.generateJoinedConfig=function(e){var t,a,u,c;return r(this,void 0,void 0,(function(){var r,l,d,f,v,h,p,g,y,m,b,S,w,I,C,E,k,x,P,R,_,T;return o(this,(function(o){switch(o.label){case 0:(r=n({},this.localConfig)).optOut=this.localConfig.optOut,r.captureEnabled=!0,o.label=1;case 1:return o.trys.push([1,6,,7]),[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_sampling_config",e)];case 2:return d=o.sent(),[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_privacy_config",e)];case 3:return f=o.sent(),v=null===(t=r.interactionConfig)||void 0===t?void 0:t.ugcFilterRules,h=r,[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_interaction_config",e)];case 4:return h.interactionConfig=o.sent(),r.interactionConfig&&v&&(r.interactionConfig.ugcFilterRules=v),p=r,[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_logging_config",e)];case 5:return p.loggingConfig=o.sent(),(d||f)&&(l={},d&&(l.sr_sampling_config=d),f&&(l.sr_privacy_config=f)),[3,7];case 6:return g=o.sent(),y=g,this.localConfig.loggerProvider.warn(y.message),r.captureEnabled=!1,[3,7];case 7:if(!l)return[2,{localConfig:this.localConfig,joinedConfig:r,remoteConfig:l}];if(m=l.sr_sampling_config,b=l.sr_privacy_config,m&&Object.keys(m).length>0?(Object.prototype.hasOwnProperty.call(m,"capture_enabled")?r.captureEnabled=m.capture_enabled:r.captureEnabled=!1,Object.prototype.hasOwnProperty.call(m,"sample_rate")&&(r.sampleRate=m.sample_rate)):(r.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),b){S=null!==(a=r.privacyConfig)&&void 0!==a?a:{},w={defaultMaskLevel:null!==(c=null!==(u=b.defaultMaskLevel)&&void 0!==u?u:S.defaultMaskLevel)&&void 0!==c?c:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[]},I=function(e){var t,n,r,o,s,a,u,c,l,d={};"string"==typeof e.blockSelector&&(e.blockSelector=[e.blockSelector]);try{for(var f=i(null!==(u=e.blockSelector)&&void 0!==u?u:[]),v=f.next();!v.done;v=f.next()){d[v.value]="block"}}catch(e){t={error:e}}finally{try{v&&!v.done&&(n=f.return)&&n.call(f)}finally{if(t)throw t.error}}try{for(var h=i(null!==(c=e.maskSelector)&&void 0!==c?c:[]),p=h.next();!p.done;p=h.next()){d[p.value]="mask"}}catch(e){r={error:e}}finally{try{p&&!p.done&&(o=h.return)&&o.call(h)}finally{if(r)throw r.error}}try{for(var g=i(null!==(l=e.unmaskSelector)&&void 0!==l?l:[]),y=g.next();!y.done;y=g.next()){d[y.value]="unmask"}}catch(e){s={error:e}}finally{try{y&&!y.done&&(a=g.return)&&a.call(g)}finally{if(s)throw s.error}}return d},C=n(n({},I(S)),I(b));try{for(E=i(Object.entries(C)),k=E.next();!k.done;k=E.next())x=s(k.value,2),P=x[0],"mask"===(R=x[1])?w.maskSelector.push(P):"block"===R?w.blockSelector.push(P):"unmask"===R&&w.unmaskSelector.push(P)}catch(e){_={error:e}}finally{try{k&&!k.done&&(T=E.return)&&T.call(E)}finally{if(_)throw _.error}}r.privacyConfig=function(e,t){var n=document.createDocumentFragment(),r=function(e){if(void 0===e&&(e=[]),"string"==typeof e&&(e=[e]),e=e.filter((function(e){try{n.querySelector(e)}catch(n){return t.warn('[session-replay-browser] omitting selector "'.concat(e,'" because it is invalid')),!1}return!0})),0!==e.length)return e};return e.blockSelector=r(e.blockSelector),e.maskSelector=r(e.maskSelector),e.unmaskSelector=r(e.unmaskSelector),e}(w,this.localConfig.loggerProvider)}return this.localConfig.loggerProvider.debug(JSON.stringify({name:"session replay joined config",config:V(r)},null,2)),[2,{localConfig:this.localConfig,joinedConfig:r,remoteConfig:l}]}}))}))},e}(),ae=function(e,t){return r(void 0,void 0,void 0,(function(){var n,r;return o(this,(function(o){switch(o.label){case 0:return n=new X(e,t),[4,ie({localConfig:n,configKeys:["sessionReplay"]})];case 1:return r=o.sent(),[2,new se(r,n)]}}))}))},ue="Failed to store session replay events in IndexedDB",ce="1.25.2",le=function(){function e(e){var t=e.trackServerUrl,n=e.loggerProvider,r=e.payloadBatcher;this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.loggerProvider=n,this.payloadBatcher=r||function(e){return e},this.trackServerUrl=t}return e.prototype.sendEventsList=function(e){this.addToQueue(n(n({},e),{attempts:0,timeout:0}))},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t.filter((function(t){return t.attempts<(t.flushMaxRetries||0)?(t.attempts+=1,!0):(e.completeRequest({context:t,err:"Session replay event batch rejected due to exceeded retry count"}),!1)})).forEach((function(t){e.queue=e.queue.concat(t),0!==t.timeout?setTimeout((function(){t.timeout=0,e.schedule(0)}),t.timeout):e.schedule(0)}))},e.prototype.schedule=function(e){var t=this;this.scheduled||(this.scheduled=setTimeout((function(){t.flush(!0).then((function(){t.queue.length>0&&t.schedule(e)}))}),e))},e.prototype.flush=function(e){return void 0===e&&(e=!1),r(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(o){switch(o.label){case 0:return t=[],n=[],this.queue.forEach((function(e){return 0===e.timeout?t.push(e):n.push(e)})),this.queue=n,this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),[4,Promise.all(t.map((function(t){return r.send(t,e)})))];case 1:return o.sent(),[2]}}))}))},e.prototype.send=function(e,t){var n,i;return void 0===t&&(t=!0),r(this,void 0,void 0,(function(){var r,s,a,u,c,l,d,v,h,p,g,y,m;return o(this,(function(o){switch(o.label){case 0:if(!(r=e.apiKey))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing api key"})];if(!(s=e.deviceId))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing device ID"})];if(b=f(),a=(null==b?void 0:b.location)?b.location.href:"",u=ce,c=e.sampleRate,l=new URLSearchParams({device_id:s,session_id:"".concat(e.sessionId),type:"".concat(e.type)}),d="".concat((null===(n=e.version)||void 0===n?void 0:n.type)||"standalone","/").concat((null===(i=e.version)||void 0===i?void 0:i.version)||u),0===(v=this.payloadBatcher({version:1,events:e.events})).events.length)return this.completeRequest({context:e}),[2];o.label=1;case 1:return o.trys.push([1,3,,4]),h={headers:{"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(r),"X-Client-Version":u,"X-Client-Library":d,"X-Client-Url":a.substring(0,1e3),"X-Client-Sample-Rate":"".concat(c)},body:JSON.stringify(v),method:"POST"},p="".concat($(e.serverZone,this.trackServerUrl),"?").concat(l.toString()),[4,fetch(p,h)];case 2:if(null===(g=o.sent()))return this.completeRequest({context:e,err:"Unexpected error occurred"}),[2];if(t)this.handleReponse(g.status,e);else{y="";try{y=JSON.stringify(g.body,null,2)}catch(e){}this.completeRequest({context:e,success:"".concat(g.status,": ").concat(y)})}return[3,4];case 3:return m=o.sent(),this.completeRequest({context:e,err:m}),[3,4];case 4:return[2]}var b}))}))},e.prototype.handleReponse=function(e,t){switch((new q).buildStatus(e)){case u.Success:this.handleSuccessResponse(t);break;case u.Failed:this.handleOtherResponse(t);break;default:this.completeRequest({context:t,err:"Network error occurred, event batch rejected"})}},e.prototype.handleSuccessResponse=function(e){var t=Math.round(new Blob(e.events).size/1024);this.completeRequest({context:e,success:"Session replay event batch tracked successfully for session id ".concat(e.sessionId,", size of events: ").concat(t," KB")})},e.prototype.handleOtherResponse=function(e){this.addToQueue(n(n({},e),{timeout:e.attempts*this.retryTimeout}))},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success;t.onComplete(),n?this.loggerProvider.warn(n):r&&this.loggerProvider.log(r)},e}();const de=(e,t)=>t.some((t=>e instanceof t));let fe,ve;const he=new WeakMap,pe=new WeakMap,ge=new WeakMap;let ye={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return he.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return we(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function me(e){ye=e(ye)}function be(e){return(ve||(ve=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Ie(this),t),we(this.request)}:function(...t){return we(e.apply(Ie(this),t))}}function Se(e){return"function"==typeof e?be(e):(e instanceof IDBTransaction&&function(e){if(he.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",i),e.removeEventListener("abort",i)},o=()=>{t(),r()},i=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",o),e.addEventListener("error",i),e.addEventListener("abort",i)}));he.set(e,t)}(e),de(e,fe||(fe=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,ye):e)}function we(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",o),e.removeEventListener("error",i)},o=()=>{t(we(e.result)),r()},i=()=>{n(e.error),r()};e.addEventListener("success",o),e.addEventListener("error",i)}));return ge.set(t,e),t}(e);if(pe.has(e))return pe.get(e);const t=Se(e);return t!==e&&(pe.set(e,t),ge.set(t,e)),t}const Ie=e=>ge.get(e);function Ce(e,t,{blocked:n,upgrade:r,blocking:o,terminated:i}={}){const s=indexedDB.open(e,t),a=we(s);return r&&s.addEventListener("upgradeneeded",(e=>{r(we(s.result),e.oldVersion,e.newVersion,we(s.transaction),e)})),n&&s.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e))),a.then((e=>{i&&e.addEventListener("close",(()=>i())),o&&e.addEventListener("versionchange",(e=>o(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),a}const Ee=["get","getKey","getAll","getAllKeys","count"],ke=["put","add","delete","clear"],xe=new Map;function Pe(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(xe.get(t))return xe.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,o=ke.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!o&&!Ee.includes(n))return;const i=async function(e,...t){const i=this.transaction(e,o?"readwrite":"readonly");let s=i.store;return r&&(s=s.index(t.shift())),(await Promise.all([s[n](...t),o&&i.done]))[0]};return xe.set(t,i),i}me((e=>({...e,get:(t,n,r)=>Pe(t,n)||e.get(t,n,r),has:(t,n)=>!!Pe(t,n)||e.has(t,n)})));const Re=["continue","continuePrimaryKey","advance"],_e={},Te=new WeakMap,Oe=new WeakMap,qe={get(e,t){if(!Re.includes(t))return e[t];let n=_e[t];return n||(n=_e[t]=function(...e){Te.set(this,Oe.get(this)[t](...e))}),n}};async function*Me(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const n=new Proxy(t,qe);for(Oe.set(n,t),ge.set(n,Ie(t));t;)yield n,t=await(Te.get(n)||t.continue()),Te.delete(n)}function Le(e,t){return t===Symbol.asyncIterator&&de(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&de(e,[IDBIndex,IDBObjectStore])}me((e=>({...e,get:(t,n,r)=>Le(t,n)?Me:e.get(t,n,r),has:(t,n)=>Le(t,n)||e.has(t,n)})));var De,Ne=function(){function e(e){var t,n,r,o=this;this.minInterval=500,this.maxInterval=1e4,this.maxPersistedEventsSize=1e6,this.interval=this.minInterval,this._timeAtLastSplit=Date.now(),this.shouldSplitEventsList=function(e,t){var n=new Blob([t]).size;return new Blob(e).size+n>=o.maxPersistedEventsSize||!!(Date.now()-o.timeAtLastSplit>o.interval&&e.length)&&(o.interval=Math.min(o.maxInterval,o.interval+o.minInterval),o._timeAtLastSplit=Date.now(),!0)},this.loggerProvider=e.loggerProvider,this.minInterval=null!==(t=e.minInterval)&&void 0!==t?t:this.minInterval,this.maxInterval=null!==(n=e.maxInterval)&&void 0!==n?n:this.maxInterval,this.maxPersistedEventsSize=null!==(r=e.maxPersistedEventsSize)&&void 0!==r?r:this.maxPersistedEventsSize}return Object.defineProperty(e.prototype,"timeAtLastSplit",{get:function(){return this._timeAtLastSplit},enumerable:!1,configurable:!0}),e}();!function(e){e.RECORDING="recording",e.SENT="sent"}(De||(De={}));var je="sessionCurrentSequence",Ue="sequencesToSend",Be=function(){var e=f();return new Promise((function(t,n){if(!e)return n(new Error("Global scope not found"));if(!e.indexedDB)return n(new Error("Session Replay: cannot find indexedDB"));try{var r=e.indexedDB.open("keyval-store");r.onupgradeneeded=function(){1===r.result.version&&(r.result.close(),r.transaction&&r.transaction.abort(),e.indexedDB.deleteDatabase("keyval-store"),t())},r.onsuccess=function(){t(r.result)},r.onerror=function(){n(r.error)}}catch(e){n(e)}}))},Fe=function(e){return r(void 0,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return e.length>0?(t=e.splice(0,10),[4,Promise.all(t)]):[3,2];case 1:return n.sent(),[3,0];case 2:return[2]}}))}))},Ae=function(e){var t,n;return e.objectStoreNames.contains(je)||(n=e.createObjectStore(je,{keyPath:"sessionId"})),e.objectStoreNames.contains(Ue)||(t=e.createObjectStore(Ue,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:n}},Ke=function(e){return r(void 0,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,Ce(e,1,{upgrade:Ae})];case 1:return[2,t.sent()]}}))}))},We=function(e){function u(t){var i=e.call(this,t)||this;return i.getSequencesToSend=function(){return r(i,void 0,void 0,(function(){var e,t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,5,,6]),e=[],[4,this.db.transaction("sequencesToSend").store.openCursor()];case 1:t=o.sent(),o.label=2;case 2:return t?(n=t.value,r=n.sessionId,i=n.events,e.push({events:i,sequenceId:t.key,sessionId:r}),[4,t.continue()]):[3,4];case 3:return t=o.sent(),[3,2];case 4:return[2,e];case 5:return s=o.sent(),this.loggerProvider.warn("".concat(ue,": ").concat(s)),[3,6];case 6:return[2,void 0]}}))}))},i.storeCurrentSequence=function(e){return r(i,void 0,void 0,(function(){var t,r,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),[4,this.db.get(je,e)];case 1:return(t=o.sent())?[4,this.db.put(Ue,{sessionId:e,events:t.events})]:[2,void 0];case 2:return r=o.sent(),[4,this.db.put(je,{sessionId:e,events:[]})];case 3:return o.sent(),[2,n(n({},t),{sessionId:e,sequenceId:r})];case 4:return i=o.sent(),this.loggerProvider.warn("".concat(ue,": ").concat(i)),[3,5];case 5:return[2,void 0]}}))}))},i.addEventToCurrentSequence=function(e,t){return r(i,void 0,void 0,(function(){var n,r,i,s,a,u;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,10,,11]),[4,(n=this.db.transaction(je,"readwrite")).store.get(e)];case 1:return(r=o.sent())?[3,3]:[4,n.store.put({sessionId:e,events:[t]})];case 2:return o.sent(),[2];case 3:return i=void 0,this.shouldSplitEventsList(r.events,t)?(i=r.events,[4,n.store.put({sessionId:e,events:[t]})]):[3,5];case 4:return o.sent(),[3,7];case 5:return s=r.events.concat(t),[4,n.store.put({sessionId:e,events:s})];case 6:o.sent(),o.label=7;case 7:return[4,n.done];case 8:return o.sent(),i?[4,this.storeSendingEvents(e,i)]:[2,void 0];case 9:return(a=o.sent())?[2,{events:i,sessionId:e,sequenceId:a}]:[2,void 0];case 10:return u=o.sent(),this.loggerProvider.warn("".concat(ue,": ").concat(u)),[3,11];case 11:return[2,void 0]}}))}))},i.storeSendingEvents=function(e,t){return r(i,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.db.put(Ue,{sessionId:e,events:t})];case 1:return[2,r.sent()];case 2:return n=r.sent(),this.loggerProvider.warn("".concat(ue,": ").concat(n)),[3,3];case 3:return[2,void 0]}}))}))},i.cleanUpSessionEventsStore=function(e,t){return r(i,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:if(!t)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.db.delete(Ue,t)];case 2:return n.sent(),[3,4];case 3:return e=n.sent(),this.loggerProvider.warn("".concat(ue,": ").concat(e)),[3,4];case 4:return[2]}}))}))},i.transitionFromKeyValStore=function(e){return r(i,void 0,void 0,(function(){var t,n,i,u,l,d,v,h,p=this;return o(this,(function(g){switch(g.label){case 0:return g.trys.push([0,6,,7]),[4,Be()];case 1:if(!(t=g.sent()))return[2];n=function(e,t){return r(p,void 0,void 0,(function(){var n,i,u=this;return o(this,(function(c){switch(c.label){case 0:return n=t.sessionSequences,i=[],Object.keys(n).forEach((function(c){var l=parseInt(c,10),d=n[l];if(l===t.currentSequenceId){var f=d.events.map((function(t){return r(u,void 0,void 0,(function(){return o(this,(function(n){return[2,this.addEventToCurrentSequence(e,t)]}))}))}));i.push.apply(i,a([],s(f),!1))}else d.status!==De.SENT&&i.push(u.storeSendingEvents(e,d.events))})),[4,Fe(i)];case 1:return c.sent(),[2]}}))}))},i="".concat(c,"_").concat(this.apiKey.substring(0,10)),g.label=2;case 2:return g.trys.push([2,4,,5]),u=t.transaction("keyval").objectStore("keyval").getAll(i),l=new Promise((function(t){u.onsuccess=function(i){return r(p,void 0,void 0,(function(){var r,s,a,u=this;return o(this,(function(o){switch(o.label){case 0:return r=i&&i.target.result,(s=r&&r[0])?(a=[],Object.keys(s).forEach((function(t){var r=parseInt(t,10),o=s[r];if(e===r)a.push(n(r,o));else{var i=o.sessionSequences;Object.keys(i).forEach((function(e){var t=parseInt(e,10);i[t].status!==De.SENT&&a.push(u.storeSendingEvents(r,i[t].events))}))}})),[4,Fe(a)]):[3,2];case 1:o.sent(),o.label=2;case 2:return t(),[2]}}))}))}})),[4,l];case 3:return g.sent(),(d=f())&&d.indexedDB.deleteDatabase("keyval-store"),[3,5];case 4:return v=g.sent(),this.loggerProvider.warn("Failed to transition session replay events from keyval to new store: ".concat(v)),[3,5];case 5:return[3,7];case 6:return h=g.sent(),this.loggerProvider.warn("Failed to access keyval store: ".concat(h,". For more information, visit: https://www.docs.developers.amplitude.com/session-replay/sdks/standalone/#indexeddb-best-practices")),[3,7];case 7:return[2]}}))}))},i.apiKey=t.apiKey,i.db=t.db,i}return t(u,e),u.new=function(e,t,i){return r(this,void 0,void 0,(function(){var r,s,a,c,l;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),r="replay"===e?"":"_".concat(e),s="".concat(t.apiKey.substring(0,10),"_amp_session_replay_events").concat(r),[4,Ke(s)];case 1:return a=o.sent(),[4,(c=new u(n(n({},t),{db:a}))).transitionFromKeyValStore(i)];case 2:return o.sent(),[2,c];case 3:return l=o.sent(),t.loggerProvider.warn("".concat(ue,": ").concat(l)),[3,4];case 4:return[2]}}))}))},u.prototype.getCurrentSequenceEvents=function(e){return r(this,void 0,void 0,(function(){var t,n,r,s,a,u,c;return o(this,(function(o){switch(o.label){case 0:return e?[4,this.db.get("sessionCurrentSequence",e)]:[3,2];case 1:return(s=o.sent())?[2,[s]]:[2,void 0];case 2:t=[],o.label=3;case 3:return o.trys.push([3,8,9,10]),[4,this.db.getAll("sessionCurrentSequence")];case 4:n=i.apply(void 0,[o.sent()]),r=n.next(),o.label=5;case 5:if(r.done)return[3,7];s=r.value,t.push(s),o.label=6;case 6:return r=n.next(),[3,5];case 7:return[3,10];case 8:return a=o.sent(),u={error:a},[3,10];case 9:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 10:return[2,t]}}))}))},u}(Ne),ze=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.finalizedSequences={},t.sequences={},t.sequenceId=0,t}return t(n,e),n.prototype.resetCurrentSequence=function(e){this.sequences[e]=[]},n.prototype.addSequence=function(e){var t=this.sequenceId++,n=a([],s(this.sequences[e]),!1);return this.finalizedSequences[t]={sessionId:e,events:n},this.resetCurrentSequence(e),{sequenceId:t,events:n,sessionId:e}},n.prototype.getSequencesToSend=function(){return r(this,void 0,void 0,(function(){return o(this,(function(e){return[2,Object.entries(this.finalizedSequences).map((function(e){var t=s(e,2),n=t[0],r=t[1],o=r.sessionId,i=r.events;return{sequenceId:Number(n),sessionId:o,events:i}}))]}))}))},n.prototype.storeCurrentSequence=function(e){return r(this,void 0,void 0,(function(){return o(this,(function(t){return this.sequences[e]?[2,this.addSequence(e)]:[2,void 0]}))}))},n.prototype.addEventToCurrentSequence=function(e,t){return r(this,void 0,void 0,(function(){var n;return o(this,(function(r){return this.sequences[e]||this.resetCurrentSequence(e),this.shouldSplitEventsList(this.sequences[e],t)&&(n=this.addSequence(e)),this.sequences[e].push(t),[2,n]}))}))},n.prototype.storeSendingEvents=function(e,t){return r(this,void 0,void 0,(function(){return o(this,(function(n){return this.finalizedSequences[this.sequenceId]={sessionId:e,events:t},[2,this.sequenceId++]}))}))},n.prototype.cleanUpSessionEventsStore=function(e,t){return r(this,void 0,void 0,(function(){return o(this,(function(e){return void 0!==t&&delete this.finalizedSequences[t],[2]}))}))},n}(Ne),Ge=function(e){var t=e.config,i=e.sessionId,s=e.minInterval,a=e.maxInterval,u=e.type,c=e.payloadBatcher,l=e.storeType;return r(void 0,void 0,void 0,(function(){function e(e){return void 0===e&&(e=!1),r(this,void 0,void 0,(function(){return o(this,(function(t){return[2,d.flush(e)]}))}))}var d,f,v,h,p,g,y,m,b;return o(this,(function(S){switch(S.label){case 0:return d=new le(n(n({},t),{loggerProvider:t.loggerProvider,payloadBatcher:c})),f=function(){return new ze({loggerProvider:t.loggerProvider,maxInterval:a,minInterval:s})},v=function(){return r(void 0,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return[4,We.new(u,{loggerProvider:t.loggerProvider,minInterval:s,maxInterval:a,apiKey:t.apiKey},i)];case 1:return e=n.sent(),t.loggerProvider.log("Failed to initialize idb store, falling back to memory store."),[2,null!=e?e:f()]}}))}))},"idb"!==l?[3,2]:[4,v()];case 1:return p=S.sent(),[3,3];case 2:p=f(),S.label=3;case 3:return h=p,g=function(e){var n=e.events,i=e.sessionId,s=e.deviceId,a=e.sequenceId;t.debugMode&&J().then((function(e){var n=e.totalStorageSize,r=e.percentOfQuota,o=e.usageDetails;t.loggerProvider.debug("Total storage size: ".concat(n," KB, percentage of quota: ").concat(r,"%, usage details: ").concat(o))})).catch((function(){})),d.sendEventsList({events:n,sessionId:i,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:s,sampleRate:t.sampleRate,serverZone:t.serverZone,version:t.version,type:u,onComplete:function(){return r(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,h.cleanUpSessionEventsStore(i,a)];case 1:return e.sent(),[2]}}))}))}})},y=function(e){var n=e.sessionId,r=e.deviceId;h.storeCurrentSequence(n).then((function(e){e&&g({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r})})).catch((function(e){t.loggerProvider.warn("Failed to get current sequence of session replay events for session:",e)}))},m=function(e){var t=e.deviceId;return r(void 0,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return[4,h.getSequencesToSend()];case 1:return(e=n.sent())&&e.forEach((function(e){g({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:t})})),[2]}}))}))},b=function(e){var n=e.event,r=e.sessionId,o=e.deviceId;h.addEventToCurrentSequence(r,n.data).then((function(e){return e&&g({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:o})})).catch((function(e){t.loggerProvider.warn("Failed to add event to session replay capture:",e)}))},[2,{sendCurrentSequenceEvents:y,addEvent:b,sendStoredEvents:m,flush:e}]}}))}))},Qe=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new Map;e.forEach((function(e){n.set(e.name,e.manager)})),this.managers=n}return e.prototype.sendStoredEvents=function(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=[],this.managers.forEach((function(n){t.push(n.sendStoredEvents(e))})),[4,Promise.all(t)];case 1:return n.sent(),[2]}}))}))},e.prototype.addEvent=function(e){var t,n=e.sessionId,r=e.event,o=e.deviceId;null===(t=this.managers.get(r.type))||void 0===t||t.addEvent({sessionId:n,event:r,deviceId:o})},e.prototype.sendCurrentSequenceEvents=function(e){var t=e.sessionId,n=e.deviceId;this.managers.forEach((function(e){e.sendCurrentSequenceEvents({sessionId:t,deviceId:n})}))},e.prototype.flush=function(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=[],this.managers.forEach((function(n){t.push(n.flush(e))})),[4,Promise.all(t)];case 1:return n.sent(),[2]}}))}))},e}();const $e={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},He={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},Je={};function Ve(e){if(Je[e])return Je[e];const t=globalThis[e],n=t.prototype,r=e in $e?$e[e]:void 0,o=Boolean(r&&r.every((e=>{var t,r;return Boolean(null==(r=null==(t=Object.getOwnPropertyDescriptor(n,e))?void 0:t.get)?void 0:r.toString().includes("[native code]"))}))),i=e in He?He[e]:void 0,s=Boolean(i&&i.every((e=>{var t;return"function"==typeof n[e]&&(null==(t=n[e])?void 0:t.toString().includes("[native code]"))})));if(o&&s&&!globalThis.Zone)return Je[e]=t.prototype,t.prototype;try{const r=document.createElement("iframe");document.body.appendChild(r);const o=r.contentWindow;if(!o)return t.prototype;const i=o[e].prototype;return document.body.removeChild(r),i?Je[e]=i:n}catch{return n}}const Ze={};function Xe(e,t,n){var r;const o=`${e}.${String(n)}`;if(Ze[o])return Ze[o].call(t);const i=Ve(e),s=null==(r=Object.getOwnPropertyDescriptor(i,n))?void 0:r.get;return s?(Ze[o]=s,s.call(t)):t[n]}const Ye={};function et(e,t,n){const r=`${e}.${String(n)}`;if(Ye[r])return Ye[r].bind(t);const o=Ve(e)[n];return"function"!=typeof o?t[n]:(Ye[r]=o,o.bind(t))}const tt={childNodes:function(e){return Xe("Node",e,"childNodes")},parentNode:function(e){return Xe("Node",e,"parentNode")},parentElement:function(e){return Xe("Node",e,"parentElement")},textContent:function(e){return Xe("Node",e,"textContent")},contains:function(e,t){return et("Node",e,"contains")(t)},getRootNode:function(e){return et("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?Xe("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?Xe("Element",e,"shadowRoot"):null},querySelector:function(e,t){return Xe("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return Xe("Element",e,"querySelectorAll")(t)},mutationObserver:function(){return Ve("MutationObserver").constructor}};function nt(){var e=f();return(null==e?void 0:e.innerHeight)||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight||0}function rt(){var e=f();return(null==e?void 0:e.innerWidth)||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth||0}var ot,it,st;function at(e,t){if(st=new Date,e.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===e.tagName.toLowerCase())return"html";var r={root:document.body,idName:function(e){return!0},className:function(e){return!0},tagName:function(e){return!0},attr:function(e,t){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};ot=n(n({},r),t),it=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(ot.root,r);var o=ut(e,"all",(function(){return ut(e,"two",(function(){return ut(e,"one",(function(){return ut(e,"none")}))}))}));if(o){var i=mt(bt(o,e));return i.length>0&&(o=i[0]),lt(o)}throw new Error("Selector was not found.")}function ut(e,t,n){for(var r=null,o=[],u=e,c=0,l=function(){var e,l,d=(new Date).getTime()-st.getTime();if(void 0!==ot.timeoutMs&&d>ot.timeoutMs)throw new Error("Timeout: Can't find a unique selector after ".concat(d,"ms"));var f=pt(function(e){var t=e.getAttribute("id");if(t&&ot.idName(t))return{name:"#"+CSS.escape(t),penalty:0};return null}(u))||pt.apply(void 0,a([],s(function(e){var t=Array.from(e.attributes).filter((function(e){return ot.attr(e.name,e.value)}));return t.map((function(e){return{name:"[".concat(CSS.escape(e.name),'="').concat(CSS.escape(e.value),'"]'),penalty:.5}}))}(u)),!1))||pt.apply(void 0,a([],s(function(e){var t=Array.from(e.classList).filter(ot.className);return t.map((function(e){return{name:"."+CSS.escape(e),penalty:1}}))}(u)),!1))||pt(function(e){var t=e.tagName.toLowerCase();if(ot.tagName(t))return{name:t,penalty:2};return null}(u))||[{name:"*",penalty:3}],v=function(e){var t=e.parentNode;if(!t)return null;var n=t.firstChild;if(!n)return null;var r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}(u);if("all"==t)v&&(f=f.concat(f.filter(ht).map((function(e){return vt(e,v)}))));else if("two"==t)f=f.slice(0,1),v&&(f=f.concat(f.filter(ht).map((function(e){return vt(e,v)}))));else if("one"==t){var h=s(f=f.slice(0,1),1)[0];v&&ht(h)&&(f=[vt(h,v)])}else"none"==t&&(f=[{name:"*",penalty:3}],v&&(f=[vt(f[0],v)]));try{for(var p=(e=void 0,i(f)),g=p.next();!g.done;g=p.next()){(h=g.value).level=c}}catch(t){e={error:t}}finally{try{g&&!g.done&&(l=p.return)&&l.call(p)}finally{if(e)throw e.error}}if(o.push(f),o.length>=ot.seedMinLength&&(r=ct(o,n)))return"break";u=u.parentElement,c++};u;){if("break"===l())break}return r||(r=ct(o,n)),!r&&n?n():r}function ct(e,t){var n,r,o=mt(yt(e));if(o.length>ot.threshold)return t?t():null;try{for(var s=i(o),a=s.next();!a.done;a=s.next()){var u=a.value;if(ft(u))return u}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return null}function lt(e){for(var t=e[0],n=t.name,r=1;r<e.length;r++){var o=e[r].level||0;n=t.level===o-1?"".concat(e[r].name," > ").concat(n):"".concat(e[r].name," ").concat(n),t=e[r]}return n}function dt(e){return e.map((function(e){return e.penalty})).reduce((function(e,t){return e+t}),0)}function ft(e){var t=lt(e);switch(it.querySelectorAll(t).length){case 0:throw new Error("Can't select any node with this selector: ".concat(t));case 1:return!0;default:return!1}}function vt(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function ht(e){return"html"!==e.name&&!e.name.startsWith("#")}function pt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(gt);return n.length>0?n:null}function gt(e){return null!=e}function yt(e,t){var n,r,s,a,u,c;return void 0===t&&(t=[]),o(this,(function(o){switch(o.label){case 0:if(!(e.length>0))return[3,9];o.label=1;case 1:o.trys.push([1,6,7,8]),n=i(e[0]),r=n.next(),o.label=2;case 2:return r.done?[3,5]:(s=r.value,[5,i(yt(e.slice(1,e.length),t.concat(s)))]);case 3:o.sent(),o.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return a=o.sent(),u={error:a},[3,8];case 7:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 8:return[3,11];case 9:return[4,t];case 10:o.sent(),o.label=11;case 11:return[2]}}))}function mt(e){return a([],s(e),!1).sort((function(e,t){return dt(e)-dt(t)}))}function bt(e,t,n){var r,u,c;return void 0===n&&(n={counter:0,visited:new Map}),o(this,(function(o){switch(o.label){case 0:if(!(e.length>2&&e.length>ot.optimizedMinLength))return[3,5];r=1,o.label=1;case 1:return r<e.length-1?n.counter>ot.maxNumberOfTries?[2]:(n.counter+=1,(u=a([],s(e),!1)).splice(r,1),c=lt(u),n.visited.has(c)?[2]:ft(u)&&function(e,t){return it.querySelector(lt(e))===t}(u,t)?[4,u]:[3,4]):[3,5];case 2:return o.sent(),n.visited.set(c,!0),[5,i(bt(u,t,n))];case 3:o.sent(),o.label=4;case 4:return r++,[3,1];case 5:return[2]}}))}var St=function(e){var t=e.version,n=e.events,r=[];return n.forEach((function(e){var t=JSON.parse(e);t.count=1,"click"===t.type&&r.push(t)})),{version:t,events:r}},wt=function(e){var t=e.version,r=e.events,o=[];r.forEach((function(e){var t=JSON.parse(e);"click"===t.type&&o.push(t)}));var i=o.reduce((function(e,t){var r=t.x,o=t.y,i=t.selector,s=t.timestamp,a=s-s%36e5,u="".concat(r,":").concat(o,":").concat(null!=i?i:"",":").concat(a);return e[u]?e[u].count+=1:e[u]=n(n({},t),{timestamp:a,count:1}),e}),{});return{version:t,events:Object.values(i)}},It=function(e,t){var n=t.eventsManager,r=t.sessionId,o=t.deviceIdFn,i=t.mirror,s=t.ugcFilterRules;return function(t){if(t.type===ee.Click){var a=f();if(a){var u=a.location,c=a.innerHeight,l=a.innerWidth;if(u){var d=t.x,v=t.y;if(void 0!==d&&void 0!==v){var h,p=i.getNode(t.id);if(p)try{h=at(p)}catch(t){e.debug("error resolving selector from finder")}var g=function(e){var t,n,r,o,i=e.document;return{left:i.scrollingElement?i.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:i.documentElement.scrollLeft||(null==i?void 0:i.body)&&(null===(t=tt.parentElement(i.body))||void 0===t?void 0:t.scrollLeft)||(null===(n=null==i?void 0:i.body)||void 0===n?void 0:n.scrollLeft)||0,top:i.scrollingElement?i.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==i?void 0:i.documentElement.scrollTop)||(null==i?void 0:i.body)&&(null===(r=tt.parentElement(i.body))||void 0===r?void 0:r.scrollTop)||(null===(o=null==i?void 0:i.body)||void 0===o?void 0:o.scrollTop)||0}}(a),y={x:d+g.left,y:v+g.top,selector:h,viewportHeight:c,viewportWidth:l,pageUrl:H(u.href,s),timestamp:Date.now(),type:"click"},m=o();m&&n.addEvent({sessionId:r,event:{type:"interaction",data:JSON.stringify(y)},deviceId:m})}}}}}},Ct=function(){function e(e,t){var n=f();n&&n.navigator&&"function"==typeof n.navigator.sendBeacon?this.sendBeacon=function(e,t){try{if(n.navigator.sendBeacon(e,JSON.stringify(t)))return!0}catch(e){}return!1}:this.sendBeacon=function(){return!1},this.sendXhr=function(e,t){var n=new XMLHttpRequest;return n.open("POST",e,!0),n.setRequestHeader("Accept","*/*"),n.send(JSON.stringify(t)),!0},this.basePageUrl=$(t.serverZone,t.trackServerUrl),this.apiKey=t.apiKey,this.context=e}return e.prototype.send=function(e,t){var n=this.context,r=n.sessionId,o=n.type,i=new URLSearchParams({device_id:e,session_id:String(r),type:String(o),api_key:this.apiKey}),s="".concat(this.basePageUrl,"?").concat(i.toString());this.sendBeacon(s,t)||this.sendXhr(s,t)},e}(),Et=function(){function e(e,t){var n=this;this.timestamp=Date.now(),this.hook=function(e){n.update(e)},this.send=function(e){return function(t){var r,o,i=e(),s=f();s&&i&&n.transport.send(i,{version:1,events:[{maxScrollX:n._maxScrollX,maxScrollY:n._maxScrollY,maxScrollWidth:n._maxScrollWidth,maxScrollHeight:n._maxScrollHeight,viewportHeight:nt(),viewportWidth:rt(),pageUrl:H(s.location.href,null!==(o=null===(r=n.config.interactionConfig)||void 0===r?void 0:r.ugcFilterRules)&&void 0!==o?o:[]),timestamp:n.timestamp,type:"scroll"}]})}},this._maxScrollX=0,this._maxScrollY=0,this._maxScrollWidth=rt(),this._maxScrollHeight=nt(),this.config=t,this.transport=e}return e.default=function(t,n){return new e(new Ct(t,n),n)},Object.defineProperty(e.prototype,"maxScrollX",{get:function(){return this._maxScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollY",{get:function(){return this._maxScrollY},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollWidth",{get:function(){return this._maxScrollWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollHeight",{get:function(){return this._maxScrollHeight},enumerable:!1,configurable:!0}),e.prototype.update=function(e){var t=Date.now();if(e.x>this._maxScrollX){var n=rt();this._maxScrollX=e.x;var r=e.x+n;r>this._maxScrollWidth&&(this._maxScrollWidth=r),this.timestamp=t}if(e.y>this._maxScrollY){var o=nt();this._maxScrollY=e.y;var i=e.y+o;i>this._maxScrollHeight&&(this._maxScrollHeight=i),this.timestamp=t}},e}(),kt=function(e){var t=e.sessionId,n=e.deviceId;this.deviceId=n,this.sessionId=t,t&&n&&(this.sessionReplayId=function(e,t){return"".concat(t,"/").concat(e)}(t,n))},xt=Uint8Array,Pt=Uint16Array,Rt=Uint32Array,_t=new xt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Tt=new xt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ot=new xt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qt=function(e,t){for(var n=new Pt(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new Rt(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)o[i]=i-n[r]<<5|r;return[n,o]},Mt=qt(_t,2),Lt=Mt[0],Dt=Mt[1];Lt[28]=258,Dt[258]=28;for(var Nt=qt(Tt,0)[1],jt=new Pt(32768),Ut=0;Ut<32768;++Ut){var Bt=(43690&Ut)>>>1|(21845&Ut)<<1;Bt=(61680&(Bt=(52428&Bt)>>>2|(13107&Bt)<<2))>>>4|(3855&Bt)<<4,jt[Ut]=((65280&Bt)>>>8|(255&Bt)<<8)>>>1}var Ft=function(e,t,n){for(var r=e.length,o=0,i=new Pt(t);o<r;++o)++i[e[o]-1];var s,a=new Pt(t);for(o=0;o<t;++o)a[o]=a[o-1]+i[o-1]<<1;if(n){s=new Pt(1<<t);var u=15-t;for(o=0;o<r;++o)if(e[o])for(var c=o<<4|e[o],l=t-e[o],d=a[e[o]-1]++<<l,f=d|(1<<l)-1;d<=f;++d)s[jt[d]>>>u]=c}else for(s=new Pt(r),o=0;o<r;++o)s[o]=jt[a[e[o]-1]++]>>>15-e[o];return s},At=new xt(288);for(Ut=0;Ut<144;++Ut)At[Ut]=8;for(Ut=144;Ut<256;++Ut)At[Ut]=9;for(Ut=256;Ut<280;++Ut)At[Ut]=7;for(Ut=280;Ut<288;++Ut)At[Ut]=8;var Kt=new xt(32);for(Ut=0;Ut<32;++Ut)Kt[Ut]=5;var Wt=Ft(At,9,0),zt=Ft(Kt,5,0),Gt=function(e){return(e/8|0)+(7&e&&1)},Qt=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof Pt?Pt:e instanceof Rt?Rt:xt)(n-t);return r.set(e.subarray(t,n)),r},$t=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},Ht=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},Jt=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,i=n.slice();if(!o)return[new xt(0),0];if(1==o){var s=new xt(n[0].s+1);return s[n[0].s]=1,[s,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],u=n[1],c=0,l=1,d=2;for(n[0]={s:-1,f:a.f+u.f,l:a,r:u};l!=o-1;)a=n[n[c].f<n[d].f?c++:d++],u=n[c!=l&&n[c].f<n[d].f?c++:d++],n[l++]={s:-1,f:a.f+u.f,l:a,r:u};var f=i[0].s;for(r=1;r<o;++r)i[r].s>f&&(f=i[r].s);var v=new Pt(f+1),h=Vt(n[l-1],v,0);if(h>t){r=0;var p=0,g=h-t,y=1<<g;for(i.sort((function(e,t){return v[t.s]-v[e.s]||e.f-t.f}));r<o;++r){var m=i[r].s;if(!(v[m]>t))break;p+=y-(1<<h-v[m]),v[m]=t}for(p>>>=g;p>0;){var b=i[r].s;v[b]<t?p-=1<<t-v[b]++-1:++r}for(;r>=0&&p;--r){var S=i[r].s;v[S]==t&&(--v[S],++p)}h=t}return[new xt(v),h]},Vt=function(e,t,n){return-1==e.s?Math.max(Vt(e.l,t,n+1),Vt(e.r,t,n+1)):t[e.s]=n},Zt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Pt(++t),r=0,o=e[0],i=1,s=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++i;else{if(!o&&i>2){for(;i>138;i-=138)s(32754);i>2&&(s(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(s(o),--i;i>6;i-=6)s(8304);i>2&&(s(i-3<<5|8208),i=0)}for(;i--;)s(o);i=1,o=e[a]}return[n.subarray(0,r),t]},Xt=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},Yt=function(e,t,n){var r=n.length,o=Gt(t+2);e[o]=255&r,e[o+1]=r>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var i=0;i<r;++i)e[o+i+4]=n[i];return 8*(o+4+r)},en=function(e,t,n,r,o,i,s,a,u,c,l){$t(t,l++,n),++o[256];for(var d=Jt(o,15),f=d[0],v=d[1],h=Jt(i,15),p=h[0],g=h[1],y=Zt(f),m=y[0],b=y[1],S=Zt(p),w=S[0],I=S[1],C=new Pt(19),E=0;E<m.length;++E)C[31&m[E]]++;for(E=0;E<w.length;++E)C[31&w[E]]++;for(var k=Jt(C,7),x=k[0],P=k[1],R=19;R>4&&!x[Ot[R-1]];--R);var _,T,O,q,M=c+5<<3,L=Xt(o,At)+Xt(i,Kt)+s,D=Xt(o,f)+Xt(i,p)+s+14+3*R+Xt(C,x)+(2*C[16]+3*C[17]+7*C[18]);if(M<=L&&M<=D)return Yt(t,l,e.subarray(u,u+c));if($t(t,l,1+(D<L)),l+=2,D<L){_=Ft(f,v,0),T=f,O=Ft(p,g,0),q=p;var N=Ft(x,P,0);$t(t,l,b-257),$t(t,l+5,I-1),$t(t,l+10,R-4),l+=14;for(E=0;E<R;++E)$t(t,l+3*E,x[Ot[E]]);l+=3*R;for(var j=[m,w],U=0;U<2;++U){var B=j[U];for(E=0;E<B.length;++E){var F=31&B[E];$t(t,l,N[F]),l+=x[F],F>15&&($t(t,l,B[E]>>>5&127),l+=B[E]>>>12)}}}else _=Wt,T=At,O=zt,q=Kt;for(E=0;E<a;++E)if(r[E]>255){F=r[E]>>>18&31;Ht(t,l,_[F+257]),l+=T[F+257],F>7&&($t(t,l,r[E]>>>23&31),l+=_t[F]);var A=31&r[E];Ht(t,l,O[A]),l+=q[A],A>3&&(Ht(t,l,r[E]>>>5&8191),l+=Tt[A])}else Ht(t,l,_[r[E]]),l+=T[r[E]];return Ht(t,l,_[256]),l+T[256]},tn=new Rt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),nn=function(e,t,n,r,o){return function(e,t,n,r,o,i){var s=e.length,a=new xt(r+s+5*(1+Math.floor(s/7e3))+o),u=a.subarray(r,a.length-o),c=0;if(!t||s<8)for(var l=0;l<=s;l+=65535){var d=l+65535;d<s?c=Yt(u,c,e.subarray(l,d)):(u[l]=i,c=Yt(u,c,e.subarray(l,s)))}else{for(var f=tn[t-1],v=f>>>13,h=8191&f,p=(1<<n)-1,g=new Pt(32768),y=new Pt(p+1),m=Math.ceil(n/3),b=2*m,S=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<b)&p},w=new Rt(25e3),I=new Pt(288),C=new Pt(32),E=0,k=0,x=(l=0,0),P=0,R=0;l<s;++l){var _=S(l),T=32767&l,O=y[_];if(g[T]=O,y[_]=T,P<=l){var q=s-l;if((E>7e3||x>24576)&&q>423){c=en(e,u,0,w,I,C,k,x,R,l-R,c),x=E=k=0,R=l;for(var M=0;M<286;++M)I[M]=0;for(M=0;M<30;++M)C[M]=0}var L=2,D=0,N=h,j=T-O&32767;if(q>2&&_==S(l-j))for(var U=Math.min(v,q)-1,B=Math.min(32767,l),F=Math.min(258,q);j<=B&&--N&&T!=O;){if(e[l+L]==e[l+L-j]){for(var A=0;A<F&&e[l+A]==e[l+A-j];++A);if(A>L){if(L=A,D=j,A>U)break;var K=Math.min(j,A-2),W=0;for(M=0;M<K;++M){var z=l-j+M+32768&32767,G=z-g[z]+32768&32767;G>W&&(W=G,O=z)}}}j+=(T=O)-(O=g[T])+32768&32767}if(D){w[x++]=268435456|Dt[L]<<18|Nt[D];var Q=31&Dt[L],$=31&Nt[D];k+=_t[Q]+Tt[$],++I[257+Q],++C[$],P=l+L,++E}else w[x++]=e[l],++I[e[l]]}}c=en(e,u,i,w,I,C,k,x,R,l-R,c)}return Qt(a,0,r+Gt(c)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!o)};function rn(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,i=n.length,s=0;s!=i;){for(var a=Math.min(s+5552,i);s<a;++s)o+=r+=n[s];r%=65521,o%=65521}e=r,t=o},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r,o,i,s=nn(e,t,2,4);return r=s,o=t.level,i=0==o?0:o<6?1:9==o?3:2,r[0]=120,r[1]=i<<6|(i?32-2*i:1),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(s,s.length-4,n.d()),s}const on=e=>{const t={...e,v:"v1"};return function(e,t){var n="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var r=0;r<e.length;){var o=e[r++];o<128||t?n+=String.fromCharCode(o):o<224?n+=String.fromCharCode((31&o)<<6|63&e[r++]):o<240?n+=String.fromCharCode((15&o)<<12|(63&e[r++])<<6|63&e[r++]):(o=((15&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,n+=String.fromCharCode(55296|o>>10,56320|1023&o))}return n}(rn(function(e,t){var n=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new xt(e.length+(e.length>>>1)),o=0,i=function(e){r[o++]=e},s=0;s<n;++s){if(o+5>r.length){var a=new xt(o+8+(n-s<<1));a.set(r),r=a}var u=e.charCodeAt(s);u<128||t?i(u):u<2048?(i(192|u>>>6),i(128|63&u)):u>55295&&u<57344?(i(240|(u=65536+(1047552&u)|1023&e.charCodeAt(++s))>>>18),i(128|u>>>12&63),i(128|u>>>6&63),i(128|63&u)):(i(224|u>>>12),i(128|u>>>6&63),i(128|63&u))}return Qt(r,0,o)}(JSON.stringify(t))),!0)};var sn=function(){function e(e,t,n,r){var o,i,s,a=this;this.taskQueue=[],this.isProcessing=!1,this.compressEvent=function(e){var t=on(e);return JSON.stringify(t)},this.addCompressedEventToManager=function(e,t){a.eventsManager&&a.deviceId&&a.eventsManager.addEvent({event:{type:"replay",data:e},sessionId:t,deviceId:a.deviceId})},this.addCompressedEvent=function(e,t){if(a.worker)a.worker.postMessage({event:e,sessionId:t});else{var n=a.compressEvent(e);a.addCompressedEventToManager(n,t)}},this.terminate=function(){var e;null===(e=a.worker)||void 0===e||e.terminate()};var u=f();this.canUseIdleCallback=u&&"requestIdleCallback"in u,this.eventsManager=e,this.config=t,this.deviceId=n,this.timeout=(null===(o=t.performanceConfig)||void 0===o?void 0:o.timeout)||2e3;var c=null!==(i='var WebWorker=function(r){"use strict";var n=Uint8Array,e=Uint16Array,f=Uint32Array,t=new n([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),o=new n([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),a=new n([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),i=function(r,n){for(var t=new e(31),o=0;o<31;++o)t[o]=n+=1<<r[o-1];var a=new f(t[30]);for(o=1;o<30;++o)for(var i=t[o];i<t[o+1];++i)a[i]=i-t[o]<<5|o;return[t,a]},v=i(t,2),u=v[0],s=v[1];u[28]=258,s[258]=28;for(var l=i(o,0)[1],c=new e(32768),h=0;h<32768;++h){var g=(43690&h)>>>1|(21845&h)<<1;g=(61680&(g=(52428&g)>>>2|(13107&g)<<2))>>>4|(3855&g)<<4,c[h]=((65280&g)>>>8|(255&g)<<8)>>>1}var w=function(r,n,f){for(var t=r.length,o=0,a=new e(n);o<t;++o)++a[r[o]-1];var i,v=new e(n);for(o=0;o<n;++o)v[o]=v[o-1]+a[o-1]<<1;if(f){i=new e(1<<n);var u=15-n;for(o=0;o<t;++o)if(r[o])for(var s=o<<4|r[o],l=n-r[o],h=v[r[o]-1]++<<l,g=h|(1<<l)-1;h<=g;++h)i[c[h]>>>u]=s}else for(i=new e(t),o=0;o<t;++o)i[o]=c[v[r[o]-1]++]>>>15-r[o];return i},d=new n(288);for(h=0;h<144;++h)d[h]=8;for(h=144;h<256;++h)d[h]=9;for(h=256;h<280;++h)d[h]=7;for(h=280;h<288;++h)d[h]=8;var m=new n(32);for(h=0;h<32;++h)m[h]=5;var M=w(d,9,0),y=w(m,5,0),b=function(r){return(r/8|0)+(7&r&&1)},p=function(r,t,o){(null==o||o>r.length)&&(o=r.length);var a=new(r instanceof e?e:r instanceof f?f:n)(o-t);return a.set(r.subarray(t,o)),a},C=function(r,n,e){e<<=7&n;var f=n/8|0;r[f]|=e,r[f+1]|=e>>>8},x=function(r,n,e){e<<=7&n;var f=n/8|0;r[f]|=e,r[f+1]|=e>>>8,r[f+2]|=e>>>16},S=function(r,f){for(var t=[],o=0;o<r.length;++o)r[o]&&t.push({s:o,f:r[o]});var a=t.length,i=t.slice();if(!a)return[new n(0),0];if(1==a){var v=new n(t[0].s+1);return v[t[0].s]=1,[v,1]}t.sort((function(r,n){return r.f-n.f})),t.push({s:-1,f:25001});var u=t[0],s=t[1],l=0,c=1,h=2;for(t[0]={s:-1,f:u.f+s.f,l:u,r:s};c!=a-1;)u=t[t[l].f<t[h].f?l++:h++],s=t[l!=c&&t[l].f<t[h].f?l++:h++],t[c++]={s:-1,f:u.f+s.f,l:u,r:s};var g=i[0].s;for(o=1;o<a;++o)i[o].s>g&&(g=i[o].s);var w=new e(g+1),d=A(t[c-1],w,0);if(d>f){o=0;var m=0,M=d-f,y=1<<M;for(i.sort((function(r,n){return w[n.s]-w[r.s]||r.f-n.f}));o<a;++o){var b=i[o].s;if(!(w[b]>f))break;m+=y-(1<<d-w[b]),w[b]=f}for(m>>>=M;m>0;){var p=i[o].s;w[p]<f?m-=1<<f-w[p]++-1:++o}for(;o>=0&&m;--o){var C=i[o].s;w[C]==f&&(--w[C],++m)}d=f}return[new n(w),d]},A=function(r,n,e){return-1==r.s?Math.max(A(r.l,n,e+1),A(r.r,n,e+1)):n[r.s]=e},O=function(r){for(var n=r.length;n&&!r[--n];);for(var f=new e(++n),t=0,o=r[0],a=1,i=function(r){f[t++]=r},v=1;v<=n;++v)if(r[v]==o&&v!=n)++a;else{if(!o&&a>2){for(;a>138;a-=138)i(32754);a>2&&(i(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(i(o),--a;a>6;a-=6)i(8304);a>2&&(i(a-3<<5|8208),a=0)}for(;a--;)i(o);a=1,o=r[v]}return[f.subarray(0,t),n]},T=function(r,n){for(var e=0,f=0;f<n.length;++f)e+=r[f]*n[f];return e},k=function(r,n,e){var f=e.length,t=b(n+2);r[t]=255&f,r[t+1]=f>>>8,r[t+2]=255^r[t],r[t+3]=255^r[t+1];for(var o=0;o<f;++o)r[t+o+4]=e[o];return 8*(t+4+f)},E=function(r,n,f,i,v,u,s,l,c,h,g){C(n,g++,f),++v[256];for(var b=S(v,15),p=b[0],A=b[1],E=S(u,15),U=E[0],D=E[1],I=O(p),J=I[0],N=I[1],W=O(U),_=W[0],j=W[1],P=new e(19),q=0;q<J.length;++q)P[31&J[q]]++;for(q=0;q<_.length;++q)P[31&_[q]]++;for(var z=S(P,7),B=z[0],F=z[1],G=19;G>4&&!B[a[G-1]];--G);var H,K,L,Q,R=h+5<<3,V=T(v,d)+T(u,m)+s,X=T(v,p)+T(u,U)+s+14+3*G+T(P,B)+(2*P[16]+3*P[17]+7*P[18]);if(R<=V&&R<=X)return k(n,g,r.subarray(c,c+h));if(C(n,g,1+(X<V)),g+=2,X<V){H=w(p,A,0),K=p,L=w(U,D,0),Q=U;var Y=w(B,F,0);C(n,g,N-257),C(n,g+5,j-1),C(n,g+10,G-4),g+=14;for(q=0;q<G;++q)C(n,g+3*q,B[a[q]]);g+=3*G;for(var Z=[J,_],$=0;$<2;++$){var rr=Z[$];for(q=0;q<rr.length;++q){var nr=31&rr[q];C(n,g,Y[nr]),g+=B[nr],nr>15&&(C(n,g,rr[q]>>>5&127),g+=rr[q]>>>12)}}}else H=M,K=d,L=y,Q=m;for(q=0;q<l;++q)if(i[q]>255){nr=i[q]>>>18&31;x(n,g,H[nr+257]),g+=K[nr+257],nr>7&&(C(n,g,i[q]>>>23&31),g+=t[nr]);var er=31&i[q];x(n,g,L[er]),g+=Q[er],er>3&&(x(n,g,i[q]>>>5&8191),g+=o[er])}else x(n,g,H[i[q]]),g+=K[i[q]];return x(n,g,H[256]),g+K[256]},U=new f([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),D=function(r,a,i,v,u){return function(r,a,i,v,u,c){var h=r.length,g=new n(v+h+5*(1+Math.floor(h/7e3))+u),w=g.subarray(v,g.length-u),d=0;if(!a||h<8)for(var m=0;m<=h;m+=65535){var M=m+65535;M<h?d=k(w,d,r.subarray(m,M)):(w[m]=c,d=k(w,d,r.subarray(m,h)))}else{for(var y=U[a-1],C=y>>>13,x=8191&y,S=(1<<i)-1,A=new e(32768),O=new e(S+1),T=Math.ceil(i/3),D=2*T,I=function(n){return(r[n]^r[n+1]<<T^r[n+2]<<D)&S},J=new f(25e3),N=new e(288),W=new e(32),_=0,j=0,P=(m=0,0),q=0,z=0;m<h;++m){var B=I(m),F=32767&m,G=O[B];if(A[F]=G,O[B]=F,q<=m){var H=h-m;if((_>7e3||P>24576)&&H>423){d=E(r,w,0,J,N,W,j,P,z,m-z,d),P=_=j=0,z=m;for(var K=0;K<286;++K)N[K]=0;for(K=0;K<30;++K)W[K]=0}var L=2,Q=0,R=x,V=F-G&32767;if(H>2&&B==I(m-V))for(var X=Math.min(C,H)-1,Y=Math.min(32767,m),Z=Math.min(258,H);V<=Y&&--R&&F!=G;){if(r[m+L]==r[m+L-V]){for(var $=0;$<Z&&r[m+$]==r[m+$-V];++$);if($>L){if(L=$,Q=V,$>X)break;var rr=Math.min(V,$-2),nr=0;for(K=0;K<rr;++K){var er=m-V+K+32768&32767,fr=er-A[er]+32768&32767;fr>nr&&(nr=fr,G=er)}}}V+=(F=G)-(G=A[F])+32768&32767}if(Q){J[P++]=268435456|s[L]<<18|l[Q];var tr=31&s[L],or=31&l[Q];j+=t[tr]+o[or],++N[257+tr],++W[or],q=m+L,++_}else J[P++]=r[m],++N[r[m]]}}d=E(r,w,c,J,N,W,j,P,z,m-z,d)}return p(g,0,v+b(d)+u)}(r,null==a.level?6:a.level,null==a.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+a.mem,i,v,!u)};function I(r,n){void 0===n&&(n={});var e=function(){var r=1,n=0;return{p:function(e){for(var f=r,t=n,o=e.length,a=0;a!=o;){for(var i=Math.min(a+5552,o);a<i;++a)t+=f+=e[a];f%=65521,t%=65521}r=f,n=t},d:function(){return(r>>>8<<16|(255&n)<<8|n>>>8)+2*((255&r)<<23)}}}();e.p(r);var f,t,o,a=D(r,n,2,4);return f=a,t=n.level,o=0==t?0:t<6?1:9==t?3:2,f[0]=120,f[1]=o<<6|(o?32-2*o:1),function(r,n,e){for(;e;++n)r[n]=e,e>>>=8}(a,a.length-4,e.d()),a}const J=r=>{const e={...r,v:"v1"};return function(r,n){var e="";if(!n&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(r);for(var f=0;f<r.length;){var t=r[f++];t<128||n?e+=String.fromCharCode(t):t<224?e+=String.fromCharCode((31&t)<<6|63&r[f++]):t<240?e+=String.fromCharCode((15&t)<<12|(63&r[f++])<<6|63&r[f++]):(t=((15&t)<<18|(63&r[f++])<<12|(63&r[f++])<<6|63&r[f++])-65536,e+=String.fromCharCode(55296|t>>10,56320|1023&t))}return e}(I(function(r,e){var f=r.length;if(!e&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(r);for(var t=new n(r.length+(r.length>>>1)),o=0,a=function(r){t[o++]=r},i=0;i<f;++i){if(o+5>t.length){var v=new n(o+8+(f-i<<1));v.set(t),t=v}var u=r.charCodeAt(i);u<128||e?a(u):u<2048?(a(192|u>>>6),a(128|63&u)):u>55295&&u<57344?(a(240|(u=65536+(1047552&u)|1023&r.charCodeAt(++i))>>>18),a(128|u>>>12&63),a(128|u>>>6&63),a(128|63&u)):(a(224|u>>>12),a(128|u>>>6&63),a(128|63&u))}return p(t,0,o)}(JSON.stringify(e))),!0)};onmessage=r=>{const{event:n,sessionId:e}=r.data,f=JSON.stringify(J(n));postMessage({compressedEvent:f,sessionId:e})};const N=onmessage;return r.compressionOnMessage=N,Object.defineProperty(r,"__esModule",{value:!0}),r}({});\n')?i:r;if((null===(s=this.config.experimental)||void 0===s?void 0:s.useWebWorker)&&u&&u.Worker&&c){t.loggerProvider.log("[Experimental] Enabling web worker for compression");var l=new Worker(URL.createObjectURL(new Blob([c],{type:"application/javascript"})));l.onerror=function(e){t.loggerProvider.error(e)},l.onmessage=function(e){var t=e.data,n=t.compressedEvent,r=t.sessionId;a.addCompressedEventToManager(n,r)},this.worker=l}}return e.prototype.scheduleIdleProcessing=function(){var e=this;this.isProcessing||(this.isProcessing=!0,requestIdleCallback((function(t){e.processQueue(t)}),{timeout:this.timeout}))},e.prototype.enqueueEvent=function(e,t){var n;this.canUseIdleCallback&&(null===(n=this.config.performanceConfig)||void 0===n?void 0:n.enabled)?(this.config.loggerProvider.debug("Enqueuing event for processing during idle time."),this.taskQueue.push({event:e,sessionId:t}),this.scheduleIdleProcessing()):(this.config.loggerProvider.debug("Processing event without idle callback."),this.addCompressedEvent(e,t))},e.prototype.processQueue=function(e){for(var t=this;this.taskQueue.length>0&&(e.timeRemaining()>0||e.didTimeout);){var n=this.taskQueue.shift();if(n){var r=n.event,o=n.sessionId;this.addCompressedEvent(r,o)}}this.taskQueue.length>0?requestIdleCallback((function(e){t.processQueue(e)}),{timeout:this.timeout}):this.isProcessing=!1},e}(),an=function(){function e(){var e=this;this.name="@amplitude/session-replay-browser",this.recordCancelCallback=null,this.eventCount=0,this.pageLeaveFns=[],this.recordFunction=null,this.teardownEventListeners=function(t){var n=f();n&&(n.removeEventListener("blur",e.blurListener),n.removeEventListener("focus",e.focusListener),!t&&n.addEventListener("blur",e.blurListener),!t&&n.addEventListener("focus",e.focusListener),n.self&&"onpagehide"in n.self?(n.removeEventListener("pagehide",e.pageLeaveListener),!t&&n.addEventListener("pagehide",e.pageLeaveListener)):(n.removeEventListener("beforeunload",e.pageLeaveListener),!t&&n.addEventListener("beforeunload",e.pageLeaveListener)))},this.blurListener=function(){e.sendEvents()},this.focusListener=function(){e.recordEvents(!1)},this.pageLeaveListener=function(t){e.pageLeaveFns.forEach((function(e){e(t)}))},this.addCustomRRWebEvent=function(t,i,s){return void 0===i&&(i={}),void 0===s&&(s=!0),r(e,void 0,void 0,(function(){var e,r,a,u;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),e=void 0,(r=this.config)&&t!==L.METADATA?(e={config:V(r),version:ce},s?[4,J()]:[3,2]):[3,2];case 1:a=o.sent(),e=n(n({},a),e),o.label=2;case 2:return this.recordCancelCallback&&this.recordFunction?this.recordFunction.addCustomEvent(t,n(n({},i),e)):this.loggerProvider.debug("Not able to add custom replay capture event ".concat(t," due to no ongoing recording.")),[3,4];case 3:return u=o.sent(),this.loggerProvider.debug("Error while adding custom replay capture event: ",u),[3,4];case 4:return[2]}}))}))},this.stopRecordingEvents=function(){var t;try{e.loggerProvider.log("Session Replay capture stopping."),e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null,null===(t=e.networkObservers)||void 0===t||t.stop()}catch(t){var n=t;e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(n.toString()))}},this.loggerProvider=new F(new p)}return e.prototype.init=function(e,t){return v(this._init(e,t))},e.prototype._init=function(e,t){var n,i,u,c,l,d;return r(this,void 0,void 0,(function(){var r,v,h,g,y,m,b,S,w,I,C,E,k,x;return o(this,(function(o){switch(o.label){case 0:return this.loggerProvider=new F(t.loggerProvider||new p),Object.prototype.hasOwnProperty.call(t,"logLevel")&&this.loggerProvider.enable(t.logLevel),this.identifiers=new kt({sessionId:t.sessionId,deviceId:t.deviceId}),r=this,[4,ae(e,t)];case 1:return r.joinedConfigGenerator=o.sent(),[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)];case 2:v=o.sent(),h=v.joinedConfig,g=v.localConfig,y=v.remoteConfig,this.config=h,this.setMetadata(t.sessionId,h,g,y,null===(n=t.version)||void 0===n?void 0:n.version,ce,null===(i=t.version)||void 0===i?void 0:i.type),t.sessionId&&(null===(u=this.config.interactionConfig)||void 0===u?void 0:u.enabled)&&(m=Et.default({sessionId:t.sessionId,type:"interaction"},this.config),this.pageLeaveFns=[m.send(this.getDeviceId.bind(this)).bind(m)],this.scrollHook=m.hook.bind(m)),b=[],"idb"!==(S=this.config.storeType)||(null===(c=f())||void 0===c?void 0:c.indexedDB)||(S="memory",this.loggerProvider.warn("Could not use preferred indexedDB storage, reverting to in memory option.")),this.loggerProvider.log("Using ".concat(S," for event storage.")),o.label=3;case 3:return o.trys.push([3,5,,6]),[4,Ge({config:this.config,sessionId:this.identifiers.sessionId,type:"replay",storeType:S})];case 4:return w=o.sent(),b.push({name:"replay",manager:w}),[3,6];case 5:return I=o.sent(),x=I,this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(x.toString())),[3,6];case 6:if(!(null===(l=this.config.interactionConfig)||void 0===l?void 0:l.enabled))return[3,10];C=this.config.interactionConfig.batch?wt:St,o.label=7;case 7:return o.trys.push([7,9,,10]),[4,Ge({config:this.config,sessionId:this.identifiers.sessionId,type:"interaction",minInterval:null!==(d=this.config.interactionConfig.trackEveryNms)&&void 0!==d?d:3e4,maxInterval:6e4,payloadBatcher:C,storeType:S})];case 8:return E=o.sent(),b.push({name:"interaction",manager:E}),[3,10];case 9:return k=o.sent(),x=k,this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(x.toString())),[3,10];case 10:return this.eventsManager=new(Qe.bind.apply(Qe,a([void 0],s(b),!1))),this.eventCompressor&&this.eventCompressor.terminate(),this.eventCompressor=new sn(this.eventsManager,this.config,this.getDeviceId()),[4,this.initializeNetworkObservers()];case 11:return o.sent(),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),this.teardownEventListeners(!1),this.initialize(!0),[2]}}))}))},e.prototype.setSessionId=function(e,t){return v(this.asyncSetSessionId(e,t))},e.prototype.asyncSetSessionId=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return(n=this.identifiers&&this.identifiers.sessionId)&&this.sendEvents(n),r=t||this.getDeviceId(),this.identifiers=new kt({sessionId:e,deviceId:r}),this.joinedConfigGenerator&&n?[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)]:[3,2];case 1:i=o.sent().joinedConfig,this.config=i,o.label=2;case 2:return this.recordEvents(),[2]}}))}))},e.prototype.getSessionReplayProperties=function(){var e,t=this.config,n=this.identifiers;if(!t||!n)return this.loggerProvider.warn("Session replay init has not been called, cannot get session replay properties."),{};var r=this.getShouldRecord(),o={};return r&&((e={})[N]=n.sessionReplayId?n.sessionReplayId:null,o=e,t.debugMode&&(o[U]=JSON.stringify({appHash:Q(t.apiKey).toString()}))),this.addCustomRRWebEvent(L.GET_SR_PROPS,{shouldRecord:r,eventProperties:o},10===this.eventCount),10===this.eventCount&&(this.eventCount=0),this.eventCount++,o},e.prototype.sendEvents=function(e){var t,n=e||(null===(t=this.identifiers)||void 0===t?void 0:t.sessionId),r=this.getDeviceId();this.eventsManager&&n&&r&&this.eventsManager.sendCurrentSequenceEvents({sessionId:n,deviceId:r})},e.prototype.initialize=function(e){var t;return void 0===e&&(e=!1),r(this,void 0,void 0,(function(){var n;return o(this,(function(r){return(null===(t=this.identifiers)||void 0===t?void 0:t.sessionId)?(n=this.getDeviceId())?(this.eventsManager&&e&&this.eventsManager.sendStoredEvents({deviceId:n}),[2,this.recordEvents()]):(this.loggerProvider.log("Session is not being recorded due to lack of device id."),[2,Promise.resolve()]):(this.loggerProvider.log("Session is not being recorded due to lack of session id."),[2,Promise.resolve()])}))}))},e.prototype.shouldOptOut=function(){var e,t,n,r;(null===(e=this.config)||void 0===e?void 0:e.instanceName)&&(n=(r=this.config.instanceName,void 0===r&&(r="$default_instance"),T.getInstance(r)).identityStore.getIdentity().optOut);return void 0!==n?n:null===(t=this.config)||void 0===t?void 0:t.optOut},e.prototype.getShouldRecord=function(){if(!this.identifiers||!this.config||!this.identifiers.sessionId)return this.loggerProvider.warn("Session is not being recorded due to lack of config, please call sessionReplay.init."),!1;if(!this.config.captureEnabled)return this.loggerProvider.log("Session ".concat(this.identifiers.sessionId," not being captured due to capture being disabled for project or because the remote config could not be fetched.")),!1;if(this.shouldOptOut())return this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to optOut config.")),!1;var e,t,n,r=(e=this.identifiers.sessionId,t=this.config.sampleRate,n=Q(e.toString()),31*Math.abs(n)%1e6/1e6<t);return r||this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate.")),r},e.prototype.getBlockSelectors=function(){var e,t,n,r=null!==(n=null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.blockSelector)&&void 0!==n?n:[];if(0!==r.length)return r},e.prototype.getMaskTextSelectors=function(){var e,t,n,r;if("conservative"===(null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.defaultMaskLevel))return"*";var o=null===(r=null===(n=this.config)||void 0===n?void 0:n.privacyConfig)||void 0===r?void 0:r.maskSelector;return o||void 0},e.prototype.getRecordingPlugins=function(e){var t;return r(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:if(n=[],!(null===(t=null==e?void 0:e.console)||void 0===t?void 0:t.enabled))return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,import("./console-plugin-min.js")];case 2:return r=o.sent().getRecordConsolePlugin,n.push(r({level:e.console.levels})),[3,4];case 3:return i=o.sent(),this.loggerProvider.warn("Failed to load console plugin:",i),[3,4];case 4:return[2,n.length>0?n:void 0]}}))}))},e.prototype.getRecordFunction=function(){return r(this,void 0,void 0,(function(){var e,t;return o(this,(function(n){switch(n.label){case 0:if(this.recordFunction)return[2,this.recordFunction];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,import("./rrweb-record-min.js")];case 2:return e=n.sent().record,this.recordFunction=e,[2,e];case 3:return t=n.sent(),this.loggerProvider.warn("Failed to load rrweb-record module:",t),[2,null];case 4:return[2]}}))}))},e.prototype.recordEvents=function(e){var t,n,i;return void 0===e&&(e=!0),r(this,void 0,void 0,(function(){var r,s,a,u,c,l,d,f,v,h,p,g,y,m=this;return o(this,(function(o){switch(o.label){case 0:return r=this.config,s=this.getShouldRecord(),a=null===(t=this.identifiers)||void 0===t?void 0:t.sessionId,s&&a&&r?(this.stopRecordingEvents(),[4,this.getRecordFunction()]):[2];case 1:return(u=o.sent())?[4,this.initializeNetworkObservers()]:[2];case 2:o.sent(),null===(n=this.networkObservers)||void 0===n||n.start((function(e){m.addCustomRRWebEvent(L.FETCH_REQUEST,e)})),c=r.privacyConfig,l=r.interactionConfig,d=r.loggingConfig,f=(null==l?void 0:l.enabled)?{mouseInteraction:this.eventsManager&&It(this.loggerProvider,{eventsManager:this.eventsManager,sessionId:a,deviceIdFn:this.getDeviceId.bind(this),mirror:u.mirror,ugcFilterRules:null!==(i=l.ugcFilterRules)&&void 0!==i?i:[]}),scroll:this.scrollHook}:{},v=(null==l?void 0:l.enabled)&&l.ugcFilterRules?l.ugcFilterRules:[],this.loggerProvider.log("Session Replay capture beginning for ".concat(a,".")),o.label=3;case 3:return o.trys.push([3,5,,6]),h=this,p=u,y={emit:function(e){if(m.shouldOptOut())return m.loggerProvider.log("Opting session ".concat(a," out of recording due to optOut config.")),m.stopRecordingEvents(),void m.sendEvents();e.type===Y.Meta&&(e.data.href=H(e.data.href,v)),m.eventCompressor&&m.eventCompressor.enqueueEvent(e,a)},inlineStylesheet:r.shouldInlineStylesheet,hooks:f,maskAllInputs:!0,maskTextClass:B,blockClass:"amp-block",blockSelector:this.getBlockSelectors(),applyBackgroundColorToBlockedElements:r.applyBackgroundColorToBlockedElements,maskInputFn:G("input",c),maskTextFn:G("text",c),maskTextSelector:this.getMaskTextSelectors(),recordCanvas:!1,errorHandler:function(e){var t=e;if(t.message.includes("insertRule")&&t.message.includes("CSSStyleSheet"))throw t;if(t._external_)throw t;return m.loggerProvider.warn("Error while capturing replay: ",t.toString()),!0}},[4,this.getRecordingPlugins(d)];case 4:return h.recordCancelCallback=p.apply(void 0,[(y.plugins=o.sent(),y)]),this.addCustomRRWebEvent(L.DEBUG_INFO),e&&this.addCustomRRWebEvent(L.METADATA,this.metadata),[3,6];case 5:return g=o.sent(),this.loggerProvider.warn("Failed to initialize session replay:",g),[3,6];case 6:return[2]}}))}))},e.prototype.getDeviceId=function(){var e;return null===(e=this.identifiers)||void 0===e?void 0:e.deviceId},e.prototype.getSessionId=function(){var e;return null===(e=this.identifiers)||void 0===e?void 0:e.sessionId},e.prototype.flush=function(e){var t;return void 0===e&&(e=!1),r(this,void 0,void 0,(function(){return o(this,(function(n){return[2,null===(t=this.eventsManager)||void 0===t?void 0:t.flush(e)]}))}))},e.prototype.shutdown=function(){this.teardownEventListeners(!0),this.stopRecordingEvents(),this.sendEvents()},e.prototype.mapSDKType=function(e){return"plugin"===e?"@amplitude/plugin-session-replay-browser":"segment"===e?"@amplitude/segment-session-replay-plugin":null},e.prototype.setMetadata=function(e,t,n,r,o,i,s){var a=(null==e?void 0:e.toString())?Q(e.toString()):void 0;this.metadata={joinedConfig:t,localConfig:n,remoteConfig:r,sessionId:e,hashValue:a,sampleRate:t.sampleRate,replaySDKType:this.mapSDKType(s),replaySDKVersion:o,standaloneSDKType:"@amplitude/session-replay-browser",standaloneSDKVersion:i}},e.prototype.initializeNetworkObservers=function(){var e,t,n;return r(this,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:if(!(null===(n=null===(t=null===(e=this.config)||void 0===e?void 0:e.loggingConfig)||void 0===t?void 0:t.network)||void 0===n?void 0:n.enabled)||this.networkObservers)return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,import("./observers-min.js")];case 2:return r=o.sent().NetworkObservers,this.networkObservers=new r,[3,4];case 3:return i=o.sent(),this.loggerProvider.warn("Failed to import or instantiate NetworkObservers:",i),[3,4];case 4:return[2]}}))}))},e}(),un=function(e){return function(){var t=e.config||Z();return{logger:t.loggerProvider,logLevel:t.logLevel}}},cn=function(){var e=new an;return{init:O(e.init.bind(e),"init",un(e)),setSessionId:O(e.setSessionId.bind(e),"setSessionId",un(e)),getSessionId:O(e.getSessionId.bind(e),"getSessionId",un(e)),getSessionReplayProperties:O(e.getSessionReplayProperties.bind(e),"getSessionReplayProperties",un(e)),flush:O(e.flush.bind(e),"flush",un(e)),shutdown:O(e.shutdown.bind(e),"shutdown",un(e))}}(),ln=cn.init,dn=cn.setSessionId,fn=cn.getSessionId,vn=cn.getSessionReplayProperties,hn=cn.flush,pn=cn.shutdown;const gn="1.19.2";class yn{constructor(e){this.name=yn.pluginName,this.type="enrichment",this.sessionReplay={flush:hn,getSessionId:fn,getSessionReplayProperties:vn,init:ln,setSessionId:dn,shutdown:pn},this.options=Object.assign({forceSessionTracking:!1},e),this.srInitOptions=this.options}setup(e,t){var n,o,i,s,a;return r(this,void 0,void 0,(function*(){try{null==e||e.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${gn}.`),this.config=e,this.options.forceSessionTracking&&("boolean"==typeof e.defaultTracking?!1===e.defaultTracking&&(e.defaultTracking={pageViews:!1,formInteractions:!1,fileDownloads:!1,sessions:!0}):e.defaultTracking=Object.assign(Object.assign({},e.defaultTracking),{sessions:!0})),this.srInitOptions={instanceName:this.config.instanceName,deviceId:null!==(n=this.options.deviceId)&&void 0!==n?n:this.config.deviceId,optOut:this.config.optOut,sessionId:this.options.customSessionId?void 0:this.config.sessionId,loggerProvider:this.config.loggerProvider,logLevel:this.config.logLevel,flushMaxRetries:this.config.flushMaxRetries,serverZone:this.config.serverZone,configServerUrl:this.options.configServerUrl,trackServerUrl:this.options.trackServerUrl,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:null===(o=this.options.privacyConfig)||void 0===o?void 0:o.blockSelector,maskSelector:null===(i=this.options.privacyConfig)||void 0===i?void 0:i.maskSelector,unmaskSelector:null===(s=this.options.privacyConfig)||void 0===s?void 0:s.unmaskSelector,defaultMaskLevel:null===(a=this.options.privacyConfig)||void 0===a?void 0:a.defaultMaskLevel},debugMode:this.options.debugMode,shouldInlineStylesheet:this.options.shouldInlineStylesheet,version:{type:"plugin",version:gn},performanceConfig:this.options.performanceConfig,storeType:this.options.storeType,experimental:this.options.experimental,applyBackgroundColorToBlockedElements:this.options.applyBackgroundColorToBlockedElements,interactionConfig:this.options.interactionConfig},yield this.sessionReplay.init(e.apiKey,this.srInitOptions).promise}catch(t){null==e||e.loggerProvider.error(`Session Replay: Failed to initialize due to ${t.message}`)}}))}onSessionIdChanged(e){return r(this,void 0,void 0,(function*(){this.config.loggerProvider.debug(`Analytics session id is changed to ${e}, SR session id is ${String(this.sessionReplay.getSessionId())}.`),yield this.sessionReplay.setSessionId(e).promise}))}onOptOutChanged(e){return r(this,void 0,void 0,(function*(){this.config.loggerProvider.debug(`optOut is changed to ${String(e)}, calling ${e?"sessionReplay.shutdown()":"sessionReplay.init()"}.`),e?this.sessionReplay.shutdown():yield this.sessionReplay.init(this.config.apiKey,this.srInitOptions).promise}))}execute(e){var t;return r(this,void 0,void 0,(function*(){try{if(this.options.customSessionId){const t=this.options.customSessionId(e);if(t){t!==this.sessionReplay.getSessionId()&&(yield this.sessionReplay.setSessionId(t).promise);const n=this.sessionReplay.getSessionReplayProperties();e.event_properties=Object.assign(Object.assign({},e.event_properties),n)}}else{const t=this.config.sessionId;if(t&&t!==this.sessionReplay.getSessionId()&&(yield this.sessionReplay.setSessionId(t).promise),t&&t===e.session_id){const t=this.sessionReplay.getSessionReplayProperties();e.event_properties=Object.assign(Object.assign({},e.event_properties),t)}}return Promise.resolve(e)}catch(n){return null===(t=this.config)||void 0===t||t.loggerProvider.error(`Session Replay: Failed to enrich event due to ${n.message}`),Promise.resolve(e)}}))}teardown(){var e;return r(this,void 0,void 0,(function*(){try{this.sessionReplay.shutdown(),this.config=null}catch(t){null===(e=this.config)||void 0===e||e.loggerProvider.error(`Session Replay: teardown failed due to ${t.message}`)}}))}getSessionReplayProperties(){return this.sessionReplay.getSessionReplayProperties()}}yn.pluginName="@amplitude/plugin-session-replay-browser";const mn=e=>new yn(e);export{yn as S,r as _,o as a,f as g,mn as s};
|
|
1
|
+
var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function i(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function a(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var u,c="".concat("AMP","_unsent"),l="https://api2.amplitude.com/2/httpapi";!function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(u||(u={}));var d,f=function(){var e="ampIntegrationContext";return"undefined"!=typeof globalThis&&void 0!==globalThis[e]?globalThis[e]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},v=function(e){return{promise:e||Promise.resolve()}};!function(e){e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warn=2]="Warn",e[e.Verbose=3]="Verbose",e[e.Debug=4]="Debug"}(d||(d={}));var h="Amplitude Logger ",p=function(){function e(){this.logLevel=d.None}return e.prototype.disable=function(){this.logLevel=d.None},e.prototype.enable=function(e){void 0===e&&(e=d.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<d.Verbose||console.log("".concat(h,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<d.Warn||console.warn("".concat(h,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<d.Error||console.error("".concat(h,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<d.Debug||console.log("".concat(h,"[Debug]: ").concat(e.join(" ")))},e}(),g=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:"$default_instance",logLevel:d.Warn,loggerProvider:new p,offline:!1,optOut:!1,serverUrl:l,serverZone:"US",useBatch:!1}},y=function(){function e(e){var t,n,r,o;this._optOut=!1;var i=g();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:i.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||i.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||i.flushQueueSize,this.instanceName=e.instanceName||i.instanceName,this.loggerProvider=e.loggerProvider||i.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:i.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=void 0!==e.offline?e.offline:i.offline,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:i.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||i.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(o=e.useBatch)&&void 0!==o?o:i.useBatch,this.loggerProvider.enable(this.logLevel);var s=b(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=s.serverZone,this.serverUrl=s.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),m=function(e,t){return"EU"===e?t?"https://api.eu.amplitude.com/batch":"https://api.eu.amplitude.com/2/httpapi":t?"https://api2.amplitude.com/batch":l},b=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=g().serverZone),void 0===n&&(n=g().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:g().serverZone;return{serverZone:r,serverUrl:m(r,n)}},S=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:w(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),w=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},I=function(){function e(){this.queue=[]}return e.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},e.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach((function(t){e(t)})),this.queue=[])},e}(),C=function(){return C=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},C.apply(this,arguments)};function E(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function k(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}"function"==typeof SuppressedError&&SuppressedError;var x=function(e,t){var n,r,o=typeof e;if(o!==typeof t)return!1;try{for(var i=E(["string","number","boolean","undefined"]),s=i.next();!s.done;s=i.next()){if(s.value===o)return e===t}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var a=Array.isArray(e),u=Array.isArray(t);if(a!==u)return!1;if(!a||!u){var c=Object.keys(e).sort(),l=Object.keys(t).sort();if(!x(c,l))return!1;var d=!0;return Object.keys(e).forEach((function(n){x(e[n],t[n])||(d=!1)})),d}for(var f=0;f<e.length;f++)if(!x(e[f],t[f]))return!1;return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var P,R=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=C({},this.identity.userProperties),n=C(C({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){var t,r,o,i,s,a,u=n.userProperties||{};try{for(var c=E(Object.entries(e)),l=c.next();!l.done;l=c.next()){var d=k(l.value,2),f=d[0],v=d[1];switch(f){case"$set":try{for(var h=(o=void 0,E(Object.entries(v))),p=h.next();!p.done;p=h.next()){var g=k(p.value,2),y=g[0],m=g[1];u[y]=m}}catch(e){o={error:e}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(o)throw o.error}}break;case"$unset":try{for(var b=(s=void 0,E(Object.keys(v))),S=b.next();!S.done;S=b.next()){delete u[y=S.value]}}catch(e){s={error:e}}finally{try{S&&!S.done&&(a=b.return)&&a.call(b)}finally{if(s)throw s.error}}break;case"$clearAll":u={}}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}return n.userProperties=u,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return C({},this.identity)},e.prototype.setIdentity=function(e){var t=C({},this.identity);this.identity=C({},e),x(t,this.identity)||this.listeners.forEach((function(t){t(e)}))},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),_="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,T=function(){function e(){this.identityStore=new R,this.eventBridge=new I,this.applicationContextProvider=new S}return e.getInstance=function(t){return _.analyticsConnectorInstances||(_.analyticsConnectorInstances={}),_.analyticsConnectorInstances[t]||(_.analyticsConnectorInstances[t]=new e),_.analyticsConnectorInstances[t]},e}(),O=function(e,t,n,r,o){return void 0===o&&(o=null),function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];var a=n(),u=a.logger,c=a.logLevel;if(c&&c<d.Debug||!c||!u)return e.apply(o,i);var l,f={type:"invoke public method",name:t,args:i,stacktrace:(l=1,void 0===l&&(l=0),((new Error).stack||"").split("\n").slice(2+l).map((function(e){return e.trim()}))),time:{start:(new Date).toISOString()},states:{}};r&&f.states&&(f.states.before=r());var v=e.apply(o,i);return v&&v.promise?v.promise.then((function(){r&&f.states&&(f.states.after=r()),f.time&&(f.time.end=(new Date).toISOString()),u.debug(JSON.stringify(f,null,2))})):(r&&f.states&&(f.states.after=r()),f.time&&(f.time.end=(new Date).toISOString()),u.debug(JSON.stringify(f,null,2))),v}},q=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,o,i,s,a,c,l,d,f,v,h,p,g,y,m,b,S,w,I,C;if("object"!=typeof e)return null;var E=e.code||0,k=this.buildStatus(E);switch(k){case u.Success:return{status:k,statusCode:E,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case u.Invalid:return{status:k,statusCode:E,body:{error:null!==(o=e.error)&&void 0!==o?o:"",missingField:null!==(i=e.missing_field)&&void 0!==i?i:"",eventsWithInvalidFields:null!==(s=e.events_with_invalid_fields)&&void 0!==s?s:{},eventsWithMissingFields:null!==(a=e.events_with_missing_fields)&&void 0!==a?a:{},eventsWithInvalidIdLengths:null!==(c=e.events_with_invalid_id_lengths)&&void 0!==c?c:{},epsThreshold:null!==(l=e.eps_threshold)&&void 0!==l?l:0,exceededDailyQuotaDevices:null!==(d=e.exceeded_daily_quota_devices)&&void 0!==d?d:{},silencedDevices:null!==(f=e.silenced_devices)&&void 0!==f?f:[],silencedEvents:null!==(v=e.silenced_events)&&void 0!==v?v:[],throttledDevices:null!==(h=e.throttled_devices)&&void 0!==h?h:{},throttledEvents:null!==(p=e.throttled_events)&&void 0!==p?p:[]}};case u.PayloadTooLarge:return{status:k,statusCode:E,body:{error:null!==(g=e.error)&&void 0!==g?g:""}};case u.RateLimit:return{status:k,statusCode:E,body:{error:null!==(y=e.error)&&void 0!==y?y:"",epsThreshold:null!==(m=e.eps_threshold)&&void 0!==m?m:0,throttledDevices:null!==(b=e.throttled_devices)&&void 0!==b?b:{},throttledUsers:null!==(S=e.throttled_users)&&void 0!==S?S:{},exceededDailyQuotaDevices:null!==(w=e.exceeded_daily_quota_devices)&&void 0!==w?w:{},exceededDailyQuotaUsers:null!==(I=e.exceeded_daily_quota_users)&&void 0!==I?I:{},throttledEvents:null!==(C=e.throttled_events)&&void 0!==C?C:[]}};case u.Timeout:default:return{status:k,statusCode:E}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?u.Success:429===e?u.RateLimit:413===e?u.PayloadTooLarge:408===e?u.Timeout:e>=400&&e<500?u.Invalid:e>=500?u.Failed:u.Unknown},e}(),M=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.send=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return n={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(t),method:"POST"},[4,fetch(e,n)];case 1:return[4,(r=o.sent()).text()];case 2:i=o.sent();try{return[2,this.buildResponse(JSON.parse(i))]}catch(e){return[2,this.buildResponse({code:r.status})]}return[2]}}))}))},n}(q);!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(P||(P={}));var L,D="[Amplitude]",N="".concat(D," Session Replay ID"),j=P.US,U="".concat(D," Session Replay Debug"),B="amp-mask";!function(e){e.GET_SR_PROPS="get-sr-props",e.DEBUG_INFO="debug-info",e.FETCH_REQUEST="fetch-request",e.METADATA="metadata"}(L||(L={}));var F=function(){function e(e){this.logger=e,this.log=this.getSafeMethod("log"),this.warn=this.getSafeMethod("warn"),this.error=this.getSafeMethod("error"),this.debug=this.getSafeMethod("debug")}return e.prototype.getSafeMethod=function(e){var t;if(!this.logger)return function(){};var n=this.logger[e];return"function"==typeof n?(null!==(t=n.__rrweb_original__)&&void 0!==t?t:n).bind(this.logger):function(){}},e.prototype.enable=function(e){this.logger.enable(e)},e.prototype.disable=function(){this.logger.disable()},e}(),A="medium";var K,W,z=function(e,t,n){switch(t){case"light":if("input"!==e)return!0;var r=n?function(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?t.toLowerCase():null}(n):"";return!!r&&(!!["password","hidden","email","tel"].includes(r)||!!n.autocomplete.startsWith("cc-"));case"medium":case"conservative":return!0;default:return z(e,A,n)}},G=function(e,t){return function(n,r){return function(e,t,n){var r,o,i;if(void 0===t&&(t={defaultMaskLevel:A}),n){if(n.closest("."+B))return!0;var s=(null!==(r=t.maskSelector)&&void 0!==r?r:[]).some((function(e){return n.closest(e)}));if(s)return!0;if(n.closest(".amp-unmask"))return!1;var a=(null!==(o=t.unmaskSelector)&&void 0!==o?o:[]).some((function(e){return n.closest(e)}));if(a)return!1}return z(e,null!==(i=t.defaultMaskLevel)&&void 0!==i?i:A,n)}(e,t,r)?n.replace(/[^\s]/g,"*"):n}},Q=function(e){var t=0;if(0===e.length)return t;for(var n=0;n<e.length;n++){t=(t<<5)-t+e.charCodeAt(n),t|=0}return t},$=function(e,t){return t||(e===P.STAGING?"https://api-sr.stag2.amplitude.com/sessions/v2/track":e===P.EU?"https://api-sr.eu.amplitude.com/sessions/v2/track":"https://api-sr.amplitude.com/sessions/v2/track")},H=function(e,t){var n,r,o,s;try{for(var a=i(t),u=a.next();!u.done;u=a.next()){var c=u.value,l=(o=c.selector,s=void 0,s=o.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,"."),new RegExp("^".concat(s,"$")));if(l.test(e))return e.replace(l,c.replacement)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return e},J=function(){return r(void 0,void 0,void 0,(function(){var e,t,n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),(e=f())?[4,e.navigator.storage.estimate()]:[3,2];case 1:return t=o.sent(),n=t.usage,r=t.quota,i=t.usageDetails,s=n?Math.round(n/1024):0,a=n&&r?Math.round(1e3*(n/r+Number.EPSILON))/1e3:0,[2,{totalStorageSize:s,percentOfQuota:a,usageDetails:JSON.stringify(i)}];case 2:return[3,4];case 3:return o.sent(),[3,4];case 4:return[2,{totalStorageSize:0,percentOfQuota:0,usageDetails:""}]}}))}))},V=function(e){var t=n({},e),r=t.apiKey;return t.apiKey="****".concat(r.substring(r.length-4)),t},Z=function(){return{flushMaxRetries:2,logLevel:d.Warn,loggerProvider:new p,transportProvider:new M}},X=function(e){function r(t,r){var o,i,s=this,a=Z();return(s=e.call(this,n(n({transportProvider:a.transportProvider,loggerProvider:new F(r.loggerProvider||a.loggerProvider)},r),{apiKey:t}))||this).flushMaxRetries=void 0!==r.flushMaxRetries&&r.flushMaxRetries<=a.flushMaxRetries?r.flushMaxRetries:a.flushMaxRetries,s.apiKey=t,s.sampleRate=r.sampleRate||0,s.serverZone=r.serverZone||j,s.configServerUrl=r.configServerUrl,s.trackServerUrl=r.trackServerUrl,s.shouldInlineStylesheet=r.shouldInlineStylesheet,s.version=r.version,s.performanceConfig=r.performanceConfig,s.storeType=null!==(o=r.storeType)&&void 0!==o?o:"idb",s.applyBackgroundColorToBlockedElements=null!==(i=r.applyBackgroundColorToBlockedElements)&&void 0!==i&&i,r.privacyConfig&&(s.privacyConfig=r.privacyConfig),r.interactionConfig&&(s.interactionConfig=r.interactionConfig,s.interactionConfig.ugcFilterRules&&function(e){if(!e.every((function(e){return"string"==typeof e.selector&&"string"==typeof e.replacement})))throw new Error("ugcFilterRules must be an array of objects with selector and replacement properties");if(!e.every((function(e){return"string"==typeof(t=e.selector)&&""!==t.trim()&&!!/^\/|^https?:\/\/[^\s]+$/.test(t);var t})))throw new Error("ugcFilterRules must be an array of objects with valid globs")}(s.interactionConfig.ugcFilterRules)),r.debugMode&&(s.debugMode=r.debugMode),r.experimental&&(s.experimental=r.experimental),s}return t(r,e),r}(y),Y=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(Y||{}),ee=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(ee||{});!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(K||(K={})),function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(W||(W={}));var te=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,o,i,s,a,u,c,l,d,f,v,h,p,g,y,m,b,S,w,I;if("object"!=typeof e)return null;var C=e.code||0,E=this.buildStatus(C);switch(E){case W.Success:return{status:E,statusCode:C,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case W.Invalid:return{status:E,statusCode:C,body:{error:null!==(o=e.error)&&void 0!==o?o:"",missingField:null!==(i=e.missing_field)&&void 0!==i?i:"",eventsWithInvalidFields:null!==(s=e.events_with_invalid_fields)&&void 0!==s?s:{},eventsWithMissingFields:null!==(a=e.events_with_missing_fields)&&void 0!==a?a:{},eventsWithInvalidIdLengths:null!==(u=e.events_with_invalid_id_lengths)&&void 0!==u?u:{},epsThreshold:null!==(c=e.eps_threshold)&&void 0!==c?c:0,exceededDailyQuotaDevices:null!==(l=e.exceeded_daily_quota_devices)&&void 0!==l?l:{},silencedDevices:null!==(d=e.silenced_devices)&&void 0!==d?d:[],silencedEvents:null!==(f=e.silenced_events)&&void 0!==f?f:[],throttledDevices:null!==(v=e.throttled_devices)&&void 0!==v?v:{},throttledEvents:null!==(h=e.throttled_events)&&void 0!==h?h:[]}};case W.PayloadTooLarge:return{status:E,statusCode:C,body:{error:null!==(p=e.error)&&void 0!==p?p:""}};case W.RateLimit:return{status:E,statusCode:C,body:{error:null!==(g=e.error)&&void 0!==g?g:"",epsThreshold:null!==(y=e.eps_threshold)&&void 0!==y?y:0,throttledDevices:null!==(m=e.throttled_devices)&&void 0!==m?m:{},throttledUsers:null!==(b=e.throttled_users)&&void 0!==b?b:{},exceededDailyQuotaDevices:null!==(S=e.exceeded_daily_quota_devices)&&void 0!==S?S:{},exceededDailyQuotaUsers:null!==(w=e.exceeded_daily_quota_users)&&void 0!==w?w:{},throttledEvents:null!==(I=e.throttled_events)&&void 0!==I?I:[]}};case W.Timeout:default:return{status:E,statusCode:C}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?W.Success:429===e?W.RateLimit:413===e?W.PayloadTooLarge:408===e?W.Timeout:e>=400&&e<500?W.Invalid:e>=500?W.Failed:W.Unknown},e}(),ne="Remote config fetch rejected due to timeout after 5 seconds",re="Unexpected error occurred",oe=function(){function e(e){var t=e.localConfig,s=e.configKeys,a=this;this.retryTimeout=1e3,this.attempts=0,this.sessionTargetingMatch=!1,this.metrics={},this.getRemoteNamespaceConfig=function(e,t){return r(a,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return n=Date.now(),[4,this.fetchWithTimeout(t)];case 1:return(r=o.sent())&&(i=r.configs&&r.configs[e])?(this.metrics.fetchTimeAPISuccess=Date.now()-n,[2,i]):(this.metrics.fetchTimeAPIFail=Date.now()-n,[2,void 0])}}))}))},this.getRemoteConfig=function(e,t,n){return r(a,void 0,void 0,(function(){var r;return o(this,(function(o){switch(o.label){case 0:return[4,this.getRemoteNamespaceConfig(e,n)];case 1:return[2,null==(r=o.sent())?void 0:r[t]]}}))}))},this.fetchWithTimeout=function(e){return r(a,void 0,void 0,(function(){var t,n,r;return o(this,(function(o){switch(o.label){case 0:return t=new AbortController,n=setTimeout((function(){return t.abort()}),5e3),[4,this.fetchRemoteConfig(t.signal,e)];case 1:return r=o.sent(),clearTimeout(n),[2,r]}}))}))},this.fetchRemoteConfig=function(e,t){return r(a,void 0,void 0,(function(){var r,s,a,u,c,l,d,f,v,h,p,g;return o(this,(function(o){switch(o.label){case 0:if(t===this.lastFetchedSessionId&&this.attempts>=this.localConfig.flushMaxRetries)return[2,this.completeRequest({err:"Remote config fetch rejected due to exceeded retry count"})];if(e.aborted)return[2,this.completeRequest({err:ne})];t!==this.lastFetchedSessionId&&(this.lastFetchedSessionId=t,this.attempts=0),o.label=1;case 1:o.trys.push([1,3,,4]),r=new URLSearchParams({api_key:this.localConfig.apiKey});try{for(s=i(this.configKeys),a=s.next();!a.done;a=s.next())u=a.value,r.append("config_keys",u)}catch(e){h={error:e}}finally{try{a&&!a.done&&(p=s.return)&&p.call(s)}finally{if(h)throw h.error}}return t&&r.set("session_id",String(t)),c={headers:{Accept:"*/*"},method:"GET"},l="".concat(this.getServerUrl(),"?").concat(r.toString()),this.attempts+=1,[4,fetch(l,n(n({},c),{signal:e}))];case 2:if(null===(d=o.sent()))return[2,this.completeRequest({err:re})];switch((new te).buildStatus(d.status)){case W.Success:return this.attempts=0,[2,this.parseAndStoreConfig(d)];case W.Failed:return[2,this.retryFetch(e,t)];default:return[2,this.completeRequest({err:"Network error occurred, remote config fetch failed"})]}case 3:return f=o.sent(),v=f,e.aborted?[2,this.completeRequest({err:ne})]:[2,this.completeRequest({err:null!==(g=v.message)&&void 0!==g?g:re})];case 4:return[2]}}))}))},this.retryFetch=function(e,t){return r(a,void 0,void 0,(function(){var n=this;return o(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(e){return setTimeout(e,n.attempts*n.retryTimeout)}))];case 1:return r.sent(),[2,this.fetchRemoteConfig(e,t)]}}))}))},this.parseAndStoreConfig=function(e){return r(a,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return[4,e.json()];case 1:return t=n.sent(),this.completeRequest({success:"Remote config successfully fetched"}),[2,t]}}))}))},this.localConfig=t,this.configKeys=s}return e.prototype.getServerUrl=function(){return this.localConfig.configServerUrl?this.localConfig.configServerUrl:this.localConfig.serverZone===K.STAGING?"https://sr-client-cfg.stag2.amplitude.com/config":this.localConfig.serverZone===K.EU?"https://sr-client-cfg.eu.amplitude.com/config":"https://sr-client-cfg.amplitude.com/config"},e.prototype.completeRequest=function(e){var t=e.err,n=e.success;if(t)throw new Error(t);n&&this.localConfig.loggerProvider.log(n)},e}(),ie=function(e){var t=e.localConfig,n=e.configKeys;return r(void 0,void 0,void 0,(function(){return o(this,(function(e){return[2,new oe({localConfig:t,configKeys:n})]}))}))},se=function(){function e(e,t){this.localConfig=t,this.remoteConfigFetch=e}return e.prototype.generateJoinedConfig=function(e){var t,a,u,c;return r(this,void 0,void 0,(function(){var r,l,d,f,v,h,p,g,y,m,b,S,w,I,C,E,k,x,P,R,_;return o(this,(function(o){switch(o.label){case 0:(r=n({},this.localConfig)).optOut=this.localConfig.optOut,r.captureEnabled=!0,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.remoteConfigFetch.getRemoteNamespaceConfig("sessionReplay",e)];case 2:return(d=o.sent())&&(f=d.sr_sampling_config,v=d.sr_privacy_config,h=null===(t=r.interactionConfig)||void 0===t?void 0:t.ugcFilterRules,r.interactionConfig=d.sr_interaction_config,r.interactionConfig&&h&&(r.interactionConfig.ugcFilterRules=h),r.loggingConfig=d.sr_logging_config,(f||v)&&(l={},f&&(l.sr_sampling_config=f),v&&(l.sr_privacy_config=v))),[3,4];case 3:return p=o.sent(),g=p,this.localConfig.loggerProvider.warn(g.message),r.captureEnabled=!1,[3,4];case 4:if(!l)return[2,{localConfig:this.localConfig,joinedConfig:r,remoteConfig:l}];if(y=l.sr_sampling_config,m=l.sr_privacy_config,y&&Object.keys(y).length>0?(Object.prototype.hasOwnProperty.call(y,"capture_enabled")?r.captureEnabled=y.capture_enabled:r.captureEnabled=!1,Object.prototype.hasOwnProperty.call(y,"sample_rate")&&(r.sampleRate=y.sample_rate)):(r.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),m){b=null!==(a=r.privacyConfig)&&void 0!==a?a:{},S={defaultMaskLevel:null!==(c=null!==(u=m.defaultMaskLevel)&&void 0!==u?u:b.defaultMaskLevel)&&void 0!==c?c:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[]},w=function(e){var t,n,r,o,s,a,u,c,l,d={};"string"==typeof e.blockSelector&&(e.blockSelector=[e.blockSelector]);try{for(var f=i(null!==(u=e.blockSelector)&&void 0!==u?u:[]),v=f.next();!v.done;v=f.next()){d[v.value]="block"}}catch(e){t={error:e}}finally{try{v&&!v.done&&(n=f.return)&&n.call(f)}finally{if(t)throw t.error}}try{for(var h=i(null!==(c=e.maskSelector)&&void 0!==c?c:[]),p=h.next();!p.done;p=h.next()){d[p.value]="mask"}}catch(e){r={error:e}}finally{try{p&&!p.done&&(o=h.return)&&o.call(h)}finally{if(r)throw r.error}}try{for(var g=i(null!==(l=e.unmaskSelector)&&void 0!==l?l:[]),y=g.next();!y.done;y=g.next()){d[y.value]="unmask"}}catch(e){s={error:e}}finally{try{y&&!y.done&&(a=g.return)&&a.call(g)}finally{if(s)throw s.error}}return d},I=n(n({},w(b)),w(m));try{for(C=i(Object.entries(I)),E=C.next();!E.done;E=C.next())k=s(E.value,2),x=k[0],"mask"===(P=k[1])?S.maskSelector.push(x):"block"===P?S.blockSelector.push(x):"unmask"===P&&S.unmaskSelector.push(x)}catch(e){R={error:e}}finally{try{E&&!E.done&&(_=C.return)&&_.call(C)}finally{if(R)throw R.error}}r.privacyConfig=function(e,t){var n=document.createDocumentFragment(),r=function(e){if(void 0===e&&(e=[]),"string"==typeof e&&(e=[e]),e=e.filter((function(e){try{n.querySelector(e)}catch(n){return t.warn('[session-replay-browser] omitting selector "'.concat(e,'" because it is invalid')),!1}return!0})),0!==e.length)return e};return e.blockSelector=r(e.blockSelector),e.maskSelector=r(e.maskSelector),e.unmaskSelector=r(e.unmaskSelector),e}(S,this.localConfig.loggerProvider)}return this.localConfig.loggerProvider.debug(JSON.stringify({name:"session replay joined config",config:V(r)},null,2)),[2,{localConfig:this.localConfig,joinedConfig:r,remoteConfig:l}]}}))}))},e}(),ae=function(e,t){return r(void 0,void 0,void 0,(function(){var n,r;return o(this,(function(o){switch(o.label){case 0:return n=new X(e,t),[4,ie({localConfig:n,configKeys:["sessionReplay"]})];case 1:return r=o.sent(),[2,new se(r,n)]}}))}))},ue="Failed to store session replay events in IndexedDB",ce="1.25.3",le=function(){function e(e){var t=e.trackServerUrl,n=e.loggerProvider,r=e.payloadBatcher;this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.loggerProvider=n,this.payloadBatcher=r||function(e){return e},this.trackServerUrl=t}return e.prototype.sendEventsList=function(e){this.addToQueue(n(n({},e),{attempts:0,timeout:0}))},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t.filter((function(t){return t.attempts<(t.flushMaxRetries||0)?(t.attempts+=1,!0):(e.completeRequest({context:t,err:"Session replay event batch rejected due to exceeded retry count"}),!1)})).forEach((function(t){e.queue=e.queue.concat(t),0!==t.timeout?setTimeout((function(){t.timeout=0,e.schedule(0)}),t.timeout):e.schedule(0)}))},e.prototype.schedule=function(e){var t=this;this.scheduled||(this.scheduled=setTimeout((function(){t.flush(!0).then((function(){t.queue.length>0&&t.schedule(e)}))}),e))},e.prototype.flush=function(e){return void 0===e&&(e=!1),r(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(o){switch(o.label){case 0:return t=[],n=[],this.queue.forEach((function(e){return 0===e.timeout?t.push(e):n.push(e)})),this.queue=n,this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),[4,Promise.all(t.map((function(t){return r.send(t,e)})))];case 1:return o.sent(),[2]}}))}))},e.prototype.send=function(e,t){var n,i;return void 0===t&&(t=!0),r(this,void 0,void 0,(function(){var r,s,a,u,c,l,d,v,h,p,g,y,m;return o(this,(function(o){switch(o.label){case 0:if(!(r=e.apiKey))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing api key"})];if(!(s=e.deviceId))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing device ID"})];if(b=f(),a=(null==b?void 0:b.location)?b.location.href:"",u=ce,c=e.sampleRate,l=new URLSearchParams({device_id:s,session_id:"".concat(e.sessionId),type:"".concat(e.type)}),d="".concat((null===(n=e.version)||void 0===n?void 0:n.type)||"standalone","/").concat((null===(i=e.version)||void 0===i?void 0:i.version)||u),0===(v=this.payloadBatcher({version:1,events:e.events})).events.length)return this.completeRequest({context:e}),[2];o.label=1;case 1:return o.trys.push([1,3,,4]),h={headers:{"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(r),"X-Client-Version":u,"X-Client-Library":d,"X-Client-Url":a.substring(0,1e3),"X-Client-Sample-Rate":"".concat(c)},body:JSON.stringify(v),method:"POST"},p="".concat($(e.serverZone,this.trackServerUrl),"?").concat(l.toString()),[4,fetch(p,h)];case 2:if(null===(g=o.sent()))return this.completeRequest({context:e,err:"Unexpected error occurred"}),[2];if(t)this.handleReponse(g.status,e);else{y="";try{y=JSON.stringify(g.body,null,2)}catch(e){}this.completeRequest({context:e,success:"".concat(g.status,": ").concat(y)})}return[3,4];case 3:return m=o.sent(),this.completeRequest({context:e,err:m}),[3,4];case 4:return[2]}var b}))}))},e.prototype.handleReponse=function(e,t){switch((new q).buildStatus(e)){case u.Success:this.handleSuccessResponse(t);break;case u.Failed:this.handleOtherResponse(t);break;default:this.completeRequest({context:t,err:"Network error occurred, event batch rejected"})}},e.prototype.handleSuccessResponse=function(e){var t=Math.round(new Blob(e.events).size/1024);this.completeRequest({context:e,success:"Session replay event batch tracked successfully for session id ".concat(e.sessionId,", size of events: ").concat(t," KB")})},e.prototype.handleOtherResponse=function(e){this.addToQueue(n(n({},e),{timeout:e.attempts*this.retryTimeout}))},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success;t.onComplete(),n?this.loggerProvider.warn(n):r&&this.loggerProvider.log(r)},e}();const de=(e,t)=>t.some((t=>e instanceof t));let fe,ve;const he=new WeakMap,pe=new WeakMap,ge=new WeakMap;let ye={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return he.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return we(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function me(e){ye=e(ye)}function be(e){return(ve||(ve=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Ie(this),t),we(this.request)}:function(...t){return we(e.apply(Ie(this),t))}}function Se(e){return"function"==typeof e?be(e):(e instanceof IDBTransaction&&function(e){if(he.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",i),e.removeEventListener("abort",i)},o=()=>{t(),r()},i=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",o),e.addEventListener("error",i),e.addEventListener("abort",i)}));he.set(e,t)}(e),de(e,fe||(fe=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,ye):e)}function we(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",o),e.removeEventListener("error",i)},o=()=>{t(we(e.result)),r()},i=()=>{n(e.error),r()};e.addEventListener("success",o),e.addEventListener("error",i)}));return ge.set(t,e),t}(e);if(pe.has(e))return pe.get(e);const t=Se(e);return t!==e&&(pe.set(e,t),ge.set(t,e)),t}const Ie=e=>ge.get(e);function Ce(e,t,{blocked:n,upgrade:r,blocking:o,terminated:i}={}){const s=indexedDB.open(e,t),a=we(s);return r&&s.addEventListener("upgradeneeded",(e=>{r(we(s.result),e.oldVersion,e.newVersion,we(s.transaction),e)})),n&&s.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e))),a.then((e=>{i&&e.addEventListener("close",(()=>i())),o&&e.addEventListener("versionchange",(e=>o(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),a}const Ee=["get","getKey","getAll","getAllKeys","count"],ke=["put","add","delete","clear"],xe=new Map;function Pe(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(xe.get(t))return xe.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,o=ke.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!o&&!Ee.includes(n))return;const i=async function(e,...t){const i=this.transaction(e,o?"readwrite":"readonly");let s=i.store;return r&&(s=s.index(t.shift())),(await Promise.all([s[n](...t),o&&i.done]))[0]};return xe.set(t,i),i}me((e=>({...e,get:(t,n,r)=>Pe(t,n)||e.get(t,n,r),has:(t,n)=>!!Pe(t,n)||e.has(t,n)})));const Re=["continue","continuePrimaryKey","advance"],_e={},Te=new WeakMap,Oe=new WeakMap,qe={get(e,t){if(!Re.includes(t))return e[t];let n=_e[t];return n||(n=_e[t]=function(...e){Te.set(this,Oe.get(this)[t](...e))}),n}};async function*Me(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const n=new Proxy(t,qe);for(Oe.set(n,t),ge.set(n,Ie(t));t;)yield n,t=await(Te.get(n)||t.continue()),Te.delete(n)}function Le(e,t){return t===Symbol.asyncIterator&&de(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&de(e,[IDBIndex,IDBObjectStore])}me((e=>({...e,get:(t,n,r)=>Le(t,n)?Me:e.get(t,n,r),has:(t,n)=>Le(t,n)||e.has(t,n)})));var De,Ne=function(){function e(e){var t,n,r,o=this;this.minInterval=500,this.maxInterval=1e4,this.maxPersistedEventsSize=1e6,this.interval=this.minInterval,this._timeAtLastSplit=Date.now(),this.shouldSplitEventsList=function(e,t){var n=new Blob([t]).size;return new Blob(e).size+n>=o.maxPersistedEventsSize||!!(Date.now()-o.timeAtLastSplit>o.interval&&e.length)&&(o.interval=Math.min(o.maxInterval,o.interval+o.minInterval),o._timeAtLastSplit=Date.now(),!0)},this.loggerProvider=e.loggerProvider,this.minInterval=null!==(t=e.minInterval)&&void 0!==t?t:this.minInterval,this.maxInterval=null!==(n=e.maxInterval)&&void 0!==n?n:this.maxInterval,this.maxPersistedEventsSize=null!==(r=e.maxPersistedEventsSize)&&void 0!==r?r:this.maxPersistedEventsSize}return Object.defineProperty(e.prototype,"timeAtLastSplit",{get:function(){return this._timeAtLastSplit},enumerable:!1,configurable:!0}),e}();!function(e){e.RECORDING="recording",e.SENT="sent"}(De||(De={}));var je="sessionCurrentSequence",Ue="sequencesToSend",Be=function(){var e=f();return new Promise((function(t,n){if(!e)return n(new Error("Global scope not found"));if(!e.indexedDB)return n(new Error("Session Replay: cannot find indexedDB"));try{var r=e.indexedDB.open("keyval-store");r.onupgradeneeded=function(){1===r.result.version&&(r.result.close(),r.transaction&&r.transaction.abort(),e.indexedDB.deleteDatabase("keyval-store"),t())},r.onsuccess=function(){t(r.result)},r.onerror=function(){n(r.error)}}catch(e){n(e)}}))},Fe=function(e){return r(void 0,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return e.length>0?(t=e.splice(0,10),[4,Promise.all(t)]):[3,2];case 1:return n.sent(),[3,0];case 2:return[2]}}))}))},Ae=function(e){var t,n;return e.objectStoreNames.contains(je)||(n=e.createObjectStore(je,{keyPath:"sessionId"})),e.objectStoreNames.contains(Ue)||(t=e.createObjectStore(Ue,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:n}},Ke=function(e){return r(void 0,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,Ce(e,1,{upgrade:Ae})];case 1:return[2,t.sent()]}}))}))},We=function(e){function u(t){var i=e.call(this,t)||this;return i.getSequencesToSend=function(){return r(i,void 0,void 0,(function(){var e,t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,5,,6]),e=[],[4,this.db.transaction("sequencesToSend").store.openCursor()];case 1:t=o.sent(),o.label=2;case 2:return t?(n=t.value,r=n.sessionId,i=n.events,e.push({events:i,sequenceId:t.key,sessionId:r}),[4,t.continue()]):[3,4];case 3:return t=o.sent(),[3,2];case 4:return[2,e];case 5:return s=o.sent(),this.loggerProvider.warn("".concat(ue,": ").concat(s)),[3,6];case 6:return[2,void 0]}}))}))},i.storeCurrentSequence=function(e){return r(i,void 0,void 0,(function(){var t,r,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),[4,this.db.get(je,e)];case 1:return(t=o.sent())?[4,this.db.put(Ue,{sessionId:e,events:t.events})]:[2,void 0];case 2:return r=o.sent(),[4,this.db.put(je,{sessionId:e,events:[]})];case 3:return o.sent(),[2,n(n({},t),{sessionId:e,sequenceId:r})];case 4:return i=o.sent(),this.loggerProvider.warn("".concat(ue,": ").concat(i)),[3,5];case 5:return[2,void 0]}}))}))},i.addEventToCurrentSequence=function(e,t){return r(i,void 0,void 0,(function(){var n,r,i,s,a,u;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,10,,11]),[4,(n=this.db.transaction(je,"readwrite")).store.get(e)];case 1:return(r=o.sent())?[3,3]:[4,n.store.put({sessionId:e,events:[t]})];case 2:return o.sent(),[2];case 3:return i=void 0,this.shouldSplitEventsList(r.events,t)?(i=r.events,[4,n.store.put({sessionId:e,events:[t]})]):[3,5];case 4:return o.sent(),[3,7];case 5:return s=r.events.concat(t),[4,n.store.put({sessionId:e,events:s})];case 6:o.sent(),o.label=7;case 7:return[4,n.done];case 8:return o.sent(),i?[4,this.storeSendingEvents(e,i)]:[2,void 0];case 9:return(a=o.sent())?[2,{events:i,sessionId:e,sequenceId:a}]:[2,void 0];case 10:return u=o.sent(),this.loggerProvider.warn("".concat(ue,": ").concat(u)),[3,11];case 11:return[2,void 0]}}))}))},i.storeSendingEvents=function(e,t){return r(i,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.db.put(Ue,{sessionId:e,events:t})];case 1:return[2,r.sent()];case 2:return n=r.sent(),this.loggerProvider.warn("".concat(ue,": ").concat(n)),[3,3];case 3:return[2,void 0]}}))}))},i.cleanUpSessionEventsStore=function(e,t){return r(i,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:if(!t)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.db.delete(Ue,t)];case 2:return n.sent(),[3,4];case 3:return e=n.sent(),this.loggerProvider.warn("".concat(ue,": ").concat(e)),[3,4];case 4:return[2]}}))}))},i.transitionFromKeyValStore=function(e){return r(i,void 0,void 0,(function(){var t,n,i,u,l,d,v,h,p=this;return o(this,(function(g){switch(g.label){case 0:return g.trys.push([0,6,,7]),[4,Be()];case 1:if(!(t=g.sent()))return[2];n=function(e,t){return r(p,void 0,void 0,(function(){var n,i,u=this;return o(this,(function(c){switch(c.label){case 0:return n=t.sessionSequences,i=[],Object.keys(n).forEach((function(c){var l=parseInt(c,10),d=n[l];if(l===t.currentSequenceId){var f=d.events.map((function(t){return r(u,void 0,void 0,(function(){return o(this,(function(n){return[2,this.addEventToCurrentSequence(e,t)]}))}))}));i.push.apply(i,a([],s(f),!1))}else d.status!==De.SENT&&i.push(u.storeSendingEvents(e,d.events))})),[4,Fe(i)];case 1:return c.sent(),[2]}}))}))},i="".concat(c,"_").concat(this.apiKey.substring(0,10)),g.label=2;case 2:return g.trys.push([2,4,,5]),u=t.transaction("keyval").objectStore("keyval").getAll(i),l=new Promise((function(t){u.onsuccess=function(i){return r(p,void 0,void 0,(function(){var r,s,a,u=this;return o(this,(function(o){switch(o.label){case 0:return r=i&&i.target.result,(s=r&&r[0])?(a=[],Object.keys(s).forEach((function(t){var r=parseInt(t,10),o=s[r];if(e===r)a.push(n(r,o));else{var i=o.sessionSequences;Object.keys(i).forEach((function(e){var t=parseInt(e,10);i[t].status!==De.SENT&&a.push(u.storeSendingEvents(r,i[t].events))}))}})),[4,Fe(a)]):[3,2];case 1:o.sent(),o.label=2;case 2:return t(),[2]}}))}))}})),[4,l];case 3:return g.sent(),(d=f())&&d.indexedDB.deleteDatabase("keyval-store"),[3,5];case 4:return v=g.sent(),this.loggerProvider.warn("Failed to transition session replay events from keyval to new store: ".concat(v)),[3,5];case 5:return[3,7];case 6:return h=g.sent(),this.loggerProvider.warn("Failed to access keyval store: ".concat(h,". For more information, visit: https://www.docs.developers.amplitude.com/session-replay/sdks/standalone/#indexeddb-best-practices")),[3,7];case 7:return[2]}}))}))},i.apiKey=t.apiKey,i.db=t.db,i}return t(u,e),u.new=function(e,t,i){return r(this,void 0,void 0,(function(){var r,s,a,c,l;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),r="replay"===e?"":"_".concat(e),s="".concat(t.apiKey.substring(0,10),"_amp_session_replay_events").concat(r),[4,Ke(s)];case 1:return a=o.sent(),[4,(c=new u(n(n({},t),{db:a}))).transitionFromKeyValStore(i)];case 2:return o.sent(),[2,c];case 3:return l=o.sent(),t.loggerProvider.warn("".concat(ue,": ").concat(l)),[3,4];case 4:return[2]}}))}))},u.prototype.getCurrentSequenceEvents=function(e){return r(this,void 0,void 0,(function(){var t,n,r,s,a,u,c;return o(this,(function(o){switch(o.label){case 0:return e?[4,this.db.get("sessionCurrentSequence",e)]:[3,2];case 1:return(s=o.sent())?[2,[s]]:[2,void 0];case 2:t=[],o.label=3;case 3:return o.trys.push([3,8,9,10]),[4,this.db.getAll("sessionCurrentSequence")];case 4:n=i.apply(void 0,[o.sent()]),r=n.next(),o.label=5;case 5:if(r.done)return[3,7];s=r.value,t.push(s),o.label=6;case 6:return r=n.next(),[3,5];case 7:return[3,10];case 8:return a=o.sent(),u={error:a},[3,10];case 9:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 10:return[2,t]}}))}))},u}(Ne),ze=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.finalizedSequences={},t.sequences={},t.sequenceId=0,t}return t(n,e),n.prototype.resetCurrentSequence=function(e){this.sequences[e]=[]},n.prototype.addSequence=function(e){var t=this.sequenceId++,n=a([],s(this.sequences[e]),!1);return this.finalizedSequences[t]={sessionId:e,events:n},this.resetCurrentSequence(e),{sequenceId:t,events:n,sessionId:e}},n.prototype.getSequencesToSend=function(){return r(this,void 0,void 0,(function(){return o(this,(function(e){return[2,Object.entries(this.finalizedSequences).map((function(e){var t=s(e,2),n=t[0],r=t[1],o=r.sessionId,i=r.events;return{sequenceId:Number(n),sessionId:o,events:i}}))]}))}))},n.prototype.storeCurrentSequence=function(e){return r(this,void 0,void 0,(function(){return o(this,(function(t){return this.sequences[e]?[2,this.addSequence(e)]:[2,void 0]}))}))},n.prototype.addEventToCurrentSequence=function(e,t){return r(this,void 0,void 0,(function(){var n;return o(this,(function(r){return this.sequences[e]||this.resetCurrentSequence(e),this.shouldSplitEventsList(this.sequences[e],t)&&(n=this.addSequence(e)),this.sequences[e].push(t),[2,n]}))}))},n.prototype.storeSendingEvents=function(e,t){return r(this,void 0,void 0,(function(){return o(this,(function(n){return this.finalizedSequences[this.sequenceId]={sessionId:e,events:t},[2,this.sequenceId++]}))}))},n.prototype.cleanUpSessionEventsStore=function(e,t){return r(this,void 0,void 0,(function(){return o(this,(function(e){return void 0!==t&&delete this.finalizedSequences[t],[2]}))}))},n}(Ne),Ge=function(e){var t=e.config,i=e.sessionId,s=e.minInterval,a=e.maxInterval,u=e.type,c=e.payloadBatcher,l=e.storeType;return r(void 0,void 0,void 0,(function(){function e(e){return void 0===e&&(e=!1),r(this,void 0,void 0,(function(){return o(this,(function(t){return[2,d.flush(e)]}))}))}var d,f,v,h,p,g,y,m,b;return o(this,(function(S){switch(S.label){case 0:return d=new le(n(n({},t),{loggerProvider:t.loggerProvider,payloadBatcher:c})),f=function(){return new ze({loggerProvider:t.loggerProvider,maxInterval:a,minInterval:s})},v=function(){return r(void 0,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return[4,We.new(u,{loggerProvider:t.loggerProvider,minInterval:s,maxInterval:a,apiKey:t.apiKey},i)];case 1:return e=n.sent(),t.loggerProvider.log("Failed to initialize idb store, falling back to memory store."),[2,null!=e?e:f()]}}))}))},"idb"!==l?[3,2]:[4,v()];case 1:return p=S.sent(),[3,3];case 2:p=f(),S.label=3;case 3:return h=p,g=function(e){var n=e.events,i=e.sessionId,s=e.deviceId,a=e.sequenceId;t.debugMode&&J().then((function(e){var n=e.totalStorageSize,r=e.percentOfQuota,o=e.usageDetails;t.loggerProvider.debug("Total storage size: ".concat(n," KB, percentage of quota: ").concat(r,"%, usage details: ").concat(o))})).catch((function(){})),d.sendEventsList({events:n,sessionId:i,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:s,sampleRate:t.sampleRate,serverZone:t.serverZone,version:t.version,type:u,onComplete:function(){return r(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,h.cleanUpSessionEventsStore(i,a)];case 1:return e.sent(),[2]}}))}))}})},y=function(e){var n=e.sessionId,r=e.deviceId;h.storeCurrentSequence(n).then((function(e){e&&g({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r})})).catch((function(e){t.loggerProvider.warn("Failed to get current sequence of session replay events for session:",e)}))},m=function(e){var t=e.deviceId;return r(void 0,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return[4,h.getSequencesToSend()];case 1:return(e=n.sent())&&e.forEach((function(e){g({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:t})})),[2]}}))}))},b=function(e){var n=e.event,r=e.sessionId,o=e.deviceId;h.addEventToCurrentSequence(r,n.data).then((function(e){return e&&g({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:o})})).catch((function(e){t.loggerProvider.warn("Failed to add event to session replay capture:",e)}))},[2,{sendCurrentSequenceEvents:y,addEvent:b,sendStoredEvents:m,flush:e}]}}))}))},Qe=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new Map;e.forEach((function(e){n.set(e.name,e.manager)})),this.managers=n}return e.prototype.sendStoredEvents=function(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=[],this.managers.forEach((function(n){t.push(n.sendStoredEvents(e))})),[4,Promise.all(t)];case 1:return n.sent(),[2]}}))}))},e.prototype.addEvent=function(e){var t,n=e.sessionId,r=e.event,o=e.deviceId;null===(t=this.managers.get(r.type))||void 0===t||t.addEvent({sessionId:n,event:r,deviceId:o})},e.prototype.sendCurrentSequenceEvents=function(e){var t=e.sessionId,n=e.deviceId;this.managers.forEach((function(e){e.sendCurrentSequenceEvents({sessionId:t,deviceId:n})}))},e.prototype.flush=function(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=[],this.managers.forEach((function(n){t.push(n.flush(e))})),[4,Promise.all(t)];case 1:return n.sent(),[2]}}))}))},e}();const $e={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},He={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},Je={};function Ve(e){if(Je[e])return Je[e];const t=globalThis[e],n=t.prototype,r=e in $e?$e[e]:void 0,o=Boolean(r&&r.every((e=>{var t,r;return Boolean(null==(r=null==(t=Object.getOwnPropertyDescriptor(n,e))?void 0:t.get)?void 0:r.toString().includes("[native code]"))}))),i=e in He?He[e]:void 0,s=Boolean(i&&i.every((e=>{var t;return"function"==typeof n[e]&&(null==(t=n[e])?void 0:t.toString().includes("[native code]"))})));if(o&&s&&!globalThis.Zone)return Je[e]=t.prototype,t.prototype;try{const r=document.createElement("iframe");document.body.appendChild(r);const o=r.contentWindow;if(!o)return t.prototype;const i=o[e].prototype;return document.body.removeChild(r),i?Je[e]=i:n}catch{return n}}const Ze={};function Xe(e,t,n){var r;const o=`${e}.${String(n)}`;if(Ze[o])return Ze[o].call(t);const i=Ve(e),s=null==(r=Object.getOwnPropertyDescriptor(i,n))?void 0:r.get;return s?(Ze[o]=s,s.call(t)):t[n]}const Ye={};function et(e,t,n){const r=`${e}.${String(n)}`;if(Ye[r])return Ye[r].bind(t);const o=Ve(e)[n];return"function"!=typeof o?t[n]:(Ye[r]=o,o.bind(t))}const tt={childNodes:function(e){return Xe("Node",e,"childNodes")},parentNode:function(e){return Xe("Node",e,"parentNode")},parentElement:function(e){return Xe("Node",e,"parentElement")},textContent:function(e){return Xe("Node",e,"textContent")},contains:function(e,t){return et("Node",e,"contains")(t)},getRootNode:function(e){return et("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?Xe("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?Xe("Element",e,"shadowRoot"):null},querySelector:function(e,t){return Xe("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return Xe("Element",e,"querySelectorAll")(t)},mutationObserver:function(){return Ve("MutationObserver").constructor}};function nt(){var e=f();return(null==e?void 0:e.innerHeight)||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight||0}function rt(){var e=f();return(null==e?void 0:e.innerWidth)||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth||0}var ot,it,st;function at(e,t){if(st=new Date,e.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===e.tagName.toLowerCase())return"html";var r={root:document.body,idName:function(e){return!0},className:function(e){return!0},tagName:function(e){return!0},attr:function(e,t){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};ot=n(n({},r),t),it=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(ot.root,r);var o=ut(e,"all",(function(){return ut(e,"two",(function(){return ut(e,"one",(function(){return ut(e,"none")}))}))}));if(o){var i=mt(bt(o,e));return i.length>0&&(o=i[0]),lt(o)}throw new Error("Selector was not found.")}function ut(e,t,n){for(var r=null,o=[],u=e,c=0,l=function(){var e,l,d=(new Date).getTime()-st.getTime();if(void 0!==ot.timeoutMs&&d>ot.timeoutMs)throw new Error("Timeout: Can't find a unique selector after ".concat(d,"ms"));var f=pt(function(e){var t=e.getAttribute("id");if(t&&ot.idName(t))return{name:"#"+CSS.escape(t),penalty:0};return null}(u))||pt.apply(void 0,a([],s(function(e){var t=Array.from(e.attributes).filter((function(e){return ot.attr(e.name,e.value)}));return t.map((function(e){return{name:"[".concat(CSS.escape(e.name),'="').concat(CSS.escape(e.value),'"]'),penalty:.5}}))}(u)),!1))||pt.apply(void 0,a([],s(function(e){var t=Array.from(e.classList).filter(ot.className);return t.map((function(e){return{name:"."+CSS.escape(e),penalty:1}}))}(u)),!1))||pt(function(e){var t=e.tagName.toLowerCase();if(ot.tagName(t))return{name:t,penalty:2};return null}(u))||[{name:"*",penalty:3}],v=function(e){var t=e.parentNode;if(!t)return null;var n=t.firstChild;if(!n)return null;var r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}(u);if("all"==t)v&&(f=f.concat(f.filter(ht).map((function(e){return vt(e,v)}))));else if("two"==t)f=f.slice(0,1),v&&(f=f.concat(f.filter(ht).map((function(e){return vt(e,v)}))));else if("one"==t){var h=s(f=f.slice(0,1),1)[0];v&&ht(h)&&(f=[vt(h,v)])}else"none"==t&&(f=[{name:"*",penalty:3}],v&&(f=[vt(f[0],v)]));try{for(var p=(e=void 0,i(f)),g=p.next();!g.done;g=p.next()){(h=g.value).level=c}}catch(t){e={error:t}}finally{try{g&&!g.done&&(l=p.return)&&l.call(p)}finally{if(e)throw e.error}}if(o.push(f),o.length>=ot.seedMinLength&&(r=ct(o,n)))return"break";u=u.parentElement,c++};u;){if("break"===l())break}return r||(r=ct(o,n)),!r&&n?n():r}function ct(e,t){var n,r,o=mt(yt(e));if(o.length>ot.threshold)return t?t():null;try{for(var s=i(o),a=s.next();!a.done;a=s.next()){var u=a.value;if(ft(u))return u}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return null}function lt(e){for(var t=e[0],n=t.name,r=1;r<e.length;r++){var o=e[r].level||0;n=t.level===o-1?"".concat(e[r].name," > ").concat(n):"".concat(e[r].name," ").concat(n),t=e[r]}return n}function dt(e){return e.map((function(e){return e.penalty})).reduce((function(e,t){return e+t}),0)}function ft(e){var t=lt(e);switch(it.querySelectorAll(t).length){case 0:throw new Error("Can't select any node with this selector: ".concat(t));case 1:return!0;default:return!1}}function vt(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function ht(e){return"html"!==e.name&&!e.name.startsWith("#")}function pt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(gt);return n.length>0?n:null}function gt(e){return null!=e}function yt(e,t){var n,r,s,a,u,c;return void 0===t&&(t=[]),o(this,(function(o){switch(o.label){case 0:if(!(e.length>0))return[3,9];o.label=1;case 1:o.trys.push([1,6,7,8]),n=i(e[0]),r=n.next(),o.label=2;case 2:return r.done?[3,5]:(s=r.value,[5,i(yt(e.slice(1,e.length),t.concat(s)))]);case 3:o.sent(),o.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return a=o.sent(),u={error:a},[3,8];case 7:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 8:return[3,11];case 9:return[4,t];case 10:o.sent(),o.label=11;case 11:return[2]}}))}function mt(e){return a([],s(e),!1).sort((function(e,t){return dt(e)-dt(t)}))}function bt(e,t,n){var r,u,c;return void 0===n&&(n={counter:0,visited:new Map}),o(this,(function(o){switch(o.label){case 0:if(!(e.length>2&&e.length>ot.optimizedMinLength))return[3,5];r=1,o.label=1;case 1:return r<e.length-1?n.counter>ot.maxNumberOfTries?[2]:(n.counter+=1,(u=a([],s(e),!1)).splice(r,1),c=lt(u),n.visited.has(c)?[2]:ft(u)&&function(e,t){return it.querySelector(lt(e))===t}(u,t)?[4,u]:[3,4]):[3,5];case 2:return o.sent(),n.visited.set(c,!0),[5,i(bt(u,t,n))];case 3:o.sent(),o.label=4;case 4:return r++,[3,1];case 5:return[2]}}))}var St=function(e){var t=e.version,n=e.events,r=[];return n.forEach((function(e){var t=JSON.parse(e);t.count=1,"click"===t.type&&r.push(t)})),{version:t,events:r}},wt=function(e){var t=e.version,r=e.events,o=[];r.forEach((function(e){var t=JSON.parse(e);"click"===t.type&&o.push(t)}));var i=o.reduce((function(e,t){var r=t.x,o=t.y,i=t.selector,s=t.timestamp,a=s-s%36e5,u="".concat(r,":").concat(o,":").concat(null!=i?i:"",":").concat(a);return e[u]?e[u].count+=1:e[u]=n(n({},t),{timestamp:a,count:1}),e}),{});return{version:t,events:Object.values(i)}},It=function(e,t){var n=t.eventsManager,r=t.sessionId,o=t.deviceIdFn,i=t.mirror,s=t.ugcFilterRules;return function(t){if(t.type===ee.Click){var a=f();if(a){var u=a.location,c=a.innerHeight,l=a.innerWidth;if(u){var d=t.x,v=t.y;if(void 0!==d&&void 0!==v){var h,p=i.getNode(t.id);if(p)try{h=at(p)}catch(t){e.debug("error resolving selector from finder")}var g=function(e){var t,n,r,o,i=e.document;return{left:i.scrollingElement?i.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:i.documentElement.scrollLeft||(null==i?void 0:i.body)&&(null===(t=tt.parentElement(i.body))||void 0===t?void 0:t.scrollLeft)||(null===(n=null==i?void 0:i.body)||void 0===n?void 0:n.scrollLeft)||0,top:i.scrollingElement?i.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==i?void 0:i.documentElement.scrollTop)||(null==i?void 0:i.body)&&(null===(r=tt.parentElement(i.body))||void 0===r?void 0:r.scrollTop)||(null===(o=null==i?void 0:i.body)||void 0===o?void 0:o.scrollTop)||0}}(a),y={x:d+g.left,y:v+g.top,selector:h,viewportHeight:c,viewportWidth:l,pageUrl:H(u.href,s),timestamp:Date.now(),type:"click"},m=o();m&&n.addEvent({sessionId:r,event:{type:"interaction",data:JSON.stringify(y)},deviceId:m})}}}}}},Ct=function(){function e(e,t){var n=f();n&&n.navigator&&"function"==typeof n.navigator.sendBeacon?this.sendBeacon=function(e,t){try{if(n.navigator.sendBeacon(e,JSON.stringify(t)))return!0}catch(e){}return!1}:this.sendBeacon=function(){return!1},this.sendXhr=function(e,t){var n=new XMLHttpRequest;return n.open("POST",e,!0),n.setRequestHeader("Accept","*/*"),n.send(JSON.stringify(t)),!0},this.basePageUrl=$(t.serverZone,t.trackServerUrl),this.apiKey=t.apiKey,this.context=e}return e.prototype.send=function(e,t){var n=this.context,r=n.sessionId,o=n.type,i=new URLSearchParams({device_id:e,session_id:String(r),type:String(o),api_key:this.apiKey}),s="".concat(this.basePageUrl,"?").concat(i.toString());this.sendBeacon(s,t)||this.sendXhr(s,t)},e}(),Et=function(){function e(e,t){var n=this;this.timestamp=Date.now(),this.hook=function(e){n.update(e)},this.send=function(e){return function(t){var r,o,i=e(),s=f();s&&i&&n.transport.send(i,{version:1,events:[{maxScrollX:n._maxScrollX,maxScrollY:n._maxScrollY,maxScrollWidth:n._maxScrollWidth,maxScrollHeight:n._maxScrollHeight,viewportHeight:nt(),viewportWidth:rt(),pageUrl:H(s.location.href,null!==(o=null===(r=n.config.interactionConfig)||void 0===r?void 0:r.ugcFilterRules)&&void 0!==o?o:[]),timestamp:n.timestamp,type:"scroll"}]})}},this._maxScrollX=0,this._maxScrollY=0,this._maxScrollWidth=rt(),this._maxScrollHeight=nt(),this.config=t,this.transport=e}return e.default=function(t,n){return new e(new Ct(t,n),n)},Object.defineProperty(e.prototype,"maxScrollX",{get:function(){return this._maxScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollY",{get:function(){return this._maxScrollY},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollWidth",{get:function(){return this._maxScrollWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollHeight",{get:function(){return this._maxScrollHeight},enumerable:!1,configurable:!0}),e.prototype.update=function(e){var t=Date.now();if(e.x>this._maxScrollX){var n=rt();this._maxScrollX=e.x;var r=e.x+n;r>this._maxScrollWidth&&(this._maxScrollWidth=r),this.timestamp=t}if(e.y>this._maxScrollY){var o=nt();this._maxScrollY=e.y;var i=e.y+o;i>this._maxScrollHeight&&(this._maxScrollHeight=i),this.timestamp=t}},e}(),kt=function(e){var t=e.sessionId,n=e.deviceId;this.deviceId=n,this.sessionId=t,t&&n&&(this.sessionReplayId=function(e,t){return"".concat(t,"/").concat(e)}(t,n))},xt=Uint8Array,Pt=Uint16Array,Rt=Uint32Array,_t=new xt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Tt=new xt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ot=new xt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qt=function(e,t){for(var n=new Pt(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new Rt(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)o[i]=i-n[r]<<5|r;return[n,o]},Mt=qt(_t,2),Lt=Mt[0],Dt=Mt[1];Lt[28]=258,Dt[258]=28;for(var Nt=qt(Tt,0)[1],jt=new Pt(32768),Ut=0;Ut<32768;++Ut){var Bt=(43690&Ut)>>>1|(21845&Ut)<<1;Bt=(61680&(Bt=(52428&Bt)>>>2|(13107&Bt)<<2))>>>4|(3855&Bt)<<4,jt[Ut]=((65280&Bt)>>>8|(255&Bt)<<8)>>>1}var Ft=function(e,t,n){for(var r=e.length,o=0,i=new Pt(t);o<r;++o)++i[e[o]-1];var s,a=new Pt(t);for(o=0;o<t;++o)a[o]=a[o-1]+i[o-1]<<1;if(n){s=new Pt(1<<t);var u=15-t;for(o=0;o<r;++o)if(e[o])for(var c=o<<4|e[o],l=t-e[o],d=a[e[o]-1]++<<l,f=d|(1<<l)-1;d<=f;++d)s[jt[d]>>>u]=c}else for(s=new Pt(r),o=0;o<r;++o)s[o]=jt[a[e[o]-1]++]>>>15-e[o];return s},At=new xt(288);for(Ut=0;Ut<144;++Ut)At[Ut]=8;for(Ut=144;Ut<256;++Ut)At[Ut]=9;for(Ut=256;Ut<280;++Ut)At[Ut]=7;for(Ut=280;Ut<288;++Ut)At[Ut]=8;var Kt=new xt(32);for(Ut=0;Ut<32;++Ut)Kt[Ut]=5;var Wt=Ft(At,9,0),zt=Ft(Kt,5,0),Gt=function(e){return(e/8|0)+(7&e&&1)},Qt=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof Pt?Pt:e instanceof Rt?Rt:xt)(n-t);return r.set(e.subarray(t,n)),r},$t=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},Ht=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},Jt=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,i=n.slice();if(!o)return[new xt(0),0];if(1==o){var s=new xt(n[0].s+1);return s[n[0].s]=1,[s,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],u=n[1],c=0,l=1,d=2;for(n[0]={s:-1,f:a.f+u.f,l:a,r:u};l!=o-1;)a=n[n[c].f<n[d].f?c++:d++],u=n[c!=l&&n[c].f<n[d].f?c++:d++],n[l++]={s:-1,f:a.f+u.f,l:a,r:u};var f=i[0].s;for(r=1;r<o;++r)i[r].s>f&&(f=i[r].s);var v=new Pt(f+1),h=Vt(n[l-1],v,0);if(h>t){r=0;var p=0,g=h-t,y=1<<g;for(i.sort((function(e,t){return v[t.s]-v[e.s]||e.f-t.f}));r<o;++r){var m=i[r].s;if(!(v[m]>t))break;p+=y-(1<<h-v[m]),v[m]=t}for(p>>>=g;p>0;){var b=i[r].s;v[b]<t?p-=1<<t-v[b]++-1:++r}for(;r>=0&&p;--r){var S=i[r].s;v[S]==t&&(--v[S],++p)}h=t}return[new xt(v),h]},Vt=function(e,t,n){return-1==e.s?Math.max(Vt(e.l,t,n+1),Vt(e.r,t,n+1)):t[e.s]=n},Zt=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Pt(++t),r=0,o=e[0],i=1,s=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++i;else{if(!o&&i>2){for(;i>138;i-=138)s(32754);i>2&&(s(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(s(o),--i;i>6;i-=6)s(8304);i>2&&(s(i-3<<5|8208),i=0)}for(;i--;)s(o);i=1,o=e[a]}return[n.subarray(0,r),t]},Xt=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},Yt=function(e,t,n){var r=n.length,o=Gt(t+2);e[o]=255&r,e[o+1]=r>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var i=0;i<r;++i)e[o+i+4]=n[i];return 8*(o+4+r)},en=function(e,t,n,r,o,i,s,a,u,c,l){$t(t,l++,n),++o[256];for(var d=Jt(o,15),f=d[0],v=d[1],h=Jt(i,15),p=h[0],g=h[1],y=Zt(f),m=y[0],b=y[1],S=Zt(p),w=S[0],I=S[1],C=new Pt(19),E=0;E<m.length;++E)C[31&m[E]]++;for(E=0;E<w.length;++E)C[31&w[E]]++;for(var k=Jt(C,7),x=k[0],P=k[1],R=19;R>4&&!x[Ot[R-1]];--R);var _,T,O,q,M=c+5<<3,L=Xt(o,At)+Xt(i,Kt)+s,D=Xt(o,f)+Xt(i,p)+s+14+3*R+Xt(C,x)+(2*C[16]+3*C[17]+7*C[18]);if(M<=L&&M<=D)return Yt(t,l,e.subarray(u,u+c));if($t(t,l,1+(D<L)),l+=2,D<L){_=Ft(f,v,0),T=f,O=Ft(p,g,0),q=p;var N=Ft(x,P,0);$t(t,l,b-257),$t(t,l+5,I-1),$t(t,l+10,R-4),l+=14;for(E=0;E<R;++E)$t(t,l+3*E,x[Ot[E]]);l+=3*R;for(var j=[m,w],U=0;U<2;++U){var B=j[U];for(E=0;E<B.length;++E){var F=31&B[E];$t(t,l,N[F]),l+=x[F],F>15&&($t(t,l,B[E]>>>5&127),l+=B[E]>>>12)}}}else _=Wt,T=At,O=zt,q=Kt;for(E=0;E<a;++E)if(r[E]>255){F=r[E]>>>18&31;Ht(t,l,_[F+257]),l+=T[F+257],F>7&&($t(t,l,r[E]>>>23&31),l+=_t[F]);var A=31&r[E];Ht(t,l,O[A]),l+=q[A],A>3&&(Ht(t,l,r[E]>>>5&8191),l+=Tt[A])}else Ht(t,l,_[r[E]]),l+=T[r[E]];return Ht(t,l,_[256]),l+T[256]},tn=new Rt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),nn=function(e,t,n,r,o){return function(e,t,n,r,o,i){var s=e.length,a=new xt(r+s+5*(1+Math.floor(s/7e3))+o),u=a.subarray(r,a.length-o),c=0;if(!t||s<8)for(var l=0;l<=s;l+=65535){var d=l+65535;d<s?c=Yt(u,c,e.subarray(l,d)):(u[l]=i,c=Yt(u,c,e.subarray(l,s)))}else{for(var f=tn[t-1],v=f>>>13,h=8191&f,p=(1<<n)-1,g=new Pt(32768),y=new Pt(p+1),m=Math.ceil(n/3),b=2*m,S=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<b)&p},w=new Rt(25e3),I=new Pt(288),C=new Pt(32),E=0,k=0,x=(l=0,0),P=0,R=0;l<s;++l){var _=S(l),T=32767&l,O=y[_];if(g[T]=O,y[_]=T,P<=l){var q=s-l;if((E>7e3||x>24576)&&q>423){c=en(e,u,0,w,I,C,k,x,R,l-R,c),x=E=k=0,R=l;for(var M=0;M<286;++M)I[M]=0;for(M=0;M<30;++M)C[M]=0}var L=2,D=0,N=h,j=T-O&32767;if(q>2&&_==S(l-j))for(var U=Math.min(v,q)-1,B=Math.min(32767,l),F=Math.min(258,q);j<=B&&--N&&T!=O;){if(e[l+L]==e[l+L-j]){for(var A=0;A<F&&e[l+A]==e[l+A-j];++A);if(A>L){if(L=A,D=j,A>U)break;var K=Math.min(j,A-2),W=0;for(M=0;M<K;++M){var z=l-j+M+32768&32767,G=z-g[z]+32768&32767;G>W&&(W=G,O=z)}}}j+=(T=O)-(O=g[T])+32768&32767}if(D){w[x++]=268435456|Dt[L]<<18|Nt[D];var Q=31&Dt[L],$=31&Nt[D];k+=_t[Q]+Tt[$],++I[257+Q],++C[$],P=l+L,++E}else w[x++]=e[l],++I[e[l]]}}c=en(e,u,i,w,I,C,k,x,R,l-R,c)}return Qt(a,0,r+Gt(c)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!o)};function rn(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,i=n.length,s=0;s!=i;){for(var a=Math.min(s+5552,i);s<a;++s)o+=r+=n[s];r%=65521,o%=65521}e=r,t=o},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r,o,i,s=nn(e,t,2,4);return r=s,o=t.level,i=0==o?0:o<6?1:9==o?3:2,r[0]=120,r[1]=i<<6|(i?32-2*i:1),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(s,s.length-4,n.d()),s}const on=e=>{const t={...e,v:"v1"};return function(e,t){var n="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var r=0;r<e.length;){var o=e[r++];o<128||t?n+=String.fromCharCode(o):o<224?n+=String.fromCharCode((31&o)<<6|63&e[r++]):o<240?n+=String.fromCharCode((15&o)<<12|(63&e[r++])<<6|63&e[r++]):(o=((15&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,n+=String.fromCharCode(55296|o>>10,56320|1023&o))}return n}(rn(function(e,t){var n=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new xt(e.length+(e.length>>>1)),o=0,i=function(e){r[o++]=e},s=0;s<n;++s){if(o+5>r.length){var a=new xt(o+8+(n-s<<1));a.set(r),r=a}var u=e.charCodeAt(s);u<128||t?i(u):u<2048?(i(192|u>>>6),i(128|63&u)):u>55295&&u<57344?(i(240|(u=65536+(1047552&u)|1023&e.charCodeAt(++s))>>>18),i(128|u>>>12&63),i(128|u>>>6&63),i(128|63&u)):(i(224|u>>>12),i(128|u>>>6&63),i(128|63&u))}return Qt(r,0,o)}(JSON.stringify(t))),!0)};var sn=function(){function e(e,t,n,r){var o,i,s,a=this;this.taskQueue=[],this.isProcessing=!1,this.compressEvent=function(e){var t=on(e);return JSON.stringify(t)},this.addCompressedEventToManager=function(e,t){a.eventsManager&&a.deviceId&&a.eventsManager.addEvent({event:{type:"replay",data:e},sessionId:t,deviceId:a.deviceId})},this.addCompressedEvent=function(e,t){if(a.worker)a.worker.postMessage({event:e,sessionId:t});else{var n=a.compressEvent(e);a.addCompressedEventToManager(n,t)}},this.terminate=function(){var e;null===(e=a.worker)||void 0===e||e.terminate()};var u=f();this.canUseIdleCallback=u&&"requestIdleCallback"in u,this.eventsManager=e,this.config=t,this.deviceId=n,this.timeout=(null===(o=t.performanceConfig)||void 0===o?void 0:o.timeout)||2e3;var c=null!==(i='var WebWorker=function(r){"use strict";var n=Uint8Array,e=Uint16Array,f=Uint32Array,t=new n([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),o=new n([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),a=new n([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),i=function(r,n){for(var t=new e(31),o=0;o<31;++o)t[o]=n+=1<<r[o-1];var a=new f(t[30]);for(o=1;o<30;++o)for(var i=t[o];i<t[o+1];++i)a[i]=i-t[o]<<5|o;return[t,a]},v=i(t,2),u=v[0],s=v[1];u[28]=258,s[258]=28;for(var l=i(o,0)[1],c=new e(32768),h=0;h<32768;++h){var g=(43690&h)>>>1|(21845&h)<<1;g=(61680&(g=(52428&g)>>>2|(13107&g)<<2))>>>4|(3855&g)<<4,c[h]=((65280&g)>>>8|(255&g)<<8)>>>1}var w=function(r,n,f){for(var t=r.length,o=0,a=new e(n);o<t;++o)++a[r[o]-1];var i,v=new e(n);for(o=0;o<n;++o)v[o]=v[o-1]+a[o-1]<<1;if(f){i=new e(1<<n);var u=15-n;for(o=0;o<t;++o)if(r[o])for(var s=o<<4|r[o],l=n-r[o],h=v[r[o]-1]++<<l,g=h|(1<<l)-1;h<=g;++h)i[c[h]>>>u]=s}else for(i=new e(t),o=0;o<t;++o)i[o]=c[v[r[o]-1]++]>>>15-r[o];return i},d=new n(288);for(h=0;h<144;++h)d[h]=8;for(h=144;h<256;++h)d[h]=9;for(h=256;h<280;++h)d[h]=7;for(h=280;h<288;++h)d[h]=8;var m=new n(32);for(h=0;h<32;++h)m[h]=5;var M=w(d,9,0),y=w(m,5,0),b=function(r){return(r/8|0)+(7&r&&1)},p=function(r,t,o){(null==o||o>r.length)&&(o=r.length);var a=new(r instanceof e?e:r instanceof f?f:n)(o-t);return a.set(r.subarray(t,o)),a},C=function(r,n,e){e<<=7&n;var f=n/8|0;r[f]|=e,r[f+1]|=e>>>8},x=function(r,n,e){e<<=7&n;var f=n/8|0;r[f]|=e,r[f+1]|=e>>>8,r[f+2]|=e>>>16},S=function(r,f){for(var t=[],o=0;o<r.length;++o)r[o]&&t.push({s:o,f:r[o]});var a=t.length,i=t.slice();if(!a)return[new n(0),0];if(1==a){var v=new n(t[0].s+1);return v[t[0].s]=1,[v,1]}t.sort((function(r,n){return r.f-n.f})),t.push({s:-1,f:25001});var u=t[0],s=t[1],l=0,c=1,h=2;for(t[0]={s:-1,f:u.f+s.f,l:u,r:s};c!=a-1;)u=t[t[l].f<t[h].f?l++:h++],s=t[l!=c&&t[l].f<t[h].f?l++:h++],t[c++]={s:-1,f:u.f+s.f,l:u,r:s};var g=i[0].s;for(o=1;o<a;++o)i[o].s>g&&(g=i[o].s);var w=new e(g+1),d=A(t[c-1],w,0);if(d>f){o=0;var m=0,M=d-f,y=1<<M;for(i.sort((function(r,n){return w[n.s]-w[r.s]||r.f-n.f}));o<a;++o){var b=i[o].s;if(!(w[b]>f))break;m+=y-(1<<d-w[b]),w[b]=f}for(m>>>=M;m>0;){var p=i[o].s;w[p]<f?m-=1<<f-w[p]++-1:++o}for(;o>=0&&m;--o){var C=i[o].s;w[C]==f&&(--w[C],++m)}d=f}return[new n(w),d]},A=function(r,n,e){return-1==r.s?Math.max(A(r.l,n,e+1),A(r.r,n,e+1)):n[r.s]=e},O=function(r){for(var n=r.length;n&&!r[--n];);for(var f=new e(++n),t=0,o=r[0],a=1,i=function(r){f[t++]=r},v=1;v<=n;++v)if(r[v]==o&&v!=n)++a;else{if(!o&&a>2){for(;a>138;a-=138)i(32754);a>2&&(i(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(i(o),--a;a>6;a-=6)i(8304);a>2&&(i(a-3<<5|8208),a=0)}for(;a--;)i(o);a=1,o=r[v]}return[f.subarray(0,t),n]},T=function(r,n){for(var e=0,f=0;f<n.length;++f)e+=r[f]*n[f];return e},k=function(r,n,e){var f=e.length,t=b(n+2);r[t]=255&f,r[t+1]=f>>>8,r[t+2]=255^r[t],r[t+3]=255^r[t+1];for(var o=0;o<f;++o)r[t+o+4]=e[o];return 8*(t+4+f)},E=function(r,n,f,i,v,u,s,l,c,h,g){C(n,g++,f),++v[256];for(var b=S(v,15),p=b[0],A=b[1],E=S(u,15),U=E[0],D=E[1],I=O(p),J=I[0],N=I[1],W=O(U),_=W[0],j=W[1],P=new e(19),q=0;q<J.length;++q)P[31&J[q]]++;for(q=0;q<_.length;++q)P[31&_[q]]++;for(var z=S(P,7),B=z[0],F=z[1],G=19;G>4&&!B[a[G-1]];--G);var H,K,L,Q,R=h+5<<3,V=T(v,d)+T(u,m)+s,X=T(v,p)+T(u,U)+s+14+3*G+T(P,B)+(2*P[16]+3*P[17]+7*P[18]);if(R<=V&&R<=X)return k(n,g,r.subarray(c,c+h));if(C(n,g,1+(X<V)),g+=2,X<V){H=w(p,A,0),K=p,L=w(U,D,0),Q=U;var Y=w(B,F,0);C(n,g,N-257),C(n,g+5,j-1),C(n,g+10,G-4),g+=14;for(q=0;q<G;++q)C(n,g+3*q,B[a[q]]);g+=3*G;for(var Z=[J,_],$=0;$<2;++$){var rr=Z[$];for(q=0;q<rr.length;++q){var nr=31&rr[q];C(n,g,Y[nr]),g+=B[nr],nr>15&&(C(n,g,rr[q]>>>5&127),g+=rr[q]>>>12)}}}else H=M,K=d,L=y,Q=m;for(q=0;q<l;++q)if(i[q]>255){nr=i[q]>>>18&31;x(n,g,H[nr+257]),g+=K[nr+257],nr>7&&(C(n,g,i[q]>>>23&31),g+=t[nr]);var er=31&i[q];x(n,g,L[er]),g+=Q[er],er>3&&(x(n,g,i[q]>>>5&8191),g+=o[er])}else x(n,g,H[i[q]]),g+=K[i[q]];return x(n,g,H[256]),g+K[256]},U=new f([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),D=function(r,a,i,v,u){return function(r,a,i,v,u,c){var h=r.length,g=new n(v+h+5*(1+Math.floor(h/7e3))+u),w=g.subarray(v,g.length-u),d=0;if(!a||h<8)for(var m=0;m<=h;m+=65535){var M=m+65535;M<h?d=k(w,d,r.subarray(m,M)):(w[m]=c,d=k(w,d,r.subarray(m,h)))}else{for(var y=U[a-1],C=y>>>13,x=8191&y,S=(1<<i)-1,A=new e(32768),O=new e(S+1),T=Math.ceil(i/3),D=2*T,I=function(n){return(r[n]^r[n+1]<<T^r[n+2]<<D)&S},J=new f(25e3),N=new e(288),W=new e(32),_=0,j=0,P=(m=0,0),q=0,z=0;m<h;++m){var B=I(m),F=32767&m,G=O[B];if(A[F]=G,O[B]=F,q<=m){var H=h-m;if((_>7e3||P>24576)&&H>423){d=E(r,w,0,J,N,W,j,P,z,m-z,d),P=_=j=0,z=m;for(var K=0;K<286;++K)N[K]=0;for(K=0;K<30;++K)W[K]=0}var L=2,Q=0,R=x,V=F-G&32767;if(H>2&&B==I(m-V))for(var X=Math.min(C,H)-1,Y=Math.min(32767,m),Z=Math.min(258,H);V<=Y&&--R&&F!=G;){if(r[m+L]==r[m+L-V]){for(var $=0;$<Z&&r[m+$]==r[m+$-V];++$);if($>L){if(L=$,Q=V,$>X)break;var rr=Math.min(V,$-2),nr=0;for(K=0;K<rr;++K){var er=m-V+K+32768&32767,fr=er-A[er]+32768&32767;fr>nr&&(nr=fr,G=er)}}}V+=(F=G)-(G=A[F])+32768&32767}if(Q){J[P++]=268435456|s[L]<<18|l[Q];var tr=31&s[L],or=31&l[Q];j+=t[tr]+o[or],++N[257+tr],++W[or],q=m+L,++_}else J[P++]=r[m],++N[r[m]]}}d=E(r,w,c,J,N,W,j,P,z,m-z,d)}return p(g,0,v+b(d)+u)}(r,null==a.level?6:a.level,null==a.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+a.mem,i,v,!u)};function I(r,n){void 0===n&&(n={});var e=function(){var r=1,n=0;return{p:function(e){for(var f=r,t=n,o=e.length,a=0;a!=o;){for(var i=Math.min(a+5552,o);a<i;++a)t+=f+=e[a];f%=65521,t%=65521}r=f,n=t},d:function(){return(r>>>8<<16|(255&n)<<8|n>>>8)+2*((255&r)<<23)}}}();e.p(r);var f,t,o,a=D(r,n,2,4);return f=a,t=n.level,o=0==t?0:t<6?1:9==t?3:2,f[0]=120,f[1]=o<<6|(o?32-2*o:1),function(r,n,e){for(;e;++n)r[n]=e,e>>>=8}(a,a.length-4,e.d()),a}const J=r=>{const e={...r,v:"v1"};return function(r,n){var e="";if(!n&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(r);for(var f=0;f<r.length;){var t=r[f++];t<128||n?e+=String.fromCharCode(t):t<224?e+=String.fromCharCode((31&t)<<6|63&r[f++]):t<240?e+=String.fromCharCode((15&t)<<12|(63&r[f++])<<6|63&r[f++]):(t=((15&t)<<18|(63&r[f++])<<12|(63&r[f++])<<6|63&r[f++])-65536,e+=String.fromCharCode(55296|t>>10,56320|1023&t))}return e}(I(function(r,e){var f=r.length;if(!e&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(r);for(var t=new n(r.length+(r.length>>>1)),o=0,a=function(r){t[o++]=r},i=0;i<f;++i){if(o+5>t.length){var v=new n(o+8+(f-i<<1));v.set(t),t=v}var u=r.charCodeAt(i);u<128||e?a(u):u<2048?(a(192|u>>>6),a(128|63&u)):u>55295&&u<57344?(a(240|(u=65536+(1047552&u)|1023&r.charCodeAt(++i))>>>18),a(128|u>>>12&63),a(128|u>>>6&63),a(128|63&u)):(a(224|u>>>12),a(128|u>>>6&63),a(128|63&u))}return p(t,0,o)}(JSON.stringify(e))),!0)};onmessage=r=>{const{event:n,sessionId:e}=r.data,f=JSON.stringify(J(n));postMessage({compressedEvent:f,sessionId:e})};const N=onmessage;return r.compressionOnMessage=N,Object.defineProperty(r,"__esModule",{value:!0}),r}({});\n')?i:r;if((null===(s=this.config.experimental)||void 0===s?void 0:s.useWebWorker)&&u&&u.Worker&&c){t.loggerProvider.log("[Experimental] Enabling web worker for compression");var l=new Worker(URL.createObjectURL(new Blob([c],{type:"application/javascript"})));l.onerror=function(e){t.loggerProvider.error(e)},l.onmessage=function(e){var t=e.data,n=t.compressedEvent,r=t.sessionId;a.addCompressedEventToManager(n,r)},this.worker=l}}return e.prototype.scheduleIdleProcessing=function(){var e=this;this.isProcessing||(this.isProcessing=!0,requestIdleCallback((function(t){e.processQueue(t)}),{timeout:this.timeout}))},e.prototype.enqueueEvent=function(e,t){var n;this.canUseIdleCallback&&(null===(n=this.config.performanceConfig)||void 0===n?void 0:n.enabled)?(this.config.loggerProvider.debug("Enqueuing event for processing during idle time."),this.taskQueue.push({event:e,sessionId:t}),this.scheduleIdleProcessing()):(this.config.loggerProvider.debug("Processing event without idle callback."),this.addCompressedEvent(e,t))},e.prototype.processQueue=function(e){for(var t=this;this.taskQueue.length>0&&(e.timeRemaining()>0||e.didTimeout);){var n=this.taskQueue.shift();if(n){var r=n.event,o=n.sessionId;this.addCompressedEvent(r,o)}}this.taskQueue.length>0?requestIdleCallback((function(e){t.processQueue(e)}),{timeout:this.timeout}):this.isProcessing=!1},e}(),an=function(){function e(){var e=this;this.name="@amplitude/session-replay-browser",this.recordCancelCallback=null,this.eventCount=0,this.pageLeaveFns=[],this.recordFunction=null,this.teardownEventListeners=function(t){var n=f();n&&(n.removeEventListener("blur",e.blurListener),n.removeEventListener("focus",e.focusListener),!t&&n.addEventListener("blur",e.blurListener),!t&&n.addEventListener("focus",e.focusListener),n.self&&"onpagehide"in n.self?(n.removeEventListener("pagehide",e.pageLeaveListener),!t&&n.addEventListener("pagehide",e.pageLeaveListener)):(n.removeEventListener("beforeunload",e.pageLeaveListener),!t&&n.addEventListener("beforeunload",e.pageLeaveListener)))},this.blurListener=function(){e.sendEvents()},this.focusListener=function(){e.recordEvents(!1)},this.pageLeaveListener=function(t){e.pageLeaveFns.forEach((function(e){e(t)}))},this.addCustomRRWebEvent=function(t,i,s){return void 0===i&&(i={}),void 0===s&&(s=!0),r(e,void 0,void 0,(function(){var e,r,a,u;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),e=void 0,(r=this.config)&&t!==L.METADATA?(e={config:V(r),version:ce},s?[4,J()]:[3,2]):[3,2];case 1:a=o.sent(),e=n(n({},a),e),o.label=2;case 2:return this.recordCancelCallback&&this.recordFunction?this.recordFunction.addCustomEvent(t,n(n({},i),e)):this.loggerProvider.debug("Not able to add custom replay capture event ".concat(t," due to no ongoing recording.")),[3,4];case 3:return u=o.sent(),this.loggerProvider.debug("Error while adding custom replay capture event: ",u),[3,4];case 4:return[2]}}))}))},this.stopRecordingEvents=function(){var t;try{e.loggerProvider.log("Session Replay capture stopping."),e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null,null===(t=e.networkObservers)||void 0===t||t.stop()}catch(t){var n=t;e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(n.toString()))}},this.loggerProvider=new F(new p)}return e.prototype.init=function(e,t){return v(this._init(e,t))},e.prototype._init=function(e,t){var n,i,u,c,l,d;return r(this,void 0,void 0,(function(){var r,v,h,g,y,m,b,S,w,I,C,E,k,x;return o(this,(function(o){switch(o.label){case 0:return this.loggerProvider=new F(t.loggerProvider||new p),Object.prototype.hasOwnProperty.call(t,"logLevel")&&this.loggerProvider.enable(t.logLevel),this.identifiers=new kt({sessionId:t.sessionId,deviceId:t.deviceId}),r=this,[4,ae(e,t)];case 1:return r.joinedConfigGenerator=o.sent(),[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)];case 2:v=o.sent(),h=v.joinedConfig,g=v.localConfig,y=v.remoteConfig,this.config=h,this.setMetadata(t.sessionId,h,g,y,null===(n=t.version)||void 0===n?void 0:n.version,ce,null===(i=t.version)||void 0===i?void 0:i.type),t.sessionId&&(null===(u=this.config.interactionConfig)||void 0===u?void 0:u.enabled)&&(m=Et.default({sessionId:t.sessionId,type:"interaction"},this.config),this.pageLeaveFns=[m.send(this.getDeviceId.bind(this)).bind(m)],this.scrollHook=m.hook.bind(m)),b=[],"idb"!==(S=this.config.storeType)||(null===(c=f())||void 0===c?void 0:c.indexedDB)||(S="memory",this.loggerProvider.warn("Could not use preferred indexedDB storage, reverting to in memory option.")),this.loggerProvider.log("Using ".concat(S," for event storage.")),o.label=3;case 3:return o.trys.push([3,5,,6]),[4,Ge({config:this.config,sessionId:this.identifiers.sessionId,type:"replay",storeType:S})];case 4:return w=o.sent(),b.push({name:"replay",manager:w}),[3,6];case 5:return I=o.sent(),x=I,this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(x.toString())),[3,6];case 6:if(!(null===(l=this.config.interactionConfig)||void 0===l?void 0:l.enabled))return[3,10];C=this.config.interactionConfig.batch?wt:St,o.label=7;case 7:return o.trys.push([7,9,,10]),[4,Ge({config:this.config,sessionId:this.identifiers.sessionId,type:"interaction",minInterval:null!==(d=this.config.interactionConfig.trackEveryNms)&&void 0!==d?d:3e4,maxInterval:6e4,payloadBatcher:C,storeType:S})];case 8:return E=o.sent(),b.push({name:"interaction",manager:E}),[3,10];case 9:return k=o.sent(),x=k,this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(x.toString())),[3,10];case 10:return this.eventsManager=new(Qe.bind.apply(Qe,a([void 0],s(b),!1))),this.eventCompressor&&this.eventCompressor.terminate(),this.eventCompressor=new sn(this.eventsManager,this.config,this.getDeviceId()),[4,this.initializeNetworkObservers()];case 11:return o.sent(),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),this.teardownEventListeners(!1),this.initialize(!0),[2]}}))}))},e.prototype.setSessionId=function(e,t){return v(this.asyncSetSessionId(e,t))},e.prototype.asyncSetSessionId=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return(n=this.identifiers&&this.identifiers.sessionId)&&this.sendEvents(n),r=t||this.getDeviceId(),this.identifiers=new kt({sessionId:e,deviceId:r}),this.joinedConfigGenerator&&n?[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)]:[3,2];case 1:i=o.sent().joinedConfig,this.config=i,o.label=2;case 2:return this.recordEvents(),[2]}}))}))},e.prototype.getSessionReplayProperties=function(){var e,t=this.config,n=this.identifiers;if(!t||!n)return this.loggerProvider.warn("Session replay init has not been called, cannot get session replay properties."),{};var r=this.getShouldRecord(),o={};return r&&((e={})[N]=n.sessionReplayId?n.sessionReplayId:null,o=e,t.debugMode&&(o[U]=JSON.stringify({appHash:Q(t.apiKey).toString()}))),this.addCustomRRWebEvent(L.GET_SR_PROPS,{shouldRecord:r,eventProperties:o},10===this.eventCount),10===this.eventCount&&(this.eventCount=0),this.eventCount++,o},e.prototype.sendEvents=function(e){var t,n=e||(null===(t=this.identifiers)||void 0===t?void 0:t.sessionId),r=this.getDeviceId();this.eventsManager&&n&&r&&this.eventsManager.sendCurrentSequenceEvents({sessionId:n,deviceId:r})},e.prototype.initialize=function(e){var t;return void 0===e&&(e=!1),r(this,void 0,void 0,(function(){var n;return o(this,(function(r){return(null===(t=this.identifiers)||void 0===t?void 0:t.sessionId)?(n=this.getDeviceId())?(this.eventsManager&&e&&this.eventsManager.sendStoredEvents({deviceId:n}),[2,this.recordEvents()]):(this.loggerProvider.log("Session is not being recorded due to lack of device id."),[2,Promise.resolve()]):(this.loggerProvider.log("Session is not being recorded due to lack of session id."),[2,Promise.resolve()])}))}))},e.prototype.shouldOptOut=function(){var e,t,n,r;(null===(e=this.config)||void 0===e?void 0:e.instanceName)&&(n=(r=this.config.instanceName,void 0===r&&(r="$default_instance"),T.getInstance(r)).identityStore.getIdentity().optOut);return void 0!==n?n:null===(t=this.config)||void 0===t?void 0:t.optOut},e.prototype.getShouldRecord=function(){if(!this.identifiers||!this.config||!this.identifiers.sessionId)return this.loggerProvider.warn("Session is not being recorded due to lack of config, please call sessionReplay.init."),!1;if(!this.config.captureEnabled)return this.loggerProvider.log("Session ".concat(this.identifiers.sessionId," not being captured due to capture being disabled for project or because the remote config could not be fetched.")),!1;if(this.shouldOptOut())return this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to optOut config.")),!1;var e,t,n,r=(e=this.identifiers.sessionId,t=this.config.sampleRate,n=Q(e.toString()),31*Math.abs(n)%1e6/1e6<t);return r||this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate.")),r},e.prototype.getBlockSelectors=function(){var e,t,n,r=null!==(n=null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.blockSelector)&&void 0!==n?n:[];if(0!==r.length)return r},e.prototype.getMaskTextSelectors=function(){var e,t,n,r;if("conservative"===(null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.defaultMaskLevel))return"*";var o=null===(r=null===(n=this.config)||void 0===n?void 0:n.privacyConfig)||void 0===r?void 0:r.maskSelector;return o||void 0},e.prototype.getRecordingPlugins=function(e){var t;return r(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:if(n=[],!(null===(t=null==e?void 0:e.console)||void 0===t?void 0:t.enabled))return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,import("./console-plugin-min.js")];case 2:return r=o.sent().getRecordConsolePlugin,n.push(r({level:e.console.levels})),[3,4];case 3:return i=o.sent(),this.loggerProvider.warn("Failed to load console plugin:",i),[3,4];case 4:return[2,n.length>0?n:void 0]}}))}))},e.prototype.getRecordFunction=function(){return r(this,void 0,void 0,(function(){var e,t;return o(this,(function(n){switch(n.label){case 0:if(this.recordFunction)return[2,this.recordFunction];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,import("./rrweb-record-min.js")];case 2:return e=n.sent().record,this.recordFunction=e,[2,e];case 3:return t=n.sent(),this.loggerProvider.warn("Failed to load rrweb-record module:",t),[2,null];case 4:return[2]}}))}))},e.prototype.recordEvents=function(e){var t,n,i;return void 0===e&&(e=!0),r(this,void 0,void 0,(function(){var r,s,a,u,c,l,d,f,v,h,p,g,y,m=this;return o(this,(function(o){switch(o.label){case 0:return r=this.config,s=this.getShouldRecord(),a=null===(t=this.identifiers)||void 0===t?void 0:t.sessionId,s&&a&&r?(this.stopRecordingEvents(),[4,this.getRecordFunction()]):[2];case 1:return(u=o.sent())?[4,this.initializeNetworkObservers()]:[2];case 2:o.sent(),null===(n=this.networkObservers)||void 0===n||n.start((function(e){m.addCustomRRWebEvent(L.FETCH_REQUEST,e)})),c=r.privacyConfig,l=r.interactionConfig,d=r.loggingConfig,f=(null==l?void 0:l.enabled)?{mouseInteraction:this.eventsManager&&It(this.loggerProvider,{eventsManager:this.eventsManager,sessionId:a,deviceIdFn:this.getDeviceId.bind(this),mirror:u.mirror,ugcFilterRules:null!==(i=l.ugcFilterRules)&&void 0!==i?i:[]}),scroll:this.scrollHook}:{},v=(null==l?void 0:l.enabled)&&l.ugcFilterRules?l.ugcFilterRules:[],this.loggerProvider.log("Session Replay capture beginning for ".concat(a,".")),o.label=3;case 3:return o.trys.push([3,5,,6]),h=this,p=u,y={emit:function(e){if(m.shouldOptOut())return m.loggerProvider.log("Opting session ".concat(a," out of recording due to optOut config.")),m.stopRecordingEvents(),void m.sendEvents();e.type===Y.Meta&&(e.data.href=H(e.data.href,v)),m.eventCompressor&&m.eventCompressor.enqueueEvent(e,a)},inlineStylesheet:r.shouldInlineStylesheet,hooks:f,maskAllInputs:!0,maskTextClass:B,blockClass:"amp-block",blockSelector:this.getBlockSelectors(),applyBackgroundColorToBlockedElements:r.applyBackgroundColorToBlockedElements,maskInputFn:G("input",c),maskTextFn:G("text",c),maskTextSelector:this.getMaskTextSelectors(),recordCanvas:!1,errorHandler:function(e){var t=e;if(t.message.includes("insertRule")&&t.message.includes("CSSStyleSheet"))throw t;if(t._external_)throw t;return m.loggerProvider.warn("Error while capturing replay: ",t.toString()),!0}},[4,this.getRecordingPlugins(d)];case 4:return h.recordCancelCallback=p.apply(void 0,[(y.plugins=o.sent(),y)]),this.addCustomRRWebEvent(L.DEBUG_INFO),e&&this.addCustomRRWebEvent(L.METADATA,this.metadata),[3,6];case 5:return g=o.sent(),this.loggerProvider.warn("Failed to initialize session replay:",g),[3,6];case 6:return[2]}}))}))},e.prototype.getDeviceId=function(){var e;return null===(e=this.identifiers)||void 0===e?void 0:e.deviceId},e.prototype.getSessionId=function(){var e;return null===(e=this.identifiers)||void 0===e?void 0:e.sessionId},e.prototype.flush=function(e){var t;return void 0===e&&(e=!1),r(this,void 0,void 0,(function(){return o(this,(function(n){return[2,null===(t=this.eventsManager)||void 0===t?void 0:t.flush(e)]}))}))},e.prototype.shutdown=function(){this.teardownEventListeners(!0),this.stopRecordingEvents(),this.sendEvents()},e.prototype.mapSDKType=function(e){return"plugin"===e?"@amplitude/plugin-session-replay-browser":"segment"===e?"@amplitude/segment-session-replay-plugin":null},e.prototype.setMetadata=function(e,t,n,r,o,i,s){var a=(null==e?void 0:e.toString())?Q(e.toString()):void 0;this.metadata={joinedConfig:t,localConfig:n,remoteConfig:r,sessionId:e,hashValue:a,sampleRate:t.sampleRate,replaySDKType:this.mapSDKType(s),replaySDKVersion:o,standaloneSDKType:"@amplitude/session-replay-browser",standaloneSDKVersion:i}},e.prototype.initializeNetworkObservers=function(){var e,t,n;return r(this,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:if(!(null===(n=null===(t=null===(e=this.config)||void 0===e?void 0:e.loggingConfig)||void 0===t?void 0:t.network)||void 0===n?void 0:n.enabled)||this.networkObservers)return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,import("./observers-min.js")];case 2:return r=o.sent().NetworkObservers,this.networkObservers=new r,[3,4];case 3:return i=o.sent(),this.loggerProvider.warn("Failed to import or instantiate NetworkObservers:",i),[3,4];case 4:return[2]}}))}))},e}(),un=function(e){return function(){var t=e.config||Z();return{logger:t.loggerProvider,logLevel:t.logLevel}}},cn=function(){var e=new an;return{init:O(e.init.bind(e),"init",un(e)),setSessionId:O(e.setSessionId.bind(e),"setSessionId",un(e)),getSessionId:O(e.getSessionId.bind(e),"getSessionId",un(e)),getSessionReplayProperties:O(e.getSessionReplayProperties.bind(e),"getSessionReplayProperties",un(e)),flush:O(e.flush.bind(e),"flush",un(e)),shutdown:O(e.shutdown.bind(e),"shutdown",un(e))}}(),ln=cn.init,dn=cn.setSessionId,fn=cn.getSessionId,vn=cn.getSessionReplayProperties,hn=cn.flush,pn=cn.shutdown;const gn="1.19.3";class yn{constructor(e){this.name=yn.pluginName,this.type="enrichment",this.sessionReplay={flush:hn,getSessionId:fn,getSessionReplayProperties:vn,init:ln,setSessionId:dn,shutdown:pn},this.options=Object.assign({forceSessionTracking:!1},e),this.srInitOptions=this.options}setup(e,t){var n,o,i,s,a;return r(this,void 0,void 0,(function*(){try{null==e||e.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${gn}.`),this.config=e,this.options.forceSessionTracking&&("boolean"==typeof e.defaultTracking?!1===e.defaultTracking&&(e.defaultTracking={pageViews:!1,formInteractions:!1,fileDownloads:!1,sessions:!0}):e.defaultTracking=Object.assign(Object.assign({},e.defaultTracking),{sessions:!0})),this.srInitOptions={instanceName:this.config.instanceName,deviceId:null!==(n=this.options.deviceId)&&void 0!==n?n:this.config.deviceId,optOut:this.config.optOut,sessionId:this.options.customSessionId?void 0:this.config.sessionId,loggerProvider:this.config.loggerProvider,logLevel:this.config.logLevel,flushMaxRetries:this.config.flushMaxRetries,serverZone:this.config.serverZone,configServerUrl:this.options.configServerUrl,trackServerUrl:this.options.trackServerUrl,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:null===(o=this.options.privacyConfig)||void 0===o?void 0:o.blockSelector,maskSelector:null===(i=this.options.privacyConfig)||void 0===i?void 0:i.maskSelector,unmaskSelector:null===(s=this.options.privacyConfig)||void 0===s?void 0:s.unmaskSelector,defaultMaskLevel:null===(a=this.options.privacyConfig)||void 0===a?void 0:a.defaultMaskLevel},debugMode:this.options.debugMode,shouldInlineStylesheet:this.options.shouldInlineStylesheet,version:{type:"plugin",version:gn},performanceConfig:this.options.performanceConfig,storeType:this.options.storeType,experimental:this.options.experimental,applyBackgroundColorToBlockedElements:this.options.applyBackgroundColorToBlockedElements,interactionConfig:this.options.interactionConfig},yield this.sessionReplay.init(e.apiKey,this.srInitOptions).promise}catch(t){null==e||e.loggerProvider.error(`Session Replay: Failed to initialize due to ${t.message}`)}}))}onSessionIdChanged(e){return r(this,void 0,void 0,(function*(){this.config.loggerProvider.debug(`Analytics session id is changed to ${e}, SR session id is ${String(this.sessionReplay.getSessionId())}.`),yield this.sessionReplay.setSessionId(e).promise}))}onOptOutChanged(e){return r(this,void 0,void 0,(function*(){this.config.loggerProvider.debug(`optOut is changed to ${String(e)}, calling ${e?"sessionReplay.shutdown()":"sessionReplay.init()"}.`),e?this.sessionReplay.shutdown():yield this.sessionReplay.init(this.config.apiKey,this.srInitOptions).promise}))}execute(e){var t;return r(this,void 0,void 0,(function*(){try{if(this.options.customSessionId){const t=this.options.customSessionId(e);if(t){t!==this.sessionReplay.getSessionId()&&(yield this.sessionReplay.setSessionId(t).promise);const n=this.sessionReplay.getSessionReplayProperties();e.event_properties=Object.assign(Object.assign({},e.event_properties),n)}}else{const t=this.config.sessionId;if(t&&t!==this.sessionReplay.getSessionId()&&(yield this.sessionReplay.setSessionId(t).promise),t&&t===e.session_id){const t=this.sessionReplay.getSessionReplayProperties();e.event_properties=Object.assign(Object.assign({},e.event_properties),t)}}return Promise.resolve(e)}catch(n){return null===(t=this.config)||void 0===t||t.loggerProvider.error(`Session Replay: Failed to enrich event due to ${n.message}`),Promise.resolve(e)}}))}teardown(){var e;return r(this,void 0,void 0,(function*(){try{this.sessionReplay.shutdown(),this.config=null}catch(t){null===(e=this.config)||void 0===e||e.loggerProvider.error(`Session Replay: teardown failed due to ${t.message}`)}}))}getSessionReplayProperties(){return this.sessionReplay.getSessionReplayProperties()}}yn.pluginName="@amplitude/plugin-session-replay-browser";const mn=e=>new yn(e);export{yn as S,r as _,o as a,f as g,mn as s};
|
|
2
2
|
//# sourceMappingURL=index-min.js.map
|
|
Binary file
|