@devskin/browser-sdk 1.0.14 → 1.0.15
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/devskin.cjs.js +66 -5
- package/dist/devskin.cjs.js.map +1 -1
- package/dist/devskin.esm.js +66 -5
- package/dist/devskin.esm.js.map +1 -1
- package/dist/devskin.umd.js +66 -5
- package/dist/devskin.umd.js.map +1 -1
- package/dist/devskin.umd.min.js +3 -3
- package/dist/devskin.umd.min.js.map +1 -1
- package/dist/transport.d.ts +1 -0
- package/dist/transport.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/devskin.umd.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DevSkin=t()}(this,function(){"use strict";class e{constructor(e){this.config=e}collect(){return{type:this.getDeviceType(),vendor:this.getVendor(),model:this.getModel(),os:this.getOS(),screen:this.getScreenInfo(),memory:this.getMemory(),cores:this.getCores(),connection:this.getConnection()}}getDeviceType(){const e=navigator.userAgent;return/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(e)?"tablet":/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(e)?"mobile":e.includes("Windows")||e.includes("Macintosh")||e.includes("Linux")?"desktop":"unknown"}getVendor(){return navigator.vendor||void 0}getModel(){const e=navigator.userAgent.match(/\(([^)]+)\)/);if(e&&e[1])return e[1]}getOS(){const e=navigator.userAgent;let t="Unknown",n="";if(e.includes("Win"))t="Windows",e.includes("Windows NT 10.0")?n="10":e.includes("Windows NT 6.3")?n="8.1":e.includes("Windows NT 6.2")?n="8":e.includes("Windows NT 6.1")&&(n="7");else if(e.includes("Mac")){t="macOS";const o=e.match(/Mac OS X (\d+[._]\d+[._]\d+)?/);o&&o[1]&&(n=o[1].replace(/_/g,"."))}else if(e.includes("X11")||e.includes("Linux"))t="Linux";else if(e.includes("Android")){t="Android";const o=e.match(/Android (\d+\.?\d*)/);o&&o[1]&&(n=o[1])}else if(e.includes("iOS")||e.includes("iPhone")||e.includes("iPad")){t="iOS";const o=e.match(/OS (\d+_\d+(_\d+)?)/);o&&o[1]&&(n=o[1].replace(/_/g,"."))}return{name:t,version:n}}getScreenInfo(){return{width:window.screen.width,height:window.screen.height,orientation:this.getOrientation(),pixelRatio:window.devicePixelRatio||1}}getOrientation(){return window.screen.orientation?window.screen.orientation.type:window.innerWidth>window.innerHeight?"landscape":"portrait"}getMemory(){return navigator.deviceMemory}getCores(){return navigator.hardwareConcurrency}getConnection(){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(e)return{effectiveType:e.effectiveType,downlink:e.downlink,rtt:e.rtt,saveData:e.saveData}}}function t(e,t,n,o){return new(n||(n=Promise))(function(r,s){function i(e){try{l(o.next(e))}catch(e){s(e)}}function a(e){try{l(o.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,a)}l((o=o.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(e){this.config=e,this.geoData=null,this.config.captureLocation&&this.requestGeolocation()}collect(){return Object.assign({url:window.location.href,hostname:window.location.hostname,pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,protocol:window.location.protocol,port:window.location.port,referrer:document.referrer},this.geoData)}requestGeolocation(){return t(this,void 0,void 0,function*(){try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;this.geoData={timezone:e},"geolocation"in navigator&&navigator.geolocation.getCurrentPosition(e=>{this.geoData=Object.assign(Object.assign({},this.geoData),{latitude:e.coords.latitude,longitude:e.coords.longitude}),this.reverseGeocode(e.coords.latitude,e.coords.longitude)},e=>{this.config.debug&&console.log("[DevSkin] Geolocation permission denied or error:",e)},{timeout:5e3,maximumAge:6e5})}catch(e){this.config.debug&&console.error("[DevSkin] Error requesting geolocation:",e)}})}reverseGeocode(e,n){return t(this,void 0,void 0,function*(){try{const t=yield fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${e}&lon=${n}&zoom=10&addressdetails=1`,{headers:{"User-Agent":"DevSkin-SDK/1.0"}});if(t.ok){const e=yield t.json();e.address&&(this.geoData=Object.assign(Object.assign({},this.geoData),{country:e.address.country,region:e.address.state||e.address.region,city:e.address.city||e.address.town||e.address.village}))}}catch(e){this.config.debug&&console.error("[DevSkin] Error reverse geocoding:",e)}})}}class o{constructor(e){this.config=e}collect(){return{name:this.getBrowserName(),version:this.getBrowserVersion(),engine:this.getEngine(),userAgent:navigator.userAgent,language:navigator.language,languages:navigator.languages?Array.from(navigator.languages):[navigator.language],cookieEnabled:navigator.cookieEnabled,doNotTrack:this.getDoNotTrack(),viewport:{width:window.innerWidth,height:window.innerHeight},timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffset:(new Date).getTimezoneOffset()}}getBrowserName(){const e=navigator.userAgent;return e.includes("Firefox")?"Firefox":e.includes("Edg")?"Edge":e.includes("Chrome")?"Chrome":e.includes("Safari")&&!e.includes("Chrome")?"Safari":e.includes("Opera")||e.includes("OPR")?"Opera":e.includes("Trident")||e.includes("MSIE")?"Internet Explorer":"Unknown"}getBrowserVersion(){const e=navigator.userAgent;let t=null;switch(this.getBrowserName()){case"Chrome":t=e.match(/Chrome\/(\d+\.\d+)/);break;case"Firefox":t=e.match(/Firefox\/(\d+\.\d+)/);break;case"Safari":t=e.match(/Version\/(\d+\.\d+)/);break;case"Edge":t=e.match(/Edg\/(\d+\.\d+)/);break;case"Opera":if(t=e.match(/(Opera|OPR)\/(\d+\.\d+)/),t)return t[2];break;case"Internet Explorer":if(t=e.match(/(MSIE |rv:)(\d+\.\d+)/),t)return t[2]}return t&&t[1]?t[1]:""}getEngine(){const e=navigator.userAgent;return e.includes("Gecko")&&e.includes("Firefox")?"Gecko":e.includes("AppleWebKit")?e.includes("Chrome")||e.includes("Edg")?"Blink":"WebKit":e.includes("Trident")?"Trident":"Unknown"}getDoNotTrack(){const e=navigator.doNotTrack||window.doNotTrack||navigator.msDoNotTrack;return"1"===e||"yes"===e||"0"!==e&&"no"!==e&&null}}var r,s,i,a,l,c=-1,d=function(e){addEventListener("pageshow",function(t){t.persisted&&(c=t.timeStamp,e(t))},!0)},u=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},h=function(){var e=u();return e&&e.activationStart||0},p=function(e,t){var n=u(),o="navigate";return c>=0?o="back-forward-cache":n&&(document.prerendering||h()>0?o="prerender":document.wasDiscarded?o="restore":n.type&&(o=n.type.replace(/_/g,"-"))),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:o}},m=function(e,t,n){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var o=new PerformanceObserver(function(e){Promise.resolve().then(function(){t(e.getEntries())})});return o.observe(Object.assign({type:e,buffered:!0},n||{})),o}}catch(e){}},f=function(e,t,n,o){var r,s;return function(i){t.value>=0&&(i||o)&&((s=t.value-(r||0))||void 0===r)&&(r=t.value,t.delta=s,t.rating=function(e,t){return e>t[1]?"poor":e>t[0]?"needs-improvement":"good"}(t.value,n),e(t))}},g=function(e){requestAnimationFrame(function(){return requestAnimationFrame(function(){return e()})})},v=function(e){var t=function(t){"pagehide"!==t.type&&"hidden"!==document.visibilityState||e(t)};addEventListener("visibilitychange",t,!0),addEventListener("pagehide",t,!0)},y=function(e){var t=!1;return function(n){t||(e(n),t=!0)}},S=-1,b=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},w=function(e){"hidden"===document.visibilityState&&S>-1&&(S="visibilitychange"===e.type?e.timeStamp:0,I())},k=function(){addEventListener("visibilitychange",w,!0),addEventListener("prerenderingchange",w,!0)},I=function(){removeEventListener("visibilitychange",w,!0),removeEventListener("prerenderingchange",w,!0)},C=function(){return S<0&&(S=b(),k(),d(function(){setTimeout(function(){S=b(),k()},0)})),{get firstHiddenTime(){return S}}},M=function(e){document.prerendering?addEventListener("prerenderingchange",function(){return e()},!0):e()},E=[1800,3e3],T=function(e,t){t=t||{},M(function(){var n,o=C(),r=p("FCP"),s=m("paint",function(e){e.forEach(function(e){"first-contentful-paint"===e.name&&(s.disconnect(),e.startTime<o.firstHiddenTime&&(r.value=Math.max(e.startTime-h(),0),r.entries.push(e),n(!0)))})});s&&(n=f(e,r,E,t.reportAllChanges),d(function(o){r=p("FCP"),n=f(e,r,E,t.reportAllChanges),g(function(){r.value=performance.now()-o.timeStamp,n(!0)})}))})},O=[.1,.25],D={passive:!0,capture:!0},R=new Date,x=function(e,t){r||(r=t,s=e,i=new Date,F(removeEventListener),L())},L=function(){if(s>=0&&s<i-R){var e={entryType:"first-input",name:r.type,target:r.target,cancelable:r.cancelable,startTime:r.timeStamp,processingStart:r.timeStamp+s};a.forEach(function(t){t(e)}),a=[]}},N=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){x(e,t),r()},o=function(){r()},r=function(){removeEventListener("pointerup",n,D),removeEventListener("pointercancel",o,D)};addEventListener("pointerup",n,D),addEventListener("pointercancel",o,D)}(t,e):x(t,e)}},F=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach(function(t){return e(t,N,D)})},A=[100,300],_=[2500,4e3],W={},P=[800,1800],j=function e(t){document.prerendering?M(function(){return e(t)}):"complete"!==document.readyState?addEventListener("load",function(){return e(t)},!0):setTimeout(t,0)},U=function(e,t){t=t||{};var n=p("TTFB"),o=f(e,n,P,t.reportAllChanges);j(function(){var r=u();if(r){var s=r.responseStart;if(s<=0||s>performance.now())return;n.value=Math.max(s-h(),0),n.entries=[r],o(!0),d(function(){n=p("TTFB",0),(o=f(e,n,P,t.reportAllChanges))(!0)})}})};class B{constructor(e,t){this.config=e,this.transport=t,this.metrics={}}start(){!function(e,t){t=t||{},T(y(function(){var n,o=p("CLS",0),r=0,s=[],i=function(e){e.forEach(function(e){if(!e.hadRecentInput){var t=s[0],n=s[s.length-1];r&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(r+=e.value,s.push(e)):(r=e.value,s=[e])}}),r>o.value&&(o.value=r,o.entries=s,n())},a=m("layout-shift",i);a&&(n=f(e,o,O,t.reportAllChanges),v(function(){i(a.takeRecords()),n(!0)}),d(function(){r=0,o=p("CLS",0),n=f(e,o,O,t.reportAllChanges),g(function(){return n()})}),setTimeout(n,0))}))}(e=>this.handleMetric(e)),T(e=>this.handleMetric(e)),function(e,t){t=t||{},M(function(){var n,o=C(),i=p("FID"),l=function(e){e.startTime<o.firstHiddenTime&&(i.value=e.processingStart-e.startTime,i.entries.push(e),n(!0))},c=function(e){e.forEach(l)},u=m("first-input",c);n=f(e,i,A,t.reportAllChanges),u&&v(y(function(){c(u.takeRecords()),u.disconnect()})),u&&d(function(){var o;i=p("FID"),n=f(e,i,A,t.reportAllChanges),a=[],s=-1,r=null,F(addEventListener),o=l,a.push(o),L()})})}(e=>this.handleMetric(e)),function(e,t){t=t||{},M(function(){var n,o=C(),r=p("LCP"),s=function(e){var t=e[e.length-1];t&&t.startTime<o.firstHiddenTime&&(r.value=Math.max(t.startTime-h(),0),r.entries=[t],n())},i=m("largest-contentful-paint",s);if(i){n=f(e,r,_,t.reportAllChanges);var a=y(function(){W[r.id]||(s(i.takeRecords()),i.disconnect(),W[r.id]=!0,n(!0))});["keydown","click"].forEach(function(e){addEventListener(e,function(){return setTimeout(a,0)},!0)}),v(a),d(function(o){r=p("LCP"),n=f(e,r,_,t.reportAllChanges),g(function(){r.value=performance.now()-o.timeStamp,W[r.id]=!0,n(!0)})})}})}(e=>this.handleMetric(e)),U(e=>this.handleMetric(e)),this.collectNavigationTimings(),this.collectResourceTimings(),this.config.longTaskThreshold&&this.observeLongTasks()}handleMetric(e){const t=e.name.toLowerCase();this.metrics[t]=e.value,this.config.debug&&console.log(`[DevSkin] Web Vital ${e.name}:`,e.value),this.transport.sendPerformanceMetric({name:e.name,value:e.value,rating:e.rating,delta:e.delta,timestamp:(new Date).toISOString()})}collectNavigationTimings(){window.performance&&window.performance.timing&&window.addEventListener("load",()=>{setTimeout(()=>{const e=window.performance.timing,t=window.performance.navigation,n=e.domContentLoadedEventEnd-e.navigationStart,o=e.loadEventEnd-e.navigationStart;this.metrics.domLoad=n,this.metrics.windowLoad=o,this.config.debug&&console.log("[DevSkin] Navigation Timings:",{domLoad:n,windowLoad:o,navigationType:t.type}),this.transport.sendPerformanceMetric({name:"Navigation",value:o,details:{domLoad:n,windowLoad:o,navigationType:t.type,redirectCount:t.redirectCount,dns:e.domainLookupEnd-e.domainLookupStart,tcp:e.connectEnd-e.connectStart,request:e.responseStart-e.requestStart,response:e.responseEnd-e.responseStart,dom:e.domComplete-e.domLoading},timestamp:(new Date).toISOString()})},0)})}collectResourceTimings(){window.performance&&window.performance.getEntriesByType&&window.addEventListener("load",()=>{setTimeout(()=>{const e=window.performance.getEntriesByType("resource"),t={total:e.length,byType:{},slowest:[]};e.forEach(e=>{const n=e.initiatorType||"other";t.byType[n]=(t.byType[n]||0)+1}),t.slowest=e.map(e=>({name:e.name,duration:e.duration,type:e.initiatorType})).sort((e,t)=>t.duration-e.duration).slice(0,10),this.config.debug&&console.log("[DevSkin] Resource Timings:",t),this.transport.sendPerformanceMetric({name:"Resources",value:e.length,details:t,timestamp:(new Date).toISOString()})},1e3)})}observeLongTasks(){if("PerformanceObserver"in window)try{new PerformanceObserver(e=>{for(const t of e.getEntries())t.duration>=(this.config.longTaskThreshold||50)&&(this.config.debug&&console.log("[DevSkin] Long Task detected:",t),this.transport.sendPerformanceMetric({name:"LongTask",value:t.duration,details:{name:t.name,entryType:t.entryType,startTime:t.startTime},timestamp:(new Date).toISOString()}))}).observe({entryTypes:["longtask"]})}catch(e){this.config.debug&&console.error("[DevSkin] Error observing long tasks:",e)}}getMetrics(){return Object.assign({},this.metrics)}}class z{constructor(e,t){var n;this.config=e,this.transport=t,this.breadcrumbs=[],this.maxBreadcrumbs=(null===(n=e.errorOptions)||void 0===n?void 0:n.maxBreadcrumbs)||30}start(){window.addEventListener("error",e=>{this.handleError(e.error||e.message,{filename:e.filename,lineno:e.lineno,colno:e.colno})}),window.addEventListener("unhandledrejection",e=>{this.handleError(e.reason,{type:"unhandledrejection"})}),this.setupAutomaticBreadcrumbs()}captureError(e,t){this.handleError(e,t)}addBreadcrumb(e){const t={category:e.category,message:e.message,level:e.level||"info",timestamp:(new Date).toISOString(),data:e.data};this.breadcrumbs.push(t),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift(),this.config.debug&&console.log("[DevSkin] Breadcrumb added:",t)}handleError(e,t){var n;if(this.shouldIgnoreError(e))return;let o;if(e instanceof Error){if(o={message:e.message,stack:e.stack,type:e.name||"Error",timestamp:(new Date).toISOString(),session_id:"",url:window.location.href,breadcrumbs:[...this.breadcrumbs],context:Object.assign(Object.assign({},t),{userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight}})},e.stack){const t=e.stack.match(/:(\d+):(\d+)/);t&&(o.line=parseInt(t[1],10),o.column=parseInt(t[2],10))}}else o={message:String(e),type:"Error",timestamp:(new Date).toISOString(),session_id:"",url:window.location.href,breadcrumbs:[...this.breadcrumbs],context:t};(null===(n=this.config.errorOptions)||void 0===n?void 0:n.includeLocalVariables)&&t&&(o.context=Object.assign(Object.assign({},o.context),{localVariables:t})),this.config.debug&&console.log("[DevSkin] Error captured:",o),this.addBreadcrumb({category:"error",message:o.message,level:"error",data:{type:o.type,stack:o.stack}}),this.transport.sendError(o)}shouldIgnoreError(e){var t,n;const o=(null===(t=this.config.errorOptions)||void 0===t?void 0:t.ignoreErrors)||[],r=e instanceof Error?e.message:String(e);for(const e of o)if(e instanceof RegExp){if(e.test(r))return!0}else if("string"==typeof e&&r.includes(e))return!0;const s=(null===(n=this.config.errorOptions)||void 0===n?void 0:n.denyUrls)||[],i=e instanceof Error?e.stack:"";for(const e of s)if(e.test(i||""))return!0;return!1}setupAutomaticBreadcrumbs(){this.wrapConsole(),document.addEventListener("click",e=>{var t;const n=e.target;this.addBreadcrumb({category:"ui.click",message:`Clicked on ${n.tagName}`,data:{tagName:n.tagName,id:n.id,className:n.className,innerText:null===(t=n.innerText)||void 0===t?void 0:t.substring(0,100)}})},!0);let e=window.location.href;const t=()=>{e!==window.location.href&&(this.addBreadcrumb({category:"navigation",message:`Navigated to ${window.location.pathname}`,data:{from:e,to:window.location.href}}),e=window.location.href)};window.addEventListener("popstate",t),window.addEventListener("hashchange",t);const n=history.pushState;history.pushState=function(...e){n.apply(this,e),t()};const o=history.replaceState;history.replaceState=function(...e){o.apply(this,e),t()}}wrapConsole(){["log","info","warn","error"].forEach(e=>{const t=console[e];console[e]=(...n)=>{if(t.apply(console,n),"warn"===e||"error"===e){const t=n.map(e=>String(e)).join(" ");if(t.startsWith("[DevSkin]"))return;this.addBreadcrumb({category:"console",message:t,level:"warn"===e?"warning":"error",data:{arguments:n}})}}})}getBreadcrumbs(){return[...this.breadcrumbs]}}class H{constructor(e,t){this.config=e,this.transport=t}start(){this.interceptFetch(),this.interceptXHR()}interceptFetch(){if(!window.fetch)return;const e=window.fetch;window.fetch=(...n)=>t(this,void 0,void 0,function*(){var t,o,r;const[s,i]=n,a="string"==typeof s?s:s instanceof Request?s.url:s.toString(),l=(null==i?void 0:i.method)||"GET",c=Date.now();try{const s=yield e(...n),i=s.clone(),d=Date.now()-c;if(this.shouldIgnoreUrl(a))return s;if((null===(t=this.config.networkRequestOptions)||void 0===t?void 0:t.captureFailedOnly)&&s.ok)return s;const u={url:a,method:l,status:s.status,duration:d,size:yield this.getResponseSize(i),type:"fetch",timestamp:(new Date).toISOString(),failed:!s.ok};if((null===(o=this.config.networkRequestOptions)||void 0===o?void 0:o.captureHeaders)&&(u.headers=this.headersToObject(s.headers)),(null===(r=this.config.networkRequestOptions)||void 0===r?void 0:r.captureBody)&&!s.ok)try{const e=yield i.text();u.body=e.substring(0,1e4)}catch(e){}return this.config.debug&&console.log("[DevSkin] Network request tracked:",u),this.transport.sendNetworkRequest(u),s}catch(e){const t=Date.now()-c;if(!this.shouldIgnoreUrl(a)){const e={url:a,method:l,duration:t,type:"fetch",timestamp:(new Date).toISOString(),failed:!0};this.config.debug&&console.log("[DevSkin] Network request failed:",e),this.transport.sendNetworkRequest(e)}throw e}})}interceptXHR(){const e=XMLHttpRequest.prototype.open,t=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(t,n,o,r,s){return this.__devskin={method:t,url:n.toString(),startTime:Date.now()},void 0!==r?e.call(this,t,n,null==o||o,r,null!=s?s:void 0):void 0!==o?e.call(this,t,n,o):e.call(this,t,n,!0)},XMLHttpRequest.prototype.send=function(e){const n=this,o=n.__devskin;if(!o)return t.call(this,e);const r=window.__devskinNetworkCollector,s=()=>{const e=Date.now()-o.startTime;if(!(null==r?void 0:r.shouldIgnoreUrl(o.url))){const t={url:o.url,method:o.method,duration:e,type:"xhr",timestamp:(new Date).toISOString(),failed:!0};(null==r?void 0:r.config.debug)&&console.log("[DevSkin] XHR request failed:",t),null==r||r.transport.sendNetworkRequest(t)}};return n.addEventListener("load",()=>{var e,t,s,i;const a=Date.now()-o.startTime;if(null==r?void 0:r.shouldIgnoreUrl(o.url))return;if((null===(e=null==r?void 0:r.config.networkRequestOptions)||void 0===e?void 0:e.captureFailedOnly)&&n.status>=200&&n.status<400)return;const l={url:o.url,method:o.method,status:n.status,duration:a,type:"xhr",timestamp:(new Date).toISOString(),failed:0===n.status||n.status>=400};if((null===(t=null==r?void 0:r.config.networkRequestOptions)||void 0===t?void 0:t.captureHeaders)&&(l.headers=r.parseResponseHeaders(n.getAllResponseHeaders())),(null===(s=null==r?void 0:r.config.networkRequestOptions)||void 0===s?void 0:s.captureBody)&&l.failed)try{l.body=null===(i=n.responseText)||void 0===i?void 0:i.substring(0,1e4)}catch(e){}(null==r?void 0:r.config.debug)&&console.log("[DevSkin] XHR request tracked:",l),null==r||r.transport.sendNetworkRequest(l)}),n.addEventListener("error",s),n.addEventListener("abort",s),t.call(this,e)},window.__devskinNetworkCollector=this}shouldIgnoreUrl(e){var t;if(e.includes(this.config.apiUrl||""))return!0;const n=(null===(t=this.config.networkRequestOptions)||void 0===t?void 0:t.ignoreUrls)||[];for(const t of n)if(t.test(e))return!0;return!1}getResponseSize(e){return t(this,void 0,void 0,function*(){try{return(yield e.blob()).size}catch(e){return}})}headersToObject(e){const t={};return e.forEach((e,n)=>{t[n]=e}),t}parseResponseHeaders(e){const t={};if(!e)return t;return e.trim().split(/[\r\n]+/).forEach(e=>{const n=e.split(": "),o=n.shift(),r=n.join(": ");o&&(t[o]=r)}),t}}class q{constructor(e,t){this.config=e,this.transport=t,this.clickData=[],this.scrollData=[],this.mouseMoveData=[],this.maxScrollDepth=0,this.flushInterval=null,this.mouseMoveSampling=.1}start(){var e;(null===(e=this.config.heatmapOptions)||void 0===e?void 0:e.enabled)&&(this.config.debug&&console.log("[DevSkin] Starting heatmap collection"),!1!==this.config.heatmapOptions.trackClicks&&this.trackClicks(),!1!==this.config.heatmapOptions.trackScroll&&this.trackScrollDepth(),this.config.heatmapOptions.trackMouseMovement&&(this.mouseMoveSampling=this.config.heatmapOptions.mouseMoveSampling||.1,this.trackMouseMovement()),this.flushInterval=setInterval(()=>{this.flush()},1e4),window.addEventListener("beforeunload",()=>{this.flush()}))}stop(){this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null),this.flush()}trackClicks(){document.addEventListener("click",e=>{const t=e.target,n=t.getBoundingClientRect(),o=e.clientX-n.left,r=e.clientY-n.top,s=e.clientX+window.scrollX,i=e.clientY+window.scrollY,a={x:e.clientX,y:e.clientY,relativeX:o,relativeY:r,pageX:s,pageY:i,element:this.getElementSelector(t),elementId:t.id||void 0,elementClass:t.className||void 0,pageUrl:window.location.href,timestamp:(new Date).toISOString(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight};this.clickData.push(a),this.config.debug&&console.log("[DevSkin] Click tracked:",a),this.clickData.length>=50&&this.flush()},!0)}trackScrollDepth(){const e=()=>{const e=window.innerHeight,t=document.documentElement.scrollHeight,n=window.scrollY||document.documentElement.scrollTop,o=Math.round((n+e)/t*100);if(o>this.maxScrollDepth){this.maxScrollDepth=o;const n={depth:o,maxDepth:this.maxScrollDepth,pageHeight:t,viewportHeight:e,pageUrl:window.location.href,timestamp:(new Date).toISOString()};this.scrollData.push(n),this.config.debug&&console.log("[DevSkin] Scroll depth:",o+"%")}};let t=null;window.addEventListener("scroll",()=>{t&&clearTimeout(t),t=setTimeout(e,100)}),e()}trackMouseMovement(){let e=null;window.addEventListener("mousemove",t=>{if(Math.random()>this.mouseMoveSampling)return;if(e)return;e=setTimeout(()=>{e=null},100);const n={x:t.clientX+window.scrollX,y:t.clientY+window.scrollY,pageUrl:window.location.href,timestamp:(new Date).toISOString()};this.mouseMoveData.push(n),this.mouseMoveData.length>=100&&this.flush()})}flush(){this.clickData.length>0&&(this.transport.sendHeatmapData({type:"clicks",data:this.clickData}),this.clickData=[]),this.scrollData.length>0&&(this.transport.sendHeatmapData({type:"scroll",data:this.scrollData}),this.scrollData=[]),this.mouseMoveData.length>0&&(this.transport.sendHeatmapData({type:"mousemove",data:this.mouseMoveData}),this.mouseMoveData=[])}getElementSelector(e){if(e.id)return`#${e.id}`;if(e.className){const t=e.className.split(" ").filter(e=>e);if(t.length>0)return`${e.tagName.toLowerCase()}.${t.join(".")}`}return e.tagName.toLowerCase()}}function $(e){const t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function V(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function G(e){try{const n=e.rules||e.cssRules;return n?((t=Array.from(n,X).join("")).includes(" background-clip: text;")&&!t.includes(" -webkit-background-clip: text;")&&(t=t.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),t):null}catch(e){return null}var t}function X(e){let t;if(function(e){return"styleSheet"in e}(e))try{t=G(e.styleSheet)||function(e){const{cssText:t}=e;if(t.split('"').length<3)return t;const n=["@import",`url(${JSON.stringify(e.href)})`];return""===e.layerName?n.push("layer"):e.layerName&&n.push(`layer(${e.layerName})`),e.supportsText&&n.push(`supports(${e.supportsText})`),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}(e)}catch(e){}else if(function(e){return"selectorText"in e}(e)&&e.selectorText.includes(":"))return function(e){const t=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return e.replace(t,"$1\\$2")}(e.cssText);return t||e.cssText}!function(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"}(l||(l={}));class K{constructor(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}getId(e){var t;if(!e)return-1;const n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const t=this.getId(e);this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(e=>this.removeNodeFromMap(e))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){const n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)}replace(e,t){const n=this.getNode(e);if(n){const e=this.nodeMetaMap.get(n);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}}function Y({element:e,maskInputOptions:t,tagName:n,type:o,value:r,maskInputFn:s}){let i=r||"";const a=o&&J(o);return(t[n.toLowerCase()]||a&&t[a])&&(i=s?s(i,e):"*".repeat(i.length)),i}function J(e){return e.toLowerCase()}const Z="__rrweb_original__";function Q(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?J(t):null}function ee(e,t){var n;let o;try{o=new URL(e,null!=t?t:window.location.href)}catch(e){return null}const r=o.pathname.match(/\.([0-9a-z]+)(?:$)/i);return null!==(n=null==r?void 0:r[1])&&void 0!==n?n:null}let te=1;const ne=new RegExp("[^a-z0-9-_:]");function oe(){return te++}let re,se;const ie=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,ae=/^(?:[a-z+]+:)?\/\//i,le=/^www\..*/i,ce=/^(data:)([^,]*),(.*)/i;function de(e,t){return(e||"").replace(ie,(e,n,o,r,s,i)=>{const a=o||s||i,l=n||r||"";if(!a)return e;if(ae.test(a)||le.test(a))return`url(${l}${a}${l})`;if(ce.test(a))return`url(${l}${a}${l})`;if("/"===a[0])return`url(${l}${function(e){let t="";return t=e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0],t=t.split("?")[0],t}(t)+a}${l})`;const c=t.split("/"),d=a.split("/");c.pop();for(const e of d)"."!==e&&(".."===e?c.pop():c.push(e));return`url(${l}${c.join("/")}${l})`})}const ue=/^[^ \t\n\r\u000c]+/,he=/^[, \t\n\r\u000c]+/;function pe(e,t){if(!t||""===t.trim())return t;const n=e.createElement("a");return n.href=t,n.href}function me(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function fe(){const e=document.createElement("a");return e.href="",e.href}function ge(e,t,n,o){return o?"src"===n||"href"===n&&("use"!==t||"#"!==o[0])||"xlink:href"===n&&"#"!==o[0]?pe(e,o):"background"!==n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n?function(e,t){if(""===t.trim())return t;let n=0;function o(e){let o;const r=e.exec(t.substring(n));return r?(o=r[0],n+=o.length,o):""}const r=[];for(;o(he),!(n>=t.length);){let s=o(ue);if(","===s.slice(-1))s=pe(e,s.substring(0,s.length-1)),r.push(s);else{let o="";s=pe(e,s);let i=!1;for(;;){const e=t.charAt(n);if(""===e){r.push((s+o).trim());break}if(i)")"===e&&(i=!1);else{if(","===e){n+=1,r.push((s+o).trim());break}"("===e&&(i=!0)}o+=e,n+=1}}}return r.join(", ")}(e,o):"style"===n?de(o,fe()):"object"===t&&"data"===n?pe(e,o):o:pe(e,o):o}function ve(e,t,n){return("video"===e||"audio"===e)&&"autoplay"===t}function ye(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&ye(e.parentNode,t,n);for(let n=e.classList.length;n--;){const o=e.classList[n];if(t.test(o))return!0}return!!n&&ye(e.parentNode,t,n)}function Se(e,t,n,o){try{const r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===r)return!1;if("string"==typeof t){if(o){if(r.closest(`.${t}`))return!0}else if(r.classList.contains(t))return!0}else if(ye(r,t,o))return!0;if(n)if(o){if(r.closest(n))return!0}else if(r.matches(n))return!0}catch(e){}return!1}function be(e,t){const{doc:n,mirror:o,blockClass:r,blockSelector:s,needsMask:i,inlineStylesheet:a,maskInputOptions:c={},maskTextFn:d,maskInputFn:u,dataURLOptions:h={},inlineImages:p,recordCanvas:m,keepIframeSrcFn:f,newlyAddedElement:g=!1}=t,v=function(e,t){if(!t.hasNode(e))return;const n=t.getId(e);return 1===n?void 0:n}(n,o);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:l.Document,childNodes:[],compatMode:e.compatMode}:{type:l.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:l.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:v};case e.ELEMENT_NODE:return function(e,t){const{doc:n,blockClass:o,blockSelector:r,inlineStylesheet:s,maskInputOptions:i={},maskInputFn:a,dataURLOptions:c={},inlineImages:d,recordCanvas:u,keepIframeSrcFn:h,newlyAddedElement:p=!1,rootId:m}=t,f=function(e,t,n){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;){const o=e.classList[n];if(t.test(o))return!0}if(n)return e.matches(n)}catch(e){}return!1}(e,o,r),g=function(e){if(e instanceof HTMLFormElement)return"form";const t=J(e.tagName);return ne.test(t)?"div":t}(e);let v={};const y=e.attributes.length;for(let t=0;t<y;t++){const o=e.attributes[t];ve(g,o.name,o.value)||(v[o.name]=ge(n,g,J(o.name),o.value))}if("link"===g&&s){const t=Array.from(n.styleSheets).find(t=>t.href===e.href);let o=null;t&&(o=G(t)),o&&(delete v.rel,delete v.href,v._cssText=de(o,t.href))}if("style"===g&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){const t=G(e.sheet);t&&(v._cssText=de(t,fe()))}if("input"===g||"textarea"===g||"select"===g){const t=e.value,n=e.checked;"radio"!==v.type&&"checkbox"!==v.type&&"submit"!==v.type&&"button"!==v.type&&t?v.value=Y({element:e,type:Q(e),tagName:g,value:t,maskInputOptions:i,maskInputFn:a}):n&&(v.checked=n)}"option"===g&&(e.selected&&!i.select?v.selected=!0:delete v.selected);if("canvas"===g&&u)if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let n=0;n<e.width;n+=50)for(let o=0;o<e.height;o+=50){const r=t.getImageData,s=Z in r?r[Z]:r;if(new Uint32Array(s.call(t,n,o,Math.min(50,e.width-n),Math.min(50,e.height-o)).data.buffer).some(e=>0!==e))return!1}return!0})(e)||(v.rr_dataURL=e.toDataURL(c.type,c.quality));else if(!("__context"in e)){const t=e.toDataURL(c.type,c.quality),n=document.createElement("canvas");n.width=e.width,n.height=e.height;t!==n.toDataURL(c.type,c.quality)&&(v.rr_dataURL=t)}if("img"===g&&d){re||(re=n.createElement("canvas"),se=re.getContext("2d"));const t=e,o=t.crossOrigin;t.crossOrigin="anonymous";const r=()=>{t.removeEventListener("load",r);try{re.width=t.naturalWidth,re.height=t.naturalHeight,se.drawImage(t,0,0),v.rr_dataURL=re.toDataURL(c.type,c.quality)}catch(e){console.warn(`Cannot inline img src=${t.currentSrc}! Error: ${e}`)}o?v.crossOrigin=o:t.removeAttribute("crossorigin")};t.complete&&0!==t.naturalWidth?r():t.addEventListener("load",r)}if("audio"===g||"video"===g){const t=v;t.rr_mediaState=e.paused?"paused":"played",t.rr_mediaCurrentTime=e.currentTime,t.rr_mediaPlaybackRate=e.playbackRate,t.rr_mediaMuted=e.muted,t.rr_mediaLoop=e.loop,t.rr_mediaVolume=e.volume}p||(e.scrollLeft&&(v.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(v.rr_scrollTop=e.scrollTop));if(f){const{width:t,height:n}=e.getBoundingClientRect();v={class:v.class,rr_width:`${t}px`,rr_height:`${n}px`}}"iframe"!==g||h(v.src)||(e.contentDocument||(v.rr_src=v.src),delete v.src);let S;try{customElements.get(g)&&(S=!0)}catch(e){}return{type:l.Element,tagName:g,attributes:v,childNodes:[],isSVG:me(e)||void 0,needBlock:f,rootId:m,isCustom:S}}(e,{doc:n,blockClass:r,blockSelector:s,inlineStylesheet:a,maskInputOptions:c,maskInputFn:u,dataURLOptions:h,inlineImages:p,recordCanvas:m,keepIframeSrcFn:f,newlyAddedElement:g,rootId:v});case e.TEXT_NODE:return function(e,t){var n;const{needsMask:o,maskTextFn:r,rootId:s}=t,i=e.parentNode&&e.parentNode.tagName;let a=e.textContent;const c="STYLE"===i||void 0,d="SCRIPT"===i||void 0;if(c&&a){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(a=G(e.parentNode.sheet))}catch(t){console.warn(`Cannot get CSS styles from text's parentNode. Error: ${t}`,e)}a=de(a,fe())}d&&(a="SCRIPT_PLACEHOLDER");!c&&!d&&a&&o&&(a=r?r(a,e.parentElement):a.replace(/[\S]/g,"*"));return{type:l.Text,textContent:a||"",isStyle:c,rootId:s}}(e,{needsMask:i,maskTextFn:d,rootId:v});case e.CDATA_SECTION_NODE:return{type:l.CDATA,textContent:"",rootId:v};case e.COMMENT_NODE:return{type:l.Comment,textContent:e.textContent||"",rootId:v};default:return!1}}function we(e){return null==e?"":e.toLowerCase()}function ke(e,t){const{doc:n,mirror:o,blockClass:r,blockSelector:s,maskTextClass:i,maskTextSelector:a,skipChild:c=!1,inlineStylesheet:d=!0,maskInputOptions:u={},maskTextFn:h,maskInputFn:p,slimDOMOptions:m,dataURLOptions:f={},inlineImages:g=!1,recordCanvas:v=!1,onSerialize:y,onIframeLoad:S,iframeLoadTimeout:b=5e3,onStylesheetLoad:w,stylesheetLoadTimeout:k=5e3,keepIframeSrcFn:I=()=>!1,newlyAddedElement:C=!1}=t;let{needsMask:M}=t,{preserveWhiteSpace:E=!0}=t;if(!M&&e.childNodes){M=Se(e,i,a,void 0===M)}const T=be(e,{doc:n,mirror:o,blockClass:r,blockSelector:s,needsMask:M,inlineStylesheet:d,maskInputOptions:u,maskTextFn:h,maskInputFn:p,dataURLOptions:f,inlineImages:g,recordCanvas:v,keepIframeSrcFn:I,newlyAddedElement:C});if(!T)return console.warn(e,"not serialized"),null;let O;O=o.hasNode(e)?o.getId(e):!function(e,t){if(t.comment&&e.type===l.Comment)return!0;if(e.type===l.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel||"modulepreload"===e.attributes.rel)&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&"js"===ee(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(we(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===we(e.attributes.name)||"icon"===we(e.attributes.rel)||"apple-touch-icon"===we(e.attributes.rel)||"shortcut icon"===we(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&we(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(we(e.attributes.property).match(/^(og|twitter|fb):/)||we(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===we(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===we(e.attributes.name)||"googlebot"===we(e.attributes.name)||"bingbot"===we(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===we(e.attributes.name)||"generator"===we(e.attributes.name)||"framework"===we(e.attributes.name)||"publisher"===we(e.attributes.name)||"progid"===we(e.attributes.name)||we(e.attributes.property).match(/^article:/)||we(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===we(e.attributes.name)||"yandex-verification"===we(e.attributes.name)||"csrf-token"===we(e.attributes.name)||"p:domain_verify"===we(e.attributes.name)||"verify-v1"===we(e.attributes.name)||"verification"===we(e.attributes.name)||"shopify-checkout-api-token"===we(e.attributes.name)))return!0}}return!1}(T,m)&&(E||T.type!==l.Text||T.isStyle||T.textContent.replace(/^\s+|\s+$/gm,"").length)?oe():-2;const D=Object.assign(T,{id:O});if(o.add(e,D),-2===O)return null;y&&y(e);let R=!c;if(D.type===l.Element){R=R&&!D.needBlock,delete D.needBlock;const t=e.shadowRoot;t&&V(t)&&(D.isShadowHost=!0)}if((D.type===l.Document||D.type===l.Element)&&R){m.headWhitespace&&D.type===l.Element&&"head"===D.tagName&&(E=!1);const t={doc:n,mirror:o,blockClass:r,blockSelector:s,needsMask:M,maskTextClass:i,maskTextSelector:a,skipChild:c,inlineStylesheet:d,maskInputOptions:u,maskTextFn:h,maskInputFn:p,slimDOMOptions:m,dataURLOptions:f,inlineImages:g,recordCanvas:v,preserveWhiteSpace:E,onSerialize:y,onIframeLoad:S,iframeLoadTimeout:b,onStylesheetLoad:w,stylesheetLoadTimeout:k,keepIframeSrcFn:I};if(D.type===l.Element&&"textarea"===D.tagName&&void 0!==D.attributes.value);else for(const n of Array.from(e.childNodes)){const e=ke(n,t);e&&D.childNodes.push(e)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(const n of Array.from(e.shadowRoot.childNodes)){const o=ke(n,t);o&&(V(e.shadowRoot)&&(o.isShadow=!0),D.childNodes.push(o))}}return e.parentNode&&$(e.parentNode)&&V(e.parentNode)&&(D.isShadow=!0),D.type===l.Element&&"iframe"===D.tagName&&function(e,t,n){const o=e.contentWindow;if(!o)return;let r,s=!1;try{r=o.document.readyState}catch(e){return}if("complete"!==r){const o=setTimeout(()=>{s||(t(),s=!0)},n);return void e.addEventListener("load",()=>{clearTimeout(o),s=!0,t()})}const i="about:blank";if(o.location.href!==i||e.src===i||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}(e,()=>{const t=e.contentDocument;if(t&&S){const n=ke(t,{doc:t,mirror:o,blockClass:r,blockSelector:s,needsMask:M,maskTextClass:i,maskTextSelector:a,skipChild:!1,inlineStylesheet:d,maskInputOptions:u,maskTextFn:h,maskInputFn:p,slimDOMOptions:m,dataURLOptions:f,inlineImages:g,recordCanvas:v,preserveWhiteSpace:E,onSerialize:y,onIframeLoad:S,iframeLoadTimeout:b,onStylesheetLoad:w,stylesheetLoadTimeout:k,keepIframeSrcFn:I});n&&S(e,n)}},b),D.type===l.Element&&"link"===D.tagName&&"string"==typeof D.attributes.rel&&("stylesheet"===D.attributes.rel||"preload"===D.attributes.rel&&"string"==typeof D.attributes.href&&"css"===ee(D.attributes.href))&&function(e,t,n){let o,r=!1;try{o=e.sheet}catch(e){return}if(o)return;const s=setTimeout(()=>{r||(t(),r=!0)},n);e.addEventListener("load",()=>{clearTimeout(s),r=!0,t()})}(e,()=>{if(w){const t=ke(e,{doc:n,mirror:o,blockClass:r,blockSelector:s,needsMask:M,maskTextClass:i,maskTextSelector:a,skipChild:!1,inlineStylesheet:d,maskInputOptions:u,maskTextFn:h,maskInputFn:p,slimDOMOptions:m,dataURLOptions:f,inlineImages:g,recordCanvas:v,preserveWhiteSpace:E,onSerialize:y,onIframeLoad:S,iframeLoadTimeout:b,onStylesheetLoad:w,stylesheetLoadTimeout:k,keepIframeSrcFn:I});t&&w(e,t)}},k),D}function Ie(e,t,n=document){const o={capture:!0,passive:!0};return n.addEventListener(e,t,o),()=>n.removeEventListener(e,t,o)}const Ce="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let Me={map:{},getId:()=>(console.error(Ce),-1),getNode:()=>(console.error(Ce),null),removeNodeFromMap(){console.error(Ce)},has:()=>(console.error(Ce),!1),reset(){console.error(Ce)}};function Ee(e,t,n={}){let o=null,r=0;return function(...s){const i=Date.now();r||!1!==n.leading||(r=i);const a=t-(i-r),l=this;a<=0||a>t?(o&&(clearTimeout(o),o=null),r=i,e.apply(l,s)):o||!1===n.trailing||(o=setTimeout(()=>{r=!1===n.leading?0:Date.now(),o=null,e.apply(l,s)},a))}}function Te(e,t,n,o,r=window){const s=r.Object.getOwnPropertyDescriptor(e,t);return r.Object.defineProperty(e,t,o?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),s&&s.set&&s.set.call(this,e)}}),()=>Te(e,t,s||{},!0)}function Oe(e,t,n){try{if(!(t in e))return()=>{};const o=e[t],r=n(o);return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:o}})),e[t]=r,()=>{e[t]=o}}catch(e){return()=>{}}}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Me=new Proxy(Me,{get:(e,t,n)=>("map"===t&&console.error(Ce),Reflect.get(e,t,n))}));let De=Date.now;function Re(e){var t,n,o,r,s,i;const a=e.document;return{left:a.scrollingElement?a.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:(null==a?void 0:a.documentElement.scrollLeft)||(null===(n=null===(t=null==a?void 0:a.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(o=null==a?void 0:a.body)||void 0===o?void 0:o.scrollLeft)||0,top:a.scrollingElement?a.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==a?void 0:a.documentElement.scrollTop)||(null===(s=null===(r=null==a?void 0:a.body)||void 0===r?void 0:r.parentElement)||void 0===s?void 0:s.scrollTop)||(null===(i=null==a?void 0:a.body)||void 0===i?void 0:i.scrollTop)||0}}function xe(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Le(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Ne(e){if(!e)return null;return e.nodeType===e.ELEMENT_NODE?e:e.parentElement}function Fe(e,t,n,o){if(!e)return!1;const r=Ne(e);if(!r)return!1;try{if("string"==typeof t){if(r.classList.contains(t))return!0;if(o&&null!==r.closest("."+t))return!0}else if(ye(r,t,o))return!0}catch(e){}if(n){if(r.matches(n))return!0;if(o&&null!==r.closest(n))return!0}return!1}function Ae(e,t){return-2===t.getId(e)}function _e(e,t){if($(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||_e(e.parentNode,t))}function We(e){return Boolean(e.changedTouches)}function Pe(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function je(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function Ue(e){return Boolean(null==e?void 0:e.shadowRoot)}/[1-9][0-9]{12}/.test(Date.now().toString())||(De=()=>(new Date).getTime());class Be{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function ze(e){var t,n;let o=null;return(null===(n=null===(t=e.getRootNode)||void 0===t?void 0:t.call(e))||void 0===n?void 0:n.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&e.getRootNode().host&&(o=e.getRootNode().host),o}function He(e){const t=e.ownerDocument;if(!t)return!1;const n=function(e){let t,n=e;for(;t=ze(n);)n=t;return n}(e);return t.contains(n)}function qe(e){const t=e.ownerDocument;return!!t&&(t.contains(e)||He(e))}var $e=(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))($e||{}),Ve=(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))(Ve||{}),Ge=(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))(Ge||{}),Xe=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Xe||{}),Ke=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(Ke||{});function Ye(e){return"__ln"in e}class Je{constructor(){this.length=0,this.head=null,this.tail=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&Ye(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&Ye(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}}const Ze=(e,t)=>`${e}@${t}`;class Qe{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],t=new Set,n=new Je,o=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},r=r=>{if(!r.parentNode||!qe(r)||"TEXTAREA"===r.parentNode.tagName)return;const s=$(r.parentNode)?this.mirror.getId(ze(r)):this.mirror.getId(r.parentNode),i=o(r);if(-1===s||-1===i)return n.addNode(r);const a=ke(r,{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,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{Pe(e,this.mirror)&&this.iframeManager.addIframe(e),je(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),Ue(r)&&this.shadowDomManager.addShadowRoot(r.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});a&&(e.push({parentId:s,nextId:i,node:a}),t.add(a.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of this.movedSet)tt(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||r(e);for(const e of this.addedSet)ot(this.droppedSet,e)||tt(this.removes,e,this.mirror)?ot(this.movedSet,e)?r(e):this.droppedSet.add(e):r(e);let s=null;for(;n.length;){let e=null;if(s){const t=this.mirror.getId(s.value.parentNode),n=o(s.value);-1!==t&&-1!==n&&(e=s)}if(!e){let t=n.tail;for(;t;){const n=t;if(t=t.previous,n){const t=this.mirror.getId(n.value.parentNode);if(-1===o(n.value))continue;if(-1!==t){e=n;break}{const t=n.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const o=t.parentNode.host;if(-1!==this.mirror.getId(o)){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}s=e.previous,n.removeNode(e.value),r(e.value)}const i={texts:this.texts.map(e=>{const t=e.node;return t.parentNode&&"TEXTAREA"===t.parentNode.tagName&&this.genTextAreaValueMutation(t.parentNode),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>{const{attributes:t}=e;if("string"==typeof t.style){const n=JSON.stringify(e.styleDiff),o=JSON.stringify(e._unchangedStyles);n.length<t.style.length&&(n+o).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};(i.texts.length||i.attributes.length||i.removes.length||i.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(i))},this.genTextAreaValueMutation=e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t)),t.attributes.value=Array.from(e.childNodes,e=>e.textContent||"").join("")},this.processMutation=e=>{if(!Ae(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;Fe(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:Se(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,Ne(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.attributeName,o=e.target.getAttribute(n);if("value"===n){const e=Q(t);o=Y({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:e,value:o,maskInputFn:this.maskInputFn})}if(Fe(e.target,this.blockClass,this.blockSelector,!1)||o===e.oldValue)return;let r=this.attributeMap.get(e.target);if("IFRAME"===t.tagName&&"src"===n&&!this.keepIframeSrcFn(o)){if(t.contentDocument)return;n="rr_src"}if(r||(r={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(r),this.attributeMap.set(e.target,r)),"type"===n&&"INPUT"===t.tagName&&"password"===(e.oldValue||"").toLowerCase()&&t.setAttribute("data-rr-is-password","true"),!ve(t.tagName,n)&&(r.attributes[n]=ge(this.doc,J(t.tagName),J(n),o),"style"===n)){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(e){this.unattachedDoc=this.doc}const n=this.unattachedDoc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue);for(const e of Array.from(t.style)){const o=t.style.getPropertyValue(e),s=t.style.getPropertyPriority(e);o!==n.style.getPropertyValue(e)||s!==n.style.getPropertyPriority(e)?r.styleDiff[e]=""===s?o:[o,s]:r._unchangedStyles[e]=[o,s]}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(r.styleDiff[e]=!1)}break}case"childList":if(Fe(e.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const n=this.mirror.getId(t),o=$(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);Fe(e.target,this.blockClass,this.blockSelector,!1)||Ae(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(et(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||_e(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Ze(n,o)]?et(this.movedSet,t):this.removes.push({parentId:o,id:n,isShadow:!(!$(e.target)||!V(e.target))||void 0})),this.mapRemoves.push(t))})}},this.genAdds=(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(Ae(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[Ze(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);Fe(e,this.blockClass,this.blockSelector,!1)||(e.childNodes.forEach(e=>this.genAdds(e)),Ue(e)&&e.shadowRoot.childNodes.forEach(t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)}))}}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(t=>{this[t]=e[t]})}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 et(e,t){e.delete(t),t.childNodes.forEach(t=>et(e,t))}function tt(e,t,n){return 0!==e.length&&nt(e,t,n)}function nt(e,t,n){const{parentNode:o}=t;if(!o)return!1;const r=n.getId(o);return!!e.some(e=>e.id===r)||nt(e,o,n)}function ot(e,t){return 0!==e.size&&rt(e,t)}function rt(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||rt(e,n))}let st;function it(e){st=e}function at(){st=void 0}const lt=e=>{if(!st)return e;return(...t)=>{try{return e(...t)}catch(e){if(st&&!0===st(e))return;throw e}}},ct=[];function dt(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch(e){}return e&&e.target}function ut(e,t){var n,o;const r=new Qe;ct.push(r),r.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=null===(o=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===o?void 0:o.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const a=new s(lt(r.processMutations.bind(r)));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function ht({mouseInteractionCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];let l=null;return Object.keys(Ge).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e]).forEach(s=>{let i=J(s);const c=(t=>s=>{const i=dt(s);if(Fe(i,o,r,!0))return;let a=null,c=t;if("pointerType"in s){switch(s.pointerType){case"mouse":a=Xe.Mouse;break;case"touch":a=Xe.Touch;break;case"pen":a=Xe.Pen}a===Xe.Touch?Ge[t]===Ge.MouseDown?c="TouchStart":Ge[t]===Ge.MouseUp&&(c="TouchEnd"):Xe.Pen}else We(s)&&(a=Xe.Touch);null!==a?(l=a,(c.startsWith("Touch")&&a===Xe.Touch||c.startsWith("Mouse")&&a===Xe.Mouse)&&(a=null)):Ge[t]===Ge.Click&&(a=l,l=null);const d=We(s)?s.changedTouches[0]:s;if(!d)return;const u=n.getId(i),{clientX:h,clientY:p}=d;lt(e)(Object.assign({type:Ge[c],id:u,x:h,y:p},null!==a&&{pointerType:a}))})(s);if(window.PointerEvent)switch(Ge[s]){case Ge.MouseDown:case Ge.MouseUp:i=i.replace("mouse","pointer");break;case Ge.TouchStart:case Ge.TouchEnd:return}a.push(Ie(i,c,t))}),lt(()=>{a.forEach(e=>e())})}function pt({scrollCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:s}){return Ie("scroll",lt(Ee(lt(s=>{const i=dt(s);if(!i||Fe(i,o,r,!0))return;const a=n.getId(i);if(i===t&&t.defaultView){const n=Re(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})}),s.scroll||100)),t)}const mt=["INPUT","TEXTAREA","SELECT"],ft=new WeakMap;function gt(e){return function(e,t){if(bt("CSSGroupingRule")&&e.parentRule instanceof CSSGroupingRule||bt("CSSMediaRule")&&e.parentRule instanceof CSSMediaRule||bt("CSSSupportsRule")&&e.parentRule instanceof CSSSupportsRule||bt("CSSConditionRule")&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function vt(e,t,n){let o,r;return e?(e.ownerNode?o=t.getId(e.ownerNode):r=n.getId(e),{styleId:r,id:o}):{}}function yt({mirror:e,stylesheetManager:t},n){var o,r,s;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(o=n.defaultView)||void 0===o?void 0:o.Document:null===(s=null===(r=n.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===s?void 0:s.ShadowRoot,l=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==i&&-1!==i&&a&&l?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var e;return null===(e=l.get)||void 0===e?void 0:e.call(this)},set(e){var n;const o=null===(n=l.set)||void 0===n?void 0:n.call(this,e);if(null!==i&&-1!==i)try{t.adoptStyleSheets(e,i)}catch(e){}return o}}),lt(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})})):()=>{}}function St(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let o;!function(e,t){const{mutationCb:n,mousemoveCb:o,mouseInteractionCb:r,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:p,customElementCb:m}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),o(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),r(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),s(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),i(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),l(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),c(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)},e.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),m(...e)}}(e,t),e.recordDOM&&(o=ut(e,e.doc));const r=function({mousemoveCb:e,sampling:t,doc:n,mirror:o}){if(!1===t.mousemove)return()=>{};const r="number"==typeof t.mousemove?t.mousemove:50,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const l=Ee(lt(t=>{const n=Date.now()-i;e(a.map(e=>(e.timeOffset-=n,e)),t),a=[],i=null}),s),c=lt(Ee(lt(e=>{const t=dt(e),{clientX:n,clientY:r}=We(e)?e.changedTouches[0]:e;i||(i=De()),a.push({x:n,y:r,id:o.getId(t),timeOffset:De()-i}),l("undefined"!=typeof DragEvent&&e instanceof DragEvent?Ve.Drag:e instanceof MouseEvent?Ve.MouseMove:Ve.TouchMove)}),r,{trailing:!1})),d=[Ie("mousemove",c,n),Ie("touchmove",c,n),Ie("drag",c,n)];return lt(()=>{d.forEach(e=>e())})}(e),s=ht(e),i=pt(e),a=function({viewportResizeCb:e},{win:t}){let n=-1,o=-1;return Ie("resize",lt(Ee(lt(()=>{const t=xe(),r=Le();n===t&&o===r||(e({width:Number(r),height:Number(t)}),n=t,o=r)}),200)),t)}(e,{win:n}),l=function({inputCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,ignoreClass:s,ignoreSelector:i,maskInputOptions:a,maskInputFn:l,sampling:c,userTriggeredOnInput:d}){function u(e){let n=dt(e);const c=e.isTrusted,u=n&&n.tagName;if(n&&"OPTION"===u&&(n=n.parentElement),!n||!u||mt.indexOf(u)<0||Fe(n,o,r,!0))return;if(n.classList.contains(s)||i&&n.matches(i))return;let p=n.value,m=!1;const f=Q(n)||"";"radio"===f||"checkbox"===f?m=n.checked:(a[u.toLowerCase()]||a[f])&&(p=Y({element:n,maskInputOptions:a,tagName:u,type:f,value:p,maskInputFn:l})),h(n,d?{text:p,isChecked:m,userTriggered:c}:{text:p,isChecked:m});const g=n.name;"radio"===f&&g&&m&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach(e=>{if(e!==n){const t=e.value;h(e,d?{text:t,isChecked:!m,userTriggered:!1}:{text:t,isChecked:!m})}})}function h(t,o){const r=ft.get(t);if(!r||r.text!==o.text||r.isChecked!==o.isChecked){ft.set(t,o);const r=n.getId(t);lt(e)(Object.assign(Object.assign({},o),{id:r}))}}const p=("last"===c.input?["change"]:["input","change"]).map(e=>Ie(e,lt(u),t)),m=t.defaultView;if(!m)return()=>{p.forEach(e=>e())};const f=m.Object.getOwnPropertyDescriptor(m.HTMLInputElement.prototype,"value"),g=[[m.HTMLInputElement.prototype,"value"],[m.HTMLInputElement.prototype,"checked"],[m.HTMLSelectElement.prototype,"value"],[m.HTMLTextAreaElement.prototype,"value"],[m.HTMLSelectElement.prototype,"selectedIndex"],[m.HTMLOptionElement.prototype,"selected"]];return f&&f.set&&p.push(...g.map(e=>Te(e[0],e[1],{set(){lt(u)({target:this,isTrusted:!1})}},!1,m))),lt(()=>{p.forEach(e=>e())})}(e),c=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:o,sampling:r,doc:s}){const i=lt(s=>Ee(lt(r=>{const i=dt(r);if(!i||Fe(i,t,n,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:d,loop:u}=i;e({type:s,id:o.getId(i),currentTime:a,volume:l,muted:c,playbackRate:d,loop:u})}),r.media||500)),a=[Ie("play",i(0),s),Ie("pause",i(1),s),Ie("seeked",i(2),s),Ie("volumechange",i(3),s),Ie("ratechange",i(4),s)];return lt(()=>{a.forEach(e=>e())})}(e);let d=()=>{},u=()=>{},h=()=>{},p=()=>{};e.recordDOM&&(d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:o}){if(!o.CSSStyleSheet||!o.CSSStyleSheet.prototype)return()=>{};const r=o.CSSStyleSheet.prototype.insertRule;o.CSSStyleSheet.prototype.insertRule=new Proxy(r,{apply:lt((o,r,s)=>{const[i,a]=s,{id:l,styleId:c}=vt(r,t,n.styleMirror);return(l&&-1!==l||c&&-1!==c)&&e({id:l,styleId:c,adds:[{rule:i,index:a}]}),o.apply(r,s)})});const s=o.CSSStyleSheet.prototype.deleteRule;let i,a;o.CSSStyleSheet.prototype.deleteRule=new Proxy(s,{apply:lt((o,r,s)=>{const[i]=s,{id:a,styleId:l}=vt(r,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,removes:[{index:i}]}),o.apply(r,s)})}),o.CSSStyleSheet.prototype.replace&&(i=o.CSSStyleSheet.prototype.replace,o.CSSStyleSheet.prototype.replace=new Proxy(i,{apply:lt((o,r,s)=>{const[i]=s,{id:a,styleId:l}=vt(r,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,replace:i}),o.apply(r,s)})})),o.CSSStyleSheet.prototype.replaceSync&&(a=o.CSSStyleSheet.prototype.replaceSync,o.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:lt((o,r,s)=>{const[i]=s,{id:a,styleId:l}=vt(r,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,replaceSync:i}),o.apply(r,s)})}));const l={};wt("CSSGroupingRule")?l.CSSGroupingRule=o.CSSGroupingRule:(wt("CSSMediaRule")&&(l.CSSMediaRule=o.CSSMediaRule),wt("CSSConditionRule")&&(l.CSSConditionRule=o.CSSConditionRule),wt("CSSSupportsRule")&&(l.CSSSupportsRule=o.CSSSupportsRule));const c={};return Object.entries(l).forEach(([o,r])=>{c[o]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=new Proxy(c[o].insertRule,{apply:lt((o,r,s)=>{const[i,a]=s,{id:l,styleId:c}=vt(r.parentStyleSheet,t,n.styleMirror);return(l&&-1!==l||c&&-1!==c)&&e({id:l,styleId:c,adds:[{rule:i,index:[...gt(r),a||0]}]}),o.apply(r,s)})}),r.prototype.deleteRule=new Proxy(c[o].deleteRule,{apply:lt((o,r,s)=>{const[i]=s,{id:a,styleId:l}=vt(r.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,removes:[{index:[...gt(r),i]}]}),o.apply(r,s)})})}),lt(()=>{o.CSSStyleSheet.prototype.insertRule=r,o.CSSStyleSheet.prototype.deleteRule=s,i&&(o.CSSStyleSheet.prototype.replace=i),a&&(o.CSSStyleSheet.prototype.replaceSync=a),Object.entries(l).forEach(([e,t])=>{t.prototype.insertRule=c[e].insertRule,t.prototype.deleteRule=c[e].deleteRule})})}(e,{win:n}),u=yt(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:o},{win:r}){const s=r.CSSStyleDeclaration.prototype.setProperty;r.CSSStyleDeclaration.prototype.setProperty=new Proxy(s,{apply:lt((r,i,a)=>{var l;const[c,d,u]=a;if(n.has(c))return s.apply(i,[c,d,u]);const{id:h,styleId:p}=vt(null===(l=i.parentRule)||void 0===l?void 0:l.parentStyleSheet,t,o.styleMirror);return(h&&-1!==h||p&&-1!==p)&&e({id:h,styleId:p,set:{property:c,value:d,priority:u},index:gt(i.parentRule)}),r.apply(i,a)})});const i=r.CSSStyleDeclaration.prototype.removeProperty;return r.CSSStyleDeclaration.prototype.removeProperty=new Proxy(i,{apply:lt((r,s,a)=>{var l;const[c]=a;if(n.has(c))return i.apply(s,[c]);const{id:d,styleId:u}=vt(null===(l=s.parentRule)||void 0===l?void 0:l.parentStyleSheet,t,o.styleMirror);return(d&&-1!==d||u&&-1!==u)&&e({id:d,styleId:u,remove:{property:c},index:gt(s.parentRule)}),r.apply(s,a)})}),lt(()=>{r.CSSStyleDeclaration.prototype.setProperty=s,r.CSSStyleDeclaration.prototype.removeProperty=i})}(e,{win:n}),e.collectFonts&&(p=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const o=[],r=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const o=new s(e,t,n);return r.set(o,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),o};const i=Oe(t.fonts,"add",function(t){return function(n){return setTimeout(lt(()=>{const t=r.get(n);t&&(e(t),r.delete(n))}),0),t.apply(this,[n])}});return o.push(()=>{n.FontFace=s}),o.push(i),lt(()=>{o.forEach(e=>e())})}(e)));const m=function(e){const{doc:t,mirror:n,blockClass:o,blockSelector:r,selectionCb:s}=e;let i=!0;const a=lt(()=>{const e=t.getSelection();if(!e||i&&(null==e?void 0:e.isCollapsed))return;i=e.isCollapsed||!1;const a=[],l=e.rangeCount||0;for(let t=0;t<l;t++){const s=e.getRangeAt(t),{startContainer:i,startOffset:l,endContainer:c,endOffset:d}=s;Fe(i,o,r,!0)||Fe(c,o,r,!0)||a.push({start:n.getId(i),startOffset:l,end:n.getId(c),endOffset:d})}s({ranges:a})});return a(),Ie("selectionchange",a)}(e),f=function({doc:e,customElementCb:t}){const n=e.defaultView;return n&&n.customElements?Oe(n.customElements,"define",function(e){return function(n,o,r){try{t({define:{name:n}})}catch(e){console.warn(`Custom element callback failed for ${n}`)}return e.apply(this,[n,o,r])}}):()=>{}}(e),g=[];for(const t of e.plugins)g.push(t.observer(t.callback,n,t.options));return lt(()=>{ct.forEach(e=>e.reset()),null==o||o.disconnect(),r(),s(),i(),a(),l(),c(),d(),u(),h(),p(),m(),f(),g.forEach(e=>e())})}function bt(e){return void 0!==window[e]}function wt(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}class kt{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,o){const r=n||this.getIdToRemoteIdMap(e),s=o||this.getRemoteIdToIdMap(e);let i=r.get(t);return i||(i=this.generateIdFn(),r.set(t,i),s.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),o=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,o))}getRemoteId(e,t,n){const o=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const r=o.get(t);return r||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map(t=>this.getRemoteId(e,t,n))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class It{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new kt(oe),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new kt(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const n=this.crossOriginIframeMap.get(e.source);if(!n)return;const o=this.transformCrossOriginEvent(n,t.data.event);o&&this.wrappedEmit(o,t.data.isCheckout)}transformCrossOriginEvent(e,t){var n;switch(t.type){case $e.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const n=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,n),this.patchRootIdOnNode(t.data.node,n),{timestamp:t.timestamp,type:$e.IncrementalSnapshot,data:{source:Ve.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case $e.Meta:case $e.Load:case $e.DomContentLoaded:return!1;case $e.Plugin:return t;case $e.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case $e.IncrementalSnapshot:switch(t.data.source){case Ve.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const n=this.crossOriginIframeRootIdMap.get(e);n&&this.patchRootIdOnNode(t.node,n)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,["parentId","id"])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,["id"])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case Ve.Drag:case Ve.TouchMove:case Ve.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case Ve.ViewportResize:return!1;case Ve.MediaInteraction:case Ve.MouseInteraction:case Ve.Scroll:case Ve.CanvasMutation:case Ve.Input:return this.replaceIds(t.data,e,["id"]),t;case Ve.StyleSheetRule:case Ve.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case Ve.Font:return t;case Ve.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case Ve.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(n=t.data.styles)||void 0===n||n.forEach(t=>{this.replaceStyleIds(t,e,["styleId"])}),t}}return!1}replace(e,t,n,o){for(const r of o)(Array.isArray(t[r])||"number"==typeof t[r])&&(Array.isArray(t[r])?t[r]=e.getIds(n,t[r]):t[r]=e.getId(n,t[r]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}patchRootIdOnNode(e,t){e.type===l.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}}class Ct{constructor(e){this.shadowDoms=new WeakSet,this.restoreHandlers=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){if(!V(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const n=ut(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(pt(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),this.restoreHandlers.push(yt({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))},0)}observeAttachShadow(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){const n=this;this.restoreHandlers.push(Oe(e.prototype,"attachShadow",function(e){return function(o){const r=e.call(this,o);return this.shadowRoot&&qe(this)&&n.addShadowRoot(this.shadowRoot,t),r}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch(e){}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DevSkin=t()}(this,function(){"use strict";class e{constructor(e){this.config=e}collect(){return{type:this.getDeviceType(),vendor:this.getVendor(),model:this.getModel(),os:this.getOS(),screen:this.getScreenInfo(),memory:this.getMemory(),cores:this.getCores(),connection:this.getConnection()}}getDeviceType(){const e=navigator.userAgent;return/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(e)?"tablet":/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(e)?"mobile":e.includes("Windows")||e.includes("Macintosh")||e.includes("Linux")?"desktop":"unknown"}getVendor(){return navigator.vendor||void 0}getModel(){const e=navigator.userAgent.match(/\(([^)]+)\)/);if(e&&e[1])return e[1]}getOS(){const e=navigator.userAgent;let t="Unknown",n="";if(e.includes("Win"))t="Windows",e.includes("Windows NT 10.0")?n="10":e.includes("Windows NT 6.3")?n="8.1":e.includes("Windows NT 6.2")?n="8":e.includes("Windows NT 6.1")&&(n="7");else if(e.includes("Mac")){t="macOS";const o=e.match(/Mac OS X (\d+[._]\d+[._]\d+)?/);o&&o[1]&&(n=o[1].replace(/_/g,"."))}else if(e.includes("X11")||e.includes("Linux"))t="Linux";else if(e.includes("Android")){t="Android";const o=e.match(/Android (\d+\.?\d*)/);o&&o[1]&&(n=o[1])}else if(e.includes("iOS")||e.includes("iPhone")||e.includes("iPad")){t="iOS";const o=e.match(/OS (\d+_\d+(_\d+)?)/);o&&o[1]&&(n=o[1].replace(/_/g,"."))}return{name:t,version:n}}getScreenInfo(){return{width:window.screen.width,height:window.screen.height,orientation:this.getOrientation(),pixelRatio:window.devicePixelRatio||1}}getOrientation(){return window.screen.orientation?window.screen.orientation.type:window.innerWidth>window.innerHeight?"landscape":"portrait"}getMemory(){return navigator.deviceMemory}getCores(){return navigator.hardwareConcurrency}getConnection(){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(e)return{effectiveType:e.effectiveType,downlink:e.downlink,rtt:e.rtt,saveData:e.saveData}}}function t(e,t,n,o){return new(n||(n=Promise))(function(r,s){function i(e){try{l(o.next(e))}catch(e){s(e)}}function a(e){try{l(o.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,a)}l((o=o.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(e){this.config=e,this.geoData=null,this.config.captureLocation&&this.requestGeolocation()}collect(){return Object.assign({url:window.location.href,hostname:window.location.hostname,pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,protocol:window.location.protocol,port:window.location.port,referrer:document.referrer},this.geoData)}requestGeolocation(){return t(this,void 0,void 0,function*(){try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;this.geoData={timezone:e},"geolocation"in navigator&&navigator.geolocation.getCurrentPosition(e=>{this.geoData=Object.assign(Object.assign({},this.geoData),{latitude:e.coords.latitude,longitude:e.coords.longitude}),this.reverseGeocode(e.coords.latitude,e.coords.longitude)},e=>{this.config.debug&&console.log("[DevSkin] Geolocation permission denied or error:",e)},{timeout:5e3,maximumAge:6e5})}catch(e){this.config.debug&&console.error("[DevSkin] Error requesting geolocation:",e)}})}reverseGeocode(e,n){return t(this,void 0,void 0,function*(){try{const t=yield fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${e}&lon=${n}&zoom=10&addressdetails=1`,{headers:{"User-Agent":"DevSkin-SDK/1.0"}});if(t.ok){const e=yield t.json();e.address&&(this.geoData=Object.assign(Object.assign({},this.geoData),{country:e.address.country,region:e.address.state||e.address.region,city:e.address.city||e.address.town||e.address.village}))}}catch(e){this.config.debug&&console.error("[DevSkin] Error reverse geocoding:",e)}})}}class o{constructor(e){this.config=e}collect(){return{name:this.getBrowserName(),version:this.getBrowserVersion(),engine:this.getEngine(),userAgent:navigator.userAgent,language:navigator.language,languages:navigator.languages?Array.from(navigator.languages):[navigator.language],cookieEnabled:navigator.cookieEnabled,doNotTrack:this.getDoNotTrack(),viewport:{width:window.innerWidth,height:window.innerHeight},timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffset:(new Date).getTimezoneOffset()}}getBrowserName(){const e=navigator.userAgent;return e.includes("Firefox")?"Firefox":e.includes("Edg")?"Edge":e.includes("Chrome")?"Chrome":e.includes("Safari")&&!e.includes("Chrome")?"Safari":e.includes("Opera")||e.includes("OPR")?"Opera":e.includes("Trident")||e.includes("MSIE")?"Internet Explorer":"Unknown"}getBrowserVersion(){const e=navigator.userAgent;let t=null;switch(this.getBrowserName()){case"Chrome":t=e.match(/Chrome\/(\d+\.\d+)/);break;case"Firefox":t=e.match(/Firefox\/(\d+\.\d+)/);break;case"Safari":t=e.match(/Version\/(\d+\.\d+)/);break;case"Edge":t=e.match(/Edg\/(\d+\.\d+)/);break;case"Opera":if(t=e.match(/(Opera|OPR)\/(\d+\.\d+)/),t)return t[2];break;case"Internet Explorer":if(t=e.match(/(MSIE |rv:)(\d+\.\d+)/),t)return t[2]}return t&&t[1]?t[1]:""}getEngine(){const e=navigator.userAgent;return e.includes("Gecko")&&e.includes("Firefox")?"Gecko":e.includes("AppleWebKit")?e.includes("Chrome")||e.includes("Edg")?"Blink":"WebKit":e.includes("Trident")?"Trident":"Unknown"}getDoNotTrack(){const e=navigator.doNotTrack||window.doNotTrack||navigator.msDoNotTrack;return"1"===e||"yes"===e||"0"!==e&&"no"!==e&&null}}var r,s,i,a,l,c=-1,d=function(e){addEventListener("pageshow",function(t){t.persisted&&(c=t.timeStamp,e(t))},!0)},u=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},h=function(){var e=u();return e&&e.activationStart||0},p=function(e,t){var n=u(),o="navigate";return c>=0?o="back-forward-cache":n&&(document.prerendering||h()>0?o="prerender":document.wasDiscarded?o="restore":n.type&&(o=n.type.replace(/_/g,"-"))),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:o}},m=function(e,t,n){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var o=new PerformanceObserver(function(e){Promise.resolve().then(function(){t(e.getEntries())})});return o.observe(Object.assign({type:e,buffered:!0},n||{})),o}}catch(e){}},f=function(e,t,n,o){var r,s;return function(i){t.value>=0&&(i||o)&&((s=t.value-(r||0))||void 0===r)&&(r=t.value,t.delta=s,t.rating=function(e,t){return e>t[1]?"poor":e>t[0]?"needs-improvement":"good"}(t.value,n),e(t))}},g=function(e){requestAnimationFrame(function(){return requestAnimationFrame(function(){return e()})})},v=function(e){var t=function(t){"pagehide"!==t.type&&"hidden"!==document.visibilityState||e(t)};addEventListener("visibilitychange",t,!0),addEventListener("pagehide",t,!0)},y=function(e){var t=!1;return function(n){t||(e(n),t=!0)}},S=-1,w=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},b=function(e){"hidden"===document.visibilityState&&S>-1&&(S="visibilitychange"===e.type?e.timeStamp:0,I())},k=function(){addEventListener("visibilitychange",b,!0),addEventListener("prerenderingchange",b,!0)},I=function(){removeEventListener("visibilitychange",b,!0),removeEventListener("prerenderingchange",b,!0)},C=function(){return S<0&&(S=w(),k(),d(function(){setTimeout(function(){S=w(),k()},0)})),{get firstHiddenTime(){return S}}},M=function(e){document.prerendering?addEventListener("prerenderingchange",function(){return e()},!0):e()},T=[1800,3e3],E=function(e,t){t=t||{},M(function(){var n,o=C(),r=p("FCP"),s=m("paint",function(e){e.forEach(function(e){"first-contentful-paint"===e.name&&(s.disconnect(),e.startTime<o.firstHiddenTime&&(r.value=Math.max(e.startTime-h(),0),r.entries.push(e),n(!0)))})});s&&(n=f(e,r,T,t.reportAllChanges),d(function(o){r=p("FCP"),n=f(e,r,T,t.reportAllChanges),g(function(){r.value=performance.now()-o.timeStamp,n(!0)})}))})},O=[.1,.25],D={passive:!0,capture:!0},R=new Date,x=function(e,t){r||(r=t,s=e,i=new Date,F(removeEventListener),L())},L=function(){if(s>=0&&s<i-R){var e={entryType:"first-input",name:r.type,target:r.target,cancelable:r.cancelable,startTime:r.timeStamp,processingStart:r.timeStamp+s};a.forEach(function(t){t(e)}),a=[]}},N=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){x(e,t),r()},o=function(){r()},r=function(){removeEventListener("pointerup",n,D),removeEventListener("pointercancel",o,D)};addEventListener("pointerup",n,D),addEventListener("pointercancel",o,D)}(t,e):x(t,e)}},F=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach(function(t){return e(t,N,D)})},A=[100,300],_=[2500,4e3],P={},W=[800,1800],j=function e(t){document.prerendering?M(function(){return e(t)}):"complete"!==document.readyState?addEventListener("load",function(){return e(t)},!0):setTimeout(t,0)},U=function(e,t){t=t||{};var n=p("TTFB"),o=f(e,n,W,t.reportAllChanges);j(function(){var r=u();if(r){var s=r.responseStart;if(s<=0||s>performance.now())return;n.value=Math.max(s-h(),0),n.entries=[r],o(!0),d(function(){n=p("TTFB",0),(o=f(e,n,W,t.reportAllChanges))(!0)})}})};class B{constructor(e,t){this.config=e,this.transport=t,this.metrics={}}start(){!function(e,t){t=t||{},E(y(function(){var n,o=p("CLS",0),r=0,s=[],i=function(e){e.forEach(function(e){if(!e.hadRecentInput){var t=s[0],n=s[s.length-1];r&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(r+=e.value,s.push(e)):(r=e.value,s=[e])}}),r>o.value&&(o.value=r,o.entries=s,n())},a=m("layout-shift",i);a&&(n=f(e,o,O,t.reportAllChanges),v(function(){i(a.takeRecords()),n(!0)}),d(function(){r=0,o=p("CLS",0),n=f(e,o,O,t.reportAllChanges),g(function(){return n()})}),setTimeout(n,0))}))}(e=>this.handleMetric(e)),E(e=>this.handleMetric(e)),function(e,t){t=t||{},M(function(){var n,o=C(),i=p("FID"),l=function(e){e.startTime<o.firstHiddenTime&&(i.value=e.processingStart-e.startTime,i.entries.push(e),n(!0))},c=function(e){e.forEach(l)},u=m("first-input",c);n=f(e,i,A,t.reportAllChanges),u&&v(y(function(){c(u.takeRecords()),u.disconnect()})),u&&d(function(){var o;i=p("FID"),n=f(e,i,A,t.reportAllChanges),a=[],s=-1,r=null,F(addEventListener),o=l,a.push(o),L()})})}(e=>this.handleMetric(e)),function(e,t){t=t||{},M(function(){var n,o=C(),r=p("LCP"),s=function(e){var t=e[e.length-1];t&&t.startTime<o.firstHiddenTime&&(r.value=Math.max(t.startTime-h(),0),r.entries=[t],n())},i=m("largest-contentful-paint",s);if(i){n=f(e,r,_,t.reportAllChanges);var a=y(function(){P[r.id]||(s(i.takeRecords()),i.disconnect(),P[r.id]=!0,n(!0))});["keydown","click"].forEach(function(e){addEventListener(e,function(){return setTimeout(a,0)},!0)}),v(a),d(function(o){r=p("LCP"),n=f(e,r,_,t.reportAllChanges),g(function(){r.value=performance.now()-o.timeStamp,P[r.id]=!0,n(!0)})})}})}(e=>this.handleMetric(e)),U(e=>this.handleMetric(e)),this.collectNavigationTimings(),this.collectResourceTimings(),this.config.longTaskThreshold&&this.observeLongTasks()}handleMetric(e){const t=e.name.toLowerCase();this.metrics[t]=e.value,this.config.debug&&console.log(`[DevSkin] Web Vital ${e.name}:`,e.value),this.transport.sendPerformanceMetric({name:e.name,value:e.value,rating:e.rating,delta:e.delta,timestamp:(new Date).toISOString()})}collectNavigationTimings(){window.performance&&window.performance.timing&&window.addEventListener("load",()=>{setTimeout(()=>{const e=window.performance.timing,t=window.performance.navigation,n=e.domContentLoadedEventEnd-e.navigationStart,o=e.loadEventEnd-e.navigationStart;this.metrics.domLoad=n,this.metrics.windowLoad=o,this.config.debug&&console.log("[DevSkin] Navigation Timings:",{domLoad:n,windowLoad:o,navigationType:t.type}),this.transport.sendPerformanceMetric({name:"Navigation",value:o,details:{domLoad:n,windowLoad:o,navigationType:t.type,redirectCount:t.redirectCount,dns:e.domainLookupEnd-e.domainLookupStart,tcp:e.connectEnd-e.connectStart,request:e.responseStart-e.requestStart,response:e.responseEnd-e.responseStart,dom:e.domComplete-e.domLoading},timestamp:(new Date).toISOString()})},0)})}collectResourceTimings(){window.performance&&window.performance.getEntriesByType&&window.addEventListener("load",()=>{setTimeout(()=>{const e=window.performance.getEntriesByType("resource"),t={total:e.length,byType:{},slowest:[]};e.forEach(e=>{const n=e.initiatorType||"other";t.byType[n]=(t.byType[n]||0)+1}),t.slowest=e.map(e=>({name:e.name,duration:e.duration,type:e.initiatorType})).sort((e,t)=>t.duration-e.duration).slice(0,10),this.config.debug&&console.log("[DevSkin] Resource Timings:",t),this.transport.sendPerformanceMetric({name:"Resources",value:e.length,details:t,timestamp:(new Date).toISOString()})},1e3)})}observeLongTasks(){if("PerformanceObserver"in window)try{new PerformanceObserver(e=>{for(const t of e.getEntries())t.duration>=(this.config.longTaskThreshold||50)&&(this.config.debug&&console.log("[DevSkin] Long Task detected:",t),this.transport.sendPerformanceMetric({name:"LongTask",value:t.duration,details:{name:t.name,entryType:t.entryType,startTime:t.startTime},timestamp:(new Date).toISOString()}))}).observe({entryTypes:["longtask"]})}catch(e){this.config.debug&&console.error("[DevSkin] Error observing long tasks:",e)}}getMetrics(){return Object.assign({},this.metrics)}}class H{constructor(e,t){var n;this.config=e,this.transport=t,this.breadcrumbs=[],this.maxBreadcrumbs=(null===(n=e.errorOptions)||void 0===n?void 0:n.maxBreadcrumbs)||30}start(){window.addEventListener("error",e=>{this.handleError(e.error||e.message,{filename:e.filename,lineno:e.lineno,colno:e.colno})}),window.addEventListener("unhandledrejection",e=>{this.handleError(e.reason,{type:"unhandledrejection"})}),this.setupAutomaticBreadcrumbs()}captureError(e,t){this.handleError(e,t)}addBreadcrumb(e){const t={category:e.category,message:e.message,level:e.level||"info",timestamp:(new Date).toISOString(),data:e.data};this.breadcrumbs.push(t),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift(),this.config.debug&&console.log("[DevSkin] Breadcrumb added:",t)}handleError(e,t){var n;if(this.shouldIgnoreError(e))return;let o;if(e instanceof Error){if(o={message:e.message,stack:e.stack,type:e.name||"Error",timestamp:(new Date).toISOString(),session_id:"",url:window.location.href,breadcrumbs:[...this.breadcrumbs],context:Object.assign(Object.assign({},t),{userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight}})},e.stack){const t=e.stack.match(/:(\d+):(\d+)/);t&&(o.line=parseInt(t[1],10),o.column=parseInt(t[2],10))}}else o={message:String(e),type:"Error",timestamp:(new Date).toISOString(),session_id:"",url:window.location.href,breadcrumbs:[...this.breadcrumbs],context:t};(null===(n=this.config.errorOptions)||void 0===n?void 0:n.includeLocalVariables)&&t&&(o.context=Object.assign(Object.assign({},o.context),{localVariables:t})),this.config.debug&&console.log("[DevSkin] Error captured:",o),this.addBreadcrumb({category:"error",message:o.message,level:"error",data:{type:o.type,stack:o.stack}}),this.transport.sendError(o)}shouldIgnoreError(e){var t,n;const o=(null===(t=this.config.errorOptions)||void 0===t?void 0:t.ignoreErrors)||[],r=e instanceof Error?e.message:String(e);for(const e of o)if(e instanceof RegExp){if(e.test(r))return!0}else if("string"==typeof e&&r.includes(e))return!0;const s=(null===(n=this.config.errorOptions)||void 0===n?void 0:n.denyUrls)||[],i=e instanceof Error?e.stack:"";for(const e of s)if(e.test(i||""))return!0;return!1}setupAutomaticBreadcrumbs(){this.wrapConsole(),document.addEventListener("click",e=>{var t;const n=e.target;this.addBreadcrumb({category:"ui.click",message:`Clicked on ${n.tagName}`,data:{tagName:n.tagName,id:n.id,className:n.className,innerText:null===(t=n.innerText)||void 0===t?void 0:t.substring(0,100)}})},!0);let e=window.location.href;const t=()=>{e!==window.location.href&&(this.addBreadcrumb({category:"navigation",message:`Navigated to ${window.location.pathname}`,data:{from:e,to:window.location.href}}),e=window.location.href)};window.addEventListener("popstate",t),window.addEventListener("hashchange",t);const n=history.pushState;history.pushState=function(...e){n.apply(this,e),t()};const o=history.replaceState;history.replaceState=function(...e){o.apply(this,e),t()}}wrapConsole(){["log","info","warn","error"].forEach(e=>{const t=console[e];console[e]=(...n)=>{if(t.apply(console,n),"warn"===e||"error"===e){const t=n.map(e=>String(e)).join(" ");if(t.startsWith("[DevSkin]"))return;this.addBreadcrumb({category:"console",message:t,level:"warn"===e?"warning":"error",data:{arguments:n}})}}})}getBreadcrumbs(){return[...this.breadcrumbs]}}class z{constructor(e,t){this.config=e,this.transport=t}start(){this.interceptFetch(),this.interceptXHR()}interceptFetch(){if(!window.fetch)return;const e=window.fetch;window.fetch=(...n)=>t(this,void 0,void 0,function*(){var t,o,r;const[s,i]=n,a="string"==typeof s?s:s instanceof Request?s.url:s.toString(),l=(null==i?void 0:i.method)||"GET",c=Date.now();try{const s=yield e(...n),i=s.clone(),d=Date.now()-c;if(this.shouldIgnoreUrl(a))return s;if((null===(t=this.config.networkRequestOptions)||void 0===t?void 0:t.captureFailedOnly)&&s.ok)return s;const u={url:a,method:l,status:s.status,duration:d,size:yield this.getResponseSize(i),type:"fetch",timestamp:(new Date).toISOString(),failed:!s.ok};if((null===(o=this.config.networkRequestOptions)||void 0===o?void 0:o.captureHeaders)&&(u.headers=this.headersToObject(s.headers)),(null===(r=this.config.networkRequestOptions)||void 0===r?void 0:r.captureBody)&&!s.ok)try{const e=yield i.text();u.body=e.substring(0,1e4)}catch(e){}return this.config.debug&&console.log("[DevSkin] Network request tracked:",u),this.transport.sendNetworkRequest(u),s}catch(e){const t=Date.now()-c;if(!this.shouldIgnoreUrl(a)){const e={url:a,method:l,duration:t,type:"fetch",timestamp:(new Date).toISOString(),failed:!0};this.config.debug&&console.log("[DevSkin] Network request failed:",e),this.transport.sendNetworkRequest(e)}throw e}})}interceptXHR(){const e=XMLHttpRequest.prototype.open,t=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(t,n,o,r,s){return this.__devskin={method:t,url:n.toString(),startTime:Date.now()},void 0!==r?e.call(this,t,n,null==o||o,r,null!=s?s:void 0):void 0!==o?e.call(this,t,n,o):e.call(this,t,n,!0)},XMLHttpRequest.prototype.send=function(e){const n=this,o=n.__devskin;if(!o)return t.call(this,e);const r=window.__devskinNetworkCollector,s=()=>{const e=Date.now()-o.startTime;if(!(null==r?void 0:r.shouldIgnoreUrl(o.url))){const t={url:o.url,method:o.method,duration:e,type:"xhr",timestamp:(new Date).toISOString(),failed:!0};(null==r?void 0:r.config.debug)&&console.log("[DevSkin] XHR request failed:",t),null==r||r.transport.sendNetworkRequest(t)}};return n.addEventListener("load",()=>{var e,t,s,i;const a=Date.now()-o.startTime;if(null==r?void 0:r.shouldIgnoreUrl(o.url))return;if((null===(e=null==r?void 0:r.config.networkRequestOptions)||void 0===e?void 0:e.captureFailedOnly)&&n.status>=200&&n.status<400)return;const l={url:o.url,method:o.method,status:n.status,duration:a,type:"xhr",timestamp:(new Date).toISOString(),failed:0===n.status||n.status>=400};if((null===(t=null==r?void 0:r.config.networkRequestOptions)||void 0===t?void 0:t.captureHeaders)&&(l.headers=r.parseResponseHeaders(n.getAllResponseHeaders())),(null===(s=null==r?void 0:r.config.networkRequestOptions)||void 0===s?void 0:s.captureBody)&&l.failed)try{l.body=null===(i=n.responseText)||void 0===i?void 0:i.substring(0,1e4)}catch(e){}(null==r?void 0:r.config.debug)&&console.log("[DevSkin] XHR request tracked:",l),null==r||r.transport.sendNetworkRequest(l)}),n.addEventListener("error",s),n.addEventListener("abort",s),t.call(this,e)},window.__devskinNetworkCollector=this}shouldIgnoreUrl(e){var t;if(e.includes(this.config.apiUrl||""))return!0;const n=(null===(t=this.config.networkRequestOptions)||void 0===t?void 0:t.ignoreUrls)||[];for(const t of n)if(t.test(e))return!0;return!1}getResponseSize(e){return t(this,void 0,void 0,function*(){try{return(yield e.blob()).size}catch(e){return}})}headersToObject(e){const t={};return e.forEach((e,n)=>{t[n]=e}),t}parseResponseHeaders(e){const t={};if(!e)return t;return e.trim().split(/[\r\n]+/).forEach(e=>{const n=e.split(": "),o=n.shift(),r=n.join(": ");o&&(t[o]=r)}),t}}class q{constructor(e,t){this.config=e,this.transport=t,this.clickData=[],this.scrollData=[],this.mouseMoveData=[],this.maxScrollDepth=0,this.flushInterval=null,this.mouseMoveSampling=.1}start(){var e;(null===(e=this.config.heatmapOptions)||void 0===e?void 0:e.enabled)&&(this.config.debug&&console.log("[DevSkin] Starting heatmap collection"),!1!==this.config.heatmapOptions.trackClicks&&this.trackClicks(),!1!==this.config.heatmapOptions.trackScroll&&this.trackScrollDepth(),this.config.heatmapOptions.trackMouseMovement&&(this.mouseMoveSampling=this.config.heatmapOptions.mouseMoveSampling||.1,this.trackMouseMovement()),this.flushInterval=setInterval(()=>{this.flush()},1e4),window.addEventListener("beforeunload",()=>{this.flush()}))}stop(){this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null),this.flush()}trackClicks(){document.addEventListener("click",e=>{const t=e.target,n=t.getBoundingClientRect(),o=e.clientX-n.left,r=e.clientY-n.top,s=e.clientX+window.scrollX,i=e.clientY+window.scrollY,a={x:e.clientX,y:e.clientY,relativeX:o,relativeY:r,pageX:s,pageY:i,element:this.getElementSelector(t),elementId:t.id||void 0,elementClass:t.className||void 0,pageUrl:window.location.href,timestamp:(new Date).toISOString(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight};this.clickData.push(a),this.config.debug&&console.log("[DevSkin] Click tracked:",a),this.clickData.length>=50&&this.flush()},!0)}trackScrollDepth(){const e=()=>{const e=window.innerHeight,t=document.documentElement.scrollHeight,n=window.scrollY||document.documentElement.scrollTop,o=Math.round((n+e)/t*100);if(o>this.maxScrollDepth){this.maxScrollDepth=o;const n={depth:o,maxDepth:this.maxScrollDepth,pageHeight:t,viewportHeight:e,pageUrl:window.location.href,timestamp:(new Date).toISOString()};this.scrollData.push(n),this.config.debug&&console.log("[DevSkin] Scroll depth:",o+"%")}};let t=null;window.addEventListener("scroll",()=>{t&&clearTimeout(t),t=setTimeout(e,100)}),e()}trackMouseMovement(){let e=null;window.addEventListener("mousemove",t=>{if(Math.random()>this.mouseMoveSampling)return;if(e)return;e=setTimeout(()=>{e=null},100);const n={x:t.clientX+window.scrollX,y:t.clientY+window.scrollY,pageUrl:window.location.href,timestamp:(new Date).toISOString()};this.mouseMoveData.push(n),this.mouseMoveData.length>=100&&this.flush()})}flush(){this.clickData.length>0&&(this.transport.sendHeatmapData({type:"clicks",data:this.clickData}),this.clickData=[]),this.scrollData.length>0&&(this.transport.sendHeatmapData({type:"scroll",data:this.scrollData}),this.scrollData=[]),this.mouseMoveData.length>0&&(this.transport.sendHeatmapData({type:"mousemove",data:this.mouseMoveData}),this.mouseMoveData=[])}getElementSelector(e){if(e.id)return`#${e.id}`;if(e.className){const t=e.className.split(" ").filter(e=>e);if(t.length>0)return`${e.tagName.toLowerCase()}.${t.join(".")}`}return e.tagName.toLowerCase()}}function $(e){const t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function V(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function G(e){try{const n=e.rules||e.cssRules;return n?((t=Array.from(n,X).join("")).includes(" background-clip: text;")&&!t.includes(" -webkit-background-clip: text;")&&(t=t.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),t):null}catch(e){return null}var t}function X(e){let t;if(function(e){return"styleSheet"in e}(e))try{t=G(e.styleSheet)||function(e){const{cssText:t}=e;if(t.split('"').length<3)return t;const n=["@import",`url(${JSON.stringify(e.href)})`];return""===e.layerName?n.push("layer"):e.layerName&&n.push(`layer(${e.layerName})`),e.supportsText&&n.push(`supports(${e.supportsText})`),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}(e)}catch(e){}else if(function(e){return"selectorText"in e}(e)&&e.selectorText.includes(":"))return function(e){const t=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return e.replace(t,"$1\\$2")}(e.cssText);return t||e.cssText}!function(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"}(l||(l={}));class K{constructor(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}getId(e){var t;if(!e)return-1;const n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const t=this.getId(e);this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(e=>this.removeNodeFromMap(e))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){const n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)}replace(e,t){const n=this.getNode(e);if(n){const e=this.nodeMetaMap.get(n);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}}function Y({element:e,maskInputOptions:t,tagName:n,type:o,value:r,maskInputFn:s}){let i=r||"";const a=o&&J(o);return(t[n.toLowerCase()]||a&&t[a])&&(i=s?s(i,e):"*".repeat(i.length)),i}function J(e){return e.toLowerCase()}const Z="__rrweb_original__";function Q(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?J(t):null}function ee(e,t){var n;let o;try{o=new URL(e,null!=t?t:window.location.href)}catch(e){return null}const r=o.pathname.match(/\.([0-9a-z]+)(?:$)/i);return null!==(n=null==r?void 0:r[1])&&void 0!==n?n:null}let te=1;const ne=new RegExp("[^a-z0-9-_:]");function oe(){return te++}let re,se;const ie=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,ae=/^(?:[a-z+]+:)?\/\//i,le=/^www\..*/i,ce=/^(data:)([^,]*),(.*)/i;function de(e,t){return(e||"").replace(ie,(e,n,o,r,s,i)=>{const a=o||s||i,l=n||r||"";if(!a)return e;if(ae.test(a)||le.test(a))return`url(${l}${a}${l})`;if(ce.test(a))return`url(${l}${a}${l})`;if("/"===a[0])return`url(${l}${function(e){let t="";return t=e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0],t=t.split("?")[0],t}(t)+a}${l})`;const c=t.split("/"),d=a.split("/");c.pop();for(const e of d)"."!==e&&(".."===e?c.pop():c.push(e));return`url(${l}${c.join("/")}${l})`})}const ue=/^[^ \t\n\r\u000c]+/,he=/^[, \t\n\r\u000c]+/;function pe(e,t){if(!t||""===t.trim())return t;const n=e.createElement("a");return n.href=t,n.href}function me(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function fe(){const e=document.createElement("a");return e.href="",e.href}function ge(e,t,n,o){return o?"src"===n||"href"===n&&("use"!==t||"#"!==o[0])||"xlink:href"===n&&"#"!==o[0]?pe(e,o):"background"!==n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n?function(e,t){if(""===t.trim())return t;let n=0;function o(e){let o;const r=e.exec(t.substring(n));return r?(o=r[0],n+=o.length,o):""}const r=[];for(;o(he),!(n>=t.length);){let s=o(ue);if(","===s.slice(-1))s=pe(e,s.substring(0,s.length-1)),r.push(s);else{let o="";s=pe(e,s);let i=!1;for(;;){const e=t.charAt(n);if(""===e){r.push((s+o).trim());break}if(i)")"===e&&(i=!1);else{if(","===e){n+=1,r.push((s+o).trim());break}"("===e&&(i=!0)}o+=e,n+=1}}}return r.join(", ")}(e,o):"style"===n?de(o,fe()):"object"===t&&"data"===n?pe(e,o):o:pe(e,o):o}function ve(e,t,n){return("video"===e||"audio"===e)&&"autoplay"===t}function ye(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&ye(e.parentNode,t,n);for(let n=e.classList.length;n--;){const o=e.classList[n];if(t.test(o))return!0}return!!n&&ye(e.parentNode,t,n)}function Se(e,t,n,o){try{const r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===r)return!1;if("string"==typeof t){if(o){if(r.closest(`.${t}`))return!0}else if(r.classList.contains(t))return!0}else if(ye(r,t,o))return!0;if(n)if(o){if(r.closest(n))return!0}else if(r.matches(n))return!0}catch(e){}return!1}function we(e,t){const{doc:n,mirror:o,blockClass:r,blockSelector:s,needsMask:i,inlineStylesheet:a,maskInputOptions:c={},maskTextFn:d,maskInputFn:u,dataURLOptions:h={},inlineImages:p,recordCanvas:m,keepIframeSrcFn:f,newlyAddedElement:g=!1}=t,v=function(e,t){if(!t.hasNode(e))return;const n=t.getId(e);return 1===n?void 0:n}(n,o);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:l.Document,childNodes:[],compatMode:e.compatMode}:{type:l.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:l.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:v};case e.ELEMENT_NODE:return function(e,t){const{doc:n,blockClass:o,blockSelector:r,inlineStylesheet:s,maskInputOptions:i={},maskInputFn:a,dataURLOptions:c={},inlineImages:d,recordCanvas:u,keepIframeSrcFn:h,newlyAddedElement:p=!1,rootId:m}=t,f=function(e,t,n){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;){const o=e.classList[n];if(t.test(o))return!0}if(n)return e.matches(n)}catch(e){}return!1}(e,o,r),g=function(e){if(e instanceof HTMLFormElement)return"form";const t=J(e.tagName);return ne.test(t)?"div":t}(e);let v={};const y=e.attributes.length;for(let t=0;t<y;t++){const o=e.attributes[t];ve(g,o.name,o.value)||(v[o.name]=ge(n,g,J(o.name),o.value))}if("link"===g&&s){const t=Array.from(n.styleSheets).find(t=>t.href===e.href);let o=null;t&&(o=G(t)),o&&(delete v.rel,delete v.href,v._cssText=de(o,t.href))}if("style"===g&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){const t=G(e.sheet);t&&(v._cssText=de(t,fe()))}if("input"===g||"textarea"===g||"select"===g){const t=e.value,n=e.checked;"radio"!==v.type&&"checkbox"!==v.type&&"submit"!==v.type&&"button"!==v.type&&t?v.value=Y({element:e,type:Q(e),tagName:g,value:t,maskInputOptions:i,maskInputFn:a}):n&&(v.checked=n)}"option"===g&&(e.selected&&!i.select?v.selected=!0:delete v.selected);if("canvas"===g&&u)if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let n=0;n<e.width;n+=50)for(let o=0;o<e.height;o+=50){const r=t.getImageData,s=Z in r?r[Z]:r;if(new Uint32Array(s.call(t,n,o,Math.min(50,e.width-n),Math.min(50,e.height-o)).data.buffer).some(e=>0!==e))return!1}return!0})(e)||(v.rr_dataURL=e.toDataURL(c.type,c.quality));else if(!("__context"in e)){const t=e.toDataURL(c.type,c.quality),n=document.createElement("canvas");n.width=e.width,n.height=e.height;t!==n.toDataURL(c.type,c.quality)&&(v.rr_dataURL=t)}if("img"===g&&d){re||(re=n.createElement("canvas"),se=re.getContext("2d"));const t=e,o=t.crossOrigin;t.crossOrigin="anonymous";const r=()=>{t.removeEventListener("load",r);try{re.width=t.naturalWidth,re.height=t.naturalHeight,se.drawImage(t,0,0),v.rr_dataURL=re.toDataURL(c.type,c.quality)}catch(e){console.warn(`Cannot inline img src=${t.currentSrc}! Error: ${e}`)}o?v.crossOrigin=o:t.removeAttribute("crossorigin")};t.complete&&0!==t.naturalWidth?r():t.addEventListener("load",r)}if("audio"===g||"video"===g){const t=v;t.rr_mediaState=e.paused?"paused":"played",t.rr_mediaCurrentTime=e.currentTime,t.rr_mediaPlaybackRate=e.playbackRate,t.rr_mediaMuted=e.muted,t.rr_mediaLoop=e.loop,t.rr_mediaVolume=e.volume}p||(e.scrollLeft&&(v.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(v.rr_scrollTop=e.scrollTop));if(f){const{width:t,height:n}=e.getBoundingClientRect();v={class:v.class,rr_width:`${t}px`,rr_height:`${n}px`}}"iframe"!==g||h(v.src)||(e.contentDocument||(v.rr_src=v.src),delete v.src);let S;try{customElements.get(g)&&(S=!0)}catch(e){}return{type:l.Element,tagName:g,attributes:v,childNodes:[],isSVG:me(e)||void 0,needBlock:f,rootId:m,isCustom:S}}(e,{doc:n,blockClass:r,blockSelector:s,inlineStylesheet:a,maskInputOptions:c,maskInputFn:u,dataURLOptions:h,inlineImages:p,recordCanvas:m,keepIframeSrcFn:f,newlyAddedElement:g,rootId:v});case e.TEXT_NODE:return function(e,t){var n;const{needsMask:o,maskTextFn:r,rootId:s}=t,i=e.parentNode&&e.parentNode.tagName;let a=e.textContent;const c="STYLE"===i||void 0,d="SCRIPT"===i||void 0;if(c&&a){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(a=G(e.parentNode.sheet))}catch(t){console.warn(`Cannot get CSS styles from text's parentNode. Error: ${t}`,e)}a=de(a,fe())}d&&(a="SCRIPT_PLACEHOLDER");!c&&!d&&a&&o&&(a=r?r(a,e.parentElement):a.replace(/[\S]/g,"*"));return{type:l.Text,textContent:a||"",isStyle:c,rootId:s}}(e,{needsMask:i,maskTextFn:d,rootId:v});case e.CDATA_SECTION_NODE:return{type:l.CDATA,textContent:"",rootId:v};case e.COMMENT_NODE:return{type:l.Comment,textContent:e.textContent||"",rootId:v};default:return!1}}function be(e){return null==e?"":e.toLowerCase()}function ke(e,t){const{doc:n,mirror:o,blockClass:r,blockSelector:s,maskTextClass:i,maskTextSelector:a,skipChild:c=!1,inlineStylesheet:d=!0,maskInputOptions:u={},maskTextFn:h,maskInputFn:p,slimDOMOptions:m,dataURLOptions:f={},inlineImages:g=!1,recordCanvas:v=!1,onSerialize:y,onIframeLoad:S,iframeLoadTimeout:w=5e3,onStylesheetLoad:b,stylesheetLoadTimeout:k=5e3,keepIframeSrcFn:I=()=>!1,newlyAddedElement:C=!1}=t;let{needsMask:M}=t,{preserveWhiteSpace:T=!0}=t;if(!M&&e.childNodes){M=Se(e,i,a,void 0===M)}const E=we(e,{doc:n,mirror:o,blockClass:r,blockSelector:s,needsMask:M,inlineStylesheet:d,maskInputOptions:u,maskTextFn:h,maskInputFn:p,dataURLOptions:f,inlineImages:g,recordCanvas:v,keepIframeSrcFn:I,newlyAddedElement:C});if(!E)return console.warn(e,"not serialized"),null;let O;O=o.hasNode(e)?o.getId(e):!function(e,t){if(t.comment&&e.type===l.Comment)return!0;if(e.type===l.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel||"modulepreload"===e.attributes.rel)&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&"js"===ee(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(be(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===be(e.attributes.name)||"icon"===be(e.attributes.rel)||"apple-touch-icon"===be(e.attributes.rel)||"shortcut icon"===be(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&be(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(be(e.attributes.property).match(/^(og|twitter|fb):/)||be(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===be(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===be(e.attributes.name)||"googlebot"===be(e.attributes.name)||"bingbot"===be(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===be(e.attributes.name)||"generator"===be(e.attributes.name)||"framework"===be(e.attributes.name)||"publisher"===be(e.attributes.name)||"progid"===be(e.attributes.name)||be(e.attributes.property).match(/^article:/)||be(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===be(e.attributes.name)||"yandex-verification"===be(e.attributes.name)||"csrf-token"===be(e.attributes.name)||"p:domain_verify"===be(e.attributes.name)||"verify-v1"===be(e.attributes.name)||"verification"===be(e.attributes.name)||"shopify-checkout-api-token"===be(e.attributes.name)))return!0}}return!1}(E,m)&&(T||E.type!==l.Text||E.isStyle||E.textContent.replace(/^\s+|\s+$/gm,"").length)?oe():-2;const D=Object.assign(E,{id:O});if(o.add(e,D),-2===O)return null;y&&y(e);let R=!c;if(D.type===l.Element){R=R&&!D.needBlock,delete D.needBlock;const t=e.shadowRoot;t&&V(t)&&(D.isShadowHost=!0)}if((D.type===l.Document||D.type===l.Element)&&R){m.headWhitespace&&D.type===l.Element&&"head"===D.tagName&&(T=!1);const t={doc:n,mirror:o,blockClass:r,blockSelector:s,needsMask:M,maskTextClass:i,maskTextSelector:a,skipChild:c,inlineStylesheet:d,maskInputOptions:u,maskTextFn:h,maskInputFn:p,slimDOMOptions:m,dataURLOptions:f,inlineImages:g,recordCanvas:v,preserveWhiteSpace:T,onSerialize:y,onIframeLoad:S,iframeLoadTimeout:w,onStylesheetLoad:b,stylesheetLoadTimeout:k,keepIframeSrcFn:I};if(D.type===l.Element&&"textarea"===D.tagName&&void 0!==D.attributes.value);else for(const n of Array.from(e.childNodes)){const e=ke(n,t);e&&D.childNodes.push(e)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(const n of Array.from(e.shadowRoot.childNodes)){const o=ke(n,t);o&&(V(e.shadowRoot)&&(o.isShadow=!0),D.childNodes.push(o))}}return e.parentNode&&$(e.parentNode)&&V(e.parentNode)&&(D.isShadow=!0),D.type===l.Element&&"iframe"===D.tagName&&function(e,t,n){const o=e.contentWindow;if(!o)return;let r,s=!1;try{r=o.document.readyState}catch(e){return}if("complete"!==r){const o=setTimeout(()=>{s||(t(),s=!0)},n);return void e.addEventListener("load",()=>{clearTimeout(o),s=!0,t()})}const i="about:blank";if(o.location.href!==i||e.src===i||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}(e,()=>{const t=e.contentDocument;if(t&&S){const n=ke(t,{doc:t,mirror:o,blockClass:r,blockSelector:s,needsMask:M,maskTextClass:i,maskTextSelector:a,skipChild:!1,inlineStylesheet:d,maskInputOptions:u,maskTextFn:h,maskInputFn:p,slimDOMOptions:m,dataURLOptions:f,inlineImages:g,recordCanvas:v,preserveWhiteSpace:T,onSerialize:y,onIframeLoad:S,iframeLoadTimeout:w,onStylesheetLoad:b,stylesheetLoadTimeout:k,keepIframeSrcFn:I});n&&S(e,n)}},w),D.type===l.Element&&"link"===D.tagName&&"string"==typeof D.attributes.rel&&("stylesheet"===D.attributes.rel||"preload"===D.attributes.rel&&"string"==typeof D.attributes.href&&"css"===ee(D.attributes.href))&&function(e,t,n){let o,r=!1;try{o=e.sheet}catch(e){return}if(o)return;const s=setTimeout(()=>{r||(t(),r=!0)},n);e.addEventListener("load",()=>{clearTimeout(s),r=!0,t()})}(e,()=>{if(b){const t=ke(e,{doc:n,mirror:o,blockClass:r,blockSelector:s,needsMask:M,maskTextClass:i,maskTextSelector:a,skipChild:!1,inlineStylesheet:d,maskInputOptions:u,maskTextFn:h,maskInputFn:p,slimDOMOptions:m,dataURLOptions:f,inlineImages:g,recordCanvas:v,preserveWhiteSpace:T,onSerialize:y,onIframeLoad:S,iframeLoadTimeout:w,onStylesheetLoad:b,stylesheetLoadTimeout:k,keepIframeSrcFn:I});t&&b(e,t)}},k),D}function Ie(e,t,n=document){const o={capture:!0,passive:!0};return n.addEventListener(e,t,o),()=>n.removeEventListener(e,t,o)}const Ce="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let Me={map:{},getId:()=>(console.error(Ce),-1),getNode:()=>(console.error(Ce),null),removeNodeFromMap(){console.error(Ce)},has:()=>(console.error(Ce),!1),reset(){console.error(Ce)}};function Te(e,t,n={}){let o=null,r=0;return function(...s){const i=Date.now();r||!1!==n.leading||(r=i);const a=t-(i-r),l=this;a<=0||a>t?(o&&(clearTimeout(o),o=null),r=i,e.apply(l,s)):o||!1===n.trailing||(o=setTimeout(()=>{r=!1===n.leading?0:Date.now(),o=null,e.apply(l,s)},a))}}function Ee(e,t,n,o,r=window){const s=r.Object.getOwnPropertyDescriptor(e,t);return r.Object.defineProperty(e,t,o?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),s&&s.set&&s.set.call(this,e)}}),()=>Ee(e,t,s||{},!0)}function Oe(e,t,n){try{if(!(t in e))return()=>{};const o=e[t],r=n(o);return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:o}})),e[t]=r,()=>{e[t]=o}}catch(e){return()=>{}}}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Me=new Proxy(Me,{get:(e,t,n)=>("map"===t&&console.error(Ce),Reflect.get(e,t,n))}));let De=Date.now;function Re(e){var t,n,o,r,s,i;const a=e.document;return{left:a.scrollingElement?a.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:(null==a?void 0:a.documentElement.scrollLeft)||(null===(n=null===(t=null==a?void 0:a.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(o=null==a?void 0:a.body)||void 0===o?void 0:o.scrollLeft)||0,top:a.scrollingElement?a.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==a?void 0:a.documentElement.scrollTop)||(null===(s=null===(r=null==a?void 0:a.body)||void 0===r?void 0:r.parentElement)||void 0===s?void 0:s.scrollTop)||(null===(i=null==a?void 0:a.body)||void 0===i?void 0:i.scrollTop)||0}}function xe(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Le(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Ne(e){if(!e)return null;return e.nodeType===e.ELEMENT_NODE?e:e.parentElement}function Fe(e,t,n,o){if(!e)return!1;const r=Ne(e);if(!r)return!1;try{if("string"==typeof t){if(r.classList.contains(t))return!0;if(o&&null!==r.closest("."+t))return!0}else if(ye(r,t,o))return!0}catch(e){}if(n){if(r.matches(n))return!0;if(o&&null!==r.closest(n))return!0}return!1}function Ae(e,t){return-2===t.getId(e)}function _e(e,t){if($(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||_e(e.parentNode,t))}function Pe(e){return Boolean(e.changedTouches)}function We(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function je(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function Ue(e){return Boolean(null==e?void 0:e.shadowRoot)}/[1-9][0-9]{12}/.test(Date.now().toString())||(De=()=>(new Date).getTime());class Be{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function He(e){var t,n;let o=null;return(null===(n=null===(t=e.getRootNode)||void 0===t?void 0:t.call(e))||void 0===n?void 0:n.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&e.getRootNode().host&&(o=e.getRootNode().host),o}function ze(e){const t=e.ownerDocument;if(!t)return!1;const n=function(e){let t,n=e;for(;t=He(n);)n=t;return n}(e);return t.contains(n)}function qe(e){const t=e.ownerDocument;return!!t&&(t.contains(e)||ze(e))}var $e=(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))($e||{}),Ve=(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))(Ve||{}),Ge=(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))(Ge||{}),Xe=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Xe||{}),Ke=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(Ke||{});function Ye(e){return"__ln"in e}class Je{constructor(){this.length=0,this.head=null,this.tail=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&Ye(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&Ye(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}}const Ze=(e,t)=>`${e}@${t}`;class Qe{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],t=new Set,n=new Je,o=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},r=r=>{if(!r.parentNode||!qe(r)||"TEXTAREA"===r.parentNode.tagName)return;const s=$(r.parentNode)?this.mirror.getId(He(r)):this.mirror.getId(r.parentNode),i=o(r);if(-1===s||-1===i)return n.addNode(r);const a=ke(r,{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,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{We(e,this.mirror)&&this.iframeManager.addIframe(e),je(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),Ue(r)&&this.shadowDomManager.addShadowRoot(r.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});a&&(e.push({parentId:s,nextId:i,node:a}),t.add(a.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of this.movedSet)tt(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||r(e);for(const e of this.addedSet)ot(this.droppedSet,e)||tt(this.removes,e,this.mirror)?ot(this.movedSet,e)?r(e):this.droppedSet.add(e):r(e);let s=null;for(;n.length;){let e=null;if(s){const t=this.mirror.getId(s.value.parentNode),n=o(s.value);-1!==t&&-1!==n&&(e=s)}if(!e){let t=n.tail;for(;t;){const n=t;if(t=t.previous,n){const t=this.mirror.getId(n.value.parentNode);if(-1===o(n.value))continue;if(-1!==t){e=n;break}{const t=n.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const o=t.parentNode.host;if(-1!==this.mirror.getId(o)){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}s=e.previous,n.removeNode(e.value),r(e.value)}const i={texts:this.texts.map(e=>{const t=e.node;return t.parentNode&&"TEXTAREA"===t.parentNode.tagName&&this.genTextAreaValueMutation(t.parentNode),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>{const{attributes:t}=e;if("string"==typeof t.style){const n=JSON.stringify(e.styleDiff),o=JSON.stringify(e._unchangedStyles);n.length<t.style.length&&(n+o).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};(i.texts.length||i.attributes.length||i.removes.length||i.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(i))},this.genTextAreaValueMutation=e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t)),t.attributes.value=Array.from(e.childNodes,e=>e.textContent||"").join("")},this.processMutation=e=>{if(!Ae(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;Fe(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:Se(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,Ne(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.attributeName,o=e.target.getAttribute(n);if("value"===n){const e=Q(t);o=Y({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:e,value:o,maskInputFn:this.maskInputFn})}if(Fe(e.target,this.blockClass,this.blockSelector,!1)||o===e.oldValue)return;let r=this.attributeMap.get(e.target);if("IFRAME"===t.tagName&&"src"===n&&!this.keepIframeSrcFn(o)){if(t.contentDocument)return;n="rr_src"}if(r||(r={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(r),this.attributeMap.set(e.target,r)),"type"===n&&"INPUT"===t.tagName&&"password"===(e.oldValue||"").toLowerCase()&&t.setAttribute("data-rr-is-password","true"),!ve(t.tagName,n)&&(r.attributes[n]=ge(this.doc,J(t.tagName),J(n),o),"style"===n)){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(e){this.unattachedDoc=this.doc}const n=this.unattachedDoc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue);for(const e of Array.from(t.style)){const o=t.style.getPropertyValue(e),s=t.style.getPropertyPriority(e);o!==n.style.getPropertyValue(e)||s!==n.style.getPropertyPriority(e)?r.styleDiff[e]=""===s?o:[o,s]:r._unchangedStyles[e]=[o,s]}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(r.styleDiff[e]=!1)}break}case"childList":if(Fe(e.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const n=this.mirror.getId(t),o=$(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);Fe(e.target,this.blockClass,this.blockSelector,!1)||Ae(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(et(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||_e(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Ze(n,o)]?et(this.movedSet,t):this.removes.push({parentId:o,id:n,isShadow:!(!$(e.target)||!V(e.target))||void 0})),this.mapRemoves.push(t))})}},this.genAdds=(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(Ae(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[Ze(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);Fe(e,this.blockClass,this.blockSelector,!1)||(e.childNodes.forEach(e=>this.genAdds(e)),Ue(e)&&e.shadowRoot.childNodes.forEach(t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)}))}}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(t=>{this[t]=e[t]})}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 et(e,t){e.delete(t),t.childNodes.forEach(t=>et(e,t))}function tt(e,t,n){return 0!==e.length&&nt(e,t,n)}function nt(e,t,n){const{parentNode:o}=t;if(!o)return!1;const r=n.getId(o);return!!e.some(e=>e.id===r)||nt(e,o,n)}function ot(e,t){return 0!==e.size&&rt(e,t)}function rt(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||rt(e,n))}let st;function it(e){st=e}function at(){st=void 0}const lt=e=>{if(!st)return e;return(...t)=>{try{return e(...t)}catch(e){if(st&&!0===st(e))return;throw e}}},ct=[];function dt(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch(e){}return e&&e.target}function ut(e,t){var n,o;const r=new Qe;ct.push(r),r.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=null===(o=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===o?void 0:o.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const a=new s(lt(r.processMutations.bind(r)));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function ht({mouseInteractionCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];let l=null;return Object.keys(Ge).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e]).forEach(s=>{let i=J(s);const c=(t=>s=>{const i=dt(s);if(Fe(i,o,r,!0))return;let a=null,c=t;if("pointerType"in s){switch(s.pointerType){case"mouse":a=Xe.Mouse;break;case"touch":a=Xe.Touch;break;case"pen":a=Xe.Pen}a===Xe.Touch?Ge[t]===Ge.MouseDown?c="TouchStart":Ge[t]===Ge.MouseUp&&(c="TouchEnd"):Xe.Pen}else Pe(s)&&(a=Xe.Touch);null!==a?(l=a,(c.startsWith("Touch")&&a===Xe.Touch||c.startsWith("Mouse")&&a===Xe.Mouse)&&(a=null)):Ge[t]===Ge.Click&&(a=l,l=null);const d=Pe(s)?s.changedTouches[0]:s;if(!d)return;const u=n.getId(i),{clientX:h,clientY:p}=d;lt(e)(Object.assign({type:Ge[c],id:u,x:h,y:p},null!==a&&{pointerType:a}))})(s);if(window.PointerEvent)switch(Ge[s]){case Ge.MouseDown:case Ge.MouseUp:i=i.replace("mouse","pointer");break;case Ge.TouchStart:case Ge.TouchEnd:return}a.push(Ie(i,c,t))}),lt(()=>{a.forEach(e=>e())})}function pt({scrollCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:s}){return Ie("scroll",lt(Te(lt(s=>{const i=dt(s);if(!i||Fe(i,o,r,!0))return;const a=n.getId(i);if(i===t&&t.defaultView){const n=Re(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})}),s.scroll||100)),t)}const mt=["INPUT","TEXTAREA","SELECT"],ft=new WeakMap;function gt(e){return function(e,t){if(wt("CSSGroupingRule")&&e.parentRule instanceof CSSGroupingRule||wt("CSSMediaRule")&&e.parentRule instanceof CSSMediaRule||wt("CSSSupportsRule")&&e.parentRule instanceof CSSSupportsRule||wt("CSSConditionRule")&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function vt(e,t,n){let o,r;return e?(e.ownerNode?o=t.getId(e.ownerNode):r=n.getId(e),{styleId:r,id:o}):{}}function yt({mirror:e,stylesheetManager:t},n){var o,r,s;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(o=n.defaultView)||void 0===o?void 0:o.Document:null===(s=null===(r=n.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===s?void 0:s.ShadowRoot,l=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==i&&-1!==i&&a&&l?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var e;return null===(e=l.get)||void 0===e?void 0:e.call(this)},set(e){var n;const o=null===(n=l.set)||void 0===n?void 0:n.call(this,e);if(null!==i&&-1!==i)try{t.adoptStyleSheets(e,i)}catch(e){}return o}}),lt(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})})):()=>{}}function St(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let o;!function(e,t){const{mutationCb:n,mousemoveCb:o,mouseInteractionCb:r,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:p,customElementCb:m}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),o(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),r(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),s(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),i(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),l(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),c(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)},e.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),m(...e)}}(e,t),e.recordDOM&&(o=ut(e,e.doc));const r=function({mousemoveCb:e,sampling:t,doc:n,mirror:o}){if(!1===t.mousemove)return()=>{};const r="number"==typeof t.mousemove?t.mousemove:50,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const l=Te(lt(t=>{const n=Date.now()-i;e(a.map(e=>(e.timeOffset-=n,e)),t),a=[],i=null}),s),c=lt(Te(lt(e=>{const t=dt(e),{clientX:n,clientY:r}=Pe(e)?e.changedTouches[0]:e;i||(i=De()),a.push({x:n,y:r,id:o.getId(t),timeOffset:De()-i}),l("undefined"!=typeof DragEvent&&e instanceof DragEvent?Ve.Drag:e instanceof MouseEvent?Ve.MouseMove:Ve.TouchMove)}),r,{trailing:!1})),d=[Ie("mousemove",c,n),Ie("touchmove",c,n),Ie("drag",c,n)];return lt(()=>{d.forEach(e=>e())})}(e),s=ht(e),i=pt(e),a=function({viewportResizeCb:e},{win:t}){let n=-1,o=-1;return Ie("resize",lt(Te(lt(()=>{const t=xe(),r=Le();n===t&&o===r||(e({width:Number(r),height:Number(t)}),n=t,o=r)}),200)),t)}(e,{win:n}),l=function({inputCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,ignoreClass:s,ignoreSelector:i,maskInputOptions:a,maskInputFn:l,sampling:c,userTriggeredOnInput:d}){function u(e){let n=dt(e);const c=e.isTrusted,u=n&&n.tagName;if(n&&"OPTION"===u&&(n=n.parentElement),!n||!u||mt.indexOf(u)<0||Fe(n,o,r,!0))return;if(n.classList.contains(s)||i&&n.matches(i))return;let p=n.value,m=!1;const f=Q(n)||"";"radio"===f||"checkbox"===f?m=n.checked:(a[u.toLowerCase()]||a[f])&&(p=Y({element:n,maskInputOptions:a,tagName:u,type:f,value:p,maskInputFn:l})),h(n,d?{text:p,isChecked:m,userTriggered:c}:{text:p,isChecked:m});const g=n.name;"radio"===f&&g&&m&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach(e=>{if(e!==n){const t=e.value;h(e,d?{text:t,isChecked:!m,userTriggered:!1}:{text:t,isChecked:!m})}})}function h(t,o){const r=ft.get(t);if(!r||r.text!==o.text||r.isChecked!==o.isChecked){ft.set(t,o);const r=n.getId(t);lt(e)(Object.assign(Object.assign({},o),{id:r}))}}const p=("last"===c.input?["change"]:["input","change"]).map(e=>Ie(e,lt(u),t)),m=t.defaultView;if(!m)return()=>{p.forEach(e=>e())};const f=m.Object.getOwnPropertyDescriptor(m.HTMLInputElement.prototype,"value"),g=[[m.HTMLInputElement.prototype,"value"],[m.HTMLInputElement.prototype,"checked"],[m.HTMLSelectElement.prototype,"value"],[m.HTMLTextAreaElement.prototype,"value"],[m.HTMLSelectElement.prototype,"selectedIndex"],[m.HTMLOptionElement.prototype,"selected"]];return f&&f.set&&p.push(...g.map(e=>Ee(e[0],e[1],{set(){lt(u)({target:this,isTrusted:!1})}},!1,m))),lt(()=>{p.forEach(e=>e())})}(e),c=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:o,sampling:r,doc:s}){const i=lt(s=>Te(lt(r=>{const i=dt(r);if(!i||Fe(i,t,n,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:d,loop:u}=i;e({type:s,id:o.getId(i),currentTime:a,volume:l,muted:c,playbackRate:d,loop:u})}),r.media||500)),a=[Ie("play",i(0),s),Ie("pause",i(1),s),Ie("seeked",i(2),s),Ie("volumechange",i(3),s),Ie("ratechange",i(4),s)];return lt(()=>{a.forEach(e=>e())})}(e);let d=()=>{},u=()=>{},h=()=>{},p=()=>{};e.recordDOM&&(d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:o}){if(!o.CSSStyleSheet||!o.CSSStyleSheet.prototype)return()=>{};const r=o.CSSStyleSheet.prototype.insertRule;o.CSSStyleSheet.prototype.insertRule=new Proxy(r,{apply:lt((o,r,s)=>{const[i,a]=s,{id:l,styleId:c}=vt(r,t,n.styleMirror);return(l&&-1!==l||c&&-1!==c)&&e({id:l,styleId:c,adds:[{rule:i,index:a}]}),o.apply(r,s)})});const s=o.CSSStyleSheet.prototype.deleteRule;let i,a;o.CSSStyleSheet.prototype.deleteRule=new Proxy(s,{apply:lt((o,r,s)=>{const[i]=s,{id:a,styleId:l}=vt(r,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,removes:[{index:i}]}),o.apply(r,s)})}),o.CSSStyleSheet.prototype.replace&&(i=o.CSSStyleSheet.prototype.replace,o.CSSStyleSheet.prototype.replace=new Proxy(i,{apply:lt((o,r,s)=>{const[i]=s,{id:a,styleId:l}=vt(r,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,replace:i}),o.apply(r,s)})})),o.CSSStyleSheet.prototype.replaceSync&&(a=o.CSSStyleSheet.prototype.replaceSync,o.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:lt((o,r,s)=>{const[i]=s,{id:a,styleId:l}=vt(r,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,replaceSync:i}),o.apply(r,s)})}));const l={};bt("CSSGroupingRule")?l.CSSGroupingRule=o.CSSGroupingRule:(bt("CSSMediaRule")&&(l.CSSMediaRule=o.CSSMediaRule),bt("CSSConditionRule")&&(l.CSSConditionRule=o.CSSConditionRule),bt("CSSSupportsRule")&&(l.CSSSupportsRule=o.CSSSupportsRule));const c={};return Object.entries(l).forEach(([o,r])=>{c[o]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=new Proxy(c[o].insertRule,{apply:lt((o,r,s)=>{const[i,a]=s,{id:l,styleId:c}=vt(r.parentStyleSheet,t,n.styleMirror);return(l&&-1!==l||c&&-1!==c)&&e({id:l,styleId:c,adds:[{rule:i,index:[...gt(r),a||0]}]}),o.apply(r,s)})}),r.prototype.deleteRule=new Proxy(c[o].deleteRule,{apply:lt((o,r,s)=>{const[i]=s,{id:a,styleId:l}=vt(r.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,removes:[{index:[...gt(r),i]}]}),o.apply(r,s)})})}),lt(()=>{o.CSSStyleSheet.prototype.insertRule=r,o.CSSStyleSheet.prototype.deleteRule=s,i&&(o.CSSStyleSheet.prototype.replace=i),a&&(o.CSSStyleSheet.prototype.replaceSync=a),Object.entries(l).forEach(([e,t])=>{t.prototype.insertRule=c[e].insertRule,t.prototype.deleteRule=c[e].deleteRule})})}(e,{win:n}),u=yt(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:o},{win:r}){const s=r.CSSStyleDeclaration.prototype.setProperty;r.CSSStyleDeclaration.prototype.setProperty=new Proxy(s,{apply:lt((r,i,a)=>{var l;const[c,d,u]=a;if(n.has(c))return s.apply(i,[c,d,u]);const{id:h,styleId:p}=vt(null===(l=i.parentRule)||void 0===l?void 0:l.parentStyleSheet,t,o.styleMirror);return(h&&-1!==h||p&&-1!==p)&&e({id:h,styleId:p,set:{property:c,value:d,priority:u},index:gt(i.parentRule)}),r.apply(i,a)})});const i=r.CSSStyleDeclaration.prototype.removeProperty;return r.CSSStyleDeclaration.prototype.removeProperty=new Proxy(i,{apply:lt((r,s,a)=>{var l;const[c]=a;if(n.has(c))return i.apply(s,[c]);const{id:d,styleId:u}=vt(null===(l=s.parentRule)||void 0===l?void 0:l.parentStyleSheet,t,o.styleMirror);return(d&&-1!==d||u&&-1!==u)&&e({id:d,styleId:u,remove:{property:c},index:gt(s.parentRule)}),r.apply(s,a)})}),lt(()=>{r.CSSStyleDeclaration.prototype.setProperty=s,r.CSSStyleDeclaration.prototype.removeProperty=i})}(e,{win:n}),e.collectFonts&&(p=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const o=[],r=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const o=new s(e,t,n);return r.set(o,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),o};const i=Oe(t.fonts,"add",function(t){return function(n){return setTimeout(lt(()=>{const t=r.get(n);t&&(e(t),r.delete(n))}),0),t.apply(this,[n])}});return o.push(()=>{n.FontFace=s}),o.push(i),lt(()=>{o.forEach(e=>e())})}(e)));const m=function(e){const{doc:t,mirror:n,blockClass:o,blockSelector:r,selectionCb:s}=e;let i=!0;const a=lt(()=>{const e=t.getSelection();if(!e||i&&(null==e?void 0:e.isCollapsed))return;i=e.isCollapsed||!1;const a=[],l=e.rangeCount||0;for(let t=0;t<l;t++){const s=e.getRangeAt(t),{startContainer:i,startOffset:l,endContainer:c,endOffset:d}=s;Fe(i,o,r,!0)||Fe(c,o,r,!0)||a.push({start:n.getId(i),startOffset:l,end:n.getId(c),endOffset:d})}s({ranges:a})});return a(),Ie("selectionchange",a)}(e),f=function({doc:e,customElementCb:t}){const n=e.defaultView;return n&&n.customElements?Oe(n.customElements,"define",function(e){return function(n,o,r){try{t({define:{name:n}})}catch(e){console.warn(`Custom element callback failed for ${n}`)}return e.apply(this,[n,o,r])}}):()=>{}}(e),g=[];for(const t of e.plugins)g.push(t.observer(t.callback,n,t.options));return lt(()=>{ct.forEach(e=>e.reset()),null==o||o.disconnect(),r(),s(),i(),a(),l(),c(),d(),u(),h(),p(),m(),f(),g.forEach(e=>e())})}function wt(e){return void 0!==window[e]}function bt(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}class kt{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,o){const r=n||this.getIdToRemoteIdMap(e),s=o||this.getRemoteIdToIdMap(e);let i=r.get(t);return i||(i=this.generateIdFn(),r.set(t,i),s.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),o=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,o))}getRemoteId(e,t,n){const o=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const r=o.get(t);return r||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map(t=>this.getRemoteId(e,t,n))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class It{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new kt(oe),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new kt(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const n=this.crossOriginIframeMap.get(e.source);if(!n)return;const o=this.transformCrossOriginEvent(n,t.data.event);o&&this.wrappedEmit(o,t.data.isCheckout)}transformCrossOriginEvent(e,t){var n;switch(t.type){case $e.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const n=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,n),this.patchRootIdOnNode(t.data.node,n),{timestamp:t.timestamp,type:$e.IncrementalSnapshot,data:{source:Ve.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case $e.Meta:case $e.Load:case $e.DomContentLoaded:return!1;case $e.Plugin:return t;case $e.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case $e.IncrementalSnapshot:switch(t.data.source){case Ve.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const n=this.crossOriginIframeRootIdMap.get(e);n&&this.patchRootIdOnNode(t.node,n)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,["parentId","id"])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,["id"])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case Ve.Drag:case Ve.TouchMove:case Ve.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case Ve.ViewportResize:return!1;case Ve.MediaInteraction:case Ve.MouseInteraction:case Ve.Scroll:case Ve.CanvasMutation:case Ve.Input:return this.replaceIds(t.data,e,["id"]),t;case Ve.StyleSheetRule:case Ve.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case Ve.Font:return t;case Ve.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case Ve.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(n=t.data.styles)||void 0===n||n.forEach(t=>{this.replaceStyleIds(t,e,["styleId"])}),t}}return!1}replace(e,t,n,o){for(const r of o)(Array.isArray(t[r])||"number"==typeof t[r])&&(Array.isArray(t[r])?t[r]=e.getIds(n,t[r]):t[r]=e.getId(n,t[r]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}patchRootIdOnNode(e,t){e.type===l.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}}class Ct{constructor(e){this.shadowDoms=new WeakSet,this.restoreHandlers=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){if(!V(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const n=ut(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(pt(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),this.restoreHandlers.push(yt({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))},0)}observeAttachShadow(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){const n=this;this.restoreHandlers.push(Oe(e.prototype,"attachShadow",function(e){return function(o){const r=e.call(this,o);return this.shadowRoot&&qe(this)&&n.addShadowRoot(this.shadowRoot,t),r}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch(e){}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */function Mt(e,t,n,o){return new(n||(n=Promise))(function(t,r){function s(e){try{a(o.next(e))}catch(e){r(e)}}function i(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var o;e.done?t(e.value):(o=e.value,o instanceof n?o:new n(function(e){e(o)})).then(s,i)}a((o=o.apply(e,[])).next())})}for(var
|
|
15
|
+
***************************************************************************** */function Mt(e,t,n,o){return new(n||(n=Promise))(function(t,r){function s(e){try{a(o.next(e))}catch(e){r(e)}}function i(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var o;e.done?t(e.value):(o=e.value,o instanceof n?o:new n(function(e){e(o)})).then(s,i)}a((o=o.apply(e,[])).next())})}for(var Tt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Et="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Ot=0;Ot<64;Ot++)Et[Tt.charCodeAt(Ot)]=Ot;const Dt=new Map;const Rt=(e,t,n)=>{if(!e||!Nt(e,t)&&"object"!=typeof e)return;const o=function(e,t){let n=Dt.get(e);return n||(n=new Map,Dt.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let r=o.indexOf(e);return-1===r&&(r=o.length,o.push(e)),r};function xt(e,t,n){if(e instanceof Array)return e.map(e=>xt(e,t,n));if(null===e)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){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),o=n.length,r="";for(t=0;t<o;t+=3)r+=Tt[n[t]>>2],r+=Tt[(3&n[t])<<4|n[t+1]>>4],r+=Tt[(15&n[t+1])<<2|n[t+2]>>6],r+=Tt[63&n[t+2]];return o%3==2?r=r.substring(0,r.length-1)+"=":o%3==1&&(r=r.substring(0,r.length-2)+"=="),r}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[xt(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[xt(e.data,t,n),e.width,e.height]}}if(Nt(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Rt(e,t,n)}}return e}const Lt=(e,t,n)=>e.map(e=>xt(e,t,n)),Nt=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function Ft(e,t,n,o){const r=[];try{const s=Oe(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(r,...s){if(!Fe(this,t,n,!0)){const e=function(e){return"experimental-webgl"===e?"webgl":e}(r);if("__context"in this||(this.__context=e),o&&["webgl","webgl2"].includes(e))if(s[0]&&"object"==typeof s[0]){const e=s[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else s.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[r,...s])}});r.push(s)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{r.forEach(e=>e())}}function At(e,t,n,o,r,s,i){const a=[],l=Object.getOwnPropertyNames(e);for(const s of l)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof e[s])continue;const l=Oe(e,s,function(e){return function(...a){const l=e.apply(this,a);if(Rt(l,i,this),"tagName"in this.canvas&&!Fe(this.canvas,o,r,!0)){const e=Lt(a,i,this),o={type:t,property:s,args:e};n(this.canvas,o)}return l}});a.push(l)}catch(o){const r=Ee(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(r)}return a}var _t,Pt,Wt=(_t=function(){!function(){
|
|
16
16
|
/*! *****************************************************************************
|
|
17
17
|
Copyright (c) Microsoft Corporation.
|
|
18
18
|
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
28
28
|
PERFORMANCE OF THIS SOFTWARE.
|
|
29
29
|
***************************************************************************** */
|
|
30
|
-
function e(e,t,n,o){return new(n||(n=Promise))(function(t,r){function s(e){try{a(o.next(e))}catch(e){r(e)}}function i(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var o;e.done?t(e.value):(o=e.value,o instanceof n?o:new n(function(e){e(o)})).then(s,i)}a((o=o.apply(e,[])).next())})}for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="undefined"==typeof Uint8Array?[]:new Uint8Array(256),o=0;o<64;o++)n[t.charCodeAt(o)]=o;var r=function(e){var n,o=new Uint8Array(e),r=o.length,s="";for(n=0;n<r;n+=3)s+=t[o[n]>>2],s+=t[(3&o[n])<<4|o[n+1]>>4],s+=t[(15&o[n+1])<<2|o[n+2]>>6],s+=t[63&o[n+2]];return r%3==2?s=s.substring(0,s.length-1)+"=":r%3==1&&(s=s.substring(0,s.length-2)+"=="),s};const s=new Map,i=new Map,a=self;a.onmessage=function(t){return e(this,0,void 0,function*(){if(!("OffscreenCanvas"in globalThis))return a.postMessage({id:t.data.id});{const{id:n,bitmap:o,width:l,height:c,dataURLOptions:d}=t.data,u=function(t,n,o){return e(this,0,void 0,function*(){const e=`${t}-${n}`;if("OffscreenCanvas"in globalThis){if(i.has(e))return i.get(e);const s=new OffscreenCanvas(t,n);s.getContext("2d");const a=yield s.convertToBlob(o),l=yield a.arrayBuffer(),c=r(l);return i.set(e,c),c}return""})}(l,c,d),h=new OffscreenCanvas(l,c);h.getContext("2d").drawImage(o,0,0),o.close();const p=yield h.convertToBlob(d),m=p.type,f=yield p.arrayBuffer(),g=r(f);if(!s.has(n)&&(yield u)===g)return s.set(n,g),a.postMessage({id:n});if(s.get(n)===g)return a.postMessage({id:n});a.postMessage({id:n,type:m,base64:g,width:l,height:c}),s.set(n,g)}})}}()},function(e){return Wt=Wt||function(e){var t=function(e){var t=e.toString().split("\n");t.pop(),t.shift();for(var n=t[0].search(/\S/),o=/(['"])__worker_loader_strict__(['"])/g,r=0,s=t.length;r<s;++r)t[r]=t[r].substring(n).replace(o,"$1use strict$2")+"\n";return t}(e),n=new Blob(t,{type:"application/javascript"});return URL.createObjectURL(n)}(_t),new Worker(Wt,e)});class jt{reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:o,blockSelector:r,recordCanvas:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,o,r),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,o,r,{dataURLOptions:i})}initCanvasFPSObserver(e,t,n,o,r){const s=Ft(t,n,o,!0),i=new Map,a=new Pt;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:o,width:r,height:s}=e.data;this.mutationCb({id:t,type:Ke["2D"],commands:[{property:"clearRect",args:[0,0,r,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:o}]},0,0]}]})};const l=1e3/e;let c,d=0;const u=e=>{d&&e-d<l||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{Fe(t,n,o,!0)||e.push(t)}),e})().forEach(e=>Mt(this,0,void 0,function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(0===e.width||0===e.height)return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)}const o=yield createImageBitmap(e);a.postMessage({id:n,bitmap:o,width:e.width,height:e.height,dataURLOptions:r.dataURLOptions},[o])}))),c=requestAnimationFrame(u)};c=requestAnimationFrame(u),this.resetObservers=()=>{s(),cancelAnimationFrame(c)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const o=Ft(e,t,n,!1),r=function(e,t,n,o){const r=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=Oe(t.CanvasRenderingContext2D.prototype,i,function(r){return function(...s){return Fe(this.canvas,n,o,!0)||setTimeout(()=>{const n=Lt(s,t,this);e(this.canvas,{type:Ke["2D"],property:i,args:n})},0),r.apply(this,s)}});r.push(s)}catch(n){const o=Te(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:Ke["2D"],property:i,args:[t],setter:!0})}});r.push(o)}return()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,o){const r=[];return r.push(...At(t.WebGLRenderingContext.prototype,Ke.WebGL,e,n,o,0,t)),void 0!==t.WebGL2RenderingContext&&r.push(...At(t.WebGL2RenderingContext.prototype,Ke.WebGL2,e,n,o,0,t)),()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{o(),r(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const o=n.map(e=>{const t=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["type"]);return t}),{type:r}=n[0];this.mutationCb({id:t,type:r,commands:o}),this.pendingCanvasMutations.delete(e)}}class Ut{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new Be,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},o=[];for(const t of e){let e;this.styleMirror.has(t)?e=this.styleMirror.getId(t):(e=this.styleMirror.add(t),o.push({styleId:e,rules:Array.from(t.rules||CSSRule,(e,t)=>({rule:X(e),index:t}))})),n.styleIds.push(e)}o.length>0&&(n.styles=o),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}class Bt{constructor(){this.nodeMap=new WeakMap,this.loop=!0,this.periodicallyClear()}periodicallyClear(){requestAnimationFrame(()=>{this.clear(),this.loop&&this.periodicallyClear()})}inOtherBuffer(e,t){const n=this.nodeMap.get(e);return n&&Array.from(n).some(e=>e!==t)}add(e,t){this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}clear(){this.nodeMap=new WeakMap}destroy(){this.loop=!1}}function zt(e){return Object.assign(Object.assign({},e),{timestamp:De()})}let Ht,qt,$t,Vt=!1;const Gt=new K;function Xt(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:o,blockClass:r="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",ignoreSelector:a=null,maskTextClass:l="rr-mask",maskTextSelector:c=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:h,slimDOMOptions:p,maskInputFn:m,maskTextFn:f,hooks:g,packFn:v,sampling:y={},dataURLOptions:S={},mousemoveWait:b,recordDOM:w=!0,recordCanvas:k=!1,recordCrossOriginIframes:I=!1,recordAfter:C=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:M=!1,collectFonts:E=!1,inlineImages:T=!1,plugins:O,keepIframeSrcFn:D=()=>!1,ignoreCSSAttributes:R=new Set([]),errorHandler:x}=e;it(x);const L=!I||window.parent===window;let N=!1;if(!L)try{window.parent.document&&(N=!1)}catch(e){N=!0}if(L&&!t)throw new Error("emit function is required");void 0!==b&&void 0===y.mousemove&&(y.mousemove=b),Gt.reset();const F=!0===u?{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}:void 0!==h?h:{password:!0},A=!0===p||"all"===p?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===p,headMetaDescKeywords:"all"===p}:p||{};let _;!function(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),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let W=0;const P=e=>{for(const t of O||[])t.eventProcessor&&(e=t.eventProcessor(e));return v&&!N&&(e=v(e)),e};Ht=(e,r)=>{var s;if(!(null===(s=ct[0])||void 0===s?void 0:s.isFrozen())||e.type===$e.FullSnapshot||e.type===$e.IncrementalSnapshot&&e.data.source===Ve.Mutation||ct.forEach(e=>e.unfreeze()),L)null==t||t(P(e),r);else if(N){const t={type:"rrweb",event:P(e),origin:window.location.origin,isCheckout:r};window.parent.postMessage(t,"*")}if(e.type===$e.FullSnapshot)_=e,W=0;else if(e.type===$e.IncrementalSnapshot){if(e.data.source===Ve.Mutation&&e.data.isAttachIframe)return;W++;const t=o&&W>=o,r=n&&e.timestamp-_.timestamp>n;(t||r)&&qt(!0)}};const j=e=>{Ht(zt({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.Mutation},e)}))},U=e=>Ht(zt({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.Scroll},e)})),B=e=>Ht(zt({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.CanvasMutation},e)})),z=new Ut({mutationCb:j,adoptedStyleSheetCb:e=>Ht(zt({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.AdoptedStyleSheet},e)}))}),H=new It({mirror:Gt,mutationCb:j,stylesheetManager:z,recordCrossOriginIframes:I,wrappedEmit:Ht});for(const e of O||[])e.getMirror&&e.getMirror({nodeMirror:Gt,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});const q=new Bt;$t=new jt({recordCanvas:k,mutationCb:B,win:window,blockClass:r,blockSelector:s,mirror:Gt,sampling:y.canvas,dataURLOptions:S});const $=new Ct({mutationCb:j,scrollCb:U,bypassOptions:{blockClass:r,blockSelector:s,maskTextClass:l,maskTextSelector:c,inlineStylesheet:d,maskInputOptions:F,dataURLOptions:S,maskTextFn:f,maskInputFn:m,recordCanvas:k,inlineImages:T,sampling:y,slimDOMOptions:A,iframeManager:H,stylesheetManager:z,canvasManager:$t,keepIframeSrcFn:D,processedNodeManager:q},mirror:Gt});qt=(e=!1)=>{if(!w)return;Ht(zt({type:$e.Meta,data:{href:window.location.href,width:Le(),height:xe()}}),e),z.reset(),$.init(),ct.forEach(e=>e.lock());const t=function(e,t){const{mirror:n=new K,blockClass:o="rr-block",blockSelector:r=null,maskTextClass:s="rr-mask",maskTextSelector:i=null,inlineStylesheet:a=!0,inlineImages:l=!1,recordCanvas:c=!1,maskAllInputs:d=!1,maskTextFn:u,maskInputFn:h,slimDOM:p=!1,dataURLOptions:m,preserveWhiteSpace:f,onSerialize:g,onIframeLoad:v,iframeLoadTimeout:y,onStylesheetLoad:S,stylesheetLoadTimeout:b,keepIframeSrcFn:w=()=>!1}=t||{};return ke(e,{doc:e,mirror:n,blockClass:o,blockSelector:r,maskTextClass:s,maskTextSelector:i,skipChild:!1,inlineStylesheet:a,maskInputOptions:!0===d?{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}:!1===d?{password:!0}:d,maskTextFn:u,maskInputFn:h,slimDOMOptions:!0===p||"all"===p?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===p,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===p?{}:p,dataURLOptions:m,inlineImages:l,recordCanvas:c,preserveWhiteSpace:f,onSerialize:g,onIframeLoad:v,iframeLoadTimeout:y,onStylesheetLoad:S,stylesheetLoadTimeout:b,keepIframeSrcFn:w,newlyAddedElement:!1})}(document,{mirror:Gt,blockClass:r,blockSelector:s,maskTextClass:l,maskTextSelector:c,inlineStylesheet:d,maskAllInputs:F,maskTextFn:f,slimDOM:A,dataURLOptions:S,recordCanvas:k,inlineImages:T,onSerialize:e=>{Pe(e,Gt)&&H.addIframe(e),je(e,Gt)&&z.trackLinkElement(e),Ue(e)&&$.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{H.attachIframe(e,t),$.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{z.attachLinkElement(e,t)},keepIframeSrcFn:D});if(!t)return console.warn("Failed to snapshot the document");Ht(zt({type:$e.FullSnapshot,data:{node:t,initialOffset:Re(window)}}),e),ct.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&z.adoptStyleSheets(document.adoptedStyleSheets,Gt.getId(document))};try{const e=[],t=e=>{var t;return lt(St)({mutationCb:j,mousemoveCb:(e,t)=>Ht(zt({type:$e.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Ht(zt({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.MouseInteraction},e)})),scrollCb:U,viewportResizeCb:e=>Ht(zt({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.ViewportResize},e)})),inputCb:e=>Ht(zt({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.Input},e)})),mediaInteractionCb:e=>Ht(zt({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.MediaInteraction},e)})),styleSheetRuleCb:e=>Ht(zt({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.StyleSheetRule},e)})),styleDeclarationCb:e=>Ht(zt({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.StyleDeclaration},e)})),canvasMutationCb:B,fontCb:e=>Ht(zt({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.Font},e)})),selectionCb:e=>{Ht(zt({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.Selection},e)}))},customElementCb:e=>{Ht(zt({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.CustomElement},e)}))},blockClass:r,ignoreClass:i,ignoreSelector:a,maskTextClass:l,maskTextSelector:c,maskInputOptions:F,inlineStylesheet:d,sampling:y,recordDOM:w,recordCanvas:k,inlineImages:T,userTriggeredOnInput:M,collectFonts:E,doc:e,maskInputFn:m,maskTextFn:f,keepIframeSrcFn:D,blockSelector:s,slimDOMOptions:A,dataURLOptions:S,mirror:Gt,iframeManager:H,stylesheetManager:z,shadowDomManager:$,processedNodeManager:q,canvasManager:$t,ignoreCSSAttributes:R,plugins:(null===(t=null==O?void 0:O.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>Ht(zt({type:$e.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},g)};H.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(e){console.warn(e)}});const n=()=>{qt(),e.push(t(document)),Vt=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():(e.push(Ie("DOMContentLoaded",()=>{Ht(zt({type:$e.DomContentLoaded,data:{}})),"DOMContentLoaded"===C&&n()})),e.push(Ie("load",()=>{Ht(zt({type:$e.Load,data:{}})),"load"===C&&n()},window))),()=>{e.forEach(e=>e()),q.destroy(),Vt=!1,at()}}catch(e){console.warn(e)}}Xt.addCustomEvent=(e,t)=>{if(!Vt)throw new Error("please add custom event after start recording");Ht(zt({type:$e.Custom,data:{tag:e,payload:t}}))},Xt.freezePage=()=>{ct.forEach(e=>e.freeze())},Xt.takeFullSnapshot=e=>{if(!Vt)throw new Error("please take full snapshot after start recording");qt(e)},Xt.mirror=Gt;class Kt{constructor(e,t,n){this.stopFn=null,this.events=[],this.onEventsReady=null,this.flushInterval=null,this.hasFullSnapshot=!1,this.sessionId=e,this.config=t,this.onEventsReady=n}start(){if(this.config.enabled)if(this.stopFn)console.warn("[RRWeb] Recording already started");else try{console.log("[RRWeb] Starting session recording:",this.sessionId),console.log("[RRWeb] SDK Version: 1.0.14"),this.stopFn=Xt({emit:e=>{this.hasFullSnapshot||console.log("[RRWeb] Event captured:",{type:e.type,timestamp:e.timestamp,hasData:!!e.data}),this.events.push(e),2===e.type?(this.hasFullSnapshot=!0,console.log("[RRWeb] ✅ FullSnapshot captured! Sending immediately..."),console.log("[RRWeb] FullSnapshot data keys:",Object.keys(e.data||{})),this.flush()):this.hasFullSnapshot&&this.events.length>=50&&this.flush()},sampling:{mousemove:void 0===this.config.sampleRate||Math.floor(100/this.config.sampleRate),mouseInteraction:!0,scroll:150,media:800,input:"last"},checkoutEveryNms:this.config.checkoutEveryNms||3e5,checkoutEveryNth:this.config.checkoutEveryNth||200,blockClass:this.config.blockClass||"rr-block",ignoreClass:this.config.ignoreClass||"rr-ignore",maskAllInputs:void 0===this.config.maskAllInputs||this.config.maskAllInputs,maskInputOptions:this.config.maskInputOptions||{password:!0,email:!0,tel:!0},maskTextClass:"rr-mask",inlineStylesheet:void 0===this.config.inlineStylesheet||this.config.inlineStylesheet,recordCanvas:this.config.recordCanvas||!1,collectFonts:void 0===this.config.collectFonts||this.config.collectFonts,recordCrossOriginIframes:!1}),this.flushInterval=window.setInterval(()=>{this.hasFullSnapshot&&this.events.length>0&&this.flush()},1e4),setTimeout(()=>{if(!this.hasFullSnapshot){console.warn("[RRWeb] ⚠️ No FullSnapshot captured after 2 seconds!"),console.warn("[RRWeb] Events captured so far:",this.events.length),console.warn("[RRWeb] Event types:",this.events.map(e=>e.type)),console.warn("[RRWeb] Forcing a full snapshot via record.takeFullSnapshot()...");try{Xt.takeFullSnapshot(),console.log("[RRWeb] ✅ Manual FullSnapshot triggered!")}catch(e){console.error("[RRWeb] Failed to force snapshot:",e),this.events.length>0&&(console.warn("[RRWeb] Flushing existing events WITHOUT FullSnapshot..."),this.hasFullSnapshot=!0,this.flush())}}},2e3),console.log("[RRWeb] Recording started successfully")}catch(e){console.error("[RRWeb] Failed to start recording:",e)}else console.log("[RRWeb] Recording disabled in config")}stop(){this.stopFn&&(this.stopFn(),this.stopFn=null,console.log("[RRWeb] Recording stopped")),this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null),this.events.length>0&&(this.hasFullSnapshot||console.warn("[RRWeb] Flushing events without FullSnapshot - recording may not replay correctly"),this.flush())}flush(){if(0===this.events.length)return;const e=[...this.events];this.events=[];const t={};e.forEach(e=>{t[e.type]=(t[e.type]||0)+1}),console.log("[RRWeb] Flushing events:",t),this.onEventsReady&&this.onEventsReady(e)}getEventCount(){return this.events.length}isRecording(){return null!==this.stopFn}}class Yt{constructor(e){this.config=e,this.queue=[],this.flushInterval=null,this.maxQueueSize=50,this.flushIntervalMs=5e3,this.apiUrl=e.apiUrl||"https://api.devskin.com",this.startPeriodicFlush(),"undefined"!=typeof window&&(window.addEventListener("beforeunload",()=>{this.flush()}),window.addEventListener("visibilitychange",()=>{document.hidden&&this.flush(!0)}))}sendEvent(e){this.enqueue("event",e)}identifyUser(e){this.sendToBackend("/v1/analytics/identify",e)}startSession(e){this.sendToBackend("/v1/analytics/session",e)}sendError(e){this.enqueue("error",e)}sendNetworkRequest(e){this.enqueue("network",e)}sendPerformanceMetric(e){this.enqueue("performance",e)}sendRecordingEvents(e,n){return t(this,void 0,void 0,function*(){const t=n.reduce((e,t)=>(e[t.type]=(e[t.type]||0)+1,e),{}),o={session_id:e,events:n,timestamp:(new Date).toISOString(),apiKey:this.config.apiKey,appId:this.config.appId},r=new Blob([JSON.stringify(o)]).size,s=(r/1024/1024).toFixed(2);console.log(`[DevSkin SDK] Sending ${n.length} recording events:`,t),console.log(`[DevSkin SDK] Payload size: ${s} MB (${r} bytes)`),console.log("[DevSkin SDK] First 3 events:",n.slice(0,3).map(e=>({type:e.type,timestamp:e.timestamp})));const i=n.some(e=>2===e.type),a=i?3:1;let l=null;for(let t=1;t<=a;t++)try{return yield this.sendToBackend("/v1/rum/recordings",{session_id:e,events:n,timestamp:(new Date).toISOString()}),void console.log("[DevSkin SDK] ✅ Recording events sent successfully"+(t>1?` (attempt ${t})`:""))}catch(e){if(l=e,t<a){const e=1e3*t;console.warn(`[DevSkin SDK] ⚠️ Failed to send recording events (attempt ${t}/${a}), retrying in ${e}ms...`),yield new Promise(t=>setTimeout(t,e))}}console.error(`[DevSkin SDK] ❌ Failed to send recording events after ${a} attempts:`,l)})}sendHeatmapData(e){this.enqueue("heatmap",e)}flush(e=!1){if(0===this.queue.length)return;const t=[...this.queue];this.queue=[];const n={};t.forEach(e=>{n[e.type]||(n[e.type]=[]),n[e.type].push(e.data)}),Object.entries(n).forEach(([t,n])=>{const o=this.getEndpointForType(t);this.sendToBackend(o,{[t+"s"]:n},e)}),this.config.debug&&console.log(`[DevSkin] Flushed ${t.length} items to backend`)}enqueue(e,t){this.queue.push({type:e,data:t,timestamp:Date.now()}),this.queue.length>=this.maxQueueSize&&this.flush()}startPeriodicFlush(){this.flushInterval=setInterval(()=>{this.flush()},this.flushIntervalMs)}getEndpointForType(e){switch(e){case"event":default:return"/v1/analytics/events";case"error":return"/v1/analytics/errors";case"network":return"/v1/analytics/network";case"performance":return"/v1/analytics/performance";case"heatmap":return"/v1/analytics/heatmap"}}sendToBackend(e,n){return t(this,arguments,void 0,function*(e,t,n=!1){const o=`${this.apiUrl}${e}`,r=Object.assign(Object.assign({},t),{apiKey:this.config.apiKey,appId:this.config.appId,environment:this.config.environment,release:this.config.release});if(this.config.beforeSend){if(!this.config.beforeSend(r))return}if(n&&navigator.sendBeacon){const e=new Blob([JSON.stringify(r)],{type:"application/json"});return void navigator.sendBeacon(o,e)}try{const t=yield fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify(r),keepalive:!0});if(!t.ok){const e=yield t.text();throw console.error("[DevSkin] HTTP Error:",t.status,e),new Error(`HTTP ${t.status}: ${t.statusText}`)}this.config.debug&&console.log("[DevSkin] Data sent successfully:",e)}catch(t){throw console.error("[DevSkin] Failed to send data to",e,":",t),t}})}destroy(){this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null),this.flush()}}return new class{constructor(){this.config=null,this.transport=null,this.sessionId=null,this.userId=null,this.anonymousId=null,this.sessionStartTime=0,this.initialized=!1,this.deviceCollector=null,this.locationCollector=null,this.browserCollector=null,this.performanceCollector=null,this.errorCollector=null,this.networkCollector=null,this.heatmapCollector=null,this.rrwebRecorder=null}init(t){var r,s;this.initialized?console.warn("[DevSkin] SDK already initialized"):(this.config=Object.assign({debug:!1,captureWebVitals:!0,captureNetworkRequests:!0,captureErrors:!0,captureUserAgent:!0,captureLocation:!0,captureDevice:!0},t),this.config.debug&&console.log("[DevSkin] Initializing SDK with config:",this.config),this.transport=new Yt(this.config),this.anonymousId=this.getOrCreateAnonymousId(),this.deviceCollector=new e(this.config),this.locationCollector=new n(this.config),this.browserCollector=new o(this.config),this.startSession(),this.config.captureWebVitals&&(this.performanceCollector=new B(this.config,this.transport),this.performanceCollector.start()),this.config.captureErrors&&(this.errorCollector=new z(this.config,this.transport),this.errorCollector.start()),this.config.captureNetworkRequests&&(this.networkCollector=new H(this.config,this.transport),this.networkCollector.start()),(null===(r=this.config.heatmapOptions)||void 0===r?void 0:r.enabled)&&(this.heatmapCollector=new q(this.config,this.transport),this.heatmapCollector.start()),(null===(s=this.config.sessionRecording)||void 0===s?void 0:s.enabled)&&(this.rrwebRecorder=new Kt(this.sessionId,{enabled:!0,sampleRate:this.config.sessionRecording.sampling||.5,blockClass:"rr-block",ignoreClass:this.config.sessionRecording.ignoreClass||"rr-ignore",maskAllInputs:void 0===this.config.sessionRecording.maskAllInputs||this.config.sessionRecording.maskAllInputs,maskInputOptions:{password:!0,email:!0,tel:!0},recordCanvas:this.config.sessionRecording.recordCanvas||!1,collectFonts:!0,inlineStylesheet:!0,checkoutEveryNms:3e5,checkoutEveryNth:200},e=>{var t;null===(t=this.transport)||void 0===t||t.sendRecordingEvents(this.sessionId,e)}),setTimeout(()=>{var e,t;null===(e=this.rrwebRecorder)||void 0===e||e.start(),(null===(t=this.config)||void 0===t?void 0:t.debug)&&console.log("[DevSkin] RRWeb recording started for session:",this.sessionId)},500)),this.trackPageView(),this.setupVisibilityTracking(),this.setupUnloadTracking(),this.initialized=!0,this.config.debug&&console.log("[DevSkin] SDK initialized successfully"))}track(e,t){var n,o;if(!this.initialized)return void console.warn("[DevSkin] SDK not initialized. Call init() first.");const r={event_name:e,event_type:"track",timestamp:(new Date).toISOString(),session_id:this.sessionId,user_id:this.userId||void 0,anonymous_id:this.anonymousId||void 0,properties:Object.assign(Object.assign({},t),this.getContextData()),page_url:window.location.href,page_title:document.title};null===(n=this.transport)||void 0===n||n.sendEvent(r),(null===(o=this.config)||void 0===o?void 0:o.debug)&&console.log("[DevSkin] Event tracked:",r)}trackPageView(e){this.track("page_view",Object.assign({path:window.location.pathname,search:window.location.search,hash:window.location.hash,referrer:document.referrer},e))}identify(e,t){var n,o;if(!this.initialized)return void console.warn("[DevSkin] SDK not initialized. Call init() first.");this.userId=e;const r={user_id:e,anonymous_id:this.anonymousId||void 0,traits:Object.assign(Object.assign({},t),this.getContextData()),session_id:this.sessionId,timestamp:(new Date).toISOString()};null===(n=this.transport)||void 0===n||n.identifyUser(r),(null===(o=this.config)||void 0===o?void 0:o.debug)&&console.log("[DevSkin] User identified:",r)}captureError(e,t){var n;this.initialized?null===(n=this.errorCollector)||void 0===n||n.captureError(e,Object.assign(Object.assign({},t),{session_id:this.sessionId,user_id:this.userId||void 0})):console.warn("[DevSkin] SDK not initialized. Call init() first.")}addBreadcrumb(e){var t;this.initialized&&(null===(t=this.errorCollector)||void 0===t||t.addBreadcrumb(e))}startRecording(){var e;null===(e=this.rrwebRecorder)||void 0===e||e.start()}stopRecording(){var e;null===(e=this.rrwebRecorder)||void 0===e||e.stop()}optOut(){localStorage.setItem("devskin_opt_out","true"),this.initialized=!1}optIn(){localStorage.removeItem("devskin_opt_out")}startSession(){var e;this.sessionId=this.generateId(),this.sessionStartTime=Date.now();const t=Object.assign({session_id:this.sessionId,user_id:this.userId||void 0,anonymous_id:this.anonymousId,started_at:(new Date).toISOString()},this.getContextData());null===(e=this.transport)||void 0===e||e.startSession(t)}getContextData(){const e={};return this.deviceCollector&&(e.device=this.deviceCollector.collect()),this.browserCollector&&(e.browser=this.browserCollector.collect()),this.locationCollector&&(e.location=this.locationCollector.collect()),e}getOrCreateAnonymousId(){let e=localStorage.getItem("devskin_anonymous_id");return e||(e=this.generateId(),localStorage.setItem("devskin_anonymous_id",e)),e}generateId(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}setupVisibilityTracking(){document.addEventListener("visibilitychange",()=>{document.hidden?this.track("page_hidden"):this.track("page_visible")})}setupUnloadTracking(){window.addEventListener("beforeunload",()=>{var e,t;if(this.track("page_unload"),this.sessionId&&this.sessionStartTime){const t=new Date,n=Date.now()-this.sessionStartTime;null===(e=this.transport)||void 0===e||e.startSession(Object.assign({session_id:this.sessionId,user_id:this.userId||void 0,anonymous_id:this.anonymousId,ended_at:t.toISOString(),duration_ms:n},this.getContextData()))}null===(t=this.transport)||void 0===t||t.flush(!0)})}}});
|
|
30
|
+
function e(e,t,n,o){return new(n||(n=Promise))(function(t,r){function s(e){try{a(o.next(e))}catch(e){r(e)}}function i(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var o;e.done?t(e.value):(o=e.value,o instanceof n?o:new n(function(e){e(o)})).then(s,i)}a((o=o.apply(e,[])).next())})}for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="undefined"==typeof Uint8Array?[]:new Uint8Array(256),o=0;o<64;o++)n[t.charCodeAt(o)]=o;var r=function(e){var n,o=new Uint8Array(e),r=o.length,s="";for(n=0;n<r;n+=3)s+=t[o[n]>>2],s+=t[(3&o[n])<<4|o[n+1]>>4],s+=t[(15&o[n+1])<<2|o[n+2]>>6],s+=t[63&o[n+2]];return r%3==2?s=s.substring(0,s.length-1)+"=":r%3==1&&(s=s.substring(0,s.length-2)+"=="),s};const s=new Map,i=new Map,a=self;a.onmessage=function(t){return e(this,0,void 0,function*(){if(!("OffscreenCanvas"in globalThis))return a.postMessage({id:t.data.id});{const{id:n,bitmap:o,width:l,height:c,dataURLOptions:d}=t.data,u=function(t,n,o){return e(this,0,void 0,function*(){const e=`${t}-${n}`;if("OffscreenCanvas"in globalThis){if(i.has(e))return i.get(e);const s=new OffscreenCanvas(t,n);s.getContext("2d");const a=yield s.convertToBlob(o),l=yield a.arrayBuffer(),c=r(l);return i.set(e,c),c}return""})}(l,c,d),h=new OffscreenCanvas(l,c);h.getContext("2d").drawImage(o,0,0),o.close();const p=yield h.convertToBlob(d),m=p.type,f=yield p.arrayBuffer(),g=r(f);if(!s.has(n)&&(yield u)===g)return s.set(n,g),a.postMessage({id:n});if(s.get(n)===g)return a.postMessage({id:n});a.postMessage({id:n,type:m,base64:g,width:l,height:c}),s.set(n,g)}})}}()},function(e){return Pt=Pt||function(e){var t=function(e){var t=e.toString().split("\n");t.pop(),t.shift();for(var n=t[0].search(/\S/),o=/(['"])__worker_loader_strict__(['"])/g,r=0,s=t.length;r<s;++r)t[r]=t[r].substring(n).replace(o,"$1use strict$2")+"\n";return t}(e),n=new Blob(t,{type:"application/javascript"});return URL.createObjectURL(n)}(_t),new Worker(Pt,e)});class jt{reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:o,blockSelector:r,recordCanvas:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,o,r),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,o,r,{dataURLOptions:i})}initCanvasFPSObserver(e,t,n,o,r){const s=Ft(t,n,o,!0),i=new Map,a=new Wt;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:o,width:r,height:s}=e.data;this.mutationCb({id:t,type:Ke["2D"],commands:[{property:"clearRect",args:[0,0,r,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:o}]},0,0]}]})};const l=1e3/e;let c,d=0;const u=e=>{d&&e-d<l||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{Fe(t,n,o,!0)||e.push(t)}),e})().forEach(e=>Mt(this,0,void 0,function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(0===e.width||0===e.height)return;if(i.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)}const o=yield createImageBitmap(e);a.postMessage({id:n,bitmap:o,width:e.width,height:e.height,dataURLOptions:r.dataURLOptions},[o])}))),c=requestAnimationFrame(u)};c=requestAnimationFrame(u),this.resetObservers=()=>{s(),cancelAnimationFrame(c)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const o=Ft(e,t,n,!1),r=function(e,t,n,o){const r=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=Oe(t.CanvasRenderingContext2D.prototype,i,function(r){return function(...s){return Fe(this.canvas,n,o,!0)||setTimeout(()=>{const n=Lt(s,t,this);e(this.canvas,{type:Ke["2D"],property:i,args:n})},0),r.apply(this,s)}});r.push(s)}catch(n){const o=Ee(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:Ke["2D"],property:i,args:[t],setter:!0})}});r.push(o)}return()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,o){const r=[];return r.push(...At(t.WebGLRenderingContext.prototype,Ke.WebGL,e,n,o,0,t)),void 0!==t.WebGL2RenderingContext&&r.push(...At(t.WebGL2RenderingContext.prototype,Ke.WebGL2,e,n,o,0,t)),()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{o(),r(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const o=n.map(e=>{const t=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["type"]);return t}),{type:r}=n[0];this.mutationCb({id:t,type:r,commands:o}),this.pendingCanvasMutations.delete(e)}}class Ut{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new Be,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},o=[];for(const t of e){let e;this.styleMirror.has(t)?e=this.styleMirror.getId(t):(e=this.styleMirror.add(t),o.push({styleId:e,rules:Array.from(t.rules||CSSRule,(e,t)=>({rule:X(e),index:t}))})),n.styleIds.push(e)}o.length>0&&(n.styles=o),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}class Bt{constructor(){this.nodeMap=new WeakMap,this.loop=!0,this.periodicallyClear()}periodicallyClear(){requestAnimationFrame(()=>{this.clear(),this.loop&&this.periodicallyClear()})}inOtherBuffer(e,t){const n=this.nodeMap.get(e);return n&&Array.from(n).some(e=>e!==t)}add(e,t){this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}clear(){this.nodeMap=new WeakMap}destroy(){this.loop=!1}}function Ht(e){return Object.assign(Object.assign({},e),{timestamp:De()})}let zt,qt,$t,Vt=!1;const Gt=new K;function Xt(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:o,blockClass:r="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",ignoreSelector:a=null,maskTextClass:l="rr-mask",maskTextSelector:c=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:h,slimDOMOptions:p,maskInputFn:m,maskTextFn:f,hooks:g,packFn:v,sampling:y={},dataURLOptions:S={},mousemoveWait:w,recordDOM:b=!0,recordCanvas:k=!1,recordCrossOriginIframes:I=!1,recordAfter:C=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:M=!1,collectFonts:T=!1,inlineImages:E=!1,plugins:O,keepIframeSrcFn:D=()=>!1,ignoreCSSAttributes:R=new Set([]),errorHandler:x}=e;it(x);const L=!I||window.parent===window;let N=!1;if(!L)try{window.parent.document&&(N=!1)}catch(e){N=!0}if(L&&!t)throw new Error("emit function is required");void 0!==w&&void 0===y.mousemove&&(y.mousemove=w),Gt.reset();const F=!0===u?{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}:void 0!==h?h:{password:!0},A=!0===p||"all"===p?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===p,headMetaDescKeywords:"all"===p}:p||{};let _;!function(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),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let P=0;const W=e=>{for(const t of O||[])t.eventProcessor&&(e=t.eventProcessor(e));return v&&!N&&(e=v(e)),e};zt=(e,r)=>{var s;if(!(null===(s=ct[0])||void 0===s?void 0:s.isFrozen())||e.type===$e.FullSnapshot||e.type===$e.IncrementalSnapshot&&e.data.source===Ve.Mutation||ct.forEach(e=>e.unfreeze()),L)null==t||t(W(e),r);else if(N){const t={type:"rrweb",event:W(e),origin:window.location.origin,isCheckout:r};window.parent.postMessage(t,"*")}if(e.type===$e.FullSnapshot)_=e,P=0;else if(e.type===$e.IncrementalSnapshot){if(e.data.source===Ve.Mutation&&e.data.isAttachIframe)return;P++;const t=o&&P>=o,r=n&&e.timestamp-_.timestamp>n;(t||r)&&qt(!0)}};const j=e=>{zt(Ht({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.Mutation},e)}))},U=e=>zt(Ht({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.Scroll},e)})),B=e=>zt(Ht({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.CanvasMutation},e)})),H=new Ut({mutationCb:j,adoptedStyleSheetCb:e=>zt(Ht({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.AdoptedStyleSheet},e)}))}),z=new It({mirror:Gt,mutationCb:j,stylesheetManager:H,recordCrossOriginIframes:I,wrappedEmit:zt});for(const e of O||[])e.getMirror&&e.getMirror({nodeMirror:Gt,crossOriginIframeMirror:z.crossOriginIframeMirror,crossOriginIframeStyleMirror:z.crossOriginIframeStyleMirror});const q=new Bt;$t=new jt({recordCanvas:k,mutationCb:B,win:window,blockClass:r,blockSelector:s,mirror:Gt,sampling:y.canvas,dataURLOptions:S});const $=new Ct({mutationCb:j,scrollCb:U,bypassOptions:{blockClass:r,blockSelector:s,maskTextClass:l,maskTextSelector:c,inlineStylesheet:d,maskInputOptions:F,dataURLOptions:S,maskTextFn:f,maskInputFn:m,recordCanvas:k,inlineImages:E,sampling:y,slimDOMOptions:A,iframeManager:z,stylesheetManager:H,canvasManager:$t,keepIframeSrcFn:D,processedNodeManager:q},mirror:Gt});qt=(e=!1)=>{if(!b)return;zt(Ht({type:$e.Meta,data:{href:window.location.href,width:Le(),height:xe()}}),e),H.reset(),$.init(),ct.forEach(e=>e.lock());const t=function(e,t){const{mirror:n=new K,blockClass:o="rr-block",blockSelector:r=null,maskTextClass:s="rr-mask",maskTextSelector:i=null,inlineStylesheet:a=!0,inlineImages:l=!1,recordCanvas:c=!1,maskAllInputs:d=!1,maskTextFn:u,maskInputFn:h,slimDOM:p=!1,dataURLOptions:m,preserveWhiteSpace:f,onSerialize:g,onIframeLoad:v,iframeLoadTimeout:y,onStylesheetLoad:S,stylesheetLoadTimeout:w,keepIframeSrcFn:b=()=>!1}=t||{};return ke(e,{doc:e,mirror:n,blockClass:o,blockSelector:r,maskTextClass:s,maskTextSelector:i,skipChild:!1,inlineStylesheet:a,maskInputOptions:!0===d?{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}:!1===d?{password:!0}:d,maskTextFn:u,maskInputFn:h,slimDOMOptions:!0===p||"all"===p?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===p,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===p?{}:p,dataURLOptions:m,inlineImages:l,recordCanvas:c,preserveWhiteSpace:f,onSerialize:g,onIframeLoad:v,iframeLoadTimeout:y,onStylesheetLoad:S,stylesheetLoadTimeout:w,keepIframeSrcFn:b,newlyAddedElement:!1})}(document,{mirror:Gt,blockClass:r,blockSelector:s,maskTextClass:l,maskTextSelector:c,inlineStylesheet:d,maskAllInputs:F,maskTextFn:f,slimDOM:A,dataURLOptions:S,recordCanvas:k,inlineImages:E,onSerialize:e=>{We(e,Gt)&&z.addIframe(e),je(e,Gt)&&H.trackLinkElement(e),Ue(e)&&$.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{z.attachIframe(e,t),$.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{H.attachLinkElement(e,t)},keepIframeSrcFn:D});if(!t)return console.warn("Failed to snapshot the document");zt(Ht({type:$e.FullSnapshot,data:{node:t,initialOffset:Re(window)}}),e),ct.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&H.adoptStyleSheets(document.adoptedStyleSheets,Gt.getId(document))};try{const e=[],t=e=>{var t;return lt(St)({mutationCb:j,mousemoveCb:(e,t)=>zt(Ht({type:$e.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>zt(Ht({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.MouseInteraction},e)})),scrollCb:U,viewportResizeCb:e=>zt(Ht({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.ViewportResize},e)})),inputCb:e=>zt(Ht({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.Input},e)})),mediaInteractionCb:e=>zt(Ht({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.MediaInteraction},e)})),styleSheetRuleCb:e=>zt(Ht({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.StyleSheetRule},e)})),styleDeclarationCb:e=>zt(Ht({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.StyleDeclaration},e)})),canvasMutationCb:B,fontCb:e=>zt(Ht({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.Font},e)})),selectionCb:e=>{zt(Ht({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.Selection},e)}))},customElementCb:e=>{zt(Ht({type:$e.IncrementalSnapshot,data:Object.assign({source:Ve.CustomElement},e)}))},blockClass:r,ignoreClass:i,ignoreSelector:a,maskTextClass:l,maskTextSelector:c,maskInputOptions:F,inlineStylesheet:d,sampling:y,recordDOM:b,recordCanvas:k,inlineImages:E,userTriggeredOnInput:M,collectFonts:T,doc:e,maskInputFn:m,maskTextFn:f,keepIframeSrcFn:D,blockSelector:s,slimDOMOptions:A,dataURLOptions:S,mirror:Gt,iframeManager:z,stylesheetManager:H,shadowDomManager:$,processedNodeManager:q,canvasManager:$t,ignoreCSSAttributes:R,plugins:(null===(t=null==O?void 0:O.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>zt(Ht({type:$e.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},g)};z.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(e){console.warn(e)}});const n=()=>{qt(),e.push(t(document)),Vt=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():(e.push(Ie("DOMContentLoaded",()=>{zt(Ht({type:$e.DomContentLoaded,data:{}})),"DOMContentLoaded"===C&&n()})),e.push(Ie("load",()=>{zt(Ht({type:$e.Load,data:{}})),"load"===C&&n()},window))),()=>{e.forEach(e=>e()),q.destroy(),Vt=!1,at()}}catch(e){console.warn(e)}}Xt.addCustomEvent=(e,t)=>{if(!Vt)throw new Error("please add custom event after start recording");zt(Ht({type:$e.Custom,data:{tag:e,payload:t}}))},Xt.freezePage=()=>{ct.forEach(e=>e.freeze())},Xt.takeFullSnapshot=e=>{if(!Vt)throw new Error("please take full snapshot after start recording");qt(e)},Xt.mirror=Gt;class Kt{constructor(e,t,n){this.stopFn=null,this.events=[],this.onEventsReady=null,this.flushInterval=null,this.hasFullSnapshot=!1,this.sessionId=e,this.config=t,this.onEventsReady=n}start(){if(this.config.enabled)if(this.stopFn)console.warn("[RRWeb] Recording already started");else try{console.log("[RRWeb] Starting session recording:",this.sessionId),console.log("[RRWeb] SDK Version: 1.0.14"),this.stopFn=Xt({emit:e=>{this.hasFullSnapshot||console.log("[RRWeb] Event captured:",{type:e.type,timestamp:e.timestamp,hasData:!!e.data}),this.events.push(e),2===e.type?(this.hasFullSnapshot=!0,console.log("[RRWeb] ✅ FullSnapshot captured! Sending immediately..."),console.log("[RRWeb] FullSnapshot data keys:",Object.keys(e.data||{})),this.flush()):this.hasFullSnapshot&&this.events.length>=50&&this.flush()},sampling:{mousemove:void 0===this.config.sampleRate||Math.floor(100/this.config.sampleRate),mouseInteraction:!0,scroll:150,media:800,input:"last"},checkoutEveryNms:this.config.checkoutEveryNms||3e5,checkoutEveryNth:this.config.checkoutEveryNth||200,blockClass:this.config.blockClass||"rr-block",ignoreClass:this.config.ignoreClass||"rr-ignore",maskAllInputs:void 0===this.config.maskAllInputs||this.config.maskAllInputs,maskInputOptions:this.config.maskInputOptions||{password:!0,email:!0,tel:!0},maskTextClass:"rr-mask",inlineStylesheet:void 0===this.config.inlineStylesheet||this.config.inlineStylesheet,recordCanvas:this.config.recordCanvas||!1,collectFonts:void 0===this.config.collectFonts||this.config.collectFonts,recordCrossOriginIframes:!1}),this.flushInterval=window.setInterval(()=>{this.hasFullSnapshot&&this.events.length>0&&this.flush()},1e4),setTimeout(()=>{if(!this.hasFullSnapshot){console.warn("[RRWeb] ⚠️ No FullSnapshot captured after 2 seconds!"),console.warn("[RRWeb] Events captured so far:",this.events.length),console.warn("[RRWeb] Event types:",this.events.map(e=>e.type)),console.warn("[RRWeb] Forcing a full snapshot via record.takeFullSnapshot()...");try{Xt.takeFullSnapshot(),console.log("[RRWeb] ✅ Manual FullSnapshot triggered!")}catch(e){console.error("[RRWeb] Failed to force snapshot:",e),this.events.length>0&&(console.warn("[RRWeb] Flushing existing events WITHOUT FullSnapshot..."),this.hasFullSnapshot=!0,this.flush())}}},2e3),console.log("[RRWeb] Recording started successfully")}catch(e){console.error("[RRWeb] Failed to start recording:",e)}else console.log("[RRWeb] Recording disabled in config")}stop(){this.stopFn&&(this.stopFn(),this.stopFn=null,console.log("[RRWeb] Recording stopped")),this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null),this.events.length>0&&(this.hasFullSnapshot||console.warn("[RRWeb] Flushing events without FullSnapshot - recording may not replay correctly"),this.flush())}flush(){if(0===this.events.length)return;const e=[...this.events];this.events=[];const t={};e.forEach(e=>{t[e.type]=(t[e.type]||0)+1}),console.log("[RRWeb] Flushing events:",t),this.onEventsReady&&this.onEventsReady(e)}getEventCount(){return this.events.length}isRecording(){return null!==this.stopFn}}class Yt{constructor(e){this.config=e,this.queue=[],this.flushInterval=null,this.maxQueueSize=50,this.flushIntervalMs=5e3,this.apiUrl=e.apiUrl||"https://api.devskin.com",this.startPeriodicFlush(),"undefined"!=typeof window&&(window.addEventListener("beforeunload",()=>{this.flush()}),window.addEventListener("visibilitychange",()=>{document.hidden&&this.flush(!0)}))}sendEvent(e){this.enqueue("event",e)}identifyUser(e){this.sendToBackend("/v1/analytics/identify",e)}startSession(e){this.sendToBackend("/v1/analytics/session",e)}sendError(e){this.enqueue("error",e)}sendNetworkRequest(e){this.enqueue("network",e)}sendPerformanceMetric(e){this.enqueue("performance",e)}sendRecordingEvents(e,n){return t(this,void 0,void 0,function*(){const t=n.reduce((e,t)=>(e[t.type]=(e[t.type]||0)+1,e),{}),o={session_id:e,events:n,timestamp:(new Date).toISOString(),apiKey:this.config.apiKey,appId:this.config.appId},r=new Blob([JSON.stringify(o)]).size,s=(r/1024/1024).toFixed(2);console.log(`[DevSkin SDK] Sending ${n.length} recording events:`,t),console.log(`[DevSkin SDK] Payload size: ${s} MB (${r} bytes)`),console.log("[DevSkin SDK] First 3 events:",n.slice(0,3).map(e=>({type:e.type,timestamp:e.timestamp})));const i=n.some(e=>2===e.type),a=i?3:1;let l=null;for(let t=1;t<=a;t++)try{return r>1e5?yield this.sendToBackendXHR("/v1/rum/recordings",{session_id:e,events:n,timestamp:(new Date).toISOString()}):yield this.sendToBackend("/v1/rum/recordings",{session_id:e,events:n,timestamp:(new Date).toISOString()}),void console.log("[DevSkin SDK] ✅ Recording events sent successfully"+(t>1?` (attempt ${t})`:""))}catch(e){if(l=e,t<a){const e=1e3*t;console.warn(`[DevSkin SDK] ⚠️ Failed to send recording events (attempt ${t}/${a}), retrying in ${e}ms...`),yield new Promise(t=>setTimeout(t,e))}}console.error(`[DevSkin SDK] ❌ Failed to send recording events after ${a} attempts:`,l)})}sendHeatmapData(e){this.enqueue("heatmap",e)}flush(e=!1){if(0===this.queue.length)return;const t=[...this.queue];this.queue=[];const n={};t.forEach(e=>{n[e.type]||(n[e.type]=[]),n[e.type].push(e.data)}),Object.entries(n).forEach(([t,n])=>{const o=this.getEndpointForType(t);this.sendToBackend(o,{[t+"s"]:n},e)}),this.config.debug&&console.log(`[DevSkin] Flushed ${t.length} items to backend`)}enqueue(e,t){this.queue.push({type:e,data:t,timestamp:Date.now()}),this.queue.length>=this.maxQueueSize&&this.flush()}startPeriodicFlush(){this.flushInterval=setInterval(()=>{this.flush()},this.flushIntervalMs)}getEndpointForType(e){switch(e){case"event":default:return"/v1/analytics/events";case"error":return"/v1/analytics/errors";case"network":return"/v1/analytics/network";case"performance":return"/v1/analytics/performance";case"heatmap":return"/v1/analytics/heatmap"}}sendToBackendXHR(e,n){return t(this,void 0,void 0,function*(){const t=`${this.apiUrl}${e}`,o=Object.assign(Object.assign({},n),{apiKey:this.config.apiKey,appId:this.config.appId,environment:this.config.environment,release:this.config.release});if(this.config.beforeSend){if(!this.config.beforeSend(o))return}return new Promise((n,r)=>{const s=new XMLHttpRequest;s.open("POST",t,!0),s.setRequestHeader("Content-Type","application/json"),s.setRequestHeader("Authorization",`Bearer ${this.config.apiKey}`),s.onload=()=>{s.status>=200&&s.status<300?(this.config.debug&&console.log("[DevSkin] Data sent successfully via XHR:",e),n()):(console.error("[DevSkin] XHR HTTP Error:",s.status,s.responseText),r(new Error(`HTTP ${s.status}: ${s.statusText}`)))},s.onerror=()=>{console.error("[DevSkin] XHR network error:",e),r(new Error("Network error"))},s.ontimeout=()=>{console.error("[DevSkin] XHR timeout:",e),r(new Error("Request timeout"))},s.timeout=3e4;try{const e=JSON.stringify(o);console.log(`[DevSkin SDK] Using XMLHttpRequest for large payload (${(e.length/1024).toFixed(2)} KB)`),s.send(e)}catch(e){console.error("[DevSkin] Failed to send XHR request:",e),r(e)}})})}sendToBackend(e,n){return t(this,arguments,void 0,function*(e,t,n=!1){const o=`${this.apiUrl}${e}`,r=Object.assign(Object.assign({},t),{apiKey:this.config.apiKey,appId:this.config.appId,environment:this.config.environment,release:this.config.release});if(this.config.beforeSend){if(!this.config.beforeSend(r))return}if(n&&navigator.sendBeacon){const e=new Blob([JSON.stringify(r)],{type:"application/json"});return void navigator.sendBeacon(o,e)}try{const t=yield fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify(r),keepalive:!0});if(!t.ok){const e=yield t.text();throw console.error("[DevSkin] HTTP Error:",t.status,e),new Error(`HTTP ${t.status}: ${t.statusText}`)}this.config.debug&&console.log("[DevSkin] Data sent successfully:",e)}catch(t){throw console.error("[DevSkin] Failed to send data to",e,":",t),t}})}destroy(){this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null),this.flush()}}return new class{constructor(){this.config=null,this.transport=null,this.sessionId=null,this.userId=null,this.anonymousId=null,this.sessionStartTime=0,this.initialized=!1,this.deviceCollector=null,this.locationCollector=null,this.browserCollector=null,this.performanceCollector=null,this.errorCollector=null,this.networkCollector=null,this.heatmapCollector=null,this.rrwebRecorder=null}init(t){var r,s;this.initialized?console.warn("[DevSkin] SDK already initialized"):(this.config=Object.assign({debug:!1,captureWebVitals:!0,captureNetworkRequests:!0,captureErrors:!0,captureUserAgent:!0,captureLocation:!0,captureDevice:!0},t),this.config.debug&&console.log("[DevSkin] Initializing SDK with config:",this.config),this.transport=new Yt(this.config),this.anonymousId=this.getOrCreateAnonymousId(),this.deviceCollector=new e(this.config),this.locationCollector=new n(this.config),this.browserCollector=new o(this.config),this.startSession(),this.config.captureWebVitals&&(this.performanceCollector=new B(this.config,this.transport),this.performanceCollector.start()),this.config.captureErrors&&(this.errorCollector=new H(this.config,this.transport),this.errorCollector.start()),this.config.captureNetworkRequests&&(this.networkCollector=new z(this.config,this.transport),this.networkCollector.start()),(null===(r=this.config.heatmapOptions)||void 0===r?void 0:r.enabled)&&(this.heatmapCollector=new q(this.config,this.transport),this.heatmapCollector.start()),(null===(s=this.config.sessionRecording)||void 0===s?void 0:s.enabled)&&(this.rrwebRecorder=new Kt(this.sessionId,{enabled:!0,sampleRate:this.config.sessionRecording.sampling||.5,blockClass:"rr-block",ignoreClass:this.config.sessionRecording.ignoreClass||"rr-ignore",maskAllInputs:void 0===this.config.sessionRecording.maskAllInputs||this.config.sessionRecording.maskAllInputs,maskInputOptions:{password:!0,email:!0,tel:!0},recordCanvas:this.config.sessionRecording.recordCanvas||!1,collectFonts:!0,inlineStylesheet:!0,checkoutEveryNms:3e5,checkoutEveryNth:200},e=>{var t;null===(t=this.transport)||void 0===t||t.sendRecordingEvents(this.sessionId,e)}),setTimeout(()=>{var e,t;null===(e=this.rrwebRecorder)||void 0===e||e.start(),(null===(t=this.config)||void 0===t?void 0:t.debug)&&console.log("[DevSkin] RRWeb recording started for session:",this.sessionId)},500)),this.trackPageView(),this.setupVisibilityTracking(),this.setupUnloadTracking(),this.initialized=!0,this.config.debug&&console.log("[DevSkin] SDK initialized successfully"))}track(e,t){var n,o;if(!this.initialized)return void console.warn("[DevSkin] SDK not initialized. Call init() first.");const r={event_name:e,event_type:"track",timestamp:(new Date).toISOString(),session_id:this.sessionId,user_id:this.userId||void 0,anonymous_id:this.anonymousId||void 0,properties:Object.assign(Object.assign({},t),this.getContextData()),page_url:window.location.href,page_title:document.title};null===(n=this.transport)||void 0===n||n.sendEvent(r),(null===(o=this.config)||void 0===o?void 0:o.debug)&&console.log("[DevSkin] Event tracked:",r)}trackPageView(e){this.track("page_view",Object.assign({path:window.location.pathname,search:window.location.search,hash:window.location.hash,referrer:document.referrer},e))}identify(e,t){var n,o;if(!this.initialized)return void console.warn("[DevSkin] SDK not initialized. Call init() first.");this.userId=e;const r={user_id:e,anonymous_id:this.anonymousId||void 0,traits:Object.assign(Object.assign({},t),this.getContextData()),session_id:this.sessionId,timestamp:(new Date).toISOString()};null===(n=this.transport)||void 0===n||n.identifyUser(r),(null===(o=this.config)||void 0===o?void 0:o.debug)&&console.log("[DevSkin] User identified:",r)}captureError(e,t){var n;this.initialized?null===(n=this.errorCollector)||void 0===n||n.captureError(e,Object.assign(Object.assign({},t),{session_id:this.sessionId,user_id:this.userId||void 0})):console.warn("[DevSkin] SDK not initialized. Call init() first.")}addBreadcrumb(e){var t;this.initialized&&(null===(t=this.errorCollector)||void 0===t||t.addBreadcrumb(e))}startRecording(){var e;null===(e=this.rrwebRecorder)||void 0===e||e.start()}stopRecording(){var e;null===(e=this.rrwebRecorder)||void 0===e||e.stop()}optOut(){localStorage.setItem("devskin_opt_out","true"),this.initialized=!1}optIn(){localStorage.removeItem("devskin_opt_out")}startSession(){var e;this.sessionId=this.generateId(),this.sessionStartTime=Date.now();const t=Object.assign({session_id:this.sessionId,user_id:this.userId||void 0,anonymous_id:this.anonymousId,started_at:(new Date).toISOString()},this.getContextData());null===(e=this.transport)||void 0===e||e.startSession(t)}getContextData(){const e={};return this.deviceCollector&&(e.device=this.deviceCollector.collect()),this.browserCollector&&(e.browser=this.browserCollector.collect()),this.locationCollector&&(e.location=this.locationCollector.collect()),e}getOrCreateAnonymousId(){let e=localStorage.getItem("devskin_anonymous_id");return e||(e=this.generateId(),localStorage.setItem("devskin_anonymous_id",e)),e}generateId(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}setupVisibilityTracking(){document.addEventListener("visibilitychange",()=>{document.hidden?this.track("page_hidden"):this.track("page_visible")})}setupUnloadTracking(){window.addEventListener("beforeunload",()=>{var e,t;if(this.track("page_unload"),this.sessionId&&this.sessionStartTime){const t=new Date,n=Date.now()-this.sessionStartTime;null===(e=this.transport)||void 0===e||e.startSession(Object.assign({session_id:this.sessionId,user_id:this.userId||void 0,anonymous_id:this.anonymousId,ended_at:t.toISOString(),duration_ms:n},this.getContextData()))}null===(t=this.transport)||void 0===t||t.flush(!0)})}}});
|
|
31
31
|
//# sourceMappingURL=devskin.umd.min.js.map
|