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