@adora-so/adora-js 0.0.4 → 0.0.6

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.cjs DELETED
@@ -1,4 +0,0 @@
1
- "use strict";var vn=Object.create;var $e=Object.defineProperty;var bn=Object.getOwnPropertyDescriptor;var Cn=Object.getOwnPropertyNames;var wn=Object.getPrototypeOf,En=Object.prototype.hasOwnProperty;var In=(e,t,r)=>t in e?$e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var _n=(e,t)=>{for(var r in t)$e(e,r,{get:t[r],enumerable:!0})},Hr=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Cn(t))!En.call(e,n)&&n!==r&&$e(e,n,{get:()=>t[n],enumerable:!(o=bn(t,n))||o.enumerable});return e};var Yr=(e,t,r)=>(r=e!=null?vn(wn(e)):{},Hr(t||!e||!e.__esModule?$e(r,"default",{value:e,enumerable:!0}):r,e)),Rn=e=>Hr($e({},"__esModule",{value:!0}),e);var de=(e,t,r)=>In(e,typeof t!="symbol"?t+"":t,r);var Qi={};_n(Qi,{adoraIsRunning:()=>xe,adoraStart:()=>Xi,adoraStop:()=>qi});module.exports=Rn(Qi);var An={"Content-Type":"application/json"},Dn=/\{[^{}]+\}/g,Wt=class extends Request{constructor(t,r){super(t,r);for(let o in r)o in this||(this[o]=r[o])}};function Bt(e){let{baseUrl:t="",fetch:r=globalThis.fetch,querySerializer:o,bodySerializer:n,headers:s,...a}={...e};t.endsWith("/")&&(t=t.substring(0,t.length-1)),s=Wr(An,s);let c=[];async function i(u,d){let{fetch:l=r,headers:g,params:f={},parseAs:p="json",querySerializer:h,bodySerializer:C=n??Nn,...I}=d||{},v=typeof o=="function"?o:Vr(o);h&&(v=typeof h=="function"?h:Vr({...typeof o=="object"?o:{},...h}));let y={redirect:"follow",...a,...I,headers:Wr(s,g,f.header)};y.body&&(y.body=C(y.body)),y.body instanceof FormData&&y.headers.delete("Content-Type");let _=new Wt(On(u,{baseUrl:t,params:f,querySerializer:v}),y),A={baseUrl:t,fetch:l,parseAs:p,querySerializer:v,bodySerializer:C};for(let w of c)if(w&&typeof w=="object"&&typeof w.onRequest=="function"){_.schemaPath=u,_.params=f;let D=await w.onRequest(_,A);if(D){if(!(D instanceof Request))throw new Error("Middleware must return new Request() when modifying the request");_=D}}let m=await l(_);for(let w=c.length-1;w>=0;w--){let D=c[w];if(D&&typeof D=="object"&&typeof D.onResponse=="function"){let L=await D.onResponse(m,A);if(L){if(!(L instanceof Response))throw new Error("Middleware must return new Response() when modifying the response");m=L}}}if(m.status===204||m.headers.get("Content-Length")==="0")return m.ok?{data:{},response:m}:{error:{},response:m};if(m.ok)return p==="stream"?{data:m.body,response:m}:{data:await m[p](),response:m};let E=await m.text();try{E=JSON.parse(E)}catch{}return{error:E,response:m}}return{async GET(u,d){return i(u,{...d,method:"GET"})},async PUT(u,d){return i(u,{...d,method:"PUT"})},async POST(u,d){return i(u,{...d,method:"POST"})},async DELETE(u,d){return i(u,{...d,method:"DELETE"})},async OPTIONS(u,d){return i(u,{...d,method:"OPTIONS"})},async HEAD(u,d){return i(u,{...d,method:"HEAD"})},async PATCH(u,d){return i(u,{...d,method:"PATCH"})},async TRACE(u,d){return i(u,{...d,method:"TRACE"})},use(...u){for(let d of u)if(d){if(typeof d!="object"||!("onRequest"in d||"onResponse"in d))throw new Error("Middleware must be an object with one of `onRequest()` or `onResponse()`");c.push(d)}},eject(...u){for(let d of u){let l=c.indexOf(d);l!==-1&&c.splice(l,1)}}}}function lt(e,t,r){if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${r?.allowReserved===!0?t:encodeURIComponent(t)}`}function Br(e,t,r){if(!t||typeof t!="object")return"";let o=[],n={simple:",",label:".",matrix:";"}[r.style]||"&";if(r.style!=="deepObject"&&r.explode===!1){for(let c in t)o.push(c,r.allowReserved===!0?t[c]:encodeURIComponent(t[c]));let a=o.join(",");switch(r.style){case"form":return`${e}=${a}`;case"label":return`.${a}`;case"matrix":return`;${e}=${a}`;default:return a}}for(let a in t){let c=r.style==="deepObject"?`${e}[${a}]`:a;o.push(lt(c,t[a],r))}let s=o.join(n);return r.style==="label"||r.style==="matrix"?`${n}${s}`:s}function zr(e,t,r){if(!Array.isArray(t))return"";if(r.explode===!1){let s={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[r.style]||",",a=(r.allowReserved===!0?t:t.map(c=>encodeURIComponent(c))).join(s);switch(r.style){case"simple":return a;case"label":return`.${a}`;case"matrix":return`;${e}=${a}`;default:return`${e}=${a}`}}let o={simple:",",label:".",matrix:";"}[r.style]||"&",n=[];for(let s of t)r.style==="simple"||r.style==="label"?n.push(r.allowReserved===!0?s:encodeURIComponent(s)):n.push(lt(e,s,r));return r.style==="label"||r.style==="matrix"?`${o}${n.join(o)}`:n.join(o)}function Vr(e){return function(r){let o=[];if(r&&typeof r=="object")for(let n in r){let s=r[n];if(s!=null){if(Array.isArray(s)){o.push(zr(n,s,{style:"form",explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}));continue}if(typeof s=="object"){o.push(Br(n,s,{style:"deepObject",explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}));continue}o.push(lt(n,s,e))}}return o.join("&")}}function Tn(e,t){let r=e;for(let o of e.match(Dn)??[]){let n=o.substring(1,o.length-1),s=!1,a="simple";if(n.endsWith("*")&&(s=!0,n=n.substring(0,n.length-1)),n.startsWith(".")?(a="label",n=n.substring(1)):n.startsWith(";")&&(a="matrix",n=n.substring(1)),!t||t[n]===void 0||t[n]===null)continue;let c=t[n];if(Array.isArray(c)){r=r.replace(o,zr(n,c,{style:a,explode:s}));continue}if(typeof c=="object"){r=r.replace(o,Br(n,c,{style:a,explode:s}));continue}if(a==="matrix"){r=r.replace(o,`;${lt(n,c)}`);continue}r=r.replace(o,a==="label"?`.${c}`:c)}return r}function Nn(e){return JSON.stringify(e)}function On(e,t){let r=`${t.baseUrl}${e}`;t.params?.path&&(r=Tn(r,t.params.path));let o=t.querySerializer(t.params.query??{});return o.startsWith("?")&&(o=o.substring(1)),o&&(r+=`?${o}`),r}function Wr(...e){let t=new Headers;for(let r of e){if(!r||typeof r!="object")continue;let o=r instanceof Headers?r.entries():Object.entries(r);for(let[n,s]of o)if(s===null)t.delete(n);else if(Array.isArray(s))for(let a of s)t.append(n,a);else s!==void 0&&t.set(n,s)}return t}var Q=(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))(Q||{}),De=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(De||{}),zt=(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))(zt||{});var xn="Adora.URLChange",Gr="Adora.Cohort",Mn="Adora.AddCohort",kn="Adora.Click";var Gt=["onclick","ondblclick","onmousedown","onmousemove","onmouseout","onmouseover","onmouseup","onchange","onfocus","onblur","onscroll","onselect","onsubmit","onkeydown","onkeypress","onkeyup","onload","onunload"];function Kr({dom0EventHandlers:e,delay:t,timestamp:r}){return{type:Q.Custom,data:{tag:kn,payload:{dom0EventHandlers:e}},delay:t,timestamp:r}}function Ze({payload:e,delay:t,timestamp:r}){return{type:Q.Custom,data:{tag:Mn,payload:e},delay:t,timestamp:r}}function jr({href:e,delay:t,timestamp:r}){return{type:Q.Custom,data:{tag:xn,payload:{href:e}},delay:t,timestamp:r}}function ae(e){throw new Error(`This code path should be unreachable: ${e}`)}var zn=require("uuidv7");var md=1e3*60*30;var yd=10080*60*1e3;var Zr="https://c.adora-cdn.com";var ve=class{constructor(t){de(this,"backendClient");de(this,"eventPostBackendClient");this.backendClient=jt({baseUrl:t??Zr})}getOrCreateEventPostClient(t){return!t.eventPostUrl||!t.eventPostToken?{path:t.sessionId,client:this.backendClient}:(this.eventPostBackendClient||(this.eventPostBackendClient=jt({baseUrl:t.eventPostUrl})),{path:t.sessionId,client:this.eventPostBackendClient})}async sessionPreload({orgId:t}){return this.backendClient.POST("/sessions/preload",{body:{orgId:t},mode:"cors"}).catch(()=>{})}async startSession({bypassSampling:t,orgId:r,language:o,domain:n,userCohorts:s,uid:a,devicePixelRatio:c,adoraUserId:i,userAgent:u,documentReferrer:d,snippetVersion:l}){return this.backendClient.POST("/sessions/start",{body:{bypassSampling:t,orgId:r,language:o,domain:n,devicePixelRatio:c,userCohorts:s||{},userAgent:u,uid:typeof a=="number"?a.toString():a!=="null"&&a!=="undefined"?a:void 0,adoraUserId:i,documentReferrer:d,snippetVersion:l},mode:"cors"}).catch(()=>{})}async gzipWithCompressionStream(t){let r=JSON.stringify(t),n=new TextEncoder().encode(r),s=new CompressionStream("gzip"),c=new ReadableStream({start(u){u.enqueue(n),u.close()}}).pipeThrough(s);return new Response(c).arrayBuffer()}async saveSessionEvents({sessionId:t,events:r,metadata:o,eventPostUrl:n,eventPostToken:s,fastpathToken:a}){let{path:c,client:i}=this.getOrCreateEventPostClient({sessionId:t,eventPostToken:s,eventPostUrl:n}),u={events:r.slice(),metadata:o,fastpathToken:a},d={params:{path:{sessionId:c}},headers:s?{token:s}:void 0};if(typeof CompressionStream<"u"){let l=await this.gzipWithCompressionStream(u);return i.POSTGzipped("/sessions/{sessionId}/events",{...d,body:l}).catch(()=>{})}return i.POST("/sessions/{sessionId}/events",{...d,body:u}).catch(()=>{})}async refreshEventToken(t){return await this.backendClient.POST("/sessions/{sessionId}/events/token",{params:{path:{sessionId:t.sessionId}},body:{},mode:"cors"}).catch(()=>{})}async syncSession(t){return await this.backendClient.POST("/sessions/{sessionId}/sync",{params:{path:{sessionId:t.sessionId}}}).catch(()=>{})}};var ht=require("minimatch");function jn(e){return e.endsWith("$")&&(e=e.substring(0,e.length-1)),(e.endsWith("+?")||e.endsWith("*?"))&&(e=e.substring(0,e.length-1)),e}function Pe(e,t){let r=t.replace||t.path;switch(t.type){case"regexp":{let o=(t.path.startsWith("^")?"":"^")+t.path+(!t.path.endsWith("$")&&!t.partial?"$":""),n=new RegExp(o);return n.test(e)?t.partial?e.replace(n,r):r:void 0}case"wildcard":case void 0:if(t.partial){let o=(0,ht.makeRe)(t.path,{partial:t.partial,dot:!0});if(!o)throw new Error("unable to make regexp");let n=new RegExp(jn(o.source));return n.test(e)?e.replace(n,r):void 0}return(0,ht.minimatch)(e,t.path,{dot:!0})?r:void 0;default:ae(t.type)}}var $t;(function(e){e.GOAL_SURVEY_FINISHED="goal_survey_finished",e.WELCOME_DIALOG_FINISHED="welcome_dialog_finished"})($t||($t={}));var Zt;(function(e){e.EXPLORE_AND_VISUALIZE="Explore and visualize",e.MEASURE_AND_OPTIMIZE="Measure and optimize",e.IDENTIFY_FRICTION="Identify friction",e.DIAGNOSE_ISSUES="Diagnose issues"})(Zt||(Zt={}));var Jt;(function(e){e.SKIPPED="skipped",e.COMPLETED="completed"})(Jt||(Jt={}));var Xt;(function(e){e.NONE="none",e.NEW_USER_GOAL_SURVEY="new_user_goal_survey",e.EXISTING_USER_WELCOME_DIALOG="existing_user_welcome_dialog"})(Xt||(Xt={}));var jt=e=>({...Bt(e),POSTGzipped:async(r,o)=>{if(!o?.body)throw new Error("Body is required for gzipped requests");let n={...o.headers,"Content-Type":"application/json","Content-Encoding":"gzip"},s=r;o.params?.path&&Object.entries(o.params.path).forEach(([i,u])=>{s=s.replace(`{${i}}`,u)});let a=await fetch(`${e.baseUrl}${s}`,{method:"POST",headers:n,body:o.body});if(!a.ok){let i=await a.text();try{i=JSON.parse(i)}catch{}return{data:void 0,error:i,response:a}}return{data:await a.json(),error:void 0,response:a}}});var yn=require("fast-equals"),dt=Yr(require("js-cookie"),1),Sn=require("uuidv7");var ft=class{constructor(t,r){this.storage=r;this.eventStorageKey=t==="adoraSessionScript"?"adoraEventsScript":"adoraEventsExtension"}getEvents(){let t=this.storage.getItem(this.eventStorageKey);return t?JSON.parse(t):null}setEvents(t){this.storage.setItem(this.eventStorageKey,JSON.stringify(t))}removeEvents(){this.storage.removeItem(this.eventStorageKey)}};function qt(e){return`${e}-rate-limit-timestamp`}var Ie=class{constructor(t,r){this.sessionType=t;this.storage=r}get lastRateLimitedTimestamp(){let t=this.storage.getItem(qt(this.sessionType));if($n(t))return t}clearLastRateLimitedTimestamp(){this.storage.removeItem(qt(this.sessionType))}setLastRateLimitedTimestamp(t){this.storage.setItem(qt(this.sessionType),t.toString())}getSession(){let t=this.storage.getItem(this.sessionType);return t?JSON.parse(t):null}setSession(t){this.storage.setItem(this.sessionType,JSON.stringify(t))}removeSession(){this.storage.removeItem(this.sessionType)}};function $n(e){return!isNaN(Number(e))}function b(e,...t){(typeof window=="object"&&window.enableAdoraDebugLogs||typeof window=="object"&&window.localStorage.getItem("enableAdoraDebugLogs"))&&console.log(e,...t)}var be=class{getItem(t){if(!Qt())return null;try{return window.sessionStorage.getItem(t)}catch{return null}}setItem(t,r){if(!Qt())return null;try{return window.sessionStorage.setItem(t,r)}catch{return null}}removeItem(t){if(!Qt())return null;try{return window.sessionStorage.removeItem(t)}catch{return null}}};function Qt(){return typeof window.sessionStorage=="object"}var pt="v0.0.1";var Jr=async(e,t,r)=>{let o=new Ie(e,new be),n=new ve(r.backendUrl),s=await Zn(n,r,t);return s.type==="success"&&o.setSession(s.storedSession),s};async function Zn(e,t,r){try{b("starting session over network",{uid:t.uid,userCohorts:t.userCohorts||{}});let o=await e.startSession({bypassSampling:t.bypassSampling,orgId:t.orgId,language:t.language||navigator.language,domain:new URL(window.location.href).hostname,userCohorts:t.userCohorts||{},uid:t.uid,devicePixelRatio:window.devicePixelRatio,adoraUserId:r,documentReferrer:document.referrer,snippetVersion:pt});if(!o)return{type:"error",code:void 0};if(o.error)return{type:"error",code:o.error.code};if(o.response.status!==201)return b("session not created, aborting"),{type:"error",code:"code"in o.data?o.data.code:void 0};if(o.data&&"scheduledDowntime"in o.data)return b("scheduled downtime, exiting"),{type:"error",code:void 0};if(!o.data||!("session"in o.data))return b("malformed session, exiting"),{type:"error",code:void 0};let{session:n,organization:s,eventPostUrl:a,eventPostToken:c}=o.data;return{type:"success",storedSession:{id:n.id,createdAt:n.createdAt,status:n.status,lastSyncedAt:n.lastSyncedAt,domain:n.domain,requestIp:n.requestIp,country:n.country,userAgent:n.userAgent,language:n.language,initialUserCohorts:n.initialUserCohorts,devicePixelRatio:n.devicePixelRatio,organization:s,documentReferrer:n.documentReferrer,canvasRecordingEnabled:n.canvasRecordingEnabled||!1,adoraUserId:r,settings:t,eventPostUrl:a,eventPostToken:c,limitedCanvasRecording:n.limitedCanvasRecording||!1,compressionType:n.compressionType}}}catch{return{type:"error",code:void 0}}}var Ke=Yr(require("web-vitals"),1);var Xr="__STATSIG__",Jn="statsig@@",qr=e=>{try{if(!e[Xr])return;let t=e[Xr];if(!qn(t))return;let r={};return Object.values(t.instances).forEach(o=>{o._logger?._lastExposureTimeMap&&Object.keys(o._logger?._lastExposureTimeMap).forEach(n=>{let s=Xn(n);if(!s)return;let a=o.getExperiment(s);ts(a)&&(r[Jn+a.name]=a.groupName)})}),r}catch{return}},Xn=e=>{let t=e.split("|");if(t.length>3)return t[3]};function qn(e){if(!e||typeof e!="object"||!("instances"in e)||typeof e.instances!="object"||!e.instances)return!1;let t=Object.values(e.instances);for(let r of t)if(!Qn(r))return!1;return!0}function Qn(e){return!e||typeof e!="object"?!1:"_logger"in e&&typeof e._logger=="object"&&es(e._logger)&&"_sdkKey"in e&&typeof e._sdkKey=="string"&&"getExperiment"in e&&typeof e.getExperiment=="function"}function es(e){return!e||typeof e!="object"?!1:"_lastExposureTimeMap"in e&&typeof e._lastExposureTimeMap=="object"}function ts(e){return!e||typeof e!="object"?!1:"name"in e&&typeof e.name=="string"&&"groupName"in e&&typeof e.groupName=="string"}function gt(e,t){if(!t.windowGetters)return;let r={};if(t.windowGetters.forEach(({key:o,paths:n})=>{let s=rs(e,n);s&&(r[o]=s)}),Object.keys(r).length!==0)return r}function rs(e,t){if(typeof e>"u")return;let r=e;for(let n=0;n<t.length-1;n++)if(r=r[t[n]],typeof r!="object")return;let o=r[t[t.length-1]];if(typeof o=="string")return o;if(typeof o=="boolean"||typeof o=="number")return o.toString()}function er(e){return qr(e)}var os=Object.defineProperty,ns=(e,t,r)=>t in e?os(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,S=(e,t,r)=>ns(e,typeof t!="symbol"?t+"":t,r),Qr,ss=Object.defineProperty,is=(e,t,r)=>t in e?ss(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,eo=(e,t,r)=>is(e,typeof t!="symbol"?t+"":t,r),K=(e=>(e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e))(K||{}),to={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},ro={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},mt={};function Cr(e){if(mt[e])return mt[e];let t=globalThis[e],r=t.prototype,o=e in to?to[e]:void 0,n=!!(o&&o.every(c=>{var i,u;return!!((u=(i=Object.getOwnPropertyDescriptor(r,c))==null?void 0:i.get)!=null&&u.toString().includes("[native code]"))})),s=e in ro?ro[e]:void 0,a=!!(s&&s.every(c=>{var i;return typeof r[c]=="function"&&((i=r[c])==null?void 0:i.toString().includes("[native code]"))}));if(n&&a)return mt[e]=t.prototype,t.prototype;try{let c=document.createElement("iframe");document.body.appendChild(c);let i=c.contentWindow;if(!i)return t.prototype;let u=i[e].prototype;return document.body.removeChild(c),u?mt[e]=u:r}catch{return r}}var tr={};function Re(e,t,r){var o;let n=`${e}.${String(r)}`;if(tr[n])return tr[n].call(t);let s=Cr(e),a=(o=Object.getOwnPropertyDescriptor(s,r))==null?void 0:o.get;return a?(tr[n]=a,a.call(t)):t[r]}var rr={};function bo(e,t,r){let o=`${e}.${String(r)}`;if(rr[o])return rr[o].bind(t);let s=Cr(e)[r];return typeof s!="function"?t[r]:(rr[o]=s,s.bind(t))}function as(e){return Re("Node",e,"childNodes")}function ds(e){return Re("Node",e,"parentNode")}function cs(e){return Re("Node",e,"parentElement")}function us(e){return Re("Node",e,"textContent")}function ls(e,t){return bo("Node",e,"contains")(t)}function hs(e){return bo("Node",e,"getRootNode")()}function fs(e){return!e||!("host"in e)?null:Re("ShadowRoot",e,"host")}function ps(e){return e.styleSheets}function gs(e){return!e||!("shadowRoot"in e)?null:Re("Element",e,"shadowRoot")}function ms(e,t){return Re("Element",e,"querySelector")(t)}function ys(e,t){return Re("Element",e,"querySelectorAll")(t)}function Ss(){return Cr("MutationObserver").constructor}var q={childNodes:as,parentNode:ds,parentElement:cs,textContent:us,contains:ls,getRootNode:hs,host:fs,styleSheets:ps,shadowRoot:gs,querySelector:ms,querySelectorAll:ys,mutationObserver:Ss};function Co(e){return e.nodeType===e.ELEMENT_NODE}function Xe(e){let t=e&&"host"in e&&"mode"in e&&q.host(e)||null;return!!(t&&"shadowRoot"in t&&q.shadowRoot(t)===e)}function qe(e){return Object.prototype.toString.call(e)==="[object ShadowRoot]"}function vs(e){return e.includes(" background-clip: text;")&&!e.includes(" -webkit-background-clip: text;")&&(e=e.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),e}function bs(e){let{cssText:t}=e;if(t.split('"').length<3)return t;let r=["@import",`url(${JSON.stringify(e.href)})`];return e.layerName===""?r.push("layer"):e.layerName&&r.push(`layer(${e.layerName})`),e.supportsText&&r.push(`supports(${e.supportsText})`),e.media.length&&r.push(e.media.mediaText),r.join(" ")+";"}function dr(e){try{let t=e.rules||e.cssRules;if(!t)return null;let r=e.href;!r&&e.ownerNode&&e.ownerNode.ownerDocument&&(r=e.ownerNode.ownerDocument.location.href);let o=Array.from(t,n=>wo(n,r)).join("");return vs(o)}catch{return null}}function wo(e,t){if(ws(e)){let r;try{r=dr(e.styleSheet)||bs(e)}catch{r=e.cssText}return e.styleSheet.href?It(r,e.styleSheet.href):r}else{let r=e.cssText;return Es(e)&&e.selectorText.includes(":")&&(r=Cs(r)),t?It(r,t):r}}function Cs(e){let t=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return e.replace(t,"$1\\$2")}function ws(e){return"styleSheet"in e}function Es(e){return"selectorText"in e}var wt=class{constructor(){eo(this,"idNodeMap",new Map),eo(this,"nodeMetaMap",new WeakMap)}getId(t){var r;return t?((r=this.getMeta(t))==null?void 0:r.id)??-1:-1}getNode(t){return this.idNodeMap.get(t)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(t){return this.nodeMetaMap.get(t)||null}removeNodeFromMap(t){let r=this.getId(t);this.idNodeMap.delete(r),t.childNodes&&t.childNodes.forEach(o=>this.removeNodeFromMap(o))}has(t){return this.idNodeMap.has(t)}hasNode(t){return this.nodeMetaMap.has(t)}add(t,r){let o=r.id;this.idNodeMap.set(o,t),this.nodeMetaMap.set(t,r)}replace(t,r){let o=this.getNode(t);if(o){let n=this.nodeMetaMap.get(o);n&&this.nodeMetaMap.set(r,n)}this.idNodeMap.set(t,r)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}};function Is(){return new wt}function Et({element:e,maskInputOptions:t,tagName:r,type:o,value:n,maskInputFn:s}){let a=n||"",c=o&&Ne(o);return(t[r.toLowerCase()]||c&&t[c])&&(s?a=s(a,e):a="*".repeat(a.length)),a}function Ne(e){return e.toLowerCase()}var oo="__rrweb_original__";function _s(e){let t=e.getContext("2d");if(!t)return!0;let r=50;for(let o=0;o<e.width;o+=r)for(let n=0;n<e.height;n+=r){let s=t.getImageData,a=oo in s?s[oo]:s;if(new Uint32Array(a.call(t,o,n,Math.min(r,e.width-o),Math.min(r,e.height-n)).data.buffer).some(i=>i!==0))return!1}return!0}function wr(e){let t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?Ne(t):null}function Eo(e,t){let r;try{r=new URL(e,t??window.location.href)}catch{return null}let o=/\.([0-9a-z]+)(?:$)/i,n=r.pathname.match(o);return n?.[1]??null}function Rs(e){let t="";return e.indexOf("//")>-1?t=e.split("/").slice(0,3).join("/"):t=e.split("/")[0],t=t.split("?")[0],t}var As=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Ds=/^(?:[a-z+]+:)?\/\//i,Ts=/^www\..*/i,Ns=/^(data:)([^,]*),(.*)/i;function It(e,t){return(e||"").replace(As,(r,o,n,s,a,c)=>{let i=n||a||c,u=o||s||"";if(!i)return r;if(Ds.test(i)||Ts.test(i))return`url(${u}${i}${u})`;if(Ns.test(i))return`url(${u}${i}${u})`;if(i[0]==="/")return`url(${u}${Rs(t)+i}${u})`;let d=t.split("/"),l=i.split("/");d.pop();for(let g of l)g!=="."&&(g===".."?d.pop():d.push(g));return`url(${u}${d.join("/")}${u})`})}function or(e){return e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"")}function Os(e,t){let r=Array.from(t.childNodes),o=[];if(r.length>1&&e&&typeof e=="string"){let n=or(e);for(let s=1;s<r.length;s++)if(r[s].textContent&&typeof r[s].textContent=="string"){let a=or(r[s].textContent);for(let c=3;c<a.length;c++){let i=a.substring(0,c);if(n.split(i).length===2){let u=n.indexOf(i);for(let d=u;d<e.length;d++)if(or(e.substring(0,d)).length===u){o.push(e.substring(0,d)),e=e.substring(d);break}break}}}}return o.push(e),o}function xs(e,t){return Os(e,t).join("/* rr_split */")}var Ms=1,ks=new RegExp("[^a-z0-9-_:]"),et=-2;function Io(){return Ms++}function Ls(e){if(e instanceof HTMLFormElement)return"form";let t=Ne(e.tagName);return ks.test(t)?"div":t}var Fe,no,Ps=/^[^ \t\n\r\u000c]+/,Fs=/^[, \t\n\r\u000c]+/;function Us(e,t){if(t.trim()==="")return t;let r=0;function o(s){let a,c=s.exec(t.substring(r));return c?(a=c[0],r+=a.length,a):""}let n=[];for(;o(Fs),!(r>=t.length);){let s=o(Ps);if(s.slice(-1)===",")s=Ye(e,s.substring(0,s.length-1)),n.push(s);else{let a="";s=Ye(e,s);let c=!1;for(;;){let i=t.charAt(r);if(i===""){n.push((s+a).trim());break}else if(c)i===")"&&(c=!1);else if(i===","){r+=1,n.push((s+a).trim());break}else i==="("&&(c=!0);a+=i,r+=1}}}return n.join(", ")}var so=new WeakMap;function Ye(e,t){return!t||t.trim()===""?t:Er(e,t)}function Hs(e){return!!(e.tagName==="svg"||e.ownerSVGElement)}function Er(e,t){let r=so.get(e);if(r||(r=e.createElement("a"),so.set(e,r)),!t)t="";else if(t.startsWith("blob:")||t.startsWith("data:"))return t;return r.setAttribute("href",t),r.href}function _o(e,t,r,o){return o&&(r==="src"||r==="href"&&!(t==="use"&&o[0]==="#")||r==="xlink:href"&&o[0]!=="#"||r==="background"&&(t==="table"||t==="td"||t==="th")?Ye(e,o):r==="srcset"?Us(e,o):r==="style"?It(o,Er(e)):t==="object"&&r==="data"?Ye(e,o):o)}function Ro(e,t,r){return(e==="video"||e==="audio")&&t==="autoplay"}function Ys(e,t,r,o){try{if(typeof t=="string"){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;){let s=e.classList[n];if(t.test(s))return!0}if(r)return e.matches(r);if(o&&e.tagName==="IMG"){let n=e.getAttribute("src");if(n&&o.test(n))return!0}}catch{}return!1}function _t(e,t,r){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return r?_t(q.parentNode(e),t,r):!1;for(let o=e.classList.length;o--;){let n=e.classList[o];if(t.test(n))return!0}return r?_t(q.parentNode(e),t,r):!1}function Ao(e,t,r,o){let n;if(Co(e)){if(n=e,!q.childNodes(n).length)return!1}else{if(q.parentElement(e)===null)return!1;n=q.parentElement(e)}try{if(typeof t=="string"){if(o){if(n.closest(`.${t}`))return!0}else if(n.classList.contains(t))return!0}else if(_t(n,t,o))return!0;if(r){if(o){if(n.closest(r))return!0}else if(n.matches(r))return!0}if(n.getAttribute("contenteditable")||n.closest('[contenteditable="true"]'))return!0}catch{}return!1}function Vs(e,t,r){let o=e.contentWindow;if(!o)return;let n=!1,s;try{s=o.document.readyState}catch{return}if(s!=="complete"){let c=setTimeout(()=>{n||(t(),n=!0)},r);e.addEventListener("load",()=>{clearTimeout(c),n=!0,t()});return}let a="about:blank";if(o.location.href!==a||e.src===a||e.src==="")return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}function Ws(e,t,r){let o=!1,n;try{n=e.sheet}catch{return}if(n)return;let s=setTimeout(()=>{o||(t(),o=!0)},r);e.addEventListener("load",()=>{clearTimeout(s),o=!0,t()})}function Bs(e,t){let{doc:r,mirror:o,blockClass:n,blockSelector:s,needsMask:a,inlineStylesheet:c,maskInputOptions:i={},maskTextFn:u,maskInputFn:d,maskAnchorHrefFn:l,blockImgSrcPattern:g,blockImgSrcFillOptions:f,dataURLOptions:p={},inlineImages:h,recordCanvas:C,keepIframeSrcFn:I,newlyAddedElement:v=!1,cssCaptured:y=!1}=t,_=zs(r,o);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode!=="CSS1Compat"?{type:K.Document,childNodes:[],compatMode:e.compatMode}:{type:K.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:K.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:_};case e.ELEMENT_NODE:return Ks(e,{doc:r,blockClass:n,blockSelector:s,inlineStylesheet:c,maskInputOptions:i,maskInputFn:d,maskAnchorHrefFn:l,blockImgSrcPattern:g,blockImgSrcFillOptions:f,dataURLOptions:p,inlineImages:h,recordCanvas:C,keepIframeSrcFn:I,newlyAddedElement:v,rootId:_});case e.TEXT_NODE:return Gs(e,{doc:r,needsMask:a,maskTextFn:u,rootId:_,cssCaptured:y});case e.CDATA_SECTION_NODE:return{type:K.CDATA,textContent:"",rootId:_};case e.COMMENT_NODE:return{type:K.Comment,textContent:q.textContent(e)||"",rootId:_};default:return!1}}function zs(e,t){if(!t.hasNode(e))return;let r=t.getId(e);return r===1?void 0:r}function Gs(e,t){let{needsMask:r,maskTextFn:o,rootId:n,cssCaptured:s}=t,a=q.parentNode(e),c=a&&a.tagName,i="",u=c==="STYLE"?!0:void 0,d=c==="SCRIPT"?!0:void 0;return d?i="SCRIPT_PLACEHOLDER":s||(i=q.textContent(e),u&&i&&(i=It(i,Er(t.doc)))),!u&&!d&&i&&r&&(i=o?o(i,q.parentElement(e)):i.replace(/[\S]/g,"*")),{type:K.Text,textContent:i||"",rootId:n}}function Ks(e,t){let{doc:r,blockClass:o,blockSelector:n,inlineStylesheet:s,maskInputOptions:a={},maskInputFn:c,maskAnchorHrefFn:i,blockImgSrcPattern:u,blockImgSrcFillOptions:d,dataURLOptions:l={},inlineImages:g,recordCanvas:f,keepIframeSrcFn:p,newlyAddedElement:h=!1,rootId:C}=t,I=Ys(e,o,n,u),v=Ls(e),y={},_=e.attributes.length;for(let m=0;m<_;m++){let E=e.attributes[m];Ro(v,E.name,E.value)||(y[E.name]=_o(r,v,Ne(E.name),E.value))}if(v==="a"&&i&&typeof y.href=="string"&&(y.href=i(y.href,e)),v==="link"&&s){let m=Array.from(r.styleSheets).find(w=>w.href===e.href);if(!m&&e.href.includes(".css")){let w=window.location.origin,D=e.href.replace(window.location.href,""),L=w+"/"+D;m=Array.from(r.styleSheets).find(oe=>oe.href===L)}let E=null;m&&(E=dr(m)),E&&(delete y.rel,delete y.href,y._cssText=E)}if(v==="style"&&e.sheet){let m=dr(e.sheet);m&&(e.childNodes.length>1&&(m=xs(m,e)),y._cssText=m)}if(v==="input"||v==="textarea"||v==="select"){let m=e.value,E=e.checked;y.type!=="radio"&&y.type!=="checkbox"&&y.type!=="submit"&&y.type!=="button"&&m?y.value=Et({element:e,type:wr(e),tagName:v,value:m,maskInputOptions:a,maskInputFn:c}):E&&(y.checked=E)}if(v==="option"&&(e.selected&&!a.select?y.selected=!0:delete y.selected),v==="dialog"&&e.open&&(y.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal"),v==="canvas"&&f){if(e.__context==="2d")_s(e)||(y.rr_dataURL=e.toDataURL(l.type,l.quality));else if(!("__context"in e)){let m=e.toDataURL(l.type,l.quality),E=r.createElement("canvas");E.width=e.width,E.height=e.height;let w=E.toDataURL(l.type,l.quality);m!==w&&(y.rr_dataURL=m)}}if(v==="img"&&g){Fe||(Fe=r.createElement("canvas"),no=Fe.getContext("2d"));let m=e,E=m.currentSrc||m.getAttribute("src")||"<unknown-src>",w=m.crossOrigin,D=()=>{m.removeEventListener("load",D);try{Fe.width=m.naturalWidth,Fe.height=m.naturalHeight,no.drawImage(m,0,0),y.rr_dataURL=Fe.toDataURL(l.type,l.quality)}catch(L){if(m.crossOrigin!=="anonymous"){m.crossOrigin="anonymous",m.complete&&m.naturalWidth!==0?D():m.addEventListener("load",D);return}else console.warn(`Cannot inline img src=${E}! Error: ${L}`)}m.crossOrigin==="anonymous"&&(w?y.crossOrigin=w:m.removeAttribute("crossorigin"))};m.complete&&m.naturalWidth!==0?D():m.addEventListener("load",D)}if(v==="audio"||v==="video"){let m=y;m.rr_mediaState=e.paused?"paused":"played",m.rr_mediaCurrentTime=e.currentTime,m.rr_mediaPlaybackRate=e.playbackRate,m.rr_mediaMuted=e.muted,m.rr_mediaLoop=e.loop,m.rr_mediaVolume=e.volume}if(h||(e.scrollLeft&&(y.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(y.rr_scrollTop=e.scrollTop)),I){let{width:m,height:E}=e.getBoundingClientRect();y={class:y.class,rr_width:`${m}px`,rr_height:`${E}px`}}I&&v==="img"&&(y={...y,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP89v3nfwAJuAPnyTr4jAAAAABJRU5ErkJggg==",rr_fill:d.backgroundColor,rr_stroke:d.strokeColor,rr_stroke_width:d.strokeWidth}),v==="iframe"&&!p(y.src)&&(e.contentDocument||(y.rr_src=y.src),delete y.src);let A;try{customElements.get(v)&&(A=!0)}catch{}return{type:K.Element,tagName:v,attributes:y,childNodes:[],isSVG:Hs(e)||void 0,needBlock:I,rootId:C,isCustom:A}}function U(e){return e==null?"":e.toLowerCase()}function js(e,t){if(t.comment&&e.type===K.Comment)return!0;if(e.type===K.Element){if(t.script&&(e.tagName==="script"||e.tagName==="link"&&(e.attributes.rel==="preload"||e.attributes.rel==="modulepreload")&&e.attributes.as==="script"||e.tagName==="link"&&e.attributes.rel==="prefetch"&&typeof e.attributes.href=="string"&&Eo(e.attributes.href)==="js"))return!0;if(t.headFavicon&&(e.tagName==="link"&&e.attributes.rel==="shortcut icon"||e.tagName==="meta"&&(U(e.attributes.name).match(/^msapplication-tile(image|color)$/)||U(e.attributes.name)==="application-name"||U(e.attributes.rel)==="icon"||U(e.attributes.rel)==="apple-touch-icon"||U(e.attributes.rel)==="shortcut icon")))return!0;if(e.tagName==="meta"){if(t.headMetaDescKeywords&&U(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(U(e.attributes.property).match(/^(og|twitter|fb):/)||U(e.attributes.name).match(/^(og|twitter):/)||U(e.attributes.name)==="pinterest"))return!0;if(t.headMetaRobots&&(U(e.attributes.name)==="robots"||U(e.attributes.name)==="googlebot"||U(e.attributes.name)==="bingbot"))return!0;if(t.headMetaHttpEquiv&&e.attributes["http-equiv"]!==void 0)return!0;if(t.headMetaAuthorship&&(U(e.attributes.name)==="author"||U(e.attributes.name)==="generator"||U(e.attributes.name)==="framework"||U(e.attributes.name)==="publisher"||U(e.attributes.name)==="progid"||U(e.attributes.property).match(/^article:/)||U(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&(U(e.attributes.name)==="google-site-verification"||U(e.attributes.name)==="yandex-verification"||U(e.attributes.name)==="csrf-token"||U(e.attributes.name)==="p:domain_verify"||U(e.attributes.name)==="verify-v1"||U(e.attributes.name)==="verification"||U(e.attributes.name)==="shopify-checkout-api-token"))return!0}}return!1}function Ve(e,t){if(e.nodeName.toLowerCase().includes("grammarly"))return null;let{doc:r,mirror:o,blockClass:n,blockSelector:s,maskTextClass:a,maskTextSelector:c,skipChild:i=!1,inlineStylesheet:u=!0,maskInputOptions:d={},maskTextFn:l,maskInputFn:g,maskAnchorHrefFn:f,blockImgSrcPattern:p,blockImgSrcFillOptions:h,slimDOMOptions:C,dataURLOptions:I={},inlineImages:v=!1,recordCanvas:y=!1,onSerialize:_,onIframeLoad:A,iframeLoadTimeout:m=5e3,onStylesheetLoad:E,stylesheetLoadTimeout:w=5e3,keepIframeSrcFn:D=()=>!1,newlyAddedElement:L=!1,cssCaptured:oe=!1}=t,{needsMask:H}=t,{preserveWhiteSpace:ne=!0}=t;H||(H=Ao(e,a,c,H===void 0));let G=Bs(e,{doc:r,mirror:o,blockClass:n,blockSelector:s,needsMask:H,inlineStylesheet:u,maskInputOptions:d,maskTextFn:l,maskInputFn:g,maskAnchorHrefFn:f,blockImgSrcPattern:p,blockImgSrcFillOptions:h,dataURLOptions:I,inlineImages:v,recordCanvas:y,keepIframeSrcFn:D,newlyAddedElement:L,cssCaptured:oe});if(!G)return console.warn(e,"not serialized"),null;let V;o.hasNode(e)?V=o.getId(e):js(G,C)||!ne&&G.type===K.Text&&!G.textContent.replace(/^\s+|\s+$/gm,"").length?V=et:V=Io();let R=Object.assign(G,{id:V});if(o.add(e,R),V===et)return null;_&&_(e);let Y=!i;if(R.type===K.Element){Y=Y&&!R.needBlock,delete R.needBlock;let P=q.shadowRoot(e);P&&qe(P)&&(R.isShadowHost=!0)}if((R.type===K.Document||R.type===K.Element)&&Y){C.headWhitespace&&R.type===K.Element&&R.tagName==="head"&&(ne=!1);let P={doc:r,mirror:o,blockClass:n,blockSelector:s,needsMask:H,maskTextClass:a,maskTextSelector:c,skipChild:i,inlineStylesheet:u,maskInputOptions:d,maskTextFn:l,maskInputFn:g,maskAnchorHrefFn:f,blockImgSrcPattern:p,blockImgSrcFillOptions:h,slimDOMOptions:C,dataURLOptions:I,inlineImages:v,recordCanvas:y,preserveWhiteSpace:ne,onSerialize:_,onIframeLoad:A,iframeLoadTimeout:m,onStylesheetLoad:E,stylesheetLoadTimeout:w,keepIframeSrcFn:D,cssCaptured:!1};if(!(R.type===K.Element&&R.tagName==="textarea"&&R.attributes.value!==void 0)){R.type===K.Element&&R.attributes._cssText!==void 0&&typeof R.attributes._cssText=="string"&&(P.cssCaptured=!0);for(let j of Array.from(q.childNodes(e))){let J=Ve(j,P);J&&R.childNodes.push(J)}}let Z=null;if(Co(e)&&(Z=q.shadowRoot(e)))for(let j of Array.from(q.childNodes(Z))){let J=Ve(j,P);J&&(qe(Z)&&(J.isShadow=!0),R.childNodes.push(J))}}let $=q.parentNode(e);return $&&Xe($)&&qe($)&&(R.isShadow=!0),R.type===K.Element&&R.tagName==="iframe"&&Vs(e,()=>{let P=e.contentDocument;if(P&&A){let Z=Ve(P,{doc:P,mirror:o,blockClass:n,blockSelector:s,needsMask:H,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:u,maskInputOptions:d,maskTextFn:l,maskInputFn:g,maskAnchorHrefFn:f,blockImgSrcPattern:p,blockImgSrcFillOptions:h,slimDOMOptions:C,dataURLOptions:I,inlineImages:v,recordCanvas:y,preserveWhiteSpace:ne,onSerialize:_,onIframeLoad:A,iframeLoadTimeout:m,onStylesheetLoad:E,stylesheetLoadTimeout:w,keepIframeSrcFn:D});Z&&A(e,Z)}},m),R.type===K.Element&&R.tagName==="link"&&typeof R.attributes.rel=="string"&&(R.attributes.rel==="stylesheet"||R.attributes.rel==="preload"&&typeof R.attributes.href=="string"&&Eo(R.attributes.href)==="css")&&Ws(e,()=>{if(E){let P=Ve(e,{doc:r,mirror:o,blockClass:n,blockSelector:s,needsMask:H,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:u,maskInputOptions:d,maskTextFn:l,maskInputFn:g,maskAnchorHrefFn:f,blockImgSrcPattern:p,blockImgSrcFillOptions:h,slimDOMOptions:C,dataURLOptions:I,inlineImages:v,recordCanvas:y,preserveWhiteSpace:ne,onSerialize:_,onIframeLoad:A,iframeLoadTimeout:m,onStylesheetLoad:E,stylesheetLoadTimeout:w,keepIframeSrcFn:D});P&&E(e,P)}},w),R}function $s(e,t){let{mirror:r=new wt,blockClass:o="rr-block",blockSelector:n=null,maskTextClass:s="rr-mask",maskTextSelector:a=null,inlineStylesheet:c=!0,inlineImages:i=!1,recordCanvas:u=!1,maskAllInputs:d=!1,maskTextFn:l,maskInputFn:g,maskAnchorHrefFn:f,blockImgSrcPattern:p=null,blockImgSrcFillOptions:h={backgroundColor:"#F6F7F9",strokeColor:"#E9EBEF",strokeWidth:"1px"},slimDOM:C=!1,dataURLOptions:I,preserveWhiteSpace:v,onSerialize:y,onIframeLoad:_,iframeLoadTimeout:A,onStylesheetLoad:m,stylesheetLoadTimeout:E,keepIframeSrcFn:w=()=>!1}=t||{};return Ve(e,{doc:e,mirror:r,blockClass:o,blockSelector:n,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:d===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:d===!1?{password:!0}:d,maskTextFn:l,maskInputFn:g,maskAnchorHrefFn:f,blockImgSrcPattern:p,blockImgSrcFillOptions:h,slimDOMOptions:C===!0||C==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:C==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:C===!1?{}:C,dataURLOptions:I,inlineImages:i,recordCanvas:u,preserveWhiteSpace:v,onSerialize:y,onIframeLoad:_,iframeLoadTimeout:A,onStylesheetLoad:m,stylesheetLoadTimeout:E,keepIframeSrcFn:w,newlyAddedElement:!1})}var cr=class e{constructor(...t){__publicField2(this,"parentElement",null),__publicField2(this,"parentNode",null),__publicField2(this,"ownerDocument"),__publicField2(this,"firstChild",null),__publicField2(this,"lastChild",null),__publicField2(this,"previousSibling",null),__publicField2(this,"nextSibling",null),__publicField2(this,"ELEMENT_NODE",1),__publicField2(this,"TEXT_NODE",3),__publicField2(this,"nodeType"),__publicField2(this,"nodeName"),__publicField2(this,"RRNodeType")}get childNodes(){let t=[],r=this.firstChild;for(;r;)t.push(r),r=r.nextSibling;return t}contains(t){if(t instanceof e){if(t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0}else return!1;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}appendChild(t){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(t,r){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(t){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}},io={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},ao={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},yt={};function Ir(e){if(yt[e])return yt[e];let t=globalThis[e],r=t.prototype,o=e in io?io[e]:void 0,n=!!(o&&o.every(c=>{var i,u;return!!((u=(i=Object.getOwnPropertyDescriptor(r,c))==null?void 0:i.get)!=null&&u.toString().includes("[native code]"))})),s=e in ao?ao[e]:void 0,a=!!(s&&s.every(c=>{var i;return typeof r[c]=="function"&&((i=r[c])==null?void 0:i.toString().includes("[native code]"))}));if(n&&a)return yt[e]=t.prototype,t.prototype;try{let c=document.createElement("iframe");document.body.appendChild(c);let i=c.contentWindow;if(!i)return t.prototype;let u=i[e].prototype;return document.body.removeChild(c),u?yt[e]=u:r}catch{return r}}var nr={};function Ae(e,t,r){var o;let n=`${e}.${String(r)}`;if(nr[n])return nr[n].call(t);let s=Ir(e),a=(o=Object.getOwnPropertyDescriptor(s,r))==null?void 0:o.get;return a?(nr[n]=a,a.call(t)):t[r]}var sr={};function Do(e,t,r){let o=`${e}.${String(r)}`;if(sr[o])return sr[o].bind(t);let s=Ir(e)[r];return typeof s!="function"?t[r]:(sr[o]=s,s.bind(t))}function Zs(e){return Ae("Node",e,"childNodes")}function Js(e){return Ae("Node",e,"parentNode")}function Xs(e){return Ae("Node",e,"parentElement")}function qs(e){return Ae("Node",e,"textContent")}function Qs(e,t){return Do("Node",e,"contains")(t)}function ei(e){return Do("Node",e,"getRootNode")()}function ti(e){return!e||!("host"in e)?null:Ae("ShadowRoot",e,"host")}function ri(e){return e.styleSheets}function oi(e){return!e||!("shadowRoot"in e)?null:Ae("Element",e,"shadowRoot")}function ni(e,t){return Ae("Element",e,"querySelector")(t)}function si(e,t){return Ae("Element",e,"querySelectorAll")(t)}function To(){return Ir("MutationObserver").constructor}var T={childNodes:Zs,parentNode:Js,parentElement:Xs,textContent:qs,contains:Qs,getRootNode:ei,host:ti,styleSheets:ri,shadowRoot:oi,querySelector:ni,querySelectorAll:si,mutationObserver:To};function ee(e,t,r=document){let o={capture:!0,passive:!0};return r.addEventListener(e,t,o),()=>r.removeEventListener(e,t,o)}var Ue=`Please stop import mirror directly. Instead of that,\r
2
- now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
3
- or you can use record.mirror to access the mirror instance during recording.`,co={map:{},getId(){return console.error(Ue),-1},getNode(){return console.error(Ue),null},removeNodeFromMap(){console.error(Ue)},has(){return console.error(Ue),!1},reset(){console.error(Ue)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(co=new Proxy(co,{get(e,t,r){return t==="map"&&console.error(Ue),Reflect.get(e,t,r)}}));function tt(e,t,r={}){let o=null,n=0;return function(...s){let a=Date.now();!n&&r.leading===!1&&(n=a);let c=t-(a-n),i=this;c<=0||c>t?(o&&(clearTimeout(o),o=null),n=a,e.apply(i,s)):!o&&r.trailing!==!1&&(o=setTimeout(()=>{n=r.leading===!1?0:Date.now(),o=null,e.apply(i,s)},c))}}function Nt(e,t,r,o,n=window){let s=n.Object.getOwnPropertyDescriptor(e,t);return n.Object.defineProperty(e,t,o?r:{set(a){setTimeout(()=>{r.set.call(this,a)},0),s&&s.set&&s.set.call(this,a)}}),()=>Nt(e,t,s||{},!0)}function ze(e,t,r){try{if(!(t in e))return()=>{};let o=e[t],n=r(o);return typeof n=="function"&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__rrweb_original__:{enumerable:!1,value:o}})),e[t]=n,()=>{e[t]=o}}catch{return()=>{}}}var Rt=Date.now;/[1-9][0-9]{12}/.test(Date.now().toString())||(Rt=()=>new Date().getTime());function No(e){var t,r,o,n;let s=e.document;return{left:s.scrollingElement?s.scrollingElement.scrollLeft:e.pageXOffset!==void 0?e.pageXOffset:s.documentElement.scrollLeft||s?.body&&((t=T.parentElement(s.body))==null?void 0:t.scrollLeft)||((r=s?.body)==null?void 0:r.scrollLeft)||0,top:s.scrollingElement?s.scrollingElement.scrollTop:e.pageYOffset!==void 0?e.pageYOffset:s?.documentElement.scrollTop||s?.body&&((o=T.parentElement(s.body))==null?void 0:o.scrollTop)||((n=s?.body)==null?void 0:n.scrollTop)||0}}function Oo(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function xo(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Mo(e){return e?e.nodeType===e.ELEMENT_NODE?e:T.parentElement(e):null}function te(e,t,r,o){if(!e)return!1;let n=Mo(e);if(!n)return!1;try{if(typeof t=="string"){if(n.classList.contains(t)||o&&n.closest("."+t)!==null)return!0}else if(_t(n,t,o))return!0}catch{}return!!(r&&(n.matches(r)||o&&n.closest(r)!==null))}function ii(e,t){return t.getId(e)!==-1}function ir(e,t,r){return e.tagName==="TITLE"&&r.headTitleMutations?!0:t.getId(e)===et}function ko(e,t){if(Xe(e))return!1;let r=t.getId(e);if(!t.has(r))return!0;let o=T.parentNode(e);return o&&o.nodeType===e.DOCUMENT_NODE?!1:o?ko(o,t):!0}function ur(e){return!!e.changedTouches}function ai(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach)}function Lo(e,t){return!!(e.nodeName==="IFRAME"&&t.getMeta(e))}function Po(e,t){return!!(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function lr(e){return e?e instanceof cr&&"shadowRoot"in e?!!e.shadowRoot:!!T.shadowRoot(e):!1}var hr=class{constructor(){S(this,"id",1),S(this,"styleIDMap",new WeakMap),S(this,"idStyleMap",new Map)}getId(t){return this.styleIDMap.get(t)??-1}has(t){return this.styleIDMap.has(t)}add(t,r){if(this.has(t))return this.getId(t);let o;return r===void 0?o=this.id++:o=r,this.styleIDMap.set(t,o),this.idStyleMap.set(o,t),o}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}};function Fo(e){var t;let r=null;return"getRootNode"in e&&((t=T.getRootNode(e))==null?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&T.host(T.getRootNode(e))&&(r=T.host(T.getRootNode(e))),r}function di(e){let t=e,r;for(;r=Fo(t);)t=r;return t}function ci(e){let t=e.ownerDocument;if(!t)return!1;let r=di(e);return T.contains(t,r)}function Uo(e){let t=e.ownerDocument;return t?T.contains(t,e)||ci(e):!1}var M=(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))(M||{}),N=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(N||{}),ie=(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))(ie||{}),Ce=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Ce||{}),Be=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(Be||{}),He=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(He||{});function uo(e){return"__ln"in e}var fr=class{constructor(){S(this,"length",0),S(this,"head",null),S(this,"tail",null)}get(t){if(t>=this.length)throw new Error("Position outside of list range");let r=this.head;for(let o=0;o<t;o++)r=r?.next||null;return r}addNode(t){let r={value:t,previous:null,next:null};if(t.__ln=r,t.previousSibling&&uo(t.previousSibling)){let o=t.previousSibling.__ln.next;r.next=o,r.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=r,o&&(o.previous=r)}else if(t.nextSibling&&uo(t.nextSibling)&&t.nextSibling.__ln.previous){let o=t.nextSibling.__ln.previous;r.previous=o,r.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=r,o&&(o.next=r)}else this.head&&(this.head.previous=r),r.next=this.head,this.head=r;r.next===null&&(this.tail=r),this.length++}removeNode(t){let r=t.__ln;this.head&&(r.previous?(r.previous.next=r.next,r.next?r.next.previous=r.previous:this.tail=r.previous):(this.head=r.next,this.head?this.head.previous=null:this.tail=null),t.__ln&&delete t.__ln,this.length--)}},lo=(e,t)=>`${e}@${t}`,pr=class{constructor(){S(this,"frozen",!1),S(this,"locked",!1),S(this,"texts",[]),S(this,"attributes",[]),S(this,"attributeMap",new WeakMap),S(this,"removes",[]),S(this,"mapRemoves",[]),S(this,"movedMap",{}),S(this,"addedSet",new Set),S(this,"movedSet",new Set),S(this,"droppedSet",new Set),S(this,"mutationCb"),S(this,"blockClass"),S(this,"blockSelector"),S(this,"maskTextClass"),S(this,"maskTextSelector"),S(this,"inlineStylesheet"),S(this,"maskInputOptions"),S(this,"maskTextFn"),S(this,"maskInputFn"),S(this,"maskAnchorHrefFn"),S(this,"blockImgSrcPattern"),S(this,"blockImgSrcFillOptions"),S(this,"keepIframeSrcFn"),S(this,"recordCanvas"),S(this,"inlineImages"),S(this,"slimDOMOptions"),S(this,"dataURLOptions"),S(this,"doc"),S(this,"mirror"),S(this,"iframeManager"),S(this,"stylesheetManager"),S(this,"shadowDomManager"),S(this,"canvasManager"),S(this,"processedNodeManager"),S(this,"unattachedDoc"),S(this,"processMutations",t=>{t.forEach(this.processMutation),this.emit()}),S(this,"emit",()=>{if(this.frozen||this.locked)return;let t=[],r=new Set,o=new fr,n=i=>{let u=i,d=et;for(;d===et;)u=u&&u.nextSibling,d=u&&this.mirror.getId(u);return d},s=i=>{let u=T.parentNode(i);if(!u||!Uo(i))return;let d=!1;if(i.nodeType===Node.TEXT_NODE){let p=u.tagName;if(p==="TEXTAREA")return;p==="STYLE"&&this.addedSet.has(u)&&(d=!0)}let l=Xe(u)?this.mirror.getId(Fo(i)):this.mirror.getId(u),g=n(i);if(l===-1||g===-1)return o.addNode(i);let f=Ve(i,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,maskAnchorHrefFn:this.maskAnchorHrefFn,blockImgSrcPattern:this.blockImgSrcPattern,blockImgSrcFillOptions:this.blockImgSrcFillOptions,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:p=>{Lo(p,this.mirror)&&this.iframeManager.addIframe(p),Po(p,this.mirror)&&this.stylesheetManager.trackLinkElement(p),lr(i)&&this.shadowDomManager.addShadowRoot(T.shadowRoot(i),this.doc)},onIframeLoad:(p,h)=>{this.iframeManager.attachIframe(p,h),this.shadowDomManager.observeAttachShadow(p)},onStylesheetLoad:(p,h)=>{this.stylesheetManager.attachLinkElement(p,h)},cssCaptured:d});f&&(t.push({parentId:l,nextId:g,node:f}),r.add(f.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(let i of this.movedSet)ho(this.removes,i,this.mirror)&&!this.movedSet.has(T.parentNode(i))||s(i);for(let i of this.addedSet)!fo(this.droppedSet,i)&&!ho(this.removes,i,this.mirror)||fo(this.movedSet,i)?s(i):this.droppedSet.add(i);let a=null;for(;o.length;){let i=null;if(a){let u=this.mirror.getId(T.parentNode(a.value)),d=n(a.value);u!==-1&&d!==-1&&(i=a)}if(!i){let u=o.tail;for(;u;){let d=u;if(u=u.previous,d){let l=this.mirror.getId(T.parentNode(d.value));if(n(d.value)===-1)continue;if(l!==-1){i=d;break}else{let f=d.value,p=T.parentNode(f);if(p&&p.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let h=T.host(p);if(this.mirror.getId(h)!==-1){i=d;break}}}}}}if(!i){for(;o.head;)o.removeNode(o.head.value);break}a=i.previous,o.removeNode(i.value),s(i.value)}let c={texts:this.texts.map(i=>{let u=i.node,d=T.parentNode(u);return d&&d.tagName==="TEXTAREA"&&this.genTextAreaValueMutation(d),{id:this.mirror.getId(u),value:i.value}}).filter(i=>!r.has(i.id)).filter(i=>this.mirror.has(i.id)),attributes:this.attributes.map(i=>{let{attributes:u}=i;if(typeof u.style=="string"){let d=JSON.stringify(i.styleDiff),l=JSON.stringify(i._unchangedStyles);d.length<u.style.length&&(d+l).split("var(").length===u.style.split("var(").length&&(u.style=i.styleDiff)}return{id:this.mirror.getId(i.node),attributes:u}}).filter(i=>!r.has(i.id)).filter(i=>this.mirror.has(i.id)),removes:this.removes,adds:t};!c.texts.length&&!c.attributes.length&&!c.removes.length&&!c.adds.length||(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(c))}),S(this,"genTextAreaValueMutation",t=>{let r=this.attributeMap.get(t);r||(r={node:t,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(r),this.attributeMap.set(t,r));let o=r.attributes.value=Array.from(T.childNodes(t),n=>T.textContent(n)||"").join("");r.attributes.value=Et({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:null,value:o,maskInputFn:this.maskInputFn})}),S(this,"processMutation",t=>{if(!ir(t.target,this.mirror,this.slimDOMOptions))switch(t.type){case"characterData":{let r=T.textContent(t.target);!te(t.target,this.blockClass,this.blockSelector,!1)&&r!==t.oldValue&&this.texts.push({value:Ao(t.target,this.maskTextClass,this.maskTextSelector,!0)&&r?this.maskTextFn?this.maskTextFn(r,Mo(t.target)):r.replace(/[\S]/g,"*"):r,node:t.target});break}case"attributes":{let r=t.target,o=t.attributeName,n=t.target.getAttribute(o);if(o==="value"){let c=wr(r);n=Et({element:r,maskInputOptions:this.maskInputOptions,tagName:r.tagName,type:c,value:n,maskInputFn:this.maskInputFn})}let s=te(t.target,this.blockClass,this.blockSelector,!1);if(s&&o==="style"){let c=t.target,{width:i,height:u}=c.getBoundingClientRect(),d=this.attributeMap.get(t.target);d||(d={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(d),this.attributeMap.set(t.target,d)),d.attributes.rr_width=`${i}px`,d.attributes.rr_height=`${u}px`}if(s||n===t.oldValue)return;let a=this.attributeMap.get(t.target);if(r.tagName==="IFRAME"&&o==="src"&&!this.keepIframeSrcFn(n))if(!r.contentDocument)o="rr_src";else return;if(a||(a={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(a),this.attributeMap.set(t.target,a)),o==="type"&&r.tagName==="INPUT"&&(t.oldValue||"").toLowerCase()==="password"&&r.setAttribute("data-rr-is-password","true"),!Ro(r.tagName,o))if(a.attributes[o]=_o(this.doc,Ne(r.tagName),Ne(o),n),o==="style"){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch{this.unattachedDoc=this.doc}let c=this.unattachedDoc.createElement("span");t.oldValue&&c.setAttribute("style",t.oldValue);for(let i of Array.from(r.style)){let u=r.style.getPropertyValue(i),d=r.style.getPropertyPriority(i);u!==c.style.getPropertyValue(i)||d!==c.style.getPropertyPriority(i)?d===""?a.styleDiff[i]=u:a.styleDiff[i]=[u,d]:a._unchangedStyles[i]=[u,d]}for(let i of Array.from(c.style))r.style.getPropertyValue(i)===""&&(a.styleDiff[i]=!1)}else o==="open"&&r.tagName==="DIALOG"&&(r.matches("dialog:modal")?a.attributes.rr_open_mode="modal":a.attributes.rr_open_mode="non-modal");break}case"childList":{if(te(t.target,this.blockClass,this.blockSelector,!0))return;if(t.target.tagName==="TEXTAREA"){this.genTextAreaValueMutation(t.target);return}t.addedNodes.forEach(r=>this.genAdds(r,t.target)),t.removedNodes.forEach(r=>{let o=this.mirror.getId(r),n=Xe(t.target)?this.mirror.getId(T.host(t.target)):this.mirror.getId(t.target);te(t.target,this.blockClass,this.blockSelector,!1)||ir(r,this.mirror,this.slimDOMOptions)||!ii(r,this.mirror)||(this.addedSet.has(r)?(gr(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&o===-1||ko(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[lo(o,n)]?gr(this.movedSet,r):this.removes.push({parentId:n,id:o,isShadow:Xe(t.target)&&qe(t.target)?!0:void 0})),this.mapRemoves.push(r))});break}}}),S(this,"genAdds",(t,r)=>{if(!this.processedNodeManager.inOtherBuffer(t,this)&&!(this.addedSet.has(t)||this.movedSet.has(t))){if(this.mirror.hasNode(t)){if(ir(t,this.mirror,this.slimDOMOptions))return;this.movedSet.add(t);let o=null;r&&this.mirror.hasNode(r)&&(o=this.mirror.getId(r)),o&&o!==-1&&(this.movedMap[lo(this.mirror.getId(t),o)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);te(t,this.blockClass,this.blockSelector,!1)||(T.childNodes(t).forEach(o=>this.genAdds(o)),lr(t)&&T.childNodes(T.shadowRoot(t)).forEach(o=>{this.processedNodeManager.add(o,this),this.genAdds(o,t)}))}})}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","maskAnchorHrefFn","blockImgSrcPattern","blockImgSrcFillOptions","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(r=>{this[r]=t[r]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}};function gr(e,t){e.delete(t),T.childNodes(t).forEach(r=>gr(e,r))}function ho(e,t,r){return e.length===0?!1:ui(e,t,r)}function ui(e,t,r){let o=T.parentNode(t);for(;o;){let n=r.getId(o);if(e.some(s=>s.id===n))return!0;o=T.parentNode(o)}return!1}function fo(e,t){return e.size===0?!1:Ho(e,t)}function Ho(e,t){let r=T.parentNode(t);return r?e.has(r)?!0:Ho(e,r):!1}var Qe;function li(e){Qe=e}function hi(){Qe=void 0}var x=e=>Qe?(...r)=>{try{return e(...r)}catch(o){if(Qe&&Qe(o)===!0)return;throw o}}:e,Te=[];function rt(e){try{if("composedPath"in e){let t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch{}return e&&e.target}function Yo(e,t){let r=new pr;Te.push(r),r.init(e);let o=new(To())(x(r.processMutations.bind(r)));return o.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),o}function fi({mousemoveCb:e,sampling:t,doc:r,mirror:o}){if(t.mousemove===!1)return()=>{};let n=typeof t.mousemove=="number"?t.mousemove:50,s=typeof t.mousemoveCallback=="number"?t.mousemoveCallback:500,a=[],c,i=tt(x(l=>{let g=Date.now()-c;e(a.map(f=>(f.timeOffset-=g,f)),l),a=[],c=null}),s),u=x(tt(x(l=>{let g=rt(l),{clientX:f,clientY:p}=ur(l)?l.changedTouches[0]:l;c||(c=Rt()),a.push({x:f,y:p,id:o.getId(g),timeOffset:Rt()-c}),i(typeof DragEvent<"u"&&l instanceof DragEvent?N.Drag:l instanceof MouseEvent?N.MouseMove:N.TouchMove)}),n,{trailing:!1})),d=[ee("mousemove",u,r),ee("touchmove",u,r),ee("drag",u,r)];return x(()=>{d.forEach(l=>l())})}function pi({mouseInteractionCb:e,doc:t,mirror:r,blockClass:o,blockSelector:n,sampling:s}){if(s.mouseInteraction===!1)return()=>{};let a=s.mouseInteraction===!0||s.mouseInteraction===void 0?{}:s.mouseInteraction,c=[],i=null,u=d=>l=>{let g=rt(l);if(te(g,o,n,!0))return;let f=null,p=d;if("pointerType"in l){switch(l.pointerType){case"mouse":f=Ce.Mouse;break;case"touch":f=Ce.Touch;break;case"pen":f=Ce.Pen;break}f===Ce.Touch?ie[d]===ie.MouseDown?p="TouchStart":ie[d]===ie.MouseUp&&(p="TouchEnd"):Ce.Pen}else ur(l)&&(f=Ce.Touch);f!==null?(i=f,(p.startsWith("Touch")&&f===Ce.Touch||p.startsWith("Mouse")&&f===Ce.Mouse)&&(f=null)):ie[d]===ie.Click&&(f=i,i=null);let h=ur(l)?l.changedTouches[0]:l;if(!h)return;let C=r.getId(g),{clientX:I,clientY:v}=h;x(e)({type:ie[p],id:C,x:I,y:v,...f!==null&&{pointerType:f}})};return Object.keys(ie).filter(d=>Number.isNaN(Number(d))&&!d.endsWith("_Departed")&&a[d]!==!1).forEach(d=>{let l=Ne(d),g=u(d);if(window.PointerEvent)switch(ie[d]){case ie.MouseDown:case ie.MouseUp:l=l.replace("mouse","pointer");break;case ie.TouchStart:case ie.TouchEnd:return}c.push(ee(l,g,t))}),x(()=>{c.forEach(d=>d())})}function Vo({scrollCb:e,doc:t,mirror:r,blockClass:o,blockSelector:n,sampling:s}){let a=x(tt(x(c=>{let i=rt(c);if(!i||te(i,o,n,!0))return;let u=r.getId(i);if(i===t&&t.defaultView){let d=No(t.defaultView);e({id:u,x:d.left,y:d.top})}else e({id:u,x:i.scrollLeft,y:i.scrollTop})}),s.scroll||100));return ee("scroll",a,t)}function gi({viewportResizeCb:e},{win:t}){let r=-1,o=-1,n=x(tt(x(()=>{let s=Oo(),a=xo();(r!==s||o!==a)&&(e({width:Number(a),height:Number(s)}),r=s,o=a)}),200));return ee("resize",n,t)}var mi=["INPUT","TEXTAREA","SELECT"],po=new WeakMap;function yi({inputCb:e,doc:t,mirror:r,blockClass:o,blockSelector:n,ignoreClass:s,ignoreSelector:a,maskInputOptions:c,maskInputFn:i,sampling:u,userTriggeredOnInput:d}){function l(v){let y=rt(v),_=v.isTrusted,A=y&&y.tagName;if(y&&A==="OPTION"&&(y=T.parentElement(y)),!y||!A||mi.indexOf(A)<0||te(y,o,n,!0)||y.classList.contains(s)||a&&y.matches(a))return;let m=y.value,E=!1,w=wr(y)||"";w==="radio"||w==="checkbox"?E=y.checked:(c[A.toLowerCase()]||c[w])&&(m=Et({element:y,maskInputOptions:c,tagName:A,type:w,value:m,maskInputFn:i})),g(y,d?{text:m,isChecked:E,userTriggered:_}:{text:m,isChecked:E});let D=y.name;w==="radio"&&D&&E&&t.querySelectorAll(`input[type="radio"][name="${Si(D)}"]`).forEach(L=>{if(L!==y){let oe=L.value;g(L,d?{text:oe,isChecked:!E,userTriggered:!1}:{text:oe,isChecked:!E})}})}function g(v,y){let _=po.get(v);if(!_||_.text!==y.text||_.isChecked!==y.isChecked){po.set(v,y);let A=r.getId(v);x(e)({...y,id:A})}}let p=(u.input==="last"?["change"]:["input","change"]).map(v=>ee(v,x(l),t)),h=t.defaultView;if(!h)return()=>{p.forEach(v=>v())};let C=h.Object.getOwnPropertyDescriptor(h.HTMLInputElement.prototype,"value"),I=[[h.HTMLInputElement.prototype,"value"],[h.HTMLInputElement.prototype,"checked"],[h.HTMLSelectElement.prototype,"value"],[h.HTMLTextAreaElement.prototype,"value"],[h.HTMLSelectElement.prototype,"selectedIndex"],[h.HTMLOptionElement.prototype,"selected"]];return C&&C.set&&p.push(...I.map(v=>Nt(v[0],v[1],{set(){x(l)({target:this,isTrusted:!1})}},!1,h))),x(()=>{p.forEach(v=>v())})}function At(e){let t=[];function r(o,n){if(St("CSSGroupingRule")&&o.parentRule instanceof CSSGroupingRule||St("CSSMediaRule")&&o.parentRule instanceof CSSMediaRule||St("CSSSupportsRule")&&o.parentRule instanceof CSSSupportsRule||St("CSSConditionRule")&&o.parentRule instanceof CSSConditionRule){let a=Array.from(o.parentRule.cssRules).indexOf(o);n.unshift(a)}else if(o.parentStyleSheet){let a=Array.from(o.parentStyleSheet.cssRules).indexOf(o);n.unshift(a)}return n}return r(e,t)}function Si(e){return e.replace(/["\\]/g,"\\$&")}function _e(e,t,r){let o,n;return e?(e.ownerNode?o=t.getId(e.ownerNode):n=r.getId(e),{styleId:n,id:o}):{}}function vi({styleSheetRuleCb:e,mirror:t,stylesheetManager:r},{win:o}){if(!o.CSSStyleSheet||!o.CSSStyleSheet.prototype)return()=>{};let n=o.CSSStyleSheet.prototype.insertRule;o.CSSStyleSheet.prototype.insertRule=new Proxy(n,{apply:x((d,l,g)=>{let[f,p]=g,{id:h,styleId:C}=_e(l,t,r.styleMirror);return(h&&h!==-1||C&&C!==-1)&&e({id:h,styleId:C,adds:[{rule:f,index:p}]}),d.apply(l,g)})}),o.CSSStyleSheet.prototype.addRule=function(d,l,g=this.cssRules.length){let f=`${d} { ${l} }`;return o.CSSStyleSheet.prototype.insertRule.apply(this,[f,g])};let s=o.CSSStyleSheet.prototype.deleteRule;o.CSSStyleSheet.prototype.deleteRule=new Proxy(s,{apply:x((d,l,g)=>{let[f]=g,{id:p,styleId:h}=_e(l,t,r.styleMirror);return(p&&p!==-1||h&&h!==-1)&&e({id:p,styleId:h,removes:[{index:f}]}),d.apply(l,g)})}),o.CSSStyleSheet.prototype.removeRule=function(d){return o.CSSStyleSheet.prototype.deleteRule.apply(this,[d])};let a;o.CSSStyleSheet.prototype.replace&&(a=o.CSSStyleSheet.prototype.replace,o.CSSStyleSheet.prototype.replace=new Proxy(a,{apply:x((d,l,g)=>{let[f]=g,{id:p,styleId:h}=_e(l,t,r.styleMirror);return(p&&p!==-1||h&&h!==-1)&&e({id:p,styleId:h,replace:f}),d.apply(l,g)})}));let c;o.CSSStyleSheet.prototype.replaceSync&&(c=o.CSSStyleSheet.prototype.replaceSync,o.CSSStyleSheet.prototype.replaceSync=new Proxy(c,{apply:x((d,l,g)=>{let[f]=g,{id:p,styleId:h}=_e(l,t,r.styleMirror);return(p&&p!==-1||h&&h!==-1)&&e({id:p,styleId:h,replaceSync:f}),d.apply(l,g)})}));let i={};vt("CSSGroupingRule")?i.CSSGroupingRule=o.CSSGroupingRule:(vt("CSSMediaRule")&&(i.CSSMediaRule=o.CSSMediaRule),vt("CSSConditionRule")&&(i.CSSConditionRule=o.CSSConditionRule),vt("CSSSupportsRule")&&(i.CSSSupportsRule=o.CSSSupportsRule));let u={};return Object.entries(i).forEach(([d,l])=>{u[d]={insertRule:l.prototype.insertRule,deleteRule:l.prototype.deleteRule},l.prototype.insertRule=new Proxy(u[d].insertRule,{apply:x((g,f,p)=>{let[h,C]=p,{id:I,styleId:v}=_e(f.parentStyleSheet,t,r.styleMirror);return(I&&I!==-1||v&&v!==-1)&&e({id:I,styleId:v,adds:[{rule:h,index:[...At(f),C||0]}]}),g.apply(f,p)})}),l.prototype.deleteRule=new Proxy(u[d].deleteRule,{apply:x((g,f,p)=>{let[h]=p,{id:C,styleId:I}=_e(f.parentStyleSheet,t,r.styleMirror);return(C&&C!==-1||I&&I!==-1)&&e({id:C,styleId:I,removes:[{index:[...At(f),h]}]}),g.apply(f,p)})})}),x(()=>{o.CSSStyleSheet.prototype.insertRule=n,o.CSSStyleSheet.prototype.deleteRule=s,a&&(o.CSSStyleSheet.prototype.replace=a),c&&(o.CSSStyleSheet.prototype.replaceSync=c),Object.entries(i).forEach(([d,l])=>{l.prototype.insertRule=u[d].insertRule,l.prototype.deleteRule=u[d].deleteRule})})}function Wo({mirror:e,stylesheetManager:t},r){var o,n,s;let a=null;r.nodeName==="#document"?a=e.getId(r):a=e.getId(T.host(r));let c=r.nodeName==="#document"?(o=r.defaultView)==null?void 0:o.Document:(s=(n=r.ownerDocument)==null?void 0:n.defaultView)==null?void 0:s.ShadowRoot,i=c?.prototype?Object.getOwnPropertyDescriptor(c?.prototype,"adoptedStyleSheets"):void 0;return a===null||a===-1||!c||!i?()=>{}:(Object.defineProperty(r,"adoptedStyleSheets",{configurable:i.configurable,enumerable:i.enumerable,get(){var u;return(u=i.get)==null?void 0:u.call(this)},set(u){var d;let l=(d=i.set)==null?void 0:d.call(this,u);if(a!==null&&a!==-1)try{t.adoptStyleSheets(u,a)}catch{}return l}}),x(()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:i.configurable,enumerable:i.enumerable,get:i.get,set:i.set})}))}function bi({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:r,stylesheetManager:o},{win:n}){let s=n.CSSStyleDeclaration.prototype.setProperty;n.CSSStyleDeclaration.prototype.setProperty=new Proxy(s,{apply:x((c,i,u)=>{var d;let[l,g,f]=u;if(r.has(l))return s.apply(i,[l,g,f]);let{id:p,styleId:h}=_e((d=i.parentRule)==null?void 0:d.parentStyleSheet,t,o.styleMirror);return(p&&p!==-1||h&&h!==-1)&&e({id:p,styleId:h,set:{property:l,value:g,priority:f},index:At(i.parentRule)}),c.apply(i,u)})});let a=n.CSSStyleDeclaration.prototype.removeProperty;return n.CSSStyleDeclaration.prototype.removeProperty=new Proxy(a,{apply:x((c,i,u)=>{var d;let[l]=u;if(r.has(l))return a.apply(i,[l]);let{id:g,styleId:f}=_e((d=i.parentRule)==null?void 0:d.parentStyleSheet,t,o.styleMirror);return(g&&g!==-1||f&&f!==-1)&&e({id:g,styleId:f,remove:{property:l},index:At(i.parentRule)}),c.apply(i,u)})}),x(()=>{n.CSSStyleDeclaration.prototype.setProperty=s,n.CSSStyleDeclaration.prototype.removeProperty=a})}function Ci({mediaInteractionCb:e,blockClass:t,blockSelector:r,mirror:o,sampling:n,doc:s}){let a=x(i=>tt(x(u=>{let d=rt(u);if(!d||te(d,t,r,!0))return;let{currentTime:l,volume:g,muted:f,playbackRate:p,loop:h}=d;e({type:i,id:o.getId(d),currentTime:l,volume:g,muted:f,playbackRate:p,loop:h})}),n.media||500)),c=[ee("play",a(He.Play),s),ee("pause",a(He.Pause),s),ee("seeked",a(He.Seeked),s),ee("volumechange",a(He.VolumeChange),s),ee("ratechange",a(He.RateChange),s)];return x(()=>{c.forEach(i=>i())})}function wi({fontCb:e,doc:t}){let r=t.defaultView;if(!r)return()=>{};let o=[],n=new WeakMap,s=r.FontFace;r.FontFace=function(i,u,d){let l=new s(i,u,d);return n.set(l,{family:i,buffer:typeof u!="string",descriptors:d,fontSource:typeof u=="string"?u:JSON.stringify(Array.from(new Uint8Array(u)))}),l};let a=ze(t.fonts,"add",function(c){return function(i){return setTimeout(x(()=>{let u=n.get(i);u&&(e(u),n.delete(i))}),0),c.apply(this,[i])}});return o.push(()=>{r.FontFace=s}),o.push(a),x(()=>{o.forEach(c=>c())})}function Ei(e){let{doc:t,mirror:r,blockClass:o,blockSelector:n,selectionCb:s}=e,a=!0,c=x(()=>{let i=t.getSelection();if(!i||a&&i?.isCollapsed)return;a=i.isCollapsed||!1;let u=[],d=i.rangeCount||0;for(let l=0;l<d;l++){let g=i.getRangeAt(l),{startContainer:f,startOffset:p,endContainer:h,endOffset:C}=g;te(f,o,n,!0)||te(h,o,n,!0)||u.push({start:r.getId(f),startOffset:p,end:r.getId(h),endOffset:C})}s({ranges:u})});return c(),ee("selectionchange",c)}function Ii({doc:e,customElementCb:t}){let r=e.defaultView;return!r||!r.customElements?()=>{}:ze(r.customElements,"define",function(n){return function(s,a,c){try{t({define:{name:s}})}catch{console.warn(`Custom element callback failed for ${s}`)}return n.apply(this,[s,a,c])}})}function _i(e,t){let{mutationCb:r,mousemoveCb:o,mouseInteractionCb:n,scrollCb:s,viewportResizeCb:a,inputCb:c,mediaInteractionCb:i,styleSheetRuleCb:u,styleDeclarationCb:d,canvasMutationCb:l,fontCb:g,selectionCb:f,customElementCb:p}=e;e.mutationCb=(...h)=>{t.mutation&&t.mutation(...h),r(...h)},e.mousemoveCb=(...h)=>{t.mousemove&&t.mousemove(...h),o(...h)},e.mouseInteractionCb=(...h)=>{t.mouseInteraction&&t.mouseInteraction(...h),n(...h)},e.scrollCb=(...h)=>{t.scroll&&t.scroll(...h),s(...h)},e.viewportResizeCb=(...h)=>{t.viewportResize&&t.viewportResize(...h),a(...h)},e.inputCb=(...h)=>{t.input&&t.input(...h),c(...h)},e.mediaInteractionCb=(...h)=>{t.mediaInteaction&&t.mediaInteaction(...h),i(...h)},e.styleSheetRuleCb=(...h)=>{t.styleSheetRule&&t.styleSheetRule(...h),u(...h)},e.styleDeclarationCb=(...h)=>{t.styleDeclaration&&t.styleDeclaration(...h),d(...h)},e.canvasMutationCb=(...h)=>{t.canvasMutation&&t.canvasMutation(...h),l(...h)},e.fontCb=(...h)=>{t.font&&t.font(...h),g(...h)},e.selectionCb=(...h)=>{t.selection&&t.selection(...h),f(...h)},e.customElementCb=(...h)=>{t.customElement&&t.customElement(...h),p(...h)}}function Ri(e,t={}){let r=e.doc.defaultView;if(!r)return()=>{};_i(e,t);let o;e.recordDOM&&(o=Yo(e,e.doc));let n=fi(e),s=pi(e),a=Vo(e),c=gi(e,{win:r}),i=yi(e),u=Ci(e),d=()=>{},l=()=>{},g=()=>{},f=()=>{};e.recordDOM&&(d=vi(e,{win:r}),l=Wo(e,e.doc),g=bi(e,{win:r}),e.collectFonts&&(f=wi(e)));let p=Ei(e),h=Ii(e),C=[];for(let I of e.plugins)C.push(I.observer(I.callback,r,I.options));return x(()=>{Te.forEach(I=>I.reset()),o?.disconnect(),n(),s(),a(),c(),i(),u(),d(),l(),g(),f(),p(),h(),C.forEach(I=>I())})}function St(e){return typeof window[e]<"u"}function vt(e){return!!(typeof window[e]<"u"&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}var Dt=class{constructor(t){S(this,"iframeIdToRemoteIdMap",new WeakMap),S(this,"iframeRemoteIdToIdMap",new WeakMap),this.generateIdFn=t}getId(t,r,o,n){let s=o||this.getIdToRemoteIdMap(t),a=n||this.getRemoteIdToIdMap(t),c=s.get(r);return c||(c=this.generateIdFn(),s.set(r,c),a.set(c,r)),c}getIds(t,r){let o=this.getIdToRemoteIdMap(t),n=this.getRemoteIdToIdMap(t);return r.map(s=>this.getId(t,s,o,n))}getRemoteId(t,r,o){let n=o||this.getRemoteIdToIdMap(t);if(typeof r!="number")return r;let s=n.get(r);return s||-1}getRemoteIds(t,r){let o=this.getRemoteIdToIdMap(t);return r.map(n=>this.getRemoteId(t,n,o))}reset(t){if(!t){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let r=this.iframeIdToRemoteIdMap.get(t);return r||(r=new Map,this.iframeIdToRemoteIdMap.set(t,r)),r}getRemoteIdToIdMap(t){let r=this.iframeRemoteIdToIdMap.get(t);return r||(r=new Map,this.iframeRemoteIdToIdMap.set(t,r)),r}},mr=class{constructor(t){S(this,"iframes",new WeakMap),S(this,"crossOriginIframeMap",new WeakMap),S(this,"crossOriginIframeMirror",new Dt(Io)),S(this,"crossOriginIframeStyleMirror"),S(this,"crossOriginIframeRootIdMap",new WeakMap),S(this,"mirror"),S(this,"mutationCb"),S(this,"wrappedEmit"),S(this,"loadListener"),S(this,"stylesheetManager"),S(this,"recordCrossOriginIframes"),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Dt(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,r){var o,n;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:r}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&((o=t.contentWindow)==null||o.addEventListener("message",this.handleMessage.bind(this))),(n=this.loadListener)==null||n.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){let r=t;if(r.data.type!=="rrweb"||r.origin!==r.data.origin||!t.source)return;let n=this.crossOriginIframeMap.get(t.source);if(!n)return;let s=this.transformCrossOriginEvent(n,r.data.event);s&&this.wrappedEmit(s,r.data.isCheckout)}transformCrossOriginEvent(t,r){var o;switch(r.type){case M.FullSnapshot:{this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(r.data.node,t);let n=r.data.node.id;return this.crossOriginIframeRootIdMap.set(t,n),this.patchRootIdOnNode(r.data.node,n),{timestamp:r.timestamp,type:M.IncrementalSnapshot,data:{source:N.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:r.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case M.Meta:case M.Load:case M.DomContentLoaded:return!1;case M.Plugin:return r;case M.Custom:return this.replaceIds(r.data.payload,t,["id","parentId","previousId","nextId"]),r;case M.IncrementalSnapshot:switch(r.data.source){case N.Mutation:return r.data.adds.forEach(n=>{this.replaceIds(n,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(n.node,t);let s=this.crossOriginIframeRootIdMap.get(t);s&&this.patchRootIdOnNode(n.node,s)}),r.data.removes.forEach(n=>{this.replaceIds(n,t,["parentId","id"])}),r.data.attributes.forEach(n=>{this.replaceIds(n,t,["id"])}),r.data.texts.forEach(n=>{this.replaceIds(n,t,["id"])}),r;case N.Drag:case N.TouchMove:case N.MouseMove:return r.data.positions.forEach(n=>{this.replaceIds(n,t,["id"])}),r;case N.ViewportResize:return!1;case N.MediaInteraction:case N.MouseInteraction:case N.Scroll:case N.CanvasMutation:case N.Input:return this.replaceIds(r.data,t,["id"]),r;case N.StyleSheetRule:case N.StyleDeclaration:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleId"]),r;case N.Font:return r;case N.Selection:return r.data.ranges.forEach(n=>{this.replaceIds(n,t,["start","end"])}),r;case N.AdoptedStyleSheet:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleIds"]),(o=r.data.styles)==null||o.forEach(n=>{this.replaceStyleIds(n,t,["styleId"])}),r}}return!1}replace(t,r,o,n){for(let s of n)!Array.isArray(r[s])&&typeof r[s]!="number"||(Array.isArray(r[s])?r[s]=t.getIds(o,r[s]):r[s]=t.getId(o,r[s]));return r}replaceIds(t,r,o){return this.replace(this.crossOriginIframeMirror,t,r,o)}replaceStyleIds(t,r,o){return this.replace(this.crossOriginIframeStyleMirror,t,r,o)}replaceIdOnNode(t,r){this.replaceIds(t,r,["id","rootId"]),"childNodes"in t&&t.childNodes.forEach(o=>{this.replaceIdOnNode(o,r)})}patchRootIdOnNode(t,r){t.type!==K.Document&&!t.rootId&&(t.rootId=r),"childNodes"in t&&t.childNodes.forEach(o=>{this.patchRootIdOnNode(o,r)})}},yr=class{constructor(t){S(this,"shadowDoms",new WeakSet),S(this,"mutationCb"),S(this,"scrollCb"),S(this,"bypassOptions"),S(this,"mirror"),S(this,"restoreHandlers",[]),this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(t,r){if(!qe(t)||this.shadowDoms.has(t))return;this.shadowDoms.add(t);let o=Yo({...this.bypassOptions,doc:r,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},t);this.restoreHandlers.push(()=>o.disconnect()),this.restoreHandlers.push(Vo({...this.bypassOptions,scrollCb:this.scrollCb,doc:t,mirror:this.mirror})),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(T.host(t))),this.restoreHandlers.push(Wo({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t))},0)}observeAttachShadow(t){!t.contentWindow||!t.contentDocument||this.patchAttachShadow(t.contentWindow.Element,t.contentDocument)}patchAttachShadow(t,r){let o=this;this.restoreHandlers.push(ze(t.prototype,"attachShadow",function(n){return function(s){let a=n.call(this,s),c=T.shadowRoot(this);return c&&Uo(this)&&o.addShadowRoot(c,r),a}}))}reset(){this.restoreHandlers.forEach(t=>{try{t()}catch{}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}},We="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ai=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(Je=0;Je<We.length;Je++)Ai[We.charCodeAt(Je)]=Je;var Je,Di=function(e){var t=new Uint8Array(e),r,o=t.length,n="";for(r=0;r<o;r+=3)n+=We[t[r]>>2],n+=We[(t[r]&3)<<4|t[r+1]>>4],n+=We[(t[r+1]&15)<<2|t[r+2]>>6],n+=We[t[r+2]&63];return o%3===2?n=n.substring(0,n.length-1)+"=":o%3===1&&(n=n.substring(0,n.length-2)+"=="),n},go=new Map;function Ti(e,t){let r=go.get(e);return r||(r=new Map,go.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}var Bo=(e,t,r)=>{if(!e||!(Go(e,t)||typeof e=="object"))return;let o=e.constructor.name,n=Ti(r,o),s=n.indexOf(e);return s===-1&&(s=n.length,n.push(e)),s};function bt(e,t,r){if(e instanceof Array)return e.map(o=>bt(o,t,r));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer){let o=e.constructor.name,n=Di(e);return{rr_type:o,base64:n}}else{if(e instanceof DataView)return{rr_type:e.constructor.name,args:[bt(e.buffer,t,r),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){let o=e.constructor.name,{src:n}=e;return{rr_type:o,src:n}}else if(e instanceof HTMLCanvasElement){let o="HTMLImageElement",n=e.toDataURL();return{rr_type:o,src:n}}else{if(e instanceof ImageData)return{rr_type:e.constructor.name,args:[bt(e.data,t,r),e.width,e.height]};if(Go(e,t)||typeof e=="object"){let o=e.constructor.name,n=Bo(e,t,r);return{rr_type:o,index:n}}}}return e}var zo=(e,t,r)=>e.map(o=>bt(o,t,r)),Go=(e,t)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(n=>typeof t[n]=="function").find(n=>e instanceof t[n]);function Ni(e,t,r,o){let n=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(let a of s)try{if(typeof t.CanvasRenderingContext2D.prototype[a]!="function")continue;let c=ze(t.CanvasRenderingContext2D.prototype,a,function(i){return function(...u){return te(this.canvas,r,o,!0)||setTimeout(()=>{let d=zo(u,t,this);e(this.canvas,{type:Be["2D"],property:a,args:d})},0),i.apply(this,u)}});n.push(c)}catch{let c=Nt(t.CanvasRenderingContext2D.prototype,a,{set(i){e(this.canvas,{type:Be["2D"],property:a,args:[i],setter:!0})}});n.push(c)}return()=>{n.forEach(a=>a())}}function Oi(e){return e==="experimental-webgl"?"webgl":e}function mo(e,t,r,o){let n=[];try{let s=ze(e.HTMLCanvasElement.prototype,"getContext",function(a){return function(c,...i){if(!te(this,t,r,!0)){let u=Oi(c);if("__context"in this||(this.__context=u),o&&["webgl","webgl2"].includes(u))if(i[0]&&typeof i[0]=="object"){let d=i[0];d.preserveDrawingBuffer||(d.preserveDrawingBuffer=!0)}else i.splice(0,1,{preserveDrawingBuffer:!0})}return a.apply(this,[c,...i])}});n.push(s)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{n.forEach(s=>s())}}function yo(e,t,r,o,n,s){let a=[],c=Object.getOwnPropertyNames(e);for(let i of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(i))try{if(typeof e[i]!="function")continue;let u=ze(e,i,function(d){return function(...l){let g=d.apply(this,l);if(Bo(g,s,this),"tagName"in this.canvas&&!te(this.canvas,o,n,!0)){let f=zo(l,s,this),p={type:t,property:i,args:f};r(this.canvas,p)}return g}});a.push(u)}catch{let u=Nt(e,i,{set(d){r(this.canvas,{type:t,property:i,args:[d],setter:!0})}});a.push(u)}return a}function xi(e,t,r,o){let n=[];return n.push(...yo(t.WebGLRenderingContext.prototype,Be.WebGL,e,r,o,t)),typeof t.WebGL2RenderingContext<"u"&&n.push(...yo(t.WebGL2RenderingContext.prototype,Be.WebGL2,e,r,o,t)),()=>{n.forEach(s=>s())}}var Ko="KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=",Mi=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)),So=typeof window<"u"&&window.Blob&&new Blob([Mi(Ko)],{type:"text/javascript;charset=utf-8"});function ki(e){let t;try{if(t=So&&(window.URL||window.webkitURL).createObjectURL(So),!t)throw"";let r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;base64,"+Ko,{name:e?.name})}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}var Sr=class{constructor(t){S(this,"pendingCanvasMutations",new Map),S(this,"rafStamps",{latestId:0,invokeId:null}),S(this,"mirror"),S(this,"mutationCb"),S(this,"resetObservers"),S(this,"frozen",!1),S(this,"locked",!1),S(this,"processMutation",(i,u)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(i)||this.pendingCanvasMutations.set(i,[]),this.pendingCanvasMutations.get(i).push(u)});let{sampling:r="all",win:o,blockClass:n,blockSelector:s,recordCanvas:a,dataURLOptions:c}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,a&&r==="all"&&this.initCanvasMutationObserver(o,n,s),a&&typeof r=="number"&&this.initCanvasFPSObserver(r,o,n,s,{dataURLOptions:c})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,r,o,n,s){let a=mo(r,o,n,!0),c=new Map,i=new ki;i.onmessage=p=>{let{id:h}=p.data;if(c.set(h,!1),!("base64"in p.data))return;let{base64:C,type:I,width:v,height:y}=p.data;this.mutationCb({id:h,type:Be["2D"],commands:[{property:"clearRect",args:[0,0,v,y]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:C}],type:I}]},0,0]}]})};let u=1e3/t,d=0,l,g=()=>{let p=[];return r.document.querySelectorAll("canvas").forEach(h=>{te(h,o,n,!0)||p.push(h)}),p},f=p=>{if(d&&p-d<u){l=requestAnimationFrame(f);return}d=p,g().forEach(async h=>{var C;let I=this.mirror.getId(h);if(c.get(I)||h.width===0||h.height===0)return;if(c.set(I,!0),["webgl","webgl2"].includes(h.__context)){let y=h.getContext(h.__context);((C=y?.getContextAttributes())==null?void 0:C.preserveDrawingBuffer)===!1&&y.clear(y.COLOR_BUFFER_BIT)}let v=await createImageBitmap(h);i.postMessage({id:I,bitmap:v,width:h.width,height:h.height,dataURLOptions:s.dataURLOptions},[v])}),l=requestAnimationFrame(f)};l=requestAnimationFrame(f),this.resetObservers=()=>{a(),cancelAnimationFrame(l)}}initCanvasMutationObserver(t,r,o){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();let n=mo(t,r,o,!1),s=Ni(this.processMutation.bind(this),t,r,o),a=xi(this.processMutation.bind(this),t,r,o);this.resetObservers=()=>{n(),s(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){let t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{let o=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,o)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;let o=this.pendingCanvasMutations.get(t);if(!o||r===-1)return;let n=o.map(a=>{let{type:c,...i}=a;return i}),{type:s}=o[0];this.mutationCb({id:r,type:s,commands:n}),this.pendingCanvasMutations.delete(t)}},vr=class{constructor(t){S(this,"trackedLinkElements",new WeakSet),S(this,"mutationCb"),S(this,"adoptedStyleSheetCb"),S(this,"styleMirror",new hr),this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;let o={id:r,styleIds:[]},n=[];for(let s of t){let a;this.styleMirror.has(s)?a=this.styleMirror.getId(s):(a=this.styleMirror.add(s),n.push({styleId:a,rules:Array.from(s.rules||CSSRule,(c,i)=>({rule:wo(c,s.href),index:i}))})),o.styleIds.push(a)}n.length>0&&(o.styles=n),this.adoptedStyleSheetCb(o)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}},br=class{constructor(){S(this,"nodeMap",new WeakMap),S(this,"active",!1)}inOtherBuffer(t,r){let o=this.nodeMap.get(t);return o&&Array.from(o).some(n=>n!==r)}add(t,r){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(r))}destroy(){}},z,Ct,ar,Tt=!1;try{if(Array.from([1],e=>e*2)[0]!==2){let e=document.createElement("iframe");document.body.appendChild(e),Array.from=((Qr=e.contentWindow)==null?void 0:Qr.Array.from)||Array.from,document.body.removeChild(e)}}catch(e){console.debug("Unable to override Array.from",e)}var he=Is();function me(e={}){let{emit:t,checkoutEveryNms:r,checkoutEveryNth:o,blockClass:n="rr-block",blockSelector:s=null,ignoreClass:a="rr-ignore",ignoreSelector:c=null,maskTextClass:i="rr-mask",maskTextSelector:u=null,inlineStylesheet:d=!0,maskAllInputs:l,maskInputOptions:g,slimDOMOptions:f,maskInputFn:p,maskTextFn:h,maskAnchorHrefFn:C,blockImgSrcPattern:I=null,blockImgSrcFillOptions:v={backgroundColor:"#F6F7F9",strokeColor:"#E9EBEF",strokeWidth:"1px"},hooks:y,packFn:_,sampling:A={},dataURLOptions:m={},mousemoveWait:E,recordDOM:w=!0,recordCanvas:D=!1,recordCrossOriginIframes:L=!1,recordAfter:oe=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:H=!1,collectFonts:ne=!1,inlineImages:G=!1,plugins:V,keepIframeSrcFn:R=()=>!1,ignoreCSSAttributes:Y=new Set([]),errorHandler:$}=e;li($);let P=L?window.parent===window:!0,Z=!1;if(!P)try{window.parent.document&&(Z=!1)}catch{Z=!0}if(P&&!t)throw new Error("emit function is required");if(!P&&!Z)return()=>{};E!==void 0&&A.mousemove===void 0&&(A.mousemove=E),he.reset();let j=l===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:g!==void 0?g:{password:!0},J=f===!0||f==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:f==="all",headMetaDescKeywords:f==="all",headTitleMutations:f==="all"}:f||{};ai();let Se,se=0,X=O=>{for(let le of V||[])le.eventProcessor&&(O=le.eventProcessor(O));return _&&!Z&&(O=_(O)),O};z=(O,le)=>{var W;let B=O;if(B.timestamp=Rt(),(W=Te[0])!=null&&W.isFrozen()&&B.type!==M.FullSnapshot&&!(B.type===M.IncrementalSnapshot&&B.data.source===N.Mutation)&&Te.forEach(ge=>ge.unfreeze()),P)t?.(X(B),le);else if(Z){let ge={type:"rrweb",event:X(B),origin:window.location.origin,isCheckout:le};window.parent.postMessage(ge,"*")}if(B.type===M.FullSnapshot)Se=B,se=0;else if(B.type===M.IncrementalSnapshot){if(B.data.source===N.Mutation&&B.data.isAttachIframe)return;se++;let ge=o&&se>=o,F=r&&B.timestamp-Se.timestamp>r;(ge||F)&&Ct(!0)}};let Me=O=>{z({type:M.IncrementalSnapshot,data:{source:N.Mutation,...O}})},je=O=>z({type:M.IncrementalSnapshot,data:{source:N.Scroll,...O}}),ke=O=>z({type:M.IncrementalSnapshot,data:{source:N.CanvasMutation,...O}}),Yt=O=>z({type:M.IncrementalSnapshot,data:{source:N.AdoptedStyleSheet,...O}}),fe=new vr({mutationCb:Me,adoptedStyleSheetCb:Yt}),pe=new mr({mirror:he,mutationCb:Me,stylesheetManager:fe,recordCrossOriginIframes:L,wrappedEmit:z});for(let O of V||[])O.getMirror&&O.getMirror({nodeMirror:he,crossOriginIframeMirror:pe.crossOriginIframeMirror,crossOriginIframeStyleMirror:pe.crossOriginIframeStyleMirror});let Le=new br;ar=new Sr({recordCanvas:D,mutationCb:ke,win:window,blockClass:n,blockSelector:s,mirror:he,sampling:A.canvas,dataURLOptions:m});let ut=new yr({mutationCb:Me,scrollCb:je,bypassOptions:{blockClass:n,blockSelector:s,maskTextClass:i,maskTextSelector:u,inlineStylesheet:d,maskInputOptions:j,dataURLOptions:m,maskTextFn:h,maskInputFn:p,maskAnchorHrefFn:C,blockImgSrcPattern:I,blockImgSrcFillOptions:v,recordCanvas:D,inlineImages:G,sampling:A,slimDOMOptions:J,iframeManager:pe,stylesheetManager:fe,canvasManager:ar,keepIframeSrcFn:R,processedNodeManager:Le},mirror:he});Ct=(O=!1)=>{if(!w)return;z({type:M.Meta,data:{href:window.location.href,width:xo(),height:Oo()}},O),fe.reset(),ut.init(),Te.forEach(W=>W.lock());let le=$s(document,{mirror:he,blockClass:n,blockSelector:s,maskTextClass:i,maskTextSelector:u,inlineStylesheet:d,maskAllInputs:j,maskTextFn:h,maskInputFn:p,maskAnchorHrefFn:C,blockImgSrcPattern:I,blockImgSrcFillOptions:v,slimDOM:J,dataURLOptions:m,recordCanvas:D,inlineImages:G,onSerialize:W=>{Lo(W,he)&&pe.addIframe(W),Po(W,he)&&fe.trackLinkElement(W),lr(W)&&ut.addShadowRoot(T.shadowRoot(W),document)},onIframeLoad:(W,B)=>{pe.attachIframe(W,B),ut.observeAttachShadow(W)},onStylesheetLoad:(W,B)=>{fe.attachLinkElement(W,B)},keepIframeSrcFn:R});if(!le)return console.warn("Failed to snapshot the document");z({type:M.FullSnapshot,data:{node:le,initialOffset:No(window)}},O),Te.forEach(W=>W.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&fe.adoptStyleSheets(document.adoptedStyleSheets,he.getId(document))};try{let O=[],le=B=>{var ge;return x(Ri)({mutationCb:Me,mousemoveCb:(F,Vt)=>z({type:M.IncrementalSnapshot,data:{source:Vt,positions:F}}),mouseInteractionCb:F=>z({type:M.IncrementalSnapshot,data:{source:N.MouseInteraction,...F}}),scrollCb:je,viewportResizeCb:F=>z({type:M.IncrementalSnapshot,data:{source:N.ViewportResize,...F}}),inputCb:F=>z({type:M.IncrementalSnapshot,data:{source:N.Input,...F}}),mediaInteractionCb:F=>z({type:M.IncrementalSnapshot,data:{source:N.MediaInteraction,...F}}),styleSheetRuleCb:F=>z({type:M.IncrementalSnapshot,data:{source:N.StyleSheetRule,...F}}),styleDeclarationCb:F=>z({type:M.IncrementalSnapshot,data:{source:N.StyleDeclaration,...F}}),canvasMutationCb:ke,fontCb:F=>z({type:M.IncrementalSnapshot,data:{source:N.Font,...F}}),selectionCb:F=>{z({type:M.IncrementalSnapshot,data:{source:N.Selection,...F}})},customElementCb:F=>{z({type:M.IncrementalSnapshot,data:{source:N.CustomElement,...F}})},blockClass:n,ignoreClass:a,ignoreSelector:c,maskTextClass:i,maskTextSelector:u,maskInputOptions:j,inlineStylesheet:d,sampling:A,recordDOM:w,recordCanvas:D,inlineImages:G,userTriggeredOnInput:H,collectFonts:ne,doc:B,maskInputFn:p,maskTextFn:h,maskAnchorHrefFn:C,blockImgSrcPattern:I,blockImgSrcFillOptions:v,keepIframeSrcFn:R,blockSelector:s,slimDOMOptions:J,dataURLOptions:m,mirror:he,iframeManager:pe,stylesheetManager:fe,shadowDomManager:ut,processedNodeManager:Le,canvasManager:ar,ignoreCSSAttributes:Y,plugins:((ge=V?.filter(F=>F.observer))==null?void 0:ge.map(F=>({observer:F.observer,options:F.options,callback:Vt=>z({type:M.Plugin,data:{plugin:F.name,payload:Vt}})})))||[]},y)};pe.addLoadListener(B=>{try{O.push(le(B.contentDocument))}catch(ge){console.warn(ge)}});let W=()=>{Ct(),O.push(le(document)),Tt=!0};return document.readyState==="interactive"||document.readyState==="complete"?W():(O.push(ee("DOMContentLoaded",()=>{z({type:M.DomContentLoaded,data:{}}),oe==="DOMContentLoaded"&&W()})),O.push(ee("load",()=>{z({type:M.Load,data:{}}),oe==="load"&&W()},window))),()=>{O.forEach(B=>B()),Le.destroy(),Tt=!1,hi()}}catch(O){console.warn(O)}}me.addCustomEvent=(e,t)=>{if(!Tt)throw new Error("please add custom event after start recording");z({type:M.Custom,data:{tag:e,payload:t}})};me.freezePage=()=>{Te.forEach(e=>e.freeze())};me.takeFullSnapshot=e=>{if(!Tt)throw new Error("please take full snapshot after start recording");Ct(e)};me.mirror=he;var vo;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(vo||(vo={}));function Ot(e,t){if(!t)return;let r=new URL(e),o={};for(let[n,s]of r.searchParams)t.includes(n)&&(o[n]=s);return Object.keys(o).length>0?o:void 0}var jo=require("minimatch");function _r(e){throw new Error(`This code path should be unreachable: ${e}`)}function Li(e){return(e.startsWith("http://")||e.startsWith("https://"))&&(e=e.replace(/^https?:\/\//,"")),e.endsWith("/")&&(e=e.substring(0,e.length-1)),e=e.replace(/:\d+$/,""),e}function Pi(e,t){if(!t||t==="")return!1;if(t==="*")return!0;let r=Li(t);return e===r}function ce({urlStr:e,pathConfig:t}){let r=new URL(e),o=r.pathname,n=r.hostname,s=t.rules.filter(c=>Pi(n,c.domain));if(s.length>0){let c=s.find(i=>i.path==="**");if(!c)return t.defaultAction==="allow"?r:void 0;for(let i of s){if(i.path==="**")continue;let u=Pe(o,i);if(u!==void 0)switch(i.action){case"allow":return r;case"block":return;case"replace":return r.pathname=u,r;default:_r(i.action)}}return c.action==="allow"?r:void 0}let a=t.rules.filter(c=>!c.domain);for(let c of a){let i=Pe(o,c);if(i!==void 0)switch(c.action){case"allow":return r;case"block":return;case"replace":return r.pathname=i,r;default:_r(c.action)}}return t.defaultAction==="allow"?r:void 0}function ot(e,t,r){let o=ce({urlStr:e,pathConfig:r});o||(o=new URL(e));let n=Fi(o.pathname,t.rules||[]),s=[];for(let a of o.searchParams.keys()){let c=Ui(a,n?.rules||[]);switch(c){case"accept":break;case"delete":s.push(a);break;case"anonymize":o.searchParams.set(a,"*");break;default:ae(c)}}for(let a of s)o.searchParams.delete(a);if(o.pathname.includes("%3F")){let a=o.pathname.split("/");a[a.length-1]=a[a.length-1].split("%3F")[0],o.pathname=a.join("/")}return o.hash.includes("=")&&(o.hash=""),o.toString()}function Fi(e,t){for(let r of t)if(Pe(e,{path:r.path}))return r}function Ui(e,t){for(let r of t)if((0,jo.minimatch)(e,r.param))return r.anonymizeValue?"anonymize":"accept";return"delete"}var Rr=class{constructor(t,r,o){this.org=t;this.recorder=r;this.events=[];this._estimatedByteSize=0;this.events=o,this._estimatedByteSize=this.calculateTotalSize()}get estimatedByteSize(){return this._estimatedByteSize}calculateTotalSize(){try{let t=JSON.stringify(this.events,this.getCircularReplacer());return Hi(t)}catch(t){return b(`Error calculating event size: ${t}. Falling back to approximation.`),this.events.length*500}}getCircularReplacer(){let t=new WeakSet;return(r,o)=>{if(typeof o=="object"&&o!==null){if(t.has(o))return;t.add(o)}return o}}clearEvents(){this.events=[],this._estimatedByteSize=this.calculateTotalSize()}pushEvent({eventHref:t,event:r}){if(!ce({urlStr:t,pathConfig:this.org.pathConfig})){b(`URL not accepted: ${t}`);return}if(!this.recorder.isRecording){b("Dropping event - recorder is not recording");return}this.events.push(r),this._estimatedByteSize=this.calculateTotalSize()}getEvents(){return this.events}},xt=class{constructor(t,r,o,n,s){this.org=t;this.eventStorage=r;this.getHref=o;this.eventStore=new Rr(t,n,s)}get estimatedSerializedByteSize(){return this.eventStore.estimatedByteSize}clear(){this.eventStore.clearEvents(),this.eventStorage.removeEvents()}getEvents(){return this.eventStore.getEvents()}onVisibilityChange(t){t||this.eventStorage.setEvents(this.getEvents())}append(t){let r=this.getHref();if(t.type===Q.Meta)t.data.href=ot(t.data.href,this.org.allowedQueryParams,this.org.pathConfig),this.lastHref=this.getHref();else if(this.lastHref&&r!=this.lastHref){b(`URL changed from ${this.lastHref} to ${r}, adding artificial meta event for ${this.getHref()}`),this.eventStore.pushEvent({eventHref:r,event:jr({href:ot(r,this.org.allowedQueryParams,this.org.pathConfig),delay:t.delay,timestamp:t.timestamp})});let o=Ot(r,this.org.customQueryParamsCohorts);o&&this.eventStore.pushEvent({eventHref:r,event:Ze({payload:{userCohorts:o,source:"query_params"},timestamp:t.timestamp,delay:t.delay})}),this.lastHref=this.getHref()}if(t.type===Q.IncrementalSnapshot&&t.data.source===De.MouseInteraction&&t.data.type===zt.Click){let o=me.mirror.getNode(t.data.id);if(o){let n=Yi(o),s=Kr({dom0EventHandlers:n,delay:t.delay,timestamp:t.timestamp});this.eventStore.pushEvent({eventHref:r,event:s})}}this.eventStore.pushEvent({eventHref:r,event:t})}};function Hi(e){return new Blob([e]).size}function Yi(e){let t=[];for(let r=0;r<Gt.length;r++){let n=Gt[r];typeof e[n]=="function"&&t.push(n)}return t}var ue=Uint8Array,re=Uint16Array,at=Uint32Array,xr=new ue([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]),Mr=new ue([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]),$o=new ue([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qo=function(e,t){for(var r=new re(31),o=0;o<31;++o)r[o]=t+=1<<e[o-1];for(var n=new at(r[30]),o=1;o<30;++o)for(var s=r[o];s<r[o+1];++s)n[s]=s-r[o]<<5|o;return[r,n]},Qo=qo(xr,2),Vi=Qo[0],Dr=Qo[1];Vi[28]=258,Dr[258]=28;var en=qo(Mr,0),au=en[0],Zo=en[1],Tr=new re(32768);for(k=0;k<32768;++k)we=(k&43690)>>>1|(k&21845)<<1,we=(we&52428)>>>2|(we&13107)<<2,we=(we&61680)>>>4|(we&3855)<<4,Tr[k]=((we&65280)>>>8|(we&255)<<8)>>>1;var we,k,it=function(e,t,r){for(var o=e.length,n=0,s=new re(t);n<o;++n)++s[e[n]-1];var a=new re(t);for(n=0;n<t;++n)a[n]=a[n-1]+s[n-1]<<1;var c;if(r){c=new re(1<<t);var i=15-t;for(n=0;n<o;++n)if(e[n])for(var u=n<<4|e[n],d=t-e[n],l=a[e[n]-1]++<<d,g=l|(1<<d)-1;l<=g;++l)c[Tr[l]>>>i]=u}else for(c=new re(o),n=0;n<o;++n)c[n]=Tr[a[e[n]-1]++]>>>15-e[n];return c},Oe=new ue(288);for(k=0;k<144;++k)Oe[k]=8;var k;for(k=144;k<256;++k)Oe[k]=9;var k;for(k=256;k<280;++k)Oe[k]=7;var k;for(k=280;k<288;++k)Oe[k]=8;var k,Mt=new ue(32);for(k=0;k<32;++k)Mt[k]=5;var k,Wi=it(Oe,9,0);var Bi=it(Mt,5,0);var tn=function(e){return(e/8>>0)+(e&7&&1)},rn=function(e,t,r){(r==null||r>e.length)&&(r=e.length);var o=new(e instanceof re?re:e instanceof at?at:ue)(r-t);return o.set(e.subarray(t,r)),o};var Ee=function(e,t,r){r<<=t&7;var o=t/8>>0;e[o]|=r,e[o+1]|=r>>>8},nt=function(e,t,r){r<<=t&7;var o=t/8>>0;e[o]|=r,e[o+1]|=r>>>8,e[o+2]|=r>>>16},Ar=function(e,t){for(var r=[],o=0;o<e.length;++o)e[o]&&r.push({s:o,f:e[o]});var n=r.length,s=r.slice();if(!n)return[new ue(0),0];if(n==1){var a=new ue(r[0].s+1);return a[r[0].s]=1,[a,1]}r.sort(function(A,m){return A.f-m.f}),r.push({s:-1,f:25001});var c=r[0],i=r[1],u=0,d=1,l=2;for(r[0]={s:-1,f:c.f+i.f,l:c,r:i};d!=n-1;)c=r[r[u].f<r[l].f?u++:l++],i=r[u!=d&&r[u].f<r[l].f?u++:l++],r[d++]={s:-1,f:c.f+i.f,l:c,r:i};for(var g=s[0].s,o=1;o<n;++o)s[o].s>g&&(g=s[o].s);var f=new re(g+1),p=Nr(r[d-1],f,0);if(p>t){var o=0,h=0,C=p-t,I=1<<C;for(s.sort(function(m,E){return f[E.s]-f[m.s]||m.f-E.f});o<n;++o){var v=s[o].s;if(f[v]>t)h+=I-(1<<p-f[v]),f[v]=t;else break}for(h>>>=C;h>0;){var y=s[o].s;f[y]<t?h-=1<<t-f[y]++-1:++o}for(;o>=0&&h;--o){var _=s[o].s;f[_]==t&&(--f[_],++h)}p=t}return[new ue(f),p]},Nr=function(e,t,r){return e.s==-1?Math.max(Nr(e.l,t,r+1),Nr(e.r,t,r+1)):t[e.s]=r},Jo=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new re(++t),o=0,n=e[0],s=1,a=function(i){r[o++]=i},c=1;c<=t;++c)if(e[c]==n&&c!=t)++s;else{if(!n&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(n),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(n);s=1,n=e[c]}return[r.subarray(0,o),t]},st=function(e,t){for(var r=0,o=0;o<t.length;++o)r+=e[o]*t[o];return r},Or=function(e,t,r){var o=r.length,n=tn(t+2);e[n]=o&255,e[n+1]=o>>>8,e[n+2]=e[n]^255,e[n+3]=e[n+1]^255;for(var s=0;s<o;++s)e[n+s+4]=r[s];return(n+4+o)*8},Xo=function(e,t,r,o,n,s,a,c,i,u,d){Ee(t,d++,r),++n[256];for(var l=Ar(n,15),g=l[0],f=l[1],p=Ar(s,15),h=p[0],C=p[1],I=Jo(g),v=I[0],y=I[1],_=Jo(h),A=_[0],m=_[1],E=new re(19),w=0;w<v.length;++w)E[v[w]&31]++;for(var w=0;w<A.length;++w)E[A[w]&31]++;for(var D=Ar(E,7),L=D[0],oe=D[1],H=19;H>4&&!L[$o[H-1]];--H);var ne=u+5<<3,G=st(n,Oe)+st(s,Mt)+a,V=st(n,g)+st(s,h)+a+14+3*H+st(E,L)+(2*E[16]+3*E[17]+7*E[18]);if(ne<=G&&ne<=V)return Or(t,d,e.subarray(i,i+u));var R,Y,$,P;if(Ee(t,d,1+(V<G)),d+=2,V<G){R=it(g,f,0),Y=g,$=it(h,C,0),P=h;var Z=it(L,oe,0);Ee(t,d,y-257),Ee(t,d+5,m-1),Ee(t,d+10,H-4),d+=14;for(var w=0;w<H;++w)Ee(t,d+3*w,L[$o[w]]);d+=3*H;for(var j=[v,A],J=0;J<2;++J)for(var Se=j[J],w=0;w<Se.length;++w){var se=Se[w]&31;Ee(t,d,Z[se]),d+=L[se],se>15&&(Ee(t,d,Se[w]>>>5&127),d+=Se[w]>>>12)}}else R=Wi,Y=Oe,$=Bi,P=Mt;for(var w=0;w<c;++w)if(o[w]>255){var se=o[w]>>>18&31;nt(t,d,R[se+257]),d+=Y[se+257],se>7&&(Ee(t,d,o[w]>>>23&31),d+=xr[se]);var X=o[w]&31;nt(t,d,$[X]),d+=P[X],X>3&&(nt(t,d,o[w]>>>5&8191),d+=Mr[X])}else nt(t,d,R[o[w]]),d+=Y[o[w]];return nt(t,d,R[256]),d+Y[256]},zi=new at([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Gi=function(e,t,r,o,n,s){var a=e.length,c=new ue(o+a+5*(1+Math.floor(a/7e3))+n),i=c.subarray(o,c.length-n),u=0;if(!t||a<8)for(var d=0;d<=a;d+=65535){var l=d+65535;l<a?u=Or(i,u,e.subarray(d,l)):(i[d]=s,u=Or(i,u,e.subarray(d,a)))}else{for(var g=zi[t-1],f=g>>>13,p=g&8191,h=(1<<r)-1,C=new re(32768),I=new re(h+1),v=Math.ceil(r/3),y=2*v,_=function(O){return(e[O]^e[O+1]<<v^e[O+2]<<y)&h},A=new at(25e3),m=new re(288),E=new re(32),w=0,D=0,d=0,L=0,oe=0,H=0;d<a;++d){var ne=_(d),G=d&32767,V=I[ne];if(C[G]=V,I[ne]=G,oe<=d){var R=a-d;if((w>7e3||L>24576)&&R>423){u=Xo(e,i,0,A,m,E,D,L,H,d-H,u),L=w=D=0,H=d;for(var Y=0;Y<286;++Y)m[Y]=0;for(var Y=0;Y<30;++Y)E[Y]=0}var $=2,P=0,Z=p,j=G-V&32767;if(R>2&&ne==_(d-j))for(var J=Math.min(f,R)-1,Se=Math.min(32767,d),se=Math.min(258,R);j<=Se&&--Z&&G!=V;){if(e[d+$]==e[d+$-j]){for(var X=0;X<se&&e[d+X]==e[d+X-j];++X);if(X>$){if($=X,P=j,X>J)break;for(var Me=Math.min(j,X-2),je=0,Y=0;Y<Me;++Y){var ke=d-j+Y+32768&32767,Yt=C[ke],fe=ke-Yt+32768&32767;fe>je&&(je=fe,V=ke)}}}G=V,V=C[G],j+=G-V+32768&32767}if(P){A[L++]=268435456|Dr[$]<<18|Zo[P];var pe=Dr[$]&31,Le=Zo[P]&31;D+=xr[pe]+Mr[Le],++m[257+pe],++E[Le],oe=d+$,++w}else A[L++]=e[d],++m[e[d]]}}u=Xo(e,i,s,A,m,E,D,L,H,d-H,u)}return rn(c,0,o+tn(u)+n)},Ki=function(){var e=1,t=0;return{p:function(r){for(var o=e,n=t,s=r.length,a=0;a!=s;){for(var c=Math.min(a+5552,s);a<c;++a)o+=r[a],n+=o;o%=65521,n%=65521}e=o,t=n},d:function(){return(e>>>8<<16|(t&255)<<8|t>>>8)+((e&255)<<23)*2}}},ji=function(e,t,r,o,n){return Gi(e,t.level==null?6:t.level,t.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):12+t.mem,r,o,!n)},$i=function(e,t,r){for(;r;++t)e[t]=r,r>>>=8},Zi=function(e,t){var r=t.level,o=r==0?0:r<6?1:r==9?3:2;e[0]=120,e[1]=o<<6|(o?32-2*o:1)};function on(e,t){t===void 0&&(t={});var r=Ki();r.p(e);var o=ji(e,t,2,4);return Zi(o,t),$i(o,o.length-4,r.d()),o}function kr(e,t){var r=e.length;if(!t&&typeof TextEncoder<"u")return new TextEncoder().encode(e);for(var o=new ue(e.length+(e.length>>>1)),n=0,s=function(u){o[n++]=u},a=0;a<r;++a){if(n+5>o.length){var c=new ue(n+8+(r-a<<1));c.set(o),o=c}var i=e.charCodeAt(a);i<128||t?s(i):i<2048?(s(192|i>>>6),s(128|i&63)):i>55295&&i<57344?(i=65536+(i&1047552)|e.charCodeAt(++a)&1023,s(240|i>>>18),s(128|i>>>12&63),s(128|i>>>6&63),s(128|i&63)):(s(224|i>>>12),s(128|i>>>6&63),s(128|i&63))}return rn(o,0,n)}function Lr(e,t){var r="";if(!t&&typeof TextDecoder<"u")return new TextDecoder().decode(e);for(var o=0;o<e.length;){var n=e[o++];n<128||t?r+=String.fromCharCode(n):n<224?r+=String.fromCharCode((n&31)<<6|e[o++]&63):n<240?r+=String.fromCharCode((n&15)<<12|(e[o++]&63)<<6|e[o++]&63):(n=((n&15)<<18|(e[o++]&63)<<12|(e[o++]&63)<<6|e[o++]&63)-65536,r+=String.fromCharCode(55296|n>>10,56320|n&1023))}return r}var Pr="v1";var Fr=e=>{let t={...e,v:Pr};return Lr(on(kr(JSON.stringify(t))),!0)};function nn(e){let t=new URL(e),r={};for(let[o,n]of t.searchParams)switch(o){case"utm_source":case"utm_medium":case"utm_campaign":case"utm_term":case"utm_content":r[`UTM@@${o}`]=n;break}return Object.keys(r).length>0?r:void 0}var sn=3*1024*1024,an=5e3,kt=class{constructor(t,r,o,n,s,a,c){this.window=t;this.storage=r;this.eventHolder=o;this.recorder=n;this.api=s;this.organization=a;this.windowGetters=c;this.lastSendTime=-1;this.lastAutoCohorts=void 0;this.fastpathToken=void 0;n.setOnEvent(i=>this.onEvent(i))}onEvent(t){if(t.type===Q.FullSnapshot){let s,a=gt(this.window,this.organization.cohortsBootstrapConfig),c=nn(this.windowGetters.getHref()),i=Ot(this.windowGetters.getHref(),this.organization.customQueryParamsCohorts),u=er(this.window);this.lastAutoCohorts=u,(c||a||u||i)&&(s=Ze({payload:{userCohorts:{...a||{},...u||{},...c||{},...i||{}},source:"window_getters"},delay:t.delay,timestamp:t.timestamp}));let d=s?[...this.eventHolder.getEvents(),s,t]:[...this.eventHolder.getEvents(),t];this.clearAndSaveEvents(d);return}else if(t.type===Q.IncrementalSnapshot&&t.data.source===De.Mutation){let s=er(this.window);s&&(!this.lastAutoCohorts||Object.keys(s).length!==Object.keys(this.lastAutoCohorts).length)&&(b("auto cohorts different, appending new event",s),this.eventHolder.append(Ze({payload:{userCohorts:s,source:"window_getters"},delay:t.delay,timestamp:t.timestamp}))),this.lastAutoCohorts=s}this.eventHolder.append(t);let r=this.eventHolder.estimatedSerializedByteSize,n=Date.now()-this.lastSendTime;r>sn&&n>=an&&(b(`MAX_EVENT_BYTE_SIZE and timeSinceLastSend exceeded: ${r} > ${sn} and ${n} >= ${an}`),this.clearAndSaveEvents())}async clearAndSaveEvents(t){let r=this.windowGetters.getHref();if(!ce({urlStr:r,pathConfig:this.organization.pathConfig}))return;let o=t||this.eventHolder.getEvents();if(o.length!==0){this.eventHolder.clear();try{b("saving events...");let n=await this.prepareAndSendEvents(o);switch(b("save events result",n.type),n.type){case"success":break;case"recreate-session":await this.recreateSession(n.session);break;case"no-session":case"unknown-failure":case"rate-limit-exceeded":this.storage.removeSession(),this.eventHolder.clear();break;default:ae(n)}}catch(n){throw b("error saving events",n),this.storage.removeSession(),n}}}async prepareAndSendEvents(t){this.lastSendTime=Date.now();let r=this.storage.getSession();if(!r)return{type:"no-session"};if(r.eventPostUrl&&r.eventPostToken){let s=JSON.parse(atob(r.eventPostToken.split(".")[1]));if(s&&Date.now()>s.lastEventAt-10*1e3){b("refreshing token as it is about to expire");let a=await this.refreshToken(r);if(a.type!=="success")return a;if(r=this.storage.getSession(),!r)return{type:"no-session"}}}let o=r.compressionType==="RRWEB_PACK"?t.map(s=>Fr(s)):t,n=await this.api.saveSessionEvents({sessionId:r.id,events:o,metadata:{url:ot(this.windowGetters.getHref(),this.organization.allowedQueryParams,this.organization.pathConfig)},eventPostUrl:r.eventPostUrl,eventPostToken:r.eventPostToken,fastpathToken:this.fastpathToken});if(!n)return{type:"unknown-failure"};if(n.error)switch(n.error.code){case"SessionNotFound":case"SessionAlreadySynced":return{type:"recreate-session",session:r};case"RateLimitExceeded":return{type:"rate-limit-exceeded"}}if(!n.data)return{type:"unknown-failure"};if(n.data&&"code"in n.data)switch(n.data.code){case"TOKEN_REFRESH":{b("refreshing token as it expired on the worker");let s=await this.refreshToken(r);return s.type!=="success"?s:this.prepareAndSendEvents(t)}default:ae(n.data.code)}if(this.fastpathToken=n.data.fastpathToken,n.response.status<200||n.response.status>201)throw new Error(`got status ${n.response.status}`);return{type:"success"}}async refreshToken(t){let r=await this.api.refreshEventToken({sessionId:t.id});if(!r)return{type:"unknown-failure"};if(r.error)switch(r.error.code){case"SessionNotFound":case"SessionAlreadySynced":return{type:"recreate-session",session:t};case"RateLimitExceeded":return{type:"rate-limit-exceeded"}}return r.data?(this.storage.setSession({...t,eventPostToken:r.data.token}),{type:"success"}):{type:"unknown-failure"}}async recreateSession(t){b("recreating sessions");let r,o=this.recorder.isRecording;this.recorder.setRecording(!1),this.storage.removeSession(),this.fastpathToken=void 0;let n,s;try{b("recreating session...");let c=await this.api.startSession({orgId:t.settings.orgId,language:t.settings.language||this.windowGetters.getLanguage(),domain:new URL(this.windowGetters.getHref()).hostname,userCohorts:t.settings.userCohorts||{},uid:t.settings.uid,devicePixelRatio:this.windowGetters.getDevicePixelRatio(),adoraUserId:t.adoraUserId,documentReferrer:t.documentReferrer,snippetVersion:pt});if(!c||c.error)return;if(c.response.status!==201){b("session not created, aborting");return}if(!c.data||!("session"in c.data)){b("malformed session, exiting");return}c?.data&&"eventPostUrl"in c.data&&c.data.eventPostUrl&&"eventPostToken"in c.data&&c.data.eventPostToken&&(n=c.data.eventPostUrl,s=c.data.eventPostToken),r=c.data}catch{}if(!r)return;let a={id:r.session.id,createdAt:r.session.createdAt,status:r.session.status,lastSyncedAt:r.session.lastSyncedAt,domain:r.session.domain,requestIp:r.session.requestIp,country:r.session.country,userAgent:r.session.userAgent,language:r.session.language,initialUserCohorts:r.session.initialUserCohorts,devicePixelRatio:r.session.devicePixelRatio,organization:r.organization,settings:t.settings,adoraUserId:t.adoraUserId,documentReferrer:t.documentReferrer,canvasRecordingEnabled:t.canvasRecordingEnabled,eventPostUrl:n,eventPostToken:s,limitedCanvasRecording:t.limitedCanvasRecording,compressionType:t.compressionType};this.storage.setSession(a),this.eventHolder.clear(),o&&this.recorder.setRecording(!0)}};var Pt=class{constructor(t){this._options=t;this._buckets={};this._refillBuckets=()=>{Object.keys(this._buckets).forEach(t=>{let r=this._getBucket(t)+this._refillRate;r>=this._bucketSize?delete this._buckets[t]:this._setBucket(t,r)})};this._getBucket=t=>this._buckets[String(t)];this._setBucket=(t,r)=>{this._buckets[String(t)]=r};this.consumeRateLimit=t=>{let r=this._getBucket(t)??this._bucketSize;if(r=Math.max(r-1,0),r===0)return!0;this._setBucket(t,r);let o=r===0;return o&&this._onBucketRateLimited?.(t),o};this._onBucketRateLimited=this._options._onBucketRateLimited,this._bucketSize=Lt(this._options.bucketSize,0,100),this._refillRate=Lt(this._options.refillRate,0,this._bucketSize),this._refillInterval=Lt(this._options.refillInterval,0,864e5),this._removeInterval=setInterval(()=>{this._refillBuckets()},this._refillInterval)}stop(){this._removeInterval&&(clearInterval(this._removeInterval),this._removeInterval=void 0)}};function Lt(e,t,r,o){return t>r&&(t=r),Ji(e)?e>r?r:e<t?t:e:Lt(o||r,t,r)}var Ji=e=>toString.call(e)=="[object Number]";var Ft=class{constructor(t,r={}){this._rrweb=t;this._options=r;this._loggedTracker={};this._onNodeRateLimited=t=>{if(!this._loggedTracker[t]){this._loggedTracker[t]=!0;let r=this._getNode(t);this._options.onBlockedNode?.(t,r)}};this._getNodeOrRelevantParent=t=>{let r=this._getNode(t);if(r?.nodeName!=="svg"&&r instanceof Element){let o=r.closest("svg");if(o)return[this._rrweb.mirror.getId(o),o]}return[t,r]};this._getNode=t=>this._rrweb.mirror.getNode(t);this._numberOfChanges=t=>(t.removes?.length??0)+(t.attributes?.length??0)+(t.texts?.length??0)+(t.adds?.length??0);this.throttleMutations=t=>{if(t.type!==Q.IncrementalSnapshot||t.data.source!==De.Mutation)return t;let r=t.data,o=this._numberOfChanges(r);r.attributes&&(r.attributes=r.attributes.filter(s=>{let[a]=this._getNodeOrRelevantParent(s.id);return this._rateLimiter.consumeRateLimit(a)?!1:s}));let n=this._numberOfChanges(r);if(!(n===0&&o!==n))return t};this._rateLimiter=new Pt({bucketSize:this._options.bucketSize??100,refillRate:this._options.refillRate??10,refillInterval:1e3,_onBucketRateLimited:this._onNodeRateLimited})}reset(){this._loggedTracker={}}stop(){this._rateLimiter.stop(),this.reset()}};var Ge,dn=()=>{if(Ge!==void 0)return Ge;try{return Ge=document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp")===0,b("adora script - isWebpSupported? - ",Ge),Ge}catch{return Ge=!1,!1}};var Ut=class{constructor(t,r,o,n){this.limitedCanvasRecording=t;this.canvasRecordingEnabled=r;this.org=o;this.rrwebRecorder=n;this.startable=!0;b("new recorder")}setOnEvent(t){this.onEvent=t}get args(){let t=this.org.blockedCSSClasses.length>0?`|(${this.org.blockedCSSClasses.join(")|(")})`:"",r=this.org.maskedCSSClasses&&this.org.maskedCSSClasses?.length>0?`|(${this.org.maskedCSSClasses?.join(")|(")})`:"",o=dn()?"image/webp":this.limitedCanvasRecording?"image/jpeg":"image/png";return{emit:n=>{if(!this.onEvent)throw new Error("onEvent must be assigned before starting recording");n.type===Q.FullSnapshot&&this.mutationThrottler?.reset();let s=this.mutationThrottler?this.mutationThrottler.throttleMutations(n):n;s&&this.onEvent(s)},userTriggeredOnInput:!0,blockClass:new RegExp(`(adora-block)|(rr-block|fs-exclude|ph-no-capture)${t}`),maskTextClass:new RegExp(`(adora-mask)|(rr-mask|fs-mask)${r}`),maskAllInputs:!0,maskInputFn:(n,s)=>cn(this.org,s)?n:"*".repeat(n.length),maskTextFn:(n,s)=>s&&this.org.maskByDefault&&s.closest('button,a,div[role="button"],div[role*="menuitem"],input[type="button"],input[type="submit"],input[type="reset"]')||s&&cn(this.org,s)?n:n.replace(/[\S]/g,"*"),maskTextSelector:this.org?.maskByDefault?"*":"",recordCanvas:this.canvasRecordingEnabled,sampling:this.canvasRecordingEnabled?{canvas:this.limitedCanvasRecording?1:2}:void 0,dataURLOptions:this.canvasRecordingEnabled?{type:o,quality:.6}:{}}}recordChangeCustomCohort(t){b("sending custom cohort change",t),this.rrwebRecorder.addCustomEvent(Gr,t)}recordCLS(t){this.rrwebRecorder.addCustomEvent("CLS",t)}recordFID(t){this.rrwebRecorder.addCustomEvent("FID",t)}recordLCP(t){this.rrwebRecorder.addCustomEvent("LCP",t)}recordVisibilityChange(t){this.rrwebRecorder.addCustomEvent("Adora.VisibilityChange",{visibilityState:t})}recordFocusChange(t){this.rrwebRecorder.addCustomEvent("Adora.FocusChange",{focusState:t})}get isRecording(){return this.rrwebRecorder.isRecording}setRecording(t){if(b("setRecording",`requested status: ${t}`,`current status ${this.rrwebRecorder.isRecording}`),this.rrwebRecorder.isRecording!==t){if(t){this.startRecording();return}this.stopRecording()}}startRecording(){if(this.isRecording)throw new Error("recording already in progress!");if(!this.startable){b("recorder is not startable, returning");return}this.mutationThrottler=new Ft(this.rrwebRecorder,{bucketSize:100,refillRate:10,onBlockedNode:(t,r)=>{b("mutation throttler blocked node",{id:t,node:r})}}),this.rrwebRecorder.record(this.args)}stopRecording(){this.mutationThrottler?.stop(),this.mutationThrottler=void 0,this.rrwebRecorder.stop()}stopFutureRecordings(){this.startable=!1}};function cn(e,t){if(t.classList.contains("adora-unmask"))return!0;for(let r of e.unmaskSelectors)if(Array.from(document.querySelectorAll(r)).find(o=>o===t))return!0;return!1}var Ht=class{constructor(){this._isRecording=!1}get isRecording(){return this._isRecording}get mirror(){return me.mirror}record(t){if(b("record",{stopFn:typeof this.stopFn,isRecording:this._isRecording}),this.stopFn!==void 0&&this.stop(),this._isRecording=!0,this.stopFn=me(t),!this.stopFn)throw new Error("recorder could not successfully start")}stop(){this._isRecording=!1,this.stopFn&&(this.stopFn(),this.stopFn=void 0)}addCustomEvent(t,r){if(!this._isRecording)return b("WARNING! attempting to add custom event with recording off"),!1;try{me.addCustomEvent(t,r)}catch(o){return b("trying to record an event even though",o),!1}return!0}};var un=5e3;function ln({sessionType:e}){b("initialize recording");let t=new Ie(e,new be),r=t.getSession();if(!r)return;let o=new ve(r.settings.backendUrl),n=new ft(e,new be),s=n.getEvents();n.removeEvents();let a=()=>window.location.href,c=()=>window.navigator.language,i=()=>window.devicePixelRatio,u=new Ht,d=new Ut(r.limitedCanvasRecording??!1,r.canvasRecordingEnabled??!1,r.organization,u),l=new xt(r.organization,n,a,d,s||[]),g=new kt(window,t,l,d,o,r.organization,{getHref:a,getLanguage:c,getDevicePixelRatio:i}),f=window.location.href;ce({urlStr:f,pathConfig:r.organization.pathConfig})?(b("starting recording..."),d.setRecording(!0)):b("recording did not start as current URL is blocked");let p=gt(window,r.organization.cohortsBootstrapConfig);d.isRecording&&(d.recordChangeCustomCohort({uid:r.settings.uid,userCohorts:r.settings.userCohorts?{...p,...r.settings.userCohorts}:{}}),t.setSession(r)),Ke.onCLS(_=>{d.isRecording&&d.recordCLS(_)}),Ke.onFID(_=>{d.isRecording&&d.recordFID(_)}),Ke.onLCP(_=>{d.isRecording&&d.recordLCP(_)});let h=()=>{g.clearAndSaveEvents(l.getEvents())},C=window.setInterval(h,un);window.addEventListener("blur",()=>{d.recordFocusChange("blur")}),window.addEventListener("focus",()=>{d.recordFocusChange("focus")}),document.addEventListener("visibilitychange",()=>{if(b(`detected a visibility change to ${document.visibilityState}`),d.isRecording&&d.recordVisibilityChange(document.visibilityState),document.visibilityState==="hidden"){C&&(b("clearing the saveInterval"),clearInterval(C),C=void 0),l.onVisibilityChange(!1);return}C||(b("resuming the saveInterval"),C=window.setInterval(h,un))});let I=f,v=new MutationObserver(function(){if(l&&window.location.href!==I){let _=ce({urlStr:window.location.href,pathConfig:r.organization.pathConfig});b(`url changed detected, status: ${!!_}`),d.setRecording(!!_),I=window.location.href}});return v.observe(document,{subtree:!0,childList:!0}),{recorder:d,eventSync:g,urlChangeObserverDispose:()=>{v.disconnect()}}}var hn=e=>ln(e);var xe=!1,fn="_adora_user_id",pn="_adora_rate_limited",ye,ct,Ur="stopped",gn=()=>{b("startRecording",`adoraIsRunning: ${xe}`),Ur==="started"&&(ye=hn({sessionType:"adoraSessionScript"}))},mn=1e3*60*30,Xi=async({userCohorts:e,...t})=>{let r=t;if(Ur="started",b("adora start",{adoraIsRunning:xe,uid:r.uid,userCohorts:e||{}}),typeof window.sessionStorage!="object"){b("SSR detected");return}if(e){r.userCohorts={};for(let[i,u]of Object.entries(e))u!==void 0?(b("setting user cohorts key",{key:i,value:u}),r.userCohorts[i]=u):b("found undefined user cohorts key",{key:i})}let o=new Ie("adoraSessionScript",new be),n=o.getSession();if(n){b("session detected; finding if changes should be written");let i=!1;if(r.uid&&n.settings.uid!==r.uid&&(b("detected uid change"),n.settings.uid=r.uid,o.setSession(n),i=!0),r.userCohorts&&Object.keys(r.userCohorts).length>0){b("detected user cohorts");let u=structuredClone(n.settings.userCohorts);(0,yn.strictDeepEqual)(u,r.userCohorts)||(b("detected user cohorts have been changed"),n.settings.userCohorts=r.userCohorts,o.setSession(n),i=!0)}i&&ye?.recorder&&ye?.recorder.isRecording&&(b("writing cohort change to recorder"),ye?.recorder.recordChangeCustomCohort({uid:n.settings.uid,userCohorts:n.settings.userCohorts?{...n.settings.userCohorts}:{}}))}if(xe===!0)return;xe=!0;let s=o.lastRateLimitedTimestamp;if(s!==void 0){if(Date.now()-s<mn){b("exiting as the session has been rate limited recently");return}o.clearLastRateLimitedTimestamp()}if(dt.default.get(pn)){b("exiting as the domain has been rate limited recently");return}if(n){b("start recording for existing session"),gn();return}let a=!1,c=async(i,u)=>{if(b("start status",{started:a}),a)return;a=!0;let d=await Jr("adoraSessionScript",u,r);if(d.type==="error"){d.code==="RateLimitExceeded"&&(b("setting expiration on local storage"),o.setLastRateLimitedTimestamp(Date.now()),i&&(b("setting expiration cookie"),dt.default.set(pn,i,{expires:new Date(Date.now()+mn),domain:i})));return}gn()};b("launching session preload");try{let i=await new ve(r.backendUrl).sessionPreload({orgId:r.orgId});b("session preload resolved");let u=window.location.href;if(i){if(i.error){b("error preloading",i.error);return}if("scheduledDowntime"in i.data){b("scheduled downtime; exiting");return}let{organization:d}=i.data;b("session preload success");let l=dt.default.get(fn),g;b("existing adora user id cookie:",l);for(let f of d.cookieDomains)(window.location.hostname.toLowerCase()===f||window.location.hostname.toLowerCase().endsWith("."+f))&&(g=f,l||(l=(0,Sn.uuidv7)(),dt.default.set(fn,l,{domain:f,expires:new Date(Date.now()+365*24*60*60*1e3)}),b("setting adoraUserId cookie on domain",l)));b("using adora user id:",l),ce({urlStr:u,pathConfig:d.pathConfig})?(b("at an unblocked URL, starting adora"),await c(g,l)):(b("at an blocked URL, waiting for unblocked URL to start adora"),ct&&ct.disconnect(),ct=new MutationObserver(function(f,p){if(u!=window.location.href){let h=window.location.href,C=ce({urlStr:h,pathConfig:d.pathConfig});if(b(`url changed detected during blocked state, status: ${!!C}`),C){b("disconnecting observer"),p.disconnect(),b("scheduling adora to start"),c(g,l);return}u=h}}),ct.observe(document,{subtree:!0,childList:!0}))}}catch(i){b("Error in adoraStart:",i)}},qi=async()=>{Ur="stopped",b("adora stop",{adoraIsRunning:xe}),ye&&(ye.recorder.setRecording(!1),ye.recorder.stopFutureRecordings(),ye.urlChangeObserverDispose(),await ye.eventSync.clearAndSaveEvents()),ct?.disconnect(),xe=!1,ye=void 0};
4
- //# sourceMappingURL=index.cjs.map