@walkeros/core 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,i={};((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(i,{Collector:()=>a,ConsentSchema:()=>x,Const:()=>v,Data:()=>s,Destination:()=>c,Elb:()=>u,Flow:()=>l,Handler:()=>p,Hooks:()=>m,LoopSchema:()=>A,MapSchema:()=>L,Mapping:()=>d,On:()=>g,Request:()=>f,Schema:()=>y,SetSchema:()=>T,Source:()=>h,ValueConfigSchema:()=>M,ValueSchema:()=>P,WalkerOS:()=>b,anonymizeIP:()=>R,assign:()=>H,castToProperty:()=>ye,castValue:()=>ie,clone:()=>ne,createArraySchema:()=>q,createDestination:()=>se,createEnumSchema:()=>_,createEvent:()=>ce,createObjectSchema:()=>D,createTupleSchema:()=>K,debounce:()=>me,filterValues:()=>fe,getBrowser:()=>Ie,getBrowserVersion:()=>$e,getByPath:()=>re,getDeviceType:()=>Ne,getEvent:()=>ue,getGrantedConsent:()=>ae,getHeaders:()=>Ae,getId:()=>le,getMappingEvent:()=>ve,getMappingValue:()=>we,getMarketingParameters:()=>pe,getOS:()=>Ve,getOSVersion:()=>De,isArguments:()=>J,isArray:()=>U,isBoolean:()=>F,isCommand:()=>W,isDefined:()=>X,isElementOrDocument:()=>G,isFunction:()=>Q,isNumber:()=>Y,isObject:()=>Z,isPropertyType:()=>ge,isSameType:()=>ee,isString:()=>te,loopJsonSchema:()=>I,mapJsonSchema:()=>V,mockEnv:()=>je,onLog:()=>ke,parseUserAgent:()=>Ce,processEventMapping:()=>xe,requestToData:()=>ze,requestToParameter:()=>Ee,setByPath:()=>oe,setJsonSchema:()=>$,throttle:()=>de,throwError:()=>Te,transformData:()=>Pe,traverseEnv:()=>Oe,trim:()=>Le,tryCatch:()=>he,tryCatchAsync:()=>be,useHooks:()=>Me,validateEvent:()=>qe,validateProperty:()=>_e,valueConfigJsonSchema:()=>C}),module.exports=(e=i,((e,i,a,s)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of r(i))o.call(e,c)||c===a||t(e,c,{get:()=>i[c],enumerable:!(s=n(i,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a={},s={},c={},u={},l={},p={},m={},d={},g={},f={},y={},h={},b={},v={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}},w=require("zod"),S=require("zod-to-json-schema"),x=w.z.record(w.z.string(),w.z.boolean()).describe("Consent requirement mapping"),j=w.z.lazy(()=>w.z.union([w.z.string(),w.z.number(),w.z.boolean(),E,w.z.array(j)])),O=w.z.tuple([j,j]).describe("Loop: [source, transform] tuple for array transformations"),k=w.z.array(j).describe("Set: Array of values"),z=w.z.record(w.z.string(),j).describe("Map: Object mapping keys to values"),E=w.z.object({key:w.z.string().optional().describe('Property path (e.g., "data.id")'),value:w.z.union([w.z.string(),w.z.number(),w.z.boolean()]).optional().describe("Static primitive value"),fn:w.z.string().optional().describe("Function string for custom transformation"),map:z.optional().describe("Object with key-value mappings"),loop:O.optional().describe("Tuple [source, transform]"),set:k.optional().describe("Array of values"),consent:x.optional().describe("Required consent states"),condition:w.z.string().optional().describe("Condition function string"),validate:w.z.string().optional().describe("Validation function string")}).refine(e=>Object.keys(e).length>0,{message:"ValueConfig must have at least one property"}).describe("Value configuration for transformations"),P=j,A=O,T=k,L=z,M=E,C=(0,S.zodToJsonSchema)(M,{target:"jsonSchema7",$refStrategy:"relative",name:"ValueConfig"}),I=(0,S.zodToJsonSchema)(A,{target:"jsonSchema7",$refStrategy:"relative",name:"Loop"}),$=(0,S.zodToJsonSchema)(T,{target:"jsonSchema7",$refStrategy:"relative",name:"Set"}),V=(0,S.zodToJsonSchema)(L,{target:"jsonSchema7",$refStrategy:"relative",name:"Map"});function D(e,t){const n=[],r={};for(const[t,o]of Object.entries(e)){o.required&&n.push(t);const e={type:o.type};if(o.description&&(e.description=o.description),o.pattern&&(e.pattern=o.pattern),void 0!==o.minLength&&(e.minLength=o.minLength),void 0!==o.maxLength&&(e.maxLength=o.maxLength),void 0!==o.minimum&&(e.minimum=o.minimum),void 0!==o.maximum&&(e.maximum=o.maximum),o.enum&&(e.enum=[...o.enum]),void 0!==o.default&&(e.default=o.default),"object"===o.type&&o.properties){const t={};for(const[e,n]of Object.entries(o.properties))t[e]=N(n);e.properties=t}"array"===o.type&&o.items&&(e.items=N(o.items)),r[t]=e}const o={type:"object",properties:r};return t&&(o.title=t),n.length>0&&(o.required=n),o}function N(e){const t={type:e.type};if(e.description&&(t.description=e.description),e.pattern&&(t.pattern=e.pattern),void 0!==e.minLength&&(t.minLength=e.minLength),void 0!==e.maxLength&&(t.maxLength=e.maxLength),void 0!==e.minimum&&(t.minimum=e.minimum),void 0!==e.maximum&&(t.maximum=e.maximum),e.enum&&(t.enum=[...e.enum]),void 0!==e.default&&(t.default=e.default),"object"===e.type&&e.properties){const n={};for(const[t,r]of Object.entries(e.properties))n[t]=N(r);t.properties=n}return"array"===e.type&&e.items&&(t.items=N(e.items)),t}function q(e,t){const n={type:"array",items:N(e)};return void 0!==t?.minItems&&(n.minItems=t.minItems),void 0!==t?.maxItems&&(n.maxItems=t.maxItems),t?.description&&(n.description=t.description),t?.title&&(n.title=t.title),n}function _(e,t="string",n){const r={type:t,enum:[...e]};return n?.description&&(r.description=n.description),n?.title&&(r.title=n.title),r}function K(e,t,n){return q({type:"object"},{minItems:2,maxItems:2,description:n||"Tuple with exactly 2 elements [source, transform]"})}function R(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}var B={merge:!0,shallow:!0,extend:!0};function H(e,t={},n={}){n={...B,...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 J(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function U(e){return Array.isArray(e)}function F(e){return"boolean"==typeof e}function W(e){return"walker"===e}function X(e){return void 0!==e}function G(e){return e===document||e instanceof Element}function Q(e){return"function"==typeof e}function Y(e){return"number"==typeof e&&!Number.isNaN(e)}function Z(e){return"object"==typeof e&&null!==e&&!U(e)&&"[object Object]"===Object.prototype.toString.call(e)}function ee(e,t){return typeof e==typeof t}function te(e){return"string"==typeof e}function ne(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=ne(e[r],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(ne(e,t))}),n}if("[object Date]"===n)return new Date(e.getTime());if("[object RegExp]"===n){const t=e;return new RegExp(t.source,t.flags)}return e}function re(e,t="",n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const t=r[e];if("*"===t&&U(o)){const t=r.slice(e+1).join("."),i=[];for(const e of o){const r=re(e,t,n);i.push(r)}return i}if(o=o instanceof Object?o[t]:void 0,!o)break}return X(o)?o:n}function oe(e,t,n){if(!Z(e))return e;const r=ne(e),o=t.split(".");let i=r;for(let e=0;e<o.length;e++){const t=o[e];e===o.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return r}function ie(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function ae(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}function se(e,t){const n={...e};return n.config=H(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=H(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=H(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function ce(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",r=e.count||1,o=H({name:"entity action",data:{string:"foo",number:1,boolean:!0,array:[0,"text",!1],not:void 0},context:{dev:["test",1]},globals:{lang:"elb"},custom:{completely:"random"},user:{id:"us3r",device:"c00k13",session:"s3ss10n"},nested:[{entity:"child",data:{is:"subordinated"},nested:[],context:{element:["child",0]}}],consent:{functional:!0},id:`${t}-${n}-${r}`,trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,group:n,count:r,version:{source:"0.2.1",tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.name){const[t,n]=e.name.split(" ")??[];t&&n&&(o.entity=t,o.action=n)}return o}function ue(e="entity action",t={}){const n=t.timestamp||(new Date).setHours(0,13,37,0),r={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},o={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return ce({...{"cart view":{data:{currency:"EUR",value:2*r.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",data:{...r.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:r.data.price+o.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...r,context:{shopping:["checkout",0]},nested:[]},{entity:"product",...o,context:{shopping:["checkout",0]},nested:[]}],trigger:"load"},"order complete":{data:{id:"0rd3r1d",currency:"EUR",shipping:5.22,taxes:73.76,total:555},context:{shopping:["complete",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...r,context:{shopping:["complete",0]},nested:[]},{entity:"product",...o,context:{shopping:["complete",0]},nested:[]},{entity:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.elbwalker.com/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":{...r,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...r,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...r.data,position:3,promo:!0},context:{shopping:["discover",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"promotion visible":{data:{name:"Setting up tracking easily",position:"hero"},context:{ab_test:["engagement",0]},globals:{pagegroup:"homepage"},trigger:"visible"},"session start":{data:{id:"s3ss10n",start:n,isNew:!0,count:1,runs:1,isStart:!0,storage:!0,referrer:"",device:"c00k13"},user:{id:"us3r",device:"c00k13",session:"s3ss10n",hash:"h4sh",address:"street number",email:"user@example.com",phone:"+49 123 456 789",userAgent:"Mozilla...",browser:"Chrome",browserVersion:"90",deviceType:"desktop",language:"de-DE",country:"DE",region:"HH",city:"Hamburg",zip:"20354",timezone:"Berlin",os:"walkerOS",osVersion:"1.0",screenSize:"1337x420",ip:"127.0.0.0",internal:!0,custom:"value"}}}[e],...t,name:e})}function le(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function pe(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(H(o,t)).forEach(([t,o])=>{const i=e.searchParams.get(t);i&&(o===n&&(o=t,r[n]=t),r[o]=i)}),r}function me(e,t=1e3,n=!1){let r,o=null,i=!1;return(...a)=>new Promise(s=>{const c=n&&!i;o&&clearTimeout(o),o=setTimeout(()=>{o=null,n&&!i||(r=e(...a),s(r))},t),c&&(i=!0,r=e(...a),s(r))})}function de(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}function ge(e){return F(e)||te(e)||Y(e)||!X(e)||U(e)&&e.every(ge)||Z(e)&&Object.values(e).every(ge)}function fe(e){return F(e)||te(e)||Y(e)?e:J(e)?fe(Array.from(e)):U(e)?e.map(e=>fe(e)).filter(e=>void 0!==e):Z(e)?Object.entries(e).reduce((e,[t,n])=>{const r=fe(n);return void 0!==r&&(e[t]=r),e},{}):void 0}function ye(e){return ge(e)?e:void 0}function he(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function be(e,t,n){return async function(...r){try{return await e(...r)}catch(e){if(!t)return;return await t(e)}finally{await(n?.())}}}async function ve(e,t){const[n,r]=(e.name||"").split(" ");if(!t||!n||!r)return{};let o,i="",a=n,s=r;const c=t=>{if(t)return(t=U(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[a]||(a="*");const u=t[a];return u&&(u[s]||(s="*"),o=c(u[s])),o||(a="*",s="*",o=c(t[a]?.[s])),o&&(i=`${a} ${s}`),{eventMapping:o,mappingKey:i}}async function we(e,t={},n={}){if(!X(e))return;const r=Z(e)&&e.consent||n.consent||n.collector?.consent,o=U(t)?t:[t];for(const t of o){const o=await be(Se)(e,t,{...n,consent:r});if(X(o))return o}}async function Se(e,t,n={}){const{collector:r,consent:o}=n;return(U(t)?t:[t]).reduce(async(t,i)=>{const a=await t;if(a)return a;const s=te(i)?{key:i}:i;if(!Object.keys(s).length)return;const{condition:c,consent:u,fn:l,key:p,loop:m,map:d,set:g,validate:f,value:y}=s;if(c&&!await be(c)(e,i,r))return;if(u&&!ae(u,o))return y;let h=X(y)?y:e;if(l&&(h=await be(l)(e,i,n)),p&&(h=re(e,p,y)),m){const[t,r]=m,o="this"===t?[e]:await we(e,t,n);U(o)&&(h=(await Promise.all(o.map(e=>we(e,r,n)))).filter(X))}else d?h=await Object.entries(d).reduce(async(t,[r,o])=>{const i=await t,a=await we(e,o,n);return X(a)&&(i[r]=a),i},Promise.resolve({})):g&&(h=await Promise.all(g.map(t=>Se(e,t,n))));f&&!await be(f)(h)&&(h=void 0);const b=ye(h);return X(b)?b:ye(y)},Promise.resolve(void 0))}async function xe(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,r])=>{const o=await we(e,r,{collector:n});e=oe(e,t,o)}));const{eventMapping:r,mappingKey:o}=await ve(e,t.mapping);r?.policy&&await Promise.all(Object.entries(r.policy).map(async([t,r])=>{const o=await we(e,r,{collector:n});e=oe(e,t,o)}));let i=t.data&&await we(e,t.data,{collector:n});if(r){if(r.ignore)return{event:e,data:i,mapping:r,mappingKey:o,ignore:!0};if(r.name&&(e.name=r.name),r.data){const t=r.data&&await we(e,r.data,{collector:n});i=Z(i)&&Z(t)?H(i,t):t}}return{event:e,data:i,mapping:r,mappingKey:o,ignore:!1}}function je(e,t){const n=(e,r=[])=>new Proxy(e,{get(e,o){const i=e[o],a=[...r,o];return"function"==typeof i?(...e)=>t(a,e,i):i&&"object"==typeof i?n(i,a):i}});return n(e)}function Oe(e,t){const n=(e,r=[])=>{if(!e||"object"!=typeof e)return e;const o=Array.isArray(e)?[]:{};for(const[i,a]of Object.entries(e)){const e=[...r,i];Array.isArray(o)?o[Number(i)]=t(a,e):o[i]=t(a,e),a&&"object"==typeof a&&"function"!=typeof a&&(Array.isArray(o)?o[Number(i)]=n(a,e):o[i]=n(a,e))}return o};return n(e)}function ke(e,t=!1){t&&console.dir(e,{depth:4})}function ze(e){const t=String(e),n=t.split("?")[1]||t;return he(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const r=n.split(/[[\]]+/).filter(Boolean);let o=t;r.forEach((t,n)=>{const i=n===r.length-1;if(U(o)){const a=parseInt(t,10);i?o[a]=ie(e):(o[a]=o[a]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[a])}else Z(o)&&(i?o[t]=ie(e):(o[t]=o[t]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[t]))})}),t})()}function Ee(e){if(!e)return"";const t=[],n=encodeURIComponent;function r(e,o){null!=o&&(U(o)?o.forEach((t,n)=>r(`${e}[${n}]`,t)):Z(o)?Object.entries(o).forEach(([t,n])=>r(`${e}[${t}]`,n)):t.push(`${n(e)}=${n(String(o))}`))}return"object"!=typeof e?n(e):(Object.entries(e).forEach(([e,t])=>r(e,t)),t.join("&"))}function Pe(e){return void 0===e||ee(e,"")?e:JSON.stringify(e)}function Ae(e={}){return H({"Content-Type":"application/json; charset=utf-8"},e)}function Te(e){throw new Error(String(e))}function Le(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function Me(e,t,n){return function(...r){let o;const i="post"+t,a=n["pre"+t],s=n[i];return o=a?a({fn:e},...r):e(...r),s&&(o=s({fn:e,result:o},...r)),o}}function Ce(e){return e?{userAgent:e,browser:Ie(e),browserVersion:$e(e),os:Ve(e),osVersion:De(e),deviceType:Ne(e)}:{}}function Ie(e){const t=[{name:"Edge",substr:"Edg"},{name:"Chrome",substr:"Chrome"},{name:"Safari",substr:"Safari",exclude:"Chrome"},{name:"Firefox",substr:"Firefox"},{name:"IE",substr:"MSIE"},{name:"IE",substr:"Trident"}];for(const n of t)if(e.includes(n.substr)&&(!n.exclude||!e.includes(n.exclude)))return n.name}function $e(e){const t=[/Edg\/([0-9]+)/,/Chrome\/([0-9]+)/,/Version\/([0-9]+).*Safari/,/Firefox\/([0-9]+)/,/MSIE ([0-9]+)/,/rv:([0-9]+).*Trident/];for(const n of t){const t=e.match(n);if(t)return t[1]}}function Ve(e){const t=[{name:"Windows",substr:"Windows NT"},{name:"macOS",substr:"Mac OS X"},{name:"Android",substr:"Android"},{name:"iOS",substr:"iPhone OS"},{name:"Linux",substr:"Linux"}];for(const n of t)if(e.includes(n.substr))return n.name}function De(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function Ne(e){let t="Desktop";return/Tablet|iPad/i.test(e)?t="Tablet":/Mobi|Android|iPhone|iPod|BlackBerry|Opera Mini|IEMobile|WPDesktop/i.test(e)&&(t="Mobile"),t}function qe(e,t=[]){let n,r,o;ee(e,{})||Te("Invalid object"),ee(e.name,"")?(n=e.name,[r,o]=n.split(" "),r&&o||Te("Invalid event name")):ee(e.entity,"")&&ee(e.action,"")?(r=e.entity,o=e.action,n=`${r} ${o}`):Te("Missing or invalid name, entity, or action");const i={name:n,data:{},context:{},custom:{},globals:{},user:{},nested:[],consent:{},id:"",trigger:"",entity:r,action:o,timestamp:0,timing:0,group:"",count:0,version:{source:"",tagging:0},source:{type:"",id:"",previous_id:""}};return[{"*":{"*":{name:{maxLength:255},user:{allowedKeys:["id","device","session"]},consent:{allowedValues:[!0,!1]},timestamp:{min:0},timing:{min:0},count:{min:0},version:{allowedKeys:["source","tagging"]},source:{allowedKeys:["type","id","previous_id"]}}}}].concat(t).reduce((e,t)=>["*",r].reduce((e,n)=>["*",o].reduce((e,r)=>{const o=t[n]?.[r];return o?e.concat([o]):e},e),e),[]).reduce((t,n)=>{const r=Object.keys(n).filter(e=>{const t=n[e];return!0===t?.required});return[...Object.keys(e),...r].reduce((t,r)=>{const o=n[r];let i=e[r];return o&&(i=he(_e,e=>{Te(String(e))})(t,r,i,o)),ee(i,t[r])&&(t[r]=i),t},t)},i)}function _e(e,t,n,r){if(r.validate&&(n=he(r.validate,e=>{Te(String(e))})(n,t,e)),r.required&&void 0===n&&Te("Missing required property"),ee(n,""))r.maxLength&&n.length>r.maxLength&&(r.strict&&Te("Value exceeds maxLength"),n=n.substring(0,r.maxLength));else if(ee(n,1))ee(r.min,1)&&n<r.min?(r.strict&&Te("Value below min"),n=r.min):ee(r.max,1)&&n>r.max&&(r.strict&&Te("Value exceeds max"),n=r.max);else if(ee(n,{})){if(r.schema){const e=r.schema;Object.keys(e).reduce((t,n)=>{const r=e[n];let o=t[n];return r&&(r.type&&typeof o!==r.type&&Te(`Type doesn't match (${n})`),o=he(_e,e=>{Te(String(e))})(t,n,o,r)),o},n)}for(const e of Object.keys(n))r.allowedKeys&&!r.allowedKeys.includes(e)&&(r.strict&&Te("Key not allowed"),delete n[e])}return n}//# sourceMappingURL=index.js.map
1
+ "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,r=(e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})},a={};r(a,{BaseContextConfig:()=>re,BatchConfig:()=>ae,Collector:()=>s,CollectorSchemas:()=>Ot,ConsentSchema:()=>ye,Const:()=>z,Counter:()=>x,Data:()=>c,DeepPartialEventSchema:()=>Je,Destination:()=>l,DestinationSchemas:()=>it,DestinationsMapConfig:()=>le,DisabledConfig:()=>Q,Elb:()=>d,EntitiesSchema:()=>we,EntitySchema:()=>je,EventSchema:()=>Ce,Flow:()=>u,GenericEnvConfig:()=>Z,GenericSettingsConfig:()=>Y,Handler:()=>p,HandlersConfig:()=>W,Hooks:()=>m,IdConfig:()=>F,Identifier:()=>E,InitConfig:()=>G,LoopSchema:()=>Ve,MapSchema:()=>Ue,Mapping:()=>g,MappingResultSchema:()=>Fe,MappingSchemas:()=>qe,On:()=>b,OptionalPrimitiveValue:()=>k,OrderedPropertiesSchema:()=>fe,PartialEventSchema:()=>Ee,PolicySchema:()=>He,PrimaryConfig:()=>X,PrimitiveValue:()=>T,ProcessingControlConfig:()=>se,PropertiesSchema:()=>be,PropertySchema:()=>ge,PropertyTypeSchema:()=>me,QueueConfig:()=>K,Request:()=>f,RequiredBoolean:()=>C,RequiredNumber:()=>w,RequiredString:()=>j,RuleSchema:()=>We,RulesSchema:()=>_e,RuntimeInstanceConfig:()=>ie,Schema:()=>h,SetSchema:()=>Be,Source:()=>y,SourceSchema:()=>ve,SourceSchemas:()=>Gt,SourceTypeSchema:()=>he,SourcesMapConfig:()=>ce,TaggingVersion:()=>P,Timestamp:()=>J,UserSchema:()=>Se,UtilitySchemas:()=>O,ValueConfigSchema:()=>Ne,ValueSchema:()=>Re,ValuesSchema:()=>Ae,VerboseConfig:()=>_,VersionSchema:()=>ze,WalkerOS:()=>S,WalkerOSSchemas:()=>de,anonymizeIP:()=>vn,assign:()=>wn,castToProperty:()=>Gn,castValue:()=>Rn,clone:()=>qn,consentJsonSchema:()=>$e,createArraySchema:()=>gn,createConsentConfig:()=>oe,createDataTransformationConfig:()=>ee,createDestination:()=>Vn,createEnumSchema:()=>bn,createEvent:()=>Bn,createMappingRulesConfig:()=>te,createObjectSchema:()=>pn,createPolicyConfig:()=>ne,createTupleSchema:()=>fn,debounce:()=>Wn,entityJsonSchema:()=>Oe,eventJsonSchema:()=>xe,filterValues:()=>Fn,getBrowser:()=>go,getBrowserVersion:()=>bo,getByPath:()=>Mn,getDeviceType:()=>yo,getEvent:()=>Un,getGrantedConsent:()=>An,getHeaders:()=>co,getId:()=>Nn,getMappingEvent:()=>Yn,getMappingValue:()=>Zn,getMarketingParameters:()=>Hn,getOS:()=>fo,getOSVersion:()=>ho,isArguments:()=>Cn,isArray:()=>En,isBoolean:()=>Jn,isCommand:()=>xn,isDefined:()=>Pn,isElementOrDocument:()=>Tn,isFunction:()=>kn,isNumber:()=>Dn,isObject:()=>On,isPropertyType:()=>Kn,isSameType:()=>In,isString:()=>$n,loopJsonSchema:()=>Xe,mapJsonSchema:()=>Ze,mockEnv:()=>no,onLog:()=>io,orderedPropertiesJsonSchema:()=>De,parseUserAgent:()=>mo,partialEventJsonSchema:()=>Pe,policyJsonSchema:()=>et,processEventMapping:()=>to,propertiesJsonSchema:()=>ke,requestToData:()=>ro,requestToParameter:()=>ao,ruleJsonSchema:()=>tt,rulesJsonSchema:()=>nt,setByPath:()=>Ln,setJsonSchema:()=>Ye,sourceTypeJsonSchema:()=>Ie,throttle:()=>_n,throwError:()=>lo,transformData:()=>so,traverseEnv:()=>oo,trim:()=>uo,tryCatch:()=>Qn,tryCatchAsync:()=>Xn,useHooks:()=>po,userJsonSchema:()=>Te,validateEvent:()=>So,validateProperty:()=>zo,valueConfigJsonSchema:()=>Qe,valueJsonSchema:()=>Ge,z:()=>hn.z,zodToJsonSchema:()=>yn.zodToJsonSchema,zodToSchema:()=>zn}),module.exports=(e=a,((e,r,a,s)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let c of o(r))i.call(e,c)||c===a||t(e,c,{get:()=>r[c],enumerable:!(s=n(r,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s={},c={},l={},d={},u={},p={},m={},g={},b={},f={},h={},y={},S={},z={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}},v=require("zod"),j=v.z.string(),w=v.z.number(),C=v.z.boolean(),E=v.z.string().min(1),J=v.z.number().int().positive(),x=v.z.number().int().nonnegative(),P=v.z.number().describe("Tagging version number"),T=v.z.union([v.z.string(),v.z.number(),v.z.boolean()]),k=T.optional(),D=require("zod"),O={};r(O,{ErrorHandlerSchema:()=>L,HandlerSchema:()=>A,LogHandlerSchema:()=>R,StorageSchema:()=>M,StorageTypeSchema:()=>q,errorHandlerJsonSchema:()=>U,handlerJsonSchema:()=>H,logHandlerJsonSchema:()=>N,storageJsonSchema:()=>B,storageTypeJsonSchema:()=>V});var I=require("zod"),$=require("zod-to-json-schema"),q=I.z.enum(["local","session","cookie"]).describe("Storage mechanism: local, session, or cookie"),M=I.z.object({Local:I.z.literal("local"),Session:I.z.literal("session"),Cookie:I.z.literal("cookie")}).describe("Storage type constants for type-safe references"),L=I.z.any().describe("Error handler function: (error, state?) => void"),R=I.z.any().describe("Log handler function: (message, verbose?) => void"),A=I.z.object({Error:L.describe("Error handler function"),Log:R.describe("Log handler function")}).describe("Handler interface with error and log functions"),V=(0,$.zodToJsonSchema)(q,{target:"jsonSchema7",$refStrategy:"relative",name:"StorageType"}),B=(0,$.zodToJsonSchema)(M,{target:"jsonSchema7",$refStrategy:"relative",name:"Storage"}),U=(0,$.zodToJsonSchema)(L,{target:"jsonSchema7",$refStrategy:"relative",name:"ErrorHandler"}),N=(0,$.zodToJsonSchema)(R,{target:"jsonSchema7",$refStrategy:"relative",name:"LogHandler"}),H=(0,$.zodToJsonSchema)(A,{target:"jsonSchema7",$refStrategy:"relative",name:"Handler"}),W=D.z.object({onError:L.optional().describe("Error handler function: (error, state?) => void"),onLog:R.optional().describe("Log handler function: (message, verbose?) => void")}).partial(),_=D.z.object({verbose:D.z.boolean().describe("Enable verbose logging for debugging").optional()}).partial(),K=D.z.object({queue:D.z.boolean().describe("Whether to queue events when consent is not granted").optional()}).partial(),F=D.z.object({}).partial(),G=D.z.object({init:D.z.boolean().describe("Whether to initialize immediately").optional(),loadScript:D.z.boolean().describe("Whether to load external script (for web destinations)").optional()}).partial(),Q=D.z.object({disabled:D.z.boolean().describe("Set to true to disable").optional()}).partial(),X=D.z.object({primary:D.z.boolean().describe("Mark as primary (only one can be primary)").optional()}).partial(),Y=D.z.object({settings:D.z.any().optional().describe("Implementation-specific configuration")}).partial(),Z=D.z.object({env:D.z.any().optional().describe("Environment dependencies (platform-specific)")}).partial();function ee(e,t){return D.z.object({data:D.z.union([e,t]).optional().describe("Data transformation rules")}).partial()}function te(e){return D.z.object({mapping:e.optional().describe("Event mapping rules")}).partial()}function ne(e){return D.z.object({policy:e.optional().describe("Pre-processing policy rules")}).partial()}function oe(e){return D.z.object({consent:e.optional().describe("Required consent states")}).partial()}var ie=D.z.object({type:D.z.string().optional().describe("Instance type identifier"),config:D.z.any().describe("Instance configuration")}).partial(),re=D.z.object({collector:D.z.any().describe("Collector instance (runtime object)"),config:D.z.any().describe("Configuration"),env:D.z.any().describe("Environment dependencies")}).partial(),ae=D.z.object({batch:D.z.number().optional().describe("Batch size: bundle N events for batch processing"),batched:D.z.any().optional().describe("Batch of events to be processed")}).partial(),se=D.z.object({ignore:D.z.boolean().describe("Set to true to skip processing").optional(),condition:D.z.string().optional().describe("Condition function: return true to process")}).partial(),ce=D.z.object({sources:D.z.record(D.z.string(),D.z.any()).describe("Map of source instances")}).partial(),le=D.z.object({destinations:D.z.record(D.z.string(),D.z.any()).describe("Map of destination instances")}).partial(),de={};r(de,{ConsentSchema:()=>ye,DeepPartialEventSchema:()=>Je,EntitiesSchema:()=>we,EntitySchema:()=>je,EventSchema:()=>Ce,OrderedPropertiesSchema:()=>fe,PartialEventSchema:()=>Ee,PropertiesSchema:()=>be,PropertySchema:()=>ge,PropertyTypeSchema:()=>me,SourceSchema:()=>ve,SourceTypeSchema:()=>he,UserSchema:()=>Se,VersionSchema:()=>ze,consentJsonSchema:()=>$e,entityJsonSchema:()=>Oe,eventJsonSchema:()=>xe,orderedPropertiesJsonSchema:()=>De,partialEventJsonSchema:()=>Pe,propertiesJsonSchema:()=>ke,sourceTypeJsonSchema:()=>Ie,userJsonSchema:()=>Te});var ue=require("zod"),pe=require("zod-to-json-schema"),me=ue.z.lazy(()=>ue.z.union([ue.z.boolean(),ue.z.string(),ue.z.number(),ue.z.record(ue.z.string(),ge)])),ge=ue.z.lazy(()=>ue.z.union([me,ue.z.array(me)])),be=ue.z.record(ue.z.string(),ge.optional()).describe("Flexible property collection with optional values"),fe=ue.z.record(ue.z.string(),ue.z.tuple([ge,ue.z.number()]).optional()).describe("Ordered properties with [value, order] tuples for priority control"),he=ue.z.union([ue.z.enum(["web","server","app","other"]),ue.z.string()]).describe("Source type: web, server, app, other, or custom"),ye=ue.z.record(ue.z.string(),ue.z.boolean()).describe("Consent requirement mapping (group name → state)"),Se=be.and(ue.z.object({id:ue.z.string().optional().describe("User identifier"),device:ue.z.string().optional().describe("Device identifier"),session:ue.z.string().optional().describe("Session identifier"),hash:ue.z.string().optional().describe("Hashed identifier"),address:ue.z.string().optional().describe("User address"),email:ue.z.string().email().optional().describe("User email address"),phone:ue.z.string().optional().describe("User phone number"),userAgent:ue.z.string().optional().describe("Browser user agent string"),browser:ue.z.string().optional().describe("Browser name"),browserVersion:ue.z.string().optional().describe("Browser version"),deviceType:ue.z.string().optional().describe("Device type (mobile, desktop, tablet)"),os:ue.z.string().optional().describe("Operating system"),osVersion:ue.z.string().optional().describe("Operating system version"),screenSize:ue.z.string().optional().describe("Screen dimensions"),language:ue.z.string().optional().describe("User language"),country:ue.z.string().optional().describe("User country"),region:ue.z.string().optional().describe("User region/state"),city:ue.z.string().optional().describe("User city"),zip:ue.z.string().optional().describe("User postal code"),timezone:ue.z.string().optional().describe("User timezone"),ip:ue.z.string().optional().describe("User IP address"),internal:ue.z.boolean().optional().describe("Internal user flag (employee, test user)")})).describe("User identification and properties"),ze=be.and(ue.z.object({source:j.describe('Walker implementation version (e.g., "2.0.0")'),tagging:P})).describe("Walker version information"),ve=be.and(ue.z.object({type:he.describe("Source type identifier"),id:j.describe("Source identifier (typically URL on web)"),previous_id:j.describe("Previous source identifier (typically referrer on web)")})).describe("Event source information"),je=ue.z.lazy(()=>ue.z.object({entity:ue.z.string().describe("Entity name"),data:be.describe("Entity-specific properties"),nested:ue.z.array(je).describe("Nested child entities"),context:fe.describe("Entity context data")})).describe("Nested entity structure with recursive nesting support"),we=ue.z.array(je).describe("Array of nested entities"),Ce=ue.z.object({name:ue.z.string().describe('Event name in "entity action" format (e.g., "page view", "product add")'),data:be.describe("Event-specific properties"),context:fe.describe("Ordered context properties with priorities"),globals:be.describe("Global properties shared across events"),custom:be.describe("Custom implementation-specific properties"),user:Se.describe("User identification and attributes"),nested:we.describe("Related nested entities"),consent:ye.describe("Consent states at event time"),id:E.describe("Unique event identifier (timestamp-based)"),trigger:j.describe("Event trigger identifier"),entity:j.describe("Parsed entity from event name"),action:j.describe("Parsed action from event name"),timestamp:J.describe("Unix timestamp in milliseconds since epoch"),timing:w.describe("Event processing timing information"),group:j.describe("Event grouping identifier"),count:x.describe("Event count in session"),version:ze.describe("Walker version information"),source:ve.describe("Event source information")}).describe("Complete walkerOS event structure"),Ee=Ce.partial().describe("Partial event structure with all fields optional"),Je=ue.z.lazy(()=>Ce.deepPartial()).describe("Deep partial event structure with all nested fields optional"),xe=(0,pe.zodToJsonSchema)(Ce,{target:"jsonSchema7",$refStrategy:"relative",name:"Event"}),Pe=(0,pe.zodToJsonSchema)(Ee,{target:"jsonSchema7",$refStrategy:"relative",name:"PartialEvent"}),Te=(0,pe.zodToJsonSchema)(Se,{target:"jsonSchema7",$refStrategy:"relative",name:"User"}),ke=(0,pe.zodToJsonSchema)(be,{target:"jsonSchema7",$refStrategy:"relative",name:"Properties"}),De=(0,pe.zodToJsonSchema)(fe,{target:"jsonSchema7",$refStrategy:"relative",name:"OrderedProperties"}),Oe=(0,pe.zodToJsonSchema)(je,{target:"jsonSchema7",$refStrategy:"relative",name:"Entity"}),Ie=(0,pe.zodToJsonSchema)(he,{target:"jsonSchema7",$refStrategy:"relative",name:"SourceType"}),$e=(0,pe.zodToJsonSchema)(ye,{target:"jsonSchema7",$refStrategy:"relative",name:"Consent"}),qe={};r(qe,{ConfigSchema:()=>Ke,LoopSchema:()=>Ve,MapSchema:()=>Ue,PolicySchema:()=>He,ResultSchema:()=>Fe,RuleSchema:()=>We,RulesSchema:()=>_e,SetSchema:()=>Be,ValueConfigSchema:()=>Ne,ValueSchema:()=>Re,ValuesSchema:()=>Ae,configJsonSchema:()=>ot,loopJsonSchema:()=>Xe,mapJsonSchema:()=>Ze,policyJsonSchema:()=>et,ruleJsonSchema:()=>tt,rulesJsonSchema:()=>nt,setJsonSchema:()=>Ye,valueConfigJsonSchema:()=>Qe,valueJsonSchema:()=>Ge});var Me=require("zod"),Le=require("zod-to-json-schema"),Re=Me.z.lazy(()=>Me.z.union([Me.z.string().describe('String value or property path (e.g., "data.id")'),Me.z.number().describe("Numeric value"),Me.z.boolean().describe("Boolean value"),Ne,Me.z.array(Re).describe("Array of values")])),Ae=Me.z.array(Re).describe("Array of transformation values"),Ve=Me.z.tuple([Re,Re]).describe("Loop transformation: [source, transform] tuple for array processing"),Be=Me.z.array(Re).describe("Set: Array of values for selection or combination"),Ue=Me.z.record(Me.z.string(),Re).describe("Map: Object mapping keys to transformation values"),Ne=Me.z.object({key:Me.z.string().optional().describe('Property path to extract from event (e.g., "data.id", "user.email")'),value:Me.z.union([Me.z.string(),Me.z.number(),Me.z.boolean()]).optional().describe("Static primitive value"),fn:Me.z.string().optional().describe("Custom transformation function as string (serialized)"),map:Ue.optional().describe("Object mapping: transform event data to structured output"),loop:Ve.optional().describe("Loop transformation: [source, transform] for array processing"),set:Be.optional().describe("Set of values: combine or select from multiple values"),consent:ye.optional().describe("Required consent states to include this value"),condition:Me.z.string().optional().describe("Condition function as string: return true to include value"),validate:Me.z.string().optional().describe("Validation function as string: return true if value is valid")}).refine(e=>Object.keys(e).length>0,{message:"ValueConfig must have at least one property"}).describe("Value transformation configuration with multiple strategies"),He=Me.z.record(Me.z.string(),Re).describe("Policy rules for event pre-processing (key → value mapping)"),We=Me.z.object({batch:Me.z.number().optional().describe("Batch size: bundle N events for batch processing"),condition:Me.z.string().optional().describe("Condition function as string: return true to process event"),consent:ye.optional().describe("Required consent states to process this event"),settings:Me.z.any().optional().describe("Destination-specific settings for this event mapping"),data:Me.z.union([Re,Ae]).optional().describe("Data transformation rules for event"),ignore:Me.z.boolean().optional().describe("Set to true to skip processing this event"),name:Me.z.string().optional().describe('Custom event name override (e.g., "view_item" for "product view")'),policy:He.optional().describe("Event-level policy overrides (applied after config-level policy)")}).describe("Mapping rule for specific entity-action combination"),_e=Me.z.record(Me.z.string(),Me.z.record(Me.z.string(),Me.z.union([We,Me.z.array(We)])).optional()).describe("Nested mapping rules: { entity: { action: Rule | Rule[] } } with wildcard support"),Ke=Me.z.object({consent:ye.optional().describe("Required consent states to process any events"),data:Me.z.union([Re,Ae]).optional().describe("Global data transformation applied to all events"),mapping:_e.optional().describe("Entity-action specific mapping rules"),policy:He.optional().describe("Pre-processing policy rules applied before mapping")}).describe("Shared mapping configuration for sources and destinations"),Fe=Me.z.object({eventMapping:We.optional().describe("Resolved mapping rule for event"),mappingKey:Me.z.string().optional().describe('Mapping key used (e.g., "product.view")')}).describe("Mapping resolution result"),Ge=(0,Le.zodToJsonSchema)(Re,{target:"jsonSchema7",$refStrategy:"relative",name:"Value"}),Qe=(0,Le.zodToJsonSchema)(Ne,{target:"jsonSchema7",$refStrategy:"relative",name:"ValueConfig"}),Xe=(0,Le.zodToJsonSchema)(Ve,{target:"jsonSchema7",$refStrategy:"relative",name:"Loop"}),Ye=(0,Le.zodToJsonSchema)(Be,{target:"jsonSchema7",$refStrategy:"relative",name:"Set"}),Ze=(0,Le.zodToJsonSchema)(Ue,{target:"jsonSchema7",$refStrategy:"relative",name:"Map"}),et=(0,Le.zodToJsonSchema)(He,{target:"jsonSchema7",$refStrategy:"relative",name:"Policy"}),tt=(0,Le.zodToJsonSchema)(We,{target:"jsonSchema7",$refStrategy:"relative",name:"Rule"}),nt=(0,Le.zodToJsonSchema)(_e,{target:"jsonSchema7",$refStrategy:"relative",name:"Rules"}),ot=(0,Le.zodToJsonSchema)(Ke,{target:"jsonSchema7",$refStrategy:"relative",name:"MappingConfig"}),it={};r(it,{BatchSchema:()=>bt,ConfigSchema:()=>st,ContextSchema:()=>dt,DLQSchema:()=>Ct,DataSchema:()=>ft,DestinationPolicySchema:()=>lt,DestinationsSchema:()=>zt,InitDestinationsSchema:()=>St,InitSchema:()=>yt,InstanceSchema:()=>ht,PartialConfigSchema:()=>ct,PushBatchContextSchema:()=>pt,PushContextSchema:()=>ut,PushEventSchema:()=>mt,PushEventsSchema:()=>gt,PushResultSchema:()=>jt,RefSchema:()=>vt,ResultSchema:()=>wt,batchJsonSchema:()=>Tt,configJsonSchema:()=>Et,contextJsonSchema:()=>xt,instanceJsonSchema:()=>kt,partialConfigJsonSchema:()=>Jt,pushContextJsonSchema:()=>Pt,resultJsonSchema:()=>Dt});var rt=require("zod"),at=require("zod-to-json-schema"),st=rt.z.object({consent:ye.optional().describe("Required consent states to send events to this destination"),settings:rt.z.any().describe("Implementation-specific configuration").optional(),data:rt.z.union([Re,Ae]).optional().describe("Global data transformation applied to all events for this destination"),env:rt.z.any().describe("Environment dependencies (platform-specific)").optional(),id:E.describe("Destination instance identifier (defaults to destination key)").optional(),init:rt.z.boolean().describe("Whether to initialize immediately").optional(),loadScript:rt.z.boolean().describe("Whether to load external script (for web destinations)").optional(),mapping:_e.optional().describe("Entity-action specific mapping rules for this destination"),policy:He.optional().describe("Pre-processing policy rules applied before event mapping"),queue:rt.z.boolean().describe("Whether to queue events when consent is not granted").optional(),verbose:rt.z.boolean().describe("Enable verbose logging for debugging").optional(),onError:L.optional(),onLog:R.optional()}).describe("Destination configuration"),ct=st.deepPartial().describe("Partial destination configuration with all fields deeply optional"),lt=He.describe("Destination policy rules for event pre-processing"),dt=rt.z.object({collector:rt.z.any().describe("Collector instance (runtime object)"),config:st.describe("Destination configuration"),data:rt.z.union([rt.z.any(),rt.z.undefined(),rt.z.array(rt.z.union([rt.z.any(),rt.z.undefined()]))]).optional().describe("Transformed event data"),env:rt.z.any().describe("Environment dependencies")}).describe("Destination context for init and push functions"),ut=dt.extend({mapping:We.optional().describe("Resolved mapping rule for this specific event")}).describe("Push context with event-specific mapping"),pt=ut.describe("Batch push context with event-specific mapping"),mt=rt.z.object({event:Ce.describe("The event to process"),mapping:We.optional().describe("Mapping rule for this event")}).describe("Event with optional mapping for batch processing"),gt=rt.z.array(mt).describe("Array of events with mappings"),bt=rt.z.object({key:rt.z.string().describe('Batch key (usually mapping key like "product.view")'),events:rt.z.array(Ce).describe("Array of events in batch"),data:rt.z.array(rt.z.union([rt.z.any(),rt.z.undefined(),rt.z.array(rt.z.union([rt.z.any(),rt.z.undefined()]))])).describe("Transformed data for each event"),mapping:We.optional().describe("Shared mapping rule for batch")}).describe("Batch of events grouped by mapping key"),ft=rt.z.union([rt.z.any(),rt.z.undefined(),rt.z.array(rt.z.union([rt.z.any(),rt.z.undefined()]))]).describe("Transformed event data (Property, undefined, or array)"),ht=rt.z.object({config:st.describe("Destination configuration"),queue:rt.z.array(Ce).optional().describe("Queued events awaiting consent"),dlq:rt.z.array(rt.z.tuple([Ce,rt.z.any()])).optional().describe("Dead letter queue (failed events with errors)"),type:rt.z.string().optional().describe("Destination type identifier"),env:rt.z.any().optional().describe("Environment dependencies"),init:rt.z.any().optional().describe("Initialization function"),push:rt.z.any().describe("Push function for single events"),pushBatch:rt.z.any().optional().describe("Batch push function"),on:rt.z.any().optional().describe("Event lifecycle hook function")}).describe("Destination instance (runtime object with functions)"),yt=rt.z.object({code:ht.describe("Destination instance with implementation"),config:ct.optional().describe("Partial configuration overrides"),env:rt.z.any().optional().describe("Partial environment overrides")}).describe("Destination initialization configuration"),St=rt.z.record(rt.z.string(),yt).describe("Map of destination IDs to initialization configurations"),zt=rt.z.record(rt.z.string(),ht).describe("Map of destination IDs to runtime instances"),vt=rt.z.object({id:rt.z.string().describe("Destination ID"),destination:ht.describe("Destination instance")}).describe("Destination reference (ID + instance)"),jt=rt.z.object({queue:rt.z.array(Ce).optional().describe("Events queued (awaiting consent)"),error:rt.z.any().optional().describe("Error if push failed")}).describe("Push operation result"),wt=rt.z.object({successful:rt.z.array(vt).describe("Destinations that processed successfully"),queued:rt.z.array(vt).describe("Destinations that queued events"),failed:rt.z.array(vt).describe("Destinations that failed to process")}).describe("Overall destination processing result"),Ct=rt.z.array(rt.z.tuple([Ce,rt.z.any()])).describe("Dead letter queue: [(event, error), ...]"),Et=(0,at.zodToJsonSchema)(st,{target:"jsonSchema7",$refStrategy:"relative",name:"DestinationConfig"}),Jt=(0,at.zodToJsonSchema)(ct,{target:"jsonSchema7",$refStrategy:"relative",name:"PartialDestinationConfig"}),xt=(0,at.zodToJsonSchema)(dt,{target:"jsonSchema7",$refStrategy:"relative",name:"DestinationContext"}),Pt=(0,at.zodToJsonSchema)(ut,{target:"jsonSchema7",$refStrategy:"relative",name:"PushContext"}),Tt=(0,at.zodToJsonSchema)(bt,{target:"jsonSchema7",$refStrategy:"relative",name:"Batch"}),kt=(0,at.zodToJsonSchema)(ht,{target:"jsonSchema7",$refStrategy:"relative",name:"DestinationInstance"}),Dt=(0,at.zodToJsonSchema)(wt,{target:"jsonSchema7",$refStrategy:"relative",name:"DestinationResult"}),Ot={};r(Ot,{CommandTypeSchema:()=>qt,ConfigSchema:()=>Mt,DestinationsSchema:()=>Bt,InitConfigSchema:()=>Rt,InstanceSchema:()=>Ut,PushContextSchema:()=>At,SessionDataSchema:()=>Lt,SourcesSchema:()=>Vt,commandTypeJsonSchema:()=>Nt,configJsonSchema:()=>Ht,initConfigJsonSchema:()=>_t,instanceJsonSchema:()=>Ft,pushContextJsonSchema:()=>Kt,sessionDataJsonSchema:()=>Wt});var It=require("zod"),$t=require("zod-to-json-schema"),qt=It.z.union([It.z.enum(["action","config","consent","context","destination","elb","globals","hook","init","link","run","user","walker"]),It.z.string()]).describe("Collector command type: standard commands or custom string for extensions"),Mt=It.z.object({run:It.z.boolean().describe("Whether to run collector automatically on initialization").optional(),tagging:P,globalsStatic:be.describe("Static global properties that persist across collector runs"),sessionStatic:It.z.record(It.z.any()).describe("Static session data that persists across collector runs"),verbose:It.z.boolean().describe("Enable verbose logging for debugging"),onError:L.optional(),onLog:R.optional()}).describe("Core collector configuration"),Lt=be.and(It.z.object({isStart:It.z.boolean().describe("Whether this is a new session start"),storage:It.z.boolean().describe("Whether storage is available"),id:E.describe("Session identifier").optional(),start:J.describe("Session start timestamp").optional(),marketing:It.z.literal(!0).optional().describe("Marketing attribution flag"),updated:J.describe("Last update timestamp").optional(),isNew:It.z.boolean().describe("Whether this is a new session").optional(),device:E.describe("Device identifier").optional(),count:x.describe("Event count in session").optional(),runs:x.describe("Number of runs").optional()})).describe("Session state and tracking data"),Rt=Mt.partial().extend({consent:ye.optional().describe("Initial consent state"),user:Se.optional().describe("Initial user data"),globals:be.optional().describe("Initial global properties"),sources:It.z.any().optional().describe("Source configurations"),destinations:It.z.any().optional().describe("Destination configurations"),custom:be.optional().describe("Initial custom implementation-specific properties")}).describe("Collector initialization configuration with initial state"),At=It.z.object({mapping:Ke.optional().describe("Source-level mapping configuration")}).describe("Push context with optional source mapping"),Vt=It.z.record(It.z.string(),It.z.any()).describe("Map of source IDs to source instances"),Bt=It.z.record(It.z.string(),It.z.any()).describe("Map of destination IDs to destination instances"),Ut=It.z.object({push:It.z.any().describe("Push function for processing events"),command:It.z.any().describe("Command function for walker commands"),allowed:It.z.boolean().describe("Whether event processing is allowed"),config:Mt.describe("Current collector configuration"),consent:ye.describe("Current consent state"),count:It.z.number().describe("Event count (increments with each event)"),custom:be.describe("Custom implementation-specific properties"),sources:Vt.describe("Registered source instances"),destinations:Bt.describe("Registered destination instances"),globals:be.describe("Current global properties"),group:It.z.string().describe("Event grouping identifier"),hooks:It.z.any().describe("Lifecycle hook functions"),on:It.z.any().describe("Event lifecycle configuration"),queue:It.z.array(Ce).describe("Queued events awaiting processing"),round:It.z.number().describe("Collector run count (increments with each run)"),session:It.z.union([It.z.undefined(),Lt]).describe("Current session state"),timing:It.z.number().describe("Event processing timing information"),user:Se.describe("Current user data"),version:It.z.string().describe("Walker implementation version")}).describe("Collector instance with state and methods"),Nt=(0,$t.zodToJsonSchema)(qt,{target:"jsonSchema7",$refStrategy:"relative",name:"CommandType"}),Ht=(0,$t.zodToJsonSchema)(Mt,{target:"jsonSchema7",$refStrategy:"relative",name:"CollectorConfig"}),Wt=(0,$t.zodToJsonSchema)(Lt,{target:"jsonSchema7",$refStrategy:"relative",name:"SessionData"}),_t=(0,$t.zodToJsonSchema)(Rt,{target:"jsonSchema7",$refStrategy:"relative",name:"InitConfig"}),Kt=(0,$t.zodToJsonSchema)(At,{target:"jsonSchema7",$refStrategy:"relative",name:"CollectorPushContext"}),Ft=(0,$t.zodToJsonSchema)(Ut,{target:"jsonSchema7",$refStrategy:"relative",name:"CollectorInstance"}),Gt={};r(Gt,{BaseEnvSchema:()=>Yt,ConfigSchema:()=>Zt,InitSchema:()=>nn,InitSourceSchema:()=>on,InitSourcesSchema:()=>rn,InstanceSchema:()=>tn,PartialConfigSchema:()=>en,baseEnvJsonSchema:()=>an,configJsonSchema:()=>sn,initSourceJsonSchema:()=>dn,initSourcesJsonSchema:()=>un,instanceJsonSchema:()=>ln,partialConfigJsonSchema:()=>cn});var Qt=require("zod"),Xt=require("zod-to-json-schema"),Yt=Qt.z.object({push:Qt.z.any().describe("Collector push function"),command:Qt.z.any().describe("Collector command function"),sources:Qt.z.any().optional().describe("Map of registered source instances"),elb:Qt.z.any().describe("Public API function (alias for collector.push)")}).catchall(Qt.z.unknown()).describe("Base environment for dependency injection - platform-specific sources extend this"),Zt=Ke.extend({settings:Qt.z.any().describe("Implementation-specific configuration").optional(),env:Yt.optional().describe("Environment dependencies (platform-specific)"),id:E.describe("Source identifier (defaults to source key)").optional(),onError:L.optional(),disabled:Qt.z.boolean().describe("Set to true to disable").optional(),primary:Qt.z.boolean().describe("Mark as primary (only one can be primary)").optional()}).describe("Source configuration with mapping and environment"),en=Zt.deepPartial().describe("Partial source configuration with all fields deeply optional"),tn=Qt.z.object({type:Qt.z.string().describe('Source type identifier (e.g., "browser", "dataLayer")'),config:Zt.describe("Current source configuration"),push:Qt.z.any().describe("Push function - THE HANDLER (flexible signature for platform compatibility)"),destroy:Qt.z.any().optional().describe("Cleanup function called when source is removed"),on:Qt.z.any().optional().describe("Lifecycle hook function for event types")}).describe("Source instance with push handler and lifecycle methods"),nn=Qt.z.any().describe("Source initialization function: (config, env) => Instance | Promise<Instance>"),on=Qt.z.object({code:nn.describe("Source initialization function"),config:en.optional().describe("Partial configuration overrides"),env:Yt.partial().optional().describe("Partial environment overrides"),primary:Qt.z.boolean().optional().describe("Mark as primary source (only one can be primary)")}).describe("Source initialization configuration"),rn=Qt.z.record(Qt.z.string(),on).describe("Map of source IDs to initialization configurations"),an=(0,Xt.zodToJsonSchema)(Yt,{target:"jsonSchema7",$refStrategy:"relative",name:"SourceBaseEnv"}),sn=(0,Xt.zodToJsonSchema)(Zt,{target:"jsonSchema7",$refStrategy:"relative",name:"SourceConfig"}),cn=(0,Xt.zodToJsonSchema)(en,{target:"jsonSchema7",$refStrategy:"relative",name:"PartialSourceConfig"}),ln=(0,Xt.zodToJsonSchema)(tn,{target:"jsonSchema7",$refStrategy:"relative",name:"SourceInstance"}),dn=(0,Xt.zodToJsonSchema)(on,{target:"jsonSchema7",$refStrategy:"relative",name:"InitSource"}),un=(0,Xt.zodToJsonSchema)(rn,{target:"jsonSchema7",$refStrategy:"relative",name:"InitSources"});function pn(e,t){const n=[],o={};for(const[t,i]of Object.entries(e)){i.required&&n.push(t);const e={type:i.type};if(i.description&&(e.description=i.description),i.pattern&&(e.pattern=i.pattern),void 0!==i.minLength&&(e.minLength=i.minLength),void 0!==i.maxLength&&(e.maxLength=i.maxLength),void 0!==i.minimum&&(e.minimum=i.minimum),void 0!==i.maximum&&(e.maximum=i.maximum),i.enum&&(e.enum=[...i.enum]),void 0!==i.default&&(e.default=i.default),"object"===i.type&&i.properties){const t={};for(const[e,n]of Object.entries(i.properties))t[e]=mn(n);e.properties=t}"array"===i.type&&i.items&&(e.items=mn(i.items)),o[t]=e}const i={type:"object",properties:o};return t&&(i.title=t),n.length>0&&(i.required=n),i}function mn(e){const t={type:e.type};if(e.description&&(t.description=e.description),e.pattern&&(t.pattern=e.pattern),void 0!==e.minLength&&(t.minLength=e.minLength),void 0!==e.maxLength&&(t.maxLength=e.maxLength),void 0!==e.minimum&&(t.minimum=e.minimum),void 0!==e.maximum&&(t.maximum=e.maximum),e.enum&&(t.enum=[...e.enum]),void 0!==e.default&&(t.default=e.default),"object"===e.type&&e.properties){const n={};for(const[t,o]of Object.entries(e.properties))n[t]=mn(o);t.properties=n}return"array"===e.type&&e.items&&(t.items=mn(e.items)),t}function gn(e,t){const n={type:"array",items:mn(e)};return void 0!==t?.minItems&&(n.minItems=t.minItems),void 0!==t?.maxItems&&(n.maxItems=t.maxItems),t?.description&&(n.description=t.description),t?.title&&(n.title=t.title),n}function bn(e,t="string",n){const o={type:t,enum:[...e]};return n?.description&&(o.description=n.description),n?.title&&(o.title=n.title),o}function fn(e,t,n){return gn({type:"object"},{minItems:2,maxItems:2,description:n||"Tuple with exactly 2 elements [source, transform]"})}var hn=require("zod"),yn=require("zod-to-json-schema"),Sn=require("zod-to-json-schema");function zn(e){return(0,Sn.zodToJsonSchema)(e,{target:"jsonSchema7",$refStrategy:"none"})}function vn(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}var jn={merge:!0,shallow:!0,extend:!0};function wn(e,t={},n={}){n={...jn,...n};const o=Object.entries(t).reduce((t,[o,i])=>{const r=e[o];return n.merge&&Array.isArray(r)&&Array.isArray(i)?t[o]=i.reduce((e,t)=>e.includes(t)?e:[...e,t],[...r]):(n.extend||o in e)&&(t[o]=i),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function Cn(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function En(e){return Array.isArray(e)}function Jn(e){return"boolean"==typeof e}function xn(e){return"walker"===e}function Pn(e){return void 0!==e}function Tn(e){return e===document||e instanceof Element}function kn(e){return"function"==typeof e}function Dn(e){return"number"==typeof e&&!Number.isNaN(e)}function On(e){return"object"==typeof e&&null!==e&&!En(e)&&"[object Object]"===Object.prototype.toString.call(e)}function In(e,t){return typeof e==typeof t}function $n(e){return"string"==typeof e}function qn(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=qn(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(qn(e,t))}),n}if("[object Date]"===n)return new Date(e.getTime());if("[object RegExp]"===n){const t=e;return new RegExp(t.source,t.flags)}return e}function Mn(e,t="",n){const o=t.split(".");let i=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&En(i)){const t=o.slice(e+1).join("."),r=[];for(const e of i){const o=Mn(e,t,n);r.push(o)}return r}if(i=i instanceof Object?i[t]:void 0,!i)break}return Pn(i)?i:n}function Ln(e,t,n){if(!On(e))return e;const o=qn(e),i=t.split(".");let r=o;for(let e=0;e<i.length;e++){const t=i[e];e===i.length-1?r[t]=n:(t in r&&"object"==typeof r[t]&&null!==r[t]||(r[t]={}),r=r[t])}return o}function Rn(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function An(e,t={},n={}){const o={...t,...n},i={};let r=void 0===e;return Object.keys(o).forEach(t=>{o[t]&&(i[t]=!0,e&&e[t]&&(r=!0))}),!!r&&i}function Vn(e,t){const n={...e};return n.config=wn(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=wn(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=wn(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function Bn(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",o=e.count||1,i=wn({name:"entity action",data:{string:"foo",number:1,boolean:!0,array:[0,"text",!1],not:void 0},context:{dev:["test",1]},globals:{lang:"elb"},custom:{completely:"random"},user:{id:"us3r",device:"c00k13",session:"s3ss10n"},nested:[{entity:"child",data:{is:"subordinated"},nested:[],context:{element:["child",0]}}],consent:{functional:!0},id:`${t}-${n}-${o}`,trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,group:n,count:o,version:{source:"0.3.0",tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.name){const[t,n]=e.name.split(" ")??[];t&&n&&(i.entity=t,i.action=n)}return i}function Un(e="entity action",t={}){const n=t.timestamp||(new Date).setHours(0,13,37,0),o={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},i={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return Bn({...{"cart view":{data:{currency:"EUR",value:2*o.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",data:{...o.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:o.data.price+i.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...o,context:{shopping:["checkout",0]},nested:[]},{entity:"product",...i,context:{shopping:["checkout",0]},nested:[]}],trigger:"load"},"order complete":{data:{id:"0rd3r1d",currency:"EUR",shipping:5.22,taxes:73.76,total:555},context:{shopping:["complete",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...o,context:{shopping:["complete",0]},nested:[]},{entity:"product",...i,context:{shopping:["complete",0]},nested:[]},{entity:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.elbwalker.com/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":{...o,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...o,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...o.data,position:3,promo:!0},context:{shopping:["discover",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"promotion visible":{data:{name:"Setting up tracking easily",position:"hero"},context:{ab_test:["engagement",0]},globals:{pagegroup:"homepage"},trigger:"visible"},"session start":{data:{id:"s3ss10n",start:n,isNew:!0,count:1,runs:1,isStart:!0,storage:!0,referrer:"",device:"c00k13"},user:{id:"us3r",device:"c00k13",session:"s3ss10n",hash:"h4sh",address:"street number",email:"user@example.com",phone:"+49 123 456 789",userAgent:"Mozilla...",browser:"Chrome",browserVersion:"90",deviceType:"desktop",language:"de-DE",country:"DE",region:"HH",city:"Hamburg",zip:"20354",timezone:"Berlin",os:"walkerOS",osVersion:"1.0",screenSize:"1337x420",ip:"127.0.0.0",internal:!0,custom:"value"}}}[e],...t,name:e})}function Nn(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function Hn(e,t={}){const 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(wn(i,t)).forEach(([t,i])=>{const r=e.searchParams.get(t);r&&(i===n&&(i=t,o[n]=t),o[i]=r)}),o}function Wn(e,t=1e3,n=!1){let o,i=null,r=!1;return(...a)=>new Promise(s=>{const c=n&&!r;i&&clearTimeout(i),i=setTimeout(()=>{i=null,n&&!r||(o=e(...a),s(o))},t),c&&(r=!0,o=e(...a),s(o))})}function _n(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}function Kn(e){return Jn(e)||$n(e)||Dn(e)||!Pn(e)||En(e)&&e.every(Kn)||On(e)&&Object.values(e).every(Kn)}function Fn(e){return Jn(e)||$n(e)||Dn(e)?e:Cn(e)?Fn(Array.from(e)):En(e)?e.map(e=>Fn(e)).filter(e=>void 0!==e):On(e)?Object.entries(e).reduce((e,[t,n])=>{const o=Fn(n);return void 0!==o&&(e[t]=o),e},{}):void 0}function Gn(e){return Kn(e)?e:void 0}function Qn(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function Xn(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(n?.())}}}async function Yn(e,t){const[n,o]=(e.name||"").split(" ");if(!t||!n||!o)return{};let i,r="",a=n,s=o;const c=t=>{if(t)return(t=En(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[a]||(a="*");const l=t[a];return l&&(l[s]||(s="*"),i=c(l[s])),i||(a="*",s="*",i=c(t[a]?.[s])),i&&(r=`${a} ${s}`),{eventMapping:i,mappingKey:r}}async function Zn(e,t={},n={}){if(!Pn(e))return;const o=On(e)&&e.consent||n.consent||n.collector?.consent,i=En(t)?t:[t];for(const t of i){const i=await Xn(eo)(e,t,{...n,consent:o});if(Pn(i))return i}}async function eo(e,t,n={}){const{collector:o,consent:i}=n;return(En(t)?t:[t]).reduce(async(t,r)=>{const a=await t;if(a)return a;const s=$n(r)?{key:r}:r;if(!Object.keys(s).length)return;const{condition:c,consent:l,fn:d,key:u,loop:p,map:m,set:g,validate:b,value:f}=s;if(c&&!await Xn(c)(e,r,o))return;if(l&&!An(l,i))return f;let h=Pn(f)?f:e;if(d&&(h=await Xn(d)(e,r,n)),u&&(h=Mn(e,u,f)),p){const[t,o]=p,i="this"===t?[e]:await Zn(e,t,n);En(i)&&(h=(await Promise.all(i.map(e=>Zn(e,o,n)))).filter(Pn))}else m?h=await Object.entries(m).reduce(async(t,[o,i])=>{const r=await t,a=await Zn(e,i,n);return Pn(a)&&(r[o]=a),r},Promise.resolve({})):g&&(h=await Promise.all(g.map(t=>eo(e,t,n))));b&&!await Xn(b)(h)&&(h=void 0);const y=Gn(h);return Pn(y)?y:Gn(f)},Promise.resolve(void 0))}async function to(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const i=await Zn(e,o,{collector:n});e=Ln(e,t,i)}));const{eventMapping:o,mappingKey:i}=await Yn(e,t.mapping);o?.policy&&await Promise.all(Object.entries(o.policy).map(async([t,o])=>{const i=await Zn(e,o,{collector:n});e=Ln(e,t,i)}));let r=t.data&&await Zn(e,t.data,{collector:n});if(o){if(o.ignore)return{event:e,data:r,mapping:o,mappingKey:i,ignore:!0};if(o.name&&(e.name=o.name),o.data){const t=o.data&&await Zn(e,o.data,{collector:n});r=On(r)&&On(t)?wn(r,t):t}}return{event:e,data:r,mapping:o,mappingKey:i,ignore:!1}}function no(e,t){const n=(e,o=[])=>new Proxy(e,{get(e,i){const r=e[i],a=[...o,i];return"function"==typeof r?(...e)=>t(a,e,r):r&&"object"==typeof r?n(r,a):r}});return n(e)}function oo(e,t){const n=(e,o=[])=>{if(!e||"object"!=typeof e)return e;const i=Array.isArray(e)?[]:{};for(const[r,a]of Object.entries(e)){const e=[...o,r];Array.isArray(i)?i[Number(r)]=t(a,e):i[r]=t(a,e),a&&"object"==typeof a&&"function"!=typeof a&&(Array.isArray(i)?i[Number(r)]=n(a,e):i[r]=n(a,e))}return i};return n(e)}function io(e,t=!1){t&&console.dir(e,{depth:4})}function ro(e){const t=String(e),n=t.split("?")[1]||t;return Qn(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const o=n.split(/[[\]]+/).filter(Boolean);let i=t;o.forEach((t,n)=>{const r=n===o.length-1;if(En(i)){const a=parseInt(t,10);r?i[a]=Rn(e):(i[a]=i[a]||(isNaN(parseInt(o[n+1],10))?{}:[]),i=i[a])}else On(i)&&(r?i[t]=Rn(e):(i[t]=i[t]||(isNaN(parseInt(o[n+1],10))?{}:[]),i=i[t]))})}),t})()}function ao(e){if(!e)return"";const t=[],n=encodeURIComponent;function o(e,i){null!=i&&(En(i)?i.forEach((t,n)=>o(`${e}[${n}]`,t)):On(i)?Object.entries(i).forEach(([t,n])=>o(`${e}[${t}]`,n)):t.push(`${n(e)}=${n(String(i))}`))}return"object"!=typeof e?n(e):(Object.entries(e).forEach(([e,t])=>o(e,t)),t.join("&"))}function so(e){return void 0===e||In(e,"")?e:JSON.stringify(e)}function co(e={}){return wn({"Content-Type":"application/json; charset=utf-8"},e)}function lo(e){throw new Error(String(e))}function uo(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function po(e,t,n){return function(...o){let i;const r="post"+t,a=n["pre"+t],s=n[r];return i=a?a({fn:e},...o):e(...o),s&&(i=s({fn:e,result:i},...o)),i}}function mo(e){return e?{userAgent:e,browser:go(e),browserVersion:bo(e),os:fo(e),osVersion:ho(e),deviceType:yo(e)}:{}}function go(e){const t=[{name:"Edge",substr:"Edg"},{name:"Chrome",substr:"Chrome"},{name:"Safari",substr:"Safari",exclude:"Chrome"},{name:"Firefox",substr:"Firefox"},{name:"IE",substr:"MSIE"},{name:"IE",substr:"Trident"}];for(const n of t)if(e.includes(n.substr)&&(!n.exclude||!e.includes(n.exclude)))return n.name}function bo(e){const t=[/Edg\/([0-9]+)/,/Chrome\/([0-9]+)/,/Version\/([0-9]+).*Safari/,/Firefox\/([0-9]+)/,/MSIE ([0-9]+)/,/rv:([0-9]+).*Trident/];for(const n of t){const t=e.match(n);if(t)return t[1]}}function fo(e){const t=[{name:"Windows",substr:"Windows NT"},{name:"macOS",substr:"Mac OS X"},{name:"Android",substr:"Android"},{name:"iOS",substr:"iPhone OS"},{name:"Linux",substr:"Linux"}];for(const n of t)if(e.includes(n.substr))return n.name}function ho(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function yo(e){let t="Desktop";return/Tablet|iPad/i.test(e)?t="Tablet":/Mobi|Android|iPhone|iPod|BlackBerry|Opera Mini|IEMobile|WPDesktop/i.test(e)&&(t="Mobile"),t}function So(e,t=[]){let n,o,i;In(e,{})||lo("Invalid object"),In(e.name,"")?(n=e.name,[o,i]=n.split(" "),o&&i||lo("Invalid event name")):In(e.entity,"")&&In(e.action,"")?(o=e.entity,i=e.action,n=`${o} ${i}`):lo("Missing or invalid name, entity, or action");const r={name:n,data:{},context:{},custom:{},globals:{},user:{},nested:[],consent:{},id:"",trigger:"",entity:o,action:i,timestamp:0,timing:0,group:"",count:0,version:{source:"",tagging:0},source:{type:"",id:"",previous_id:""}};return[{"*":{"*":{name:{maxLength:255},user:{allowedKeys:["id","device","session"]},consent:{allowedValues:[!0,!1]},timestamp:{min:0},timing:{min:0},count:{min:0},version:{allowedKeys:["source","tagging"]},source:{allowedKeys:["type","id","previous_id"]}}}}].concat(t).reduce((e,t)=>["*",o].reduce((e,n)=>["*",i].reduce((e,o)=>{const i=t[n]?.[o];return i?e.concat([i]):e},e),e),[]).reduce((t,n)=>{const o=Object.keys(n).filter(e=>{const t=n[e];return!0===t?.required});return[...Object.keys(e),...o].reduce((t,o)=>{const i=n[o];let r=e[o];return i&&(r=Qn(zo,e=>{lo(String(e))})(t,o,r,i)),In(r,t[o])&&(t[o]=r),t},t)},r)}function zo(e,t,n,o){if(o.validate&&(n=Qn(o.validate,e=>{lo(String(e))})(n,t,e)),o.required&&void 0===n&&lo("Missing required property"),In(n,""))o.maxLength&&n.length>o.maxLength&&(o.strict&&lo("Value exceeds maxLength"),n=n.substring(0,o.maxLength));else if(In(n,1))In(o.min,1)&&n<o.min?(o.strict&&lo("Value below min"),n=o.min):In(o.max,1)&&n>o.max&&(o.strict&&lo("Value exceeds max"),n=o.max);else if(In(n,{})){if(o.schema){const e=o.schema;Object.keys(e).reduce((t,n)=>{const o=e[n];let i=t[n];return o&&(o.type&&typeof i!==o.type&&lo(`Type doesn't match (${n})`),i=Qn(zo,e=>{lo(String(e))})(t,n,i,o)),i},n)}for(const e of Object.keys(n))o.allowedKeys&&!o.allowedKeys.includes(e)&&(o.strict&&lo("Key not allowed"),delete n[e])}return n}//# sourceMappingURL=index.js.map