@walkeros/web-source-browser 0.0.7 → 0.0.9

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.
@@ -1 +1 @@
1
- "use strict";var Source=(()=>{var e,t,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,i={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(i,{SourceBrowser:()=>he,createTagger:()=>we,default:()=>ve,getAllEvents:()=>D,getEvents:()=>M,getGlobals:()=>T,sourceBrowser:()=>ke});var c=Object.getOwnPropertyNames,a=(e={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.7",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return t||(0,e[c(e)[0]])((t={exports:{}}).exports,t),t.exports}),l={Storage:{Local:"local",Session:"session",Cookie:"cookie"}},u={merge:!0,shallow:!0,extend:!0};function d(e,t={},n={}){n={...u,...n};const r=Object.entries(t).reduce((t,[r,o])=>{const s=e[r];return n.merge&&Array.isArray(s)&&Array.isArray(o)?t[r]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...s]):(n.extend||r in e)&&(t[r]=o),t},{});return n.shallow?{...e,...r}:(Object.assign(e,r),e)}function f(e){return Array.isArray(e)}function m(e){return void 0!==e}function g(e){return"object"==typeof e&&null!==e&&!f(e)&&"[object Object]"===Object.prototype.toString.call(e)}function p(e){return"string"==typeof e}function b(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}var h,w,{version:y}=a();function k(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function v(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function S(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}var O=Object.getOwnPropertyNames,j=(h={"package.json"(e,t){t.exports={name:"@walkeros/collector",description:"Unified platform-agnostic collector for walkerOS",version:"0.0.7",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{"@walkeros/core":"0.0.7"},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/collector"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","collector","event processing"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},{Commands:{Action:"action",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"},Utils:{Storage:{Cookie:"cookie",Local:"local",Session:"session"}}});function C(e,t,n,r){let o=n||[];if(n||(o=e.on[t]||[],Object.values(e.destinations).forEach(e=>{var n;const r=null==(n=e.config.on)?void 0:n[t];r&&(o=o.concat(r))})),o.length)switch(t){case j.Commands.Consent:!function(e,t,n){const r=n||e.consent;t.forEach(t=>{Object.keys(r).filter(e=>e in t).forEach(n=>{v(t[n])(e,r)})})}(e,o,r);break;case j.Commands.Ready:case j.Commands.Run:i=o,(s=e).allowed&&i.forEach(e=>{v(e)(s)});break;case j.Commands.Session:!function(e,t){e.session&&t.forEach(t=>{v(t)(e,e.session)})}(e,o)}var s,i}function x(e,t){return(e.getAttribute(t)||"").trim()}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 r=window.innerHeight,o=e.getBoundingClientRect(),s=o.height,i=o.y,c=i+s,a={x:o.x+e.offsetWidth/2,y:o.y+e.offsetHeight/2};if(s<=r){if(e.offsetWidth+o.width===0||e.offsetHeight+o.height===0)return!1;if(a.x<0)return!1;if(a.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(a.y<0)return!1;if(a.y>(document.documentElement.clientHeight||window.innerHeight))return!1;n=document.elementFromPoint(a.x,a.y)}else{const e=r/2;if(i<0&&c<e)return!1;if(c>r&&i>e)return!1;n=document.elementFromPoint(a.x,r/2)}if(n)do{if(n===e)return!0}while(n=n.parentElement);return!1}function $(e={}){const{cb:t,consent:n,collector:r,storage:o}=e,s=(null==r?void 0:r.push)||E;if(!n)return P((o?W:R)(e),r,t);{const r=function(e,t){let n;return(r,o)=>{if(m(n)&&n===(null==r?void 0:r.group))return;n=null==r?void 0:r.group;let s=()=>R(e);if(e.consent){(function(e,t={},n={}){const r={...t,...n},o={};let s=void 0===e;return Object.keys(r).forEach(t=>{r[t]&&(o[t]=!0,e&&e[t]&&(s=!0))}),!!s&&o})((f(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{}),o)&&(s=()=>W(e))}return P(s(),r,t)}}(e,t);s("walker on","consent",(f(n)?n:[n]).reduce((e,t)=>({...e,[t]:r}),{}))}}function P(e,t,n){return!1===n?e:(n||(n=A),n(e,t,A))}var A=(e,t)=>{const n=(null==t?void 0:t.push)||E,r={};return e.id&&(r.session=e.id),e.storage&&e.device&&(r.device=e.device),n("walker user",r),e.isStart&&n({event:"session start",data:e}),e};function I(e,t=l.Storage.Session){var n;function r(e){try{return JSON.parse(e||"")}catch(t){let n=1,r="";return e&&(n=0,r=e),{e:n,v:r}}}let o,s;switch(t){case l.Storage.Cookie:o=decodeURIComponent((null==(n=document.cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:n.split("=")[1])||"");break;case l.Storage.Local:s=r(window.localStorage.getItem(e));break;case l.Storage.Session:s=r(window.sessionStorage.getItem(e))}return s&&(o=s.v,0!=s.e&&s.e<Date.now()&&(function(e,t=l.Storage.Session){switch(t){case l.Storage.Cookie:_(e,"",0,t);break;case l.Storage.Local:window.localStorage.removeItem(e);break;case l.Storage.Session:window.sessionStorage.removeItem(e)}}(e,t),o="")),b(o||"")}function _(e,t,n=30,r=l.Storage.Session,o){const s={e:Date.now()+6e4*n,v:String(t)},i=JSON.stringify(s);switch(r){case l.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let r=`${e}=${encodeURIComponent(t)}; max-age=${60*n}; path=/; SameSite=Lax; secure`;o&&(r+="; domain="+o),document.cookie=r;break}case l.Storage.Local:window.localStorage.setItem(e,i);break;case l.Storage.Session:window.sessionStorage.setItem(e,i)}return I(e,r)}function W(e={}){const t=Date.now(),{length:n=30,deviceKey:r="elbDeviceId",deviceStorage:o="local",deviceAge:s=30,sessionKey:i="elbSessionId",sessionStorage:c="local",pulse:a=!1}=e,l=R(e);let u=!1;const d=v((e,t,n)=>{let r=I(e,n);return r||(r=k(8),_(e,r,1440*t,n)),String(r)})(r,s,o),f=v((e,r)=>{const o=JSON.parse(String(I(e,r)));return a||(o.isNew=!1,l.marketing&&(Object.assign(o,l),u=!0),u||o.updated+6e4*n<t?(delete o.id,delete o.referrer,o.start=t,o.count++,o.runs=1,u=!0):o.runs++),o},()=>{u=!0})(i,c)||{},m={id:k(12),start:t,isNew:!0,count:1,runs:1},g=Object.assign(m,l,f,{device:d},{isStart:u,storage:!0,updated:t},e.data);return _(i,JSON.stringify(g),2*n,c),g}function R(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),o=e.referrer||document.referrer,s=o&&new URL(o).hostname,i=function(e,t={}){const n="clickId",r={},o={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(d(o,t)).forEach(([t,o])=>{const s=e.searchParams.get(t);s&&(o===n&&(o=t,r[n]=t),r[o]=s)}),r}(r,e.parameters);if(Object.keys(i).length&&(i.marketing||(i.marketing=!0),t=!0),!t){const n=e.domains||[];n.push(r.hostname),t=!n.includes(s)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:k(12),referrer:s},i,e.data):n}function H(e,t,n=!0){return e+(t=null!=t?(n?"-":"")+t:"")}function N(e,t,n,r=!0){return B(x(t,H(e,n,r))||"").reduce((e,n)=>{let[r,o]=F(n);if(!r)return e;if(o||(r.endsWith(":")&&(r=r.slice(0,-1)),o=""),o.startsWith("#")){o=o.slice(1);try{let e=t[o];e||"selected"!==o||(e=t.options[t.selectedIndex].text),o=String(e)}catch(e){o=""}}return r.endsWith("[]")?(r=r.slice(0,-2),f(e[r])||(e[r]=[]),e[r].push(b(o))):e[r]=b(o),e},{})}function D(e=document.body,t=j.Commands.Prefix){let n=[];const r=j.Commands.Action,o=`[${H(t,r,!1)}]`,s=e=>{Object.keys(N(t,e,r,!1)).forEach(r=>{n=n.concat(M(e,r,t))})};return e!==document&&e.matches(o)&&s(e),q(e,o,s),n}function M(e,t,n=j.Commands.Prefix){const r=[],o=function(e,t,n){let r=t;for(;r;){const t=U(x(r,H(e,j.Commands.Action,!1)));if(t[n]||"click"!==n)return t[n];r=G(e,r)}return[]}(n,e,t);return o?(o.forEach(o=>{const s=B(o.actionParams||"",",").reduce((e,t)=>(e[S(t)]=!0,e),{}),i=function(e,t,n){const r=[];let o=t;n=0!==Object.keys(n||{}).length?n:void 0;for(;o;){const s=V(e,o,t,n);s&&r.push(s),o=G(e,o)}return r}(n,e,s);if(!i.length){const t="page",r=`[${H(n,t)}]`,[o,s]=J(e,r,n,t);i.push({type:t,data:o,nested:[],context:s})}i.forEach(e=>{r.push({entity:e.type,action:o.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),r):r}function T(e=j.Commands.Prefix,t=document){const n=H(e,j.Commands.Globals,!1);let r={};return q(t,`[${n}]`,t=>{r=d(r,N(e,t,j.Commands.Globals,!1))}),r}function U(e){const t={};return B(e).forEach(e=>{const[n,r]=F(e),[o,s]=K(n);if(!o)return;let[i,c]=K(r||"");i=i||o,t[o]||(t[o]=[]),t[o].push({trigger:o,triggerParams:s,action:i,actionParams:c})}),t}function V(e,t,n,r){const o=x(t,H(e));if(!o||r&&!r[o])return null;const s=[t],i=`[${H(e,o)}],[${H(e,"")}]`,c=H(e,j.Commands.Link,!1);let a={};const l=[],[u,f]=J(n||t,i,e,o);q(t,`[${c}]`,t=>{const[n,r]=F(x(t,c));"parent"===r&&q(document.body,`[${c}="${n}:child"]`,t=>{s.push(t);const n=V(e,t);n&&l.push(n)})});const m=[];s.forEach(e=>{e.matches(i)&&m.push(e),q(e,i,e=>m.push(e))});let g={};return m.forEach(t=>{g=d(g,N(e,t,"")),a=d(a,N(e,t,o))}),a=d(d(g,a),u),s.forEach(t=>{q(t,`[${H(e)}]`,t=>{const n=V(e,t);n&&l.push(n)})}),{type:o,data:a,context:f,nested:l}}function G(e,t){const n=H(e,j.Commands.Link,!1);if(t.matches(`[${n}]`)){const[e,r]=F(x(t,n));if("child"===r)return document.querySelector(`[${n}="${e}:parent"]`)}return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof ShadowRoot?t.getRootNode().host:t.parentElement}function J(e,t,n,r){let o={};const s={};let i=e;const c=`[${H(n,j.Commands.Context,!1)}]`;let a=0;for(;i;)i.matches(t)&&(o=d(N(n,i,""),o),o=d(N(n,i,r),o)),i.matches(c)&&(Object.entries(N(n,i,j.Commands.Context,!1)).forEach(([e,t])=>{t&&!s[e]&&(s[e]=[t,a])}),++a),i=G(n,i);return[o,s]}function q(e,t,n){e.querySelectorAll(t).forEach(n)}function B(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function F(e){const[t,n]=e.split(/:(.+)/,2);return[S(t),S(n)]}function K(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var Y=new WeakMap,z=new WeakMap;function Q(e){const t=Date.now();let n=z.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:L(e),lastChecked:t},z.set(e,n)),n.isVisible}function X(e){if(window.IntersectionObserver)return v(()=>new window.IntersectionObserver(t=>{t.forEach(t=>{!function(e,t){var n,r;const o=t.target,s=e._visibilityState;if(!s)return;const i=s.timers.get(o);if(t.intersectionRatio>0){const r=Date.now();let c=Y.get(o);(!c||r-c.lastChecked>1e3)&&(c={isLarge:o.offsetHeight>window.innerHeight,lastChecked:r},Y.set(o,c));if(t.intersectionRatio>=.5||c.isLarge&&Q(o)){const t=null==(n=s.elementConfigs)?void 0:n.get(o);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!i){const t=window.setTimeout(async()=>{var t;if(Q(o)){await ue(e,o,ce.Visible,"data-elb");const n=null==(t=s.elementConfigs)?void 0:t.get(o);(null==n?void 0:n.multiple)?n.blocked=!0:function(e,t){const n=e._visibilityState;if(!n)return;n.observer&&n.observer.unobserve(t);const r=n.timers.get(t);r&&(clearTimeout(r),n.timers.delete(t)),Y.delete(t),z.delete(t)}(e,o)}},s.duration);s.timers.set(o,t)}return}}i&&(clearTimeout(i),s.timers.delete(o));const c=null==(r=s.elementConfigs)?void 0:r.get(o);(null==c?void 0:c.multiple)&&(c.blocked=!1)}(e,t)})},{rootMargin:"0px",threshold:[0,.5]}),()=>{})()}function Z(e,t,n={multiple:!1}){var r;const o=e._visibilityState;(null==o?void 0:o.observer)&&t&&(o.elementConfigs||(o.elementConfigs=new WeakMap),o.elementConfigs.set(t,{multiple:null!=(r=n.multiple)&&r,blocked:!1}),o.observer.observe(t))}function ee(e){const t=e._visibilityState;t&&(t.observer&&t.observer.disconnect(),delete e._visibilityState)}function te(e,t,n,r,o,s,i){if(p(t)&&t.startsWith("walker ")){if("walker config"===t)return e.push("walker config",n);if("walker consent"===t)return e.push("walker consent",n);if("walker user"===t)return e.push("walker user",n);if("walker run"===t)return e.push("walker run",n)}if(g(t)){const n=t;return n.source||(n.source=oe()),e.push(n)}if(p(t)&&t.length>0){const c={event:t,data:ne(n||{}),context:re(o||{}),custom:i,nested:s,source:oe()};return p(r)&&(c.trigger=r),e.push(c)}if(!m(t))return Promise.resolve({ok:!0,successful:[],queued:[],failed:[]});const c={event:String(t||""),data:ne(n||{}),context:re(o||{}),custom:i,nested:s,source:oe()};return p(r)&&(c.trigger=r),e.push(c)}function ne(e){return e?typeof e==typeof{}?e:{}:{}}function re(e){return e?(t=e)===document||t instanceof Element?{}:g(e)&&Object.keys(e).length?e:{}:{};var t}function oe(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var se,ie=[],ce={Click:"click",Custom:"custom",Hover:"hover",Load:"load",Pulse:"pulse",Scroll:"scroll",Submit:"submit",Visible:"visible",Visibles:"visibles",Wait:"wait"};function ae(e,t){const{prefix:n,scope:r,pageview:o}=t;if(o){const[t,o]=function(e,t){const n=window.location,r="page",o=t===document?document.body:t,[s,i]=J(o,`[${H(e,r)}]`,e,r);return s.domain=n.hostname,s.title=document.title,s.referrer=document.referrer,n.search&&(s.search=n.search),n.hash&&(s.hash=n.hash),[s,i]}(n,r);te(e,"page view",t,ce.Load,o)}!function(e,t,n){ie=[],ee(e),function(e,t=1e3){e._visibilityState||(e._visibilityState={observer:X(e),timers:new WeakMap,duration:t})}(e,1e3);const r=H(t,j.Commands.Action,!1),o=n||document;o!==document&&de(e,o,r,t);o.querySelectorAll(`[${r}]`).forEach(n=>de(e,n,r,t)),ie.length&&function(e,t){const n=(e,t)=>e.filter(([e,n])=>{const r=window.scrollY+window.innerHeight,o=e.offsetTop;if(r<o)return!0;const s=e.clientHeight;return!(100*(1-(o+s-r)/(s||1))>=n)||(ue(t,e,ce.Scroll,"data-elb"),!1)});se||(se=function(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}(function(){ie=n.call(t,ie,e)}),t.addEventListener("scroll",se))}(e,o)}(e,n,r)}function le(e,t){t.addEventListener("click",v(function(t){fe.call(this,e,t)})),t.addEventListener("submit",v(function(t){me.call(this,e,t)}))}async function ue(e,t,n,r){const o=M(t,n,r);return Promise.all(o.map(t=>te(e,{event:`${t.entity} ${t.action}`,...t,trigger:n})))}function de(e,t,n,r){const o=x(t,n);o&&Object.values(U(o)).forEach(n=>n.forEach(n=>{switch(n.trigger){case ce.Hover:!function(e,t,n){t.addEventListener("mouseenter",v(function(t){t.target instanceof Element&&ue(e,t.target,ce.Hover,n)}))}(e,t,r);break;case ce.Load:!function(e,t,n){ue(e,t,ce.Load,n)}(e,t,r);break;case ce.Pulse:!function(e,t,n="",r){setInterval(()=>{document.hidden||ue(e,t,ce.Pulse,r)},parseInt(n||"")||15e3)}(e,t,n.triggerParams,r);break;case ce.Scroll:!function(e,t=""){const n=parseInt(t||"")||50;if(n<0||n>100)return;ie.push([e,n])}(t,n.triggerParams);break;case ce.Visible:Z(e,t);break;case ce.Visibles:Z(e,t,{multiple:!0});break;case ce.Wait:!function(e,t,n="",r){setTimeout(()=>ue(e,t,ce.Wait,r),parseInt(n||"")||15e3)}(e,t,n.triggerParams,r)}}))}function fe(e,t){ue(e,t.target,ce.Click,"data-elb")}function me(e,t){t.target&&ue(e,t.target,ce.Submit,"data-elb")}function ge(e,t={}){const n=t.name||"elbLayer";window[n]||(window[n]=[]);const r=window[n];Array.isArray(r)&&r.length>0&&function(e,t){const n=[],r=[];t.forEach(e=>{!function(e){if(be(e)){const t=Array.from(e);return"string"==typeof t[0]&&t[0].startsWith("walker ")}return!1}(e)?r.push(e):n.push(e)}),n.forEach(t=>{pe(e,t)}),r.forEach(t=>{pe(e,t)}),t.length=0}(e,r)}function pe(e,t){null!=t&&""!==t&&"number"!=typeof t&&"string"!=typeof t&&v(()=>{if(be(t)){const n=Array.from(t);if(n.length>=1){const[t,r,o,s]=n;"string"==typeof t&&t.length>0&&te(e,t,r,o,s)}}else if("object"==typeof t&&null!==t){if(0===Object.keys(t).length)return;te(e,t)}},()=>{})()}function be(e){return null!=e&&"object"==typeof e&&"length"in e&&"number"==typeof e.length}var he={};function we(e={}){const t=e.prefix||"data-elb";return function(e){let n=e;const r={},o={},s={},i={},c={};function a(e){return Object.entries(e).map(([e,t])=>`${e}:${function(e){if(!m(e)||null===e)return"undefined";let t=String(e);return t=t.replace(/\\/g,"\\\\"),t=t.replace(/;/g,"\\;"),t=t.replace(/:/g,"\\:"),t=t.replace(/'/g,"\\'"),t}(t)}`).join(";")}const l={entity:e=>(n=e,l),data(e,t){const o=null!=n?n:"";return r[o]||(r[o]={}),p(e)?r[o][e]=t:Object.assign(r[o],e),l},action(e,t){if(p(e))if(m(t))o[e]=t;else if(e.includes(":")){const[t,n]=e.split(":",2);o[t]=n}else o[e]=e;else Object.assign(o,e);return l},context:(e,t)=>(p(e)?s[e]=t:Object.assign(s,e),l),globals:(e,t)=>(p(e)?i[e]=t:Object.assign(i,e),l),link:(e,t)=>(p(e)?c[e]=t:Object.assign(c,e),l),get(){const e={};return n&&(e[t]=n),Object.entries(r).forEach(([n,r])=>{if(Object.keys(r).length>0){e[n?`${t}-${n}`:`${t}-`]=a(r)}}),Object.keys(o).length>0&&(e[`${t}action`]=a(o)),Object.keys(s).length>0&&(e[`${t}context`]=a(s)),Object.keys(i).length>0&&(e[`${t}globals`]=a(i)),Object.keys(c).length>0&&(e[`${t}link`]=a(c)),e}};return l}}var ye,ke=async(e,t)=>{const n=function(e={}){const t=e.scope||document;return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",name:"walkerjs",elbLayer:"elbLayer",...e,scope:t}}(t.settings),r={...t,settings:n},o=n.scope,s={type:"browser",config:r,collector:e,destroy(){ee(e)}};if(!1!==n.elbLayer&&ge(e,{name:p(n.elbLayer)?n.elbLayer:"elbLayer"}),le(e,o),n.session){const t="boolean"==typeof n.session?{}:n.session;!function(e,t={}){const n=t.config||{},r=d(e.config.sessionStatic||{},t.data||{});var o,s,i;(o=$,s="SessionStart",i=e.hooks,function(...e){let t;const n="post"+s,r=i["pre"+s],c=i[n];return t=r?r({fn:o},...e):o(...e),c&&(t=c({fn:o,result:t},...e)),t})({...n,cb:(e,t,r)=>{let o;const s=n;return!1!==s.cb&&s.cb?o=s.cb(e,t,r):!1!==s.cb&&(o=r(e,t,r)),t&&(t.session=e,C(t,"session")),o},data:r,collector:e})}(e,{config:t})}await async function(e,t,n){const r=()=>{e(t,n),C(t,"ready")};"loading"!==document.readyState?r():document.addEventListener("DOMContentLoaded",r)}(ae,e,n);const i=e._destroy;e._destroy=()=>{var e;null==(e=s.destroy)||e.call(s),i&&i()};return{source:s,elb:(...t)=>{const[n,r,o,s,i,c]=t;return te(e,n,r,o,s,i,c)}}},ve=ke;return ye=i,((e,t,i,c)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of o(t))s.call(e,a)||a===i||n(e,a,{get:()=>t[a],enumerable:!(c=r(t,a))||c.enumerable});return e})(n({},"__esModule",{value:!0}),ye)})();
1
+ "use strict";var Source=(()=>{var e,t,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(s,{SourceBrowser:()=>ve,createTagger:()=>ke,default:()=>xe,getAllEvents:()=>M,getEvents:()=>T,getGlobals:()=>U,sourceBrowser:()=>Oe});var c=Object.getOwnPropertyNames,a=(e={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.8",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return t||(0,e[c(e)[0]])((t={exports:{}}).exports,t),t.exports}),l={Storage:{Local:"local",Session:"session",Cookie:"cookie"}},u={merge:!0,shallow:!0,extend:!0};function d(e,t={},n={}){n={...u,...n};const r=Object.entries(t).reduce((t,[r,o])=>{const i=e[r];return n.merge&&Array.isArray(i)&&Array.isArray(o)?t[r]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||r in e)&&(t[r]=o),t},{});return n.shallow?{...e,...r}:(Object.assign(e,r),e)}function f(e){return Array.isArray(e)}function g(e){return void 0!==e}function m(e){return e===document||e instanceof Element}function p(e){return"object"==typeof e&&null!==e&&!f(e)&&"[object Object]"===Object.prototype.toString.call(e)}function b(e){return"string"==typeof e}function h(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}var y,w,{version:v}=a();function k(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function S(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function O(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}var x=Object.getOwnPropertyNames,j=(y={"package.json"(e,t){t.exports={name:"@walkeros/collector",description:"Unified platform-agnostic collector for walkerOS",version:"0.0.8",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{"@walkeros/core":"0.0.8"},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/collector"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","collector","event processing"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},{Commands:{Action:"action",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"},Utils:{Storage:{Cookie:"cookie",Local:"local",Session:"session"}}});function C(e,t,n,r){let o=n||[];if(n||(o=e.on[t]||[],Object.values(e.destinations).forEach(e=>{var n;const r=null==(n=e.config.on)?void 0:n[t];r&&(o=o.concat(r))})),o.length)switch(t){case j.Commands.Consent:!function(e,t,n){const r=n||e.consent;t.forEach(t=>{Object.keys(r).filter(e=>e in t).forEach(n=>{S(t[n])(e,r)})})}(e,o,r);break;case j.Commands.Ready:case j.Commands.Run:s=o,(i=e).allowed&&s.forEach(e=>{S(e)(i)});break;case j.Commands.Session:!function(e,t){e.session&&t.forEach(t=>{S(t)(e,e.session)})}(e,o)}var i,s}function E(e,t){return(e.getAttribute(t)||"").trim()}var A=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 r=window.innerHeight,o=e.getBoundingClientRect(),i=o.height,s=o.y,c=s+i,a={x:o.x+e.offsetWidth/2,y:o.y+e.offsetHeight/2};if(i<=r){if(e.offsetWidth+o.width===0||e.offsetHeight+o.height===0)return!1;if(a.x<0)return!1;if(a.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(a.y<0)return!1;if(a.y>(document.documentElement.clientHeight||window.innerHeight))return!1;n=document.elementFromPoint(a.x,a.y)}else{const e=r/2;if(s<0&&c<e)return!1;if(c>r&&s>e)return!1;n=document.elementFromPoint(a.x,r/2)}if(n)do{if(n===e)return!0}while(n=n.parentElement);return!1}function $(e={}){const{cb:t,consent:n,collector:r,storage:o}=e,i=(null==r?void 0:r.push)||A;if(!n)return P((o?R:H)(e),r,t);{const r=function(e,t){let n;return(r,o)=>{if(g(n)&&n===(null==r?void 0:r.group))return;n=null==r?void 0:r.group;let i=()=>H(e);if(e.consent){(function(e,t={},n={}){const r={...t,...n},o={};let i=void 0===e;return Object.keys(r).forEach(t=>{r[t]&&(o[t]=!0,e&&e[t]&&(i=!0))}),!!i&&o})((f(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{}),o)&&(i=()=>R(e))}return P(i(),r,t)}}(e,t);i("walker on","consent",(f(n)?n:[n]).reduce((e,t)=>({...e,[t]:r}),{}))}}function P(e,t,n){return!1===n?e:(n||(n=I),n(e,t,I))}var I=(e,t)=>{const n=(null==t?void 0:t.push)||A,r={};return e.id&&(r.session=e.id),e.storage&&e.device&&(r.device=e.device),n("walker user",r),e.isStart&&n({event:"session start",data:e}),e};function W(e,t=l.Storage.Session){var n;function r(e){try{return JSON.parse(e||"")}catch(t){let n=1,r="";return e&&(n=0,r=e),{e:n,v:r}}}let o,i;switch(t){case l.Storage.Cookie:o=decodeURIComponent((null==(n=document.cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:n.split("=")[1])||"");break;case l.Storage.Local:i=r(window.localStorage.getItem(e));break;case l.Storage.Session:i=r(window.sessionStorage.getItem(e))}return i&&(o=i.v,0!=i.e&&i.e<Date.now()&&(function(e,t=l.Storage.Session){switch(t){case l.Storage.Cookie:_(e,"",0,t);break;case l.Storage.Local:window.localStorage.removeItem(e);break;case l.Storage.Session:window.sessionStorage.removeItem(e)}}(e,t),o="")),h(o||"")}function _(e,t,n=30,r=l.Storage.Session,o){const i={e:Date.now()+6e4*n,v:String(t)},s=JSON.stringify(i);switch(r){case l.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let r=`${e}=${encodeURIComponent(t)}; max-age=${60*n}; path=/; SameSite=Lax; secure`;o&&(r+="; domain="+o),document.cookie=r;break}case l.Storage.Local:window.localStorage.setItem(e,s);break;case l.Storage.Session:window.sessionStorage.setItem(e,s)}return W(e,r)}function R(e={}){const t=Date.now(),{length:n=30,deviceKey:r="elbDeviceId",deviceStorage:o="local",deviceAge:i=30,sessionKey:s="elbSessionId",sessionStorage:c="local",pulse:a=!1}=e,l=H(e);let u=!1;const d=S((e,t,n)=>{let r=W(e,n);return r||(r=k(8),_(e,r,1440*t,n)),String(r)})(r,i,o),f=S((e,r)=>{const o=JSON.parse(String(W(e,r)));return a||(o.isNew=!1,l.marketing&&(Object.assign(o,l),u=!0),u||o.updated+6e4*n<t?(delete o.id,delete o.referrer,o.start=t,o.count++,o.runs=1,u=!0):o.runs++),o},()=>{u=!0})(s,c)||{},g={id:k(12),start:t,isNew:!0,count:1,runs:1},m=Object.assign(g,l,f,{device:d},{isStart:u,storage:!0,updated:t},e.data);return _(s,JSON.stringify(m),2*n,c),m}function H(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),o=e.referrer||document.referrer,i=o&&new URL(o).hostname,s=function(e,t={}){const n="clickId",r={},o={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(d(o,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(i)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:k(12),referrer:i},s,e.data):n}function N(e,t,n=!0){return e+(t=null!=t?(n?"-":"")+t:"")}function D(e,t,n,r=!0){return K(E(t,N(e,n,r))||"").reduce((e,n)=>{let[r,o]=Y(n);if(!r)return e;if(o||(r.endsWith(":")&&(r=r.slice(0,-1)),o=""),o.startsWith("#")){o=o.slice(1);try{let e=t[o];e||"selected"!==o||(e=t.options[t.selectedIndex].text),o=String(e)}catch(e){o=""}}return r.endsWith("[]")?(r=r.slice(0,-2),f(e[r])||(e[r]=[]),e[r].push(h(o))):e[r]=h(o),e},{})}function M(e=document.body,t=j.Commands.Prefix){let n=[];const r=j.Commands.Action,o=`[${N(t,r,!1)}]`,i=e=>{Object.keys(D(t,e,r,!1)).forEach(r=>{n=n.concat(T(e,r,t))})};return e!==document&&e.matches(o)&&i(e),F(e,o,i),n}function T(e,t,n=j.Commands.Prefix){const r=[],o=function(e,t,n){let r=t;for(;r;){const t=V(E(r,N(e,j.Commands.Action,!1)));if(t[n]||"click"!==n)return t[n];r=B(e,r)}return[]}(n,e,t);return o?(o.forEach(o=>{const i=K(o.actionParams||"",",").reduce((e,t)=>(e[O(t)]=!0,e),{}),s=G(n,e,i);if(!s.length){const t="page",r=`[${N(n,t)}]`,[o,i]=q(e,r,n,t);s.push({type:t,data:o,nested:[],context:i})}s.forEach(e=>{r.push({entity:e.type,action:o.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),r):r}function U(e=j.Commands.Prefix,t=document){const n=N(e,j.Commands.Globals,!1);let r={};return F(t,`[${n}]`,t=>{r=d(r,D(e,t,j.Commands.Globals,!1))}),r}function V(e){const t={};return K(e).forEach(e=>{const[n,r]=Y(e),[o,i]=z(n);if(!o)return;let[s,c]=z(r||"");s=s||o,t[o]||(t[o]=[]),t[o].push({trigger:o,triggerParams:i,action:s,actionParams:c})}),t}function G(e,t,n){const r=[];let o=t;for(n=0!==Object.keys(n||{}).length?n:void 0;o;){const i=J(e,o,t,n);i&&r.push(i),o=B(e,o)}return r}function J(e,t,n,r){const o=E(t,N(e));if(!o||r&&!r[o])return null;const i=[t],s=`[${N(e,o)}],[${N(e,"")}]`,c=N(e,j.Commands.Link,!1);let a={};const l=[],[u,f]=q(n||t,s,e,o);F(t,`[${c}]`,t=>{const[n,r]=Y(E(t,c));"parent"===r&&F(document.body,`[${c}="${n}:child"]`,t=>{i.push(t);const n=J(e,t);n&&l.push(n)})});const g=[];i.forEach(e=>{e.matches(s)&&g.push(e),F(e,s,e=>g.push(e))});let m={};return g.forEach(t=>{m=d(m,D(e,t,"")),a=d(a,D(e,t,o))}),a=d(d(m,a),u),i.forEach(t=>{F(t,`[${N(e)}]`,t=>{const n=J(e,t);n&&l.push(n)})}),{type:o,data:a,context:f,nested:l}}function B(e,t){const n=N(e,j.Commands.Link,!1);if(t.matches(`[${n}]`)){const[e,r]=Y(E(t,n));if("child"===r)return document.querySelector(`[${n}="${e}:parent"]`)}return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof ShadowRoot?t.getRootNode().host:t.parentElement}function q(e,t,n,r){let o={};const i={};let s=e;const c=`[${N(n,j.Commands.Context,!1)}]`;let a=0;for(;s;)s.matches(t)&&(o=d(D(n,s,""),o),o=d(D(n,s,r),o)),s.matches(c)&&(Object.entries(D(n,s,j.Commands.Context,!1)).forEach(([e,t])=>{t&&!i[e]&&(i[e]=[t,a])}),++a),s=B(n,s);return[o,i]}function F(e,t,n){e.querySelectorAll(t).forEach(n)}function K(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function Y(e){const[t,n]=e.split(/:(.+)/,2);return[O(t),O(n)]}function z(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var Q=new WeakMap,X=new WeakMap;function Z(e){const t=Date.now();let n=X.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:L(e),lastChecked:t},X.set(e,n)),n.isVisible}function ee(e){if(window.IntersectionObserver)return S(()=>new window.IntersectionObserver(t=>{t.forEach(t=>{!function(e,t){var n,r;const o=t.target,i=e._visibilityState;if(!i)return;const s=i.timers.get(o);if(t.intersectionRatio>0){const r=Date.now();let c=Q.get(o);(!c||r-c.lastChecked>1e3)&&(c={isLarge:o.offsetHeight>window.innerHeight,lastChecked:r},Q.set(o,c));if(t.intersectionRatio>=.5||c.isLarge&&Z(o)){const t=null==(n=i.elementConfigs)?void 0:n.get(o);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!s){const t=window.setTimeout(async()=>{var t,n;if(Z(o)){const r=null==(t=i.elementConfigs)?void 0:t.get(o),s=(null==r?void 0:r.prefix)||"data-elb";await de(e,s,o,ae.Visible);const c=null==(n=i.elementConfigs)?void 0:n.get(o);(null==c?void 0:c.multiple)?c.blocked=!0:function(e,t){const n=e._visibilityState;if(!n)return;n.observer&&n.observer.unobserve(t);const r=n.timers.get(t);r&&(clearTimeout(r),n.timers.delete(t)),Q.delete(t),X.delete(t)}(e,o)}},i.duration);i.timers.set(o,t)}return}}s&&(clearTimeout(s),i.timers.delete(o));const c=null==(r=i.elementConfigs)?void 0:r.get(o);(null==c?void 0:c.multiple)&&(c.blocked=!1)}(e,t)})},{rootMargin:"0px",threshold:[0,.5]}),()=>{})()}function te(e,t,n={multiple:!1}){var r;const o=e._visibilityState;(null==o?void 0:o.observer)&&t&&(o.elementConfigs||(o.elementConfigs=new WeakMap),o.elementConfigs.set(t,{multiple:null!=(r=n.multiple)&&r,blocked:!1,prefix:n.prefix||"data-elb"}),o.observer.observe(t))}function ne(e){const t=e._visibilityState;t&&(t.observer&&t.observer.disconnect(),delete e._visibilityState)}var re=performance.now();function oe(e,t="data-elb",n,r,o,i,s,c){if(b(n)&&n.startsWith("walker ")){return e.push(n,r)}if(p(n)){const t=n;return t.source||(t.source=ie()),e.push(t)}const[a]=String(p(n)?n.event:n).split(" ");let l,u=p(r)?r:{},d={},f=!1;if(m(r)&&(l=r,f=!0),m(i)?l=i:p(i)&&Object.keys(i).length&&(d=i),l){const e=G(t,l).find(e=>e.type===a);e&&(f&&(u=e.data),d=e.context)}"page"===a&&(u.id=u.id||window.location.pathname);const g={event:String(n||""),data:u,context:d,nested:s,custom:c,trigger:b(o)?o:"",timing:Math.round((performance.now()-re)/10)/100,source:ie()};return e.push(g)}function ie(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var se,ce=[],ae={Click:"click",Custom:"custom",Hover:"hover",Load:"load",Pulse:"pulse",Scroll:"scroll",Submit:"submit",Visible:"visible",Visibles:"visibles",Wait:"wait"};function le(e,t){const{scope:n,prefix:r}=t;!function(e,t,n){t.addEventListener("click",S(function(t){ge.call(this,e,t,n)})),t.addEventListener("submit",S(function(t){me.call(this,e,t,n)}))}(e,n,r)}function ue(e,t){const{prefix:n,scope:r}=t;!function(e,t,n){ce=[],ne(e),function(e,t=1e3){e._visibilityState||(e._visibilityState={observer:ee(e),timers:new WeakMap,duration:t})}(e,1e3);const r=N(t,j.Commands.Action,!1),o=n||document;o!==document&&fe(e,o,r,t);const i=o.querySelectorAll(`[${r}]`);i.forEach(n=>{fe(e,n,r,t)}),ce.length&&function(e,t,n){const r=(e,t,n)=>e.filter(([e,r])=>{const o=window.scrollY+window.innerHeight,i=e.offsetTop;if(o<i)return!0;const s=e.clientHeight;return!(100*(1-(i+s-o)/(s||1))>=r)||(de(t,n,e,ae.Scroll),!1)});se||(se=function(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}(function(){ce=r.call(t,ce,e,n)}),t.addEventListener("scroll",se))}(e,o,t)}(e,n,r)}async function de(e,t,n,r){const o=T(n,r,t);return Promise.all(o.map(n=>oe(e,t,{event:`${n.entity} ${n.action}`,...n,trigger:r})))}function fe(e,t,n,r){const o=E(t,n);o&&Object.values(V(o)).forEach(n=>n.forEach(n=>{switch(n.trigger){case ae.Hover:!function(e,t,n){t.addEventListener("mouseenter",S(function(t){t.target instanceof Element&&de(e,n,t.target,ae.Hover)}))}(e,t,r);break;case ae.Load:!function(e,t,n){de(e,n,t,ae.Load)}(e,t,r);break;case ae.Pulse:!function(e,t,n="",r){setInterval(()=>{document.hidden||de(e,r,t,ae.Pulse)},parseInt(n||"")||15e3)}(e,t,n.triggerParams,r);break;case ae.Scroll:!function(e,t=""){const n=parseInt(t||"")||50;if(n<0||n>100)return;ce.push([e,n])}(t,n.triggerParams);break;case ae.Visible:te(e,t,{prefix:r});break;case ae.Visibles:te(e,t,{multiple:!0,prefix:r});break;case ae.Wait:!function(e,t,n="",r){setTimeout(()=>de(e,r,t,ae.Wait),parseInt(n||"")||15e3)}(e,t,n.triggerParams,r)}}))}function ge(e,t,n){de(e,n,t.target,ae.Click)}function me(e,t,n){t.target&&de(e,n,t.target,ae.Submit)}function pe(e,t={}){const n=t.name||"elbLayer";window[n]||(window[n]=[]);const r=window[n];r.push=function(...n){if(ye(n[0])){const r=[...Array.from(n[0])],o=Array.prototype.push.apply(this,[r]);return he(e,t.prefix,r),o}const r=Array.prototype.push.apply(this,n);return n.forEach(n=>{he(e,t.prefix,n)}),r},Array.isArray(r)&&r.length>0&&function(e,t="data-elb",n){be(e,t,n,!0),be(e,t,n,!1),n.length=0}(e,t.prefix,r)}function be(e,t,n,r){const o=[];let i=!0;n.forEach(e=>{const t=ye(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 s=t[0],c=!p(s)&&b(s)&&s.startsWith("walker ");if(p(s)){if("object"==typeof s&&0===Object.keys(s).length)return}else{const e=Array.from(t);if(!b(e[0])||""===e[0].trim())return;const n="walker run";i&&e[0]===n&&(i=!1)}(r&&c||!r&&!c)&&o.push(t)}),o.forEach(n=>{he(e,t,n)})}function he(e,t="data-elb",n){S(()=>{if(Array.isArray(n)){const[r,...o]=n;if(!r||b(r)&&""===r.trim())return;if(b(r)&&r.startsWith("walker "))return void e.push(r,o[0]);oe(e,t,r,...o)}else if(n&&"object"==typeof n){if(0===Object.keys(n).length)return;e.push(n)}},()=>{})()}function ye(e){return null!=e&&"object"==typeof e&&"[object Arguments]"===Object.prototype.toString.call(e)}function we(e={}){return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:document,...e}}var ve={};function ke(e={}){const t=e.prefix||"data-elb";return function(e){let n,r=e;const o={},i={},s={},c={},a={};function l(e){return Object.entries(e).map(([e,t])=>`${e}:${function(e){if(!g(e)||null===e)return"undefined";let t=String(e);return t=t.replace(/\\/g,"\\\\"),t=t.replace(/;/g,"\\;"),t=t.replace(/:/g,"\\:"),t=t.replace(/'/g,"\\'"),t}(t)}`).join(";")}const u={entity:e=>(n=e,r=e,u),data(e,t){const n=null!=r?r:"";return o[n]||(o[n]={}),b(e)?o[n][e]=t:Object.assign(o[n],e),u},action(e,t){if(b(e))if(g(t))i[e]=t;else if(e.includes(":")){const[t,n]=e.split(":",2);i[t]=n}else i[e]=e;else Object.assign(i,e);return u},context:(e,t)=>(b(e)?s[e]=t:Object.assign(s,e),u),globals:(e,t)=>(b(e)?c[e]=t:Object.assign(c,e),u),link:(e,t)=>(b(e)?a[e]=t:Object.assign(a,e),u),get(){const e={};return n&&(e[t]=n),Object.entries(o).forEach(([n,r])=>{if(Object.keys(r).length>0){e[n?`${t}-${n}`:`${t}-`]=l(r)}}),Object.keys(i).length>0&&(e[`${t}action`]=l(i)),Object.keys(s).length>0&&(e[`${t}context`]=l(s)),Object.keys(c).length>0&&(e[`${t}globals`]=l(c)),Object.keys(a).length>0&&(e[`${t}link`]=l(a)),e}};return u}}var Se,Oe=async(e,t)=>{try{const n={...t,settings:we(t.settings)},r={type:"browser",config:n,collector:e,destroy(){ne(e)}};if(!1!==n.settings.elbLayer&&pe(e,{name:b(n.settings.elbLayer)?n.settings.elbLayer:"elbLayer",prefix:n.settings.prefix}),n.settings.session){const t="boolean"==typeof n.settings.session?{}:n.settings.session;!function(e,t={}){const n=t.config||{},r=d(e.config.sessionStatic||{},t.data||{});var o,i,s;(o=$,i="SessionStart",s=e.hooks,function(...e){let t;const n="post"+i,r=s["pre"+i],c=s[n];return t=r?r({fn:o},...e):o(...e),c&&(t=c({fn:o,result:t},...e)),t})({...n,cb:(e,t,r)=>{let o;const i=n;return!1!==i.cb&&i.cb?o=i.cb(e,t,r):!1!==i.cb&&(o=r(e,t,r)),t&&(t.session=e,C(t,"session")),o},data:r,collector:e})}(e,{config:t})}await async function(e,t,n){const r=()=>{if(e(t,n),null==t?void 0:t.on)try{C(t,"ready")}catch(e){}};"loading"!==document.readyState?r():document.addEventListener("DOMContentLoaded",r)}(le,e,n.settings);const o=e=>{if(ue(e,n.settings),n.settings.pageview){const[t,r]=function(e,t){const n=window.location,r="page",o=t===document?document.body:t,[i,s]=q(o,`[${N(e,r)}]`,e,r);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,s]}(n.settings.prefix||"data-elb",n.settings.scope);oe(e,"page view",t,ae.Load,r)}};await e.push("walker on","run",o);const i=e._destroy;e._destroy=()=>{var e;null==(e=r.destroy)||e.call(r),i&&i()};const s=(...t)=>{const[r,o,i,s,c,a]=t;return oe(e,n.settings.prefix,r,o,i,s,c,a)};return b(n.settings.elb)&&(window[n.settings.elb]=s),{source:r,elb:s}}catch(e){throw e}},xe=Oe;return Se=s,((e,t,s,c)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of o(t))i.call(e,a)||a===s||n(e,a,{get:()=>t[a],enumerable:!(c=r(t,a))||c.enumerable});return e})(n({},"__esModule",{value:!0}),Se)})();
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as _walkeros_core from '@walkeros/core';
2
- import { Elb, WalkerOS, Collector, Source, Mapping as Mapping$1 } from '@walkeros/core';
3
- import { DestinationWeb, Elb as Elb$1, SessionConfig, Walker, SessionCallback } from '@walkeros/web-core';
2
+ import { Elb, WalkerOS, Collector, Source } from '@walkeros/core';
3
+ import { DestinationWeb, Elb as Elb$1, SessionConfig, SessionCallback, Walker } from '@walkeros/web-core';
4
4
 
5
5
  type Scope$1 = Element | Document;
6
- type Trigger$1 = string;
6
+ type Trigger = string;
7
7
  interface BrowserPush<R = Promise<Elb.PushResult>> {
8
8
  (event: WalkerOS.DeepPartialEvent): R;
9
9
  (event: 'walker config', config: Partial<Collector.Config>): R;
@@ -16,35 +16,30 @@ interface BrowserPush<R = Promise<Elb.PushResult>> {
16
16
  (event?: unknown, data?: BrowserPushData, options?: BrowserPushOptions, context?: BrowserPushContext, nested?: WalkerOS.Entities, custom?: WalkerOS.Properties): R;
17
17
  }
18
18
  type BrowserArguments<R = Promise<Elb.PushResult>> = (event?: unknown, data?: BrowserPushData, options?: BrowserPushOptions, context?: BrowserPushContext, nested?: WalkerOS.Entities, custom?: WalkerOS.Properties) => R;
19
- type BrowserPushData = Elb.PushData | DestinationWeb.Destination | DestinationWeb.Init | Scope$1 | Array<Scope$1> | Trigger$1 | string | object;
20
- type BrowserPushOptions = Trigger$1 | DestinationWeb.Config | string | object;
19
+ type BrowserPushData = Elb.PushData | DestinationWeb.Destination | DestinationWeb.Init | Scope$1 | Array<Scope$1> | Trigger | string | object | IArguments;
20
+ type BrowserPushOptions = Trigger | DestinationWeb.Config | string | object;
21
21
  type BrowserPushContext = WalkerOS.OrderedProperties | Element;
22
22
  type BrowserCommands<R = Promise<Elb.PushResult>> = CommandInit<R> | CommandDestination<R> | CommandRun<R>;
23
23
  type CommandInit<R = Promise<Elb.PushResult>> = (event: 'walker init', scope: Scope$1 | Scope$1[]) => R;
24
24
  type CommandDestination<R = Promise<Elb.PushResult>> = (event: 'walker destination', destination: DestinationWeb.Destination | DestinationWeb.Init, config?: DestinationWeb.Config) => R;
25
25
  type CommandRun<R = Promise<Elb.PushResult>> = (event: 'walker run', state?: Partial<Collector.Instance>) => R;
26
26
  type PushResult = Elb.PushResult;
27
- type Layer = Elb.Layer;
27
+ type Layer = Elb.Layer | IArguments;
28
28
 
29
29
  interface BrowserSourceConfig extends Source.Config {
30
30
  type: 'browser';
31
31
  settings: Settings;
32
32
  }
33
- interface Config {
34
- settings: Settings;
35
- mapping?: Mapping;
36
- }
37
33
  interface Settings extends Record<string, unknown> {
38
34
  prefix?: string;
39
35
  scope?: Element | Document;
40
36
  pageview?: boolean;
41
37
  session?: boolean | SessionConfig;
42
38
  elb?: string;
43
- name?: string;
44
39
  elbLayer?: boolean | string | Elb$1.Layer;
45
40
  }
46
41
 
47
- type ELBLayer = Elb$1.Layer;
42
+ type ELBLayer = Array<Elb$1.Layer | IArguments>;
48
43
  interface ELBLayerConfig {
49
44
  name?: string;
50
45
  }
@@ -53,28 +48,8 @@ declare global {
53
48
  [key: string]: Elb$1.Layer | unknown;
54
49
  }
55
50
  }
56
- interface Mapping {
57
- }
58
- type Rule = Mapping$1.Rule<Mapping>;
59
- type Rules = Mapping$1.Rules<Rule>;
60
- type Trigger = Walker.Trigger;
61
- type WalkerEvent = Walker.Event;
62
- type Events = Walker.Events;
63
- type Filter = Walker.Filter;
64
- interface TriggerAction {
65
- trigger: string;
66
- triggerParams?: string;
67
- action: string;
68
- actionParams?: string;
69
- }
70
- type TriggerActions = Walker.TriggerActions;
71
- type TriggersActionGroups = Walker.TriggersActionGroups;
72
- type ScrollElements = Walker.ScrollElements;
73
- type Attributes = Walker.Attributes;
74
- type KeyVal = Walker.KeyVal;
75
51
  type Scope = Document | Element;
76
52
 
77
- type index_Attributes = Attributes;
78
53
  type index_BrowserArguments<R = Promise<Elb.PushResult>> = BrowserArguments<R>;
79
54
  type index_BrowserCommands<R = Promise<Elb.PushResult>> = BrowserCommands<R>;
80
55
  type index_BrowserPush<R = Promise<Elb.PushResult>> = BrowserPush<R>;
@@ -85,33 +60,21 @@ type index_BrowserSourceConfig = BrowserSourceConfig;
85
60
  type index_CommandDestination<R = Promise<Elb.PushResult>> = CommandDestination<R>;
86
61
  type index_CommandInit<R = Promise<Elb.PushResult>> = CommandInit<R>;
87
62
  type index_CommandRun<R = Promise<Elb.PushResult>> = CommandRun<R>;
88
- type index_Config = Config;
89
63
  type index_ELBLayer = ELBLayer;
90
64
  type index_ELBLayerConfig = ELBLayerConfig;
91
- type index_Events = Events;
92
- type index_Filter = Filter;
93
- type index_KeyVal = KeyVal;
94
65
  type index_Layer = Layer;
95
- type index_Mapping = Mapping;
96
66
  type index_PushResult = PushResult;
97
- type index_Rule = Rule;
98
- type index_Rules = Rules;
99
67
  type index_Scope = Scope;
100
- type index_ScrollElements = ScrollElements;
101
68
  declare const index_SessionCallback: typeof SessionCallback;
102
69
  declare const index_SessionConfig: typeof SessionConfig;
103
70
  type index_Settings = Settings;
104
71
  type index_Trigger = Trigger;
105
- type index_TriggerAction = TriggerAction;
106
- type index_TriggerActions = TriggerActions;
107
- type index_TriggersActionGroups = TriggersActionGroups;
108
- type index_WalkerEvent = WalkerEvent;
109
72
  declare namespace index {
110
- export { type index_Attributes as Attributes, type index_BrowserArguments as BrowserArguments, type index_BrowserCommands as BrowserCommands, type index_BrowserPush as BrowserPush, type index_BrowserPushContext as BrowserPushContext, type index_BrowserPushData as BrowserPushData, type index_BrowserPushOptions as BrowserPushOptions, type index_BrowserSourceConfig as BrowserSourceConfig, type index_CommandDestination as CommandDestination, type index_CommandInit as CommandInit, type index_CommandRun as CommandRun, type index_Config as Config, type index_ELBLayer as ELBLayer, type index_ELBLayerConfig as ELBLayerConfig, type index_Events as Events, type index_Filter as Filter, type index_KeyVal as KeyVal, type index_Layer as Layer, type index_Mapping as Mapping, type index_PushResult as PushResult, type index_Rule as Rule, type index_Rules as Rules, type index_Scope as Scope, type index_ScrollElements as ScrollElements, index_SessionCallback as SessionCallback, index_SessionConfig as SessionConfig, type index_Settings as Settings, type index_Trigger as Trigger, type index_TriggerAction as TriggerAction, type index_TriggerActions as TriggerActions, type index_TriggersActionGroups as TriggersActionGroups, type index_WalkerEvent as WalkerEvent };
73
+ export { type index_BrowserArguments as BrowserArguments, type index_BrowserCommands as BrowserCommands, type index_BrowserPush as BrowserPush, type index_BrowserPushContext as BrowserPushContext, type index_BrowserPushData as BrowserPushData, type index_BrowserPushOptions as BrowserPushOptions, type index_BrowserSourceConfig as BrowserSourceConfig, type index_CommandDestination as CommandDestination, type index_CommandInit as CommandInit, type index_CommandRun as CommandRun, type index_ELBLayer as ELBLayer, type index_ELBLayerConfig as ELBLayerConfig, type index_Layer as Layer, type index_PushResult as PushResult, type index_Scope as Scope, index_SessionCallback as SessionCallback, index_SessionConfig as SessionConfig, type index_Settings as Settings, type index_Trigger as Trigger };
111
74
  }
112
75
 
113
- declare function getAllEvents(scope?: Scope, prefix?: string): Events;
114
- declare function getEvents(target: Element, trigger: string, prefix?: string): Events;
76
+ declare function getAllEvents(scope?: Scope, prefix?: string): Walker.Events;
77
+ declare function getEvents(target: Element, trigger: string, prefix?: string): Walker.Events;
115
78
  declare function getGlobals(prefix?: string, scope?: Scope): WalkerOS.Properties;
116
79
 
117
80
  interface TaggerConfig {
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as _walkeros_core from '@walkeros/core';
2
- import { Elb, WalkerOS, Collector, Source, Mapping as Mapping$1 } from '@walkeros/core';
3
- import { DestinationWeb, Elb as Elb$1, SessionConfig, Walker, SessionCallback } from '@walkeros/web-core';
2
+ import { Elb, WalkerOS, Collector, Source } from '@walkeros/core';
3
+ import { DestinationWeb, Elb as Elb$1, SessionConfig, SessionCallback, Walker } from '@walkeros/web-core';
4
4
 
5
5
  type Scope$1 = Element | Document;
6
- type Trigger$1 = string;
6
+ type Trigger = string;
7
7
  interface BrowserPush<R = Promise<Elb.PushResult>> {
8
8
  (event: WalkerOS.DeepPartialEvent): R;
9
9
  (event: 'walker config', config: Partial<Collector.Config>): R;
@@ -16,35 +16,30 @@ interface BrowserPush<R = Promise<Elb.PushResult>> {
16
16
  (event?: unknown, data?: BrowserPushData, options?: BrowserPushOptions, context?: BrowserPushContext, nested?: WalkerOS.Entities, custom?: WalkerOS.Properties): R;
17
17
  }
18
18
  type BrowserArguments<R = Promise<Elb.PushResult>> = (event?: unknown, data?: BrowserPushData, options?: BrowserPushOptions, context?: BrowserPushContext, nested?: WalkerOS.Entities, custom?: WalkerOS.Properties) => R;
19
- type BrowserPushData = Elb.PushData | DestinationWeb.Destination | DestinationWeb.Init | Scope$1 | Array<Scope$1> | Trigger$1 | string | object;
20
- type BrowserPushOptions = Trigger$1 | DestinationWeb.Config | string | object;
19
+ type BrowserPushData = Elb.PushData | DestinationWeb.Destination | DestinationWeb.Init | Scope$1 | Array<Scope$1> | Trigger | string | object | IArguments;
20
+ type BrowserPushOptions = Trigger | DestinationWeb.Config | string | object;
21
21
  type BrowserPushContext = WalkerOS.OrderedProperties | Element;
22
22
  type BrowserCommands<R = Promise<Elb.PushResult>> = CommandInit<R> | CommandDestination<R> | CommandRun<R>;
23
23
  type CommandInit<R = Promise<Elb.PushResult>> = (event: 'walker init', scope: Scope$1 | Scope$1[]) => R;
24
24
  type CommandDestination<R = Promise<Elb.PushResult>> = (event: 'walker destination', destination: DestinationWeb.Destination | DestinationWeb.Init, config?: DestinationWeb.Config) => R;
25
25
  type CommandRun<R = Promise<Elb.PushResult>> = (event: 'walker run', state?: Partial<Collector.Instance>) => R;
26
26
  type PushResult = Elb.PushResult;
27
- type Layer = Elb.Layer;
27
+ type Layer = Elb.Layer | IArguments;
28
28
 
29
29
  interface BrowserSourceConfig extends Source.Config {
30
30
  type: 'browser';
31
31
  settings: Settings;
32
32
  }
33
- interface Config {
34
- settings: Settings;
35
- mapping?: Mapping;
36
- }
37
33
  interface Settings extends Record<string, unknown> {
38
34
  prefix?: string;
39
35
  scope?: Element | Document;
40
36
  pageview?: boolean;
41
37
  session?: boolean | SessionConfig;
42
38
  elb?: string;
43
- name?: string;
44
39
  elbLayer?: boolean | string | Elb$1.Layer;
45
40
  }
46
41
 
47
- type ELBLayer = Elb$1.Layer;
42
+ type ELBLayer = Array<Elb$1.Layer | IArguments>;
48
43
  interface ELBLayerConfig {
49
44
  name?: string;
50
45
  }
@@ -53,28 +48,8 @@ declare global {
53
48
  [key: string]: Elb$1.Layer | unknown;
54
49
  }
55
50
  }
56
- interface Mapping {
57
- }
58
- type Rule = Mapping$1.Rule<Mapping>;
59
- type Rules = Mapping$1.Rules<Rule>;
60
- type Trigger = Walker.Trigger;
61
- type WalkerEvent = Walker.Event;
62
- type Events = Walker.Events;
63
- type Filter = Walker.Filter;
64
- interface TriggerAction {
65
- trigger: string;
66
- triggerParams?: string;
67
- action: string;
68
- actionParams?: string;
69
- }
70
- type TriggerActions = Walker.TriggerActions;
71
- type TriggersActionGroups = Walker.TriggersActionGroups;
72
- type ScrollElements = Walker.ScrollElements;
73
- type Attributes = Walker.Attributes;
74
- type KeyVal = Walker.KeyVal;
75
51
  type Scope = Document | Element;
76
52
 
77
- type index_Attributes = Attributes;
78
53
  type index_BrowserArguments<R = Promise<Elb.PushResult>> = BrowserArguments<R>;
79
54
  type index_BrowserCommands<R = Promise<Elb.PushResult>> = BrowserCommands<R>;
80
55
  type index_BrowserPush<R = Promise<Elb.PushResult>> = BrowserPush<R>;
@@ -85,33 +60,21 @@ type index_BrowserSourceConfig = BrowserSourceConfig;
85
60
  type index_CommandDestination<R = Promise<Elb.PushResult>> = CommandDestination<R>;
86
61
  type index_CommandInit<R = Promise<Elb.PushResult>> = CommandInit<R>;
87
62
  type index_CommandRun<R = Promise<Elb.PushResult>> = CommandRun<R>;
88
- type index_Config = Config;
89
63
  type index_ELBLayer = ELBLayer;
90
64
  type index_ELBLayerConfig = ELBLayerConfig;
91
- type index_Events = Events;
92
- type index_Filter = Filter;
93
- type index_KeyVal = KeyVal;
94
65
  type index_Layer = Layer;
95
- type index_Mapping = Mapping;
96
66
  type index_PushResult = PushResult;
97
- type index_Rule = Rule;
98
- type index_Rules = Rules;
99
67
  type index_Scope = Scope;
100
- type index_ScrollElements = ScrollElements;
101
68
  declare const index_SessionCallback: typeof SessionCallback;
102
69
  declare const index_SessionConfig: typeof SessionConfig;
103
70
  type index_Settings = Settings;
104
71
  type index_Trigger = Trigger;
105
- type index_TriggerAction = TriggerAction;
106
- type index_TriggerActions = TriggerActions;
107
- type index_TriggersActionGroups = TriggersActionGroups;
108
- type index_WalkerEvent = WalkerEvent;
109
72
  declare namespace index {
110
- export { type index_Attributes as Attributes, type index_BrowserArguments as BrowserArguments, type index_BrowserCommands as BrowserCommands, type index_BrowserPush as BrowserPush, type index_BrowserPushContext as BrowserPushContext, type index_BrowserPushData as BrowserPushData, type index_BrowserPushOptions as BrowserPushOptions, type index_BrowserSourceConfig as BrowserSourceConfig, type index_CommandDestination as CommandDestination, type index_CommandInit as CommandInit, type index_CommandRun as CommandRun, type index_Config as Config, type index_ELBLayer as ELBLayer, type index_ELBLayerConfig as ELBLayerConfig, type index_Events as Events, type index_Filter as Filter, type index_KeyVal as KeyVal, type index_Layer as Layer, type index_Mapping as Mapping, type index_PushResult as PushResult, type index_Rule as Rule, type index_Rules as Rules, type index_Scope as Scope, type index_ScrollElements as ScrollElements, index_SessionCallback as SessionCallback, index_SessionConfig as SessionConfig, type index_Settings as Settings, type index_Trigger as Trigger, type index_TriggerAction as TriggerAction, type index_TriggerActions as TriggerActions, type index_TriggersActionGroups as TriggersActionGroups, type index_WalkerEvent as WalkerEvent };
73
+ export { type index_BrowserArguments as BrowserArguments, type index_BrowserCommands as BrowserCommands, type index_BrowserPush as BrowserPush, type index_BrowserPushContext as BrowserPushContext, type index_BrowserPushData as BrowserPushData, type index_BrowserPushOptions as BrowserPushOptions, type index_BrowserSourceConfig as BrowserSourceConfig, type index_CommandDestination as CommandDestination, type index_CommandInit as CommandInit, type index_CommandRun as CommandRun, type index_ELBLayer as ELBLayer, type index_ELBLayerConfig as ELBLayerConfig, type index_Layer as Layer, type index_PushResult as PushResult, type index_Scope as Scope, index_SessionCallback as SessionCallback, index_SessionConfig as SessionConfig, type index_Settings as Settings, type index_Trigger as Trigger };
111
74
  }
112
75
 
113
- declare function getAllEvents(scope?: Scope, prefix?: string): Events;
114
- declare function getEvents(target: Element, trigger: string, prefix?: string): Events;
76
+ declare function getAllEvents(scope?: Scope, prefix?: string): Walker.Events;
77
+ declare function getEvents(target: Element, trigger: string, prefix?: string): Walker.Events;
115
78
  declare function getGlobals(prefix?: string, scope?: Scope): WalkerOS.Properties;
116
79
 
117
80
  interface TaggerConfig {
package/dist/index.es5.js CHANGED
@@ -1 +1 @@
1
- "use strict";function _array_like_to_array(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _array_with_holes(e){if(Array.isArray(e))return e}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function asyncGeneratorStep(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function _async_to_generator(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){asyncGeneratorStep(i,r,o,a,c,"next",e)}function c(e){asyncGeneratorStep(i,r,o,a,c,"throw",e)}a(void 0)})}}function _define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _instanceof(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterable_to_array_limit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){_define_property(e,t,n[t])})}return e}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function _sliced_to_array(e,t){return _array_with_holes(e)||_iterable_to_array_limit(e,t)||_unsupported_iterable_to_array(e,t)||_non_iterable_rest()}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,t){if(e){if("string"==typeof e)return _array_like_to_array(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_array_like_to_array(e,t):void 0}}function _ts_generator(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}var Source=function(){var e,t,n=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n=_object_spread({},_e,n);var r=Object.entries(t).reduce(function(t,r){var o=_sliced_to_array(r,2),i=o[0],a=o[1],c=e[i];return n.merge&&Array.isArray(c)&&Array.isArray(a)?t[i]=a.reduce(function(e,t){return e.includes(t)?e:_to_consumable_array(e).concat([t])},_to_consumable_array(c)):(n.extend||i in e)&&(t[i]=a),t},{});return n.shallow?_object_spread({},e,r):(Object.assign(e,r),e)},r=function(e){return Array.isArray(e)},o=function(e){return void 0!==e},i=function(e){return"object"==(void 0===e?"undefined":_type_of(e))&&null!==e&&!r(e)&&"[object Object]"===Object.prototype.toString.call(e)},a=function(e){return"string"==typeof e},c=function(e){if("true"===e)return!0;if("false"===e)return!1;var t=Number(e);return e==t&&""!==e?t:String(e)},s=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6,t="";t.length<e;)t+=(36*Math.random()|0).toString(36);return t},u=function(e,t,n){return function(){for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];try{return e.apply(void 0,_to_consumable_array(o))}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}},l=function(e){return e?e.trim().replace(/^'|'$/g,"").trim():""},f=function(e,t,n,r){var o,i,a,c=n||[];if(n||(c=e.on[t]||[],Object.values(e.destinations).forEach(function(e){var n,r=null===(n=e.config.on)||void 0===n?void 0:n[t];r&&(c=c.concat(r))})),c.length)switch(t){case he.Commands.Consent:o=e,i=c,a=r||o.consent,i.forEach(function(e){Object.keys(a).filter(function(t){return t in e}).forEach(function(t){u(e[t])(o,a)})});break;case he.Commands.Ready:case he.Commands.Run:!function(e,t){e.allowed&&t.forEach(function(t){u(t)(e)})}(e,c);break;case he.Commands.Session:!function(e,t){e.session&&t.forEach(function(t){u(t)(e,e.session)})}(e,c)}},d=function(e,t){return(e.getAttribute(t)||"").trim()},p=function(e){var t,n=getComputedStyle(e);if("none"===n.display)return!1;if("visible"!==n.visibility)return!1;if(n.opacity&&Number(n.opacity)<.1)return!1;var r=window.innerHeight,o=e.getBoundingClientRect(),i=o.height,a=o.y,c=a+i,s={x:o.x+e.offsetWidth/2,y:o.y+e.offsetHeight/2};if(i<=r){if(e.offsetWidth+o.width===0||e.offsetHeight+o.height===0)return!1;if(s.x<0)return!1;if(s.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(s.y<0)return!1;if(s.y>(document.documentElement.clientHeight||window.innerHeight))return!1;t=document.elementFromPoint(s.x,s.y)}else{var u=r/2;if(a<0&&c<u)return!1;if(c>r&&a>u)return!1;t=document.elementFromPoint(s.x,r/2)}if(t)do{if(t===e)return!0}while(t=t.parentElement);return!1},v=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.cb,n=e.consent,i=e.collector,a=e.storage,c=(null==i?void 0:i.push)||we;if(!n)return g((a?_:m)(e),i,t);var s,u,l,f=(s=e,u=t,function(e,t){if(!o(l)||l!==(null==e?void 0:e.group)){l=null==e?void 0:e.group;var n=function(){return m(s)};return s.consent&&function(e){var t=_object_spread({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}),n={},r=void 0===e;return Object.keys(t).forEach(function(o){t[o]&&(n[o]=!0,e&&e[o]&&(r=!0))}),!!r&&n}((r(s.consent)?s.consent:[s.consent]).reduce(function(e,t){return _object_spread_props(_object_spread({},e),_define_property({},t,!0))},{}),t)&&(n=function(){return _(s)}),g(n(),e,u)}});c("walker on","consent",(r(n)?n:[n]).reduce(function(e,t){return _object_spread_props(_object_spread({},e),_define_property({},t,f))},{}))},g=function(e,t,n){return!1===n?e:(n||(n=ke),n(e,t,ke))},y=function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:be.Utils.Storage.Session;function o(e){try{return JSON.parse(e||"")}catch(r){var t=1,n="";return e&&(t=0,n=e),{e:t,v:n}}}switch(r){case be.Utils.Storage.Cookie:var i;t=decodeURIComponent((null===(i=document.cookie.split("; ").find(function(t){return t.startsWith(e+"=")}))||void 0===i?void 0:i.split("=")[1])||"");break;case be.Utils.Storage.Local:n=o(window.localStorage.getItem(e));break;case be.Utils.Storage.Session:n=o(window.sessionStorage.getItem(e))}return n&&(t=n.v,0!=n.e&&n.e<Date.now()&&(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:be.Utils.Storage.Session;switch(t){case be.Utils.Storage.Cookie:b(e,"",0,t);break;case be.Utils.Storage.Local:window.localStorage.removeItem(e);break;case be.Utils.Storage.Session:window.sessionStorage.removeItem(e)}}(e,r),t="")),c(t||"")},b=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:30,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:be.Utils.Storage.Session,o=arguments.length>4?arguments[4]:void 0,i={e:Date.now()+6e4*n,v:String(t)},a=JSON.stringify(i);switch(r){case be.Utils.Storage.Cookie:t="object"==(void 0===t?"undefined":_type_of(t))?JSON.stringify(t):t;var c="".concat(e,"=").concat(encodeURIComponent(t),"; max-age=").concat(60*n,"; path=/; SameSite=Lax; secure");o&&(c+="; domain="+o),document.cookie=c;break;case be.Utils.Storage.Local:window.localStorage.setItem(e,a);break;case be.Utils.Storage.Session:window.sessionStorage.setItem(e,a)}return y(e,r)},_=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Date.now(),n=e.length,r=void 0===n?30:n,o=e.deviceKey,i=void 0===o?"elbDeviceId":o,a=e.deviceStorage,c=void 0===a?"local":a,l=e.deviceAge,f=void 0===l?30:l,d=e.sessionKey,p=void 0===d?"elbSessionId":d,v=e.sessionStorage,g=void 0===v?"local":v,_=e.pulse,h=void 0!==_&&_,w=m(e),k=!1,S=u(function(e,t,n){var r=y(e,n);return r||(r=s(8),b(e,r,1440*t,n)),String(r)})(i,f,c),j=u(function(e,n){var o=JSON.parse(String(y(e,n)));return h||(o.isNew=!1,w.marketing&&(Object.assign(o,w),k=!0),k||o.updated+6e4*r<t?(delete o.id,delete o.referrer,o.start=t,o.count++,o.runs=1,k=!0):o.runs++),o},function(){k=!0})(p,g)||{},O={id:s(12),start:t,isNew:!0,count:1,runs:1},x=Object.assign(O,w,j,{device:S},{isStart:k,storage:!0,updated:t},e.data);return b(p,JSON.stringify(x),2*r,g),x},m=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.isStart||!1,r={isStart:t,storage:!1};if(!1===e.isStart)return r;if(!t&&"navigate"!==_sliced_to_array(performance.getEntriesByType("navigation"),1)[0].type)return r;var o=new URL(e.url||window.location.href),i=e.referrer||document.referrer,a=i&&new URL(i).hostname,c=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="clickId",o={},i={utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term",dclid:r,fbclid:r,gclid:r,msclkid:r,ttclid:r,twclid:r,igshid:r,sclid:r};return Object.entries(n(i,t)).forEach(function(t){var n=_sliced_to_array(t,2),i=n[0],a=n[1],c=e.searchParams.get(i);c&&(a===r&&(a=i,o[r]=i),o[a]=c)}),o}(o,e.parameters);if(Object.keys(c).length&&(c.marketing||(c.marketing=!0),t=!0),!t){var u=e.domains||[];u.push(o.hostname),t=!u.includes(a)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:s(12),referrer:a},c,e.data):r},h=function(e,t){return e+(t=null!=t?(!(arguments.length>2&&void 0!==arguments[2])||arguments[2]?"-":"")+t:"")},w=function(e,t,n){var o=d(t,h(e,n,!(arguments.length>3&&void 0!==arguments[3])||arguments[3]))||"";return L(o).reduce(function(e,n){var o=_sliced_to_array(I(n),2),i=o[0],a=o[1];if(!i)return e;if(a||(i.endsWith(":")&&(i=i.slice(0,-1)),a=""),a.startsWith("#")){a=a.slice(1);try{var s=t[a];s||"selected"!==a||(s=t.options[t.selectedIndex].text),a=String(s)}catch(e){a=""}}return i.endsWith("[]")?(i=i.slice(0,-2),r(e[i])||(e[i]=[]),e[i].push(c(a))):e[i]=c(a),e},{})},k=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:he.Commands.Prefix,n=[],r=he.Commands.Action,o="[".concat(h(t,r,!1),"]"),i=function(e){Object.keys(w(t,e,r,!1)).forEach(function(r){n=n.concat(S(e,r,t))})};return e!==document&&e.matches(o)&&i(e),P(e,o,i),n},S=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:he.Commands.Prefix,r=[],o=A(n,e,t);return o?(o.forEach(function(o){var i=L(o.actionParams||"",",").reduce(function(e,t){return e[l(t)]=!0,e},{}),a=x(n,e,i);if(!a.length){var c="page",s="[".concat(h(n,c),"]"),u=_sliced_to_array(E(e,s,n,c),2),f=u[0],d=u[1];a.push({type:c,data:f,nested:[],context:d})}a.forEach(function(e){r.push({entity:e.type,action:o.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),r):r},j=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:he.Commands.Prefix,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document,r=h(e,he.Commands.Globals,!1),o="[".concat(r,"]"),i={};return P(t,o,function(t){i=n(i,w(e,t,he.Commands.Globals,!1))}),i},O=function(e){var t={};return L(e).forEach(function(e){var n=_sliced_to_array(I(e),2),r=n[0],o=n[1],i=_sliced_to_array(U(r),2),a=i[0],c=i[1];if(a){var s=_sliced_to_array(U(o||""),2),u=s[0],l=s[1];u=u||a,t[a]||(t[a]=[]),t[a].push({trigger:a,triggerParams:c,action:u,actionParams:l})}}),t},x=function(e,t,n){var r=[],o=t;for(n=0!==Object.keys(n||{}).length?n:void 0;o;){var i=Se(e,o,t,n);i&&r.push(i),o=C(e,o)}return r},C=function(e,t){var n=h(e,he.Commands.Link,!1);if(t.matches("[".concat(n,"]"))){var r=_sliced_to_array(I(d(t,n)),2),o=r[0];if("child"===r[1])return document.querySelector("[".concat(n,'="').concat(o,':parent"]'))}return!t.parentElement&&t.getRootNode&&_instanceof(t.getRootNode(),ShadowRoot)?t.getRootNode().host:t.parentElement},E=function(e,t,r,o){for(var i={},a={},c=e,s="[".concat(h(r,he.Commands.Context,!1),"]"),u=0;c;)c.matches(t)&&(i=n(w(r,c,""),i),i=n(w(r,c,o),i)),c.matches(s)&&(Object.entries(w(r,c,he.Commands.Context,!1)).forEach(function(e){var t=_sliced_to_array(e,2),n=t[0],r=t[1];r&&!a[n]&&(a[n]=[r,u])}),++u),c=C(r,c);return[i,a]},P=function(e,t,n){e.querySelectorAll(t).forEach(n)},A=function(e,t,n){for(var r=t;r;){var o=d(r,h(e,he.Commands.Action,!1)),i=O(o);if(i[n]||"click"!==n)return i[n];r=C(e,r)}return[]},L=function(e){if(!e)return[];var t=new RegExp("(?:[^".concat(arguments.length>1&&void 0!==arguments[1]?arguments[1]:";","']+|'[^']*')+"),"ig");return e.match(t)||[]},I=function(e){var t=_sliced_to_array(e.split(/:(.+)/,2),2),n=t[0],r=t[1];return[l(n),l(r)]},U=function(e){var t=_sliced_to_array(e.split("(",2),2),n=t[0],r=t[1];return[n,r?r.slice(0,-1):""]},W=function(e){var t=Date.now(),n=Ce.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:p(e),lastChecked:t},Ce.set(e,n)),n.isVisible},D=function(e){if(window.IntersectionObserver)return u(function(){return new window.IntersectionObserver(function(t){t.forEach(function(t){R(e,t)})},{rootMargin:"0px",threshold:[0,.5]})},function(){})()},R=function(e,t){var n,r=t.target,o=e._visibilityState;if(o){var i=o.timers.get(r);if(t.intersectionRatio>0){var a=Date.now(),c=xe.get(r);if((!c||a-c.lastChecked>1e3)&&(c={isLarge:r.offsetHeight>window.innerHeight,lastChecked:a},xe.set(r,c)),t.intersectionRatio>=.5||c.isLarge&&W(r)){var s,u=null===(s=o.elementConfigs)||void 0===s?void 0:s.get(r);if((null==u?void 0:u.multiple)&&u.blocked)return;if(!i){var l=window.setTimeout(function(){return _async_to_generator(function(){var t,n;return _ts_generator(this,function(i){switch(i.label){case 0:return W(r)?[4,K(e,r,Pe.Visible,"data-elb")]:[3,2];case 1:i.sent(),(null==(n=null===(t=o.elementConfigs)||void 0===t?void 0:t.get(r))?void 0:n.multiple)?n.blocked=!0:function(e,t){var n=e._visibilityState;if(n){n.observer&&n.observer.unobserve(t);var r=n.timers.get(t);r&&(clearTimeout(r),n.timers.delete(t)),xe.delete(t),Ce.delete(t)}}(e,r),i.label=2;case 2:return[2]}})})()},o.duration);o.timers.set(r,l)}return}}i&&(clearTimeout(i),o.timers.delete(r));var f=null===(n=o.elementConfigs)||void 0===n?void 0:n.get(r);(null==f?void 0:f.multiple)&&(f.blocked=!1)}},H=function(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{multiple:!1},o=e._visibilityState;(null==o?void 0:o.observer)&&t&&(o.elementConfigs||(o.elementConfigs=new WeakMap),o.elementConfigs.set(t,{multiple:null!==(n=r.multiple)&&void 0!==n&&n,blocked:!1}),o.observer.observe(t))},N=function(e){var t=e._visibilityState;t&&(t.observer&&t.observer.disconnect(),delete e._visibilityState)},T=function(e,t,n,r,c,s,u){if(a(t)&&t.startsWith("walker ")){if("walker config"===t)return e.push("walker config",n);if("walker consent"===t)return e.push("walker consent",n);if("walker user"===t)return e.push("walker user",n);if("walker run"===t)return e.push("walker run",n)}if(i(t)){var l=t;return l.source||(l.source=V()),e.push(l)}if(a(t)&&t.length>0){var f={event:t,data:M(n||{}),context:G(c||{}),custom:u,nested:s,source:V()};return a(r)&&(f.trigger=r),e.push(f)}if(!o(t))return Promise.resolve({ok:!0,successful:[],queued:[],failed:[]});var d={event:String(t||""),data:M(n||{}),context:G(c||{}),custom:u,nested:s,source:V()};return a(r)&&(d.trigger=r),e.push(d)},M=function(e){return e?(n={},(void 0===(t=e)?"undefined":_type_of(t))==(void 0===n?"undefined":_type_of(n))?e:{}):{};var t,n},G=function(e){return e?(t=e)===document||_instanceof(t,Element)?{}:i(e)&&Object.keys(e).length?e:{}:{};var t},V=function(){return{type:"browser",id:window.location.href,previous_id:document.referrer}},J=function(e,t,n){return _async_to_generator(function(){var r;return _ts_generator(this,function(o){return r=function(){e(t,n),f(t,"ready")},"loading"!==document.readyState?r():document.addEventListener("DOMContentLoaded",r),[2]})})()},q=function(e,t){var n=t.prefix,r=t.scope;if(t.pageview){var o=_sliced_to_array(function(e,t){var n=window.location,r="page",o=t===document?document.body:t,i=_sliced_to_array(E(o,"[".concat(h(e,r),"]"),e,r),2),a=i[0],c=i[1];return a.domain=n.hostname,a.title=document.title,a.referrer=document.referrer,n.search&&(a.search=n.search),n.hash&&(a.hash=n.hash),[a,c]}(n,r),2),i=o[0],a=o[1];T(e,"page view",i,Pe.Load,a)}B(e,n,r)},B=function(e,t,n){Ee=[],N(e),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;e._visibilityState||(e._visibilityState={observer:D(e),timers:new WeakMap,duration:t})}(e,1e3);var r=h(t,he.Commands.Action,!1),o=n||document;o!==document&&F(e,o,r,t),o.querySelectorAll("[".concat(r,"]")).forEach(function(n){return F(e,n,r,t)}),Ee.length&&te(e,o)},K=function(e,t,n,r){return _async_to_generator(function(){var o;return _ts_generator(this,function(i){return o=S(t,n,r),[2,Promise.all(o.map(function(t){return T(e,_object_spread_props(_object_spread({event:"".concat(t.entity," ").concat(t.action)},t),{trigger:n}))}))]})})()},F=function(e,t,n,r){var o=d(t,n);o&&Object.values(O(o)).forEach(function(n){return n.forEach(function(n){switch(n.trigger){case Pe.Hover:Y(e,t,r);break;case Pe.Load:z(e,t,r);break;case Pe.Pulse:Q(e,t,n.triggerParams,r);break;case Pe.Scroll:X(t,n.triggerParams);break;case Pe.Visible:H(e,t);break;case Pe.Visibles:H(e,t,{multiple:!0});break;case Pe.Wait:ee(e,t,n.triggerParams,r)}})})},$=function(e,t){K(e,t.target,Pe.Click,"data-elb")},Y=function(e,t,n){t.addEventListener("mouseenter",u(function(t){_instanceof(t.target,Element)&&K(e,t.target,Pe.Hover,n)}))},z=function(e,t,n){K(e,t,Pe.Load,n)},Q=function(e,t){var n=arguments.length>3?arguments[3]:void 0;setInterval(function(){document.hidden||K(e,t,Pe.Pulse,n)},parseInt((arguments.length>2&&void 0!==arguments[2]?arguments[2]:"")||"")||15e3)},X=function(e){var t=parseInt((arguments.length>1&&void 0!==arguments[1]?arguments[1]:"")||"")||50;t<0||t>100||Ee.push([e,t])},Z=function(e,t){t.target&&K(e,t.target,Pe.Submit,"data-elb")},ee=function(e,t){var n=arguments.length>3?arguments[3]:void 0;setTimeout(function(){return K(e,t,Pe.Wait,n)},parseInt((arguments.length>2&&void 0!==arguments[2]?arguments[2]:"")||"")||15e3)},te=function(e,t){var n=function(e,t){return e.filter(function(e){var n=_sliced_to_array(e,2),r=n[0],o=n[1],i=window.scrollY+window.innerHeight,a=r.offsetTop;if(i<a)return!0;var c=r.clientHeight;return!(100*(1-(a+c-i)/(c||1))>=o)||(K(t,r,Pe.Scroll,"data-elb"),!1)})};je||(je=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,n=null;return function(){for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];if(null===n)return n=setTimeout(function(){n=null},t),e.apply(void 0,_to_consumable_array(o))}}(function(){Ee=n.call(t,Ee,e)}),t.addEventListener("scroll",je))},ne=function(e,t){var n=[],r=[];t.forEach(function(e){oe(e)?n.push(e):r.push(e)}),n.forEach(function(t){re(e,t)}),r.forEach(function(t){re(e,t)}),t.length=0},re=function(e,t){null!=t&&""!==t&&"number"!=typeof t&&"string"!=typeof t&&u(function(){if(ie(t)){var n=Array.from(t);if(n.length>=1){var r=_sliced_to_array(n,4),o=r[0],i=r[1],a=r[2],c=r[3];"string"==typeof o&&o.length>0&&T(e,o,i,a,c)}}else if("object"===(void 0===t?"undefined":_type_of(t))&&null!==t){if(0===Object.keys(t).length)return;T(e,t)}},function(){})()},oe=function(e){if(ie(e)){var t=Array.from(e);return"string"==typeof t[0]&&t[0].startsWith("walker ")}return!1},ie=function(e){return null!=e&&"object"===(void 0===e?"undefined":_type_of(e))&&"length"in e&&"number"==typeof e.length},ae=function(e){var t,r,o,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=i.config||{},c=n(e.config.sessionStatic||{},i.data||{}),s=(t=v,r="SessionStart",o=e.hooks,function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];var a,c="post"+r,s=o["pre"+r],u=o[c];return a=s?s.apply(void 0,[{fn:t}].concat(_to_consumable_array(n))):t.apply(void 0,_to_consumable_array(n)),u&&(a=u.apply(void 0,[{fn:t,result:a}].concat(_to_consumable_array(n)))),a})(_object_spread_props(_object_spread({},a),{cb:function(e,t,n){var r,o=a;return!1!==o.cb&&o.cb?r=o.cb(e,t,n):!1!==o.cb&&(r=n(e,t,n)),t&&(t.session=e,f(t,"session")),r},data:c,collector:e}));return s},ce=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).prefix||"data-elb";return function(t){var n=t,r={},i={},c={},s={},u={};function l(e){return Object.entries(e).map(function(e){var t=_sliced_to_array(e,2),n=t[0],r=t[1];return"".concat(n,":").concat(function(e){if(!o(e)||null===e)return"undefined";var t=String(e);return(t=(t=(t=t.replace(/\\/g,"\\\\")).replace(/;/g,"\\;")).replace(/:/g,"\\:")).replace(/'/g,"\\'")}(r))}).join(";")}var f={entity:function(e){return n=e,f},data:function(e,t){var o=null!=n?n:"";return r[o]||(r[o]={}),a(e)?r[o][e]=t:Object.assign(r[o],e),f},action:function(e,t){if(a(e))if(o(t))i[e]=t;else if(e.includes(":")){var n=_sliced_to_array(e.split(":",2),2),r=n[0],c=n[1];i[r]=c}else i[e]=e;else Object.assign(i,e);return f},context:function(e,t){return a(e)?c[e]=t:Object.assign(c,e),f},globals:function(e,t){return a(e)?s[e]=t:Object.assign(s,e),f},link:function(e,t){return a(e)?u[e]=t:Object.assign(u,e),f},get:function(){var t={};return n&&(t[e]=n),Object.entries(r).forEach(function(n){var r=_sliced_to_array(n,2),o=r[0],i=r[1];if(Object.keys(i).length>0){var a=o?"".concat(e,"-").concat(o):"".concat(e,"-");t[a]=l(i)}}),Object.keys(i).length>0&&(t["".concat(e,"action")]=l(i)),Object.keys(c).length>0&&(t["".concat(e,"context")]=l(c)),Object.keys(s).length>0&&(t["".concat(e,"globals")]=l(s)),Object.keys(u).length>0&&(t["".concat(e,"link")]=l(u)),t}};return f}},se=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,le=Object.getOwnPropertyNames,fe=Object.prototype.hasOwnProperty,de={};!function(e,t){for(var n in t)se(e,n,{get:t[n],enumerable:!0})}(de,{SourceBrowser:function(){return Ae},createTagger:function(){return ce},default:function(){return Ie},getAllEvents:function(){return k},getEvents:function(){return S},getGlobals:function(){return j},sourceBrowser:function(){return Le}});var pe,ve,ge=Object.getOwnPropertyNames,ye=(e={"package.json":function(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.7",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return t||(0,e[ge(e)[0]])((t={exports:{}}).exports,t),t.exports}),be={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}},_e={merge:!0,shallow:!0,extend:!0},me=(ye().version,Object.getOwnPropertyNames),he=(pe={"package.json":function(e,t){t.exports={name:"@walkeros/collector",description:"Unified platform-agnostic collector for walkerOS",version:"0.0.7",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{"@walkeros/core":"0.0.7"},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/collector"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","collector","event processing"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},{Commands:{Action:"action",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"},Utils:{Storage:{Cookie:"cookie",Local:"local",Session:"session"}}}),we=function(){var e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)},ke=function(e,t){var n=(null==t?void 0:t.push)||we,r={};return e.id&&(r.session=e.id),e.storage&&e.device&&(r.device=e.device),n("walker user",r),e.isStart&&n({event:"session start",data:e}),e};function Se(e,t,r,o){var i=d(t,h(e));if(!i||o&&!o[i])return null;var a=[t],c="[".concat(h(e,i),"],[").concat(h(e,""),"]"),s=h(e,he.Commands.Link,!1),u={},l=[],f=_sliced_to_array(E(r||t,c,e,i),2),p=f[0],v=f[1];P(t,"[".concat(s,"]"),function(t){var n=_sliced_to_array(I(d(t,s)),2),r=n[0];"parent"===n[1]&&P(document.body,"[".concat(s,'="').concat(r,':child"]'),function(t){a.push(t);var n=Se(e,t);n&&l.push(n)})});var g=[];a.forEach(function(e){e.matches(c)&&g.push(e),P(e,c,function(e){return g.push(e)})});var y={};return g.forEach(function(t){y=n(y,w(e,t,"")),u=n(u,w(e,t,i))}),u=n(n(y,u),p),a.forEach(function(t){P(t,"[".concat(h(e),"]"),function(t){var n=Se(e,t);n&&l.push(n)})}),{type:i,data:u,context:v,nested:l}}var je,Oe,xe=new WeakMap,Ce=new WeakMap,Ee=[],Pe={Click:"click",Custom:"custom",Hover:"hover",Load:"load",Pulse:"pulse",Scroll:"scroll",Submit:"submit",Visible:"visible",Visibles:"visibles",Wait:"wait"},Ae={},Le=function(e,t){return _async_to_generator(function(){var n,r,o,i,c,s,l;return _ts_generator(this,function(f){switch(f.label){case 0:return n=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.scope||document;return _object_spread_props(_object_spread({prefix:"data-elb",pageview:!0,session:!0,elb:"elb",name:"walkerjs",elbLayer:"elbLayer"},e),{scope:t})}(t.settings),r=_object_spread_props(_object_spread({},t),{settings:n}),o=n.scope,i={type:"browser",config:r,collector:e,destroy:function(){N(e)}},!1!==n.elbLayer&&function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).name||"elbLayer";window[t]||(window[t]=[]);var n=window[t];Array.isArray(n)&&n.length>0&&ne(e,n)}(e,{name:a(n.elbLayer)?n.elbLayer:"elbLayer"}),function(e,t){t.addEventListener("click",u(function(t){$.call(this,e,t)})),t.addEventListener("submit",u(function(t){Z.call(this,e,t)}))}(e,o),n.session&&(c="boolean"==typeof n.session?{}:n.session,ae(e,{config:c})),[4,J(q,e,n)];case 1:return f.sent(),s=e._destroy,e._destroy=function(){var e;null===(e=i.destroy)||void 0===e||e.call(i),s&&s()},l=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o=_sliced_to_array(n,6),i=o[0],a=o[1],c=o[2],s=o[3],u=o[4],l=o[5];return T(e,i,a,c,s,u,l)},[2,{source:i,elb:l}]}})})()},Ie=Le;return Oe=de,function(e,t,n,r){if(t&&"object"===(void 0===t?"undefined":_type_of(t))||"function"==typeof t){var o=!0,i=!1,a=void 0;try{for(var c,s=function(){var o=c.value;fe.call(e,o)||o===n||se(e,o,{get:function(){return t[o]},enumerable:!(r=ue(t,o))||r.enumerable})},u=le(t)[Symbol.iterator]();!(o=(c=u.next()).done);o=!0)s()}catch(e){i=!0,a=e}finally{try{o||null==u.return||u.return()}finally{if(i)throw a}}}return e}(se({},"__esModule",{value:!0}),Oe)}();
1
+ "use strict";function _array_like_to_array(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _array_with_holes(e){if(Array.isArray(e))return e}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function asyncGeneratorStep(e,t,r,n,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,o)}function _async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){asyncGeneratorStep(i,n,o,a,c,"next",e)}function c(e){asyncGeneratorStep(i,n,o,a,c,"throw",e)}a(void 0)})}}function _define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _instanceof(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterable_to_array_limit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i=[],a=!0,c=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(c)throw o}}return i}}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){_define_property(e,t,r[t])})}return e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function _sliced_to_array(e,t){return _array_with_holes(e)||_iterable_to_array_limit(e,t)||_unsupported_iterable_to_array(e,t)||_non_iterable_rest()}function _to_array(e){return _array_with_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_rest()}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,t){if(e){if("string"==typeof e)return _array_like_to_array(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_array_like_to_array(e,t):void 0}}function _ts_generator(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}var Source=function(){var e,t,r=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r=_object_spread({},me,r);var n=Object.entries(t).reduce(function(t,n){var o=_sliced_to_array(n,2),i=o[0],a=o[1],c=e[i];return r.merge&&Array.isArray(c)&&Array.isArray(a)?t[i]=a.reduce(function(e,t){return e.includes(t)?e:_to_consumable_array(e).concat([t])},_to_consumable_array(c)):(r.extend||i in e)&&(t[i]=a),t},{});return r.shallow?_object_spread({},e,n):(Object.assign(e,n),e)},n=function(e){return Array.isArray(e)},o=function(e){return void 0!==e},i=function(e){return e===document||_instanceof(e,Element)},a=function(e){return"object"==(void 0===e?"undefined":_type_of(e))&&null!==e&&!n(e)&&"[object Object]"===Object.prototype.toString.call(e)},c=function(e){return"string"==typeof e},s=function(e){if("true"===e)return!0;if("false"===e)return!1;var t=Number(e);return e==t&&""!==e?t:String(e)},u=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6,t="";t.length<e;)t+=(36*Math.random()|0).toString(36);return t},l=function(e,t,r){return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];try{return e.apply(void 0,_to_consumable_array(o))}catch(e){if(!t)return;return t(e)}finally{null==r||r()}}},f=function(e){return e?e.trim().replace(/^'|'$/g,"").trim():""},d=function(e,t,r,n){var o,i,a,c=r||[];if(r||(c=e.on[t]||[],Object.values(e.destinations).forEach(function(e){var r,n=null===(r=e.config.on)||void 0===r?void 0:r[t];n&&(c=c.concat(n))})),c.length)switch(t){case ke.Commands.Consent:o=e,i=c,a=n||o.consent,i.forEach(function(e){Object.keys(a).filter(function(t){return t in e}).forEach(function(t){l(e[t])(o,a)})});break;case ke.Commands.Ready:case ke.Commands.Run:!function(e,t){e.allowed&&t.forEach(function(t){l(t)(e)})}(e,c);break;case ke.Commands.Session:!function(e,t){e.session&&t.forEach(function(t){l(t)(e,e.session)})}(e,c)}},p=function(e,t){return(e.getAttribute(t)||"").trim()},v=function(e){var t,r=getComputedStyle(e);if("none"===r.display)return!1;if("visible"!==r.visibility)return!1;if(r.opacity&&Number(r.opacity)<.1)return!1;var n=window.innerHeight,o=e.getBoundingClientRect(),i=o.height,a=o.y,c=a+i,s={x:o.x+e.offsetWidth/2,y:o.y+e.offsetHeight/2};if(i<=n){if(e.offsetWidth+o.width===0||e.offsetHeight+o.height===0)return!1;if(s.x<0)return!1;if(s.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(s.y<0)return!1;if(s.y>(document.documentElement.clientHeight||window.innerHeight))return!1;t=document.elementFromPoint(s.x,s.y)}else{var u=n/2;if(a<0&&c<u)return!1;if(c>n&&a>u)return!1;t=document.elementFromPoint(s.x,n/2)}if(t)do{if(t===e)return!0}while(t=t.parentElement);return!1},g=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.cb,r=e.consent,i=e.collector,a=e.storage,c=(null==i?void 0:i.push)||Se;if(!r)return y((a?h:m)(e),i,t);var s,u,l,f=(s=e,u=t,function(e,t){if(!o(l)||l!==(null==e?void 0:e.group)){l=null==e?void 0:e.group;var r=function(){return m(s)};return s.consent&&function(e){var t=_object_spread({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}),r={},n=void 0===e;return Object.keys(t).forEach(function(o){t[o]&&(r[o]=!0,e&&e[o]&&(n=!0))}),!!n&&r}((n(s.consent)?s.consent:[s.consent]).reduce(function(e,t){return _object_spread_props(_object_spread({},e),_define_property({},t,!0))},{}),t)&&(r=function(){return h(s)}),y(r(),e,u)}});c("walker on","consent",(n(r)?r:[r]).reduce(function(e,t){return _object_spread_props(_object_spread({},e),_define_property({},t,f))},{}))},y=function(e,t,r){return!1===r?e:(r||(r=je),r(e,t,je))},_=function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:he.Utils.Storage.Session;function o(e){try{return JSON.parse(e||"")}catch(n){var t=1,r="";return e&&(t=0,r=e),{e:t,v:r}}}switch(n){case he.Utils.Storage.Cookie:var i;t=decodeURIComponent((null===(i=document.cookie.split("; ").find(function(t){return t.startsWith(e+"=")}))||void 0===i?void 0:i.split("=")[1])||"");break;case he.Utils.Storage.Local:r=o(window.localStorage.getItem(e));break;case he.Utils.Storage.Session:r=o(window.sessionStorage.getItem(e))}return r&&(t=r.v,0!=r.e&&r.e<Date.now()&&(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:he.Utils.Storage.Session;switch(t){case he.Utils.Storage.Cookie:b(e,"",0,t);break;case he.Utils.Storage.Local:window.localStorage.removeItem(e);break;case he.Utils.Storage.Session:window.sessionStorage.removeItem(e)}}(e,n),t="")),s(t||"")},b=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:30,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:he.Utils.Storage.Session,o=arguments.length>4?arguments[4]:void 0,i={e:Date.now()+6e4*r,v:String(t)},a=JSON.stringify(i);switch(n){case he.Utils.Storage.Cookie:t="object"==(void 0===t?"undefined":_type_of(t))?JSON.stringify(t):t;var c="".concat(e,"=").concat(encodeURIComponent(t),"; max-age=").concat(60*r,"; path=/; SameSite=Lax; secure");o&&(c+="; domain="+o),document.cookie=c;break;case he.Utils.Storage.Local:window.localStorage.setItem(e,a);break;case he.Utils.Storage.Session:window.sessionStorage.setItem(e,a)}return _(e,n)},h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Date.now(),r=e.length,n=void 0===r?30:r,o=e.deviceKey,i=void 0===o?"elbDeviceId":o,a=e.deviceStorage,c=void 0===a?"local":a,s=e.deviceAge,f=void 0===s?30:s,d=e.sessionKey,p=void 0===d?"elbSessionId":d,v=e.sessionStorage,g=void 0===v?"local":v,y=e.pulse,h=void 0!==y&&y,w=m(e),k=!1,S=l(function(e,t,r){var n=_(e,r);return n||(n=u(8),b(e,n,1440*t,r)),String(n)})(i,f,c),j=l(function(e,r){var o=JSON.parse(String(_(e,r)));return h||(o.isNew=!1,w.marketing&&(Object.assign(o,w),k=!0),k||o.updated+6e4*n<t?(delete o.id,delete o.referrer,o.start=t,o.count++,o.runs=1,k=!0):o.runs++),o},function(){k=!0})(p,g)||{},O={id:u(12),start:t,isNew:!0,count:1,runs:1},x=Object.assign(O,w,j,{device:S},{isStart:k,storage:!0,updated:t},e.data);return b(p,JSON.stringify(x),2*n,g),x},m=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.isStart||!1,n={isStart:t,storage:!1};if(!1===e.isStart)return n;if(!t&&"navigate"!==_sliced_to_array(performance.getEntriesByType("navigation"),1)[0].type)return n;var o=new URL(e.url||window.location.href),i=e.referrer||document.referrer,a=i&&new URL(i).hostname,c=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="clickId",o={},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(r(i,t)).forEach(function(t){var r=_sliced_to_array(t,2),i=r[0],a=r[1],c=e.searchParams.get(i);c&&(a===n&&(a=i,o[n]=i),o[a]=c)}),o}(o,e.parameters);if(Object.keys(c).length&&(c.marketing||(c.marketing=!0),t=!0),!t){var s=e.domains||[];s.push(o.hostname),t=!s.includes(a)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:u(12),referrer:a},c,e.data):n},w=function(e,t){return e+(t=null!=t?(!(arguments.length>2&&void 0!==arguments[2])||arguments[2]?"-":"")+t:"")},k=function(e,t,r){var o=p(t,w(e,r,!(arguments.length>3&&void 0!==arguments[3])||arguments[3]))||"";return I(o).reduce(function(e,r){var o=_sliced_to_array(U(r),2),i=o[0],a=o[1];if(!i)return e;if(a||(i.endsWith(":")&&(i=i.slice(0,-1)),a=""),a.startsWith("#")){a=a.slice(1);try{var c=t[a];c||"selected"!==a||(c=t.options[t.selectedIndex].text),a=String(c)}catch(e){a=""}}return i.endsWith("[]")?(i=i.slice(0,-2),n(e[i])||(e[i]=[]),e[i].push(s(a))):e[i]=s(a),e},{})},S=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ke.Commands.Prefix,r=[],n=ke.Commands.Action,o="[".concat(w(t,n,!1),"]"),i=function(e){Object.keys(k(t,e,n,!1)).forEach(function(n){r=r.concat(j(e,n,t))})};return e!==document&&e.matches(o)&&i(e),P(e,o,i),r},j=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ke.Commands.Prefix,n=[],o=L(r,e,t);return o?(o.forEach(function(o){var i=I(o.actionParams||"",",").reduce(function(e,t){return e[f(t)]=!0,e},{}),a=C(r,e,i);if(!a.length){var c="page",s="[".concat(w(r,c),"]"),u=_sliced_to_array(E(e,s,r,c),2),l=u[0],d=u[1];a.push({type:c,data:l,nested:[],context:d})}a.forEach(function(e){n.push({entity:e.type,action:o.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),n):n},O=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ke.Commands.Prefix,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document,n=w(e,ke.Commands.Globals,!1),o="[".concat(n,"]"),i={};return P(t,o,function(t){i=r(i,k(e,t,ke.Commands.Globals,!1))}),i},x=function(e){var t={};return I(e).forEach(function(e){var r=_sliced_to_array(U(e),2),n=r[0],o=r[1],i=_sliced_to_array(W(n),2),a=i[0],c=i[1];if(a){var s=_sliced_to_array(W(o||""),2),u=s[0],l=s[1];u=u||a,t[a]||(t[a]=[]),t[a].push({trigger:a,triggerParams:c,action:u,actionParams:l})}}),t},C=function(e,t,r){var n=[],o=t;for(r=0!==Object.keys(r||{}).length?r:void 0;o;){var i=Oe(e,o,t,r);i&&n.push(i),o=A(e,o)}return n},A=function(e,t){var r=w(e,ke.Commands.Link,!1);if(t.matches("[".concat(r,"]"))){var n=_sliced_to_array(U(p(t,r)),2),o=n[0];if("child"===n[1])return document.querySelector("[".concat(r,'="').concat(o,':parent"]'))}return!t.parentElement&&t.getRootNode&&_instanceof(t.getRootNode(),ShadowRoot)?t.getRootNode().host:t.parentElement},E=function(e,t,n,o){for(var i={},a={},c=e,s="[".concat(w(n,ke.Commands.Context,!1),"]"),u=0;c;)c.matches(t)&&(i=r(k(n,c,""),i),i=r(k(n,c,o),i)),c.matches(s)&&(Object.entries(k(n,c,ke.Commands.Context,!1)).forEach(function(e){var t=_sliced_to_array(e,2),r=t[0],n=t[1];n&&!a[r]&&(a[r]=[n,u])}),++u),c=A(n,c);return[i,a]},P=function(e,t,r){e.querySelectorAll(t).forEach(r)},L=function(e,t,r){for(var n=t;n;){var o=p(n,w(e,ke.Commands.Action,!1)),i=x(o);if(i[r]||"click"!==r)return i[r];n=A(e,n)}return[]},I=function(e){if(!e)return[];var t=new RegExp("(?:[^".concat(arguments.length>1&&void 0!==arguments[1]?arguments[1]:";","']+|'[^']*')+"),"ig");return e.match(t)||[]},U=function(e){var t=_sliced_to_array(e.split(/:(.+)/,2),2),r=t[0],n=t[1];return[f(r),f(n)]},W=function(e){var t=_sliced_to_array(e.split("(",2),2),r=t[0],n=t[1];return[r,n?n.slice(0,-1):""]},D=function(e){var t=Date.now(),r=Ee.get(e);return(!r||t-r.lastChecked>500)&&(r={isVisible:v(e),lastChecked:t},Ee.set(e,r)),r.isVisible},R=function(e){if(window.IntersectionObserver)return l(function(){return new window.IntersectionObserver(function(t){t.forEach(function(t){H(e,t)})},{rootMargin:"0px",threshold:[0,.5]})},function(){})()},H=function(e,t){var r,n=t.target,o=e._visibilityState;if(o){var i=o.timers.get(n);if(t.intersectionRatio>0){var a=Date.now(),c=Ae.get(n);if((!c||a-c.lastChecked>1e3)&&(c={isLarge:n.offsetHeight>window.innerHeight,lastChecked:a},Ae.set(n,c)),t.intersectionRatio>=.5||c.isLarge&&D(n)){var s,u=null===(s=o.elementConfigs)||void 0===s?void 0:s.get(n);if((null==u?void 0:u.multiple)&&u.blocked)return;if(!i){var l=window.setTimeout(function(){return _async_to_generator(function(){var t,r,i,a,c;return _ts_generator(this,function(s){switch(s.label){case 0:return D(n)?(i=null===(t=o.elementConfigs)||void 0===t?void 0:t.get(n),a=(null==i?void 0:i.prefix)||"data-elb",[4,q(e,a,n,Ie.Visible)]):[3,2];case 1:s.sent(),(null==(c=null===(r=o.elementConfigs)||void 0===r?void 0:r.get(n))?void 0:c.multiple)?c.blocked=!0:function(e,t){var r=e._visibilityState;if(r){r.observer&&r.observer.unobserve(t);var n=r.timers.get(t);n&&(clearTimeout(n),r.timers.delete(t)),Ae.delete(t),Ee.delete(t)}}(e,n),s.label=2;case 2:return[2]}})})()},o.duration);o.timers.set(n,l)}return}}i&&(clearTimeout(i),o.timers.delete(n));var f=null===(r=o.elementConfigs)||void 0===r?void 0:r.get(n);(null==f?void 0:f.multiple)&&(f.blocked=!1)}},N=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{multiple:!1},o=e._visibilityState;(null==o?void 0:o.observer)&&t&&(o.elementConfigs||(o.elementConfigs=new WeakMap),o.elementConfigs.set(t,{multiple:null!==(r=n.multiple)&&void 0!==r&&r,blocked:!1,prefix:n.prefix||"data-elb"}),o.observer.observe(t))},T=function(e){var t=e._visibilityState;t&&(t.observer&&t.observer.disconnect(),delete e._visibilityState)},M=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"data-elb",r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0,u=arguments.length>6?arguments[6]:void 0,l=arguments.length>7?arguments[7]:void 0;if(c(r)&&r.startsWith("walker "))return e.push(r,n);if(a(r)){var f=r;return f.source||(f.source=G()),e.push(f)}var d,p=_sliced_to_array(String(a(r)?r.event:r).split(" "),1)[0],v=a(n)?n:{},g={},y=!1;if(i(n)&&(d=n,y=!0),i(s)?d=s:a(s)&&Object.keys(s).length&&(g=s),d){var _=C(t,d).find(function(e){return e.type===p});_&&(y&&(v=_.data),g=_.context)}"page"===p&&(v.id=v.id||window.location.pathname);var b={event:String(r||""),data:v,context:g,nested:u,custom:l,trigger:c(o)?o:"",timing:Math.round((performance.now()-Pe)/10)/100,source:G()};return e.push(b)},G=function(){return{type:"browser",id:window.location.href,previous_id:document.referrer}},V=function(e,t,r){return _async_to_generator(function(){var n;return _ts_generator(this,function(o){return n=function(){if(e(t,r),null==t?void 0:t.on)try{d(t,"ready")}catch(e){}},"loading"!==document.readyState?n():document.addEventListener("DOMContentLoaded",n),[2]})})()},J=function(e,t){var r=t.scope,n=t.prefix;B(e,r,n)},B=function(e,t,r){t.addEventListener("click",l(function(t){$.call(this,e,t,r)})),t.addEventListener("submit",l(function(t){Z.call(this,e,t,r)}))},K=function(e,t,r){Le=[],T(e),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;e._visibilityState||(e._visibilityState={observer:R(e),timers:new WeakMap,duration:t})}(e,1e3);var n=w(t,ke.Commands.Action,!1),o=r||document;o!==document&&F(e,o,n,t),o.querySelectorAll("[".concat(n,"]")).forEach(function(r){F(e,r,n,t)}),Le.length&&te(e,o,t)},q=function(e,t,r,n){return _async_to_generator(function(){var o;return _ts_generator(this,function(i){return o=j(r,n,t),[2,Promise.all(o.map(function(r){return M(e,t,_object_spread_props(_object_spread({event:"".concat(r.entity," ").concat(r.action)},r),{trigger:n}))}))]})})()},F=function(e,t,r,n){var o=p(t,r);o&&Object.values(x(o)).forEach(function(r){return r.forEach(function(r){switch(r.trigger){case Ie.Hover:Y(e,t,n);break;case Ie.Load:z(e,t,n);break;case Ie.Pulse:Q(e,t,r.triggerParams,n);break;case Ie.Scroll:X(t,r.triggerParams);break;case Ie.Visible:N(e,t,{prefix:n});break;case Ie.Visibles:N(e,t,{multiple:!0,prefix:n});break;case Ie.Wait:ee(e,t,r.triggerParams,n)}})})},$=function(e,t,r){q(e,r,t.target,Ie.Click)},Y=function(e,t,r){t.addEventListener("mouseenter",l(function(t){_instanceof(t.target,Element)&&q(e,r,t.target,Ie.Hover)}))},z=function(e,t,r){q(e,r,t,Ie.Load)},Q=function(e,t){var r=arguments.length>3?arguments[3]:void 0;setInterval(function(){document.hidden||q(e,r,t,Ie.Pulse)},parseInt((arguments.length>2&&void 0!==arguments[2]?arguments[2]:"")||"")||15e3)},X=function(e){var t=parseInt((arguments.length>1&&void 0!==arguments[1]?arguments[1]:"")||"")||50;t<0||t>100||Le.push([e,t])},Z=function(e,t,r){t.target&&q(e,r,t.target,Ie.Submit)},ee=function(e,t){var r=arguments.length>3?arguments[3]:void 0;setTimeout(function(){return q(e,r,t,Ie.Wait)},parseInt((arguments.length>2&&void 0!==arguments[2]?arguments[2]:"")||"")||15e3)},te=function(e,t,r){var n=function(e,t,r){return e.filter(function(e){var n=_sliced_to_array(e,2),o=n[0],i=n[1],a=window.scrollY+window.innerHeight,c=o.offsetTop;if(a<c)return!0;var s=o.clientHeight;return!(100*(1-(c+s-a)/(s||1))>=i)||(q(t,r,o,Ie.Scroll),!1)})};xe||(xe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,r=null;return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];if(null===r)return r=setTimeout(function(){r=null},t),e.apply(void 0,_to_consumable_array(o))}}(function(){Le=n.call(t,Le,e,r)}),t.addEventListener("scroll",xe))},re=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"data-elb",r=arguments.length>2?arguments[2]:void 0;ne(e,t,r,!0),ne(e,t,r,!1),r.length=0},ne=function(e,t,r,n){var o=[],i=!0;r.forEach(function(e){var t=ie(e)?_to_consumable_array(Array.from(e)):ae(e)?Array.from(e):[e];if((!Array.isArray(t)||0!==t.length)&&(!Array.isArray(t)||1!==t.length||t[0])){var r=t[0],s=!a(r)&&c(r)&&r.startsWith("walker ");if(a(r)){if("object"===(void 0===r?"undefined":_type_of(r))&&0===Object.keys(r).length)return}else{var u=Array.from(t);if(!c(u[0])||""===u[0].trim())return;i&&"walker run"===u[0]&&(i=!1)}(n&&s||!n&&!s)&&o.push(t)}}),o.forEach(function(r){oe(e,t,r)})},oe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"data-elb",r=arguments.length>2?arguments[2]:void 0;l(function(){if(Array.isArray(r)){var n=_to_array(r),o=n[0],i=n.slice(1);if(!o||c(o)&&""===o.trim())return;if(c(o)&&o.startsWith("walker "))return void e.push(o,i[0]);M.apply(void 0,[e,t,o].concat(_to_consumable_array(i)))}else if(r&&"object"===(void 0===r?"undefined":_type_of(r))){if(0===Object.keys(r).length)return;e.push(r)}},function(){})()},ie=function(e){return null!=e&&"object"===(void 0===e?"undefined":_type_of(e))&&"[object Arguments]"===Object.prototype.toString.call(e)},ae=function(e){return null!=e&&"object"===(void 0===e?"undefined":_type_of(e))&&"length"in e&&"number"==typeof e.length},ce=function(e){var t,n,o,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=i.config||{},c=r(e.config.sessionStatic||{},i.data||{}),s=(t=g,n="SessionStart",o=e.hooks,function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];var a,c="post"+n,s=o["pre"+n],u=o[c];return a=s?s.apply(void 0,[{fn:t}].concat(_to_consumable_array(r))):t.apply(void 0,_to_consumable_array(r)),u&&(a=u.apply(void 0,[{fn:t,result:a}].concat(_to_consumable_array(r)))),a})(_object_spread_props(_object_spread({},a),{cb:function(e,t,r){var n,o=a;return!1!==o.cb&&o.cb?n=o.cb(e,t,r):!1!==o.cb&&(n=r(e,t,r)),t&&(t.session=e,d(t,"session")),n},data:c,collector:e}));return s},se=function(){return _object_spread({prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:document},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})},ue=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).prefix||"data-elb";return function(t){var r=void 0,n=t,i={},a={},s={},u={},l={};function f(e){return Object.entries(e).map(function(e){var t=_sliced_to_array(e,2),r=t[0],n=t[1];return"".concat(r,":").concat(function(e){if(!o(e)||null===e)return"undefined";var t=String(e);return(t=(t=(t=t.replace(/\\/g,"\\\\")).replace(/;/g,"\\;")).replace(/:/g,"\\:")).replace(/'/g,"\\'")}(n))}).join(";")}var d={entity:function(e){return r=e,n=e,d},data:function(e,t){var r=null!=n?n:"";return i[r]||(i[r]={}),c(e)?i[r][e]=t:Object.assign(i[r],e),d},action:function(e,t){if(c(e))if(o(t))a[e]=t;else if(e.includes(":")){var r=_sliced_to_array(e.split(":",2),2),n=r[0],i=r[1];a[n]=i}else a[e]=e;else Object.assign(a,e);return d},context:function(e,t){return c(e)?s[e]=t:Object.assign(s,e),d},globals:function(e,t){return c(e)?u[e]=t:Object.assign(u,e),d},link:function(e,t){return c(e)?l[e]=t:Object.assign(l,e),d},get:function(){var t={};return r&&(t[e]=r),Object.entries(i).forEach(function(r){var n=_sliced_to_array(r,2),o=n[0],i=n[1];if(Object.keys(i).length>0){var a=o?"".concat(e,"-").concat(o):"".concat(e,"-");t[a]=f(i)}}),Object.keys(a).length>0&&(t["".concat(e,"action")]=f(a)),Object.keys(s).length>0&&(t["".concat(e,"context")]=f(s)),Object.keys(u).length>0&&(t["".concat(e,"globals")]=f(u)),Object.keys(l).length>0&&(t["".concat(e,"link")]=f(l)),t}};return d}},le=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,de=Object.getOwnPropertyNames,pe=Object.prototype.hasOwnProperty,ve={};!function(e,t){for(var r in t)le(e,r,{get:t[r],enumerable:!0})}(ve,{SourceBrowser:function(){return Ue},createTagger:function(){return ue},default:function(){return De},getAllEvents:function(){return S},getEvents:function(){return j},getGlobals:function(){return O},sourceBrowser:function(){return We}});var ge,ye,_e=Object.getOwnPropertyNames,be=(e={"package.json":function(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.8",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return t||(0,e[_e(e)[0]])((t={exports:{}}).exports,t),t.exports}),he={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}},me={merge:!0,shallow:!0,extend:!0},we=(be().version,Object.getOwnPropertyNames),ke=(ge={"package.json":function(e,t){t.exports={name:"@walkeros/collector",description:"Unified platform-agnostic collector for walkerOS",version:"0.0.8",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{"@walkeros/core":"0.0.8"},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/collector"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","collector","event processing"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},{Commands:{Action:"action",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"},Utils:{Storage:{Cookie:"cookie",Local:"local",Session:"session"}}}),Se=function(){var e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)},je=function(e,t){var r=(null==t?void 0:t.push)||Se,n={};return e.id&&(n.session=e.id),e.storage&&e.device&&(n.device=e.device),r("walker user",n),e.isStart&&r({event:"session start",data:e}),e};function Oe(e,t,n,o){var i=p(t,w(e));if(!i||o&&!o[i])return null;var a=[t],c="[".concat(w(e,i),"],[").concat(w(e,""),"]"),s=w(e,ke.Commands.Link,!1),u={},l=[],f=_sliced_to_array(E(n||t,c,e,i),2),d=f[0],v=f[1];P(t,"[".concat(s,"]"),function(t){var r=_sliced_to_array(U(p(t,s)),2),n=r[0];"parent"===r[1]&&P(document.body,"[".concat(s,'="').concat(n,':child"]'),function(t){a.push(t);var r=Oe(e,t);r&&l.push(r)})});var g=[];a.forEach(function(e){e.matches(c)&&g.push(e),P(e,c,function(e){return g.push(e)})});var y={};return g.forEach(function(t){y=r(y,k(e,t,"")),u=r(u,k(e,t,i))}),u=r(r(y,u),d),a.forEach(function(t){P(t,"[".concat(w(e),"]"),function(t){var r=Oe(e,t);r&&l.push(r)})}),{type:i,data:u,context:v,nested:l}}var xe,Ce,Ae=new WeakMap,Ee=new WeakMap,Pe=performance.now(),Le=[],Ie={Click:"click",Custom:"custom",Hover:"hover",Load:"load",Pulse:"pulse",Scroll:"scroll",Submit:"submit",Visible:"visible",Visibles:"visibles",Wait:"wait"},Ue={},We=function(e,t){return _async_to_generator(function(){var r,n,o,i,a,s;return _ts_generator(this,function(u){switch(u.label){case 0:return u.trys.push([0,3,,4]),r=_object_spread_props(_object_spread({},t),{settings:se(t.settings)}),n={type:"browser",config:r,collector:e,destroy:function(){T(e)}},!1!==r.settings.elbLayer&&function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.name||"elbLayer";window[r]||(window[r]=[]);var n=window[r];n.push=function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];if(ie(n[0])){var i=_to_consumable_array(Array.from(n[0])),a=Array.prototype.push.apply(this,[i]);return oe(e,t.prefix,i),a}var c=Array.prototype.push.apply(this,n);return n.forEach(function(r){oe(e,t.prefix,r)}),c},Array.isArray(n)&&n.length>0&&re(e,t.prefix,n)}(e,{name:c(r.settings.elbLayer)?r.settings.elbLayer:"elbLayer",prefix:r.settings.prefix}),r.settings.session&&(o="boolean"==typeof r.settings.session?{}:r.settings.session,ce(e,{config:o})),[4,V(J,e,r.settings)];case 1:return u.sent(),i=function(e){if(function(e,t){var r=t.prefix,n=t.scope;K(e,r,n)}(e,r.settings),r.settings.pageview){var t=_sliced_to_array(function(e,t){var r=window.location,n="page",o=t===document?document.body:t,i=_sliced_to_array(E(o,"[".concat(w(e,n),"]"),e,n),2),a=i[0],c=i[1];return a.domain=r.hostname,a.title=document.title,a.referrer=document.referrer,r.search&&(a.search=r.search),r.hash&&(a.hash=r.hash),[a,c]}(r.settings.prefix||"data-elb",r.settings.scope),2),n=t[0],o=t[1];M(e,"page view",n,Ie.Load,o)}},[4,e.push("walker on","run",i)];case 2:return u.sent(),a=e._destroy,e._destroy=function(){var e;null===(e=n.destroy)||void 0===e||e.call(n),a&&a()},s=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=_sliced_to_array(n,6),a=i[0],c=i[1],s=i[2],u=i[3],l=i[4],f=i[5];return M(e,r.settings.prefix,a,c,s,u,l,f)},c(r.settings.elb)&&(window[r.settings.elb]=s),[2,{source:n,elb:s}];case 3:throw u.sent();case 4:return[2]}})})()},De=We;return Ce=ve,function(e,t,r,n){if(t&&"object"===(void 0===t?"undefined":_type_of(t))||"function"==typeof t){var o=!0,i=!1,a=void 0;try{for(var c,s=function(){var o=c.value;pe.call(e,o)||o===r||le(e,o,{get:function(){return t[o]},enumerable:!(n=fe(t,o))||n.enumerable})},u=de(t)[Symbol.iterator]();!(o=(c=u.next()).done);o=!0)s()}catch(e){i=!0,a=e}finally{try{o||null==u.return||u.return()}finally{if(i)throw a}}}return e}(le({},"__esModule",{value:!0}),Ce)}();
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t,n,r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})(c,{SourceBrowser:()=>ae,createTagger:()=>le,default:()=>fe,getAllEvents:()=>x,getEvents:()=>E,getGlobals:()=>$,sourceBrowser:()=>ue}),module.exports=(e=c,((e,t,n,c)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of s(t))i.call(e,a)||a===n||r(e,a,{get:()=>t[a],enumerable:!(c=o(t,a))||c.enumerable});return e})(r({},"__esModule",{value:!0}),e));var a=Object.getOwnPropertyNames,l=(t={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.7",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return n||(0,t[a(t)[0]])((n={exports:{}}).exports,n),n.exports}),u={merge:!0,shallow:!0,extend:!0};function f(e,t={},n={}){n={...u,...n};const r=Object.entries(t).reduce((t,[r,o])=>{const s=e[r];return n.merge&&Array.isArray(s)&&Array.isArray(o)?t[r]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...s]):(n.extend||r in e)&&(t[r]=o),t},{});return n.shallow?{...e,...r}:(Object.assign(e,r),e)}function d(e){return Array.isArray(e)}function b(e){return void 0!==e}function g(e){return"object"==typeof e&&null!==e&&!d(e)&&"[object Object]"===Object.prototype.toString.call(e)}function p(e){return"string"==typeof e}function m(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}var{version:h}=l();function y(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function w(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}var k=require("@walkeros/collector"),v=require("@walkeros/web-core"),C=require("@walkeros/collector"),j=require("@walkeros/web-core");function O(e,t,n=!0){return e+(t=null!=t?(n?"-":"")+t:"")}function S(e,t,n,r=!0){return q((0,j.getAttribute)(t,O(e,n,r))||"").reduce((e,n)=>{let[r,o]=H(n);if(!r)return e;if(o||(r.endsWith(":")&&(r=r.slice(0,-1)),o=""),o.startsWith("#")){o=o.slice(1);try{let e=t[o];e||"selected"!==o||(e=t.options[t.selectedIndex].text),o=String(e)}catch(e){o=""}}return r.endsWith("[]")?(r=r.slice(0,-2),d(e[r])||(e[r]=[]),e[r].push(m(o))):e[r]=m(o),e},{})}function x(e=document.body,t=C.Const.Commands.Prefix){let n=[];const r=C.Const.Commands.Action,o=`[${O(t,r,!1)}]`,s=e=>{Object.keys(S(t,e,r,!1)).forEach(r=>{n=n.concat(E(e,r,t))})};return e!==document&&e.matches(o)&&s(e),W(e,o,s),n}function E(e,t,n=C.Const.Commands.Prefix){const r=[],o=function(e,t,n){let r=t;for(;r;){const t=A((0,j.getAttribute)(r,O(e,C.Const.Commands.Action,!1)));if(t[n]||"click"!==n)return t[n];r=P(e,r)}return[]}(n,e,t);return o?(o.forEach(o=>{const s=q(o.actionParams||"",",").reduce((e,t)=>(e[w(t)]=!0,e),{}),i=function(e,t,n){const r=[];let o=t;n=0!==Object.keys(n||{}).length?n:void 0;for(;o;){const s=L(e,o,t,n);s&&r.push(s),o=P(e,o)}return r}(n,e,s);if(!i.length){const t="page",r=`[${O(n,t)}]`,[o,s]=_(e,r,n,t);i.push({type:t,data:o,nested:[],context:s})}i.forEach(e=>{r.push({entity:e.type,action:o.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),r):r}function $(e=C.Const.Commands.Prefix,t=document){const n=O(e,C.Const.Commands.Globals,!1);let r={};return W(t,`[${n}]`,t=>{r=f(r,S(e,t,C.Const.Commands.Globals,!1))}),r}function A(e){const t={};return q(e).forEach(e=>{const[n,r]=H(e),[o,s]=I(n);if(!o)return;let[i,c]=I(r||"");i=i||o,t[o]||(t[o]=[]),t[o].push({trigger:o,triggerParams:s,action:i,actionParams:c})}),t}function L(e,t,n,r){const o=(0,j.getAttribute)(t,O(e));if(!o||r&&!r[o])return null;const s=[t],i=`[${O(e,o)}],[${O(e,"")}]`,c=O(e,C.Const.Commands.Link,!1);let a={};const l=[],[u,d]=_(n||t,i,e,o);W(t,`[${c}]`,t=>{const[n,r]=H((0,j.getAttribute)(t,c));"parent"===r&&W(document.body,`[${c}="${n}:child"]`,t=>{s.push(t);const n=L(e,t);n&&l.push(n)})});const b=[];s.forEach(e=>{e.matches(i)&&b.push(e),W(e,i,e=>b.push(e))});let g={};return b.forEach(t=>{g=f(g,S(e,t,"")),a=f(a,S(e,t,o))}),a=f(f(g,a),u),s.forEach(t=>{W(t,`[${O(e)}]`,t=>{const n=L(e,t);n&&l.push(n)})}),{type:o,data:a,context:d,nested:l}}function P(e,t){const n=O(e,C.Const.Commands.Link,!1);if(t.matches(`[${n}]`)){const[e,r]=H((0,j.getAttribute)(t,n));if("child"===r)return document.querySelector(`[${n}="${e}:parent"]`)}return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof ShadowRoot?t.getRootNode().host:t.parentElement}function _(e,t,n,r){let o={};const s={};let i=e;const c=`[${O(n,C.Const.Commands.Context,!1)}]`;let a=0;for(;i;)i.matches(t)&&(o=f(S(n,i,""),o),o=f(S(n,i,r),o)),i.matches(c)&&(Object.entries(S(n,i,C.Const.Commands.Context,!1)).forEach(([e,t])=>{t&&!s[e]&&(s[e]=[t,a])}),++a),i=P(n,i);return[o,s]}function W(e,t,n){e.querySelectorAll(t).forEach(n)}function q(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function H(e){const[t,n]=e.split(/:(.+)/,2);return[w(t),w(n)]}function I(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var M=require("@walkeros/web-core"),T=new WeakMap,V=new WeakMap;function R(e){const t=Date.now();let n=V.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:(0,M.isVisible)(e),lastChecked:t},V.set(e,n)),n.isVisible}function N(e){if(window.IntersectionObserver)return y(()=>new window.IntersectionObserver(t=>{t.forEach(t=>{!function(e,t){var n,r;const o=t.target,s=e._visibilityState;if(!s)return;const i=s.timers.get(o);if(t.intersectionRatio>0){const r=Date.now();let c=T.get(o);(!c||r-c.lastChecked>1e3)&&(c={isLarge:o.offsetHeight>window.innerHeight,lastChecked:r},T.set(o,c));if(t.intersectionRatio>=.5||c.isLarge&&R(o)){const t=null==(n=s.elementConfigs)?void 0:n.get(o);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!i){const t=window.setTimeout(async()=>{var t;if(R(o)){await Z(e,o,Q.Visible,"data-elb");const n=null==(t=s.elementConfigs)?void 0:t.get(o);(null==n?void 0:n.multiple)?n.blocked=!0:function(e,t){const n=e._visibilityState;if(!n)return;n.observer&&n.observer.unobserve(t);const r=n.timers.get(t);r&&(clearTimeout(r),n.timers.delete(t)),T.delete(t),V.delete(t)}(e,o)}},s.duration);s.timers.set(o,t)}return}}i&&(clearTimeout(i),s.timers.delete(o));const c=null==(r=s.elementConfigs)?void 0:r.get(o);(null==c?void 0:c.multiple)&&(c.blocked=!1)}(e,t)})},{rootMargin:"0px",threshold:[0,.5]}),()=>{})()}function D(e,t,n={multiple:!1}){var r;const o=e._visibilityState;(null==o?void 0:o.observer)&&t&&(o.elementConfigs||(o.elementConfigs=new WeakMap),o.elementConfigs.set(t,{multiple:null!=(r=n.multiple)&&r,blocked:!1}),o.observer.observe(t))}function G(e){const t=e._visibilityState;t&&(t.observer&&t.observer.disconnect(),delete e._visibilityState)}function B(e,t,n,r,o,s,i){if(p(t)&&t.startsWith("walker ")){if("walker config"===t)return e.push("walker config",n);if("walker consent"===t)return e.push("walker consent",n);if("walker user"===t)return e.push("walker user",n);if("walker run"===t)return e.push("walker run",n)}if(g(t)){const n=t;return n.source||(n.source=F()),e.push(n)}if(p(t)&&t.length>0){const c={event:t,data:Y(n||{}),context:z(o||{}),custom:i,nested:s,source:F()};return p(r)&&(c.trigger=r),e.push(c)}if(!b(t))return Promise.resolve({ok:!0,successful:[],queued:[],failed:[]});const c={event:String(t||""),data:Y(n||{}),context:z(o||{}),custom:i,nested:s,source:F()};return p(r)&&(c.trigger=r),e.push(c)}function Y(e){return e?typeof e==typeof{}?e:{}:{}}function z(e){return e?(t=e)===document||t instanceof Element?{}:g(e)&&Object.keys(e).length?e:{}:{};var t}function F(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var J,K=[],Q={Click:"click",Custom:"custom",Hover:"hover",Load:"load",Pulse:"pulse",Scroll:"scroll",Submit:"submit",Visible:"visible",Visibles:"visibles",Wait:"wait"};function U(e,t){const{prefix:n,scope:r,pageview:o}=t;if(o){const[t,o]=function(e,t){const n=window.location,r="page",o=t===document?document.body:t,[s,i]=_(o,`[${O(e,r)}]`,e,r);return s.domain=n.hostname,s.title=document.title,s.referrer=document.referrer,n.search&&(s.search=n.search),n.hash&&(s.hash=n.hash),[s,i]}(n,r);B(e,"page view",t,Q.Load,o)}!function(e,t,n){K=[],G(e),function(e,t=1e3){e._visibilityState||(e._visibilityState={observer:N(e),timers:new WeakMap,duration:t})}(e,1e3);const r=O(t,k.Const.Commands.Action,!1),o=n||document;o!==document&&ee(e,o,r,t);o.querySelectorAll(`[${r}]`).forEach(n=>ee(e,n,r,t)),K.length&&function(e,t){const n=(e,t)=>e.filter(([e,n])=>{const r=window.scrollY+window.innerHeight,o=e.offsetTop;if(r<o)return!0;const s=e.clientHeight;return!(100*(1-(o+s-r)/(s||1))>=n)||(Z(t,e,Q.Scroll,"data-elb"),!1)});J||(J=function(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}(function(){K=n.call(t,K,e)}),t.addEventListener("scroll",J))}(e,o)}(e,n,r)}function X(e,t){t.addEventListener("click",y(function(t){te.call(this,e,t)})),t.addEventListener("submit",y(function(t){ne.call(this,e,t)}))}async function Z(e,t,n,r){const o=E(t,n,r);return Promise.all(o.map(t=>B(e,{event:`${t.entity} ${t.action}`,...t,trigger:n})))}function ee(e,t,n,r){const o=(0,v.getAttribute)(t,n);o&&Object.values(A(o)).forEach(n=>n.forEach(n=>{switch(n.trigger){case Q.Hover:!function(e,t,n){t.addEventListener("mouseenter",y(function(t){t.target instanceof Element&&Z(e,t.target,Q.Hover,n)}))}(e,t,r);break;case Q.Load:!function(e,t,n){Z(e,t,Q.Load,n)}(e,t,r);break;case Q.Pulse:!function(e,t,n="",r){setInterval(()=>{document.hidden||Z(e,t,Q.Pulse,r)},parseInt(n||"")||15e3)}(e,t,n.triggerParams,r);break;case Q.Scroll:!function(e,t=""){const n=parseInt(t||"")||50;if(n<0||n>100)return;K.push([e,n])}(t,n.triggerParams);break;case Q.Visible:D(e,t);break;case Q.Visibles:D(e,t,{multiple:!0});break;case Q.Wait:!function(e,t,n="",r){setTimeout(()=>Z(e,t,Q.Wait,r),parseInt(n||"")||15e3)}(e,t,n.triggerParams,r)}}))}function te(e,t){Z(e,t.target,Q.Click,"data-elb")}function ne(e,t){t.target&&Z(e,t.target,Q.Submit,"data-elb")}function re(e,t={}){const n=t.name||"elbLayer";window[n]||(window[n]=[]);const r=window[n];Array.isArray(r)&&r.length>0&&function(e,t){const n=[],r=[];t.forEach(e=>{!function(e){if(se(e)){const t=Array.from(e);return"string"==typeof t[0]&&t[0].startsWith("walker ")}return!1}(e)?r.push(e):n.push(e)}),n.forEach(t=>{oe(e,t)}),r.forEach(t=>{oe(e,t)}),t.length=0}(e,r)}function oe(e,t){null!=t&&""!==t&&"number"!=typeof t&&"string"!=typeof t&&y(()=>{if(se(t)){const n=Array.from(t);if(n.length>=1){const[t,r,o,s]=n;"string"==typeof t&&t.length>0&&B(e,t,r,o,s)}}else if("object"==typeof t&&null!==t){if(0===Object.keys(t).length)return;B(e,t)}},()=>{})()}function se(e){return null!=e&&"object"==typeof e&&"length"in e&&"number"==typeof e.length}var ie=require("@walkeros/collector"),ce=require("@walkeros/web-core");var ae={};function le(e={}){const t=e.prefix||"data-elb";return function(e){let n=e;const r={},o={},s={},i={},c={};function a(e){return Object.entries(e).map(([e,t])=>`${e}:${function(e){if(!b(e)||null===e)return"undefined";let t=String(e);return t=t.replace(/\\/g,"\\\\"),t=t.replace(/;/g,"\\;"),t=t.replace(/:/g,"\\:"),t=t.replace(/'/g,"\\'"),t}(t)}`).join(";")}const l={entity:e=>(n=e,l),data(e,t){const o=null!=n?n:"";return r[o]||(r[o]={}),p(e)?r[o][e]=t:Object.assign(r[o],e),l},action(e,t){if(p(e))if(b(t))o[e]=t;else if(e.includes(":")){const[t,n]=e.split(":",2);o[t]=n}else o[e]=e;else Object.assign(o,e);return l},context:(e,t)=>(p(e)?s[e]=t:Object.assign(s,e),l),globals:(e,t)=>(p(e)?i[e]=t:Object.assign(i,e),l),link:(e,t)=>(p(e)?c[e]=t:Object.assign(c,e),l),get(){const e={};return n&&(e[t]=n),Object.entries(r).forEach(([n,r])=>{if(Object.keys(r).length>0){e[n?`${t}-${n}`:`${t}-`]=a(r)}}),Object.keys(o).length>0&&(e[`${t}action`]=a(o)),Object.keys(s).length>0&&(e[`${t}context`]=a(s)),Object.keys(i).length>0&&(e[`${t}globals`]=a(i)),Object.keys(c).length>0&&(e[`${t}link`]=a(c)),e}};return l}}var ue=async(e,t)=>{const n=function(e={}){const t=e.scope||document;return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",name:"walkerjs",elbLayer:"elbLayer",...e,scope:t}}(t.settings),r={...t,settings:n},o=n.scope,s={type:"browser",config:r,collector:e,destroy(){G(e)}};if(!1!==n.elbLayer&&re(e,{name:p(n.elbLayer)?n.elbLayer:"elbLayer"}),X(e,o),n.session){const t="boolean"==typeof n.session?{}:n.session;!function(e,t={}){const n=t.config||{},r=f(e.config.sessionStatic||{},t.data||{});var o,s,i;(o=ce.sessionStart,s="SessionStart",i=e.hooks,function(...e){let t;const n="post"+s,r=i["pre"+s],c=i[n];return t=r?r({fn:o},...e):o(...e),c&&(t=c({fn:o,result:t},...e)),t})({...n,cb:(e,t,r)=>{let o;const s=n;return!1!==s.cb&&s.cb?o=s.cb(e,t,r):!1!==s.cb&&(o=r(e,t,r)),t&&(t.session=e,(0,ie.onApply)(t,"session")),o},data:r,collector:e})}(e,{config:t})}await async function(e,t,n){const r=()=>{e(t,n),(0,k.onApply)(t,"ready")};"loading"!==document.readyState?r():document.addEventListener("DOMContentLoaded",r)}(U,e,n);const i=e._destroy;e._destroy=()=>{var e;null==(e=s.destroy)||e.call(s),i&&i()};return{source:s,elb:(...t)=>{const[n,r,o,s,i,c]=t;return B(e,n,r,o,s,i,c)}}},fe=ue;//# sourceMappingURL=index.js.map
1
+ "use strict";var e,t,n,r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})(c,{SourceBrowser:()=>fe,createTagger:()=>de,default:()=>ge,getAllEvents:()=>S,getEvents:()=>E,getGlobals:()=>$,sourceBrowser:()=>pe}),module.exports=(e=c,((e,t,n,c)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of s(t))i.call(e,a)||a===n||r(e,a,{get:()=>t[a],enumerable:!(c=o(t,a))||c.enumerable});return e})(r({},"__esModule",{value:!0}),e));var a=Object.getOwnPropertyNames,l=(t={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.8",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return n||(0,t[a(t)[0]])((n={exports:{}}).exports,n),n.exports}),u={merge:!0,shallow:!0,extend:!0};function f(e,t={},n={}){n={...u,...n};const r=Object.entries(t).reduce((t,[r,o])=>{const s=e[r];return n.merge&&Array.isArray(s)&&Array.isArray(o)?t[r]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...s]):(n.extend||r in e)&&(t[r]=o),t},{});return n.shallow?{...e,...r}:(Object.assign(e,r),e)}function d(e){return Array.isArray(e)}function p(e){return void 0!==e}function g(e){return e===document||e instanceof Element}function b(e){return"object"==typeof e&&null!==e&&!d(e)&&"[object Object]"===Object.prototype.toString.call(e)}function m(e){return"string"==typeof e}function h(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}var{version:y}=l();function w(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function v(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}var k=require("@walkeros/collector"),x=require("@walkeros/web-core"),j=require("@walkeros/collector"),C=require("@walkeros/web-core");function O(e,t,n=!0){return e+(t=null!=t?(n?"-":"")+t:"")}function A(e,t,n,r=!0){return H((0,C.getAttribute)(t,O(e,n,r))||"").reduce((e,n)=>{let[r,o]=I(n);if(!r)return e;if(o||(r.endsWith(":")&&(r=r.slice(0,-1)),o=""),o.startsWith("#")){o=o.slice(1);try{let e=t[o];e||"selected"!==o||(e=t.options[t.selectedIndex].text),o=String(e)}catch(e){o=""}}return r.endsWith("[]")?(r=r.slice(0,-2),d(e[r])||(e[r]=[]),e[r].push(h(o))):e[r]=h(o),e},{})}function S(e=document.body,t=j.Const.Commands.Prefix){let n=[];const r=j.Const.Commands.Action,o=`[${O(t,r,!1)}]`,s=e=>{Object.keys(A(t,e,r,!1)).forEach(r=>{n=n.concat(E(e,r,t))})};return e!==document&&e.matches(o)&&s(e),M(e,o,s),n}function E(e,t,n=j.Const.Commands.Prefix){const r=[],o=function(e,t,n){let r=t;for(;r;){const t=L((0,C.getAttribute)(r,O(e,j.Const.Commands.Action,!1)));if(t[n]||"click"!==n)return t[n];r=_(e,r)}return[]}(n,e,t);return o?(o.forEach(o=>{const s=H(o.actionParams||"",",").reduce((e,t)=>(e[v(t)]=!0,e),{}),i=P(n,e,s);if(!i.length){const t="page",r=`[${O(n,t)}]`,[o,s]=q(e,r,n,t);i.push({type:t,data:o,nested:[],context:s})}i.forEach(e=>{r.push({entity:e.type,action:o.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),r):r}function $(e=j.Const.Commands.Prefix,t=document){const n=O(e,j.Const.Commands.Globals,!1);let r={};return M(t,`[${n}]`,t=>{r=f(r,A(e,t,j.Const.Commands.Globals,!1))}),r}function L(e){const t={};return H(e).forEach(e=>{const[n,r]=I(e),[o,s]=T(n);if(!o)return;let[i,c]=T(r||"");i=i||o,t[o]||(t[o]=[]),t[o].push({trigger:o,triggerParams:s,action:i,actionParams:c})}),t}function P(e,t,n){const r=[];let o=t;for(n=0!==Object.keys(n||{}).length?n:void 0;o;){const s=W(e,o,t,n);s&&r.push(s),o=_(e,o)}return r}function W(e,t,n,r){const o=(0,C.getAttribute)(t,O(e));if(!o||r&&!r[o])return null;const s=[t],i=`[${O(e,o)}],[${O(e,"")}]`,c=O(e,j.Const.Commands.Link,!1);let a={};const l=[],[u,d]=q(n||t,i,e,o);M(t,`[${c}]`,t=>{const[n,r]=I((0,C.getAttribute)(t,c));"parent"===r&&M(document.body,`[${c}="${n}:child"]`,t=>{s.push(t);const n=W(e,t);n&&l.push(n)})});const p=[];s.forEach(e=>{e.matches(i)&&p.push(e),M(e,i,e=>p.push(e))});let g={};return p.forEach(t=>{g=f(g,A(e,t,"")),a=f(a,A(e,t,o))}),a=f(f(g,a),u),s.forEach(t=>{M(t,`[${O(e)}]`,t=>{const n=W(e,t);n&&l.push(n)})}),{type:o,data:a,context:d,nested:l}}function _(e,t){const n=O(e,j.Const.Commands.Link,!1);if(t.matches(`[${n}]`)){const[e,r]=I((0,C.getAttribute)(t,n));if("child"===r)return document.querySelector(`[${n}="${e}:parent"]`)}return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof ShadowRoot?t.getRootNode().host:t.parentElement}function q(e,t,n,r){let o={};const s={};let i=e;const c=`[${O(n,j.Const.Commands.Context,!1)}]`;let a=0;for(;i;)i.matches(t)&&(o=f(A(n,i,""),o),o=f(A(n,i,r),o)),i.matches(c)&&(Object.entries(A(n,i,j.Const.Commands.Context,!1)).forEach(([e,t])=>{t&&!s[e]&&(s[e]=[t,a])}),++a),i=_(n,i);return[o,s]}function M(e,t,n){e.querySelectorAll(t).forEach(n)}function H(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function I(e){const[t,n]=e.split(/:(.+)/,2);return[v(t),v(n)]}function T(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var V=require("@walkeros/web-core"),R=new WeakMap,N=new WeakMap;function D(e){const t=Date.now();let n=N.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:(0,V.isVisible)(e),lastChecked:t},N.set(e,n)),n.isVisible}function G(e){if(window.IntersectionObserver)return w(()=>new window.IntersectionObserver(t=>{t.forEach(t=>{!function(e,t){var n,r;const o=t.target,s=e._visibilityState;if(!s)return;const i=s.timers.get(o);if(t.intersectionRatio>0){const r=Date.now();let c=R.get(o);(!c||r-c.lastChecked>1e3)&&(c={isLarge:o.offsetHeight>window.innerHeight,lastChecked:r},R.set(o,c));if(t.intersectionRatio>=.5||c.isLarge&&D(o)){const t=null==(n=s.elementConfigs)?void 0:n.get(o);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!i){const t=window.setTimeout(async()=>{var t,n;if(D(o)){const r=null==(t=s.elementConfigs)?void 0:t.get(o),i=(null==r?void 0:r.prefix)||"data-elb";await ee(e,i,o,U.Visible);const c=null==(n=s.elementConfigs)?void 0:n.get(o);(null==c?void 0:c.multiple)?c.blocked=!0:function(e,t){const n=e._visibilityState;if(!n)return;n.observer&&n.observer.unobserve(t);const r=n.timers.get(t);r&&(clearTimeout(r),n.timers.delete(t)),R.delete(t),N.delete(t)}(e,o)}},s.duration);s.timers.set(o,t)}return}}i&&(clearTimeout(i),s.timers.delete(o));const c=null==(r=s.elementConfigs)?void 0:r.get(o);(null==c?void 0:c.multiple)&&(c.blocked=!1)}(e,t)})},{rootMargin:"0px",threshold:[0,.5]}),()=>{})()}function B(e,t,n={multiple:!1}){var r;const o=e._visibilityState;(null==o?void 0:o.observer)&&t&&(o.elementConfigs||(o.elementConfigs=new WeakMap),o.elementConfigs.set(t,{multiple:null!=(r=n.multiple)&&r,blocked:!1,prefix:n.prefix||"data-elb"}),o.observer.observe(t))}function Y(e){const t=e._visibilityState;t&&(t.observer&&t.observer.disconnect(),delete e._visibilityState)}var z=performance.now();function F(e,t="data-elb",n,r,o,s,i,c){if(m(n)&&n.startsWith("walker ")){return e.push(n,r)}if(b(n)){const t=n;return t.source||(t.source=J()),e.push(t)}const[a]=String(b(n)?n.event:n).split(" ");let l,u=b(r)?r:{},f={},d=!1;if(g(r)&&(l=r,d=!0),g(s)?l=s:b(s)&&Object.keys(s).length&&(f=s),l){const e=P(t,l).find(e=>e.type===a);e&&(d&&(u=e.data),f=e.context)}"page"===a&&(u.id=u.id||window.location.pathname);const p={event:String(n||""),data:u,context:f,nested:i,custom:c,trigger:m(o)?o:"",timing:Math.round((performance.now()-z)/10)/100,source:J()};return e.push(p)}function J(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var K,Q=[],U={Click:"click",Custom:"custom",Hover:"hover",Load:"load",Pulse:"pulse",Scroll:"scroll",Submit:"submit",Visible:"visible",Visibles:"visibles",Wait:"wait"};function X(e,t){const{scope:n,prefix:r}=t;!function(e,t,n){t.addEventListener("click",w(function(t){ne.call(this,e,t,n)})),t.addEventListener("submit",w(function(t){re.call(this,e,t,n)}))}(e,n,r)}function Z(e,t){const{prefix:n,scope:r}=t;!function(e,t,n){Q=[],Y(e),function(e,t=1e3){e._visibilityState||(e._visibilityState={observer:G(e),timers:new WeakMap,duration:t})}(e,1e3);const r=O(t,k.Const.Commands.Action,!1),o=n||document;o!==document&&te(e,o,r,t);const s=o.querySelectorAll(`[${r}]`);s.forEach(n=>{te(e,n,r,t)}),Q.length&&function(e,t,n){const r=(e,t,n)=>e.filter(([e,r])=>{const o=window.scrollY+window.innerHeight,s=e.offsetTop;if(o<s)return!0;const i=e.clientHeight;return!(100*(1-(s+i-o)/(i||1))>=r)||(ee(t,n,e,U.Scroll),!1)});K||(K=function(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}(function(){Q=r.call(t,Q,e,n)}),t.addEventListener("scroll",K))}(e,o,t)}(e,n,r)}async function ee(e,t,n,r){const o=E(n,r,t);return Promise.all(o.map(n=>F(e,t,{event:`${n.entity} ${n.action}`,...n,trigger:r})))}function te(e,t,n,r){const o=(0,x.getAttribute)(t,n);o&&Object.values(L(o)).forEach(n=>n.forEach(n=>{switch(n.trigger){case U.Hover:!function(e,t,n){t.addEventListener("mouseenter",w(function(t){t.target instanceof Element&&ee(e,n,t.target,U.Hover)}))}(e,t,r);break;case U.Load:!function(e,t,n){ee(e,n,t,U.Load)}(e,t,r);break;case U.Pulse:!function(e,t,n="",r){setInterval(()=>{document.hidden||ee(e,r,t,U.Pulse)},parseInt(n||"")||15e3)}(e,t,n.triggerParams,r);break;case U.Scroll:!function(e,t=""){const n=parseInt(t||"")||50;if(n<0||n>100)return;Q.push([e,n])}(t,n.triggerParams);break;case U.Visible:B(e,t,{prefix:r});break;case U.Visibles:B(e,t,{multiple:!0,prefix:r});break;case U.Wait:!function(e,t,n="",r){setTimeout(()=>ee(e,r,t,U.Wait),parseInt(n||"")||15e3)}(e,t,n.triggerParams,r)}}))}function ne(e,t,n){ee(e,n,t.target,U.Click)}function re(e,t,n){t.target&&ee(e,n,t.target,U.Submit)}function oe(e,t={}){const n=t.name||"elbLayer";window[n]||(window[n]=[]);const r=window[n];r.push=function(...n){if(ce(n[0])){const r=[...Array.from(n[0])],o=Array.prototype.push.apply(this,[r]);return ie(e,t.prefix,r),o}const r=Array.prototype.push.apply(this,n);return n.forEach(n=>{ie(e,t.prefix,n)}),r},Array.isArray(r)&&r.length>0&&function(e,t="data-elb",n){se(e,t,n,!0),se(e,t,n,!1),n.length=0}(e,t.prefix,r)}function se(e,t,n,r){const o=[];let s=!0;n.forEach(e=>{const t=ce(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 i=t[0],c=!b(i)&&m(i)&&i.startsWith("walker ");if(b(i)){if("object"==typeof i&&0===Object.keys(i).length)return}else{const e=Array.from(t);if(!m(e[0])||""===e[0].trim())return;const n="walker run";s&&e[0]===n&&(s=!1)}(r&&c||!r&&!c)&&o.push(t)}),o.forEach(n=>{ie(e,t,n)})}function ie(e,t="data-elb",n){w(()=>{if(Array.isArray(n)){const[r,...o]=n;if(!r||m(r)&&""===r.trim())return;if(m(r)&&r.startsWith("walker "))return void e.push(r,o[0]);F(e,t,r,...o)}else if(n&&"object"==typeof n){if(0===Object.keys(n).length)return;e.push(n)}},()=>{})()}function ce(e){return null!=e&&"object"==typeof e&&"[object Arguments]"===Object.prototype.toString.call(e)}var ae=require("@walkeros/collector"),le=require("@walkeros/web-core");function ue(e={}){return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:document,...e}}var fe={};function de(e={}){const t=e.prefix||"data-elb";return function(e){let n,r=e;const o={},s={},i={},c={},a={};function l(e){return Object.entries(e).map(([e,t])=>`${e}:${function(e){if(!p(e)||null===e)return"undefined";let t=String(e);return t=t.replace(/\\/g,"\\\\"),t=t.replace(/;/g,"\\;"),t=t.replace(/:/g,"\\:"),t=t.replace(/'/g,"\\'"),t}(t)}`).join(";")}const u={entity:e=>(n=e,r=e,u),data(e,t){const n=null!=r?r:"";return o[n]||(o[n]={}),m(e)?o[n][e]=t:Object.assign(o[n],e),u},action(e,t){if(m(e))if(p(t))s[e]=t;else if(e.includes(":")){const[t,n]=e.split(":",2);s[t]=n}else s[e]=e;else Object.assign(s,e);return u},context:(e,t)=>(m(e)?i[e]=t:Object.assign(i,e),u),globals:(e,t)=>(m(e)?c[e]=t:Object.assign(c,e),u),link:(e,t)=>(m(e)?a[e]=t:Object.assign(a,e),u),get(){const e={};return n&&(e[t]=n),Object.entries(o).forEach(([n,r])=>{if(Object.keys(r).length>0){e[n?`${t}-${n}`:`${t}-`]=l(r)}}),Object.keys(s).length>0&&(e[`${t}action`]=l(s)),Object.keys(i).length>0&&(e[`${t}context`]=l(i)),Object.keys(c).length>0&&(e[`${t}globals`]=l(c)),Object.keys(a).length>0&&(e[`${t}link`]=l(a)),e}};return u}}var pe=async(e,t)=>{try{const n={...t,settings:ue(t.settings)},r={type:"browser",config:n,collector:e,destroy(){Y(e)}};if(!1!==n.settings.elbLayer&&oe(e,{name:m(n.settings.elbLayer)?n.settings.elbLayer:"elbLayer",prefix:n.settings.prefix}),n.settings.session){const t="boolean"==typeof n.settings.session?{}:n.settings.session;!function(e,t={}){const n=t.config||{},r=f(e.config.sessionStatic||{},t.data||{});var o,s,i;(o=le.sessionStart,s="SessionStart",i=e.hooks,function(...e){let t;const n="post"+s,r=i["pre"+s],c=i[n];return t=r?r({fn:o},...e):o(...e),c&&(t=c({fn:o,result:t},...e)),t})({...n,cb:(e,t,r)=>{let o;const s=n;return!1!==s.cb&&s.cb?o=s.cb(e,t,r):!1!==s.cb&&(o=r(e,t,r)),t&&(t.session=e,(0,ae.onApply)(t,"session")),o},data:r,collector:e})}(e,{config:t})}await async function(e,t,n){const r=()=>{if(e(t,n),null==t?void 0:t.on)try{(0,k.onApply)(t,"ready")}catch(e){}};"loading"!==document.readyState?r():document.addEventListener("DOMContentLoaded",r)}(X,e,n.settings);const o=e=>{if(Z(e,n.settings),n.settings.pageview){const[t,r]=function(e,t){const n=window.location,r="page",o=t===document?document.body:t,[s,i]=q(o,`[${O(e,r)}]`,e,r);return s.domain=n.hostname,s.title=document.title,s.referrer=document.referrer,n.search&&(s.search=n.search),n.hash&&(s.hash=n.hash),[s,i]}(n.settings.prefix||"data-elb",n.settings.scope);F(e,"page view",t,U.Load,r)}};await e.push("walker on","run",o);const s=e._destroy;e._destroy=()=>{var e;null==(e=r.destroy)||e.call(r),s&&s()};const i=(...t)=>{const[r,o,s,i,c,a]=t;return F(e,n.settings.prefix,r,o,s,i,c,a)};return m(n.settings.elb)&&(window[n.settings.elb]=i),{source:r,elb:i}}catch(e){throw e}},ge=pe;//# sourceMappingURL=index.js.map