@feiyangdefeng/sdk 1.0.0

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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +389 -0
  3. package/dist/collector/auto-tracker.d.ts +45 -0
  4. package/dist/collector/auto-tracker.d.ts.map +1 -0
  5. package/dist/collector/click-tracker.d.ts +38 -0
  6. package/dist/collector/click-tracker.d.ts.map +1 -0
  7. package/dist/collector/custom-tracker.d.ts +10 -0
  8. package/dist/collector/custom-tracker.d.ts.map +1 -0
  9. package/dist/collector/error-tracker.d.ts +43 -0
  10. package/dist/collector/error-tracker.d.ts.map +1 -0
  11. package/dist/collector/exposure-tracker.d.ts +60 -0
  12. package/dist/collector/exposure-tracker.d.ts.map +1 -0
  13. package/dist/collector/input-tracker.d.ts +30 -0
  14. package/dist/collector/input-tracker.d.ts.map +1 -0
  15. package/dist/collector/performance-tracker.d.ts +48 -0
  16. package/dist/collector/performance-tracker.d.ts.map +1 -0
  17. package/dist/collector/view-tracker.d.ts +38 -0
  18. package/dist/collector/view-tracker.d.ts.map +1 -0
  19. package/dist/core/config.d.ts +27 -0
  20. package/dist/core/config.d.ts.map +1 -0
  21. package/dist/core/event-bus.d.ts +30 -0
  22. package/dist/core/event-bus.d.ts.map +1 -0
  23. package/dist/core/request.d.ts +35 -0
  24. package/dist/core/request.d.ts.map +1 -0
  25. package/dist/core/storage.d.ts +67 -0
  26. package/dist/core/storage.d.ts.map +1 -0
  27. package/dist/core/utils.d.ts +61 -0
  28. package/dist/core/utils.d.ts.map +1 -0
  29. package/dist/extension/behavior-analysis.d.ts +41 -0
  30. package/dist/extension/behavior-analysis.d.ts.map +1 -0
  31. package/dist/extension/network-interceptor.d.ts +32 -0
  32. package/dist/extension/network-interceptor.d.ts.map +1 -0
  33. package/dist/extension/plugin-manager.d.ts +32 -0
  34. package/dist/extension/plugin-manager.d.ts.map +1 -0
  35. package/dist/extension/session-replay.d.ts +80 -0
  36. package/dist/extension/session-replay.d.ts.map +1 -0
  37. package/dist/index.d.ts +9 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.es.js +8443 -0
  40. package/dist/index.es.js.map +1 -0
  41. package/dist/index.iife.js +3 -0
  42. package/dist/index.iife.js.map +1 -0
  43. package/dist/index.umd.js +3 -0
  44. package/dist/index.umd.js.map +1 -0
  45. package/dist/processor/compressor.d.ts +16 -0
  46. package/dist/processor/compressor.d.ts.map +1 -0
  47. package/dist/processor/data-processor.d.ts +36 -0
  48. package/dist/processor/data-processor.d.ts.map +1 -0
  49. package/dist/processor/deduplicator.d.ts +29 -0
  50. package/dist/processor/deduplicator.d.ts.map +1 -0
  51. package/dist/processor/sampler.d.ts +16 -0
  52. package/dist/processor/sampler.d.ts.map +1 -0
  53. package/dist/tracker.d.ts +111 -0
  54. package/dist/tracker.d.ts.map +1 -0
  55. package/dist/transport/batch-sender.d.ts +80 -0
  56. package/dist/transport/batch-sender.d.ts.map +1 -0
  57. package/dist/transport/offline-storage.d.ts +60 -0
  58. package/dist/transport/offline-storage.d.ts.map +1 -0
  59. package/dist/transport/retry-handler.d.ts +29 -0
  60. package/dist/transport/retry-handler.d.ts.map +1 -0
  61. package/dist/transport/sender.d.ts +27 -0
  62. package/dist/transport/sender.d.ts.map +1 -0
  63. package/package.json +70 -0
@@ -0,0 +1,3 @@
1
+ var TrackerSDK=function(e){"use strict";var t=Object.defineProperty,r=(e,r,s)=>((e,r,s)=>r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s)(e,"symbol"!=typeof r?r+"":r,s);const s={appId:"",serverUrl:void 0,enableAutoTrack:!0,enableErrorTrack:!0,enablePerformanceTrack:!1,enableSessionReplay:!1,batchSize:10,batchWait:5e3,sampleRate:1,enableOfflineStorage:!0,maxOfflineStorageSize:1e3,maxRetries:3,userId:"",deviceId:"",customProperties:{}};class n{constructor(e){r(this,"config"),this.config={...s,...e,customProperties:{...s.customProperties,...e.customProperties}}}get(e){return this.config[e]}getAll(){return{...this.config}}set(e,t){this.config[e]=t}update(e){this.config={...this.config,...e,customProperties:{...this.config.customProperties,...e.customProperties||{}}}}}const i=new class{constructor(){r(this,"events",new Map)}on(e,t){this.events.has(e)||this.events.set(e,[]),this.events.get(e).push(t)}off(e,t){if(!this.events.has(e))return;if(!t)return void this.events.delete(e);const r=this.events.get(e),s=r.indexOf(t);s>-1&&r.splice(s,1)}emit(e,...t){if(!this.events.has(e))return;this.events.get(e).forEach(r=>{try{r(...t)}catch(s){console.error(`EventBus: Error in callback for event "${e}":`,s)}})}once(e,t){const r=(...s)=>{t(...s),this.off(e,r)};this.on(e,r)}clear(){this.events.clear()}};function a(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function o(){return"undefined"==typeof window?"":window.location.href}function l(){return"undefined"==typeof window?"":document.title||""}function c(e,t){let r=null;return function(...s){r&&clearTimeout(r),r=setTimeout(()=>{r=null,e(...s)},t)}}function h(e,t){let r=null,s=0;return function(...n){const i=Date.now(),a=t-(i-s);a<=0||a>t?(r&&(clearTimeout(r),r=null),s=i,e(...n)):r||(r=setTimeout(()=>{s=Date.now(),r=null,e(...n)},a))}}function d(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof Array)return e.map(e=>d(e));if("object"==typeof e){const t={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=d(e[r]));return t}return e}function u(e){if(!e)return"";const t=[];for(;e&&e.nodeType===Node.ELEMENT_NODE;){let r=e.nodeName.toLowerCase();if(e.id){r+=`#${e.id}`,t.unshift(r);break}if(e.className){const t=e.className.trim().split(/\s+/).filter(e=>e.length>0).join(".");t&&(r+=`.${t}`)}let s=e,n=1;for(;s=s.previousElementSibling;)s.nodeName===e.nodeName&&n++;n>1&&(r+=`:nth-of-type(${n})`),t.unshift(r),e=e.parentElement}return t.join(" > ")}function f(e){var t;return e?{tagName:e.tagName.toLowerCase(),id:e.id||void 0,className:e.className&&"string"==typeof e.className?e.className:void 0,text:(null==(t=e.textContent)?void 0:t.trim().substring(0,100))||void 0}:{}}class p{constructor(){r(this,"startTime",Date.now()),r(this,"currentUrl",""),r(this,"popstateHandler",null),r(this,"visibilityChangeHandler",null),r(this,"beforeUnloadHandler",null),r(this,"isTracking",!1),r(this,"pendingUrlCheck",null),r(this,"lastPageViewTime",0),r(this,"minPageViewInterval",1e3),r(this,"hiddenStartTime",null),r(this,"totalHiddenTime",0),r(this,"isVisible",!0)}init(){this.trackPageView(),this.setupSPARouter(),this.setupPageLifecycle()}trackPageView(){if(this.isTracking)return{type:"pageview",name:"pageview",timestamp:Date.now(),url:this.currentUrl||o(),title:l()};this.isTracking=!0;try{const e=Date.now(),t=o(),r=l(),s="undefined"==typeof window?"":document.referrer||"",n=t!==this.currentUrl||""===this.currentUrl;if(!n&&this.lastPageViewTime>0){if(e-this.lastPageViewTime<this.minPageViewInterval)return{type:"pageview",name:"pageview",timestamp:e,url:this.currentUrl,title:r}}const i=this.currentUrl?e-this.startTime-this.totalHiddenTime:0,a=i>0?i:0,c={type:"pageview",name:"pageview",timestamp:e,url:t,title:r,referrer:this.currentUrl?s:void 0,duration:a>0?a:void 0};return n&&(this.startTime=e,this.currentUrl=t,this.totalHiddenTime=0),this.lastPageViewTime=e,"undefined"!=typeof window&&window.__trackerEventBus&&window.__trackerEventBus.emit("pageview",c),c}finally{setTimeout(()=>{this.isTracking=!1},0)}}setupSPARouter(){if("undefined"==typeof window)return;this.popstateHandler=()=>{this.trackPageView()},window.addEventListener("popstate",this.popstateHandler);const e=history;if(!e._trackerPushStateWrapped){const t=history.pushState.bind(history);e._originalPushState=t,e._trackerPushStateWrapped=!0;const r=this;history.pushState=function(...e){const s=t.apply(history,e);return r.pendingUrlCheck&&clearTimeout(r.pendingUrlCheck),r.pendingUrlCheck=setTimeout(()=>{o()!==r.currentUrl&&r.trackPageView(),r.pendingUrlCheck=null},100),s}}if(!e._trackerReplaceStateWrapped){const t=history.replaceState.bind(history);e._originalReplaceState=t,e._trackerReplaceStateWrapped=!0;const r=this;history.replaceState=function(...e){const s=t.apply(history,e);return r.pendingUrlCheck&&clearTimeout(r.pendingUrlCheck),r.pendingUrlCheck=setTimeout(()=>{o()!==r.currentUrl&&r.trackPageView(),r.pendingUrlCheck=null},100),s}}}setupPageLifecycle(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const e=document.hidden,t=Date.now();e&&this.isVisible?(this.hiddenStartTime=t,this.isVisible=!1):e||this.isVisible||(this.hiddenStartTime&&(this.totalHiddenTime+=t-this.hiddenStartTime,this.hiddenStartTime=null),this.isVisible=!0)},document.addEventListener("visibilitychange",this.visibilityChangeHandler),this.beforeUnloadHandler=()=>{const e=Date.now();this.hiddenStartTime&&(this.totalHiddenTime+=e-this.hiddenStartTime,this.hiddenStartTime=null);const t=this.currentUrl?e-this.startTime-this.totalHiddenTime:0;if(t>0&&this.currentUrl)try{const r={type:"pageview",name:"page-before-unload",timestamp:e,url:this.currentUrl,title:l(),duration:t};"undefined"!=typeof window&&window.__trackerEventBus&&window.__trackerEventBus.emit("pageview",r)}catch(r){console.error("ViewTracker: Error sending final pageview event:",r)}},window.addEventListener("beforeunload",this.beforeUnloadHandler))}destroy(){if(this.pendingUrlCheck&&(clearTimeout(this.pendingUrlCheck),this.pendingUrlCheck=null),this.popstateHandler&&"undefined"!=typeof window&&(window.removeEventListener("popstate",this.popstateHandler),this.popstateHandler=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null),this.beforeUnloadHandler&&"undefined"!=typeof window&&(window.removeEventListener("beforeunload",this.beforeUnloadHandler),this.beforeUnloadHandler=null),"undefined"!=typeof window){const e=history;e._trackerPushStateWrapped&&e._originalPushState&&(history.pushState=e._originalPushState,e._trackerPushStateWrapped=!1,delete e._originalPushState),e._trackerReplaceStateWrapped&&e._originalReplaceState&&(history.replaceState=e._originalReplaceState,e._trackerReplaceStateWrapped=!1,delete e._originalReplaceState)}}}class m{constructor(){r(this,"clickHandler",null),r(this,"touchStartHandler",null),r(this,"touchEndHandler",null),r(this,"debounceTime",300),r(this,"touchTimeout",null),r(this,"lastTouch",null),r(this,"TOUCH_CLICK_THRESHOLD",300),r(this,"TOUCH_DISTANCE_THRESHOLD",10)}init(e){"undefined"!=typeof window&&(void 0!==e&&(this.debounceTime=e),this.clickHandler=c((...e)=>{const t=e[0];this.handleClick(t)},this.debounceTime),this.touchStartHandler=e=>{this.handleTouch(e)},this.touchEndHandler=c((...e)=>{const t=e[0];this.handleTouch(t)},this.debounceTime),document.addEventListener("click",this.clickHandler,!1),document.addEventListener("touchstart",this.touchStartHandler,{passive:!0,capture:!1}),document.addEventListener("touchend",this.touchEndHandler,{passive:!0,capture:!1}))}handleTouch(e){try{const t=Date.now();switch(e.type){case"touchstart":if(e.touches.length>0){const r=e.touches[0];this.lastTouch={x:r.clientX,y:r.clientY,time:t}}break;case"touchend":if(this.lastTouch&&e.changedTouches.length>0){const r=e.changedTouches[0],s=Math.abs(r.clientX-this.lastTouch.x),n=Math.abs(r.clientY-this.lastTouch.y);t-this.lastTouch.time<this.TOUCH_CLICK_THRESHOLD&&s<this.TOUCH_DISTANCE_THRESHOLD&&n<this.TOUCH_DISTANCE_THRESHOLD&&(this.touchTimeout&&clearTimeout(this.touchTimeout),this.touchTimeout=window.setTimeout(()=>{try{this.processTouchInteraction(r,e.target)}catch(t){console.error("ClickTracker: Error processing touch interaction:",t)}this.touchTimeout=null},100)),this.lastTouch=null}}}catch(t){console.error("ClickTracker: Error handling touch event:",t)}}processTouchInteraction(e,t){if(!t)return;const r=o(),s=l(),n=Date.now(),i={x:e.clientX,y:e.clientY},a=()=>{try{const e=u(t),a=f(t),o={type:"click",name:"touch-click",timestamp:n,url:r,title:s,elementPath:e,elementInfo:a,position:i,interactionType:"touch"};"undefined"!=typeof window&&window.__trackerEventBus&&window.__trackerEventBus.emit("click",o)}catch(e){console.error("ClickTracker: Error processing touch interaction:",e)}};"undefined"!=typeof requestIdleCallback?requestIdleCallback(a,{timeout:50}):setTimeout(a,0)}handleClick(e){try{const t=e.target;if(!t)return;const r=o(),s=l(),n=Date.now(),i={x:e.clientX,y:e.clientY},a=()=>{try{const e=u(t),a=f(t),o={type:"click",name:"click",timestamp:n,url:r,title:s,elementPath:e,elementInfo:a,position:i,interactionType:"mouse"};"undefined"!=typeof window&&window.__trackerEventBus&&window.__trackerEventBus.emit("click",o)}catch(e){console.error("ClickTracker: Error processing click event:",e)}};"undefined"!=typeof requestIdleCallback?requestIdleCallback(a,{timeout:100}):setTimeout(a,0)}catch(t){console.error("ClickTracker: Error handling click event:",t)}}getClickEvent(e){try{const t=e.target;return t?{type:"click",name:"click",timestamp:Date.now(),url:o(),title:l(),elementPath:u(t),elementInfo:f(t),position:{x:e.clientX,y:e.clientY},interactionType:"mouse"}:null}catch(t){return console.error("ClickTracker: Error creating click event:",t),null}}destroy(){this.clickHandler&&"undefined"!=typeof document&&(document.removeEventListener("click",this.clickHandler,!1),this.clickHandler=null),this.touchStartHandler&&"undefined"!=typeof document&&(document.removeEventListener("touchstart",this.touchStartHandler),this.touchStartHandler=null),this.touchEndHandler&&"undefined"!=typeof document&&(document.removeEventListener("touchend",this.touchEndHandler),this.touchEndHandler=null),this.touchTimeout&&(clearTimeout(this.touchTimeout),this.touchTimeout=null),this.lastTouch=null}}class g{constructor(e={}){r(this,"observer",null),r(this,"exposedElements",new Set),r(this,"options"),r(this,"exposureMap",new Map),r(this,"scrollFallbackHandler",null),r(this,"resizeFallbackHandler",null),r(this,"cachedElements",[]),r(this,"lastCacheUpdate",0),r(this,"CACHE_UPDATE_INTERVAL",2e3),this.options={threshold:.5,root:null,rootMargin:"0px",...e}}init(){"undefined"!=typeof window&&window.IntersectionObserver?(this.observer=new IntersectionObserver(h((...e)=>{e[0].forEach(e=>{this.handleIntersection(e)})},100),{threshold:this.options.threshold||.5,root:this.options.root,rootMargin:this.options.rootMargin}),this.observeElements()):this.initScrollFallback()}observeElements(){if(!this.observer||"undefined"==typeof document)return;const e=document.querySelectorAll("[data-track-exposure]");e.forEach(e=>{this.observer.observe(e)}),this.cachedElements=Array.from(e),this.lastCacheUpdate=Date.now()}observe(e){this.observer&&(this.observer.observe(e),this.cachedElements.includes(e)||(this.cachedElements.push(e),this.lastCacheUpdate=Date.now()))}unobserve(e){if(!this.observer)return;this.observer.unobserve(e),this.exposedElements.delete(e),this.exposureMap.delete(e);const t=this.cachedElements.indexOf(e);t>-1&&(this.cachedElements.splice(t,1),this.lastCacheUpdate=Date.now())}handleIntersection(e){const{target:t,intersectionRatio:r,isIntersecting:s}=e;if(s&&r>=(this.options.threshold||.5))this.exposedElements.has(t)||(this.exposedElements.add(t),this.triggerExposure(t)),this.exposureMap.set(t,Date.now());else if(!s){const e=this.exposureMap.get(t);if(e){const r=Date.now()-e;this.triggerExposure(t,r),this.exposureMap.delete(t),this.exposedElements.delete(t)}}}triggerExposure(e,t){try{const r={type:"exposure",name:"exposure",timestamp:Date.now(),url:o(),title:l(),elementPath:u(e),duration:t};"undefined"!=typeof window&&window.__trackerEventBus&&window.__trackerEventBus.emit("exposure",r)}catch(r){console.error("ExposureTracker: Error triggering exposure event:",r)}}getExposureElements(){const e=Date.now();return(0===this.cachedElements.length||e-this.lastCacheUpdate>this.CACHE_UPDATE_INTERVAL)&&"undefined"!=typeof document&&(this.cachedElements=Array.from(document.querySelectorAll("[data-track-exposure]")),this.lastCacheUpdate=e),this.cachedElements}initScrollFallback(){if("undefined"==typeof window)return;this.cachedElements=Array.from(document.querySelectorAll("[data-track-exposure]")),this.lastCacheUpdate=Date.now();const e=h(()=>{const e=this.getExposureElements(),t=Date.now();e.forEach(e=>{const r=e.getBoundingClientRect(),s=window.innerHeight||document.documentElement.clientHeight,n=window.innerWidth||document.documentElement.clientWidth,i=(Math.min(r.bottom,s)-Math.max(r.top,0))*(Math.min(r.right,n)-Math.max(r.left,0)),a=r.height*r.width;if((a>0?i/a:0)>=(this.options.threshold||.5))this.exposedElements.has(e)||(this.exposedElements.add(e),this.exposureMap.set(e,t),this.triggerExposure(e));else if(this.exposedElements.has(e)){const r=this.exposureMap.get(e);if(r){const s=t-r;this.triggerExposure(e,s),this.exposureMap.delete(e),this.exposedElements.delete(e)}}})},100);this.scrollFallbackHandler=e,this.resizeFallbackHandler=e,window.addEventListener("scroll",this.scrollFallbackHandler,{passive:!0}),window.addEventListener("resize",this.resizeFallbackHandler,{passive:!0}),setTimeout(e,0)}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.scrollFallbackHandler&&"undefined"!=typeof window&&(window.removeEventListener("scroll",this.scrollFallbackHandler),this.scrollFallbackHandler=null),this.resizeFallbackHandler&&"undefined"!=typeof window&&(window.removeEventListener("resize",this.resizeFallbackHandler),this.resizeFallbackHandler=null),this.exposedElements.clear(),this.exposureMap.clear(),this.cachedElements=[],this.lastCacheUpdate=0}}class w{constructor(){r(this,"inputHandler",null),r(this,"changeHandler",null),r(this,"inputDebounceTime",500),r(this,"selectDebounceTime",300),r(this,"skipEmptyInput",!0),r(this,"sensitiveKeywords",["password","pwd","secret","token","key","auth","credential"])}init(e,t){"undefined"!=typeof window&&(void 0!==e&&(this.inputDebounceTime=e,this.selectDebounceTime=Math.min(e,300)),void 0!==t&&(this.skipEmptyInput=t),this.inputHandler=c((...e)=>{const t=e[0];this.handleInput(t)},this.inputDebounceTime),this.changeHandler=c((...e)=>{const t=e[0];this.handleChange(t)},this.selectDebounceTime),document.addEventListener("input",this.inputHandler,!1),document.addEventListener("change",this.changeHandler,!1))}handleInput(e){var t;const r=e.target;if(!r)return;const s=null==(t=r.tagName)?void 0:t.toLowerCase();if("input"!==s&&"textarea"!==s)return;const n=o(),i=l(),a=Date.now(),c=()=>{var e;try{const t=u(r),o={...f(r),name:r.name||void 0,type:r.type||void 0,placeholder:r.placeholder||void 0},l=this.isSensitiveField(r);let c,h,d="text";if("textarea"===s)d="textarea";else if("input"===s){const t=(null==(e=r.type)?void 0:e.toLowerCase())||"text";d="checkbox"===t?"checkbox":"radio"===t?"radio":"text"}if(l?(h=r.value.length,c=void 0):(c=r.value,h=r.value.length),this.skipEmptyInput&&0===h)return;const p={type:"input",name:"input",timestamp:a,url:n,title:i,elementPath:t,elementInfo:o,inputType:d,value:c,valueLength:h,isSensitive:l};"undefined"!=typeof window&&window.__trackerEventBus&&window.__trackerEventBus.emit("input",p)}catch(t){console.error("InputTracker: Error processing input event:",t)}};"undefined"!=typeof requestIdleCallback?requestIdleCallback(c,{timeout:100}):setTimeout(c,0)}handleChange(e){var t;const r=e.target;if(!r)return;if("select"!==(null==(t=r.tagName)?void 0:t.toLowerCase()))return;const s=o(),n=l(),i=Date.now(),a=()=>{try{const e=u(r),t={...f(r),name:r.name||void 0},a=this.isSensitiveField(r),o=r;let l,c;if(a?(c=o.value.length,l=void 0):(l=o.value,c=o.value.length),this.skipEmptyInput&&0===c)return;const h={type:"input",name:"input",timestamp:i,url:s,title:n,elementPath:e,elementInfo:t,inputType:"select",value:l,valueLength:c,isSensitive:a};"undefined"!=typeof window&&window.__trackerEventBus&&window.__trackerEventBus.emit("input",h)}catch(e){console.error("InputTracker: Error processing change event:",e)}};"undefined"!=typeof requestIdleCallback?requestIdleCallback(a,{timeout:100}):setTimeout(a,0)}isSensitiveField(e){var t,r,s,n;if(e instanceof HTMLInputElement){if("password"===(null==(t=e.type)?void 0:t.toLowerCase()))return!0}const i=(null==(r=e.name)?void 0:r.toLowerCase())||"";if(i)for(const l of this.sensitiveKeywords)if(i.includes(l))return!0;const a=(null==(s=e.id)?void 0:s.toLowerCase())||"";if(a)for(const l of this.sensitiveKeywords)if(a.includes(l))return!0;const o=(null==(n=e.className)?void 0:n.toLowerCase())||"";if(o)for(const l of this.sensitiveKeywords)if(o.includes(l))return!0;return!1}destroy(){this.inputHandler&&"undefined"!=typeof document&&(document.removeEventListener("input",this.inputHandler,!1),this.inputHandler=null),this.changeHandler&&"undefined"!=typeof document&&(document.removeEventListener("change",this.changeHandler,!1),this.changeHandler=null)}}class _{constructor(){r(this,"viewTracker"),r(this,"clickTracker"),r(this,"exposureTracker"),r(this,"inputTracker"),r(this,"enabled",!1),this.viewTracker=new p,this.clickTracker=new m,this.exposureTracker=new g,this.inputTracker=new w}init(e){if(this.enabled)return;const{enableClick:t=!0,enableExposure:r=!0,enableInput:s=!0,clickDebounceTime:n,inputDebounceTime:i}=e||{};this.viewTracker.init(),t&&this.clickTracker.init(n),r&&this.exposureTracker.init(),s&&this.inputTracker.init(i),this.enabled=!0}getViewTracker(){return this.viewTracker}getClickTracker(){return this.clickTracker}getExposureTracker(){return this.exposureTracker}getInputTracker(){return this.inputTracker}destroy(){this.enabled&&(this.viewTracker.destroy(),this.clickTracker.destroy(),this.exposureTracker.destroy(),this.inputTracker.destroy(),this.enabled=!1)}}class y{constructor(){r(this,"handlers",[]),r(this,"errorCache",new Map),r(this,"debounceTime",500)}init(){if("undefined"==typeof window)return;const e=e=>{e instanceof ErrorEvent?this.handleJSError(e):this.handleResourceError(e)};window.addEventListener("error",e,!0),this.handlers.push(()=>{window.removeEventListener("error",e,!0)});const t=e=>{this.handlePromiseError(e)};window.addEventListener("unhandledrejection",t),this.handlers.push(()=>{window.removeEventListener("unhandledrejection",t)})}handleJSError(e){var t;try{const r={type:"error",name:"js-error",timestamp:Date.now(),url:e.filename||o(),title:l(),errorType:"js",message:e.message||"Unknown error",stack:null==(t=e.error)?void 0:t.stack,filename:e.filename,lineno:e.lineno,colno:e.colno};this.emitError(r)}catch(r){console.error("ErrorTracker: Error handling JS error:",r)}}handlePromiseError(e){try{const t=e.reason;let r,s="Unhandled promise rejection";t instanceof Error?(s=t.message,r=t.stack):s="string"==typeof t?t:JSON.stringify(t);const n={type:"error",name:"promise-error",timestamp:Date.now(),url:o(),title:l(),errorType:"promise",message:s,stack:r};this.emitError(n)}catch(t){console.error("ErrorTracker: Error handling promise error:",t)}}handleResourceError(e){var t;try{const r=e.target;if(!r)return;const s=null==(t=r.tagName)?void 0:t.toLowerCase();if(!["img","script","link","audio","video"].includes(s))return;let n="";if(r instanceof HTMLImageElement||r instanceof HTMLScriptElement?n=r.src||"":r instanceof HTMLLinkElement?n=r.href||"":(r instanceof HTMLAudioElement||r instanceof HTMLVideoElement)&&(n=r.src||""),!n)return;const i={type:"error",name:"resource-error",timestamp:Date.now(),url:o(),title:l(),errorType:"resource",message:`Failed to load resource: ${n}`,resourceUrl:n,resourceType:s};this.emitError(i)}catch(r){console.error("ErrorTracker: Error handling resource error:",r)}}getErrorKey(e){const t=[e.errorType,e.message];return"js"!==e.errorType&&"promise"!==e.errorType||(e.filename&&t.push(e.filename),e.lineno&&t.push(String(e.lineno)),e.colno&&t.push(String(e.colno))),"resource"===e.errorType&&e.resourceUrl&&t.push(e.resourceUrl),t.join("|")}emitError(e){const t=this.getErrorKey(e),r=this.errorCache.get(t),s=Date.now();r&&s-r<this.debounceTime||(this.errorCache.set(t,s),this.cleanExpiredErrorCache(s),"undefined"!=typeof window&&window.__trackerEventBus&&window.__trackerEventBus.emit("error",e))}cleanExpiredErrorCache(e){for(const[t,r]of this.errorCache.entries())e-r>3e5&&this.errorCache.delete(t)}trackError(e,t){try{let r,s;e instanceof Error?(r=e.message,s=e.stack):r=e;const n={type:"error",name:"custom-error",timestamp:Date.now(),url:o(),title:l(),errorType:"js",message:r,stack:s,properties:t};this.emitError(n)}catch(r){console.error("ErrorTracker: Error tracking custom error:",r)}}destroy(){this.handlers.forEach(e=>e()),this.handlers=[],this.errorCache.clear()}}class b{constructor(){r(this,"observer",null),r(this,"navigationTimingCollected",!1),r(this,"resourceCache",new Map),r(this,"longTaskCache",new Map),r(this,"resourceDebounceTime",1e3),r(this,"longTaskDebounceTime",100)}init(){"undefined"!=typeof window&&window.performance&&("complete"===document.readyState?(this.collectNavigationTiming(),this.collectResourceTiming()):window.addEventListener("load",()=>{this.collectNavigationTiming(),this.collectResourceTiming()}),this.observeLongTasks())}collectNavigationTiming(){if(!this.navigationTimingCollected)try{const e=performance.getEntriesByType("navigation")[0];if(!e)return;const t={dns:e.domainLookupEnd-e.domainLookupStart,tcp:e.connectEnd-e.connectStart,ssl:e.secureConnectionStart>0?e.connectEnd-e.secureConnectionStart:0,ttfb:e.responseStart-e.requestStart,response:e.responseEnd-e.responseStart,domParse:e.domInteractive-e.responseEnd,resourceLoad:e.loadEventStart-e.domContentLoadedEventEnd,total:e.loadEventEnd-e.fetchStart,domContentLoaded:e.domContentLoadedEventEnd-e.fetchStart,load:e.loadEventEnd-e.fetchStart},r={type:"performance",name:"navigation-timing",timestamp:Date.now(),url:o(),title:l(),metricType:"navigation",metrics:t};this.navigationTimingCollected=!0,this.emitPerformance(r)}catch(e){console.error("PerformanceTracker: Error collecting navigation timing:",e)}}collectResourceTiming(){try{const e=performance.getEntriesByType("resource");if(!e||0===e.length)return;const t=Date.now();e.forEach(e=>{const r=e.name,s=this.resourceCache.get(r);if(s&&t-s<this.resourceDebounceTime)return;this.resourceCache.set(r,t);const n={dns:e.domainLookupEnd-e.domainLookupStart,tcp:e.connectEnd-e.connectStart,request:e.responseStart-e.requestStart,response:e.responseEnd-e.responseStart,total:e.responseEnd-e.startTime,size:e.transferSize||0},i={type:"performance",name:"resource-timing",timestamp:t,url:o(),title:l(),metricType:"resource",metrics:{...n,resourceUrl:e.name,resourceType:e.initiatorType}};this.emitPerformance(i)}),this.cleanExpiredResourceCache(t)}catch(e){console.error("PerformanceTracker: Error collecting resource timing:",e)}}observeLongTasks(){if("undefined"!=typeof PerformanceObserver)try{const e=h((...e)=>{const t=e[0],r=Date.now(),s=`${t.startTime}-${t.duration}`,n=this.longTaskCache.get(s);if(n&&r-n<this.longTaskDebounceTime)return;this.longTaskCache.set(s,r);const i={type:"performance",name:"longtask",timestamp:r,url:o(),title:l(),metricType:"longtask",metrics:{duration:t.duration,startTime:t.startTime}};this.emitPerformance(i),this.cleanExpiredLongTaskCache(r)},this.longTaskDebounceTime);this.observer=new PerformanceObserver(t=>{t.getEntries().forEach(t=>{"longtask"===t.entryType&&e(t)})}),this.observer.observe({entryTypes:["longtask"]})}catch(e){console.error("PerformanceTracker: Error observing long tasks:",e)}}cleanExpiredResourceCache(e){for(const[t,r]of this.resourceCache.entries())e-r>3e5&&this.resourceCache.delete(t)}cleanExpiredLongTaskCache(e){for(const[t,r]of this.longTaskCache.entries())e-r>6e4&&this.longTaskCache.delete(t)}emitPerformance(e){"undefined"!=typeof window&&window.__trackerEventBus&&window.__trackerEventBus.emit("performance",e)}collectMetrics(){try{const e=performance.getEntriesByType("navigation")[0];if(!e)return null;const t={dns:e.domainLookupEnd-e.domainLookupStart,tcp:e.connectEnd-e.connectStart,ttfb:e.responseStart-e.requestStart,response:e.responseEnd-e.responseStart,domParse:e.domInteractive-e.responseEnd,resourceLoad:e.loadEventStart-e.domContentLoadedEventEnd,total:e.loadEventEnd-e.fetchStart};return{type:"performance",name:"custom-performance",timestamp:Date.now(),url:o(),title:l(),metricType:"navigation",metrics:t}}catch(e){return console.error("PerformanceTracker: Error collecting metrics:",e),null}}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.navigationTimingCollected=!1,this.resourceCache.clear(),this.longTaskCache.clear()}}class v{track(e,t){return{type:"custom",name:"custom",eventName:e,timestamp:Date.now(),url:o(),title:l(),properties:t}}}class k{shouldSample(e){return e>=1||!(e<=0)&&Math.random()<e}shouldSampleCritical(e,t){return!!e||this.shouldSample(t)}}class E{constructor(){r(this,"eventCache",new Map),r(this,"cacheTimeouts",{click:1e4,exposure:3e4,error:5e3,performance:6e4,pageview:1e4,input:3e3,custom:1e3}),r(this,"defaultCacheTimeout",6e4)}isDuplicate(e){const t=this.getEventKey(e),r=this.eventCache.get(t),s=Date.now();let n=this.cacheTimeouts[e.type]||this.defaultCacheTimeout;if("custom"===e.type&&"eventName"in e){const t=e.eventName;"api-request"!==t&&"api-response"!==t||(n=5e3)}return!!(r&&s-r<n)||(this.eventCache.set(t,s),this.cleanExpiredCache(s),!1)}getEventKey(e){const t=[e.type,e.name,e.url];if("click"===e.type&&"elementPath"in e){if(t.push(e.elementPath||""),"position"in e&&e.position){const r=10,s=Math.floor(e.position.x/r)*r,n=Math.floor(e.position.y/r)*r;t.push(`${s}-${n}`)}}else if("exposure"===e.type&&"elementPath"in e)t.push(e.elementPath||"");else if("input"===e.type&&"elementPath"in e){if(t.push(e.elementPath||""),"value"in e&&void 0!==e.value&&null!==e.value){const r=String(e.value),s=r.length>10?r.substring(0,10):r;t.push(this.simpleHash(s))}else"valueLength"in e&&void 0!==e.valueLength&&t.push(String(e.valueLength));"isSensitive"in e&&e.isSensitive&&t.push("sensitive")}else if("error"===e.type&&"message"in e)t.push(e.message),"filename"in e&&e.filename&&t.push(e.filename),"lineno"in e&&e.lineno&&t.push(String(e.lineno)),"colno"in e&&e.colno&&t.push(String(e.colno)),"resourceUrl"in e&&e.resourceUrl&&t.push(e.resourceUrl);else if("performance"===e.type&&"metricType"in e)if(t.push(e.metricType),"resource"===e.metricType&&"metrics"in e&&e.metrics){const r=e.metrics.resourceUrl;r&&t.push(String(r))}else if("longtask"===e.metricType&&"metrics"in e&&e.metrics){const r=e.metrics;void 0!==r.startTime&&void 0!==r.duration&&t.push(`${r.startTime}-${r.duration}`)}else e.metricType;else if("custom"===e.type&&"eventName"in e){if(t.push(e.eventName),"api-request"===e.eventName||"api-response"===e.eventName){if(e.properties){const r=e.properties,s=r.url?String(r.url):"",n=r.method?String(r.method):"",i=r.fullUrl?String(r.fullUrl):"";if(s||n||i)t.push(i||`${n}:${s}`);else try{const r=JSON.stringify(e.properties);t.push(r.substring(0,100))}catch{t.push(String(Object.keys(e.properties).length))}}}else if(e.properties)try{const r=JSON.stringify(e.properties);t.push(r.substring(0,100))}catch{t.push(String(Object.keys(e.properties).length))}}else if("pageview"===e.type){const r=Math.floor(e.timestamp/1e4);t.push(String(r))}return t.join("|")}simpleHash(e){let t=0;for(let r=0;r<e.length;r++){t=(t<<5)-t+e.charCodeAt(r),t&=t}return Math.abs(t).toString(36).substring(0,8)}cleanExpiredCache(e){const t=2*Math.max(...Object.values(this.cacheTimeouts),this.defaultCacheTimeout);for(const[r,s]of this.eventCache.entries())e-s>t&&this.eventCache.delete(r)}clear(){this.eventCache.clear()}}
2
+ /*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function T(e){let t=e.length;for(;--t>=0;)e[t]=0}const S=256,x=286,z=30,I=15,R=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),C=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),D=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),U=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),A=new Array(576);T(A);const H=new Array(60);T(H);const L=new Array(512);T(L);const B=new Array(256);T(B);const O=new Array(29);T(O);const P=new Array(z);function N(e,t,r,s,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=s,this.max_length=n,this.has_stree=e&&e.length}let M,F,Z;function q(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}T(P);const j=e=>e<256?L[e]:L[256+(e>>>7)],$=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},K=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,$(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},V=(e,t,r)=>{K(e,r[2*t],r[2*t+1])},X=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},W=(e,t,r)=>{const s=new Array(16);let n,i,a=0;for(n=1;n<=I;n++)a=a+r[n-1]<<1,s[n]=a;for(i=0;i<=t;i++){let t=e[2*i+1];0!==t&&(e[2*i]=X(s[t]++,t))}},J=e=>{let t;for(t=0;t<x;t++)e.dyn_ltree[2*t]=0;for(t=0;t<z;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},Y=e=>{e.bi_valid>8?$(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},G=(e,t,r,s)=>{const n=2*t,i=2*r;return e[n]<e[i]||e[n]===e[i]&&s[t]<=s[r]},Q=(e,t,r)=>{const s=e.heap[r];let n=r<<1;for(;n<=e.heap_len&&(n<e.heap_len&&G(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!G(t,s,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=s},ee=(e,t,r)=>{let s,n,i,a,o=0;if(0!==e.sym_next)do{s=255&e.pending_buf[e.sym_buf+o++],s+=(255&e.pending_buf[e.sym_buf+o++])<<8,n=e.pending_buf[e.sym_buf+o++],0===s?V(e,n,t):(i=B[n],V(e,i+S+1,t),a=R[i],0!==a&&(n-=O[i],K(e,n,a)),s--,i=j(s),V(e,i,r),a=C[i],0!==a&&(s-=P[i],K(e,s,a)))}while(o<e.sym_next);V(e,256,t)},te=(e,t)=>{const r=t.dyn_tree,s=t.stat_desc.static_tree,n=t.stat_desc.has_stree,i=t.stat_desc.elems;let a,o,l,c=-1;for(e.heap_len=0,e.heap_max=573,a=0;a<i;a++)0!==r[2*a]?(e.heap[++e.heap_len]=c=a,e.depth[a]=0):r[2*a+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=c<2?++c:0,r[2*l]=1,e.depth[l]=0,e.opt_len--,n&&(e.static_len-=s[2*l+1]);for(t.max_code=c,a=e.heap_len>>1;a>=1;a--)Q(e,r,a);l=i;do{a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Q(e,r,1),o=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=o,r[2*l]=r[2*a]+r[2*o],e.depth[l]=(e.depth[a]>=e.depth[o]?e.depth[a]:e.depth[o])+1,r[2*a+1]=r[2*o+1]=l,e.heap[1]=l++,Q(e,r,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const r=t.dyn_tree,s=t.max_code,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,l=t.stat_desc.max_length;let c,h,d,u,f,p,m=0;for(u=0;u<=I;u++)e.bl_count[u]=0;for(r[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)h=e.heap[c],u=r[2*r[2*h+1]+1]+1,u>l&&(u=l,m++),r[2*h+1]=u,h>s||(e.bl_count[u]++,f=0,h>=o&&(f=a[h-o]),p=r[2*h],e.opt_len+=p*(u+f),i&&(e.static_len+=p*(n[2*h+1]+f)));if(0!==m){do{for(u=l-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[l]--,m-=2}while(m>0);for(u=l;0!==u;u--)for(h=e.bl_count[u];0!==h;)d=e.heap[--c],d>s||(r[2*d+1]!==u&&(e.opt_len+=(u-r[2*d+1])*r[2*d],r[2*d+1]=u),h--)}})(e,t),W(r,c,e.bl_count)},re=(e,t,r)=>{let s,n,i=-1,a=t[1],o=0,l=7,c=4;for(0===a&&(l=138,c=3),t[2*(r+1)+1]=65535,s=0;s<=r;s++)n=a,a=t[2*(s+1)+1],++o<l&&n===a||(o<c?e.bl_tree[2*n]+=o:0!==n?(n!==i&&e.bl_tree[2*n]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,i=n,0===a?(l=138,c=3):n===a?(l=6,c=3):(l=7,c=4))},se=(e,t,r)=>{let s,n,i=-1,a=t[1],o=0,l=7,c=4;for(0===a&&(l=138,c=3),s=0;s<=r;s++)if(n=a,a=t[2*(s+1)+1],!(++o<l&&n===a)){if(o<c)do{V(e,n,e.bl_tree)}while(0!==--o);else 0!==n?(n!==i&&(V(e,n,e.bl_tree),o--),V(e,16,e.bl_tree),K(e,o-3,2)):o<=10?(V(e,17,e.bl_tree),K(e,o-3,3)):(V(e,18,e.bl_tree),K(e,o-11,7));o=0,i=n,0===a?(l=138,c=3):n===a?(l=6,c=3):(l=7,c=4)}};let ne=!1;const ie=(e,t,r,s)=>{K(e,0+(s?1:0),3),Y(e),$(e,r),$(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r};var ae={_tr_init:e=>{ne||((()=>{let e,t,r,s,n;const i=new Array(16);for(r=0,s=0;s<28;s++)for(O[s]=r,e=0;e<1<<R[s];e++)B[r++]=s;for(B[r-1]=s,n=0,s=0;s<16;s++)for(P[s]=n,e=0;e<1<<C[s];e++)L[n++]=s;for(n>>=7;s<z;s++)for(P[s]=n<<7,e=0;e<1<<C[s]-7;e++)L[256+n++]=s;for(t=0;t<=I;t++)i[t]=0;for(e=0;e<=143;)A[2*e+1]=8,e++,i[8]++;for(;e<=255;)A[2*e+1]=9,e++,i[9]++;for(;e<=279;)A[2*e+1]=7,e++,i[7]++;for(;e<=287;)A[2*e+1]=8,e++,i[8]++;for(W(A,287,i),e=0;e<z;e++)H[2*e+1]=5,H[2*e]=X(e,5);M=new N(A,R,257,x,I),F=new N(H,C,0,z,I),Z=new N(new Array(0),D,0,19,7)})(),ne=!0),e.l_desc=new q(e.dyn_ltree,M),e.d_desc=new q(e.dyn_dtree,F),e.bl_desc=new q(e.bl_tree,Z),e.bi_buf=0,e.bi_valid=0,J(e)},_tr_stored_block:ie,_tr_flush_block:(e,t,r,s)=>{let n,i,a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<S;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),te(e,e.l_desc),te(e,e.d_desc),a=(e=>{let t;for(re(e,e.dyn_ltree,e.l_desc.max_code),re(e,e.dyn_dtree,e.d_desc.max_code),te(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*U[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),n=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=n&&(n=i)):n=i=r+5,r+4<=n&&-1!==t?ie(e,t,r,s):4===e.strategy||i===n?(K(e,2+(s?1:0),3),ee(e,A,H)):(K(e,4+(s?1:0),3),((e,t,r,s)=>{let n;for(K(e,t-257,5),K(e,r-1,5),K(e,s-4,4),n=0;n<s;n++)K(e,e.bl_tree[2*U[n]+1],3);se(e,e.dyn_ltree,t-1),se(e,e.dyn_dtree,r-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),ee(e,e.dyn_ltree,e.dyn_dtree)),J(e),s&&Y(e)},_tr_tally:(e,t,r)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=r,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(B[r]+S+1)]++,e.dyn_dtree[2*j(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{K(e,2,3),V(e,256,A),(e=>{16===e.bi_valid?($(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var oe=(e,t,r,s)=>{let n=65535&e,i=e>>>16&65535,a=0;for(;0!==r;){a=r>2e3?2e3:r,r-=a;do{n=n+t[s++]|0,i=i+n|0}while(--a);n%=65521,i%=65521}return n|i<<16};const le=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var s=0;s<8;s++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t})());var ce=(e,t,r,s)=>{const n=le,i=s+r;e^=-1;for(let a=s;a<i;a++)e=e>>>8^n[255&(e^t[a])];return-1^e},he={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},de={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:ue,_tr_stored_block:fe,_tr_flush_block:pe,_tr_tally:me,_tr_align:ge}=ae,{Z_NO_FLUSH:we,Z_PARTIAL_FLUSH:_e,Z_FULL_FLUSH:ye,Z_FINISH:be,Z_BLOCK:ve,Z_OK:ke,Z_STREAM_END:Ee,Z_STREAM_ERROR:Te,Z_DATA_ERROR:Se,Z_BUF_ERROR:xe,Z_DEFAULT_COMPRESSION:ze,Z_FILTERED:Ie,Z_HUFFMAN_ONLY:Re,Z_RLE:Ce,Z_FIXED:De,Z_DEFAULT_STRATEGY:Ue,Z_UNKNOWN:Ae,Z_DEFLATED:He}=de,Le=258,Be=262,Oe=42,Pe=113,Ne=666,Me=(e,t)=>(e.msg=he[t],t),Fe=e=>2*e-(e>4?9:0),Ze=e=>{let t=e.length;for(;--t>=0;)e[t]=0},qe=e=>{let t,r,s,n=e.w_size;t=e.hash_size,s=t;do{r=e.head[--s],e.head[s]=r>=n?r-n:0}while(--t);t=n,s=t;do{r=e.prev[--s],e.prev[s]=r>=n?r-n:0}while(--t)};let je=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask;const $e=e=>{const t=e.state;let r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},Ke=(e,t)=>{pe(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,$e(e.strm)},Ve=(e,t)=>{e.pending_buf[e.pending++]=t},Xe=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},We=(e,t,r,s)=>{let n=e.avail_in;return n>s&&(n=s),0===n?0:(e.avail_in-=n,t.set(e.input.subarray(e.next_in,e.next_in+n),r),1===e.state.wrap?e.adler=oe(e.adler,t,n,r):2===e.state.wrap&&(e.adler=ce(e.adler,t,n,r)),e.next_in+=n,e.total_in+=n,n)},Je=(e,t)=>{let r,s,n=e.max_chain_length,i=e.strstart,a=e.prev_length,o=e.nice_match;const l=e.strstart>e.w_size-Be?e.strstart-(e.w_size-Be):0,c=e.window,h=e.w_mask,d=e.prev,u=e.strstart+Le;let f=c[i+a-1],p=c[i+a];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do{if(r=t,c[r+a]===p&&c[r+a-1]===f&&c[r]===c[i]&&c[++r]===c[i+1]){i+=2,r++;do{}while(c[++i]===c[++r]&&c[++i]===c[++r]&&c[++i]===c[++r]&&c[++i]===c[++r]&&c[++i]===c[++r]&&c[++i]===c[++r]&&c[++i]===c[++r]&&c[++i]===c[++r]&&i<u);if(s=Le-(u-i),i=u-Le,s>a){if(e.match_start=t,a=s,s>=o)break;f=c[i+a-1],p=c[i+a]}}}while((t=d[t&h])>l&&0!==--n);return a<=e.lookahead?a:e.lookahead},Ye=e=>{const t=e.w_size;let r,s,n;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Be)&&(e.window.set(e.window.subarray(t,t+t-s),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),qe(e),s+=t),0===e.strm.avail_in)break;if(r=We(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=r,e.lookahead+e.insert>=3)for(n=e.strstart-e.insert,e.ins_h=e.window[n],e.ins_h=je(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=je(e,e.ins_h,e.window[n+3-1]),e.prev[n&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=n,n++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<Be&&0!==e.strm.avail_in)},Ge=(e,t)=>{let r,s,n,i=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,a=0,o=e.strm.avail_in;do{if(r=65535,n=e.bi_valid+42>>3,e.strm.avail_out<n)break;if(n=e.strm.avail_out-n,s=e.strstart-e.block_start,r>s+e.strm.avail_in&&(r=s+e.strm.avail_in),r>n&&(r=n),r<i&&(0===r&&t!==be||t===we||r!==s+e.strm.avail_in))break;a=t===be&&r===s+e.strm.avail_in?1:0,fe(e,0,0,a),e.pending_buf[e.pending-4]=r,e.pending_buf[e.pending-3]=r>>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,$e(e.strm),s&&(s>r&&(s=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+s),e.strm.next_out),e.strm.next_out+=s,e.strm.avail_out-=s,e.strm.total_out+=s,e.block_start+=s,r-=s),r&&(We(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(0===a);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),a?4:t!==we&&t!==be&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(n=e.window_size-e.strstart,e.strm.avail_in>n&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,n+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),n>e.strm.avail_in&&(n=e.strm.avail_in),n&&(We(e.strm,e.window,e.strstart,n),e.strstart+=n,e.insert+=n>e.w_size-e.insert?e.w_size-e.insert:n),e.high_water<e.strstart&&(e.high_water=e.strstart),n=e.bi_valid+42>>3,n=e.pending_buf_size-n>65535?65535:e.pending_buf_size-n,i=n>e.w_size?e.w_size:n,s=e.strstart-e.block_start,(s>=i||(s||t===be)&&t!==we&&0===e.strm.avail_in&&s<=n)&&(r=s>n?n:s,a=t===be&&0===e.strm.avail_in&&r===s?1:0,fe(e,e.block_start,r,a),e.block_start+=r,$e(e.strm)),a?3:1)},Qe=(e,t)=>{let r,s;for(;;){if(e.lookahead<Be){if(Ye(e),e.lookahead<Be&&t===we)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=je(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-Be&&(e.match_length=Je(e,r)),e.match_length>=3)if(s=me(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=je(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!==--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=je(e,e.ins_h,e.window[e.strstart+1]);else s=me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(s&&(Ke(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===be?(Ke(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Ke(e,!1),0===e.strm.avail_out)?1:2},et=(e,t)=>{let r,s,n;for(;;){if(e.lookahead<Be){if(Ye(e),e.lookahead<Be&&t===we)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=je(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-Be&&(e.match_length=Je(e,r),e.match_length<=5&&(e.strategy===Ie||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-3,s=me(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=je(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!==--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,s&&(Ke(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(s=me(e,0,e.window[e.strstart-1]),s&&Ke(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(s=me(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===be?(Ke(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Ke(e,!1),0===e.strm.avail_out)?1:2};function tt(e,t,r,s,n){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=s,this.func=n}const rt=[new tt(0,0,0,0,Ge),new tt(4,4,8,4,Qe),new tt(4,5,16,8,Qe),new tt(4,6,32,32,Qe),new tt(4,4,16,16,et),new tt(8,16,32,32,et),new tt(8,16,128,128,et),new tt(8,32,128,256,et),new tt(32,128,258,1024,et),new tt(32,258,258,4096,et)];function st(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=He,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Ze(this.dyn_ltree),Ze(this.dyn_dtree),Ze(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Ze(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Ze(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const nt=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Oe&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Pe&&t.status!==Ne?1:0},it=e=>{if(nt(e))return Me(e,Te);e.total_in=e.total_out=0,e.data_type=Ae;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?Oe:Pe,e.adler=2===t.wrap?0:1,t.last_flush=-2,ue(t),ke},at=e=>{const t=it(e);var r;return t===ke&&((r=e.state).window_size=2*r.w_size,Ze(r.head),r.max_lazy_match=rt[r.level].max_lazy,r.good_match=rt[r.level].good_length,r.nice_match=rt[r.level].nice_length,r.max_chain_length=rt[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=2,r.match_available=0,r.ins_h=0),t},ot=(e,t,r,s,n,i)=>{if(!e)return Te;let a=1;if(t===ze&&(t=6),s<0?(a=0,s=-s):s>15&&(a=2,s-=16),n<1||n>9||r!==He||s<8||s>15||t<0||t>9||i<0||i>De||8===s&&1!==a)return Me(e,Te);8===s&&(s=9);const o=new st;return e.state=o,o.strm=e,o.status=Oe,o.wrap=a,o.gzhead=null,o.w_bits=s,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=n+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<n+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=t,o.strategy=i,o.method=r,at(e)};var lt={deflateInit:(e,t)=>ot(e,t,He,15,8,Ue),deflateInit2:ot,deflateReset:at,deflateResetKeep:it,deflateSetHeader:(e,t)=>nt(e)||2!==e.state.wrap?Te:(e.state.gzhead=t,ke),deflate:(e,t)=>{if(nt(e)||t>ve||t<0)return e?Me(e,Te):Te;const r=e.state;if(!e.output||0!==e.avail_in&&!e.input||r.status===Ne&&t!==be)return Me(e,0===e.avail_out?xe:Te);const s=r.last_flush;if(r.last_flush=t,0!==r.pending){if($e(e),0===e.avail_out)return r.last_flush=-1,ke}else if(0===e.avail_in&&Fe(t)<=Fe(s)&&t!==be)return Me(e,xe);if(r.status===Ne&&0!==e.avail_in)return Me(e,xe);if(r.status===Oe&&0===r.wrap&&(r.status=Pe),r.status===Oe){let t=He+(r.w_bits-8<<4)<<8,s=-1;if(s=r.strategy>=Re||r.level<2?0:r.level<6?1:6===r.level?2:3,t|=s<<6,0!==r.strstart&&(t|=32),t+=31-t%31,Xe(r,t),0!==r.strstart&&(Xe(r,e.adler>>>16),Xe(r,65535&e.adler)),e.adler=1,r.status=Pe,$e(e),0!==r.pending)return r.last_flush=-1,ke}if(57===r.status)if(e.adler=0,Ve(r,31),Ve(r,139),Ve(r,8),r.gzhead)Ve(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Ve(r,255&r.gzhead.time),Ve(r,r.gzhead.time>>8&255),Ve(r,r.gzhead.time>>16&255),Ve(r,r.gzhead.time>>24&255),Ve(r,9===r.level?2:r.strategy>=Re||r.level<2?4:0),Ve(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(Ve(r,255&r.gzhead.extra.length),Ve(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=ce(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(Ve(r,0),Ve(r,0),Ve(r,0),Ve(r,0),Ve(r,0),Ve(r,9===r.level?2:r.strategy>=Re||r.level<2?4:0),Ve(r,3),r.status=Pe,$e(e),0!==r.pending)return r.last_flush=-1,ke;if(69===r.status){if(r.gzhead.extra){let t=r.pending,s=(65535&r.gzhead.extra.length)-r.gzindex;for(;r.pending+s>r.pending_buf_size;){let n=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+n),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>t&&(e.adler=ce(e.adler,r.pending_buf,r.pending-t,t)),r.gzindex+=n,$e(e),0!==r.pending)return r.last_flush=-1,ke;t=0,s-=n}let n=new Uint8Array(r.gzhead.extra);r.pending_buf.set(n.subarray(r.gzindex,r.gzindex+s),r.pending),r.pending+=s,r.gzhead.hcrc&&r.pending>t&&(e.adler=ce(e.adler,r.pending_buf,r.pending-t,t)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){let t,s=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>s&&(e.adler=ce(e.adler,r.pending_buf,r.pending-s,s)),$e(e),0!==r.pending)return r.last_flush=-1,ke;s=0}t=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,Ve(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>s&&(e.adler=ce(e.adler,r.pending_buf,r.pending-s,s)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){let t,s=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>s&&(e.adler=ce(e.adler,r.pending_buf,r.pending-s,s)),$e(e),0!==r.pending)return r.last_flush=-1,ke;s=0}t=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,Ve(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>s&&(e.adler=ce(e.adler,r.pending_buf,r.pending-s,s))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&($e(e),0!==r.pending))return r.last_flush=-1,ke;Ve(r,255&e.adler),Ve(r,e.adler>>8&255),e.adler=0}if(r.status=Pe,$e(e),0!==r.pending)return r.last_flush=-1,ke}if(0!==e.avail_in||0!==r.lookahead||t!==we&&r.status!==Ne){let s=0===r.level?Ge(r,t):r.strategy===Re?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(Ye(e),0===e.lookahead)){if(t===we)return 1;break}if(e.match_length=0,r=me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Ke(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===be?(Ke(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Ke(e,!1),0===e.strm.avail_out)?1:2})(r,t):r.strategy===Ce?((e,t)=>{let r,s,n,i;const a=e.window;for(;;){if(e.lookahead<=Le){if(Ye(e),e.lookahead<=Le&&t===we)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,s=a[n],s===a[++n]&&s===a[++n]&&s===a[++n])){i=e.strstart+Le;do{}while(s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&n<i);e.match_length=Le-(i-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=me(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Ke(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===be?(Ke(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Ke(e,!1),0===e.strm.avail_out)?1:2})(r,t):rt[r.level].func(r,t);if(3!==s&&4!==s||(r.status=Ne),1===s||3===s)return 0===e.avail_out&&(r.last_flush=-1),ke;if(2===s&&(t===_e?ge(r):t!==ve&&(fe(r,0,0,!1),t===ye&&(Ze(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),$e(e),0===e.avail_out))return r.last_flush=-1,ke}return t!==be?ke:r.wrap<=0?Ee:(2===r.wrap?(Ve(r,255&e.adler),Ve(r,e.adler>>8&255),Ve(r,e.adler>>16&255),Ve(r,e.adler>>24&255),Ve(r,255&e.total_in),Ve(r,e.total_in>>8&255),Ve(r,e.total_in>>16&255),Ve(r,e.total_in>>24&255)):(Xe(r,e.adler>>>16),Xe(r,65535&e.adler)),$e(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?ke:Ee)},deflateEnd:e=>{if(nt(e))return Te;const t=e.state.status;return e.state=null,t===Pe?Me(e,Se):ke},deflateSetDictionary:(e,t)=>{let r=t.length;if(nt(e))return Te;const s=e.state,n=s.wrap;if(2===n||1===n&&s.status!==Oe||s.lookahead)return Te;if(1===n&&(e.adler=oe(e.adler,t,r,0)),s.wrap=0,r>=s.w_size){0===n&&(Ze(s.head),s.strstart=0,s.block_start=0,s.insert=0);let e=new Uint8Array(s.w_size);e.set(t.subarray(r-s.w_size,r),0),t=e,r=s.w_size}const i=e.avail_in,a=e.next_in,o=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,Ye(s);s.lookahead>=3;){let e=s.strstart,t=s.lookahead-2;do{s.ins_h=je(s,s.ins_h,s.window[e+3-1]),s.prev[e&s.w_mask]=s.head[s.ins_h],s.head[s.ins_h]=e,e++}while(--t);s.strstart=e,s.lookahead=2,Ye(s)}return s.strstart+=s.lookahead,s.block_start=s.strstart,s.insert=s.lookahead,s.lookahead=0,s.match_length=s.prev_length=2,s.match_available=0,e.next_in=a,e.input=o,e.avail_in=i,s.wrap=n,ke},deflateInfo:"pako deflate (from Nodeca project)"};const ct=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var ht=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const t in r)ct(r,t)&&(e[t]=r[t])}}return e},dt=e=>{let t=0;for(let s=0,n=e.length;s<n;s++)t+=e[s].length;const r=new Uint8Array(t);for(let s=0,n=0,i=e.length;s<i;s++){let t=e[s];r.set(t,n),n+=t.length}return r};let ut=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(cs){ut=!1}const ft=new Uint8Array(256);for(let hs=0;hs<256;hs++)ft[hs]=hs>=252?6:hs>=248?5:hs>=240?4:hs>=224?3:hs>=192?2:1;ft[254]=ft[254]=1;var pt=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,r,s,n,i,a=e.length,o=0;for(n=0;n<a;n++)r=e.charCodeAt(n),55296==(64512&r)&&n+1<a&&(s=e.charCodeAt(n+1),56320==(64512&s)&&(r=65536+(r-55296<<10)+(s-56320),n++)),o+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(o),i=0,n=0;i<o;n++)r=e.charCodeAt(n),55296==(64512&r)&&n+1<a&&(s=e.charCodeAt(n+1),56320==(64512&s)&&(r=65536+(r-55296<<10)+(s-56320),n++)),r<128?t[i++]=r:r<2048?(t[i++]=192|r>>>6,t[i++]=128|63&r):r<65536?(t[i++]=224|r>>>12,t[i++]=128|r>>>6&63,t[i++]=128|63&r):(t[i++]=240|r>>>18,t[i++]=128|r>>>12&63,t[i++]=128|r>>>6&63,t[i++]=128|63&r);return t},mt=(e,t)=>{const r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let s,n;const i=new Array(2*r);for(n=0,s=0;s<r;){let t=e[s++];if(t<128){i[n++]=t;continue}let a=ft[t];if(a>4)i[n++]=65533,s+=a-1;else{for(t&=2===a?31:3===a?15:7;a>1&&s<r;)t=t<<6|63&e[s++],a--;a>1?i[n++]=65533:t<65536?i[n++]=t:(t-=65536,i[n++]=55296|t>>10&1023,i[n++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&ut)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let s=0;s<t;s++)r+=String.fromCharCode(e[s]);return r})(i,n)},gt=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+ft[e[r]]>t?r:t};var wt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const _t=Object.prototype.toString,{Z_NO_FLUSH:yt,Z_SYNC_FLUSH:bt,Z_FULL_FLUSH:vt,Z_FINISH:kt,Z_OK:Et,Z_STREAM_END:Tt,Z_DEFAULT_COMPRESSION:St,Z_DEFAULT_STRATEGY:xt,Z_DEFLATED:zt}=de;function It(e){this.options=ht({level:St,method:zt,chunkSize:16384,windowBits:15,memLevel:8,strategy:xt},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new wt,this.strm.avail_out=0;let r=lt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Et)throw new Error(he[r]);if(t.header&&lt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?pt(t.dictionary):"[object ArrayBuffer]"===_t.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,r=lt.deflateSetDictionary(this.strm,e),r!==Et)throw new Error(he[r]);this._dict_set=!0}}function Rt(e,t){const r=new It(t);if(r.push(e,!0),r.err)throw r.msg||he[r.err];return r.result}It.prototype.push=function(e,t){const r=this.strm,s=this.options.chunkSize;let n,i;if(this.ended)return!1;for(i=t===~~t?t:!0===t?kt:yt,"string"==typeof e?r.input=pt(e):"[object ArrayBuffer]"===_t.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(s),r.next_out=0,r.avail_out=s),(i===bt||i===vt)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(n=lt.deflate(r,i),n===Tt)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),n=lt.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Et;if(0!==r.avail_out){if(i>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},It.prototype.onData=function(e){this.chunks.push(e)},It.prototype.onEnd=function(e){e===Et&&(this.result=dt(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Ct={Deflate:It,deflate:Rt,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Rt(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Rt(e,t)}};const Dt=16209;var Ut=function(e,t){let r,s,n,i,a,o,l,c,h,d,u,f,p,m,g,w,_,y,b,v,k,E,T,S;const x=e.state;r=e.next_in,T=e.input,s=r+(e.avail_in-5),n=e.next_out,S=e.output,i=n-(t-e.avail_out),a=n+(e.avail_out-257),o=x.dmax,l=x.wsize,c=x.whave,h=x.wnext,d=x.window,u=x.hold,f=x.bits,p=x.lencode,m=x.distcode,g=(1<<x.lenbits)-1,w=(1<<x.distbits)-1;e:do{f<15&&(u+=T[r++]<<f,f+=8,u+=T[r++]<<f,f+=8),_=p[u&g];t:for(;;){if(y=_>>>24,u>>>=y,f-=y,y=_>>>16&255,0===y)S[n++]=65535&_;else{if(!(16&y)){if(64&y){if(32&y){x.mode=16191;break e}e.msg="invalid literal/length code",x.mode=Dt;break e}_=p[(65535&_)+(u&(1<<y)-1)];continue t}for(b=65535&_,y&=15,y&&(f<y&&(u+=T[r++]<<f,f+=8),b+=u&(1<<y)-1,u>>>=y,f-=y),f<15&&(u+=T[r++]<<f,f+=8,u+=T[r++]<<f,f+=8),_=m[u&w];;){if(y=_>>>24,u>>>=y,f-=y,y=_>>>16&255,16&y){if(v=65535&_,y&=15,f<y&&(u+=T[r++]<<f,f+=8,f<y&&(u+=T[r++]<<f,f+=8)),v+=u&(1<<y)-1,v>o){e.msg="invalid distance too far back",x.mode=Dt;break e}if(u>>>=y,f-=y,y=n-i,v>y){if(y=v-y,y>c&&x.sane){e.msg="invalid distance too far back",x.mode=Dt;break e}if(k=0,E=d,0===h){if(k+=l-y,y<b){b-=y;do{S[n++]=d[k++]}while(--y);k=n-v,E=S}}else if(h<y){if(k+=l+h-y,y-=h,y<b){b-=y;do{S[n++]=d[k++]}while(--y);if(k=0,h<b){y=h,b-=y;do{S[n++]=d[k++]}while(--y);k=n-v,E=S}}}else if(k+=h-y,y<b){b-=y;do{S[n++]=d[k++]}while(--y);k=n-v,E=S}for(;b>2;)S[n++]=E[k++],S[n++]=E[k++],S[n++]=E[k++],b-=3;b&&(S[n++]=E[k++],b>1&&(S[n++]=E[k++]))}else{k=n-v;do{S[n++]=S[k++],S[n++]=S[k++],S[n++]=S[k++],b-=3}while(b>2);b&&(S[n++]=S[k++],b>1&&(S[n++]=S[k++]))}break}if(64&y){e.msg="invalid distance code",x.mode=Dt;break e}_=m[(65535&_)+(u&(1<<y)-1)]}}break}}while(r<s&&n<a);b=f>>3,r-=b,f-=b<<3,u&=(1<<f)-1,e.next_in=r,e.next_out=n,e.avail_in=r<s?s-r+5:5-(r-s),e.avail_out=n<a?a-n+257:257-(n-a),x.hold=u,x.bits=f};const At=15,Ht=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Lt=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Bt=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Ot=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var Pt=(e,t,r,s,n,i,a,o)=>{const l=o.bits;let c,h,d,u,f,p,m=0,g=0,w=0,_=0,y=0,b=0,v=0,k=0,E=0,T=0,S=null;const x=new Uint16Array(16),z=new Uint16Array(16);let I,R,C,D=null;for(m=0;m<=At;m++)x[m]=0;for(g=0;g<s;g++)x[t[r+g]]++;for(y=l,_=At;_>=1&&0===x[_];_--);if(y>_&&(y=_),0===_)return n[i++]=20971520,n[i++]=20971520,o.bits=1,0;for(w=1;w<_&&0===x[w];w++);for(y<w&&(y=w),k=1,m=1;m<=At;m++)if(k<<=1,k-=x[m],k<0)return-1;if(k>0&&(0===e||1!==_))return-1;for(z[1]=0,m=1;m<At;m++)z[m+1]=z[m]+x[m];for(g=0;g<s;g++)0!==t[r+g]&&(a[z[t[r+g]]++]=g);if(0===e?(S=D=a,p=20):1===e?(S=Ht,D=Lt,p=257):(S=Bt,D=Ot,p=0),T=0,g=0,m=w,f=i,b=y,v=0,d=-1,E=1<<y,u=E-1,1===e&&E>852||2===e&&E>592)return 1;for(;;){I=m-v,a[g]+1<p?(R=0,C=a[g]):a[g]>=p?(R=D[a[g]-p],C=S[a[g]-p]):(R=96,C=0),c=1<<m-v,h=1<<b,w=h;do{h-=c,n[f+(T>>v)+h]=I<<24|R<<16|C}while(0!==h);for(c=1<<m-1;T&c;)c>>=1;if(0!==c?(T&=c-1,T+=c):T=0,g++,0===--x[m]){if(m===_)break;m=t[r+a[g]]}if(m>y&&(T&u)!==d){for(0===v&&(v=y),f+=w,b=m-v,k=1<<b;b+v<_&&(k-=x[b+v],!(k<=0));)b++,k<<=1;if(E+=1<<b,1===e&&E>852||2===e&&E>592)return 1;d=T&u,n[d]=y<<24|b<<16|f-i}}return 0!==T&&(n[f+T]=m-v<<24|64<<16),o.bits=y,0};const{Z_FINISH:Nt,Z_BLOCK:Mt,Z_TREES:Ft,Z_OK:Zt,Z_STREAM_END:qt,Z_NEED_DICT:jt,Z_STREAM_ERROR:$t,Z_DATA_ERROR:Kt,Z_MEM_ERROR:Vt,Z_BUF_ERROR:Xt,Z_DEFLATED:Wt}=de,Jt=16180,Yt=16190,Gt=16191,Qt=16192,er=16194,tr=16199,rr=16200,sr=16206,nr=16209,ir=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function ar(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const or=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<Jt||t.mode>16211?1:0},lr=e=>{if(or(e))return $t;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Jt,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Zt},cr=e=>{if(or(e))return $t;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,lr(e)},hr=(e,t)=>{let r;if(or(e))return $t;const s=e.state;return t<0?(r=0,t=-t):(r=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?$t:(null!==s.window&&s.wbits!==t&&(s.window=null),s.wrap=r,s.wbits=t,cr(e))},dr=(e,t)=>{if(!e)return $t;const r=new ar;e.state=r,r.strm=e,r.window=null,r.mode=Jt;const s=hr(e,t);return s!==Zt&&(e.state=null),s};let ur,fr,pr=!0;const mr=e=>{if(pr){ur=new Int32Array(512),fr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Pt(1,e.lens,0,288,ur,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Pt(2,e.lens,0,32,fr,0,e.work,{bits:5}),pr=!1}e.lencode=ur,e.lenbits=9,e.distcode=fr,e.distbits=5},gr=(e,t,r,s)=>{let n;const i=e.state;return null===i.window&&(i.wsize=1<<i.wbits,i.wnext=0,i.whave=0,i.window=new Uint8Array(i.wsize)),s>=i.wsize?(i.window.set(t.subarray(r-i.wsize,r),0),i.wnext=0,i.whave=i.wsize):(n=i.wsize-i.wnext,n>s&&(n=s),i.window.set(t.subarray(r-s,r-s+n),i.wnext),(s-=n)?(i.window.set(t.subarray(r-s,r),0),i.wnext=s,i.whave=i.wsize):(i.wnext+=n,i.wnext===i.wsize&&(i.wnext=0),i.whave<i.wsize&&(i.whave+=n))),0};var wr={inflateReset:cr,inflateReset2:hr,inflateResetKeep:lr,inflateInit:e=>dr(e,15),inflateInit2:dr,inflate:(e,t)=>{let r,s,n,i,a,o,l,c,h,d,u,f,p,m,g,w,_,y,b,v,k,E,T=0;const S=new Uint8Array(4);let x,z;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(or(e)||!e.output||!e.input&&0!==e.avail_in)return $t;r=e.state,r.mode===Gt&&(r.mode=Qt),a=e.next_out,n=e.output,l=e.avail_out,i=e.next_in,s=e.input,o=e.avail_in,c=r.hold,h=r.bits,d=o,u=l,E=Zt;e:for(;;)switch(r.mode){case Jt:if(0===r.wrap){r.mode=Qt;break}for(;h<16;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}if(2&r.wrap&&35615===c){0===r.wbits&&(r.wbits=15),r.check=0,S[0]=255&c,S[1]=c>>>8&255,r.check=ce(r.check,S,2,0),c=0,h=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=nr;break}if((15&c)!==Wt){e.msg="unknown compression method",r.mode=nr;break}if(c>>>=4,h-=4,k=8+(15&c),0===r.wbits&&(r.wbits=k),k>15||k>r.wbits){e.msg="invalid window size",r.mode=nr;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=512&c?16189:Gt,c=0,h=0;break;case 16181:for(;h<16;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}if(r.flags=c,(255&r.flags)!==Wt){e.msg="unknown compression method",r.mode=nr;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=nr;break}r.head&&(r.head.text=c>>8&1),512&r.flags&&4&r.wrap&&(S[0]=255&c,S[1]=c>>>8&255,r.check=ce(r.check,S,2,0)),c=0,h=0,r.mode=16182;case 16182:for(;h<32;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}r.head&&(r.head.time=c),512&r.flags&&4&r.wrap&&(S[0]=255&c,S[1]=c>>>8&255,S[2]=c>>>16&255,S[3]=c>>>24&255,r.check=ce(r.check,S,4,0)),c=0,h=0,r.mode=16183;case 16183:for(;h<16;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&r.flags&&4&r.wrap&&(S[0]=255&c,S[1]=c>>>8&255,r.check=ce(r.check,S,2,0)),c=0,h=0,r.mode=16184;case 16184:if(1024&r.flags){for(;h<16;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}r.length=c,r.head&&(r.head.extra_len=c),512&r.flags&&4&r.wrap&&(S[0]=255&c,S[1]=c>>>8&255,r.check=ce(r.check,S,2,0)),c=0,h=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(f=r.length,f>o&&(f=o),f&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(s.subarray(i,i+f),k)),512&r.flags&&4&r.wrap&&(r.check=ce(r.check,s,f,i)),o-=f,i+=f,r.length-=f),r.length))break e;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===o)break e;f=0;do{k=s[i+f++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k))}while(k&&f<o);if(512&r.flags&&4&r.wrap&&(r.check=ce(r.check,s,f,i)),o-=f,i+=f,k)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===o)break e;f=0;do{k=s[i+f++],r.head&&k&&r.length<65536&&(r.head.comment+=String.fromCharCode(k))}while(k&&f<o);if(512&r.flags&&4&r.wrap&&(r.check=ce(r.check,s,f,i)),o-=f,i+=f,k)break e}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;h<16;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}if(4&r.wrap&&c!==(65535&r.check)){e.msg="header crc mismatch",r.mode=nr;break}c=0,h=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Gt;break;case 16189:for(;h<32;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}e.adler=r.check=ir(c),c=0,h=0,r.mode=Yt;case Yt:if(0===r.havedict)return e.next_out=a,e.avail_out=l,e.next_in=i,e.avail_in=o,r.hold=c,r.bits=h,jt;e.adler=r.check=1,r.mode=Gt;case Gt:if(t===Mt||t===Ft)break e;case Qt:if(r.last){c>>>=7&h,h-=7&h,r.mode=sr;break}for(;h<3;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}switch(r.last=1&c,c>>>=1,h-=1,3&c){case 0:r.mode=16193;break;case 1:if(mr(r),r.mode=tr,t===Ft){c>>>=2,h-=2;break e}break;case 2:r.mode=16196;break;case 3:e.msg="invalid block type",r.mode=nr}c>>>=2,h-=2;break;case 16193:for(c>>>=7&h,h-=7&h;h<32;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",r.mode=nr;break}if(r.length=65535&c,c=0,h=0,r.mode=er,t===Ft)break e;case er:r.mode=16195;case 16195:if(f=r.length,f){if(f>o&&(f=o),f>l&&(f=l),0===f)break e;n.set(s.subarray(i,i+f),a),o-=f,i+=f,l-=f,a+=f,r.length-=f;break}r.mode=Gt;break;case 16196:for(;h<14;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}if(r.nlen=257+(31&c),c>>>=5,h-=5,r.ndist=1+(31&c),c>>>=5,h-=5,r.ncode=4+(15&c),c>>>=4,h-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=nr;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;h<3;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}r.lens[I[r.have++]]=7&c,c>>>=3,h-=3}for(;r.have<19;)r.lens[I[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,x={bits:r.lenbits},E=Pt(0,r.lens,0,19,r.lencode,0,r.work,x),r.lenbits=x.bits,E){e.msg="invalid code lengths set",r.mode=nr;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;T=r.lencode[c&(1<<r.lenbits)-1],g=T>>>24,w=T>>>16&255,_=65535&T,!(g<=h);){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}if(_<16)c>>>=g,h-=g,r.lens[r.have++]=_;else{if(16===_){for(z=g+2;h<z;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}if(c>>>=g,h-=g,0===r.have){e.msg="invalid bit length repeat",r.mode=nr;break}k=r.lens[r.have-1],f=3+(3&c),c>>>=2,h-=2}else if(17===_){for(z=g+3;h<z;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}c>>>=g,h-=g,k=0,f=3+(7&c),c>>>=3,h-=3}else{for(z=g+7;h<z;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}c>>>=g,h-=g,k=0,f=11+(127&c),c>>>=7,h-=7}if(r.have+f>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=nr;break}for(;f--;)r.lens[r.have++]=k}}if(r.mode===nr)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=nr;break}if(r.lenbits=9,x={bits:r.lenbits},E=Pt(1,r.lens,0,r.nlen,r.lencode,0,r.work,x),r.lenbits=x.bits,E){e.msg="invalid literal/lengths set",r.mode=nr;break}if(r.distbits=6,r.distcode=r.distdyn,x={bits:r.distbits},E=Pt(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,x),r.distbits=x.bits,E){e.msg="invalid distances set",r.mode=nr;break}if(r.mode=tr,t===Ft)break e;case tr:r.mode=rr;case rr:if(o>=6&&l>=258){e.next_out=a,e.avail_out=l,e.next_in=i,e.avail_in=o,r.hold=c,r.bits=h,Ut(e,u),a=e.next_out,n=e.output,l=e.avail_out,i=e.next_in,s=e.input,o=e.avail_in,c=r.hold,h=r.bits,r.mode===Gt&&(r.back=-1);break}for(r.back=0;T=r.lencode[c&(1<<r.lenbits)-1],g=T>>>24,w=T>>>16&255,_=65535&T,!(g<=h);){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}if(w&&!(240&w)){for(y=g,b=w,v=_;T=r.lencode[v+((c&(1<<y+b)-1)>>y)],g=T>>>24,w=T>>>16&255,_=65535&T,!(y+g<=h);){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}c>>>=y,h-=y,r.back+=y}if(c>>>=g,h-=g,r.back+=g,r.length=_,0===w){r.mode=16205;break}if(32&w){r.back=-1,r.mode=Gt;break}if(64&w){e.msg="invalid literal/length code",r.mode=nr;break}r.extra=15&w,r.mode=16201;case 16201:if(r.extra){for(z=r.extra;h<z;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,h-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;T=r.distcode[c&(1<<r.distbits)-1],g=T>>>24,w=T>>>16&255,_=65535&T,!(g<=h);){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}if(!(240&w)){for(y=g,b=w,v=_;T=r.distcode[v+((c&(1<<y+b)-1)>>y)],g=T>>>24,w=T>>>16&255,_=65535&T,!(y+g<=h);){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}c>>>=y,h-=y,r.back+=y}if(c>>>=g,h-=g,r.back+=g,64&w){e.msg="invalid distance code",r.mode=nr;break}r.offset=_,r.extra=15&w,r.mode=16203;case 16203:if(r.extra){for(z=r.extra;h<z;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,h-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=nr;break}r.mode=16204;case 16204:if(0===l)break e;if(f=u-l,r.offset>f){if(f=r.offset-f,f>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=nr;break}f>r.wnext?(f-=r.wnext,p=r.wsize-f):p=r.wnext-f,f>r.length&&(f=r.length),m=r.window}else m=n,p=a-r.offset,f=r.length;f>l&&(f=l),l-=f,r.length-=f;do{n[a++]=m[p++]}while(--f);0===r.length&&(r.mode=rr);break;case 16205:if(0===l)break e;n[a++]=r.length,l--,r.mode=rr;break;case sr:if(r.wrap){for(;h<32;){if(0===o)break e;o--,c|=s[i++]<<h,h+=8}if(u-=l,e.total_out+=u,r.total+=u,4&r.wrap&&u&&(e.adler=r.check=r.flags?ce(r.check,n,u,a-u):oe(r.check,n,u,a-u)),u=l,4&r.wrap&&(r.flags?c:ir(c))!==r.check){e.msg="incorrect data check",r.mode=nr;break}c=0,h=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;h<32;){if(0===o)break e;o--,c+=s[i++]<<h,h+=8}if(4&r.wrap&&c!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=nr;break}c=0,h=0}r.mode=16208;case 16208:E=qt;break e;case nr:E=Kt;break e;case 16210:return Vt;default:return $t}return e.next_out=a,e.avail_out=l,e.next_in=i,e.avail_in=o,r.hold=c,r.bits=h,(r.wsize||u!==e.avail_out&&r.mode<nr&&(r.mode<sr||t!==Nt))&&gr(e,e.output,e.next_out,u-e.avail_out),d-=e.avail_in,u-=e.avail_out,e.total_in+=d,e.total_out+=u,r.total+=u,4&r.wrap&&u&&(e.adler=r.check=r.flags?ce(r.check,n,u,e.next_out-u):oe(r.check,n,u,e.next_out-u)),e.data_type=r.bits+(r.last?64:0)+(r.mode===Gt?128:0)+(r.mode===tr||r.mode===er?256:0),(0===d&&0===u||t===Nt)&&E===Zt&&(E=Xt),E},inflateEnd:e=>{if(or(e))return $t;let t=e.state;return t.window&&(t.window=null),e.state=null,Zt},inflateGetHeader:(e,t)=>{if(or(e))return $t;const r=e.state;return 2&r.wrap?(r.head=t,t.done=!1,Zt):$t},inflateSetDictionary:(e,t)=>{const r=t.length;let s,n,i;return or(e)?$t:(s=e.state,0!==s.wrap&&s.mode!==Yt?$t:s.mode===Yt&&(n=1,n=oe(n,t,r,0),n!==s.check)?Kt:(i=gr(e,t,r,r),i?(s.mode=16210,Vt):(s.havedict=1,Zt)))},inflateInfo:"pako inflate (from Nodeca project)"};var _r=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const yr=Object.prototype.toString,{Z_NO_FLUSH:br,Z_FINISH:vr,Z_OK:kr,Z_STREAM_END:Er,Z_NEED_DICT:Tr,Z_STREAM_ERROR:Sr,Z_DATA_ERROR:xr,Z_MEM_ERROR:zr}=de;function Ir(e){this.options=ht({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new wt,this.strm.avail_out=0;let r=wr.inflateInit2(this.strm,t.windowBits);if(r!==kr)throw new Error(he[r]);if(this.header=new _r,wr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=pt(t.dictionary):"[object ArrayBuffer]"===yr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=wr.inflateSetDictionary(this.strm,t.dictionary),r!==kr)))throw new Error(he[r])}function Rr(e,t){const r=new Ir(t);if(r.push(e),r.err)throw r.msg||he[r.err];return r.result}Ir.prototype.push=function(e,t){const r=this.strm,s=this.options.chunkSize,n=this.options.dictionary;let i,a,o;if(this.ended)return!1;for(a=t===~~t?t:!0===t?vr:br,"[object ArrayBuffer]"===yr.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(s),r.next_out=0,r.avail_out=s),i=wr.inflate(r,a),i===Tr&&n&&(i=wr.inflateSetDictionary(r,n),i===kr?i=wr.inflate(r,a):i===xr&&(i=Tr));r.avail_in>0&&i===Er&&r.state.wrap>0&&0!==e[r.next_in];)wr.inflateReset(r),i=wr.inflate(r,a);switch(i){case Sr:case xr:case Tr:case zr:return this.onEnd(i),this.ended=!0,!1}if(o=r.avail_out,r.next_out&&(0===r.avail_out||i===Er))if("string"===this.options.to){let e=gt(r.output,r.next_out),t=r.next_out-e,n=mt(r.output,e);r.next_out=t,r.avail_out=s-t,t&&r.output.set(r.output.subarray(e,e+t),0),this.onData(n)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(i!==kr||0!==o){if(i===Er)return i=wr.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},Ir.prototype.onData=function(e){this.chunks.push(e)},Ir.prototype.onEnd=function(e){e===kr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=dt(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Cr={Inflate:Ir,inflate:Rr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Rr(e,t)},ungzip:Rr};const{Deflate:Dr,deflate:Ur,deflateRaw:Ar,gzip:Hr}=Ct,{Inflate:Lr,inflate:Br,inflateRaw:Or,ungzip:Pr}=Cr;var Nr={Deflate:Dr,deflate:Ur,deflateRaw:Ar,gzip:Hr,Inflate:Lr,inflate:Br,inflateRaw:Or,ungzip:Pr,constants:de};class Mr{compress(e){try{const t=Nr.deflate(e);if("undefined"!=typeof btoa){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}return"undefined"!=typeof Buffer?Buffer.from(t).toString("base64"):e}catch(t){return console.error("Compressor: Error compressing data:",t),e}}decompress(e){try{let t;if("undefined"!=typeof atob){const r=atob(e);t=new Uint8Array(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e)}else{if("undefined"==typeof Buffer)return e;{const r=Buffer.from(e,"base64");t=new Uint8Array(r)}}return Nr.inflate(t,{to:"string"})}catch(t){return console.error("Compressor: Error decompressing data:",t),e}}shouldCompress(e){return e.length>1024}}class Fr{constructor(){r(this,"sampler"),r(this,"deduplicator"),r(this,"compressor"),this.sampler=new k,this.deduplicator=new E,this.compressor=new Mr}process(e,t={}){const{sampleRate:r=1,enableDeduplication:s=!0,enableCompression:n=!1,isCritical:i=!1}=t;if(!this.sampler.shouldSampleCritical(i,r))return null;if(s&&this.deduplicator.isDuplicate(e))return null;const a=d(e);if(n&&a.properties){const e=JSON.stringify(a.properties);this.compressor.shouldCompress(e)&&(a.compressedProperties=this.compressor.compress(e),delete a.properties)}return a}processBatch(e,t={}){return e.map(e=>this.process(e,t)).filter(e=>null!==e)}serialize(e){try{return JSON.stringify(e)}catch(t){return console.error("DataProcessor: Error serializing event:",t),""}}deserialize(e){try{return JSON.parse(e)}catch(t){return console.error("DataProcessor: Error deserializing event:",t),null}}}function Zr(){if("undefined"!=typeof AbortController)return AbortController;class e{constructor(){r(this,"aborted",!1)}abort(){this.aborted=!0}}return class{constructor(){r(this,"signal"),this.signal=new e}abort(){this.signal.abort()}}}async function qr(e,t){return new Promise((r,s)=>{const n=new XMLHttpRequest,i=(null==t?void 0:t.method)||"GET";if(n.open(i,e,!0),null==t?void 0:t.headers){new Headers(t.headers).forEach((e,t)=>{null!=e&&n.setRequestHeader(t,String(e))})}if(null==t?void 0:t.signal){if(t.signal.aborted)return void s(new DOMException("Aborted","AbortError"))}n.onload=()=>{const t=n.getAllResponseHeaders(),s={};t.split("\n").forEach(e=>{const t=e.split(": ");t[0]&&t[1]&&(s[t[0].toLowerCase()]=t[1])});const i=new Headers(s),a=n.responseText||"",o=n.responseURL||e,l=n.status,c={ok:l>=200&&l<300,status:l,statusText:n.statusText,type:"basic",url:o,headers:i,redirected:!1,body:null,bodyUsed:!1,arrayBuffer:()=>Promise.resolve(new ArrayBuffer(0)),blob:()=>Promise.resolve(new Blob),formData:()=>Promise.resolve(new FormData),json:async()=>{try{return JSON.parse(a||"{}")}catch{throw new TypeError("Invalid JSON response")}},text:()=>Promise.resolve(a),clone:()=>({...c,headers:new Headers(s)})};r(c)},n.onerror=()=>{s(new TypeError("Network request failed"))},n.ontimeout=()=>{s(new Error("Request timeout"))};const a=null==t?void 0:t.body;a instanceof FormData||a instanceof Blob||"string"==typeof a||null===a?n.send(a):a?n.send(String(a)):n.send(null)})}async function jr(e,t={}){const{method:r="POST",headers:s={},body:n,timeout:i=1e4}=t,a=new(Zr()),o=setTimeout(()=>a.abort(),i);try{const t=function(){if("function"==typeof fetch)try{return new(Zr()),fetch}catch{return qr}if("undefined"!=typeof XMLHttpRequest)return qr;throw new Error("fetch is not available and XMLHttpRequest fallback is not supported")}(),i=await t(e,{method:r,headers:{"Content-Type":"application/json",...s},body:n,signal:a.signal});let l;clearTimeout(o);const c=i.headers.get("content-type");return l=c&&c.includes("application/json")?await i.json():await i.text(),{ok:i.ok,status:i.status,statusText:i.statusText,data:l}}catch(l){throw clearTimeout(o),l}}async function $r(e,t={}){var r;return"undefined"!=typeof process&&(null==(r=process.versions)?void 0:r.node)?async function(e,t={}){var r;const{method:s="POST",headers:n={},body:i,timeout:a=1e4}=t;try{let t;try{const e=await import("node-fetch");t=e.default||e}catch(o){if("undefined"!=typeof process&&(null==(r=process.versions)?void 0:r.node))throw new Error("node-fetch is required in Node.js environment. Please install it: pnpm add node-fetch");throw new Error("Network request failed: node-fetch not available")}const c=new(Zr()),h=setTimeout(()=>c.abort(),a);try{const r=await t(e,{method:s,headers:{"Content-Type":"application/json",...n},body:i,signal:c.signal});let a;clearTimeout(h);const o=r.headers.get("content-type");return a=o&&o.includes("application/json")?await r.json():await r.text(),{ok:r.ok,status:r.status,statusText:r.statusText,data:a}}catch(l){throw clearTimeout(h),l}}catch(l){throw l}}(e,t):jr(e,t)}function Kr(e,t,r={}){return $r(e,{...r,method:"POST",body:"string"==typeof t?t:JSON.stringify(t)})}class Vr{async execute(e,t={}){const{maxRetries:r=3,initialDelay:s=1e3,maxDelay:n=1e4,shouldRetry:i=()=>!0}=t;let a,o=s;for(let c=0;c<=r;c++)try{return await e()}catch(l){if(a=l,!(c<r&&i(l)))break;await this.sleep(o),o=Math.min(2*o,n)}throw a}sleep(e){return new Promise(t=>setTimeout(t,e))}isRetryableError(e){if(e instanceof Error){const t=e.message.toLowerCase();return t.includes("network")||t.includes("timeout")||t.includes("fetch")||t.includes("connection")}return!1}}class Xr{constructor(e){r(this,"serverUrl"),r(this,"retryHandler"),this.serverUrl=e,this.retryHandler=new Vr}async send(e,t={}){if(!this.serverUrl||"about:blank"===this.serverUrl)return!1;const{enableRetry:r=!0,maxRetries:s=3}=t;try{if(r)await this.retryHandler.execute(async()=>{const t=await Kr(this.serverUrl,e);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);return t},{maxRetries:s,shouldRetry:e=>this.retryHandler.isRetryableError(e)});else{const t=await Kr(this.serverUrl,e);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`)}return!0}catch(n){return console.error("Sender: Error sending event:",n),!1}}async sendBatch(e,t={}){if(0===e.length)return!0;if(!this.serverUrl||"about:blank"===this.serverUrl)return!1;const{enableRetry:r=!0,maxRetries:s=3}=t;try{if(r)await this.retryHandler.execute(async()=>{const t=await Kr(this.serverUrl,{events:e});if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);return t},{maxRetries:s,shouldRetry:e=>this.retryHandler.isRetryableError(e)});else{const t=await Kr(this.serverUrl,{events:e});if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`)}return!0}catch(n){return console.error("Sender: Error sending batch events:",n),!1}}setServerUrl(e){this.serverUrl=e}}const Wr=new class{constructor(){if(r(this,"storage",null),"undefined"!=typeof window&&window.localStorage)try{const e="__tracker_test__";window.localStorage.setItem(e,e),window.localStorage.removeItem(e),this.storage=window.localStorage}catch(e){}}getItem(e){if(!this.storage)return null;try{return this.storage.getItem(e)}catch(t){return null}}setItem(e,t){if(this.storage)try{this.storage.setItem(e,t)}catch(r){}}removeItem(e){if(this.storage)try{this.storage.removeItem(e)}catch(t){}}clear(){if(this.storage)try{this.storage.clear()}catch(e){}}},Jr=new class{constructor(){if(r(this,"storage",null),"undefined"!=typeof window&&window.sessionStorage)try{const e="__tracker_test__";window.sessionStorage.setItem(e,e),window.sessionStorage.removeItem(e),this.storage=window.sessionStorage}catch(e){}}getItem(e){if(!this.storage)return null;try{return this.storage.getItem(e)}catch(t){return null}}setItem(e,t){if(this.storage)try{this.storage.setItem(e,t)}catch(r){}}removeItem(e){if(this.storage)try{this.storage.removeItem(e)}catch(t){}}clear(){if(this.storage)try{this.storage.clear()}catch(e){}}},Yr=new class{constructor(){r(this,"data",new Map)}getItem(e){return this.data.get(e)||null}setItem(e,t){this.data.set(e,t)}removeItem(e){this.data.delete(e)}clear(){this.data.clear()}},Gr=new class{constructor(){r(this,"dbName","__tracker_db__"),r(this,"storeName","__tracker_store__"),r(this,"db",null),r(this,"initPromise",null)}async init(){return!!this.db||(this.initPromise?this.initPromise:!("undefined"==typeof window||!window.indexedDB)&&(this.initPromise=new Promise(e=>{const t=indexedDB.open(this.dbName,1);t.onerror=()=>{this.initPromise=null,e(!1)},t.onsuccess=()=>{this.db=t.result,this.initPromise=null,e(!0)},t.onupgradeneeded=e=>{const t=e.target.result;if(!t.objectStoreNames.contains(this.storeName)){t.createObjectStore(this.storeName,{keyPath:"id",autoIncrement:!0}).createIndex("key","key",{unique:!0})}}}),this.initPromise))}async getItem(e){return this.db||await this.init(),this.db?new Promise(t=>{let r;try{r=this.db.transaction([this.storeName],"readonly")}catch(n){return console.error("IndexedDBStorage: Error creating transaction for get:",n),void t(null)}r.onerror=()=>{console.error("IndexedDBStorage: Transaction error in get:",r.error),t(null)},r.onabort=()=>{console.error("IndexedDBStorage: Transaction aborted in get"),t(null)};const s=r.objectStore(this.storeName).index("key").get(e);s.onsuccess=()=>{const e=s.result;t(e?e.value:null)},s.onerror=()=>{console.error("IndexedDBStorage: Error in get request:",s.error),t(null)}}):null}async setItem(e,t){return this.db||await this.init(),!!this.db&&new Promise(r=>{let s;try{s=this.db.transaction([this.storeName],"readwrite")}catch(a){return console.error("IndexedDBStorage: Error creating transaction:",a),void r(!1)}s.onerror=()=>{console.error("IndexedDBStorage: Transaction error:",s.error),r(!1)},s.onabort=()=>{console.error("IndexedDBStorage: Transaction aborted"),r(!1)};const n=s.objectStore(this.storeName),i=n.index("key").get(e);i.onsuccess=()=>{const s={key:e,value:t,updatedAt:Date.now()};let a;i.result?(s.id=i.result.id,a=n.put(s)):a=n.add(s),a.onsuccess=()=>{r(!0)},a.onerror=()=>{console.error("IndexedDBStorage: Error in put/add request:",a.error),r(!1)}},i.onerror=()=>{console.error("IndexedDBStorage: Error in get request:",i.error),r(!1)}})}async removeItem(e){return!!this.db&&new Promise(t=>{let r;try{r=this.db.transaction([this.storeName],"readwrite")}catch(i){return console.error("IndexedDBStorage: Error creating transaction for remove:",i),void t(!1)}r.onerror=()=>{console.error("IndexedDBStorage: Transaction error in remove:",r.error),t(!1)},r.onabort=()=>{console.error("IndexedDBStorage: Transaction aborted in remove"),t(!1)};const s=r.objectStore(this.storeName),n=s.index("key").get(e);n.onsuccess=()=>{if(n.result){const e=s.delete(n.result.id);e.onsuccess=()=>t(!0),e.onerror=()=>{console.error("IndexedDBStorage: Error in delete request:",e.error),t(!1)}}else t(!0)},n.onerror=()=>{console.error("IndexedDBStorage: Error in get request for remove:",n.error),t(!1)}})}async getAll(){return this.db||await this.init(),this.db?new Promise(e=>{const t=this.db.transaction([this.storeName],"readonly").objectStore(this.storeName).getAll();t.onsuccess=()=>{const r=t.result.map(e=>({key:e.key,value:e.value}));e(r)},t.onerror=()=>{e([])}}):[]}};class Qr{constructor(e=1e3){if(r(this,"storageKey","__tracker_offline_events__"),r(this,"maxSize"),r(this,"useIndexedDB",!0),r(this,"memoryStorage",new Map),r(this,"saveQueue",Promise.resolve()),e<=0)throw new Error("OfflineStorage: maxSize must be positive");this.maxSize=e}async init(){await Gr.init()||(this.useIndexedDB=!1,console.warn("OfflineStorage: IndexedDB initialization failed, will use memory storage as fallback"))}async save(e){try{return this.saveQueue=this.saveQueue.then(async()=>{await this.doSave(e)}).catch(e=>{throw console.error("OfflineStorage: Error in save queue:",e),e}),await this.saveQueue,!0}catch(t){console.error("OfflineStorage: Error saving event:",t);try{const t=this.memoryStorage.get(this.storageKey)||[];return t.length>=this.maxSize&&t.shift(),t.push(this.sanitizeEvent(e)),this.memoryStorage.set(this.storageKey,t),!0}catch(r){return console.error("OfflineStorage: Fallback storage also failed:",r),!1}}}async doSave(e){try{const t=this.sanitizeEvent(e),r=await this.getAll();if(r.length>=this.maxSize&&r.shift(),r.push(t),this.useIndexedDB){const e=this.safeStringify(r);if(!e)throw new Error("Failed to stringify events");await Gr.setItem(this.storageKey,e)||(this.useIndexedDB=!1,this.memoryStorage.set(this.storageKey,r))}else this.memoryStorage.set(this.storageKey,r)}catch(t){if(console.error("OfflineStorage: Error in doSave:",t),!this.useIndexedDB)throw t;this.useIndexedDB=!1;try{const t=this.memoryStorage.get(this.storageKey)||[];t.length>=this.maxSize&&t.shift(),t.push(this.sanitizeEvent(e)),this.memoryStorage.set(this.storageKey,t)}catch(r){throw r}}}sanitizeEvent(e){return{...e,properties:e.properties?this.sanitizeObject(e.properties):void 0}}sanitizeObject(e,t=new WeakSet){if("object"!=typeof e||null===e)return e;if(t.has(e))return{};t.add(e);const r={};for(const[s,n]of Object.entries(e))r[s]="object"==typeof n&&null!==n?this.sanitizeObject(n,t):n;return r}safeStringify(e){try{return JSON.stringify(e)}catch(t){try{if("object"==typeof e&&null!==e){const t=this.sanitizeObject(e);return JSON.stringify(t)}return JSON.stringify(e)}catch(r){return console.error("OfflineStorage: Failed to stringify after sanitization:",r),null}}}async getAll(){try{if(this.useIndexedDB){const e=await Gr.getItem(this.storageKey);return e?JSON.parse(e):[]}return this.memoryStorage.get(this.storageKey)||[]}catch(e){return console.error("OfflineStorage: Error getting events:",e),this.useIndexedDB?(this.useIndexedDB=!1,this.memoryStorage.get(this.storageKey)||[]):[]}}async remove(e){try{const t=await this.getAll(),r=new Map(e.map(e=>[this.getEventKey(e),e])),s=t.filter(e=>!r.has(this.getEventKey(e)));if(0===s.length)return this.useIndexedDB?await Gr.removeItem(this.storageKey):this.memoryStorage.delete(this.storageKey),!0;if(this.useIndexedDB){const e=this.safeStringify(s);if(!e)throw new Error("Failed to stringify remaining events");const t=await Gr.setItem(this.storageKey,e);return t||(this.useIndexedDB=!1,this.memoryStorage.set(this.storageKey,s),!0)}return this.memoryStorage.set(this.storageKey,s),!0}catch(t){return console.error("OfflineStorage: Error removing events:",t),!1}}async clear(){try{return this.useIndexedDB?await Gr.removeItem(this.storageKey):this.memoryStorage.delete(this.storageKey),!0}catch(e){return console.error("OfflineStorage: Error clearing events:",e),!1}}async getCount(){return(await this.getAll()).length}getEventKey(e){return`${e.type}-${e.name}-${e.timestamp}-${e.url}`}}class es{constructor(e,t={}){r(this,"sender"),r(this,"offlineStorage"),r(this,"queue",[]),r(this,"timer",null),r(this,"batchSize"),r(this,"batchWait"),r(this,"enableOfflineStorage"),r(this,"isProcessing",!1),r(this,"isInitialized",!1),r(this,"initPromise",null),r(this,"eventCallbacks",new Map),this.sender=new Xr(e),this.offlineStorage=new Qr(t.maxOfflineStorageSize??1e3),this.batchSize=t.batchSize||10,this.batchWait=t.batchWait||5e3,this.enableOfflineStorage=t.enableOfflineStorage??!0,this.initPromise=this.init()}async init(){this.enableOfflineStorage&&(await this.offlineStorage.init(),this.flushOfflineEvents()),this.isInitialized=!0}async ensureInitialized(){!this.isInitialized&&this.initPromise&&await this.initPromise}add(e,t){this.queue.push(e),(null==t?void 0:t.onBatchComplete)&&this.eventCallbacks.set(e,t),this.queue.length>=this.batchSize?this.flush():this.timer||(this.timer=setTimeout(()=>{this.flush()},this.batchWait))}async addAsync(e){await this.ensureInitialized(),this.add(e)}async flush(){if(this.isProcessing||0===this.queue.length)return;await this.ensureInitialized(),this.isProcessing=!0,this.timer&&(clearTimeout(this.timer),this.timer=null);const e=[...this.queue];this.queue=[];const t=new Map;e.forEach(e=>{const r=this.eventCallbacks.get(e);if(null==r?void 0:r.onBatchComplete){const s=r.onBatchComplete;t.has(s)||t.set(s,[]),t.get(s).push(e)}this.eventCallbacks.delete(e)});try{const r=await this.sender.sendBatch(e);if(!r&&this.enableOfflineStorage)for(const t of e)await this.offlineStorage.save(t);t.forEach((e,t)=>{try{t(e,r)}catch(s){console.error("BatchSender: Error in batch complete callback:",s)}})}catch(r){if(console.error("BatchSender: Error flushing events:",r),this.enableOfflineStorage)for(const t of e)await this.offlineStorage.save(t);t.forEach((e,t)=>{try{t(e,!1)}catch(r){console.error("BatchSender: Error in batch complete callback:",r)}})}finally{this.isProcessing=!1,this.queue.length>0&&setTimeout(()=>{this.flush().catch(e=>{console.error("BatchSender: Error in recursive flush:",e)})},0)}}async flushOfflineEvents(){try{const e=await this.offlineStorage.getAll();if(0===e.length)return;const t=this.batchSize;for(let r=0;r<e.length;r+=t){const s=e.slice(r,r+t);if(!(await this.sender.sendBatch(s)))break;await this.offlineStorage.remove(s)}}catch(e){console.error("BatchSender: Error flushing offline events:",e)}}setServerUrl(e){this.sender.setServerUrl(e)}async getOfflineEvents(){return await this.ensureInitialized(),this.offlineStorage.getAll()}async getOfflineEventCount(){return await this.ensureInitialized(),this.offlineStorage.getCount()}async clearOfflineStorage(){return await this.ensureInitialized(),this.offlineStorage.clear()}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.flush().catch(e=>{console.error("BatchSender: Error during destroy flush:",e)})}async destroyAsync(){this.timer&&(clearTimeout(this.timer),this.timer=null),await this.flush()}}class ts{constructor(){r(this,"plugins",new Map),r(this,"trackerInstance",null)}setTrackerInstance(e){this.trackerInstance=e}use(e){if(this.plugins.has(e.name))console.warn(`PluginManager: Plugin "${e.name}" is already installed`);else if(this.trackerInstance)try{e.install(this.trackerInstance),this.plugins.set(e.name,e)}catch(t){console.error(`PluginManager: Error installing plugin "${e.name}":`,t)}else console.error("PluginManager: Tracker instance is not set")}unuse(e){const t=this.plugins.get(e);if(t){if(t.uninstall&&this.trackerInstance)try{t.uninstall(this.trackerInstance)}catch(r){console.error(`PluginManager: Error uninstalling plugin "${e}":`,r)}this.plugins.delete(e)}}get(e){return this.plugins.get(e)}getAll(){return Array.from(this.plugins.values())}clear(){for(const e of this.plugins.keys())this.unuse(e)}}class rs{constructor(){r(this,"pageViews",[]),r(this,"startTime",Date.now())}analyzePageView(e){this.pageViews.push(e)}getMetrics(){const e=new Set,t=new Set;let r=0;const s=[];return this.pageViews.forEach(n=>{n.deviceId&&e.add(n.deviceId),n.sessionId&&t.add(n.sessionId),n.duration&&(r+=n.duration),s.push(n.url)}),{pv:this.pageViews.length,uv:e.size,sessions:t.size,avgDuration:this.pageViews.length>0?r/this.pageViews.length:0,paths:s}}getVisitPath(){return this.pageViews.map(e=>e.url)}getDuration(){return Date.now()-this.startTime}reset(){this.pageViews=[],this.startTime=Date.now()}}class ss{constructor(){r(this,"snapshots",[]),r(this,"interactions",[]),r(this,"observer",null),r(this,"isRecording",!1),r(this,"maxSnapshots",1e3),r(this,"mutationHandler",null),r(this,"throttledMouseMoveHandler",null),r(this,"handleClick",e=>{var t;this.recordInteraction({type:"click",timestamp:Date.now(),data:{x:e.clientX,y:e.clientY,target:null==(t=e.target)?void 0:t.tagName}})}),r(this,"handleInput",e=>{const t=e.target;t&&this.recordInteraction({type:"input",timestamp:Date.now(),data:{tagName:t.tagName,value:t.value.substring(0,100)}})}),r(this,"handleScroll",()=>{this.recordInteraction({type:"scroll",timestamp:Date.now(),data:{scrollX:window.scrollX,scrollY:window.scrollY}})}),r(this,"handleMouseMove",e=>{this.recordInteraction({type:"mousemove",timestamp:Date.now(),data:{x:e.clientX,y:e.clientY}})})}start(){this.isRecording||"undefined"==typeof document||(this.isRecording=!0,this.takeSnapshot(),this.mutationHandler=h((...e)=>{const t=e[0];this.recordMutations(t)},100),this.observer=new MutationObserver(this.mutationHandler),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,characterData:!0}),this.setupInteractionListeners())}stop(){this.isRecording&&(this.isRecording=!1,this.observer&&(this.observer.disconnect(),this.observer=null),this.removeInteractionListeners())}takeSnapshot(){this.snapshots.length>=this.maxSnapshots&&this.snapshots.shift();try{const e={timestamp:Date.now(),html:document.documentElement.outerHTML,mutations:[]};this.snapshots.push(e)}catch(e){console.error("SessionReplay: Error taking snapshot:",e)}}recordMutations(e){if(0===this.snapshots.length)return;this.snapshots[this.snapshots.length-1].mutations.push(...e)}setupInteractionListeners(){"undefined"!=typeof window&&(document.addEventListener("click",this.handleClick,!0),document.addEventListener("input",this.handleInput,!0),window.addEventListener("scroll",this.handleScroll,{passive:!0}),this.throttledMouseMoveHandler=h((...e)=>{const t=e[0];this.handleMouseMove(t)},100),document.addEventListener("mousemove",this.throttledMouseMoveHandler,{passive:!0}))}removeInteractionListeners(){"undefined"!=typeof document&&(document.removeEventListener("click",this.handleClick,!0),document.removeEventListener("input",this.handleInput,!0),window.removeEventListener("scroll",this.handleScroll,{passive:!0}),this.throttledMouseMoveHandler&&(document.removeEventListener("mousemove",this.throttledMouseMoveHandler,{passive:!0}),this.throttledMouseMoveHandler=null))}recordInteraction(e){this.interactions.length>=this.maxSnapshots&&this.interactions.shift(),this.interactions.push(e)}getData(){return{snapshots:[...this.snapshots],interactions:[...this.interactions]}}clear(){this.snapshots=[],this.interactions=[]}destroy(){this.stop(),this.clear()}}const ns={enabled:!0,recordRequestBody:!0,recordResponseBody:!0,maxResponseBodySize:102400,maxRequestBodySize:102400,onlyFailedRequests:!1};function is(e,t){return!t||("string"==typeof t?e.includes(t):t instanceof RegExp?t.test(e):"function"!=typeof t||t(e))}function as(e,t){if(!e||"object"!=typeof e||0===t.length)return e;if(Array.isArray(e))return e.map(e=>as(e,t));const r={};for(const[s,n]of Object.entries(e)){const e=s.toLowerCase(),i=t.some(t=>e.includes(t.toLowerCase()));r[s]=i?"[FILTERED]":"object"==typeof n&&null!==n?as(n,t):n}return r}function os(e={}){const t={...ns,...e};let r=null,s=null,n=null,i=null;const a=new Map;return{name:"network-interceptor",install(e){if(t.enabled&&"undefined"!=typeof window&&(void 0!==window.fetch&&(r=window.fetch,window.fetch=async function(s,n){const i="string"==typeof s?s:s instanceof URL?s.href:s.url,c=(null==n?void 0:n.method)||("string"==typeof s||s instanceof URL||!("method"in s)?void 0:s.method)||"GET";if(!is(i,t.urlFilter))return r.call(this,s,n);const h=`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,d=Date.now(),u={};let f;if("string"!=typeof s&&!(s instanceof URL)&&"headers"in s&&s.headers instanceof Headers&&s.headers.forEach((e,t)=>{u[t]=e}),(null==n?void 0:n.headers)&&(n.headers instanceof Headers?n.headers.forEach((e,t)=>{u[t]=e}):Array.isArray(n.headers)?n.headers.forEach(([e,t])=>{u[e]=t}):Object.assign(u,n.headers)),t.recordRequestBody){const e=(null==n?void 0:n.body)??("string"==typeof s||s instanceof URL||!("body"in s)?null:s.body);if(f=await async function(e,t,r){if(e&&r)try{if("string"==typeof e)return e.length>t?e.substring(0,t)+"...[TRUNCATED]":e;if(e instanceof FormData){const t={};for(const[r,s]of e.entries())s instanceof File?t[r]=`[File: ${s.name}, ${s.size} bytes]`:t[r]=s;return t}if(e instanceof URLSearchParams)return Object.fromEntries(e.entries());if(e instanceof Blob){if(e.size>t)return`[Blob: ${e.size} bytes, type: ${e.type}]`;try{return await e.text()}catch{return`[Blob: ${e.size} bytes, type: ${e.type}]`}}return e instanceof ArrayBuffer?e.byteLength>t?`[ArrayBuffer: ${e.byteLength} bytes]`:(new TextDecoder).decode(e):"[Unsupported body type]"}catch(s){return console.warn("NetworkInterceptor: Failed to read request body:",s),"[Error reading body]"}}(e,t.maxRequestBodySize,t.recordRequestBody),t.sensitiveFields&&t.sensitiveFields.length>0&&void 0!==f)if("string"==typeof f)try{f=as(JSON.parse(f),t.sensitiveFields)}catch{f=as(f,t.sensitiveFields)}else f=as(f,t.sensitiveFields)}a.set(h,{url:i,method:c,headers:u,startTime:d,requestBody:f});const p={type:"custom",name:"custom",eventName:"api-request",timestamp:d,url:o(),title:l(),properties:{url:i.split("?")[0].split("#")[0],fullUrl:i,method:c,headers:t.sensitiveFields&&t.sensitiveFields.length>0?as(u,t.sensitiveFields):u,body:f,timestamp:d}};e.send(p);try{const u=await r.call(this,s,n),f=Date.now(),p=f-d,m=u.status,g=u.ok;if(t.onlyFailedRequests&&g)return a.delete(h),u;let w;t.recordResponseBody&&(w=await async function(e,t,r){if(r)try{if(!(e instanceof Response)){const r=e,s=r.responseText||"";if(s.length>t)return s.substring(0,t)+"...[TRUNCATED]";let n="";try{n=r.getResponseHeader("content-type")||""}catch{}if(n.includes("application/json"))try{return JSON.parse(s)}catch{return s}return s}{const r=e.headers.get("content-length");if(r&&parseInt(r,10)>t)return`[Response too large: ${r} bytes]`;let n;try{n=e.clone()}catch(s){return"[Response body already consumed]"}const i=e.headers.get("content-type")||"";if(i.includes("application/json")){const e=await n.text();if(e.length>t)return e.substring(0,t)+"...[TRUNCATED]";try{return JSON.parse(e)}catch{return e}}else{if(i.includes("text/")){const e=await n.text();return e.length>t?e.substring(0,t)+"...[TRUNCATED]":e}try{return`[${i||"unknown"}: ${(await n.blob()).size} bytes]`}catch{return`[${i||"unknown"}: unable to read]`}}}}catch(s){return console.warn("NetworkInterceptor: Failed to read response body:",s),"[Error reading response]"}}(u,t.maxResponseBodySize,t.recordResponseBody),t.sensitiveFields&&t.sensitiveFields.length>0&&void 0!==w&&(w=as(w,t.sensitiveFields)));const _=u.headers.get("content-length"),y=_?parseInt(_,10):void 0,b={type:"custom",name:"custom",eventName:"api-response",timestamp:f,url:o(),title:l(),properties:{url:i.split("?")[0].split("#")[0],fullUrl:i,method:c,statusCode:m,duration:p,responseSize:y,success:g,body:w,timestamp:f}};return e.send(b),a.delete(h),u}catch(m){const t=Date.now(),r=t-d,s={type:"custom",name:"custom",eventName:"api-response",timestamp:t,url:o(),title:l(),properties:{url:i.split("?")[0].split("#")[0],fullUrl:i,method:c,statusCode:0,duration:r,success:!1,error:m instanceof Error?m.message:String(m),timestamp:t}};throw e.send(s),a.delete(h),m}}),"undefined"!=typeof XMLHttpRequest)){s=XMLHttpRequest.prototype.open,n=XMLHttpRequest.prototype.send,i=XMLHttpRequest.prototype.setRequestHeader;const r=new WeakMap,a=new WeakMap;XMLHttpRequest.prototype.open=function(e,t,n,i,o){const l="string"==typeof t?t:t.href;return a.set(this,{url:l,method:e.toUpperCase(),startTime:Date.now()}),r.set(this,{}),s.call(this,e,t,void 0===n||n,i,o)},XMLHttpRequest.prototype.setRequestHeader=function(e,t){const s=r.get(this)||{};return s[e]=t,r.set(this,s),i.call(this,e,t)},XMLHttpRequest.prototype.send=function(s){const i=a.get(this);if(!i)return n.call(this,s);const{url:c,method:h,startTime:d}=i,u=r.get(this)||{};if(!is(c,t.urlFilter))return n.call(this,s);let f;if(t.recordRequestBody&&s){if("string"==typeof s)f=s.length>t.maxRequestBodySize?s.substring(0,t.maxRequestBodySize)+"...[TRUNCATED]":s;else if(s instanceof FormData){const e={};for(const[t,r]of s.entries())r instanceof File?e[t]=`[File: ${r.name}, ${r.size} bytes]`:e[t]=r;f=e}else f=s instanceof Blob?s.size>t.maxRequestBodySize?`[Blob: ${s.size} bytes, type: ${s.type}]`:"[Blob]":"[Unsupported body type]";t.sensitiveFields&&t.sensitiveFields.length>0&&(f=as(f,t.sensitiveFields))}i.requestBody=f;const p={type:"custom",name:"custom",eventName:"api-request",timestamp:d,url:o(),title:l(),properties:{url:c.split("?")[0].split("#")[0],fullUrl:c,method:h,headers:t.sensitiveFields&&t.sensitiveFields.length>0?as(u,t.sensitiveFields):u,body:f,timestamp:d}};e.send(p);const m=()=>{if(this.readyState===XMLHttpRequest.DONE){const n=Date.now(),i=n-d,u=this.status,f=u>=200&&u<400;if(t.onlyFailedRequests&&f)return this.removeEventListener("readystatechange",m),a.delete(this),void r.delete(this);let p="";try{p=this.responseText||""}catch(s){console.warn("NetworkInterceptor: Failed to read XHR responseText:",s)}const g=p.length;let w;if(t.recordResponseBody){if(p.length>t.maxResponseBodySize)w=p.substring(0,t.maxResponseBodySize)+"...[TRUNCATED]";else{let e="";try{e=this.getResponseHeader("content-type")||""}catch{}if(e.includes("application/json"))try{w=JSON.parse(p)}catch{w=p}else w=p}t.sensitiveFields&&t.sensitiveFields.length>0&&(w=as(w,t.sensitiveFields))}const _={type:"custom",name:"custom",eventName:"api-response",timestamp:n,url:o(),title:l(),properties:{url:c.split("?")[0].split("#")[0],fullUrl:c,method:h,statusCode:u,duration:i,responseSize:g,success:f,body:w,timestamp:n}};e.send(_),this.removeEventListener("readystatechange",m),a.delete(this),r.delete(this)}};return this.addEventListener("readystatechange",m),n.call(this,s)}}},uninstall(){"undefined"!=typeof window&&(r&&(window.fetch=r,r=null),s&&n&&i&&(XMLHttpRequest.prototype.open=s,XMLHttpRequest.prototype.send=n,XMLHttpRequest.prototype.setRequestHeader=i,s=null,n=null,i=null),a.clear())}}}const ls=os();return e.createNetworkInterceptorPlugin=os,e.default=class{constructor(e){if(r(this,"config"),r(this,"autoTracker",null),r(this,"errorTracker",null),r(this,"performanceTracker",null),r(this,"customTracker"),r(this,"dataProcessor"),r(this,"batchSender"),r(this,"pluginManager"),r(this,"behaviorAnalysis"),r(this,"sessionReplay",null),r(this,"userInfo",null),r(this,"deviceId"),r(this,"sessionId"),!e.appId)throw new Error("Tracker: appId is required");this.config=new n(e),this.deviceId=e.deviceId||function(){if("undefined"==typeof window)return a();const e="__tracker_device_id__";let t=localStorage.getItem(e);if(!t){t=a();try{localStorage.setItem(e,t)}catch(r){}}return t}(),this.sessionId=function(){if("undefined"==typeof window)return a();const e="__tracker_session_id__";let t=sessionStorage.getItem(e);if(!t){t=a();try{sessionStorage.setItem(e,t)}catch(r){}}return t}(),this.customTracker=new v,this.dataProcessor=new Fr;const t=e.serverUrl||"about:blank";this.batchSender=new es(t,{batchSize:this.config.get("batchSize"),batchWait:this.config.get("batchWait"),enableOfflineStorage:this.config.get("enableOfflineStorage")??!0,maxOfflineStorageSize:this.config.get("maxOfflineStorageSize")}),e.serverUrl||this.batchSender.setServerUrl(""),this.pluginManager=new ts,this.behaviorAnalysis=new rs,this.pluginManager.setTrackerInstance({send:this.send.bind(this),getConfig:()=>this.config.getAll(),setUser:this.setUser.bind(this),getUser:()=>this.userInfo}),this.init(),"undefined"!=typeof window&&(window.__trackerEventBus={emit:(e,t)=>{i.emit(e,t)}})}init(){this.config.get("enableAutoTrack")&&(this.autoTracker=new _,this.autoTracker.init(),this.setupAutoTrackListeners()),this.config.get("enableErrorTrack")&&(this.errorTracker=new y,this.errorTracker.init()),this.config.get("enablePerformanceTrack")&&(this.performanceTracker=new b,this.performanceTracker.init()),this.config.get("enableSessionReplay")&&(this.sessionReplay=new ss,this.sessionReplay.start()),this.config.get("userId")&&this.setUser({userId:this.config.get("userId")})}setupAutoTrackListeners(){i.on("pageview",e=>{this.send(e)}),i.on("click",e=>{this.send(e)}),i.on("exposure",e=>{this.send(e)}),i.on("input",e=>{this.send(e)}),i.on("error",e=>{this.send(e)}),i.on("performance",e=>{this.send(e)})}send(e){try{const t=this.enrichEvent(e),r=this.dataProcessor.process(t,{sampleRate:this.config.get("sampleRate"),enableDeduplication:!0,isCritical:"error"===e.type});if(!r)return;const s=this.config.get("beforeSend");if(s){const e=s(r);if(!1===e||null===e)return;e&&Object.assign(r,e)}this.batchSender.add(r,{onBatchComplete:(e,t)=>{const r=this.config.get("afterSend");r&&e.forEach(e=>{setTimeout(()=>{r(e,t)},0)})}}),"pageview"===e.type&&this.behaviorAnalysis.analyzePageView(r)}catch(t){const e=this.config.get("onError");e?e(t):console.error("Tracker: Error sending event:",t)}}enrichEvent(e){var t;const r=e.userId||(null==(t=this.userInfo)?void 0:t.userId)||this.config.get("userId"),s={...this.config.get("customProperties")||{},...e.properties||{}},n=Object.keys(s).length>0?s:void 0,i={...e,deviceId:e.deviceId||this.deviceId,sessionId:e.sessionId||this.sessionId};return r&&""!==r&&(i.userId=r),n&&(i.properties=n),i}track(e,t){const r=this.customTracker.track(e,t);this.send(r)}setUser(e){this.userInfo={...this.userInfo,...e},this.config.set("userId",e.userId||"")}getUser(){return this.userInfo}trackError(e,t){if(this.errorTracker)this.errorTracker.trackError(e,t);else{const r={type:"error",name:"custom-error",timestamp:Date.now(),url:o(),title:l(),errorType:"js",message:e instanceof Error?e.message:e,stack:e instanceof Error?e.stack:void 0,properties:t};this.send(r)}}trackPerformance(){if(this.performanceTracker){const e=this.performanceTracker.collectMetrics();e&&this.send(e)}}trackPageView(){if(this.autoTracker){const e=this.autoTracker.getViewTracker().trackPageView();this.send(e)}}use(e){this.pluginManager.use(e)}updateConfig(e){this.config.update(e),void 0!==e.serverUrl&&(e.serverUrl?this.batchSender.setServerUrl(e.serverUrl):this.batchSender.setServerUrl(""))}getConfig(){return this.config.getAll()}getBehaviorMetrics(){return this.behaviorAnalysis.getMetrics()}getSessionReplayData(){var e;return null==(e=this.sessionReplay)?void 0:e.getData()}async getOfflineEvents(){return this.batchSender.getOfflineEvents()}async getOfflineEventCount(){return this.batchSender.getOfflineEventCount()}async clearOfflineStorage(){return this.batchSender.clearOfflineStorage()}getAutoTracker(){return this.autoTracker}destroy(){var e,t,r,s;null==(e=this.autoTracker)||e.destroy(),null==(t=this.errorTracker)||t.destroy(),null==(r=this.performanceTracker)||r.destroy(),null==(s=this.sessionReplay)||s.destroy(),this.batchSender.destroy(),this.pluginManager.clear(),i.clear()}async destroyAsync(){var e,t,r,s;null==(e=this.autoTracker)||e.destroy(),null==(t=this.errorTracker)||t.destroy(),null==(r=this.performanceTracker)||r.destroy(),null==(s=this.sessionReplay)||s.destroy(),await this.batchSender.destroyAsync(),this.pluginManager.clear(),i.clear()}},e.eventBus=i,e.indexedDBStorage=Gr,e.localStorage=Wr,e.memoryStorage=Yr,e.networkInterceptorPlugin=ls,e.sessionStorage=Jr,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),e}({});
3
+ //# sourceMappingURL=index.iife.js.map