@devskin/browser-sdk 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collectors/error.d.ts.map +1 -1
- package/dist/devskin.cjs.js +7 -3
- package/dist/devskin.cjs.js.map +1 -1
- package/dist/devskin.esm.js +8 -3
- package/dist/devskin.esm.js.map +1 -1
- package/dist/devskin.umd.js +12 -10
- package/dist/devskin.umd.js.map +1 -1
- package/dist/devskin.umd.min.js +2 -2
- package/dist/devskin.umd.min.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.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?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).DevSkin={})}(this,function(e){"use strict";class t{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 n(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((o=o.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class o{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 n(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,t){return n(this,void 0,void 0,function*(){try{const n=yield fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${e}&lon=${t}&zoom=10&addressdetails=1`,{headers:{"User-Agent":"DevSkin-SDK/1.0"}});if(n.ok){const e=yield n.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 r{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 i,s,a,c,l,d=-1,u=function(e){addEventListener("pageshow",function(t){t.persisted&&(d=t.timeStamp,e(t))},!0)},h=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},g=function(){var e=h();return e&&e.activationStart||0},p=function(e,t){var n=h(),o="navigate";return d>=0?o="back-forward-cache":n&&(document.prerendering||g()>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,i;return function(s){t.value>=0&&(s||o)&&((i=t.value-(r||0))||void 0===r)&&(r=t.value,t.delta=i,t.rating=function(e,t){return e>t[1]?"poor":e>t[0]?"needs-improvement":"good"}(t.value,n),e(t))}},I=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)},C=function(e){var t=!1;return function(n){t||(e(n),t=!0)}},y=-1,b=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},S=function(e){"hidden"===document.visibilityState&&y>-1&&(y="visibilitychange"===e.type?e.timeStamp:0,k())},w=function(){addEventListener("visibilitychange",S,!0),addEventListener("prerenderingchange",S,!0)},k=function(){removeEventListener("visibilitychange",S,!0),removeEventListener("prerenderingchange",S,!0)},A=function(){return y<0&&(y=b(),w(),u(function(){setTimeout(function(){y=b(),w()},0)})),{get firstHiddenTime(){return y}}},T=function(e){document.prerendering?addEventListener("prerenderingchange",function(){return e()},!0):e()},M=[1800,3e3],E=function(e,t){t=t||{},T(function(){var n,o=A(),r=p("FCP"),i=m("paint",function(e){e.forEach(function(e){"first-contentful-paint"===e.name&&(i.disconnect(),e.startTime<o.firstHiddenTime&&(r.value=Math.max(e.startTime-g(),0),r.entries.push(e),n(!0)))})});i&&(n=f(e,r,M,t.reportAllChanges),u(function(o){r=p("FCP"),n=f(e,r,M,t.reportAllChanges),I(function(){r.value=performance.now()-o.timeStamp,n(!0)})}))})},R=[.1,.25],O={passive:!0,capture:!0},N=new Date,D=function(e,t){i||(i=t,s=e,a=new Date,x(removeEventListener),L())},L=function(){if(s>=0&&s<a-N){var e={entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+s};c.forEach(function(t){t(e)}),c=[]}},F=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(){D(e,t),r()},o=function(){r()},r=function(){removeEventListener("pointerup",n,O),removeEventListener("pointercancel",o,O)};addEventListener("pointerup",n,O),addEventListener("pointercancel",o,O)}(t,e):D(t,e)}},x=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach(function(t){return e(t,F,O)})},B=[100,300],W=[2500,4e3],V={},G=[800,1800],Z=function e(t){document.prerendering?T(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,G,t.reportAllChanges);Z(function(){var r=h();if(r){var i=r.responseStart;if(i<=0||i>performance.now())return;n.value=Math.max(i-g(),0),n.entries=[r],o(!0),u(function(){n=p("TTFB",0),(o=f(e,n,G,t.reportAllChanges))(!0)})}})};class K{constructor(e,t){this.config=e,this.transport=t,this.metrics={}}start(){!function(e,t){t=t||{},E(C(function(){var n,o=p("CLS",0),r=0,i=[],s=function(e){e.forEach(function(e){if(!e.hadRecentInput){var t=i[0],n=i[i.length-1];r&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(r+=e.value,i.push(e)):(r=e.value,i=[e])}}),r>o.value&&(o.value=r,o.entries=i,n())},a=m("layout-shift",s);a&&(n=f(e,o,R,t.reportAllChanges),v(function(){s(a.takeRecords()),n(!0)}),u(function(){r=0,o=p("CLS",0),n=f(e,o,R,t.reportAllChanges),I(function(){return n()})}),setTimeout(n,0))}))}(e=>this.handleMetric(e)),E(e=>this.handleMetric(e)),function(e,t){t=t||{},T(function(){var n,o=A(),r=p("FID"),a=function(e){e.startTime<o.firstHiddenTime&&(r.value=e.processingStart-e.startTime,r.entries.push(e),n(!0))},l=function(e){e.forEach(a)},d=m("first-input",l);n=f(e,r,B,t.reportAllChanges),d&&v(C(function(){l(d.takeRecords()),d.disconnect()})),d&&u(function(){var o;r=p("FID"),n=f(e,r,B,t.reportAllChanges),c=[],s=-1,i=null,x(addEventListener),o=a,c.push(o),L()})})}(e=>this.handleMetric(e)),function(e,t){t=t||{},T(function(){var n,o=A(),r=p("LCP"),i=function(e){var t=e[e.length-1];t&&t.startTime<o.firstHiddenTime&&(r.value=Math.max(t.startTime-g(),0),r.entries=[t],n())},s=m("largest-contentful-paint",i);if(s){n=f(e,r,W,t.reportAllChanges);var a=C(function(){V[r.id]||(i(s.takeRecords()),s.disconnect(),V[r.id]=!0,n(!0))});["keydown","click"].forEach(function(e){addEventListener(e,function(){return setTimeout(a,0)},!0)}),v(a),u(function(o){r=p("LCP"),n=f(e,r,W,t.reportAllChanges),I(function(){r.value=performance.now()-o.timeStamp,V[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 _{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 i=(null===(n=this.config.errorOptions)||void 0===n?void 0:n.denyUrls)||[],s=e instanceof Error?e.stack:"";for(const e of i)if(e.test(s||""))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)=>{t.apply(console,n),"warn"!==e&&"error"!==e||this.addBreadcrumb({category:"console",message:n.map(e=>String(e)).join(" "),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=(...t)=>n(this,void 0,void 0,function*(){var n,o,r;const[i,s]=t,a="string"==typeof i?i:i instanceof Request?i.url:i.toString(),c=(null==s?void 0:s.method)||"GET",l=Date.now();try{const i=yield e(...t),s=i.clone(),d=Date.now()-l;if(this.shouldIgnoreUrl(a))return i;if((null===(n=this.config.networkRequestOptions)||void 0===n?void 0:n.captureFailedOnly)&&i.ok)return i;const u={url:a,method:c,status:i.status,duration:d,size:yield this.getResponseSize(s),type:"fetch",timestamp:(new Date).toISOString(),failed:!i.ok};if((null===(o=this.config.networkRequestOptions)||void 0===o?void 0:o.captureHeaders)&&(u.headers=this.headersToObject(i.headers)),(null===(r=this.config.networkRequestOptions)||void 0===r?void 0:r.captureBody)&&!i.ok)try{const e=yield s.text();u.body=e.substring(0,1e4)}catch(e){}return this.config.debug&&console.log("[DevSkin] Network request tracked:",u),this.transport.sendNetworkRequest(u),i}catch(e){const t=Date.now()-l;if(!this.shouldIgnoreUrl(a)){const e={url:a,method:c,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,i){return this.__devskin={method:t,url:n.toString(),startTime:Date.now()},void 0!==r?e.call(this,t,n,null==o||o,r,null!=i?i: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,i=()=>{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,i,s;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 c={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)&&(c.headers=r.parseResponseHeaders(n.getAllResponseHeaders())),(null===(i=null==r?void 0:r.config.networkRequestOptions)||void 0===i?void 0:i.captureBody)&&c.failed)try{c.body=null===(s=n.responseText)||void 0===s?void 0:s.substring(0,1e4)}catch(e){}(null==r?void 0:r.config.debug)&&console.log("[DevSkin] XHR request tracked:",c),null==r||r.transport.sendNetworkRequest(c)}),n.addEventListener("error",i),n.addEventListener("abort",i),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 n(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 Y{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,i=e.clientX+window.scrollX,s=e.clientY+window.scrollY,a={x:e.clientX,y:e.clientY,relativeX:o,relativeY:r,pageX:i,pageY:s,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 H(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function j(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function q(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t).map(P).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(e){return null}var n}function P(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=q(e.styleSheet)||t}catch(e){}return t}!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={}));var J=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(e){var t;if(!e)return-1;var n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1},e.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},e.prototype.removeNodeFromMap=function(e){var t=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach(function(e){return t.removeNodeFromMap(e)})},e.prototype.has=function(e){return this.idNodeMap.has(e)},e.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},e.prototype.add=function(e,t){var n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)},e.prototype.replace=function(e,t){var n=this.getNode(e);if(n){var o=this.nodeMetaMap.get(n);o&&this.nodeMetaMap.set(t,o)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function Q(e){var t=e.maskInputOptions,n=e.tagName,o=e.type,r=e.value,i=e.maskInputFn,s=r||"";return(t[n.toLowerCase()]||t[o])&&(s=i?i(s):"*".repeat(s.length)),s}var X="__rrweb_original__";var $,ee,te=1,ne=new RegExp("[^a-z0-9-_:]");function oe(){return te++}var re=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,ie=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,se=/^(data:)([^,]*),(.*)/i;function ae(e,t){return(e||"").replace(re,function(e,n,o,r,i,s){var a,c=o||i||s,l=n||r||"";if(!c)return e;if(!ie.test(c))return"url(".concat(l).concat(c).concat(l,")");if(se.test(c))return"url(".concat(l).concat(c).concat(l,")");if("/"===c[0])return"url(".concat(l).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+c)).concat(l,")");var d=t.split("/"),u=c.split("/");d.pop();for(var h=0,g=u;h<g.length;h++){var p=g[h];"."!==p&&(".."===p?d.pop():d.push(p))}return"url(".concat(l).concat(d.join("/")).concat(l,")")})}var ce=/^[^ \t\n\r\u000c]+/,le=/^[, \t\n\r\u000c]+/;function de(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function ue(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function he(){var e=document.createElement("a");return e.href="",e.href}function ge(e,t,n,o){return"src"===n||"href"===n&&o&&("use"!==t||"#"!==o[0])||"xlink:href"===n&&o&&"#"!==o[0]?de(e,o):"background"!==n||!o||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n&&o?function(e,t){if(""===t.trim())return t;var n=0;function o(e){var o,r=e.exec(t.substring(n));return r?(o=r[0],n+=o.length,o):""}for(var r=[];o(le),!(n>=t.length);){var i=o(ce);if(","===i.slice(-1))i=de(e,i.substring(0,i.length-1)),r.push(i);else{var s="";i=de(e,i);for(var a=!1;;){var c=t.charAt(n);if(""===c){r.push((i+s).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,r.push((i+s).trim());break}"("===c&&(a=!0)}s+=c,n+=1}}}return r.join(", ")}(e,o):"style"===n&&o?ae(o,he()):"object"===t&&"data"===n&&o?de(e,o):o:de(e,o)}function pe(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&pe(e.parentNode,t,n);for(var o=e.classList.length;o--;){var r=e.classList[o];if(t.test(r))return!0}return!!n&&pe(e.parentNode,t,n)}function me(e,t,n){var o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===o)return!1;if("string"==typeof t){if(o.classList.contains(t))return!0;if(o.closest(".".concat(t)))return!0}else if(pe(o,t,!0))return!0;if(n){if(o.matches(n))return!0;if(o.closest(n))return!0}return!1}function fe(e,t){var n=t.doc,o=t.mirror,r=t.blockClass,i=t.blockSelector,s=t.maskTextClass,a=t.maskTextSelector,c=t.inlineStylesheet,d=t.maskInputOptions,u=void 0===d?{}:d,h=t.maskTextFn,g=t.maskInputFn,p=t.dataURLOptions,m=void 0===p?{}:p,f=t.inlineImages,I=t.recordCanvas,v=t.keepIframeSrcFn,C=t.newlyAddedElement,y=void 0!==C&&C,b=function(e,t){if(!t.hasNode(e))return;var 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:b};case e.ELEMENT_NODE:return function(e,t){for(var n=t.doc,o=t.blockClass,r=t.blockSelector,i=t.inlineStylesheet,s=t.maskInputOptions,a=void 0===s?{}:s,c=t.maskInputFn,d=t.dataURLOptions,u=void 0===d?{}:d,h=t.inlineImages,g=t.recordCanvas,p=t.keepIframeSrcFn,m=t.newlyAddedElement,f=void 0!==m&&m,I=t.rootId,v=function(e,t,n){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var o=e.classList.length;o--;){var r=e.classList[o];if(t.test(r))return!0}return!!n&&e.matches(n)}(e,o,r),C=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return ne.test(t)?"div":t}(e),y={},b=e.attributes.length,S=0;S<b;S++){var w=e.attributes[S];y[w.name]=ge(n,C,w.name,w.value)}if("link"===C&&i){var k=Array.from(n.styleSheets).find(function(t){return t.href===e.href}),A=null;k&&(A=q(k)),A&&(delete y.rel,delete y.href,y._cssText=ae(A,k.href))}if("style"===C&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){(A=q(e.sheet))&&(y._cssText=ae(A,he()))}if("input"===C||"textarea"===C||"select"===C){var T=e.value,M=e.checked;"radio"!==y.type&&"checkbox"!==y.type&&"submit"!==y.type&&"button"!==y.type&&T?y.value=Q({type:y.type,tagName:C,value:T,maskInputOptions:a,maskInputFn:c}):M&&(y.checked=M)}"option"===C&&(e.selected&&!a.select?y.selected=!0:delete y.selected);if("canvas"===C&&g)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var o=0;o<e.height;o+=50){var r=t.getImageData,i=X in r?r[X]:r;if(new Uint32Array(i.call(t,n,o,Math.min(50,e.width-n),Math.min(50,e.height-o)).data.buffer).some(function(e){return 0!==e}))return!1}return!0})(e)||(y.rr_dataURL=e.toDataURL(u.type,u.quality));else if(!("__context"in e)){var E=e.toDataURL(u.type,u.quality),R=document.createElement("canvas");R.width=e.width,R.height=e.height,E!==R.toDataURL(u.type,u.quality)&&(y.rr_dataURL=E)}if("img"===C&&h){$||($=n.createElement("canvas"),ee=$.getContext("2d"));var O=e,N=O.crossOrigin;O.crossOrigin="anonymous";var D=function(){try{$.width=O.naturalWidth,$.height=O.naturalHeight,ee.drawImage(O,0,0),y.rr_dataURL=$.toDataURL(u.type,u.quality)}catch(e){console.warn("Cannot inline img src=".concat(O.currentSrc,"! Error: ").concat(e))}N?y.crossOrigin=N:O.removeAttribute("crossorigin")};O.complete&&0!==O.naturalWidth?D():O.onload=D}"audio"!==C&&"video"!==C||(y.rr_mediaState=e.paused?"paused":"played",y.rr_mediaCurrentTime=e.currentTime);f||(e.scrollLeft&&(y.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(y.rr_scrollTop=e.scrollTop));if(v){var L=e.getBoundingClientRect(),F=L.width,x=L.height;y={class:y.class,rr_width:"".concat(F,"px"),rr_height:"".concat(x,"px")}}"iframe"!==C||p(y.src)||(e.contentDocument||(y.rr_src=y.src),delete y.src);return{type:l.Element,tagName:C,attributes:y,childNodes:[],isSVG:ue(e)||void 0,needBlock:v,rootId:I}}(e,{doc:n,blockClass:r,blockSelector:i,inlineStylesheet:c,maskInputOptions:u,maskInputFn:g,dataURLOptions:m,inlineImages:f,recordCanvas:I,keepIframeSrcFn:v,newlyAddedElement:y,rootId:b});case e.TEXT_NODE:return function(e,t){var n,o=t.maskTextClass,r=t.maskTextSelector,i=t.maskTextFn,s=t.rootId,a=e.parentNode&&e.parentNode.tagName,c=e.textContent,d="STYLE"===a||void 0,u="SCRIPT"===a||void 0;if(d&&c){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=(h=e.parentNode.sheet).cssRules?Array.from(h.cssRules).map(function(e){return e.cssText||""}).join(""):"")}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}c=ae(c,he())}var h;u&&(c="SCRIPT_PLACEHOLDER");!d&&!u&&c&&me(e,o,r)&&(c=i?i(c):c.replace(/[\S]/g,"*"));return{type:l.Text,textContent:c||"",isStyle:d,rootId:s}}(e,{maskTextClass:s,maskTextSelector:a,maskTextFn:h,rootId:b});case e.CDATA_SECTION_NODE:return{type:l.CDATA,textContent:"",rootId:b};case e.COMMENT_NODE:return{type:l.Comment,textContent:e.textContent||"",rootId:b};default:return!1}}function Ie(e){return void 0===e?"":e.toLowerCase()}function ve(e,t){var n,o=t.doc,r=t.mirror,i=t.blockClass,s=t.blockSelector,a=t.maskTextClass,c=t.maskTextSelector,d=t.skipChild,u=void 0!==d&&d,h=t.inlineStylesheet,g=void 0===h||h,p=t.maskInputOptions,m=void 0===p?{}:p,f=t.maskTextFn,I=t.maskInputFn,v=t.slimDOMOptions,C=t.dataURLOptions,y=void 0===C?{}:C,b=t.inlineImages,S=void 0!==b&&b,w=t.recordCanvas,k=void 0!==w&&w,A=t.onSerialize,T=t.onIframeLoad,M=t.iframeLoadTimeout,E=void 0===M?5e3:M,R=t.onStylesheetLoad,O=t.stylesheetLoadTimeout,N=void 0===O?5e3:O,D=t.keepIframeSrcFn,L=void 0===D?function(){return!1}:D,F=t.newlyAddedElement,x=void 0!==F&&F,B=t.preserveWhiteSpace,W=void 0===B||B,V=fe(e,{doc:o,mirror:r,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:g,maskInputOptions:m,maskTextFn:f,maskInputFn:I,dataURLOptions:y,inlineImages:S,recordCanvas:k,keepIframeSrcFn:L,newlyAddedElement:x});if(!V)return console.warn(e,"not serialized"),null;n=r.hasNode(e)?r.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&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(Ie(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===Ie(e.attributes.name)||"icon"===Ie(e.attributes.rel)||"apple-touch-icon"===Ie(e.attributes.rel)||"shortcut icon"===Ie(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&Ie(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(Ie(e.attributes.property).match(/^(og|twitter|fb):/)||Ie(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===Ie(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===Ie(e.attributes.name)||"googlebot"===Ie(e.attributes.name)||"bingbot"===Ie(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===Ie(e.attributes.name)||"generator"===Ie(e.attributes.name)||"framework"===Ie(e.attributes.name)||"publisher"===Ie(e.attributes.name)||"progid"===Ie(e.attributes.name)||Ie(e.attributes.property).match(/^article:/)||Ie(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===Ie(e.attributes.name)||"yandex-verification"===Ie(e.attributes.name)||"csrf-token"===Ie(e.attributes.name)||"p:domain_verify"===Ie(e.attributes.name)||"verify-v1"===Ie(e.attributes.name)||"verification"===Ie(e.attributes.name)||"shopify-checkout-api-token"===Ie(e.attributes.name)))return!0}}return!1}(V,v)&&(W||V.type!==l.Text||V.isStyle||V.textContent.replace(/^\s+|\s+$/gm,"").length)?oe():-2;var G=Object.assign(V,{id:n});if(r.add(e,G),-2===n)return null;A&&A(e);var Z=!u;if(G.type===l.Element){Z=Z&&!G.needBlock,delete G.needBlock;var U=e.shadowRoot;U&&j(U)&&(G.isShadowHost=!0)}if((G.type===l.Document||G.type===l.Element)&&Z){v.headWhitespace&&G.type===l.Element&&"head"===G.tagName&&(W=!1);for(var K={doc:o,mirror:r,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,skipChild:u,inlineStylesheet:g,maskInputOptions:m,maskTextFn:f,maskInputFn:I,slimDOMOptions:v,dataURLOptions:y,inlineImages:S,recordCanvas:k,preserveWhiteSpace:W,onSerialize:A,onIframeLoad:T,iframeLoadTimeout:E,onStylesheetLoad:R,stylesheetLoadTimeout:N,keepIframeSrcFn:L},_=0,z=Array.from(e.childNodes);_<z.length;_++){(P=ve(z[_],K))&&G.childNodes.push(P)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var Y=0,q=Array.from(e.shadowRoot.childNodes);Y<q.length;Y++){var P;(P=ve(q[Y],K))&&(j(e.shadowRoot)&&(P.isShadow=!0),G.childNodes.push(P))}}return e.parentNode&&H(e.parentNode)&&j(e.parentNode)&&(G.isShadow=!0),G.type===l.Element&&"iframe"===G.tagName&&function(e,t,n){var o=e.contentWindow;if(o){var r,i=!1;try{r=o.document.readyState}catch(e){return}if("complete"===r){var s="about:blank";if(o.location.href!==s||e.src===s||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout(function(){i||(t(),i=!0)},n);e.addEventListener("load",function(){clearTimeout(a),i=!0,t()})}}}(e,function(){var t=e.contentDocument;if(t&&T){var n=ve(t,{doc:t,mirror:r,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:g,maskInputOptions:m,maskTextFn:f,maskInputFn:I,slimDOMOptions:v,dataURLOptions:y,inlineImages:S,recordCanvas:k,preserveWhiteSpace:W,onSerialize:A,onIframeLoad:T,iframeLoadTimeout:E,onStylesheetLoad:R,stylesheetLoadTimeout:N,keepIframeSrcFn:L});n&&T(e,n)}},E),G.type===l.Element&&"link"===G.tagName&&"stylesheet"===G.attributes.rel&&function(e,t,n){var o,r=!1;try{o=e.sheet}catch(e){return}if(!o){var i=setTimeout(function(){r||(t(),r=!0)},n);e.addEventListener("load",function(){clearTimeout(i),r=!0,t()})}}(e,function(){if(R){var t=ve(e,{doc:o,mirror:r,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:g,maskInputOptions:m,maskTextFn:f,maskInputFn:I,slimDOMOptions:v,dataURLOptions:y,inlineImages:S,recordCanvas:k,preserveWhiteSpace:W,onSerialize:A,onIframeLoad:T,iframeLoadTimeout:E,onStylesheetLoad:R,stylesheetLoadTimeout:N,keepIframeSrcFn:L});t&&R(e,t)}},N),G}function Ce(e,t,n=document){const o={capture:!0,passive:!0};return n.addEventListener(e,t,o),()=>n.removeEventListener(e,t,o)}const ye="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 be={map:{},getId:()=>(console.error(ye),-1),getNode:()=>(console.error(ye),null),removeNodeFromMap(){console.error(ye)},has:()=>(console.error(ye),!1),reset(){console.error(ye)}};function Se(e,t,n={}){let o=null,r=0;return function(...i){const s=Date.now();r||!1!==n.leading||(r=s);const a=t-(s-r),c=this;a<=0||a>t?(o&&(clearTimeout(o),o=null),r=s,e.apply(c,i)):o||!1===n.trailing||(o=setTimeout(()=>{r=!1===n.leading?0:Date.now(),o=null,e.apply(c,i)},a))}}function we(e,t,n,o,r=window){const i=r.Object.getOwnPropertyDescriptor(e,t);return r.Object.defineProperty(e,t,o?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),i&&i.set&&i.set.call(this,e)}}),()=>we(e,t,i||{},!0)}function ke(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()=>{}}}function Ae(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Te(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Me(e,t,n,o){if(!e)return!1;const r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(o&&null!==r.closest("."+t))return!0}else if(pe(r,t,o))return!0;if(n){if(e.matches(n))return!0;if(o&&null!==r.closest(n))return!0}return!1}function Ee(e,t){return-2===t.getId(e)}function Re(e,t){if(H(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||Re(e.parentNode,t))}function Oe(e){return Boolean(e.changedTouches)}function Ne(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function De(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function Le(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(be=new Proxy(be,{get:(e,t,n)=>("map"===t&&console.error(ye),Reflect.get(e,t,n))}));class Fe{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++}}var xe=(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))(xe||{}),Be=(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))(Be||{}),We=(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))(We||{}),Ve=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(Ve||{});function Ge(e){return"__ln"in e}class Ze{constructor(){this.length=0,this.head=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&&Ge(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&&Ge(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;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.head=t.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const Ue=(e,t)=>`${e}@${t}`;class Ke{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],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 Ze,n=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{var r,i,s,a;let c=null;(null===(i=null===(r=o.getRootNode)||void 0===r?void 0:r.call(o))||void 0===i?void 0:i.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&o.getRootNode().host&&(c=o.getRootNode().host);let l=c;for(;(null===(a=null===(s=null==l?void 0:l.getRootNode)||void 0===s?void 0:s.call(l))||void 0===a?void 0:a.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&l.getRootNode().host;)l=l.getRootNode().host;const d=!(this.doc.contains(o)||l&&this.doc.contains(l));if(!o.parentNode||d)return;const u=H(o.parentNode)?this.mirror.getId(c):this.mirror.getId(o.parentNode),h=n(o);if(-1===u||-1===h)return t.addNode(o);const g=ve(o,{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=>{Ne(e,this.mirror)&&this.iframeManager.addIframe(e),De(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),Le(o)&&this.shadowDomManager.addShadowRoot(o.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});g&&e.push({parentId:u,nextId:h,node:g})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of Array.from(this.movedSet.values()))ze(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||o(e);for(const e of Array.from(this.addedSet.values()))He(this.droppedSet,e)||ze(this.removes,e,this.mirror)?He(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let r=null;for(;t.length;){let e=null;if(r){const t=this.mirror.getId(r.value.parentNode),o=n(r.value);-1!==t&&-1!==o&&(e=r)}if(!e)for(let o=t.length-1;o>=0;o--){const r=t.get(o);if(r){const t=this.mirror.getId(r.value.parentNode);if(-1===n(r.value))continue;if(-1!==t){e=r;break}{const t=r.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=t.parentNode.host;if(-1!==this.mirror.getId(n)){e=r;break}}}}}if(!e){for(;t.head;)t.removeNode(t.head.value);break}r=e.previous,t.removeNode(e.value),o(e.value)}const i={texts:this.texts.map(e=>({id:this.mirror.getId(e.node),value:e.value})).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>({id:this.mirror.getId(e.node),attributes:e.attributes})).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.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(i))},this.processMutation=e=>{if(!Ee(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;Me(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:me(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.target.getAttribute(e.attributeName);if("value"===e.attributeName&&(n=Q({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),Me(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let o=this.attributes.find(t=>t.node===e.target);if("IFRAME"===t.tagName&&"src"===e.attributeName&&!this.keepIframeSrcFn(n)){if(t.contentDocument)return;e.attributeName="rr_src"}if(o||(o={node:e.target,attributes:{}},this.attributes.push(o)),"style"===e.attributeName){const n=this.doc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue),void 0!==o.attributes.style&&null!==o.attributes.style||(o.attributes.style={});const r=o.attributes.style;for(const e of Array.from(t.style)){const o=t.style.getPropertyValue(e),i=t.style.getPropertyPriority(e);o===n.style.getPropertyValue(e)&&i===n.style.getPropertyPriority(e)||(r[e]=""===i?o:[o,i])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(r[e]=!1)}else o.attributes[e.attributeName]=ge(this.doc,t.tagName,e.attributeName,n);break}case"childList":if(Me(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const n=this.mirror.getId(t),o=H(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);Me(e.target,this.blockClass,this.blockSelector,!1)||Ee(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(_e(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||Re(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Ue(n,o)]?_e(this.movedSet,t):this.removes.push({parentId:o,id:n,isShadow:!(!H(e.target)||!j(e.target))||void 0})),this.mapRemoves.push(t))})}},this.genAdds=(e,t)=>{if(this.mirror.hasNode(e)){if(Ee(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[Ue(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);Me(e,this.blockClass,this.blockSelector,!1)||e.childNodes.forEach(e=>this.genAdds(e))}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].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 _e(e,t){e.delete(t),t.childNodes.forEach(t=>_e(e,t))}function ze(e,t,n){return 0!==e.length&&Ye(e,t,n)}function Ye(e,t,n){const{parentNode:o}=t;if(!o)return!1;const r=n.getId(o);return!!e.some(e=>e.id===r)||Ye(e,o,n)}function He(e,t){return 0!==e.size&&je(e,t)}function je(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||je(e,n))}const qe=[],Pe="undefined"!=typeof CSSGroupingRule,Je="undefined"!=typeof CSSMediaRule,Qe="undefined"!=typeof CSSSupportsRule,Xe="undefined"!=typeof CSSConditionRule;function $e(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];return e.target}catch(t){return e.target}}function et(e,t){var n,o;const r=new Ke;qe.push(r),r.init(e);let i=window.MutationObserver||window.__rrMutationObserver;const s=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");s&&window[s]&&(i=window[s]);const a=new i(r.processMutations.bind(r));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function tt({mouseInteractionCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:i}){if(!1===i.mouseInteraction)return()=>{};const s=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,a=[];return Object.keys(We).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]).forEach(i=>{const s=i.toLowerCase(),c=(t=>i=>{const s=$e(i);if(Me(s,o,r,!0))return;const a=Oe(i)?i.changedTouches[0]:i;if(!a)return;const c=n.getId(s),{clientX:l,clientY:d}=a;e({type:We[t],id:c,x:l,y:d})})(i);a.push(Ce(s,c,t))}),()=>{a.forEach(e=>e())}}function nt({scrollCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:i}){return Ce("scroll",Se(i=>{const s=$e(i);if(!s||Me(s,o,r,!0))return;const a=n.getId(s);if(s===t){const n=t.scrollingElement||t.documentElement;e({id:a,x:n.scrollLeft,y:n.scrollTop})}else e({id:a,x:s.scrollLeft,y:s.scrollTop})},i.scroll||100),t)}function ot(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const rt=["INPUT","TEXTAREA","SELECT"],it=new WeakMap;function st(e){return function(e,t){if(Pe&&e.parentRule instanceof CSSGroupingRule||Je&&e.parentRule instanceof CSSMediaRule||Qe&&e.parentRule instanceof CSSSupportsRule||Xe&&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 at(e,t,n){let o,r;return e?(e.ownerNode?o=t.getId(e.ownerNode):r=n.getId(e),{styleId:r,id:o}):{}}function ct({mirror:e,stylesheetManager:t},n){var o,r,i;let s=null;s="#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===(i=null===(r=n.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===i?void 0:i.ShadowRoot,c=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==s&&-1!==s&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null===(e=c.get)||void 0===e?void 0:e.call(this)},set(e){var n;const o=null===(n=c.set)||void 0===n?void 0:n.call(this,e);if(null!==s&&-1!==s)try{t.adoptStyleSheets(e,s)}catch(e){}return o}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}):()=>{}}function lt(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:o,mouseInteractionCb:r,scrollCb:i,viewportResizeCb:s,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:g}=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),i(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),s(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...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),g(...e)}}(e,t);const o=et(e,e.doc),r=function({mousemoveCb:e,sampling:t,doc:n,mirror:o}){if(!1===t.mousemove)return()=>{};const r="number"==typeof t.mousemove?t.mousemove:50,i="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let s,a=[];const c=Se(t=>{const n=Date.now()-s;e(a.map(e=>(e.timeOffset-=n,e)),t),a=[],s=null},i),l=Se(e=>{const t=$e(e),{clientX:n,clientY:r}=Oe(e)?e.changedTouches[0]:e;s||(s=Date.now()),a.push({x:n,y:r,id:o.getId(t),timeOffset:Date.now()-s}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?Be.Drag:e instanceof MouseEvent?Be.MouseMove:Be.TouchMove)},r,{trailing:!1}),d=[Ce("mousemove",l,n),Ce("touchmove",l,n),Ce("drag",l,n)];return()=>{d.forEach(e=>e())}}(e),i=tt(e),s=nt(e),a=function({viewportResizeCb:e}){let t=-1,n=-1;return Ce("resize",Se(()=>{const o=Ae(),r=Te();t===o&&n===r||(e({width:Number(r),height:Number(o)}),t=o,n=r)},200),window)}(e),c=function({inputCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,ignoreClass:i,maskInputOptions:s,maskInputFn:a,sampling:c,userTriggeredOnInput:l}){function d(e){let n=$e(e);const c=e.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||rt.indexOf(n.tagName)<0||Me(n,o,r,!0))return;const d=n.type;if(n.classList.contains(i))return;let h=n.value,g=!1;"radio"===d||"checkbox"===d?g=n.checked:(s[n.tagName.toLowerCase()]||s[d])&&(h=Q({maskInputOptions:s,tagName:n.tagName,type:d,value:h,maskInputFn:a})),u(n,ot({text:h,isChecked:g,userTriggered:c},l));const p=n.name;"radio"===d&&p&&g&&t.querySelectorAll(`input[type="radio"][name="${p}"]`).forEach(e=>{e!==n&&u(e,ot({text:e.value,isChecked:!g,userTriggered:!1},l))})}function u(t,o){const r=it.get(t);if(!r||r.text!==o.text||r.isChecked!==o.isChecked){it.set(t,o);const r=n.getId(t);e(Object.assign(Object.assign({},o),{id:r}))}}const h=("last"===c.input?["change"]:["input","change"]).map(e=>Ce(e,d,t)),g=t.defaultView;if(!g)return()=>{h.forEach(e=>e())};const p=g.Object.getOwnPropertyDescriptor(g.HTMLInputElement.prototype,"value"),m=[[g.HTMLInputElement.prototype,"value"],[g.HTMLInputElement.prototype,"checked"],[g.HTMLSelectElement.prototype,"value"],[g.HTMLTextAreaElement.prototype,"value"],[g.HTMLSelectElement.prototype,"selectedIndex"],[g.HTMLOptionElement.prototype,"selected"]];return p&&p.set&&h.push(...m.map(e=>we(e[0],e[1],{set(){d({target:this})}},!1,g))),()=>{h.forEach(e=>e())}}(e),l=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:o,sampling:r}){const i=i=>Se(r=>{const s=$e(r);if(!s||Me(s,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:d}=s;e({type:i,id:o.getId(s),currentTime:a,volume:c,muted:l,playbackRate:d})},r.media||500),s=[Ce("play",i(0)),Ce("pause",i(1)),Ce("seeked",i(2)),Ce("volumechange",i(3)),Ce("ratechange",i(4))];return()=>{s.forEach(e=>e())}}(e),d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:o}){const r=o.CSSStyleSheet.prototype.insertRule;o.CSSStyleSheet.prototype.insertRule=function(o,i){const{id:s,styleId:a}=at(this,t,n.styleMirror);return(s&&-1!==s||a&&-1!==a)&&e({id:s,styleId:a,adds:[{rule:o,index:i}]}),r.apply(this,[o,i])};const i=o.CSSStyleSheet.prototype.deleteRule;let s,a;o.CSSStyleSheet.prototype.deleteRule=function(o){const{id:r,styleId:s}=at(this,t,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&e({id:r,styleId:s,removes:[{index:o}]}),i.apply(this,[o])},o.CSSStyleSheet.prototype.replace&&(s=o.CSSStyleSheet.prototype.replace,o.CSSStyleSheet.prototype.replace=function(o){const{id:r,styleId:i}=at(this,t,n.styleMirror);return(r&&-1!==r||i&&-1!==i)&&e({id:r,styleId:i,replace:o}),s.apply(this,[o])}),o.CSSStyleSheet.prototype.replaceSync&&(a=o.CSSStyleSheet.prototype.replaceSync,o.CSSStyleSheet.prototype.replaceSync=function(o){const{id:r,styleId:i}=at(this,t,n.styleMirror);return(r&&-1!==r||i&&-1!==i)&&e({id:r,styleId:i,replaceSync:o}),a.apply(this,[o])});const c={};Pe?c.CSSGroupingRule=o.CSSGroupingRule:(Je&&(c.CSSMediaRule=o.CSSMediaRule),Xe&&(c.CSSConditionRule=o.CSSConditionRule),Qe&&(c.CSSSupportsRule=o.CSSSupportsRule));const l={};return Object.entries(c).forEach(([o,r])=>{l[o]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=function(r,i){const{id:s,styleId:a}=at(this.parentStyleSheet,t,n.styleMirror);return(s&&-1!==s||a&&-1!==a)&&e({id:s,styleId:a,adds:[{rule:r,index:[...st(this),i||0]}]}),l[o].insertRule.apply(this,[r,i])},r.prototype.deleteRule=function(r){const{id:i,styleId:s}=at(this.parentStyleSheet,t,n.styleMirror);return(i&&-1!==i||s&&-1!==s)&&e({id:i,styleId:s,removes:[{index:[...st(this),r]}]}),l[o].deleteRule.apply(this,[r])}}),()=>{o.CSSStyleSheet.prototype.insertRule=r,o.CSSStyleSheet.prototype.deleteRule=i,s&&(o.CSSStyleSheet.prototype.replace=s),a&&(o.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule})}}(e,{win:n}),u=ct(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:o},{win:r}){const i=r.CSSStyleDeclaration.prototype.setProperty;r.CSSStyleDeclaration.prototype.setProperty=function(r,s,a){var c;if(n.has(r))return i.apply(this,[r,s,a]);const{id:l,styleId:d}=at(null===(c=this.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,o.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,set:{property:r,value:s,priority:a},index:st(this.parentRule)}),i.apply(this,[r,s,a])};const s=r.CSSStyleDeclaration.prototype.removeProperty;return r.CSSStyleDeclaration.prototype.removeProperty=function(r){var i;if(n.has(r))return s.apply(this,[r]);const{id:a,styleId:c}=at(null===(i=this.parentRule)||void 0===i?void 0:i.parentStyleSheet,t,o.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,remove:{property:r},index:st(this.parentRule)}),s.apply(this,[r])},()=>{r.CSSStyleDeclaration.prototype.setProperty=i,r.CSSStyleDeclaration.prototype.removeProperty=s}}(e,{win:n}),g=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const o=[],r=new WeakMap,i=n.FontFace;n.FontFace=function(e,t,n){const o=new i(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 s=ke(t.fonts,"add",function(t){return function(n){return setTimeout(()=>{const t=r.get(n);t&&(e(t),r.delete(n))},0),t.apply(this,[n])}});return o.push(()=>{n.FontFace=i}),o.push(s),()=>{o.forEach(e=>e())}}(e):()=>{},p=function(e){const{doc:t,mirror:n,blockClass:o,blockSelector:r,selectionCb:i}=e;let s=!0;const a=()=>{const e=t.getSelection();if(!e||s&&(null==e?void 0:e.isCollapsed))return;s=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const i=e.getRangeAt(t),{startContainer:s,startOffset:c,endContainer:l,endOffset:d}=i;Me(s,o,r,!0)||Me(l,o,r,!0)||a.push({start:n.getId(s),startOffset:c,end:n.getId(l),endOffset:d})}i({ranges:a})};return a(),Ce("selectionchange",a)}(e),m=[];for(const t of e.plugins)m.push(t.observer(t.callback,n,t.options));return()=>{qe.forEach(e=>e.reset()),o.disconnect(),r(),i(),s(),a(),c(),l(),d(),u(),h(),g(),p(),m.forEach(e=>e())}}class dt{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,o){const r=n||this.getIdToRemoteIdMap(e),i=o||this.getRemoteIdToIdMap(e);let s=r.get(t);return s||(s=this.generateIdFn(),r.set(t,s),i.set(s,t)),s}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 ut{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new dt(oe),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new dt(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){if("rrweb"===e.data.type){if(!e.source)return;const t=this.crossOriginIframeMap.get(e.source);if(!t)return;const n=this.transformCrossOriginEvent(t,e.data.event);n&&this.wrappedEmit(n,e.data.isCheckout)}}transformCrossOriginEvent(e,t){var n;switch(t.type){case xe.FullSnapshot:return this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e),{timestamp:t.timestamp,type:xe.IncrementalSnapshot,data:{source:Be.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case xe.Meta:case xe.Load:case xe.DomContentLoaded:return!1;case xe.Plugin:return t;case xe.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case xe.IncrementalSnapshot:switch(t.data.source){case Be.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e)}),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 Be.Drag:case Be.TouchMove:case Be.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case Be.ViewportResize:return!1;case Be.MediaInteraction:case Be.MouseInteraction:case Be.Scroll:case Be.CanvasMutation:case Be.Input:return this.replaceIds(t.data,e,["id"]),t;case Be.StyleSheetRule:case Be.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case Be.Font:return t;case Be.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case Be.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}}}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"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}}class ht{constructor(e){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror;const t=this;this.restorePatches.push(ke(Element.prototype,"attachShadow",function(e){return function(n){const o=e.call(this,n);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,this.ownerDocument),o}}))}addShadowRoot(e,t){j(e)&&(this.shadowDoms.has(e)||(this.shadowDoms.add(e),et(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),nt(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)),ct({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)},0)))}observeAttachShadow(e){if(e.contentWindow){const t=this;this.restorePatches.push(ke(e.contentWindow.HTMLElement.prototype,"attachShadow",function(n){return function(o){const r=n.call(this,o);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,e.contentDocument),r}}))}}reset(){this.restorePatches.forEach(e=>e()),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,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((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,i,s,a,c,l=-1,d=function(e){addEventListener("pageshow",function(t){t.persisted&&(l=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},g=function(e,t){var n=u(),o="navigate";return l>=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}},p=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){}},m=function(e,t,n,o){var r,i;return function(s){t.value>=0&&(s||o)&&((i=t.value-(r||0))||void 0===r)&&(r=t.value,t.delta=i,t.rating=function(e,t){return e>t[1]?"poor":e>t[0]?"needs-improvement":"good"}(t.value,n),e(t))}},f=function(e){requestAnimationFrame(function(){return requestAnimationFrame(function(){return e()})})},I=function(e){var t=function(t){"pagehide"!==t.type&&"hidden"!==document.visibilityState||e(t)};addEventListener("visibilitychange",t,!0),addEventListener("pagehide",t,!0)},v=function(e){var t=!1;return function(n){t||(e(n),t=!0)}},C=-1,y=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},b=function(e){"hidden"===document.visibilityState&&C>-1&&(C="visibilitychange"===e.type?e.timeStamp:0,w())},S=function(){addEventListener("visibilitychange",b,!0),addEventListener("prerenderingchange",b,!0)},w=function(){removeEventListener("visibilitychange",b,!0),removeEventListener("prerenderingchange",b,!0)},k=function(){return C<0&&(C=y(),S(),d(function(){setTimeout(function(){C=y(),S()},0)})),{get firstHiddenTime(){return C}}},A=function(e){document.prerendering?addEventListener("prerenderingchange",function(){return e()},!0):e()},T=[1800,3e3],M=function(e,t){t=t||{},A(function(){var n,o=k(),r=g("FCP"),i=p("paint",function(e){e.forEach(function(e){"first-contentful-paint"===e.name&&(i.disconnect(),e.startTime<o.firstHiddenTime&&(r.value=Math.max(e.startTime-h(),0),r.entries.push(e),n(!0)))})});i&&(n=m(e,r,T,t.reportAllChanges),d(function(o){r=g("FCP"),n=m(e,r,T,t.reportAllChanges),f(function(){r.value=performance.now()-o.timeStamp,n(!0)})}))})},E=[.1,.25],R={passive:!0,capture:!0},O=new Date,N=function(e,t){r||(r=t,i=e,s=new Date,F(removeEventListener),D())},D=function(){if(i>=0&&i<s-O){var e={entryType:"first-input",name:r.type,target:r.target,cancelable:r.cancelable,startTime:r.timeStamp,processingStart:r.timeStamp+i};a.forEach(function(t){t(e)}),a=[]}},L=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(){N(e,t),r()},o=function(){r()},r=function(){removeEventListener("pointerup",n,R),removeEventListener("pointercancel",o,R)};addEventListener("pointerup",n,R),addEventListener("pointercancel",o,R)}(t,e):N(t,e)}},F=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach(function(t){return e(t,L,R)})},x=[100,300],B=[2500,4e3],W={},V=[800,1800],G=function e(t){document.prerendering?A(function(){return e(t)}):"complete"!==document.readyState?addEventListener("load",function(){return e(t)},!0):setTimeout(t,0)},Z=function(e,t){t=t||{};var n=g("TTFB"),o=m(e,n,V,t.reportAllChanges);G(function(){var r=u();if(r){var i=r.responseStart;if(i<=0||i>performance.now())return;n.value=Math.max(i-h(),0),n.entries=[r],o(!0),d(function(){n=g("TTFB",0),(o=m(e,n,V,t.reportAllChanges))(!0)})}})};class U{constructor(e,t){this.config=e,this.transport=t,this.metrics={}}start(){!function(e,t){t=t||{},M(v(function(){var n,o=g("CLS",0),r=0,i=[],s=function(e){e.forEach(function(e){if(!e.hadRecentInput){var t=i[0],n=i[i.length-1];r&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(r+=e.value,i.push(e)):(r=e.value,i=[e])}}),r>o.value&&(o.value=r,o.entries=i,n())},a=p("layout-shift",s);a&&(n=m(e,o,E,t.reportAllChanges),I(function(){s(a.takeRecords()),n(!0)}),d(function(){r=0,o=g("CLS",0),n=m(e,o,E,t.reportAllChanges),f(function(){return n()})}),setTimeout(n,0))}))}(e=>this.handleMetric(e)),M(e=>this.handleMetric(e)),function(e,t){t=t||{},A(function(){var n,o=k(),s=g("FID"),c=function(e){e.startTime<o.firstHiddenTime&&(s.value=e.processingStart-e.startTime,s.entries.push(e),n(!0))},l=function(e){e.forEach(c)},u=p("first-input",l);n=m(e,s,x,t.reportAllChanges),u&&I(v(function(){l(u.takeRecords()),u.disconnect()})),u&&d(function(){var o;s=g("FID"),n=m(e,s,x,t.reportAllChanges),a=[],i=-1,r=null,F(addEventListener),o=c,a.push(o),D()})})}(e=>this.handleMetric(e)),function(e,t){t=t||{},A(function(){var n,o=k(),r=g("LCP"),i=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())},s=p("largest-contentful-paint",i);if(s){n=m(e,r,B,t.reportAllChanges);var a=v(function(){W[r.id]||(i(s.takeRecords()),s.disconnect(),W[r.id]=!0,n(!0))});["keydown","click"].forEach(function(e){addEventListener(e,function(){return setTimeout(a,0)},!0)}),I(a),d(function(o){r=g("LCP"),n=m(e,r,B,t.reportAllChanges),f(function(){r.value=performance.now()-o.timeStamp,W[r.id]=!0,n(!0)})})}})}(e=>this.handleMetric(e)),Z(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 K{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 i=(null===(n=this.config.errorOptions)||void 0===n?void 0:n.denyUrls)||[],s=e instanceof Error?e.stack:"";for(const e of i)if(e.test(s||""))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 _{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[i,s]=n,a="string"==typeof i?i:i instanceof Request?i.url:i.toString(),c=(null==s?void 0:s.method)||"GET",l=Date.now();try{const i=yield e(...n),s=i.clone(),d=Date.now()-l;if(this.shouldIgnoreUrl(a))return i;if((null===(t=this.config.networkRequestOptions)||void 0===t?void 0:t.captureFailedOnly)&&i.ok)return i;const u={url:a,method:c,status:i.status,duration:d,size:yield this.getResponseSize(s),type:"fetch",timestamp:(new Date).toISOString(),failed:!i.ok};if((null===(o=this.config.networkRequestOptions)||void 0===o?void 0:o.captureHeaders)&&(u.headers=this.headersToObject(i.headers)),(null===(r=this.config.networkRequestOptions)||void 0===r?void 0:r.captureBody)&&!i.ok)try{const e=yield s.text();u.body=e.substring(0,1e4)}catch(e){}return this.config.debug&&console.log("[DevSkin] Network request tracked:",u),this.transport.sendNetworkRequest(u),i}catch(e){const t=Date.now()-l;if(!this.shouldIgnoreUrl(a)){const e={url:a,method:c,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,i){return this.__devskin={method:t,url:n.toString(),startTime:Date.now()},void 0!==r?e.call(this,t,n,null==o||o,r,null!=i?i: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,i=()=>{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,i,s;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 c={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)&&(c.headers=r.parseResponseHeaders(n.getAllResponseHeaders())),(null===(i=null==r?void 0:r.config.networkRequestOptions)||void 0===i?void 0:i.captureBody)&&c.failed)try{c.body=null===(s=n.responseText)||void 0===s?void 0:s.substring(0,1e4)}catch(e){}(null==r?void 0:r.config.debug)&&console.log("[DevSkin] XHR request tracked:",c),null==r||r.transport.sendNetworkRequest(c)}),n.addEventListener("error",i),n.addEventListener("abort",i),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 z{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,i=e.clientX+window.scrollX,s=e.clientY+window.scrollY,a={x:e.clientX,y:e.clientY,relativeX:o,relativeY:r,pageX:i,pageY:s,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 Y(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function H(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function q(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t).map(j).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(e){return null}var n}function j(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=q(e.styleSheet)||t}catch(e){}return t}!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"}(c||(c={}));var P=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(e){var t;if(!e)return-1;var n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1},e.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},e.prototype.removeNodeFromMap=function(e){var t=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach(function(e){return t.removeNodeFromMap(e)})},e.prototype.has=function(e){return this.idNodeMap.has(e)},e.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},e.prototype.add=function(e,t){var n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)},e.prototype.replace=function(e,t){var n=this.getNode(e);if(n){var o=this.nodeMetaMap.get(n);o&&this.nodeMetaMap.set(t,o)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function J(e){var t=e.maskInputOptions,n=e.tagName,o=e.type,r=e.value,i=e.maskInputFn,s=r||"";return(t[n.toLowerCase()]||t[o])&&(s=i?i(s):"*".repeat(s.length)),s}var Q="__rrweb_original__";var X,$,ee=1,te=new RegExp("[^a-z0-9-_:]");function ne(){return ee++}var oe=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,re=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,ie=/^(data:)([^,]*),(.*)/i;function se(e,t){return(e||"").replace(oe,function(e,n,o,r,i,s){var a,c=o||i||s,l=n||r||"";if(!c)return e;if(!re.test(c))return"url(".concat(l).concat(c).concat(l,")");if(ie.test(c))return"url(".concat(l).concat(c).concat(l,")");if("/"===c[0])return"url(".concat(l).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+c)).concat(l,")");var d=t.split("/"),u=c.split("/");d.pop();for(var h=0,g=u;h<g.length;h++){var p=g[h];"."!==p&&(".."===p?d.pop():d.push(p))}return"url(".concat(l).concat(d.join("/")).concat(l,")")})}var ae=/^[^ \t\n\r\u000c]+/,ce=/^[, \t\n\r\u000c]+/;function le(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function de(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function ue(){var e=document.createElement("a");return e.href="",e.href}function he(e,t,n,o){return"src"===n||"href"===n&&o&&("use"!==t||"#"!==o[0])||"xlink:href"===n&&o&&"#"!==o[0]?le(e,o):"background"!==n||!o||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n&&o?function(e,t){if(""===t.trim())return t;var n=0;function o(e){var o,r=e.exec(t.substring(n));return r?(o=r[0],n+=o.length,o):""}for(var r=[];o(ce),!(n>=t.length);){var i=o(ae);if(","===i.slice(-1))i=le(e,i.substring(0,i.length-1)),r.push(i);else{var s="";i=le(e,i);for(var a=!1;;){var c=t.charAt(n);if(""===c){r.push((i+s).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,r.push((i+s).trim());break}"("===c&&(a=!0)}s+=c,n+=1}}}return r.join(", ")}(e,o):"style"===n&&o?se(o,ue()):"object"===t&&"data"===n&&o?le(e,o):o:le(e,o)}function ge(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&ge(e.parentNode,t,n);for(var o=e.classList.length;o--;){var r=e.classList[o];if(t.test(r))return!0}return!!n&&ge(e.parentNode,t,n)}function pe(e,t,n){var o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===o)return!1;if("string"==typeof t){if(o.classList.contains(t))return!0;if(o.closest(".".concat(t)))return!0}else if(ge(o,t,!0))return!0;if(n){if(o.matches(n))return!0;if(o.closest(n))return!0}return!1}function me(e,t){var n=t.doc,o=t.mirror,r=t.blockClass,i=t.blockSelector,s=t.maskTextClass,a=t.maskTextSelector,l=t.inlineStylesheet,d=t.maskInputOptions,u=void 0===d?{}:d,h=t.maskTextFn,g=t.maskInputFn,p=t.dataURLOptions,m=void 0===p?{}:p,f=t.inlineImages,I=t.recordCanvas,v=t.keepIframeSrcFn,C=t.newlyAddedElement,y=void 0!==C&&C,b=function(e,t){if(!t.hasNode(e))return;var n=t.getId(e);return 1===n?void 0:n}(n,o);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:c.Document,childNodes:[],compatMode:e.compatMode}:{type:c.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:c.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:b};case e.ELEMENT_NODE:return function(e,t){for(var n=t.doc,o=t.blockClass,r=t.blockSelector,i=t.inlineStylesheet,s=t.maskInputOptions,a=void 0===s?{}:s,l=t.maskInputFn,d=t.dataURLOptions,u=void 0===d?{}:d,h=t.inlineImages,g=t.recordCanvas,p=t.keepIframeSrcFn,m=t.newlyAddedElement,f=void 0!==m&&m,I=t.rootId,v=function(e,t,n){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var o=e.classList.length;o--;){var r=e.classList[o];if(t.test(r))return!0}return!!n&&e.matches(n)}(e,o,r),C=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return te.test(t)?"div":t}(e),y={},b=e.attributes.length,S=0;S<b;S++){var w=e.attributes[S];y[w.name]=he(n,C,w.name,w.value)}if("link"===C&&i){var k=Array.from(n.styleSheets).find(function(t){return t.href===e.href}),A=null;k&&(A=q(k)),A&&(delete y.rel,delete y.href,y._cssText=se(A,k.href))}if("style"===C&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){(A=q(e.sheet))&&(y._cssText=se(A,ue()))}if("input"===C||"textarea"===C||"select"===C){var T=e.value,M=e.checked;"radio"!==y.type&&"checkbox"!==y.type&&"submit"!==y.type&&"button"!==y.type&&T?y.value=J({type:y.type,tagName:C,value:T,maskInputOptions:a,maskInputFn:l}):M&&(y.checked=M)}"option"===C&&(e.selected&&!a.select?y.selected=!0:delete y.selected);if("canvas"===C&&g)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var o=0;o<e.height;o+=50){var r=t.getImageData,i=Q in r?r[Q]:r;if(new Uint32Array(i.call(t,n,o,Math.min(50,e.width-n),Math.min(50,e.height-o)).data.buffer).some(function(e){return 0!==e}))return!1}return!0})(e)||(y.rr_dataURL=e.toDataURL(u.type,u.quality));else if(!("__context"in e)){var E=e.toDataURL(u.type,u.quality),R=document.createElement("canvas");R.width=e.width,R.height=e.height,E!==R.toDataURL(u.type,u.quality)&&(y.rr_dataURL=E)}if("img"===C&&h){X||(X=n.createElement("canvas"),$=X.getContext("2d"));var O=e,N=O.crossOrigin;O.crossOrigin="anonymous";var D=function(){try{X.width=O.naturalWidth,X.height=O.naturalHeight,$.drawImage(O,0,0),y.rr_dataURL=X.toDataURL(u.type,u.quality)}catch(e){console.warn("Cannot inline img src=".concat(O.currentSrc,"! Error: ").concat(e))}N?y.crossOrigin=N:O.removeAttribute("crossorigin")};O.complete&&0!==O.naturalWidth?D():O.onload=D}"audio"!==C&&"video"!==C||(y.rr_mediaState=e.paused?"paused":"played",y.rr_mediaCurrentTime=e.currentTime);f||(e.scrollLeft&&(y.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(y.rr_scrollTop=e.scrollTop));if(v){var L=e.getBoundingClientRect(),F=L.width,x=L.height;y={class:y.class,rr_width:"".concat(F,"px"),rr_height:"".concat(x,"px")}}"iframe"!==C||p(y.src)||(e.contentDocument||(y.rr_src=y.src),delete y.src);return{type:c.Element,tagName:C,attributes:y,childNodes:[],isSVG:de(e)||void 0,needBlock:v,rootId:I}}(e,{doc:n,blockClass:r,blockSelector:i,inlineStylesheet:l,maskInputOptions:u,maskInputFn:g,dataURLOptions:m,inlineImages:f,recordCanvas:I,keepIframeSrcFn:v,newlyAddedElement:y,rootId:b});case e.TEXT_NODE:return function(e,t){var n,o=t.maskTextClass,r=t.maskTextSelector,i=t.maskTextFn,s=t.rootId,a=e.parentNode&&e.parentNode.tagName,l=e.textContent,d="STYLE"===a||void 0,u="SCRIPT"===a||void 0;if(d&&l){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(l=(h=e.parentNode.sheet).cssRules?Array.from(h.cssRules).map(function(e){return e.cssText||""}).join(""):"")}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}l=se(l,ue())}var h;u&&(l="SCRIPT_PLACEHOLDER");!d&&!u&&l&&pe(e,o,r)&&(l=i?i(l):l.replace(/[\S]/g,"*"));return{type:c.Text,textContent:l||"",isStyle:d,rootId:s}}(e,{maskTextClass:s,maskTextSelector:a,maskTextFn:h,rootId:b});case e.CDATA_SECTION_NODE:return{type:c.CDATA,textContent:"",rootId:b};case e.COMMENT_NODE:return{type:c.Comment,textContent:e.textContent||"",rootId:b};default:return!1}}function fe(e){return void 0===e?"":e.toLowerCase()}function Ie(e,t){var n,o=t.doc,r=t.mirror,i=t.blockClass,s=t.blockSelector,a=t.maskTextClass,l=t.maskTextSelector,d=t.skipChild,u=void 0!==d&&d,h=t.inlineStylesheet,g=void 0===h||h,p=t.maskInputOptions,m=void 0===p?{}:p,f=t.maskTextFn,I=t.maskInputFn,v=t.slimDOMOptions,C=t.dataURLOptions,y=void 0===C?{}:C,b=t.inlineImages,S=void 0!==b&&b,w=t.recordCanvas,k=void 0!==w&&w,A=t.onSerialize,T=t.onIframeLoad,M=t.iframeLoadTimeout,E=void 0===M?5e3:M,R=t.onStylesheetLoad,O=t.stylesheetLoadTimeout,N=void 0===O?5e3:O,D=t.keepIframeSrcFn,L=void 0===D?function(){return!1}:D,F=t.newlyAddedElement,x=void 0!==F&&F,B=t.preserveWhiteSpace,W=void 0===B||B,V=me(e,{doc:o,mirror:r,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:l,inlineStylesheet:g,maskInputOptions:m,maskTextFn:f,maskInputFn:I,dataURLOptions:y,inlineImages:S,recordCanvas:k,keepIframeSrcFn:L,newlyAddedElement:x});if(!V)return console.warn(e,"not serialized"),null;n=r.hasNode(e)?r.getId(e):!function(e,t){if(t.comment&&e.type===c.Comment)return!0;if(e.type===c.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===e.attributes.rel&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(fe(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===fe(e.attributes.name)||"icon"===fe(e.attributes.rel)||"apple-touch-icon"===fe(e.attributes.rel)||"shortcut icon"===fe(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&fe(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(fe(e.attributes.property).match(/^(og|twitter|fb):/)||fe(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===fe(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===fe(e.attributes.name)||"googlebot"===fe(e.attributes.name)||"bingbot"===fe(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===fe(e.attributes.name)||"generator"===fe(e.attributes.name)||"framework"===fe(e.attributes.name)||"publisher"===fe(e.attributes.name)||"progid"===fe(e.attributes.name)||fe(e.attributes.property).match(/^article:/)||fe(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===fe(e.attributes.name)||"yandex-verification"===fe(e.attributes.name)||"csrf-token"===fe(e.attributes.name)||"p:domain_verify"===fe(e.attributes.name)||"verify-v1"===fe(e.attributes.name)||"verification"===fe(e.attributes.name)||"shopify-checkout-api-token"===fe(e.attributes.name)))return!0}}return!1}(V,v)&&(W||V.type!==c.Text||V.isStyle||V.textContent.replace(/^\s+|\s+$/gm,"").length)?ne():-2;var G=Object.assign(V,{id:n});if(r.add(e,G),-2===n)return null;A&&A(e);var Z=!u;if(G.type===c.Element){Z=Z&&!G.needBlock,delete G.needBlock;var U=e.shadowRoot;U&&H(U)&&(G.isShadowHost=!0)}if((G.type===c.Document||G.type===c.Element)&&Z){v.headWhitespace&&G.type===c.Element&&"head"===G.tagName&&(W=!1);for(var K={doc:o,mirror:r,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:l,skipChild:u,inlineStylesheet:g,maskInputOptions:m,maskTextFn:f,maskInputFn:I,slimDOMOptions:v,dataURLOptions:y,inlineImages:S,recordCanvas:k,preserveWhiteSpace:W,onSerialize:A,onIframeLoad:T,iframeLoadTimeout:E,onStylesheetLoad:R,stylesheetLoadTimeout:N,keepIframeSrcFn:L},_=0,z=Array.from(e.childNodes);_<z.length;_++){(P=Ie(z[_],K))&&G.childNodes.push(P)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var q=0,j=Array.from(e.shadowRoot.childNodes);q<j.length;q++){var P;(P=Ie(j[q],K))&&(H(e.shadowRoot)&&(P.isShadow=!0),G.childNodes.push(P))}}return e.parentNode&&Y(e.parentNode)&&H(e.parentNode)&&(G.isShadow=!0),G.type===c.Element&&"iframe"===G.tagName&&function(e,t,n){var o=e.contentWindow;if(o){var r,i=!1;try{r=o.document.readyState}catch(e){return}if("complete"===r){var s="about:blank";if(o.location.href!==s||e.src===s||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout(function(){i||(t(),i=!0)},n);e.addEventListener("load",function(){clearTimeout(a),i=!0,t()})}}}(e,function(){var t=e.contentDocument;if(t&&T){var n=Ie(t,{doc:t,mirror:r,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:g,maskInputOptions:m,maskTextFn:f,maskInputFn:I,slimDOMOptions:v,dataURLOptions:y,inlineImages:S,recordCanvas:k,preserveWhiteSpace:W,onSerialize:A,onIframeLoad:T,iframeLoadTimeout:E,onStylesheetLoad:R,stylesheetLoadTimeout:N,keepIframeSrcFn:L});n&&T(e,n)}},E),G.type===c.Element&&"link"===G.tagName&&"stylesheet"===G.attributes.rel&&function(e,t,n){var o,r=!1;try{o=e.sheet}catch(e){return}if(!o){var i=setTimeout(function(){r||(t(),r=!0)},n);e.addEventListener("load",function(){clearTimeout(i),r=!0,t()})}}(e,function(){if(R){var t=Ie(e,{doc:o,mirror:r,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:g,maskInputOptions:m,maskTextFn:f,maskInputFn:I,slimDOMOptions:v,dataURLOptions:y,inlineImages:S,recordCanvas:k,preserveWhiteSpace:W,onSerialize:A,onIframeLoad:T,iframeLoadTimeout:E,onStylesheetLoad:R,stylesheetLoadTimeout:N,keepIframeSrcFn:L});t&&R(e,t)}},N),G}function ve(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 ye={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 be(e,t,n={}){let o=null,r=0;return function(...i){const s=Date.now();r||!1!==n.leading||(r=s);const a=t-(s-r),c=this;a<=0||a>t?(o&&(clearTimeout(o),o=null),r=s,e.apply(c,i)):o||!1===n.trailing||(o=setTimeout(()=>{r=!1===n.leading?0:Date.now(),o=null,e.apply(c,i)},a))}}function Se(e,t,n,o,r=window){const i=r.Object.getOwnPropertyDescriptor(e,t);return r.Object.defineProperty(e,t,o?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),i&&i.set&&i.set.call(this,e)}}),()=>Se(e,t,i||{},!0)}function we(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()=>{}}}function ke(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Ae(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Te(e,t,n,o){if(!e)return!1;const r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(o&&null!==r.closest("."+t))return!0}else if(ge(r,t,o))return!0;if(n){if(e.matches(n))return!0;if(o&&null!==r.closest(n))return!0}return!1}function Me(e,t){return-2===t.getId(e)}function Ee(e,t){if(Y(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||Ee(e.parentNode,t))}function Re(e){return Boolean(e.changedTouches)}function Oe(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function Ne(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function De(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(ye=new Proxy(ye,{get:(e,t,n)=>("map"===t&&console.error(Ce),Reflect.get(e,t,n))}));class Le{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++}}var Fe=(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))(Fe||{}),xe=(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))(xe||{}),Be=(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))(Be||{}),We=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(We||{});function Ve(e){return"__ln"in e}class Ge{constructor(){this.length=0,this.head=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&&Ve(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&&Ve(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;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.head=t.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const Ze=(e,t)=>`${e}@${t}`;class Ue{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],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 Ge,n=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{var r,i,s,a;let c=null;(null===(i=null===(r=o.getRootNode)||void 0===r?void 0:r.call(o))||void 0===i?void 0:i.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&o.getRootNode().host&&(c=o.getRootNode().host);let l=c;for(;(null===(a=null===(s=null==l?void 0:l.getRootNode)||void 0===s?void 0:s.call(l))||void 0===a?void 0:a.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&l.getRootNode().host;)l=l.getRootNode().host;const d=!(this.doc.contains(o)||l&&this.doc.contains(l));if(!o.parentNode||d)return;const u=Y(o.parentNode)?this.mirror.getId(c):this.mirror.getId(o.parentNode),h=n(o);if(-1===u||-1===h)return t.addNode(o);const g=Ie(o,{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=>{Oe(e,this.mirror)&&this.iframeManager.addIframe(e),Ne(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),De(o)&&this.shadowDomManager.addShadowRoot(o.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});g&&e.push({parentId:u,nextId:h,node:g})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of Array.from(this.movedSet.values()))_e(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||o(e);for(const e of Array.from(this.addedSet.values()))Ye(this.droppedSet,e)||_e(this.removes,e,this.mirror)?Ye(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let r=null;for(;t.length;){let e=null;if(r){const t=this.mirror.getId(r.value.parentNode),o=n(r.value);-1!==t&&-1!==o&&(e=r)}if(!e)for(let o=t.length-1;o>=0;o--){const r=t.get(o);if(r){const t=this.mirror.getId(r.value.parentNode);if(-1===n(r.value))continue;if(-1!==t){e=r;break}{const t=r.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=t.parentNode.host;if(-1!==this.mirror.getId(n)){e=r;break}}}}}if(!e){for(;t.head;)t.removeNode(t.head.value);break}r=e.previous,t.removeNode(e.value),o(e.value)}const i={texts:this.texts.map(e=>({id:this.mirror.getId(e.node),value:e.value})).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>({id:this.mirror.getId(e.node),attributes:e.attributes})).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.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(i))},this.processMutation=e=>{if(!Me(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;Te(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:pe(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.target.getAttribute(e.attributeName);if("value"===e.attributeName&&(n=J({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),Te(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let o=this.attributes.find(t=>t.node===e.target);if("IFRAME"===t.tagName&&"src"===e.attributeName&&!this.keepIframeSrcFn(n)){if(t.contentDocument)return;e.attributeName="rr_src"}if(o||(o={node:e.target,attributes:{}},this.attributes.push(o)),"style"===e.attributeName){const n=this.doc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue),void 0!==o.attributes.style&&null!==o.attributes.style||(o.attributes.style={});const r=o.attributes.style;for(const e of Array.from(t.style)){const o=t.style.getPropertyValue(e),i=t.style.getPropertyPriority(e);o===n.style.getPropertyValue(e)&&i===n.style.getPropertyPriority(e)||(r[e]=""===i?o:[o,i])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(r[e]=!1)}else o.attributes[e.attributeName]=he(this.doc,t.tagName,e.attributeName,n);break}case"childList":if(Te(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const n=this.mirror.getId(t),o=Y(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);Te(e.target,this.blockClass,this.blockSelector,!1)||Me(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(Ke(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||Ee(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Ze(n,o)]?Ke(this.movedSet,t):this.removes.push({parentId:o,id:n,isShadow:!(!Y(e.target)||!H(e.target))||void 0})),this.mapRemoves.push(t))})}},this.genAdds=(e,t)=>{if(this.mirror.hasNode(e)){if(Me(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);Te(e,this.blockClass,this.blockSelector,!1)||e.childNodes.forEach(e=>this.genAdds(e))}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].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 Ke(e,t){e.delete(t),t.childNodes.forEach(t=>Ke(e,t))}function _e(e,t,n){return 0!==e.length&&ze(e,t,n)}function ze(e,t,n){const{parentNode:o}=t;if(!o)return!1;const r=n.getId(o);return!!e.some(e=>e.id===r)||ze(e,o,n)}function Ye(e,t){return 0!==e.size&&He(e,t)}function He(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||He(e,n))}const qe=[],je="undefined"!=typeof CSSGroupingRule,Pe="undefined"!=typeof CSSMediaRule,Je="undefined"!=typeof CSSSupportsRule,Qe="undefined"!=typeof CSSConditionRule;function Xe(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];return e.target}catch(t){return e.target}}function $e(e,t){var n,o;const r=new Ue;qe.push(r),r.init(e);let i=window.MutationObserver||window.__rrMutationObserver;const s=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");s&&window[s]&&(i=window[s]);const a=new i(r.processMutations.bind(r));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function et({mouseInteractionCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:i}){if(!1===i.mouseInteraction)return()=>{};const s=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,a=[];return Object.keys(Be).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]).forEach(i=>{const s=i.toLowerCase(),c=(t=>i=>{const s=Xe(i);if(Te(s,o,r,!0))return;const a=Re(i)?i.changedTouches[0]:i;if(!a)return;const c=n.getId(s),{clientX:l,clientY:d}=a;e({type:Be[t],id:c,x:l,y:d})})(i);a.push(ve(s,c,t))}),()=>{a.forEach(e=>e())}}function tt({scrollCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:i}){return ve("scroll",be(i=>{const s=Xe(i);if(!s||Te(s,o,r,!0))return;const a=n.getId(s);if(s===t){const n=t.scrollingElement||t.documentElement;e({id:a,x:n.scrollLeft,y:n.scrollTop})}else e({id:a,x:s.scrollLeft,y:s.scrollTop})},i.scroll||100),t)}function nt(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const ot=["INPUT","TEXTAREA","SELECT"],rt=new WeakMap;function it(e){return function(e,t){if(je&&e.parentRule instanceof CSSGroupingRule||Pe&&e.parentRule instanceof CSSMediaRule||Je&&e.parentRule instanceof CSSSupportsRule||Qe&&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 st(e,t,n){let o,r;return e?(e.ownerNode?o=t.getId(e.ownerNode):r=n.getId(e),{styleId:r,id:o}):{}}function at({mirror:e,stylesheetManager:t},n){var o,r,i;let s=null;s="#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===(i=null===(r=n.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===i?void 0:i.ShadowRoot,c=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==s&&-1!==s&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null===(e=c.get)||void 0===e?void 0:e.call(this)},set(e){var n;const o=null===(n=c.set)||void 0===n?void 0:n.call(this,e);if(null!==s&&-1!==s)try{t.adoptStyleSheets(e,s)}catch(e){}return o}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}):()=>{}}function ct(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:o,mouseInteractionCb:r,scrollCb:i,viewportResizeCb:s,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:u,fontCb:h,selectionCb:g}=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),i(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),s(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...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),g(...e)}}(e,t);const o=$e(e,e.doc),r=function({mousemoveCb:e,sampling:t,doc:n,mirror:o}){if(!1===t.mousemove)return()=>{};const r="number"==typeof t.mousemove?t.mousemove:50,i="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let s,a=[];const c=be(t=>{const n=Date.now()-s;e(a.map(e=>(e.timeOffset-=n,e)),t),a=[],s=null},i),l=be(e=>{const t=Xe(e),{clientX:n,clientY:r}=Re(e)?e.changedTouches[0]:e;s||(s=Date.now()),a.push({x:n,y:r,id:o.getId(t),timeOffset:Date.now()-s}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?xe.Drag:e instanceof MouseEvent?xe.MouseMove:xe.TouchMove)},r,{trailing:!1}),d=[ve("mousemove",l,n),ve("touchmove",l,n),ve("drag",l,n)];return()=>{d.forEach(e=>e())}}(e),i=et(e),s=tt(e),a=function({viewportResizeCb:e}){let t=-1,n=-1;return ve("resize",be(()=>{const o=ke(),r=Ae();t===o&&n===r||(e({width:Number(r),height:Number(o)}),t=o,n=r)},200),window)}(e),c=function({inputCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,ignoreClass:i,maskInputOptions:s,maskInputFn:a,sampling:c,userTriggeredOnInput:l}){function d(e){let n=Xe(e);const c=e.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||ot.indexOf(n.tagName)<0||Te(n,o,r,!0))return;const d=n.type;if(n.classList.contains(i))return;let h=n.value,g=!1;"radio"===d||"checkbox"===d?g=n.checked:(s[n.tagName.toLowerCase()]||s[d])&&(h=J({maskInputOptions:s,tagName:n.tagName,type:d,value:h,maskInputFn:a})),u(n,nt({text:h,isChecked:g,userTriggered:c},l));const p=n.name;"radio"===d&&p&&g&&t.querySelectorAll(`input[type="radio"][name="${p}"]`).forEach(e=>{e!==n&&u(e,nt({text:e.value,isChecked:!g,userTriggered:!1},l))})}function u(t,o){const r=rt.get(t);if(!r||r.text!==o.text||r.isChecked!==o.isChecked){rt.set(t,o);const r=n.getId(t);e(Object.assign(Object.assign({},o),{id:r}))}}const h=("last"===c.input?["change"]:["input","change"]).map(e=>ve(e,d,t)),g=t.defaultView;if(!g)return()=>{h.forEach(e=>e())};const p=g.Object.getOwnPropertyDescriptor(g.HTMLInputElement.prototype,"value"),m=[[g.HTMLInputElement.prototype,"value"],[g.HTMLInputElement.prototype,"checked"],[g.HTMLSelectElement.prototype,"value"],[g.HTMLTextAreaElement.prototype,"value"],[g.HTMLSelectElement.prototype,"selectedIndex"],[g.HTMLOptionElement.prototype,"selected"]];return p&&p.set&&h.push(...m.map(e=>Se(e[0],e[1],{set(){d({target:this})}},!1,g))),()=>{h.forEach(e=>e())}}(e),l=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:o,sampling:r}){const i=i=>be(r=>{const s=Xe(r);if(!s||Te(s,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:d}=s;e({type:i,id:o.getId(s),currentTime:a,volume:c,muted:l,playbackRate:d})},r.media||500),s=[ve("play",i(0)),ve("pause",i(1)),ve("seeked",i(2)),ve("volumechange",i(3)),ve("ratechange",i(4))];return()=>{s.forEach(e=>e())}}(e),d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:o}){const r=o.CSSStyleSheet.prototype.insertRule;o.CSSStyleSheet.prototype.insertRule=function(o,i){const{id:s,styleId:a}=st(this,t,n.styleMirror);return(s&&-1!==s||a&&-1!==a)&&e({id:s,styleId:a,adds:[{rule:o,index:i}]}),r.apply(this,[o,i])};const i=o.CSSStyleSheet.prototype.deleteRule;let s,a;o.CSSStyleSheet.prototype.deleteRule=function(o){const{id:r,styleId:s}=st(this,t,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&e({id:r,styleId:s,removes:[{index:o}]}),i.apply(this,[o])},o.CSSStyleSheet.prototype.replace&&(s=o.CSSStyleSheet.prototype.replace,o.CSSStyleSheet.prototype.replace=function(o){const{id:r,styleId:i}=st(this,t,n.styleMirror);return(r&&-1!==r||i&&-1!==i)&&e({id:r,styleId:i,replace:o}),s.apply(this,[o])}),o.CSSStyleSheet.prototype.replaceSync&&(a=o.CSSStyleSheet.prototype.replaceSync,o.CSSStyleSheet.prototype.replaceSync=function(o){const{id:r,styleId:i}=st(this,t,n.styleMirror);return(r&&-1!==r||i&&-1!==i)&&e({id:r,styleId:i,replaceSync:o}),a.apply(this,[o])});const c={};je?c.CSSGroupingRule=o.CSSGroupingRule:(Pe&&(c.CSSMediaRule=o.CSSMediaRule),Qe&&(c.CSSConditionRule=o.CSSConditionRule),Je&&(c.CSSSupportsRule=o.CSSSupportsRule));const l={};return Object.entries(c).forEach(([o,r])=>{l[o]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=function(r,i){const{id:s,styleId:a}=st(this.parentStyleSheet,t,n.styleMirror);return(s&&-1!==s||a&&-1!==a)&&e({id:s,styleId:a,adds:[{rule:r,index:[...it(this),i||0]}]}),l[o].insertRule.apply(this,[r,i])},r.prototype.deleteRule=function(r){const{id:i,styleId:s}=st(this.parentStyleSheet,t,n.styleMirror);return(i&&-1!==i||s&&-1!==s)&&e({id:i,styleId:s,removes:[{index:[...it(this),r]}]}),l[o].deleteRule.apply(this,[r])}}),()=>{o.CSSStyleSheet.prototype.insertRule=r,o.CSSStyleSheet.prototype.deleteRule=i,s&&(o.CSSStyleSheet.prototype.replace=s),a&&(o.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule})}}(e,{win:n}),u=at(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:o},{win:r}){const i=r.CSSStyleDeclaration.prototype.setProperty;r.CSSStyleDeclaration.prototype.setProperty=function(r,s,a){var c;if(n.has(r))return i.apply(this,[r,s,a]);const{id:l,styleId:d}=st(null===(c=this.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,o.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,set:{property:r,value:s,priority:a},index:it(this.parentRule)}),i.apply(this,[r,s,a])};const s=r.CSSStyleDeclaration.prototype.removeProperty;return r.CSSStyleDeclaration.prototype.removeProperty=function(r){var i;if(n.has(r))return s.apply(this,[r]);const{id:a,styleId:c}=st(null===(i=this.parentRule)||void 0===i?void 0:i.parentStyleSheet,t,o.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,remove:{property:r},index:it(this.parentRule)}),s.apply(this,[r])},()=>{r.CSSStyleDeclaration.prototype.setProperty=i,r.CSSStyleDeclaration.prototype.removeProperty=s}}(e,{win:n}),g=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const o=[],r=new WeakMap,i=n.FontFace;n.FontFace=function(e,t,n){const o=new i(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 s=we(t.fonts,"add",function(t){return function(n){return setTimeout(()=>{const t=r.get(n);t&&(e(t),r.delete(n))},0),t.apply(this,[n])}});return o.push(()=>{n.FontFace=i}),o.push(s),()=>{o.forEach(e=>e())}}(e):()=>{},p=function(e){const{doc:t,mirror:n,blockClass:o,blockSelector:r,selectionCb:i}=e;let s=!0;const a=()=>{const e=t.getSelection();if(!e||s&&(null==e?void 0:e.isCollapsed))return;s=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const i=e.getRangeAt(t),{startContainer:s,startOffset:c,endContainer:l,endOffset:d}=i;Te(s,o,r,!0)||Te(l,o,r,!0)||a.push({start:n.getId(s),startOffset:c,end:n.getId(l),endOffset:d})}i({ranges:a})};return a(),ve("selectionchange",a)}(e),m=[];for(const t of e.plugins)m.push(t.observer(t.callback,n,t.options));return()=>{qe.forEach(e=>e.reset()),o.disconnect(),r(),i(),s(),a(),c(),l(),d(),u(),h(),g(),p(),m.forEach(e=>e())}}class lt{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,o){const r=n||this.getIdToRemoteIdMap(e),i=o||this.getRemoteIdToIdMap(e);let s=r.get(t);return s||(s=this.generateIdFn(),r.set(t,s),i.set(s,t)),s}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 dt{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new lt(ne),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new lt(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){if("rrweb"===e.data.type){if(!e.source)return;const t=this.crossOriginIframeMap.get(e.source);if(!t)return;const n=this.transformCrossOriginEvent(t,e.data.event);n&&this.wrappedEmit(n,e.data.isCheckout)}}transformCrossOriginEvent(e,t){var n;switch(t.type){case Fe.FullSnapshot:return this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e),{timestamp:t.timestamp,type:Fe.IncrementalSnapshot,data:{source:xe.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case Fe.Meta:case Fe.Load:case Fe.DomContentLoaded:return!1;case Fe.Plugin:return t;case Fe.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case Fe.IncrementalSnapshot:switch(t.data.source){case xe.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e)}),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 xe.Drag:case xe.TouchMove:case xe.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case xe.ViewportResize:return!1;case xe.MediaInteraction:case xe.MouseInteraction:case xe.Scroll:case xe.CanvasMutation:case xe.Input:return this.replaceIds(t.data,e,["id"]),t;case xe.StyleSheetRule:case xe.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case xe.Font:return t;case xe.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case xe.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}}}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"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}}class ut{constructor(e){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror;const t=this;this.restorePatches.push(we(Element.prototype,"attachShadow",function(e){return function(n){const o=e.call(this,n);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,this.ownerDocument),o}}))}addShadowRoot(e,t){H(e)&&(this.shadowDoms.has(e)||(this.shadowDoms.add(e),$e(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),tt(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)),at({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)},0)))}observeAttachShadow(e){if(e.contentWindow){const t=this;this.restorePatches.push(we(e.contentWindow.HTMLElement.prototype,"attachShadow",function(n){return function(o){const r=n.call(this,o);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,e.contentDocument),r}}))}}reset(){this.restorePatches.forEach(e=>e()),this.shadowDoms=new WeakSet}}
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -12,5 +12,5 @@
|
|
|
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 gt(e,t,n,o){return new(n||(n=Promise))(function(t,r){function i(e){try{a(o.next(e))}catch(e){r(e)}}function s(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(i,s)}a((o=o.apply(e,[])).next())})}for(var pt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",mt="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ft=0;ft<64;ft++)mt[pt.charCodeAt(ft)]=ft;const It=new Map;const vt=(e,t,n)=>{if(!e||!bt(e,t)&&"object"!=typeof e)return;const o=function(e,t){let n=It.get(e);return n||(n=new Map,It.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 Ct(e,t,n){if(e instanceof Array)return e.map(e=>Ct(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+=pt[n[t]>>2],r+=pt[(3&n[t])<<4|n[t+1]>>4],r+=pt[(15&n[t+1])<<2|n[t+2]>>6],r+=pt[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:[Ct(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:[Ct(e.data,t,n),e.width,e.height]}}if(bt(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:vt(e,t,n)}}return e}const yt=(e,t,n)=>[...e].map(e=>Ct(e,t,n)),bt=(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 St(e,t,n){const o=[];try{const r=ke(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(o,...r){return Me(this,t,n,!0)||"__context"in this||(this.__context=o),e.apply(this,[o,...r])}});o.push(r)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach(e=>e())}}function wt(e,t,n,o,r,i,s){const a=[],c=Object.getOwnPropertyNames(e);for(const i of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(i))try{if("function"!=typeof e[i])continue;const c=ke(e,i,function(e){return function(...a){const c=e.apply(this,a);if(vt(c,s,this),!Me(this.canvas,o,r,!0)){const e=yt([...a],s,this),o={type:t,property:i,args:e};n(this.canvas,o)}return c}});a.push(c)}catch(o){const r=we(e,i,{set(e){n(this.canvas,{type:t,property:i,args:[e],setter:!0})}});a.push(r)}return a}var kt=null;try{var At="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");kt=At.Worker}catch(i){}function Tt(e,t,n){var o=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),r=o.indexOf("\n",10)+1,i=o.substring(r)+"";return function(e){return new kt(i,Object.assign({},e,{eval:!0}))}}function Mt(e,t,n){var o=function(e){return atob(e)}(e),r=o.indexOf("\n",10)+1,i=o.substring(r)+"",s=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(s)}var Et="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Rt,Ot=(Rt="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Et?Tt(Rt):function(e){var t;return function(n){return t=t||Mt(e),new Worker(t,n)}}(Rt));class Nt{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:i,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,i&&"all"===t&&this.initCanvasMutationObserver(n,o,r),i&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,o,r,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,o,r){const i=St(t,n,o),s=new Map,a=new Ot;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:n,type:o,width:r,height:i}=e.data;this.mutationCb({id:t,type:Ve["2D"],commands:[{property:"clearRect",args:[0,0,r,i]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:o}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{Me(t,n,o,!0)||e.push(t)}),e})().forEach(e=>gt(this,0,void 0,function*(){var t;const n=this.mirror.getId(e);if(s.get(n))return;if(s.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)&&(null==n||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])}))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{i(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const o=St(e,t,n),r=function(e,t,n,o){const r=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of i)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const i=ke(t.CanvasRenderingContext2D.prototype,s,function(r){return function(...i){return Me(this.canvas,n,o,!0)||setTimeout(()=>{const n=yt([...i],t,this);e(this.canvas,{type:Ve["2D"],property:s,args:n})},0),r.apply(this,i)}});r.push(i)}catch(n){const o=we(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:Ve["2D"],property:s,args:[t],setter:!0})}});r.push(o)}return()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),i=function(e,t,n,o){const r=[];return r.push(...wt(t.WebGLRenderingContext.prototype,Ve.WebGL,e,n,o,0,t)),void 0!==t.WebGL2RenderingContext&&r.push(...wt(t.WebGL2RenderingContext.prototype,Ve.WebGL2,e,n,o,0,t)),()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{o(),r(),i()}}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 Dt{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new Fe,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;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);o.push({styleId:e,rules:n.map((e,t)=>({rule:P(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){}}function Lt(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Ft,xt,Bt,Wt=!1;const Vt=new J;function Gt(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:o,blockClass:r="rr-block",blockSelector:i=null,ignoreClass:s="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:c=null,inlineStylesheet:l=!0,maskAllInputs:d,maskInputOptions:u,slimDOMOptions:h,maskInputFn:g,maskTextFn:p,hooks:m,packFn:f,sampling:I={},dataURLOptions:v={},mousemoveWait:C,recordCanvas:y=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:S=!1,collectFonts:w=!1,inlineImages:k=!1,plugins:A,keepIframeSrcFn:T=()=>!1,ignoreCSSAttributes:M=new Set([])}=e,E=!b||window.parent===window;let R=!1;if(!E)try{window.parent.document,R=!1}catch(e){R=!0}if(E&&!t)throw new Error("emit function is required");void 0!==C&&void 0===I.mousemove&&(I.mousemove=C),Vt.reset();const O=!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}:void 0!==u?u:{password:!0},N=!0===h||"all"===h?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===h,headMetaDescKeywords:"all"===h}:h||{};let D;!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 L=0;const F=e=>{for(const t of A||[])t.eventProcessor&&(e=t.eventProcessor(e));return f&&(e=f(e)),e};Ft=(e,r)=>{var i;if(!(null===(i=qe[0])||void 0===i?void 0:i.isFrozen())||e.type===xe.FullSnapshot||e.type===xe.IncrementalSnapshot&&e.data.source===Be.Mutation||qe.forEach(e=>e.unfreeze()),E)null==t||t(F(e),r);else if(R){const t={type:"rrweb",event:F(e),isCheckout:r};window.parent.postMessage(t,"*")}if(e.type===xe.FullSnapshot)D=e,L=0;else if(e.type===xe.IncrementalSnapshot){if(e.data.source===Be.Mutation&&e.data.isAttachIframe)return;L++;const t=o&&L>=o,r=n&&e.timestamp-D.timestamp>n;(t||r)&&xt(!0)}};const x=e=>{Ft(Lt({type:xe.IncrementalSnapshot,data:Object.assign({source:Be.Mutation},e)}))},B=e=>Ft(Lt({type:xe.IncrementalSnapshot,data:Object.assign({source:Be.Scroll},e)})),W=e=>Ft(Lt({type:xe.IncrementalSnapshot,data:Object.assign({source:Be.CanvasMutation},e)})),V=new Dt({mutationCb:x,adoptedStyleSheetCb:e=>Ft(Lt({type:xe.IncrementalSnapshot,data:Object.assign({source:Be.AdoptedStyleSheet},e)}))}),G=new ut({mirror:Vt,mutationCb:x,stylesheetManager:V,recordCrossOriginIframes:b,wrappedEmit:Ft});for(const e of A||[])e.getMirror&&e.getMirror({nodeMirror:Vt,crossOriginIframeMirror:G.crossOriginIframeMirror,crossOriginIframeStyleMirror:G.crossOriginIframeStyleMirror});Bt=new Nt({recordCanvas:y,mutationCb:W,win:window,blockClass:r,blockSelector:i,mirror:Vt,sampling:I.canvas,dataURLOptions:v});const Z=new ht({mutationCb:x,scrollCb:B,bypassOptions:{blockClass:r,blockSelector:i,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskInputOptions:O,dataURLOptions:v,maskTextFn:p,maskInputFn:g,recordCanvas:y,inlineImages:k,sampling:I,slimDOMOptions:N,iframeManager:G,stylesheetManager:V,canvasManager:Bt,keepIframeSrcFn:T},mirror:Vt});xt=(e=!1)=>{var t,n,o,s,d,u;Ft(Lt({type:xe.Meta,data:{href:window.location.href,width:Te(),height:Ae()}}),e),V.reset(),qe.forEach(e=>e.lock());const h=function(e,t){var n=t||{},o=n.mirror,r=void 0===o?new J:o,i=n.blockClass,s=void 0===i?"rr-block":i,a=n.blockSelector,c=void 0===a?null:a,l=n.maskTextClass,d=void 0===l?"rr-mask":l,u=n.maskTextSelector,h=void 0===u?null:u,g=n.inlineStylesheet,p=void 0===g||g,m=n.inlineImages,f=void 0!==m&&m,I=n.recordCanvas,v=void 0!==I&&I,C=n.maskAllInputs,y=void 0!==C&&C,b=n.maskTextFn,S=n.maskInputFn,w=n.slimDOM,k=void 0!==w&&w,A=n.dataURLOptions,T=n.preserveWhiteSpace,M=n.onSerialize,E=n.onIframeLoad,R=n.iframeLoadTimeout,O=n.onStylesheetLoad,N=n.stylesheetLoadTimeout,D=n.keepIframeSrcFn;return ve(e,{doc:e,mirror:r,blockClass:s,blockSelector:c,maskTextClass:d,maskTextSelector:h,skipChild:!1,inlineStylesheet:p,maskInputOptions:!0===y?{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===y?{password:!0}:y,maskTextFn:b,maskInputFn:S,slimDOMOptions:!0===k||"all"===k?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===k,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===k?{}:k,dataURLOptions:A,inlineImages:f,recordCanvas:v,preserveWhiteSpace:T,onSerialize:M,onIframeLoad:E,iframeLoadTimeout:R,onStylesheetLoad:O,stylesheetLoadTimeout:N,keepIframeSrcFn:void 0===D?function(){return!1}:D,newlyAddedElement:!1})}(document,{mirror:Vt,blockClass:r,blockSelector:i,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskAllInputs:O,maskTextFn:p,slimDOM:N,dataURLOptions:v,recordCanvas:y,inlineImages:k,onSerialize:e=>{Ne(e,Vt)&&G.addIframe(e),De(e,Vt)&&V.trackLinkElement(e),Le(e)&&Z.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{G.attachIframe(e,t),Z.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{V.attachLinkElement(e,t)},keepIframeSrcFn:T});if(!h)return console.warn("Failed to snapshot the document");Ft(Lt({type:xe.FullSnapshot,data:{node:h,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(o=null===document||void 0===document?void 0:document.body)||void 0===o?void 0:o.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(d=null===(s=null===document||void 0===document?void 0:document.body)||void 0===s?void 0:s.parentElement)||void 0===d?void 0:d.scrollTop)||(null===(u=null===document||void 0===document?void 0:document.body)||void 0===u?void 0:u.scrollTop)||0}}})),qe.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&V.adoptStyleSheets(document.adoptedStyleSheets,Vt.getId(document))};try{const e=[];e.push(Ce("DOMContentLoaded",()=>{Ft(Lt({type:xe.DomContentLoaded,data:{}}))}));const t=e=>{var t;return lt({mutationCb:x,mousemoveCb:(e,t)=>Ft(Lt({type:xe.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Ft(Lt({type:xe.IncrementalSnapshot,data:Object.assign({source:Be.MouseInteraction},e)})),scrollCb:B,viewportResizeCb:e=>Ft(Lt({type:xe.IncrementalSnapshot,data:Object.assign({source:Be.ViewportResize},e)})),inputCb:e=>Ft(Lt({type:xe.IncrementalSnapshot,data:Object.assign({source:Be.Input},e)})),mediaInteractionCb:e=>Ft(Lt({type:xe.IncrementalSnapshot,data:Object.assign({source:Be.MediaInteraction},e)})),styleSheetRuleCb:e=>Ft(Lt({type:xe.IncrementalSnapshot,data:Object.assign({source:Be.StyleSheetRule},e)})),styleDeclarationCb:e=>Ft(Lt({type:xe.IncrementalSnapshot,data:Object.assign({source:Be.StyleDeclaration},e)})),canvasMutationCb:W,fontCb:e=>Ft(Lt({type:xe.IncrementalSnapshot,data:Object.assign({source:Be.Font},e)})),selectionCb:e=>{Ft(Lt({type:xe.IncrementalSnapshot,data:Object.assign({source:Be.Selection},e)}))},blockClass:r,ignoreClass:s,maskTextClass:a,maskTextSelector:c,maskInputOptions:O,inlineStylesheet:l,sampling:I,recordCanvas:y,inlineImages:k,userTriggeredOnInput:S,collectFonts:w,doc:e,maskInputFn:g,maskTextFn:p,keepIframeSrcFn:T,blockSelector:i,slimDOMOptions:N,dataURLOptions:v,mirror:Vt,iframeManager:G,stylesheetManager:V,shadowDomManager:Z,canvasManager:Bt,ignoreCSSAttributes:M,plugins:(null===(t=null==A?void 0:A.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>Ft(Lt({type:xe.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},m)};G.addLoadListener(n=>{e.push(t(n.contentDocument))});const n=()=>{xt(),e.push(t(document)),Wt=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(Ce("load",()=>{Ft(Lt({type:xe.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),Wt=!1}}catch(e){console.warn(e)}}Gt.addCustomEvent=(e,t)=>{if(!Wt)throw new Error("please add custom event after start recording");Ft(Lt({type:xe.Custom,data:{tag:e,payload:t}}))},Gt.freezePage=()=>{qe.forEach(e=>e.freeze())},Gt.takeFullSnapshot=e=>{if(!Wt)throw new Error("please take full snapshot after start recording");xt(e)},Gt.mirror=Vt;class Zt{constructor(e,t,n){this.stopFn=null,this.events=[],this.onEventsReady=null,this.flushInterval=null,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),this.stopFn=Gt({emit:e=>{this.events.push(e),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.events.length>0&&this.flush()},1e4),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.flush()}flush(){if(0===this.events.length)return;const e=[...this.events];this.events=[],this.onEventsReady&&this.onEventsReady(e)}getEventCount(){return this.events.length}isRecording(){return null!==this.stopFn}}class Ut{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,t){this.sendToBackend("/v1/rum/recordings",{session_id:e,events:t,timestamp:(new Date).toISOString()})}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,t){return n(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)throw new Error(`HTTP ${t.status}: ${t.statusText}`);this.config.debug&&console.log("[DevSkin] Data sent successfully:",e)}catch(e){this.config.debug&&console.error("[DevSkin] Failed to send data:",e)}})}destroy(){this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null),this.flush()}}const Kt=new class{constructor(){this.config=null,this.transport=null,this.sessionId=null,this.userId=null,this.anonymousId=null,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(e){var n,i;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},e),this.config.debug&&console.log("[DevSkin] Initializing SDK with config:",this.config),this.transport=new Ut(this.config),this.anonymousId=this.getOrCreateAnonymousId(),this.startSession(),this.deviceCollector=new t(this.config),this.locationCollector=new o(this.config),this.browserCollector=new r(this.config),this.config.captureWebVitals&&(this.performanceCollector=new K(this.config,this.transport),this.performanceCollector.start()),this.config.captureErrors&&(this.errorCollector=new _(this.config,this.transport),this.errorCollector.start()),this.config.captureNetworkRequests&&(this.networkCollector=new z(this.config,this.transport),this.networkCollector.start()),(null===(n=this.config.heatmapOptions)||void 0===n?void 0:n.enabled)&&(this.heatmapCollector=new Y(this.config,this.transport),this.heatmapCollector.start()),(null===(i=this.config.sessionRecording)||void 0===i?void 0:i.enabled)&&(this.rrwebRecorder=new Zt(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)}),this.rrwebRecorder.start(),this.config.debug&&console.log("[DevSkin] RRWeb recording started for session:",this.sessionId)),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();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;this.track("page_unload"),null===(e=this.transport)||void 0===e||e.flush()})}};e.DevSkin=Kt,e.default=Kt,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
15
|
+
***************************************************************************** */function ht(e,t,n,o){return new(n||(n=Promise))(function(t,r){function i(e){try{a(o.next(e))}catch(e){r(e)}}function s(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(i,s)}a((o=o.apply(e,[])).next())})}for(var gt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",pt="undefined"==typeof Uint8Array?[]:new Uint8Array(256),mt=0;mt<64;mt++)pt[gt.charCodeAt(mt)]=mt;const ft=new Map;const It=(e,t,n)=>{if(!e||!yt(e,t)&&"object"!=typeof e)return;const o=function(e,t){let n=ft.get(e);return n||(n=new Map,ft.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 vt(e,t,n){if(e instanceof Array)return e.map(e=>vt(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+=gt[n[t]>>2],r+=gt[(3&n[t])<<4|n[t+1]>>4],r+=gt[(15&n[t+1])<<2|n[t+2]>>6],r+=gt[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:[vt(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:[vt(e.data,t,n),e.width,e.height]}}if(yt(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:It(e,t,n)}}return e}const Ct=(e,t,n)=>[...e].map(e=>vt(e,t,n)),yt=(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 bt(e,t,n){const o=[];try{const r=we(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(o,...r){return Te(this,t,n,!0)||"__context"in this||(this.__context=o),e.apply(this,[o,...r])}});o.push(r)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach(e=>e())}}function St(e,t,n,o,r,i,s){const a=[],c=Object.getOwnPropertyNames(e);for(const i of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(i))try{if("function"!=typeof e[i])continue;const c=we(e,i,function(e){return function(...a){const c=e.apply(this,a);if(It(c,s,this),!Te(this.canvas,o,r,!0)){const e=Ct([...a],s,this),o={type:t,property:i,args:e};n(this.canvas,o)}return c}});a.push(c)}catch(o){const r=Se(e,i,{set(e){n(this.canvas,{type:t,property:i,args:[e],setter:!0})}});a.push(r)}return a}var wt=null;try{var kt="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeof require&&require("worker_threads");wt=kt.Worker}catch(r){}function At(e,t,n){var o=function(e){return Buffer.from(e,"base64").toString("utf8")}(e),r=o.indexOf("\n",10)+1,i=o.substring(r)+"";return function(e){return new wt(i,Object.assign({},e,{eval:!0}))}}function Tt(e,t,n){var o=function(e){return atob(e)}(e),r=o.indexOf("\n",10)+1,i=o.substring(r)+"",s=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(s)}var Mt="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);var Et,Rt=(Et="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Mt?At(Et):function(e){var t;return function(n){return t=t||Tt(e),new Worker(t,n)}}(Et));class Ot{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:i,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,i&&"all"===t&&this.initCanvasMutationObserver(n,o,r),i&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,o,r,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,o,r){const i=bt(t,n,o),s=new Map,a=new Rt;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:n,type:o,width:r,height:i}=e.data;this.mutationCb({id:t,type:We["2D"],commands:[{property:"clearRect",args:[0,0,r,i]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:o}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{Te(t,n,o,!0)||e.push(t)}),e})().forEach(e=>ht(this,0,void 0,function*(){var t;const n=this.mirror.getId(e);if(s.get(n))return;if(s.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)&&(null==n||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])}))),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{i(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const o=bt(e,t,n),r=function(e,t,n,o){const r=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of i)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const i=we(t.CanvasRenderingContext2D.prototype,s,function(r){return function(...i){return Te(this.canvas,n,o,!0)||setTimeout(()=>{const n=Ct([...i],t,this);e(this.canvas,{type:We["2D"],property:s,args:n})},0),r.apply(this,i)}});r.push(i)}catch(n){const o=Se(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:We["2D"],property:s,args:[t],setter:!0})}});r.push(o)}return()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),i=function(e,t,n,o){const r=[];return r.push(...St(t.WebGLRenderingContext.prototype,We.WebGL,e,n,o,0,t)),void 0!==t.WebGL2RenderingContext&&r.push(...St(t.WebGL2RenderingContext.prototype,We.WebGL2,e,n,o,0,t)),()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{o(),r(),i()}}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 Nt{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new Le,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;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);const n=Array.from(t.rules||CSSRule);o.push({styleId:e,rules:n.map((e,t)=>({rule:j(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){}}function Dt(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Lt,Ft,xt,Bt=!1;const Wt=new P;function Vt(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:o,blockClass:r="rr-block",blockSelector:i=null,ignoreClass:s="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:c=null,inlineStylesheet:l=!0,maskAllInputs:d,maskInputOptions:u,slimDOMOptions:h,maskInputFn:g,maskTextFn:p,hooks:m,packFn:f,sampling:I={},dataURLOptions:v={},mousemoveWait:C,recordCanvas:y=!1,recordCrossOriginIframes:b=!1,userTriggeredOnInput:S=!1,collectFonts:w=!1,inlineImages:k=!1,plugins:A,keepIframeSrcFn:T=()=>!1,ignoreCSSAttributes:M=new Set([])}=e,E=!b||window.parent===window;let R=!1;if(!E)try{window.parent.document,R=!1}catch(e){R=!0}if(E&&!t)throw new Error("emit function is required");void 0!==C&&void 0===I.mousemove&&(I.mousemove=C),Wt.reset();const O=!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}:void 0!==u?u:{password:!0},N=!0===h||"all"===h?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===h,headMetaDescKeywords:"all"===h}:h||{};let D;!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 L=0;const F=e=>{for(const t of A||[])t.eventProcessor&&(e=t.eventProcessor(e));return f&&(e=f(e)),e};Lt=(e,r)=>{var i;if(!(null===(i=qe[0])||void 0===i?void 0:i.isFrozen())||e.type===Fe.FullSnapshot||e.type===Fe.IncrementalSnapshot&&e.data.source===xe.Mutation||qe.forEach(e=>e.unfreeze()),E)null==t||t(F(e),r);else if(R){const t={type:"rrweb",event:F(e),isCheckout:r};window.parent.postMessage(t,"*")}if(e.type===Fe.FullSnapshot)D=e,L=0;else if(e.type===Fe.IncrementalSnapshot){if(e.data.source===xe.Mutation&&e.data.isAttachIframe)return;L++;const t=o&&L>=o,r=n&&e.timestamp-D.timestamp>n;(t||r)&&Ft(!0)}};const x=e=>{Lt(Dt({type:Fe.IncrementalSnapshot,data:Object.assign({source:xe.Mutation},e)}))},B=e=>Lt(Dt({type:Fe.IncrementalSnapshot,data:Object.assign({source:xe.Scroll},e)})),W=e=>Lt(Dt({type:Fe.IncrementalSnapshot,data:Object.assign({source:xe.CanvasMutation},e)})),V=new Nt({mutationCb:x,adoptedStyleSheetCb:e=>Lt(Dt({type:Fe.IncrementalSnapshot,data:Object.assign({source:xe.AdoptedStyleSheet},e)}))}),G=new dt({mirror:Wt,mutationCb:x,stylesheetManager:V,recordCrossOriginIframes:b,wrappedEmit:Lt});for(const e of A||[])e.getMirror&&e.getMirror({nodeMirror:Wt,crossOriginIframeMirror:G.crossOriginIframeMirror,crossOriginIframeStyleMirror:G.crossOriginIframeStyleMirror});xt=new Ot({recordCanvas:y,mutationCb:W,win:window,blockClass:r,blockSelector:i,mirror:Wt,sampling:I.canvas,dataURLOptions:v});const Z=new ut({mutationCb:x,scrollCb:B,bypassOptions:{blockClass:r,blockSelector:i,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskInputOptions:O,dataURLOptions:v,maskTextFn:p,maskInputFn:g,recordCanvas:y,inlineImages:k,sampling:I,slimDOMOptions:N,iframeManager:G,stylesheetManager:V,canvasManager:xt,keepIframeSrcFn:T},mirror:Wt});Ft=(e=!1)=>{var t,n,o,s,d,u;Lt(Dt({type:Fe.Meta,data:{href:window.location.href,width:Ae(),height:ke()}}),e),V.reset(),qe.forEach(e=>e.lock());const h=function(e,t){var n=t||{},o=n.mirror,r=void 0===o?new P:o,i=n.blockClass,s=void 0===i?"rr-block":i,a=n.blockSelector,c=void 0===a?null:a,l=n.maskTextClass,d=void 0===l?"rr-mask":l,u=n.maskTextSelector,h=void 0===u?null:u,g=n.inlineStylesheet,p=void 0===g||g,m=n.inlineImages,f=void 0!==m&&m,I=n.recordCanvas,v=void 0!==I&&I,C=n.maskAllInputs,y=void 0!==C&&C,b=n.maskTextFn,S=n.maskInputFn,w=n.slimDOM,k=void 0!==w&&w,A=n.dataURLOptions,T=n.preserveWhiteSpace,M=n.onSerialize,E=n.onIframeLoad,R=n.iframeLoadTimeout,O=n.onStylesheetLoad,N=n.stylesheetLoadTimeout,D=n.keepIframeSrcFn;return Ie(e,{doc:e,mirror:r,blockClass:s,blockSelector:c,maskTextClass:d,maskTextSelector:h,skipChild:!1,inlineStylesheet:p,maskInputOptions:!0===y?{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===y?{password:!0}:y,maskTextFn:b,maskInputFn:S,slimDOMOptions:!0===k||"all"===k?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===k,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===k?{}:k,dataURLOptions:A,inlineImages:f,recordCanvas:v,preserveWhiteSpace:T,onSerialize:M,onIframeLoad:E,iframeLoadTimeout:R,onStylesheetLoad:O,stylesheetLoadTimeout:N,keepIframeSrcFn:void 0===D?function(){return!1}:D,newlyAddedElement:!1})}(document,{mirror:Wt,blockClass:r,blockSelector:i,maskTextClass:a,maskTextSelector:c,inlineStylesheet:l,maskAllInputs:O,maskTextFn:p,slimDOM:N,dataURLOptions:v,recordCanvas:y,inlineImages:k,onSerialize:e=>{Oe(e,Wt)&&G.addIframe(e),Ne(e,Wt)&&V.trackLinkElement(e),De(e)&&Z.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{G.attachIframe(e,t),Z.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{V.attachLinkElement(e,t)},keepIframeSrcFn:T});if(!h)return console.warn("Failed to snapshot the document");Lt(Dt({type:Fe.FullSnapshot,data:{node:h,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(o=null===document||void 0===document?void 0:document.body)||void 0===o?void 0:o.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(d=null===(s=null===document||void 0===document?void 0:document.body)||void 0===s?void 0:s.parentElement)||void 0===d?void 0:d.scrollTop)||(null===(u=null===document||void 0===document?void 0:document.body)||void 0===u?void 0:u.scrollTop)||0}}})),qe.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&V.adoptStyleSheets(document.adoptedStyleSheets,Wt.getId(document))};try{const e=[];e.push(ve("DOMContentLoaded",()=>{Lt(Dt({type:Fe.DomContentLoaded,data:{}}))}));const t=e=>{var t;return ct({mutationCb:x,mousemoveCb:(e,t)=>Lt(Dt({type:Fe.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Lt(Dt({type:Fe.IncrementalSnapshot,data:Object.assign({source:xe.MouseInteraction},e)})),scrollCb:B,viewportResizeCb:e=>Lt(Dt({type:Fe.IncrementalSnapshot,data:Object.assign({source:xe.ViewportResize},e)})),inputCb:e=>Lt(Dt({type:Fe.IncrementalSnapshot,data:Object.assign({source:xe.Input},e)})),mediaInteractionCb:e=>Lt(Dt({type:Fe.IncrementalSnapshot,data:Object.assign({source:xe.MediaInteraction},e)})),styleSheetRuleCb:e=>Lt(Dt({type:Fe.IncrementalSnapshot,data:Object.assign({source:xe.StyleSheetRule},e)})),styleDeclarationCb:e=>Lt(Dt({type:Fe.IncrementalSnapshot,data:Object.assign({source:xe.StyleDeclaration},e)})),canvasMutationCb:W,fontCb:e=>Lt(Dt({type:Fe.IncrementalSnapshot,data:Object.assign({source:xe.Font},e)})),selectionCb:e=>{Lt(Dt({type:Fe.IncrementalSnapshot,data:Object.assign({source:xe.Selection},e)}))},blockClass:r,ignoreClass:s,maskTextClass:a,maskTextSelector:c,maskInputOptions:O,inlineStylesheet:l,sampling:I,recordCanvas:y,inlineImages:k,userTriggeredOnInput:S,collectFonts:w,doc:e,maskInputFn:g,maskTextFn:p,keepIframeSrcFn:T,blockSelector:i,slimDOMOptions:N,dataURLOptions:v,mirror:Wt,iframeManager:G,stylesheetManager:V,shadowDomManager:Z,canvasManager:xt,ignoreCSSAttributes:M,plugins:(null===(t=null==A?void 0:A.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>Lt(Dt({type:Fe.Plugin,data:{plugin:e.name,payload:t}}))})))||[]},m)};G.addLoadListener(n=>{e.push(t(n.contentDocument))});const n=()=>{Ft(),e.push(t(document)),Bt=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():e.push(ve("load",()=>{Lt(Dt({type:Fe.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),Bt=!1}}catch(e){console.warn(e)}}Vt.addCustomEvent=(e,t)=>{if(!Bt)throw new Error("please add custom event after start recording");Lt(Dt({type:Fe.Custom,data:{tag:e,payload:t}}))},Vt.freezePage=()=>{qe.forEach(e=>e.freeze())},Vt.takeFullSnapshot=e=>{if(!Bt)throw new Error("please take full snapshot after start recording");Ft(e)},Vt.mirror=Wt;class Gt{constructor(e,t,n){this.stopFn=null,this.events=[],this.onEventsReady=null,this.flushInterval=null,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),this.stopFn=Vt({emit:e=>{this.events.push(e),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.events.length>0&&this.flush()},1e4),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.flush()}flush(){if(0===this.events.length)return;const e=[...this.events];this.events=[],this.onEventsReady&&this.onEventsReady(e)}getEventCount(){return this.events.length}isRecording(){return null!==this.stopFn}}class Zt{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,t){this.sendToBackend("/v1/rum/recordings",{session_id:e,events:t,timestamp:(new Date).toISOString()})}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)throw new Error(`HTTP ${t.status}: ${t.statusText}`);this.config.debug&&console.log("[DevSkin] Data sent successfully:",e)}catch(e){this.config.debug&&console.error("[DevSkin] Failed to send data:",e)}})}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.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,i;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 Zt(this.config),this.anonymousId=this.getOrCreateAnonymousId(),this.startSession(),this.deviceCollector=new e(this.config),this.locationCollector=new n(this.config),this.browserCollector=new o(this.config),this.config.captureWebVitals&&(this.performanceCollector=new U(this.config,this.transport),this.performanceCollector.start()),this.config.captureErrors&&(this.errorCollector=new K(this.config,this.transport),this.errorCollector.start()),this.config.captureNetworkRequests&&(this.networkCollector=new _(this.config,this.transport),this.networkCollector.start()),(null===(r=this.config.heatmapOptions)||void 0===r?void 0:r.enabled)&&(this.heatmapCollector=new z(this.config,this.transport),this.heatmapCollector.start()),(null===(i=this.config.sessionRecording)||void 0===i?void 0:i.enabled)&&(this.rrwebRecorder=new Gt(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)}),this.rrwebRecorder.start(),this.config.debug&&console.log("[DevSkin] RRWeb recording started for session:",this.sessionId)),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();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;this.track("page_unload"),null===(e=this.transport)||void 0===e||e.flush()})}}});
|
|
16
16
|
//# sourceMappingURL=devskin.umd.min.js.map
|