@walkeros/web-source-browser 4.7.0-next-1790722899482 → 4.7.1-next-1791015692826

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/CHANGELOG.md CHANGED
@@ -1,6 +1,32 @@
1
1
  # @walkeros/web-source-browser
2
2
 
3
- ## 4.7.0-next-1790722899482
3
+ ## 4.7.1-next-1791015692826
4
+
5
+ ### Patch Changes
6
+
7
+ - 91e9aeb: Attribute values now support backslash escapes: `\'`, `\;` and `\\`
8
+ keep a quote, semicolon or backslash in the value, so `name:Men\'s shirt`
9
+ works and tagger output is read back as passed. The tagger no longer escapes
10
+ colons in values. A single backslash in existing markup now escapes the next
11
+ character, so write `\\` for a literal backslash.
12
+ - Updated dependencies [91e9aeb]
13
+ - Updated dependencies [0635330]
14
+ - Updated dependencies [0635330]
15
+ - Updated dependencies [91e9aeb]
16
+ - Updated dependencies [0635330]
17
+ - @walkeros/web-core@4.7.1-next-1791015692826
18
+ - @walkeros/collector@4.7.1-next-1791015692826
19
+ - @walkeros/core@4.7.1-next-1791015692826
20
+
21
+ ## 4.7.0
22
+
23
+ ### Minor Changes
24
+
25
+ - c9ea71f: New `history` setting for single-page apps: every route change
26
+ (pushState, replaceState with a new path, back and forward) sends a page view,
27
+ and tagged elements are picked up as the new route renders. Off by default.
28
+ Page views after the first now carry the previous page's URL as
29
+ `data.referrer`.
4
30
 
5
31
  ### Patch Changes
6
32
 
@@ -9,9 +35,19 @@
9
35
  a missing entity, so other entities and events on the page are tracked as
10
36
  before. Link ids (`data-elblink`) containing quotes or brackets no longer
11
37
  throw either.
38
+ - 050d776: Simulated click and impression examples of the browser source carry
39
+ `source` and `globals` again. A page scope from another realm, such as an
40
+ iframe or a simulated page, is now recognized. Simulate also exposes `Node`,
41
+ `Element`, `HTMLElement`, `Document` and `ShadowRoot`, so `instanceof` checks
42
+ behave as in a browser.
43
+ - Updated dependencies [786a860]
12
44
  - Updated dependencies [74821ed]
13
45
  - Updated dependencies [06b498a]
46
+ - Updated dependencies [7e5e3de]
47
+ - Updated dependencies [b9668bf]
14
48
  - Updated dependencies [74821ed]
49
+ - Updated dependencies [64b06de]
50
+ - Updated dependencies [4b4937f]
15
51
  - Updated dependencies [74821ed]
16
52
  - Updated dependencies [74821ed]
17
53
  - Updated dependencies [74821ed]
@@ -21,11 +57,13 @@
21
57
  - Updated dependencies [74821ed]
22
58
  - Updated dependencies [74821ed]
23
59
  - Updated dependencies [74821ed]
60
+ - Updated dependencies [e860006]
24
61
  - Updated dependencies [74821ed]
25
62
  - Updated dependencies [74821ed]
26
- - @walkeros/collector@4.7.0-next-1790722899482
27
- - @walkeros/core@4.7.0-next-1790722899482
28
- - @walkeros/web-core@4.7.0-next-1790722899482
63
+ - Updated dependencies [4f89234]
64
+ - @walkeros/collector@4.7.0
65
+ - @walkeros/core@4.7.0
66
+ - @walkeros/web-core@4.7.0
29
67
 
30
68
  ## 4.6.1
31
69
 
package/dist/dev.d.mts CHANGED
@@ -26,6 +26,7 @@ declare const SettingsSchema: z.ZodObject<{
26
26
  scope: z.ZodOptional<z.ZodString>;
27
27
  pageview: z.ZodDefault<z.ZodBoolean>;
28
28
  capture: z.ZodDefault<z.ZodBoolean>;
29
+ history: z.ZodDefault<z.ZodBoolean>;
29
30
  elb: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<false>]>>;
30
31
  name: z.ZodOptional<z.ZodString>;
31
32
  elbLayer: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString, z.ZodAny]>>;
@@ -87,6 +88,7 @@ declare namespace env {
87
88
  }
88
89
 
89
90
  declare const pageView: Flow.StepExample;
91
+ declare const routeChange: Flow.StepExample;
90
92
  declare const clickEvent: Flow.StepExample;
91
93
  declare const submitEvent: Flow.StepExample;
92
94
  declare const impressionEvent: Flow.StepExample;
@@ -100,9 +102,10 @@ declare const step_dataAttributeTypes: typeof dataAttributeTypes;
100
102
  declare const step_impressionEvent: typeof impressionEvent;
101
103
  declare const step_nestedEntities: typeof nestedEntities;
102
104
  declare const step_pageView: typeof pageView;
105
+ declare const step_routeChange: typeof routeChange;
103
106
  declare const step_submitEvent: typeof submitEvent;
104
107
  declare namespace step {
105
- export { step_clickEvent as clickEvent, step_contextAndGlobals as contextAndGlobals, step_dataAttributeTypes as dataAttributeTypes, step_impressionEvent as impressionEvent, step_nestedEntities as nestedEntities, step_pageView as pageView, step_submitEvent as submitEvent };
108
+ export { step_clickEvent as clickEvent, step_contextAndGlobals as contextAndGlobals, step_dataAttributeTypes as dataAttributeTypes, step_impressionEvent as impressionEvent, step_nestedEntities as nestedEntities, step_pageView as pageView, step_routeChange as routeChange, step_submitEvent as submitEvent };
106
109
  }
107
110
 
108
111
  /**
@@ -120,6 +123,11 @@ declare namespace step {
120
123
  * @example
121
124
  * // Impression trigger, handleTrigger reads data-elbaction directly
122
125
  * await trigger('impression', '[data-elb="promo"]')('<div data-elb="promo" data-elbaction="visible:promo seen">Ad</div>');
126
+ *
127
+ * @example
128
+ * // Route change, for a source with `history: true`: lands on `url`, then
129
+ * // pushes `path`
130
+ * await trigger('history', { url: 'https://example.com/docs', path: '/pricing' })('');
123
131
  */
124
132
  declare const createTrigger: Trigger.CreateFn<string, void>;
125
133
  /**
package/dist/dev.d.ts CHANGED
@@ -26,6 +26,7 @@ declare const SettingsSchema: z.ZodObject<{
26
26
  scope: z.ZodOptional<z.ZodString>;
27
27
  pageview: z.ZodDefault<z.ZodBoolean>;
28
28
  capture: z.ZodDefault<z.ZodBoolean>;
29
+ history: z.ZodDefault<z.ZodBoolean>;
29
30
  elb: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<false>]>>;
30
31
  name: z.ZodOptional<z.ZodString>;
31
32
  elbLayer: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString, z.ZodAny]>>;
@@ -87,6 +88,7 @@ declare namespace env {
87
88
  }
88
89
 
89
90
  declare const pageView: Flow.StepExample;
91
+ declare const routeChange: Flow.StepExample;
90
92
  declare const clickEvent: Flow.StepExample;
91
93
  declare const submitEvent: Flow.StepExample;
92
94
  declare const impressionEvent: Flow.StepExample;
@@ -100,9 +102,10 @@ declare const step_dataAttributeTypes: typeof dataAttributeTypes;
100
102
  declare const step_impressionEvent: typeof impressionEvent;
101
103
  declare const step_nestedEntities: typeof nestedEntities;
102
104
  declare const step_pageView: typeof pageView;
105
+ declare const step_routeChange: typeof routeChange;
103
106
  declare const step_submitEvent: typeof submitEvent;
104
107
  declare namespace step {
105
- export { step_clickEvent as clickEvent, step_contextAndGlobals as contextAndGlobals, step_dataAttributeTypes as dataAttributeTypes, step_impressionEvent as impressionEvent, step_nestedEntities as nestedEntities, step_pageView as pageView, step_submitEvent as submitEvent };
108
+ export { step_clickEvent as clickEvent, step_contextAndGlobals as contextAndGlobals, step_dataAttributeTypes as dataAttributeTypes, step_impressionEvent as impressionEvent, step_nestedEntities as nestedEntities, step_pageView as pageView, step_routeChange as routeChange, step_submitEvent as submitEvent };
106
109
  }
107
110
 
108
111
  /**
@@ -120,6 +123,11 @@ declare namespace step {
120
123
  * @example
121
124
  * // Impression trigger, handleTrigger reads data-elbaction directly
122
125
  * await trigger('impression', '[data-elb="promo"]')('<div data-elb="promo" data-elbaction="visible:promo seen">Ad</div>');
126
+ *
127
+ * @example
128
+ * // Route change, for a source with `history: true`: lands on `url`, then
129
+ * // pushes `path`
130
+ * await trigger('history', { url: 'https://example.com/docs', path: '/pricing' })('');
123
131
  */
124
132
  declare const createTrigger: Trigger.CreateFn<string, void>;
125
133
  /**
package/dist/dev.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,a=(e,r)=>{for(var o in r)t(e,o,{get:r[o],enumerable:!0})},i={};a(i,{examples:()=>w,schemas:()=>s}),module.exports=(e=i,((e,a,i,s)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let c of o(a))n.call(e,c)||c===i||t(e,c,{get:()=>a[c],enumerable:!(s=r(a,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s={};a(s,{DataAttributePrefix:()=>d,JavaScriptVarName:()=>p,ScopeSelector:()=>m,SettingsSchema:()=>f,TaggerSchema:()=>g,settings:()=>h,tagger:()=>v});var c=require("@walkeros/core/dev"),l=require("@walkeros/core/dev"),u=require("@walkeros/core/dev"),d=u.z.string().min(1).regex(/^[a-z][a-z0-9-]*$/,"Must be lowercase kebab-case").describe("Prefix for data attributes on DOM elements"),p=u.z.string().min(1).regex(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,"Must be a valid JavaScript identifier").describe("JavaScript variable name"),m=u.z.string().describe('DOM scope for event tracking (CSS selector or "document")').optional(),b=l.z.union([l.z.boolean(),l.z.string(),l.z.any().describe("Elb.Layer array for async command queuing")]),f=l.z.object({prefix:d.default("data-elb").describe("Prefix for data attributes (default: data-elb)"),scope:m.describe("DOM scope for event tracking (default: document)"),pageview:l.z.boolean().default(!0).describe("Enable automatic pageview tracking"),capture:l.z.boolean().default(!0).describe("Read click/submit triggers in the capture phase so tagged elements are resolved at click time before app handlers run (set false for the previous bubble-phase behavior)"),elb:l.z.union([p,l.z.literal(!1)]).default("elb").describe("Name for global elb function, or false to install none"),name:l.z.string().describe("Custom name for source instance").optional(),elbLayer:b.default("elbLayer").describe("Enable elbLayer for async command queuing (boolean, string, or Elb.Layer)")}),g=require("@walkeros/core/dev").z.object({prefix:d.default("data-elb").describe("Custom prefix for generated data attributes")}),h=(0,c.zodToSchema)(f),v=(0,c.zodToSchema)(g),w={};a(w,{createTrigger:()=>ne,env:()=>y,step:()=>C,trigger:()=>ae});var y={};a(y,{push:()=>S});var k=()=>{},x=()=>()=>Promise.resolve({ok:!0}),E={error:k,warn:k,info:k,debug:k,throw:e=>{throw"string"==typeof e?new Error(e):e},json:k,scope:()=>E},S={get push(){return x()},get command(){return x()},get elb(){return x()},get window(){return{addEventListener:k,removeEventListener:k,location:{href:"https://example.com/page",pathname:"/page",search:"?query=test",hash:"#section",host:"example.com",hostname:"example.com",origin:"https://example.com",protocol:"https:"},document:{},navigator:{language:"en-US",userAgent:"Mozilla/5.0 (Test)"},screen:{width:1920,height:1080},innerWidth:1920,innerHeight:1080,pageXOffset:0,pageYOffset:0,scrollX:0,scrollY:0}},get document(){return{addEventListener:k,removeEventListener:k,querySelector:k,querySelectorAll:()=>[],getElementById:k,getElementsByClassName:()=>[],getElementsByTagName:()=>[],createElement:()=>({setAttribute:k,getAttribute:k,addEventListener:k,removeEventListener:k}),body:{appendChild:k,removeChild:k},documentElement:{scrollTop:0,scrollLeft:0},readyState:"complete",title:"Test Page",referrer:"",cookie:""}},logger:E},C={};a(C,{clickEvent:()=>O,contextAndGlobals:()=>P,dataAttributeTypes:()=>j,impressionEvent:()=>q,nestedEntities:()=>$,pageView:()=>A,submitEvent:()=>z});var A={title:"Page view",description:"A page load trigger captures the current URL, title, and referrer as a walker page view event.",trigger:{type:"load",options:{url:"https://example.com/docs",title:"Documentation",referrer:"https://example.com/"}},in:"",out:[["elb",{name:"page view",data:{domain:"example.com",title:"Documentation",referrer:"https://example.com/",id:"/docs"},context:{},globals:{},nested:void 0,custom:void 0,trigger:"load",source:{type:"browser",platform:"web",url:"https://example.com/docs",referrer:"https://example.com/"}}]]},O={title:"Click event",description:"A button click with walker data attributes is captured as an entity action event with the mapped label data.",trigger:{type:"click",options:"button"},in:'<button data-elb="cta" data-elb-cta="label:Sign Up" data-elbaction="click:click">Sign Up</button>',out:[["elb",{name:"cta click",entity:"cta",action:"click",data:{label:"Sign Up"},context:{},globals:{},nested:[],source:{type:"browser",platform:"web",url:"https://example.com/",referrer:""},trigger:"click"}]]},z={title:"Submit event",description:"A form submit with walker data attributes produces a signup complete event carrying the selected plan.",trigger:{type:"submit",options:"form"},in:'<form data-elb="signup" data-elb-signup="plan:premium" data-elbaction="submit:complete"></form>',out:[["elb",{name:"signup complete",entity:"signup",action:"complete",data:{plan:"premium"},context:{},globals:{},nested:[],source:{type:"browser",platform:"web",url:"https://example.com/",referrer:""},trigger:"submit"}]]},q={title:"Impression event",description:"An intersection observer impression on a div with walker attributes emits a banner view event.",trigger:{type:"impression",options:"div"},in:'<div data-elb="banner" data-elb-banner="type:promotional;position:sidebar" data-elbaction="impression:view"></div>',out:[["elb",{name:"banner view",entity:"banner",action:"view",data:{type:"promotional",position:"sidebar"},context:{},globals:{},nested:[],source:{type:"browser",platform:"web",url:"https://example.com/",referrer:""},trigger:"impression"}]]},$={title:"Nested entities",description:"A page load produces a page view plus a product view whose nested size entity is captured on the product event.",trigger:{type:"load"},in:'<div data-elb="product" data-elb-product="id:SKU-42;name:Sneakers" data-elbaction="load:view"><div data-elb="size" data-elb-size="selected:large;inStock:true"></div></div>',out:[["elb",{name:"page view",data:{domain:"example.com",title:"",referrer:"",id:"/"},context:{},globals:{},nested:void 0,custom:void 0,trigger:"load",source:{type:"browser",platform:"web",url:"https://example.com/",referrer:""}}],["elb",{name:"product view",entity:"product",action:"view",data:{id:"SKU-42",name:"Sneakers"},context:{},globals:{},nested:[{entity:"size",data:{selected:"large",inStock:!0},context:{},nested:[]}],source:{type:"browser",platform:"web",url:"https://example.com/",referrer:""},trigger:"load"}]]},j={title:"Data attribute types",description:"Walker data attributes parse scalar, boolean, and array values into typed fields on the emitted event.",trigger:{type:"click",options:"div"},in:'<div data-elb="product" data-elb-product="price:99.99;available:true;colors[]:red;colors[]:blue" data-elbaction="click:select"></div>',out:[["elb",{name:"product select",entity:"product",action:"select",data:{price:99.99,available:!0,colors:["red","blue"]},context:{},globals:{},nested:[],source:{type:"browser",platform:"web",url:"https://example.com/",referrer:""},trigger:"click"}]]},P={title:"Context and globals",description:"Walker context and globals attributes attach ambient metadata to events emitted by the browser source.",trigger:{type:"click",options:'[data-elb="cta"]'},in:'<div data-elbcontext="test:engagement_flow" data-elbglobals="language:en;plan:premium"><div data-elb="cta" data-elb-cta="label:Try Now" data-elbaction="click:signup">Try Now</div></div>',out:[["elb",{name:"cta signup",entity:"cta",action:"signup",data:{label:"Try Now"},context:{test:["engagement_flow",0]},globals:{language:"en",plan:"premium"},nested:[],source:{type:"browser",platform:"web",url:"https://example.com/",referrer:""},trigger:"click"}]]},T=require("@walkeros/collector"),D=(require("@walkeros/core"),require("@walkeros/collector"),require("@walkeros/web-core"),require("@walkeros/core")),L=require("@walkeros/collector"),R=require("@walkeros/web-core");function M(e,t,r=!0){return e+(t=null!=t?(r?"-":"")+t:"")}function N(e,t,r,o=!0){return X((0,R.getAttribute)(t,M(e,r,o))||"").reduce((e,r)=>{let[o,n]=Y(r);if(!o)return e;if(n||(o.endsWith(":")&&(o=o.slice(0,-1)),n=""),n.startsWith("#")){n=n.slice(1);try{let e=t[n];e||"selected"!==n||(e=t.options[t.selectedIndex].text),n=String(e)}catch(e){n=""}}return o.endsWith("[]")?(o=o.slice(0,-2),(0,D.isArray)(e[o])||(e[o]=[]),e[o].push((0,D.castValue)(n))):e[o]=(0,D.castValue)(n),e},{})}function U(e,t,r=L.Const.Commands.Prefix){const o=[],{actions:n,nearestOnly:a}=function(e,t,r){let o=t;for(;o;){const t=(0,R.getAttribute)(o,M(e,L.Const.Commands.Actions,!1));if(t){const e=V(t);if(e[r])return{actions:e[r],nearestOnly:!1}}const n=(0,R.getAttribute)(o,M(e,L.Const.Commands.Action,!1));if(n){const e=V(n);if(e[r]||"click"!==r)return{actions:e[r]||[],nearestOnly:!0}}o=G(e,o)}return{actions:[],nearestOnly:!1}}(r,e,t);return n.length?(n.forEach(n=>{const i=X(n.actionParams||"",",").reduce((e,t)=>(e[(0,D.trim)(t)]=!0,e),{}),s=_(r,e,i,a);if(!s.length){const t="page",o=`[${M(r,t)}]`,[n,a]=J(e,o,r,t);s.push({entity:t,data:n,nested:[],context:a})}s.forEach(e=>{var r;o.push({entity:e.entity,action:n.action,data:e.data,trigger:t,context:e.context,nested:null!=(r=e.nested)?r:[]})})}),o):o}function W(e=L.Const.Commands.Prefix,t){if(!t)return{};const r=M(e,L.Const.Commands.Globals,!1);let o={};return H(t,`[${r}]`,t=>{o=(0,D.assign)(o,N(e,t,L.Const.Commands.Globals,!1))}),o}function V(e){const t={};return X(e).forEach(e=>{const[r,o]=Y(e),[n,a]=Z(r);if(!n)return;let[i,s]=Z(o||"");i=i||n,t[n]||(t[n]=[]),t[n].push({trigger:n,triggerParams:a,action:i,actionParams:s})}),t}function _(e,t,r,o=!1){const n=[];let a=t;for(r=0!==Object.keys(r||{}).length?r:void 0;a;){const i=B(e,a,t,r);if(i&&(n.push(i),o))break;a=G(e,a)}return n}var I=/^[\w\u0080-\uffff-]+$/;function B(e,t,r,o){const n=(0,R.getAttribute)(t,M(e));if(!n||!I.test(n)||o&&!o[n])return null;const a=[t],i=`[${M(e,n)}],[${M(e,"")}]`,s=M(e,L.Const.Commands.Link,!1);let c={};const l=[],[u,d]=J(r||t,i,e,n,!0);K(t,`[${s}]`,r=>{const[o,n]=Y((0,R.getAttribute)(r,s));"parent"===n&&K(t.ownerDocument.body,`[${s}]`,t=>{if(t.getAttribute(s)!==`${o}:child`)return;a.push(t);const r=B(e,t);r&&l.push(r)})});const p=[];a.forEach(e=>{e.matches(i)&&p.push(e),K(e,i,e=>p.push(e))});let m={};return p.forEach(t=>{m=(0,D.assign)(m,N(e,t,"")),c=(0,D.assign)(c,N(e,t,n))}),c=(0,D.assign)((0,D.assign)(m,c),u),a.forEach(t=>{K(t,`[${M(e)}]`,t=>{const r=B(e,t);r&&l.push(r)})}),{entity:n,data:c,context:d,nested:l}}function G(e,t){const r=M(e,L.Const.Commands.Link,!1);if(t.matches(`[${r}]`)){const[e,o]=Y((0,R.getAttribute)(t,r));if("child"===o){const o=t.ownerDocument;let n=null;return H(o,`[${r}]`,t=>{n||t.getAttribute(r)!==`${e}:parent`||(n=t)}),n}}const o=t.ownerDocument.defaultView;return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof o.ShadowRoot?t.getRootNode().host:t.parentElement}function J(e,t,r,o,n=!1){let a={};const i={};let s=e;const c=`[${M(r,L.Const.Commands.Context,!1)}]`,l=L.Const.Commands.Scoped,u=`[${M(r,l,!1)}]`;let d=0;for(;s;)n&&l&&s.matches(u)&&(a=(0,D.assign)(N(r,s,l,!1),a)),s.matches(t)&&(a=(0,D.assign)(N(r,s,""),a),a=(0,D.assign)(N(r,s,o),a)),s.matches(c)&&(Object.entries(N(r,s,L.Const.Commands.Context,!1)).forEach(([e,t])=>{t&&!i[e]&&(i[e]=[t,d])}),++d),s=G(r,s);return[a,i]}function H(e,t,r){e.querySelectorAll(t).forEach(r)}function K(e,t,r){e.querySelectorAll(t).forEach(r);e instanceof(e.ownerDocument||e).defaultView.Element&&e.shadowRoot&&K(e.shadowRoot,t,r),e.querySelectorAll("*").forEach(e=>{e.shadowRoot&&K(e.shadowRoot,t,r)})}function X(e,t=";"){if(!e)return[];const r=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(r)||[]}function Y(e){const[t,r]=e.split(/:(.+)/,2);return[(0,D.trim)(t),(0,D.trim)(r)]}function Z(e){const[t,r]=e.split("(",2);return[t,r?r.slice(0,-1):""]}require("@walkeros/core"),require("@walkeros/web-core"),Array.from({length:101},(e,t)=>t/100);var F=require("@walkeros/core"),Q=require("@walkeros/collector");function ee(e,t,r,o,n,a,i){var s;const{elb:c,push:l,settings:u}=e,d=null!=(s=e.root)?s:u.scope;if((0,F.isString)(t)&&t.startsWith("walker ")){if("walker init"===t&&e.initScope){const t=function(e,t){if(re(e))return[e];if(Array.isArray(e)){const t=[];for(const r of e)re(r)&&t.push(r);return t}if(void 0===e){const e=t.scope;if(re(e))return[e];if(void 0!==globalThis.document)return[globalThis.document]}return[]}(r,u);for(const r of t)e.initScope({...e,settings:{...u,scope:r}});return Promise.resolve((0,Q.createPushResult)({ok:!0}))}return c(t,r)}if((0,F.isObject)(t)){const e=t;if(!e.source&&u.scope){const t=u.scope.ownerDocument||u.scope,r=t.defaultView;e.source=te(r,t)}return!e.globals&&d&&(e.globals=oe(d)?W(u.prefix,d):{}),l(e)}const[p]=String((0,F.isObject)(t)?t.name:t).split(" ");let m,b=(0,F.isObject)(r)?r:{},f={},g=!1;if((0,F.isElementOrDocument)(r)&&(m=r,g=!0),(0,F.isElementOrDocument)(n)?m=n:(0,F.isObject)(n)&&Object.keys(n).length&&(f=n),m){const e=_(u.prefix||"data-elb",m).find(e=>e.entity===p);e&&(g&&(b=e.data),e.context&&(f=e.context))}const h=u.scope?u.scope.ownerDocument||u.scope:void 0,v=null==h?void 0:h.defaultView;"page"===p&&v&&(b.id=b.id||v.location.pathname);const w=d&&oe(d)?W(u.prefix,d):{};return l({name:String(t||""),data:b,context:f,globals:w,nested:a,custom:i,trigger:(0,F.isString)(o)?o:"",source:v&&h?te(v,h):void 0})}function te(e,t){return{type:"browser",platform:"web",url:e.location.href,referrer:t.referrer}}function re(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof Element&&e instanceof Element)return!0;if("undefined"!=typeof Document&&e instanceof Document)return!0;if("undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot)return!0;if("nodeType"in e){const t=e.nodeType;return 1===t||9===t||11===t}return!1}function oe(e){return 11!==e.nodeType}var ne=async(e,t)=>{const r=(null==t?void 0:t.sourceId)||"browser";let o;const n=document,a=window;return{get flow(){return o},trigger:(t,i)=>async s=>{var c;if("load"===t||!t){const e="object"==typeof i&&null!==i?i:{};if(e.url){const t=new URL(e.url);a.history.replaceState({},"",t.pathname)}e.title&&(n.title=e.title),e.referrer&&Object.defineProperty(n,"referrer",{value:e.referrer,configurable:!0})}if(s&&(n.body.innerHTML=s),!o){const t=await(0,T.startFlow)({...e,run:null==(c=e.run)||c});o={collector:t.collector,elb:t.elb}}if(!t||"load"===t)return;const l="string"==typeof i?i:void 0,u=l?n.querySelector(l):null;if(!u)return void console.warn(`Trigger: element not found for selector "${l}"`);const d=o.collector.sources[r];if(!d)return void console.warn(`Trigger: source "${r}" not found in collector`);const p={elb:o.elb,push:o.collector.push,settings:d.config.settings,registry:{scopes:new Map,elements:new WeakMap,visibility:new WeakMap,destroyed:!1}};await async function(e,t,r){const o=U(t,r,e.settings.prefix);return Promise.all(o.map(t=>ee(e,{name:`${t.entity} ${t.action}`,...t,trigger:r})))}(p,u,t)}}},ae=(e,t)=>{if(!e||"object"!=typeof e)return;const r=e,o=t.document,n=t.window,a=()=>{var e,t;if(!r.attributes)return;const n=(null==(t=null==(e=r.element)?void 0:e.match(/^(\w+)/))?void 0:t[1])||"div",a=o.createElement(n);for(const[e,t]of Object.entries(r.attributes))a.setAttribute(e,t);if(r.children)for(const e of r.children){const t=o.createElement("div");for(const[r,o]of Object.entries(e))t.setAttribute(r,o);a.appendChild(t)}return o.body.appendChild(a),a};if(!r.trigger||"load"===r.trigger){if(r.url){const e=new URL(r.url);n.history.replaceState({},"",e.pathname)}return r.title&&(o.title=r.title),r.referrer&&Object.defineProperty(o,"referrer",{value:r.referrer}),void a()}return()=>{const e=a();if(e)switch(r.trigger){case"click":e.dispatchEvent(new MouseEvent("click",{bubbles:!0}));break;case"submit":e.dispatchEvent(new Event("submit",{bubbles:!0}));break;case"hover":e.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0}));break;case"scroll":n.dispatchEvent(new Event("scroll"))}}};//# sourceMappingURL=dev.js.map
1
+ "use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,i=(e,r)=>{for(var o in r)t(e,o,{get:r[o],enumerable:!0})},a={};i(a,{examples:()=>w,schemas:()=>s}),module.exports=(e=a,((e,i,a,s)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of o(i))n.call(e,c)||c===a||t(e,c,{get:()=>i[c],enumerable:!(s=r(i,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s={};i(s,{DataAttributePrefix:()=>d,JavaScriptVarName:()=>p,ScopeSelector:()=>b,SettingsSchema:()=>f,TaggerSchema:()=>g,settings:()=>h,tagger:()=>v});var c=require("@walkeros/core/dev"),l=require("@walkeros/core/dev"),u=require("@walkeros/core/dev"),d=u.z.string().min(1).regex(/^[a-z][a-z0-9-]*$/,"Must be lowercase kebab-case").describe("Prefix for data attributes on DOM elements"),p=u.z.string().min(1).regex(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,"Must be a valid JavaScript identifier").describe("JavaScript variable name"),b=u.z.string().describe('DOM scope for event tracking (CSS selector or "document")').optional(),m=l.z.union([l.z.boolean(),l.z.string(),l.z.any().describe("Elb.Layer array for async command queuing")]),f=l.z.object({prefix:d.default("data-elb").describe("Prefix for data attributes (default: data-elb)"),scope:b.describe("DOM scope for event tracking (default: document)"),pageview:l.z.boolean().default(!0).describe("Enable automatic pageview tracking"),capture:l.z.boolean().default(!0).describe("Read click/submit triggers in the capture phase so tagged elements are resolved at click time before app handlers run (set false for the previous bubble-phase behavior)"),history:l.z.boolean().default(!1).describe("Single-page apps: send a page view on every route change (pushState, replaceState with a new path, back and forward) and pick up tagged elements as the new route renders"),elb:l.z.union([p,l.z.literal(!1)]).default("elb").describe("Name for global elb function, or false to install none"),name:l.z.string().describe("Custom name for source instance").optional(),elbLayer:m.default("elbLayer").describe("Enable elbLayer for async command queuing (boolean, string, or Elb.Layer)")}),g=require("@walkeros/core/dev").z.object({prefix:d.default("data-elb").describe("Custom prefix for generated data attributes")}),h=(0,c.zodToSchema)(f),v=(0,c.zodToSchema)(g),w={};i(w,{createTrigger:()=>ce,env:()=>y,step:()=>O,trigger:()=>le});var y={};i(y,{push:()=>E});var x=()=>{},k=()=>()=>Promise.resolve({ok:!0}),S={error:x,warn:x,info:x,debug:x,throw:e=>{throw"string"==typeof e?new Error(e):e},json:x,scope:()=>S},E={get push(){return k()},get command(){return k()},get elb(){return k()},get window(){return{addEventListener:x,removeEventListener:x,location:{href:"https://example.com/page",pathname:"/page",search:"?query=test",hash:"#section",host:"example.com",hostname:"example.com",origin:"https://example.com",protocol:"https:"},document:{},navigator:{language:"en-US",userAgent:"Mozilla/5.0 (Test)"},screen:{width:1920,height:1080},innerWidth:1920,innerHeight:1080,pageXOffset:0,pageYOffset:0,scrollX:0,scrollY:0}},get document(){return{addEventListener:x,removeEventListener:x,querySelector:x,querySelectorAll:()=>[],getElementById:x,getElementsByClassName:()=>[],getElementsByTagName:()=>[],createElement:()=>({setAttribute:x,getAttribute:x,addEventListener:x,removeEventListener:x}),body:{appendChild:x,removeChild:x},documentElement:{scrollTop:0,scrollLeft:0},readyState:"complete",title:"Test Page",referrer:"",cookie:""}},logger:S},O={};i(O,{clickEvent:()=>j,contextAndGlobals:()=>T,dataAttributeTypes:()=>P,impressionEvent:()=>q,nestedEntities:()=>z,pageView:()=>C,routeChange:()=>A,submitEvent:()=>L});var C={title:"Page view",description:"A page load trigger captures the current URL, title, and referrer as a walker page view event.",trigger:{type:"load",options:{url:"https://example.com/docs",title:"Documentation",referrer:"https://example.com/"}},in:"",out:[["elb",{name:"page view",data:{domain:"example.com",title:"Documentation",referrer:"https://example.com/",id:"/docs"},context:{},globals:{},nested:void 0,custom:void 0,trigger:"load",source:{type:"browser",platform:"web",url:"https://example.com/docs",referrer:"https://example.com/"}}]]},A={title:"Route change",description:"With history enabled, a single-page app route change sends a page view for the new URL, with the previous page as its referrer.",trigger:{type:"history",options:{url:"https://example.com/docs",path:"/pricing"}},in:"",out:[["elb",{name:"page view",data:{domain:"example.com",title:"",referrer:"",id:"/docs"},context:{},globals:{},nested:void 0,custom:void 0,trigger:"load",source:{type:"browser",platform:"web",url:"https://example.com/docs",referrer:""}}],["elb",{name:"page view",data:{domain:"example.com",title:"",referrer:"https://example.com/docs",id:"/pricing"},context:{},globals:{},nested:void 0,custom:void 0,trigger:"load",source:{type:"browser",platform:"web",url:"https://example.com/pricing",referrer:""}}]]},j={title:"Click event",description:"A button click with walker data attributes is captured as an entity action event with the mapped label data.",trigger:{type:"click",options:"button"},in:'<button data-elb="cta" data-elb-cta="label:Sign Up" data-elbaction="click:click">Sign Up</button>',out:[["elb",{name:"cta click",entity:"cta",action:"click",data:{label:"Sign Up"},context:{},globals:{},nested:[],source:{type:"browser",platform:"web",url:"https://example.com/",referrer:""},trigger:"click"}]]},L={title:"Submit event",description:"A form submit with walker data attributes produces a signup complete event carrying the selected plan.",trigger:{type:"submit",options:"form"},in:'<form data-elb="signup" data-elb-signup="plan:premium" data-elbaction="submit:complete"></form>',out:[["elb",{name:"signup complete",entity:"signup",action:"complete",data:{plan:"premium"},context:{},globals:{},nested:[],source:{type:"browser",platform:"web",url:"https://example.com/",referrer:""},trigger:"submit"}]]},q={title:"Impression event",description:"An intersection observer impression on a div with walker attributes emits a banner view event.",trigger:{type:"impression",options:"div"},in:'<div data-elb="banner" data-elb-banner="type:promotional;position:sidebar" data-elbaction="impression:view"></div>',out:[["elb",{name:"banner view",entity:"banner",action:"view",data:{type:"promotional",position:"sidebar"},context:{},globals:{},nested:[],source:{type:"browser",platform:"web",url:"https://example.com/",referrer:""},trigger:"impression"}]]},z={title:"Nested entities",description:"A page load produces a page view plus a product view whose nested size entity is captured on the product event.",trigger:{type:"load"},in:'<div data-elb="product" data-elb-product="id:SKU-42;name:Sneakers" data-elbaction="load:view"><div data-elb="size" data-elb-size="selected:large;inStock:true"></div></div>',out:[["elb",{name:"page view",data:{domain:"example.com",title:"",referrer:"",id:"/"},context:{},globals:{},nested:void 0,custom:void 0,trigger:"load",source:{type:"browser",platform:"web",url:"https://example.com/",referrer:""}}],["elb",{name:"product view",entity:"product",action:"view",data:{id:"SKU-42",name:"Sneakers"},context:{},globals:{},nested:[{entity:"size",data:{selected:"large",inStock:!0},context:{},nested:[]}],source:{type:"browser",platform:"web",url:"https://example.com/",referrer:""},trigger:"load"}]]},P={title:"Data attribute types",description:"Walker data attributes parse scalar, boolean, and array values into typed fields on the emitted event.",trigger:{type:"click",options:"div"},in:'<div data-elb="product" data-elb-product="price:99.99;available:true;colors[]:red;colors[]:blue" data-elbaction="click:select"></div>',out:[["elb",{name:"product select",entity:"product",action:"select",data:{price:99.99,available:!0,colors:["red","blue"]},context:{},globals:{},nested:[],source:{type:"browser",platform:"web",url:"https://example.com/",referrer:""},trigger:"click"}]]},T={title:"Context and globals",description:"Walker context and globals attributes attach ambient metadata to events emitted by the browser source.",trigger:{type:"click",options:'[data-elb="cta"]'},in:'<div data-elbcontext="test:engagement_flow" data-elbglobals="language:en;plan:premium"><div data-elb="cta" data-elb-cta="label:Try Now" data-elbaction="click:signup">Try Now</div></div>',out:[["elb",{name:"cta signup",entity:"cta",action:"signup",data:{label:"Try Now"},context:{test:["engagement_flow",0]},globals:{language:"en",plan:"premium"},nested:[],source:{type:"browser",platform:"web",url:"https://example.com/",referrer:""},trigger:"click"}]]},$=require("@walkeros/core"),D=require("@walkeros/collector"),R=(require("@walkeros/core"),require("@walkeros/collector"),require("@walkeros/web-core"),require("@walkeros/core")),M=require("@walkeros/collector"),N=require("@walkeros/web-core");function U(e,t,r=!0){return e+(t=null!=t?(r?"-":"")+t:"")}function V(e,t,r,o=!0){const n=(0,N.getAttribute)(t,U(e,r,o))||"";return(0,N.splitAttribute)(n).reduce((e,r)=>{let[o,n]=(0,N.splitKeyVal)(r);if(!o)return e;if(n.startsWith("#")){n=n.slice(1);try{let e=t[n];e||"selected"!==n||(e=t.options[t.selectedIndex].text),n=String(e)}catch(e){n=""}}return o.endsWith("[]")?(o=o.slice(0,-2),(0,R.isArray)(e[o])||(e[o]=[]),e[o].push((0,R.castValue)(n))):e[o]=(0,R.castValue)(n),e},{})}function W(e,t,r=M.Const.Commands.Prefix){const o=[],{actions:n,nearestOnly:i}=function(e,t,r){let o=t;for(;o;){const t=(0,N.getAttribute)(o,U(e,M.Const.Commands.Actions,!1));if(t){const e=_(t);if(e[r])return{actions:e[r],nearestOnly:!1}}const n=(0,N.getAttribute)(o,U(e,M.Const.Commands.Action,!1));if(n){const e=_(n);if(e[r]||"click"!==r)return{actions:e[r]||[],nearestOnly:!0}}o=J(e,o)}return{actions:[],nearestOnly:!1}}(r,e,t);return n.length?(n.forEach(n=>{const a=(0,N.splitAttribute)(n.actionParams||"",",").reduce((e,t)=>(e[(0,R.trim)(t)]=!0,e),{}),s=I(r,e,a,i);if(!s.length){const t="page",o=`[${U(r,t)}]`,[n,i]=H(e,o,r,t);s.push({entity:t,data:n,nested:[],context:i})}s.forEach(e=>{var r;o.push({entity:e.entity,action:n.action,data:e.data,trigger:t,context:e.context,nested:null!=(r=e.nested)?r:[]})})}),o):o}function B(e=M.Const.Commands.Prefix,t){if(!t)return{};const r=U(e,M.Const.Commands.Globals,!1);let o={};return X(t,`[${r}]`,t=>{o=(0,R.assign)(o,V(e,t,M.Const.Commands.Globals,!1))}),o}function _(e){const t={};return(0,N.splitAttribute)(e).forEach(e=>{const[r,o]=(0,N.splitKeyVal)(e),[n,i]=F(r);if(!n)return;let[a,s]=F(o||"");a=a||n,t[n]||(t[n]=[]),t[n].push({trigger:n,triggerParams:i,action:a,actionParams:s})}),t}function I(e,t,r,o=!1){const n=[];let i=t;for(r=0!==Object.keys(r||{}).length?r:void 0;i;){const a=G(e,i,t,r);if(a&&(n.push(a),o))break;i=J(e,i)}return n}var K=/^[\w\u0080-\uffff-]+$/;function G(e,t,r,o){const n=(0,N.getAttribute)(t,U(e));if(!n||!K.test(n)||o&&!o[n])return null;const i=[t],a=`[${U(e,n)}],[${U(e,"")}]`,s=U(e,M.Const.Commands.Link,!1);let c={};const l=[],[u,d]=H(r||t,a,e,n,!0);Y(t,`[${s}]`,r=>{const[o,n]=Z(r,s);"parent"===n&&Y(t.ownerDocument.body,`[${s}]`,t=>{const[r,n]=Z(t,s);if(r!==o||"child"!==n)return;i.push(t);const a=G(e,t);a&&l.push(a)})});const p=[];i.forEach(e=>{e.matches(a)&&p.push(e),Y(e,a,e=>p.push(e))});let b={};return p.forEach(t=>{b=(0,R.assign)(b,V(e,t,"")),c=(0,R.assign)(c,V(e,t,n))}),c=(0,R.assign)((0,R.assign)(b,c),u),i.forEach(t=>{Y(t,`[${U(e)}]`,t=>{const r=G(e,t);r&&l.push(r)})}),{entity:n,data:c,context:d,nested:l}}function J(e,t){const r=U(e,M.Const.Commands.Link,!1);if(t.matches(`[${r}]`)){const[e,o]=Z(t,r);if("child"===o){const o=t.ownerDocument;let n=null;return X(o,`[${r}]`,t=>{const[o,i]=Z(t,r);n||o!==e||"parent"!==i||(n=t)}),n}}const o=t.ownerDocument.defaultView;return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof o.ShadowRoot?t.getRootNode().host:t.parentElement}function H(e,t,r,o,n=!1){let i={};const a={};let s=e;const c=`[${U(r,M.Const.Commands.Context,!1)}]`,l=M.Const.Commands.Scoped,u=`[${U(r,l,!1)}]`;let d=0;for(;s;)n&&l&&s.matches(u)&&(i=(0,R.assign)(V(r,s,l,!1),i)),s.matches(t)&&(i=(0,R.assign)(V(r,s,""),i),i=(0,R.assign)(V(r,s,o),i)),s.matches(c)&&(Object.entries(V(r,s,M.Const.Commands.Context,!1)).forEach(([e,t])=>{t&&!a[e]&&(a[e]=[t,d])}),++d),s=J(r,s);return[i,a]}function X(e,t,r){e.querySelectorAll(t).forEach(r)}function Y(e,t,r){e.querySelectorAll(t).forEach(r);e instanceof(e.ownerDocument||e).defaultView.Element&&e.shadowRoot&&Y(e.shadowRoot,t,r),e.querySelectorAll("*").forEach(e=>{e.shadowRoot&&Y(e.shadowRoot,t,r)})}function Z(e,t){return(0,N.splitKeyVal)((0,N.getAttribute)(e,t))}function F(e){const[t,r]=e.split("(",2);return[t,r?r.slice(0,-1):""]}require("@walkeros/core"),require("@walkeros/web-core"),Array.from({length:101},(e,t)=>t/100);var Q=require("@walkeros/core"),ee=require("@walkeros/collector");function te(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof Element&&e instanceof Element)return!0;if("undefined"!=typeof Document&&e instanceof Document)return!0;if("undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot)return!0;if("nodeType"in e){const t=e.nodeType;return 1===t||9===t||11===t}return!1}function re(e,t,r,o,n,i,a){var s;const{elb:c,push:l,settings:u}=e,d=null!=(s=e.root)?s:u.scope;if((0,Q.isString)(t)&&t.startsWith("walker ")){if("walker init"===t&&e.initScope){const t=function(e,t){if(te(e))return[e];if(Array.isArray(e)){const t=[];for(const r of e)te(r)&&t.push(r);return t}if(void 0===e){const e=t.scope;if(te(e))return[e];if(void 0!==globalThis.document)return[globalThis.document]}return[]}(r,u);for(const r of t)e.initScope({...e,settings:{...u,scope:r}});return Promise.resolve((0,ee.createPushResult)({ok:!0}))}return c(t,r)}if((0,Q.isObject)(t)){const r=t;if(!r.source&&u.scope){const t=u.scope.ownerDocument||u.scope,o=t.defaultView;r.source=oe(o,t,e.href)}return!r.globals&&d&&(r.globals=ne(d)?B(u.prefix,d):{}),l(r)}const[p]=String((0,Q.isObject)(t)?t.name:t).split(" ");let b,m=(0,Q.isObject)(r)?r:{},f={},g=!1;if((0,Q.isElementOrDocument)(r)&&(b=r,g=!0),(0,Q.isElementOrDocument)(n)?b=n:(0,Q.isObject)(n)&&Object.keys(n).length&&(f=n),b){const e=I(u.prefix||"data-elb",b).find(e=>e.entity===p);e&&(g&&(m=e.data),e.context&&(f=e.context))}const h=u.scope?u.scope.ownerDocument||u.scope:void 0,v=null==h?void 0:h.defaultView;"page"===p&&v&&(m.id=m.id||(e.href?new URL(e.href):v.location).pathname);const w=d&&ne(d)?B(u.prefix,d):{};return l({name:String(t||""),data:m,context:f,globals:w,nested:i,custom:a,trigger:(0,Q.isString)(o)?o:"",source:v&&h?oe(v,h,e.href):void 0})}function oe(e,t,r){return{type:"browser",platform:"web",url:r||e.location.href,referrer:t.referrer}}function ne(e){return 11!==e.nodeType}var ie=require("@walkeros/core");function ae(e={},t){return{prefix:"data-elb",pageview:!0,capture:!0,history:!1,elb:"elb",elbLayer:"elbLayer",scope:t||void 0,...e}}function se(e){if(!(0,ie.isObject)(e))return ae();const t={};return(0,ie.isString)(e.prefix)&&(t.prefix=e.prefix),(0,ie.isBoolean)(e.pageview)&&(t.pageview=e.pageview),(0,ie.isBoolean)(e.capture)&&(t.capture=e.capture),(0,ie.isBoolean)(e.history)&&(t.history=e.history),(0,ie.isString)(e.name)&&(t.name=e.name),((0,ie.isString)(e.elb)||!1===e.elb)&&(t.elb=e.elb),((0,ie.isString)(e.elbLayer)||(0,ie.isBoolean)(e.elbLayer))&&(t.elbLayer=e.elbLayer),te(e.scope)&&(t.scope=e.scope),ae(t)}var ce=async(e,t)=>{const r=(0,$.isObject)(t)&&(0,$.isString)(t.sourceId)&&t.sourceId||"browser";let o;const n=document,i=window;return{get flow(){return o},trigger:(t,a)=>async s=>{var c;if("load"===t||"history"===t||!t){const e=pe(a);if(e.url){const t=new URL(e.url);i.history.replaceState({},"",t.pathname)}e.title&&(n.title=e.title),e.referrer&&Object.defineProperty(n,"referrer",{value:e.referrer,configurable:!0})}if(s&&(n.body.innerHTML=s),!o){const t=await(0,D.startFlow)({...e,run:null==(c=e.run)||c});o={collector:t.collector,elb:t.elb}}if(!t||"load"===t)return;if("history"===t){const e=(0,$.isObject)(a)?ue(a.path):void 0;return e&&i.history.pushState({},"",e),void await new Promise(e=>setTimeout(e,0))}const l="string"==typeof a?a:void 0,u=l?n.querySelector(l):null;if(!u)return void console.warn(`Trigger: element not found for selector "${l}"`);const d=o.collector.sources[r];if(!d)return void console.warn(`Trigger: source "${r}" not found in collector`);const p={elb:o.elb,push:o.collector.push,settings:se(d.config.settings),registry:{scopes:new Map,elements:new WeakMap,visibility:new WeakMap,destroyed:!1}};await async function(e,t,r){const o=W(t,r,e.settings.prefix);return Promise.all(o.map(t=>re(e,{name:`${t.entity} ${t.action}`,...t,trigger:r})))}(p,u,t)}}},le=(e,t)=>{const r=function(e){var t;if(!(0,$.isObject)(e))return;const r=(0,$.isArray)(e.children)?e.children.map(de).filter(be):void 0;return{...pe(e),trigger:null!=(t=ue(e.trigger))?t:"",element:ue(e.element),attributes:de(e.attributes),children:r}}(e),o=t.document,n=t.window;if(!r||("object"!=typeof(i=o)||null===i||!("createElement"in i))||!function(e){return"object"==typeof e&&null!==e&&"addEventListener"in e}(n))return;var i;const a=()=>{var e,t;if(!r.attributes)return;const n=(null==(t=null==(e=r.element)?void 0:e.match(/^(\w+)/))?void 0:t[1])||"div",i=o.createElement(n);for(const[e,t]of Object.entries(r.attributes))i.setAttribute(e,t);if(r.children)for(const e of r.children){const t=o.createElement("div");for(const[r,o]of Object.entries(e))t.setAttribute(r,o);i.appendChild(t)}return o.body.appendChild(i),i};if(!r.trigger||"load"===r.trigger){if(r.url){const e=new URL(r.url);n.history.replaceState({},"",e.pathname)}return r.title&&(o.title=r.title),r.referrer&&Object.defineProperty(o,"referrer",{value:r.referrer}),void a()}return()=>{const e=a();if(e)switch(r.trigger){case"click":e.dispatchEvent(new MouseEvent("click",{bubbles:!0}));break;case"submit":e.dispatchEvent(new Event("submit",{bubbles:!0}));break;case"hover":e.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0}));break;case"scroll":n.dispatchEvent(new Event("scroll"))}}};function ue(e){return(0,$.isString)(e)?e:void 0}function de(e){if(!(0,$.isObject)(e))return;const t={};for(const[r,o]of Object.entries(e))(0,$.isString)(o)&&(t[r]=o);return t}function pe(e){return(0,$.isObject)(e)?{url:ue(e.url),title:ue(e.title),referrer:ue(e.referrer)}:{}}function be(e){return void 0!==e}//# sourceMappingURL=dev.js.map