@walkeros/core 3.1.0-next-1773969156384 → 3.1.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 CHANGED
@@ -2961,7 +2961,7 @@ declare function resolveContracts(contracts: Contract): Record<string, ContractE
2961
2961
  */
2962
2962
  declare function mergeContractSchemas(parent: Record<string, unknown>, child: Record<string, unknown>): Record<string, unknown>;
2963
2963
 
2964
- declare function mcpResult(result: unknown, summary?: string, hints?: {
2964
+ declare function mcpResult(result: unknown, hints?: {
2965
2965
  next?: string[];
2966
2966
  warnings?: string[];
2967
2967
  }): {
package/dist/index.d.ts CHANGED
@@ -2961,7 +2961,7 @@ declare function resolveContracts(contracts: Contract): Record<string, ContractE
2961
2961
  */
2962
2962
  declare function mergeContractSchemas(parent: Record<string, unknown>, child: Record<string, unknown>): Record<string, unknown>;
2963
2963
 
2964
- declare function mcpResult(result: unknown, summary?: string, hints?: {
2964
+ declare function mcpResult(result: unknown, hints?: {
2965
2965
  next?: string[];
2966
2966
  warnings?: string[];
2967
2967
  }): {
package/dist/index.js CHANGED
@@ -1 +1 @@
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})},s={};r(s,{Collector:()=>a,Const:()=>O,Context:()=>c,Destination:()=>l,ENV_MARKER_PREFIX:()=>L,Elb:()=>d,Flow:()=>p,Hint:()=>E,Hooks:()=>u,Level:()=>b,Lifecycle:()=>k,Logger:()=>f,Mapping:()=>g,Matcher:()=>x,On:()=>m,Request:()=>z,Simulation:()=>j,Source:()=>v,Store:()=>y,Transformer:()=>h,Trigger:()=>w,WalkerOS:()=>S,anonymizeIP:()=>C,assign:()=>F,branch:()=>P,castToProperty:()=>je,castValue:()=>ce,clone:()=>re,compileMatcher:()=>on,createDestination:()=>de,createEvent:()=>pe,createLogger:()=>ye,createMockLogger:()=>De,createRespond:()=>tn,debounce:()=>ge,fetchPackage:()=>Xe,fetchPackageSchema:()=>Ye,filterValues:()=>Se,getBrowser:()=>Ue,getBrowserVersion:()=>We,getByPath:()=>se,getDeviceType:()=>He,getEvent:()=>ue,getFlowSettings:()=>B,getGrantedConsent:()=>le,getHeaders:()=>Te,getId:()=>fe,getMappingEvent:()=>Oe,getMappingValue:()=>Pe,getMarketingParameters:()=>be,getOS:()=>_e,getOSVersion:()=>Be,getPlatform:()=>H,isArguments:()=>K,isArray:()=>G,isBoolean:()=>Z,isCommand:()=>Q,isDefined:()=>X,isElementOrDocument:()=>Y,isFunction:()=>ee,isNumber:()=>ne,isObject:()=>te,isPropertyType:()=>ke,isSameType:()=>ie,isString:()=>oe,mcpError:()=>nn,mcpResult:()=>en,mergeConfigSchema:()=>ai,mergeContractSchemas:()=>R,mockEnv:()=>$e,packageNameToVariable:()=>W,parseUserAgent:()=>Je,processEventMapping:()=>Ne,requestToData:()=>Re,requestToParameter:()=>Ie,resolveContracts:()=>D,setByPath:()=>ae,throttle:()=>me,throwError:()=>N,transformData:()=>Me,traverseEnv:()=>Ae,trim:()=>qe,tryCatch:()=>xe,tryCatchAsync:()=>Ee,useHooks:()=>Le,walkPath:()=>J,wrapCondition:()=>Fe,wrapFn:()=>Ke,wrapValidate:()=>Ge}),module.exports=(e=s,((e,r,s,a)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let c of i(r))o.call(e,c)||c===s||n(e,c,{get:()=>r[c],enumerable:!(a=t(r,c))||a.enumerable});return e})(n({},"__esModule",{value:!0}),e));var a={},c={},l={},d={},p={},u={},f={};r(f,{Level:()=>b});var b=(e=>(e[e.ERROR=0]="ERROR",e[e.WARN=1]="WARN",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e))(b||{}),g={},m={},h={},z={},v={},y={},w={},k={},S={},j={},x={},E={},O={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function P(e,n){return{event:e,next:n}}function C(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}function N(e){throw new Error(String(e))}var $=["globals","context","custom","user","consent"],A=new Set(["description","examples","title","$comment"]);function D(e){const n={},t=new Set;function i(o){if(n[o])return n[o];t.has(o)&&N(`Circular extends chain detected: ${[...t,o].join(" → ")}`);const r=e[o];r||N(`Contract "${o}" not found`),t.add(o);let s={};if(r.extends){s=function(e,n){const t={};void 0===e.tagging&&void 0===n.tagging||(t.tagging=n.tagging??e.tagging);void 0===e.description&&void 0===n.description||(t.description=n.description??e.description);for(const i of $){const o=e[i],r=n[i];o&&r?t[i]=R(o,r):(o||r)&&(t[i]={...o||r})}if(e.events||n.events){const i={},o=new Set([...Object.keys(e.events||{}),...Object.keys(n.events||{})]);for(const t of o){const o=e.events?.[t]||{},r=n.events?.[t]||{},s=new Set([...Object.keys(o),...Object.keys(r)]);i[t]={};for(const e of s){const n=o[e],s=r[e];i[t][e]=n&&s?R(n,s):{...n||s}}}t.events=i}return t}(i(r.extends),r)}else s={...r};if(delete s.extends,s.events&&(s.events=function(e){const n={};for(const t of Object.keys(e))if("*"!==t){n[t]={};for(const i of Object.keys(e[t]||{})){let o={};const r=e["*"]?.["*"];r&&(o=R(o,r));const s=e["*"]?.[i];s&&"*"!==i&&(o=R(o,s));const a=e[t]?.["*"];a&&"*"!==i&&(o=R(o,a));const c=e[t]?.[i];c&&(o=R(o,c)),n[t][i]=o}}e["*"]&&(n["*"]={...e["*"]});return n}(s.events)),s.events){const e={};for(const[n,t]of Object.entries(s.events)){e[n]={};for(const[i,o]of Object.entries(t))e[n][i]=I(o)}s.events=e}return t.delete(o),n[o]=s,s}for(const n of Object.keys(e))i(n);return n}function R(e,n){const t={...e};for(const i of Object.keys(n)){const o=e[i],r=n[i];"required"===i&&Array.isArray(o)&&Array.isArray(r)?t[i]=[...new Set([...o,...r])]:M(o)&&M(r)?t[i]=R(o,r):t[i]=r}return t}function I(e){const n={};for(const[t,i]of Object.entries(e))A.has(t)||(null===i||"object"!=typeof i||Array.isArray(i)?n[t]=i:n[t]=I(i));return n}function M(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function T(...e){const n={};for(const t of e)t&&Object.assign(n,t);return n}function q(...e){const n={};for(const t of e)t&&Object.assign(n,t);return n}var L="__WALKEROS_ENV:";function J(e,n,t){const i=n.split(".");let o=e;for(let e=0;e<i.length;e++){const r=i[e];if(null==o||"object"!=typeof o){const o=i.slice(0,e).join(".");N(`Path "${n}" not found in "${t}": "${r}" does not exist${o?` in "${o}"`:""}`)}const s=o;if(!(r in s)){const o=i.slice(0,e).join(".");N(`Path "${n}" not found in "${t}": "${r}" does not exist${o?` in "${o}"`:""}`)}o=s[r]}return o}function U(e,n,t,i,o){if("string"==typeof e){const r=e.match(/^\$def\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/);if(r){const e=r[1],s=r[2];void 0===t[e]&&N(`Definition "${e}" not found`);let a=U(t[e],n,t,i,o);return s&&(a=J(a,s,`$def.${e}`)),a}const s=e.match(/^\$contract\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/);if(s&&o){const e=s[1],n=s[2];e in o||N(`Contract "${e}" not found`);let t=o[e];return n&&(t=J(t,n,`$contract.${e}`)),t}let a=e.replace(/\$var\.([a-zA-Z_][a-zA-Z0-9_]*)/g,(e,t)=>{if(void 0!==n[t])return String(n[t]);N(`Variable "${t}" not found`)});return a=a.replace(/\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g,(e,n,t)=>i?.deferred?void 0!==t?`${L}${n}:${t}`:`${L}${n}`:"undefined"!=typeof process&&void 0!==process.env?.[n]?process.env[n]:void 0!==t?t:void N(`Environment variable "${n}" not found and no default provided`)),a}if(Array.isArray(e))return e.map(e=>U(e,n,t,i,o));if(null!==e&&"object"==typeof e){const r={};for(const[s,a]of Object.entries(e))r[s]=U(a,n,t,i,o);return r}return e}function W(e){const n=e.startsWith("@"),t=e.replace("@","").replace(/[/-]/g,"_").split("_").filter(e=>e.length>0).map((e,n)=>0===n?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");return n?"_"+t:t}function _(e,n,t){if(n)return n;if(!e||!t)return;return t[e]?W(e):void 0}function B(e,n,t){const i=Object.keys(e.flows);n||(1===i.length?n=i[0]:N(`Multiple flows found (${i.join(", ")}). Please specify a flow.`));const o=e.flows[n];o||N(`Flow "${n}" not found. Available: ${i.join(", ")}`);const r=JSON.parse(JSON.stringify(o));let s;if(e.contract){const n=T(e.variables,o.variables),i=q(e.definitions,o.definitions);s=D(U(e.contract,n,i,t))}if(r.sources)for(const[n,i]of Object.entries(r.sources)){const a=T(e.variables,o.variables,i.variables),c=q(e.definitions,o.definitions,i.definitions),l=U(i.config,a,c,t,s),d=U(i.env,a,c,t,s),p=_(i.package,i.code,r.packages),u="string"==typeof i.code||"object"==typeof i.code?i.code:void 0,f=p||u;r.sources[n]={package:i.package,config:l,env:d,primary:i.primary,variables:i.variables,definitions:i.definitions,next:i.next,code:f}}if(r.destinations)for(const[n,i]of Object.entries(r.destinations)){const a=T(e.variables,o.variables,i.variables),c=q(e.definitions,o.definitions,i.definitions),l=U(i.config,a,c,t,s),d=U(i.env,a,c,t,s),p=_(i.package,i.code,r.packages),u="string"==typeof i.code||"object"==typeof i.code?i.code:void 0,f=p||u;r.destinations[n]={package:i.package,config:l,env:d,variables:i.variables,definitions:i.definitions,before:i.before,code:f}}if(r.stores)for(const[n,i]of Object.entries(r.stores)){const a=T(e.variables,o.variables,i.variables),c=q(e.definitions,o.definitions,i.definitions),l=U(i.config,a,c,t,s),d=U(i.env,a,c,t,s),p=_(i.package,i.code,r.packages),u="string"==typeof i.code||"object"==typeof i.code?i.code:void 0,f=p||u;r.stores[n]={package:i.package,config:l,env:d,variables:i.variables,definitions:i.definitions,code:f}}if(r.transformers)for(const[n,i]of Object.entries(r.transformers)){const a=T(e.variables,o.variables,i.variables),c=q(e.definitions,o.definitions,i.definitions),l=U(i.config,a,c,t,s),d=U(i.env,a,c,t,s),p=_(i.package,i.code,r.packages),u="string"==typeof i.code||"object"==typeof i.code?i.code:void 0,f=p||u;r.transformers[n]={package:i.package,config:l,env:d,variables:i.variables,definitions:i.definitions,next:i.next,code:f}}if(r.collector){const n=T(e.variables,o.variables),i=q(e.definitions,o.definitions),a=U(r.collector,n,i,t,s);r.collector=a}return r}function H(e){return void 0!==e.web?"web":void 0!==e.server?"server":void N("Settings must have web or server key")}var V={merge:!0,shallow:!0,extend:!0};function F(e,n={},t={}){t={...V,...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 K(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function G(e){return Array.isArray(e)}function Z(e){return"boolean"==typeof e}function Q(e){return"walker"===e}function X(e){return void 0!==e}function Y(e){return e===document||e instanceof Element}function ee(e){return"function"==typeof e}function ne(e){return"number"==typeof e&&!Number.isNaN(e)}function te(e){return"object"==typeof e&&null!==e&&!G(e)&&"[object Object]"===Object.prototype.toString.call(e)}function ie(e,n){return typeof e==typeof n}function oe(e){return"string"==typeof e}function re(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]=re(e[i],n));return t}if("[object Array]"===t){const t=[];return n.set(e,t),e.forEach(e=>{t.push(re(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 se(e,n="",t){const i=n.split(".");let o=e;for(let e=0;e<i.length;e++){const n=i[e];if("*"===n&&G(o)){const n=i.slice(e+1).join("."),r=[];for(const e of o){const i=se(e,n,t);r.push(i)}return r}if(o=o instanceof Object?o[n]:void 0,void 0===o)break}return X(o)?o:t}function ae(e,n,t){if(!te(e))return e;const i=re(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 ce(e){if("true"===e)return!0;if("false"===e)return!1;const n=Number(e);return e==n&&""!==e?n:String(e)}function le(e,n={},t={}){const i={...n,...t},o={};let r=!e||0===Object.keys(e).length;return Object.keys(i).forEach(n=>{i[n]&&(o[n]=!0,e&&e[n]&&(r=!0))}),!!r&&o}function de(e,n){const t={...e};return t.config=F(e.config,n,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&n.settings&&(t.config.settings=F(e.config.settings,n.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&n.mapping&&(t.config.mapping=F(e.config.mapping,n.mapping,{shallow:!0,merge:!0,extend:!0})),t}function pe(e={}){const n=e.timestamp||(new Date).setHours(0,13,37,0),t=e.group||"gr0up",i=e.count||1,o=F({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:"3.0.2",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 ue(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 pe({...{"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.walkeros.io/",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 fe(e=6){let n="";for(let t=36;n.length<e;)n+=(Math.random()*t|0).toString(t);return n}function be(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(F(o,n)).forEach(([n,o])=>{const r=e.searchParams.get(n);r&&(o===t&&(o=n,i[t]=n),i[o]=r)}),i}function ge(e,n=1e3,t=!1){let i,o=null,r=!1;return(...s)=>new Promise(a=>{const c=t&&!r;o&&clearTimeout(o),o=setTimeout(()=>{o=null,t&&!r||(i=e(...s),a(i))},n),c&&(r=!0,i=e(...s),a(i))})}function me(e,n=1e3){let t=null;return function(...i){if(null===t)return t=setTimeout(()=>{t=null},n),e(...i)}}function he(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function ze(e,n){let t,i={};return e instanceof Error?(t=e.message,i.error=he(e)):t=e,void 0!==n&&(n instanceof Error?i.error=he(n):"object"==typeof n&&null!==n?(i={...i,...n},"error"in i&&i.error instanceof Error&&(i.error=he(i.error))):i.value=n),{message:t,context:i}}var ve=(e,n,t,i)=>{const o=`${b[e]}${i.length>0?` [${i.join(":")}]`:""}`,r=Object.keys(t).length>0,s=0===e?console.error:1===e?console.warn:console.log;r?s(o,n,t):s(o,n)};function ye(e={}){return we({level:void 0!==e.level?function(e){return"string"==typeof e?b[e]:e}(e.level):0,handler:e.handler,jsonHandler:e.jsonHandler,scope:[]})}function we(e){const{level:n,handler:t,jsonHandler:i,scope:o}=e,r=(e,i,r)=>{if(e<=n){const n=ze(i,r);t?t(e,n.message,n.context,o,ve):ve(e,n.message,n.context,o)}};return{error:(e,n)=>r(0,e,n),warn:(e,n)=>r(1,e,n),info:(e,n)=>r(2,e,n),debug:(e,n)=>r(3,e,n),throw:(e,n)=>{const i=ze(e,n);throw t?t(0,i.message,i.context,o,ve):ve(0,i.message,i.context,o),new Error(i.message)},json:e=>{i?i(e):console.log(JSON.stringify(e,null,2))},scope:e=>we({level:n,handler:t,jsonHandler:i,scope:[...o,e]})}}function ke(e){return Z(e)||oe(e)||ne(e)||!X(e)||G(e)&&e.every(ke)||te(e)&&Object.values(e).every(ke)}function Se(e){return Z(e)||oe(e)||ne(e)?e:K(e)?Se(Array.from(e)):G(e)?e.map(e=>Se(e)).filter(e=>void 0!==e):te(e)?Object.entries(e).reduce((e,[n,t])=>{const i=Se(t);return void 0!==i&&(e[n]=i),e},{}):void 0}function je(e){return ke(e)?e:void 0}function xe(e,n,t){return function(...i){try{return e(...i)}catch(e){if(!n)return;return n(e)}finally{t?.()}}}function Ee(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 Oe(e,n){const[t,i]=(e.name||"").split(" ");if(!n||!t||!i)return{};let o,r="",s=t,a=i;const c=n=>{if(n)return(n=G(n)?n:[n]).find(n=>!n.condition||n.condition(e))};n[s]||(s="*");const l=n[s];return l&&(l[a]||(a="*"),o=c(l[a])),o||(s="*",a="*",o=c(n[s]?.[a])),o&&(r=`${s} ${a}`),{eventMapping:o,mappingKey:r}}async function Pe(e,n={},t={}){if(!X(e))return;const i=te(e)&&e.consent||t.consent||t.collector?.consent,o=G(n)?n:[n];for(const n of o){const o=await Ee(Ce)(e,n,{...t,consent:i});if(X(o))return o}}async function Ce(e,n,t={}){const{collector:i,consent:o}=t;return(G(n)?n:[n]).reduce(async(n,r)=>{const s=await n;if(s)return s;const a=oe(r)?{key:r}:r;if(!Object.keys(a).length)return;const{condition:c,consent:l,fn:d,key:p,loop:u,map:f,set:b,validate:g,value:m}=a;if(c&&!await Ee(c)(e,r,i))return;if(l&&!le(l,o))return m;let h=X(m)?m:e;if(d&&(h=await Ee(d)(e,r,t)),p&&(h=se(e,p,m)),u){const[n,i]=u,o="this"===n?[e]:await Pe(e,n,t);G(o)&&(h=(await Promise.all(o.map(e=>Pe(e,i,t)))).filter(X))}else f?h=await Object.entries(f).reduce(async(n,[i,o])=>{const r=await n,s=await Pe(e,o,t);return X(s)&&(r[i]=s),r},Promise.resolve({})):b&&(h=await Promise.all(b.map(n=>Ce(e,n,t))));g&&!await Ee(g)(h)&&(h=void 0);const z=je(h);return X(z)?z:je(m)},Promise.resolve(void 0))}async function Ne(e,n,t){n.policy&&await Promise.all(Object.entries(n.policy).map(async([n,i])=>{const o=await Pe(e,i,{collector:t});e=ae(e,n,o)}));const{eventMapping:i,mappingKey:o}=await Oe(e,n.mapping);i?.policy&&await Promise.all(Object.entries(i.policy).map(async([n,i])=>{const o=await Pe(e,i,{collector:t});e=ae(e,n,o)}));let r=n.data&&await Pe(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 Pe(e,i.data,{collector:t});r=te(r)&&te(n)?F(r,n):n}}return{event:e,data:r,mapping:i,mappingKey:o,ignore:!1}}function $e(e,n){const t=(e,i=[])=>new Proxy(e,{get(e,o){const r=e[o],s=[...i,o];return"function"==typeof r?(...e)=>n(s,e,r):r&&"object"==typeof r?t(r,s):r}});return t(e)}function Ae(e,n){const t=(e,i=[])=>{if(!e||"object"!=typeof e)return e;const o=Array.isArray(e)?[]:{};for(const[r,s]of Object.entries(e)){const e=[...i,r];Array.isArray(o)?o[Number(r)]=n(s,e):o[r]=n(s,e),s&&"object"==typeof s&&"function"!=typeof s&&(Array.isArray(o)?o[Number(r)]=t(s,e):o[r]=t(s,e))}return o};return t(e)}function De(){const e=[],n=jest.fn(e=>{const n=e instanceof Error?e.message:e;throw new Error(n)}),t=jest.fn(n=>{const t=De();return e.push(t),t});return{error:jest.fn(),warn:jest.fn(),info:jest.fn(),debug:jest.fn(),throw:n,json:jest.fn(),scope:t,scopedLoggers:e}}function Re(e){const n=String(e),t=n.split("?")[1]||n;return xe(()=>{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(G(o)){const s=parseInt(n,10);r?o[s]=ce(e):(o[s]=o[s]||(isNaN(parseInt(i[t+1],10))?{}:[]),o=o[s])}else te(o)&&(r?o[n]=ce(e):(o[n]=o[n]||(isNaN(parseInt(i[t+1],10))?{}:[]),o=o[n]))})}),n})()}function Ie(e){if(!e)return"";const n=[],t=encodeURIComponent;function i(e,o){null!=o&&(G(o)?o.forEach((n,t)=>i(`${e}[${t}]`,n)):te(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 Me(e){return void 0===e||ie(e,"")?e:JSON.stringify(e)}function Te(e={}){return F({"Content-Type":"application/json; charset=utf-8"},e)}function qe(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function Le(e,n,t){return function(...i){let o;const r="post"+n,s=t["pre"+n],a=t[r];return o=s?s({fn:e},...i):e(...i),a&&(o=a({fn:e,result:o},...i)),o}}function Je(e){return e?{userAgent:e,browser:Ue(e),browserVersion:We(e),os:_e(e),osVersion:Be(e),deviceType:He(e)}:{}}function Ue(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 We(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 _e(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 Be(e){const n=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return n?n[1].replace(/_/g,"."):void 0}function He(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 Ve(e){return function(e){return/\breturn\b/.test(e)}(e)?e:`return ${e}`}function Fe(e){const n=Ve(e);return new Function("value","mapping","collector",n)}function Ke(e){const n=Ve(e);return new Function("value","mapping","options",n)}function Ge(e){const n=Ve(e);return new Function("value",n)}var Ze="https://cdn.jsdelivr.net/npm",Qe="dist/walkerOS.json";async function Xe(e,n){const t=n?.version||"latest",i=`${Ze}/${e}@${t}`,o=new AbortController,r=setTimeout(()=>o.abort(),n?.timeout||1e4);try{const n=await fetch(`${i}/package.json`,{signal:o.signal});if(!n.ok)throw new Error(`Package "${e}" not found on npm (HTTP ${n.status})`);const r=await n.json(),a=await fetch(`${i}/${Qe}`,{signal:o.signal});if(!a.ok)throw new Error(`walkerOS.json not found at ${Qe} (HTTP ${a.status}). This package may not support the walkerOS.json convention yet.`);const c=await a.json(),l=c.$meta||{},d=c.schemas||{},p=c.examples||{},u=c.hints,f=u?Object.keys(u):[],b=[],g=p.step||{};for(const[e,n]of Object.entries(g)){const t=n,i={name:e};"string"==typeof t?.description&&(i.description=t.description),b.push(i)}const m="string"==typeof l.docs?l.docs:void 0,h="string"==typeof l.source?l.source:void 0;return{packageName:e,version:"string"==typeof r.version?r.version:t,description:"string"==typeof r.description?r.description:void 0,type:"string"==typeof l.type?l.type:void 0,platform:(s=l.platform,"string"==typeof s||Array.isArray(s)&&s.every(e=>"string"==typeof e)?s:void 0),schemas:d,examples:p,...m?{docs:m}:{},...h?{source:h}:{},...u&&Object.keys(u).length>0?{hints:u}:{},hintKeys:f,exampleSummaries:b}}finally{clearTimeout(r)}var s}async function Ye(e,n){const t=await Xe(e,n);return{packageName:t.packageName,version:t.version,type:t.type,platform:t.platform,schemas:t.schemas,examples:t.examples,...t.hints?{hints:t.hints}:{}}}function en(e,n,t){const i=t?{...e,_hints:t}:e;return{content:[{type:"text",text:n??JSON.stringify(i,null,2)}],structuredContent:i}}function nn(e,n){let t,i,o,r;if(e instanceof Error){t=e.message;const n=e;n.code&&(o=n.code),Array.isArray(n.details)&&(r=n.details)}else if("string"==typeof e)t=e;else if(e&&"object"==typeof e&&"issues"in e&&Array.isArray(e.issues)){const n=e.issues;t=n.map(e=>e.message).join("; "),i=n[0]?.path?.join(".")||void 0}else t=e&&"object"==typeof e&&"message"in e?String(e.message):"Unknown error";const s={error:t};return n&&(s.hint=n),i&&(s.path=i),o&&(s.code=o),r&&(s.details=r),{content:[{type:"text",text:JSON.stringify(s)}],structuredContent:s,isError:!0}}function tn(e){let n=!1;return(t={})=>{n||(n=!0,e(t))}}function on(e){if("*"===e)return()=>!0;if("and"in e){const n=e.and.map(on);return e=>n.every(n=>n(e))}if("or"in e){const n=e.or.map(on);return e=>n.some(n=>n(e))}return function(e){const{key:n,operator:t,value:i,not:o}=e,r=function(e,n){switch(e){case"eq":return e=>String(e??"")===n;case"contains":return e=>String(e??"").includes(n);case"prefix":return e=>String(e??"").startsWith(n);case"suffix":return e=>String(e??"").endsWith(n);case"regex":{const e=new RegExp(n);return n=>e.test(String(n??""))}case"gt":{const e=Number(n);return n=>Number(n)>e}case"lt":{const e=Number(n);return n=>Number(n)<e}case"exists":return e=>null!=e}}(t,i);return e=>{const t=e[n],i=r(t);return o?!i:i}}(e)}var rn=require("zod");function sn(e,n,t="draft-7"){return rn.z.toJSONSchema(e,{target:t})}var an,cn=rn.z.string(),ln=rn.z.number(),dn=(rn.z.boolean(),rn.z.string().min(1)),pn=rn.z.number().int().positive(),un=rn.z.number().int().nonnegative(),fn=rn.z.number().describe("Tagging version number"),bn=(rn.z.union([rn.z.string(),rn.z.number(),rn.z.boolean()]).optional(),rn.z.enum(["local","session","cookie"]).describe("Storage mechanism: local, session, or cookie")),gn=rn.z.object({Local:rn.z.literal("local"),Session:rn.z.literal("session"),Cookie:rn.z.literal("cookie")}).describe("Storage type constants for type-safe references"),mn=rn.z.any().describe("Error handler function: (error, state?) => void"),hn=rn.z.any().describe("Log handler function: (message, verbose?) => void"),zn=rn.z.object({Error:mn.describe("Error handler function"),Log:hn.describe("Log handler function")}).describe("Handler interface with error and log functions"),vn=(sn(bn),sn(gn),sn(mn),sn(hn),sn(zn),rn.z.object({onError:mn.optional().describe("Error handler function: (error, state?) => void"),onLog:hn.optional().describe("Log handler function: (message, verbose?) => void")}).partial(),rn.z.object({verbose:rn.z.boolean().describe("Enable verbose logging for debugging").optional()}).partial(),rn.z.object({queue:rn.z.boolean().describe("Whether to queue events when consent is not granted").optional()}).partial(),rn.z.object({}).partial(),rn.z.object({init:rn.z.boolean().describe("Whether to initialize immediately").optional(),loadScript:rn.z.boolean().describe("Whether to load external script (for web destinations)").optional()}).partial(),rn.z.object({primary:rn.z.boolean().describe("Mark as primary (only one can be primary)").optional()}).partial(),rn.z.object({settings:rn.z.any().optional().describe("Implementation-specific configuration")}).partial(),rn.z.object({env:rn.z.any().optional().describe("Environment dependencies (platform-specific)")}).partial(),rn.z.object({type:rn.z.string().optional().describe("Instance type identifier"),config:rn.z.unknown().describe("Instance configuration")}).partial(),rn.z.object({collector:rn.z.unknown().describe("Collector instance (runtime object)"),config:rn.z.unknown().describe("Configuration"),env:rn.z.unknown().describe("Environment dependencies")}).partial(),rn.z.object({batch:rn.z.number().optional().describe("Batch size: bundle N events for batch processing"),batched:rn.z.unknown().optional().describe("Batch of events to be processed")}).partial(),rn.z.object({ignore:rn.z.boolean().describe("Set to true to skip processing").optional(),condition:rn.z.string().optional().describe("Condition function: return true to process")}).partial(),rn.z.object({sources:rn.z.record(rn.z.string(),rn.z.unknown()).describe("Map of source instances")}).partial(),rn.z.object({destinations:rn.z.record(rn.z.string(),rn.z.unknown()).describe("Map of destination instances")}).partial(),rn.z.lazy(()=>rn.z.union([rn.z.boolean(),rn.z.string(),rn.z.number(),rn.z.record(rn.z.string(),yn)]))),yn=rn.z.lazy(()=>rn.z.union([vn,rn.z.array(vn)])),wn=rn.z.record(rn.z.string(),yn.optional()).describe("Flexible property collection with optional values"),kn=rn.z.record(rn.z.string(),rn.z.tuple([yn,rn.z.number()]).optional()).describe("Ordered properties with [value, order] tuples for priority control"),Sn=rn.z.union([rn.z.enum(["web","server","app","other"]),rn.z.string()]).describe("Source type: web, server, app, other, or custom"),jn=rn.z.record(rn.z.string(),rn.z.boolean()).describe("Consent requirement mapping (group name → state)"),xn=wn.and(rn.z.object({id:rn.z.string().optional().describe("User identifier"),device:rn.z.string().optional().describe("Device identifier"),session:rn.z.string().optional().describe("Session identifier"),hash:rn.z.string().optional().describe("Hashed identifier"),address:rn.z.string().optional().describe("User address"),email:rn.z.string().email().optional().describe("User email address"),phone:rn.z.string().optional().describe("User phone number"),userAgent:rn.z.string().optional().describe("Browser user agent string"),browser:rn.z.string().optional().describe("Browser name"),browserVersion:rn.z.string().optional().describe("Browser version"),deviceType:rn.z.string().optional().describe("Device type (mobile, desktop, tablet)"),os:rn.z.string().optional().describe("Operating system"),osVersion:rn.z.string().optional().describe("Operating system version"),screenSize:rn.z.string().optional().describe("Screen dimensions"),language:rn.z.string().optional().describe("User language"),country:rn.z.string().optional().describe("User country"),region:rn.z.string().optional().describe("User region/state"),city:rn.z.string().optional().describe("User city"),zip:rn.z.string().optional().describe("User postal code"),timezone:rn.z.string().optional().describe("User timezone"),ip:rn.z.string().optional().describe("User IP address"),internal:rn.z.boolean().optional().describe("Internal user flag (employee, test user)")})).describe("User identification and properties"),En=wn.and(rn.z.object({source:cn.describe('Walker implementation version (e.g., "2.0.0")'),tagging:fn})).describe("Walker version information"),On=wn.and(rn.z.object({type:Sn.describe("Source type identifier"),id:cn.describe("Source identifier (typically URL on web)"),previous_id:cn.describe("Previous source identifier (typically referrer on web)")})).describe("Event source information"),Pn=rn.z.lazy(()=>rn.z.object({entity:rn.z.string().describe("Entity name"),data:wn.describe("Entity-specific properties"),nested:rn.z.array(Pn).describe("Nested child entities"),context:kn.describe("Entity context data")})).describe("Nested entity structure with recursive nesting support"),Cn=rn.z.array(Pn).describe("Array of nested entities"),Nn=rn.z.object({name:rn.z.string().describe('Event name in "entity action" format (e.g., "page view", "product add")'),data:wn.describe("Event-specific properties"),context:kn.describe("Ordered context properties with priorities"),globals:wn.describe("Global properties shared across events"),custom:wn.describe("Custom implementation-specific properties"),user:xn.describe("User identification and attributes"),nested:Cn.describe("Related nested entities"),consent:jn.describe("Consent states at event time"),id:dn.describe("Unique event identifier (timestamp-based)"),trigger:cn.describe("Event trigger identifier"),entity:cn.describe("Parsed entity from event name"),action:cn.describe("Parsed action from event name"),timestamp:pn.describe("Unix timestamp in milliseconds since epoch"),timing:ln.describe("Event processing timing information"),group:cn.describe("Event grouping identifier"),count:un.describe("Event count in session"),version:En.describe("Walker version information"),source:On.describe("Event source information")}).describe("Complete walkerOS event structure"),$n=Nn.partial().describe("Partial event structure with all fields optional"),An=(Nn.partial().describe("Partial event structure with all top-level fields optional"),sn(Nn),sn($n),sn(xn),sn(wn),sn(kn),sn(Pn),sn(Sn),sn(jn),rn.z.lazy(()=>rn.z.union([rn.z.string().describe('String value or property path (e.g., "data.id")'),rn.z.number().describe("Numeric value"),rn.z.boolean().describe("Boolean value"),rn.z.lazy(()=>an),rn.z.array(An).describe("Array of values")]))),Dn=rn.z.array(An).describe("Array of transformation values"),Rn=rn.z.lazy(()=>rn.z.tuple([An,An]).describe("Loop transformation: [source, transform] tuple for array processing")),In=rn.z.lazy(()=>rn.z.array(An).describe("Set: Array of values for selection or combination")),Mn=rn.z.lazy(()=>rn.z.record(rn.z.string(),An).describe("Map: Object mapping keys to transformation values")),Tn=an=rn.z.object({key:rn.z.string().optional().describe('Property path to extract from event (e.g., "data.id", "user.email")'),value:rn.z.union([rn.z.string(),rn.z.number(),rn.z.boolean()]).optional().describe("Static primitive value"),fn:rn.z.string().optional().describe("Custom transformation function as string (serialized)"),map:Mn.optional().describe("Object mapping: transform event data to structured output"),loop:Rn.optional().describe("Loop transformation: [source, transform] for array processing"),set:In.optional().describe("Set of values: combine or select from multiple values"),consent:jn.optional().describe("Required consent states to include this value"),condition:rn.z.string().optional().describe("Condition function as string: return true to include value"),validate:rn.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"),qn=rn.z.record(rn.z.string(),An).describe("Policy rules for event pre-processing (key → value mapping)"),Ln=rn.z.object({batch:rn.z.number().optional().describe("Batch size: bundle N events for batch processing"),condition:rn.z.string().optional().describe("Condition function as string: return true to process event"),consent:jn.optional().describe("Required consent states to process this event"),settings:rn.z.any().optional().describe("Destination-specific settings for this event mapping"),data:rn.z.union([An,Dn]).optional().describe("Data transformation rules for event"),ignore:rn.z.boolean().optional().describe("Set to true to skip processing this event"),name:rn.z.string().optional().describe('Custom event name override (e.g., "view_item" for "product view")'),policy:qn.optional().describe("Event-level policy overrides (applied after config-level policy)")}).describe("Mapping rule for specific entity-action combination"),Jn=rn.z.record(rn.z.string(),rn.z.record(rn.z.string(),rn.z.union([Ln,rn.z.array(Ln)])).optional()).describe('Event mapping rules: entity → action → Rule. Keys match event name split by space. Use "*" as wildcard for entity or action. Priority: exact > entity wildcard > action wildcard > global wildcard (*→*).'),Un=rn.z.object({consent:jn.optional().describe("Required consent states to process any events"),data:rn.z.union([An,Dn]).optional().describe("Global data transformation applied to all events"),mapping:Jn.optional().describe("Entity-action specific mapping rules"),policy:qn.optional().describe("Pre-processing policy rules applied before mapping")}).describe("Shared mapping configuration for sources and destinations"),Wn=(rn.z.object({eventMapping:Ln.optional().describe("Resolved mapping rule for event"),mappingKey:rn.z.string().optional().describe('Mapping key used (e.g., "product.view")')}).describe("Mapping resolution result"),sn(An),sn(Tn),sn(Rn),sn(In),sn(Mn),sn(qn),sn(Ln),sn(Jn),sn(Un),{});r(Wn,{BatchSchema:()=>Qn,ConfigSchema:()=>_n,ContextSchema:()=>Vn,DLQSchema:()=>st,DataSchema:()=>Xn,DestinationPolicySchema:()=>Hn,DestinationsSchema:()=>tt,InitDestinationsSchema:()=>nt,InitSchema:()=>et,InstanceSchema:()=>Yn,PartialConfigSchema:()=>Bn,PushBatchContextSchema:()=>Kn,PushContextSchema:()=>Fn,PushEventSchema:()=>Gn,PushEventsSchema:()=>Zn,PushResultSchema:()=>ot,RefSchema:()=>it,ResultSchema:()=>rt,batchJsonSchema:()=>pt,configJsonSchema:()=>at,contextJsonSchema:()=>lt,instanceJsonSchema:()=>ut,partialConfigJsonSchema:()=>ct,pushContextJsonSchema:()=>dt,resultJsonSchema:()=>ft});var _n=rn.z.object({consent:jn.optional().describe("Required consent states to send events to this destination"),settings:rn.z.any().describe("Implementation-specific configuration").optional(),data:rn.z.union([An,Dn]).optional().describe("Global data transformation applied to all events for this destination"),env:rn.z.any().describe("Environment dependencies (platform-specific)").optional(),id:dn.describe("Destination instance identifier (defaults to destination key)").optional(),init:rn.z.boolean().describe("Whether to initialize immediately").optional(),loadScript:rn.z.boolean().describe("Whether to load external script (for web destinations)").optional(),mapping:Jn.optional().describe("Entity-action specific mapping rules for this destination"),policy:qn.optional().describe("Pre-processing policy rules applied before event mapping"),queue:rn.z.boolean().describe("Whether to queue events when consent is not granted").optional(),require:rn.z.array(rn.z.string()).optional().describe('Defer destination initialization until these collector events fire (e.g., ["consent"])'),logger:rn.z.object({level:rn.z.union([rn.z.number(),rn.z.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:rn.z.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler) to override the collector defaults"),onError:mn.optional(),onLog:hn.optional()}).describe("Destination configuration"),Bn=_n.partial().describe("Partial destination configuration with all fields optional"),Hn=qn.describe("Destination policy rules for event pre-processing"),Vn=rn.z.object({collector:rn.z.unknown().describe("Collector instance (runtime object)"),config:_n.describe("Destination configuration"),data:rn.z.union([rn.z.unknown(),rn.z.array(rn.z.unknown())]).optional().describe("Transformed event data"),env:rn.z.unknown().describe("Environment dependencies")}).describe("Destination context for init and push functions"),Fn=Vn.extend({mapping:Ln.optional().describe("Resolved mapping rule for this specific event")}).describe("Push context with event-specific mapping"),Kn=Fn.describe("Batch push context with event-specific mapping"),Gn=rn.z.object({event:Nn.describe("The event to process"),mapping:Ln.optional().describe("Mapping rule for this event")}).describe("Event with optional mapping for batch processing"),Zn=rn.z.array(Gn).describe("Array of events with mappings"),Qn=rn.z.object({key:rn.z.string().describe('Batch key (usually mapping key like "product.view")'),events:rn.z.array(Nn).describe("Array of events in batch"),data:rn.z.array(rn.z.union([rn.z.unknown(),rn.z.array(rn.z.unknown())]).optional()).describe("Transformed data for each event"),mapping:Ln.optional().describe("Shared mapping rule for batch")}).describe("Batch of events grouped by mapping key"),Xn=rn.z.union([rn.z.unknown(),rn.z.array(rn.z.unknown())]).optional().describe("Transformed event data (Property, undefined, or array)"),Yn=rn.z.object({config:_n.describe("Destination configuration"),queue:rn.z.array(Nn).optional().describe("Queued events awaiting consent"),dlq:rn.z.array(rn.z.tuple([Nn,rn.z.unknown()])).optional().describe("Dead letter queue (failed events with errors)"),type:rn.z.string().optional().describe("Destination type identifier"),env:rn.z.unknown().optional().describe("Environment dependencies"),init:rn.z.unknown().optional().describe("Initialization function"),push:rn.z.unknown().describe("Push function for single events"),pushBatch:rn.z.unknown().optional().describe("Batch push function"),on:rn.z.unknown().optional().describe("Event lifecycle hook function")}).describe("Destination instance (runtime object with functions)"),et=rn.z.object({code:Yn.describe("Destination instance with implementation"),config:Bn.optional().describe("Partial configuration overrides"),env:rn.z.unknown().optional().describe("Partial environment overrides")}).describe("Destination initialization configuration"),nt=rn.z.record(rn.z.string(),et).describe("Map of destination IDs to initialization configurations"),tt=rn.z.record(rn.z.string(),Yn).describe("Map of destination IDs to runtime instances"),it=rn.z.object({type:rn.z.string().describe('Destination type ("gtag", "meta", "bigquery")'),data:rn.z.unknown().optional().describe("Response from push()"),error:rn.z.unknown().optional().describe("Error if failed")}).describe("Destination reference with type and response data"),ot=rn.z.object({queue:rn.z.array(Nn).optional().describe("Events queued (awaiting consent)"),error:rn.z.unknown().optional().describe("Error if push failed")}).describe("Push operation result"),rt=rn.z.object({ok:rn.z.boolean().describe("True if nothing failed"),event:rn.z.unknown().optional().describe("The processed event"),done:rn.z.record(rn.z.string(),it).optional().describe("Destinations that processed successfully"),queued:rn.z.record(rn.z.string(),it).optional().describe("Destinations that queued events"),failed:rn.z.record(rn.z.string(),it).optional().describe("Destinations that failed to process")}).describe("Push result with destination outcomes"),st=rn.z.array(rn.z.tuple([Nn,rn.z.unknown()])).describe("Dead letter queue: [(event, error), ...]"),at=sn(_n),ct=sn(Bn),lt=sn(Vn),dt=sn(Fn),pt=sn(Qn),ut=sn(Yn),ft=sn(rt),bt=rn.z.union([rn.z.enum(["action","config","consent","context","destination","elb","globals","hook","init","link","run","user","walker"]),rn.z.string()]).describe("Collector command type: standard commands or custom string for extensions"),gt=rn.z.object({run:rn.z.boolean().describe("Whether to run collector automatically on initialization").optional(),tagging:fn,globalsStatic:wn.describe("Static global properties that persist across collector runs"),sessionStatic:rn.z.record(rn.z.string(),rn.z.unknown()).describe("Static session data that persists across collector runs"),verbose:rn.z.boolean().describe("Enable verbose logging for debugging"),onError:mn.optional(),onLog:hn.optional()}).describe("Core collector configuration"),mt=wn.and(rn.z.object({isStart:rn.z.boolean().describe("Whether this is a new session start"),storage:rn.z.boolean().describe("Whether storage is available"),id:dn.describe("Session identifier").optional(),start:pn.describe("Session start timestamp").optional(),marketing:rn.z.literal(!0).optional().describe("Marketing attribution flag"),updated:pn.describe("Last update timestamp").optional(),isNew:rn.z.boolean().describe("Whether this is a new session").optional(),device:dn.describe("Device identifier").optional(),count:un.describe("Event count in session").optional(),runs:un.describe("Number of runs").optional()})).describe("Session state and tracking data"),ht=gt.partial().extend({consent:jn.optional().describe("Initial consent state"),user:xn.optional().describe("Initial user data"),globals:wn.optional().describe("Initial global properties"),sources:rn.z.unknown().optional().describe("Source configurations"),destinations:rn.z.unknown().optional().describe("Destination configurations"),custom:wn.optional().describe("Initial custom implementation-specific properties")}).describe("Collector initialization configuration with initial state"),zt=rn.z.object({mapping:Un.optional().describe("Source-level mapping configuration")}).describe("Push context with optional source mapping"),vt=rn.z.record(rn.z.string(),rn.z.unknown()).describe("Map of source IDs to source instances"),yt=rn.z.record(rn.z.string(),rn.z.unknown()).describe("Map of destination IDs to destination instances"),wt=rn.z.object({push:rn.z.unknown().describe("Push function for processing events"),command:rn.z.unknown().describe("Command function for walker commands"),allowed:rn.z.boolean().describe("Whether event processing is allowed"),config:gt.describe("Current collector configuration"),consent:jn.describe("Current consent state"),count:rn.z.number().describe("Event count (increments with each event)"),custom:wn.describe("Custom implementation-specific properties"),sources:vt.describe("Registered source instances"),destinations:yt.describe("Registered destination instances"),globals:wn.describe("Current global properties"),group:rn.z.string().describe("Event grouping identifier"),hooks:rn.z.unknown().describe("Lifecycle hook functions"),on:rn.z.unknown().describe("Event lifecycle configuration"),queue:rn.z.array(Nn).describe("Queued events awaiting processing"),round:rn.z.number().describe("Collector run count (increments with each run)"),session:rn.z.union([mt]).describe("Current session state"),timing:rn.z.number().describe("Event processing timing information"),user:xn.describe("Current user data"),version:rn.z.string().describe("Walker implementation version")}).describe("Collector instance with state and methods"),kt=(sn(bt),sn(gt),sn(mt),sn(ht),sn(zt),sn(wt),{});r(kt,{BaseEnvSchema:()=>St,ConfigSchema:()=>jt,InitSchema:()=>Ot,InitSourceSchema:()=>Pt,InitSourcesSchema:()=>Ct,InstanceSchema:()=>Et,PartialConfigSchema:()=>xt,baseEnvJsonSchema:()=>Nt,configJsonSchema:()=>$t,initSourceJsonSchema:()=>Rt,initSourcesJsonSchema:()=>It,instanceJsonSchema:()=>Dt,partialConfigJsonSchema:()=>At});var St=rn.z.object({push:rn.z.unknown().describe("Collector push function"),command:rn.z.unknown().describe("Collector command function"),sources:rn.z.unknown().optional().describe("Map of registered source instances"),elb:rn.z.unknown().describe("Public API function (alias for collector.push)")}).catchall(rn.z.unknown()).describe("Base environment for dependency injection - platform-specific sources extend this"),jt=Un.extend({settings:rn.z.any().describe("Implementation-specific configuration").optional(),env:St.optional().describe("Environment dependencies (platform-specific)"),id:dn.describe("Source identifier (defaults to source key)").optional(),onError:mn.optional(),primary:rn.z.boolean().describe("Mark as primary (only one can be primary)").optional(),require:rn.z.array(rn.z.string()).optional().describe('Defer source initialization until these collector events fire (e.g., ["consent"])'),logger:rn.z.object({level:rn.z.union([rn.z.number(),rn.z.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:rn.z.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler) to override the collector defaults"),ingest:rn.z.union([An,Dn]).optional().describe("Ingest metadata extraction mapping. Extracts values from raw request objects (Express req, Lambda event) using mapping syntax.")}).describe("Source configuration with mapping and environment"),xt=jt.partial().describe("Partial source configuration with all fields optional"),Et=rn.z.object({type:rn.z.string().describe('Source type identifier (e.g., "browser", "dataLayer")'),config:jt.describe("Current source configuration"),push:rn.z.any().describe("Push function - THE HANDLER (flexible signature for platform compatibility)"),destroy:rn.z.any().optional().describe("Cleanup function called when source is removed"),on:rn.z.unknown().optional().describe("Lifecycle hook function for event types")}).describe("Source instance with push handler and lifecycle methods"),Ot=rn.z.any().describe("Source initialization function: (config, env) => Instance | Promise<Instance>"),Pt=rn.z.object({code:Ot.describe("Source initialization function"),config:xt.optional().describe("Partial configuration overrides"),env:St.partial().optional().describe("Partial environment overrides"),primary:rn.z.boolean().optional().describe("Mark as primary source (only one can be primary)")}).describe("Source initialization configuration"),Ct=rn.z.record(rn.z.string(),Pt).describe("Map of source IDs to initialization configurations"),Nt=sn(St),$t=sn(jt),At=sn(xt),Dt=sn(Et),Rt=sn(Pt),It=sn(Ct),Mt=rn.z.union([rn.z.string(),rn.z.number(),rn.z.boolean()]).describe("Primitive value: string, number, or boolean"),Tt=rn.z.record(rn.z.string(),Mt).describe("Variables for interpolation"),qt=rn.z.record(rn.z.string(),rn.z.unknown()).describe("Reusable configuration definitions"),Lt=rn.z.record(rn.z.string().regex(/^(@[a-z0-9\-~][a-z0-9\-._~]*\/)?[a-z0-9\-~][a-z0-9\-._~]*$/,"Invalid npm package name"),rn.z.object({version:rn.z.string().optional(),imports:rn.z.array(rn.z.string()).optional(),path:rn.z.string().optional()})).describe("NPM packages to bundle"),Jt=rn.z.object({windowCollector:rn.z.string().default("collector").optional().describe('Window property name for the collector instance (default: "collector")'),windowElb:rn.z.string().default("elb").optional().describe('Window property name for the elb command queue (default: "elb")')}).describe("Web platform configuration"),Ut=rn.z.object({}).passthrough().describe("Server platform configuration (reserved for future options)"),Wt=rn.z.object({push:rn.z.string().min(1,"Push function cannot be empty").describe('JavaScript function for processing events. Must start with "$code:" prefix. Example: "$code:(event) => { console.log(event); }"'),type:rn.z.string().optional().describe("Optional type identifier for the inline instance"),init:rn.z.string().optional().describe("Optional initialization function. Use $code: prefix for inline JavaScript.")}).describe("Inline code for custom sources/transformers/destinations"),_t=rn.z.object({description:rn.z.string().optional().describe("Human-readable description"),in:rn.z.unknown().optional().describe("Input to the step"),trigger:rn.z.object({type:rn.z.string().optional().describe("Trigger mechanism (e.g., click, POST, load)"),options:rn.z.unknown().optional().describe("Mechanism-specific options")}).optional().describe("Source trigger metadata"),mapping:rn.z.unknown().optional().describe("Mapping configuration"),out:rn.z.unknown().optional().describe("Expected output from the step")}).describe("Named example with input/output pair"),Bt=rn.z.record(rn.z.string(),_t).describe("Named step examples for testing and documentation"),Ht=rn.z.object({package:rn.z.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/web-source-browser@2.0.0")'),code:rn.z.union([rn.z.string(),Wt]).optional().describe('Either a named export string (e.g., "sourceExpress") or an inline code object with push function'),config:rn.z.unknown().optional().describe("Source-specific configuration object"),env:rn.z.unknown().optional().describe("Source environment configuration"),primary:rn.z.boolean().optional().describe("Mark as primary source (provides main elb). Only one source should be primary."),variables:Tt.optional().describe("Source-level variables (highest priority in cascade)"),definitions:qt.optional().describe("Source-level definitions (highest priority in cascade)"),next:rn.z.union([rn.z.string(),rn.z.array(rn.z.string())]).optional().describe("Pre-collector transformer chain. Name of the first transformer to run after this source captures an event. If omitted, events go directly to the collector. Can be an array for explicit chain control."),examples:Bt.optional().describe("Named step examples for testing and documentation (stripped during bundling)")}).describe("Source package reference with configuration"),Vt=rn.z.object({package:rn.z.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/transformer-enricher@1.0.0")'),code:rn.z.union([rn.z.string(),Wt]).optional().describe('Either a named export string (e.g., "transformerEnricher") or an inline code object with push function'),config:rn.z.unknown().optional().describe("Transformer-specific configuration object"),env:rn.z.unknown().optional().describe("Transformer environment configuration"),next:rn.z.union([rn.z.string(),rn.z.array(rn.z.string())]).optional().describe("Next transformer in chain. If omitted: pre-collector routes to collector, post-collector routes to destination."),variables:Tt.optional().describe("Transformer-level variables (highest priority in cascade)"),definitions:qt.optional().describe("Transformer-level definitions (highest priority in cascade)"),examples:Bt.optional().describe("Named step examples for testing and documentation (stripped during bundling)")}).describe("Transformer package reference with configuration"),Ft=rn.z.object({package:rn.z.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/web-destination-gtag@2.0.0")'),code:rn.z.union([rn.z.string(),Wt]).optional().describe('Either a named export string (e.g., "destinationAnalytics") or an inline code object with push function'),config:rn.z.unknown().optional().describe("Destination-specific configuration object"),env:rn.z.unknown().optional().describe("Destination environment configuration"),variables:Tt.optional().describe("Destination-level variables (highest priority in cascade)"),definitions:qt.optional().describe("Destination-level definitions (highest priority in cascade)"),before:rn.z.union([rn.z.string(),rn.z.array(rn.z.string())]).optional().describe("Post-collector transformer chain. Name of the first transformer to run before sending events to this destination. If omitted, events come directly from the collector. Can be an array for explicit chain control."),examples:Bt.optional().describe("Named step examples for testing and documentation (stripped during bundling)")}).describe("Destination package reference with configuration"),Kt=rn.z.object({package:rn.z.string().min(1,"Package name cannot be empty").optional().describe("Store package specifier with optional version"),code:rn.z.union([rn.z.string(),Wt]).optional().describe("Named export string or inline code definition"),config:rn.z.unknown().optional().describe("Store-specific configuration object"),env:rn.z.unknown().optional().describe("Store environment configuration"),variables:Tt.optional().describe("Store-level variables (highest priority in cascade)"),definitions:qt.optional().describe("Store-level definitions (highest priority in cascade)"),examples:Bt.optional().describe("Named step examples for testing and documentation (stripped during bundling)")}).describe("Store package reference with configuration"),Gt=rn.z.record(rn.z.string(),rn.z.unknown()).describe("JSON Schema object for event validation with description/examples annotations"),Zt=rn.z.record(rn.z.string(),Gt).describe("Action-level contract entries"),Qt=rn.z.record(rn.z.string(),Zt).describe("Entity-action event schemas"),Xt=rn.z.object({extends:rn.z.string().optional().describe("Inherit from another named contract"),tagging:rn.z.number().int().min(0).optional().describe("Contract version number"),description:rn.z.string().optional().describe("Human-readable description"),globals:Gt.optional().describe("JSON Schema for event.globals"),context:Gt.optional().describe("JSON Schema for event.context"),custom:Gt.optional().describe("JSON Schema for event.custom"),user:Gt.optional().describe("JSON Schema for event.user"),consent:Gt.optional().describe("JSON Schema for event.consent"),events:Qt.optional().describe("Entity-action event schemas")}).describe("Named contract entry with optional sections and events"),Yt=rn.z.record(rn.z.string(),Xt).describe("Named contracts with optional extends inheritance"),ei=rn.z.object({web:Jt.optional().describe("Web platform configuration (browser-based tracking). Mutually exclusive with server."),server:Ut.optional().describe("Server platform configuration (Node.js). Mutually exclusive with web."),sources:rn.z.record(rn.z.string(),Ht).optional().describe("Source configurations (data capture) keyed by unique identifier"),destinations:rn.z.record(rn.z.string(),Ft).optional().describe("Destination configurations (data output) keyed by unique identifier"),transformers:rn.z.record(rn.z.string(),Vt).optional().describe("Transformer configurations (event transformation) keyed by unique identifier"),stores:rn.z.record(rn.z.string(),Kt).optional().describe("Store configurations (key-value storage) keyed by unique identifier"),collector:rn.z.unknown().optional().describe("Collector configuration for event processing (uses Collector.InitConfig)"),packages:Lt.optional().describe("NPM packages to bundle"),variables:Tt.optional().describe("Flow-level variables (override Config.variables, overridden by source/destination variables)"),definitions:qt.optional().describe("Flow-level definitions (extend Config.definitions, overridden by source/destination definitions)")}).refine(e=>{const n=void 0!==e.web,t=void 0!==e.server;return(n||t)&&!(n&&t)},{message:'Exactly one of "web" or "server" must be present'}).describe("Single flow settings for one deployment target"),ni=rn.z.object({$schema:rn.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/v2.json")'),include:rn.z.array(rn.z.string()).optional().describe("Folders to include in the bundle output"),variables:Tt.optional().describe("Shared variables for interpolation across all flows (use $var.name syntax)"),definitions:qt.optional().describe("Reusable configuration definitions (use $def.name syntax)"),flows:rn.z.record(rn.z.string(),ei).refine(e=>Object.keys(e).length>0,{message:"At least one flow is required"}).describe("Named flow configurations (e.g., production, staging, development)")}).extend({version:rn.z.literal(3).describe("Configuration schema version"),contract:Yt.optional().describe("Named contracts with extends inheritance and dot-path references")}).describe("walkerOS flow configuration (walkeros.config.json)"),ti=(rn.z.toJSONSchema(ni,{target:"draft-7"}),sn(ei),sn(Ht),sn(Ft),sn(Vt),sn(Kt),sn(Xt),sn(Yt),require("zod")),ii=ti.z.object({lang:ti.z.string().optional().describe("Language identifier (e.g. json, sql, bash, typescript)"),code:ti.z.string().describe("Code snippet")}),oi=ti.z.object({text:ti.z.string().describe("Short actionable hint text focused on walkerOS usage"),code:ti.z.array(ii).optional().describe("Optional code snippets")}),ri=(ti.z.record(ti.z.string(),oi).describe("Keyed hints for AI consumption — lightweight context beyond schemas and examples"),new Set(["env","onError","onLog","primary"])),si={source:kt.configJsonSchema,destination:Wn.configJsonSchema};function ai(e,n){const t=si[e];if(!t||!t.properties){return{type:"object",properties:{settings:n.settings?ci(n.settings):{description:"Implementation-specific configuration"}}}}const i=JSON.parse(JSON.stringify(t)),o=i.properties;for(const e of ri)delete o[e];return n.settings&&(o.settings=ci(n.settings)),i}function ci(e){const{$schema:n,...t}=e;return t}//# 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})},s={};r(s,{Collector:()=>a,Const:()=>O,Context:()=>c,Destination:()=>l,ENV_MARKER_PREFIX:()=>L,Elb:()=>d,Flow:()=>p,Hint:()=>E,Hooks:()=>u,Level:()=>b,Lifecycle:()=>k,Logger:()=>f,Mapping:()=>g,Matcher:()=>x,On:()=>m,Request:()=>z,Simulation:()=>j,Source:()=>v,Store:()=>y,Transformer:()=>h,Trigger:()=>w,WalkerOS:()=>S,anonymizeIP:()=>C,assign:()=>F,branch:()=>P,castToProperty:()=>je,castValue:()=>ce,clone:()=>re,compileMatcher:()=>on,createDestination:()=>de,createEvent:()=>pe,createLogger:()=>ye,createMockLogger:()=>De,createRespond:()=>tn,debounce:()=>ge,fetchPackage:()=>Xe,fetchPackageSchema:()=>Ye,filterValues:()=>Se,getBrowser:()=>Ue,getBrowserVersion:()=>We,getByPath:()=>se,getDeviceType:()=>He,getEvent:()=>ue,getFlowSettings:()=>B,getGrantedConsent:()=>le,getHeaders:()=>Te,getId:()=>fe,getMappingEvent:()=>Oe,getMappingValue:()=>Pe,getMarketingParameters:()=>be,getOS:()=>_e,getOSVersion:()=>Be,getPlatform:()=>H,isArguments:()=>K,isArray:()=>G,isBoolean:()=>Z,isCommand:()=>Q,isDefined:()=>X,isElementOrDocument:()=>Y,isFunction:()=>ee,isNumber:()=>ne,isObject:()=>te,isPropertyType:()=>ke,isSameType:()=>ie,isString:()=>oe,mcpError:()=>nn,mcpResult:()=>en,mergeConfigSchema:()=>ai,mergeContractSchemas:()=>R,mockEnv:()=>$e,packageNameToVariable:()=>W,parseUserAgent:()=>Je,processEventMapping:()=>Ne,requestToData:()=>Re,requestToParameter:()=>Ie,resolveContracts:()=>D,setByPath:()=>ae,throttle:()=>me,throwError:()=>N,transformData:()=>Me,traverseEnv:()=>Ae,trim:()=>qe,tryCatch:()=>xe,tryCatchAsync:()=>Ee,useHooks:()=>Le,walkPath:()=>J,wrapCondition:()=>Fe,wrapFn:()=>Ke,wrapValidate:()=>Ge}),module.exports=(e=s,((e,r,s,a)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let c of i(r))o.call(e,c)||c===s||n(e,c,{get:()=>r[c],enumerable:!(a=t(r,c))||a.enumerable});return e})(n({},"__esModule",{value:!0}),e));var a={},c={},l={},d={},p={},u={},f={};r(f,{Level:()=>b});var b=(e=>(e[e.ERROR=0]="ERROR",e[e.WARN=1]="WARN",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e))(b||{}),g={},m={},h={},z={},v={},y={},w={},k={},S={},j={},x={},E={},O={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function P(e,n){return{event:e,next:n}}function C(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}function N(e){throw new Error(String(e))}var $=["globals","context","custom","user","consent"],A=new Set(["description","examples","title","$comment"]);function D(e){const n={},t=new Set;function i(o){if(n[o])return n[o];t.has(o)&&N(`Circular extends chain detected: ${[...t,o].join(" → ")}`);const r=e[o];r||N(`Contract "${o}" not found`),t.add(o);let s={};if(r.extends){s=function(e,n){const t={};void 0===e.tagging&&void 0===n.tagging||(t.tagging=n.tagging??e.tagging);void 0===e.description&&void 0===n.description||(t.description=n.description??e.description);for(const i of $){const o=e[i],r=n[i];o&&r?t[i]=R(o,r):(o||r)&&(t[i]={...o||r})}if(e.events||n.events){const i={},o=new Set([...Object.keys(e.events||{}),...Object.keys(n.events||{})]);for(const t of o){const o=e.events?.[t]||{},r=n.events?.[t]||{},s=new Set([...Object.keys(o),...Object.keys(r)]);i[t]={};for(const e of s){const n=o[e],s=r[e];i[t][e]=n&&s?R(n,s):{...n||s}}}t.events=i}return t}(i(r.extends),r)}else s={...r};if(delete s.extends,s.events&&(s.events=function(e){const n={};for(const t of Object.keys(e))if("*"!==t){n[t]={};for(const i of Object.keys(e[t]||{})){let o={};const r=e["*"]?.["*"];r&&(o=R(o,r));const s=e["*"]?.[i];s&&"*"!==i&&(o=R(o,s));const a=e[t]?.["*"];a&&"*"!==i&&(o=R(o,a));const c=e[t]?.[i];c&&(o=R(o,c)),n[t][i]=o}}e["*"]&&(n["*"]={...e["*"]});return n}(s.events)),s.events){const e={};for(const[n,t]of Object.entries(s.events)){e[n]={};for(const[i,o]of Object.entries(t))e[n][i]=I(o)}s.events=e}return t.delete(o),n[o]=s,s}for(const n of Object.keys(e))i(n);return n}function R(e,n){const t={...e};for(const i of Object.keys(n)){const o=e[i],r=n[i];"required"===i&&Array.isArray(o)&&Array.isArray(r)?t[i]=[...new Set([...o,...r])]:M(o)&&M(r)?t[i]=R(o,r):t[i]=r}return t}function I(e){const n={};for(const[t,i]of Object.entries(e))A.has(t)||(null===i||"object"!=typeof i||Array.isArray(i)?n[t]=i:n[t]=I(i));return n}function M(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function T(...e){const n={};for(const t of e)t&&Object.assign(n,t);return n}function q(...e){const n={};for(const t of e)t&&Object.assign(n,t);return n}var L="__WALKEROS_ENV:";function J(e,n,t){const i=n.split(".");let o=e;for(let e=0;e<i.length;e++){const r=i[e];if(null==o||"object"!=typeof o){const o=i.slice(0,e).join(".");N(`Path "${n}" not found in "${t}": "${r}" does not exist${o?` in "${o}"`:""}`)}const s=o;if(!(r in s)){const o=i.slice(0,e).join(".");N(`Path "${n}" not found in "${t}": "${r}" does not exist${o?` in "${o}"`:""}`)}o=s[r]}return o}function U(e,n,t,i,o){if("string"==typeof e){const r=e.match(/^\$def\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/);if(r){const e=r[1],s=r[2];void 0===t[e]&&N(`Definition "${e}" not found`);let a=U(t[e],n,t,i,o);return s&&(a=J(a,s,`$def.${e}`)),a}const s=e.match(/^\$contract\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/);if(s&&o){const e=s[1],n=s[2];e in o||N(`Contract "${e}" not found`);let t=o[e];return n&&(t=J(t,n,`$contract.${e}`)),t}let a=e.replace(/\$var\.([a-zA-Z_][a-zA-Z0-9_]*)/g,(e,t)=>{if(void 0!==n[t])return String(n[t]);N(`Variable "${t}" not found`)});return a=a.replace(/\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g,(e,n,t)=>i?.deferred?void 0!==t?`${L}${n}:${t}`:`${L}${n}`:"undefined"!=typeof process&&void 0!==process.env?.[n]?process.env[n]:void 0!==t?t:void N(`Environment variable "${n}" not found and no default provided`)),a}if(Array.isArray(e))return e.map(e=>U(e,n,t,i,o));if(null!==e&&"object"==typeof e){const r={};for(const[s,a]of Object.entries(e))r[s]=U(a,n,t,i,o);return r}return e}function W(e){const n=e.startsWith("@"),t=e.replace("@","").replace(/[/-]/g,"_").split("_").filter(e=>e.length>0).map((e,n)=>0===n?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");return n?"_"+t:t}function _(e,n,t){if(n)return n;if(!e||!t)return;return t[e]?W(e):void 0}function B(e,n,t){const i=Object.keys(e.flows);n||(1===i.length?n=i[0]:N(`Multiple flows found (${i.join(", ")}). Please specify a flow.`));const o=e.flows[n];o||N(`Flow "${n}" not found. Available: ${i.join(", ")}`);const r=JSON.parse(JSON.stringify(o));let s;if(e.contract){const n=T(e.variables,o.variables),i=q(e.definitions,o.definitions);s=D(U(e.contract,n,i,t))}if(r.sources)for(const[n,i]of Object.entries(r.sources)){const a=T(e.variables,o.variables,i.variables),c=q(e.definitions,o.definitions,i.definitions),l=U(i.config,a,c,t,s),d=U(i.env,a,c,t,s),p=_(i.package,i.code,r.packages),u="string"==typeof i.code||"object"==typeof i.code?i.code:void 0,f=p||u;r.sources[n]={package:i.package,config:l,env:d,primary:i.primary,variables:i.variables,definitions:i.definitions,next:i.next,code:f}}if(r.destinations)for(const[n,i]of Object.entries(r.destinations)){const a=T(e.variables,o.variables,i.variables),c=q(e.definitions,o.definitions,i.definitions),l=U(i.config,a,c,t,s),d=U(i.env,a,c,t,s),p=_(i.package,i.code,r.packages),u="string"==typeof i.code||"object"==typeof i.code?i.code:void 0,f=p||u;r.destinations[n]={package:i.package,config:l,env:d,variables:i.variables,definitions:i.definitions,before:i.before,code:f}}if(r.stores)for(const[n,i]of Object.entries(r.stores)){const a=T(e.variables,o.variables,i.variables),c=q(e.definitions,o.definitions,i.definitions),l=U(i.config,a,c,t,s),d=U(i.env,a,c,t,s),p=_(i.package,i.code,r.packages),u="string"==typeof i.code||"object"==typeof i.code?i.code:void 0,f=p||u;r.stores[n]={package:i.package,config:l,env:d,variables:i.variables,definitions:i.definitions,code:f}}if(r.transformers)for(const[n,i]of Object.entries(r.transformers)){const a=T(e.variables,o.variables,i.variables),c=q(e.definitions,o.definitions,i.definitions),l=U(i.config,a,c,t,s),d=U(i.env,a,c,t,s),p=_(i.package,i.code,r.packages),u="string"==typeof i.code||"object"==typeof i.code?i.code:void 0,f=p||u;r.transformers[n]={package:i.package,config:l,env:d,variables:i.variables,definitions:i.definitions,next:i.next,code:f}}if(r.collector){const n=T(e.variables,o.variables),i=q(e.definitions,o.definitions),a=U(r.collector,n,i,t,s);r.collector=a}return r}function H(e){return void 0!==e.web?"web":void 0!==e.server?"server":void N("Settings must have web or server key")}var V={merge:!0,shallow:!0,extend:!0};function F(e,n={},t={}){t={...V,...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 K(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function G(e){return Array.isArray(e)}function Z(e){return"boolean"==typeof e}function Q(e){return"walker"===e}function X(e){return void 0!==e}function Y(e){return e===document||e instanceof Element}function ee(e){return"function"==typeof e}function ne(e){return"number"==typeof e&&!Number.isNaN(e)}function te(e){return"object"==typeof e&&null!==e&&!G(e)&&"[object Object]"===Object.prototype.toString.call(e)}function ie(e,n){return typeof e==typeof n}function oe(e){return"string"==typeof e}function re(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]=re(e[i],n));return t}if("[object Array]"===t){const t=[];return n.set(e,t),e.forEach(e=>{t.push(re(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 se(e,n="",t){const i=n.split(".");let o=e;for(let e=0;e<i.length;e++){const n=i[e];if("*"===n&&G(o)){const n=i.slice(e+1).join("."),r=[];for(const e of o){const i=se(e,n,t);r.push(i)}return r}if(o=o instanceof Object?o[n]:void 0,void 0===o)break}return X(o)?o:t}function ae(e,n,t){if(!te(e))return e;const i=re(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 ce(e){if("true"===e)return!0;if("false"===e)return!1;const n=Number(e);return e==n&&""!==e?n:String(e)}function le(e,n={},t={}){const i={...n,...t},o={};let r=!e||0===Object.keys(e).length;return Object.keys(i).forEach(n=>{i[n]&&(o[n]=!0,e&&e[n]&&(r=!0))}),!!r&&o}function de(e,n){const t={...e};return t.config=F(e.config,n,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&n.settings&&(t.config.settings=F(e.config.settings,n.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&n.mapping&&(t.config.mapping=F(e.config.mapping,n.mapping,{shallow:!0,merge:!0,extend:!0})),t}function pe(e={}){const n=e.timestamp||(new Date).setHours(0,13,37,0),t=e.group||"gr0up",i=e.count||1,o=F({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:"3.1.0",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 ue(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 pe({...{"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.walkeros.io/",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 fe(e=6){let n="";for(let t=36;n.length<e;)n+=(Math.random()*t|0).toString(t);return n}function be(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(F(o,n)).forEach(([n,o])=>{const r=e.searchParams.get(n);r&&(o===t&&(o=n,i[t]=n),i[o]=r)}),i}function ge(e,n=1e3,t=!1){let i,o=null,r=!1;return(...s)=>new Promise(a=>{const c=t&&!r;o&&clearTimeout(o),o=setTimeout(()=>{o=null,t&&!r||(i=e(...s),a(i))},n),c&&(r=!0,i=e(...s),a(i))})}function me(e,n=1e3){let t=null;return function(...i){if(null===t)return t=setTimeout(()=>{t=null},n),e(...i)}}function he(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function ze(e,n){let t,i={};return e instanceof Error?(t=e.message,i.error=he(e)):t=e,void 0!==n&&(n instanceof Error?i.error=he(n):"object"==typeof n&&null!==n?(i={...i,...n},"error"in i&&i.error instanceof Error&&(i.error=he(i.error))):i.value=n),{message:t,context:i}}var ve=(e,n,t,i)=>{const o=`${b[e]}${i.length>0?` [${i.join(":")}]`:""}`,r=Object.keys(t).length>0,s=0===e?console.error:1===e?console.warn:console.log;r?s(o,n,t):s(o,n)};function ye(e={}){return we({level:void 0!==e.level?function(e){return"string"==typeof e?b[e]:e}(e.level):0,handler:e.handler,jsonHandler:e.jsonHandler,scope:[]})}function we(e){const{level:n,handler:t,jsonHandler:i,scope:o}=e,r=(e,i,r)=>{if(e<=n){const n=ze(i,r);t?t(e,n.message,n.context,o,ve):ve(e,n.message,n.context,o)}};return{error:(e,n)=>r(0,e,n),warn:(e,n)=>r(1,e,n),info:(e,n)=>r(2,e,n),debug:(e,n)=>r(3,e,n),throw:(e,n)=>{const i=ze(e,n);throw t?t(0,i.message,i.context,o,ve):ve(0,i.message,i.context,o),new Error(i.message)},json:e=>{i?i(e):console.log(JSON.stringify(e,null,2))},scope:e=>we({level:n,handler:t,jsonHandler:i,scope:[...o,e]})}}function ke(e){return Z(e)||oe(e)||ne(e)||!X(e)||G(e)&&e.every(ke)||te(e)&&Object.values(e).every(ke)}function Se(e){return Z(e)||oe(e)||ne(e)?e:K(e)?Se(Array.from(e)):G(e)?e.map(e=>Se(e)).filter(e=>void 0!==e):te(e)?Object.entries(e).reduce((e,[n,t])=>{const i=Se(t);return void 0!==i&&(e[n]=i),e},{}):void 0}function je(e){return ke(e)?e:void 0}function xe(e,n,t){return function(...i){try{return e(...i)}catch(e){if(!n)return;return n(e)}finally{t?.()}}}function Ee(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 Oe(e,n){const[t,i]=(e.name||"").split(" ");if(!n||!t||!i)return{};let o,r="",s=t,a=i;const c=n=>{if(n)return(n=G(n)?n:[n]).find(n=>!n.condition||n.condition(e))};n[s]||(s="*");const l=n[s];return l&&(l[a]||(a="*"),o=c(l[a])),o||(s="*",a="*",o=c(n[s]?.[a])),o&&(r=`${s} ${a}`),{eventMapping:o,mappingKey:r}}async function Pe(e,n={},t={}){if(!X(e))return;const i=te(e)&&e.consent||t.consent||t.collector?.consent,o=G(n)?n:[n];for(const n of o){const o=await Ee(Ce)(e,n,{...t,consent:i});if(X(o))return o}}async function Ce(e,n,t={}){const{collector:i,consent:o}=t;return(G(n)?n:[n]).reduce(async(n,r)=>{const s=await n;if(s)return s;const a=oe(r)?{key:r}:r;if(!Object.keys(a).length)return;const{condition:c,consent:l,fn:d,key:p,loop:u,map:f,set:b,validate:g,value:m}=a;if(c&&!await Ee(c)(e,r,i))return;if(l&&!le(l,o))return m;let h=X(m)?m:e;if(d&&(h=await Ee(d)(e,r,t)),p&&(h=se(e,p,m)),u){const[n,i]=u,o="this"===n?[e]:await Pe(e,n,t);G(o)&&(h=(await Promise.all(o.map(e=>Pe(e,i,t)))).filter(X))}else f?h=await Object.entries(f).reduce(async(n,[i,o])=>{const r=await n,s=await Pe(e,o,t);return X(s)&&(r[i]=s),r},Promise.resolve({})):b&&(h=await Promise.all(b.map(n=>Ce(e,n,t))));g&&!await Ee(g)(h)&&(h=void 0);const z=je(h);return X(z)?z:je(m)},Promise.resolve(void 0))}async function Ne(e,n,t){n.policy&&await Promise.all(Object.entries(n.policy).map(async([n,i])=>{const o=await Pe(e,i,{collector:t});e=ae(e,n,o)}));const{eventMapping:i,mappingKey:o}=await Oe(e,n.mapping);i?.policy&&await Promise.all(Object.entries(i.policy).map(async([n,i])=>{const o=await Pe(e,i,{collector:t});e=ae(e,n,o)}));let r=n.data&&await Pe(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 Pe(e,i.data,{collector:t});r=te(r)&&te(n)?F(r,n):n}}return{event:e,data:r,mapping:i,mappingKey:o,ignore:!1}}function $e(e,n){const t=(e,i=[])=>new Proxy(e,{get(e,o){const r=e[o],s=[...i,o];return"function"==typeof r?(...e)=>n(s,e,r):r&&"object"==typeof r?t(r,s):r}});return t(e)}function Ae(e,n){const t=(e,i=[])=>{if(!e||"object"!=typeof e)return e;const o=Array.isArray(e)?[]:{};for(const[r,s]of Object.entries(e)){const e=[...i,r];Array.isArray(o)?o[Number(r)]=n(s,e):o[r]=n(s,e),s&&"object"==typeof s&&"function"!=typeof s&&(Array.isArray(o)?o[Number(r)]=t(s,e):o[r]=t(s,e))}return o};return t(e)}function De(){const e=[],n=jest.fn(e=>{const n=e instanceof Error?e.message:e;throw new Error(n)}),t=jest.fn(n=>{const t=De();return e.push(t),t});return{error:jest.fn(),warn:jest.fn(),info:jest.fn(),debug:jest.fn(),throw:n,json:jest.fn(),scope:t,scopedLoggers:e}}function Re(e){const n=String(e),t=n.split("?")[1]||n;return xe(()=>{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(G(o)){const s=parseInt(n,10);r?o[s]=ce(e):(o[s]=o[s]||(isNaN(parseInt(i[t+1],10))?{}:[]),o=o[s])}else te(o)&&(r?o[n]=ce(e):(o[n]=o[n]||(isNaN(parseInt(i[t+1],10))?{}:[]),o=o[n]))})}),n})()}function Ie(e){if(!e)return"";const n=[],t=encodeURIComponent;function i(e,o){null!=o&&(G(o)?o.forEach((n,t)=>i(`${e}[${t}]`,n)):te(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 Me(e){return void 0===e||ie(e,"")?e:JSON.stringify(e)}function Te(e={}){return F({"Content-Type":"application/json; charset=utf-8"},e)}function qe(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function Le(e,n,t){return function(...i){let o;const r="post"+n,s=t["pre"+n],a=t[r];return o=s?s({fn:e},...i):e(...i),a&&(o=a({fn:e,result:o},...i)),o}}function Je(e){return e?{userAgent:e,browser:Ue(e),browserVersion:We(e),os:_e(e),osVersion:Be(e),deviceType:He(e)}:{}}function Ue(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 We(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 _e(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 Be(e){const n=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return n?n[1].replace(/_/g,"."):void 0}function He(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 Ve(e){return function(e){return/\breturn\b/.test(e)}(e)?e:`return ${e}`}function Fe(e){const n=Ve(e);return new Function("value","mapping","collector",n)}function Ke(e){const n=Ve(e);return new Function("value","mapping","options",n)}function Ge(e){const n=Ve(e);return new Function("value",n)}var Ze="https://cdn.jsdelivr.net/npm",Qe="dist/walkerOS.json";async function Xe(e,n){const t=n?.version||"latest",i=`${Ze}/${e}@${t}`,o=new AbortController,r=setTimeout(()=>o.abort(),n?.timeout||1e4);try{const n=await fetch(`${i}/package.json`,{signal:o.signal});if(!n.ok)throw new Error(`Package "${e}" not found on npm (HTTP ${n.status})`);const r=await n.json(),a=await fetch(`${i}/${Qe}`,{signal:o.signal});if(!a.ok)throw new Error(`walkerOS.json not found at ${Qe} (HTTP ${a.status}). This package may not support the walkerOS.json convention yet.`);const c=await a.json(),l=c.$meta||{},d=c.schemas||{},p=c.examples||{},u=c.hints,f=u?Object.keys(u):[],b=[],g=p.step||{};for(const[e,n]of Object.entries(g)){const t=n,i={name:e};"string"==typeof t?.description&&(i.description=t.description),b.push(i)}const m="string"==typeof l.docs?l.docs:void 0,h="string"==typeof l.source?l.source:void 0;return{packageName:e,version:"string"==typeof r.version?r.version:t,description:"string"==typeof r.description?r.description:void 0,type:"string"==typeof l.type?l.type:void 0,platform:(s=l.platform,"string"==typeof s||Array.isArray(s)&&s.every(e=>"string"==typeof e)?s:void 0),schemas:d,examples:p,...m?{docs:m}:{},...h?{source:h}:{},...u&&Object.keys(u).length>0?{hints:u}:{},hintKeys:f,exampleSummaries:b}}finally{clearTimeout(r)}var s}async function Ye(e,n){const t=await Xe(e,n);return{packageName:t.packageName,version:t.version,type:t.type,platform:t.platform,schemas:t.schemas,examples:t.examples,...t.hints?{hints:t.hints}:{}}}function en(e,n){const t=n?{...e,_hints:n}:e;return{content:[{type:"text",text:JSON.stringify(t,null,2)}],structuredContent:t}}function nn(e,n){let t,i,o,r;if(e instanceof Error){t=e.message;const n=e;n.code&&(o=n.code),Array.isArray(n.details)&&(r=n.details)}else if("string"==typeof e)t=e;else if(e&&"object"==typeof e&&"issues"in e&&Array.isArray(e.issues)){const n=e.issues;t=n.map(e=>e.message).join("; "),i=n[0]?.path?.join(".")||void 0}else t=e&&"object"==typeof e&&"message"in e?String(e.message):"Unknown error";const s={error:t};return n&&(s.hint=n),i&&(s.path=i),o&&(s.code=o),r&&(s.details=r),{content:[{type:"text",text:JSON.stringify(s)}],structuredContent:s,isError:!0}}function tn(e){let n=!1;return(t={})=>{n||(n=!0,e(t))}}function on(e){if("*"===e)return()=>!0;if("and"in e){const n=e.and.map(on);return e=>n.every(n=>n(e))}if("or"in e){const n=e.or.map(on);return e=>n.some(n=>n(e))}return function(e){const{key:n,operator:t,value:i,not:o}=e,r=function(e,n){switch(e){case"eq":return e=>String(e??"")===n;case"contains":return e=>String(e??"").includes(n);case"prefix":return e=>String(e??"").startsWith(n);case"suffix":return e=>String(e??"").endsWith(n);case"regex":{const e=new RegExp(n);return n=>e.test(String(n??""))}case"gt":{const e=Number(n);return n=>Number(n)>e}case"lt":{const e=Number(n);return n=>Number(n)<e}case"exists":return e=>null!=e}}(t,i);return e=>{const t=e[n],i=r(t);return o?!i:i}}(e)}var rn=require("zod");function sn(e,n,t="draft-7"){return rn.z.toJSONSchema(e,{target:t})}var an,cn=rn.z.string(),ln=rn.z.number(),dn=(rn.z.boolean(),rn.z.string().min(1)),pn=rn.z.number().int().positive(),un=rn.z.number().int().nonnegative(),fn=rn.z.number().describe("Tagging version number"),bn=(rn.z.union([rn.z.string(),rn.z.number(),rn.z.boolean()]).optional(),rn.z.enum(["local","session","cookie"]).describe("Storage mechanism: local, session, or cookie")),gn=rn.z.object({Local:rn.z.literal("local"),Session:rn.z.literal("session"),Cookie:rn.z.literal("cookie")}).describe("Storage type constants for type-safe references"),mn=rn.z.any().describe("Error handler function: (error, state?) => void"),hn=rn.z.any().describe("Log handler function: (message, verbose?) => void"),zn=rn.z.object({Error:mn.describe("Error handler function"),Log:hn.describe("Log handler function")}).describe("Handler interface with error and log functions"),vn=(sn(bn),sn(gn),sn(mn),sn(hn),sn(zn),rn.z.object({onError:mn.optional().describe("Error handler function: (error, state?) => void"),onLog:hn.optional().describe("Log handler function: (message, verbose?) => void")}).partial(),rn.z.object({verbose:rn.z.boolean().describe("Enable verbose logging for debugging").optional()}).partial(),rn.z.object({queue:rn.z.boolean().describe("Whether to queue events when consent is not granted").optional()}).partial(),rn.z.object({}).partial(),rn.z.object({init:rn.z.boolean().describe("Whether to initialize immediately").optional(),loadScript:rn.z.boolean().describe("Whether to load external script (for web destinations)").optional()}).partial(),rn.z.object({primary:rn.z.boolean().describe("Mark as primary (only one can be primary)").optional()}).partial(),rn.z.object({settings:rn.z.any().optional().describe("Implementation-specific configuration")}).partial(),rn.z.object({env:rn.z.any().optional().describe("Environment dependencies (platform-specific)")}).partial(),rn.z.object({type:rn.z.string().optional().describe("Instance type identifier"),config:rn.z.unknown().describe("Instance configuration")}).partial(),rn.z.object({collector:rn.z.unknown().describe("Collector instance (runtime object)"),config:rn.z.unknown().describe("Configuration"),env:rn.z.unknown().describe("Environment dependencies")}).partial(),rn.z.object({batch:rn.z.number().optional().describe("Batch size: bundle N events for batch processing"),batched:rn.z.unknown().optional().describe("Batch of events to be processed")}).partial(),rn.z.object({ignore:rn.z.boolean().describe("Set to true to skip processing").optional(),condition:rn.z.string().optional().describe("Condition function: return true to process")}).partial(),rn.z.object({sources:rn.z.record(rn.z.string(),rn.z.unknown()).describe("Map of source instances")}).partial(),rn.z.object({destinations:rn.z.record(rn.z.string(),rn.z.unknown()).describe("Map of destination instances")}).partial(),rn.z.lazy(()=>rn.z.union([rn.z.boolean(),rn.z.string(),rn.z.number(),rn.z.record(rn.z.string(),yn)]))),yn=rn.z.lazy(()=>rn.z.union([vn,rn.z.array(vn)])),wn=rn.z.record(rn.z.string(),yn.optional()).describe("Flexible property collection with optional values"),kn=rn.z.record(rn.z.string(),rn.z.tuple([yn,rn.z.number()]).optional()).describe("Ordered properties with [value, order] tuples for priority control"),Sn=rn.z.union([rn.z.enum(["web","server","app","other"]),rn.z.string()]).describe("Source type: web, server, app, other, or custom"),jn=rn.z.record(rn.z.string(),rn.z.boolean()).describe("Consent requirement mapping (group name → state)"),xn=wn.and(rn.z.object({id:rn.z.string().optional().describe("User identifier"),device:rn.z.string().optional().describe("Device identifier"),session:rn.z.string().optional().describe("Session identifier"),hash:rn.z.string().optional().describe("Hashed identifier"),address:rn.z.string().optional().describe("User address"),email:rn.z.string().email().optional().describe("User email address"),phone:rn.z.string().optional().describe("User phone number"),userAgent:rn.z.string().optional().describe("Browser user agent string"),browser:rn.z.string().optional().describe("Browser name"),browserVersion:rn.z.string().optional().describe("Browser version"),deviceType:rn.z.string().optional().describe("Device type (mobile, desktop, tablet)"),os:rn.z.string().optional().describe("Operating system"),osVersion:rn.z.string().optional().describe("Operating system version"),screenSize:rn.z.string().optional().describe("Screen dimensions"),language:rn.z.string().optional().describe("User language"),country:rn.z.string().optional().describe("User country"),region:rn.z.string().optional().describe("User region/state"),city:rn.z.string().optional().describe("User city"),zip:rn.z.string().optional().describe("User postal code"),timezone:rn.z.string().optional().describe("User timezone"),ip:rn.z.string().optional().describe("User IP address"),internal:rn.z.boolean().optional().describe("Internal user flag (employee, test user)")})).describe("User identification and properties"),En=wn.and(rn.z.object({source:cn.describe('Walker implementation version (e.g., "2.0.0")'),tagging:fn})).describe("Walker version information"),On=wn.and(rn.z.object({type:Sn.describe("Source type identifier"),id:cn.describe("Source identifier (typically URL on web)"),previous_id:cn.describe("Previous source identifier (typically referrer on web)")})).describe("Event source information"),Pn=rn.z.lazy(()=>rn.z.object({entity:rn.z.string().describe("Entity name"),data:wn.describe("Entity-specific properties"),nested:rn.z.array(Pn).describe("Nested child entities"),context:kn.describe("Entity context data")})).describe("Nested entity structure with recursive nesting support"),Cn=rn.z.array(Pn).describe("Array of nested entities"),Nn=rn.z.object({name:rn.z.string().describe('Event name in "entity action" format (e.g., "page view", "product add")'),data:wn.describe("Event-specific properties"),context:kn.describe("Ordered context properties with priorities"),globals:wn.describe("Global properties shared across events"),custom:wn.describe("Custom implementation-specific properties"),user:xn.describe("User identification and attributes"),nested:Cn.describe("Related nested entities"),consent:jn.describe("Consent states at event time"),id:dn.describe("Unique event identifier (timestamp-based)"),trigger:cn.describe("Event trigger identifier"),entity:cn.describe("Parsed entity from event name"),action:cn.describe("Parsed action from event name"),timestamp:pn.describe("Unix timestamp in milliseconds since epoch"),timing:ln.describe("Event processing timing information"),group:cn.describe("Event grouping identifier"),count:un.describe("Event count in session"),version:En.describe("Walker version information"),source:On.describe("Event source information")}).describe("Complete walkerOS event structure"),$n=Nn.partial().describe("Partial event structure with all fields optional"),An=(Nn.partial().describe("Partial event structure with all top-level fields optional"),sn(Nn),sn($n),sn(xn),sn(wn),sn(kn),sn(Pn),sn(Sn),sn(jn),rn.z.lazy(()=>rn.z.union([rn.z.string().describe('String value or property path (e.g., "data.id")'),rn.z.number().describe("Numeric value"),rn.z.boolean().describe("Boolean value"),rn.z.lazy(()=>an),rn.z.array(An).describe("Array of values")]))),Dn=rn.z.array(An).describe("Array of transformation values"),Rn=rn.z.lazy(()=>rn.z.tuple([An,An]).describe("Loop transformation: [source, transform] tuple for array processing")),In=rn.z.lazy(()=>rn.z.array(An).describe("Set: Array of values for selection or combination")),Mn=rn.z.lazy(()=>rn.z.record(rn.z.string(),An).describe("Map: Object mapping keys to transformation values")),Tn=an=rn.z.object({key:rn.z.string().optional().describe('Property path to extract from event (e.g., "data.id", "user.email")'),value:rn.z.union([rn.z.string(),rn.z.number(),rn.z.boolean()]).optional().describe("Static primitive value"),fn:rn.z.string().optional().describe("Custom transformation function as string (serialized)"),map:Mn.optional().describe("Object mapping: transform event data to structured output"),loop:Rn.optional().describe("Loop transformation: [source, transform] for array processing"),set:In.optional().describe("Set of values: combine or select from multiple values"),consent:jn.optional().describe("Required consent states to include this value"),condition:rn.z.string().optional().describe("Condition function as string: return true to include value"),validate:rn.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"),qn=rn.z.record(rn.z.string(),An).describe("Policy rules for event pre-processing (key → value mapping)"),Ln=rn.z.object({batch:rn.z.number().optional().describe("Batch size: bundle N events for batch processing"),condition:rn.z.string().optional().describe("Condition function as string: return true to process event"),consent:jn.optional().describe("Required consent states to process this event"),settings:rn.z.any().optional().describe("Destination-specific settings for this event mapping"),data:rn.z.union([An,Dn]).optional().describe("Data transformation rules for event"),ignore:rn.z.boolean().optional().describe("Set to true to skip processing this event"),name:rn.z.string().optional().describe('Custom event name override (e.g., "view_item" for "product view")'),policy:qn.optional().describe("Event-level policy overrides (applied after config-level policy)")}).describe("Mapping rule for specific entity-action combination"),Jn=rn.z.record(rn.z.string(),rn.z.record(rn.z.string(),rn.z.union([Ln,rn.z.array(Ln)])).optional()).describe('Event mapping rules: entity → action → Rule. Keys match event name split by space. Use "*" as wildcard for entity or action. Priority: exact > entity wildcard > action wildcard > global wildcard (*→*).'),Un=rn.z.object({consent:jn.optional().describe("Required consent states to process any events"),data:rn.z.union([An,Dn]).optional().describe("Global data transformation applied to all events"),mapping:Jn.optional().describe("Entity-action specific mapping rules"),policy:qn.optional().describe("Pre-processing policy rules applied before mapping")}).describe("Shared mapping configuration for sources and destinations"),Wn=(rn.z.object({eventMapping:Ln.optional().describe("Resolved mapping rule for event"),mappingKey:rn.z.string().optional().describe('Mapping key used (e.g., "product.view")')}).describe("Mapping resolution result"),sn(An),sn(Tn),sn(Rn),sn(In),sn(Mn),sn(qn),sn(Ln),sn(Jn),sn(Un),{});r(Wn,{BatchSchema:()=>Qn,ConfigSchema:()=>_n,ContextSchema:()=>Vn,DLQSchema:()=>st,DataSchema:()=>Xn,DestinationPolicySchema:()=>Hn,DestinationsSchema:()=>tt,InitDestinationsSchema:()=>nt,InitSchema:()=>et,InstanceSchema:()=>Yn,PartialConfigSchema:()=>Bn,PushBatchContextSchema:()=>Kn,PushContextSchema:()=>Fn,PushEventSchema:()=>Gn,PushEventsSchema:()=>Zn,PushResultSchema:()=>ot,RefSchema:()=>it,ResultSchema:()=>rt,batchJsonSchema:()=>pt,configJsonSchema:()=>at,contextJsonSchema:()=>lt,instanceJsonSchema:()=>ut,partialConfigJsonSchema:()=>ct,pushContextJsonSchema:()=>dt,resultJsonSchema:()=>ft});var _n=rn.z.object({consent:jn.optional().describe("Required consent states to send events to this destination"),settings:rn.z.any().describe("Implementation-specific configuration").optional(),data:rn.z.union([An,Dn]).optional().describe("Global data transformation applied to all events for this destination"),env:rn.z.any().describe("Environment dependencies (platform-specific)").optional(),id:dn.describe("Destination instance identifier (defaults to destination key)").optional(),init:rn.z.boolean().describe("Whether to initialize immediately").optional(),loadScript:rn.z.boolean().describe("Whether to load external script (for web destinations)").optional(),mapping:Jn.optional().describe("Entity-action specific mapping rules for this destination"),policy:qn.optional().describe("Pre-processing policy rules applied before event mapping"),queue:rn.z.boolean().describe("Whether to queue events when consent is not granted").optional(),require:rn.z.array(rn.z.string()).optional().describe('Defer destination initialization until these collector events fire (e.g., ["consent"])'),logger:rn.z.object({level:rn.z.union([rn.z.number(),rn.z.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:rn.z.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler) to override the collector defaults"),onError:mn.optional(),onLog:hn.optional()}).describe("Destination configuration"),Bn=_n.partial().describe("Partial destination configuration with all fields optional"),Hn=qn.describe("Destination policy rules for event pre-processing"),Vn=rn.z.object({collector:rn.z.unknown().describe("Collector instance (runtime object)"),config:_n.describe("Destination configuration"),data:rn.z.union([rn.z.unknown(),rn.z.array(rn.z.unknown())]).optional().describe("Transformed event data"),env:rn.z.unknown().describe("Environment dependencies")}).describe("Destination context for init and push functions"),Fn=Vn.extend({mapping:Ln.optional().describe("Resolved mapping rule for this specific event")}).describe("Push context with event-specific mapping"),Kn=Fn.describe("Batch push context with event-specific mapping"),Gn=rn.z.object({event:Nn.describe("The event to process"),mapping:Ln.optional().describe("Mapping rule for this event")}).describe("Event with optional mapping for batch processing"),Zn=rn.z.array(Gn).describe("Array of events with mappings"),Qn=rn.z.object({key:rn.z.string().describe('Batch key (usually mapping key like "product.view")'),events:rn.z.array(Nn).describe("Array of events in batch"),data:rn.z.array(rn.z.union([rn.z.unknown(),rn.z.array(rn.z.unknown())]).optional()).describe("Transformed data for each event"),mapping:Ln.optional().describe("Shared mapping rule for batch")}).describe("Batch of events grouped by mapping key"),Xn=rn.z.union([rn.z.unknown(),rn.z.array(rn.z.unknown())]).optional().describe("Transformed event data (Property, undefined, or array)"),Yn=rn.z.object({config:_n.describe("Destination configuration"),queue:rn.z.array(Nn).optional().describe("Queued events awaiting consent"),dlq:rn.z.array(rn.z.tuple([Nn,rn.z.unknown()])).optional().describe("Dead letter queue (failed events with errors)"),type:rn.z.string().optional().describe("Destination type identifier"),env:rn.z.unknown().optional().describe("Environment dependencies"),init:rn.z.unknown().optional().describe("Initialization function"),push:rn.z.unknown().describe("Push function for single events"),pushBatch:rn.z.unknown().optional().describe("Batch push function"),on:rn.z.unknown().optional().describe("Event lifecycle hook function")}).describe("Destination instance (runtime object with functions)"),et=rn.z.object({code:Yn.describe("Destination instance with implementation"),config:Bn.optional().describe("Partial configuration overrides"),env:rn.z.unknown().optional().describe("Partial environment overrides")}).describe("Destination initialization configuration"),nt=rn.z.record(rn.z.string(),et).describe("Map of destination IDs to initialization configurations"),tt=rn.z.record(rn.z.string(),Yn).describe("Map of destination IDs to runtime instances"),it=rn.z.object({type:rn.z.string().describe('Destination type ("gtag", "meta", "bigquery")'),data:rn.z.unknown().optional().describe("Response from push()"),error:rn.z.unknown().optional().describe("Error if failed")}).describe("Destination reference with type and response data"),ot=rn.z.object({queue:rn.z.array(Nn).optional().describe("Events queued (awaiting consent)"),error:rn.z.unknown().optional().describe("Error if push failed")}).describe("Push operation result"),rt=rn.z.object({ok:rn.z.boolean().describe("True if nothing failed"),event:rn.z.unknown().optional().describe("The processed event"),done:rn.z.record(rn.z.string(),it).optional().describe("Destinations that processed successfully"),queued:rn.z.record(rn.z.string(),it).optional().describe("Destinations that queued events"),failed:rn.z.record(rn.z.string(),it).optional().describe("Destinations that failed to process")}).describe("Push result with destination outcomes"),st=rn.z.array(rn.z.tuple([Nn,rn.z.unknown()])).describe("Dead letter queue: [(event, error), ...]"),at=sn(_n),ct=sn(Bn),lt=sn(Vn),dt=sn(Fn),pt=sn(Qn),ut=sn(Yn),ft=sn(rt),bt=rn.z.union([rn.z.enum(["action","config","consent","context","destination","elb","globals","hook","init","link","run","user","walker"]),rn.z.string()]).describe("Collector command type: standard commands or custom string for extensions"),gt=rn.z.object({run:rn.z.boolean().describe("Whether to run collector automatically on initialization").optional(),tagging:fn,globalsStatic:wn.describe("Static global properties that persist across collector runs"),sessionStatic:rn.z.record(rn.z.string(),rn.z.unknown()).describe("Static session data that persists across collector runs"),verbose:rn.z.boolean().describe("Enable verbose logging for debugging"),onError:mn.optional(),onLog:hn.optional()}).describe("Core collector configuration"),mt=wn.and(rn.z.object({isStart:rn.z.boolean().describe("Whether this is a new session start"),storage:rn.z.boolean().describe("Whether storage is available"),id:dn.describe("Session identifier").optional(),start:pn.describe("Session start timestamp").optional(),marketing:rn.z.literal(!0).optional().describe("Marketing attribution flag"),updated:pn.describe("Last update timestamp").optional(),isNew:rn.z.boolean().describe("Whether this is a new session").optional(),device:dn.describe("Device identifier").optional(),count:un.describe("Event count in session").optional(),runs:un.describe("Number of runs").optional()})).describe("Session state and tracking data"),ht=gt.partial().extend({consent:jn.optional().describe("Initial consent state"),user:xn.optional().describe("Initial user data"),globals:wn.optional().describe("Initial global properties"),sources:rn.z.unknown().optional().describe("Source configurations"),destinations:rn.z.unknown().optional().describe("Destination configurations"),custom:wn.optional().describe("Initial custom implementation-specific properties")}).describe("Collector initialization configuration with initial state"),zt=rn.z.object({mapping:Un.optional().describe("Source-level mapping configuration")}).describe("Push context with optional source mapping"),vt=rn.z.record(rn.z.string(),rn.z.unknown()).describe("Map of source IDs to source instances"),yt=rn.z.record(rn.z.string(),rn.z.unknown()).describe("Map of destination IDs to destination instances"),wt=rn.z.object({push:rn.z.unknown().describe("Push function for processing events"),command:rn.z.unknown().describe("Command function for walker commands"),allowed:rn.z.boolean().describe("Whether event processing is allowed"),config:gt.describe("Current collector configuration"),consent:jn.describe("Current consent state"),count:rn.z.number().describe("Event count (increments with each event)"),custom:wn.describe("Custom implementation-specific properties"),sources:vt.describe("Registered source instances"),destinations:yt.describe("Registered destination instances"),globals:wn.describe("Current global properties"),group:rn.z.string().describe("Event grouping identifier"),hooks:rn.z.unknown().describe("Lifecycle hook functions"),on:rn.z.unknown().describe("Event lifecycle configuration"),queue:rn.z.array(Nn).describe("Queued events awaiting processing"),round:rn.z.number().describe("Collector run count (increments with each run)"),session:rn.z.union([mt]).describe("Current session state"),timing:rn.z.number().describe("Event processing timing information"),user:xn.describe("Current user data"),version:rn.z.string().describe("Walker implementation version")}).describe("Collector instance with state and methods"),kt=(sn(bt),sn(gt),sn(mt),sn(ht),sn(zt),sn(wt),{});r(kt,{BaseEnvSchema:()=>St,ConfigSchema:()=>jt,InitSchema:()=>Ot,InitSourceSchema:()=>Pt,InitSourcesSchema:()=>Ct,InstanceSchema:()=>Et,PartialConfigSchema:()=>xt,baseEnvJsonSchema:()=>Nt,configJsonSchema:()=>$t,initSourceJsonSchema:()=>Rt,initSourcesJsonSchema:()=>It,instanceJsonSchema:()=>Dt,partialConfigJsonSchema:()=>At});var St=rn.z.object({push:rn.z.unknown().describe("Collector push function"),command:rn.z.unknown().describe("Collector command function"),sources:rn.z.unknown().optional().describe("Map of registered source instances"),elb:rn.z.unknown().describe("Public API function (alias for collector.push)")}).catchall(rn.z.unknown()).describe("Base environment for dependency injection - platform-specific sources extend this"),jt=Un.extend({settings:rn.z.any().describe("Implementation-specific configuration").optional(),env:St.optional().describe("Environment dependencies (platform-specific)"),id:dn.describe("Source identifier (defaults to source key)").optional(),onError:mn.optional(),primary:rn.z.boolean().describe("Mark as primary (only one can be primary)").optional(),require:rn.z.array(rn.z.string()).optional().describe('Defer source initialization until these collector events fire (e.g., ["consent"])'),logger:rn.z.object({level:rn.z.union([rn.z.number(),rn.z.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:rn.z.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler) to override the collector defaults"),ingest:rn.z.union([An,Dn]).optional().describe("Ingest metadata extraction mapping. Extracts values from raw request objects (Express req, Lambda event) using mapping syntax.")}).describe("Source configuration with mapping and environment"),xt=jt.partial().describe("Partial source configuration with all fields optional"),Et=rn.z.object({type:rn.z.string().describe('Source type identifier (e.g., "browser", "dataLayer")'),config:jt.describe("Current source configuration"),push:rn.z.any().describe("Push function - THE HANDLER (flexible signature for platform compatibility)"),destroy:rn.z.any().optional().describe("Cleanup function called when source is removed"),on:rn.z.unknown().optional().describe("Lifecycle hook function for event types")}).describe("Source instance with push handler and lifecycle methods"),Ot=rn.z.any().describe("Source initialization function: (config, env) => Instance | Promise<Instance>"),Pt=rn.z.object({code:Ot.describe("Source initialization function"),config:xt.optional().describe("Partial configuration overrides"),env:St.partial().optional().describe("Partial environment overrides"),primary:rn.z.boolean().optional().describe("Mark as primary source (only one can be primary)")}).describe("Source initialization configuration"),Ct=rn.z.record(rn.z.string(),Pt).describe("Map of source IDs to initialization configurations"),Nt=sn(St),$t=sn(jt),At=sn(xt),Dt=sn(Et),Rt=sn(Pt),It=sn(Ct),Mt=rn.z.union([rn.z.string(),rn.z.number(),rn.z.boolean()]).describe("Primitive value: string, number, or boolean"),Tt=rn.z.record(rn.z.string(),Mt).describe("Variables for interpolation"),qt=rn.z.record(rn.z.string(),rn.z.unknown()).describe("Reusable configuration definitions"),Lt=rn.z.record(rn.z.string().regex(/^(@[a-z0-9\-~][a-z0-9\-._~]*\/)?[a-z0-9\-~][a-z0-9\-._~]*$/,"Invalid npm package name"),rn.z.object({version:rn.z.string().optional(),imports:rn.z.array(rn.z.string()).optional(),path:rn.z.string().optional()})).describe("NPM packages to bundle"),Jt=rn.z.object({windowCollector:rn.z.string().default("collector").optional().describe('Window property name for the collector instance (default: "collector")'),windowElb:rn.z.string().default("elb").optional().describe('Window property name for the elb command queue (default: "elb")')}).describe("Web platform configuration"),Ut=rn.z.object({}).passthrough().describe("Server platform configuration (reserved for future options)"),Wt=rn.z.object({push:rn.z.string().min(1,"Push function cannot be empty").describe('JavaScript function for processing events. Must start with "$code:" prefix. Example: "$code:(event) => { console.log(event); }"'),type:rn.z.string().optional().describe("Optional type identifier for the inline instance"),init:rn.z.string().optional().describe("Optional initialization function. Use $code: prefix for inline JavaScript.")}).describe("Inline code for custom sources/transformers/destinations"),_t=rn.z.object({description:rn.z.string().optional().describe("Human-readable description"),in:rn.z.unknown().optional().describe("Input to the step"),trigger:rn.z.object({type:rn.z.string().optional().describe("Trigger mechanism (e.g., click, POST, load)"),options:rn.z.unknown().optional().describe("Mechanism-specific options")}).optional().describe("Source trigger metadata"),mapping:rn.z.unknown().optional().describe("Mapping configuration"),out:rn.z.unknown().optional().describe("Expected output from the step")}).describe("Named example with input/output pair"),Bt=rn.z.record(rn.z.string(),_t).describe("Named step examples for testing and documentation"),Ht=rn.z.object({package:rn.z.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/web-source-browser@2.0.0")'),code:rn.z.union([rn.z.string(),Wt]).optional().describe('Either a named export string (e.g., "sourceExpress") or an inline code object with push function'),config:rn.z.unknown().optional().describe("Source-specific configuration object"),env:rn.z.unknown().optional().describe("Source environment configuration"),primary:rn.z.boolean().optional().describe("Mark as primary source (provides main elb). Only one source should be primary."),variables:Tt.optional().describe("Source-level variables (highest priority in cascade)"),definitions:qt.optional().describe("Source-level definitions (highest priority in cascade)"),next:rn.z.union([rn.z.string(),rn.z.array(rn.z.string())]).optional().describe("Pre-collector transformer chain. Name of the first transformer to run after this source captures an event. If omitted, events go directly to the collector. Can be an array for explicit chain control."),examples:Bt.optional().describe("Named step examples for testing and documentation (stripped during bundling)")}).describe("Source package reference with configuration"),Vt=rn.z.object({package:rn.z.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/transformer-enricher@1.0.0")'),code:rn.z.union([rn.z.string(),Wt]).optional().describe('Either a named export string (e.g., "transformerEnricher") or an inline code object with push function'),config:rn.z.unknown().optional().describe("Transformer-specific configuration object"),env:rn.z.unknown().optional().describe("Transformer environment configuration"),next:rn.z.union([rn.z.string(),rn.z.array(rn.z.string())]).optional().describe("Next transformer in chain. If omitted: pre-collector routes to collector, post-collector routes to destination."),variables:Tt.optional().describe("Transformer-level variables (highest priority in cascade)"),definitions:qt.optional().describe("Transformer-level definitions (highest priority in cascade)"),examples:Bt.optional().describe("Named step examples for testing and documentation (stripped during bundling)")}).describe("Transformer package reference with configuration"),Ft=rn.z.object({package:rn.z.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/web-destination-gtag@2.0.0")'),code:rn.z.union([rn.z.string(),Wt]).optional().describe('Either a named export string (e.g., "destinationAnalytics") or an inline code object with push function'),config:rn.z.unknown().optional().describe("Destination-specific configuration object"),env:rn.z.unknown().optional().describe("Destination environment configuration"),variables:Tt.optional().describe("Destination-level variables (highest priority in cascade)"),definitions:qt.optional().describe("Destination-level definitions (highest priority in cascade)"),before:rn.z.union([rn.z.string(),rn.z.array(rn.z.string())]).optional().describe("Post-collector transformer chain. Name of the first transformer to run before sending events to this destination. If omitted, events come directly from the collector. Can be an array for explicit chain control."),examples:Bt.optional().describe("Named step examples for testing and documentation (stripped during bundling)")}).describe("Destination package reference with configuration"),Kt=rn.z.object({package:rn.z.string().min(1,"Package name cannot be empty").optional().describe("Store package specifier with optional version"),code:rn.z.union([rn.z.string(),Wt]).optional().describe("Named export string or inline code definition"),config:rn.z.unknown().optional().describe("Store-specific configuration object"),env:rn.z.unknown().optional().describe("Store environment configuration"),variables:Tt.optional().describe("Store-level variables (highest priority in cascade)"),definitions:qt.optional().describe("Store-level definitions (highest priority in cascade)"),examples:Bt.optional().describe("Named step examples for testing and documentation (stripped during bundling)")}).describe("Store package reference with configuration"),Gt=rn.z.record(rn.z.string(),rn.z.unknown()).describe("JSON Schema object for event validation with description/examples annotations"),Zt=rn.z.record(rn.z.string(),Gt).describe("Action-level contract entries"),Qt=rn.z.record(rn.z.string(),Zt).describe("Entity-action event schemas"),Xt=rn.z.object({extends:rn.z.string().optional().describe("Inherit from another named contract"),tagging:rn.z.number().int().min(0).optional().describe("Contract version number"),description:rn.z.string().optional().describe("Human-readable description"),globals:Gt.optional().describe("JSON Schema for event.globals"),context:Gt.optional().describe("JSON Schema for event.context"),custom:Gt.optional().describe("JSON Schema for event.custom"),user:Gt.optional().describe("JSON Schema for event.user"),consent:Gt.optional().describe("JSON Schema for event.consent"),events:Qt.optional().describe("Entity-action event schemas")}).describe("Named contract entry with optional sections and events"),Yt=rn.z.record(rn.z.string(),Xt).describe("Named contracts with optional extends inheritance"),ei=rn.z.object({web:Jt.optional().describe("Web platform configuration (browser-based tracking). Mutually exclusive with server."),server:Ut.optional().describe("Server platform configuration (Node.js). Mutually exclusive with web."),sources:rn.z.record(rn.z.string(),Ht).optional().describe("Source configurations (data capture) keyed by unique identifier"),destinations:rn.z.record(rn.z.string(),Ft).optional().describe("Destination configurations (data output) keyed by unique identifier"),transformers:rn.z.record(rn.z.string(),Vt).optional().describe("Transformer configurations (event transformation) keyed by unique identifier"),stores:rn.z.record(rn.z.string(),Kt).optional().describe("Store configurations (key-value storage) keyed by unique identifier"),collector:rn.z.unknown().optional().describe("Collector configuration for event processing (uses Collector.InitConfig)"),packages:Lt.optional().describe("NPM packages to bundle"),variables:Tt.optional().describe("Flow-level variables (override Config.variables, overridden by source/destination variables)"),definitions:qt.optional().describe("Flow-level definitions (extend Config.definitions, overridden by source/destination definitions)")}).refine(e=>{const n=void 0!==e.web,t=void 0!==e.server;return(n||t)&&!(n&&t)},{message:'Exactly one of "web" or "server" must be present'}).describe("Single flow settings for one deployment target"),ni=rn.z.object({$schema:rn.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/v2.json")'),include:rn.z.array(rn.z.string()).optional().describe("Folders to include in the bundle output"),variables:Tt.optional().describe("Shared variables for interpolation across all flows (use $var.name syntax)"),definitions:qt.optional().describe("Reusable configuration definitions (use $def.name syntax)"),flows:rn.z.record(rn.z.string(),ei).refine(e=>Object.keys(e).length>0,{message:"At least one flow is required"}).describe("Named flow configurations (e.g., production, staging, development)")}).extend({version:rn.z.literal(3).describe("Configuration schema version"),contract:Yt.optional().describe("Named contracts with extends inheritance and dot-path references")}).describe("walkerOS flow configuration (walkeros.config.json)"),ti=(rn.z.toJSONSchema(ni,{target:"draft-7"}),sn(ei),sn(Ht),sn(Ft),sn(Vt),sn(Kt),sn(Xt),sn(Yt),require("zod")),ii=ti.z.object({lang:ti.z.string().optional().describe("Language identifier (e.g. json, sql, bash, typescript)"),code:ti.z.string().describe("Code snippet")}),oi=ti.z.object({text:ti.z.string().describe("Short actionable hint text focused on walkerOS usage"),code:ti.z.array(ii).optional().describe("Optional code snippets")}),ri=(ti.z.record(ti.z.string(),oi).describe("Keyed hints for AI consumption — lightweight context beyond schemas and examples"),new Set(["env","onError","onLog","primary"])),si={source:kt.configJsonSchema,destination:Wn.configJsonSchema};function ai(e,n){const t=si[e];if(!t||!t.properties){return{type:"object",properties:{settings:n.settings?ci(n.settings):{description:"Implementation-specific configuration"}}}}const i=JSON.parse(JSON.stringify(t)),o=i.properties;for(const e of ri)delete o[e];return n.settings&&(o.settings=ci(n.settings)),i}function ci(e){const{$schema:n,...t}=e;return t}//# sourceMappingURL=index.js.map