@walkeros/walker.js 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var e=Object.defineProperty,t={Storage:{Local:"local",Session:"session",Cookie:"cookie"}},n={merge:!0,shallow:!0,extend:!0};function o(e,t={},o={}){o={...n,...o};const r=Object.entries(t).reduce((t,[n,r])=>{const i=e[n];return o.merge&&Array.isArray(i)&&Array.isArray(r)?t[n]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(o.extend||n in e)&&(t[n]=r),t},{});return o.shallow?{...e,...r}:(Object.assign(e,r),e)}function r(e){return Array.isArray(e)}function i(e){return void 0!==e}function a(e){return"object"==typeof e&&null!==e&&!r(e)&&"[object Object]"===Object.prototype.toString.call(e)}function s(e){return"string"==typeof e}function c(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=c(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(c(e,t))}),n}if("[object Date]"===n)return new Date(e.getTime());if("[object RegExp]"===n){const t=e;return new RegExp(t.source,t.flags)}return e}function u(e,t="",n){const o=t.split(".");let a=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&r(a)){const t=o.slice(e+1).join("."),r=[];for(const e of a){const o=u(e,t,n);r.push(o)}return r}if(a=a instanceof Object?a[t]:void 0,!a)break}return i(a)?a:n}function l(e,t,n){if(!a(e))return e;const o=c(e),r=t.split(".");let i=o;for(let e=0;e<r.length;e++){const t=r[e];e===r.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return o}function d(e,t={},n={}){const o={...t,...n},r={};let i=void 0===e;return Object.keys(o).forEach(t=>{o[t]&&(r[t]=!0,e&&e[t]&&(i=!0))}),!!i&&r}function f(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function g(e){return function(e){return"boolean"==typeof e}(e)||s(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!i(e)||r(e)&&e.every(g)||a(e)&&Object.values(e).every(g)}function p(e){return g(e)?e:void 0}function m(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function y(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(null==n?void 0:n())}}}async function b(e,t={},n={}){var o;if(!i(e))return;const s=a(e)&&e.consent||n.consent||(null==(o=n.collector)?void 0:o.consent),c=r(t)?t:[t];for(const t of c){const o=await y(h)(e,t,{...n,consent:s});if(i(o))return o}}async function h(e,t,n={}){const{collector:o,consent:a}=n;return(r(t)?t:[t]).reduce(async(t,c)=>{const l=await t;if(l)return l;const f=s(c)?{key:c}:c;if(!Object.keys(f).length)return;const{condition:g,consent:m,fn:v,key:w,loop:k,map:S,set:j,validate:E,value:_}=f;if(g&&!await y(g)(e,c,o))return;if(m&&!d(m,a))return _;let L=i(_)?_:e;if(v&&(L=await y(v)(e,c,n)),w&&(L=u(e,w,_)),k){const[t,o]=k,a="this"===t?[e]:await b(e,t,n);r(a)&&(L=(await Promise.all(a.map(e=>b(e,o,n)))).filter(i))}else S?L=await Object.entries(S).reduce(async(t,[o,r])=>{const a=await t,s=await b(e,r,n);return i(s)&&(a[o]=s),a},Promise.resolve({})):j&&(L=await Promise.all(j.map(t=>h(e,t,n))));E&&!await y(E)(L)&&(L=void 0);const O=p(L);return i(O)?O:p(_)},Promise.resolve(void 0))}async function v(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await b(e,o,{collector:n});e=l(e,t,r)}));const{eventMapping:i,mappingKey:s}=await async function(e,t){var n;const[o,i]=(e.name||"").split(" ");if(!t||!o||!i)return{};let a,s="",c=o,u=i;const l=t=>{if(t)return(t=r(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[c]||(c="*");const d=t[c];return d&&(d[u]||(u="*"),a=l(d[u])),a||(c="*",u="*",a=l(null==(n=t[c])?void 0:n[u])),a&&(s=`${c} ${u}`),{eventMapping:a,mappingKey:s}}(e,t.mapping);(null==i?void 0:i.policy)&&await Promise.all(Object.entries(i.policy).map(async([t,o])=>{const r=await b(e,o,{collector:n});e=l(e,t,r)}));let c=t.data&&await b(e,t.data,{collector:n});if(i){if(i.ignore)return{event:e,data:c,mapping:i,mappingKey:s,ignore:!0};if(i.name&&(e.name=i.name),i.data){const t=i.data&&await b(e,i.data,{collector:n});c=a(c)&&a(t)?o(c,t):t}}return{event:e,data:c,mapping:i,mappingKey:s,ignore:!1}}function w(e,t,n){return function(...o){let r;const i="post"+t,a=n["pre"+t],s=n[i];return r=a?a({fn:e},...o):e(...o),s&&(r=s({fn:e,result:r},...o)),r}}var k={Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Session:"session",User:"user",Walker:"walker"};async function S(e,t,n){const{allowed:r,consent:i,globals:a,user:s}=e;if(!r)return _({ok:!1});t&&e.queue.push(t),n||(n=e.destinations);const u=await Promise.all(Object.entries(n||{}).map(async([n,r])=>{let u=(r.queue||[]).map(e=>({...e,consent:i}));if(r.queue=[],t){const e=c(t);u.push(e)}if(!u.length)return{id:n,destination:r,skipped:!0};const l=[],f=u.filter(e=>{const t=d(r.config.consent,i,e.consent);return!t||(e.consent=t,l.push(e),!1)});if(r.queue.concat(f),!l.length)return{id:n,destination:r,queue:u};if(!await y(j)(e,r))return{id:n,destination:r,queue:u};let g=!1;return r.dlq||(r.dlq=[]),await Promise.all(l.map(async t=>(t.globals=o(a,t.globals),t.user=o(s,t.user),await y(E,n=>(e.config.onError&&e.config.onError(n,e),g=!0,r.dlq.push([t,n]),!1))(e,r,t),t))),{id:n,destination:r,error:g}})),l=[],f=[],g=[];for(const e of u){if(e.skipped)continue;const t=e.destination,n={id:e.id,destination:t};e.error?g.push(n):e.queue&&e.queue.length?(t.queue=(t.queue||[]).concat(e.queue),f.push(n)):l.push(n)}return _({ok:!g.length,event:t,successful:l,queued:f,failed:g})}async function j(e,t){if(t.init&&!t.config.init){const n={collector:e,config:t.config,env:L(t.env,t.config.env)},o=await w(t.init,"DestinationInit",e.hooks)(n);if(!1===o)return o;t.config={...o||t.config,init:!0}}return!0}async function E(e,t,n){var o;const{config:r}=t,a=await v(n,r,e);if(a.ignore)return!1;const s={collector:e,config:r,data:a.data,mapping:a.mapping,env:L(t.env,r.env)},c=a.mapping;if((null==c?void 0:c.batch)&&t.pushBatch){const n=c.batched||{key:a.mappingKey||"",events:[],data:[]};n.events.push(a.event),i(a.data)&&n.data.push(a.data),c.batchFn=c.batchFn||function(e,t=1e3,n=!1){let o,r=null,i=!1;return(...a)=>new Promise(s=>{const c=n&&!i;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n&&!i||(o=e(...a),s(o))},t),c&&(i=!0,o=e(...a),s(o))})}((e,t)=>{const o={collector:t,config:r,data:a.data,mapping:c,env:L(e.env,r.env)};w(e.pushBatch,"DestinationPushBatch",t.hooks)(n,o),n.events=[],n.data=[]},c.batch),c.batched=n,null==(o=c.batchFn)||o.call(c,t,e)}else await w(t.push,"DestinationPush",e.hooks)(a.event,s);return!0}function _(e){var t;return o({ok:!(null==(t=null==e?void 0:e.failed)?void 0:t.length),successful:[],queued:[],failed:[]},e)}function L(e,t){return e||t?t?e&&a(e)&&a(t)?{...e,...t}:t:e:{}}function O(e,t,n,o){let r,i=n||[];switch(n||(i=e.on[t]||[]),t){case k.Consent:r=o||e.consent;break;case k.Session:r=e.session;break;case k.Ready:case k.Run:default:r=void 0}if(Object.values(e.sources).forEach(e=>{e.on&&m(e.on)(t,r)}),Object.values(e.destinations).forEach(e=>{if(e.on){m(e.on)(t,r)}}),i.length)switch(t){case k.Consent:!function(e,t,n){const o=n||e.consent;t.forEach(t=>{Object.keys(o).filter(e=>e in t).forEach(n=>{m(t[n])(e,o)})})}(e,i,o);break;case k.Ready:case k.Run:s=i,(a=e).allowed&&s.forEach(e=>{m(e)(a)});break;case k.Session:!function(e,t){e.session&&t.forEach(t=>{m(t)(e,e.session)})}(e,i)}var a,s}async function x(e,t,n,i){let c;switch(t){case k.Config:a(n)&&o(e.config,n,{shallow:!1});break;case k.Consent:a(n)&&(c=await async function(e,t){const{consent:n}=e;let r=!1;const i={};return Object.entries(t).forEach(([e,t])=>{const n=!!t;i[e]=n,r=r||n}),e.consent=o(n,i),O(e,"consent",void 0,i),r?S(e):_({ok:!0})}(e,n));break;case k.Custom:a(n)&&(e.custom=o(e.custom,n));break;case k.Destination:a(n)&&"function"==typeof n.push&&(c=await async function(e,t,n){const{code:o,config:r={},env:i={}}=t,a=n||r||{init:!1},s={...o,config:a,env:L(o.env,i)};let c=s.config.id;if(!c)do{c=f(4)}while(e.destinations[c]);return e.destinations[c]=s,!1!==s.config.queue&&(s.queue=[...e.queue]),S(e,void 0,{[c]:s})}(e,{code:n},i));break;case k.Globals:a(n)&&(e.globals=o(e.globals,n));break;case k.On:s(n)&&function(e,t,n){const o=e.on,i=o[t]||[],a=r(n)?n:[n];a.forEach(e=>{i.push(e)}),o[t]=i,O(e,t,a)}(e,n,i);break;case k.Ready:O(e,"ready");break;case k.Run:c=await async function(e,t){e.allowed=!0,e.count=0,e.group=f(),e.timing=Date.now(),t&&(t.consent&&(e.consent=o(e.consent,t.consent)),t.user&&(e.user=o(e.user,t.user)),t.globals&&(e.globals=o(e.config.globalsStatic||{},t.globals)),t.custom&&(e.custom=o(e.custom,t.custom))),Object.values(e.destinations).forEach(e=>{e.queue=[]}),e.queue=[],e.round++;const n=await S(e);return O(e,"run"),n}(e,n);break;case k.Session:O(e,"session");break;case k.User:a(n)&&o(e.user,n,{shallow:!1})}return c||{ok:!0,successful:[],queued:[],failed:[]}}function A(e,t){return w(async(n,o={})=>await y(async()=>{let r=n;if(o.mapping){const t=await v(r,o.mapping,e);if(t.ignore)return _({ok:!0});if(o.mapping.consent&&!d(o.mapping.consent,e.consent,t.event.consent))return _({ok:!0});r=t.event}const i=t(r),a=function(e,t){if(!t.name)throw new Error("Event name is required");const[n,o]=t.name.split(" ");if(!n||!o)throw new Error("Event name is invalid");++e.count;const{timestamp:r=Date.now(),group:i=e.group,count:a=e.count}=t,{name:s=`${n} ${o}`,data:c={},context:u={},globals:l=e.globals,custom:d={},user:f=e.user,nested:g=[],consent:p=e.consent,id:m=`${r}-${i}-${a}`,trigger:y="",entity:b=n,action:h=o,timing:v=0,version:w={source:e.version,tagging:e.config.tagging||0},source:k={type:"collector",id:"",previous_id:""}}=t;return{name:s,data:c,context:u,globals:l,custom:d,user:f,nested:g,consent:p,id:m,trigger:y,entity:b,action:h,timestamp:r,timing:v,group:i,count:a,version:w,source:k}}(e,i);return await S(e,a)},()=>_({ok:!1}))(),"Push",e.hooks)}async function C(e){const t=o({globalsStatic:{},sessionStatic:{},tagging:0,verbose:!1,onLog:n,run:!0},e,{merge:!1,extend:!1});function n(e,n){!function(e,t=!1){t&&console.dir(e,{depth:4})}({message:e},n||t.verbose)}t.onLog=n;const r={...t.globalsStatic,...e.globals},i={allowed:!1,config:t,consent:e.consent||{},count:0,custom:e.custom||{},destinations:{},globals:r,group:"",hooks:{},on:{},queue:[],round:0,session:void 0,timing:Date.now(),user:e.user||{},version:"0.3.1",sources:{},push:void 0,command:void 0};return i.push=A(i,e=>({timing:Math.round((Date.now()-i.timing)/10)/100,source:{type:"collector",id:"",previous_id:""},...e})),i.command=(s=x,w(async(e,t,n)=>await y(async()=>await s(a,e,t,n),()=>_({ok:!1}))(),"Command",(a=i).hooks)),i.destinations=await async function(e,t={}){const n={};for(const[e,o]of Object.entries(t)){const{code:t,config:r={},env:i={}}=o,a={...t.config,...r},s=L(t.env,i);n[e]={...t,config:a,env:s}}return n}(0,e.destinations||{}),i;var a,s}async function q(e){e=e||{};const t=await C(e),n=(o=t,{type:"elb",config:{},push:async(e,t,n,r,i,a)=>{if("string"==typeof e&&e.startsWith("walker ")){const r=e.replace("walker ","");return o.command(r,t,n)}let s;if("string"==typeof e)s={name:e},t&&"object"==typeof t&&!Array.isArray(t)&&(s.data=t);else{if(!e||"object"!=typeof e)return{ok:!1,successful:[],queued:[],failed:[]};s=e,t&&"object"==typeof t&&!Array.isArray(t)&&(s.data={...s.data||{},...t})}return r&&"object"==typeof r&&(s.context=r),i&&Array.isArray(i)&&(s.nested=i),a&&"object"==typeof a&&(s.custom=a),o.push(s)}});var o;t.sources.elb=n;const r=await async function(e,t={}){const n={};for(const[o,r]of Object.entries(t)){const{code:t,config:i={},env:a={},primary:s}=r,c={push:(t,n={})=>e.push(t,{...n,mapping:i}),command:e.command,sources:e.sources,elb:e.sources.elb.push,...a},u=await y(t)(i,c);u&&(s&&(u.config={...u.config,primary:s}),n[o]=u)}return n}(t,e.sources||{});Object.assign(t.sources,r);const{consent:i,user:a,globals:s,custom:c}=e;i&&await t.command("consent",i),a&&await t.command("user",a),s&&Object.assign(t.globals,s),c&&Object.assign(t.custom,c),t.config.run&&await t.command("run");let u=n.push;const l=Object.values(t.sources).filter(e=>"elb"!==e.type),d=l.find(e=>e.config.primary);return d?u=d.push:l.length>0&&(u=l[0].push),{collector:t,elb:u}}function $(e,t){return(e.getAttribute(t)||"").trim()}var P=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)};function D(e){const t=getComputedStyle(e);if("none"===t.display)return!1;if("visible"!==t.visibility)return!1;if(t.opacity&&Number(t.opacity)<.1)return!1;let n;const o=window.innerHeight,r=e.getBoundingClientRect(),i=r.height,a=r.y,s=a+i,c={x:r.x+e.offsetWidth/2,y:r.y+e.offsetHeight/2};if(i<=o){if(e.offsetWidth+r.width===0||e.offsetHeight+r.height===0)return!1;if(c.x<0)return!1;if(c.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(c.y<0)return!1;if(c.y>(document.documentElement.clientHeight||window.innerHeight))return!1;n=document.elementFromPoint(c.x,c.y)}else{const e=o/2;if(a<0&&s<e)return!1;if(s>o&&a>e)return!1;n=document.elementFromPoint(c.x,o/2)}if(n)do{if(n===e)return!0}while(n=n.parentElement);return!1}function R(e,t,n){return!1===n?e:(n||(n=X),n(e,t,X))}var X=(e,t)=>{const n={};return e.id&&(n.session=e.id),e.storage&&e.device&&(n.device=e.device),t?t.command("user",n):P("walker user",n),e.isStart&&(t?t.push({name:"session start",data:e}):P({name:"session start",data:e})),e};function I(e,n=t.Storage.Session){var o;function r(e){try{return JSON.parse(e||"")}catch(t){let n=1,o="";return e&&(n=0,o=e),{e:n,v:o}}}let i,a;switch(n){case t.Storage.Cookie:i=decodeURIComponent((null==(o=document.cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:o.split("=")[1])||"");break;case t.Storage.Local:a=r(window.localStorage.getItem(e));break;case t.Storage.Session:a=r(window.sessionStorage.getItem(e))}return a&&(i=a.v,0!=a.e&&a.e<Date.now()&&(function(e,n=t.Storage.Session){switch(n){case t.Storage.Cookie:N(e,"",0,n);break;case t.Storage.Local:window.localStorage.removeItem(e);break;case t.Storage.Session:window.sessionStorage.removeItem(e)}}(e,n),i="")),function(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}(i||"")}function N(e,n,o=30,r=t.Storage.Session,i){const a={e:Date.now()+6e4*o,v:String(n)},s=JSON.stringify(a);switch(r){case t.Storage.Cookie:{n="object"==typeof n?JSON.stringify(n):n;let t=`${e}=${encodeURIComponent(n)}; max-age=${60*o}; path=/; SameSite=Lax; secure`;i&&(t+="; domain="+i),document.cookie=t;break}case t.Storage.Local:window.localStorage.setItem(e,s);break;case t.Storage.Session:window.sessionStorage.setItem(e,s)}return I(e,r)}function W(e={}){const t=Date.now(),{length:n=30,deviceKey:o="elbDeviceId",deviceStorage:r="local",deviceAge:i=30,sessionKey:a="elbSessionId",sessionStorage:s="local",pulse:c=!1}=e,u=T(e);let l=!1;const d=m((e,t,n)=>{let o=I(e,n);return o||(o=f(8),N(e,o,1440*t,n)),String(o)})(o,i,r),g=m((e,o)=>{const r=JSON.parse(String(I(e,o)));return c||(r.isNew=!1,u.marketing&&(Object.assign(r,u),l=!0),l||r.updated+6e4*n<t?(delete r.id,delete r.referrer,r.start=t,r.count++,r.runs=1,l=!0):r.runs++),r},()=>{l=!0})(a,s)||{},p={id:f(12),start:t,isNew:!0,count:1,runs:1},y=Object.assign(p,u,g,{device:d},{isStart:l,storage:!0,updated:t},e.data);return N(a,JSON.stringify(y),2*n,s),y}function T(e={}){let t=e.isStart||!1;const n={isStart:t,storage:!1};if(!1===e.isStart)return n;if(!t){const[e]=performance.getEntriesByType("navigation");if("navigate"!==e.type)return n}const r=new URL(e.url||window.location.href),i=e.referrer||document.referrer,a=i&&new URL(i).hostname,s=function(e,t={}){const n="clickId",r={},i={utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term",dclid:n,fbclid:n,gclid:n,msclkid:n,ttclid:n,twclid:n,igshid:n,sclid:n};return Object.entries(o(i,t)).forEach(([t,o])=>{const i=e.searchParams.get(t);i&&(o===n&&(o=t,r[n]=t),r[o]=i)}),r}(r,e.parameters);if(Object.keys(s).length&&(s.marketing||(s.marketing=!0),t=!0),!t){const n=e.domains||[];n.push(r.hostname),t=!n.includes(a)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:f(12),referrer:a},s,e.data):n}var M=Object.defineProperty,U=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},H={merge:!0,shallow:!0,extend:!0};function B(e,t={},n={}){n={...H,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function G(e){return Array.isArray(e)}function K(e){return e===document||e instanceof Element}function F(e){return"object"==typeof e&&null!==e&&!G(e)&&"[object Object]"===Object.prototype.toString.call(e)}function J(e){return"string"==typeof e}function z(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function Y(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function V(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function Q(e,t,n=!0){return e+(null!=t?(n?"-":"")+t:"")}function Z(e,t,n,o=!0){return le($(t,Q(e,n,o))||"").reduce((e,n)=>{let[o,r]=de(n);if(!o)return e;if(r||(o.endsWith(":")&&(o=o.slice(0,-1)),r=""),r.startsWith("#")){r=r.slice(1);try{let e=t[r];e||"selected"!==r||(e=t.options[t.selectedIndex].text),r=String(e)}catch(e){r=""}}return o.endsWith("[]")?(o=o.slice(0,-2),G(e[o])||(e[o]=[]),e[o].push(z(r))):e[o]=z(r),e},{})}function ee(e,t=k.Prefix){var n;const o=e||document.body;if(!o)return[];let r=[];const i=k.Action,a=`[${Q(t,i,!1)}]`,s=e=>{Object.keys(Z(t,e,i,!1)).forEach(n=>{r=r.concat(te(e,n,t))})};return o!==document&&(null==(n=o.matches)?void 0:n.call(o,a))&&s(o),ue(o,a,s),r}function te(e,t,n=k.Prefix){const o=[],{actions:r,nearestOnly:i}=function(e,t,n){let o=t;for(;o;){const t=$(o,Q(e,k.Actions,!1));if(t){const e=re(t);if(e[n])return{actions:e[n],nearestOnly:!1}}const r=$(o,Q(e,k.Action,!1));if(r){const e=re(r);if(e[n]||"click"!==n)return{actions:e[n]||[],nearestOnly:!0}}o=se(e,o)}return{actions:[],nearestOnly:!1}}(n,e,t);return r.length?(r.forEach(r=>{const a=le(r.actionParams||"",",").reduce((e,t)=>(e[V(t)]=!0,e),{}),s=ie(n,e,a,i);if(!s.length){const t="page",o=`[${Q(n,t)}]`,[r,i]=ce(e,o,n,t);s.push({entity:t,data:r,nested:[],context:i})}s.forEach(e=>{o.push({entity:e.entity,action:r.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),o):o}function ne(e=k.Prefix,t=document){const n=Q(e,k.Globals,!1);let o={};return ue(t,`[${n}]`,t=>{o=B(o,Z(e,t,k.Globals,!1))}),o}function oe(e,t){const n=window.location,o="page",r=t===document?document.body:t,[i,a]=ce(r,`[${Q(e,o)}]`,e,o);return i.domain=n.hostname,i.title=document.title,i.referrer=document.referrer,n.search&&(i.search=n.search),n.hash&&(i.hash=n.hash),[i,a]}function re(e){const t={};return le(e).forEach(e=>{const[n,o]=de(e),[r,i]=fe(n);if(!r)return;let[a,s]=fe(o||"");a=a||r,t[r]||(t[r]=[]),t[r].push({trigger:r,triggerParams:i,action:a,actionParams:s})}),t}function ie(e,t,n,o=!1){const r=[];let i=t;for(n=0!==Object.keys(n||{}).length?n:void 0;i;){const a=ae(e,i,t,n);if(a&&(r.push(a),o))break;i=se(e,i)}return r}function ae(e,t,n,o){const r=$(t,Q(e));if(!r||o&&!o[r])return null;const i=[t],a=`[${Q(e,r)}],[${Q(e,"")}]`,s=Q(e,k.Link,!1);let c={};const u=[],[l,d]=ce(n||t,a,e,r);ue(t,`[${s}]`,t=>{const[n,o]=de($(t,s));"parent"===o&&ue(document.body,`[${s}="${n}:child"]`,t=>{i.push(t);const n=ae(e,t);n&&u.push(n)})});const f=[];i.forEach(e=>{e.matches(a)&&f.push(e),ue(e,a,e=>f.push(e))});let g={};return f.forEach(t=>{g=B(g,Z(e,t,"")),c=B(c,Z(e,t,r))}),c=B(B(g,c),l),i.forEach(t=>{ue(t,`[${Q(e)}]`,t=>{const n=ae(e,t);n&&u.push(n)})}),{entity:r,data:c,context:d,nested:u}}function se(e,t){const n=Q(e,k.Link,!1);if(t.matches(`[${n}]`)){const[e,o]=de($(t,n));if("child"===o)return document.querySelector(`[${n}="${e}:parent"]`)}return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof ShadowRoot?t.getRootNode().host:t.parentElement}function ce(e,t,n,o){let r={};const i={};let a=e;const s=`[${Q(n,k.Context,!1)}]`;let c=0;for(;a;)a.matches(t)&&(r=B(Z(n,a,""),r),r=B(Z(n,a,o),r)),a.matches(s)&&(Object.entries(Z(n,a,k.Context,!1)).forEach(([e,t])=>{t&&!i[e]&&(i[e]=[t,c])}),++c),a=se(n,a);return[r,i]}function ue(e,t,n){e.querySelectorAll(t).forEach(n)}function le(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function de(e){const[t,n]=e.split(/:(.+)/,2);return[V(t),V(n)]}function fe(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var ge,pe=new WeakMap,me=new WeakMap,ye=new WeakMap;function be(e){const t=Date.now();let n=me.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:D(e),lastChecked:t},me.set(e,n)),n.isVisible}function he(e){if(window.IntersectionObserver)return Y(()=>new window.IntersectionObserver(t=>{t.forEach(t=>{!function(e,t){var n,o;const r=t.target,i=ye.get(e);if(!i)return;const a=i.timers.get(r);if(t.intersectionRatio>0){const o=Date.now();let s=pe.get(r);if((!s||o-s.lastChecked>1e3)&&(s={isLarge:r.offsetHeight>window.innerHeight,lastChecked:o},pe.set(r,s)),t.intersectionRatio>=.5||s.isLarge&&be(r)){const t=null==(n=i.elementConfigs)?void 0:n.get(r);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!a){const t=window.setTimeout(async()=>{var t,n;if(be(r)){const o=null==(t=i.elementConfigs)?void 0:t.get(r);(null==o?void 0:o.context)&&await qe(o.context,r,o.trigger);const a=null==(n=i.elementConfigs)?void 0:n.get(r);(null==a?void 0:a.multiple)?a.blocked=!0:function(e,t){const n=ye.get(e);if(!n)return;n.observer&&n.observer.unobserve(t);const o=n.timers.get(t);o&&(clearTimeout(o),n.timers.delete(t)),pe.delete(t),me.delete(t)}(e,r)}},i.duration);i.timers.set(r,t)}return}}a&&(clearTimeout(a),i.timers.delete(r));const s=null==(o=i.elementConfigs)?void 0:o.get(r);(null==s?void 0:s.multiple)&&(s.blocked=!1)}(e,t)})},{rootMargin:"0px",threshold:[0,.5]}),()=>{})()}function ve(e,t,n={multiple:!1}){var o;const r=e.settings.scope||document,i=ye.get(r);(null==i?void 0:i.observer)&&t&&(i.elementConfigs||(i.elementConfigs=new WeakMap),i.elementConfigs.set(t,{multiple:null!=(o=n.multiple)&&o,blocked:!1,context:e,trigger:n.multiple?"visible":"impression"}),i.observer.observe(t))}function we(e){if(!e)return;const t=ye.get(e);t&&(t.observer&&t.observer.disconnect(),ye.delete(e))}function ke(e,t,n,o,r,i,a){const{elb:s,settings:c}=e;if(J(t)&&t.startsWith("walker "))return s(t,n);if(F(t)){const e=t;return e.source||(e.source=Se()),e.globals||(e.globals=ne(c.prefix,c.scope||document)),s(e)}const[u]=String(F(t)?t.name:t).split(" ");let l,d=F(n)?n:{},f={},g=!1;if(K(n)&&(l=n,g=!0),K(r)?l=r:F(r)&&Object.keys(r).length&&(f=r),l){const e=ie(c.prefix||"data-elb",l).find(e=>e.entity===u);e&&(g&&(d=e.data),f=e.context)}"page"===u&&(d.id=d.id||window.location.pathname);const p=ne(c.prefix,c.scope);return s({name:String(t||""),data:d,context:f,globals:p,nested:i,custom:a,trigger:J(o)?o:"",source:Se()})}function Se(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var je=[],Ee="hover",_e="load",Le="pulse",Oe="scroll",xe="wait";function Ae(e,t){t.scope&&function(e,t){const n=t.scope;n&&(n.addEventListener("click",Y(function(t){Pe.call(this,e,t)})),n.addEventListener("submit",Y(function(t){De.call(this,e,t)})))}(e,t)}function Ce(e,t){t.scope&&function(e,t){const n=t.scope;je=[];const o=n||document;we(o),function(e,t=1e3){ye.has(e)||ye.set(e,{observer:he(e),timers:new WeakMap,duration:t})}(o,1e3);const r=Q(t.prefix,k.Action,!1);o!==document&&$e(e,o,r,t),o.querySelectorAll(`[${r}]`).forEach(n=>{$e(e,n,r,t)}),je.length&&function(e,t){const n=(e,t)=>e.filter(([e,n])=>{const o=window.scrollY+window.innerHeight,r=e.offsetTop;if(o<r)return!0;const i=e.clientHeight;return!(100*(1-(r+i-o)/(i||1))>=n&&(qe(t,e,Oe),1))});ge||(ge=function(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}(function(){je=n.call(t,je,e)}),t.addEventListener("scroll",ge))}(e,o)}(e,t)}async function qe(e,t,n){const o=te(t,n,e.settings.prefix);return Promise.all(o.map(t=>ke(e,{name:`${t.entity} ${t.action}`,...t,trigger:n})))}function $e(e,t,n,o){const r=$(t,n);r&&Object.values(re(r)).forEach(n=>n.forEach(n=>{switch(n.trigger){case Ee:o=e,t.addEventListener("mouseenter",Y(function(e){e.target instanceof Element&&qe(o,e.target,Ee)}));break;case _e:!function(e,t){qe(e,t,_e)}(e,t);break;case Le:!function(e,t,n=""){setInterval(()=>{document.hidden||qe(e,t,Le)},parseInt(n||"")||15e3)}(e,t,n.triggerParams);break;case Oe:!function(e,t=""){const n=parseInt(t||"")||50;n<0||n>100||je.push([e,n])}(t,n.triggerParams);break;case"impression":ve(e,t);break;case"visible":ve(e,t,{multiple:!0});break;case xe:!function(e,t,n=""){setTimeout(()=>qe(e,t,xe),parseInt(n||"")||15e3)}(e,t,n.triggerParams)}var o}))}function Pe(e,t){qe(e,t.target,"click")}function De(e,t){t.target&&qe(e,t.target,"submit")}function Re(e,t,n,o){const r=[];let i=!0;n.forEach(e=>{const t=Ie(e)?[...Array.from(e)]:null!=(n=e)&&"object"==typeof n&&"length"in n&&"number"==typeof n.length?Array.from(e):[e];var n;if(Array.isArray(t)&&0===t.length)return;if(Array.isArray(t)&&1===t.length&&!t[0])return;const a=t[0],s=!F(a)&&J(a)&&a.startsWith("walker ");if(F(a)){if("object"==typeof a&&0===Object.keys(a).length)return}else{const e=Array.from(t);if(!J(e[0])||""===e[0].trim())return;const n="walker run";i&&e[0]===n&&(i=!1)}(o&&s||!o&&!s)&&r.push(t)}),r.forEach(n=>{Xe(e,t,n)})}function Xe(e,t="data-elb",n){Y(()=>{if(Array.isArray(n)){const[o,...r]=n;if(!o||J(o)&&""===o.trim())return;if(J(o)&&o.startsWith("walker "))return void e(o,r[0]);ke({elb:e,settings:{prefix:t,scope:document,pageview:!1,session:!1,elb:"",elbLayer:!1}},o,...r)}else if(n&&"object"==typeof n){if(0===Object.keys(n).length)return;e(n)}},()=>{})()}function Ie(e){return null!=e&&"object"==typeof e&&"[object Arguments]"===Object.prototype.toString.call(e)}function Ne(e,t={},n){return function(e={}){const{cb:t,consent:n,collector:o,storage:a}=e;if(!n)return R((a?W:T)(e),o,t);{const a=function(e,t){let n;return(o,a)=>{if(i(n)&&n===(null==o?void 0:o.group))return;n=null==o?void 0:o.group;let s=()=>T(e);return e.consent&&d((r(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{}),a)&&(s=()=>W(e)),R(s(),o,t)}}(e,t),s=(r(n)?n:[n]).reduce((e,t)=>({...e,[t]:a}),{});o?o.command("on","consent",s):P("walker on","consent",s)}}({...t,collector:{push:e,group:void 0,command:n}})}U({},{env:()=>We});var We={};U(We,{push:()=>Ue});var Te=()=>{},Me=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),Ue={get push(){return Me()},get command(){return Me()},get elb(){return Me()},get window(){return{addEventListener:Te,removeEventListener:Te,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:Te,removeEventListener:Te,querySelector:Te,querySelectorAll:()=>[],getElementById:Te,getElementsByClassName:()=>[],getElementsByTagName:()=>[],createElement:()=>({setAttribute:Te,getAttribute:Te,addEventListener:Te,removeEventListener:Te}),body:{appendChild:Te,removeChild:Te},documentElement:{scrollTop:0,scrollLeft:0},readyState:"complete",title:"Test Page",referrer:"",cookie:""}}},He=async(e,t)=>{const{elb:n,command:o,window:r,document:i}=t,a=(null==e?void 0:e.settings)||{},s=r||(void 0!==globalThis.window?globalThis.window:void 0),c=i||(void 0!==globalThis.document?globalThis.document:void 0),u=function(e={},t){return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:t||void 0,...e}}(a,c),l={settings:u},d={elb:n,settings:u};if(s&&c){if(!1!==u.elbLayer&&n&&function(e,t={}){const n=t.name||"elbLayer",o=t.window||window;if(!o)return;const r=o;r[n]||(r[n]=[]);const i=r[n];i.push=function(...n){if(Ie(n[0])){const o=[...Array.from(n[0])],r=Array.prototype.push.apply(this,[o]);return Xe(e,t.prefix,o),r}const o=Array.prototype.push.apply(this,n);return n.forEach(n=>{Xe(e,t.prefix,n)}),o},Array.isArray(i)&&i.length>0&&function(e,t="data-elb",n){Re(e,t,n,!0),Re(e,t,n,!1),n.length=0}(e,t.prefix,i)}(n,{name:J(u.elbLayer)?u.elbLayer:"elbLayer",prefix:u.prefix,window:s}),u.session&&n){const e="boolean"==typeof u.session?{}:u.session;Ne(n,e,o)}await async function(e,t,n){const o=()=>{e(t,n)};"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o)}(Ae,d,u),(()=>{if(Ce(d,u),u.pageview){const[e,t]=oe(u.prefix||"data-elb",u.scope);ke(d,"page view",e,"load",t)}})(),J(u.elb)&&u.elb&&(s[u.elb]=(...e)=>{const[t,n,o,r,i,a]=e;return ke(d,t,n,o,r,i,a)})}return{type:"browser",config:l,push:(...e)=>{const[t,n,o,r,i,a]=e;return ke(d,t,n,o,r,i,a)},destroy:async()=>{c&&we(u.scope||c)},on:async(e,t)=>{switch(e){case"consent":if(u.session&&t&&n){const e="boolean"==typeof u.session?{}:u.session;Ne(n,e,o)}break;case"session":case"ready":default:break;case"run":if(c&&s&&(Ce(d,u),u.pageview)){const[e,t]=oe(u.prefix||"data-elb",u.scope);ke(d,"page view",e,"load",t)}}}}},Be=Object.defineProperty,Ge=(e,t)=>{for(var n in t)Be(e,n,{get:t[n],enumerable:!0})},Ke=!1;function Fe(e,t={},n){if(t.filter&&!0===m(()=>t.filter(n),()=>!1)())return;const o=function(e){if(a(e)&&s(e.event)){const{event:t,...n}=e;return{name:t,...n}}return r(e)&&e.length>=2?Je(e):null!=(t=e)&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&t.length>0?Je(Array.from(e)):null;var t}(n);if(!o)return;const i=`${t.prefix||"dataLayer"} ${o.name}`,{name:c,...u}=o,l={name:i,data:u};m(()=>e(l),()=>{})()}function Je(e){const[t,n,o]=e;if(!s(t))return null;let r,i={};switch(t){case"consent":if(!s(n)||e.length<3)return null;if("default"!==n&&"update"!==n)return null;if(!a(o)||null===o)return null;r=`${t} ${n}`,i={...o};break;case"event":if(!s(n))return null;r=n,a(o)&&(i={...o});break;case"config":if(!s(n))return null;r=`${t} ${n}`,a(o)&&(i={...o});break;case"set":if(s(n))r=`${t} ${n}`,a(o)&&(i={...o});else{if(!a(n))return null;r=`${t} custom`,i={...n}}break;default:return null}return{name:r,...i}}Ge({},{push:()=>Ve});var ze=()=>{},Ye=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),Ve={get push(){return Ye()},get command(){return Ye()},get elb(){return Ye()},get window(){return{dataLayer:[],addEventListener:ze,removeEventListener:ze}}};function Qe(){return["consent","update",{ad_user_data:"granted",ad_personalization:"granted",ad_storage:"denied",analytics_storage:"granted"}]}function Ze(){return["consent","default",{ad_storage:"denied",analytics_storage:"denied",ad_user_data:"denied",ad_personalization:"denied"}]}function et(){return["event","purchase",{transaction_id:"T_12345",value:25.42,currency:"EUR",items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",quantity:1,price:25.42}]}]}function tt(){return["event","add_to_cart",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_variant:"red",quantity:1,price:15.25}]}]}function nt(){return["event","view_item",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",price:15.25}]}]}function ot(){return["config","G-XXXXXXXXXX",{page_title:"Custom Page Title",page_location:"https://example.com/page",send_page_view:!1}]}function rt(){return["set",{currency:"EUR",country:"DE"}]}function it(){return{event:"custom_event",custom_parameter:"custom_value",user_id:"user123"}}Ge({},{add_to_cart:()=>tt,config:()=>ot,consentDefault:()=>Ze,consentUpdate:()=>Qe,directDataLayerEvent:()=>it,purchase:()=>et,setCustom:()=>rt,view_item:()=>nt});Ge({},{add_to_cart:()=>ct,config:()=>ft,configGA4:()=>lt,consentOnlyMapping:()=>gt,consentUpdate:()=>at,customEvent:()=>dt,purchase:()=>st,view_item:()=>ut});var at={name:"walker consent",settings:{command:{map:{functional:{value:!0},analytics:{key:"analytics_storage",fn:e=>"granted"===e},marketing:{key:"ad_storage",fn:e=>"granted"===e}}}}},st={name:"order complete",data:{map:{id:"transaction_id",total:"value",currency:"currency",nested:{loop:["items",{map:{type:{value:"product"},data:{map:{id:"item_id",name:"item_name",category:"item_category",quantity:"quantity",price:"price"}}}}]}}}},ct={name:"product add",data:{map:{id:"items.0.item_id",name:"items.0.item_name",price:"value",currency:"currency",color:"items.0.item_variant",quantity:"items.0.quantity"}}},ut={name:"product view",data:{map:{id:"items.0.item_id",name:"items.0.item_name",category:"items.0.item_category",price:"items.0.price",currency:"currency"}}},lt={name:"page view",data:{map:{title:"page_title",url:"page_location"}}},dt={data:{map:{user_id:"user_id",custom_parameter:"custom_parameter"}}},ft={consent:{update:at},purchase:st,add_to_cart:ct,view_item:ut,"config G-XXXXXXXXXX":lt,custom_event:dt,"*":{data:{}}},gt={consent:{update:at}},pt=async(e,t)=>{const{elb:n,window:o}=t,r={name:"dataLayer",prefix:"dataLayer",...null==e?void 0:e.settings},i={settings:r};return o&&(function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer",r=window[o];if(Array.isArray(r)&&!Ke){Ke=!0;try{for(const t of r)Fe(e,n,t)}finally{Ke=!1}}}(n,i),function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer";window[o]||(window[o]=[]);const r=window[o];if(!Array.isArray(r))return;const i=r.push.bind(r);r.push=function(...t){if(Ke)return i(...t);Ke=!0;try{for(const o of t)Fe(e,n,o)}finally{Ke=!1}return i(...t)}}(n,i)),{type:"dataLayer",config:i,push:n,destroy:async()=>{const e=r.name||"dataLayer";o&&o[e]&&Array.isArray(o[e])}}};function mt(){window.dataLayer=window.dataLayer||[];const e=e=>{a(e)&&a(e.source)&&String(e.source.type).includes("dataLayer")||window.dataLayer.push(e)};return{type:"dataLayer",config:{},push:(t,n)=>{e(n.data||t)},pushBatch:t=>{e({name:"batch",batched_event:t.key,events:t.data.length?t.data:t.events})}}}var yt={},bt={};((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})(bt,{browserConfig:()=>vt,collectorConfig:()=>kt,dataLayerConfig:()=>wt,settings:()=>ht});var ht={type:"object",properties:{elb:{type:"string",default:"elb",description:"Global function name for event tracking"},name:{type:"string",default:"walkerjs",description:"Global instance name"},run:{type:"boolean",default:!0,description:"Auto-initialize walker.js on load"},browser:{type:"object",default:{run:!0,session:!0,scope:"document.body",pageview:!0},description:"Browser source configuration. Set to false to disable. See browser configuration section below for details."},dataLayer:{type:"object",default:!1,description:"DataLayer source configuration. Set to true for defaults or object for custom config. See dataLayer configuration section below."},collector:{type:"object",default:{},description:"Collector configuration including destinations and consent settings. See collector configuration section below."}}},vt={type:"object",properties:{"browser.run":{type:"boolean",default:!0,description:"Auto-start DOM tracking"},"browser.session":{type:"boolean",default:!0,description:"Enable session tracking"},"browser.scope":{type:"string",default:"document.body",description:"DOM element scope for tracking"},"browser.pageview":{type:"boolean",default:!0,description:"Enable automatic page view events"}}},wt={type:"object",properties:{dataLayer:{type:"boolean",default:!1,description:"Enable dataLayer integration with defaults"},"dataLayer.name":{type:"string",default:"dataLayer",description:"DataLayer variable name"},"dataLayer.prefix":{type:"string",default:"dataLayer",description:"Event prefix for dataLayer events"}}},kt={type:"object",properties:{"collector.consent":{type:"object",default:{functional:!0},description:"Default consent state"},"collector.destinations":{type:"object",default:{},description:"Destination configurations. See destinations documentation for available options."}}};async function St(e={}){const t=o({collector:{destinations:{dataLayer:{code:mt()}}},browser:{session:!0},dataLayer:!1,elb:"elb",run:!0},e),n={...t.collector,sources:{browser:{code:He,config:{settings:t.browser},env:{window:"undefined"!=typeof window?window:void 0,document:"undefined"!=typeof document?document:void 0}}}};if(t.dataLayer){const e=a(t.dataLayer)?t.dataLayer:{};n.sources&&(n.sources.dataLayer={code:pt,config:{settings:e}})}const r=await q(n);return"undefined"!=typeof window&&(t.elb&&(window[t.elb]=r.elb),t.name&&(window[t.name]=r.collector)),r}var jt=St;export{yt as Walkerjs,St as createWalkerjs,jt as default,ee as getAllEvents,te as getEvents,ne as getGlobals,bt as schemas};//# sourceMappingURL=index.mjs.map
1
+ var e=Object.defineProperty,t=Object.defineProperty;((e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})})({},{Level:()=>o});var n,o=((n=o||{})[n.ERROR=0]="ERROR",n[n.INFO=1]="INFO",n[n.DEBUG=2]="DEBUG",n),r={Storage:{Local:"local",Session:"session",Cookie:"cookie"}},i={merge:!0,shallow:!0,extend:!0};function a(e,t={},n={}){n={...i,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function s(e){return Array.isArray(e)}function c(e){return void 0!==e}function u(e){return"object"==typeof e&&null!==e&&!s(e)&&"[object Object]"===Object.prototype.toString.call(e)}function l(e){return"string"==typeof e}function d(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=d(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(d(e,t))}),n}if("[object Date]"===n)return new Date(e.getTime());if("[object RegExp]"===n){const t=e;return new RegExp(t.source,t.flags)}return e}function f(e,t="",n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&s(r)){const t=o.slice(e+1).join("."),i=[];for(const e of r){const o=f(e,t,n);i.push(o)}return i}if(r=r instanceof Object?r[t]:void 0,!r)break}return c(r)?r:n}function g(e,t,n){if(!u(e))return e;const o=d(e),r=t.split(".");let i=o;for(let e=0;e<r.length;e++){const t=r[e];e===r.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return o}function p(e,t={},n={}){const o={...t,...n},r={};let i=void 0===e;return Object.keys(o).forEach(t=>{o[t]&&(r[t]=!0,e&&e[t]&&(i=!0))}),!!i&&r}function m(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function y(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function b(e,t){let n,o={};return e instanceof Error?(n=e.message,o.error=y(e)):n=e,void 0!==t&&(t instanceof Error?o.error=y(t):"object"==typeof t&&null!==t?(o={...o,...t},"error"in o&&o.error instanceof Error&&(o.error=y(o.error))):o.value=t),{message:n,context:o}}var h=(e,t,n,r)=>{const i=`${o[e]}${r.length>0?` [${r.join(":")}]`:""}`,a=Object.keys(n).length>0;0===e?a?console.error(i,t,n):console.error(i,t):a?console.log(i,t,n):console.log(i,t)};function v(e={}){return w({level:void 0!==e.level?(t=e.level,"string"==typeof t?o[t]:t):0,handler:e.handler,scope:[]});var t}function w(e){const{level:t,handler:n,scope:o}=e,r=(e,r,i)=>{if(e<=t){const t=b(r,i);n?n(e,t.message,t.context,o,h):h(e,t.message,t.context,o)}};return{error:(e,t)=>r(0,e,t),info:(e,t)=>r(1,e,t),debug:(e,t)=>r(2,e,t),throw:(e,t)=>{const r=b(e,t);throw n?n(0,r.message,r.context,o,h):h(0,r.message,r.context,o),new Error(r.message)},scope:e=>w({level:t,handler:n,scope:[...o,e]})}}function k(e){return function(e){return"boolean"==typeof e}(e)||l(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!c(e)||s(e)&&e.every(k)||u(e)&&Object.values(e).every(k)}function E(e){return k(e)?e:void 0}function j(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function S(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(null==n?void 0:n())}}}async function O(e,t={},n={}){var o;if(!c(e))return;const r=u(e)&&e.consent||n.consent||(null==(o=n.collector)?void 0:o.consent),i=s(t)?t:[t];for(const t of i){const o=await S(_)(e,t,{...n,consent:r});if(c(o))return o}}async function _(e,t,n={}){const{collector:o,consent:r}=n;return(s(t)?t:[t]).reduce(async(t,i)=>{const a=await t;if(a)return a;const u=l(i)?{key:i}:i;if(!Object.keys(u).length)return;const{condition:d,consent:g,fn:m,key:y,loop:b,map:h,set:v,validate:w,value:k}=u;if(d&&!await S(d)(e,i,o))return;if(g&&!p(g,r))return k;let j=c(k)?k:e;if(m&&(j=await S(m)(e,i,n)),y&&(j=f(e,y,k)),b){const[t,o]=b,r="this"===t?[e]:await O(e,t,n);s(r)&&(j=(await Promise.all(r.map(e=>O(e,o,n)))).filter(c))}else h?j=await Object.entries(h).reduce(async(t,[o,r])=>{const i=await t,a=await O(e,r,n);return c(a)&&(i[o]=a),i},Promise.resolve({})):v&&(j=await Promise.all(v.map(t=>_(e,t,n))));w&&!await S(w)(j)&&(j=void 0);const L=E(j);return c(L)?L:E(k)},Promise.resolve(void 0))}async function L(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await O(e,o,{collector:n});e=g(e,t,r)}));const{eventMapping:o,mappingKey:r}=await async function(e,t){var n;const[o,r]=(e.name||"").split(" ");if(!t||!o||!r)return{};let i,a="",c=o,u=r;const l=t=>{if(t)return(t=s(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[c]||(c="*");const d=t[c];return d&&(d[u]||(u="*"),i=l(d[u])),i||(c="*",u="*",i=l(null==(n=t[c])?void 0:n[u])),i&&(a=`${c} ${u}`),{eventMapping:i,mappingKey:a}}(e,t.mapping);(null==o?void 0:o.policy)&&await Promise.all(Object.entries(o.policy).map(async([t,o])=>{const r=await O(e,o,{collector:n});e=g(e,t,r)}));let i=t.data&&await O(e,t.data,{collector:n});if(o){if(o.ignore)return{event:e,data:i,mapping:o,mappingKey:r,ignore:!0};if(o.name&&(e.name=o.name),o.data){const t=o.data&&await O(e,o.data,{collector:n});i=u(i)&&u(t)?a(i,t):t}}return{event:e,data:i,mapping:o,mappingKey:r,ignore:!1}}function x(e,t,n){return function(...o){let r;const i="post"+t,a=n["pre"+t],s=n[i];return r=a?a({fn:e},...o):e(...o),s&&(r=s({fn:e,result:r},...o)),r}}var A={Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Session:"session",User:"user",Walker:"walker"};async function C(e,t,n){const{allowed:o,consent:r,globals:i,user:s}=e;if(!o)return q({ok:!1});t&&e.queue.push(t),n||(n=e.destinations);const c=await Promise.all(Object.entries(n||{}).map(async([n,o])=>{let c=(o.queue||[]).map(e=>({...e,consent:r}));if(o.queue=[],t){const e=d(t);c.push(e)}if(!c.length)return{id:n,destination:o,skipped:!0};const u=[],l=c.filter(e=>{const t=p(o.config.consent,r,e.consent);return!t||(e.consent=t,u.push(e),!1)});if(o.queue.concat(l),!u.length)return{id:n,destination:o,queue:c};if(!await S($)(e,o))return{id:n,destination:o,queue:c};let f=!1;return o.dlq||(o.dlq=[]),await Promise.all(u.map(async t=>(t.globals=a(i,t.globals),t.user=a(s,t.user),await S(P,n=>{const r=o.type||"unknown";return e.logger.scope(r).error("Push failed",{error:n,event:t.name}),f=!0,o.dlq.push([t,n]),!1})(e,o,t),t))),{id:n,destination:o,error:f}})),u=[],l=[],f=[];for(const e of c){if(e.skipped)continue;const t=e.destination,n={id:e.id,destination:t};e.error?f.push(n):e.queue&&e.queue.length?(t.queue=(t.queue||[]).concat(e.queue),l.push(n)):u.push(n)}return q({ok:!f.length,event:t,successful:u,queued:l,failed:f})}async function $(e,t){if(t.init&&!t.config.init){const n=t.type||"unknown",o=e.logger.scope(n),r={collector:e,config:t.config,env:R(t.env,t.config.env),logger:o},i=await x(t.init,"DestinationInit",e.hooks)(r);if(!1===i)return i;t.config={...i||t.config,init:!0}}return!0}async function P(e,t,n){var o;const{config:r}=t,i=await L(n,r,e);if(i.ignore)return!1;const a=t.type||"unknown",s=e.logger.scope(a),u={collector:e,config:r,data:i.data,mapping:i.mapping,env:R(t.env,r.env),logger:s},l=i.mapping;if((null==l?void 0:l.batch)&&t.pushBatch){const n=l.batched||{key:i.mappingKey||"",events:[],data:[]};n.events.push(i.event),c(i.data)&&n.data.push(i.data),l.batchFn=l.batchFn||function(e,t=1e3,n=!1){let o,r=null,i=!1;return(...a)=>new Promise(s=>{const c=n&&!i;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n&&!i||(o=e(...a),s(o))},t),c&&(i=!0,o=e(...a),s(o))})}((e,t)=>{const o=e.type||"unknown",a=t.logger.scope(o),s={collector:t,config:r,data:i.data,mapping:l,env:R(e.env,r.env),logger:a};x(e.pushBatch,"DestinationPushBatch",t.hooks)(n,s),n.events=[],n.data=[]},l.batch),l.batched=n,null==(o=l.batchFn)||o.call(l,t,e)}else await x(t.push,"DestinationPush",e.hooks)(i.event,u);return!0}function q(e){var t;return a({ok:!(null==(t=null==e?void 0:e.failed)?void 0:t.length),successful:[],queued:[],failed:[]},e)}function R(e,t){return e||t?t?e&&u(e)&&u(t)?{...e,...t}:t:e:{}}function D(e,t,n,o){let r,i=n||[];switch(n||(i=e.on[t]||[]),t){case A.Consent:r=o||e.consent;break;case A.Session:r=e.session;break;case A.Ready:case A.Run:default:r=void 0}if(Object.values(e.sources).forEach(e=>{e.on&&j(e.on)(t,r)}),Object.values(e.destinations).forEach(e=>{if(e.on){j(e.on)(t,r)}}),i.length)switch(t){case A.Consent:!function(e,t,n){const o=n||e.consent;t.forEach(t=>{Object.keys(o).filter(e=>e in t).forEach(n=>{j(t[n])(e,o)})})}(e,i,o);break;case A.Ready:case A.Run:!function(e,t){e.allowed&&t.forEach(t=>{j(t)(e)})}(e,i);break;case A.Session:!function(e,t){e.session&&t.forEach(t=>{j(t)(e,e.session)})}(e,i)}}async function I(e,t,n,o){let r;switch(t){case A.Config:u(n)&&a(e.config,n,{shallow:!1});break;case A.Consent:u(n)&&(r=await async function(e,t){const{consent:n}=e;let o=!1;const r={};return Object.entries(t).forEach(([e,t])=>{const n=!!t;r[e]=n,o=o||n}),e.consent=a(n,r),D(e,"consent",void 0,r),o?C(e):q({ok:!0})}(e,n));break;case A.Custom:u(n)&&(e.custom=a(e.custom,n));break;case A.Destination:u(n)&&function(e){return"function"==typeof e}(n.push)&&(r=await async function(e,t,n){const{code:o,config:r={},env:i={}}=t,a=n||r||{init:!1},s={...o,config:a,env:R(o.env,i)};let c=s.config.id;if(!c)do{c=m(4)}while(e.destinations[c]);return e.destinations[c]=s,!1!==s.config.queue&&(s.queue=[...e.queue]),C(e,void 0,{[c]:s})}(e,{code:n},o));break;case A.Globals:u(n)&&(e.globals=a(e.globals,n));break;case A.On:l(n)&&function(e,t,n){const o=e.on,r=o[t]||[],i=s(n)?n:[n];i.forEach(e=>{r.push(e)}),o[t]=r,D(e,t,i)}(e,n,o);break;case A.Ready:D(e,"ready");break;case A.Run:r=await async function(e,t){e.allowed=!0,e.count=0,e.group=m(),e.timing=Date.now(),t&&(t.consent&&(e.consent=a(e.consent,t.consent)),t.user&&(e.user=a(e.user,t.user)),t.globals&&(e.globals=a(e.config.globalsStatic||{},t.globals)),t.custom&&(e.custom=a(e.custom,t.custom))),Object.values(e.destinations).forEach(e=>{e.queue=[]}),e.queue=[],e.round++;const n=await C(e);return D(e,"run"),n}(e,n);break;case A.Session:D(e,"session");break;case A.User:u(n)&&a(e.user,n,{shallow:!1})}return r||{ok:!0,successful:[],queued:[],failed:[]}}function N(e,t){return x(async(n,o={})=>await S(async()=>{let r=n;if(o.mapping){const t=await L(r,o.mapping,e);if(t.ignore)return q({ok:!0});if(o.mapping.consent&&!p(o.mapping.consent,e.consent,t.event.consent))return q({ok:!0});r=t.event}const i=t(r),a=function(e,t){if(!t.name)throw new Error("Event name is required");const[n,o]=t.name.split(" ");if(!n||!o)throw new Error("Event name is invalid");++e.count;const{timestamp:r=Date.now(),group:i=e.group,count:a=e.count}=t,{name:s=`${n} ${o}`,data:c={},context:u={},globals:l=e.globals,custom:d={},user:f=e.user,nested:g=[],consent:p=e.consent,id:m=`${r}-${i}-${a}`,trigger:y="",entity:b=n,action:h=o,timing:v=0,version:w={source:e.version,tagging:e.config.tagging||0},source:k={type:"collector",id:"",previous_id:""}}=t;return{name:s,data:c,context:u,globals:l,custom:d,user:f,nested:g,consent:p,id:m,trigger:y,entity:b,action:h,timestamp:r,timing:v,group:i,count:a,version:w,source:k}}(e,i);return await C(e,a)},()=>q({ok:!1}))(),"Push",e.hooks)}async function X(e){var t,n;const o=a({globalsStatic:{},sessionStatic:{},tagging:0,run:!0},e,{merge:!1,extend:!1}),r=v({level:null==(t=e.logger)?void 0:t.level,handler:null==(n=e.logger)?void 0:n.handler}),i={...o.globalsStatic,...e.globals},s={allowed:!1,config:o,consent:e.consent||{},count:0,custom:e.custom||{},destinations:{},globals:i,group:"",hooks:{},logger:r,on:{},queue:[],round:0,session:void 0,timing:Date.now(),user:e.user||{},version:"0.4.2",sources:{},push:void 0,command:void 0};return s.push=N(s,e=>({timing:Math.round((Date.now()-s.timing)/10)/100,source:{type:"collector",id:"",previous_id:""},...e})),s.command=(u=I,x(async(e,t,n)=>await S(async()=>await u(c,e,t,n),()=>q({ok:!1}))(),"Command",(c=s).hooks)),s.destinations=await async function(e,t={}){const n={};for(const[e,o]of Object.entries(t)){const{code:t,config:r={},env:i={}}=o,a={...t.config,...r},s=R(t.env,i);n[e]={...t,config:a,env:s}}return n}(0,e.destinations||{}),s;var c,u}async function W(e){e=e||{};const t=await X(e),n=(o=t,{type:"elb",config:{},push:async(e,t,n,r,i,a)=>{if("string"==typeof e&&e.startsWith("walker ")){const r=e.replace("walker ","");return o.command(r,t,n)}let s;if("string"==typeof e)s={name:e},t&&"object"==typeof t&&!Array.isArray(t)&&(s.data=t);else{if(!e||"object"!=typeof e)return{ok:!1,successful:[],queued:[],failed:[]};s=e,t&&"object"==typeof t&&!Array.isArray(t)&&(s.data={...s.data||{},...t})}return r&&"object"==typeof r&&(s.context=r),i&&Array.isArray(i)&&(s.nested=i),a&&"object"==typeof a&&(s.custom=a),o.push(s)}});var o;t.sources.elb=n;const r=await async function(e,t={}){const n={};for(const[o,r]of Object.entries(t)){const{code:t,config:i={},env:a={},primary:s}=r,c=(t,n={})=>e.push(t,{...n,mapping:i}),u=e.logger.scope("source").scope(o),l={push:c,command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:u,...a},d=await S(t)(i,l);if(!d)continue;const f=d.type||"unknown",g=e.logger.scope(f).scope(o);l.logger=g,s&&(d.config={...d.config,primary:s}),n[o]=d}return n}(t,e.sources||{});Object.assign(t.sources,r);const{consent:i,user:a,globals:s,custom:c}=e;i&&await t.command("consent",i),a&&await t.command("user",a),s&&Object.assign(t.globals,s),c&&Object.assign(t.custom,c),t.config.run&&await t.command("run");let u=n.push;const l=Object.values(t.sources).filter(e=>"elb"!==e.type),d=l.find(e=>e.config.primary);return d?u=d.push:l.length>0&&(u=l[0].push),{collector:t,elb:u}}function T(e,t){return(e.getAttribute(t)||"").trim()}var U=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)};function M(e){const t=getComputedStyle(e);if("none"===t.display)return!1;if("visible"!==t.visibility)return!1;if(t.opacity&&Number(t.opacity)<.1)return!1;let n;const o=window.innerHeight,r=e.getBoundingClientRect(),i=r.height,a=r.y,s=a+i,c={x:r.x+e.offsetWidth/2,y:r.y+e.offsetHeight/2};if(i<=o){if(e.offsetWidth+r.width===0||e.offsetHeight+r.height===0)return!1;if(c.x<0)return!1;if(c.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(c.y<0)return!1;if(c.y>(document.documentElement.clientHeight||window.innerHeight))return!1;n=document.elementFromPoint(c.x,c.y)}else{const e=o/2;if(a<0&&s<e)return!1;if(s>o&&a>e)return!1;n=document.elementFromPoint(c.x,o/2)}if(n)do{if(n===e)return!0}while(n=n.parentElement);return!1}function B(e,t,n){return!1===n?e:(n||(n=G),n(e,t,G))}var G=(e,t)=>{const n={};return e.id&&(n.session=e.id),e.storage&&e.device&&(n.device=e.device),t?t.command("user",n):U("walker user",n),e.isStart&&(t?t.push({name:"session start",data:e}):U({name:"session start",data:e})),e};function H(e,t=r.Storage.Session){var n;function o(e){try{return JSON.parse(e||"")}catch(t){let n=1,o="";return e&&(n=0,o=e),{e:n,v:o}}}let i,a;switch(t){case r.Storage.Cookie:i=decodeURIComponent((null==(n=document.cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:n.split("=")[1])||"");break;case r.Storage.Local:a=o(window.localStorage.getItem(e));break;case r.Storage.Session:a=o(window.sessionStorage.getItem(e))}return a&&(i=a.v,0!=a.e&&a.e<Date.now()&&(function(e,t=r.Storage.Session){switch(t){case r.Storage.Cookie:K(e,"",0,t);break;case r.Storage.Local:window.localStorage.removeItem(e);break;case r.Storage.Session:window.sessionStorage.removeItem(e)}}(e,t),i="")),function(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}(i||"")}function K(e,t,n=30,o=r.Storage.Session,i){const a={e:Date.now()+6e4*n,v:String(t)},s=JSON.stringify(a);switch(o){case r.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let o=`${e}=${encodeURIComponent(t)}; max-age=${60*n}; path=/; SameSite=Lax; secure`;i&&(o+="; domain="+i),document.cookie=o;break}case r.Storage.Local:window.localStorage.setItem(e,s);break;case r.Storage.Session:window.sessionStorage.setItem(e,s)}return H(e,o)}function F(e={}){const t=Date.now(),{length:n=30,deviceKey:o="elbDeviceId",deviceStorage:r="local",deviceAge:i=30,sessionKey:a="elbSessionId",sessionStorage:s="local",pulse:c=!1}=e,u=J(e);let l=!1;const d=j((e,t,n)=>{let o=H(e,n);return o||(o=m(8),K(e,o,1440*t,n)),String(o)})(o,i,r),f=j((e,o)=>{const r=JSON.parse(String(H(e,o)));return c||(r.isNew=!1,u.marketing&&(Object.assign(r,u),l=!0),l||r.updated+6e4*n<t?(delete r.id,delete r.referrer,r.start=t,r.count++,r.runs=1,l=!0):r.runs++),r},()=>{l=!0})(a,s)||{},g={id:m(12),start:t,isNew:!0,count:1,runs:1},p=Object.assign(g,u,f,{device:d},{isStart:l,storage:!0,updated:t},e.data);return K(a,JSON.stringify(p),2*n,s),p}function J(e={}){let t=e.isStart||!1;const n={isStart:t,storage:!1};if(!1===e.isStart)return n;if(!t){const[e]=performance.getEntriesByType("navigation");if("navigate"!==e.type)return n}const o=new URL(e.url||window.location.href),r=e.referrer||document.referrer,i=r&&new URL(r).hostname,s=function(e,t={}){const n="clickId",o={},r={utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term",dclid:n,fbclid:n,gclid:n,msclkid:n,ttclid:n,twclid:n,igshid:n,sclid:n};return Object.entries(a(r,t)).forEach(([t,r])=>{const i=e.searchParams.get(t);i&&(r===n&&(r=t,o[n]=t),o[r]=i)}),o}(o,e.parameters);if(Object.keys(s).length&&(s.marketing||(s.marketing=!0),t=!0),!t){const n=e.domains||[];n.push(o.hostname),t=!n.includes(i)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:m(12),referrer:i},s,e.data):n}var z,Y=Object.defineProperty,V=(e,t)=>{for(var n in t)Y(e,n,{get:t[n],enumerable:!0})},Q=Object.defineProperty;((e,t)=>{for(var n in t)Q(e,n,{get:t[n],enumerable:!0})})({},{Level:()=>Z});var Z=((z=Z||{})[z.ERROR=0]="ERROR",z[z.INFO=1]="INFO",z[z.DEBUG=2]="DEBUG",z),ee={merge:!0,shallow:!0,extend:!0};function te(e,t={},n={}){n={...ee,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function ne(e){return Array.isArray(e)}function oe(e){return e===document||e instanceof Element}function re(e){return"object"==typeof e&&null!==e&&!ne(e)&&"[object Object]"===Object.prototype.toString.call(e)}function ie(e){return"string"==typeof e}function ae(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function se(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function ce(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function ue(e,t,n=!0){return e+(null!=t?(n?"-":"")+t:"")}function le(e,t,n,o=!0){return ke(T(t,ue(e,n,o))||"").reduce((e,n)=>{let[o,r]=Ee(n);if(!o)return e;if(r||(o.endsWith(":")&&(o=o.slice(0,-1)),r=""),r.startsWith("#")){r=r.slice(1);try{let e=t[r];e||"selected"!==r||(e=t.options[t.selectedIndex].text),r=String(e)}catch(e){r=""}}return o.endsWith("[]")?(o=o.slice(0,-2),ne(e[o])||(e[o]=[]),e[o].push(ae(r))):e[o]=ae(r),e},{})}function de(e,t=A.Prefix){var n;const o=e||document.body;if(!o)return[];let r=[];const i=A.Action,a=`[${ue(t,i,!1)}]`,s=e=>{Object.keys(le(t,e,i,!1)).forEach(n=>{r=r.concat(fe(e,n,t))})};return o!==document&&(null==(n=o.matches)?void 0:n.call(o,a))&&s(o),we(o,a,s),r}function fe(e,t,n=A.Prefix){const o=[],{actions:r,nearestOnly:i}=function(e,t,n){let o=t;for(;o;){const t=T(o,ue(e,A.Actions,!1));if(t){const e=me(t);if(e[n])return{actions:e[n],nearestOnly:!1}}const r=T(o,ue(e,A.Action,!1));if(r){const e=me(r);if(e[n]||"click"!==n)return{actions:e[n]||[],nearestOnly:!0}}o=he(e,o)}return{actions:[],nearestOnly:!1}}(n,e,t);return r.length?(r.forEach(r=>{const a=ke(r.actionParams||"",",").reduce((e,t)=>(e[ce(t)]=!0,e),{}),s=ye(n,e,a,i);if(!s.length){const t="page",o=`[${ue(n,t)}]`,[r,i]=ve(e,o,n,t);s.push({entity:t,data:r,nested:[],context:i})}s.forEach(e=>{o.push({entity:e.entity,action:r.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),o):o}function ge(e=A.Prefix,t=document){const n=ue(e,A.Globals,!1);let o={};return we(t,`[${n}]`,t=>{o=te(o,le(e,t,A.Globals,!1))}),o}function pe(e,t){const n=window.location,o="page",r=t===document?document.body:t,[i,a]=ve(r,`[${ue(e,o)}]`,e,o);return i.domain=n.hostname,i.title=document.title,i.referrer=document.referrer,n.search&&(i.search=n.search),n.hash&&(i.hash=n.hash),[i,a]}function me(e){const t={};return ke(e).forEach(e=>{const[n,o]=Ee(e),[r,i]=je(n);if(!r)return;let[a,s]=je(o||"");a=a||r,t[r]||(t[r]=[]),t[r].push({trigger:r,triggerParams:i,action:a,actionParams:s})}),t}function ye(e,t,n,o=!1){const r=[];let i=t;for(n=0!==Object.keys(n||{}).length?n:void 0;i;){const a=be(e,i,t,n);if(a&&(r.push(a),o))break;i=he(e,i)}return r}function be(e,t,n,o){const r=T(t,ue(e));if(!r||o&&!o[r])return null;const i=[t],a=`[${ue(e,r)}],[${ue(e,"")}]`,s=ue(e,A.Link,!1);let c={};const u=[],[l,d]=ve(n||t,a,e,r);we(t,`[${s}]`,t=>{const[n,o]=Ee(T(t,s));"parent"===o&&we(document.body,`[${s}="${n}:child"]`,t=>{i.push(t);const n=be(e,t);n&&u.push(n)})});const f=[];i.forEach(e=>{e.matches(a)&&f.push(e),we(e,a,e=>f.push(e))});let g={};return f.forEach(t=>{g=te(g,le(e,t,"")),c=te(c,le(e,t,r))}),c=te(te(g,c),l),i.forEach(t=>{we(t,`[${ue(e)}]`,t=>{const n=be(e,t);n&&u.push(n)})}),{entity:r,data:c,context:d,nested:u}}function he(e,t){const n=ue(e,A.Link,!1);if(t.matches(`[${n}]`)){const[e,o]=Ee(T(t,n));if("child"===o)return document.querySelector(`[${n}="${e}:parent"]`)}return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof ShadowRoot?t.getRootNode().host:t.parentElement}function ve(e,t,n,o){let r={};const i={};let a=e;const s=`[${ue(n,A.Context,!1)}]`;let c=0;for(;a;)a.matches(t)&&(r=te(le(n,a,""),r),r=te(le(n,a,o),r)),a.matches(s)&&(Object.entries(le(n,a,A.Context,!1)).forEach(([e,t])=>{t&&!i[e]&&(i[e]=[t,c])}),++c),a=he(n,a);return[r,i]}function we(e,t,n){e.querySelectorAll(t).forEach(n)}function ke(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function Ee(e){const[t,n]=e.split(/:(.+)/,2);return[ce(t),ce(n)]}function je(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var Se,Oe=new WeakMap,_e=new WeakMap,Le=new WeakMap;function xe(e){const t=Date.now();let n=_e.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:M(e),lastChecked:t},_e.set(e,n)),n.isVisible}function Ae(e){if(window.IntersectionObserver)return se(()=>new window.IntersectionObserver(t=>{t.forEach(t=>{!function(e,t){var n,o;const r=t.target,i=Le.get(e);if(!i)return;const a=i.timers.get(r);if(t.intersectionRatio>0){const o=Date.now();let s=Oe.get(r);if((!s||o-s.lastChecked>1e3)&&(s={isLarge:r.offsetHeight>window.innerHeight,lastChecked:o},Oe.set(r,s)),t.intersectionRatio>=.5||s.isLarge&&xe(r)){const t=null==(n=i.elementConfigs)?void 0:n.get(r);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!a){const t=window.setTimeout(async()=>{var t,n;if(xe(r)){const o=null==(t=i.elementConfigs)?void 0:t.get(r);(null==o?void 0:o.context)&&await Me(o.context,r,o.trigger);const a=null==(n=i.elementConfigs)?void 0:n.get(r);(null==a?void 0:a.multiple)?a.blocked=!0:function(e,t){const n=Le.get(e);if(!n)return;n.observer&&n.observer.unobserve(t);const o=n.timers.get(t);o&&(clearTimeout(o),n.timers.delete(t)),Oe.delete(t),_e.delete(t)}(e,r)}},i.duration);i.timers.set(r,t)}return}}a&&(clearTimeout(a),i.timers.delete(r));const s=null==(o=i.elementConfigs)?void 0:o.get(r);(null==s?void 0:s.multiple)&&(s.blocked=!1)}(e,t)})},{rootMargin:"0px",threshold:[0,.5]}),()=>{})()}function Ce(e,t,n={multiple:!1}){var o;const r=e.settings.scope||document,i=Le.get(r);(null==i?void 0:i.observer)&&t&&(i.elementConfigs||(i.elementConfigs=new WeakMap),i.elementConfigs.set(t,{multiple:null!=(o=n.multiple)&&o,blocked:!1,context:e,trigger:n.multiple?"visible":"impression"}),i.observer.observe(t))}function $e(e){if(!e)return;const t=Le.get(e);t&&(t.observer&&t.observer.disconnect(),Le.delete(e))}function Pe(e,t,n,o,r,i,a){const{elb:s,settings:c}=e;if(ie(t)&&t.startsWith("walker "))return s(t,n);if(re(t)){const e=t;return e.source||(e.source=qe()),e.globals||(e.globals=ge(c.prefix,c.scope||document)),s(e)}const[u]=String(re(t)?t.name:t).split(" ");let l,d=re(n)?n:{},f={},g=!1;if(oe(n)&&(l=n,g=!0),oe(r)?l=r:re(r)&&Object.keys(r).length&&(f=r),l){const e=ye(c.prefix||"data-elb",l).find(e=>e.entity===u);e&&(g&&(d=e.data),f=e.context)}"page"===u&&(d.id=d.id||window.location.pathname);const p=ge(c.prefix,c.scope);return s({name:String(t||""),data:d,context:f,globals:p,nested:i,custom:a,trigger:ie(o)?o:"",source:qe()})}function qe(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var Re=[],De="hover",Ie="load",Ne="pulse",Xe="scroll",We="wait";function Te(e,t){t.scope&&function(e,t){const n=t.scope;n&&(n.addEventListener("click",se(function(t){Ge.call(this,e,t)})),n.addEventListener("submit",se(function(t){He.call(this,e,t)})))}(e,t)}function Ue(e,t){t.scope&&function(e,t){const n=t.scope;Re=[];const o=n||document;$e(o),function(e,t=1e3){Le.has(e)||Le.set(e,{observer:Ae(e),timers:new WeakMap,duration:t})}(o,1e3);const r=ue(t.prefix,A.Action,!1);o!==document&&Be(e,o,r,t),o.querySelectorAll(`[${r}]`).forEach(n=>{Be(e,n,r,t)}),Re.length&&function(e,t){const n=(e,t)=>e.filter(([e,n])=>{const o=window.scrollY+window.innerHeight,r=e.offsetTop;if(o<r)return!0;const i=e.clientHeight;return!(100*(1-(r+i-o)/(i||1))>=n&&(Me(t,e,Xe),1))});Se||(Se=function(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}(function(){Re=n.call(t,Re,e)}),t.addEventListener("scroll",Se))}(e,o)}(e,t)}async function Me(e,t,n){const o=fe(t,n,e.settings.prefix);return Promise.all(o.map(t=>Pe(e,{name:`${t.entity} ${t.action}`,...t,trigger:n})))}function Be(e,t,n,o){const r=T(t,n);r&&Object.values(me(r)).forEach(n=>n.forEach(n=>{switch(n.trigger){case De:o=e,t.addEventListener("mouseenter",se(function(e){e.target instanceof Element&&Me(o,e.target,De)}));break;case Ie:!function(e,t){Me(e,t,Ie)}(e,t);break;case Ne:!function(e,t,n=""){setInterval(()=>{document.hidden||Me(e,t,Ne)},parseInt(n||"")||15e3)}(e,t,n.triggerParams);break;case Xe:!function(e,t=""){const n=parseInt(t||"")||50;n<0||n>100||Re.push([e,n])}(t,n.triggerParams);break;case"impression":Ce(e,t);break;case"visible":Ce(e,t,{multiple:!0});break;case We:!function(e,t,n=""){setTimeout(()=>Me(e,t,We),parseInt(n||"")||15e3)}(e,t,n.triggerParams)}var o}))}function Ge(e,t){Me(e,t.target,"click")}function He(e,t){t.target&&Me(e,t.target,"submit")}function Ke(e,t,n,o){const r=[];let i=!0;n.forEach(e=>{const t=Je(e)?[...Array.from(e)]:null!=(n=e)&&"object"==typeof n&&"length"in n&&"number"==typeof n.length?Array.from(e):[e];var n;if(Array.isArray(t)&&0===t.length)return;if(Array.isArray(t)&&1===t.length&&!t[0])return;const a=t[0],s=!re(a)&&ie(a)&&a.startsWith("walker ");if(re(a)){if("object"==typeof a&&0===Object.keys(a).length)return}else{const e=Array.from(t);if(!ie(e[0])||""===e[0].trim())return;const n="walker run";i&&e[0]===n&&(i=!1)}(o&&s||!o&&!s)&&r.push(t)}),r.forEach(n=>{Fe(e,t,n)})}function Fe(e,t="data-elb",n){se(()=>{if(Array.isArray(n)){const[o,...r]=n;if(!o||ie(o)&&""===o.trim())return;if(ie(o)&&o.startsWith("walker "))return void e(o,r[0]);Pe({elb:e,settings:{prefix:t,scope:document,pageview:!1,session:!1,elb:"",elbLayer:!1}},o,...r)}else if(n&&"object"==typeof n){if(0===Object.keys(n).length)return;e(n)}},()=>{})()}function Je(e){return null!=e&&"object"==typeof e&&"[object Arguments]"===Object.prototype.toString.call(e)}function ze(e,t={},n){return function(e={}){const{cb:t,consent:n,collector:o,storage:r}=e;if(!n)return B((r?F:J)(e),o,t);{const r=function(e,t){let n;return(o,r)=>{if(c(n)&&n===(null==o?void 0:o.group))return;n=null==o?void 0:o.group;let i=()=>J(e);return e.consent&&p((s(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{}),r)&&(i=()=>F(e)),B(i(),o,t)}}(e,t),i=(s(n)?n:[n]).reduce((e,t)=>({...e,[t]:r}),{});o?o.command("on","consent",i):U("walker on","consent",i)}}({...t,collector:{push:e,group:void 0,command:n}})}V({},{env:()=>Ye});var Ye={};V(Ye,{push:()=>et});var Ve=()=>{},Qe=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),Ze={error:Ve,info:Ve,debug:Ve,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>Ze},et={get push(){return Qe()},get command(){return Qe()},get elb(){return Qe()},get window(){return{addEventListener:Ve,removeEventListener:Ve,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:Ve,removeEventListener:Ve,querySelector:Ve,querySelectorAll:()=>[],getElementById:Ve,getElementsByClassName:()=>[],getElementsByTagName:()=>[],createElement:()=>({setAttribute:Ve,getAttribute:Ve,addEventListener:Ve,removeEventListener:Ve}),body:{appendChild:Ve,removeChild:Ve},documentElement:{scrollTop:0,scrollLeft:0},readyState:"complete",title:"Test Page",referrer:"",cookie:""}},logger:Ze},tt=async(e,t)=>{const{elb:n,command:o,window:r,document:i}=t,a=(null==e?void 0:e.settings)||{},s=r||(void 0!==globalThis.window?globalThis.window:void 0),c=i||(void 0!==globalThis.document?globalThis.document:void 0),u=function(e={},t){return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:t||void 0,...e}}(a,c),l={settings:u},d={elb:n,settings:u};if(s&&c){if(!1!==u.elbLayer&&n&&function(e,t={}){const n=t.name||"elbLayer",o=t.window||window;if(!o)return;const r=o;r[n]||(r[n]=[]);const i=r[n];i.push=function(...n){if(Je(n[0])){const o=[...Array.from(n[0])],r=Array.prototype.push.apply(this,[o]);return Fe(e,t.prefix,o),r}const o=Array.prototype.push.apply(this,n);return n.forEach(n=>{Fe(e,t.prefix,n)}),o},Array.isArray(i)&&i.length>0&&function(e,t="data-elb",n){Ke(e,t,n,!0),Ke(e,t,n,!1),n.length=0}(e,t.prefix,i)}(n,{name:ie(u.elbLayer)?u.elbLayer:"elbLayer",prefix:u.prefix,window:s}),u.session&&n){const e="boolean"==typeof u.session?{}:u.session;ze(n,e,o)}await async function(e,t,n){const o=()=>{e(t,n)};"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o)}(Te,d,u),(()=>{if(Ue(d,u),u.pageview){const[e,t]=pe(u.prefix||"data-elb",u.scope);Pe(d,"page view",e,"load",t)}})(),ie(u.elb)&&u.elb&&(s[u.elb]=(...e)=>{const[t,n,o,r,i,a]=e;return Pe(d,t,n,o,r,i,a)})}return{type:"browser",config:l,push:(...e)=>{const[t,n,o,r,i,a]=e;return Pe(d,t,n,o,r,i,a)},destroy:async()=>{c&&$e(u.scope||c)},on:async(e,t)=>{switch(e){case"consent":if(u.session&&t&&n){const e="boolean"==typeof u.session?{}:u.session;ze(n,e,o)}break;case"session":case"ready":default:break;case"run":if(c&&s&&(Ue(d,u),u.pageview)){const[e,t]=pe(u.prefix||"data-elb",u.scope);Pe(d,"page view",e,"load",t)}}}}},nt=Object.defineProperty,ot=(e,t)=>{for(var n in t)nt(e,n,{get:t[n],enumerable:!0})},rt=!1;function it(e,t={},n){if(t.filter&&!0===j(()=>t.filter(n),()=>!1)())return;const o=function(e){if(u(e)&&l(e.event)){const{event:t,...n}=e;return{name:t,...n}}return s(e)&&e.length>=2?at(e):null!=(t=e)&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&t.length>0?at(Array.from(e)):null;var t}(n);if(!o)return;const r=`${t.prefix||"dataLayer"} ${o.name}`,{name:i,...a}=o,c={name:r,data:a};j(()=>e(c),()=>{})()}function at(e){const[t,n,o]=e;if(!l(t))return null;let r,i={};switch(t){case"consent":if(!l(n)||e.length<3)return null;if("default"!==n&&"update"!==n)return null;if(!u(o)||null===o)return null;r=`${t} ${n}`,i={...o};break;case"event":if(!l(n))return null;r=n,u(o)&&(i={...o});break;case"config":if(!l(n))return null;r=`${t} ${n}`,u(o)&&(i={...o});break;case"set":if(l(n))r=`${t} ${n}`,u(o)&&(i={...o});else{if(!u(n))return null;r=`${t} custom`,i={...n}}break;default:return null}return{name:r,...i}}ot({},{push:()=>lt});var st=()=>{},ct=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),ut={error:st,info:st,debug:st,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>ut},lt={get push(){return ct()},get command(){return ct()},get elb(){return ct()},get window(){return{dataLayer:[],addEventListener:st,removeEventListener:st}},logger:ut};function dt(){return["consent","update",{ad_user_data:"granted",ad_personalization:"granted",ad_storage:"denied",analytics_storage:"granted"}]}function ft(){return["consent","default",{ad_storage:"denied",analytics_storage:"denied",ad_user_data:"denied",ad_personalization:"denied"}]}function gt(){return["event","purchase",{transaction_id:"T_12345",value:25.42,currency:"EUR",items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",quantity:1,price:25.42}]}]}function pt(){return["event","add_to_cart",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_variant:"red",quantity:1,price:15.25}]}]}function mt(){return["event","view_item",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",price:15.25}]}]}function yt(){return["config","G-XXXXXXXXXX",{page_title:"Custom Page Title",page_location:"https://example.com/page",send_page_view:!1}]}function bt(){return["set",{currency:"EUR",country:"DE"}]}function ht(){return{event:"custom_event",custom_parameter:"custom_value",user_id:"user123"}}ot({},{add_to_cart:()=>pt,config:()=>yt,consentDefault:()=>ft,consentUpdate:()=>dt,directDataLayerEvent:()=>ht,purchase:()=>gt,setCustom:()=>bt,view_item:()=>mt});ot({},{add_to_cart:()=>kt,config:()=>Ot,configGA4:()=>jt,consentOnlyMapping:()=>_t,consentUpdate:()=>vt,customEvent:()=>St,purchase:()=>wt,view_item:()=>Et});var vt={name:"walker consent",settings:{command:{map:{functional:{value:!0},analytics:{key:"analytics_storage",fn:e=>"granted"===e},marketing:{key:"ad_storage",fn:e=>"granted"===e}}}}},wt={name:"order complete",data:{map:{id:"transaction_id",total:"value",currency:"currency",nested:{loop:["items",{map:{type:{value:"product"},data:{map:{id:"item_id",name:"item_name",category:"item_category",quantity:"quantity",price:"price"}}}}]}}}},kt={name:"product add",data:{map:{id:"items.0.item_id",name:"items.0.item_name",price:"value",currency:"currency",color:"items.0.item_variant",quantity:"items.0.quantity"}}},Et={name:"product view",data:{map:{id:"items.0.item_id",name:"items.0.item_name",category:"items.0.item_category",price:"items.0.price",currency:"currency"}}},jt={name:"page view",data:{map:{title:"page_title",url:"page_location"}}},St={data:{map:{user_id:"user_id",custom_parameter:"custom_parameter"}}},Ot={consent:{update:vt},purchase:wt,add_to_cart:kt,view_item:Et,"config G-XXXXXXXXXX":jt,custom_event:St,"*":{data:{}}},_t={consent:{update:vt}},Lt=async(e,t)=>{const{elb:n,window:o}=t,r={name:"dataLayer",prefix:"dataLayer",...null==e?void 0:e.settings},i={settings:r};return o&&(function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer",r=window[o];if(Array.isArray(r)&&!rt){rt=!0;try{for(const t of r)it(e,n,t)}finally{rt=!1}}}(n,i),function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer";window[o]||(window[o]=[]);const r=window[o];if(!Array.isArray(r))return;const i=r.push.bind(r);r.push=function(...t){if(rt)return i(...t);rt=!0;try{for(const o of t)it(e,n,o)}finally{rt=!1}return i(...t)}}(n,i)),{type:"dataLayer",config:i,push:n,destroy:async()=>{const e=r.name||"dataLayer";o&&o[e]&&Array.isArray(o[e])}}};function xt(){window.dataLayer=window.dataLayer||[];const e=e=>{u(e)&&u(e.source)&&String(e.source.type).includes("dataLayer")||window.dataLayer.push(e)};return{type:"dataLayer",config:{},push:(t,n)=>{e(n.data||t)},pushBatch:t=>{e({name:"batch",batched_event:t.key,events:t.data.length?t.data:t.events})}}}var At={},Ct={};((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})(Ct,{browserConfig:()=>Pt,collectorConfig:()=>Rt,dataLayerConfig:()=>qt,settings:()=>$t});var $t={type:"object",properties:{elb:{type:"string",default:"elb",description:"Global function name for event tracking"},name:{type:"string",default:"walkerjs",description:"Global instance name"},run:{type:"boolean",default:!0,description:"Auto-initialize walker.js on load"},browser:{type:"object",default:{run:!0,session:!0,scope:"document.body",pageview:!0},description:"Browser source configuration. Set to false to disable. See browser configuration section below for details."},dataLayer:{type:"object",default:!1,description:"DataLayer source configuration. Set to true for defaults or object for custom config. See dataLayer configuration section below."},collector:{type:"object",default:{},description:"Collector configuration including destinations and consent settings. See collector configuration section below."}}},Pt={type:"object",properties:{"browser.run":{type:"boolean",default:!0,description:"Auto-start DOM tracking"},"browser.session":{type:"boolean",default:!0,description:"Enable session tracking"},"browser.scope":{type:"string",default:"document.body",description:"DOM element scope for tracking"},"browser.pageview":{type:"boolean",default:!0,description:"Enable automatic page view events"}}},qt={type:"object",properties:{dataLayer:{type:"boolean",default:!1,description:"Enable dataLayer integration with defaults"},"dataLayer.name":{type:"string",default:"dataLayer",description:"DataLayer variable name"},"dataLayer.prefix":{type:"string",default:"dataLayer",description:"Event prefix for dataLayer events"}}},Rt={type:"object",properties:{"collector.consent":{type:"object",default:{functional:!0},description:"Default consent state"},"collector.destinations":{type:"object",default:{},description:"Destination configurations. See destinations documentation for available options."}}};async function Dt(e={}){const t=a({collector:{destinations:{dataLayer:{code:xt()}}},browser:{session:!0},dataLayer:!1,elb:"elb",run:!0},e),n={...t.collector,sources:{browser:{code:tt,config:{settings:t.browser},env:{window:"undefined"!=typeof window?window:void 0,document:"undefined"!=typeof document?document:void 0}}}};if(t.dataLayer){const e=u(t.dataLayer)?t.dataLayer:{};n.sources&&(n.sources.dataLayer={code:Lt,config:{settings:e}})}const o=await W(n);return"undefined"!=typeof window&&(t.elb&&(window[t.elb]=o.elb),t.name&&(window[t.name]=o.collector)),o}var It=Dt;export{At as Walkerjs,Dt as createWalkerjs,It as default,de as getAllEvents,fe as getEvents,ge as getGlobals,Ct as schemas};//# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/destination.ts","../src/types/index.ts","../src/schemas.ts","../src/index.ts"],"sourcesContent":["import type { Destination } from '@walkeros/core';\nimport type { DataLayer } from './types';\nimport { isObject } from '@walkeros/core';\n\nexport function dataLayerDestination(): Destination.Instance {\n window.dataLayer = window.dataLayer || [];\n const dataLayerPush = (event: unknown) => {\n // Do not process events from dataLayer source\n if (\n isObject(event) &&\n isObject(event.source) &&\n String(event.source.type).includes('dataLayer')\n )\n return;\n\n (window.dataLayer as DataLayer)!.push(event);\n };\n const destination: Destination.Instance = {\n type: 'dataLayer',\n config: {},\n push: (event, context) => {\n dataLayerPush(context.data || event);\n },\n pushBatch: (batch) => {\n dataLayerPush({\n name: 'batch',\n batched_event: batch.key,\n events: batch.data.length ? batch.data : batch.events,\n });\n },\n };\n\n return destination;\n}\n","import type { Collector, Source, WalkerOS } from '@walkeros/core';\nimport type { SourceBrowser } from '@walkeros/web-source-browser';\nimport type { SourceDataLayer } from '@walkeros/web-source-datalayer';\n\ndeclare global {\n interface Window {\n [key: string]: DataLayer;\n }\n}\n\n// Instance interface\nexport interface Instance {\n collector: Collector.Instance;\n elb: SourceBrowser.BrowserPush;\n}\n\n// Configuration interface\nexport interface Config {\n // Collector configuration\n collector?: Collector.InitConfig;\n\n // Browser source configuration\n browser?: Partial<SourceBrowser.Settings>;\n\n // DataLayer configuration\n dataLayer?: boolean | Partial<SourceDataLayer.Settings>;\n\n // Global configuration\n elb?: string; // Name for the global elb function\n name?: string; // Name for the global instance\n run?: boolean; // Auto-run on initialization (default: true)\n}\n\nexport type DataLayer = undefined | Array<unknown>;\n","import type { RJSFSchema } from '@rjsf/utils';\n\nexport const settings: RJSFSchema = {\n type: 'object',\n properties: {\n elb: {\n type: 'string',\n default: 'elb',\n description: 'Global function name for event tracking',\n },\n name: {\n type: 'string',\n default: 'walkerjs',\n description: 'Global instance name',\n },\n run: {\n type: 'boolean',\n default: true,\n description: 'Auto-initialize walker.js on load',\n },\n browser: {\n type: 'object',\n default: {\n run: true,\n session: true,\n scope: 'document.body',\n pageview: true,\n },\n description:\n 'Browser source configuration. Set to false to disable. See browser configuration section below for details.',\n },\n dataLayer: {\n type: 'object',\n default: false,\n description:\n 'DataLayer source configuration. Set to true for defaults or object for custom config. See dataLayer configuration section below.',\n },\n collector: {\n type: 'object',\n default: {},\n description:\n 'Collector configuration including destinations and consent settings. See collector configuration section below.',\n },\n },\n};\n\nexport const browserConfig: RJSFSchema = {\n type: 'object',\n properties: {\n 'browser.run': {\n type: 'boolean',\n default: true,\n description: 'Auto-start DOM tracking',\n },\n 'browser.session': {\n type: 'boolean',\n default: true,\n description: 'Enable session tracking',\n },\n 'browser.scope': {\n type: 'string',\n default: 'document.body',\n description: 'DOM element scope for tracking',\n },\n 'browser.pageview': {\n type: 'boolean',\n default: true,\n description: 'Enable automatic page view events',\n },\n },\n};\n\nexport const dataLayerConfig: RJSFSchema = {\n type: 'object',\n properties: {\n dataLayer: {\n type: 'boolean',\n default: false,\n description: 'Enable dataLayer integration with defaults',\n },\n 'dataLayer.name': {\n type: 'string',\n default: 'dataLayer',\n description: 'DataLayer variable name',\n },\n 'dataLayer.prefix': {\n type: 'string',\n default: 'dataLayer',\n description: 'Event prefix for dataLayer events',\n },\n },\n};\n\nexport const collectorConfig: RJSFSchema = {\n type: 'object',\n properties: {\n 'collector.consent': {\n type: 'object',\n default: { functional: true },\n description: 'Default consent state',\n },\n 'collector.destinations': {\n type: 'object',\n default: {},\n description:\n 'Destination configurations. See destinations documentation for available options.',\n },\n },\n};\n","import type { Config, Instance } from './types';\nimport type { Collector, Elb, WalkerOS } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\nimport { assign, isObject } from '@walkeros/core';\nimport {\n sourceBrowser,\n getAllEvents,\n getEvents,\n getGlobals,\n SourceBrowser,\n} from '@walkeros/web-source-browser';\nimport { sourceDataLayer } from '@walkeros/web-source-datalayer';\nimport { dataLayerDestination } from './destination';\n\n// Re-export types\nexport * as Walkerjs from './types';\n\n// Export schemas\nexport * as schemas from './schemas';\n\nexport { getAllEvents, getEvents, getGlobals };\n\n// Factory function to create walker.js instance\nexport async function createWalkerjs(config: Config = {}): Promise<Instance> {\n // Default configuration\n const defaultConfig: Config = {\n collector: {\n destinations: {\n dataLayer: { code: dataLayerDestination() },\n },\n },\n browser: {\n session: true,\n },\n dataLayer: false,\n elb: 'elb',\n run: true,\n };\n\n const fullConfig = assign(defaultConfig, config);\n\n // Build collector config with sources\n const collectorConfig: Collector.InitConfig = {\n ...fullConfig.collector,\n sources: {\n browser: {\n code: sourceBrowser,\n config: {\n settings: fullConfig.browser,\n },\n env: {\n window: typeof window !== 'undefined' ? window : undefined,\n document: typeof document !== 'undefined' ? document : undefined,\n },\n },\n },\n };\n\n // Add dataLayer source if configured\n if (fullConfig.dataLayer) {\n const dataLayerSettings = isObject(fullConfig.dataLayer)\n ? fullConfig.dataLayer\n : {};\n\n if (collectorConfig.sources) {\n collectorConfig.sources.dataLayer = {\n code: sourceDataLayer,\n config: {\n settings: dataLayerSettings,\n },\n };\n }\n }\n\n const flow = await startFlow<SourceBrowser.BrowserPush>(collectorConfig);\n\n // Set up global variables if configured (only in browser environments)\n if (typeof window !== 'undefined') {\n if (fullConfig.elb) window[fullConfig.elb] = flow.elb;\n if (fullConfig.name) window[fullConfig.name] = flow.collector;\n }\n\n return flow;\n}\n\n// Export factory function as default\nexport default createWalkerjs;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,uBAA6C;AAC3D,SAAO,YAAY,OAAO,aAAa,CAAC;AACxC,QAAM,gBAAgB,CAAC,UAAmB;AAExC,QACE,EAAS,KAAK,KACd,EAAS,MAAM,MAAM,KACrB,OAAO,MAAM,OAAO,IAAI,EAAE,SAAS,WAAW;AAE9C;AAEF,IAAC,OAAO,UAAyB,KAAK,KAAK;AAAA,EAC7C;AACA,QAAM,cAAoC;AAAA,IACxC,MAAM;AAAA,IACN,QAAQ,CAAC;AAAA,IACT,MAAM,CAAC,OAAO,YAAY;AACxB,oBAAc,QAAQ,QAAQ,KAAK;AAAA,IACrC;AAAA,IACA,WAAW,CAAC,UAAU;AACpB,oBAAc;AAAA,QACZ,MAAM;AAAA,QACN,eAAe,MAAM;AAAA,QACrB,QAAQ,MAAM,KAAK,SAAS,MAAM,OAAO,MAAM;AAAA,MACjD,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;;;ACjCA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,WAAuB;AAAA,EAClC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,KAAK;AAAA,MACH,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA,QACP,KAAK;AAAA,QACL,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAU;AAAA,MACZ;AAAA,MACA,aACE;AAAA,IACJ;AAAA,IACA,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aACE;AAAA,IACJ;AAAA,IACA,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS,CAAC;AAAA,MACV,aACE;AAAA,IACJ;AAAA,EACF;AACF;AAEO,IAAM,gBAA4B;AAAA,EACvC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,eAAe;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,mBAAmB;AAAA,MACjB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,iBAAiB;AAAA,MACf,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,oBAAoB;AAAA,MAClB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,EACF;AACF;AAEO,IAAM,kBAA8B;AAAA,EACzC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,kBAAkB;AAAA,MAChB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,oBAAoB;AAAA,MAClB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,EACF;AACF;AAEO,IAAM,kBAA8B;AAAA,EACzC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,qBAAqB;AAAA,MACnB,MAAM;AAAA,MACN,SAAS,EAAE,YAAY,KAAK;AAAA,MAC5B,aAAa;AAAA,IACf;AAAA,IACA,0BAA0B;AAAA,MACxB,MAAM;AAAA,MACN,SAAS,CAAC;AAAA,MACV,aACE;AAAA,IACJ;AAAA,EACF;AACF;;;ACrFA,eAAsB,eAAe,SAAiB,CAAC,GAAsB;AAE3E,QAAM,gBAAwB;AAAA,IAC5B,WAAW;AAAA,MACT,cAAc;AAAA,QACZ,WAAW,EAAE,MAAM,qBAAqB,EAAE;AAAA,MAC5C;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,SAAS;AAAA,IACX;AAAA,IACA,WAAW;AAAA,IACX,KAAK;AAAA,IACL,KAAK;AAAA,EACP;AAEA,QAAM,aAAa,EAAO,eAAe,MAAM;AAG/C,QAAMA,mBAAwC;AAAA,IAC5C,GAAG,WAAW;AAAA,IACd,SAAS;AAAA,MACP,SAAS;AAAA,QACP,MAAM;AAAA,QACN,QAAQ;AAAA,UACN,UAAU,WAAW;AAAA,QACvB;AAAA,QACA,KAAK;AAAA,UACH,QAAQ,OAAO,WAAW,cAAc,SAAS;AAAA,UACjD,UAAU,OAAO,aAAa,cAAc,WAAW;AAAA,QACzD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,MAAI,WAAW,WAAW;AACxB,UAAM,oBAAoB,EAAS,WAAW,SAAS,IACnD,WAAW,YACX,CAAC;AAEL,QAAIA,iBAAgB,SAAS;AAC3B,MAAAA,iBAAgB,QAAQ,YAAY;AAAA,QAClC,MAAMC;AAAA,QACN,QAAQ;AAAA,UACN,UAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,OAAO,MAAM,EAAqCD,gBAAe;AAGvE,MAAI,OAAO,WAAW,aAAa;AACjC,QAAI,WAAW,IAAK,QAAO,WAAW,GAAG,IAAI,KAAK;AAClD,QAAI,WAAW,KAAM,QAAO,WAAW,IAAI,IAAI,KAAK;AAAA,EACtD;AAEA,SAAO;AACT;AAGA,IAAO,gBAAQ;","names":["collectorConfig","C"]}
1
+ {"version":3,"sources":["../src/destination.ts","../src/types/index.ts","../src/schemas.ts","../src/index.ts"],"sourcesContent":["import type { Destination } from '@walkeros/core';\nimport type { DataLayer } from './types';\nimport { isObject } from '@walkeros/core';\n\nexport function dataLayerDestination(): Destination.Instance {\n window.dataLayer = window.dataLayer || [];\n const dataLayerPush = (event: unknown) => {\n // Do not process events from dataLayer source\n if (\n isObject(event) &&\n isObject(event.source) &&\n String(event.source.type).includes('dataLayer')\n )\n return;\n\n (window.dataLayer as DataLayer)!.push(event);\n };\n const destination: Destination.Instance = {\n type: 'dataLayer',\n config: {},\n push: (event, context) => {\n dataLayerPush(context.data || event);\n },\n pushBatch: (batch) => {\n dataLayerPush({\n name: 'batch',\n batched_event: batch.key,\n events: batch.data.length ? batch.data : batch.events,\n });\n },\n };\n\n return destination;\n}\n","import type { Collector, Source, WalkerOS } from '@walkeros/core';\nimport type { SourceBrowser } from '@walkeros/web-source-browser';\nimport type { SourceDataLayer } from '@walkeros/web-source-datalayer';\n\ndeclare global {\n interface Window {\n [key: string]: DataLayer;\n }\n}\n\n// Instance interface\nexport interface Instance {\n collector: Collector.Instance;\n elb: SourceBrowser.BrowserPush;\n}\n\n// Configuration interface\nexport interface Config {\n // Collector configuration\n collector?: Collector.InitConfig;\n\n // Browser source configuration\n browser?: Partial<SourceBrowser.Settings>;\n\n // DataLayer configuration\n dataLayer?: boolean | Partial<SourceDataLayer.Settings>;\n\n // Global configuration\n elb?: string; // Name for the global elb function\n name?: string; // Name for the global instance\n run?: boolean; // Auto-run on initialization (default: true)\n}\n\nexport type DataLayer = undefined | Array<unknown>;\n","import type { RJSFSchema } from '@rjsf/utils';\n\nexport const settings: RJSFSchema = {\n type: 'object',\n properties: {\n elb: {\n type: 'string',\n default: 'elb',\n description: 'Global function name for event tracking',\n },\n name: {\n type: 'string',\n default: 'walkerjs',\n description: 'Global instance name',\n },\n run: {\n type: 'boolean',\n default: true,\n description: 'Auto-initialize walker.js on load',\n },\n browser: {\n type: 'object',\n default: {\n run: true,\n session: true,\n scope: 'document.body',\n pageview: true,\n },\n description:\n 'Browser source configuration. Set to false to disable. See browser configuration section below for details.',\n },\n dataLayer: {\n type: 'object',\n default: false,\n description:\n 'DataLayer source configuration. Set to true for defaults or object for custom config. See dataLayer configuration section below.',\n },\n collector: {\n type: 'object',\n default: {},\n description:\n 'Collector configuration including destinations and consent settings. See collector configuration section below.',\n },\n },\n};\n\nexport const browserConfig: RJSFSchema = {\n type: 'object',\n properties: {\n 'browser.run': {\n type: 'boolean',\n default: true,\n description: 'Auto-start DOM tracking',\n },\n 'browser.session': {\n type: 'boolean',\n default: true,\n description: 'Enable session tracking',\n },\n 'browser.scope': {\n type: 'string',\n default: 'document.body',\n description: 'DOM element scope for tracking',\n },\n 'browser.pageview': {\n type: 'boolean',\n default: true,\n description: 'Enable automatic page view events',\n },\n },\n};\n\nexport const dataLayerConfig: RJSFSchema = {\n type: 'object',\n properties: {\n dataLayer: {\n type: 'boolean',\n default: false,\n description: 'Enable dataLayer integration with defaults',\n },\n 'dataLayer.name': {\n type: 'string',\n default: 'dataLayer',\n description: 'DataLayer variable name',\n },\n 'dataLayer.prefix': {\n type: 'string',\n default: 'dataLayer',\n description: 'Event prefix for dataLayer events',\n },\n },\n};\n\nexport const collectorConfig: RJSFSchema = {\n type: 'object',\n properties: {\n 'collector.consent': {\n type: 'object',\n default: { functional: true },\n description: 'Default consent state',\n },\n 'collector.destinations': {\n type: 'object',\n default: {},\n description:\n 'Destination configurations. See destinations documentation for available options.',\n },\n },\n};\n","import type { Config, Instance } from './types';\nimport type { Collector, Elb, WalkerOS } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\nimport { assign, isObject } from '@walkeros/core';\nimport {\n sourceBrowser,\n getAllEvents,\n getEvents,\n getGlobals,\n SourceBrowser,\n} from '@walkeros/web-source-browser';\nimport { sourceDataLayer } from '@walkeros/web-source-datalayer';\nimport { dataLayerDestination } from './destination';\n\n// Re-export types\nexport * as Walkerjs from './types';\n\n// Export schemas\nexport * as schemas from './schemas';\n\nexport { getAllEvents, getEvents, getGlobals };\n\n// Factory function to create walker.js instance\nexport async function createWalkerjs(config: Config = {}): Promise<Instance> {\n // Default configuration\n const defaultConfig: Config = {\n collector: {\n destinations: {\n dataLayer: { code: dataLayerDestination() },\n },\n },\n browser: {\n session: true,\n },\n dataLayer: false,\n elb: 'elb',\n run: true,\n };\n\n const fullConfig = assign(defaultConfig, config);\n\n // Build collector config with sources\n const collectorConfig: Collector.InitConfig = {\n ...fullConfig.collector,\n sources: {\n browser: {\n code: sourceBrowser,\n config: {\n settings: fullConfig.browser,\n },\n env: {\n window: typeof window !== 'undefined' ? window : undefined,\n document: typeof document !== 'undefined' ? document : undefined,\n },\n },\n },\n };\n\n // Add dataLayer source if configured\n if (fullConfig.dataLayer) {\n const dataLayerSettings = isObject(fullConfig.dataLayer)\n ? fullConfig.dataLayer\n : {};\n\n if (collectorConfig.sources) {\n collectorConfig.sources.dataLayer = {\n code: sourceDataLayer,\n config: {\n settings: dataLayerSettings,\n },\n };\n }\n }\n\n const flow = await startFlow<SourceBrowser.BrowserPush>(collectorConfig);\n\n // Set up global variables if configured (only in browser environments)\n if (typeof window !== 'undefined') {\n if (fullConfig.elb) window[fullConfig.elb] = flow.elb;\n if (fullConfig.name) window[fullConfig.name] = flow.collector;\n }\n\n return flow;\n}\n\n// Export factory function as default\nexport default createWalkerjs;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,uBAA6C;AAC3D,SAAO,YAAY,OAAO,aAAa,CAAC;AACxC,QAAM,gBAAgB,CAAC,UAAmB;AAExC,QACE,EAAS,KAAK,KACd,EAAS,MAAM,MAAM,KACrB,OAAO,MAAM,OAAO,IAAI,EAAE,SAAS,WAAW;AAE9C;AAEF,IAAC,OAAO,UAAyB,KAAK,KAAK;AAAA,EAC7C;AACA,QAAM,cAAoC;AAAA,IACxC,MAAM;AAAA,IACN,QAAQ,CAAC;AAAA,IACT,MAAM,CAAC,OAAO,YAAY;AACxB,oBAAc,QAAQ,QAAQ,KAAK;AAAA,IACrC;AAAA,IACA,WAAW,CAAC,UAAU;AACpB,oBAAc;AAAA,QACZ,MAAM;AAAA,QACN,eAAe,MAAM;AAAA,QACrB,QAAQ,MAAM,KAAK,SAAS,MAAM,OAAO,MAAM;AAAA,MACjD,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;;;ACjCA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,WAAuB;AAAA,EAClC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,KAAK;AAAA,MACH,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA,QACP,KAAK;AAAA,QACL,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAU;AAAA,MACZ;AAAA,MACA,aACE;AAAA,IACJ;AAAA,IACA,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aACE;AAAA,IACJ;AAAA,IACA,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS,CAAC;AAAA,MACV,aACE;AAAA,IACJ;AAAA,EACF;AACF;AAEO,IAAM,gBAA4B;AAAA,EACvC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,eAAe;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,mBAAmB;AAAA,MACjB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,iBAAiB;AAAA,MACf,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,oBAAoB;AAAA,MAClB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,EACF;AACF;AAEO,IAAM,kBAA8B;AAAA,EACzC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,kBAAkB;AAAA,MAChB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,oBAAoB;AAAA,MAClB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,EACF;AACF;AAEO,IAAM,kBAA8B;AAAA,EACzC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,qBAAqB;AAAA,MACnB,MAAM;AAAA,MACN,SAAS,EAAE,YAAY,KAAK;AAAA,MAC5B,aAAa;AAAA,IACf;AAAA,IACA,0BAA0B;AAAA,MACxB,MAAM;AAAA,MACN,SAAS,CAAC;AAAA,MACV,aACE;AAAA,IACJ;AAAA,EACF;AACF;;;ACrFA,eAAsB,eAAe,SAAiB,CAAC,GAAsB;AAE3E,QAAM,gBAAwB;AAAA,IAC5B,WAAW;AAAA,MACT,cAAc;AAAA,QACZ,WAAW,EAAE,MAAM,qBAAqB,EAAE;AAAA,MAC5C;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,SAAS;AAAA,IACX;AAAA,IACA,WAAW;AAAA,IACX,KAAK;AAAA,IACL,KAAK;AAAA,EACP;AAEA,QAAM,aAAa,EAAO,eAAe,MAAM;AAG/C,QAAMA,mBAAwC;AAAA,IAC5C,GAAG,WAAW;AAAA,IACd,SAAS;AAAA,MACP,SAAS;AAAA,QACP,MAAM;AAAA,QACN,QAAQ;AAAA,UACN,UAAU,WAAW;AAAA,QACvB;AAAA,QACA,KAAK;AAAA,UACH,QAAQ,OAAO,WAAW,cAAc,SAAS;AAAA,UACjD,UAAU,OAAO,aAAa,cAAc,WAAW;AAAA,QACzD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,MAAI,WAAW,WAAW;AACxB,UAAM,oBAAoB,EAAS,WAAW,SAAS,IACnD,WAAW,YACX,CAAC;AAEL,QAAIA,iBAAgB,SAAS;AAC3B,MAAAA,iBAAgB,QAAQ,YAAY;AAAA,QAClC,MAAMC;AAAA,QACN,QAAQ;AAAA,UACN,UAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,OAAO,MAAM,EAAqCD,gBAAe;AAGvE,MAAI,OAAO,WAAW,aAAa;AACjC,QAAI,WAAW,IAAK,QAAO,WAAW,GAAG,IAAI,KAAK;AAClD,QAAI,WAAW,KAAM,QAAO,WAAW,IAAI,IAAI,KAAK;AAAA,EACtD;AAEA,SAAO;AACT;AAGA,IAAO,gBAAQ;","names":["collectorConfig","D"]}
package/dist/walker.js CHANGED
@@ -1 +1 @@
1
- "use strict";(()=>{var e=Object.defineProperty,t={Storage:{Local:"local",Session:"session",Cookie:"cookie"}},n={merge:!0,shallow:!0,extend:!0};function o(e,t={},o={}){o={...n,...o};const r=Object.entries(t).reduce((t,[n,r])=>{const i=e[n];return o.merge&&Array.isArray(i)&&Array.isArray(r)?t[n]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(o.extend||n in e)&&(t[n]=r),t},{});return o.shallow?{...e,...r}:(Object.assign(e,r),e)}function r(e){return Array.isArray(e)}function i(e){return void 0!==e}function a(e){return"object"==typeof e&&null!==e&&!r(e)&&"[object Object]"===Object.prototype.toString.call(e)}function s(e){return"string"==typeof e}function c(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=c(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(c(e,t))}),n}if("[object Date]"===n)return new Date(e.getTime());if("[object RegExp]"===n){const t=e;return new RegExp(t.source,t.flags)}return e}function u(e,t="",n){const o=t.split(".");let a=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&r(a)){const t=o.slice(e+1).join("."),r=[];for(const e of a){const o=u(e,t,n);r.push(o)}return r}if(a=a instanceof Object?a[t]:void 0,!a)break}return i(a)?a:n}function l(e,t,n){if(!a(e))return e;const o=c(e),r=t.split(".");let i=o;for(let e=0;e<r.length;e++){const t=r[e];e===r.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return o}function d(e,t={},n={}){const o={...t,...n},r={};let i=void 0===e;return Object.keys(o).forEach(t=>{o[t]&&(r[t]=!0,e&&e[t]&&(i=!0))}),!!i&&r}function f(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function g(e){return function(e){return"boolean"==typeof e}(e)||s(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!i(e)||r(e)&&e.every(g)||a(e)&&Object.values(e).every(g)}function p(e){return g(e)?e:void 0}function m(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function y(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(null==n?void 0:n())}}}async function b(e,t={},n={}){var o;if(!i(e))return;const s=a(e)&&e.consent||n.consent||(null==(o=n.collector)?void 0:o.consent),c=r(t)?t:[t];for(const t of c){const o=await y(h)(e,t,{...n,consent:s});if(i(o))return o}}async function h(e,t,n={}){const{collector:o,consent:a}=n;return(r(t)?t:[t]).reduce(async(t,c)=>{const l=await t;if(l)return l;const f=s(c)?{key:c}:c;if(!Object.keys(f).length)return;const{condition:g,consent:m,fn:w,key:v,loop:k,map:S,set:j,validate:E,value:L}=f;if(g&&!await y(g)(e,c,o))return;if(m&&!d(m,a))return L;let _=i(L)?L:e;if(w&&(_=await y(w)(e,c,n)),v&&(_=u(e,v,L)),k){const[t,o]=k,a="this"===t?[e]:await b(e,t,n);r(a)&&(_=(await Promise.all(a.map(e=>b(e,o,n)))).filter(i))}else S?_=await Object.entries(S).reduce(async(t,[o,r])=>{const a=await t,s=await b(e,r,n);return i(s)&&(a[o]=s),a},Promise.resolve({})):j&&(_=await Promise.all(j.map(t=>h(e,t,n))));E&&!await y(E)(_)&&(_=void 0);const O=p(_);return i(O)?O:p(L)},Promise.resolve(void 0))}async function w(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await b(e,o,{collector:n});e=l(e,t,r)}));const{eventMapping:i,mappingKey:s}=await async function(e,t){var n;const[o,i]=(e.name||"").split(" ");if(!t||!o||!i)return{};let a,s="",c=o,u=i;const l=t=>{if(t)return(t=r(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[c]||(c="*");const d=t[c];return d&&(d[u]||(u="*"),a=l(d[u])),a||(c="*",u="*",a=l(null==(n=t[c])?void 0:n[u])),a&&(s=`${c} ${u}`),{eventMapping:a,mappingKey:s}}(e,t.mapping);(null==i?void 0:i.policy)&&await Promise.all(Object.entries(i.policy).map(async([t,o])=>{const r=await b(e,o,{collector:n});e=l(e,t,r)}));let c=t.data&&await b(e,t.data,{collector:n});if(i){if(i.ignore)return{event:e,data:c,mapping:i,mappingKey:s,ignore:!0};if(i.name&&(e.name=i.name),i.data){const t=i.data&&await b(e,i.data,{collector:n});c=a(c)&&a(t)?o(c,t):t}}return{event:e,data:c,mapping:i,mappingKey:s,ignore:!1}}function v(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function k(e,t,n){return function(...o){let r;const i="post"+t,a=n["pre"+t],s=n[i];return r=a?a({fn:e},...o):e(...o),s&&(r=s({fn:e,result:r},...o)),r}}function S(e,t){return(e.getAttribute(t)||"").trim()}function j(e){const t={};return function(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}(e).forEach(e=>{const[n,o]=function(e){const[t,n]=e.split(/:(.+)/,2);return[v(t||""),v(n||"")]}(e);n&&("true"===o?t[n]=!0:"false"===o?t[n]=!1:o&&/^\d+$/.test(o)?t[n]=parseInt(o,10):o&&/^\d+\.\d+$/.test(o)?t[n]=parseFloat(o):t[n]=o||!0)}),t}var E=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)};function L(e){const t=getComputedStyle(e);if("none"===t.display)return!1;if("visible"!==t.visibility)return!1;if(t.opacity&&Number(t.opacity)<.1)return!1;let n;const o=window.innerHeight,r=e.getBoundingClientRect(),i=r.height,a=r.y,s=a+i,c={x:r.x+e.offsetWidth/2,y:r.y+e.offsetHeight/2};if(i<=o){if(e.offsetWidth+r.width===0||e.offsetHeight+r.height===0)return!1;if(c.x<0)return!1;if(c.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(c.y<0)return!1;if(c.y>(document.documentElement.clientHeight||window.innerHeight))return!1;n=document.elementFromPoint(c.x,c.y)}else{const e=o/2;if(a<0&&s<e)return!1;if(s>o&&a>e)return!1;n=document.elementFromPoint(c.x,o/2)}if(n)do{if(n===e)return!0}while(n=n.parentElement);return!1}function _(e,t,n){return!1===n?e:(n||(n=O),n(e,t,O))}var O=(e,t)=>{const n={};return e.id&&(n.session=e.id),e.storage&&e.device&&(n.device=e.device),t?t.command("user",n):E("walker user",n),e.isStart&&(t?t.push({name:"session start",data:e}):E({name:"session start",data:e})),e};function x(e,n=t.Storage.Session){var o;function r(e){try{return JSON.parse(e||"")}catch(t){let n=1,o="";return e&&(n=0,o=e),{e:n,v:o}}}let i,a;switch(n){case t.Storage.Cookie:i=decodeURIComponent((null==(o=document.cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:o.split("=")[1])||"");break;case t.Storage.Local:a=r(window.localStorage.getItem(e));break;case t.Storage.Session:a=r(window.sessionStorage.getItem(e))}return a&&(i=a.v,0!=a.e&&a.e<Date.now()&&(function(e,n=t.Storage.Session){switch(n){case t.Storage.Cookie:A(e,"",0,n);break;case t.Storage.Local:window.localStorage.removeItem(e);break;case t.Storage.Session:window.sessionStorage.removeItem(e)}}(e,n),i="")),function(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}(i||"")}function A(e,n,o=30,r=t.Storage.Session,i){const a={e:Date.now()+6e4*o,v:String(n)},s=JSON.stringify(a);switch(r){case t.Storage.Cookie:{n="object"==typeof n?JSON.stringify(n):n;let t=`${e}=${encodeURIComponent(n)}; max-age=${60*o}; path=/; SameSite=Lax; secure`;i&&(t+="; domain="+i),document.cookie=t;break}case t.Storage.Local:window.localStorage.setItem(e,s);break;case t.Storage.Session:window.sessionStorage.setItem(e,s)}return x(e,r)}function C(e={}){const t=Date.now(),{length:n=30,deviceKey:o="elbDeviceId",deviceStorage:r="local",deviceAge:i=30,sessionKey:a="elbSessionId",sessionStorage:s="local",pulse:c=!1}=e,u=$(e);let l=!1;const d=m((e,t,n)=>{let o=x(e,n);return o||(o=f(8),A(e,o,1440*t,n)),String(o)})(o,i,r),g=m((e,o)=>{const r=JSON.parse(String(x(e,o)));return c||(r.isNew=!1,u.marketing&&(Object.assign(r,u),l=!0),l||r.updated+6e4*n<t?(delete r.id,delete r.referrer,r.start=t,r.count++,r.runs=1,l=!0):r.runs++),r},()=>{l=!0})(a,s)||{},p={id:f(12),start:t,isNew:!0,count:1,runs:1},y=Object.assign(p,u,g,{device:d},{isStart:l,storage:!0,updated:t},e.data);return A(a,JSON.stringify(y),2*n,s),y}function $(e={}){let t=e.isStart||!1;const n={isStart:t,storage:!1};if(!1===e.isStart)return n;if(!t){const[e]=performance.getEntriesByType("navigation");if("navigate"!==e.type)return n}const r=new URL(e.url||window.location.href),i=e.referrer||document.referrer,a=i&&new URL(i).hostname,s=function(e,t={}){const n="clickId",r={},i={utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term",dclid:n,fbclid:n,gclid:n,msclkid:n,ttclid:n,twclid:n,igshid:n,sclid:n};return Object.entries(o(i,t)).forEach(([t,o])=>{const i=e.searchParams.get(t);i&&(o===n&&(o=t,r[n]=t),r[o]=i)}),r}(r,e.parameters);if(Object.keys(s).length&&(s.marketing||(s.marketing=!0),t=!0),!t){const n=e.domains||[];n.push(r.hostname),t=!n.includes(a)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:f(12),referrer:a},s,e.data):n}var q={Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Session:"session",User:"user",Walker:"walker"};async function P(e,t,n){const{allowed:r,consent:i,globals:a,user:s}=e;if(!r)return I({ok:!1});t&&e.queue.push(t),n||(n=e.destinations);const u=await Promise.all(Object.entries(n||{}).map(async([n,r])=>{let u=(r.queue||[]).map(e=>({...e,consent:i}));if(r.queue=[],t){const e=c(t);u.push(e)}if(!u.length)return{id:n,destination:r,skipped:!0};const l=[],f=u.filter(e=>{const t=d(r.config.consent,i,e.consent);return!t||(e.consent=t,l.push(e),!1)});if(r.queue.concat(f),!l.length)return{id:n,destination:r,queue:u};if(!await y(D)(e,r))return{id:n,destination:r,queue:u};let g=!1;return r.dlq||(r.dlq=[]),await Promise.all(l.map(async t=>(t.globals=o(a,t.globals),t.user=o(s,t.user),await y(R,n=>(e.config.onError&&e.config.onError(n,e),g=!0,r.dlq.push([t,n]),!1))(e,r,t),t))),{id:n,destination:r,error:g}})),l=[],f=[],g=[];for(const e of u){if(e.skipped)continue;const t=e.destination,n={id:e.id,destination:t};e.error?g.push(n):e.queue&&e.queue.length?(t.queue=(t.queue||[]).concat(e.queue),f.push(n)):l.push(n)}return I({ok:!g.length,event:t,successful:l,queued:f,failed:g})}async function D(e,t){if(t.init&&!t.config.init){const n={collector:e,config:t.config,env:X(t.env,t.config.env)},o=await k(t.init,"DestinationInit",e.hooks)(n);if(!1===o)return o;t.config={...o||t.config,init:!0}}return!0}async function R(e,t,n){var o;const{config:r}=t,a=await w(n,r,e);if(a.ignore)return!1;const s={collector:e,config:r,data:a.data,mapping:a.mapping,env:X(t.env,r.env)},c=a.mapping;if((null==c?void 0:c.batch)&&t.pushBatch){const n=c.batched||{key:a.mappingKey||"",events:[],data:[]};n.events.push(a.event),i(a.data)&&n.data.push(a.data),c.batchFn=c.batchFn||function(e,t=1e3,n=!1){let o,r=null,i=!1;return(...a)=>new Promise(s=>{const c=n&&!i;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n&&!i||(o=e(...a),s(o))},t),c&&(i=!0,o=e(...a),s(o))})}((e,t)=>{const o={collector:t,config:r,data:a.data,mapping:c,env:X(e.env,r.env)};k(e.pushBatch,"DestinationPushBatch",t.hooks)(n,o),n.events=[],n.data=[]},c.batch),c.batched=n,null==(o=c.batchFn)||o.call(c,t,e)}else await k(t.push,"DestinationPush",e.hooks)(a.event,s);return!0}function I(e){var t;return o({ok:!(null==(t=null==e?void 0:e.failed)?void 0:t.length),successful:[],queued:[],failed:[]},e)}function X(e,t){return e||t?t?e&&a(e)&&a(t)?{...e,...t}:t:e:{}}function N(e,t,n,o){let r,i=n||[];switch(n||(i=e.on[t]||[]),t){case q.Consent:r=o||e.consent;break;case q.Session:r=e.session;break;case q.Ready:case q.Run:default:r=void 0}if(Object.values(e.sources).forEach(e=>{e.on&&m(e.on)(t,r)}),Object.values(e.destinations).forEach(e=>{if(e.on){m(e.on)(t,r)}}),i.length)switch(t){case q.Consent:!function(e,t,n){const o=n||e.consent;t.forEach(t=>{Object.keys(o).filter(e=>e in t).forEach(n=>{m(t[n])(e,o)})})}(e,i,o);break;case q.Ready:case q.Run:s=i,(a=e).allowed&&s.forEach(e=>{m(e)(a)});break;case q.Session:!function(e,t){e.session&&t.forEach(t=>{m(t)(e,e.session)})}(e,i)}var a,s}async function T(e,t,n,i){let c;switch(t){case q.Config:a(n)&&o(e.config,n,{shallow:!1});break;case q.Consent:a(n)&&(c=await async function(e,t){const{consent:n}=e;let r=!1;const i={};return Object.entries(t).forEach(([e,t])=>{const n=!!t;i[e]=n,r=r||n}),e.consent=o(n,i),N(e,"consent",void 0,i),r?P(e):I({ok:!0})}(e,n));break;case q.Custom:a(n)&&(e.custom=o(e.custom,n));break;case q.Destination:a(n)&&"function"==typeof n.push&&(c=await async function(e,t,n){const{code:o,config:r={},env:i={}}=t,a=n||r||{init:!1},s={...o,config:a,env:X(o.env,i)};let c=s.config.id;if(!c)do{c=f(4)}while(e.destinations[c]);return e.destinations[c]=s,!1!==s.config.queue&&(s.queue=[...e.queue]),P(e,void 0,{[c]:s})}(e,{code:n},i));break;case q.Globals:a(n)&&(e.globals=o(e.globals,n));break;case q.On:s(n)&&function(e,t,n){const o=e.on,i=o[t]||[],a=r(n)?n:[n];a.forEach(e=>{i.push(e)}),o[t]=i,N(e,t,a)}(e,n,i);break;case q.Ready:N(e,"ready");break;case q.Run:c=await async function(e,t){e.allowed=!0,e.count=0,e.group=f(),e.timing=Date.now(),t&&(t.consent&&(e.consent=o(e.consent,t.consent)),t.user&&(e.user=o(e.user,t.user)),t.globals&&(e.globals=o(e.config.globalsStatic||{},t.globals)),t.custom&&(e.custom=o(e.custom,t.custom))),Object.values(e.destinations).forEach(e=>{e.queue=[]}),e.queue=[],e.round++;const n=await P(e);return N(e,"run"),n}(e,n);break;case q.Session:N(e,"session");break;case q.User:a(n)&&o(e.user,n,{shallow:!1})}return c||{ok:!0,successful:[],queued:[],failed:[]}}function W(e,t){return k(async(n,o={})=>await y(async()=>{let r=n;if(o.mapping){const t=await w(r,o.mapping,e);if(t.ignore)return I({ok:!0});if(o.mapping.consent&&!d(o.mapping.consent,e.consent,t.event.consent))return I({ok:!0});r=t.event}const i=t(r),a=function(e,t){if(!t.name)throw new Error("Event name is required");const[n,o]=t.name.split(" ");if(!n||!o)throw new Error("Event name is invalid");++e.count;const{timestamp:r=Date.now(),group:i=e.group,count:a=e.count}=t,{name:s=`${n} ${o}`,data:c={},context:u={},globals:l=e.globals,custom:d={},user:f=e.user,nested:g=[],consent:p=e.consent,id:m=`${r}-${i}-${a}`,trigger:y="",entity:b=n,action:h=o,timing:w=0,version:v={source:e.version,tagging:e.config.tagging||0},source:k={type:"collector",id:"",previous_id:""}}=t;return{name:s,data:c,context:u,globals:l,custom:d,user:f,nested:g,consent:p,id:m,trigger:y,entity:b,action:h,timestamp:r,timing:w,group:i,count:a,version:v,source:k}}(e,i);return await P(e,a)},()=>I({ok:!1}))(),"Push",e.hooks)}async function M(e){const t=o({globalsStatic:{},sessionStatic:{},tagging:0,verbose:!1,onLog:n,run:!0},e,{merge:!1,extend:!1});function n(e,n){!function(e,t=!1){t&&console.dir(e,{depth:4})}({message:e},n||t.verbose)}t.onLog=n;const r={...t.globalsStatic,...e.globals},i={allowed:!1,config:t,consent:e.consent||{},count:0,custom:e.custom||{},destinations:{},globals:r,group:"",hooks:{},on:{},queue:[],round:0,session:void 0,timing:Date.now(),user:e.user||{},version:"0.3.1",sources:{},push:void 0,command:void 0};return i.push=W(i,e=>({timing:Math.round((Date.now()-i.timing)/10)/100,source:{type:"collector",id:"",previous_id:""},...e})),i.command=(s=T,k(async(e,t,n)=>await y(async()=>await s(a,e,t,n),()=>I({ok:!1}))(),"Command",(a=i).hooks)),i.destinations=await async function(e,t={}){const n={};for(const[e,o]of Object.entries(t)){const{code:t,config:r={},env:i={}}=o,a={...t.config,...r},s=X(t.env,i);n[e]={...t,config:a,env:s}}return n}(0,e.destinations||{}),i;var a,s}async function U(e){e=e||{};const t=await M(e),n=(o=t,{type:"elb",config:{},push:async(e,t,n,r,i,a)=>{if("string"==typeof e&&e.startsWith("walker ")){const r=e.replace("walker ","");return o.command(r,t,n)}let s;if("string"==typeof e)s={name:e},t&&"object"==typeof t&&!Array.isArray(t)&&(s.data=t);else{if(!e||"object"!=typeof e)return{ok:!1,successful:[],queued:[],failed:[]};s=e,t&&"object"==typeof t&&!Array.isArray(t)&&(s.data={...s.data||{},...t})}return r&&"object"==typeof r&&(s.context=r),i&&Array.isArray(i)&&(s.nested=i),a&&"object"==typeof a&&(s.custom=a),o.push(s)}});var o;t.sources.elb=n;const r=await async function(e,t={}){const n={};for(const[o,r]of Object.entries(t)){const{code:t,config:i={},env:a={},primary:s}=r,c={push:(t,n={})=>e.push(t,{...n,mapping:i}),command:e.command,sources:e.sources,elb:e.sources.elb.push,...a},u=await y(t)(i,c);u&&(s&&(u.config={...u.config,primary:s}),n[o]=u)}return n}(t,e.sources||{});Object.assign(t.sources,r);const{consent:i,user:a,globals:s,custom:c}=e;i&&await t.command("consent",i),a&&await t.command("user",a),s&&Object.assign(t.globals,s),c&&Object.assign(t.custom,c),t.config.run&&await t.command("run");let u=n.push;const l=Object.values(t.sources).filter(e=>"elb"!==e.type),d=l.find(e=>e.config.primary);return d?u=d.push:l.length>0&&(u=l[0].push),{collector:t,elb:u}}var H=Object.defineProperty,B=(e,t)=>{for(var n in t)H(e,n,{get:t[n],enumerable:!0})},K={merge:!0,shallow:!0,extend:!0};function G(e,t={},n={}){n={...K,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function F(e){return Array.isArray(e)}function J(e){return e===document||e instanceof Element}function z(e){return"object"==typeof e&&null!==e&&!F(e)&&"[object Object]"===Object.prototype.toString.call(e)}function Y(e){return"string"==typeof e}function V(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function Q(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function Z(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function ee(e,t,n=!0){return e+(null!=t?(n?"-":"")+t:"")}function te(e,t,n,o=!0){return le(S(t,ee(e,n,o))||"").reduce((e,n)=>{let[o,r]=de(n);if(!o)return e;if(r||(o.endsWith(":")&&(o=o.slice(0,-1)),r=""),r.startsWith("#")){r=r.slice(1);try{let e=t[r];e||"selected"!==r||(e=t.options[t.selectedIndex].text),r=String(e)}catch(e){r=""}}return o.endsWith("[]")?(o=o.slice(0,-2),F(e[o])||(e[o]=[]),e[o].push(V(r))):e[o]=V(r),e},{})}function ne(e=q.Prefix,t=document){const n=ee(e,q.Globals,!1);let o={};return ue(t,`[${n}]`,t=>{o=G(o,te(e,t,q.Globals,!1))}),o}function oe(e,t){const n=window.location,o="page",r=t===document?document.body:t,[i,a]=ce(r,`[${ee(e,o)}]`,e,o);return i.domain=n.hostname,i.title=document.title,i.referrer=document.referrer,n.search&&(i.search=n.search),n.hash&&(i.hash=n.hash),[i,a]}function re(e){const t={};return le(e).forEach(e=>{const[n,o]=de(e),[r,i]=fe(n);if(!r)return;let[a,s]=fe(o||"");a=a||r,t[r]||(t[r]=[]),t[r].push({trigger:r,triggerParams:i,action:a,actionParams:s})}),t}function ie(e,t,n,o=!1){const r=[];let i=t;for(n=0!==Object.keys(n||{}).length?n:void 0;i;){const a=ae(e,i,t,n);if(a&&(r.push(a),o))break;i=se(e,i)}return r}function ae(e,t,n,o){const r=S(t,ee(e));if(!r||o&&!o[r])return null;const i=[t],a=`[${ee(e,r)}],[${ee(e,"")}]`,s=ee(e,q.Link,!1);let c={};const u=[],[l,d]=ce(n||t,a,e,r);ue(t,`[${s}]`,t=>{const[n,o]=de(S(t,s));"parent"===o&&ue(document.body,`[${s}="${n}:child"]`,t=>{i.push(t);const n=ae(e,t);n&&u.push(n)})});const f=[];i.forEach(e=>{e.matches(a)&&f.push(e),ue(e,a,e=>f.push(e))});let g={};return f.forEach(t=>{g=G(g,te(e,t,"")),c=G(c,te(e,t,r))}),c=G(G(g,c),l),i.forEach(t=>{ue(t,`[${ee(e)}]`,t=>{const n=ae(e,t);n&&u.push(n)})}),{entity:r,data:c,context:d,nested:u}}function se(e,t){const n=ee(e,q.Link,!1);if(t.matches(`[${n}]`)){const[e,o]=de(S(t,n));if("child"===o)return document.querySelector(`[${n}="${e}:parent"]`)}return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof ShadowRoot?t.getRootNode().host:t.parentElement}function ce(e,t,n,o){let r={};const i={};let a=e;const s=`[${ee(n,q.Context,!1)}]`;let c=0;for(;a;)a.matches(t)&&(r=G(te(n,a,""),r),r=G(te(n,a,o),r)),a.matches(s)&&(Object.entries(te(n,a,q.Context,!1)).forEach(([e,t])=>{t&&!i[e]&&(i[e]=[t,c])}),++c),a=se(n,a);return[r,i]}function ue(e,t,n){e.querySelectorAll(t).forEach(n)}function le(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function de(e){const[t,n]=e.split(/:(.+)/,2);return[Z(t),Z(n)]}function fe(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var ge,pe=new WeakMap,me=new WeakMap,ye=new WeakMap;function be(e){const t=Date.now();let n=me.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:L(e),lastChecked:t},me.set(e,n)),n.isVisible}function he(e){if(window.IntersectionObserver)return Q(()=>new window.IntersectionObserver(t=>{t.forEach(t=>{!function(e,t){var n,o;const r=t.target,i=ye.get(e);if(!i)return;const a=i.timers.get(r);if(t.intersectionRatio>0){const o=Date.now();let s=pe.get(r);if((!s||o-s.lastChecked>1e3)&&(s={isLarge:r.offsetHeight>window.innerHeight,lastChecked:o},pe.set(r,s)),t.intersectionRatio>=.5||s.isLarge&&be(r)){const t=null==(n=i.elementConfigs)?void 0:n.get(r);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!a){const t=window.setTimeout(async()=>{var t,n;if(be(r)){const o=null==(t=i.elementConfigs)?void 0:t.get(r);(null==o?void 0:o.context)&&await $e(o.context,r,o.trigger);const a=null==(n=i.elementConfigs)?void 0:n.get(r);(null==a?void 0:a.multiple)?a.blocked=!0:function(e,t){const n=ye.get(e);if(!n)return;n.observer&&n.observer.unobserve(t);const o=n.timers.get(t);o&&(clearTimeout(o),n.timers.delete(t)),pe.delete(t),me.delete(t)}(e,r)}},i.duration);i.timers.set(r,t)}return}}a&&(clearTimeout(a),i.timers.delete(r));const s=null==(o=i.elementConfigs)?void 0:o.get(r);(null==s?void 0:s.multiple)&&(s.blocked=!1)}(e,t)})},{rootMargin:"0px",threshold:[0,.5]}),()=>{})()}function we(e,t,n={multiple:!1}){var o;const r=e.settings.scope||document,i=ye.get(r);(null==i?void 0:i.observer)&&t&&(i.elementConfigs||(i.elementConfigs=new WeakMap),i.elementConfigs.set(t,{multiple:null!=(o=n.multiple)&&o,blocked:!1,context:e,trigger:n.multiple?"visible":"impression"}),i.observer.observe(t))}function ve(e){if(!e)return;const t=ye.get(e);t&&(t.observer&&t.observer.disconnect(),ye.delete(e))}function ke(e,t,n,o,r,i,a){const{elb:s,settings:c}=e;if(Y(t)&&t.startsWith("walker "))return s(t,n);if(z(t)){const e=t;return e.source||(e.source=Se()),e.globals||(e.globals=ne(c.prefix,c.scope||document)),s(e)}const[u]=String(z(t)?t.name:t).split(" ");let l,d=z(n)?n:{},f={},g=!1;if(J(n)&&(l=n,g=!0),J(r)?l=r:z(r)&&Object.keys(r).length&&(f=r),l){const e=ie(c.prefix||"data-elb",l).find(e=>e.entity===u);e&&(g&&(d=e.data),f=e.context)}"page"===u&&(d.id=d.id||window.location.pathname);const p=ne(c.prefix,c.scope);return s({name:String(t||""),data:d,context:f,globals:p,nested:i,custom:a,trigger:Y(o)?o:"",source:Se()})}function Se(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var je=[],Ee="hover",Le="load",_e="pulse",Oe="scroll",xe="wait";function Ae(e,t){t.scope&&function(e,t){const n=t.scope;n&&(n.addEventListener("click",Q(function(t){Pe.call(this,e,t)})),n.addEventListener("submit",Q(function(t){De.call(this,e,t)})))}(e,t)}function Ce(e,t){t.scope&&function(e,t){const n=t.scope;je=[];const o=n||document;ve(o),function(e,t=1e3){ye.has(e)||ye.set(e,{observer:he(e),timers:new WeakMap,duration:t})}(o,1e3);const r=ee(t.prefix,q.Action,!1);o!==document&&qe(e,o,r,t),o.querySelectorAll(`[${r}]`).forEach(n=>{qe(e,n,r,t)}),je.length&&function(e,t){const n=(e,t)=>e.filter(([e,n])=>{const o=window.scrollY+window.innerHeight,r=e.offsetTop;if(o<r)return!0;const i=e.clientHeight;return!(100*(1-(r+i-o)/(i||1))>=n&&($e(t,e,Oe),1))});ge||(ge=function(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}(function(){je=n.call(t,je,e)}),t.addEventListener("scroll",ge))}(e,o)}(e,t)}async function $e(e,t,n){const o=function(e,t,n=q.Prefix){const o=[],{actions:r,nearestOnly:i}=function(e,t,n){let o=t;for(;o;){const t=S(o,ee(e,q.Actions,!1));if(t){const e=re(t);if(e[n])return{actions:e[n],nearestOnly:!1}}const r=S(o,ee(e,q.Action,!1));if(r){const e=re(r);if(e[n]||"click"!==n)return{actions:e[n]||[],nearestOnly:!0}}o=se(e,o)}return{actions:[],nearestOnly:!1}}(n,e,t);return r.length?(r.forEach(r=>{const a=le(r.actionParams||"",",").reduce((e,t)=>(e[Z(t)]=!0,e),{}),s=ie(n,e,a,i);if(!s.length){const t="page",o=`[${ee(n,t)}]`,[r,i]=ce(e,o,n,t);s.push({entity:t,data:r,nested:[],context:i})}s.forEach(e=>{o.push({entity:e.entity,action:r.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),o):o}(t,n,e.settings.prefix);return Promise.all(o.map(t=>ke(e,{name:`${t.entity} ${t.action}`,...t,trigger:n})))}function qe(e,t,n,o){const r=S(t,n);r&&Object.values(re(r)).forEach(n=>n.forEach(n=>{switch(n.trigger){case Ee:o=e,t.addEventListener("mouseenter",Q(function(e){e.target instanceof Element&&$e(o,e.target,Ee)}));break;case Le:!function(e,t){$e(e,t,Le)}(e,t);break;case _e:!function(e,t,n=""){setInterval(()=>{document.hidden||$e(e,t,_e)},parseInt(n||"")||15e3)}(e,t,n.triggerParams);break;case Oe:!function(e,t=""){const n=parseInt(t||"")||50;n<0||n>100||je.push([e,n])}(t,n.triggerParams);break;case"impression":we(e,t);break;case"visible":we(e,t,{multiple:!0});break;case xe:!function(e,t,n=""){setTimeout(()=>$e(e,t,xe),parseInt(n||"")||15e3)}(e,t,n.triggerParams)}var o}))}function Pe(e,t){$e(e,t.target,"click")}function De(e,t){t.target&&$e(e,t.target,"submit")}function Re(e,t,n,o){const r=[];let i=!0;n.forEach(e=>{const t=Xe(e)?[...Array.from(e)]:null!=(n=e)&&"object"==typeof n&&"length"in n&&"number"==typeof n.length?Array.from(e):[e];var n;if(Array.isArray(t)&&0===t.length)return;if(Array.isArray(t)&&1===t.length&&!t[0])return;const a=t[0],s=!z(a)&&Y(a)&&a.startsWith("walker ");if(z(a)){if("object"==typeof a&&0===Object.keys(a).length)return}else{const e=Array.from(t);if(!Y(e[0])||""===e[0].trim())return;const n="walker run";i&&e[0]===n&&(i=!1)}(o&&s||!o&&!s)&&r.push(t)}),r.forEach(n=>{Ie(e,t,n)})}function Ie(e,t="data-elb",n){Q(()=>{if(Array.isArray(n)){const[o,...r]=n;if(!o||Y(o)&&""===o.trim())return;if(Y(o)&&o.startsWith("walker "))return void e(o,r[0]);ke({elb:e,settings:{prefix:t,scope:document,pageview:!1,session:!1,elb:"",elbLayer:!1}},o,...r)}else if(n&&"object"==typeof n){if(0===Object.keys(n).length)return;e(n)}},()=>{})()}function Xe(e){return null!=e&&"object"==typeof e&&"[object Arguments]"===Object.prototype.toString.call(e)}function Ne(e,t={},n){return function(e={}){const{cb:t,consent:n,collector:o,storage:a}=e;if(!n)return _((a?C:$)(e),o,t);{const a=function(e,t){let n;return(o,a)=>{if(i(n)&&n===(null==o?void 0:o.group))return;n=null==o?void 0:o.group;let s=()=>$(e);return e.consent&&d((r(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{}),a)&&(s=()=>C(e)),_(s(),o,t)}}(e,t),s=(r(n)?n:[n]).reduce((e,t)=>({...e,[t]:a}),{});o?o.command("on","consent",s):E("walker on","consent",s)}}({...t,collector:{push:e,group:void 0,command:n}})}B({},{env:()=>Te});var Te={};B(Te,{push:()=>Ue});var We=()=>{},Me=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),Ue={get push(){return Me()},get command(){return Me()},get elb(){return Me()},get window(){return{addEventListener:We,removeEventListener:We,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:We,removeEventListener:We,querySelector:We,querySelectorAll:()=>[],getElementById:We,getElementsByClassName:()=>[],getElementsByTagName:()=>[],createElement:()=>({setAttribute:We,getAttribute:We,addEventListener:We,removeEventListener:We}),body:{appendChild:We,removeChild:We},documentElement:{scrollTop:0,scrollLeft:0},readyState:"complete",title:"Test Page",referrer:"",cookie:""}}},He=async(e,t)=>{const{elb:n,command:o,window:r,document:i}=t,a=(null==e?void 0:e.settings)||{},s=r||(void 0!==globalThis.window?globalThis.window:void 0),c=i||(void 0!==globalThis.document?globalThis.document:void 0),u=function(e={},t){return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:t||void 0,...e}}(a,c),l={settings:u},d={elb:n,settings:u};if(s&&c){if(!1!==u.elbLayer&&n&&function(e,t={}){const n=t.name||"elbLayer",o=t.window||window;if(!o)return;const r=o;r[n]||(r[n]=[]);const i=r[n];i.push=function(...n){if(Xe(n[0])){const o=[...Array.from(n[0])],r=Array.prototype.push.apply(this,[o]);return Ie(e,t.prefix,o),r}const o=Array.prototype.push.apply(this,n);return n.forEach(n=>{Ie(e,t.prefix,n)}),o},Array.isArray(i)&&i.length>0&&function(e,t="data-elb",n){Re(e,t,n,!0),Re(e,t,n,!1),n.length=0}(e,t.prefix,i)}(n,{name:Y(u.elbLayer)?u.elbLayer:"elbLayer",prefix:u.prefix,window:s}),u.session&&n){const e="boolean"==typeof u.session?{}:u.session;Ne(n,e,o)}await async function(e,t,n){const o=()=>{e(t,n)};"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o)}(Ae,d,u),(()=>{if(Ce(d,u),u.pageview){const[e,t]=oe(u.prefix||"data-elb",u.scope);ke(d,"page view",e,"load",t)}})(),Y(u.elb)&&u.elb&&(s[u.elb]=(...e)=>{const[t,n,o,r,i,a]=e;return ke(d,t,n,o,r,i,a)})}return{type:"browser",config:l,push:(...e)=>{const[t,n,o,r,i,a]=e;return ke(d,t,n,o,r,i,a)},destroy:async()=>{c&&ve(u.scope||c)},on:async(e,t)=>{switch(e){case"consent":if(u.session&&t&&n){const e="boolean"==typeof u.session?{}:u.session;Ne(n,e,o)}break;case"session":case"ready":default:break;case"run":if(c&&s&&(Ce(d,u),u.pageview)){const[e,t]=oe(u.prefix||"data-elb",u.scope);ke(d,"page view",e,"load",t)}}}}},Be=Object.defineProperty,Ke=(e,t)=>{for(var n in t)Be(e,n,{get:t[n],enumerable:!0})},Ge=!1;function Fe(e,t={},n){if(t.filter&&!0===m(()=>t.filter(n),()=>!1)())return;const o=function(e){if(a(e)&&s(e.event)){const{event:t,...n}=e;return{name:t,...n}}return r(e)&&e.length>=2?Je(e):null!=(t=e)&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&t.length>0?Je(Array.from(e)):null;var t}(n);if(!o)return;const i=`${t.prefix||"dataLayer"} ${o.name}`,{name:c,...u}=o,l={name:i,data:u};m(()=>e(l),()=>{})()}function Je(e){const[t,n,o]=e;if(!s(t))return null;let r,i={};switch(t){case"consent":if(!s(n)||e.length<3)return null;if("default"!==n&&"update"!==n)return null;if(!a(o)||null===o)return null;r=`${t} ${n}`,i={...o};break;case"event":if(!s(n))return null;r=n,a(o)&&(i={...o});break;case"config":if(!s(n))return null;r=`${t} ${n}`,a(o)&&(i={...o});break;case"set":if(s(n))r=`${t} ${n}`,a(o)&&(i={...o});else{if(!a(n))return null;r=`${t} custom`,i={...n}}break;default:return null}return{name:r,...i}}Ke({},{push:()=>Ve});var ze=()=>{},Ye=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),Ve={get push(){return Ye()},get command(){return Ye()},get elb(){return Ye()},get window(){return{dataLayer:[],addEventListener:ze,removeEventListener:ze}}};function Qe(){return["consent","update",{ad_user_data:"granted",ad_personalization:"granted",ad_storage:"denied",analytics_storage:"granted"}]}function Ze(){return["consent","default",{ad_storage:"denied",analytics_storage:"denied",ad_user_data:"denied",ad_personalization:"denied"}]}function et(){return["event","purchase",{transaction_id:"T_12345",value:25.42,currency:"EUR",items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",quantity:1,price:25.42}]}]}function tt(){return["event","add_to_cart",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_variant:"red",quantity:1,price:15.25}]}]}function nt(){return["event","view_item",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",price:15.25}]}]}function ot(){return["config","G-XXXXXXXXXX",{page_title:"Custom Page Title",page_location:"https://example.com/page",send_page_view:!1}]}function rt(){return["set",{currency:"EUR",country:"DE"}]}function it(){return{event:"custom_event",custom_parameter:"custom_value",user_id:"user123"}}Ke({},{add_to_cart:()=>tt,config:()=>ot,consentDefault:()=>Ze,consentUpdate:()=>Qe,directDataLayerEvent:()=>it,purchase:()=>et,setCustom:()=>rt,view_item:()=>nt});Ke({},{add_to_cart:()=>ct,config:()=>ft,configGA4:()=>lt,consentOnlyMapping:()=>gt,consentUpdate:()=>at,customEvent:()=>dt,purchase:()=>st,view_item:()=>ut});var at={name:"walker consent",settings:{command:{map:{functional:{value:!0},analytics:{key:"analytics_storage",fn:e=>"granted"===e},marketing:{key:"ad_storage",fn:e=>"granted"===e}}}}},st={name:"order complete",data:{map:{id:"transaction_id",total:"value",currency:"currency",nested:{loop:["items",{map:{type:{value:"product"},data:{map:{id:"item_id",name:"item_name",category:"item_category",quantity:"quantity",price:"price"}}}}]}}}},ct={name:"product add",data:{map:{id:"items.0.item_id",name:"items.0.item_name",price:"value",currency:"currency",color:"items.0.item_variant",quantity:"items.0.quantity"}}},ut={name:"product view",data:{map:{id:"items.0.item_id",name:"items.0.item_name",category:"items.0.item_category",price:"items.0.price",currency:"currency"}}},lt={name:"page view",data:{map:{title:"page_title",url:"page_location"}}},dt={data:{map:{user_id:"user_id",custom_parameter:"custom_parameter"}}},ft={consent:{update:at},purchase:st,add_to_cart:ct,view_item:ut,"config G-XXXXXXXXXX":lt,custom_event:dt,"*":{data:{}}},gt={consent:{update:at}},pt=async(e,t)=>{const{elb:n,window:o}=t,r={name:"dataLayer",prefix:"dataLayer",...null==e?void 0:e.settings},i={settings:r};return o&&(function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer",r=window[o];if(Array.isArray(r)&&!Ge){Ge=!0;try{for(const t of r)Fe(e,n,t)}finally{Ge=!1}}}(n,i),function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer";window[o]||(window[o]=[]);const r=window[o];if(!Array.isArray(r))return;const i=r.push.bind(r);r.push=function(...t){if(Ge)return i(...t);Ge=!0;try{for(const o of t)Fe(e,n,o)}finally{Ge=!1}return i(...t)}}(n,i)),{type:"dataLayer",config:i,push:n,destroy:async()=>{const e=r.name||"dataLayer";o&&o[e]&&Array.isArray(o[e])}}};function mt(){window.dataLayer=window.dataLayer||[];const e=e=>{a(e)&&a(e.source)&&String(e.source.type).includes("dataLayer")||window.dataLayer.push(e)};return{type:"dataLayer",config:{},push:(t,n)=>{e(n.data||t)},pushBatch:t=>{e({name:"batch",batched_event:t.key,events:t.data.length?t.data:t.events})}}}((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})({},{browserConfig:()=>bt,collectorConfig:()=>wt,dataLayerConfig:()=>ht,settings:()=>yt});var yt={type:"object",properties:{elb:{type:"string",default:"elb",description:"Global function name for event tracking"},name:{type:"string",default:"walkerjs",description:"Global instance name"},run:{type:"boolean",default:!0,description:"Auto-initialize walker.js on load"},browser:{type:"object",default:{run:!0,session:!0,scope:"document.body",pageview:!0},description:"Browser source configuration. Set to false to disable. See browser configuration section below for details."},dataLayer:{type:"object",default:!1,description:"DataLayer source configuration. Set to true for defaults or object for custom config. See dataLayer configuration section below."},collector:{type:"object",default:{},description:"Collector configuration including destinations and consent settings. See collector configuration section below."}}},bt={type:"object",properties:{"browser.run":{type:"boolean",default:!0,description:"Auto-start DOM tracking"},"browser.session":{type:"boolean",default:!0,description:"Enable session tracking"},"browser.scope":{type:"string",default:"document.body",description:"DOM element scope for tracking"},"browser.pageview":{type:"boolean",default:!0,description:"Enable automatic page view events"}}},ht={type:"object",properties:{dataLayer:{type:"boolean",default:!1,description:"Enable dataLayer integration with defaults"},"dataLayer.name":{type:"string",default:"dataLayer",description:"DataLayer variable name"},"dataLayer.prefix":{type:"string",default:"dataLayer",description:"Event prefix for dataLayer events"}}},wt={type:"object",properties:{"collector.consent":{type:"object",default:{functional:!0},description:"Default consent state"},"collector.destinations":{type:"object",default:{},description:"Destination configurations. See destinations documentation for available options."}}};if(window&&document){const e=async()=>{let e;const t=document.querySelector("script[data-elbconfig]");if(t){const n=t.getAttribute("data-elbconfig")||"";n.includes(":")?e=j(n):n&&(e=window[n])}e||(e=window.elbConfig),e&&await async function(e={}){const t=o({collector:{destinations:{dataLayer:{code:mt()}}},browser:{session:!0},dataLayer:!1,elb:"elb",run:!0},e),n={...t.collector,sources:{browser:{code:He,config:{settings:t.browser},env:{window:"undefined"!=typeof window?window:void 0,document:"undefined"!=typeof document?document:void 0}}}};if(t.dataLayer){const e=a(t.dataLayer)?t.dataLayer:{};n.sources&&(n.sources.dataLayer={code:pt,config:{settings:e}})}const r=await U(n);return"undefined"!=typeof window&&(t.elb&&(window[t.elb]=r.elb),t.name&&(window[t.name]=r.collector)),r}(e)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}})();
1
+ "use strict";(()=>{var e=Object.defineProperty,t=Object.defineProperty;((e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})})({},{Level:()=>o});var n,o=((n=o||{})[n.ERROR=0]="ERROR",n[n.INFO=1]="INFO",n[n.DEBUG=2]="DEBUG",n),r={Storage:{Local:"local",Session:"session",Cookie:"cookie"}},i={merge:!0,shallow:!0,extend:!0};function a(e,t={},n={}){n={...i,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function s(e){return Array.isArray(e)}function c(e){return void 0!==e}function u(e){return"object"==typeof e&&null!==e&&!s(e)&&"[object Object]"===Object.prototype.toString.call(e)}function l(e){return"string"==typeof e}function d(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=d(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(d(e,t))}),n}if("[object Date]"===n)return new Date(e.getTime());if("[object RegExp]"===n){const t=e;return new RegExp(t.source,t.flags)}return e}function f(e,t="",n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&s(r)){const t=o.slice(e+1).join("."),i=[];for(const e of r){const o=f(e,t,n);i.push(o)}return i}if(r=r instanceof Object?r[t]:void 0,!r)break}return c(r)?r:n}function g(e,t,n){if(!u(e))return e;const o=d(e),r=t.split(".");let i=o;for(let e=0;e<r.length;e++){const t=r[e];e===r.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return o}function p(e,t={},n={}){const o={...t,...n},r={};let i=void 0===e;return Object.keys(o).forEach(t=>{o[t]&&(r[t]=!0,e&&e[t]&&(i=!0))}),!!i&&r}function m(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function y(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function b(e,t){let n,o={};return e instanceof Error?(n=e.message,o.error=y(e)):n=e,void 0!==t&&(t instanceof Error?o.error=y(t):"object"==typeof t&&null!==t?(o={...o,...t},"error"in o&&o.error instanceof Error&&(o.error=y(o.error))):o.value=t),{message:n,context:o}}var h=(e,t,n,r)=>{const i=`${o[e]}${r.length>0?` [${r.join(":")}]`:""}`,a=Object.keys(n).length>0;0===e?a?console.error(i,t,n):console.error(i,t):a?console.log(i,t,n):console.log(i,t)};function w(e={}){return v({level:void 0!==e.level?(t=e.level,"string"==typeof t?o[t]:t):0,handler:e.handler,scope:[]});var t}function v(e){const{level:t,handler:n,scope:o}=e,r=(e,r,i)=>{if(e<=t){const t=b(r,i);n?n(e,t.message,t.context,o,h):h(e,t.message,t.context,o)}};return{error:(e,t)=>r(0,e,t),info:(e,t)=>r(1,e,t),debug:(e,t)=>r(2,e,t),throw:(e,t)=>{const r=b(e,t);throw n?n(0,r.message,r.context,o,h):h(0,r.message,r.context,o),new Error(r.message)},scope:e=>v({level:t,handler:n,scope:[...o,e]})}}function k(e){return function(e){return"boolean"==typeof e}(e)||l(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!c(e)||s(e)&&e.every(k)||u(e)&&Object.values(e).every(k)}function E(e){return k(e)?e:void 0}function j(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function S(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(null==n?void 0:n())}}}async function O(e,t={},n={}){var o;if(!c(e))return;const r=u(e)&&e.consent||n.consent||(null==(o=n.collector)?void 0:o.consent),i=s(t)?t:[t];for(const t of i){const o=await S(L)(e,t,{...n,consent:r});if(c(o))return o}}async function L(e,t,n={}){const{collector:o,consent:r}=n;return(s(t)?t:[t]).reduce(async(t,i)=>{const a=await t;if(a)return a;const u=l(i)?{key:i}:i;if(!Object.keys(u).length)return;const{condition:d,consent:g,fn:m,key:y,loop:b,map:h,set:w,validate:v,value:k}=u;if(d&&!await S(d)(e,i,o))return;if(g&&!p(g,r))return k;let j=c(k)?k:e;if(m&&(j=await S(m)(e,i,n)),y&&(j=f(e,y,k)),b){const[t,o]=b,r="this"===t?[e]:await O(e,t,n);s(r)&&(j=(await Promise.all(r.map(e=>O(e,o,n)))).filter(c))}else h?j=await Object.entries(h).reduce(async(t,[o,r])=>{const i=await t,a=await O(e,r,n);return c(a)&&(i[o]=a),i},Promise.resolve({})):w&&(j=await Promise.all(w.map(t=>L(e,t,n))));v&&!await S(v)(j)&&(j=void 0);const _=E(j);return c(_)?_:E(k)},Promise.resolve(void 0))}async function _(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await O(e,o,{collector:n});e=g(e,t,r)}));const{eventMapping:o,mappingKey:r}=await async function(e,t){var n;const[o,r]=(e.name||"").split(" ");if(!t||!o||!r)return{};let i,a="",c=o,u=r;const l=t=>{if(t)return(t=s(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[c]||(c="*");const d=t[c];return d&&(d[u]||(u="*"),i=l(d[u])),i||(c="*",u="*",i=l(null==(n=t[c])?void 0:n[u])),i&&(a=`${c} ${u}`),{eventMapping:i,mappingKey:a}}(e,t.mapping);(null==o?void 0:o.policy)&&await Promise.all(Object.entries(o.policy).map(async([t,o])=>{const r=await O(e,o,{collector:n});e=g(e,t,r)}));let i=t.data&&await O(e,t.data,{collector:n});if(o){if(o.ignore)return{event:e,data:i,mapping:o,mappingKey:r,ignore:!0};if(o.name&&(e.name=o.name),o.data){const t=o.data&&await O(e,o.data,{collector:n});i=u(i)&&u(t)?a(i,t):t}}return{event:e,data:i,mapping:o,mappingKey:r,ignore:!1}}function x(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function A(e,t,n){return function(...o){let r;const i="post"+t,a=n["pre"+t],s=n[i];return r=a?a({fn:e},...o):e(...o),s&&(r=s({fn:e,result:r},...o)),r}}function C(e,t){return(e.getAttribute(t)||"").trim()}function $(e){const t={};return function(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}(e).forEach(e=>{const[n,o]=function(e){const[t,n]=e.split(/:(.+)/,2);return[x(t||""),x(n||"")]}(e);n&&("true"===o?t[n]=!0:"false"===o?t[n]=!1:o&&/^\d+$/.test(o)?t[n]=parseInt(o,10):o&&/^\d+\.\d+$/.test(o)?t[n]=parseFloat(o):t[n]=o||!0)}),t}var q=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)};function P(e){const t=getComputedStyle(e);if("none"===t.display)return!1;if("visible"!==t.visibility)return!1;if(t.opacity&&Number(t.opacity)<.1)return!1;let n;const o=window.innerHeight,r=e.getBoundingClientRect(),i=r.height,a=r.y,s=a+i,c={x:r.x+e.offsetWidth/2,y:r.y+e.offsetHeight/2};if(i<=o){if(e.offsetWidth+r.width===0||e.offsetHeight+r.height===0)return!1;if(c.x<0)return!1;if(c.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(c.y<0)return!1;if(c.y>(document.documentElement.clientHeight||window.innerHeight))return!1;n=document.elementFromPoint(c.x,c.y)}else{const e=o/2;if(a<0&&s<e)return!1;if(s>o&&a>e)return!1;n=document.elementFromPoint(c.x,o/2)}if(n)do{if(n===e)return!0}while(n=n.parentElement);return!1}function R(e,t,n){return!1===n?e:(n||(n=D),n(e,t,D))}var D=(e,t)=>{const n={};return e.id&&(n.session=e.id),e.storage&&e.device&&(n.device=e.device),t?t.command("user",n):q("walker user",n),e.isStart&&(t?t.push({name:"session start",data:e}):q({name:"session start",data:e})),e};function I(e,t=r.Storage.Session){var n;function o(e){try{return JSON.parse(e||"")}catch(t){let n=1,o="";return e&&(n=0,o=e),{e:n,v:o}}}let i,a;switch(t){case r.Storage.Cookie:i=decodeURIComponent((null==(n=document.cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:n.split("=")[1])||"");break;case r.Storage.Local:a=o(window.localStorage.getItem(e));break;case r.Storage.Session:a=o(window.sessionStorage.getItem(e))}return a&&(i=a.v,0!=a.e&&a.e<Date.now()&&(function(e,t=r.Storage.Session){switch(t){case r.Storage.Cookie:N(e,"",0,t);break;case r.Storage.Local:window.localStorage.removeItem(e);break;case r.Storage.Session:window.sessionStorage.removeItem(e)}}(e,t),i="")),function(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}(i||"")}function N(e,t,n=30,o=r.Storage.Session,i){const a={e:Date.now()+6e4*n,v:String(t)},s=JSON.stringify(a);switch(o){case r.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let o=`${e}=${encodeURIComponent(t)}; max-age=${60*n}; path=/; SameSite=Lax; secure`;i&&(o+="; domain="+i),document.cookie=o;break}case r.Storage.Local:window.localStorage.setItem(e,s);break;case r.Storage.Session:window.sessionStorage.setItem(e,s)}return I(e,o)}function X(e={}){const t=Date.now(),{length:n=30,deviceKey:o="elbDeviceId",deviceStorage:r="local",deviceAge:i=30,sessionKey:a="elbSessionId",sessionStorage:s="local",pulse:c=!1}=e,u=T(e);let l=!1;const d=j((e,t,n)=>{let o=I(e,n);return o||(o=m(8),N(e,o,1440*t,n)),String(o)})(o,i,r),f=j((e,o)=>{const r=JSON.parse(String(I(e,o)));return c||(r.isNew=!1,u.marketing&&(Object.assign(r,u),l=!0),l||r.updated+6e4*n<t?(delete r.id,delete r.referrer,r.start=t,r.count++,r.runs=1,l=!0):r.runs++),r},()=>{l=!0})(a,s)||{},g={id:m(12),start:t,isNew:!0,count:1,runs:1},p=Object.assign(g,u,f,{device:d},{isStart:l,storage:!0,updated:t},e.data);return N(a,JSON.stringify(p),2*n,s),p}function T(e={}){let t=e.isStart||!1;const n={isStart:t,storage:!1};if(!1===e.isStart)return n;if(!t){const[e]=performance.getEntriesByType("navigation");if("navigate"!==e.type)return n}const o=new URL(e.url||window.location.href),r=e.referrer||document.referrer,i=r&&new URL(r).hostname,s=function(e,t={}){const n="clickId",o={},r={utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term",dclid:n,fbclid:n,gclid:n,msclkid:n,ttclid:n,twclid:n,igshid:n,sclid:n};return Object.entries(a(r,t)).forEach(([t,r])=>{const i=e.searchParams.get(t);i&&(r===n&&(r=t,o[n]=t),o[r]=i)}),o}(o,e.parameters);if(Object.keys(s).length&&(s.marketing||(s.marketing=!0),t=!0),!t){const n=e.domains||[];n.push(o.hostname),t=!n.includes(i)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:m(12),referrer:i},s,e.data):n}var U={Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Session:"session",User:"user",Walker:"walker"};async function W(e,t,n){const{allowed:o,consent:r,globals:i,user:s}=e;if(!o)return G({ok:!1});t&&e.queue.push(t),n||(n=e.destinations);const c=await Promise.all(Object.entries(n||{}).map(async([n,o])=>{let c=(o.queue||[]).map(e=>({...e,consent:r}));if(o.queue=[],t){const e=d(t);c.push(e)}if(!c.length)return{id:n,destination:o,skipped:!0};const u=[],l=c.filter(e=>{const t=p(o.config.consent,r,e.consent);return!t||(e.consent=t,u.push(e),!1)});if(o.queue.concat(l),!u.length)return{id:n,destination:o,queue:c};if(!await S(M)(e,o))return{id:n,destination:o,queue:c};let f=!1;return o.dlq||(o.dlq=[]),await Promise.all(u.map(async t=>(t.globals=a(i,t.globals),t.user=a(s,t.user),await S(B,n=>{const r=o.type||"unknown";return e.logger.scope(r).error("Push failed",{error:n,event:t.name}),f=!0,o.dlq.push([t,n]),!1})(e,o,t),t))),{id:n,destination:o,error:f}})),u=[],l=[],f=[];for(const e of c){if(e.skipped)continue;const t=e.destination,n={id:e.id,destination:t};e.error?f.push(n):e.queue&&e.queue.length?(t.queue=(t.queue||[]).concat(e.queue),l.push(n)):u.push(n)}return G({ok:!f.length,event:t,successful:u,queued:l,failed:f})}async function M(e,t){if(t.init&&!t.config.init){const n=t.type||"unknown",o=e.logger.scope(n),r={collector:e,config:t.config,env:H(t.env,t.config.env),logger:o},i=await A(t.init,"DestinationInit",e.hooks)(r);if(!1===i)return i;t.config={...i||t.config,init:!0}}return!0}async function B(e,t,n){var o;const{config:r}=t,i=await _(n,r,e);if(i.ignore)return!1;const a=t.type||"unknown",s=e.logger.scope(a),u={collector:e,config:r,data:i.data,mapping:i.mapping,env:H(t.env,r.env),logger:s},l=i.mapping;if((null==l?void 0:l.batch)&&t.pushBatch){const n=l.batched||{key:i.mappingKey||"",events:[],data:[]};n.events.push(i.event),c(i.data)&&n.data.push(i.data),l.batchFn=l.batchFn||function(e,t=1e3,n=!1){let o,r=null,i=!1;return(...a)=>new Promise(s=>{const c=n&&!i;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n&&!i||(o=e(...a),s(o))},t),c&&(i=!0,o=e(...a),s(o))})}((e,t)=>{const o=e.type||"unknown",a=t.logger.scope(o),s={collector:t,config:r,data:i.data,mapping:l,env:H(e.env,r.env),logger:a};A(e.pushBatch,"DestinationPushBatch",t.hooks)(n,s),n.events=[],n.data=[]},l.batch),l.batched=n,null==(o=l.batchFn)||o.call(l,t,e)}else await A(t.push,"DestinationPush",e.hooks)(i.event,u);return!0}function G(e){var t;return a({ok:!(null==(t=null==e?void 0:e.failed)?void 0:t.length),successful:[],queued:[],failed:[]},e)}function H(e,t){return e||t?t?e&&u(e)&&u(t)?{...e,...t}:t:e:{}}function F(e,t,n,o){let r,i=n||[];switch(n||(i=e.on[t]||[]),t){case U.Consent:r=o||e.consent;break;case U.Session:r=e.session;break;case U.Ready:case U.Run:default:r=void 0}if(Object.values(e.sources).forEach(e=>{e.on&&j(e.on)(t,r)}),Object.values(e.destinations).forEach(e=>{if(e.on){j(e.on)(t,r)}}),i.length)switch(t){case U.Consent:!function(e,t,n){const o=n||e.consent;t.forEach(t=>{Object.keys(o).filter(e=>e in t).forEach(n=>{j(t[n])(e,o)})})}(e,i,o);break;case U.Ready:case U.Run:!function(e,t){e.allowed&&t.forEach(t=>{j(t)(e)})}(e,i);break;case U.Session:!function(e,t){e.session&&t.forEach(t=>{j(t)(e,e.session)})}(e,i)}}async function K(e,t,n,o){let r;switch(t){case U.Config:u(n)&&a(e.config,n,{shallow:!1});break;case U.Consent:u(n)&&(r=await async function(e,t){const{consent:n}=e;let o=!1;const r={};return Object.entries(t).forEach(([e,t])=>{const n=!!t;r[e]=n,o=o||n}),e.consent=a(n,r),F(e,"consent",void 0,r),o?W(e):G({ok:!0})}(e,n));break;case U.Custom:u(n)&&(e.custom=a(e.custom,n));break;case U.Destination:u(n)&&function(e){return"function"==typeof e}(n.push)&&(r=await async function(e,t,n){const{code:o,config:r={},env:i={}}=t,a=n||r||{init:!1},s={...o,config:a,env:H(o.env,i)};let c=s.config.id;if(!c)do{c=m(4)}while(e.destinations[c]);return e.destinations[c]=s,!1!==s.config.queue&&(s.queue=[...e.queue]),W(e,void 0,{[c]:s})}(e,{code:n},o));break;case U.Globals:u(n)&&(e.globals=a(e.globals,n));break;case U.On:l(n)&&function(e,t,n){const o=e.on,r=o[t]||[],i=s(n)?n:[n];i.forEach(e=>{r.push(e)}),o[t]=r,F(e,t,i)}(e,n,o);break;case U.Ready:F(e,"ready");break;case U.Run:r=await async function(e,t){e.allowed=!0,e.count=0,e.group=m(),e.timing=Date.now(),t&&(t.consent&&(e.consent=a(e.consent,t.consent)),t.user&&(e.user=a(e.user,t.user)),t.globals&&(e.globals=a(e.config.globalsStatic||{},t.globals)),t.custom&&(e.custom=a(e.custom,t.custom))),Object.values(e.destinations).forEach(e=>{e.queue=[]}),e.queue=[],e.round++;const n=await W(e);return F(e,"run"),n}(e,n);break;case U.Session:F(e,"session");break;case U.User:u(n)&&a(e.user,n,{shallow:!1})}return r||{ok:!0,successful:[],queued:[],failed:[]}}function J(e,t){return A(async(n,o={})=>await S(async()=>{let r=n;if(o.mapping){const t=await _(r,o.mapping,e);if(t.ignore)return G({ok:!0});if(o.mapping.consent&&!p(o.mapping.consent,e.consent,t.event.consent))return G({ok:!0});r=t.event}const i=t(r),a=function(e,t){if(!t.name)throw new Error("Event name is required");const[n,o]=t.name.split(" ");if(!n||!o)throw new Error("Event name is invalid");++e.count;const{timestamp:r=Date.now(),group:i=e.group,count:a=e.count}=t,{name:s=`${n} ${o}`,data:c={},context:u={},globals:l=e.globals,custom:d={},user:f=e.user,nested:g=[],consent:p=e.consent,id:m=`${r}-${i}-${a}`,trigger:y="",entity:b=n,action:h=o,timing:w=0,version:v={source:e.version,tagging:e.config.tagging||0},source:k={type:"collector",id:"",previous_id:""}}=t;return{name:s,data:c,context:u,globals:l,custom:d,user:f,nested:g,consent:p,id:m,trigger:y,entity:b,action:h,timestamp:r,timing:w,group:i,count:a,version:v,source:k}}(e,i);return await W(e,a)},()=>G({ok:!1}))(),"Push",e.hooks)}async function z(e){var t,n;const o=a({globalsStatic:{},sessionStatic:{},tagging:0,run:!0},e,{merge:!1,extend:!1}),r=w({level:null==(t=e.logger)?void 0:t.level,handler:null==(n=e.logger)?void 0:n.handler}),i={...o.globalsStatic,...e.globals},s={allowed:!1,config:o,consent:e.consent||{},count:0,custom:e.custom||{},destinations:{},globals:i,group:"",hooks:{},logger:r,on:{},queue:[],round:0,session:void 0,timing:Date.now(),user:e.user||{},version:"0.4.2",sources:{},push:void 0,command:void 0};return s.push=J(s,e=>({timing:Math.round((Date.now()-s.timing)/10)/100,source:{type:"collector",id:"",previous_id:""},...e})),s.command=(u=K,A(async(e,t,n)=>await S(async()=>await u(c,e,t,n),()=>G({ok:!1}))(),"Command",(c=s).hooks)),s.destinations=await async function(e,t={}){const n={};for(const[e,o]of Object.entries(t)){const{code:t,config:r={},env:i={}}=o,a={...t.config,...r},s=H(t.env,i);n[e]={...t,config:a,env:s}}return n}(0,e.destinations||{}),s;var c,u}async function Y(e){e=e||{};const t=await z(e),n=(o=t,{type:"elb",config:{},push:async(e,t,n,r,i,a)=>{if("string"==typeof e&&e.startsWith("walker ")){const r=e.replace("walker ","");return o.command(r,t,n)}let s;if("string"==typeof e)s={name:e},t&&"object"==typeof t&&!Array.isArray(t)&&(s.data=t);else{if(!e||"object"!=typeof e)return{ok:!1,successful:[],queued:[],failed:[]};s=e,t&&"object"==typeof t&&!Array.isArray(t)&&(s.data={...s.data||{},...t})}return r&&"object"==typeof r&&(s.context=r),i&&Array.isArray(i)&&(s.nested=i),a&&"object"==typeof a&&(s.custom=a),o.push(s)}});var o;t.sources.elb=n;const r=await async function(e,t={}){const n={};for(const[o,r]of Object.entries(t)){const{code:t,config:i={},env:a={},primary:s}=r,c=(t,n={})=>e.push(t,{...n,mapping:i}),u=e.logger.scope("source").scope(o),l={push:c,command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:u,...a},d=await S(t)(i,l);if(!d)continue;const f=d.type||"unknown",g=e.logger.scope(f).scope(o);l.logger=g,s&&(d.config={...d.config,primary:s}),n[o]=d}return n}(t,e.sources||{});Object.assign(t.sources,r);const{consent:i,user:a,globals:s,custom:c}=e;i&&await t.command("consent",i),a&&await t.command("user",a),s&&Object.assign(t.globals,s),c&&Object.assign(t.custom,c),t.config.run&&await t.command("run");let u=n.push;const l=Object.values(t.sources).filter(e=>"elb"!==e.type),d=l.find(e=>e.config.primary);return d?u=d.push:l.length>0&&(u=l[0].push),{collector:t,elb:u}}var V,Q=Object.defineProperty,Z=(e,t)=>{for(var n in t)Q(e,n,{get:t[n],enumerable:!0})},ee=Object.defineProperty;((e,t)=>{for(var n in t)ee(e,n,{get:t[n],enumerable:!0})})({},{Level:()=>te});var te=((V=te||{})[V.ERROR=0]="ERROR",V[V.INFO=1]="INFO",V[V.DEBUG=2]="DEBUG",V),ne={merge:!0,shallow:!0,extend:!0};function oe(e,t={},n={}){n={...ne,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function re(e){return Array.isArray(e)}function ie(e){return e===document||e instanceof Element}function ae(e){return"object"==typeof e&&null!==e&&!re(e)&&"[object Object]"===Object.prototype.toString.call(e)}function se(e){return"string"==typeof e}function ce(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function ue(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function le(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function de(e,t,n=!0){return e+(null!=t?(n?"-":"")+t:"")}function fe(e,t,n,o=!0){return ke(C(t,de(e,n,o))||"").reduce((e,n)=>{let[o,r]=Ee(n);if(!o)return e;if(r||(o.endsWith(":")&&(o=o.slice(0,-1)),r=""),r.startsWith("#")){r=r.slice(1);try{let e=t[r];e||"selected"!==r||(e=t.options[t.selectedIndex].text),r=String(e)}catch(e){r=""}}return o.endsWith("[]")?(o=o.slice(0,-2),re(e[o])||(e[o]=[]),e[o].push(ce(r))):e[o]=ce(r),e},{})}function ge(e=U.Prefix,t=document){const n=de(e,U.Globals,!1);let o={};return ve(t,`[${n}]`,t=>{o=oe(o,fe(e,t,U.Globals,!1))}),o}function pe(e,t){const n=window.location,o="page",r=t===document?document.body:t,[i,a]=we(r,`[${de(e,o)}]`,e,o);return i.domain=n.hostname,i.title=document.title,i.referrer=document.referrer,n.search&&(i.search=n.search),n.hash&&(i.hash=n.hash),[i,a]}function me(e){const t={};return ke(e).forEach(e=>{const[n,o]=Ee(e),[r,i]=je(n);if(!r)return;let[a,s]=je(o||"");a=a||r,t[r]||(t[r]=[]),t[r].push({trigger:r,triggerParams:i,action:a,actionParams:s})}),t}function ye(e,t,n,o=!1){const r=[];let i=t;for(n=0!==Object.keys(n||{}).length?n:void 0;i;){const a=be(e,i,t,n);if(a&&(r.push(a),o))break;i=he(e,i)}return r}function be(e,t,n,o){const r=C(t,de(e));if(!r||o&&!o[r])return null;const i=[t],a=`[${de(e,r)}],[${de(e,"")}]`,s=de(e,U.Link,!1);let c={};const u=[],[l,d]=we(n||t,a,e,r);ve(t,`[${s}]`,t=>{const[n,o]=Ee(C(t,s));"parent"===o&&ve(document.body,`[${s}="${n}:child"]`,t=>{i.push(t);const n=be(e,t);n&&u.push(n)})});const f=[];i.forEach(e=>{e.matches(a)&&f.push(e),ve(e,a,e=>f.push(e))});let g={};return f.forEach(t=>{g=oe(g,fe(e,t,"")),c=oe(c,fe(e,t,r))}),c=oe(oe(g,c),l),i.forEach(t=>{ve(t,`[${de(e)}]`,t=>{const n=be(e,t);n&&u.push(n)})}),{entity:r,data:c,context:d,nested:u}}function he(e,t){const n=de(e,U.Link,!1);if(t.matches(`[${n}]`)){const[e,o]=Ee(C(t,n));if("child"===o)return document.querySelector(`[${n}="${e}:parent"]`)}return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof ShadowRoot?t.getRootNode().host:t.parentElement}function we(e,t,n,o){let r={};const i={};let a=e;const s=`[${de(n,U.Context,!1)}]`;let c=0;for(;a;)a.matches(t)&&(r=oe(fe(n,a,""),r),r=oe(fe(n,a,o),r)),a.matches(s)&&(Object.entries(fe(n,a,U.Context,!1)).forEach(([e,t])=>{t&&!i[e]&&(i[e]=[t,c])}),++c),a=he(n,a);return[r,i]}function ve(e,t,n){e.querySelectorAll(t).forEach(n)}function ke(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function Ee(e){const[t,n]=e.split(/:(.+)/,2);return[le(t),le(n)]}function je(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var Se,Oe=new WeakMap,Le=new WeakMap,_e=new WeakMap;function xe(e){const t=Date.now();let n=Le.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:P(e),lastChecked:t},Le.set(e,n)),n.isVisible}function Ae(e){if(window.IntersectionObserver)return ue(()=>new window.IntersectionObserver(t=>{t.forEach(t=>{!function(e,t){var n,o;const r=t.target,i=_e.get(e);if(!i)return;const a=i.timers.get(r);if(t.intersectionRatio>0){const o=Date.now();let s=Oe.get(r);if((!s||o-s.lastChecked>1e3)&&(s={isLarge:r.offsetHeight>window.innerHeight,lastChecked:o},Oe.set(r,s)),t.intersectionRatio>=.5||s.isLarge&&xe(r)){const t=null==(n=i.elementConfigs)?void 0:n.get(r);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!a){const t=window.setTimeout(async()=>{var t,n;if(xe(r)){const o=null==(t=i.elementConfigs)?void 0:t.get(r);(null==o?void 0:o.context)&&await Me(o.context,r,o.trigger);const a=null==(n=i.elementConfigs)?void 0:n.get(r);(null==a?void 0:a.multiple)?a.blocked=!0:function(e,t){const n=_e.get(e);if(!n)return;n.observer&&n.observer.unobserve(t);const o=n.timers.get(t);o&&(clearTimeout(o),n.timers.delete(t)),Oe.delete(t),Le.delete(t)}(e,r)}},i.duration);i.timers.set(r,t)}return}}a&&(clearTimeout(a),i.timers.delete(r));const s=null==(o=i.elementConfigs)?void 0:o.get(r);(null==s?void 0:s.multiple)&&(s.blocked=!1)}(e,t)})},{rootMargin:"0px",threshold:[0,.5]}),()=>{})()}function Ce(e,t,n={multiple:!1}){var o;const r=e.settings.scope||document,i=_e.get(r);(null==i?void 0:i.observer)&&t&&(i.elementConfigs||(i.elementConfigs=new WeakMap),i.elementConfigs.set(t,{multiple:null!=(o=n.multiple)&&o,blocked:!1,context:e,trigger:n.multiple?"visible":"impression"}),i.observer.observe(t))}function $e(e){if(!e)return;const t=_e.get(e);t&&(t.observer&&t.observer.disconnect(),_e.delete(e))}function qe(e,t,n,o,r,i,a){const{elb:s,settings:c}=e;if(se(t)&&t.startsWith("walker "))return s(t,n);if(ae(t)){const e=t;return e.source||(e.source=Pe()),e.globals||(e.globals=ge(c.prefix,c.scope||document)),s(e)}const[u]=String(ae(t)?t.name:t).split(" ");let l,d=ae(n)?n:{},f={},g=!1;if(ie(n)&&(l=n,g=!0),ie(r)?l=r:ae(r)&&Object.keys(r).length&&(f=r),l){const e=ye(c.prefix||"data-elb",l).find(e=>e.entity===u);e&&(g&&(d=e.data),f=e.context)}"page"===u&&(d.id=d.id||window.location.pathname);const p=ge(c.prefix,c.scope);return s({name:String(t||""),data:d,context:f,globals:p,nested:i,custom:a,trigger:se(o)?o:"",source:Pe()})}function Pe(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var Re=[],De="hover",Ie="load",Ne="pulse",Xe="scroll",Te="wait";function Ue(e,t){t.scope&&function(e,t){const n=t.scope;n&&(n.addEventListener("click",ue(function(t){Ge.call(this,e,t)})),n.addEventListener("submit",ue(function(t){He.call(this,e,t)})))}(e,t)}function We(e,t){t.scope&&function(e,t){const n=t.scope;Re=[];const o=n||document;$e(o),function(e,t=1e3){_e.has(e)||_e.set(e,{observer:Ae(e),timers:new WeakMap,duration:t})}(o,1e3);const r=de(t.prefix,U.Action,!1);o!==document&&Be(e,o,r,t),o.querySelectorAll(`[${r}]`).forEach(n=>{Be(e,n,r,t)}),Re.length&&function(e,t){const n=(e,t)=>e.filter(([e,n])=>{const o=window.scrollY+window.innerHeight,r=e.offsetTop;if(o<r)return!0;const i=e.clientHeight;return!(100*(1-(r+i-o)/(i||1))>=n&&(Me(t,e,Xe),1))});Se||(Se=function(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}(function(){Re=n.call(t,Re,e)}),t.addEventListener("scroll",Se))}(e,o)}(e,t)}async function Me(e,t,n){const o=function(e,t,n=U.Prefix){const o=[],{actions:r,nearestOnly:i}=function(e,t,n){let o=t;for(;o;){const t=C(o,de(e,U.Actions,!1));if(t){const e=me(t);if(e[n])return{actions:e[n],nearestOnly:!1}}const r=C(o,de(e,U.Action,!1));if(r){const e=me(r);if(e[n]||"click"!==n)return{actions:e[n]||[],nearestOnly:!0}}o=he(e,o)}return{actions:[],nearestOnly:!1}}(n,e,t);return r.length?(r.forEach(r=>{const a=ke(r.actionParams||"",",").reduce((e,t)=>(e[le(t)]=!0,e),{}),s=ye(n,e,a,i);if(!s.length){const t="page",o=`[${de(n,t)}]`,[r,i]=we(e,o,n,t);s.push({entity:t,data:r,nested:[],context:i})}s.forEach(e=>{o.push({entity:e.entity,action:r.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),o):o}(t,n,e.settings.prefix);return Promise.all(o.map(t=>qe(e,{name:`${t.entity} ${t.action}`,...t,trigger:n})))}function Be(e,t,n,o){const r=C(t,n);r&&Object.values(me(r)).forEach(n=>n.forEach(n=>{switch(n.trigger){case De:o=e,t.addEventListener("mouseenter",ue(function(e){e.target instanceof Element&&Me(o,e.target,De)}));break;case Ie:!function(e,t){Me(e,t,Ie)}(e,t);break;case Ne:!function(e,t,n=""){setInterval(()=>{document.hidden||Me(e,t,Ne)},parseInt(n||"")||15e3)}(e,t,n.triggerParams);break;case Xe:!function(e,t=""){const n=parseInt(t||"")||50;n<0||n>100||Re.push([e,n])}(t,n.triggerParams);break;case"impression":Ce(e,t);break;case"visible":Ce(e,t,{multiple:!0});break;case Te:!function(e,t,n=""){setTimeout(()=>Me(e,t,Te),parseInt(n||"")||15e3)}(e,t,n.triggerParams)}var o}))}function Ge(e,t){Me(e,t.target,"click")}function He(e,t){t.target&&Me(e,t.target,"submit")}function Fe(e,t,n,o){const r=[];let i=!0;n.forEach(e=>{const t=Je(e)?[...Array.from(e)]:null!=(n=e)&&"object"==typeof n&&"length"in n&&"number"==typeof n.length?Array.from(e):[e];var n;if(Array.isArray(t)&&0===t.length)return;if(Array.isArray(t)&&1===t.length&&!t[0])return;const a=t[0],s=!ae(a)&&se(a)&&a.startsWith("walker ");if(ae(a)){if("object"==typeof a&&0===Object.keys(a).length)return}else{const e=Array.from(t);if(!se(e[0])||""===e[0].trim())return;const n="walker run";i&&e[0]===n&&(i=!1)}(o&&s||!o&&!s)&&r.push(t)}),r.forEach(n=>{Ke(e,t,n)})}function Ke(e,t="data-elb",n){ue(()=>{if(Array.isArray(n)){const[o,...r]=n;if(!o||se(o)&&""===o.trim())return;if(se(o)&&o.startsWith("walker "))return void e(o,r[0]);qe({elb:e,settings:{prefix:t,scope:document,pageview:!1,session:!1,elb:"",elbLayer:!1}},o,...r)}else if(n&&"object"==typeof n){if(0===Object.keys(n).length)return;e(n)}},()=>{})()}function Je(e){return null!=e&&"object"==typeof e&&"[object Arguments]"===Object.prototype.toString.call(e)}function ze(e,t={},n){return function(e={}){const{cb:t,consent:n,collector:o,storage:r}=e;if(!n)return R((r?X:T)(e),o,t);{const r=function(e,t){let n;return(o,r)=>{if(c(n)&&n===(null==o?void 0:o.group))return;n=null==o?void 0:o.group;let i=()=>T(e);return e.consent&&p((s(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{}),r)&&(i=()=>X(e)),R(i(),o,t)}}(e,t),i=(s(n)?n:[n]).reduce((e,t)=>({...e,[t]:r}),{});o?o.command("on","consent",i):q("walker on","consent",i)}}({...t,collector:{push:e,group:void 0,command:n}})}Z({},{env:()=>Ye});var Ye={};Z(Ye,{push:()=>et});var Ve=()=>{},Qe=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),Ze={error:Ve,info:Ve,debug:Ve,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>Ze},et={get push(){return Qe()},get command(){return Qe()},get elb(){return Qe()},get window(){return{addEventListener:Ve,removeEventListener:Ve,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:Ve,removeEventListener:Ve,querySelector:Ve,querySelectorAll:()=>[],getElementById:Ve,getElementsByClassName:()=>[],getElementsByTagName:()=>[],createElement:()=>({setAttribute:Ve,getAttribute:Ve,addEventListener:Ve,removeEventListener:Ve}),body:{appendChild:Ve,removeChild:Ve},documentElement:{scrollTop:0,scrollLeft:0},readyState:"complete",title:"Test Page",referrer:"",cookie:""}},logger:Ze},tt=async(e,t)=>{const{elb:n,command:o,window:r,document:i}=t,a=(null==e?void 0:e.settings)||{},s=r||(void 0!==globalThis.window?globalThis.window:void 0),c=i||(void 0!==globalThis.document?globalThis.document:void 0),u=function(e={},t){return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:t||void 0,...e}}(a,c),l={settings:u},d={elb:n,settings:u};if(s&&c){if(!1!==u.elbLayer&&n&&function(e,t={}){const n=t.name||"elbLayer",o=t.window||window;if(!o)return;const r=o;r[n]||(r[n]=[]);const i=r[n];i.push=function(...n){if(Je(n[0])){const o=[...Array.from(n[0])],r=Array.prototype.push.apply(this,[o]);return Ke(e,t.prefix,o),r}const o=Array.prototype.push.apply(this,n);return n.forEach(n=>{Ke(e,t.prefix,n)}),o},Array.isArray(i)&&i.length>0&&function(e,t="data-elb",n){Fe(e,t,n,!0),Fe(e,t,n,!1),n.length=0}(e,t.prefix,i)}(n,{name:se(u.elbLayer)?u.elbLayer:"elbLayer",prefix:u.prefix,window:s}),u.session&&n){const e="boolean"==typeof u.session?{}:u.session;ze(n,e,o)}await async function(e,t,n){const o=()=>{e(t,n)};"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o)}(Ue,d,u),(()=>{if(We(d,u),u.pageview){const[e,t]=pe(u.prefix||"data-elb",u.scope);qe(d,"page view",e,"load",t)}})(),se(u.elb)&&u.elb&&(s[u.elb]=(...e)=>{const[t,n,o,r,i,a]=e;return qe(d,t,n,o,r,i,a)})}return{type:"browser",config:l,push:(...e)=>{const[t,n,o,r,i,a]=e;return qe(d,t,n,o,r,i,a)},destroy:async()=>{c&&$e(u.scope||c)},on:async(e,t)=>{switch(e){case"consent":if(u.session&&t&&n){const e="boolean"==typeof u.session?{}:u.session;ze(n,e,o)}break;case"session":case"ready":default:break;case"run":if(c&&s&&(We(d,u),u.pageview)){const[e,t]=pe(u.prefix||"data-elb",u.scope);qe(d,"page view",e,"load",t)}}}}},nt=Object.defineProperty,ot=(e,t)=>{for(var n in t)nt(e,n,{get:t[n],enumerable:!0})},rt=!1;function it(e,t={},n){if(t.filter&&!0===j(()=>t.filter(n),()=>!1)())return;const o=function(e){if(u(e)&&l(e.event)){const{event:t,...n}=e;return{name:t,...n}}return s(e)&&e.length>=2?at(e):null!=(t=e)&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&t.length>0?at(Array.from(e)):null;var t}(n);if(!o)return;const r=`${t.prefix||"dataLayer"} ${o.name}`,{name:i,...a}=o,c={name:r,data:a};j(()=>e(c),()=>{})()}function at(e){const[t,n,o]=e;if(!l(t))return null;let r,i={};switch(t){case"consent":if(!l(n)||e.length<3)return null;if("default"!==n&&"update"!==n)return null;if(!u(o)||null===o)return null;r=`${t} ${n}`,i={...o};break;case"event":if(!l(n))return null;r=n,u(o)&&(i={...o});break;case"config":if(!l(n))return null;r=`${t} ${n}`,u(o)&&(i={...o});break;case"set":if(l(n))r=`${t} ${n}`,u(o)&&(i={...o});else{if(!u(n))return null;r=`${t} custom`,i={...n}}break;default:return null}return{name:r,...i}}ot({},{push:()=>lt});var st=()=>{},ct=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),ut={error:st,info:st,debug:st,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>ut},lt={get push(){return ct()},get command(){return ct()},get elb(){return ct()},get window(){return{dataLayer:[],addEventListener:st,removeEventListener:st}},logger:ut};function dt(){return["consent","update",{ad_user_data:"granted",ad_personalization:"granted",ad_storage:"denied",analytics_storage:"granted"}]}function ft(){return["consent","default",{ad_storage:"denied",analytics_storage:"denied",ad_user_data:"denied",ad_personalization:"denied"}]}function gt(){return["event","purchase",{transaction_id:"T_12345",value:25.42,currency:"EUR",items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",quantity:1,price:25.42}]}]}function pt(){return["event","add_to_cart",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_variant:"red",quantity:1,price:15.25}]}]}function mt(){return["event","view_item",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",price:15.25}]}]}function yt(){return["config","G-XXXXXXXXXX",{page_title:"Custom Page Title",page_location:"https://example.com/page",send_page_view:!1}]}function bt(){return["set",{currency:"EUR",country:"DE"}]}function ht(){return{event:"custom_event",custom_parameter:"custom_value",user_id:"user123"}}ot({},{add_to_cart:()=>pt,config:()=>yt,consentDefault:()=>ft,consentUpdate:()=>dt,directDataLayerEvent:()=>ht,purchase:()=>gt,setCustom:()=>bt,view_item:()=>mt});ot({},{add_to_cart:()=>kt,config:()=>Ot,configGA4:()=>jt,consentOnlyMapping:()=>Lt,consentUpdate:()=>wt,customEvent:()=>St,purchase:()=>vt,view_item:()=>Et});var wt={name:"walker consent",settings:{command:{map:{functional:{value:!0},analytics:{key:"analytics_storage",fn:e=>"granted"===e},marketing:{key:"ad_storage",fn:e=>"granted"===e}}}}},vt={name:"order complete",data:{map:{id:"transaction_id",total:"value",currency:"currency",nested:{loop:["items",{map:{type:{value:"product"},data:{map:{id:"item_id",name:"item_name",category:"item_category",quantity:"quantity",price:"price"}}}}]}}}},kt={name:"product add",data:{map:{id:"items.0.item_id",name:"items.0.item_name",price:"value",currency:"currency",color:"items.0.item_variant",quantity:"items.0.quantity"}}},Et={name:"product view",data:{map:{id:"items.0.item_id",name:"items.0.item_name",category:"items.0.item_category",price:"items.0.price",currency:"currency"}}},jt={name:"page view",data:{map:{title:"page_title",url:"page_location"}}},St={data:{map:{user_id:"user_id",custom_parameter:"custom_parameter"}}},Ot={consent:{update:wt},purchase:vt,add_to_cart:kt,view_item:Et,"config G-XXXXXXXXXX":jt,custom_event:St,"*":{data:{}}},Lt={consent:{update:wt}},_t=async(e,t)=>{const{elb:n,window:o}=t,r={name:"dataLayer",prefix:"dataLayer",...null==e?void 0:e.settings},i={settings:r};return o&&(function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer",r=window[o];if(Array.isArray(r)&&!rt){rt=!0;try{for(const t of r)it(e,n,t)}finally{rt=!1}}}(n,i),function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer";window[o]||(window[o]=[]);const r=window[o];if(!Array.isArray(r))return;const i=r.push.bind(r);r.push=function(...t){if(rt)return i(...t);rt=!0;try{for(const o of t)it(e,n,o)}finally{rt=!1}return i(...t)}}(n,i)),{type:"dataLayer",config:i,push:n,destroy:async()=>{const e=r.name||"dataLayer";o&&o[e]&&Array.isArray(o[e])}}};function xt(){window.dataLayer=window.dataLayer||[];const e=e=>{u(e)&&u(e.source)&&String(e.source.type).includes("dataLayer")||window.dataLayer.push(e)};return{type:"dataLayer",config:{},push:(t,n)=>{e(n.data||t)},pushBatch:t=>{e({name:"batch",batched_event:t.key,events:t.data.length?t.data:t.events})}}}((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})({},{browserConfig:()=>Ct,collectorConfig:()=>qt,dataLayerConfig:()=>$t,settings:()=>At});var At={type:"object",properties:{elb:{type:"string",default:"elb",description:"Global function name for event tracking"},name:{type:"string",default:"walkerjs",description:"Global instance name"},run:{type:"boolean",default:!0,description:"Auto-initialize walker.js on load"},browser:{type:"object",default:{run:!0,session:!0,scope:"document.body",pageview:!0},description:"Browser source configuration. Set to false to disable. See browser configuration section below for details."},dataLayer:{type:"object",default:!1,description:"DataLayer source configuration. Set to true for defaults or object for custom config. See dataLayer configuration section below."},collector:{type:"object",default:{},description:"Collector configuration including destinations and consent settings. See collector configuration section below."}}},Ct={type:"object",properties:{"browser.run":{type:"boolean",default:!0,description:"Auto-start DOM tracking"},"browser.session":{type:"boolean",default:!0,description:"Enable session tracking"},"browser.scope":{type:"string",default:"document.body",description:"DOM element scope for tracking"},"browser.pageview":{type:"boolean",default:!0,description:"Enable automatic page view events"}}},$t={type:"object",properties:{dataLayer:{type:"boolean",default:!1,description:"Enable dataLayer integration with defaults"},"dataLayer.name":{type:"string",default:"dataLayer",description:"DataLayer variable name"},"dataLayer.prefix":{type:"string",default:"dataLayer",description:"Event prefix for dataLayer events"}}},qt={type:"object",properties:{"collector.consent":{type:"object",default:{functional:!0},description:"Default consent state"},"collector.destinations":{type:"object",default:{},description:"Destination configurations. See destinations documentation for available options."}}};if(window&&document){const e=async()=>{let e;const t=document.querySelector("script[data-elbconfig]");if(t){const n=t.getAttribute("data-elbconfig")||"";n.includes(":")?e=$(n):n&&(e=window[n])}e||(e=window.elbConfig),e&&await async function(e={}){const t=a({collector:{destinations:{dataLayer:{code:xt()}}},browser:{session:!0},dataLayer:!1,elb:"elb",run:!0},e),n={...t.collector,sources:{browser:{code:tt,config:{settings:t.browser},env:{window:"undefined"!=typeof window?window:void 0,document:"undefined"!=typeof document?document:void 0}}}};if(t.dataLayer){const e=u(t.dataLayer)?t.dataLayer:{};n.sources&&(n.sources.dataLayer={code:_t,config:{settings:e}})}const o=await Y(n);return"undefined"!=typeof window&&(t.elb&&(window[t.elb]=o.elb),t.name&&(window[t.name]=o.collector)),o}(e)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@walkeros/walker.js",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Ready-to-use walkerOS bundle with browser source, collector, and dataLayer support",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -19,11 +19,13 @@
19
19
  "types": "./dist/index.d.ts",
20
20
  "default": "./dist/index.es5.js"
21
21
  },
22
- "./src/schemas": "./src/schemas.ts"
22
+ "./src/schemas": "./src/schemas.ts",
23
+ "./src/dev": "./src/dev.ts"
23
24
  },
24
25
  "files": [
25
26
  "dist/**",
26
27
  "src/schemas.ts",
28
+ "src/dev.ts",
27
29
  "README.md",
28
30
  "CHANGELOG.md"
29
31
  ],
@@ -36,11 +38,11 @@
36
38
  "preview": "npm run build && npx serve -l 3333 examples"
37
39
  },
38
40
  "dependencies": {
39
- "@walkeros/core": "0.4.0",
40
- "@walkeros/collector": "0.4.0",
41
- "@walkeros/web-core": "0.4.0",
42
- "@walkeros/web-source-browser": "0.4.0",
43
- "@walkeros/web-source-datalayer": "0.4.0"
41
+ "@walkeros/core": "0.4.2",
42
+ "@walkeros/collector": "0.4.2",
43
+ "@walkeros/web-core": "0.4.2",
44
+ "@walkeros/web-source-browser": "0.4.2",
45
+ "@walkeros/web-source-datalayer": "0.4.2"
44
46
  },
45
47
  "devDependencies": {
46
48
  "@swc/jest": "^0.2.36",
package/src/dev.ts ADDED
@@ -0,0 +1,8 @@
1
+ export * as schemas from './schemas';
2
+
3
+ export {
4
+ settings,
5
+ browserConfig,
6
+ dataLayerConfig,
7
+ collectorConfig,
8
+ } from './schemas';
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,aAAa,0BAAY,CAAC;AAyLhC,OAAO,EAAE,aAAa,EAAE,CAAC"}