@launchdarkly/session-replay 1.1.23 → 1.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as o, P as r } from "./index-R4CurByQ.js";
1
+ import { t as o, P as r } from "./index-CMlpO4fn.js";
2
2
  export {
3
3
  o as LDRecord,
4
4
  r as default
package/dist/index.umd.js CHANGED
@@ -275,7 +275,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):d
275
275
  }
276
276
  }
277
277
  ${vr}
278
- `,fu=(e,t,s,n)=>e();function bu(e,t=fu){return{PushPayload(s,n){return t(r=>e.request(lu,s,ne(ne({},n),r)),"PushPayload","mutation",s)},PushSessionEvents(s,n){return t(r=>e.request(Wr,s,ne(ne({},n),r)),"PushSessionEvents","mutation",s)},identifySession(s,n){return t(r=>e.request(au,s,ne(ne({},n),r)),"identifySession","mutation",s)},addSessionProperties(s,n){return t(r=>e.request(cu,s,ne(ne({},n),r)),"addSessionProperties","mutation",s)},pushMetrics(s,n){return t(r=>e.request(uu,s,ne(ne({},n),r)),"pushMetrics","mutation",s)},addSessionFeedback(s,n){return t(r=>e.request(du,s,ne(ne({},n),r)),"addSessionFeedback","mutation",s)},initializeSession(s,n){return t(r=>e.request(hu,s,ne(ne({},n),r)),"initializeSession","mutation",s)},Ignore(s,n){return t(r=>e.request(pu,s,ne(ne({},n),r)),"Ignore","query",s)},GetSamplingConfig(s,n){return t(r=>e.request(mu,s,ne(ne({},n),r)),"GetSamplingConfig","query",s)}}}function yu(){var e=document.createElement("canvas");return e.getContext&&e.getContext("2d")?e.toDataURL("image/webp").indexOf("data:image/webp")==0:!1}function gu(){return yu()?{type:"image/webp",quality:.9}:{type:"image/jpeg",quality:.6}}const Zu="telemetry.sdk.name",Su="telemetry.sdk.version",wr=1e3,Iu=1e3*2,Xu=4*60*60*1e3,un=15*60*1e3,kr={normal:{bytes:1e7,time:4*60*1e3},canvas:{bytes:16e6,time:5e3}},Vu=100,Cr="app.highlight.io",Gu="https://app.launchdarkly.com",Ru={"observability.ld-stg.launchdarkly.com":"ld-stg.launchdarkly.com","observability.app.launchdarkly.com":"app.launchdarkly.com","observability.app.ld.catamorphic.com":"app.ld.catamorphic.com"},vu="/projects/default",Wu=new RegExp("pub\\.(?<domain>.+)");/*! js-cookie v3.0.8 | MIT */function ns(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)n!=="__proto__"&&(e[n]=s[n])}return e}var wu={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function dn(e,t){function s(r,l,d){if(typeof document<"u"){d=ns({},t,d),typeof d.expires=="number"&&(d.expires=new Date(Date.now()+d.expires*864e5)),d.expires&&(d.expires=d.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var f="";for(var h in d)d[h]&&(f+="; "+h,d[h]!==!0&&(f+="="+d[h].split(";")[0]));return document.cookie=r+"="+e.write(l,r)+f}}function n(r){if(!(typeof document>"u"||arguments.length&&!r)){for(var l=document.cookie?document.cookie.split("; "):[],d={},f=0;f<l.length;f++){var h=l[f].split("="),m=h.slice(1).join("=");try{var p=decodeURIComponent(h[0]);if(p in d||(d[p]=e.read(m,p)),r===p)break}catch{}}return r?d[r]:d}}return Object.create({set:s,get:n,remove:function(r,l){s(r,"",ns({},l,{expires:-1}))},withAttributes:function(r){return dn(this.converter,ns({},this.attributes,r))},withConverter:function(r){return dn(ns({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var is=dn(wu,{path:"/"}),hn=(e=>(e.CLIENT_ID="highlightClientID",e))(hn||{});let rs="localStorage",pn=!0,ku=class{constructor(){Rt(this,"storage",{})}get length(){return Object.keys(this.storage).length}key(t){var s;return(s=Object.keys(this.storage)[t])!=null?s:null}getItem(t){var s;return(s=this.storage[t])!=null?s:""}setItem(t,s){this.storage[t]=s}removeItem(t){delete this.storage[t]}},Cu=class{getItem(t){var s;return(s=is.get(t))!=null?s:""}setItem(t,s){if(!pn)return;const n=new Date;n.setTime(n.getTime()+un),is.set(t,s,{expires:n})}removeItem(t){pn&&is.remove(t)}keys(){var t;return Object.keys((t=is.get())!=null?t:{})}};const pt=new ku,mt=new Cu,os=()=>{let e=null;if(typeof window>"u")return pt;try{switch(rs){case"localStorage":e=window.localStorage;break;case"sessionStorage":e=window.sessionStorage;break}e||(lt("storage","getPersistentStorage","debug",`persistent storage was not found for mode ${rs}; using global storage`),e=pt)}catch(t){lt("storage","getPersistentStorage","debug","failed to get persistent storage; using global storage",t),e=pt}return e},xu=e=>{rs=e},xr=e=>{pn=e},Ce=e=>{try{return os().getItem(e)}catch(t){return lt("storage","getItem","debug",`failed to get item ${e}; using global storage`,t),pt.getItem(e)}},He=(e,t)=>{mt.setItem(e,t);try{return os().setItem(e,t)}catch(s){return lt("storage","setItem","debug",`failed to set item ${e}; using global storage`,s),pt.setItem(e,t)}},ls=e=>{mt.removeItem(e);try{return os().removeItem(e)}catch(t){return lt("storage","removeItem","debug",`failed to remove item ${e}; using global storage`,t),pt.removeItem(e)}},Tu=e=>{if(rs==="sessionStorage"){console.warn("highlight.io cannot use local storage; segment integration will not work");return}if(typeof window>"u"){console.warn("highlight.io cannot use local storage (not a window); segment integration will not work");return}const t=window.localStorage.setItem;window.localStorage.setItem=function(){const[s,n]=arguments;e({keyName:s,keyValue:n}),t.apply(this,[s,n])}};var Xe=(e=>(e.SEGMENT_LAST_SENT_HASH_KEY="HIGHLIGHT_SEGMENT_LAST_SENT_HASH_KEY",e.SESSION_ID="sessionID",e.SESSION_DATA="sessionData",e.USER_IDENTIFIER="highlightIdentifier",e.USER_OBJECT="highlightUserObject",e))(Xe||{});const as=e=>`${Xe.SESSION_DATA}_${e}`,Lu=()=>{var e;return typeof globalThis<"u"&&(e=globalThis.persistentSessionSecureID)!=null&&e.length?globalThis.persistentSessionSecureID:Tr()},Nu=e=>{typeof globalThis<"u"&&e!=null&&e.length&&(globalThis.persistentSessionSecureID=e)},Tr=()=>{var e;return(e=Ce(Xe.SESSION_ID))!=null?e:""},kt=e=>{He(Xe.SESSION_ID,e)},Ju=e=>{const t=as(e);return JSON.parse(Ce(t)||"{}")},cs=e=>{e||(e=Tr());let t=Ju(e);if(t&&t.lastPushTime&&Date.now()-t.lastPushTime<un)return t;ls(as(e))},st=function(e){if(!(e!=null&&e.sessionSecureID))return;const t=e.sessionSecureID;Nu(t);const s=as(t);He(s,JSON.stringify(e)),Uu(s)},Yu=function(){const e=mt.getItem(Xe.SESSION_ID);kt(e);const t=as(e),s=mt.getItem(t);try{st(JSON.parse(s))}catch{}};function Uu(e){var t;const s=`${Xe.SESSION_DATA}_`,n=new Set,r=os();for(let l=r.length-1;l>=0;l--){const d=r.key(l);d&&d.startsWith(s)&&d!==e&&n.add(d)}for(const l of mt.keys())l.startsWith(s)&&l!==e&&n.add(l);for(const l of n){let d=!0;try{const f=Ce(l)||mt.getItem(l)||"{}",h=JSON.parse(f),m=(t=h.lastPushTime)!=null?t:h.sessionStartTime;d=m===void 0||Date.now()-m>=un}catch{}d&&(lt("highlightSession","pruneSessionData","debug",`removing session data for stale key ${l}`),ls(l))}}var Lr=(e=>(e.BillingQuotaExceeded="BillingQuotaExceeded",e))(Lr||{});const Fu=3,Mu=1e3,Ou=500,Ku=[Lr.BillingQuotaExceeded.toString()],Eu=e=>{var t;return((t=e.response.errors)==null?void 0:t.find(s=>Ku.includes(s.message)))===void 0},zu=()=>{const e=(t,s,n,r,l=0)=>at(void 0,null,function*(){try{return yield t()}catch(d){if(d instanceof dt&&!Eu(d))throw d;if(l<Fu)return yield new Promise(f=>setTimeout(f,Mu+Ou*Math.pow(2,l))),yield e(t,s,n,r,l+1);throw console.error(`highlight.io: data request failed after ${l} retries`),d}});return e},Nr="feature_flag",Jr="launchdarkly",Hu=`${Nr}.set.id`,Pu=`${Nr}.provider.name`,Du=`${Jr}.application.id`,Bu=`${Jr}.application.version`,Qu="$ld:telemetry:session:init",Yr="$ld:telemetry:track";function Ur(e){return e.includes("%")||e.includes(":")?e.replace(/%/g,"%25").replace(/:/g,"%3A"):e}function Fr(e){return e.kind==="multi"}function Mr(e){return Fr(e)?Object.keys(e).sort().filter(t=>t!=="kind").map(t=>`${t}:${Ur(e[t].key)}`).join(":"):"kind"in e&&e.kind==="user"?e.key:"kind"in e?`${e.kind}:${Ur(e.key)}`:e.key}function ju(e){return Fr(e)?Object.keys(e).sort().filter(t=>t!=="kind").map(t=>({[t]:e[t].key})).reduce((t,s)=>ne(ne({},t),s),{}):"kind"in e?{[e.kind]:e.key}:{user:e.key}}let Au=class{constructor(t,s){Rt(this,"client"),Rt(this,"metadata"),this.client=t,this.metadata=s}getHooks(t){return[]}init(t){this.client.track(Qu,{sessionID:t})}recordGauge(t,s){}identify(t,s,n={},r){}error(t,s){}track(t,s){const n=s.event;this.client.track(n?`${Yr}:${n}`:Yr,Bt(ne({},s),{sessionID:t}))}},_u=class extends Bs{constructor(t,s){super(),Rt(this,"client"),this.client=new Au(t,s)}getHooks(t){return[{getMetadata:()=>({name:"highlight.run/ld"}),afterIdentify:(s,n,r)=>(this.load(this.client),n)}]}init(t){return this._bufferCall("init",[t])}recordGauge(t,s){return this._bufferCall("recordGauge",[t,s])}identify(t,s,n={},r){return this._bufferCall("identify",[t,s,n,r])}error(t,s){return this._bufferCall("error",[t,s])}track(t,s){return this._bufferCall("track",[t,s])}};const $u=e=>{e(window.location.href);const t=history.pushState;history.pushState=(l=>function(){var d=l.apply(this,arguments);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange")),d})(history.pushState);const s=history.replaceState;history.replaceState=(l=>function(){var d=l.apply(this,arguments);return window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange")),d})(history.replaceState);const n=()=>{window.dispatchEvent(new Event("locationchange"))};window.addEventListener("popstate",n);const r=function(){e(window.location.href)};return window.addEventListener("locationchange",r),()=>{window.removeEventListener("popstate",n),window.removeEventListener("locationchange",r),history.pushState=t,history.replaceState=s}},qu="10.7.5",ed={version:qu},td=ed.version;function Or(e,t){return nd(e)}function sd(e){if(e.id.length)return`#${e.id}`;if(e.classList.length){let t=[];for(const s of e.classList)t.push(`.${s}`);return`${e.nodeName.toLowerCase()}${t.join(",")}`}return e.nodeName.toLowerCase()}const nd=e=>{let t="";const s=e.getAttribute("class"),n=e.getAttribute("id");return n&&(t=t.concat(Kr(n,"#"))),s&&(t=t.concat(Kr(s,"."))),t===""&&(t=t.concat(e.tagName.toLowerCase())),t},Kr=(e,t)=>`${t}${e.trim().split(" ").join(t)}`,id=e=>{let t;const s=()=>{clearTimeout(t),t=setTimeout(()=>{var n,r;e({height:window.innerHeight,width:window.innerWidth,availHeight:window.screen.availHeight,availWidth:window.screen.availWidth,colorDepth:window.screen.colorDepth,pixelDepth:window.screen.pixelDepth,orientation:(r=(n=window.screen.orientation)==null?void 0:n.angle)!=null?r:0})},500)};return window.addEventListener("resize",s),s(),()=>window.removeEventListener("resize",s)};var Er={exports:{}};/**
278
+ `,fu=(e,t,s,n)=>e();function bu(e,t=fu){return{PushPayload(s,n){return t(r=>e.request(lu,s,ne(ne({},n),r)),"PushPayload","mutation",s)},PushSessionEvents(s,n){return t(r=>e.request(Wr,s,ne(ne({},n),r)),"PushSessionEvents","mutation",s)},identifySession(s,n){return t(r=>e.request(au,s,ne(ne({},n),r)),"identifySession","mutation",s)},addSessionProperties(s,n){return t(r=>e.request(cu,s,ne(ne({},n),r)),"addSessionProperties","mutation",s)},pushMetrics(s,n){return t(r=>e.request(uu,s,ne(ne({},n),r)),"pushMetrics","mutation",s)},addSessionFeedback(s,n){return t(r=>e.request(du,s,ne(ne({},n),r)),"addSessionFeedback","mutation",s)},initializeSession(s,n){return t(r=>e.request(hu,s,ne(ne({},n),r)),"initializeSession","mutation",s)},Ignore(s,n){return t(r=>e.request(pu,s,ne(ne({},n),r)),"Ignore","query",s)},GetSamplingConfig(s,n){return t(r=>e.request(mu,s,ne(ne({},n),r)),"GetSamplingConfig","query",s)}}}function yu(){var e=document.createElement("canvas");return e.getContext&&e.getContext("2d")?e.toDataURL("image/webp").indexOf("data:image/webp")==0:!1}function gu(){return yu()?{type:"image/webp",quality:.9}:{type:"image/jpeg",quality:.6}}const Zu="telemetry.sdk.name",Su="telemetry.sdk.version",wr=1e3,Iu=1e3*2,Xu=4*60*60*1e3,un=15*60*1e3,kr={normal:{bytes:1e7,time:4*60*1e3},canvas:{bytes:16e6,time:5e3}},Vu=100,Cr="app.highlight.io",Gu="https://app.launchdarkly.com",Ru={"observability.ld-stg.launchdarkly.com":"ld-stg.launchdarkly.com","observability.app.launchdarkly.com":"app.launchdarkly.com","observability.app.ld.catamorphic.com":"app.ld.catamorphic.com"},vu="/projects/default",Wu=new RegExp("pub\\.(?<domain>.+)");/*! js-cookie v3.0.8 | MIT */function ns(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)n!=="__proto__"&&(e[n]=s[n])}return e}var wu={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function dn(e,t){function s(r,l,d){if(typeof document<"u"){d=ns({},t,d),typeof d.expires=="number"&&(d.expires=new Date(Date.now()+d.expires*864e5)),d.expires&&(d.expires=d.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var f="";for(var h in d)d[h]&&(f+="; "+h,d[h]!==!0&&(f+="="+d[h].split(";")[0]));return document.cookie=r+"="+e.write(l,r)+f}}function n(r){if(!(typeof document>"u"||arguments.length&&!r)){for(var l=document.cookie?document.cookie.split("; "):[],d={},f=0;f<l.length;f++){var h=l[f].split("="),m=h.slice(1).join("=");try{var p=decodeURIComponent(h[0]);if(p in d||(d[p]=e.read(m,p)),r===p)break}catch{}}return r?d[r]:d}}return Object.create({set:s,get:n,remove:function(r,l){s(r,"",ns({},l,{expires:-1}))},withAttributes:function(r){return dn(this.converter,ns({},this.attributes,r))},withConverter:function(r){return dn(ns({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var is=dn(wu,{path:"/"}),hn=(e=>(e.CLIENT_ID="highlightClientID",e))(hn||{});let rs="localStorage",pn=!0,ku=class{constructor(){Rt(this,"storage",{})}get length(){return Object.keys(this.storage).length}key(t){var s;return(s=Object.keys(this.storage)[t])!=null?s:null}getItem(t){var s;return(s=this.storage[t])!=null?s:""}setItem(t,s){this.storage[t]=s}removeItem(t){delete this.storage[t]}},Cu=class{getItem(t){var s;return(s=is.get(t))!=null?s:""}setItem(t,s){if(!pn)return;const n=new Date;n.setTime(n.getTime()+un),is.set(t,s,{expires:n})}removeItem(t){pn&&is.remove(t)}keys(){var t;return Object.keys((t=is.get())!=null?t:{})}};const pt=new ku,mt=new Cu,os=()=>{let e=null;if(typeof window>"u")return pt;try{switch(rs){case"localStorage":e=window.localStorage;break;case"sessionStorage":e=window.sessionStorage;break}e||(lt("storage","getPersistentStorage","debug",`persistent storage was not found for mode ${rs}; using global storage`),e=pt)}catch(t){lt("storage","getPersistentStorage","debug","failed to get persistent storage; using global storage",t),e=pt}return e},xu=e=>{rs=e},xr=e=>{pn=e},Ce=e=>{try{return os().getItem(e)}catch(t){return lt("storage","getItem","debug",`failed to get item ${e}; using global storage`,t),pt.getItem(e)}},He=(e,t)=>{mt.setItem(e,t);try{return os().setItem(e,t)}catch(s){return lt("storage","setItem","debug",`failed to set item ${e}; using global storage`,s),pt.setItem(e,t)}},ls=e=>{mt.removeItem(e);try{return os().removeItem(e)}catch(t){return lt("storage","removeItem","debug",`failed to remove item ${e}; using global storage`,t),pt.removeItem(e)}},Tu=e=>{if(rs==="sessionStorage"){console.warn("highlight.io cannot use local storage; segment integration will not work");return}if(typeof window>"u"){console.warn("highlight.io cannot use local storage (not a window); segment integration will not work");return}const t=window.localStorage.setItem;window.localStorage.setItem=function(){const[s,n]=arguments;e({keyName:s,keyValue:n}),t.apply(this,[s,n])}};var Xe=(e=>(e.SEGMENT_LAST_SENT_HASH_KEY="HIGHLIGHT_SEGMENT_LAST_SENT_HASH_KEY",e.SESSION_ID="sessionID",e.SESSION_DATA="sessionData",e.USER_IDENTIFIER="highlightIdentifier",e.USER_OBJECT="highlightUserObject",e))(Xe||{});const as=e=>`${Xe.SESSION_DATA}_${e}`,Lu=()=>{var e;return typeof globalThis<"u"&&(e=globalThis.persistentSessionSecureID)!=null&&e.length?globalThis.persistentSessionSecureID:Tr()},Nu=e=>{typeof globalThis<"u"&&e!=null&&e.length&&(globalThis.persistentSessionSecureID=e)},Tr=()=>{var e;return(e=Ce(Xe.SESSION_ID))!=null?e:""},kt=e=>{He(Xe.SESSION_ID,e)},Ju=e=>{const t=as(e);return JSON.parse(Ce(t)||"{}")},cs=e=>{e||(e=Tr());let t=Ju(e);if(t&&t.lastPushTime&&Date.now()-t.lastPushTime<un)return t;ls(as(e))},st=function(e){if(!(e!=null&&e.sessionSecureID))return;const t=e.sessionSecureID;Nu(t);const s=as(t);He(s,JSON.stringify(e)),Uu(s)},Yu=function(){const e=mt.getItem(Xe.SESSION_ID);kt(e);const t=as(e),s=mt.getItem(t);try{st(JSON.parse(s))}catch{}};function Uu(e){var t;const s=`${Xe.SESSION_DATA}_`,n=new Set,r=os();for(let l=r.length-1;l>=0;l--){const d=r.key(l);d&&d.startsWith(s)&&d!==e&&n.add(d)}for(const l of mt.keys())l.startsWith(s)&&l!==e&&n.add(l);for(const l of n){let d=!0;try{const f=Ce(l)||mt.getItem(l)||"{}",h=JSON.parse(f),m=(t=h.lastPushTime)!=null?t:h.sessionStartTime;d=m===void 0||Date.now()-m>=un}catch{}d&&(lt("highlightSession","pruneSessionData","debug",`removing session data for stale key ${l}`),ls(l))}}var Lr=(e=>(e.BillingQuotaExceeded="BillingQuotaExceeded",e))(Lr||{});const Fu=3,Mu=1e3,Ou=500,Ku=[Lr.BillingQuotaExceeded.toString()],Eu=e=>{var t;return((t=e.response.errors)==null?void 0:t.find(s=>Ku.includes(s.message)))===void 0},zu=()=>{const e=(t,s,n,r,l=0)=>at(void 0,null,function*(){try{return yield t()}catch(d){if(d instanceof dt&&!Eu(d))throw d;if(l<Fu)return yield new Promise(f=>setTimeout(f,Mu+Ou*Math.pow(2,l))),yield e(t,s,n,r,l+1);throw console.error(`highlight.io: data request failed after ${l} retries`),d}});return e},Nr="feature_flag",Jr="launchdarkly",Hu=`${Nr}.set.id`,Pu=`${Nr}.provider.name`,Du=`${Jr}.application.id`,Bu=`${Jr}.application.version`,Qu="$ld:telemetry:session:init",Yr="$ld:telemetry:track";function Ur(e){return e.includes("%")||e.includes(":")?e.replace(/%/g,"%25").replace(/:/g,"%3A"):e}function Fr(e){return e.kind==="multi"}function Mr(e){return Fr(e)?Object.keys(e).sort().filter(t=>t!=="kind").map(t=>`${t}:${Ur(e[t].key)}`).join(":"):"kind"in e&&e.kind==="user"?e.key:"kind"in e?`${e.kind}:${Ur(e.key)}`:e.key}function ju(e){return Fr(e)?Object.keys(e).sort().filter(t=>t!=="kind").map(t=>({[t]:e[t].key})).reduce((t,s)=>ne(ne({},t),s),{}):"kind"in e?{[e.kind]:e.key}:{user:e.key}}let Au=class{constructor(t,s){Rt(this,"client"),Rt(this,"metadata"),this.client=t,this.metadata=s}getHooks(t){return[]}init(t){this.client.track(Qu,{sessionID:t})}recordGauge(t,s){}identify(t,s,n={},r){}error(t,s){}track(t,s){const n=s.event;this.client.track(n?`${Yr}:${n}`:Yr,Bt(ne({},s),{sessionID:t}))}},_u=class extends Bs{constructor(t,s){super(),Rt(this,"client"),this.client=new Au(t,s)}getHooks(t){return[{getMetadata:()=>({name:"highlight.run/ld"}),afterIdentify:(s,n,r)=>(this.load(this.client),n)}]}init(t){return this._bufferCall("init",[t])}recordGauge(t,s){return this._bufferCall("recordGauge",[t,s])}identify(t,s,n={},r){return this._bufferCall("identify",[t,s,n,r])}error(t,s){return this._bufferCall("error",[t,s])}track(t,s){return this._bufferCall("track",[t,s])}};const $u=e=>{e(window.location.href);const t=history.pushState;history.pushState=(l=>function(){var d=l.apply(this,arguments);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange")),d})(history.pushState);const s=history.replaceState;history.replaceState=(l=>function(){var d=l.apply(this,arguments);return window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange")),d})(history.replaceState);const n=()=>{window.dispatchEvent(new Event("locationchange"))};window.addEventListener("popstate",n);const r=function(){e(window.location.href)};return window.addEventListener("locationchange",r),()=>{window.removeEventListener("popstate",n),window.removeEventListener("locationchange",r),history.pushState=t,history.replaceState=s}},qu="10.7.7",ed={version:qu},td=ed.version;function Or(e,t){return nd(e)}function sd(e){if(e.id.length)return`#${e.id}`;if(e.classList.length){let t=[];for(const s of e.classList)t.push(`.${s}`);return`${e.nodeName.toLowerCase()}${t.join(",")}`}return e.nodeName.toLowerCase()}const nd=e=>{let t="";const s=e.getAttribute("class"),n=e.getAttribute("id");return n&&(t=t.concat(Kr(n,"#"))),s&&(t=t.concat(Kr(s,"."))),t===""&&(t=t.concat(e.tagName.toLowerCase())),t},Kr=(e,t)=>`${t}${e.trim().split(" ").join(t)}`,id=e=>{let t;const s=()=>{clearTimeout(t),t=setTimeout(()=>{var n,r;e({height:window.innerHeight,width:window.innerWidth,availHeight:window.screen.availHeight,availWidth:window.screen.availWidth,colorDepth:window.screen.colorDepth,pixelDepth:window.screen.pixelDepth,orientation:(r=(n=window.screen.orientation)==null?void 0:n.angle)!=null?r:0})},500)};return window.addEventListener("resize",s),s(),()=>window.removeEventListener("resize",s)};var Er={exports:{}};/**
279
279
  * @preserve
280
280
  * JS Implementation of incremental MurmurHash3 (r150) (as of May 10, 2013)
281
281
  *
@@ -456,7 +456,7 @@ or you can use record.mirror to access the mirror instance during recording.`;le
456
456
  Total since snapshot: ${(this._eventBytesSinceSnapshot/1e6).toFixed(1)}MB`)):((p=h.data.response)==null?void 0:p.type)===Ee.CustomEvent?this.addCustomEvent(h.data.response.tag,h.data.response.payload):((o=h.data.response)==null?void 0:o.type)===Ee.Stop&&(we("worker.onmessage","warn","Stopping recording due to worker failure",h.data.response),this.stop(!1))};let f=cs();if(this.reloaded=!1,!((l=this.sessionData)!=null&&l.sessionSecureID)&&f!=null&&f.sessionSecureID)this.sessionData=f,this.options.sessionSecureID=f.sessionSecureID,this.reloaded=!0,this.logger.log(`Tab reloaded, continuing previous session: ${this.sessionData.sessionSecureID}`);else{for(const h of Object.values(Xe))ls(h);this.sessionData={sessionSecureID:this.options.sessionSecureID,projectID:0,sessionStartTime:Date.now()}}this._hasPreviouslyInitialized=!1;try{window.parent.document&&(this._isCrossOriginIframe=!1)}catch{this._isCrossOriginIframe=(d=this.options.recordCrossOriginIframe)!=null?d:!0}this._initMembers(this.options)}_reset(t){return Ve(this,arguments,function*({forceNew:s,sessionKey:n}){this.pushPayloadTimerId&&(clearTimeout(this.pushPayloadTimerId),this.pushPayloadTimerId=void 0);let r,l;if(!s)try{r=Ce(Xe.USER_IDENTIFIER);const d=Ce(Xe.USER_OBJECT);d&&(l=JSON.parse(d))}catch{}for(const d of Object.values(Xe))ls(d);this.sessionData.sessionSecureID=n?Ct(`${this.organizationID}-${n}`):Ct(),this.sessionData.sessionKey=n,this.sessionData.sessionStartTime=Date.now(),this.options.sessionSecureID=this.sessionData.sessionSecureID,this.stop(),this._worker.postMessage({message:{type:Ee.Reset}}),yield this.start(),r&&l&&this.identify(r,l)})}_initMembers(t){var s,n,r,l,d,f,h,m,p,o;this.sessionShortcut=!1,this._recordingStartTime=0,this._isOnLocalHost=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"||window.location.hostname==="",this.ready=!1,this.state="NotRecording",this.manualStopped=!1,this.enableSegmentIntegration=!!t.enableSegmentIntegration,this.privacySetting=(s=t.privacySetting)!=null?s:"default",this.enableCanvasRecording=(n=t.enableCanvasRecording)!=null?n:!1,this.inlineImages=(r=t.inlineImages)!=null?r:this._isOnLocalHost,this.inlineVideos=(l=t.inlineVideos)!=null?l:this._isOnLocalHost,this.inlineStylesheet=(d=t.inlineStylesheet)!=null?d:this._isOnLocalHost,this.styleSheetResyncInterval=(f=t.styleSheetResyncInterval)!=null?f:2e3,this.samplingStrategy=z({canvasFactor:.5,canvasMaxSnapshotDimension:360,canvasClearWebGLBuffer:!0,dataUrlOptions:gu()},(h=t.samplingStrategy)!=null?h:{canvas:2}),this._backendUrl=(m=t?.backendUrl)!=null?m:"https://pub.observability.app.launchdarkly.com",this._backendUrl[0]==="/"&&(this._backendUrl=new URL(this._backendUrl,document.baseURI).href);const a=new Qc(`${this._backendUrl}`,{headers:{}});fd(this,Ps,bu(a,zu())),this.environment=(p=t.environment)!=null?p:"production",this.appVersion=t.appVersion,this.serviceName=(o=t.serviceName)!=null?o:"browser",typeof t.organizationID=="string"?this.organizationID=t.organizationID:this.organizationID=t.organizationID.toString(),this.isRunningOnHighlight=this.organizationID==="1"||this.organizationID==="1jdkoe52",this.firstloadVersion=t.firstloadVersion||"unknown",this.sessionShortcut=t.sessionShortcut||!1,this._onToggleFeedbackFormVisibility=()=>{};const i=t,c=ds(i,["firstloadVersion"]);this._optionsInternal=c,this.listeners=[],this.events=[],this.hasSessionUnloaded=!1,this.hasPushedData=!1,window.Intercom&&window.Intercom("onShow",()=>{window.Intercom("update",{highlightSessionURL:this.getCurrentSessionURLWithTimestamp()}),this.addProperties({event:"Intercom onShow"})}),this._eventBytesSinceSnapshot=0,this._lastSnapshotTime=new Date().getTime(),this._lastVisibilityChangeTime=new Date().getTime()}identify(t,s={},n){if(!t||t===""){we("identify","warn","Highlight's identify() call was passed an empty identifier.",{user_identifier:t,user_object:s});return}this.sessionData.userIdentifier=t.toString(),this.sessionData.userObject=s,He(Xe.USER_IDENTIFIER,t.toString()),He(Xe.USER_OBJECT,JSON.stringify(s)),this._worker.postMessage({message:{type:Ee.Identify,userIdentifier:t,userObject:s,source:n}})}track(t,s){this.addProperties(ge(z({},s),{event:t}))}addProperties(t={},s){const n=z({},t);Object.entries(n).forEach(([r,l])=>{try{structuredClone(l)}catch{delete n[r]}}),this._worker.postMessage({message:{type:Ee.Properties,propertiesObject:n,propertyType:s}})}addSessionProperties(t){this.addProperties(t,{type:"session"})}start(t){return Ve(this,null,function*(){var s,n,r,l,d,f,h,m,p,o;if(!((s=navigator?.userAgent)!=null&&s.includes("Googlebot")||(n=navigator?.userAgent)!=null&&n.includes("AdsBot")))try{if(t!=null&&t.forceNew){yield this._reset(t);return}if(t!=null&&t.sessionKey&&t?.sessionKey!==this.sessionData.sessionKey){yield this._reset(ge(z({},t),{forceNew:!0}));return}this.logger.log("Initializing...",t,this.sessionData,this.options),this.sessionData=(r=cs(this.sessionData.sessionSecureID))!=null?r:this.sessionData,(l=this.sessionData)!=null&&l.sessionStartTime?this._recordingStartTime=(d=this.sessionData)==null?void 0:d.sessionStartTime:(this._recordingStartTime=new Date().getTime(),this.sessionData.sessionStartTime=this._recordingStartTime);let a=Ce(hn.CLIENT_ID);a||(a=Ct(),He(hn.CLIENT_ID,a));let i;this.options.disableSessionRecording||this.options.disableNetworkRecording!==void 0||typeof this.options.networkRecording=="boolean"?i=!1:i=((f=this.options.networkRecording)==null?void 0:f.recordHeadersAndBody)||!1;let c=[];if(typeof this.options.networkRecording=="object"&&(h=this.options.networkRecording.destinationDomains)!=null&&h.length&&(c=this.options.networkRecording.destinationDomains),this._isCrossOriginIframe)yield this._setupCrossOriginIframe();else{const I=yield pd(this,Ps).initializeSession({organization_verbose_id:this.organizationID,enable_strict_privacy:this.privacySetting==="strict",privacy_setting:this.privacySetting,enable_recording_network_contents:i,clientVersion:this.firstloadVersion,firstloadVersion:this.firstloadVersion,clientConfig:JSON.stringify(this._optionsInternal),environment:this.environment,id:a,appVersion:this.appVersion,serviceName:this.serviceName,session_secure_id:this.sessionData.sessionSecureID,session_key:this.sessionData.sessionKey,client_id:a,network_recording_domains:c,disable_session_recording:this.options.disableSessionRecording});if(I.initializeSession.secure_id!==this.sessionData.sessionSecureID&&this.logger.log(`Unexpected secure id returned by initializeSession: ${I.initializeSession.secure_id}, expected ${this.sessionData.sessionSecureID}`),this.sessionData.sessionSecureID=I.initializeSession.secure_id,this.sessionData.projectID=parseInt(((m=I?.initializeSession)==null?void 0:m.project_id)||"0"),!this.sessionData.projectID||!this.sessionData.sessionSecureID){console.error("Failed to initialize Highlight; an error occurred on our end.",this.sessionData);return}}kt(""),st(this.sessionData),this.logger.log(`Loaded Highlight
457
457
  Remote: ${this._backendUrl}
458
458
  Project ID: ${this.sessionData.projectID}
459
- SessionSecureID: ${this.sessionData.sessionSecureID}`),this.options.sessionSecureID=this.sessionData.sessionSecureID,this._worker.postMessage({message:{type:Ee.Initialize,sessionSecureID:this.sessionData.sessionSecureID,backend:this._backendUrl,debug:!!this.debugOptions.clientInteractions,recordingStartTime:this._recordingStartTime}});for(const I of this._integrations)I.init(this.sessionData.sessionSecureID);if(this.sessionData.userIdentifier&&this.identify(this.sessionData.userIdentifier,this.sessionData.userObject),this.pushPayloadTimerId&&(clearTimeout(this.pushPayloadTimerId),this.pushPayloadTimerId=void 0),this._isCrossOriginIframe||(this.pushPayloadTimerId=setTimeout(()=>{this._save()},wr)),this.options.disableSessionRecording){this.logger.log("Highlight is NOT RECORDING a session replay per H.init setting."),this.ready=!0,this.state="Recording",this.manualStopped=!1;return}const u=(I,R)=>{R&&this.logger.log("received isCheckout emit",{event:I}),this.events.push(I)};u.bind(this);const b=!!this._recordStop;this._recordStop&&(this._recordStop(),this._recordStop=void 0);const[S,Z]=zp(this.privacySetting,this.options.maskAllInputs,this.options.maskInputOptions);this._recordStop=Be({ignoreClass:(p=this.options.ignoreClass)!=null?p:"highlight-ignore",ignoreSelector:this.options.ignoreSelector,blockClass:(o=this.options.blockClass)!=null?o:"highlight-block",blockSelector:this.options.blockSelector,emit:u,recordCrossOriginIframes:this.options.recordCrossOriginIframe,privacySetting:this.privacySetting,maskAllInputs:S,maskInputOptions:Z,maskTextClass:this.options.maskTextClass,maskTextSelector:this.options.maskTextSelector,recordCanvas:this.enableCanvasRecording,sampling:{canvas:{fps:this.samplingStrategy.canvas,fpsManual:this.samplingStrategy.canvasManualSnapshot,resizeFactor:this.samplingStrategy.canvasFactor,clearWebGLBuffer:this.samplingStrategy.canvasClearWebGLBuffer,initialSnapshotDelay:this.samplingStrategy.canvasInitialSnapshotDelay,dataURLOptions:this.samplingStrategy.dataUrlOptions,maxSnapshotDimension:this.samplingStrategy.canvasMaxSnapshotDimension}},keepIframeSrcFn:I=>!this.options.recordCrossOriginIframe,inlineImages:this.inlineImages,inlineVideos:this.inlineVideos,collectFonts:this.inlineImages,inlineStylesheet:this.inlineStylesheet,styleSheetResyncInterval:this.styleSheetResyncInterval,plugins:[gd()],logger:typeof this.options.debug=="boolean"&&this.options.debug||typeof this.options.debug=="object"&&this.options.debug.domRecording?{debug:this.logger.log,warn:we.bind("RecordSDK","warn")}:void 0}),b||this.options.recordCrossOriginIframe&&this._setupCrossOriginIframeParent(),document.referrer&&(window&&document.referrer.includes(window.location.origin)||(this.addCustomEvent("Referrer",document.referrer),this.addProperties({referrer:document.referrer},{type:"session"}))),this.sessionData.sessionKey&&this.addProperties({sessionKey:this.sessionData.sessionKey},{type:"session"}),this._setupWindowListeners(),this.ready=!0,this.state="Recording",this.manualStopped=!1}catch(a){we("initializeSession _setupWindowListeners","warn",a)}})}_visibilityHandler(t){return Ve(this,null,function*(){if(this.manualStopped){this.logger.log("Ignoring visibility event due to manual stop.");return}new Date().getTime()-this._lastVisibilityChangeTime<Vu||(this._lastVisibilityChangeTime=new Date().getTime(),this.logger.log(`Detected window ${t?"hidden":"visible"}.`),t?(this.addCustomEvent("TabHidden",!0),this.options.disableBackgroundRecording&&this.stop()):(this.options.disableBackgroundRecording&&(yield this.start()),this.addCustomEvent("TabHidden",!1)))})}_setupCrossOriginIframe(){return Ve(this,null,function*(){this.logger.log("highlight in cross-origin iframe is waiting "),yield new Promise(t=>{const s=n=>{if(n.data.highlight===Ra){const r=n.data;this.logger.log("highlight got window message ",r),this.sessionData.projectID=r.projectID,this.sessionData.sessionSecureID=r.sessionSecureID,window.parent.postMessage({highlight:va},"*"),window.removeEventListener("message",s),t()}};window.addEventListener("message",s)})})}_setupCrossOriginIframeParent(){this.logger.log("highlight setting up cross origin iframe parent notification"),setInterval(()=>{window.document.querySelectorAll("iframe").forEach(t=>{var s;(s=t.contentWindow)==null||s.postMessage({highlight:Ra,projectID:this.sessionData.projectID,sessionSecureID:this.sessionData.sessionSecureID},"*")})},wr),window.addEventListener("message",t=>{t.data.highlight===va&&this.logger.log("highlight got response from initialized iframe")})}_setupWindowListeners(){var t;try{const n=this;this.enableSegmentIntegration&&this.listeners.push(Bp(l=>{if(l.type==="track"){const d={};d["segment-event"]=l.event,n.addProperties(d,{type:"track",source:"segment"})}else if(l.type==="identify"){const d=l.userId.replace(/^"(.*)"$/,"$1");n.identify(d,l.traits,"segment")}})),this.listeners.push($u(l=>{this.reloaded?(this.addCustomEvent("Reload",l),this.reloaded=!1,n.addProperties({reload:!0},{type:"session"})):this.addCustomEvent("Navigate",l)})),this.listeners.push(id(l=>{this.addCustomEvent("Viewport",l)})),this.listeners.push(Hp((l,d)=>{let f=null,h=null;if(d&&d.target){const m=d.target;f=sd(m),h=m.textContent,h&&h.length>2e3&&(h=h.substring(0,2e3))}this.addCustomEvent("Click",{clickTarget:l,clickTextContent:h,clickSelector:f})})),this.listeners.push(Pp(l=>{l&&this.addCustomEvent("Focus",l)})),this.sessionShortcut&&jp(this.sessionShortcut,()=>{window.open(this.getCurrentSessionURLWithTimestamp(),"_blank")}),this._hasPreviouslyInitialized||((t=window.electron)!=null&&t.ipcRenderer?(window.electron.ipcRenderer.on("highlight.run",({visible:l})=>{this._visibilityHandler(!l)}),this.logger.log("Set up Electron highlight.run events.")):(Dp(l=>this._visibilityHandler(l)),this.logger.log("Set up document visibility listener.")),this._hasPreviouslyInitialized=!0);const r=()=>{this.hasSessionUnloaded=!0,this.pushPayloadTimerId&&(clearTimeout(this.pushPayloadTimerId),this.pushPayloadTimerId=void 0)};window.addEventListener("beforeunload",r),this.listeners.push(()=>window.removeEventListener("beforeunload",r))}catch(n){we("initializeSession _setupWindowListeners","warn",n)}const s=()=>{this.addCustomEvent("Page Unload",""),kt(this.sessionData.sessionSecureID),st(this.sessionData)};if(window.addEventListener("beforeunload",s),this.listeners.push(()=>window.removeEventListener("beforeunload",s)),navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPhone/i)){const n=()=>{this.addCustomEvent("Page Unload",""),kt(this.sessionData.sessionSecureID),st(this.sessionData)};window.addEventListener("pagehide",n),this.listeners.push(()=>window.removeEventListener("beforeunload",n))}}stop(t){this.manualStopped=!!t,this.manualStopped&&this.addCustomEvent("Stop","H.stop() was called which stops Highlight from recording."),this.state="NotRecording",t&&this._recordStop&&(this._recordStop(),this._recordStop=void 0),this.listeners.forEach(s=>s()),this.listeners=[]}getCurrentSessionURLWithTimestamp(){const t=new Date().getTime(),{projectID:s,sessionSecureID:n}=this.sessionData,r=(t-this._recordingStartTime)/1e3;return`https://${Cr}/${s}/sessions/${n}?ts=${r}`}getCurrentSessionURL(){const t=this.sessionData.projectID,s=this.sessionData.sessionSecureID;return t&&s?`https://${Cr}/${t}/sessions/${s}`:null}snapshot(t){return Ve(this,null,function*(){yield Be.snapshotCanvas(t)})}addSessionFeedback({timestamp:t,verbatim:s,user_email:n,user_name:r}){var l;this._worker.postMessage({message:{type:Ee.Feedback,verbatim:s,timestamp:t,userName:r||this.sessionData.userIdentifier,userEmail:n||((l=this.sessionData.userObject)==null?void 0:l.name)}})}_save(){return Ve(this,null,function*(){var t;try{this.state==="Recording"&&this.listeners&&!this.sessionData.sessionKey&&this.sessionData.sessionStartTime&&Date.now()-this.sessionData.sessionStartTime>Xu&&(this.logger.log("Resetting session",{start:this.sessionData.sessionStartTime}),yield this._reset({}));let s;((t=this.options)==null?void 0:t.sendMode)==="local"&&(s=n=>Ve(this,null,function*(){let r=new Blob([JSON.stringify({query:Sr(Wr),variables:n})],{type:"application/json"});return yield window.fetch(`${this._backendUrl}`,{method:"POST",body:r}),0})),yield this._sendPayload({sendFn:s}),this.hasPushedData=!0,this.sessionData.lastPushTime=Date.now(),st(this.sessionData)}catch(s){we("_save","warn",s)}this.state==="Recording"&&(this.pushPayloadTimerId&&(clearTimeout(this.pushPayloadTimerId),this.pushPayloadTimerId=void 0),this.pushPayloadTimerId=setTimeout(()=>{this._save()},Iu))})}addCustomEvent(t,s){if(this.state==="NotRecording"){let n;const r=()=>{clearInterval(n),this.state==="Recording"&&this.events.length>0?Ia(t,s):n=setTimeout(r,500)};n=setTimeout(r,500)}else this.state==="Recording"&&(this.events.length>0||this.hasPushedData)&&Ia(t,s)}_sendPayload(t){return Ve(this,arguments,function*({sendFn:s}){const n=[...this.events],{bytes:r,time:l}=this.enableCanvasRecording?kr.canvas:kr.normal;this._eventBytesSinceSnapshot>=r&&new Date().getTime()-this._lastSnapshotTime>=l&&this.takeFullSnapshot(),this.logger.log(`Sending: ${n.length} events,
459
+ SessionSecureID: ${this.sessionData.sessionSecureID}`),this.options.sessionSecureID=this.sessionData.sessionSecureID,this._worker.postMessage({message:{type:Ee.Initialize,sessionSecureID:this.sessionData.sessionSecureID,backend:this._backendUrl,debug:!!this.debugOptions.clientInteractions,recordingStartTime:this._recordingStartTime}});for(const I of this._integrations)I.init(this.sessionData.sessionSecureID);if(this.sessionData.userIdentifier&&this.identify(this.sessionData.userIdentifier,this.sessionData.userObject),this.pushPayloadTimerId&&(clearTimeout(this.pushPayloadTimerId),this.pushPayloadTimerId=void 0),this._isCrossOriginIframe||(this.pushPayloadTimerId=setTimeout(()=>{this._save()},wr)),this.options.disableSessionRecording){this.logger.log("Highlight is NOT RECORDING a session replay per H.init setting."),this.ready=!0,this.state="Recording",this.manualStopped=!1;return}const u=(I,R)=>{R&&this.logger.log("received isCheckout emit",{event:I}),this.events.push(I)};u.bind(this);const b=!!this._recordStop;this._recordStop&&(this._recordStop(),this._recordStop=void 0);const[S,Z]=zp(this.privacySetting,this.options.maskAllInputs,this.options.maskInputOptions);this._recordStop=Be({ignoreClass:(p=this.options.ignoreClass)!=null?p:"highlight-ignore",ignoreSelector:this.options.ignoreSelector,blockClass:(o=this.options.blockClass)!=null?o:"highlight-block",blockSelector:this.options.blockSelector,emit:u,recordCrossOriginIframes:this.options.recordCrossOriginIframe,privacySetting:this.privacySetting,maskAllInputs:S,maskInputOptions:Z,maskTextClass:this.options.maskTextClass,maskTextSelector:this.options.maskTextSelector,recordCanvas:this.enableCanvasRecording,sampling:{canvas:{fps:this.samplingStrategy.canvas,fpsManual:this.samplingStrategy.canvasManualSnapshot,resizeFactor:this.samplingStrategy.canvasFactor,clearWebGLBuffer:this.samplingStrategy.canvasClearWebGLBuffer,initialSnapshotDelay:this.samplingStrategy.canvasInitialSnapshotDelay,dataURLOptions:this.samplingStrategy.dataUrlOptions,maxSnapshotDimension:this.samplingStrategy.canvasMaxSnapshotDimension}},keepIframeSrcFn:I=>!this.options.recordCrossOriginIframe,inlineImages:this.inlineImages,inlineVideos:this.inlineVideos,collectFonts:this.inlineImages,inlineStylesheet:this.inlineStylesheet,styleSheetResyncInterval:this.styleSheetResyncInterval,plugins:[gd()],logger:typeof this.options.debug=="boolean"&&this.options.debug||typeof this.options.debug=="object"&&this.options.debug.domRecording?{debug:this.logger.log,warn:we.bind(null,"RecordSDK","warn")}:void 0}),b||this.options.recordCrossOriginIframe&&this._setupCrossOriginIframeParent(),document.referrer&&(window&&document.referrer.includes(window.location.origin)||(this.addCustomEvent("Referrer",document.referrer),this.addProperties({referrer:document.referrer},{type:"session"}))),this.sessionData.sessionKey&&this.addProperties({sessionKey:this.sessionData.sessionKey},{type:"session"}),this._setupWindowListeners(),this.ready=!0,this.state="Recording",this.manualStopped=!1}catch(a){we("initializeSession _setupWindowListeners","warn",a)}})}_visibilityHandler(t){return Ve(this,null,function*(){if(this.manualStopped){this.logger.log("Ignoring visibility event due to manual stop.");return}new Date().getTime()-this._lastVisibilityChangeTime<Vu||(this._lastVisibilityChangeTime=new Date().getTime(),this.logger.log(`Detected window ${t?"hidden":"visible"}.`),t?(this.addCustomEvent("TabHidden",!0),this.options.disableBackgroundRecording&&this.stop()):(this.options.disableBackgroundRecording&&(yield this.start()),this.addCustomEvent("TabHidden",!1)))})}_setupCrossOriginIframe(){return Ve(this,null,function*(){this.logger.log("highlight in cross-origin iframe is waiting "),yield new Promise(t=>{const s=n=>{if(n.data.highlight===Ra){const r=n.data;this.logger.log("highlight got window message ",r),this.sessionData.projectID=r.projectID,this.sessionData.sessionSecureID=r.sessionSecureID,window.parent.postMessage({highlight:va},"*"),window.removeEventListener("message",s),t()}};window.addEventListener("message",s)})})}_setupCrossOriginIframeParent(){this.logger.log("highlight setting up cross origin iframe parent notification"),setInterval(()=>{window.document.querySelectorAll("iframe").forEach(t=>{var s;(s=t.contentWindow)==null||s.postMessage({highlight:Ra,projectID:this.sessionData.projectID,sessionSecureID:this.sessionData.sessionSecureID},"*")})},wr),window.addEventListener("message",t=>{t.data.highlight===va&&this.logger.log("highlight got response from initialized iframe")})}_setupWindowListeners(){var t;try{const n=this;this.enableSegmentIntegration&&this.listeners.push(Bp(l=>{if(l.type==="track"){const d={};d["segment-event"]=l.event,n.addProperties(d,{type:"track",source:"segment"})}else if(l.type==="identify"){const d=l.userId.replace(/^"(.*)"$/,"$1");n.identify(d,l.traits,"segment")}})),this.listeners.push($u(l=>{this.reloaded?(this.addCustomEvent("Reload",l),this.reloaded=!1,n.addProperties({reload:!0},{type:"session"})):this.addCustomEvent("Navigate",l)})),this.listeners.push(id(l=>{this.addCustomEvent("Viewport",l)})),this.listeners.push(Hp((l,d)=>{let f=null,h=null;if(d&&d.target){const m=d.target;f=sd(m),h=m.textContent,h&&h.length>2e3&&(h=h.substring(0,2e3))}this.addCustomEvent("Click",{clickTarget:l,clickTextContent:h,clickSelector:f})})),this.listeners.push(Pp(l=>{l&&this.addCustomEvent("Focus",l)})),this.sessionShortcut&&jp(this.sessionShortcut,()=>{window.open(this.getCurrentSessionURLWithTimestamp(),"_blank")}),this._hasPreviouslyInitialized||((t=window.electron)!=null&&t.ipcRenderer?(window.electron.ipcRenderer.on("highlight.run",({visible:l})=>{this._visibilityHandler(!l)}),this.logger.log("Set up Electron highlight.run events.")):(Dp(l=>this._visibilityHandler(l)),this.logger.log("Set up document visibility listener.")),this._hasPreviouslyInitialized=!0);const r=()=>{this.hasSessionUnloaded=!0,this.pushPayloadTimerId&&(clearTimeout(this.pushPayloadTimerId),this.pushPayloadTimerId=void 0)};window.addEventListener("beforeunload",r),this.listeners.push(()=>window.removeEventListener("beforeunload",r))}catch(n){we("initializeSession _setupWindowListeners","warn",n)}const s=()=>{this.addCustomEvent("Page Unload",""),kt(this.sessionData.sessionSecureID),st(this.sessionData)};if(window.addEventListener("beforeunload",s),this.listeners.push(()=>window.removeEventListener("beforeunload",s)),navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPhone/i)){const n=()=>{this.addCustomEvent("Page Unload",""),kt(this.sessionData.sessionSecureID),st(this.sessionData)};window.addEventListener("pagehide",n),this.listeners.push(()=>window.removeEventListener("beforeunload",n))}}stop(t){this.manualStopped=!!t,this.manualStopped&&this.addCustomEvent("Stop","H.stop() was called which stops Highlight from recording."),this.state="NotRecording",t&&this._recordStop&&(this._recordStop(),this._recordStop=void 0),this.listeners.forEach(s=>s()),this.listeners=[]}getCurrentSessionURLWithTimestamp(){const t=new Date().getTime(),{projectID:s,sessionSecureID:n}=this.sessionData,r=(t-this._recordingStartTime)/1e3;return`https://${Cr}/${s}/sessions/${n}?ts=${r}`}getCurrentSessionURL(){const t=this.sessionData.projectID,s=this.sessionData.sessionSecureID;return t&&s?`https://${Cr}/${t}/sessions/${s}`:null}snapshot(t){return Ve(this,null,function*(){yield Be.snapshotCanvas(t)})}addSessionFeedback({timestamp:t,verbatim:s,user_email:n,user_name:r}){var l;this._worker.postMessage({message:{type:Ee.Feedback,verbatim:s,timestamp:t,userName:r||this.sessionData.userIdentifier,userEmail:n||((l=this.sessionData.userObject)==null?void 0:l.name)}})}_save(){return Ve(this,null,function*(){var t;try{this.state==="Recording"&&this.listeners&&!this.sessionData.sessionKey&&this.sessionData.sessionStartTime&&Date.now()-this.sessionData.sessionStartTime>Xu&&(this.logger.log("Resetting session",{start:this.sessionData.sessionStartTime}),yield this._reset({}));let s;((t=this.options)==null?void 0:t.sendMode)==="local"&&(s=n=>Ve(this,null,function*(){let r=new Blob([JSON.stringify({query:Sr(Wr),variables:n})],{type:"application/json"});return yield window.fetch(`${this._backendUrl}`,{method:"POST",body:r}),0})),yield this._sendPayload({sendFn:s}),this.hasPushedData=!0,this.sessionData.lastPushTime=Date.now(),st(this.sessionData)}catch(s){we("_save","warn",s)}this.state==="Recording"&&(this.pushPayloadTimerId&&(clearTimeout(this.pushPayloadTimerId),this.pushPayloadTimerId=void 0),this.pushPayloadTimerId=setTimeout(()=>{this._save()},Iu))})}addCustomEvent(t,s){if(this.state==="NotRecording"){let n;const r=()=>{clearInterval(n),this.state==="Recording"&&this.events.length>0?Ia(t,s):n=setTimeout(r,500)};n=setTimeout(r,500)}else this.state==="Recording"&&(this.events.length>0||this.hasPushedData)&&Ia(t,s)}_sendPayload(t){return Ve(this,arguments,function*({sendFn:s}){const n=[...this.events],{bytes:r,time:l}=this.enableCanvasRecording?kr.canvas:kr.normal;this._eventBytesSinceSnapshot>=r&&new Date().getTime()-this._lastSnapshotTime>=l&&this.takeFullSnapshot(),this.logger.log(`Sending: ${n.length} events,
460
460
  To: ${this._backendUrl}
461
461
  Org: ${this.organizationID}
462
462
  SessionSecureID: ${this.sessionData.sessionSecureID}`);const d=new Date().getTime(),f=im();if(s){const h={session_secure_id:this.sessionData.sessionSecureID,payload_id:d.toString(),events:{events:n},messages:$c({messages:[]}),resources:JSON.stringify({resources:[]}),web_socket_events:JSON.stringify({webSocketEvents:[]}),errors:[],is_beacon:!1,has_session_unloaded:this.hasSessionUnloaded,highlight_logs:f||void 0},{compressedBase64:m}=yield Sm(h);yield s({session_secure_id:this.sessionData.sessionSecureID,payload_id:d.toString(),data:m})}else this._worker.postMessage({message:{type:Ee.AsyncEvents,id:d,events:n,messages:[],errors:[],resourcesString:JSON.stringify({resources:[]}),webSocketEventsString:JSON.stringify({webSocketEvents:[]}),hasSessionUnloaded:this.hasSessionUnloaded,highlightLogs:f}});st(this.sessionData),this.events=this.events.slice(n.length),rm(f)})}takeFullSnapshot(){if(!this._recordStop){this.logger.log("skipping full snapshot as rrweb is not running");return}this.logger.log("taking full snapshot",{bytesSinceSnapshot:this._eventBytesSinceSnapshot,lastSnapshotTime:this._lastSnapshotTime}),Be.takeFullSnapshot(),this._eventBytesSinceSnapshot=0,this._lastSnapshotTime=new Date().getTime()}register(t,s){this._integrations.push(new _u(t,s))}getHooks(t){return this._integrations.flatMap(s=>{var n,r;return(r=(n=s.getHooks)==null?void 0:n.call(s,t))!=null?r:[]})}getRecordingState(){var t;return(t=this==null?void 0:this.state)!=null?t:"NotRecording"}getSession(){const t=this.sessionData.sessionSecureID,s=cs(t);if(!s)return null;const n=`${this.getFrontendUrl()}/sessions/${t}`;if(!n||!s?.sessionStartTime)return null;const r=new Date().getTime();let l;try{l=new URL(n)}catch(h){return we("identify","warn",`failed to construct session url from ${n}`,h),null}const d=new URL(l),f=(r-this._recordingStartTime)/1e3;return d.searchParams.set("ts",f.toString()),{url:l.toString(),urlWithTimestamp:d.toString(),sessionSecureID:t}}getFrontendUrl(){var t,s;const n=this._backendUrl.match(Wu);if(n&&(t=n?.groups)!=null&&t.domain){const r=(s=n.groups.domain)!=null?s:"";return`https://${Ru[r]}${vu}`}return Gu}}Ps=new WeakMap;class Wm extends ad{constructor(t){super(t),Q(this,"record"),Q(this,"options"),this.options=t}initialize(t,s){var n,r,l,d,f,h,m,p,o;try{if(typeof window>"u"||typeof document>"u"){console.warn("@launchdarkly/session-replay is not initializing because it is not supported in this environment.");return}if(typeof Worker>"u"){console.warn("@launchdarkly/session-replay is not initializing because Worker is not supported.");return}if(!t){console.warn("@launchdarkly/session-replay is not initializing because the SDK credential is undefined.");return}this.configureSession(t,s);const a=ge(z({},s),{organizationID:t,firstloadVersion:td,environment:s?.environment||"production",appVersion:s?.version,sessionSecureID:this.sessionSecureID,privacySetting:(n=s?.privacySetting)!=null?n:"strict"});this.record=new vm(a),s!=null&&s.manualStart||this.record.start(),Le.LDRecord.load(this.record),!((l=(r=s?.integrations)==null?void 0:r.mixpanel)!=null&&l.disabled)&&(f=(d=s?.integrations)==null?void 0:d.mixpanel)!=null&&f.projectToken&&Gm(s.integrations.mixpanel),!((m=(h=s?.integrations)==null?void 0:h.amplitude)!=null&&m.disabled)&&(o=(p=s?.integrations)==null?void 0:p.amplitude)!=null&&o.apiKey&&Vm(s.integrations.amplitude)}catch(a){we("Error initializing @launchdarkly/session-replay SDK","error",a)}}getMetadata(){return{name:"@launchdarkly/session-replay"}}register(t,s){var n;(n=this.record)==null||n.register(t,s)}getHooks(t){var s,n,r,l;const d=z(z({[Zu]:t.sdk.name,[Su]:t.sdk.version,[Hu]:t.clientSideId,[Pu]:"LaunchDarkly"},(s=t.application)!=null&&s.id?{[Du]:t.application.id}:{}),(n=t.application)!=null&&n.version?{[Bu]:t.application.version}:{});return this.initialize((l=(r=t.sdkKey)!=null?r:t.mobileKey)!=null?l:t.clientSideId,this.options),[{getMetadata:()=>({name:"@launchdarkly/session-replay/hooks"}),afterIdentify:(f,h,m)=>{var p,o,a,i,c,u,b,S;for(const Z of(a=(o=(p=this.record)==null?void 0:p.getHooks)==null?void 0:o.call(p,t))!=null?a:[])(i=Z.afterIdentify)==null||i.call(Z,f,h,m);if(m.status==="completed"){const Z=ge(z({},ju(f.context)),{key:(b=(u=(c=this.options)==null?void 0:c.contextFriendlyName)==null?void 0:u.call(c,f.context))!=null?b:Mr(f.context),canonicalKey:Mr(f.context)});(S=this.record)==null||S.identify(Z.key,z(z({},d),Z),"LaunchDarkly")}return h},afterEvaluation:(f,h,m)=>{var p,o,a,i;for(const c of(a=(o=(p=this.record)==null?void 0:p.getHooks)==null?void 0:o.call(p,t))!=null?a:[])(i=c.afterEvaluation)==null||i.call(c,f,h,m);return h},afterTrack:f=>{var h,m,p,o,a;for(const i of(p=(m=(h=this.record)==null?void 0:h.getHooks)==null?void 0:m.call(h,t))!=null?p:[])(o=i.afterTrack)==null||o.call(i,f);(a=this.record)==null||a.track(f.key,{data:f.data,value:f.metricValue})}}]}}const Ka=()=>{const e={end:()=>{},spanContext:()=>({traceId:"",spanId:"",traceFlags:0}),setAttribute:(t,s)=>e,setAttributes:t=>e,addEvent:(t,s,n)=>e,addLinks:t=>e,setStatus:t=>e,recordException:()=>{},addLink:()=>e,updateName:()=>e,isRecording:()=>!1};return e};function Ea(e,t,s){if(typeof s=="function")return s;if(typeof t=="function")return t;if(typeof e=="function")return e}class za extends Bs{start(){return this._sdk.start()}stop(){return this._sdk.stop()}recordGauge(t){return this._bufferCall("recordGauge",[t])}recordCount(t){return this._bufferCall("recordCount",[t])}recordIncr(t){return this._bufferCall("recordIncr",[t])}recordHistogram(t){return this._bufferCall("recordHistogram",[t])}recordUpDownCounter(t){return this._bufferCall("recordUpDownCounter",[t])}startSpan(t,s,n,r){var l;return this._isLoaded?this._bufferCall("startSpan",[t,s,n,r]):(l=Ea(s,n,r))==null?void 0:l(Ka())}startManualSpan(t,s,n,r){var l;return this._isLoaded?this._bufferCall("startManualSpan",[t,s,n,r]):(l=Ea(s,n,r))==null?void 0:l(Ka())}register(t,s){return this._bufferCall("register",[t,s])}recordLog(t,s,n){return this._bufferCall("recordLog",[t,s,n])}recordError(t,s,n,r,l){return this._bufferCall("recordError",[t,s,n,r,l])}setLDContextKeyAttributes(t){return this._bufferCall("setLDContextKeyAttributes",[t])}getLDContextKeyAttributes(){return this._bufferCall("getLDContextKeyAttributes",[])}}let Pt;typeof globalThis<"u"?globalThis.LDObserve?Pt=globalThis.LDObserve:(Pt=new za,globalThis.LDObserve=Pt):Pt=new za;const wm=Object.freeze(Object.defineProperty({__proto__:null,get LDObserve(){return Pt}},Symbol.toStringTag,{value:"Module"}));Le.default=Wm,Object.defineProperties(Le,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});