@grainql/analytics-web 3.4.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,96 +1,85 @@
1
- # Grain Analytics Web SDK
1
+ <br>
2
+ <p align="center">
3
+ <img src="https://cdn.xreos.co/webasset/images/grain_logomark_dark.svg" alt="Grain" width="150"/>
4
+ </p>
2
5
 
3
- A lightweight, dependency-free TypeScript SDK for privacy-first analytics and remote configuration management.
6
+ <h1 align="center">Grain Analytics Web SDK</h1>
4
7
 
5
- [![npm version](https://badge.fury.io/js/@grainql%2Fanalytics-web.svg)](https://www.npmjs.com/package/@grainql/analytics-web)
6
- [![Bundle Size](https://img.shields.io/bundlephobia/minzip/@grainql/analytics-web)](https://bundlephobia.com/package/@grainql/analytics-web)
8
+ <p align="center">
9
+ Lightweight TypeScript SDK for event tracking and remote configuration via <a href="https://grainql.com">Grain</a>.<br/>
10
+ Works in browsers, Node.js, and any JavaScript runtime.
11
+ </p>
7
12
 
8
- ## 🆕 What's New in v3.0
13
+ <p align="center">
14
+ <a href="https://www.npmjs.com/package/@grainql/analytics-web"><img src="https://img.shields.io/npm/v/@grainql/analytics-web" alt="npm version" /></a>
15
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License" /></a>
16
+ </p>
9
17
 
10
- **🔒 Privacy-First by Default:**
11
- - ✅ **Cookieless** - No tracking cookies, daily rotating IDs
12
- - ✅ **GDPR Compliant** - Cookieless mode requires no consent
13
- - ✅ **No IP Storage** - GeoIP data only (country, region, city)
14
- - ✅ **Query Params Stripped** - Privacy-first URL tracking
15
- - ✅ **Three Consent Modes** - Choose your privacy level
18
+ ---
16
19
 
17
- **🚨 Breaking Changes:** This is a major version with breaking changes. See [BREAKING_CHANGES.md](./BREAKING_CHANGES.md) and [MIGRATION_GUIDE_V2.md](./MIGRATION_GUIDE_V2.md).
18
-
19
- ## Features
20
-
21
- - 🔒 **Privacy-First** - Cookieless by default, GDPR compliant
22
- - 🚀 **Zero dependencies** - ~7KB gzipped
23
- - 📦 **Automatic batching** - Efficient event delivery
24
- - 🔄 **Retry logic** - Reliable with exponential backoff
25
- - 🎯 **TypeScript first** - Full type safety
26
- - ⚙️ **Remote Config** - Dynamic app control without deployments
27
- - ⚛️ **React Hooks** - Seamless React integration
28
- - 📱 **Cross-platform** - Browser, Node.js, React Native
20
+ > **For browser analytics with heatmaps, snapshots, and consent management, use [`@grainql/tag`](https://github.com/GrainQL/grain-tag) instead.**
21
+ > This SDK is the right choice when you need **remote configuration** or need to **send events from servers and non-browser environments**.
29
22
 
30
23
  ## Installation
31
24
 
32
- ### NPM
33
-
34
25
  ```bash
35
26
  npm install @grainql/analytics-web
36
27
  ```
37
28
 
38
- ### CDN (IIFE)
39
-
40
- ```html
41
- <!-- Load from CDN -->
42
- <script src="https://cdn.jsdelivr.net/npm/@grainql/analytics-web@latest/dist/index.global.js"></script>
43
-
44
- <script>
45
- // Available as window.Grain
46
- const grain = window.Grain.createGrainAnalytics({
47
- tenantId: 'your-tenant-id'
48
- });
49
-
50
- grain.track('page_view', { page: window.location.pathname });
51
- </script>
52
- ```
53
-
54
29
  ## Quick Start
55
30
 
56
- ### Vanilla JavaScript/TypeScript
31
+ ### Server-Side / Node.js
57
32
 
58
33
  ```typescript
59
34
  import { createGrainAnalytics } from '@grainql/analytics-web';
60
35
 
61
- // Cookieless by default (no consent needed)
62
36
  const grain = createGrainAnalytics({
63
37
  tenantId: 'your-tenant-id',
64
- consentMode: 'cookieless', // Default: daily rotating IDs
38
+ authStrategy: 'SERVER_SIDE',
39
+ secretKey: 'your-secret-key',
65
40
  });
66
41
 
67
- // Track events
68
- grain.track('page_viewed', { page: '/home' });
42
+ // Track server-side events
43
+ grain.track('order_completed', {
44
+ order_id: 'ORD-123',
45
+ total: 149.99,
46
+ currency: 'USD',
47
+ });
69
48
 
70
- // Get remote config
71
- const heroText = grain.getConfig('hero_text');
49
+ // Track with an explicit user ID
50
+ grain.trackForUser('user-456', 'subscription_renewed', {
51
+ plan: 'pro',
52
+ period: 'annual',
53
+ });
54
+
55
+ // Flush before process exit
56
+ await grain.flush();
72
57
  ```
73
58
 
74
- **For GDPR Strict (with consent management):**
59
+ ### Remote Configuration
75
60
 
76
61
  ```typescript
77
- const grain = createGrainAnalytics({
78
- tenantId: 'your-tenant-id',
79
- consentMode: 'gdpr-strict', // Requires consent for permanent IDs
80
- waitForConsent: true, // Queue events until consent granted
81
- });
62
+ import { createGrainAnalytics } from '@grainql/analytics-web';
82
63
 
83
- // Show consent banner
84
- if (!grain.hasConsent()) {
85
- // Show your consent UI
86
- showConsentBanner({
87
- onAccept: () => grain.grantConsent(['analytics']),
88
- onReject: () => grain.revokeConsent(),
89
- });
90
- }
64
+ const grain = createGrainAnalytics({ tenantId: 'your-tenant-id' });
65
+
66
+ // Fetch remote config from Grain dashboard
67
+ await grain.fetchConfig();
68
+
69
+ // Read values
70
+ const heroText = grain.getConfig('hero_text');
71
+ const featureEnabled = grain.getConfig('new_feature') === 'true';
72
+
73
+ // Get all configs with fallback defaults
74
+ const allConfigs = grain.getAllConfigs();
75
+
76
+ // Listen for config changes
77
+ grain.onConfigChange((configs) => {
78
+ console.log('Config updated:', configs);
79
+ });
91
80
  ```
92
81
 
93
- ### React
82
+ ### React (Remote Config Hooks)
94
83
 
95
84
  ```typescript
96
85
  import { GrainProvider, useConfig, useTrack } from '@grainql/analytics-web/react';
@@ -106,110 +95,93 @@ function App() {
106
95
  function HomePage() {
107
96
  const { value: heroText } = useConfig('hero_text');
108
97
  const track = useTrack();
109
-
98
+
110
99
  return (
111
100
  <div>
112
101
  <h1>{heroText || 'Welcome!'}</h1>
113
- <button onClick={() => track('cta_clicked')}>
114
- Get Started
115
- </button>
102
+ <button onClick={() => track('cta_clicked')}>Get Started</button>
116
103
  </div>
117
104
  );
118
105
  }
119
106
  ```
120
107
 
121
- ## Documentation
108
+ ## Configuration
122
109
 
123
- For comprehensive guides, API reference, and examples, visit our documentation:
124
-
125
- **📚 [Full Documentation](https://docs.grainql.com)** <!-- Update with actual docs URL -->
110
+ ```typescript
111
+ createGrainAnalytics({
112
+ tenantId: 'your-tenant-id', // Required
113
+ apiUrl: 'https://clientapis.grainql.com', // Default
114
+ debug: false, // Enable debug logging
115
+ // Authentication
116
+ authStrategy: 'NONE', // 'NONE' | 'SERVER_SIDE' | 'JWT'
117
+ secretKey: undefined, // For SERVER_SIDE auth
118
+ authProvider: undefined, // For JWT auth
119
+ // Batching
120
+ batchSize: 50, // Events per batch
121
+ flushInterval: 5000, // Flush interval in ms
122
+ retryAttempts: 3, // Retry attempts on failure
123
+ // Remote Config
124
+ defaultConfigurations: {}, // Fallback values
125
+ configRefreshInterval: 300000, // Auto-refresh (5 min default)
126
+ enableConfigCache: true, // Cache configs locally
127
+ // Privacy
128
+ consentMode: 'cookieless', // 'cookieless' | 'gdpr-strict' | 'gdpr-opt-out'
129
+ });
130
+ ```
126
131
 
127
- ### Key Topics
132
+ ## API Reference
128
133
 
129
- - **[Quick Start Guides](https://docs.grainql.com/quickstart)** - Choose your platform and get started in 5 minutes
130
- - [React](https://docs.grainql.com/quickstart/react) | [Next.js](https://docs.grainql.com/quickstart/nextjs) | [Vanilla JS](https://docs.grainql.com/quickstart/vanilla-js) | [CDN](https://docs.grainql.com/quickstart/cdn) | [Node.js](https://docs.grainql.com/quickstart/nodejs)
131
- - **[No-Code Integrations](https://docs.grainql.com/integrations/gtm)** - GTM, Shopify, WordPress
132
- - **[Event Tracking](https://docs.grainql.com/core/event-tracking)** - Track user actions
133
- - **[Remote Configuration](https://docs.grainql.com/core/remote-config)** - Dynamic app control
134
- - **[React Hooks](https://docs.grainql.com/react/overview)** - React integration
135
- - **[API Reference](https://docs.grainql.com/api-reference/overview)** - Complete API docs
136
- - **[Examples](https://docs.grainql.com/examples/react)** - Real-world examples
134
+ ### Event Tracking
137
135
 
136
+ ```typescript
137
+ grain.track(eventName, properties?) // Track with current user
138
+ grain.trackForUser(userId, eventName, properties?) // Track with explicit user
139
+ grain.flush() // Flush pending events
140
+ ```
138
141
 
139
- ## Key Concepts
142
+ ### Identity
140
143
 
141
- ### Event Tracking
142
- Track user actions with automatic batching and retry logic:
143
144
  ```typescript
144
- grain.track('button_clicked', { button: 'signup' });
145
- await grain.trackPurchase({ orderId: '123', total: 99.99 });
145
+ grain.setUserId(userId) // Set user identity
146
+ grain.getUserId() // Get current user ID
147
+ grain.getDeviceId() // Get device ID
148
+ grain.getSessionId() // Get session ID
146
149
  ```
147
150
 
148
151
  ### Remote Configuration
149
- Control your app dynamically without code deployments:
150
- ```typescript
151
- const featureEnabled = grain.getConfig('new_feature');
152
- if (featureEnabled === 'true') {
153
- // Show feature
154
- }
155
- ```
156
152
 
157
- ### User Identification
158
- Track users across sessions:
159
153
  ```typescript
160
- grain.setUserId('user_123');
161
- await grain.setProperty({ plan: 'premium' });
154
+ grain.fetchConfig(options?) // Fetch configs from API
155
+ grain.getConfig(key) // Get a single config value
156
+ grain.getAllConfigs() // Get all configs with defaults
157
+ grain.onConfigChange(callback) // Listen for config changes
162
158
  ```
163
159
 
164
- ### Tracks: Journey Visualization
165
-
166
- Track user journeys from start to goal to unlock path visualization:
160
+ ### Consent
167
161
 
168
162
  ```typescript
169
- // 1. Define meaningful event names for your journey
170
- grain.track('signup_started', { source: 'homepage' });
171
- grain.track('email_entered', { valid: true });
172
- grain.track('password_created', { strength: 'strong' });
173
- grain.track('signup_completed', { method: 'email' });
174
-
175
- // 2. In the dashboard, create a Track:
176
- // - Start event: 'signup_started'
177
- // - Goal event: 'signup_completed'
178
- // - The system will automatically visualize all paths between them
179
-
180
- // 3. Best practices for Tracks:
181
- // - Use consistent event naming (snake_case recommended)
182
- // - Track intermediate steps (not just start/end)
183
- // - Add properties to segment paths (e.g., source, device_type)
184
- // - Exclude noise: heartbeat events are filtered automatically
163
+ grain.grantConsent(categories?) // Grant consent
164
+ grain.revokeConsent() // Revoke consent
165
+ grain.hasConsent() // Check consent status
185
166
  ```
186
167
 
187
- **What you'll see in Tracks:**
188
- - **Conversion paths**: Most common routes users take to reach the goal
189
- - **Drop-off paths**: Where users abandon the journey
190
- - **Hub nodes**: Critical events many paths flow through
191
- - **Metrics**: Conversion rate, time-to-goal, abandonment points
168
+ ### Lifecycle
192
169
 
193
- ## More Examples
194
-
195
- Check the [examples directory](./examples) for:
196
- - Vanilla JavaScript usage
197
- - React integration
198
- - Next.js setup
199
- - E-commerce tracking
200
- - Authentication flows
170
+ ```typescript
171
+ grain.destroy() // Flush and cleanup
172
+ ```
201
173
 
202
- ## Contributing
174
+ ## When to Use Which SDK
203
175
 
204
- We welcome contributions! Please see our contributing guidelines for more details.
176
+ | Use Case | SDK |
177
+ |----------|-----|
178
+ | Browser analytics, heatmaps, snapshots | [`@grainql/tag`](https://github.com/GrainQL/grain-tag) |
179
+ | Script tag delivery (Cloudflare Workers) | [`@grainql/tag`](https://github.com/GrainQL/grain-tag) |
180
+ | Remote configuration | `@grainql/analytics-web` |
181
+ | Server-side event tracking (Node.js) | `@grainql/analytics-web` |
182
+ | React config hooks (`useConfig`) | `@grainql/analytics-web/react` |
183
+ | Non-browser runtimes | `@grainql/analytics-web` |
205
184
 
206
185
  ## License
207
186
 
208
- MIT © Grain Analytics
209
-
210
- ## Support
211
-
212
- - **Documentation**: [docs.grainql.com](https://docs.grainql.com)
213
- - **Dashboard**: [grainql.com/dashboard](https://grainql.com/dashboard)
214
- - **Issues**: [GitHub Issues](https://github.com/GrainQL/analytics-web/issues)
215
- - **Email**: support@grainql.com
187
+ [MIT](LICENSE)
@@ -1,4 +1,4 @@
1
- /* Grain Analytics Web SDK v3.4.0 | MIT License | Development Build */
1
+ /* Grain Analytics Web SDK v3.4.1 | MIT License | Development Build */
2
2
  "use strict";
3
3
  var Grain = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /* Grain Analytics Web SDK v3.4.0 | MIT License */
1
+ /* Grain Analytics Web SDK v3.4.1 | MIT License */
2
2
  "use strict";var Grain=(()=>{var Ze=Object.defineProperty;var Nr=Object.getOwnPropertyDescriptor;var $r=Object.getOwnPropertyNames;var Hr=Object.prototype.hasOwnProperty;var $=(n,e)=>()=>(n&&(e=n(n=0)),e);var z=(n,e)=>{for(var t in e)Ze(n,t,{get:e[t],enumerable:!0})},Br=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of $r(e))!Hr.call(n,r)&&r!==t&&Ze(n,r,{get:()=>e[r],enumerable:!(i=Nr(e,r))||i.enumerable});return n};var Fr=n=>Br(Ze({},"__esModule",{value:!0}),n);var Yr,W,it=$(()=>{"use strict";Yr={maxSectionDuration:9e3,minScrollDistance:100,idleThreshold:3e4},W=class{constructor(e,t={}){this.isDestroyed=!1;this.isPageVisible=!0;this.visibilityChangeHandler=null;this.sectionStates=new Map;this.lastFilterReason=null;this.activityDetector=e,this.options={...Yr,...t,debug:t.debug??!1},this.setupPageVisibilityTracking()}setupPageVisibilityTracking(){typeof document>"u"||(this.isPageVisible=document.visibilityState==="visible",this.visibilityChangeHandler=()=>{let e=this.isPageVisible;this.isPageVisible=document.visibilityState==="visible",!this.isPageVisible&&e?this.log("Page hidden - tracking paused"):this.isPageVisible&&!e&&(this.log("Page visible - tracking resumed"),this.resetAllSections())},document.addEventListener("visibilitychange",this.visibilityChangeHandler))}shouldTrack(){return this.isPageVisible?this.activityDetector.isActive(this.options.idleThreshold)?(this.lastFilterReason=null,!0):(this.lastFilterReason="user_idle",!1):(this.lastFilterReason="page_hidden",!1)}shouldTrackSection(e,t){if(!this.shouldTrack())return{shouldTrack:!1,reason:this.lastFilterReason||"global_policy"};let i=this.sectionStates.get(e);i||(i={sectionName:e,currentDuration:0,lastScrollPosition:t,lastResetTime:Date.now()},this.sectionStates.set(e,i));let r=Math.abs(t-i.lastScrollPosition);return r>=this.options.minScrollDistance?(this.log(`Section "${e}": Attention reset due to ${Math.round(r)}px scroll`),i.currentDuration=0,i.lastScrollPosition=t,i.lastResetTime=Date.now(),{shouldTrack:!0,resetAttention:!0}):i.currentDuration>=this.options.maxSectionDuration?{shouldTrack:!1,reason:"max_duration_reached"}:{shouldTrack:!0}}updateSectionDuration(e,t){let i=this.sectionStates.get(e);i&&(i.currentDuration+=t,i.currentDuration>=this.options.maxSectionDuration&&this.log(`Section "${e}": Max duration cap reached (${i.currentDuration}ms)`))}resetSection(e){let t=this.sectionStates.get(e);t&&(this.log(`Section "${e}": Attention reset (section exit)`),t.currentDuration=0,t.lastResetTime=Date.now())}resetAllSections(){this.log("Resetting all section attention states");for(let e of this.sectionStates.values())e.currentDuration=0,e.lastResetTime=Date.now()}getSectionState(e){return this.sectionStates.get(e)}getLastFilterReason(){return this.lastFilterReason}shouldTrackScroll(e,t){return this.shouldTrack()?Math.abs(t-e)<10?{shouldTrack:!1,reason:"scroll_too_small"}:{shouldTrack:!0}:{shouldTrack:!1,reason:this.lastFilterReason||"global_policy"}}getPolicies(){return{maxSectionDuration:this.options.maxSectionDuration,minScrollDistance:this.options.minScrollDistance,idleThreshold:this.options.idleThreshold}}getTrackingState(){return{isPageVisible:this.isPageVisible,isUserActive:this.activityDetector.isActive(this.options.idleThreshold),timeSinceLastActivity:this.activityDetector.getTimeSinceLastActivity(),activeSections:this.sectionStates.size}}log(...e){this.options.debug&&console.log("[AttentionQuality]",...e)}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.visibilityChangeHandler&&typeof document<"u"&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null),this.sectionStates.clear())}}});function Jr(n){if(n)return n.replace(/[\u{1F300}-\u{1F9FF}]/gu,"").replace(/[\u{1F600}-\u{1F64F}]/gu,"").replace(/[\u{1F680}-\u{1F6FF}]/gu,"").replace(/[\u{2600}-\u{26FF}]/gu,"").replace(/[\u{2700}-\u{27BF}]/gu,"").replace(/[\u{1F900}-\u{1F9FF}]/gu,"").replace(/[\u{1F1E0}-\u{1F1FF}]/gu,"").replace(/[\u{200D}]/gu,"").replace(/[\u{FE0F}]/gu,"").replace(/[\u{20E3}]/gu,"").trim()}function Ae(n,e=100){if(!n)return;let t=Jr(n);if(t)return t.substring(0,e)||void 0}var rt=$(()=>{"use strict"});var kr={};z(kr,{IGNORED_NODE:()=>ut,Mirror:()=>J,absolutifyURLs:()=>ae,adaptCssForReplay:()=>Ye,buildNodeWithSN:()=>Ht,classMatchesRegex:()=>$e,cleanupSnapshot:()=>Un,createCache:()=>Ia,createMirror:()=>pn,escapeImportStatement:()=>Mi,extractFileExtension:()=>xt,fixSafariColons:()=>Ii,genId:()=>Bi,getInputType:()=>Ui,ignoreAttribute:()=>Gi,is2DCanvasBlank:()=>Li,isCSSImportRule:()=>_i,isCSSStyleRule:()=>Ri,isElement:()=>ze,isNativeShadowDom:()=>De,isNodeMetaEqual:()=>Oi,isShadowRoot:()=>xi,markCssSplits:()=>$i,maskInputValue:()=>Di,needMaskingText:()=>zi,normalizeCssString:()=>Le,rebuild:()=>Ua,serializeNodeWithId:()=>Y,snapshot:()=>Ln,splitCssText:()=>Ni,stringifyRule:()=>Pi,stringifyStylesheet:()=>Ne,toLowerCase:()=>he,transformAttribute:()=>Fi,visitSnapshot:()=>On});function kt(n){if(Ee[n])return Ee[n];let e=globalThis[n],t=e.prototype,i=n in ri?ri[n]:void 0,r=!!(i&&i.every(o=>{var c,l;return!!((l=(c=Object.getOwnPropertyDescriptor(t,o))==null?void 0:c.get)!=null&&l.toString().includes("[native code]"))})),s=n in ni?ni[n]:void 0,a=!!(s&&s.every(o=>{var c;return typeof t[o]=="function"&&((c=t[o])==null?void 0:c.toString().includes("[native code]"))}));if(r&&a&&!Zr())return Ee[n]=e.prototype,e.prototype;try{let o=document.createElement("iframe");document.body.appendChild(o);let c=o.contentWindow;if(!c)return e.prototype;let l=c[n].prototype;return document.body.removeChild(o),l?Ee[n]=l:t}catch{return t}}function N(n,e,t){var i;let r=`${n}.${String(t)}`;if(nt[r])return nt[r].call(e);let s=kt(n),a=(i=Object.getOwnPropertyDescriptor(s,t))==null?void 0:i.get;return a?(nt[r]=a,a.call(e)):e[t]}function ki(n,e,t){let i=`${n}.${String(t)}`;if(st[i])return st[i].bind(e);let s=kt(n)[t];return typeof s!="function"?e[t]:(st[i]=s,s.bind(e))}function en(n){return N("Node",n,"childNodes")}function tn(n){return N("Node",n,"parentNode")}function rn(n){return N("Node",n,"parentElement")}function nn(n){return N("Node",n,"textContent")}function sn(n,e){return ki("Node",n,"contains")(e)}function an(n){return ki("Node",n,"getRootNode")()}function on(n){return!n||!("host"in n)?null:N("ShadowRoot",n,"host")}function cn(n){return n.styleSheets}function ln(n){return!n||!("shadowRoot"in n)?null:N("Element",n,"shadowRoot")}function un(n,e){return N("Element",n,"querySelector")(e)}function hn(n,e){return N("Element",n,"querySelectorAll")(e)}function dn(){return kt("MutationObserver").constructor}function ze(n){return n.nodeType===n.ELEMENT_NODE}function xi(n){let e=n&&"host"in n&&"mode"in n&&k.host(n)||null;return!!(e&&"shadowRoot"in e&&k.shadowRoot(e)===n)}function De(n){return Object.prototype.toString.call(n)==="[object ShadowRoot]"}function fn(n){return n.includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),n}function Mi(n){let{cssText:e}=n;if(e.split('"').length<3)return e;let t=["@import",`url(${JSON.stringify(n.href)})`];return n.layerName===""?t.push("layer"):n.layerName&&t.push(`layer(${n.layerName})`),n.supportsText&&t.push(`supports(${n.supportsText})`),n.media.length&&t.push(n.media.mediaText),t.join(" ")+";"}function Ne(n){try{let e=n.rules||n.cssRules;if(!e)return null;let t=n.href;!t&&n.ownerNode&&n.ownerNode.ownerDocument&&(t=n.ownerNode.ownerDocument.location.href);let i=Array.from(e,r=>Pi(r,t)).join("");return fn(i)}catch{return null}}function Pi(n,e){if(_i(n)){let t;try{t=Ne(n.styleSheet)||Mi(n)}catch{t=n.cssText}return n.styleSheet.href?ae(t,n.styleSheet.href):t}else{let t=n.cssText;return Ri(n)&&n.selectorText.includes(":")&&(t=Ii(t)),e?ae(t,e):t}}function Ii(n){let e=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return n.replace(e,"$1\\$2")}function _i(n){return"styleSheet"in n}function Ri(n){return"selectorText"in n}function pn(){return new J}function Di({element:n,maskInputOptions:e,tagName:t,type:i,value:r,maskInputFn:s}){let a=r||"",o=i&&he(i);return(e[t.toLowerCase()]||o&&e[o])&&(s?a=s(a,n):a="*".repeat(a.length)),a}function he(n){return n.toLowerCase()}function Li(n){let e=n.getContext("2d");if(!e)return!0;let t=50;for(let i=0;i<n.width;i+=t)for(let r=0;r<n.height;r+=t){let s=e.getImageData,a=si in s?s[si]:s;if(new Uint32Array(a.call(e,i,r,Math.min(t,n.width-i),Math.min(t,n.height-r)).data.buffer).some(c=>c!==0))return!1}return!0}function Oi(n,e){return!n||!e||n.type!==e.type?!1:n.type===m.Document?n.compatMode===e.compatMode:n.type===m.DocumentType?n.name===e.name&&n.publicId===e.publicId&&n.systemId===e.systemId:n.type===m.Comment||n.type===m.Text||n.type===m.CDATA?n.textContent===e.textContent:n.type===m.Element?n.tagName===e.tagName&&JSON.stringify(n.attributes)===JSON.stringify(e.attributes)&&n.isSVG===e.isSVG&&n.needBlock===e.needBlock:!1}function Ui(n){let e=n.type;return n.hasAttribute("data-rr-is-password")?"password":e?he(e):null}function xt(n,e){let t;try{t=new URL(n,e??window.location.href)}catch{return null}let i=/\.([0-9a-z]+)(?:$)/i,r=t.pathname.match(i);return r?.[1]??null}function gn(n){let e="";return n.indexOf("//")>-1?e=n.split("/").slice(0,3).join("/"):e=n.split("/")[0],e=e.split("?")[0],e}function ae(n,e){return(n||"").replace(mn,(t,i,r,s,a,o)=>{let c=r||a||o,l=i||s||"";if(!c)return t;if(yn.test(c)||vn.test(c))return`url(${l}${c}${l})`;if(bn.test(c))return`url(${l}${c}${l})`;if(c[0]==="/")return`url(${l}${gn(e)+c}${l})`;let u=e.split("/"),d=c.split("/");u.pop();for(let f of d)f!=="."&&(f===".."?u.pop():u.push(f));return`url(${l}${u.join("/")}${l})`})}function Le(n){return n.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"")}function Ni(n,e){let t=Array.from(e.childNodes),i=[];if(t.length>1&&n&&typeof n=="string"){let r=Le(n);for(let s=1;s<t.length;s++)if(t[s].textContent&&typeof t[s].textContent=="string"){let a=Le(t[s].textContent);for(let o=3;o<a.length;o++){let c=a.substring(0,o);if(r.split(c).length===2){let l=r.indexOf(c);for(let u=l;u<n.length;u++)if(Le(n.substring(0,u)).length===l){i.push(n.substring(0,u)),n=n.substring(u);break}break}}}}return i.push(n),i}function $i(n,e){return Ni(n,e).join("/* rr_split */")}function Bi(){return Hi++}function Sn(n){if(n instanceof HTMLFormElement)return"form";let e=he(n.tagName);return wn.test(e)?"div":e}function Cn(n,e){if(e.trim()==="")return e;let t=0;function i(s){let a,o=s.exec(e.substring(t));return o?(a=o[0],t+=a.length,a):""}let r=[];for(;i(En),!(t>=e.length);){let s=i(An);if(s.slice(-1)===",")s=Q(n,s.substring(0,s.length-1)),r.push(s);else{let a="";s=Q(n,s);let o=!1;for(;;){let c=e.charAt(t);if(c===""){r.push((s+a).trim());break}else if(o)c===")"&&(o=!1);else if(c===","){t+=1,r.push((s+a).trim());break}else c==="("&&(o=!0);a+=c,t+=1}}}return r.join(", ")}function Q(n,e){return!e||e.trim()===""?e:Mt(n,e)}function Tn(n){return!!(n.tagName==="svg"||n.ownerSVGElement)}function Mt(n,e){let t=oi.get(n);if(t||(t=n.createElement("a"),oi.set(n,t)),!e)e="";else if(e.startsWith("blob:")||e.startsWith("data:"))return e;return t.setAttribute("href",e),t.href}function Fi(n,e,t,i){return i&&(t==="src"||t==="href"&&!(e==="use"&&i[0]==="#")||t==="xlink:href"&&i[0]!=="#"||t==="background"&&(e==="table"||e==="td"||e==="th")?Q(n,i):t==="srcset"?Cn(n,i):t==="style"?ae(i,Mt(n)):e==="object"&&t==="data"?Q(n,i):i)}function Gi(n,e,t){return(n==="video"||n==="audio")&&e==="autoplay"}function kn(n,e,t){try{if(typeof e=="string"){if(n.classList.contains(e))return!0}else for(let i=n.classList.length;i--;){let r=n.classList[i];if(e.test(r))return!0}if(t)return n.matches(t)}catch{}return!1}function $e(n,e,t){if(!n)return!1;if(n.nodeType!==n.ELEMENT_NODE)return t?$e(k.parentNode(n),e,t):!1;for(let i=n.classList.length;i--;){let r=n.classList[i];if(e.test(r))return!0}return t?$e(k.parentNode(n),e,t):!1}function zi(n,e,t,i){let r;if(ze(n)){if(r=n,!k.childNodes(r).length)return!1}else{if(k.parentElement(n)===null)return!1;r=k.parentElement(n)}try{if(typeof e=="string"){if(i){if(r.closest(`.${e}`))return!0}else if(r.classList.contains(e))return!0}else if($e(r,e,i))return!0;if(t){if(i){if(r.closest(t))return!0}else if(r.matches(t))return!0}}catch{}return!1}function xn(n,e,t){let i=n.contentWindow;if(!i)return;let r=!1,s;try{s=i.document.readyState}catch{return}if(s!=="complete"){let o=setTimeout(()=>{r||(e(),r=!0)},t);n.addEventListener("load",()=>{clearTimeout(o),r=!0,e()});return}let a="about:blank";if(i.location.href!==a||n.src===a||n.src==="")return setTimeout(e,0),n.addEventListener("load",e);n.addEventListener("load",e)}function Mn(n,e,t){let i=!1,r;try{r=n.sheet}catch{return}if(r)return;let s=setTimeout(()=>{i||(e(),i=!0)},t);n.addEventListener("load",()=>{clearTimeout(s),i=!0,e()})}function Pn(n,e){let{doc:t,mirror:i,blockClass:r,blockSelector:s,needsMask:a,inlineStylesheet:o,maskInputOptions:c={},maskTextFn:l,maskInputFn:u,dataURLOptions:d={},inlineImages:f,recordCanvas:y,keepIframeSrcFn:g,newlyAddedElement:v=!1,cssCaptured:h=!1}=e,T=In(t,i);switch(n.nodeType){case n.DOCUMENT_NODE:return n.compatMode!=="CSS1Compat"?{type:m.Document,childNodes:[],compatMode:n.compatMode}:{type:m.Document,childNodes:[]};case n.DOCUMENT_TYPE_NODE:return{type:m.DocumentType,name:n.name,publicId:n.publicId,systemId:n.systemId,rootId:T};case n.ELEMENT_NODE:return Rn(n,{doc:t,blockClass:r,blockSelector:s,inlineStylesheet:o,maskInputOptions:c,maskInputFn:u,dataURLOptions:d,inlineImages:f,recordCanvas:y,keepIframeSrcFn:g,newlyAddedElement:v,rootId:T});case n.TEXT_NODE:return _n(n,{doc:t,needsMask:a,maskTextFn:l,rootId:T,cssCaptured:h});case n.CDATA_SECTION_NODE:return{type:m.CDATA,textContent:"",rootId:T};case n.COMMENT_NODE:return{type:m.Comment,textContent:k.textContent(n)||"",rootId:T};default:return!1}}function In(n,e){if(!e.hasNode(n))return;let t=e.getId(n);return t===1?void 0:t}function _n(n,e){let{needsMask:t,maskTextFn:i,rootId:r,cssCaptured:s}=e,a=k.parentNode(n),o=a&&a.tagName,c="",l=o==="STYLE"?!0:void 0,u=o==="SCRIPT"?!0:void 0;return u?c="SCRIPT_PLACEHOLDER":s||(c=k.textContent(n),l&&c&&(c=ae(c,Mt(e.doc)))),!l&&!u&&c&&t&&(c=i?i(c,k.parentElement(n)):c.replace(/[\S]/g,"*")),{type:m.Text,textContent:c||"",rootId:r}}function Rn(n,e){let{doc:t,blockClass:i,blockSelector:r,inlineStylesheet:s,maskInputOptions:a={},maskInputFn:o,dataURLOptions:c={},inlineImages:l,recordCanvas:u,keepIframeSrcFn:d,newlyAddedElement:f=!1,rootId:y}=e,g=kn(n,i,r),v=Sn(n),h={},T=n.attributes.length;for(let p=0;p<T;p++){let b=n.attributes[p];Gi(v,b.name,b.value)||(h[b.name]=Fi(t,v,he(b.name),b.value))}if(v==="link"&&s){let p=Array.from(t.styleSheets).find(M=>M.href===n.href),b=null;p&&(b=Ne(p)),b&&(delete h.rel,delete h.href,h._cssText=b)}if(v==="style"&&n.sheet){let p=Ne(n.sheet);p&&(n.childNodes.length>1&&(p=$i(p,n)),h._cssText=p)}if(v==="input"||v==="textarea"||v==="select"){let p=n.value,b=n.checked;h.type!=="radio"&&h.type!=="checkbox"&&h.type!=="submit"&&h.type!=="button"&&p?h.value=Di({element:n,type:Ui(n),tagName:v,value:p,maskInputOptions:a,maskInputFn:o}):b&&(h.checked=b)}if(v==="option"&&(n.selected&&!a.select?h.selected=!0:delete h.selected),v==="dialog"&&n.open&&(h.rr_open_mode=n.matches("dialog:modal")?"modal":"non-modal"),v==="canvas"&&u){if(n.__context==="2d")Li(n)||(h.rr_dataURL=n.toDataURL(c.type,c.quality));else if(!("__context"in n)){let p=n.toDataURL(c.type,c.quality),b=t.createElement("canvas");b.width=n.width,b.height=n.height;let M=b.toDataURL(c.type,c.quality);p!==M&&(h.rr_dataURL=p)}}if(v==="img"&&l){j||(j=t.createElement("canvas"),ai=j.getContext("2d"));let p=n,b=p.currentSrc||p.getAttribute("src")||"<unknown-src>",M=p.crossOrigin,I=()=>{p.removeEventListener("load",I);try{j.width=p.naturalWidth,j.height=p.naturalHeight,ai.drawImage(p,0,0),h.rr_dataURL=j.toDataURL(c.type,c.quality)}catch(B){if(p.crossOrigin!=="anonymous"){p.crossOrigin="anonymous",p.complete&&p.naturalWidth!==0?I():p.addEventListener("load",I);return}else console.warn(`Cannot inline img src=${b}! Error: ${B}`)}p.crossOrigin==="anonymous"&&(M?h.crossOrigin=M:p.removeAttribute("crossorigin"))};p.complete&&p.naturalWidth!==0?I():p.addEventListener("load",I)}if(v==="audio"||v==="video"){let p=h;p.rr_mediaState=n.paused?"paused":"played",p.rr_mediaCurrentTime=n.currentTime,p.rr_mediaPlaybackRate=n.playbackRate,p.rr_mediaMuted=n.muted,p.rr_mediaLoop=n.loop,p.rr_mediaVolume=n.volume}if(f||(n.scrollLeft&&(h.rr_scrollLeft=n.scrollLeft),n.scrollTop&&(h.rr_scrollTop=n.scrollTop)),g){let{width:p,height:b}=n.getBoundingClientRect();h={class:h.class,rr_width:`${p}px`,rr_height:`${b}px`}}v==="iframe"&&!d(h.src)&&(n.contentDocument||(h.rr_src=h.src),delete h.src);let x;try{customElements.get(v)&&(x=!0)}catch{}return{type:m.Element,tagName:v,attributes:h,childNodes:[],isSVG:Tn(n)||void 0,needBlock:g,rootId:y,isCustom:x}}function A(n){return n==null?"":n.toLowerCase()}function Dn(n,e){if(e.comment&&n.type===m.Comment)return!0;if(n.type===m.Element){if(e.script&&(n.tagName==="script"||n.tagName==="link"&&(n.attributes.rel==="preload"||n.attributes.rel==="modulepreload")&&n.attributes.as==="script"||n.tagName==="link"&&n.attributes.rel==="prefetch"&&typeof n.attributes.href=="string"&&xt(n.attributes.href)==="js"))return!0;if(e.headFavicon&&(n.tagName==="link"&&n.attributes.rel==="shortcut icon"||n.tagName==="meta"&&(A(n.attributes.name).match(/^msapplication-tile(image|color)$/)||A(n.attributes.name)==="application-name"||A(n.attributes.rel)==="icon"||A(n.attributes.rel)==="apple-touch-icon"||A(n.attributes.rel)==="shortcut icon")))return!0;if(n.tagName==="meta"){if(e.headMetaDescKeywords&&A(n.attributes.name).match(/^description|keywords$/))return!0;if(e.headMetaSocial&&(A(n.attributes.property).match(/^(og|twitter|fb):/)||A(n.attributes.name).match(/^(og|twitter):/)||A(n.attributes.name)==="pinterest"))return!0;if(e.headMetaRobots&&(A(n.attributes.name)==="robots"||A(n.attributes.name)==="googlebot"||A(n.attributes.name)==="bingbot"))return!0;if(e.headMetaHttpEquiv&&n.attributes["http-equiv"]!==void 0)return!0;if(e.headMetaAuthorship&&(A(n.attributes.name)==="author"||A(n.attributes.name)==="generator"||A(n.attributes.name)==="framework"||A(n.attributes.name)==="publisher"||A(n.attributes.name)==="progid"||A(n.attributes.property).match(/^article:/)||A(n.attributes.property).match(/^product:/)))return!0;if(e.headMetaVerification&&(A(n.attributes.name)==="google-site-verification"||A(n.attributes.name)==="yandex-verification"||A(n.attributes.name)==="csrf-token"||A(n.attributes.name)==="p:domain_verify"||A(n.attributes.name)==="verify-v1"||A(n.attributes.name)==="verification"||A(n.attributes.name)==="shopify-checkout-api-token"))return!0}}return!1}function Y(n,e){let{doc:t,mirror:i,blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:o,skipChild:c=!1,inlineStylesheet:l=!0,maskInputOptions:u={},maskTextFn:d,maskInputFn:f,slimDOMOptions:y,dataURLOptions:g={},inlineImages:v=!1,recordCanvas:h=!1,onSerialize:T,onIframeLoad:x,iframeLoadTimeout:p=5e3,onStylesheetLoad:b,stylesheetLoadTimeout:M=5e3,keepIframeSrcFn:I=()=>!1,newlyAddedElement:B=!1,cssCaptured:O=!1}=e,{needsMask:_}=e,{preserveWhiteSpace:U=!0}=e;_||(_=zi(n,a,o,_===void 0));let te=Pn(n,{doc:t,mirror:i,blockClass:r,blockSelector:s,needsMask:_,inlineStylesheet:l,maskInputOptions:u,maskTextFn:d,maskInputFn:f,dataURLOptions:g,inlineImages:v,recordCanvas:h,keepIframeSrcFn:I,newlyAddedElement:B,cssCaptured:O});if(!te)return console.warn(n,"not serialized"),null;let ie;i.hasNode(n)?ie=i.getId(n):Dn(te,y)||!U&&te.type===m.Text&&!te.textContent.replace(/^\s+|\s+$/gm,"").length?ie=ut:ie=Bi();let S=Object.assign(te,{id:ie});if(i.add(n,S),ie===ut)return null;T&&T(n);let Je=!c;if(S.type===m.Element){Je=Je&&!S.needBlock,delete S.needBlock;let P=k.shadowRoot(n);P&&De(P)&&(S.isShadowHost=!0)}if((S.type===m.Document||S.type===m.Element)&&Je){y.headWhitespace&&S.type===m.Element&&S.tagName==="head"&&(U=!1);let P={doc:t,mirror:i,blockClass:r,blockSelector:s,needsMask:_,maskTextClass:a,maskTextSelector:o,skipChild:c,inlineStylesheet:l,maskInputOptions:u,maskTextFn:d,maskInputFn:f,slimDOMOptions:y,dataURLOptions:g,inlineImages:v,recordCanvas:h,preserveWhiteSpace:U,onSerialize:T,onIframeLoad:x,iframeLoadTimeout:p,onStylesheetLoad:b,stylesheetLoadTimeout:M,keepIframeSrcFn:I,cssCaptured:!1};if(!(S.type===m.Element&&S.tagName==="textarea"&&S.attributes.value!==void 0)){S.type===m.Element&&S.attributes._cssText!==void 0&&typeof S.attributes._cssText=="string"&&(P.cssCaptured=!0);for(let Xe of Array.from(k.childNodes(n))){let G=Y(Xe,P);G&&S.childNodes.push(G)}}let F=null;if(ze(n)&&(F=k.shadowRoot(n)))for(let Xe of Array.from(k.childNodes(F))){let G=Y(Xe,P);G&&(De(F)&&(G.isShadow=!0),S.childNodes.push(G))}}let qe=k.parentNode(n);return qe&&xi(qe)&&De(qe)&&(S.isShadow=!0),S.type===m.Element&&S.tagName==="iframe"&&xn(n,()=>{let P=n.contentDocument;if(P&&x){let F=Y(P,{doc:P,mirror:i,blockClass:r,blockSelector:s,needsMask:_,maskTextClass:a,maskTextSelector:o,skipChild:!1,inlineStylesheet:l,maskInputOptions:u,maskTextFn:d,maskInputFn:f,slimDOMOptions:y,dataURLOptions:g,inlineImages:v,recordCanvas:h,preserveWhiteSpace:U,onSerialize:T,onIframeLoad:x,iframeLoadTimeout:p,onStylesheetLoad:b,stylesheetLoadTimeout:M,keepIframeSrcFn:I});F&&x(n,F)}},p),S.type===m.Element&&S.tagName==="link"&&typeof S.attributes.rel=="string"&&(S.attributes.rel==="stylesheet"||S.attributes.rel==="preload"&&typeof S.attributes.href=="string"&&xt(S.attributes.href)==="css")&&Mn(n,()=>{if(b){let P=Y(n,{doc:t,mirror:i,blockClass:r,blockSelector:s,needsMask:_,maskTextClass:a,maskTextSelector:o,skipChild:!1,inlineStylesheet:l,maskInputOptions:u,maskTextFn:d,maskInputFn:f,slimDOMOptions:y,dataURLOptions:g,inlineImages:v,recordCanvas:h,preserveWhiteSpace:U,onSerialize:T,onIframeLoad:x,iframeLoadTimeout:p,onStylesheetLoad:b,stylesheetLoadTimeout:M,keepIframeSrcFn:I});P&&b(n,P)}},M),S}function Ln(n,e){let{mirror:t=new J,blockClass:i="rr-block",blockSelector:r=null,maskTextClass:s="rr-mask",maskTextSelector:a=null,inlineStylesheet:o=!0,inlineImages:c=!1,recordCanvas:l=!1,maskAllInputs:u=!1,maskTextFn:d,maskInputFn:f,slimDOM:y=!1,dataURLOptions:g,preserveWhiteSpace:v,onSerialize:h,onIframeLoad:T,iframeLoadTimeout:x,onStylesheetLoad:p,stylesheetLoadTimeout:b,keepIframeSrcFn:M=()=>!1}=e||{};return Y(n,{doc:n,mirror:t,blockClass:i,blockSelector:r,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:o,maskInputOptions:u===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:u===!1?{password:!0}:u,maskTextFn:d,maskInputFn:f,slimDOMOptions:y===!0||y==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:y==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:y===!1?{}:y,dataURLOptions:g,inlineImages:c,recordCanvas:l,preserveWhiteSpace:v,onSerialize:h,onIframeLoad:T,iframeLoadTimeout:x,onStylesheetLoad:p,stylesheetLoadTimeout:b,keepIframeSrcFn:M,newlyAddedElement:!1})}function On(n,e){function t(i){e(i),(i.type===m.Document||i.type===m.Element)&&i.childNodes.forEach(t)}t(n)}function Un(){Hi=1}function Bn(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Fn(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),t}function Kn(n){return n[0].toUpperCase()+n.slice(1)}function ft(n,e){new Wn(e).stringify(n)}function pt(n,e){let t=new n.constructor;for(let i in n){if(!Object.prototype.hasOwnProperty.call(n,i)||i==="proxyCache")continue;let r=n[i],s=typeof r;i==="parent"&&s==="object"?e&&(t[i]=e):i==="source"?t[i]=r:Array.isArray(r)?t[i]=r.map(a=>pt(a,t)):(s==="object"&&r!==null&&(r=pt(r)),t[i]=r)}return t}function ss(n){return Buffer?Buffer.from(n,"base64").toString():window.atob(n)}function sr(n){return n.map(e=>(e.nodes&&(e.nodes=sr(e.nodes)),delete e.source,e))}function ar(n){if(n[Zi]=!1,n.proxyOf.nodes)for(let e of n.proxyOf.nodes)ar(e)}function Ns(n){for(let e=n.length-1;e>=0;e--){let t=n[e],i=t[3]||t[2];if(i)return i}}function Ge(n,e){let t=new Gs(n,e),i=new Fs(t);try{i.parse()}catch(r){throw r}return i.root}function se(n){return typeof n=="object"&&typeof n.then=="function"}function yr(n){let e=!1,t=Js[n.type];return n.type==="decl"?e=n.prop.toLowerCase():n.type==="atrule"&&(e=n.name.toLowerCase()),e&&n.append?[t,t+"-"+e,X,t+"Exit",t+"Exit-"+e]:e?[t,t+"-"+e,t+"Exit",t+"Exit-"+e]:n.append?[t,X,t+"Exit"]:[t,t+"Exit"]}function Ci(n){let e;return n.type==="document"?e=["Document",X,"DocumentExit"]:n.type==="root"?e=["Root",X,"RootExit"]:e=yr(n),{eventIndex:0,events:e,iterator:0,node:n,visitorIndex:0,visitors:[]}}function Et(n){return n[D]=!1,n.nodes&&n.nodes.forEach(e=>Et(e)),n}function ue(n,e){if(Array.isArray(n))return n.map(r=>ue(r));let{inputs:t,...i}=n;if(t){e=[];for(let r of t){let s={...r,__proto__:fa.prototype};s.map&&(s.map={...s.map,__proto__:ua.prototype}),e.push(s)}}if(i.nodes&&(i.nodes=n.nodes.map(r=>ue(r,e))),i.source){let{inputId:r,...s}=i.source;i.source=s,r!=null&&(i.source.input=e[r])}if(i.type==="root")return new pa(i);if(i.type==="decl")return new la(i);if(i.type==="rule")return new ga(i);if(i.type==="comment")return new ha(i);if(i.type==="atrule")return new da(i);throw new Error("Unknown node type: "+n.type)}function w(...n){return n.length===1&&Array.isArray(n[0])&&(n=n[0]),new $t(n)}function Pa(n){let e=Ti[n.tagName]?Ti[n.tagName]:n.tagName;return e==="link"&&n.attributes._cssText&&(e="style"),e}function Ye(n,e){let t=e?.stylesWithHoverClass.get(n);if(t)return t;let r=C([$n,Hn]).process(n).css;return e?.stylesWithHoverClass.set(n,r),r}function Ia(){return{stylesWithHoverClass:new Map}}function _a(n,e,t,i){let r=[];for(let a of n.childNodes)a.type===m.Text&&r.push(a);let s=e.split("/* rr_split */");for(;s.length>1&&s.length>r.length;)s.splice(-2,2,s.slice(-2).join(""));for(let a=0;a<r.length;a++){let o=r[a],c=s[a];o&&c&&(o.textContent=t?Ye(c,i):c)}}function Ra(n,e,t,i){let{doc:r,hackCss:s,cache:a}=i;n.childNodes.length?_a(n,t,s,a):(s&&(t=Ye(t,a)),e.appendChild(r.createTextNode(t)))}function Da(n,e){var t;let{doc:i,hackCss:r,cache:s}=e;switch(n.type){case m.Document:return i.implementation.createDocument(null,"",null);case m.DocumentType:return i.implementation.createDocumentType(n.name||"html",n.publicId,n.systemId);case m.Element:{let a=Pa(n),o;n.isSVG?o=i.createElementNS("http://www.w3.org/2000/svg",a):(n.isCustom&&((t=i.defaultView)!=null&&t.customElements)&&!i.defaultView.customElements.get(n.tagName)&&i.defaultView.customElements.define(n.tagName,class extends i.defaultView.HTMLElement{}),o=i.createElement(a));let c={};for(let l in n.attributes){if(!Object.prototype.hasOwnProperty.call(n.attributes,l))continue;let u=n.attributes[l];if(!(a==="option"&&l==="selected"&&u===!1)&&u!==null){if(u===!0&&(u=""),l.startsWith("rr_")){c[l]=u;continue}if(typeof u=="string"){if(a==="style"&&l==="_cssText"){Ra(n,o,u,e);continue}else if(a==="textarea"&&l==="value"){o.appendChild(i.createTextNode(u)),n.childNodes=[];continue}}try{if(n.isSVG&&l==="xlink:href")o.setAttributeNS("http://www.w3.org/1999/xlink",l,u.toString());else if(l==="onload"||l==="onclick"||l.substring(0,7)==="onmouse")o.setAttribute("_"+l,u.toString());else if(a==="meta"&&n.attributes["http-equiv"]==="Content-Security-Policy"&&l==="content"){o.setAttribute("csp-content",u.toString());continue}else a==="link"&&(n.attributes.rel==="preload"||n.attributes.rel==="modulepreload")&&n.attributes.as==="script"||a==="link"&&n.attributes.rel==="prefetch"&&typeof n.attributes.href=="string"&&n.attributes.href.endsWith(".js")||(a==="img"&&n.attributes.srcset&&n.attributes.rr_dataURL?o.setAttribute("rrweb-original-srcset",n.attributes.srcset):o.setAttribute(l,u.toString()))}catch{}}}for(let l in c){let u=c[l];if(a==="canvas"&&l==="rr_dataURL"){let d=i.createElement("img");d.onload=()=>{let f=o.getContext("2d");f&&f.drawImage(d,0,0,d.width,d.height)},d.src=u.toString(),o.RRNodeType&&(o.rr_dataURL=u.toString())}else if(a==="img"&&l==="rr_dataURL"){let d=o;d.currentSrc.startsWith("data:")||(d.setAttribute("rrweb-original-src",n.attributes.src),d.src=u.toString())}if(l==="rr_width")o.style.setProperty("width",u.toString());else if(l==="rr_height")o.style.setProperty("height",u.toString());else if(l==="rr_mediaCurrentTime"&&typeof u=="number")o.currentTime=u;else if(l==="rr_mediaState")switch(u){case"played":o.play().catch(d=>console.warn("media playback error",d));break;case"paused":o.pause();break}else l==="rr_mediaPlaybackRate"&&typeof u=="number"?o.playbackRate=u:l==="rr_mediaMuted"&&typeof u=="boolean"?o.muted=u:l==="rr_mediaLoop"&&typeof u=="boolean"?o.loop=u:l==="rr_mediaVolume"&&typeof u=="number"?o.volume=u:l==="rr_open_mode"&&o.setAttribute("rr_open_mode",u)}if(n.isShadowHost)if(!o.shadowRoot)o.attachShadow({mode:"open"});else for(;o.shadowRoot.firstChild;)o.shadowRoot.removeChild(o.shadowRoot.firstChild);return o}case m.Text:return n.isStyle&&r?i.createTextNode(Ye(n.textContent,s)):i.createTextNode(n.textContent);case m.CDATA:return i.createCDATASection(n.textContent);case m.Comment:return i.createComment(n.textContent);default:return null}}function Ht(n,e){let{doc:t,mirror:i,skipChild:r=!1,hackCss:s=!0,afterAppend:a,cache:o}=e;if(i.has(n.id)){let l=i.getNode(n.id),u=i.getMeta(l);if(Oi(u,n))return i.getNode(n.id)}let c=Da(n,{doc:t,hackCss:s,cache:o});if(!c)return null;if(n.rootId&&i.getNode(n.rootId)!==t&&i.replace(n.rootId,t),n.type===m.Document&&(t.close(),t.open(),n.compatMode==="BackCompat"&&n.childNodes&&n.childNodes[0].type!==m.DocumentType&&(n.childNodes[0].type===m.Element&&"xmlns"in n.childNodes[0].attributes&&n.childNodes[0].attributes.xmlns==="http://www.w3.org/1999/xhtml"?t.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'):t.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">')),c=t),i.add(c,n),(n.type===m.Document||n.type===m.Element)&&!r)for(let l of n.childNodes){let u=Ht(l,{doc:t,mirror:i,skipChild:!1,hackCss:s,afterAppend:a,cache:o});if(!u){console.warn("Failed to rebuild",l);continue}if(l.isShadow&&ze(c)&&c.shadowRoot)c.shadowRoot.appendChild(u);else if(n.type===m.Document&&l.type==m.Element){let d=u,f=null;d.childNodes.forEach(y=>{y.nodeName==="BODY"&&(f=y)}),f?(d.removeChild(f),c.appendChild(u),d.appendChild(f)):c.appendChild(u)}else c.appendChild(u);a&&a(u,l.id)}return c}function La(n,e){function t(i){e(i)}for(let i of n.getIds())n.has(i)&&t(n.getNode(i))}function Oa(n,e){let t=e.getMeta(n);if(t?.type!==m.Element)return;let i=n;for(let r in t.attributes){if(!(Object.prototype.hasOwnProperty.call(t.attributes,r)&&r.startsWith("rr_")))continue;let s=t.attributes[r];r==="rr_scrollLeft"&&(i.scrollLeft=s),r==="rr_scrollTop"&&(i.scrollTop=s)}}function Ua(n,e){let{doc:t,onVisit:i,hackCss:r=!0,afterAppend:s,cache:a,mirror:o=new J}=e,c=Ht(n,{doc:t,mirror:o,skipChild:!1,hackCss:r,afterAppend:s,cache:a});return La(o,l=>{i&&i(l),Oa(l,o)}),c}var qr,Xr,ii,m,ri,ni,Ee,Zr,nt,st,k,J,si,mn,yn,vn,bn,Hi,wn,ut,j,ai,An,En,oi,Nn,ci,$n,Hn,Pt,E,Vi,Gn,zn,Vn,R,li,ui,ht,It,de,hi,dt,Wi,Wn,Ve,Ce,jn,Qn,Yn,Jn,gt,Ke,qn,mt,We,Xn,Zn,es,ts,di,fi,is,rs,at,ns,yt,ji,as,os,pi,Te,vt,bt,cs,ot,gi,ls,ct,us,mi,He,je,Qi,Oe,Ue,Yi,Ji,qi,yi,hs,ds,fs,ps,Xi,gs,wt,Qe,Zi,er,tr,ir,ms,rr,_t,Rt,nr,L,H,ys,cr,lr,oe,Dt,St,ur,vs,At,Lt,lt,vi,ke,bi,xe,ne,Me,Pe,Ie,bs,ws,Ss,As,Es,Cs,Ts,ks,xs,Ms,_e,Re,Ps,wi,Is,hr,Be,Ot,dr,fr,pr,q,fe,ce,gr,mr,_s,Fe,Ut,Rs,Ds,Ls,Os,Us,Si,Ai,$s,Hs,Bs,Fs,Gs,Nt,D,zs,Vs,Ks,Ws,js,Ei,Qs,Ys,Js,qs,Xs,X,Ct,Z,br,Zs,ea,ta,ia,Tt,ra,na,sa,aa,oa,le,ca,la,ua,ha,da,fa,pa,ga,ma,ya,wr,va,ba,$t,wa,Sa,Sr,Aa,Ar,Er,Ea,Ca,Ta,ka,Cr,Tr,xa,Ma,C,Ti,xr=$(()=>{qr=Object.defineProperty,Xr=(n,e,t)=>e in n?qr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ii=(n,e,t)=>Xr(n,typeof e!="symbol"?e+"":e,t),m=(n=>(n[n.Document=0]="Document",n[n.DocumentType=1]="DocumentType",n[n.Element=2]="Element",n[n.Text=3]="Text",n[n.CDATA=4]="CDATA",n[n.Comment=5]="Comment",n))(m||{}),ri={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},ni={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},Ee={},Zr=()=>!!globalThis.Zone;nt={};st={};k={childNodes:en,parentNode:tn,parentElement:rn,textContent:nn,contains:sn,getRootNode:an,host:on,styleSheets:cn,shadowRoot:ln,querySelector:un,querySelectorAll:hn,mutationObserver:dn};J=class{constructor(){ii(this,"idNodeMap",new Map),ii(this,"nodeMetaMap",new WeakMap)}getId(e){var t;return e?((t=this.getMeta(e))==null?void 0:t.id)??-1:-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){let t=this.getId(e);this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(i=>this.removeNodeFromMap(i))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){let i=t.id;this.idNodeMap.set(i,e),this.nodeMetaMap.set(e,t)}replace(e,t){let i=this.getNode(e);if(i){let r=this.nodeMetaMap.get(i);r&&this.nodeMetaMap.set(t,r)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}};si="__rrweb_original__";mn=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,yn=/^(?:[a-z+]+:)?\/\//i,vn=/^www\..*/i,bn=/^(data:)([^,]*),(.*)/i;Hi=1,wn=new RegExp("[^a-z0-9-_:]"),ut=-2;An=/^[^ \t\n\r\u000c]+/,En=/^[, \t\n\r\u000c]+/;oi=new WeakMap;Nn=/(max|min)-device-(width|height)/,ci=new RegExp(Nn.source,"g"),$n={postcssPlugin:"postcss-custom-selectors",prepare(){return{postcssPlugin:"postcss-custom-selectors",AtRule:function(n){n.params.match(ci)&&(n.params=n.params.replace(ci,"$1-$2"))}}}},Hn={postcssPlugin:"postcss-hover-classes",prepare:function(){let n=[];return{Rule:function(e){n.indexOf(e)===-1&&(n.push(e),e.selectors.forEach(function(t){t.includes(":hover")&&(e.selector+=`,
3
3
  `+t.replace(/:hover/g,".\\:hover"))}))}}}};Pt={exports:{}},E=String,Vi=function(){return{isColorSupported:!1,reset:E,bold:E,dim:E,italic:E,underline:E,inverse:E,hidden:E,strikethrough:E,black:E,red:E,green:E,yellow:E,blue:E,magenta:E,cyan:E,white:E,gray:E,bgBlack:E,bgRed:E,bgGreen:E,bgYellow:E,bgBlue:E,bgMagenta:E,bgCyan:E,bgWhite:E}};Pt.exports=Vi();Pt.exports.createColors=Vi;Gn=Pt.exports,zn={},Vn=Object.freeze(Object.defineProperty({__proto__:null,default:zn},Symbol.toStringTag,{value:"Module"})),R=Fn(Vn),li=Gn,ui=R,ht=class Ki extends Error{constructor(e,t,i,r,s,a){super(e),this.name="CssSyntaxError",this.reason=e,s&&(this.file=s),r&&(this.source=r),a&&(this.plugin=a),typeof t<"u"&&typeof i<"u"&&(typeof t=="number"?(this.line=t,this.column=i):(this.line=t.line,this.column=t.column,this.endLine=i.line,this.endColumn=i.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,Ki)}setMessage(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",typeof this.line<"u"&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason}showSourceCode(e){if(!this.source)return"";let t=this.source;e==null&&(e=li.isColorSupported),ui&&e&&(t=ui(t));let i=t.split(/\r?\n/),r=Math.max(this.line-3,0),s=Math.min(this.line+2,i.length),a=String(s).length,o,c;if(e){let{bold:l,gray:u,red:d}=li.createColors(!0);o=f=>l(d(f)),c=f=>u(f)}else o=c=l=>l;return i.slice(r,s).map((l,u)=>{let d=r+1+u,f=" "+(" "+d).slice(-a)+" | ";if(d===this.line){let y=c(f.replace(/\d/g," "))+l.slice(0,this.column-1).replace(/[^\t]/g," ");return o(">")+c(f)+l+`
4
4
  `+y+o("^")}return" "+c(f)+l}).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grainql/analytics-web",
3
- "version": "3.4.0",
3
+ "version": "3.4.1",
4
4
  "description": "Lightweight TypeScript SDK for sending analytics events and managing remote configurations via Grain's REST API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",