@versionzero/schema 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* @versionzero/schema | Apache-2.0 | github.com/argh */
|
|
2
|
+
var ua=Object.defineProperty;var m=(e,r)=>()=>(e&&(r=e(e=0)),r);var h=(e,r)=>{for(var t in r)ua(e,t,{get:r[t],enumerable:!0})};function ve(e){if(e==="")return["",void 0];let r=e.indexOf(".");return r===-1?[e,""]:[e.slice(0,r),e.slice(r+1)]}var pr=m(()=>{"use strict"});var j,Le=m(()=>{"use strict";pr();j=class e{#e=new Map;#r;#t;#n;constructor(r,t,n){this.#t=r,t!==void 0&&n!==void 0?(this.#r=t,this.#n=t.path?`${t.path}.${n}`:`${n}`):this.#n=""}get path(){return this.#n}toString(){return this.#n}get name(){let r=this.#n.lastIndexOf(".");return r===-1?this.#n:this.#n.slice(r+1)}get schema(){return this.#t}set schema(r){if(!(r===void 0||r===this.#t)){for(let[t,n]of this.#e){let i=r.getPropertySchema(t);i!==void 0?n.schema=i:this.#e.delete(t)}this.#t=r}}get parent(){return this.#r}get root(){return this.parent===void 0?this:this.parent.root}relative(r){if(!r||r===""||r===".")return this;if(r.charAt(0)==="^")return this.parent?.relative(r.slice(1));if(r.charAt(0)==="/")return this.root.relative(r.slice(1));if(r.charAt(0)===".")return this.relative(r.slice(1));let[t,n]=ve(r),i=this.#e.get(t);if(i===void 0){let o=this.schema.getPropertySchema(t);if(o===void 0)return;let s=this.path?`${this.path}.${t}`:`${t}`;i=new e(o),i.#n=s,i.#r=this,this.#e.set(t,i)}return n===void 0?i:i.relative(n)}absolute(r){return this.root.relative(r)}sibling(r){return r?this.parent?.relative(r):this}union(r){if(r===this.#t)return this;if(!this.schema||!this.schema.isUnion||!this.schema.findUnionKey(r))return;let n=new e(r);return n.#n=this.#n,n.#r=this.#r,n}findPropertyLocation(r){if(this.#t!==void 0)for(let[t]of this.#t.propertyEntries){if(t==="*")continue;let n=this.relative(t);if(n!==void 0?r(n):void 0)return n}}}});function Se(e,r={}){let{space:t=0,maxDepth:n=100,useDelimiters:i=!0,delimiterOpen:o="\xAB",delimiterClose:s="\xBB"}=r,a=new WeakMap,c=new WeakMap,d=(E,p=null)=>i?p!==null?`${o}${E}: ${p}${s}`:`${o}${E}${s}`:null,g=E=>{let p=E.description;return p!==void 0?p:(c.has(E)||c.set(E,ma()),c.get(E))},A=(E,p="$",b=0)=>{if(b>n)return d("MaxDepth");if(E===null)return null;if(E===void 0)return d("undefined");if(typeof E=="number")return Number.isNaN(E)?d("NaN"):E===1/0?d("Infinity"):E===-1/0?d("-Infinity"):E;if(typeof E=="boolean"||typeof E=="string")return E;if(typeof E=="symbol")return d("Symbol",g(E));if(typeof E=="function")return E.name?d("Function",E.name):d("undefined");if(typeof E=="bigint")return d("BigInt",E.toString());if(E instanceof Date){let R=d("Date",E.toISOString());return R!==null?R:E.toISOString()}if(Array.isArray(E)){if(a.has(E))return d("Circular",a.get(E));a.set(E,p);let R=E.map((U,W)=>A(U,`${p}[${W}]`,b+1)).filter(U=>U!==null||E.includes(null));return a.delete(E),R}if(typeof E=="object"){if(a.has(E))return d("Circular",a.get(E));a.set(E,p);let R=Object.keys(E).sort(),U={};for(let W of R){let Ae=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(W)?`${p}.${W}`:`${p}[${JSON.stringify(W)}]`,Ur=A(E[W],Ae,b+1);(Ur!==null||E[W]===null)&&(U[W]=Ur)}return a.delete(E),U}return null},S=A(e);return JSON.stringify(S,null,t)}function Je(e,r={}){let{delimiterOpen:t="\xAB",delimiterClose:n="\xBB"}=r,i=JSON.parse(e),o=new Map,s=[],a=S=>S.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=new RegExp(`^${a(t)}([^:${a(n)}]+)(?::\\s*(.+?))?${a(n)}$`),d=S=>{if(typeof S!="string")return null;let E=S.match(c);return E?{type:E[1],value:E[2]}:null},g=(S,E="$")=>{let p=d(S);if(p)switch(p.type){case"undefined":return;case"NaN":return NaN;case"Infinity":return 1/0;case"-Infinity":return-1/0;case"BigInt":return BigInt(p.value);case"Date":return new Date(p.value);case"Symbol":return Symbol.for(p.value);case"Function":return null;case"MaxDepth":return null;case"Circular":return s.push({targetPath:E,sourcePath:p.value}),null}if(S===null||typeof S!="object")return S;if(Array.isArray(S)){let R=[];return o.set(E,R),S.forEach((U,W)=>{let Ae=`${E}[${W}]`;R[W]=g(U,Ae)}),R}let b={};o.set(E,b);for(let[R,U]of Object.entries(S)){let W=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(R)?`${E}.${R}`:`${E}[${JSON.stringify(R)}]`;b[R]=g(U,W)}return b},A=g(i);for(let{targetPath:S,sourcePath:E}of s){let p=pa(A,S),b=o.get(E);p&&b&&da(p.obj,p.key,b)}return A}function pa(e,r){if(r==="$")return null;let t=la(r),n=e;for(let i=0;i<t.length-1;i++)if(n=n[t[i]],n==null)return null;return{obj:n,key:t[t.length-1]}}function da(e,r,t){e[r]=t}function la(e){let r=[],t="",n=!1;for(let i=0;i<e.length;i++){let o=e[i];if(!(o==="$"&&i===0))if(o==="."&&!n)t&&r.push(t),t="";else if(o==="[")t&&r.push(t),t="",n=!0;else if(o==="]"){if(n){let s=t.trim();s.startsWith('"')&&s.endsWith('"')?r.push(JSON.parse(s)):r.push(Number(s)),t="",n=!1}}else t+=o}return t&&r.push(t),r}var ma,Te=m(()=>{"use strict";ma=()=>crypto.randomUUID()});function F(e){if(e==null||typeof e!="object")return!1;let r=Object.getPrototypeOf(e);return r===Object.prototype||r===null}function Ie(e){return e&&typeof e=="object"&&!Array.isArray(e)}function H(e){return e==null||Array.isArray(e)&&e.length===0||F(e)&&Object.keys(e).length===0}function Qe(e){if(e==null)return!1;let r=typeof e;return r!=="object"&&r!=="function"}function Vr(e){if(typeof e!="function")return!1;let r=Function.prototype.toString.call(e);return/^class\s/.test(r)||/\[native code\]/.test(r)&&e.prototype?.constructor===e}function K(e,r){return Array.isArray(e)?e.map(r):F(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,r(n)])):[r(e)]}var L=m(()=>{"use strict"});function dr(e){if(e.metadata.valueDescription)return e.metadata.valueDescription;let r;return e.isArray&&e.hasChildren?(r=Array.from(e.propertyEntries).sort((n,i)=>n[0]==="*"?1:i[0]==="*"?-1:n[0].localeCompare(i[0],void 0,{numeric:!0})).map(n=>n[1]).map(n=>{let i=dr(n);return!n.required&&i.length>2&&i.charAt(0)==="["&&i.charAt(i.length-1)==="]"&&(i=i.slice(1,i.length-1)),i}).join(", "),e.hasWildcard&&(r+="..."),e.metadata.validatorDescription&&r&&!r.includes(e.metadata.validatorDescription)&&(r+=` {${e.metadata.validatorDescription}}`)):(Array.isArray(e.options.values)&&e.options.values.length>0?r=e.options.values.map(t=>`${typeof t=="string"?`"${t}"`:Se(t)}`).sort((t,n)=>t.localeCompare(n,void 0,{numeric:!0})).join("|"):(r=e.metadata.valueName??(e.isArray?"":e.options.type),e.metadata.validatorDescription&&(!r||r===e.options.type?r=e.metadata.validatorDescription:r=`${r} {${e.metadata.validatorDescription}}`)),r===void 0&&(r="value"),e.isArray&&!r.includes("...")&&(r+="...")),r}function w(e,r={}){let{delimiterOpen:t="\xAB",delimiterClose:n="\xBB",maxLength:i=40}=r;try{if(e===null)return`${t}null${n}`;if(e===void 0)return`${t}undefined${n}`;let o;if(typeof e=="function"&&e.name?o=`${t}${e.name}()${n}`:typeof e=="object"&&!F(e)&&e.constructor?.name?o=`${t}${e.constructor.name}${n}`:o=Se(e,{delimiterOpen:t,delimiterClose:n}),typeof e!="string"&&(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),ha.test(o)||(o=`${t}${o}${n}`),o.length>40){let s=o.charAt(o.length-1);o=o.slice(0,40)+`...${s}`}return o}catch{return"\uFFFD"}}var ha,k=m(()=>{"use strict";Te();L();ha=/^[^A-Za-z0-9_].+[^A-Za-z0-9_]$/});function jr(e,r,t,n="at"){r===""?r="(root)":r&&(r=`"${r}"`),t&&(r=r?`${r} property "${t}"`:`property "${t}"`);let i=e;return r&&(i+=` ${n} ${r}`),i}function wa(e,r,t,n,i){let o=w(r);return o?.length&&(e=`${e} with value ${o}`),jr(e,t,n,i)}var u,f,z,fe,Z,J,Ce,de,$,I,l=m(()=>{"use strict";k();u=class e extends Error{constructor(r,t,n=!1){let i=t?.cause?t.cause instanceof Error?t.cause:new e(t.cause,void 0,!1):void 0,o=t?.path??t?.location?.path??t?.cause?.path??t?.cause?.location?.path,s=t?.property;!r?.length&&i?.message&&(r=i.message),(!o||r.indexOf(o)===-1)&&(t?.hasOwnProperty("value")?r=wa(r,t?.value,o,s):r=jr(r,o,s)),super(r,i?{cause:i}:void 0),t&&(this.data={...t,cause:i});let a=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,a):this.__proto__=a,n||delete this.stack,t?.cause&&!super.cause&&(this.cause=t.cause)}get name(){return this.constructor.name}get stack(){return""}set stack(r){}toString(){return this.message?`${this.name}: ${this.message}`:this.cause?.message?`${this.name}: ${this.cause.message}`:this.name}},f=class extends u{},z=class extends u{},fe=class extends u{},Z=class extends u{},J=class extends u{},Ce=class extends u{},de=class extends u{},$=class extends u{},I=class extends u{}});function er(e,...r){if(!r.length)return e;let t=r.shift();if(Ie(e)&&Ie(t))for(let n in t)F(t[n])?(e[n]||Object.assign(e,{[n]:{}}),er(e[n],t[n])):Object.assign(e,{[n]:t[n]});return er(e,...r)}function G(e,r){if(e===r)return!0;if(e==null||r==null||typeof e!=typeof r)return!1;if(Array.isArray(e)&&Array.isArray(r)){if(e.length!==r.length)return!1;for(let t=0;t<e.length;++t)if(!G(e[t],r[t]))return!1;return!0}if(typeof e=="object"&&typeof r=="object"){if(Array.isArray(e)||Array.isArray(r))return!1;let t=Object.keys(e);if(t.length!==Object.keys(r).length)return!1;for(let n of t)if(!r.hasOwnProperty(n)||!G(e[n],r[n]))return!1;return!0}return!1}function ne(e,r){if(r==="")return e;if(!e||typeof e!="object"||typeof r!="string")return;let t=r.split(".").filter(i=>i.length>0);if(t.length===0)return;let n=e;for(let i of t){if(!n||typeof n!="object")return;/^\d+$/.test(i)?n=n[Number(i)]:n=n[i]}return n}function rr(e){if(e!=null)if(F(e)){for(let r of Object.keys(e))rr(e[r])===void 0&&delete e[r];return Object.keys(e).length?e:void 0}else if(Array.isArray(e)){for(let r=e.length-1;r>=0;r--){let t=rr(e[r]);t===void 0?r===e.length-1?e.pop():delete e[r]:t!==e[r]&&(e[r]=t)}return e.length?e:void 0}else return e}var ie=m(()=>{"use strict";L()});var C,D,v=m(()=>{"use strict";lr();Q();l();ie();C=class e{#e;#r={};#t={};#n={};#i={};#s={};constructor(r,t,n){typeof r=="string"?(this.base=r,t&&this._setAttributes(t),n&&this.addMetadata(n)):r instanceof e||r instanceof x?(this.extend(r),r instanceof e&&(this.base=r.base),t&&this._setAttributes(t),n&&this.addMetadata(n)):typeof r=="object"&&r!==null&&this.extend(r)}get base(){return this.#e}set base(r){this.#e=r}get properties(){return this.#r}get handlers(){return this.#t}get options(){return this.#n}get metadata(){return this.#i}get unionSchemas(){return this.#s}toData(){return Me(this)}_setAttribute(r,t){if(r==="base")return this.base=t,this;if(r==="metadata")return this.addMetadata(t);if(r==="options")return this.addOptions(t??{});if(r==="handlers")return this.addHandlers(t??{});if(r==="properties")return this.addProperties(t??{});if(r==="unionSchemas")return this.addUnionSchemas(t??{});if(Object.getPrototypeOf(this)?.hasOwnProperty(r)){if(typeof this[r]!="function")throw new u("Unknown attribute!");try{return this[r].call(this,t)}catch{}}return r.startsWith("_")?this.meta(r.slice(1),t):this.option(r,t)}_setAttributes(r={}){if(typeof r!="object")throw new u("Expected an object containing options and metadata attributes");for(let[t,n]of Object.entries(r))this._setAttribute(t,n);return this}property(r,t){if(typeof r!="string")throw new u("Properties must be associated with a valid name");if(t==="string"&&(t=new e(t)),!(t instanceof e)&&!(t instanceof x)){if(t===void 0)return delete this.properties[r],this;throw new u("Property value must be a schema")}return this.properties[r]=t,this.base===void 0&&this.options.type,this.options.container??=!0,this}addProperties(r,t=D.INITIALIZE){if(typeof r!="object")throw new u("Invalid properties definition");for(let[n,i]of Object.entries(r))(t===D.OVERWRITE||this.properties[n]===void 0)&&this.property(n,e.createFromModel(i));return this}option(r,t){if(typeof r!="string")throw new u("Options must be associated with a valid key");if(r.startsWith("_"))throw new u("Option keys cannot have a leading underscore");return t===void 0&&(t=!0),t===null?delete this.options[r]:this.options[r]=t,this}addOptions(r,t=D.INITIALIZE){if(t!==D.INITIALIZE&&t!==D.OVERWRITE)throw new u("Unsupported policy");if(typeof r!="object")throw new u("Options definition must be an object");for(let[n,i]of Object.entries(r))(t===D.OVERWRITE||this.options[n]===void 0)&&this.option(n,i);return this}handler(r,t=[],n=D.APPEND){if(typeof r!="string")throw new u("Handlers must be associated with a valid key");if(!Object.values(D).includes(n))throw new u("Unknown policy");return t===void 0?(n===D.OVERWRITE&&delete this.handlers[r],this):(Array.isArray(t)||(t=[t]),t=t.map(i=>i===void 0?"$undefined":i===null?"$null":i),n===D.INITIALIZE&&Array.isArray(this.handlers[r])?this:n===D.OVERWRITE||n===D.INITIALIZE?(this.handlers[r]=t,this):(Array.isArray(this.handlers[r])||(this.handlers[r]=[]),n===D.PREPEND?this.handlers[r].unshift(...t):this.handlers[r].push(...t),this))}addHandlers(r,t=D.INITIALIZE){if(typeof r!="object")throw new u("Handlers definition must be an object");for(let[n,i]of Object.entries(r))this.handler(n,i,t);return this}meta(r,t){if(typeof r!="string")throw new u("Metadata must be associated with a valid key");return t===void 0&&(t=!0),t===null?delete this.metadata[r]:(r.startsWith("_")&&(r=r.slice(1)),this.metadata[r]=t),this}addMetadata(r,t=D.INITIALIZE){if(typeof r!="object")throw new u("Invalid metadata definition");for(let[n,i]of Object.entries(r))(t===D.OVERWRITE||this.metadata[n]===void 0)&&this.meta(n,i);return this}unionDiscriminator(r){return this.unionDiscriminators(r)}unionDiscriminators(r,t){return this.handler("discriminators",r,t)}unionSchema(r,t){if(!(t instanceof e||t instanceof x))throw new u(`Invalid schema for union member ${r}`);return this.unionSchemas[r]=t,this}addUnionSchemas(r,t=D.INITIALIZE){if(t!==D.INITIALIZE&&t!==D.OVERWRITE)throw new u("Unsupported policy");if(typeof r!="object")throw new u("Invalid union schemas object");for(let[n,i]of Object.entries(r))(t===D.OVERWRITE||this.unionSchemas[n]===void 0)&&this.unionSchema(n,e.createFromModel(i));return this}unionKey(r){return this.options.unionKey=!!(r??!0),this}selector(r){return this.options.selector=!!(r??!0),this}selection(r){return this.options.selection=r??!0,this.condition(async(t,n,i)=>{if(!i.schema.isSelection)throw new u("Conditional expected a selection schema!",{location:i});let o=this.options.selection===!0?i.name:this.options.selection,s=i.parent?.findPropertyLocation(a=>a.schema.isSelector);if(s){let a=s.schema,c=ne(n,s.path);return await a.normalizeValue(c,n,s)===await a.normalizeValue(o,n,s)}return!1}),this}required(r){return this.options.required=r??!0,this}optional(r){return this.options.required=!r,this}default(r){return this.options.default=r,this}deep(r){return this.options.deep=r??!0,this}allowEmpty(r){return this.options.allowEmpty=r??!0,this}allowIncremental(r){return this.options.allowIncremental=r??!0,this}opaque(r=!0){return this.options.allowIncremental=!r,this}strict(r){return this.options.strict=r??!0,this}lax(r){return this.options.strict=r===void 0?!1:!r,this}implicit(r){return this.options.implicit=r??!0,this}value(r){return this.values([r])}values(r=[],t=D.APPEND){return t===D.INITIALIZE&&Array.isArray(this.options.values)?this:((t===D.OVERWRITE||!Array.isArray(this.options.values))&&(this.options.values=[]),Array.isArray(r)||(r=[r]),t===D.PREPEND?this.options.values.unshift(...r):this.options.values.push(...r),this)}condition(r){return this.conditions(r)}conditions(r,t){return this.handler("conditions",r,t)}normalizer(r){return this.normalizers(r)}normalizers(r,t){return this.handler("normalizers",r,t)}transformer(r){return this.transformers(r)}transformers(r,t){return this.handler("transformers",r,t)}finalizer(r){return this.finalizers(r)}finalizers(r,t){return this.handler("finalizers",r,t)}validator(r){return this.validators(r)}validators(r,t){return this.handler("validators",r,t)}serializer(r){return this.serializers(r)}serializers(r,t){return this.handler("serializers",r,t)}extend(r,t=new Map){if(typeof r!="object")throw new u("Invalid schema to extend");return!this.base&&r.base&&(this.base=r.base),this.addProperties(Object.fromEntries(Object.entries(r.properties??{}).map(([n,i])=>[n,e.createFromModel(i,t)]))),this.addUnionSchemas(Object.fromEntries(Object.entries(r.unionSchemas??{}).map(([n,i])=>[n,e.createFromModel(i,t)]))),this.addOptions(r.options??{}),this.addMetadata(r.metadata??{}),this.addHandlers(r.handlers??{}),this}clone(){return e.createFromModel(this)}static createFromModel(r,t=new Map){if(typeof r=="string")return new e(r);if(t.has(r))return t.get(r);let n=new e;return t.set(r,n),r.base&&(n.base=r.base),n.extend(r,t)}static create(r,t,n){return new e(r,t,n)}static literal(r,t,n){let i="any";typeof r=="string"?i="string":typeof r=="number"?i="number":typeof r=="boolean"&&(i="boolean");let o=new e(i).option("values",[r]).option("default",r).option("compileHook",(s,a)=>{if(s==="finalize"){if(a.options.values?.length!==1)throw new u("Literal schema needs one value defined");if(a.hasChildren)throw new u("Literal schema should not have child properties");if(a.isUnion)throw new u("Literal schema should not be a union")}}).transformer(()=>r);return t&&o._setAttributes(t),n&&o.addMetadata(n),o}static inherit(r){return new e().option("reference",!0).transformer((t,n,i,o)=>{let s=r??i.name;if(i.parent===void 0){if(i.schema.strict!==!1)throw new u("A top-level schema cannot have an inherited value");return}let a=i.parent?.parent;for(;a!==void 0;){let c=a.relative(s);if(c!==void 0)return ne(n,c.path);a=a.parent}if(i.schema.strict!==!1)throw new u(`Inherited property "${s}" not found in any ancestor of "${i}"`)}).serializer(()=>{}).default((t,n,i)=>r??i.name).meta("omitFromSerialize").meta("internal")}static reference(r,t=!1){let n=r?.charAt(0);return(n==="^"||n==="/"||n===".")&&(t=!0),new e().option("reference",!0).default(r).normalizer(()=>r).transformer((i,o,s,a)=>{let c=t?s.relative(r):s.absolute(r);if(c===void 0)throw new u(`Reference path ${r} not found`);if(c.schema===void 0){if(a?.context?.final)throw new u(`Schema for reference path ${r} not found`);return}return ne(o,c.path)}).validator((i,o,s,a)=>{let c=t?s.relative(r):s.absolute(r);if(c===void 0)throw new u(`Reference path ${r} not found`);let d=c.schema;if(d===void 0){if(a?.context?.final)throw new u(`Schema for reference path ${r} not found`);return}if(ne(o,c.path)===i)return i;if(!d?.hasChildren||d.isOpaque)throw new u(`Reference is not exactly the same as ${r}`);return i}).serializer(()=>{}).meta("omitFromSerialize").meta("internal")}},D=Object.freeze({INITIALIZE:Symbol("INITIALIZE"),OVERWRITE:Symbol("OVERWRITE"),APPEND:Symbol("APPEND"),PREPEND:Symbol("PREPEND")})});function Me(e,r=new WeakMap){if(typeof e!="object")throw new u("Not a schema!");if(r.has(e))return r.get(e);let t={};r.set(e,t),!(e instanceof x)&&e.base&&(t.base=e.base);for(let n of["properties","unionSchemas","metadata","options","handlers"])if(e[n])for(let[i,o]of Object.entries(e[n])){t[n]===void 0&&(t[n]={});let s=o instanceof C||o instanceof x,a=o;s?a=Me(o,r):n==="handlers"&&Array.isArray(o)&&(a=o.map(c=>c===null?"$null":c===void 0?"$undefined":typeof c=="object"&&c.spec!==void 0?c.spec:c)),t[n][i]=a}return t}var lr=m(()=>{"use strict";Q();v();l()});function M(e){return e instanceof T?e:typeof e=="function"?new qe(e):new B(e)}var T,qe,B,hr,Oe,zr,Dr,Y=m(()=>{"use strict";T=class{execute(r,...t){return r}get isConstant(){return!1}},qe=class extends T{#e;constructor(r){super(),this.#e=r}execute(r,...t){return this.#e(r,...t)}},B=class extends T{#e;constructor(r){super(),this.#e=r}execute(){return this.#e}get isConstant(){return!0}},hr=new B(null),Oe=new B(void 0),zr=new B(!0),Dr=new B(!1)});var q,oe=m(()=>{"use strict";q=Symbol("EMPTY")});var tr,Lr=m(()=>{"use strict";l();oe();ie();L();tr=class{#e;#r;#t;#n;#i;#s;#o=new Map;#u;#a=void 0;#h=new Set;#w=void 0;#m=void 0;#c;#d=!1;#y=!1;#f=void 0;#g=!1;#p=void 0;#l;executorCache={};constructor(r,t){if(this.#e=r,this.#r=t,this.#i=r.root.absolute(t),this.#r==="")this.#t="";else{let n=this.#r.lastIndexOf("."),i=n===-1?"":this.#r.slice(0,n);this.#s=this.#e.getState(i),this.#t=n===-1?this.#r:this.#r.slice(n+1),this.#s.#o.set(this.#t,this)}this.#n=/^\d+$/.test(this.#t)?Number(this.#t):this.#t,this.#i?.schema!==void 0&&!this.#i.schema.hasConditions&&(this.#c=!0),this.completed=!1}get context(){return this.#e}get parent(){return this.#s}get path(){return this.#r}get name(){return this.#t}get key(){return this.#n}get location(){return this.#i===void 0&&(this.#i=this.context.root.absolute(this.path)),this.#i}set location(r){this.#i=r}get schema(){return this.location?.schema}set schema(r){if(this.location===void 0||r===void 0)throw new u("Inconsistent traversal state",{location:this.location});let t=this.schema;if(t&&t!==r){if(t.isUnion){if(this.unionKey=t.findUnionKey(r),!this.unionKey)throw new u("Union resolved to an unknown schema");this.executorCache={},this.location.schema=r,this.invalidate(),this.invalidateChildren()}this.context.update()}this.location.schema=r,r.hasConditions||(this.#c=!0)}get condition(){return this.#c}set condition(r){if(this.#c!==r){if(r===!1&&this.#c===!0)return;this.context.update()}this.#c=r}get unionKey(){return this.#p?this.#p[0]:void 0}set unionKey(r){r===void 0?this.#p=void 0:(this.#p??=[],this.#p.unshift(r))}getChildState(r){return r===""?this:this.#o.get(r)??this.context.getState(this.path?`${this.path}.${r}`:`${r}`)}getRelativeState(r){let t=this.location?.relative(r);return t?this.context.getState(t):void 0}get assignedInput(){return this.#u}set assignedInput(r){if(r===null){this.value=null;return}G(r,this.#u)||(this.context.update(),this.processed=!1,this.completed=!1,this.#u=r)}get input(){return this.#a}set input(r){if(r===null){this.value=null;return}if(!G(r,this.#a)&&(this.context.update(),this.processed=!1,this.completed=!1,this.#a=r,this.schema!==void 0)){if(!this.schema?.hasChildren&&r!==void 0&&(this.mandatory=!0),this.schema.hasChildren){if(F(r)||typeof r=="object"&&this.isIncremental){for(let[t,n]of Object.entries(r))if(n!=null){let i=this.getChildState(t);i.assignedInput=n}}else if(Array.isArray(r))for(let t=0;t<r.length;++t){let n=r[t];if(n!=null){let i=this.getChildState(`${t}`);i.assignedInput=n}}}this.schema?.hasChildren&&!this.schema.isUnion&&r!==q&&(!H(r)||this.schema.options.allowEmpty)&&(this.mandatory=!0)}}get pending(){return this.#w}set pending(r){r===null&&(this.value=null,this.#w=void 0),this.#w=r}get value(){return this.#m}set value(r){if(this.#m!==void 0&&r===void 0)throw new u("Cannot unset value",{location:this.location});if(this.#m!==r){if(this.isPruned)throw new u(`Cannot set value at ${this.path} - node is pruned`);if(Qe(r)&&this.schema?.hasChildren&&!this.schema?.isImplicit&&!this.schema?.isOpaque)throw new u("Container processing resulted in unexpected primitive",{value:r,location:this.location});this.#m=r,this.context.update(),r===void 0&&(this.completed=!1),this.path===""&&(this.processed=!0),r!==void 0&&this.#h.add(this.assignedInput),r===null&&!this.processed&&(this.processed=!0,this.completed=!0)}}copyPendingChildValues(r,t){if(t!==void 0&&!this.isOpaque&&this.hasChildren&&t!==r&&Ie(t)&&Ie(r))for(let[n,i]of Object.entries(r)){if(i===void 0)continue;let o=this.#o.get(n);o?.schema&&!o.schema.isImplicit&&(o.isPruned?t[n]!==void 0&&delete t[n]:t[n]!==i&&(t[n]=i))}}invalidate(){this.#c=this.location?.schema&&!this.location.schema.hasConditions?!0:void 0,this.#m=void 0,this.#d=!1,this.#l=void 0,this.#f=void 0,this.context.update()}get mandatory(){return this.#g}set mandatory(r){this.#g=!!r}get processed(){return this.#d}set processed(r){this.#d=!!r,this.#d&&this.hasChildren}get isRequired(){if(this.#f!==void 0)return this.#f;if(this.schema?.required)this.#f=!0;else if(!this.hasChildren)this.#f=!1;else if(this.isDeep){for(let r of this.#o.values())if(r.isRequired){this.#f=!0;break}}return this.#f??!1}get isComplete(){return this.completed||this.isPruned||!this.condition&&this.context.final?!0:this.value===void 0&&(this.isRequired||this.schema?.default!==void 0&&(typeof this.schema.default!="function"||this.schema.options.dynamic===!1))||this.hasIncompleteDescendents||this.hasWorkInProgress||this.isUnion?!1:this.processed||this.schema?.isImplicit||this.value!==void 0?!0:this.schema?.isReference&&!this.context.final||this.mandatory?!1:typeof this.assignedInput=="function"&&this.schema?.options.dynamic!==!1&&this.input===void 0?this.context.final:this.assignedInput!==void 0&&!this.#h.has(this.assignedInput)?!1:this.assignedInput===void 0&&this.context.traversals>0?!0:!!(this.assignedInput===void 0&&this.context.final)}get completed(){return this.#y}set completed(r){this.#y=!!r,!this.#y&&this.parent?.completed&&(this.parent.completed=!1)}get hasProcessedInput(){return this.value!==void 0&&this.assignedInput!==void 0&&this.input!==void 0&&this.#h.has(this.assignedInput)}get isPlaceholder(){return this.schema?.default!==void 0?!1:!this.mandatory&&this.value===void 0}get hasChildren(){return this.schema?.hasChildren??!1}get isContainer(){return this.schema?.isContainer??!1}get isPruned(){return this.#m===null||!!this.#s?.isPruned}get isDeep(){return this.schema?.deep??this.context.deep}get isOpaque(){return this.schema===void 0?!0:!this.hasChildren||this.schema.isOpaque}get isIncremental(){return this.schema===void 0?!1:this.hasChildren&&!this.schema.isOpaque}get isStrict(){return this.schema===void 0?this.parent?.isStrict??this.context.strict:this.schema.strict??this.context.strict}get allowUnknown(){return!this.isStrict}get isUnion(){return this.schema?.isUnion??!1}get isUnresolved(){return this.schema===void 0||this.schema.isUnion}get treatAsExplicit(){return this.schema===void 0?!0:this.schema.isImplicit?!1:!(this.hasChildren&&this.isIncremental)}get hasDescendentStates(){return this.hasChildren?this.#o.size>0:!1}get hasDescendentsToTraverse(){if(!this.hasChildren)return!1;let r=typeof this.#a=="object"&&!H(this.#a);return this.hasDescendentStates||r}get hasIncompleteDescendents(){return this.hasChildren?[...this.#o.values()].some(r=>!r.completed):!1}get incompleteDescendents(){if(!this.hasChildren)return[];let r=this.path?`${this.path}.`:"";return Array.from(this.#e.stateMap.values()).filter(t=>t.path!==this.path&&t.path.startsWith(r)&&!t.isComplete)}findIncompleteChildNames(r=new Set){for(let t of this.#o.values())t.completed||r.add(t.name);return r}listIncompleteChildren(){return[...this.#o.values()].filter(r=>!r.isComplete).map(r=>r.name)}listPendingChildren(){return[...this.#o.values()].filter(r=>r.hasWorkInProgress||r.needsInputProcessing).map(r=>r.name)}invalidateChildren(){for(let r of this.#o.values())r.value!==null&&r.invalidate()}get isEmptyPlaceholder(){return!this.schema?.hasChildren||!this.isPlaceholder?!1:!this.hasDescendentsToTraverse}get needsInputProcessing(){return this.value!==void 0?!1:typeof this.assignedInput!==void 0&&(this.input===void 0||this.pending===void 0)}get hasWorkInProgress(){return this.isPruned||this.pending===void 0||this.schema?.isImplicit?!1:this.hasChildren&&H(this.pending)?this.schema?.options.allowEmpty?!0:this.processed?!1:!!this.mandatory:!0}get activePropertyStates(){if(this.completed)return[];if(this.schema===void 0)return[];if(this.isOpaque&&this.processed)return[];if(!this.condition)return[];if(this.pending===void 0&&this.value===void 0&&!this.schema.options.allowUndefined&&!this.schema.options.deep)return[];if(!this.schema.hasChildren)return[];let r=new Set,t=this.input;if((F(t)||Array.isArray(t)||t&&this.isIncremental)&&Object.keys(t).forEach(o=>{r.add(o)}),this.findIncompleteChildNames(r),this.isIncremental||this.value===void 0)for(let[o,s]of this.schema.propertyEntries)o!=="*"&&(this.context.final||this.isDeep||s.required||s.default!==void 0||s.isReference)&&r.add(o);let n=this.pending??(this.isIncremental?this.value:void 0),i=Array.isArray(n)&&n.length||F(n)&&Object.keys(n).length;return!i&&!this.mandatory&&this.input===void 0&&!this.isDeep&&!this.hasIncompleteDescendents?[]:(i&&this.context.final&&Object.keys(n).forEach(o=>{(this.isStrict||this.schema?.getPropertySchema(o))&&r.add(o)}),[...r].map(o=>this.getChildState(o)))}get target(){return this.context.getValue()}get options(){return this.#l===void 0&&(this.#l={...this.context.options,deep:this.isDeep,strict:this.isStrict,state:this,context:this.context}),this.#l}}});function Mr(...e){(globalThis[ya]??console.log)?.(...e)}var ya,qr=m(()=>{"use strict";ya=Symbol.for("@versionzero/debug-sink")});var ue,wr=m(()=>{"use strict";Le();Lr();qr();pr();Q();oe();l();ue=class{constructor(r,t={}){this.root=r instanceof x?new j(r):r,this._final=!1,this._options={...t,deep:t.deep??!1,strict:t.strict??!0,debug:t.debug??!1,stats:t.stats??{}},this.traversals=0,this.counter=0,this.stateMap=new Map,this._debugEnabled=t?.debug??!1,this.compiling=!1}get options(){return this._options}get deep(){return this._options.deep}get strict(){return this._options.strict}get stats(){return this._options.stats}update(){this.counter++,this.final=!1}_finalizeCount=0;set final(r){if(this._final&&!r&&this._finalizeCount++>100)throw new u("Unable to finalize a stable output value");this._final=r??!0}get final(){return!!this._final}finalize(){return this._final=!0,this}get isComplete(){for(let r of this.stateMap.values())if(!r.isComplete)return!1;return!0}get incomplete(){let r=new Set;for(let t of this.stateMap.values())t.isComplete||r.add(t.path);return r}setValue(r){this._value=r}getValue(){return this._value!==void 0?this._value:this.getState("")?.value}setAssignedInput(r,t=""){if(r===void 0)return;let n=this.getState("");for(;t;){let[i,o]=ve(t),s=n.getChildState(i);n.assignedInput??=q,n=s,t=o,n.mandatory=!0}n.assignedInput=r,n.mandatory=!0}getState(r){r instanceof j&&(r=r.path);let t=this.stateMap.get(r);if(t===void 0){let n=this;t=new tr(n,r),n._value,this.stateMap.set(r,t)}return t}_debug(...r){this._debugEnabled&&Mr({contextName:"context"},...r)}traverse(r){let t=this.getState(""),n=!1,i=s=>(this.traversals++,this.stats.traversals=this.traversals,this.stats.updates=this.counter,this.isComplete?n=!0:this.counter===s?this.final?n=!0:this.final=!0:this.final=!1,n),o=()=>{let s;for(;!n;){let a=this.counter;if(s=r.execute(t),s instanceof Promise)return s.then(c=>i(a)?c:o(),c=>{throw c});i(a)}return s};return o()}}});var ae,Fe=m(()=>{"use strict";Y();ae=class extends T{#e;constructor(r=[]){Array.isArray(r)||(r=[r]),super(),this.#e=r.map(t=>M(t))}execute(r,...t){let n=0,i=this.#e;for(;n<i.length;)if(r=i[n++].execute(r,...t),r instanceof Promise)return r.then(o=>this.#r(o,t,n));return r}async#r(r,t,n){for(;n<this.#e.length;){let i=r;r=await this.#e[n++].execute(r,...t)}return r}}});var N,se=m(()=>{"use strict";Y();N=class extends T{#e;#r;constructor(r,t){super(),this.#r=r,this.#e=t}get description(){return this.#e}set description(r){this.#e=r}get spec(){return this.#r}set spec(r){this.#r=r}execute(r,t,n,i){return r}}});var me,Fr=m(()=>{"use strict";Y();me=class extends T{#e;constructor(r=[]){Array.isArray(r)||(r=[r]),super(),this.#e=r.map(t=>M(t))}execute(r,...t){if(r==null)return r;let n=0,i=this.#e;for(;n<i.length;){if(r=i[n++].execute(r,...t),r==null)return r;if(r instanceof Promise)return r.then(o=>this.#r(o,t,n))}return r}async#r(r,t,n){for(;n<this.#e.length;){if(r==null)return r;r=await this.#e[n++].execute(r,...t)}return r}}});function yr(e){let r=e.parent;if(r){if(e.assignedInput===void 0||e.assignedInput===q){let t=r.input?.[e.key];t!==void 0&&(e.assignedInput=t)}e.schema?.isImplicit&&!e.isPruned&&(e.value??=r.value?.[e.key])}if(e.isPruned)return null;if(!e.completed)return e}var Hr=m(()=>{"use strict";oe()});function gr(e){if(e.schema!==void 0)return e;let r=e.parent;if(r===void 0)throw new z("invariant: root path schema must be defined");if(r.schema===void 0)throw new z("invariant: cannot process a child if parent schema is undefined");if(!r.schema.isUnion||e.context.final)if(r?.schema?.strict??r?.context.strict){let i=e.context.root.schema?.isValidPath(e.path)?"Unexpected property":"Unknown property";throw new z(i,{path:e.path})}else return e.value=null,null}var Kr=m(()=>{"use strict";l()});function Br(e){return e.assignedInput===void 0&&e.pending===void 0&&e.value===void 0&&(e.schema?.default!==void 0?(e.assignedInput=e.schema.default,e.mandatory=!0):e.isDeep&&e.isContainer&&(e.assignedInput=q)),e}var Wr=m(()=>{"use strict";oe()});function Yr(e){if(e.processed&&e.hasProcessedInput)return e;if(e.assignedInput===null)return null;if(e.assignedInput===void 0)return e;if(e.location===void 0)return;let t=e.location.schema._normalizeValue(e.assignedInput,e.target,e.location,e.options),n=i=>(e.input=i,i===null?null:e);return t instanceof Promise?t.then(n):n(t)}var Zr=m(()=>{"use strict"});function Xr(e){if(e.input===null)return null;if(e.schema!==void 0)return e.schema.isImplicit||e.input===void 0||e.schema.ensureAccepts(e.input),e}var Gr=m(()=>{"use strict"});function He(e){if(!e.schema?.isUnion||!e.location)return e;let r=e.pending??e.input??e.value,t=e.schema._discriminateUnion(r,e.target,e.location,{...e.options,strict:e.context.final}),n=i=>{if(i){if(e.schema=i,i.isUnion)return He(e)}else if(e.context.final)throw new de("Unable to resolve union",{location:e.location});return e};return t instanceof Promise?t.then(i=>n(i)):n(t)}var vr=m(()=>{"use strict";l()});function nr(e){if(e.condition===!0)return e;if(e.schema===void 0)return;let r=e.schema._checkCondition(e.input,e.context.getValue(),e.location,e.options),t=n=>(e.condition=n,!n&&e.context.final&&(e.value=null),n?e:e.context.final?null:void 0);return r instanceof Promise?r.then(n=>t(n)):t(r)}var Jr=m(()=>{"use strict"});function Qr(e){if(e.location===void 0)return;let r=e.location.schema;if(e.input===void 0&&!r.options.allowUndefined)return e;if(e.hasChildren){if(e.pending!==void 0)return e;if(e.value!==void 0){if(e.isIncremental)return e.pending=e.value,e;throw new u("Value already processed",{location:e.location})}let t=r._normalizeValue(q,e.target,e.location,e.options);return t instanceof Promise?t.then(n=>(e.pending=n,e)):(e.pending=t,e)}else return e.pending=e.input,e}var et=m(()=>{"use strict";oe();l()});function rt(e){if(e.value!==void 0&&(e.value===e.pending||e.hasChildren&&e.isIncremental&&G(e.pending,e.value)))return e.pending=void 0,e;if(e.pending===void 0||e.schema===void 0||e.isUnion||e.schema.isImplicit||e.hasChildren&&e.isOpaque||e.hasChildren&&!e.mandatory&&H(e.pending))return e;let r=e.schema._transformValue(e.pending,e.target,e.location,e.options),t=n=>(n!==void 0&&(n!==e.value&&e.hasChildren&&e.copyPendingChildValues(e.pending,n),e.pending=void 0,e.value=n),e.value===null?null:e);return r instanceof Promise?r.then(t):t(r)}var tt=m(()=>{"use strict";ie();L()});function nt(e){if(e.isPruned)return null;if(e.isComplete)return e;if(!e.condition)return;if(e.schema===void 0||e.isUnion)return e;if(e.value!==void 0&&(e.value===e.pending||e.hasChildren&&e.isIncremental&&G(e.pending,e.value)))return e.pending=void 0,e;if(e.pending===void 0||e.schema?.isImplicit||!e.hasWorkInProgress||e.hasChildren&&e.isOpaque&&e.hasIncompleteDescendents||e.hasChildren&&e.isIncremental&&!e.mandatory&&H(e.pending)&&!e.schema.options.allowEmpty)return e;let r=e.schema._transformValue(e.pending,e.target,e.location,e.options),t=n=>(n!==void 0&&(n!==e.value&&e.hasChildren&&e.copyPendingChildValues(e.pending,n),e.pending=void 0,e.value=n),e.value===null?null:e);return r instanceof Promise?r.then(t):t(r)}var it=m(()=>{"use strict";ie();L()});function Er(e){if(!e.condition)return e;if(e.context.final&&e.isRequired&&e.value===void 0)throw new z("Undefined required value",{path:e.path});return e}var ot=m(()=>{"use strict";l()});function Ar(e){if(e.completed)return e;if(!(e.context.final||e.isComplete)){let i=e.isComplete;return e}if(e.schema===void 0){if(e.allowUnknown)return e;throw new z("Unknown value",{path:e.path})}if(e.schema.isUnion)throw new z("Unable to resolve union",{path:e.path});if(e.value===void 0&&e.schema.isReference&&!e.isRequired)return e;if(e.hasWorkInProgress){if(e.value===void 0&&!e.isRequired)return e;let i=e.hasWorkInProgress;throw new z("Incomplete assignment",{value:e.pending,path:e.path})}if(e.value===void 0)return e;let t=e.schema._validateValue(e.value,e.target,e.location,e.options),n=i=>(i!==e.value&&(e.value=i),e);return t instanceof Promise?t.then(n):n(t)}var st=m(()=>{"use strict";l()});function Ke(e){if(e.value===null||e.value===void 0&&e.input!==void 0)return e;if(e.completed)return;let r=e.parent;if(e.completed=e.isComplete,r===void 0)return e.isUnion||(e.processed=!0),e;let t=r.pending??r.value;if(t===null)return null;if(t===void 0||typeof t!="object"){let i=`${t}`;i.length>20&&(i=i.slice(0,20)+"...");let o=i.length?`\xAB${i}\xBB is not a valid container (set opaque option?)`:"Not a valid container (set opaque option?)";throw new u(o,{path:r.path})}let n=e.key;return e.schema?.isImplicit?(e.value??=t[n],e.processed=!0):(t[n]!==e.value&&(t[n]=e.value,e.context.update()),e.isUnion||(e.processed=!0)),e}var at=m(()=>{"use strict";l()});function Sr(e){if(e.assignedInput===void 0&&e.parent&&(e.assignedInput=e.parent.input?.[e.key]),e.isPruned)return null;if(!e.completed)return e.input=e.assignedInput,e.schema!==void 0&&(e.pending=e.input),e}var ct=m(()=>{"use strict"});function Cr(e){if(e.schema!==void 0)return e.input===void 0&&!e.schema.options.allowUndefined||(e.isUnion?e.pending??=e.input:(e.value=e.pending??e.input,e.pending=void 0)),e}var ft=m(()=>{"use strict"});function ut(e){return e==="true"||e==="1"||e==="yes"||e==="enabled"||e==="active"||e==="on"}function mt(e){return e==="false"||e==="0"||e==="no"||e==="disabled"||e==="inactive"||e==="off"||e===""||e==="undefined"||e==="null"||e==="none"}function ee(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let r=e.toLowerCase().trim();if(ut(r))return!0;if(mt(r))return!1}return e instanceof Error?!1:!!e}function pt(e){if(typeof e=="boolean")return!e;if(typeof e=="string"){let r=e.toLowerCase().trim();if(ut(r))return!1;if(mt(r))return!0}return e instanceof Error?!0:!e}var le=m(()=>{"use strict"});function dt(e){if(e.schema===void 0)return;let r=e.schema;if(e.assignedInput===null||r.isImplicit||ee(r.metadata.omitFromSerialize))return null;if(e.assignedInput===void 0)return e;let t=r._serializeValue(e.assignedInput,e.target,e.location,e.options),n=i=>i===null?(e.value=null,null):(e.pending??=e.hasChildren?r.isArray||Array.isArray(t)?[]:{}:i,e.isUnion||(e.value=e.pending),e.input=i,e);return t instanceof Promise?t.then(n):n(t)}var lt=m(()=>{"use strict";le()});function ht(e){if(e.completed)return e;if(e.schema===void 0){if(e.allowUnknown)return e;throw new J("Unknown value",{path:e.path})}if(!e.schema.requiresFinalization)return e;if(!(e.context.final||e.isComplete))return;if(e.schema.isUnion)throw new J("Unable to resolve union",{path:e.path});if(e.value===void 0&&e.schema.isReference&&!e.isRequired)return e;if(e.hasWorkInProgress){if(e.value===void 0&&!e.isRequired)return e;let i=e.hasWorkInProgress;throw new J("Incomplete assignment",{value:e.pending,path:e.path})}if(e.value===void 0)return e;let t=e.schema._finalizeValue(e.value,e.target,e.location,e.options),n=i=>(i!==e.value&&(e.value=i),e);return t instanceof Promise?t.then(n):n(t)}var wt=m(()=>{"use strict";l()});var re,xe=m(()=>{"use strict";Y();re=class extends T{#e;#r;#t;constructor(r,t,n){super(),this.#e=M(r),this.#r=t,this.#t=n}execute(r,...t){let n=this.#r?this.#r(r):r;if(!n)return r;Array.isArray(n)||(n=[n]);let i=!0,o=n.map(s=>{let a=this.#e.execute(s,...t);return i&&a instanceof Promise&&(i=!1),a});return i?this.#t?this.#t(o,r):o:Promise.all(o).then(s=>this.#t?this.#t(s,r):s)}}});var O,xr=m(()=>{"use strict";Y();le();O=class e extends T{#e;#r;#t;#n;#i;constructor(r=[],t=[]){Array.isArray(r)||(r=[r]),super(),this.#e=r.map(n=>M(n));for(let n of t)if(n===e.ALL_CRITERIA)this.#r=n;else if(n===e.ANY_CRITERIA)this.#r=n;else if(n===e.EXCLUSIVE_CRITERIA)this.#r=n;else if(n===e.SUCCESS_CHECK)this.#t=n;else if(n===e.DEFINED_CHECK)this.#t=n;else if(n===e.TRUTHY_CHECK)this.#t=n;else if(n===e.INPUT_RETURN)this.#n=n;else if(n===e.RESULT_RETURN)this.#n=n;else if(n===e.RETHROW_ERRORS)this.#i=n;else if(n===e.CAPTURE_ERRORS)this.#i=n;else throw new Error("Unknown flag");this.#r??=e.ALL_CRITERIA,this.#t??=e.SUCCESS_CHECK,this.#n??=e.INPUT_RETURN,this.#i??=e.RETHROW_ERRORS}execute(r,...t){let n,i=0,o=0,s=0,a=()=>{switch(this.#r){case e.ANY_CRITERIA:return i>0;case e.EXCLUSIVE_CRITERIA:return i===1&&s===this.#e.length;case e.ALL_CRITERIA:return i===this.#e.length}return!1},c=()=>{switch(this.#r){case e.ANY_CRITERIA:return i===0&&s===this.#e.length;case e.EXCLUSIVE_CRITERIA:return i>1;case e.ALL_CRITERIA:return o>0}return!1},d=async()=>{for(;s<this.#e.length&&!(c()||a());)try{let p=await this.#e[s++].execute(r,...t);g(p)}catch(p){if(this.#t===e.SUCCESS_CHECK)return;A(p)}return S()},g=p=>{(this.#t===e.TRUTHY_CHECK?ee(p):this.#t===e.DEFINED_CHECK?p!==void 0:!0)?i++:o++,c()||(n=p)},A=p=>{if(this.#i===e.RETHROW_ERRORS)throw p;o++},S=()=>{if(a())return this.#n===e.RESULT_RETURN?n:r},E=this.#e;for(;s<E.length;){let p;try{if(p=E[s++].execute(r,...t),p instanceof Promise)return p.then(b=>(g(b),d()),b=>(A(b),d()));g(p)}catch(b){if(A(b),this.#t===e.SUCCESS_CHECK)return}if(c()||a())break}return S()}static ANY_CRITERIA=Symbol("ANY-CRITERIA");static ALL_CRITERIA=Symbol("ALL-CRITERIA");static EXCLUSIVE_CRITERIA=Symbol("EXCLUSIVE-CRITERIA");static TRUTHY_CHECK=Symbol("TRUTHY-CHECK");static DEFINED_CHECK=Symbol("DEFINED-CHECK");static SUCCESS_CHECK=Symbol("SUCCESS-CHECK");static RESULT_RETURN=Symbol("RESULT-RETURN");static INPUT_RETURN=Symbol("INPUT-RETURN");static RETHROW_ERRORS=Symbol("RETHROW-ERRORS");static CAPTURE_ERRORS=Symbol("CAPTURE-ERRORS")}});var Be,yt=m(()=>{"use strict";xr();Be=class extends O{constructor(r=[]){Array.isArray(r)||(r=[r]),super(r)}}});var be,gt=m(()=>{"use strict";Y();xe();yt();be=class extends T{#e;constructor(r,t){super();let n=M(r),i=M(t),o=new Be(new re(this,(s=>s?.activePropertyStates??[])));this.#e=new Be([n,o,i])}execute(r){return this.#e.execute(r)}}});var ga,Ea,Et,Aa,Sa,At,Ca,xa,St,ba,Ra,br,Ct=m(()=>{"use strict";Fr();Hr();Kr();Wr();Zr();Gr();vr();Jr();et();tt();it();ot();st();at();ct();ft();lt();wt();gt();ga=new me([yr,gr,Br,Yr,Xr,He,nr,Qr,rt]),Ea=new me([nt,ht,Er,Ar,Ke]),Et=new be(ga,Ea),Aa=new me([Sr,He,nr,Cr]),Sa=new me([Er,Ar,Ke]),At=new be(Aa,Sa),Ca=new me([yr,gr,dt,He,nr]),xa=new me([Ke]),St=new be(Ca,xa),ba=new me([Sr,Cr]),Ra=new me([Ke]),br=new be(ba,Ra)});var x,Q=m(()=>{"use strict";lr();Le();wr();Fe();se();oe();Ct();l();ie();le();L();k();x=class e{static __TOKEN=Symbol("CONSTRUCT_USING_COMPILER");#e=new Map;#r;#t=new Map;#n;#i=new Map;#s={};#o={};#u={};#a=!1;constructor(r){if(r!==e.__TOKEN)throw new u("CompiledSchema must be created via compilation")}get options(){return this.#o}get metadata(){return this.#u}get properties(){return this.#r??=Object.freeze(Object.fromEntries(this.#e))}get propertyEntries(){return this.#e.entries()}get handlers(){return this.#s}getValueProcessor(r){return this.#i.get(r)}_setValueProcessor(r,t){return this.#i.set(r,t),t}get unionSchemas(){return this.#n??=Object.freeze(Object.fromEntries(this.#t))}get unionSchemaEntries(){return this.#t.entries()}toData(){return Me(this)}get hasChildren(){return this.#e.size>0}get isContainer(){return this.hasChildren||!!this.options.container}get hasWildcard(){return this.#e.has("*")}get isArray(){return this.options.type==="array"}get isFunction(){return this.options.type==="function"}get isUnion(){return this.#t.size>0}get isUnionKey(){return!!this.options.unionKey}get isSelector(){return!!this.options.selector}get hasChildSelector(){for(let r of this.#e.values())if(r.isSelector)return!0;return!1}get isSelection(){return this.options.selection!==void 0&&this.options.selection!==!1}get hasChildSelection(){for(let r of this.#e.values())if(r.isSelection)return!0;return!1}get selection(){return this.options.selection}get values(){return this.options.values}get hasValues(){let r=this.options.values;return Array.isArray(r)&&r.length>0}get strict(){return this.options.strict}get required(){return this.options.required??!1}get default(){return this.options.default}get deep(){if(this.options.deep!==void 0)return this.options.deep;if(this.hasChildren&&this.required)return!0}get isReference(){return this.options.reference??!1}get isImplicit(){return this.options.implicit??!1}get allowIncremental(){return this.options.allowIncremental??this.hasChildren}get isOpaque(){return!this.hasChildren||this.options.allowIncremental===!1}_checkCondition(r,t,n=new j(this),i){if(n.schema!==this)return n.schema._checkCondition(r,t,n,i);if(r instanceof Error&&!this.options.allowErrors)return!1;let o=this.getValueProcessor("conditions");if(!o)return!0;try{let s=o.execute(r,t,n,i);return s instanceof Promise?s.then(a=>a instanceof Error&&!this.options.allowErrors?!1:ee(a),a=>!1):s instanceof Error&&!this.options.allowErrors?!1:ee(s)}catch{return!1}}async checkCondition(r,t,n=new j(this),i){return this._checkCondition(r,t,n,i)}get hasConditions(){let r=this.handlers.conditions;return!!(r&&Array.isArray(r)&&r.length)}get requiresFinalization(){let r=this.handlers.finalizers;return!!(r&&Array.isArray(r)&&r.length)}_checkValue(r,t){if(r instanceof Error&&!this.options.allowErrors){if(t&&r instanceof t)throw r;{let n=new t(r.message,{cause:r});throw Error?.captureStackTrace(n,this._checkValue),n}}return r}_discriminateUnion(r,t,n=new j(this),i={}){if(n.schema!==this)return n.schema._discriminateUnion(r,t,n,i);let o=this.getValueProcessor("discriminators");if(!this.isUnion||!o)return;if(r instanceof Error&&!this.options.allowErrors){if(i?.strict)throw r;return}let s;try{s=o.execute(r,t,n,i)}catch(a){if(i?.strict)throw a;return}return s instanceof Promise?s.then(a=>this.getUnionSchema(a),a=>{if(i.strict)throw a}):this.getUnionSchema(s)}async discriminateUnion(r,t,n=new j(this),i){return this._discriminateUnion(r,t,n,i)}_normalizeValue(r,t,n=new j(this),i={}){if(n.schema!==this)return n.schema._normalizeValue(r,t,n,i);if(r instanceof Error&&!this.options.allowErrors)throw new fe(r.message,{cause:r});let o=i?.sync??!1,s=i?.dynamic??this.options?.dynamic??!0;if((typeof r=="function"||r instanceof N)&&s&&!i.compiling){let d=r instanceof N?r.execute(!0,t,n,i):r(!0,t,n,i);if(d instanceof Promise){if(o)throw new fe("Encountered an async value function during a forced-sync normalization",{location:n});return d.then(g=>g==null?g:this._normalizeValue(g,t,n,{...i,dynamic:!1}))}r=d}if(r===null||r===void 0&&!this.options.allowUndefined)return r;let a=this.getValueProcessor("normalizers");if(a===void 0)return this.isContainer&&r===q?this.isArray?[]:{}:r;let c;try{c=a.execute(r,t,n,i)}catch(d){throw new fe("Unable to normalize",{location:n,cause:d})}if(c instanceof Promise){if(o)throw new fe("Encountered an async processor during a forced-sync normalization",{location:n});return c.then(d=>this._checkValue(d,fe),d=>{throw new fe("Unable to normalize",{value:r,location:n,cause:d})})}return this._checkValue(c)}async normalizeValue(r,t,n=new j(this),i){return this._normalizeValue(r,t,n,i)}_transformValue(r,t,n=new j(this),i={}){if(n.schema!==this)return n.schema._transformValue(r,t,n,i);if(r instanceof Error&&!this.options.allowErrors)throw new Z(r.message,{cause:r});if(this.isImplicit)throw new Z("Cannot transform a value for an implicit schema",{location:n});if(r===null||r===void 0&&!this.options.allowUndefined)return r;let o;try{this.ensureAccepts(r);let s=this.getValueProcessor("transformers");if(s===void 0)return r;o=s.execute(r,t,n,i)}catch(s){throw new Z("Unable to transform",{value:r,location:n,cause:s})}return o instanceof Promise?o.then(s=>this._checkValue(s,Z),s=>{throw new Z("Unable to transform",{value:r,location:n,cause:s})}):this._checkValue(o,Z)}async transformValue(r,t,n=new j(this),i){return this._transformValue(r,t,n,i)}_finalizeValue(r,t,n=new j(this),i={}){if(n.schema!==this)return n.schema._finalizeValue(r,t,n,i);if(r instanceof Error&&!this.options.allowErrors)throw new J(r.message,{cause:r});if(this.isImplicit)throw new Z("Cannot finalize a value for an implicit schema",{location:n});if(r===null||r===void 0&&!this.options.allowUndefined)return r;let o;try{let s=this.getValueProcessor("finalizers");if(s===void 0)return r;o=s.execute(r,t,n,i)}catch(s){throw new J("Unable to finalize",{value:r,location:n,cause:s})}return o instanceof Promise?o.then(s=>this._checkValue(s,J),s=>{throw new J("Unable to finalize",{value:r,location:n,cause:s})}):this._checkValue(o,J)}async finalizeValue(r,t,n=new j(this),i){return this._finalizeValue(r,t,n,i)}_validateValue(r,t,n=new j(this),i={}){if(n.schema!==this)return n.schema._validateValue(r,t,n,i);if(this.required===!0&&r===void 0)throw new z("Missing required value",{location:n});if(r==null)return r;if(r instanceof Error&&!this.options.allowErrors)throw new z(r.message,{cause:r});let o=this.getValueProcessor("validators");if(!o)return r;let s=i?.revalidate??n.schema.options?.revalidate??!0,a;try{a=o.execute(r,t,n,i)}catch(c){throw c instanceof z?c:new z("Validation failed",{value:r,location:n,cause:c})}return a instanceof Promise?a.then(c=>c!==r&&c!==void 0&&s?this._validateValue(c,t,n,{...i,revalidate:!1}):c===void 0?r:this._checkValue(c,z),c=>{throw c instanceof z?c:new z("Validation failed",{value:r,location:n,cause:c})}):a!==r&&a!==void 0&&s?this._validateValue(a,t,n,{...i,revalidate:!1}):a===void 0?r:this._checkValue(a,z)}async validateValue(r,t,n,i){return this._validateValue(r,t,n,i)}_serializeValue(r,t,n=new j(this),i={}){if(n.schema!==this)return n.schema._serializeValue(r,t,n,i);if(r==null||this.isImplicit||ee(this.metadata.omitFromSerialize))return null;let o=this.getValueProcessor("serializers")??this.getValueProcessor("normalizers");if(!o)return r;let s;try{s=o.execute(r,t,n,i)}catch(a){if(i?.strict)throw new Ce("Unable to serialize",{value:r,location:n,cause:a});return}return s instanceof Promise?s.then(a=>i?.strict?this._checkValue(a,Ce):a,a=>{if(i?.strict)throw new Ce("Unable to serialize",{value:r,location:n,cause:a})}):i?.strict?this._checkValue(s,Ce):s}async serializeValue(r,t,n=new j(this),i){return this._serializeValue(r,t,n,i)}ensureAccepts(r){if(r===void 0){if(this.options.allowUndefined)return;throw new z("Schema does not accept an undefined input")}if(!Array.isArray(this.values)||this.values.length===0||this.options.allowUnknownValues)return;if(!this.values.some(n=>G(n,r))){let n=this.metadata.valueDescription??`{${this.values.map(w).join("|")}}`,i=n.length>80?'not found in schema "values" option':`expected one of ${n}`;throw new z(`Invalid value ${w(r)}, ${i}`)}}checkAccepts(r){try{return this.ensureAccepts(r),!0}catch{return!1}}_validate(r,t={}){let n=t.location??new j(this),i=t.context instanceof ue?t.context:new ue(n,t),o=[()=>(i.setAssignedInput(r,""),i.traverse(br)),()=>{for(let s of i.stateMap.values())s.completed=!1;return i.traverse(At)},()=>i.getValue()];return new ae(o).execute(i)}async validate(r,t){return this._validate(r,t)}_process(r,t,n={}){let i=n?.location??new j(this),o=n.context instanceof ue?n.context:new ue(i,{strict:n?.strict,deep:n?.deep,debug:n?.debug,stats:n?.stats}),s=[];return t!==void 0&&s.push(()=>(o.setAssignedInput(t,""),o.traverse(br))),s.push(()=>{if(o.setAssignedInput(r,n?.inputPath),n?.assignments)for(let[a,c]of n.assignments)o.setAssignedInput(c,a);return o.traverse(Et)}),s.push(()=>o.getValue()),new ae(s).execute(o)}async process(r,t,n={}){return this._process(r,t,n)}async processAssignments(r,t,n={}){return this._process(void 0,t,{...n,assignments:r})}async serialize(r,t={}){let n=t?.location??new j(this),i=t.context instanceof ue?t.context:new ue(n,{strict:t?.strict,deep:t?.deep,debug:t?.debug}),o=[()=>(i.setAssignedInput(r,""),i.traverse(St)),()=>rr(i.getValue())];return new ae(o).execute(i)}findUnionKey(r){if(!this.isUnion)throw new u("Cannot find union key because schema is not a union");for(let[t,n]of this.unionSchemaEntries)if(n===r)return t}getUnionSchema(r){if(r){if(typeof r=="string"){if(!this.isUnion)throw new u(`Cannot get union schema with key "${r}" because schema is not a union`);if(this.#t.has(r))return this.#t.get(r);throw new u(`Unknown union schema key "${r}"`)}if(r instanceof e){if(!this.isUnion)throw new u("Schema is not a union");if(this.findUnionKey(r))return r;throw new u("Schema is not a union member")}throw new u("Unable to get union schema with provided data")}}_setUnionSchema(r,t){if(!r)throw new u("Unable to set a union schema without a valid key");if(!(t instanceof e))throw new u("Union schema must be a CompiledSchema instance");if(this.#a)throw new u(`Cannot add union schema "${r}" to a frozen CompiledSchema`);return this.#n=void 0,this.#t.set(r,t),t}find(r){if(!r||r===""||r===".")return this;let t=r.split("."),n=this;for(let i of t)if(n=n?.getPropertySchema(i),!n)return;return n}toAssignments(r,t=""){if(typeof r!="object")return new Map([["",r]]);let n=new Map;function i(o,s,a){let c=Array.isArray(s)||F(s),d=o?.allowIncremental??!0;if(c&&o?.hasChildren){let g=Array.isArray(s)?s.entries():Object.entries(s);for(let[A,S]of g){let E=o?.getPropertySchema(`${A}`);i(E,S,a?`${a}.${A}`:`${A}`)}}else n.set(a,s)}return i(this,r,t),n}visitSchema(r,t){let n=new Set,i=t?.onlySerializable??!1;function o(s,a){if(!n.has(s)&&(n.add(s),!(s.metadata.omitFromSerialize&&i))){if(s.hasChildren)for(let[c,d]of s.propertyEntries){let g=a?`${a}.${c}`:`${c}`;if(o(d,g)===!1)return!1}if(s.isUnion){for(let[c,d]of s.unionSchemaEntries)if(o(d,a)===!1)return}return r(s,a)}}return o(this,"")??!0}getPropertyPaths(){let r=new Set;return this.visitSchema((t,n)=>{n&&r.add(n)}),r}getPropertySchema(r){if(!r)throw new u("Unable to retrieve an unnamed property");return this.#e.get(r)??this.#e.get("*")}_setPropertySchema(r,t){if(!r)throw new u("Unable to set an unnamed property");if(!(t instanceof e))throw new u("Property schema must be a CompiledSchema instance");if(this.#a)throw new u(`Cannot add property ${r} to a frozen CompiledSchema`);return this.#r=void 0,this.#e.set(r,t),this.#o.container??=!0,t}getTagged(r){let t=[];for(let n of this.#e.values())n.options[r]&&t.push(n);return t}getFirstTagged(r){for(let t of this.#e.values())if(t.options[r])return t}isValidPath(r){if(r==="")return!0;let t=r.split(".");function n(i,o=0){if(o>=t.length)return i!==void 0;let s=t[o],a=i.getPropertySchema(s);if(a)return n(a,o+1);if(i.isUnion){for(let c of i.#t.values())if(n(c,o))return!0}return!1}return n(this)}_freeze(r=new Set){if(!(this.#a||r.has(this))){this.#a=!0,r.add(this);for(let t of this.#e.values())t._freeze(r);Object.freeze(this.#e);for(let t of this.#t.values())t._freeze(r);Object.freeze(this.#t),Object.freeze(this.#o),Object.freeze(this.#u),Object.freeze(this)}}}});var _,X=m(()=>{"use strict";se();l();_=class extends N{#e;#r;constructor(r,t){if(super(),t){if(!(t instanceof N))throw new u("FunctionValueProcessor args must be a ValueProcessor");this.#e=t}this.#r=r,this.spec=r}execute(r,t,n,i){if(this.#e){let o=this.#e.execute(r,t,n,i);return o instanceof Promise?o.then(s=>this.#r(r,t,n,{...i,args:s})):this.#r(r,t,n,{...i,args:o})}return this.#r(r,t,n,i)}}});var y,V=m(()=>{"use strict";Te();se();L();y=class extends N{#e;constructor(r,t,n){if(r instanceof N&&(n=r.description),!n&&r.isConstant){let i=r.execute(!0);n=Qe(i)?`${i}`:Se(i)}super(t,n),this.#e=r}execute(r,t,n,i){return this.#e.execute(r,t,n,i)}get isConstant(){return this.#e.isConstant}}});var ce,Ne=m(()=>{"use strict";Y();l();ce=class extends T{#e=[];#r;#t;constructor(r={},t){super();let n=!0;for(let[i,o]of Object.entries(r)){if(o===void 0)continue;let s=M(o);this.#e.push([i,s]),n&&=s.isConstant}if(this.#r=t,n){if(t)throw new u("Cannot use a preprocessor with a constant object executor");this.#t=Object.fromEntries(this.#e.map(([i,o])=>[i,o.execute(!0)]))}}execute(r,...t){if(this.#t!==void 0)return this.#t;let n={},i=0,o=this.#e;for(;i<o.length;){let s=o[i][0],a=this.#r?this.#r(r):r,c=o[i++][1].execute(a,...t);if(c instanceof Promise)return c.then(d=>(n[s]=d,this.#n(r,t,i,n)));n[s]=c}return n}async#n(r,t,n,i){let o=this.#e;for(;n<o.length;){let s=o[n][0],a=this.#r?this.#r(r):r;i[s]=await o[n++][1].execute(a,...t)}return i}get isConstant(){return this.#t!==void 0}}});var te,Re=m(()=>{"use strict";Y();te=class extends T{#e=[];#r;constructor(r=[]){Array.isArray(r)||(r=[r]),super();let t=!0;for(let n of r){let i=M(n);t&&=i.isConstant,this.#e.push(i)}this.#r=t?this.#e.map(n=>n.execute(!0)):void 0}execute(r,...t){if(this.#r!==void 0)return this.#r;let n=[],i=0,o=this.#e;for(;i<o.length;){let s=o[i++].execute(r,...t);if(s instanceof Promise)return s.then(a=>(n.push(a),this.#t(r,t,i,n)));n.push(s)}return n}async#t(r,t,n,i){for(;n<this.#e.length;)i.push(await this.#e[n++].execute(r,...t));return i}get isConstant(){return this.#r!==void 0}}});var Ue,$r=m(()=>{"use strict";Y();Ne();se();V();l();L();Ue=class extends N{#e;#r;#t;constructor(r=[],t={}){super();let n={};if(Array.isArray(t)){if(t.length>r.length)throw new u("Too many arguments");for(let s=0;s<r.length;++s)s<t.length&&(n[r[s].parameter]=t[s])}else{if(Object.keys(t).length>r.length)throw new u("Too many arguments");for(let s=0;s<r.length;++s){let a=t[r[s].parameter];a&&(n[r[s].parameter]=a)}for(let s of Object.keys(t))if(n[s]===void 0)throw new u(`Unknown parameter ${s}`)}let i=!0,o=!1;for(let s=0;s<r.length;++s){let a=r[s].hasOwnProperty("default");if(r[s].required){if(o)throw new u(`Required parameter ${r[s].parameter} cannot follow optional parameter`)}else a||(o&&(i=!1),o=!0);if(n[r[s].parameter]===void 0&&a&&(n[r[s].parameter]=new y(new B(r[s].default),r[s].default)),n[r[s].parameter]===void 0){if(r[s].required)throw new u(`Missing required argument for parameter ${r[s].parameter}`);o&&i&&!a&&(n[r[s].parameter]=new y(new T,"$input"),i=!1)}if(n[r[s].parameter]?.isConstant&&r[s].type!==void 0){let c=n[r[s].parameter].execute(!0);if(r[s].type!==void 0&&c!==void 0&&typeof c!==r[s].type)throw new u(`Invalid ${r[s].type} type for parameter "${r[s].parameter}"`,{value:c})}}if(this.#e=new ce(n),this.#r=r,this.#e.isConstant){let s=this.#e.execute(!0);this.#t=this.#n(s);let a="";for(let[c,d]of Object.entries(s))a.length&&(a+=","),a+=`${c}=${d}`;this.description=`[${a}]`}this.spec=K(n,s=>s.spec)}#n(r){for(let t of this.#r)if(r[t.parameter]!==void 0&&t.type&&typeof r[t.parameter]!==t.type)throw new u(`Invalid type for parameter ${t.parameter}, expected ${t.type}`);return r}execute(r,t,n,i){if(this.#t!==void 0)return this.#t;let o=this.#e.execute(r,t,n,i);return o instanceof Promise?o.then(s=>this.#n(s)):this.#n(o)}get isConstant(){return this.#t!==void 0}}});var we,or=m(()=>{"use strict";se();we=class extends N{#e;#r;constructor(r,t,n,i){super(n,i),this.#e=r,this.#r=t}execute(r,t,n,i){if(this.#r){let o=this.#r.execute(r,t,n,i);return o instanceof Promise?o.then(s=>this.#e.execute(r,t,n,{...i,args:s})):this.#e.execute(r,t,n,{...i,args:o})}return this.#e.execute(r,t,n,i)}}});function Ye(e){return!e||typeof e!="string"?[]:e.split(/[^a-zA-Z0-9]+/).flatMap(r=>r.split(/(?<=[a-z])(?=[A-Z])/)).flatMap(r=>r.split(/(?<=[0-9])(?=[A-Za-z])/)).filter(r=>r.length>0).map(r=>r.toLowerCase())}function Ta(e){return e.length===0?"":e[0]+e.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")}function Ia(e){return e.length===0?"":e.map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")}function Oa(e){return e.length===0?"":e.map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function ka(e){return e.map(r=>r.toUpperCase()).join("_")}function Na(e){return e.map(r=>r.toLowerCase()).join("-")}function Vt(e){return Ta(Ye(e))}function jt(e){return Ia(Ye(e))}function zt(e){return ka(Ye(e))}function Ve(e){return Na(Ye(e))}function Dt(e){return Oa(Ye(e))}function Lt(e){if(!e||typeof e!="string")return"";let r=e.trim().replace(/\s+/g," "),t=0,n=r.search(/\b\w(?=[^]*$)/);return r.replace(/\b(\w)(\w*)\b/g,(i,o,s,a)=>t++!==0&&a!==n&&_a.has(i.toLowerCase())?i.toLowerCase():o.toUpperCase()+s.toLowerCase())}var _a,ye=m(()=>{"use strict";_a=new Set(["a","an","the","and","but","or","nor","for","so","yet","at","by","in","of","on","to","up","as","via"])});function je(e){if(e instanceof RegExp)return e;if(typeof e=="string"&&e.startsWith("/")&&e.lastIndexOf("/")>0){let r=e.lastIndexOf("/");return new RegExp(e.slice(1,r),e.slice(r+1))}throw new u("Unable to parse RegExp",{value:e})}var sr=m(()=>{"use strict";l()});var Jt={};h(Jt,{MAX_OPERATOR:()=>za,MIN_OPERATOR:()=>ja,SUM_OPERATOR:()=>Va});var Va,ja,za,Qt=m(()=>{"use strict";l();k();Va={keyword:"sum",process:(e,r,t)=>{if(!Array.isArray(e))throw new f(`$sum requires an array, got ${w(e)}`,{location:t});let n=0;for(let i=0;i<e.length;i++){if(typeof e[i]!="number"||!Number.isFinite(e[i]))throw new f(`$sum requires an array of finite numbers, got ${w(e[i])} at index ${i}`,{location:t});n+=e[i]}return n}},ja={keyword:"min",process:(e,r,t)=>{if(!Array.isArray(e))throw new f(`$min requires an array, got ${w(e)}`,{location:t});if(e.length!==0){for(let n=0;n<e.length;n++)if(typeof e[n]!="number"||!Number.isFinite(e[n]))throw new f(`$min requires an array of finite numbers, got ${w(e[n])} at index ${n}`,{location:t});return Math.min(...e)}}},za={keyword:"max",process:(e,r,t)=>{if(!Array.isArray(e))throw new f(`$max requires an array, got ${w(e)}`,{location:t});if(e.length!==0){for(let n=0;n<e.length;n++)if(typeof e[n]!="number"||!Number.isFinite(e[n]))throw new f(`$max requires an array of finite numbers, got ${w(e[n])} at index ${n}`,{location:t});return Math.max(...e)}}}});var en={};h(en,{ALPHA_CONSTRAINT:()=>Da});var Da,rn=m(()=>{"use strict";l();Da={keyword:"alpha",process:e=>{if(!/^[a-zA-Z]+$/.test(e))throw new f("Must contain only letters");return e}}});var tn={};h(tn,{ALPHANUM_CONSTRAINT:()=>La});var La,nn=m(()=>{"use strict";l();La={keyword:"alphanum",process:e=>{if(!/^[a-zA-Z0-9]+$/.test(e))throw new f("Must contain only alphanumeric characters");return e}}});var on={};h(on,{ARRAY_OPERATOR:()=>Ma});var Ma,sn=m(()=>{"use strict";Te();oe();l();Ma={keyword:"array",process:(e,r,t)=>{if(e===q)e=[];else if(e==="*"){let n=t?.schema.getPropertySchema("*")?.values;if(n!==void 0)e=[...n];else throw new f("Schema must define values in order to expand wildcard array")}if(typeof e=="string")if(e=e.trim(),e.length>0&&e[0]==="["&&e[e.length-1]==="]")try{e=Je(e)}catch{throw new f(`Invalid input string for array: ${e}`)}else e=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);if(Array.isArray(e))return e;throw new f(`Invalid input for array: ${e}`)}}});var P,ge=m(()=>{"use strict";Y();le();P=class e extends T{#e;#r;#t;#n=!1;#i=!1;#s=!1;#o=!1;constructor(r,t={},n=[]){super(),this.#e=M(r??new T),this.#r=M(t.success??new T),this.#t=M(t.failure??Oe);for(let i of n)if(i===e.CHECK_TRUTHY)this.#s=!0;else if(i===e.CHECK_DEFINED)this.#o=!0;else if(i===e.PASS_RESULT)this.#n=!0;else if(i===e.PASS_ERROR)this.#i=!0;else throw new Error("Unknown flag")}execute(r,...t){let n=(o,s)=>{let a,c=this.#n?s:r,d=this.#i?o:c;return o?a=!1:this.#s?a=ee(s):this.#o?a=s!==void 0:a=!0,a?this.#r.execute(c,...t):this.#t.execute(d,...t)},i;try{i=this.#e.execute(r,...t)}catch(o){return n(o)}return i instanceof Promise?i.then(o=>n(void 0,o),o=>n(o)):n(void 0,i)}static CHECK_TRUTHY=Symbol("CHECK-TRUTHY");static CHECK_DEFINED=Symbol("CHECK-DEFINED");static PASS_RESULT=Symbol("PASS-RESULT");static PASS_ERROR=Symbol("PASS-ERROR")}});var an={};h(an,{ASSERT_CONSTRAINT:()=>qa});var qa,cn=m(()=>{"use strict";se();V();ge();Y();l();qa={keyword:"assert",build:e=>{let r;if(Array.isArray(e))if(e.length===1)r=e[0];else if(e.length===0)r=new y(new T,[]);else throw new u("$assert requires a single processor argument");else typeof e=="object"&&(r=e.processor);if(!(r instanceof N))throw new u("$assert requires a processor argument");let t=e.length===0?"$assert":{$assert:r.spec},n=r.description;return new y(new P(r,{failure:i=>{throw i instanceof f?i:new f("Processed value was not truthy",{cause:i})}},[P.CHECK_TRUTHY,P.PASS_ERROR]),t,n)}}});var fn={};h(fn,{BASE64_CONSTRAINT:()=>Fa});var Fa,un=m(()=>{"use strict";l();Fa={keyword:"base64",process:e=>{if(!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw new f("Invalid base64 format");if(e.includes("=")&&e.length%4!==0)throw new f("Invalid base64 format");return e}}});var mn={};h(mn,{CAMEL_CASE_OPERATOR:()=>Ha});var Ha,pn=m(()=>{"use strict";ye();Ha={keyword:"camel-case",process:e=>Vt(String(e))}});var dn={};h(dn,{CAPITALIZE_OPERATOR:()=>Ka});var Ka,ln=m(()=>{"use strict";ye();Ka={keyword:"capitalize",process:e=>Dt(String(e))}});var wn={};h(wn,{CARDNUM_CONSTRAINT:()=>Za});function Ya(e){let r=0,t=!1;for(let n=e.length-1;n>=0;n--){let i=+e[n];t&&(i*=2,i>9&&(i-=9)),r+=i,t=!t}return r%10===0}function hn(e,r){let t=[],n=0;for(let i of r){if(n>=e.length)break;t.push(e.slice(n,n+i)),n+=i}return n<e.length&&t.push(e.slice(n)),t.join(" ")}var Ba,Wa,Za,yn=m(()=>{"use strict";l();Ba=[{name:"amex",match:e=>e.startsWith("34")||e.startsWith("37"),groups:[4,6,5]},{name:"diners",match:e=>{let r=+e.slice(0,3);return r>=300&&r<=305||e.startsWith("36")||e.startsWith("38")},groups:[4,6,4]},{name:"jcb",match:e=>{let r=+e.slice(0,4);return r>=3528&&r<=3589},groups:[4,4,4,4]},{name:"discover",match:e=>{let r=+e.slice(0,3),t=+e.slice(0,6);return e.startsWith("6011")||e.startsWith("65")||r>=644&&r<=649||t>=622126&&t<=622925},groups:[4,4,4,4]},{name:"mastercard",match:e=>{let r=+e.slice(0,2),t=+e.slice(0,4);return r>=51&&r<=55||t>=2221&&t<=2720},groups:[4,4,4,4]},{name:"visa",match:e=>e.startsWith("4"),groups:[4,4,4,4]}],Wa=[4,4,4,4];Za={keyword:"cardnum",parameters:[{parameter:"mask",default:!1},{parameter:"reveal",default:4}],process:(e,r,t,n)=>{let{mask:i,reveal:o}=n.args,s=e.replace(/[\s\-.]/g,"");if(!/^\d+$/.test(s))throw new f("Invalid card number format");if(s.length<12||s.length>19)throw new f("Invalid card number length");if(!Ya(s))throw new f("Invalid card number (checksum failed)");let a=Wa;for(let c of Ba)if(c.match(s)){a=c.groups;break}if(i){let c=(typeof i=="string"?i[0]:null)||"\u2022",d=Math.min(Math.max(0,o),s.length),g=c.repeat(s.length-d)+s.slice(s.length-d);return hn(g,a)}return hn(s,a)}}});var gn={};h(gn,{CEIL_OPERATOR:()=>Xa});var Xa,En=m(()=>{"use strict";Xa={keyword:"ceil",parameters:[{parameter:"precision",default:0}],process:(e,r,t,n)=>{let i=Number(e);if(!Number.isFinite(i))return e;let o=n.args.precision,s=Math.pow(10,o);return Math.ceil(i*s)/s}}});var An={};h(An,{COLLAPSE_OPERATOR:()=>Ga});var Ga,Sn=m(()=>{"use strict";Ga={keyword:"collapse",process:e=>String(e).replace(/\s+/g," ").trim()}});var Cn={};h(Cn,{COMPACT_OPERATOR:()=>va});var va,xn=m(()=>{"use strict";va={keyword:"compact",process:e=>String(e).replace(/[\s()\-./]/g,"")}});var Rn={};h(Rn,{COMPILE_OPERATOR:()=>bn});var bn,$n=m(()=>{"use strict";$r();or();X();l();k();bn={keyword:"compile",parameters:[{parameter:"schema",required:!1},{parameter:"compiler",required:!1}],build:(e,r)=>{let t=r.compiler,n=new Ue(bn.parameters,e);return new we(new _((i,o,s,a)=>{let c=a.args.compiler??t;if(typeof c?.compile!="function")throw new u(`Invalid compiler provided to $compile ${w(c)}`,{location:s});return a.args.schema!==void 0&&(i=a.args.schema),c.compile(i)}),n,{$compile:n.spec})}}});var Pn={};h(Pn,{CONCAT_OPERATOR:()=>Ja});var Ja,Tn=m(()=>{"use strict";V();X();Re();L();l();Ja={keyword:"concat",build:e=>{if(!Array.isArray(e)||e.length===0)throw new u("$concat requires a non-empty array of values to append");let r=K(e,t=>t.spec);return new _((t,n,i,o)=>{let s=Array.isArray(o.args)?o.args:[];if(!Array.isArray(t))throw new f(`$concat requires an array input, got ${t}`,{location:i});return[...t,...s]},new y(new te(e),r))}}});var In={};h(In,{CHECK_OPERATOR:()=>rc,GATE_OPERATOR:()=>ec,IF_OPERATOR:()=>Qa,TRY_OPERATOR:()=>nc,WHEN_OPERATOR:()=>tc});function Ze(e,r){return t=>{let n,i,o;if(Array.isArray(t)){if(t.length>3)throw new $(`${e} array requires 0-3 processors [predicate, success, failure]`);n=t[0],i=t[1],o=t[2]}else if(typeof t=="object"&&t!==null)n=t.predicate??t.condition??t.cond,i=t.success,o=t.failure;else if(t!==void 0)throw new $(`${e} requires predicate/success/failure processors specified as an array or object`);n??=new y(new T,[]),i??=new y(new T,[]),o??=new y(Oe,"$undefined");let s={[`${e}`]:[n.spec,i?.spec,o?.spec]},a=`(${n.description??""})?`;return i.description&&(a+=`(${i.description})`),o.description&&(a+=`:(${o.description})`),new y(new P(n,{success:i,failure:o},r),s,a)}}var Qa,ec,rc,tc,nc,On=m(()=>{"use strict";Y();ge();V();l();Qa={keyword:"if",build:Ze("$if",[P.CHECK_TRUTHY])},ec={keyword:"gate",build:Ze("$gate",[P.CHECK_DEFINED])},rc={keyword:"check",build:Ze("$check",[P.CHECK_TRUTHY,P.PASS_RESULT])},tc={keyword:"when",build:Ze("$when",[P.CHECK_DEFINED,P.PASS_RESULT])},nc={keyword:"try",build:Ze("$try",[P.PASS_ERROR,P.PASS_RESULT])}});var _n={};h(_n,{CONSTANT_CASE_OPERATOR:()=>ic});var ic,kn=m(()=>{"use strict";ye();ic={keyword:"constant-case",process:e=>zt(String(e))}});function Nn(e,r){if(typeof e=="number"){if(!Number.isFinite(e)||e<0)throw new u(`Invalid data size: ${e}`);return e}if(typeof e!="string")throw new u(`Invalid data size: expected string or number, got ${typeof e}`);let t=e.match(ac);if(!t)throw new u(`Invalid data size: "${e}"`);let[,n,i]=t,o=parseFloat(n);if(!i)return o;let s=i.toLowerCase(),a=_r.get(s);if(a===void 0)throw new u(`Unknown data size unit: "${i}"`);if(r){let c=r.toLowerCase();if(c==="iec"&&!oc.has(s))throw new u(`Unit "${i}" is not an IEC unit (expected B, KiB, MiB, GiB, TiB, PiB)`);if(c==="si"&&!sc.has(s))throw new u(`Unit "${i}" is not an SI unit (expected B, KB, MB, GB, TB, PB)`)}return o*a}function Un(e,r="iec"){if(!Number.isFinite(e)||e<0)throw new u(`Invalid byte count: ${e}`);let t=r.toLowerCase()==="si"?Or:Ir;for(let n=t.length-1;n>=0;n--){let[i,o]=t[n];if(e>=o||n===0){let s=e/o;return`${s%1===0?String(s):parseFloat(s.toFixed(2)).toString()} ${i}`}}}var Ir,Or,_r,oc,sc,ac,Vn=m(()=>{"use strict";l();Ir=[["B",1],["KiB",1024],["MiB",1024**2],["GiB",1024**3],["TiB",1024**4],["PiB",1024**5]],Or=[["B",1],["KB",1e3],["MB",1e3**2],["GB",1e3**3],["TB",1e3**4],["PB",1e3**5]],_r=new Map;for(let[e,r]of Ir)_r.set(e.toLowerCase(),r);for(let[e,r]of Or)_r.set(e.toLowerCase(),r);oc=new Set(Ir.map(([e])=>e.toLowerCase())),sc=new Set(Or.map(([e])=>e.toLowerCase())),ac=/^\s*(\d+(?:\.\d+)?)\s*([a-z]*)\s*$/i});var jn={};h(jn,{DATA_SIZE_OPERATOR:()=>uc});var cc,fc,uc,zn=m(()=>{"use strict";l();Vn();cc=new Set(["iec","si","any"]),fc=new Set(["iec","si"]),uc={keyword:"data-size",parameters:[{parameter:"standard",default:"any",type:"string"},{parameter:"format",default:void 0,type:"string"}],process:(e,r,t,n)=>{let{standard:i,format:o}=n?.args??{};if(i!==void 0&&!cc.has(i))throw new $(`$data-size: unknown standard "${i}" (expected iec, si, or any)`);if(o!==void 0&&!fc.has(o))throw new $(`$data-size: unknown format "${o}" (expected iec or si)`);if(typeof e=="number"&&o===void 0){if(!Number.isFinite(e)||e<0)throw new f(`Invalid data size: ${e}`);return e}let s=Nn(e,i==="any"?void 0:i);return o!==void 0?Un(s,o):s},describe:e=>{if(!e)return;let r=Array.isArray(e)?e[0]:e.standard,t=Array.isArray(e)?e[1]:e.format,n=r?.description,i=t?.description,o=[];return n!==void 0&&n!=="any"&&o.push(n.toUpperCase()),i!==void 0&&o.push(`\u2192 ${i.toUpperCase()}`),o.length?o.join(", "):void 0}}});var Dn={};h(Dn,{DATE_OBJECT_OPERATOR:()=>mc});var mc,Ln=m(()=>{"use strict";l();k();mc={keyword:"date-object",parameters:[{parameter:"zone"}],process:(e,r,t,n)=>{if(!(e instanceof Date))throw new f(`$date-object requires a Date, got ${w(e)}`,{location:t});let i=n.args.zone??"utc";if(i!=="utc"&&i!=="local")throw new f(`$date-object zone must be 'utc' or 'local', got ${w(i)}`,{location:t});return i==="local"?{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),ms:e.getMilliseconds(),zone:"local"}:{year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds(),ms:e.getUTCMilliseconds(),zone:"utc"}}}});function ze(e){if(e==="now")return new Date;if(typeof e=="string"){let r=e.match(/^([+-])(\d+(?:\.\d+)?)(ms|s|m|h|d|w)$/);if(r){let[,i,o,s]=r,a=i==="+"?1:-1,c=parseFloat(o)*a,d={ms:1,s:1e3,m:60*1e3,h:3600*1e3,d:1440*60*1e3,w:10080*60*1e3};return new Date(Date.now()+c*d[s])}let t=parseFloat(e);if(!isNaN(t)&&isFinite(t)&&/^\d+(\.\d+)?$/.test(e.trim())){let i=t;t>0&&t<2524608e3&&t<1e12&&(i=t*1e3);let o=new Date(i);if(isNaN(o.getTime()))throw new Z(`Invalid date: ${e}`);return o}let n=new Date(e);if(isNaN(n.getTime()))throw new Z(`Invalid date: ${e}`);return n}if(typeof e=="number"){let r=new Date(Math.abs(e)<2e8?e*1e3:e);if(isNaN(r.getTime()))throw new Z(`Invalid date: ${e}`);return r}if(e instanceof Date){if(isNaN(e.getTime()))throw new Z(`Invalid date: ${e}`);return new Date(e.getTime())}throw new Z(`Invalid date: ${e} (${typeof e})`)}var kr=m(()=>{"use strict";l()});var Mn={};h(Mn,{DATE_OPERATOR:()=>dc});function pc(e){let{year:r,month:t,day:n,hour:i=0,minute:o=0,second:s=0,ms:a=0,zone:c="utc"}=e;return c==="local"?new Date(r,t-1,n,i,o,s,a):new Date(Date.UTC(r,t-1,n,i,o,s,a))}var dc,qn=m(()=>{"use strict";kr();l();dc={keyword:"date",process:(e,r,t)=>{if(typeof e=="object"&&e!==null&&!(e instanceof Date)&&Number.isInteger(e.year)&&Number.isInteger(e.month)){let i=pc(e);if(isNaN(i.getTime()))throw new f(`Invalid date object: ${JSON.stringify(e)}`);return t.schema.options.type==="string"?i.toISOString():t.schema.options.type==="number"?i.getTime():i}if(typeof e!="string"&&typeof e!="number"&&!(e instanceof Date))throw new f(`Invalid input for date: ${e}`);let n=ze(e);return t.schema.options.type==="string"?n.toISOString():t.schema.options.type==="number"?n.getTime():n}}});var Fn={};h(Fn,{DATE_RANGE_CONSTRAINT:()=>lc});var lc,Hn=m(()=>{"use strict";l();kr();lc={keyword:"date-range",parameters:[{parameter:"min",default:void 0},{parameter:"max",default:void 0}],process:(e,r,t,n)=>{let{min:i,max:o}=n.args,s=(e instanceof Date?e:ze(e)).getTime();if(i!==void 0){let a=(i instanceof Date?i:ze(i)).getTime();if(s<a)throw new f(`Date must not be before ${new Date(a).toISOString()}`)}if(o!==void 0){let a=(o instanceof Date?o:ze(o)).getTime();if(s>a)throw new f(`Date must not be after ${new Date(a).toISOString()}`)}return e},describe:e=>{if(!e)return;let r=Array.isArray(e)?e[0]:e.min,t=Array.isArray(e)?e[1]:e.max,n=r?.description,i=t?.description;return n!==void 0&&i!==void 0?`${n}..${i}`:n!==void 0?`>=${n}`:i!==void 0?`<=${i}`:void 0}}});var Kn={};h(Kn,{DEFINED_CONSTRAINT:()=>hc});var hc,Bn=m(()=>{"use strict";l();hc={keyword:"defined",process:e=>{if(e===void 0)throw new f("Must be defined");return e}}});var Wn={};h(Wn,{EACH_OPERATOR:()=>wc});var wc,Yn=m(()=>{"use strict";xe();V();Y();Fe();wc={keyword:"each",parameters:[{parameter:"processor",required:!0}],build:e=>{let r=(Array.isArray(e)?e[0]:e.processor)??new T,t=(Array.isArray(e)?e[1]:e.values)??new T,n={$each:r.spec},i=r.description?`[${r.description}]...`:"values...";return new y(new ae([t,new re(r)]),n,i)}}});var Zn={};h(Zn,{EMAIL_CONSTRAINT:()=>Ec});var yc,gc,Ec,Xn=m(()=>{"use strict";l();le();yc=/^[a-zA-Z0-9_%+-](?:[a-zA-Z0-9_%+.-]*[a-zA-Z0-9_%+-])?@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,gc=/\.\./,Ec={keyword:"email",parameters:[{parameter:"case",default:"lower"},{parameter:"case-sensitive",type:"boolean",default:!1},{parameter:"filter",type:"boolean",default:!1}],process:(e,r,t,n)=>{let{case:i,"case-sensitive":o,filter:s}=n.args;if(!yc.test(e))throw new f("Invalid email format");let a=e.lastIndexOf("@"),c=e.slice(0,a),d=e.slice(a+1);if(gc.test(c))throw new f("Invalid email format");if(s){let A=c.indexOf("+");A!==-1&&(c=c.slice(0,A)),d.toLowerCase()==="gmail.com"&&(c=c.replace(/\./g,""))}let g=pt(i)?A=>A:i==="upper"?A=>A.toUpperCase():A=>A.toLowerCase();return d=g(d),o||(c=g(c)),`${c}@${d}`}}});var Gn={};h(Gn,{ENTRIES_OPERATOR:()=>Ac});var Ac,vn=m(()=>{"use strict";L();l();k();Ac={keyword:"entries",process:(e,r,t)=>{if(!F(e))throw new f(`$entries requires a plain object, got ${w(e)}`,{location:t});return Object.entries(e)}}});var Jn={};h(Jn,{EQ_CONSTRAINT:()=>Sc});var Sc,Qn=m(()=>{"use strict";ie();l();k();Sc={keyword:"eq",parameters:[{parameter:"value",required:!0},{parameter:"compare"}],process:(e,r,t,n)=>{let i=n.args.value,o=n.args.compare??e;if(!G(i,o))throw new f(`Value ${w(e)} was not equal to constraint`,{value:e,location:t});return e}}});var ei={};h(ei,{FILTER_OPERATOR:()=>Cc});var Cc,ri=m(()=>{"use strict";V();ge();X();xe();l();Cc={keyword:"filter",parameters:[{parameter:"processor",required:!1}],build:e=>{let r;if(Array.isArray(e)){if(e.length>1)throw new u("Expected exactly one argument for $filter operator");r=e[0]}else if(typeof e=="object"){if(Object.keys(e).length!==1)throw new u('Expected only "processor" argument for $filter operator');r=e.processor}return r??=new _(t=>t??void 0),new y(new re(new P(r,{},[P.CHECK_DEFINED,P.PASS_RESULT]),t=>Array.isArray(t)?t:[],t=>Array.isArray(t)?t.filter(n=>n!==void 0):[]),{$filter:r.spec})}}});var ti={};h(ti,{FIND_SCHEMA_OPERATOR:()=>xc});var xc,ni=m(()=>{"use strict";l();k();xc={keyword:"find-schema",parameters:[{parameter:"path",required:!1}],process:(e,r,t,n)=>{let i=n.args?.path??e??".";if(typeof i!="string")throw new u(`$find-schema "path" must be a string, got ${w(i)}`,{location:t});return t.relative(i)?.schema}}});var ii={};h(ii,{FLATTEN_OPERATOR:()=>bc});var bc,oi=m(()=>{"use strict";l();k();bc={keyword:"flatten",parameters:[{parameter:"depth",default:1}],process:(e,r,t,n)=>{if(!Array.isArray(e))throw new f(`$flatten requires an array, got ${w(e)}`,{location:t});let i=n.args?.depth??1;return e.flat(i)}}});var si={};h(si,{FLOOR_OPERATOR:()=>Rc});var Rc,ai=m(()=>{"use strict";Rc={keyword:"floor",parameters:[{parameter:"precision",default:0}],process:(e,r,t,n)=>{let i=Number(e);if(!Number.isFinite(i))return e;let o=n.args.precision,s=Math.pow(10,o);return Math.floor(i*s)/s}}});var ci={};h(ci,{GET_OPERATOR:()=>$c});var $c,fi=m(()=>{"use strict";ie();$c={keyword:"get",parameters:[{parameter:"path",required:!0}],process:(e,r,t,n)=>{let i=n.args?.path;return typeof i=="number"?Array.isArray(e)?e[i]:void 0:ne(e,i)}}});var ui={};h(ui,{GROUP_BY_OPERATOR:()=>Pc});var Pc,mi=m(()=>{"use strict";X();V();xe();l();k();Pc={keyword:"group-by",build:e=>{if(!Array.isArray(e)||e.length!==1)throw new u("$group-by requires a single key or processor argument");let r=e[0],t=r?.spec,n=typeof t=="string"&&!t.startsWith("$")?new _(i=>i?.[t]):r;return new y(new re(n,i=>{if(!Array.isArray(i))throw new f(`$group-by requires an array, got ${w(i)}`);return i},(i,o)=>{let s={};for(let a=0;a<o.length;a++){let c=i[a];if(c===void 0)continue;let d=String(c);s[d]||(s[d]=[]),s[d].push(o[a])}return s}),{"$group-by":t})}}});var pi={};h(pi,{HAS_PREFIX_CONSTRAINT:()=>Tc});var Tc,di=m(()=>{"use strict";l();k();Tc={keyword:"has-prefix",parameters:[{parameter:"match",required:!0}],process:(e,r,t,n)=>{let i=n.args.match;if(!`${e}`.startsWith(i))throw new f(`Value ${w(e)} did not start with prefix ${w(i)}`,{location:t});return e}}});var li={};h(li,{HAS_SUFFIX_CONSTRAINT:()=>Ic});var Ic,hi=m(()=>{"use strict";l();k();Ic={keyword:"has-suffix",parameters:[{parameter:"match",required:!0}],process:(e,r,t,n)=>{let i=n.args.match;if(!`${e}`.endsWith(i))throw new f(`Value ${w(e)} did not end with suffix ${w(i)}`,{location:t});return e}}});var wi={};h(wi,{HEX_CONSTRAINT:()=>Oc});var Oc,yi=m(()=>{"use strict";l();Oc={keyword:"hex",process:e=>{if(!/^[0-9a-fA-F]+$/.test(e))throw new f("Must contain only hexadecimal characters");return e}}});var gi={};h(gi,{HOSTNAME_CONSTRAINT:()=>_c});var _c,Ei=m(()=>{"use strict";l();_c={keyword:"hostname",process:e=>{if(!/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(e))throw new f("Invalid hostname format");return e}}});var Ai={};h(Ai,{HTTP_URL_CONSTRAINT:()=>kc});var kc,Si=m(()=>{"use strict";l();kc={keyword:"http-url",process:e=>{try{let r=new URL(e);if(!["http:","https:"].includes(r.protocol))throw new f("URL must use HTTP or HTTPS protocol");return e}catch(r){throw r instanceof f?r:new f("Invalid HTTP URL format",{cause:r})}}}});var Ci={};h(Ci,{IN_CONSTRAINT:()=>Nc});var Nc,xi=m(()=>{"use strict";L();V();X();Re();l();Nc={keyword:"in",build:e=>{let r=Array.isArray(e)?e:e?.values;if(H(e))throw new u("Must define at least one value for $in");let t=Array.isArray(r)?r.map(s=>s.description).join("|"):"[?]",n=K(r,s=>s.spec),i={$in:n},o=new _((s,a,c,d)=>{let g=(Array.isArray(d.args)?d.args:e.values)??[];if(!g.includes(s))throw new f(`Value must be one of {${g.join("|")}}`,{location:c});return s},new y(new te(r),n));return o.spec=i,o.description=t,o}}});var bi={};h(bi,{INSTANCEOF_CONSTRAINT:()=>Uc});var Uc,Ri=m(()=>{"use strict";l();k();Uc={keyword:"instanceof",parameters:[{parameter:"clazz",type:"function",required:!0}],process:(e,r,t,n)=>{let i=n.args.clazz;if(!(e instanceof i)){let o=i.name||"anonymous";throw new f(`Expected instance of ${o}, got ${w(e)}`,{location:t})}return e}}});var $i={};h($i,{INDEX_BY_OPERATOR:()=>Vc});var Vc,Pi=m(()=>{"use strict";X();V();xe();l();k();Vc={keyword:"index-by",parameters:[{parameter:"processor",required:!0}],build:e=>{let r,t;if(Array.isArray(e)){if(e.length!==1)throw new u("$index-by requires only a single key, or extended arguments with a processor");t=e[0]}else typeof e=="object"&&(t=e.key,r=e.processor);if(t){if(r)throw new u("$index-by requires only a key or a processor, not both");r=new _((n,i,o,s)=>{let a=t.execute(n,i,o,{...s,input:n});return a instanceof Promise?a.then(c=>c!==void 0?n?.[c]:void 0):a!==void 0?n?.[a]:void 0})}if(!r)throw new u("$index-by requires a key or processor argument");return new y(new re(r,n=>{if(!Array.isArray(n))throw new f(`$index-by requires an array, got ${w(n)}`);return n},(n,i)=>{let o={};for(let s=0;s<i.length;s++){let a=n[s];if(a!==void 0){if(o[String(a)]!==void 0)throw new f(`$index-by requires unique keys, got duplicate key ${a}`);o[String(a)]=i[s]}}return o}),{"$index-by":e})}}});var Ti={};h(Ti,{INPUT_OPERATOR:()=>jc});var jc,Ii=m(()=>{"use strict";jc={keyword:"input",process:e=>e}});var Oi={};h(Oi,{INTEGER_CONSTRAINT:()=>zc});var zc,_i=m(()=>{"use strict";l();zc={keyword:"integer",process:e=>{if(typeof e!="number"||!Number.isFinite(e))throw new f("Must be a finite number");if(!Number.isInteger(e))throw new f("Must be an integer");return e}}});var ki={};h(ki,{INVOKE_OPERATOR:()=>Dc});var Dc,Ni=m(()=>{"use strict";V();Fe();or();Dc={keyword:"invoke",parameters:[{parameter:"processor",required:!0},{parameter:"arguments",required:!1}],build:e=>{let r=Array.isArray(e)?e[0]:e.processor,t=new y(new ae([r,i=>i]),r.spec),n=Array.isArray(e)?e[1]:e.arguments;return new we(t,n,{$invoke:{processor:r?.spec,arguments:n?.spec}})}}});var Ui={};h(Ui,{IPV4_CONSTRAINT:()=>qc});function cr(e){let[r,t,n,i]=e.split(".").map(Number);return(r<<24|t<<16|n<<8|i)>>>0}function Ee(e){let[r,t]=e.split("/"),n=Number(t);if(!ar.test(r)||!Number.isInteger(n)||n<0||n>32)throw new $(`Invalid CIDR notation: ${e}`);let i=n===0?0:-1<<32-n>>>0;return{network:cr(r)&i,mask:i}}function Lc(e,r){return(e&r.mask)===r.network}function Mc(e){let r=$e[e.toLowerCase()];if(r)return r;if(e.includes("/"))return[Ee(e)];throw new $(`Unknown IPv4 range: "${e}" (expected CIDR or one of: ${Object.keys($e).join(", ")})`)}var ar,$e,qc,Vi=m(()=>{"use strict";l();ar=/^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/;$e={rfc1918:[Ee("10.0.0.0/8"),Ee("172.16.0.0/12"),Ee("192.168.0.0/16")],loopback:[Ee("127.0.0.0/8")],"link-local":[Ee("169.254.0.0/16")],rfc6598:[Ee("100.64.0.0/10")],multicast:[Ee("224.0.0.0/4")]};$e["non-routable"]=[...$e.rfc1918,...$e.loopback,...$e["link-local"],...$e.rfc6598];qc={keyword:"ipv4",parameters:[{parameter:"in",default:void 0,type:"string"},{parameter:"min",default:void 0,type:"string"},{parameter:"max",default:void 0,type:"string"},{parameter:"format",default:void 0,type:"string"}],process:(e,r,t,n)=>{if(!ar.test(e))throw new f("Invalid IPv4 address");let{in:i,min:o,max:s,format:a}=n?.args??{};if(i!==void 0&&(o!==void 0||s!==void 0))throw new $('$ipv4: "in" and "min"/"max" are mutually exclusive');if(o!==void 0&&!ar.test(o))throw new $(`$ipv4: invalid "min" address: ${o}`);if(s!==void 0&&!ar.test(s))throw new $(`$ipv4: invalid "max" address: ${s}`);let c=cr(e);if(i!==void 0&&!Mc(i).some(g=>Lc(c,g)))throw new f(`IPv4 address not in range "${i}"`);if(o!==void 0&&c<cr(o))throw new f(`IPv4 address below minimum ${o}`);if(s!==void 0&&c>cr(s))throw new f(`IPv4 address above maximum ${s}`);return a==="integer"?c:e},describe:e=>{if(!e)return;let r=Array.isArray(e)?e[0]:e.in,t=Array.isArray(e)?e[1]:e.min,n=Array.isArray(e)?e[2]:e.max,i=r?.description,o=t?.description,s=n?.description;if(i!==void 0)return`in ${i}`;if(o!==void 0&&s!==void 0)return`${o}\u2013${s}`;if(o!==void 0)return`\u2265${o}`;if(s!==void 0)return`\u2264${s}`}}});var ji={};h(ji,{IPV6_CONSTRAINT:()=>Bc});function ur(e){let r=e.replace(/%.*$/,""),t=Fc.exec(r);if(t){let[o,s,a,c]=[t[1],t[2],t[3],t[4]].map(Number),d=(o<<8|s).toString(16),g=(a<<8|c).toString(16);r=r.slice(0,t.index)+`${d}:${g}`}if(r.includes("::")){let[o,s]=r.split("::"),a=o?o.split(":"):[],c=s?s.split(":"):[],d=8-a.length-c.length,g=Array(d).fill("0");r=[...a,...g,...c].join(":")}let n=r.split(":"),i=0n;for(let o of n)i=i<<16n|BigInt(parseInt(o,16));return i}function Xe(e){let r=e.lastIndexOf("/");if(r===-1)throw new $(`Invalid IPv6 CIDR notation: ${e}`);let t=e.slice(0,r),n=Number(e.slice(r+1));if(!fr.test(t)||!Number.isInteger(n)||n<0||n>128)throw new $(`Invalid IPv6 CIDR notation: ${e}`);let i=n===0?0n:(1n<<128n)-1n<<BigInt(128-n);return{network:ur(t)&i,mask:i}}function Hc(e,r){return(e&r.mask)===r.network}function Kc(e){let r=De[e.toLowerCase()];if(r)return r;if(e.includes("/"))return[Xe(e)];throw new $(`Unknown IPv6 range: "${e}" (expected CIDR or one of: ${Object.keys(De).join(", ")})`)}var fr,Fc,De,Bc,zi=m(()=>{"use strict";l();fr=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Fc=/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;De={loopback:[Xe("::1/128")],"link-local":[Xe("fe80::/10")],"unique-local":[Xe("fc00::/7")],multicast:[Xe("ff00::/8")]};De["non-routable"]=[...De.loopback,...De["link-local"],...De["unique-local"]];Bc={keyword:"ipv6",parameters:[{parameter:"in",default:void 0,type:"string"},{parameter:"min",default:void 0,type:"string"},{parameter:"max",default:void 0,type:"string"}],process:(e,r,t,n)=>{if(!fr.test(e))throw new f("Invalid IPv6 address");let{in:i,min:o,max:s}=n?.args??{};if(i!==void 0&&(o!==void 0||s!==void 0))throw new $('$ipv6: "in" and "min"/"max" are mutually exclusive');if(o!==void 0&&!fr.test(o))throw new $(`$ipv6: invalid "min" address: ${o}`);if(s!==void 0&&!fr.test(s))throw new $(`$ipv6: invalid "max" address: ${s}`);let a=ur(e);if(i!==void 0&&!Kc(i).some(d=>Hc(a,d)))throw new f(`IPv6 address not in range "${i}"`);if(o!==void 0&&a<ur(o))throw new f(`IPv6 address below minimum ${o}`);if(s!==void 0&&a>ur(s))throw new f(`IPv6 address above maximum ${s}`);return e},describe:e=>{if(!e)return;let r=Array.isArray(e)?e[0]:e.in,t=Array.isArray(e)?e[1]:e.min,n=Array.isArray(e)?e[2]:e.max,i=r?.description,o=t?.description,s=n?.description;if(i!==void 0)return`in ${i}`;if(o!==void 0&&s!==void 0)return`${o}\u2013${s}`;if(o!==void 0)return`\u2265${o}`;if(s!==void 0)return`\u2264${s}`}}});var Di={};h(Di,{IS_ARRAY_CONSTRAINT:()=>Wc});var Wc,Li=m(()=>{"use strict";l();Wc={keyword:"is-array",process:(e,r,t)=>{if(!Array.isArray(e))throw new f("Must be an array");return e},description:""}});var Mi={};h(Mi,{IS_DATE_CONSTRAINT:()=>Yc});var Yc,qi=m(()=>{"use strict";l();k();Yc={keyword:"is-date",process:e=>{if(e instanceof Date&&!isNaN(e.getTime()))return e;throw new f(`Invalid date: ${w(e)}`)},description:""}});var Fi={};h(Fi,{IS_NUMBER_CONSTRAINT:()=>Zc});var Zc,Hi=m(()=>{"use strict";l();Zc={keyword:"is-number",process:e=>{if(typeof e!="number"||Number.isNaN(e)||!Number.isFinite(e))throw new f("Must be a number");return e},description:""}});var Ki={};h(Ki,{IS_OBJECT_CONSTRAINT:()=>Xc});var Xc,Bi=m(()=>{"use strict";l();Xc={keyword:"is-object",process:(e,r,t)=>{if(typeof e=="object"&&e!==null)return e;throw new f("Must be an object")},description:""}});var Wi={};h(Wi,{IS_STRING_CONSTRAINT:()=>Gc});var Gc,Yi=m(()=>{"use strict";l();Gc={keyword:"is-string",process:e=>{if(typeof e=="string")return e;throw new f("Must be a string")},description:""}});var Zi={};h(Zi,{JOIN_OPERATOR:()=>vc});var vc,Xi=m(()=>{"use strict";vc={keyword:"join",parameters:[{parameter:"separator",default:","}],process:(e,r,t,n)=>{let i=n.args?.separator;return Array.isArray(e)?e.join(i):`${e}`}}});var Gi={};h(Gi,{JSON_CONSTRAINT:()=>Jc});var Jc,vi=m(()=>{"use strict";l();Jc={keyword:"json",process:e=>{try{return JSON.parse(e),e}catch{throw new f("Invalid JSON format")}}}});var Ji={};h(Ji,{JSON_DECODE_OPERATOR:()=>Qc});var Qc,Qi=m(()=>{"use strict";l();k();Qc={keyword:"json-decode",process:(e,r,t)=>{if(typeof e!="string")throw new f(`$json-decode requires a string, got ${w(e)}`,{location:t});try{return JSON.parse(e)}catch(n){throw new f(`$json-decode: invalid JSON \u2014 ${n.message}`,{location:t,cause:n})}}}});var eo={};h(eo,{JSON_ENCODE_OPERATOR:()=>ef});var ef,ro=m(()=>{"use strict";ef={keyword:"json-encode",parameters:[{parameter:"indent",default:0}],process:(e,r,t,n)=>{let i=n.args?.indent||0;return JSON.stringify(e,null,i||void 0)}}});var to={};h(to,{KEBAB_CASE_OPERATOR:()=>rf});var rf,no=m(()=>{"use strict";ye();rf={keyword:"kebab-case",process:e=>Ve(String(e))}});var io={};h(io,{KEYS_OPERATOR:()=>tf});var tf,oo=m(()=>{"use strict";l();k();tf={keyword:"keys",process:(e,r,t)=>{if(typeof e!="object"||e===null||Array.isArray(e))throw new f(`$keys requires a plain object, got ${w(e)}`,{location:t});return Object.keys(e)}}});var so={};h(so,{LENGTH_CONSTRAINT:()=>nf});var nf,ao=m(()=>{"use strict";l();nf={keyword:"length",parameters:[{parameter:"exact",default:void 0,type:"number"},{parameter:"min",default:void 0,type:"number"},{parameter:"max",default:void 0,type:"number"}],process:(e,r,t,n)=>{let{min:i,max:o,exact:s}=n.args,a=Array.isArray(e)?e.length:String(e).length,c=Array.isArray(e)?"elements":"characters";if(s!==void 0){if(a!==s)throw new f(`Length must be exactly ${s} ${c}`);return e}if(i!==void 0&&a<i)throw new f(`Length must be at least ${i} ${c}`);if(o!==void 0&&a>o)throw new f(`Length must be at most ${o} ${c}`);return e},describe:e=>{if(!e)return;let r=Array.isArray(e)?e[0]:e.min,t=Array.isArray(e)?e[1]:e.max,n=Array.isArray(e)?e[2]:e.exact,i=r?.description,o=t?.description,s=n?.description;return s!==void 0?`len=${s}`:i!==void 0&&o!==void 0?`len=${i}-${o}`:i!==void 0?`len\u2265${i}`:o!==void 0?`len\u2264${o}`:void 0}}});var co={};h(co,{LOOKUP_OPERATOR:()=>of});var of,fo=m(()=>{"use strict";l();ie();of={keyword:"lookup",parameters:[{parameter:"from",required:!0,type:"object"},{parameter:"path",type:"string"}],process:(e,r,t,n)=>{let{from:i,path:o}=n.args;if(!(i===void 0||o===void 0)){if(typeof i!="object")throw new u('$lookup requires an object argument for "from"',{location:t});if(typeof o!="string")throw new u('$lookup requires a string argument for "path"',{location:t});return ne(i,o)}}}});var uo={};h(uo,{LOWERCASE_OPERATOR:()=>sf});var sf,mo=m(()=>{"use strict";sf={keyword:"lowercase",process:e=>String(e).toLowerCase()}});var po={};h(po,{MAP_OPERATOR:()=>af});var af,lo=m(()=>{"use strict";V();X();xe();L();l();k();af={keyword:"map",parameters:[{parameter:"processor",required:!0}],build:e=>{let r;if(Array.isArray(e)){if(e.length>1)throw new u("Expected exactly one argument for $map operator");r=e[0]}else if(typeof e=="object"){if(Object.keys(e).length!==1)throw new u('Expected only "processor" argument for $map operator');r=e.processor}return r??=new _(t=>t??void 0),new y(new re(r,t=>{if(Array.isArray(t))return t;if(F(t))return Object.values(t);throw new f(`$map requires an array or plain object, got ${w(t)}`)},(t,n)=>{if(Array.isArray(n))return t;if(F(n))return Object.fromEntries(Object.keys(n).map((i,o)=>[i,t[o]]))}),{$map:r.spec})}}});var ho={};h(ho,{MATCH_OPERATOR:()=>cf});var cf,wo=m(()=>{"use strict";X();V();l();sr();cf={keyword:"match",build:e=>{let r=(Array.isArray(e)?e[0]:e)?.spec;if(typeof r=="string"&&(r=je(r)),!(r instanceof RegExp))throw new u("$match requires a RegExp argument");return new y(new _((t,n,i)=>{if(typeof t!="string")throw new f("$match requires a string input",{location:i});let o=t.match(r);if(o!==null)return o.groups&&Object.keys(o.groups).length>0?{...o.groups}:[...o]}),{$match:r},`${r}`)}}});var yo={};h(yo,{MATCHES_CONSTRAINT:()=>ff});var ff,go=m(()=>{"use strict";X();V();l();sr();ff={keyword:"matches",build:e=>{let r=(Array.isArray(e)?e[0]:e)?.spec;if(typeof r=="string"&&(r=je(r)),!(r instanceof RegExp))throw new u("$matches requires a RegExp argument");let t=new _((n,i,o)=>{if(!r.test(String(n)))throw new f(`Value does not match pattern ${r}`,{location:o});return n});return t.description=`${r}`,new y(t,{$matches:r})}}});var Eo={};h(Eo,{ABS_OPERATOR:()=>uf,CLAMP_OPERATOR:()=>df,POW_OPERATOR:()=>mf,SQRT_OPERATOR:()=>pf});var uf,mf,pf,df,Ao=m(()=>{"use strict";l();k();uf={keyword:"abs",process:(e,r,t)=>{if(typeof e!="number"||!Number.isFinite(e))throw new f(`$abs requires a finite number, got ${w(e)}`,{location:t});return Math.abs(e)}},mf={keyword:"pow",parameters:[{parameter:"exponent",required:!0},{parameter:"base"}],process:(e,r,t,n)=>{let i=n.args.exponent,o=n.args.base!==void 0?n.args.base:e;if(typeof o!="number"||!Number.isFinite(o))throw new f(`$pow requires a finite number base, got ${w(o)}`,{location:t});return Math.pow(o,i)}},pf={keyword:"sqrt",process:(e,r,t)=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new f(`$sqrt requires a non-negative finite number, got ${w(e)}`,{location:t});return Math.sqrt(e)}},df={keyword:"clamp",parameters:[{parameter:"min"},{parameter:"max"}],process:(e,r,t,n)=>{let i=n.args.min,o=n.args.max;if(typeof e!="number"||!Number.isFinite(e))throw new f(`$clamp requires a finite number, got ${w(e)}`,{location:t});if(i!==void 0&&(typeof i!="number"||!Number.isFinite(i)))throw new f(`$clamp min must be a finite number, got ${w(i)}`,{location:t});if(o!==void 0&&(typeof o!="number"||!Number.isFinite(o)))throw new f(`$clamp max must be a finite number, got ${w(o)}`,{location:t});let s=e;return i!==void 0&&(s=Math.max(i,s)),o!==void 0&&(s=Math.min(o,s)),s}}});var So={};h(So,{MERGE_DEEP_OPERATOR:()=>lf});var lf,Co=m(()=>{"use strict";V();X();Ne();ie();l();lf={keyword:"merge-deep",build:e=>{if(typeof e!="object"||e===null||Array.isArray(e))throw new u("$merge-deep requires an object argument");let r=Object.fromEntries(Object.entries(e).map(([t,n])=>[t,n?.spec??n]));return new _((t,n,i,o)=>{if(typeof t!="object"||t===null||Array.isArray(t))throw new f("$merge-deep requires a plain object input",{location:i});return er({},t,o.args)},new y(new ce(e),{"$merge-deep":r}))}}});var xo={};h(xo,{MERGE_OPERATOR:()=>hf});var hf,bo=m(()=>{"use strict";V();X();Ne();l();hf={keyword:"merge",build:e=>{if(typeof e!="object"||e===null||Array.isArray(e))throw new u("$merge requires an object argument");let r=Object.fromEntries(Object.entries(e).map(([t,n])=>[t,n?.spec??n]));return new _((t,n,i,o)=>{if(typeof t!="object"||t===null||Array.isArray(t))throw new f("$merge requires a plain object input",{location:i});return{...t,...o.args}},new y(new ce(e),{$merge:r}))}}});var Ro={};h(Ro,{METADATA_OPERATOR:()=>wf});var wf,$o=m(()=>{"use strict";Q();l();k();wf={keyword:"metadata",parameters:[{parameter:"name",required:!0,type:"string"},{parameter:"schema",required:!1,default:void 0},{parameter:"inherit",required:!1,default:!0}],process:(e,r,t,n)=>{let i=n.args.name,o=n.args.schema,s=n.args.inherit;if(o!==void 0){if(o instanceof x)return o.metadata[i];if(typeof o=="string"){let c=t.relative(o);if(c===void 0)throw new u(`$metadata was unable to retrieve a schema at ${w(o)}`);t=c}else throw new u(`$metadata expects a valid schema, got ${w(o)}`,{location:t})}let a=t;for(;a!==void 0;){if(a.schema.metadata[i]!==void 0)return a.schema.metadata[i];if(!s)break;a=a.parent}}}});var Po={};h(Po,{NEGATIVE_CONSTRAINT:()=>yf});var yf,To=m(()=>{"use strict";l();yf={keyword:"negative",process:e=>{if(typeof e!="number"||!Number.isFinite(e)||e>=0)throw new f("Must be a negative number");return e}}});var Io={};h(Io,{NEVER_CONSTRAINT:()=>gf});var gf,Oo=m(()=>{"use strict";se();V();ge();Y();l();gf={keyword:"never",build:e=>{let r;if(Array.isArray(e))if(e.length===1)r=e[0];else if(e.length===0)r=new y(new T,[]);else throw new u("$never requires no more than a single value argument");else typeof e=="object"&&(r=e.processor);if(!(r instanceof N))throw new u("$never requires a value argument");let t=r.description&&/[|&>∧· ]/.test(r.description),n=r.description?t?`!(${r.description})`:`!${r.description}`:void 0,i={$never:r.spec};return new y(new P(r,{success:()=>{throw new f("Value must not match the specified condition")},failure:o=>o},[P.CHECK_DEFINED]),i,n)}}});var _o={};h(_o,{NON_EMPTY_CONSTRAINT:()=>Ef});var Ef,ko=m(()=>{"use strict";l();Ef={keyword:"non-empty",process:(e,r,t)=>{if(typeof e=="string"){if(e.trim().length===0)throw new f("String cannot be empty or whitespace only")}else if(Array.isArray(e)){if(e.length===0)throw new f("Array cannot be empty")}else if(typeof e=="object"&&e!==null){if(Object.keys(e).length===0)throw new f("Object cannot be empty")}else{if(e===void 0)throw new f("Value cannot be undefined");if(e===null)throw new f("Value cannot be null")}return e}}});var No={};h(No,{NOT_CONSTRAINT:()=>Af});var Af,Uo=m(()=>{"use strict";se();V();ge();Y();l();Af={keyword:"not",build:e=>{let r;if(Array.isArray(e))if(e.length===1)r=e[0];else if(e.length===0)r=new y(new T,[]);else throw new u("$not requires no more than a single value argument");else typeof e=="object"&&(r=e.processor);if(!(r instanceof N))throw new u("$not requires a value argument");let t=r.description&&/[|&>∧· ]/.test(r.description),n=r.description?t?`!(${r.description})`:`!${r.description}`:void 0,i={$not:r.spec};return new y(new P(r,{success:()=>{throw new f("Value must not match the specified condition")},failure:()=>!0},[P.CHECK_TRUTHY]),i,n)}}});var Vo={};h(Vo,{NUMBER_OPERATOR:()=>Sf});var Sf,jo=m(()=>{"use strict";oe();l();Sf={keyword:"number",process:e=>{if(e===q)return 0;let r=Number(e);if(Number.isNaN(r)||!Number.isFinite(r))throw new f("Must be a number or convertible to a number");return r}}});var zo={};h(zo,{NUMERIC_CONSTRAINT:()=>Cf});var Cf,Do=m(()=>{"use strict";l();Cf={keyword:"numeric",process:e=>{let r=`${e}`;if(!/^[0-9]+$/.test(r))throw new f("Must contain only digits");return e}}});var Lo={};h(Lo,{OBJECT_OPERATOR:()=>xf});var xf,Mo=m(()=>{"use strict";Te();oe();l();k();xf={keyword:"object",process:e=>{if(e===q&&(e={}),typeof e=="string")try{e=Je(e)}catch(r){throw new f(`Invalid input string for object: ${w(e)}`,{cause:r})}if(Array.isArray(e)&&e.every(r=>Array.isArray(r)&&r.length===2))return Object.fromEntries(e);if(typeof e=="object")return e;throw new f(`Invalid input for object: ${w(e)}`)}}});var qo={};h(qo,{OMIT_OPERATOR:()=>bf});var bf,Fo=m(()=>{"use strict";V();X();Re();L();l();bf={keyword:"omit",build:e=>{if(!Array.isArray(e)||e.length===0)throw new u("$omit requires a non-empty array of key names");let r=K(e,t=>t.spec);return new _((t,n,i,o)=>{let s=Array.isArray(o.args)?o.args:[];if(typeof t!="object"||t===null)throw new f("$omit requires an object or array input",{location:i});return Array.isArray(t)?t.filter((a,c)=>!s.includes(c)):Object.fromEntries(Object.entries(t).filter(([a])=>!s.includes(a)))},new y(new te(e),r))}}});var mr,Ho=m(()=>{"use strict";Y();mr=class extends T{#e;constructor(r=[]){super(),this.#e=r.map(t=>M(t))}execute(r,...t){let n=!1,i=this.#e.map(o=>{let s=o.execute(r,...t);return s instanceof Promise&&(n=!0),s});return n?Promise.all(i):i}}});var Ko={};h(Ko,{PARALLEL_OPERATOR:()=>Rf});var Rf,Bo=m(()=>{"use strict";Ho();V();l();L();Rf={keyword:"parallel",build:e=>{if(!Array.isArray(e))throw new u("$parallel requires an array of processors");let r={$parallel:K(e,i=>i.spec)},t=e.map(i=>i.description).filter(i=>i!==void 0),n=t.length>0?t.map(i=>/[|&>·∧ ]/.test(i)?`(${i})`:i).join(" \u2297 "):void 0;return new y(new mr(e),r,n)}}});var Wo={};h(Wo,{PASCAL_CASE_OPERATOR:()=>$f});var $f,Yo=m(()=>{"use strict";ye();$f={keyword:"pascal-case",process:e=>jt(String(e))}});var Zo={};h(Zo,{PICK_OPERATOR:()=>Pf});var Pf,Xo=m(()=>{"use strict";V();X();Re();L();l();Pf={keyword:"pick",build:e=>{if(!Array.isArray(e)||e.length===0)throw new u("$pick requires a non-empty array of key names");let r=K(e,t=>t.spec);return new _((t,n,i,o)=>{let s=Array.isArray(o.args)?o.args:[];if(typeof t!="object"||t===null)throw new f("$pick requires an object or array input",{location:i});if(Array.isArray(t))return s.filter(c=>c>=0&&c<t.length).map(c=>t[c]);let a={};for(let c of s)c in t&&(a[c]=t[c]);return a},new y(new te(e),r))}}});var Jo={};h(Jo,{PHONE_CONSTRAINT:()=>If});function Tf(e){let r=e.trim();return r.startsWith("+")?"+"+r.slice(1).replace(/\D/g,""):r.replace(/\D/g,"")}function vo(e,r){let t=0;return r.replace(/#/g,()=>e[t++]??"")}var Go,If,Qo=m(()=>{"use strict";l();Go={1:{lengths:[10],validate:/^[2-9]\d{2}[2-9]\d{6}$/,national:"(###) ###-####",international:"### ### ####"}};If={keyword:"phone",parameters:[{parameter:"international",type:"boolean",default:!1},{parameter:"country",default:"1"},{parameter:"countries",default:null}],process:(e,r,t,n)=>{let{international:i,country:o,countries:s}=n.args,a=s?{...Go,...s}:Go,c=Tf(e);if(!c||!/^\+?\d+$/.test(c))throw new f("Invalid phone number format");let d,g="";if(c.startsWith("+")){let S=c.slice(1),E=!1;for(let p of[1,2,3]){if(p>S.length)break;let b=S.slice(0,p);if(a[b]){d=b,g=S.slice(p),E=!0;break}}if(!E){if(!i)throw new f(`Phone number country code does not match +${o}`);if(S.length<7||S.length>15)throw new f("Invalid phone number length");return"+"+S}}else{let S=a[o];if(d=o,S)if(S.lengths.map(p=>p+o.length).includes(c.length)&&c.startsWith(o))g=c.slice(o.length);else if(S.lengths.includes(c.length))g=c;else throw new f(`Invalid phone number length for country code +${o}`);else g=c}if(!i&&d!==o)throw new f(`International numbers not accepted; expected country code +${o}`);let A=a[d];if(A){if(!A.lengths.includes(g.length))throw new f(`Invalid phone number length for country code +${d}`);if(A.validate&&!A.validate.test(g))throw new f(`Invalid phone number for country code +${d}`)}else{let S=d.length+g.length;if(S<7||S>15)throw new f("Invalid phone number length")}return i?A?.international?`+${d} ${vo(g,A.international)}`:`+${d}${g}`:A?.national?vo(g,A.national):g}}});var es={};h(es,{PIPELINE_OPERATOR:()=>Of});var Of,rs=m(()=>{"use strict";Fe();V();L();l();Of={keyword:"pipeline",build:e=>{if(!Array.isArray(e))throw new $("$pipeline requires an array of processors");let r=e.map(i=>i.description??"").filter(Boolean),t=r.length>1?r.map(i=>i.includes("|")||i.includes("&")?`(${i})`:i).join(" >> "):r[0],n={$pipeline:K(e,i=>i.spec)};return new y(new ae(e),n,t)}}});var ts={};h(ts,{PORT_CONSTRAINT:()=>_f});var _f,ns=m(()=>{"use strict";l();_f={keyword:"port",process:(e,r,t)=>{let n=Number(e);if(!(Number.isInteger(n)&&n>=1&&n<=65535))throw new f("Port must be between 1 and 65535");return t.schema.options.type==="string"?`${n}`:n}}});var is={};h(is,{POSITIVE_CONSTRAINT:()=>kf});var kf,os=m(()=>{"use strict";l();kf={keyword:"positive",process:e=>{if(typeof e!="number"||!Number.isFinite(e)||e<=0)throw new f("Must be a positive number");return e}}});var ss={};h(ss,{PROCESS_OPERATOR:()=>Nf});var Nf,as=m(()=>{"use strict";Q();l();k();Nf={keyword:"process",parameters:[{parameter:"schema",required:!0}],process:(e,r,t,n)=>{let i=n.args.schema;if(!(i instanceof x))throw new u(`Schema argument must be an instance of CompiledSchema, got ${w(i)})`,{location:t});return i._process(e)}}});var cs={};h(cs,{PROPERTY_OPERATOR:()=>Uf});var Uf,fs=m(()=>{"use strict";l();Uf={keyword:"property",parameters:[{parameter:"name",required:!0}],process:(e,r,t,n)=>{let i=n.args.name;if(i===void 0)throw new u("$property expects a property name",{location:t});if(t.schema.getPropertySchema(i)===void 0)throw new u(`Unknown $property ${i}`,{location:t});return typeof e=="object"&&e!==null?e[i]:void 0}}});var us={};h(us,{RANGE_CONSTRAINT:()=>Vf});var Vf,ms=m(()=>{"use strict";l();Vf={keyword:"range",parameters:[{parameter:"min",type:"number",default:void 0},{parameter:"max",type:"number",default:void 0}],process:(e,r,t,n)=>{let{min:i,max:o}=n.args,s=Number(e);if(!Number.isFinite(s))throw new f("Value must be a number");if(i!==void 0&&s<i)throw new f(`Value must be at least ${i}`);if(o!==void 0&&s>o)throw new f(`Value must be at most ${o}`);return e},describe:e=>{if(!e)return;let r=Array.isArray(e)?e[0]:e.min,t=Array.isArray(e)?e[1]:e.max,n=r?.description,i=t?.description;return n!==void 0&&i!==void 0?`${n}-${i}`:n!==void 0?`\u2265${n}`:i!==void 0?`\u2264${i}`:void 0}}});var ps={};h(ps,{REFERENCE_OPERATOR:()=>jf});var jf,ds=m(()=>{"use strict";ie();l();jf={keyword:"reference",parameters:[{parameter:"path",required:!0},{parameter:"pending",required:!1,default:!1},{parameter:"completed",required:!1,type:"boolean",default:!1}],process:(e,r,t,n)=>{let i=n.args.path;if(i===void 0)throw new u("$reference expects a path");let o=n.state.getRelativeState(i),s=n.args.completed;if(o===void 0){if(s)return;let a=t.relative(i);return a?ne(r,a.path):void 0}if(!(s&&!o.completed)){if(o.value!==void 0)return o.value;if(n.args.pending)return o.pending}}}});var ls={};h(ls,{REQUIRE_CONSTRAINT:()=>zf});var zf,hs=m(()=>{"use strict";se();V();ge();Y();l();zf={keyword:"require",build:e=>{let r;if(Array.isArray(e))if(e.length===1)r=e[0];else if(e.length===0)r=new y(new T,[]);else throw new u("$require requires no more than a single processor argument");else typeof e=="object"&&(r=e.processor);if(!(r instanceof N))throw new u("$require requires a processor argument");let t=e.length===0?"$require":{$require:r.spec},n=r.description;return new y(new P(r,{failure:i=>{throw i instanceof f?i:new f("Processed value was undefined",{cause:i})}},[P.CHECK_DEFINED,P.PASS_ERROR]),t,n)}}});var ws={};h(ws,{REVERSE_OPERATOR:()=>Df});var Df,ys=m(()=>{"use strict";l();k();Df={keyword:"reverse",process:(e,r,t)=>{if(!Array.isArray(e))throw new f(`$reverse requires an array, got ${w(e)}`,{location:t});return[...e].reverse()}}});var gs={};h(gs,{ROUND_OPERATOR:()=>Lf});var Lf,Es=m(()=>{"use strict";Lf={keyword:"round",parameters:[{parameter:"precision",default:0}],process:(e,r,t,n)=>{let i=n.args.precision,o=Math.pow(10,i),s=Number(e);return Number.isFinite(s)?Math.round(s*o)/o:e}}});var As={};h(As,{NORMALIZE_OPERATOR:()=>Mf});var Mf,Ss=m(()=>{"use strict";Q();l();k();Mf={keyword:"normalize",parameters:[{parameter:"schema",required:!0},{parameter:"value",required:!1}],process:(e,r,t,n={})=>{let i=n.args.schema;if(!(i instanceof x))throw new u(`Schema argument must be an instance of CompiledSchema, got ${w(i)})`,{location:t});let o=n.cycleCheck??new Set;if(o.has(t.schema))throw new u("Cycle detected while processing $normalize",{location:t,value:e});o.add(t.schema);let s=n.args.value??e;return i._normalizeValue(s,r,void 0,{cycleCheck:o})}}});var bs={};h(bs,{SEMVER_CONSTRAINT:()=>Wf});function Ge(e){let r=xs.exec(e.trim());if(!r)throw new $(`Invalid semver: "${e}"`);return{major:Number(r[1]),minor:Number(r[2]),patch:Number(r[3]),prerelease:r[4]?r[4].split("."):[],build:r[5]?r[5].split("."):[]}}function qf(e,r){if(e.length===0&&r.length===0)return 0;if(e.length===0)return 1;if(r.length===0)return-1;let t=Math.max(e.length,r.length);for(let n=0;n<t;n++){if(n>=e.length)return-1;if(n>=r.length)return 1;let i=e[n],o=r[n];if(i===o)continue;let s=/^\d+$/.test(i),a=/^\d+$/.test(o);if(s&&!a)return-1;if(!s&&a)return 1;if(s&&a){let c=Number(i)-Number(o);if(c!==0)return c}else{if(i<o)return-1;if(i>o)return 1}}return 0}function pe(e,r){return e.major-r.major||e.minor-r.minor||e.patch-r.patch||qf(e.prerelease,r.prerelease)}function Cs(e){let r=Ff.exec(e.trim());if(!r)throw new $(`Invalid semver comparator: "${e}"`);let t=r[1]||"=",n=Ge(r[2]);switch(t){case"=":return i=>pe(i,n)===0;case">":return i=>pe(i,n)>0;case">=":return i=>pe(i,n)>=0;case"<":return i=>pe(i,n)<0;case"<=":return i=>pe(i,n)<=0;default:throw new $(`Unknown semver operator: "${t}"`)}}function Hf(e){let r=Ge(e),t;return r.major>0?t={major:r.major+1,minor:0,patch:0,prerelease:[],build:[]}:r.minor>0?t={major:0,minor:r.minor+1,patch:0,prerelease:[],build:[]}:t={major:0,minor:0,patch:r.patch+1,prerelease:[],build:[]},n=>pe(n,r)>=0&&pe(n,t)<0}function Kf(e){let r=Ge(e),t={major:r.major,minor:r.minor+1,patch:0,prerelease:[],build:[]};return n=>pe(n,r)>=0&&pe(n,t)<0}function Bf(e){let r=e.trim();if(r.startsWith("^"))return Hf(r.slice(1));if(r.startsWith("~"))return Kf(r.slice(1));let t=r.split(/\s+/);if(t.length===1)return Cs(t[0]);let n=t.map(Cs);return i=>n.every(o=>o(i))}var xs,Ff,Wf,Rs=m(()=>{"use strict";l();xs=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;Ff=/^(>=|<=|>|<|=)?\s*((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?:[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/;Wf={keyword:"semver",parameters:[{parameter:"in",default:void 0,type:"string"},{parameter:"min",default:void 0,type:"string"},{parameter:"max",default:void 0,type:"string"}],process:(e,r,t,n)=>{let i=xs.exec(e);if(!i)throw new f("Invalid semver");let{in:o,min:s,max:a}=n?.args??{};if(o!==void 0&&(s!==void 0||a!==void 0))throw new $('$semver: "in" and "min"/"max" are mutually exclusive');let c={major:Number(i[1]),minor:Number(i[2]),patch:Number(i[3]),prerelease:i[4]?i[4].split("."):[],build:i[5]?i[5].split("."):[]};if(o!==void 0&&!Bf(o)(c))throw new f(`Version not in range "${o}"`);if(s!==void 0&&pe(c,Ge(s))<0)throw new f(`Version below minimum ${s}`);if(a!==void 0&&pe(c,Ge(a))>0)throw new f(`Version above maximum ${a}`);return e},describe:e=>{if(!e)return;let r=Array.isArray(e)?e[0]:e.in,t=Array.isArray(e)?e[1]:e.min,n=Array.isArray(e)?e[2]:e.max,i=r?.description,o=t?.description,s=n?.description;if(i!==void 0)return`in ${i}`;if(o!==void 0&&s!==void 0)return`${o}\u2013${s}`;if(o!==void 0)return`\u2265${o}`;if(s!==void 0)return`\u2264${s}`}}});var $s={};h($s,{ALL_CONSTRAINT:()=>Gf,AND_CONSTRAINT:()=>Zf,ANY_CONSTRAINT:()=>Xf,EXCLUSIVE_CONSTRAINT:()=>vf,FIRST_OPERATOR:()=>Qf,ONE_CONSTRAINT:()=>Jf,OR_CONSTRAINT:()=>Yf});function Pe(e,r,t){return n=>{let i;if(Array.isArray(n)?i=n:typeof n=="object"&&n!==null&&(i=Object.values(n)),!Array.isArray(i))throw new $(`${e} requires an array of processors`);let o={[e]:i.map(c=>c.spec)},s=i.map(c=>c.description).filter(c=>c!==void 0),a=s.length>1?s.map(c=>c.includes("&")?`(${c})`:c).join(r):s[0];return t(i,o,a)}}var Yf,Zf,Xf,Gf,vf,Jf,Qf,Ps=m(()=>{"use strict";ge();V();xr();l();k();Yf={keyword:"or",build:Pe("$or"," | ",(e,r,t)=>new y(new P(new O(e,[O.TRUTHY_CHECK,O.ANY_CRITERIA,O.RESULT_RETURN,O.CAPTURE_ERRORS]),{failure:n=>{throw new f(`None of the $or conditions ${w(t)} matched`,{value:n})}},[P.CHECK_TRUTHY]),r,t))},Zf={keyword:"and",build:Pe("$and"," & ",(e,r,t)=>new y(new P(new O(e,[O.TRUTHY_CHECK,O.ALL_CRITERIA,O.RESULT_RETURN,O.CAPTURE_ERRORS]),{failure:n=>{throw new f(`Not all $and conditions ${w(t)} matched`,{value:n})}},[P.CHECK_TRUTHY]),r,t))},Xf={keyword:"any",build:Pe("$any"," \u2227 ",(e,r,t)=>new y(new P(new O(e,[O.DEFINED_CHECK,O.ANY_CRITERIA,O.RESULT_RETURN,O.CAPTURE_ERRORS]),{failure:n=>{throw new f(`None of the $any conditions ${w(t)} succeeded`,{value:n})}},[P.CHECK_DEFINED]),r,t))},Gf={keyword:"all",build:Pe("$all"," \xB7 ",(e,r,t)=>new y(new P(new O(e,[O.DEFINED_CHECK,O.ALL_CRITERIA,O.RESULT_RETURN,O.CAPTURE_ERRORS]),{failure:n=>{throw new f(`Not all $all conditions ${w(t)} succeeded`,{value:n})}},[P.CHECK_DEFINED]),r,t))},vf={keyword:"exclusive",build:Pe("$exclusive"," \u2295 ",(e,r,t)=>new y(new P(new O(e,[O.TRUTHY_CHECK,O.EXCLUSIVE_CRITERIA,O.RESULT_RETURN,O.CAPTURE_ERRORS]),{failure:n=>{throw new f(`Exactly one of the $exclusive conditions ${w(t)} must match`,{value:n})}},[P.CHECK_TRUTHY]),r,t))},Jf={keyword:"one",build:Pe("$one"," \u2295 ",(e,r,t)=>new y(new P(new O(e,[O.DEFINED_CHECK,O.EXCLUSIVE_CRITERIA,O.RESULT_RETURN,O.CAPTURE_ERRORS]),{failure:n=>{throw new f(`Exactly one of the $one conditions ${w(t)} must succeed`,{value:n})}},[P.CHECK_DEFINED]),r,t))},Qf={keyword:"first",build:Pe("$first"," ?? ",(e,r,t)=>new y(new P(new O(e,[O.DEFINED_CHECK,O.ANY_CRITERIA,O.RESULT_RETURN,O.CAPTURE_ERRORS]),{},[P.CHECK_DEFINED,P.PASS_RESULT]),r,t))}});var Ts={};h(Ts,{SORT_OPERATOR:()=>eu});var eu,Is=m(()=>{"use strict";l();k();eu={keyword:"sort",parameters:[{parameter:"key",default:null},{parameter:"direction",default:"asc"}],process:(e,r,t,n)=>{if(!Array.isArray(e))throw new f(`$sort requires an array, got ${w(e)}`,{location:t});let i=n.args?.key??null,o=n.args?.direction??"asc",s=(c,d)=>typeof c=="number"&&typeof d=="number"?c-d:String(c)<String(d)?-1:String(c)>String(d)?1:0,a=[...e].sort(i?(c,d)=>s(c[i],d[i]):s);return o==="desc"?a.reverse():a}}});var Os={};h(Os,{SPLIT_OPERATOR:()=>ru});var ru,_s=m(()=>{"use strict";ru={keyword:"split",parameters:[{parameter:"separator",default:","},{parameter:"limit",default:void 0}],process:(e,r,t,n)=>{let i=n.args?.separator,o=n.args?.limit;return`${e}`.split(i,o)}}});var ks={};h(ks,{PAD_OPERATOR:()=>iu,REPLACE_OPERATOR:()=>tu,SUBSTRING_OPERATOR:()=>nu});var tu,nu,iu,Ns=m(()=>{"use strict";l();k();tu={keyword:"replace",parameters:[{parameter:"pattern",required:!0},{parameter:"replacement",required:!0,type:"string"}],process:(e,r,t,n)=>{let{pattern:i,replacement:o}=n.args;if(typeof i!="string"&&!(i instanceof RegExp))throw new u(`$replace pattern must be a string or RegExp, got ${w(i)}`);if(typeof o!="string")throw new u(`$replace replacement must be a string, got ${w(o)}`);if(typeof e!="string")throw new f(`$replace requires a string input, got ${w(e)}`,{location:t});return typeof i=="string"?e.replaceAll(i,o):e.replace(i,o)}},nu={keyword:"substring",parameters:[{parameter:"start",required:!0,type:"number"},{parameter:"length",type:"number",default:void 0}],process:(e,r,t,n)=>{if(typeof e!="string")throw new f(`$substring requires a string input, got ${w(e)}`,{location:t});let i=n.args.start,o=n.args.length;return o!==void 0?e.substring(i,i+o):e.substring(i)}},iu={keyword:"pad",parameters:[{parameter:"width",required:!0},{parameter:"char",default:" "},{parameter:"side",default:"left"}],process:(e,r,t,n)=>{if(typeof e!="string")throw new f(`$pad requires a string input, got ${w(e)}`,{location:t});let i=n.args.width,o=n.args.char;return n.args.side==="right"?e.padEnd(i,o):e.padStart(i,o)}}});var Us={};h(Us,{STRING_OPERATOR:()=>ou});var ou,Vs=m(()=>{"use strict";Te();oe();l();ou={keyword:"string",process:e=>{if(typeof e=="string")return e;if(e==null)throw new f("Invalid string",{value:e});return e===q?"":typeof e=="object"?e instanceof Date?e.toISOString():Se(e):String(e)}}});var js={};h(js,{TARGET_OPERATOR:()=>su});var su,zs=m(()=>{"use strict";su={keyword:"target",process:(e,r)=>r}});var Ds={};h(Ds,{TEMPLATE_OPERATOR:()=>au});var au,Ls=m(()=>{"use strict";X();V();l();au={keyword:"template",build:e=>{let r=(Array.isArray(e)?e[0]:e)?.spec;if(typeof r!="string")throw new u("$template requires a string argument");let t=new _((n,i,o)=>{if(typeof n!="object"||n===null)throw new f("$template requires an object input",{location:o});return r.replace(/\{\{/g,"\0").replace(/\}\}/g,"").replace(/\{([^}]+)\}/g,(s,a)=>{let c=n[a];return c===void 0?"":String(c)}).replace(/\x00/g,"{").replace(/\x01/g,"}")});return t.description=r,new y(t,{$template:r})}}});var Ms={};h(Ms,{TITLE_CASE_OPERATOR:()=>cu});var cu,qs=m(()=>{"use strict";ye();cu={keyword:"title-case",process:e=>Lt(String(e))}});var Fs={};h(Fs,{TYPE_OPERATOR:()=>fu});var fu,Hs=m(()=>{"use strict";Q();fu={keyword:"type",process:e=>e===null?"null":e===void 0?"undefined":e instanceof Date?"date":Array.isArray(e)?"array":e instanceof x?"schema":typeof e}});var Ks={};h(Ks,{TRIM_OPERATOR:()=>uu});var uu,Bs=m(()=>{"use strict";uu={keyword:"trim",process:e=>String(e).trim()}});var Ws={};h(Ws,{TRUTHY_CONSTRAINT:()=>mu});var mu,Ys=m(()=>{"use strict";le();l();mu={keyword:"truthy",process:e=>{if(ee(e))return e;throw new f("Must be truthy")}}});var Zs={};h(Zs,{UNIQUE_OPERATOR:()=>pu});var pu,Xs=m(()=>{"use strict";l();k();pu={keyword:"unique",process:(e,r,t)=>{if(!Array.isArray(e))throw new f(`$unique requires an array, got ${w(e)}`,{location:t});return[...new Set(e)]}}});var Gs={};h(Gs,{UPPERCASE_OPERATOR:()=>du});var du,vs=m(()=>{"use strict";du={keyword:"uppercase",process:e=>String(e).toUpperCase()}});var Js={};h(Js,{URL_CONSTRAINT:()=>lu});var lu,Qs=m(()=>{"use strict";l();lu={keyword:"url",process:e=>{try{return new URL(e).toString()}catch{throw new f("Invalid URL format")}}}});var ea={};h(ea,{URL_DECODE_OPERATOR:()=>hu});var hu,ra=m(()=>{"use strict";l();k();hu={keyword:"url-decode",parameters:[{parameter:"full",default:!1}],process:(e,r,t,n)=>{if(typeof e!="string")throw new f(`$url-decode requires a string, got ${w(e)}`,{location:t});let i=n.args?.full??!1;try{return i?decodeURI(e):decodeURIComponent(e)}catch(o){throw new f(`$url-decode: malformed URI sequence \u2014 ${o.message}`,{location:t,cause:o})}}}});var ta={};h(ta,{URL_ENCODE_OPERATOR:()=>wu});var wu,na=m(()=>{"use strict";wu={keyword:"url-encode",parameters:[{parameter:"full",default:!1}],process:(e,r,t,n)=>n.args?.full??!1?encodeURI(`${e}`):encodeURIComponent(`${e}`)}});var ia={};h(ia,{UUID_CONSTRAINT:()=>yu});var yu,oa=m(()=>{"use strict";l();yu={keyword:"uuid",process:e=>{if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e))throw new f("Invalid UUID format");return e}}});var sa={};h(sa,{VALUES_OPERATOR:()=>gu});var gu,aa=m(()=>{"use strict";l();k();gu={keyword:"values",process:(e,r,t)=>{if(typeof e!="object"||e===null||Array.isArray(e))throw new f(`$values requires a plain object, got ${w(e)}`,{location:t});return Object.values(e)}}});Q();v();Q();v();Le();wr();se();l();se();l();L();function _e(e){if(typeof e=="string"&&e.charAt(0)==="$")return!0;if(typeof e=="object"&&e!==null){let r=Object.keys(e);if(r.length===1&&r[0].charAt(0)==="$")return!0}return!1}function xt(e){let r,t=[];if(typeof e=="string"&&e.charAt(0)==="$")r=e.slice(1);else if(typeof e=="object"&&e!==null){let n=Object.keys(e);n.length===1&&n[0].charAt(0)==="$"&&(r=n[0].slice(1),t=e[n[0]])}if(!r)throw new u("Not a keyword operation");return[r,t]}function ir(e){if(e==null)return!1;if(e instanceof N)return!0;if(Array.isArray(e)){for(let r=0;r<e.length;++r)if(!ir(e[r]))return!1;return!0}if(F(e)){let r=0;for(let t of Object.keys(e))if(t.charAt(0)==="$"&&r++,r>1||t!=="$literal"&&!ir(e[t]))return!1;return!0}return!0}v();l();ie();k();function bt(e,r,t){if(!e.isUnion)return e;let n=Array.from(e.propertyEntries).filter(S=>S[1].isUnionKey);if(n.length===0)return e;if(n.length>1)throw new I(`Union schema has multiple properties marked as union keys: ${n.map(S=>S[0]).join(", ")}`,{location:t});let i=n[0][0],o=n[0][1],s=t.relative(i),a=[...e.unionSchemaEntries],c=new Set;for(let[S]of a)c.add(o._normalizeValue(S,void 0,void 0,{sync:!0}));if(c.size!==a.length)throw new I("Union keys must not collide after normalization with the unionKey property schema",{location:t});let d=(o.values??[]).sort(),g=[...c].sort();if(d.length>0){if(!G(d,g))throw new I(`Union key schema values {${d.join("|")}} do not include all possible union keys {${g.join("|")}}`,{location:s})}else{if(o.isSelector)throw new I("Cannot populate values for a schema that is both a selector and a union key",{location:s});o.options.values=g}if(Array.isArray(e.handlers.discriminators)&&e.handlers.discriminators.length>0)return e;let A=this;return e.handlers.discriminators=[A.resolver.compileValueProcessorSpec(A,Pa(e,i))],e}function Rt(e,r,t,n){if(!e.isUnion||Array.isArray(e.handlers.discriminators)&&e.handlers.discriminators.length>0||e.hasValues)return e;let i=this,o=Tt(e);for(let[s,a]of o){if(e.getPropertySchema(s))continue;if(a.size===1){let[b]=a,R=b.getPropertySchema(s);if(R&&!R.hasConditions&&!R.required&&R.default===void 0){e._setPropertySchema(s,R);continue}}let c,d=new Set,g=!0,A,S=!0;for(let b of a){let R=b.getPropertySchema(s);if(R){if(A||(A=R.handlers.normalizers),R.metadata.parserTypeHint&&(c===void 0?c=R.metadata.parserTypeHint:c&&c!==R.metadata.parserTypeHint&&(c="any",g=!1)),!R.hasValues){S=!1;continue}for(let U of R.values??[]){let W=R._normalizeValue(U,void 0,void 0,{sync:!0});g&&W!==U&&(g=!1),d.add(W),c===void 0&&i.resolver.hasSchema(typeof U)&&(c=typeof U)}}}let E=g&&A,p=new C(c??"any");if(E&&A)for(let b of A)p.normalizer(b);d.size>0&&(p.values(Array.from(d)),S||p.option("allowUnknownValues",!0)),e._setPropertySchema(s,this.compile(p))}return e.handlers.discriminators=[i.resolver.compileValueProcessorSpec(i,$a(e))],e}function $t(e){if(!e.isUnion||e.hasValues)return e;let r=new Set,t=!0;for(let[,n]of e.unionSchemaEntries){if(!n.hasValues){t=!1;continue}for(let i of n.values)r.add(i)}return r.size===0||(e.options.values=[...r],t||(e.options.allowUnknownValues=!0)),e}function Pt(e){if(!e.isUnion)return e;for(let[r,t]of e.unionSchemaEntries){let n=["values","type","default"];for(let[i,o]of Object.entries(e.options??{}))n.includes(i)||o!==void 0&&t.options[i]===void 0&&(t.options[i]=o)}return e}function Tt(e){let r=Array.from(e.unionSchemaEntries).map(s=>s[1]),t=new Map;for(let s of r){let a=!1;for(let[c,d]of s.propertyEntries)Array.isArray(d.values)&&d.values.length>0&&(t.has(c)||t.set(c,new Set),t.get(c).add(s),a=!0);if(!a){let c=e.findUnionKey(s)}}let n=new Set,i=new Set;for(let s=0;s<r.length;s++){let a=r[s];for(let[c,d]of a.propertyEntries){if(t.has(c)||i.has(c)||n.has(c))continue;if(d.default!==void 0){n.add(c);continue}let g=!0;for(let A=s+1;A<r.length;A++)if(r[A].getPropertySchema(c)){i.add(c),g=!1;break}g&&t.set(c,new Set([a]))}}for(let s of t.keys())n.has(s)&&t.delete(s);let o=new Set;for(let s=0;s<r.length;s++)for(let a=s+1;a<r.length;a++){let c=r[s],d=r[a],g=!1,A=!0;for(let[S,E]of t){if(E.forEach(Ae=>o.add(Ae)),!E.has(c)||!E.has(d))continue;A=!1;let p=c.getPropertySchema(S),b=d.getPropertySchema(S),R=p?.values??[],U=b?.values??[];if(!R.some(Ae=>U.includes(Ae))){g=!0;break}}if(!g&&!A)throw new I("Union members are indistinguishable (cannot discriminate between schemas)")}if(r.length>1&&o.size!==r.length){for(let s of r)if(!o.has(s))throw new I(`Union member ${w(e.findUnionKey(s))} cannot be uniquely discriminated`)}return t}function $a(e){if(!e.isUnion)throw new I("Can only generate a discriminator for a union");let r=Array.from(e.unionSchemaEntries).map(i=>i[1]),t=Tt(e);function n(i,o,s,a){let c=new Set(r),d=!1;for(let[g,A]of t){let S=i?.[g];if(S!==void 0){if(A.size===1){let[E]=A;if(c.has(E))c=new Set([E]);else if(c=new Set,c.size===0)throw new de("Union resolution conflict with",{property:g,location:s,value:S})}for(let E of A){if(!c.has(E))continue;let p=s.union(E)?.relative(g);if(p!==void 0){if(p.schema.checkAccepts(S))d=!0;else if(c.delete(E),c.size===0)throw new de("Union resolution conflict with",{property:g,value:S,location:s})}}}}if(c.size===1&&d)return Array.from(c)[0];if(c.size<=1){if(a?.strict||a?.context?.final)throw new de("Union resolution failure (no matches)",{location:s});return}else{if(a?.strict||a?.context?.final){let g=Array.from(c).map(A=>e.findUnionKey(A)).join("|");throw new de(`Union resolution ambiguity (could be ${g})`,{location:s})}return}}return n}function Pa(e,r){if(!e.getPropertySchema(r))throw new u(`Discriminator property ${r} not found`);function n(i,o,s){return i?.[r]}return n}l();function It(e,r,t){let n=[],i=[];for(let g of e.propertyEntries)g[1].isSelector&&n.push(g),g[1].isSelection&&i.push(g);if(n.length===0&&i.length===0)return e;if(n.length>1)throw new I(`Schema multiple properties marked as selectors: ${n.map(g=>g[0]).join(", ")}`,{location:t});let o=n[0][0],s=n[0][1],a=t.relative(`properties.${o}`);if(i.length===0)throw new I(`Schema has selector at property ${o} but no selections`,{location:t});let c=new Set([...s.values??[]]),d=new Set;for(let g of i){let A=g[0],S=g[1],E=t.relative(`properties.${A}`),p=S.selection;p===!0&&(p=A);let b=s._normalizeValue(p,void 0,void 0,{sync:!0});if(c.size&&!c.has(b))throw new I(`Existing selector schema values {${[...c].join("|")}} are missing selection`,{value:p,location:a});d.add(b)}if(!s.hasValues){if(s.isUnionKey)throw new I("Cannot populate values for a schema that is both a selector and a union key",{location:a});s.options.values=[...d].sort()}return e}k();function Ot(e){if(!e.metadata.validatorDescription&&e.handlers.validators?.length){let r=e.handlers.validators.map(t=>t.description??"").filter(Boolean);e.metadata.validatorDescription=r.length>1?r.map(t=>t.includes("|")||t.includes("&")?`(${t})`:t).join(" >> "):r[0]}if(!e.metadata.valueDescription){let r=dr(e);e.metadata.valueDescription=e.required?`<${r}>`:`[${r}]`}return e.metadata.valueName||(e.metadata.valueName=e.metadata.parserTypeHint??"value"),e.options.default!==void 0&&e.metadata.defaultValueDescription===void 0&&(typeof e.options.default=="function"?e.metadata.defaultValueDescription="":e.metadata.defaultValueDescription=w(e.options.default)),e}Q();l();function Rr(e,r,t){if(e===!0)return{};if(e instanceof x)return e;if(this.normalizeCache.has(e))return this.normalizeCache.get(e);let n={};this.normalizeCache.set(e,n),e=this.resolver.resolve(e,!1);for(let i of["properties","unionSchemas","metadata","options","handlers"])if(e[i])for(let[o,s]of Object.entries(e[i])){if(s===void 0)continue;n[i]===void 0&&(n[i]={});let a=s;i==="handlers"&&s===null&&(a="$null"),n[i][o]=a}return n}function _t(e,r,t,n){if(e instanceof x)return e;let i=new x(x.__TOKEN);this.compileCache.set(n.state.assignedInput,i);for(let[o,s]of Object.entries(e.properties??{}))if(s instanceof x)i._setPropertySchema(o,s);else throw new I(`Failed to compile property "${o}" schema`,{location:t});for(let[o,s]of Object.entries(e.unionSchemas??{}))if(s instanceof x)i._setUnionSchema(o,s);else throw new I(`Failed to compile union "${o}" schema `,{location:t});return Object.assign(i.handlers,e.handlers),Object.assign(i.metadata,e.metadata),Object.assign(i.options,e.options),i}function kt(e,r,t){if(!(e instanceof x))throw new I("Not a schema",{location:t});if(e.isUnion&&!e.handlers.discriminators)throw new I("No discriminator defined for union",{location:t});if(e.hasChildren&&(!e.options.container||e.options.type!=="object"&&e.options.type!=="array"&&e.options.type!=="any"))throw new I("Schema defines child properties but does not identify as a container",{location:t});if(e.isUnion&&e.hasWildcard)throw new I("Wildcard properties cannot be set on a union",{location:t});if(e.hasChildSelector!==e.hasChildSelection)throw new I("Inconsistently defined selector/selections in properties",{location:t});if(t.path===""){if(e.isSelector)throw new I("The root schema cannot be a selector",{location:t});if(e.isSelection)throw new I("The root schema cannot be a selection",{location:t});if(e.isUnionKey)throw new I("The root schema cannot be a union key",{location:t})}return e}L();function Nt(e,r,t,n){let i=this;for(let o of Object.keys(e.handlers)){let s=e.handlers[o];H(s)||e._setValueProcessor(o,this.resolver.compileValueProcessorSpec(i,s.length===1?s[0]:{$pipeline:s},!0))}return e}l();L();function Ut(e,r,t){let n=e.options.values??[];if(H(e.options.values))return e;let i=new Set,o=0;for(;o<n.length;){let s=e._normalizeValue(n[o++],void 0,void 0,{sync:!0});if(s===void 0)throw new I("Undefined after normalizing",{value:s,location:t});i.add(s)}return i.size&&(e.options.values=[...i]),e}L();var he=class extends x{constructor(r){super(x.__TOKEN),this.schema=r}},ke=class extends x{constructor(r){super(x.__TOKEN),this.resolver=r,this.normalizeCache=new Map,this.compileSeen=new Map,this.compileCache=new Map;let t=this,n=new C("any").option("dynamic",!1).opaque().validator((p,b,R)=>{if(!(p instanceof N))throw new I("Failed to compile to a value processor",{location:R});return p}),i=new C(n).transformer(p=>r.compileKeywordValueProcessorSpec(this,p)),o=new C(n).property("$literal",new C("any")).transformer(p=>r.compileKeywordValueProcessorSpec(this,p)),s=new C(n).transformer(p=>r.compileValueProcessorSpec(this,p)),a=new C(n).normalizer(p=>p===null?"$null":p).unionDiscriminator(p=>{if(p instanceof N||p==null)return"general";if(!H(p))return _e(p)?typeof p=="string"?"keyword":"keyword+args":"general"}).unionSchema("keyword",i).unionSchema("keyword+args",o).unionSchema("general",s),c=new C("any").option("dynamic",!1).unionDiscriminator(p=>{if(Array.isArray(p))return"array";if(_e(p))return"spec";if(!H(p))return F(p)?"object":"spec"}).unionSchema("spec",a).unionSchema("array",new C("array").allowEmpty().transformer(p=>p).property("*",a)).unionSchema("object",new C("object").allowEmpty().transformer(p=>p).property("*",a));o.property("*",c);let d=new C("array").property("*",a),g=new C().meta("compiler","root").required().normalizer((p,b,R)=>this.compileSeen.has(p)&&this.compileSeen.get(p)!==R.path?new he(p):(p instanceof x||this.compileSeen.set(p,R.path),p)).normalizer(Rr.bind(this)).unionDiscriminator((p,b,R,U)=>p instanceof he||this.compileSeen.has(p)?"cache":p instanceof x?"reference":typeof p=="object"?"schema":void 0).unionSchema("reference",new C().meta("compiler","reference").required().normalizer(p=>{if(!(p instanceof x))throw new I("Not a CompiledSchema reference!");return p})).unionSchema("cache",new C().meta("compiler","cache").required().normalizer(p=>{if(p instanceof he)return p;if(!(p instanceof C))throw new I("Can only cache references to schemas");return new he(p)})),A=new C("object").meta("compiler","schema").opaque().required().normalizer(Rr.bind(this)).normalizer((p,b,R,U)=>{if(p instanceof x)return p;if(typeof p=="object"){if(p instanceof C)throw new I("Internal compiler error");return p}else throw new u("not a schema")}).transformer(_t.bind(this)).finalizer({$if:[(p=>p.isUnion),{$pipeline:[$t,bt,Rt,Pt].map(p=>p.bind(this))},"$input"]}).finalizer(Nt.bind(this)).finalizer({$if:[(p=>!H(p.options.values)),Ut.bind(this),"$defined"]}).finalizer({$if:[(p=>p.hasChildSelector||p.hasChildSelection),It,"$defined"]}).finalizer(Ot).finalizer((p,b,R)=>{if(R.path!=="")return p;if(!(p instanceof x))throw new I("Schema failed to compile!");return this._replaceCachedReferences(p),p._freeze(),p}).validator(kt.bind(this)).property("properties",new C("object").property("*",g)).property("unionSchemas",new C("object").property("*",g)).property("metadata",new C("object").property("*",new C("string"))).property("options",new C("object").property("compileHook",new C("function")).property("default",new C("any").option("dynamic",!1)).property("values",new C("array")).property("*",new C("any"))).property("handlers",new C("object").property("normalizers",d).property("transformers",d).property("finalizers",d).property("validators",d).property("serializers",d).property("conditions",d).property("discriminators",d));g.unionSchema("schema",A);let S=new Map;function E(p,b){if(S.has(p))return S.get(p);if(p instanceof x)return p;b===void 0&&(b=new x(x.__TOKEN)),S.set(p,b),S.set(b,b),Object.assign(b.options,p.options),Object.assign(b.metadata,p.metadata);for(let[R,U]of Object.entries(p.handlers))b.handlers[R]=U.map(W=>r.compileValueProcessorSpec(t,W,!0)),b._setValueProcessor(R,r.compileValueProcessorSpec(t,{$pipeline:b.handlers[R]}));for(let[R,U]of Object.entries(p.properties))(U instanceof C||U instanceof x)&&b._setPropertySchema(R,E(U));for(let[R,U]of Object.entries(p.unionSchemas))(U instanceof C||U instanceof x)&&b._setUnionSchema(R,E(U));return b}E(r.resolve(g),this)}get hasChildren(){return!0}_replaceCachedReferences(r,t="",n=new Set){if(!n.has(r)){n.add(r);for(let[i,o]of r.propertyEntries){let s=t?`${t}.${i}`:i,a=o instanceof he?this.compileCache.get(o.schema):o;if(a===void 0)throw new I("Unable to find cached CompiledSchema",{path:s});a!==o&&(a.metadata.references??="",a.metadata.references+=`[${s}]`,r._setPropertySchema(i,a)),this._replaceCachedReferences(a,s,n)}for(let[i,o]of r.unionSchemaEntries){let s=o instanceof he?this.compileCache.get(o.schema):o;if(s===void 0)throw new I(`Unable to find cached CompiledSchema for unionSchema "${i}"`,{path:t});s!==o&&(s.metadata.references??="",s.metadata.references+=`[${t}:${i}]`,r._setUnionSchema(i,s)),this._replaceCachedReferences(s,t,n)}}}compile(r){try{let t=new ue(new j(this));t.compiling=!0;let n=this._process(r,void 0,{context:t});if(n instanceof Promise)throw new I("Encountered an async processor during compilation");return n}catch(t){throw t instanceof I?t:(t instanceof fe||t instanceof Z||t instanceof J||t instanceof z)&&t.cause?new I(t.cause.message,{...t.data,...t.cause.data,cause:t.cause}):new I("Error during compilation",{cause:t})}}};Y();X();V();se();Ne();Re();V();Re();Ne();$r();X();or();l();L();Q();var We=class extends we{constructor(r,t){if(!r.keyword)throw new u("No keyword found in processor definition");if(!r.process)throw new u("No process function found in processor definition");if(r.build)throw new I("Internal compiler error: factory definitions unsupported by DefinedValueProcessor");if(r instanceof x)throw new I("Internal compiler error: a CompiledSchema was incorrectly identified as a DefinedValueProcessor");let n,i;if(r.parameters!==void 0)n=new Ue(r.parameters,t),i={[`$${r.keyword}`]:n.spec};else if(H(t))i=`$${r.keyword}`;else{let s=K(t,a=>a.spec);if(Array.isArray(t))n=new y(new te(t),s);else if(typeof t=="object")n=new y(new ce(t),s);else throw new I("Internal compiler error: unsupported keyword arguments type");i={[`$${r.keyword}`]:n.spec}}let o=r.description??r.describe?.(t)??`${r.keyword}`;super(new _(r.process),n,i,o)}};l();ye();L();sr();var Mt=[];function qt(e){Mt.push(e)}var Pr=class{#e=new Map;#r=new Map;#t=new Map;constructor(){for(let r of Mt)this.use(r,{sync:!0})}registerSchema(r,t){if(!(t instanceof C))throw new $("Registry can only store Schema instances");let n=Ve(r);return this.#e.set(n,{name:n,schema:t}),this}getSchema(r){let t=Ve(r),n=this.#e.get(t);if(!n)throw new $(`Unable to resolve "${r}"`);return n.schema}hasSchema(r){let t=Ve(r);return this.#e.has(t)}listRegisteredSchemas(){return[...this.#e.values()]}registerValueProcessorDefinition(r){let{keyword:t,process:n,description:i,build:o}=r;if(!t||typeof t!="string")throw new $("Missing keyword in processor definition");if(n&&o)throw new $(`Processor definition for '$${t}' cannot define both process and build functions`);if(!n&&!o)throw new $(`Processor definition for '$${t}' must have define a process or build function`);if(i&&typeof i!="string")throw new $(`Processor definition description for '$${t}' must be a string`);if(this.#n[`${t}`])throw new $(`Processor keyword conflict with builtin literal '$${t}'`);return this.#r.set(t,r),this}registerValueProcessor(r,t,n){if(typeof t!="function")throw new $(`Processor for keyword '${r}' must be a function`);return this.registerValueProcessorDefinition({keyword:r,parameters:[],process:t,description:n??r})}registerValueProcessorBuilder(r,t){if(typeof t!="function")throw new $(`Processor builder for keyword '${r}' must be a function`);return this.registerValueProcessorDefinition({keyword:r,build:t})}listValueProcessorDefinitions(){return[...Object.entries(this.#n).map(([r,t])=>({keyword:r,build:(()=>t),spec:`$${r}`,reserved:!0})),...this.#r.values()]}async use(r,t={}){try{let n=r(this,t);if(n instanceof Promise&&t.sync)throw new $("Cannot load async library");return await n}catch(n){throw n instanceof $?n:new $("Error loading library",{cause:n})}}#n={null:new y(hr,"$null"),undefined:new y(Oe,"$undefined"),true:new y(zr,"$true"),false:new y(Dr,"$false")};compileKeywordValueProcessorSpec(r,t,n){if(!_e(t))throw new $("Not a keyword processor spec");let[i,o]=xt(t);if(this.#n[i])return this.#n[i];if(i==="literal")return new y(new B(o),t);let s=this.#r.get(i);if(!s)throw new $(`Unknown processor keyword: $${i}`);let a=K(o,c=>this.compileValueProcessorSpec(r,c,n));if(s.build){let c=s.build(a,{compiler:r});if(c?.process)return this.compileValueProcessorSpec(r,c,n);if(!(c instanceof N))throw new u(`ValueProcessor builder for $${i} returned invalid`,{value:c});return c}return new We(s,a)}compileSchemaValueProcessorSpec(r,t){let n;return r.compileCache.has(t)?new y(new B(r.compileCache.get(t)),t):new y(new qe(async()=>r.compileCache.has(t)?r.compileCache.get(t):(n??=t instanceof x?t:await r.compile(t),n)),t)}compileValueProcessorSpecObject(r,t,n=!1){if(typeof t!="object")throw new $("not a spec object");let i={};for(let[o,s]of Object.entries(t))i[o]=this.compileValueProcessorSpec(r,s,n);return new y(new ce(i),K(i,o=>o.spec))}compileValueProcessorSpecArray(r,t,n=!1){if(!Array.isArray(t))throw new $("not a spec array");let i=[];for(let o=0;o<t.length;++o)i[o]=this.compileValueProcessorSpec(r,t[o],n);return new y(new te(i),K(i,o=>o.spec))}compileValueProcessorSpec(r,t,n=!1){if(!ir(t))throw new u("Invalid value processor specification",{value:t});let i;if(t===void 0)i=new N;else if(t===null)t="$null",i=new y(hr,"$null");else if(t==="$resolver")i=new y(new B(this),t);else if(t==="$compiler")i=new y(new B(r),t);else if(t instanceof N)i=t;else if(t instanceof C)i=this.compileSchemaValueProcessorSpec(r,t);else if(t instanceof x)i=new y(new B(t),t);else if(_e(t))i=this.compileKeywordValueProcessorSpec(r,t,n);else if(t instanceof T)i=new y(t,t);else if(t instanceof RegExp)i=new y(new B(t),t,`${t}`);else if(t instanceof Date)i=new y(new B(t),t,t.toISOString());else if(typeof t=="string"&&t.startsWith("/")&&t.lastIndexOf("/")>0)try{let o=je(t);i=new y(new B(o),o,`${o}`)}catch{throw new u("Invalid regex pattern",{value:t})}else t instanceof ke?i=new y(new B(t),t):typeof t=="object"&&typeof t.process=="function"?i=new We(t):Vr(t)?i=new y(new B(t),t,t.name):typeof t=="function"?i=new _(t):Array.isArray(t)?i=this.compileValueProcessorSpecArray(r,t,n):typeof t=="object"?i=this.compileValueProcessorSpecObject(r,t,n):i=new y(M(t),t);return i.spec===void 0&&(i.spec=t),i}compiler(){return new ke(this)}compile(r){return r instanceof x?r:new ke(this).compile(r)}resolve(r,t=!0){if(r instanceof x)return r;if(typeof r=="string"&&(this.hasSchema(r)?r=this.getSchema(r):r=new C(r)),this.#t.has(r))return this.#t.get(r);let n=new C;this.#t.set(r,n),this.#t.set(n,n);let i=r,o,s=!1;for(;i!==void 0;){for(let[a,c]of Object.entries(i.properties??{}))if(!n.properties.hasOwnProperty(a)){let d=t||!(c instanceof C||c instanceof x);n.properties[a]=d?this.resolve(c):c}for(let[a,c]of Object.entries(i.metadata??{}))n.metadata.hasOwnProperty(a)||(n.metadata[a]=c);for(let[a,c]of Object.entries(i.unionSchemas??{}))if(!n.unionSchemas.hasOwnProperty(a)){let d=t||!(c instanceof C||c instanceof x);n.unionSchemas[a]=d?this.resolve(c):c}for(let[a,c]of Object.entries(i.handlers??{}))n.handlers.hasOwnProperty(a)||(n.handlers[a]=[]),n.handlers[a].unshift(...c);for(let[a,c]of Object.entries(i.options??{}))n.options.hasOwnProperty(a)||(n.options[a]=c,a==="type"&&(s=!0));if(i instanceof x)i=void 0;else if(i.base===void 0&&!s&&(i.base="any"),i.base)if(this.hasSchema(i.base))i=this.getSchema(i.base);else{let a=`${i.base}`;o=new $(`Unable to resolve "${a}"`),n.normalizer((c,d,g,A)=>{if((g.schema?.strict??A?.strict)!==!1)throw o}),i=void 0}else i=void 0}if(!(r instanceof x)&&r.base&&!n.metadata.parserTypeHint&&(n.metadata.parserTypeHint=r.base),n.options.strict!==!1&&o)throw o;return n}};v();Q();var Ua=/^[\d*]/;function Tr(e){let r=e instanceof x?e.propertyEntries:Object.entries(e.properties??{});for(let[n]of r)if(!Ua.test(n))return!0;let t=e instanceof x?e.unionSchemaEntries:Object.entries(e.unionSchemas??{});for(let[n,i]of t)if(Tr(i))return!0;return!1}oe();function Ft(e,r,t){let n=t.schema;return e===q&&n.isContainer?!n.isArray&&Tr(n)?{}:[]:e}var Ht=new C().option("type","any").normalizer(Ft).transformer(Ft);v();var Kt=new C().option("type","string").meta("valueName","string").normalizer("$string").validator("$is-string");v();var Bt=new C().option("type","number").meta("valueName","number").normalizer("$number").validator("$is-number");v();le();var Wt=new C().option("type","boolean").meta("valueName","boolean").normalizer(ee).validator({$in:[!0,!1]});v();var Yt=new C().option("type","object").option("container",!0).meta("valueName","object").normalizer("$object").validator("$is-object");v();var Zt=new C().option("type","array").option("container",!0).normalizer("$array").validator("$is-array");v();var Xt=new C().option("type","date").meta("parserTypeHint","string").meta("valueName","date").meta("valueDescription",'ms|iso date|"now"|[+|-]offset[d|h|m|s|ms]').normalizer("$date").transformer("$date").validator("$is-date").serializer("$is-date").serializer("$string");v();ie();l();var Gt=new C().option("type","function").meta("parserTypeHint","string").meta("hidden").meta("internal").meta("omitFromSerialize").option("dynamic",!1).normalizer(e=>{if(typeof e=="function"||typeof e=="string")return e;throw new f("Invalid function",{value:e})}).transformer((e,r)=>{if(typeof e=="string"&&(e=ne(r,e)),typeof e=="function")return e;throw new f("Invalid function",{value:e})}).validator(e=>{if(typeof e=="function")return e;throw new f("Invalid function",{value:e})}).serializer(e=>{if(typeof e=="function")return e.name;throw new f("Invalid function",{value:e})});v();var vt=new C().default(!0).meta("hidden").meta("internal").meta("omitFromSerialize").normalizer(()=>"root-schema").transformer((e,r,t)=>{for(;t?.parent;)t=t.parent;return t?.schema}).serializer((e,r,t)=>{for(;t?.parent;)t=t.parent;return t?.schema.toData()});var ca;try{ca??=await Promise.all([Promise.resolve().then(()=>(Qt(),Jt)),Promise.resolve().then(()=>(rn(),en)),Promise.resolve().then(()=>(nn(),tn)),Promise.resolve().then(()=>(sn(),on)),Promise.resolve().then(()=>(cn(),an)),Promise.resolve().then(()=>(un(),fn)),Promise.resolve().then(()=>(pn(),mn)),Promise.resolve().then(()=>(ln(),dn)),Promise.resolve().then(()=>(yn(),wn)),Promise.resolve().then(()=>(En(),gn)),Promise.resolve().then(()=>(Sn(),An)),Promise.resolve().then(()=>(xn(),Cn)),Promise.resolve().then(()=>($n(),Rn)),Promise.resolve().then(()=>(Tn(),Pn)),Promise.resolve().then(()=>(On(),In)),Promise.resolve().then(()=>(kn(),_n)),Promise.resolve().then(()=>(zn(),jn)),Promise.resolve().then(()=>(Ln(),Dn)),Promise.resolve().then(()=>(qn(),Mn)),Promise.resolve().then(()=>(Hn(),Fn)),Promise.resolve().then(()=>(Bn(),Kn)),Promise.resolve().then(()=>(Yn(),Wn)),Promise.resolve().then(()=>(Xn(),Zn)),Promise.resolve().then(()=>(vn(),Gn)),Promise.resolve().then(()=>(Qn(),Jn)),Promise.resolve().then(()=>(ri(),ei)),Promise.resolve().then(()=>(ni(),ti)),Promise.resolve().then(()=>(oi(),ii)),Promise.resolve().then(()=>(ai(),si)),Promise.resolve().then(()=>(fi(),ci)),Promise.resolve().then(()=>(mi(),ui)),Promise.resolve().then(()=>(di(),pi)),Promise.resolve().then(()=>(hi(),li)),Promise.resolve().then(()=>(yi(),wi)),Promise.resolve().then(()=>(Ei(),gi)),Promise.resolve().then(()=>(Si(),Ai)),Promise.resolve().then(()=>(xi(),Ci)),Promise.resolve().then(()=>(Ri(),bi)),Promise.resolve().then(()=>(Pi(),$i)),Promise.resolve().then(()=>(Ii(),Ti)),Promise.resolve().then(()=>(_i(),Oi)),Promise.resolve().then(()=>(Ni(),ki)),Promise.resolve().then(()=>(Vi(),Ui)),Promise.resolve().then(()=>(zi(),ji)),Promise.resolve().then(()=>(Li(),Di)),Promise.resolve().then(()=>(qi(),Mi)),Promise.resolve().then(()=>(Hi(),Fi)),Promise.resolve().then(()=>(Bi(),Ki)),Promise.resolve().then(()=>(Yi(),Wi)),Promise.resolve().then(()=>(Xi(),Zi)),Promise.resolve().then(()=>(vi(),Gi)),Promise.resolve().then(()=>(Qi(),Ji)),Promise.resolve().then(()=>(ro(),eo)),Promise.resolve().then(()=>(no(),to)),Promise.resolve().then(()=>(oo(),io)),Promise.resolve().then(()=>(ao(),so)),Promise.resolve().then(()=>(fo(),co)),Promise.resolve().then(()=>(mo(),uo)),Promise.resolve().then(()=>(lo(),po)),Promise.resolve().then(()=>(wo(),ho)),Promise.resolve().then(()=>(go(),yo)),Promise.resolve().then(()=>(Ao(),Eo)),Promise.resolve().then(()=>(Co(),So)),Promise.resolve().then(()=>(bo(),xo)),Promise.resolve().then(()=>($o(),Ro)),Promise.resolve().then(()=>(To(),Po)),Promise.resolve().then(()=>(Oo(),Io)),Promise.resolve().then(()=>(ko(),_o)),Promise.resolve().then(()=>(Uo(),No)),Promise.resolve().then(()=>(jo(),Vo)),Promise.resolve().then(()=>(Do(),zo)),Promise.resolve().then(()=>(Mo(),Lo)),Promise.resolve().then(()=>(Fo(),qo)),Promise.resolve().then(()=>(Bo(),Ko)),Promise.resolve().then(()=>(Yo(),Wo)),Promise.resolve().then(()=>(Xo(),Zo)),Promise.resolve().then(()=>(Qo(),Jo)),Promise.resolve().then(()=>(rs(),es)),Promise.resolve().then(()=>(ns(),ts)),Promise.resolve().then(()=>(os(),is)),Promise.resolve().then(()=>(as(),ss)),Promise.resolve().then(()=>(fs(),cs)),Promise.resolve().then(()=>(ms(),us)),Promise.resolve().then(()=>(ds(),ps)),Promise.resolve().then(()=>(hs(),ls)),Promise.resolve().then(()=>(ys(),ws)),Promise.resolve().then(()=>(Es(),gs)),Promise.resolve().then(()=>(Ss(),As)),Promise.resolve().then(()=>(Rs(),bs)),Promise.resolve().then(()=>(Ps(),$s)),Promise.resolve().then(()=>(Is(),Ts)),Promise.resolve().then(()=>(_s(),Os)),Promise.resolve().then(()=>(Ns(),ks)),Promise.resolve().then(()=>(Vs(),Us)),Promise.resolve().then(()=>(zs(),js)),Promise.resolve().then(()=>(Ls(),Ds)),Promise.resolve().then(()=>(qs(),Ms)),Promise.resolve().then(()=>(Hs(),Fs)),Promise.resolve().then(()=>(Bs(),Ks)),Promise.resolve().then(()=>(Ys(),Ws)),Promise.resolve().then(()=>(Xs(),Zs)),Promise.resolve().then(()=>(vs(),Gs)),Promise.resolve().then(()=>(Qs(),Js)),Promise.resolve().then(()=>(ra(),ea)),Promise.resolve().then(()=>(na(),ta)),Promise.resolve().then(()=>(oa(),ia)),Promise.resolve().then(()=>(aa(),sa))])}catch(e){throw new Error("Failed to load built-in processors",{cause:e})}var Eu=ca.flatMap(e=>Object.values(e).filter(r=>r&&typeof r.keyword=="string"));function fa(){return Eu}function Nr(e,r){e.registerSchema("root-schema",vt),e.registerSchema("any",Ht),e.registerSchema("string",Kt),e.registerSchema("number",Bt),e.registerSchema("boolean",Wt),e.registerSchema("object",Yt),e.registerSchema("array",Zt),e.registerSchema("date",Xt),e.registerSchema("function",Gt);for(let t of fa())e.registerValueProcessorDefinition(t)}Q();v();l();Le();oe();qt(Nr);export{x as CompiledSchema,q as EMPTY,C as Schema,u as SchemaError,j as SchemaLocation,D as SchemaPolicy,Pr as SchemaResolver};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versionzero/schema",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A composable schema library that supports asynchronous processing",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -30,26 +30,30 @@
|
|
|
30
30
|
"main": "./src/index.js",
|
|
31
31
|
"files": [
|
|
32
32
|
"src/**",
|
|
33
|
+
"dist/**",
|
|
33
34
|
"types/**",
|
|
34
35
|
"LICENSE",
|
|
35
36
|
"README.md"
|
|
36
37
|
],
|
|
37
38
|
"exports": {
|
|
38
39
|
".": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
40
|
+
"types": "./types/index.d.ts",
|
|
41
|
+
"browser": "./dist/schema.browser.mjs",
|
|
42
|
+
"default": "./src/index.js"
|
|
41
43
|
},
|
|
42
44
|
"./helpers": {
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
+
"types": "./types/helpers/index.d.ts",
|
|
46
|
+
"default": "./src/helpers/index.js"
|
|
45
47
|
},
|
|
46
48
|
"./errors": {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
+
"types": "./types/errors/index.d.ts",
|
|
50
|
+
"default": "./src/errors.js"
|
|
49
51
|
}
|
|
50
52
|
},
|
|
51
53
|
"scripts": {
|
|
54
|
+
"build": "npm run build:types && npm run build:browser",
|
|
52
55
|
"build:types": "tsc --declaration --emitDeclarationOnly",
|
|
56
|
+
"build:browser": "esbuild src/index.browser.js --bundle --format=esm --minify --legal-comments=none --banner:js=\"/* @versionzero/schema | Apache-2.0 | github.com/argh */\" --outfile=dist/schema.browser.mjs",
|
|
53
57
|
"test": "mocha",
|
|
54
58
|
"test:bail": "mocha -b",
|
|
55
59
|
"test:coverage": "c8 mocha --ignore 'test/99-*.test.js'",
|
|
@@ -60,6 +64,7 @@
|
|
|
60
64
|
"docs:api:md": "typedoc --options typedoc-md.json",
|
|
61
65
|
"docs:api:md:contributors": "typedoc --options typedoc-md.json --excludeInternal false --excludePrivate false --out docs-output-md-contributors",
|
|
62
66
|
"docs:processors": "node scripts/extract-processor-docs.js",
|
|
67
|
+
"pretest:browser": "npm run build:browser",
|
|
63
68
|
"test:browser": "playwright test",
|
|
64
69
|
"test:all": "npm test && npm run test:browser",
|
|
65
70
|
"clean": "rm -rf types docs-output* processors-output* .mdrun .c8 .nyc_output",
|
|
@@ -71,6 +76,7 @@
|
|
|
71
76
|
"@types/mocha": "^10.0.10",
|
|
72
77
|
"@types/node": "^22.19.10",
|
|
73
78
|
"c8": "^8.0.1",
|
|
79
|
+
"esbuild": "^0.28.0",
|
|
74
80
|
"eslint": "^9.39.1",
|
|
75
81
|
"eslint-config-prettier": "^10.1.8",
|
|
76
82
|
"eslint-plugin-jsdoc": "^62.5.4",
|
package/src/compiled-schema.js
CHANGED
|
@@ -1256,7 +1256,7 @@ export class CompiledSchema
|
|
|
1256
1256
|
*/
|
|
1257
1257
|
_process(input, target, options = {}) {
|
|
1258
1258
|
const location = options?.location ?? new SchemaLocation(this);
|
|
1259
|
-
const context = (options.context instanceof TraversalContext) ? options.context : new TraversalContext(location, {strict: options?.strict, deep: options?.deep, debug: options?.debug});
|
|
1259
|
+
const context = (options.context instanceof TraversalContext) ? options.context : new TraversalContext(location, {strict: options?.strict, deep: options?.deep, debug: options?.debug, stats: options?.stats});
|
|
1260
1260
|
|
|
1261
1261
|
const executors = [];
|
|
1262
1262
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright 2026 Version Zero | github.com/argh
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @module
|
|
6
|
+
* @mergeModuleWith <project>
|
|
7
|
+
*
|
|
8
|
+
* Browser entry point. Registers only the universal core library and omits the
|
|
9
|
+
* Node-only library (and its `node:*` dependencies), so the module graph can be
|
|
10
|
+
* bundled into a single artifact with no conditional/dynamic imports. This is
|
|
11
|
+
* the source for `dist/schema.browser.mjs`; see the `browser` export condition.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { registerCoreLibrary } from './schema-resolver.js';
|
|
15
|
+
import coreLibrary from './core-library/index.js';
|
|
16
|
+
|
|
17
|
+
registerCoreLibrary(coreLibrary);
|
|
18
|
+
|
|
19
|
+
export { CompiledSchema } from './compiled-schema.js';
|
|
20
|
+
export { Schema, SchemaPolicy } from './schema.js';
|
|
21
|
+
export { SchemaError } from './errors.js'
|
|
22
|
+
export { SchemaResolver } from './schema-resolver.js';
|
|
23
|
+
export { SchemaLocation } from './schema-location.js';
|
|
24
|
+
export { EMPTY } from './constants.js';
|
|
@@ -13,6 +13,7 @@ import { SchemaError } from '../errors.js';
|
|
|
13
13
|
* @property {boolean} [strict]
|
|
14
14
|
* @property {boolean} [deep]
|
|
15
15
|
* @property {boolean} [debug]
|
|
16
|
+
* @property {object} [stats]
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
/** @typedef {TraversalContextStandardOptions & {[key:string]:any}} TraversalContextOptions */
|
|
@@ -28,7 +29,7 @@ export class TraversalContext
|
|
|
28
29
|
this.root = (root instanceof CompiledSchema)? new SchemaLocation(root) : root;
|
|
29
30
|
this._final = false;
|
|
30
31
|
|
|
31
|
-
this._options = {...options, deep: options.deep ?? false, strict: options.strict ?? true, debug: options.debug ?? false}
|
|
32
|
+
this._options = {...options, deep: options.deep ?? false, strict: options.strict ?? true, debug: options.debug ?? false, stats: options.stats ?? {}}
|
|
32
33
|
|
|
33
34
|
this.traversals = 0;
|
|
34
35
|
this.counter = 0;
|
|
@@ -52,6 +53,10 @@ export class TraversalContext
|
|
|
52
53
|
return this._options.strict;
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
get stats() {
|
|
57
|
+
return this._options.stats;
|
|
58
|
+
}
|
|
59
|
+
|
|
55
60
|
update() {
|
|
56
61
|
this.counter++;
|
|
57
62
|
this.final = false;
|
|
@@ -192,6 +197,11 @@ export class TraversalContext
|
|
|
192
197
|
let done = false;
|
|
193
198
|
|
|
194
199
|
const updateDone = (counter) => {
|
|
200
|
+
this.traversals++;
|
|
201
|
+
|
|
202
|
+
this.stats.traversals = this.traversals;
|
|
203
|
+
this.stats.updates = this.counter;
|
|
204
|
+
|
|
195
205
|
if (this.isComplete) {
|
|
196
206
|
done = true;
|
|
197
207
|
}
|
|
@@ -222,7 +232,6 @@ export class TraversalContext
|
|
|
222
232
|
);
|
|
223
233
|
}
|
|
224
234
|
updateDone(counter);
|
|
225
|
-
this.traversals++;
|
|
226
235
|
}
|
|
227
236
|
return result;
|
|
228
237
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { CompiledSchema } from "./compiled-schema.js";
|
|
2
|
+
export { SchemaError } from "./errors.js";
|
|
3
|
+
export { SchemaResolver } from "./schema-resolver.js";
|
|
4
|
+
export { SchemaLocation } from "./schema-location.js";
|
|
5
|
+
export { EMPTY } from "./constants.js";
|
|
6
|
+
export { Schema, SchemaPolicy } from "./schema.js";
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @property {boolean} [strict]
|
|
4
4
|
* @property {boolean} [deep]
|
|
5
5
|
* @property {boolean} [debug]
|
|
6
|
+
* @property {object} [stats]
|
|
6
7
|
*/
|
|
7
8
|
/** @typedef {TraversalContextStandardOptions & {[key:string]:any}} TraversalContextOptions */
|
|
8
9
|
export class TraversalContext {
|
|
@@ -17,6 +18,7 @@ export class TraversalContext {
|
|
|
17
18
|
deep: boolean;
|
|
18
19
|
strict: boolean;
|
|
19
20
|
debug: boolean;
|
|
21
|
+
stats: any;
|
|
20
22
|
};
|
|
21
23
|
traversals: number;
|
|
22
24
|
counter: number;
|
|
@@ -28,9 +30,11 @@ export class TraversalContext {
|
|
|
28
30
|
deep: boolean;
|
|
29
31
|
strict: boolean;
|
|
30
32
|
debug: boolean;
|
|
33
|
+
stats: any;
|
|
31
34
|
};
|
|
32
35
|
get deep(): boolean;
|
|
33
36
|
get strict(): boolean;
|
|
37
|
+
get stats(): any;
|
|
34
38
|
update(): void;
|
|
35
39
|
set final(finalize: boolean);
|
|
36
40
|
get final(): boolean;
|
|
@@ -58,6 +62,7 @@ export type TraversalContextStandardOptions = {
|
|
|
58
62
|
strict?: boolean | undefined;
|
|
59
63
|
deep?: boolean | undefined;
|
|
60
64
|
debug?: boolean | undefined;
|
|
65
|
+
stats?: object;
|
|
61
66
|
};
|
|
62
67
|
export type TraversalContextOptions = TraversalContextStandardOptions & {
|
|
63
68
|
[key: string]: any;
|