@aperturesyndicate/synx-format 3.6.0 → 3.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,29 +1,29 @@
1
- "use strict";var SynxModule=(()=>{var K=Object.defineProperty;var yt=Object.getOwnPropertyDescriptor;var gt=Object.getOwnPropertyNames;var ht=Object.prototype.hasOwnProperty;var nt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var xt=(t,e)=>{for(var s in e)K(t,s,{get:e[s],enumerable:!0})},mt=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of gt(e))!ht.call(t,a)&&a!==s&&K(t,a,{get:()=>e[a],enumerable:!(r=yt(e,a))||r.enumerable});return t};var St=t=>mt(K({},"__esModule",{value:!0}),t);var Lt={};xt(Lt,{Synx:()=>H,SynxError:()=>z,default:()=>Vt});function F(t){if(t==="true")return!0;if(t==="false")return!1;if(t==="null")return null;let e=t.length;if(e===0)return t;let s=t.charCodeAt(0);if(s===40&&e>2){let u=t.indexOf(")");if(u>1){let l=t.substring(1,u),n=t.substring(u+1);switch(l){case"int":{let p=parseInt(n,10);return isNaN(p)?0:p}case"float":{let p=parseFloat(n);return isNaN(p)?0:p}case"bool":return n.trim()==="true";case"string":return n;case"random":return Math.floor(Math.random()*2147483647);case"random:int":return Math.floor(Math.random()*2147483647);case"random:float":return Math.random();case"random:bool":return Math.random()<.5}}}let r=0,a=s;if(a===45){if(e===1)return t;r=1,a=t.charCodeAt(1)}if(a>=48&&a<=57){let u=!0,l=-1;for(let n=r+1;n<e;n++){let p=t.charCodeAt(n);if(p===46){if(l!==-1){u=!1;break}l=n}else if(p<48||p>57){u=!1;break}}if(u){if(l===-1)return parseInt(t,10);if(l>r&&l<e-1)return parseFloat(t)}}return t}function X(t){if(t.indexOf(" ")===-1)return t;let e=t,s=e.indexOf(" //");s!==-1&&(e=e.substring(0,s));let r=e.indexOf(" #");return r!==-1&&(e=e.substring(0,r)),e.trimEnd()}function Ot(t){let e={},s=0;for(;s<t.length;){let r=t.indexOf(",",s);r===-1&&(r=t.length);let a=t.substring(s,r).trim();if(s=r+1,!!a)if(a==="required")e.required=!0;else if(a==="readonly")e.readonly=!0;else{let u=a.indexOf(":");if(u!==-1){let l=a.substring(0,u).trim(),n=a.substring(u+1).trim();switch(l){case"min":e.min=Number(n);break;case"max":e.max=Number(n);break;case"type":e.type=n;break;case"pattern":e.pattern=n;break;case"enum":e.enum=n.split("|");break}}}}return e}function U(t,e,s,r,a,u,l){if(u!=="active"||s.length===0&&!a&&!l)return;let n;t.__synx?n=t.__synx:(n={},Object.defineProperty(t,"__synx",{value:n,enumerable:!1,writable:!0,configurable:!0}));let p={markers:s};r.length>0&&(p.args=r),a&&(p.constraints=a),l&&(p.typeHint=l),n[e]=p}var rt=/^([^\s\[:\-#/(][^\s\[:(]*)(?:\(([\w:]+)\))?(?:\[([^\]]*)\])?(?::([^\s]+))?\s*(.*)$/;function R(t){let e=t.split(`
2
- `),s={},r=[{indent:-1,obj:s}],a="static",u=!1,l=[],n=null,p=null,o=!1;for(let O=0;O<e.length;O++){let c=e[O],f=c.length,i=0;for(;i<f;){let y=c.charCodeAt(i);if(y!==32&&y!==9&&y!==13)break;i++}if(i===f)continue;let d=c.charCodeAt(i);if(d===35&&c.substring(i).trimEnd()==="###"){o=!o;continue}if(o)continue;if(d===35){f-i>7&&c.charCodeAt(i+1)===33&&c.substring(i,i+7)==="#!mode:"&&(a=c.substring(i+7,f).trim()==="active"?"active":"static");continue}if(d===47&&i+1<f&&c.charCodeAt(i+1)===47)continue;let g=f;for(;g>i;){let y=c.charCodeAt(g-1);if(y!==32&&y!==9&&y!==13&&y!==10)break;g--}let h=c.substring(i,g),A=h.length;if(d===33){if(h==="!active"){a="active";continue}if(h==="!lock"){u=!0;continue}if(h.startsWith("!include ")){let y=h.substring(9).trim().split(/\s+/),m=y[0],x=y[1]||m.replace(/^.*[\/\\]/,"").replace(/\.synx$/i,"");l.push({path:m,alias:x});continue}}if(n&&i>n.indent){let y=h;n.obj[n.key]+=(n.obj[n.key]?`
3
- `:"")+y;continue}else n=null;if(d===45&&A>1&&h.charCodeAt(1)===32){if(p&&i>p.indent){let y=X(h.substring(2).trim()),m=O+1;for(;m<e.length;){let x=e[m],$=0;for(;$<x.length&&(x.charCodeAt($)===32||x.charCodeAt($)===9||x.charCodeAt($)===13);)$++;if($<x.length)break;m++}if(m<e.length){let x=e[m],$=0;for(;$<x.length&&(x.charCodeAt($)===32||x.charCodeAt($)===9||x.charCodeAt($)===13);)$++;let Y=x.charCodeAt($);if($>i&&$<x.length&&Y!==45&&Y!==35&&!(Y===47&&$+1<x.length&&x.charCodeAt($+1)===47)){let V={},tt=y.match(rt);if(tt){let[,dt,et,,,pt]=tt,L=pt||"";et&&(L=`(${et})${L}`),V[dt]=L?F(X(L)):{}}else V._value=F(y);p.arr.push(V),r.push({indent:i,obj:V});continue}}p.arr.push(F(y));continue}continue}if(p&&i<=p.indent&&(p=null),d===91||d===40||d===58||d===47)continue;let S,N,I,P,w,j=!1,T=-1;for(let y=0;y<A;y++){let m=h.charCodeAt(y);if(m===32||m===9){T=y;break}if(m===40||m===91||m===58){j=!0;break}}if(j){let y=h.match(rt);if(!y)continue;[,S,N,I,P,w]=y,w=w?X(w.trim()):""}else{if(T===-1)S=h,w="";else{S=h.substring(0,T);let y=T;for(;y<A&&(h.charCodeAt(y)===32||h.charCodeAt(y)===9);)y++;w=y<A?X(h.substring(y)):""}N=void 0,I=void 0,P=void 0}N&&(w=`(${N})${w}`);let E=[],v=[];if(P&&(E=P.split(":")),E.length>0&&E.includes("random")&&w){let y=w.split(/\s+/).filter(m=>/^\d+(\.\d+)?$/.test(m));y.length>0&&(v=y,w="")}let D=I?Ot(I):void 0;for(;r.length>1&&r[r.length-1].indent>=i;)r.pop();let C=r[r.length-1].obj;if(!(S==="__proto__"||S==="constructor"||S==="prototype"))if(w==="|")C[S]="",n={indent:i,obj:C,key:S},U(C,S,E,v,D,a,N);else if(!w&&E.length>0&&(E.includes("random")||E.includes("unique")||E.includes("geo")||E.includes("join")))C[S]=[],p={indent:i,arr:C[S]},U(C,S,E,v,D,a,N);else if(w)C[S]=F(w),U(C,S,E,v,D,a,N);else{C[S]={},r.push({indent:i,obj:C[S]});let y=O+1;for(;y<e.length;){let m=e[y],x=0;for(;x<m.length&&(m.charCodeAt(x)===32||m.charCodeAt(x)===9||m.charCodeAt(x)===13);)x++;if(x<m.length)break;y++}if(y<e.length){let m=e[y],x=0;for(;x<m.length&&(m.charCodeAt(x)===32||m.charCodeAt(x)===9||m.charCodeAt(x)===13);)x++;x+1<m.length&&m.charCodeAt(x)===45&&m.charCodeAt(x+1)===32&&(C[S]=[],r[r.length-1]={indent:i,obj:C[S]},p={indent:i,arr:C[S]})}U(C,S,E,v,D,a,N)}}return{root:s,mode:a,locked:u,includes:l.length>0?l:void 0}}function At(t){let e=[],s=0;for(;s<t.length;){let r=t[s];if(r===" "||r===" "){s++;continue}if(r>="0"&&r<="9"||r==="."&&s+1<t.length&&t[s+1]>="0"&&t[s+1]<="9"||r==="-"&&(e.length===0||e[e.length-1].type==="op"||e[e.length-1].type==="paren"&&e[e.length-1].value==="(")){let a="";for(r==="-"&&(a+="-",s++);s<t.length&&(t[s]>="0"&&t[s]<="9"||t[s]===".");)a+=t[s],s++;e.push({type:"number",value:parseFloat(a)});continue}if("+-*/%".includes(r)){e.push({type:"op",value:r}),s++;continue}if(r==="("||r===")"){e.push({type:"paren",value:r}),s++;continue}throw new Error(`SYNX :calc \u2014 unexpected character: '${r}' in expression "${t}"`)}return e}var B=class{constructor(e){this.tokens=e,this.pos=0}parse(){let e=this.expr();if(this.pos<this.tokens.length)throw new Error(`SYNX :calc \u2014 unexpected token at position ${this.pos}`);return e}expr(){let e=this.term();for(;this.pos<this.tokens.length&&this.tokens[this.pos].type==="op"&&(this.tokens[this.pos].value==="+"||this.tokens[this.pos].value==="-");){let s=this.tokens[this.pos].value;this.pos++;let r=this.term();e=s==="+"?e+r:e-r}return e}term(){let e=this.factor();for(;this.pos<this.tokens.length&&this.tokens[this.pos].type==="op"&&"*/%".includes(this.tokens[this.pos].value);){let s=this.tokens[this.pos].value;this.pos++;let r=this.factor();if(s==="*")e=e*r;else if(s==="/"){if(r===0)throw new Error("SYNX :calc \u2014 division by zero");e=e/r}else{if(r===0)throw new Error("SYNX :calc \u2014 division by zero");e=e%r}}return e}factor(){let e=this.tokens[this.pos];if(!e)throw new Error("SYNX :calc \u2014 unexpected end of expression");if(e.type==="number")return this.pos++,e.value;if(e.type==="paren"&&e.value==="("){this.pos++;let s=this.expr();if(!this.tokens[this.pos]||this.tokens[this.pos].type!=="paren"||this.tokens[this.pos].value!==")")throw new Error("SYNX :calc \u2014 missing closing parenthesis");return this.pos++,s}throw new Error(`SYNX :calc \u2014 unexpected token: ${JSON.stringify(e)}`)}};function G(t){let e=At(t.trim());return e.length===0?0:new B(e).parse()}var b,k;try{b=nt("fs"),k=nt("path")}catch{}var st=4096,it=10*1024*1024,J=16,$t=512;function q(t,e){if(!k)throw new Error("path module not available");if(k.isAbsolute(e))throw new Error(`absolute path not allowed: ${e}`);let s=k.resolve(t,e),r=k.resolve(t);if(!s.startsWith(r+k.sep)&&s!==r)throw new Error(`path escapes base directory: ${e}`);return s}function Z(t){if(!b)return;let e=b.statSync(t);if(e.size>it)throw new Error(`file too large (${e.size} bytes, max ${it})`)}var Q=class{constructor(e){this._value=e}toString(){return"[SECRET]"}toJSON(){return"[SECRET]"}reveal(){return this._value}[Symbol.toPrimitive](e){return e==="number"?NaN:"[SECRET]"}},W=new Map;function _(t,e={},s,r,a=0,u=""){if(!s){s=t,bt(t);for(let n of Object.keys(t))n.startsWith("_")&&delete t[n];!r&&e._includes&&(r=kt(e._includes,e))}if(a>=$t){for(let n of Object.keys(t))n!=="__synx"&&(t[n]="NESTING_ERR: maximum object nesting depth exceeded");return t}let l=t.__synx;for(let n of Object.keys(t)){if(n==="__synx")continue;let p=t[n];if(p&&typeof p=="object"&&!Array.isArray(p)&&_(p,e,s,r,a+1,u?`${u}.${n}`:n),Array.isArray(p))for(let c of p)c&&typeof c=="object"&&!Array.isArray(c)&&_(c,e,s,r,a+1,u?`${u}.${n}`:n);if(!l||!l[n])continue;let{markers:o,args:O}=l[n];if(o.includes("spam")){let c=o.indexOf("spam"),f=parseInt(o[c+1]??"0",10),i=Math.max(1,parseInt(o[c+2]??"1",10)||1);if(!Number.isFinite(f)||f<=0){t[n]="SPAM_ERR: invalid limit, use :spam:MAX[:WINDOW_SEC]";continue}let d=String(t[n]??n),g=`${n}::${d}`;if(!Dt(g,f,i)){t[n]=`SPAM_ERR: '${d}' exceeded ${f} calls per ${i}s`;continue}let h=M(s,d)??M(t,d);h!==void 0&&(t[n]=h)}if(o.includes("include")&&typeof t[n]=="string"){if(!b||!k){t[n]="INCLUDE_ERR: :include is not supported in browser";continue}let c=e.maxIncludeDepth??J,f=e._includeDepth??0;if(f>=c){t[n]=`INCLUDE_ERR: max include depth (${c}) exceeded`;continue}let i=String(t[n]),d=e.basePath||(typeof process<"u"?process.cwd():".");try{let g=q(d,i);Z(g);let h=b.readFileSync(g,"utf-8"),{root:A,mode:S}=R(h);S==="active"&&_(A,{...e,basePath:k.dirname(g),_includeDepth:f+1},s),t[n]=A}catch(g){t[n]=`INCLUDE_ERR: ${g.message}`}continue}if(o.includes("env")){let c=String(p),i=(e.env||(typeof process<"u"?process.env:{}))[c],d=o.indexOf("default"),g=l[n]?.typeHint==="string";if(i!==void 0&&i!=="")t[n]=g||isNaN(Number(i))?i:Number(i);else if(d!==-1&&o.length>d+1){let h=o.slice(d+1).join(":");t[n]=g||isNaN(Number(h))?h:Number(h)}else t[n]=null}if(o.includes("random")&&Array.isArray(t[n])){let c=t[n];if(c.length===0){t[n]=null;continue}if(O&&O.length>0){let f=O.map(Number);t[n]=vt(c,f)}else t[n]=c[Math.floor(Math.random()*c.length)]}if(o.includes("ref")&&typeof t[n]=="string"){let c=t[n],f=M(s,c)??M(t,c);if(f!==void 0){if(t[n]=f,o.includes("calc")){let i=o.indexOf("calc"),d=o[i+1]??"";if(d&&typeof f=="number"){let g=d.charAt(0);if("+-*/%".includes(g)){let h=`${f} ${d}`;try{t[n]=G(h)}catch{t[n]=f}}}}}else t[n]=null}if(o.includes("i18n")&&t[n]&&typeof t[n]=="object"&&!Array.isArray(t[n])){let c=t[n],f=e.lang||"en",i=c[f]??c.en??Object.values(c)[0]??null;t[n]=i}if(o.includes("calc")&&typeof t[n]=="string"){let c=t[n];if(c.length>st){t[n]=`CALC_ERR: expression too long (${c.length} chars, max ${st})`;continue}let f=new Map;for(let i of Object.keys(s))typeof s[i]=="number"&&f.set(i,String(s[i]));for(let i of Object.keys(t))i!==n&&typeof t[i]=="number"&&f.set(i,String(t[i]));f.size>0&&(c=Tt(c,f));try{t[n]=G(c)}catch(i){t[n]=`CALC_ERR: ${i.message}`}}if(o.includes("alias")&&typeof t[n]=="string"){let c=t[n],f=u?`${u}.${n}`:n;if(c===n||c===f)t[n]=`ALIAS_ERR: self-referential alias: ${f} \u2192 ${c}`;else{let i=M(s,c),d=c.lastIndexOf("."),g=d>=0?c.slice(0,d):"",h=d>=0?c.slice(d+1):c,A=g?M(s,g):s;((A!=null&&typeof A=="object"?A.__synx:void 0)?.[h]?.markers?.includes("alias")??!1)&&typeof i=="string"&&i===n?t[n]=`ALIAS_ERR: circular alias detected: ${n} \u2192 ${c}`:t[n]=i??null}}if(o.includes("secret")&&(t[n]=new Q(String(t[n]))),o.includes("unique")&&Array.isArray(t[n])){let c=new Set;t[n]=t[n].filter(f=>{let i=String(f);return c.has(i)?!1:(c.add(i),!0)})}if(o.includes("geo")&&Array.isArray(t[n])){let c=e.region||"US",f=t[n],i=f.find(d=>String(d).startsWith(c+" "));if(i)t[n]=i.substring(c.length+1).trim();else{let d=f[0];typeof d=="string"&&d.includes(" ")?t[n]=d.substring(d.indexOf(" ")+1).trim():t[n]=d??null}}if(o.includes("split")&&typeof t[n]=="string"){let c=o.indexOf("split"),f=c+1<o.length?o[c+1]:",",i=ot(f);t[n]=t[n].split(i).map(d=>d.trim()).filter(d=>d!=="").map(d=>ct(d))}if(o.includes("join")&&Array.isArray(t[n])){let c=o.indexOf("join"),f=c+1<o.length?o[c+1]:",",i=ot(f);t[n]=t[n].map(d=>String(d)).join(i)}if(o.includes("default")&&!o.includes("env")&&(t[n]===null||t[n]===void 0||t[n]==="")){let c=o.indexOf("default");if(c!==-1&&o.length>c+1){let f=o.slice(c+1).join(":"),i=l[n]?.typeHint==="string";t[n]=i||isNaN(Number(f))?f:Number(f)}}if(o.includes("clamp")){let c=o.indexOf("clamp"),f=parseFloat(o[c+1]??""),i=parseFloat(o[c+2]??"");!isNaN(f)&&!isNaN(i)&&(f>i?t[n]=`CONSTRAINT_ERR: clamp min (${f}) > max (${i})`:typeof t[n]=="number"&&(t[n]=Math.min(i,Math.max(f,t[n]))))}if(o.includes("round")){let c=o.indexOf("round"),f=parseInt(o[c+1]??"0",10)||0;if(typeof t[n]=="number"){let i=Math.pow(10,f);t[n]=Math.round(t[n]*i)/i}}if(o.includes("map")&&Array.isArray(t[n])){let c=o.indexOf("map"),f=o[c+1]??"",i=String(f?M(s,f)??M(t,f)??"":""),g=t[n].find(h=>{let A=String(h),S=A.indexOf(" ");return S!==-1&&A.substring(0,S).trim()===i});t[n]=g?ct(g.substring(g.indexOf(" ")+1).trim()):null}if(o.includes("format")){let c=o.indexOf("format"),f=o[c+1]??"%s";t[n]=Mt(f,t[n])}if(o.includes("fallback")){let c=o.indexOf("fallback"),f=o[c+1]??"",i=t[n],d=i==null||i==="";if(!d&&typeof i=="string"&&b&&k&&e.basePath)try{let g=q(e.basePath,i);d=!b.existsSync(g)}catch{d=!0}d&&f&&(t[n]=f)}if(o.includes("once")){let c=o.indexOf("once"),f=o[c+1]??"uuid",i=k&&e.basePath?k.resolve(e.basePath,".synx.lock"):".synx.lock",d=Et(i,n);if(d!==null)t[n]=d;else{let g;f==="uuid"?g=at():f==="timestamp"?g=String(Date.now()):f==="random"?g=String(Math.floor(Math.random()*2147483647)):g=at(),Nt(i,n,g),t[n]=g}}if(o.includes("version")&&typeof t[n]=="string"){let c=o.indexOf("version"),f=o[c+1]??">=",i=o[c+2]??"0";t[n]=Rt(t[n],f,i)}if(o.includes("watch")&&typeof t[n]=="string")if(!b||!k)t[n]="WATCH_ERR: not supported in browser";else{let c=e.maxIncludeDepth??J;if((e._includeDepth??0)>=c)t[n]=`WATCH_ERR: max include depth (${c}) exceeded`;else{let i=t[n],d=e.basePath||(typeof process<"u"?process.cwd():"."),g=o.indexOf("watch"),h=o[g+1];try{let A=q(d,i);Z(A);let S=b.readFileSync(A,"utf-8"),N=k.extname(A).slice(1);h?t[n]=_t(S,h,N):t[n]=S.trim()}catch(A){t[n]=`WATCH_ERR: ${A.message}`}}}if(o.includes("prompt")){let c=o.indexOf("prompt"),f=o[c+1]??n,i=t[n],d=ut(i,0);t[n]=`${f} (SYNX):
1
+ "use strict";var SynxModule=(()=>{var j=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var ht=Object.getOwnPropertyNames;var xt=Object.prototype.hasOwnProperty;var at=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var St=(t,e)=>{for(var s in e)j(t,s,{get:e[s],enumerable:!0})},mt=(t,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of ht(e))!xt.call(t,c)&&c!==s&&j(t,c,{get:()=>e[c],enumerable:!(n=gt(e,c))||n.enumerable});return t};var At=t=>mt(j({},"__esModule",{value:!0}),t);var Ft={};St(Ft,{Synx:()=>Q,SynxError:()=>Z,default:()=>Ut});function D(t){let e=t.length;if(e>=2){let u=t.charCodeAt(0),o=t.charCodeAt(e-1);if(u===34&&o===34||u===39&&o===39)return t.substring(1,e-1)}if(t==="true")return!0;if(t==="false")return!1;if(t==="null")return null;if(e===0)return t;let s=t.charCodeAt(0);if(s===40&&e>2){let u=t.indexOf(")");if(u>1){let o=t.substring(1,u);if(/^[A-Za-z_][A-Za-z0-9_:]*$/.test(o)){let r=t.substring(u+1);switch(o){case"int":{let p=parseInt(r,10);return isNaN(p)?0:p}case"float":{let p=parseFloat(r);return isNaN(p)?0:p}case"bool":return r.trim()==="true";case"string":return r;case"random":return Math.floor(Math.random()*2147483647);case"random:int":return Math.floor(Math.random()*2147483647);case"random:float":return Math.random();case"random:bool":return Math.random()<.5;default:return D(r)}}}}let n=0,c=s;if(c===45){if(e===1)return t;n=1,c=t.charCodeAt(1)}if(c>=48&&c<=57){let u=!0,o=-1;for(let r=n+1;r<e;r++){let p=t.charCodeAt(r);if(p===46){if(o!==-1){u=!1;break}o=r}else if(p<48||p>57){u=!1;break}}if(u){if(o===-1)return parseInt(t,10);if(o>n&&o<e-1)return parseFloat(t)}}return t}function W(t){if(t.indexOf(" ")===-1)return t;let e=t,s=e.indexOf(" //");s!==-1&&(e=e.substring(0,s));let n=e.indexOf(" #");return n!==-1&&(e=e.substring(0,n)),e.trimEnd()}function Ot(t){let e={},s=0;for(;s<t.length;){let n=t.indexOf(",",s);n===-1&&(n=t.length);let c=t.substring(s,n).trim();if(s=n+1,!!c)if(c==="required")e.required=!0;else if(c==="readonly")e.readonly=!0;else{let u=c.indexOf(":");if(u!==-1){let o=c.substring(0,u).trim(),r=c.substring(u+1).trim();switch(o){case"min":e.min=Number(r);break;case"max":e.max=Number(r);break;case"type":e.type=r;break;case"pattern":e.pattern=r;break;case"enum":e.enum=r.split("|").slice(0,4096);break}}}}return e}function q(t,e,s,n,c,u,o){if(u!=="active"||s.length===0&&!c&&!o)return;let r;t.__synx?r=t.__synx:(r={},Object.defineProperty(t,"__synx",{value:r,enumerable:!1,writable:!0,configurable:!0}));let p={markers:s};n.length>0&&(p.args=n),c&&(p.constraints=c),o&&(p.typeHint=o),r[e]=p}function ct(t){let e=t.length;if(e===0)return null;let s=t.charCodeAt(0);if(s===91||s===58||s===45||s===35||s===47||s===40)return null;let n=0;for(;n<e;){let i=t.charCodeAt(n);if(i===32||i===9||i===91||i===58||i===40)break;n++}if(n===0)return null;let c=t.substring(0,n),u,o,r;if(n<e&&t.charCodeAt(n)===40){let i=t.indexOf(")",n+1);i!==-1?(u=t.substring(n+1,i),n=i+1):n++}if(n<e&&t.charCodeAt(n)===91){n++;let i=n,x=1;for(;n<e&&x>0;){let a=t.charCodeAt(n);a===91?x++:a===93&&x--,x>0&&n++}if(x===0)o=t.substring(i,n),n++;else{let a=t.indexOf("]",i);a!==-1?(o=t.substring(i,a),n=a+1):(o=t.substring(i),n=e)}}if(n<e&&t.charCodeAt(n)===58){let i=n+1,x=i;for(;x<e;){let a=t.charCodeAt(x);if(a===32||a===9)break;x++}r=t.substring(i,x),n=x}for(;n<e;){let i=t.charCodeAt(n);if(i!==32&&i!==9)break;n++}let p=n<e?t.substring(n):"";return{key:c,typeHint:u,constraintStr:o,markerChain:r,rawValue:p}}function v(t){t.length>16777216&&(t=t.substring(0,16777216));let e=t.split(`
2
+ `);e.length>2e6&&(e=e.slice(0,2e6));let s={},n=[{indent:-1,obj:s}],c="static",u=!1,o=!1,r=!1,p=!1,i=[],x=null,a=null,f=!1;for(let l=0;l<e.length;l++){let d=e[l],h=d.length,g=0;for(;g<h;){let y=d.charCodeAt(g);if(y!==32&&y!==9&&y!==13)break;g++}if(g===h)continue;let m=d.charCodeAt(g);if(m===35&&d.substring(g).trimEnd()==="###"){f=!f;continue}if(f)continue;if(m===35){h-g>7&&d.charCodeAt(g+1)===33&&d.substring(g,g+7)==="#!mode:"&&(c=d.substring(g+7,h).trim()==="active"?"active":"static");continue}if(m===47&&g+1<h&&d.charCodeAt(g+1)===47)continue;let w=h;for(;w>g;){let y=d.charCodeAt(w-1);if(y!==32&&y!==9&&y!==13&&y!==10)break;w--}let O=d.substring(g,w),R=O.length;if(m===33){if(O==="!active"){c="active";continue}if(O==="!lock"){u=!0;continue}if(O==="!llm"){o=!0;continue}if(O==="!tool"){r=!0;continue}if(O==="!schema"){p=!0;continue}if(O.startsWith("!include ")){if(i.length<4096){let y=O.substring(9).trim().split(/\s+/),A=y[0],S=y[1]||A.replace(/^.*[\/\\]/,"").replace(/\.synx$/i,"");i.push({path:A,alias:S})}continue}}if(x&&g>x.indent){let y=x.obj[x.key];if(y.length<1048576){let A=O,S=1048576-y.length,V=(y?`
3
+ `:"")+A;x.obj[x.key]=y+V.substring(0,S)}continue}else x=null;if(m===45&&R>1&&O.charCodeAt(1)===32){if(a&&g>a.indent){if(a.arr.length>=1048576)continue;let y=W(O.substring(2).trim()),A=l+1;for(;A<e.length;){let S=e[A],b=0;for(;b<S.length&&(S.charCodeAt(b)===32||S.charCodeAt(b)===9||S.charCodeAt(b)===13);)b++;if(b<S.length)break;A++}if(A<e.length){let S=e[A],b=0;for(;b<S.length&&(S.charCodeAt(b)===32||S.charCodeAt(b)===9||S.charCodeAt(b)===13);)b++;let V=S.charCodeAt(b);if(b>g&&b<S.length&&V!==45&&V!==35&&!(V===47&&b+1<S.length&&S.charCodeAt(b+1)===47)){let z={},L=ct(y);if(L){let B=L.rawValue;L.typeHint&&(B=`(${L.typeHint})${B}`),z[L.key]=B?D(W(B)):{}}else z._value=D(y);a.arr.push(z),n.push({indent:g,obj:z});continue}}a.arr.push(D(y));continue}continue}if(a&&g<=a.indent&&(a=null),m===91||m===40||m===58||m===47)continue;let _,k,U,F,$,it=!1,Y=-1;for(let y=0;y<R;y++){let A=O.charCodeAt(y);if(A===32||A===9){Y=y;break}if(A===40||A===91||A===58){it=!0;break}}if(it){let y=ct(O);if(!y)continue;_=y.key,k=y.typeHint,U=y.constraintStr,F=y.markerChain,$=y.rawValue?W(y.rawValue):""}else{if(Y===-1)_=O,$="";else{_=O.substring(0,Y);let y=Y;for(;y<R&&(O.charCodeAt(y)===32||O.charCodeAt(y)===9);)y++;$=y<R?W(O.substring(y)):""}k=void 0,U=void 0,F=void 0}k&&($=`(${k})${$}`);let I=[],T=[];if(F&&(I=F.split(":").slice(0,512)),I.length>0&&I.includes("random")&&$){let y=$.split(/\s+/).filter(A=>/^\d+(\.\d+)?$/.test(A));y.length>0&&(T=y,$="")}I.length>0&&I.includes("inherit")&&$&&(T=[$.trim()],$="");let H=U?Ot(U):void 0;for(;n.length>1&&n[n.length-1].indent>=g;)n.pop();let N=n[n.length-1].obj;if(!(_==="__proto__"||_==="constructor"||_==="prototype"))if($==="|")N[_]="",x={indent:g,obj:N,key:_},q(N,_,I,T,H,c,k);else if(!$&&I.length>0&&(I.includes("random")||I.includes("unique")||I.includes("geo")||I.includes("join")))N[_]=[],a={indent:g,arr:N[_]},q(N,_,I,T,H,c,k);else if($)N[_]=D($),q(N,_,I,T,H,c,k);else{N[_]={},n.length<128&&n.push({indent:g,obj:N[_]});let y=l+1;for(;y<e.length;){let A=e[y],S=0;for(;S<A.length&&(A.charCodeAt(S)===32||A.charCodeAt(S)===9||A.charCodeAt(S)===13);)S++;if(S<A.length)break;y++}if(y<e.length){let A=e[y],S=0;for(;S<A.length&&(A.charCodeAt(S)===32||A.charCodeAt(S)===9||A.charCodeAt(S)===13);)S++;S+1<A.length&&A.charCodeAt(S)===45&&A.charCodeAt(S+1)===32&&(N[_]=[],n[n.length-1]={indent:g,obj:N[_]},a={indent:g,arr:N[_]})}q(N,_,I,T,H,c,k)}}return{root:s,mode:c,locked:u,...o?{llm:!0}:{},...r?{tool:!0}:{},...p?{schema:!0}:{},includes:i.length>0?i:void 0}}function _t(t){let e=[],s=0;for(;s<t.length;){let n=t[s];if(n===" "||n===" "){s++;continue}if(n>="0"&&n<="9"||n==="."&&s+1<t.length&&t[s+1]>="0"&&t[s+1]<="9"||n==="-"&&(e.length===0||e[e.length-1].type==="op"||e[e.length-1].type==="paren"&&e[e.length-1].value==="(")){let c="";for(n==="-"&&(c+="-",s++);s<t.length&&(t[s]>="0"&&t[s]<="9"||t[s]===".");)c+=t[s],s++;e.push({type:"number",value:parseFloat(c)});continue}if("+-*/%".includes(n)){e.push({type:"op",value:n}),s++;continue}if(n==="("||n===")"){e.push({type:"paren",value:n}),s++;continue}throw new Error(`SYNX :calc \u2014 unexpected character: '${n}' in expression`)}return e}var tt=class{constructor(e){this.tokens=e,this.pos=0}parse(){let e=this.expr();if(this.pos<this.tokens.length)throw new Error(`SYNX :calc \u2014 unexpected token at position ${this.pos}`);return e}expr(){let e=this.term();for(;this.pos<this.tokens.length&&this.tokens[this.pos].type==="op"&&(this.tokens[this.pos].value==="+"||this.tokens[this.pos].value==="-");){let s=this.tokens[this.pos].value;this.pos++;let n=this.term();e=s==="+"?e+n:e-n}return e}term(){let e=this.factor();for(;this.pos<this.tokens.length&&this.tokens[this.pos].type==="op"&&"*/%".includes(this.tokens[this.pos].value);){let s=this.tokens[this.pos].value;this.pos++;let n=this.factor();if(s==="*")e=e*n;else if(s==="/"){if(n===0)throw new Error("SYNX :calc \u2014 division by zero");e=e/n}else{if(n===0)throw new Error("SYNX :calc \u2014 division by zero");e=e%n}}return e}factor(){let e=this.tokens[this.pos];if(!e)throw new Error("SYNX :calc \u2014 unexpected end of expression");if(e.type==="number")return this.pos++,e.value;if(e.type==="paren"&&e.value==="("){this.pos++;let s=this.expr();if(!this.tokens[this.pos]||this.tokens[this.pos].type!=="paren"||this.tokens[this.pos].value!==")")throw new Error("SYNX :calc \u2014 missing closing parenthesis");return this.pos++,s}throw new Error(`SYNX :calc \u2014 unexpected token: ${JSON.stringify(e)}`)}};function et(t){let e=_t(t.trim());return e.length===0?0:new tt(e).parse()}var M,C;try{M=at("fs"),C=at("path")}catch{}var ot=4096,lt=10*1024*1024,nt=16,bt=512;function G(t,e){if(!C)throw new Error("path module not available");let s=e.charCodeAt(0);if(s===47||s===92)throw new Error(`SECURITY: rooted paths are not allowed: '${e}'`);if(C.isAbsolute(e))throw new Error(`SECURITY: absolute paths are not allowed: '${e}'`);let n=C.resolve(t,e),c=C.resolve(t);if(e.includes("..")&&!n.startsWith(c+C.sep)&&n!==c)throw new Error(`SECURITY: path traversal detected: '${e}'`);if(!n.startsWith(c+C.sep)&&n!==c)throw new Error(`SECURITY: path escapes base directory: '${e}'`);return n}function rt(t){if(!M)return;let e=M.statSync(t);if(e.size>lt)throw new Error(`file too large (${e.size} bytes, max ${lt})`)}var st=class{constructor(e){this._value=e}toString(){return"[SECRET]"}toJSON(){return"[SECRET]"}reveal(){return this._value}[Symbol.toPrimitive](e){return e==="number"?NaN:"[SECRET]"}},K=new Map;function ut(t,e){let s=t&&t.code;return s==="ENOENT"?`file not found: ${e}`:s==="EACCES"||s==="EPERM"?`permission denied: ${e}`:t&&t.message?t.message:String(t)}function P(t,e={},s,n,c=0,u=""){if(!s){s=t,wt(t);for(let r of Object.keys(t))r.startsWith("_")&&delete t[r];if(!n){let r=e._includes;n=r?Ct(r,e):new Map}}if(c>=bt){for(let r of Object.keys(t))r!=="__synx"&&(t[r]="NESTING_ERR: maximum object nesting depth exceeded");return t}let o=t.__synx;for(let r of Object.keys(t)){if(r==="__synx")continue;let p=t[r];if(p&&typeof p=="object"&&!Array.isArray(p)&&P(p,e,s,n,c+1,u?`${u}.${r}`:r),Array.isArray(p))for(let a of p)a&&typeof a=="object"&&!Array.isArray(a)&&P(a,e,s,n,c+1,u?`${u}.${r}`:r);if(!o||!o[r])continue;let{markers:i,args:x}=o[r];if(i.includes("spam")){let a=i.indexOf("spam"),f=parseInt(i[a+1]??"0",10),l=Math.max(1,parseInt(i[a+2]??"1",10)||1);if(!Number.isFinite(f)||f<=0){t[r]="SPAM_ERR: invalid limit, use :spam:MAX[:WINDOW_SEC]";continue}let d=String(t[r]??r),h=`${r}::${d}`;if(!Xt(h,f,l)){t[r]=`SPAM_ERR: '${d}' exceeded ${f} calls per ${l}s`;continue}let g=E(s,d)??E(t,d);g!==void 0&&(t[r]=g)}if((i.includes("include")||i.includes("import"))&&typeof t[r]=="string"){if(!M||!C){t[r]="INCLUDE_ERR: :include/:import is not supported in browser";continue}let a=e.maxIncludeDepth??nt,f=e._includeDepth??0;if(f>=a){t[r]=`INCLUDE_ERR: max include depth (${a}) exceeded`;continue}let l=String(t[r]),d=e.basePath||(typeof process<"u"?process.cwd():".");try{let h=G(d,l);rt(h);let g=M.readFileSync(h,"utf-8"),{root:m,mode:w}=v(g);w==="active"&&P(m,{...e,basePath:C.dirname(h),_includeDepth:f+1},s),t[r]=m,n&&n.set(r,m)}catch(h){t[r]=`INCLUDE_ERR: ${ut(h,l)}`}continue}if(i.includes("env")&&typeof p=="string"){let a=p,l=(e.env||(typeof process<"u"?process.env:{}))[a],d=i.indexOf("default"),h=o[r]?.typeHint==="string";if(l!==void 0&&l!=="")t[r]=h?l:X(l);else if(d!==-1&&i.length>d+1){let g=i.slice(d+1).join(":");t[r]=h?g:X(g)}else t[r]=null}if(i.includes("random")&&Array.isArray(t[r])){let a=t[r];if(a.length===0){t[r]=null;continue}if(x&&x.length>0){let f=x.map(Number);t[r]=Pt(a,f)}else t[r]=a[Math.floor(Math.random()*a.length)]}if(i.includes("ref")&&typeof t[r]=="string"){let a=t[r],f=E(s,a)??E(t,a);if(f!==void 0){if(t[r]=f,i.includes("calc")){let l=i.indexOf("calc"),d=i[l+1]??"";if(d&&typeof f=="number"){let h=d.charAt(0);if("+-*/%".includes(h)){let g=`${f} ${d}`;try{t[r]=et(g)}catch{t[r]=f}}}}}else t[r]=null}if(i.includes("i18n")&&t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])){let a=t[r],f=e.lang||"en",l=a[f]??a.en??Object.values(a)[0]??null,d=i.indexOf("i18n"),h=i[d+1];if(h&&l&&typeof l=="object"&&!Array.isArray(l)){let g=l,m=E(s,h)??E(t,h),w=typeof m=="number"?m:typeof m=="string"&&!isNaN(Number(m))?Number(m):0,O=Tt(f,Math.trunc(w)),R=g[O]??g.other??Object.values(g)[0]??null;typeof R=="string"?t[r]=R.split("{count}").join(String(Math.trunc(w))):t[r]=R}else t[r]=l}if(i.includes("calc")&&typeof t[r]=="string"){let a=t[r];if(a.length>ot){t[r]=`CALC_ERR: expression too long (${a.length} chars, max ${ot})`;continue}let f=new Map;for(let l of Object.keys(s))typeof s[l]=="number"&&f.set(l,String(s[l]));for(let l of Object.keys(t))l!==r&&typeof t[l]=="number"&&f.set(l,String(t[l]));f.size>0&&(a=Lt(a,f)),a=Dt(a,s);try{t[r]=et(a)}catch(l){t[r]=`CALC_ERR: ${l.message}`}}if(i.includes("alias")&&typeof t[r]=="string"){let a=t[r],f=u?`${u}.${r}`:r;if(a===r||a===f)t[r]=`ALIAS_ERR: self-referential alias: ${f} \u2192 ${a}`;else{let l=E(s,a),d=a.lastIndexOf("."),h=d>=0?a.slice(0,d):"",g=d>=0?a.slice(d+1):a,m=h?E(s,h):s;if(((m!=null&&typeof m=="object"?m.__synx:void 0)?.[g]?.markers?.includes("alias")??!1)&&typeof l=="string"&&l===r){let _=f<=a?f:a,k=f<=a?a:f;t[r]=`ALIAS_ERR: circular alias detected: ${_} \u2192 ${k}`}else t[r]=l??null}}if(i.includes("secret")&&(t[r]=new st(String(t[r]))),i.includes("unique")&&Array.isArray(t[r])){let a=new Set;t[r]=t[r].filter(f=>{let l=String(f);return a.has(l)?!1:(a.add(l),!0)})}if(i.includes("geo")&&Array.isArray(t[r])){let a=e.region||"US",f=t[r],l=f.find(d=>String(d).startsWith(a+" "));if(l)t[r]=l.substring(a.length+1).trim();else{let d=f[0];typeof d=="string"&&d.includes(" ")?t[r]=d.substring(d.indexOf(" ")+1).trim():t[r]=d??null}}if(i.includes("split")&&typeof t[r]=="string"){let a=i.indexOf("split"),f=a+1<i.length?i[a+1]:",",l=dt(f);t[r]=t[r].split(l).map(d=>d.trim()).filter(d=>d!=="").map(d=>X(d))}if(i.includes("join")&&Array.isArray(t[r])){let a=i.indexOf("join"),f=a+1<i.length?i[a+1]:",",l=dt(f);t[r]=t[r].map(d=>String(d)).join(l)}if(i.includes("default")&&!i.includes("env")&&(t[r]===null||t[r]===void 0||t[r]==="")){let a=i.indexOf("default");if(a!==-1&&i.length>a+1){let f=i.slice(a+1).join(":"),l=o[r]?.typeHint==="string";t[r]=l?f:X(f)}}if(i.includes("clamp")){let a=i.indexOf("clamp"),f=parseFloat(i[a+1]??""),l=parseFloat(i[a+2]??"");!isNaN(f)&&!isNaN(l)&&(f>l?t[r]=`CONSTRAINT_ERR: clamp min (${f}) > max (${l})`:typeof t[r]=="number"&&(t[r]=Math.min(l,Math.max(f,t[r]))))}if(i.includes("round")){let a=i.indexOf("round"),f=parseInt(i[a+1]??"0",10)||0;if(typeof t[r]=="number"){let l=Math.pow(10,f);t[r]=Math.round(t[r]*l)/l}}if(i.includes("map")&&Array.isArray(t[r])){let a=i.indexOf("map"),f=i[a+1]??"",l=String(f?E(s,f)??E(t,f)??"":""),h=t[r].find(g=>{let m=String(g),w=m.indexOf(" ");return w!==-1&&m.substring(0,w).trim()===l});t[r]=h?X(h.substring(h.indexOf(" ")+1).trim()):null}if(i.includes("format")){let a=i.indexOf("format"),f=i[a+1]??"%s";t[r]=$t(f,t[r])}if(i.includes("replace")&&typeof t[r]=="string"){let a=i.indexOf("replace"),f=i[a+1],l=i[a+2]??"";f!==void 0&&f!==""&&(t[r]=t[r].split(f).join(l))}if(i.includes("sort")&&Array.isArray(t[r])){let a=i.indexOf("sort"),f=i[a+1],l=t[r].slice().sort((d,h)=>typeof d=="number"&&typeof h=="number"?d-h:String(d).localeCompare(String(h)));f==="desc"&&l.reverse(),t[r]=l}if(i.includes("sum")&&Array.isArray(t[r])){let a=0,f=!0;for(let l of t[r])if(typeof l=="number")a+=l,Number.isInteger(l)||(f=!1);else if(typeof l=="string"&&l!==""&&!isNaN(Number(l))){let d=Number(l);a+=d,Number.isInteger(d)||(f=!1)}t[r]=f?Math.trunc(a):a}if(i.includes("fallback")){let a=i.indexOf("fallback"),f=i[a+1]??"",l=t[r],d=l==null||l==="";if(!d&&typeof l=="string"&&M&&C&&e.basePath)try{let h=G(e.basePath,l);d=!M.existsSync(h)}catch{d=!0}d&&f&&(t[r]=f)}if(i.includes("once")){let a=i.indexOf("once"),f=i[a+1]??"uuid",l=C&&e.basePath?C.resolve(e.basePath,".synx.lock"):".synx.lock",d=It(l,r);if(d!==null)t[r]=d;else{let h;f==="uuid"?h=ft():f==="timestamp"?h=String(Date.now()):f==="random"?h=String(Math.floor(Math.random()*2147483647)):h=ft(),Nt(l,r,h),t[r]=h}}if(i.includes("version")&&typeof t[r]=="string"){let a=i.indexOf("version"),f=i[a+1]??">=",l=i[a+2]??"0";t[r]=kt(t[r],f,l)}if(i.includes("watch")&&typeof t[r]=="string")if(!M||!C)t[r]="WATCH_ERR: not supported in browser";else{let a=e.maxIncludeDepth??nt;if((e._includeDepth??0)>=a)t[r]=`WATCH_ERR: max include depth (${a}) exceeded`;else{let l=t[r],d=e.basePath||(typeof process<"u"?process.cwd():"."),h=i.indexOf("watch"),g=i[h+1];try{let m=G(d,l);rt(m);let w=M.readFileSync(m,"utf-8"),O=C.extname(m).slice(1);g?t[r]=Rt(w,g,O):t[r]=w.trim()}catch(m){t[r]=`WATCH_ERR: ${ut(m,l)}`}}}if(i.includes("prompt")){let a=i.indexOf("prompt"),f=i[a+1]??r,l=t[r],d=pt(l,0);t[r]=`${f} (SYNX):
4
4
  \`\`\`synx
5
- ${d}\`\`\``}l&&l[n]?.constraints&&Ct(t,n,l[n].constraints)}for(let n of Object.keys(t))n!=="__synx"&&typeof t[n]=="string"&&t[n].includes("{")&&(t[n]=wt(t[n],s,t,r));return t}function bt(t){let e=t.__synx;if(e)for(let s of Object.keys(t)){if(s==="__synx")continue;let r=e[s];if(!r||!r.markers.includes("inherit"))continue;let a=r.markers.indexOf("inherit"),u=r.markers[a+1];if(!u)continue;let l=t[u];if(!l||typeof l!="object"||Array.isArray(l))continue;let n=t[s];if(!n||typeof n!="object"||Array.isArray(n))continue;let p={...l,...n},o=l.__synx,O=n.__synx;if(o||O){let c={...o||{},...O||{}};Object.defineProperty(p,"__synx",{value:c,enumerable:!1,writable:!0,configurable:!0})}t[s]=p}}function wt(t,e,s,r){return t.replace(/\{(\w+(?:\.\w+)*)(?::(\w+(?:[./\\][\w./\\]*)?))?\}/g,(a,u,l)=>{if(l){if(l==="include"){if(!r||r.size===0)return a;if(r.size>1)return"INCLUDE_ERR: multiple !include \u2014 specify alias";let p=r.values().next().value,o=M(p,u);return o!=null?String(o):a}if(r){let p=r.get(l);if(p){let o=M(p,u);return o!=null?String(o):a}}return a}let n=M(e,u)??M(s,u);return n!=null?String(n):a})}function kt(t,e){let s=new Map;if(!b||!k)return s;let r=e.basePath||(typeof process<"u"?process.cwd():"."),a=e.maxIncludeDepth??J,u=e._includeDepth??0;if(u>=a)return s;for(let l of t)try{let n=q(r,l.path);Z(n);let p=b.readFileSync(n,"utf-8"),{root:o,mode:O}=R(p);O==="active"&&_(o,{...e,basePath:k.dirname(n),_includeDepth:u+1},void 0,s),s.set(l.alias,o)}catch{}return s}function Ct(t,e,s){let r=t[e];if(s.required&&(r==null||r==="")){t[e]=`CONSTRAINT_ERR: '${e}' is required`;return}if(r==null)return;if(s.type&&!(()=>{switch(s.type){case"int":return typeof r=="number"&&Number.isInteger(r);case"float":return typeof r=="number";case"bool":return typeof r=="boolean";case"string":return typeof r=="string";default:return!0}})()){t[e]=`CONSTRAINT_ERR: '${e}' expected type '${s.type}'`;return}if(s.enum){let u=String(r);if(!s.enum.includes(u)){t[e]=`CONSTRAINT_ERR: '${e}' must be one of [${s.enum.join("|")}]`;return}}let a=typeof r=="number"?r:typeof r=="string"&&(s.min!==void 0||s.max!==void 0)?r.length:null;if(a!==null){if(s.min!==void 0&&a<s.min){t[e]=`CONSTRAINT_ERR: '${e}' value ${a} is below min ${s.min}`;return}if(s.max!==void 0&&a>s.max){t[e]=`CONSTRAINT_ERR: '${e}' value ${a} exceeds max ${s.max}`;return}}if(s.pattern&&typeof r=="string"){if(s.pattern.length>128)return;try{if(!new RegExp(s.pattern).test(r)){t[e]=`CONSTRAINT_ERR: '${e}' does not match pattern /${s.pattern}/`;return}}catch{}}}function Mt(t,e){let s=typeof e=="number"?e:parseFloat(String(e));if(isNaN(s))return String(e);let r=t.match(/^%\.(\d+)f$/);if(r)return s.toFixed(parseInt(r[1],10));let a=t.match(/^%0(\d+)d$/);if(a)return String(Math.round(s)).padStart(parseInt(a[1],10),"0");let u=t.match(/^%(\d+)d$/);return u?String(Math.round(s)).padStart(parseInt(u[1],10)):t==="%e"?s.toExponential():String(e)}function Et(t,e){if(!b)return null;try{let s=b.readFileSync(t,"utf-8");for(let r of s.split(/\r?\n/))if(r.startsWith(e+" "))return r.substring(e.length+1)}catch{}return null}function Nt(t,e,s){if(!b)return;let r=[];try{r=b.readFileSync(t,"utf-8").split(/\r?\n/)}catch{}let a=`${e} ${s}`,u=r.findIndex(l=>l.startsWith(e+" "));u!==-1?r[u]=a:r.push(a);try{b.writeFileSync(t,r.filter(Boolean).join(`
5
+ ${d}\`\`\``}o&&o[r]?.constraints&&Mt(t,r,o[r].constraints)}for(let r of Object.keys(t))r!=="__synx"&&typeof t[r]=="string"&&t[r].includes("{")&&(t[r]=Et(t[r],s,t,n));return t}function wt(t){let e=t.__synx;if(e)for(let s of Object.keys(t)){if(s==="__synx")continue;let n=e[s];if(!n||!n.markers.includes("inherit"))continue;let c=n.markers.indexOf("inherit"),u=n.markers[c+1]||n.args&&n.args[0];if(!u)continue;let o=t[u];if(!o||typeof o!="object"||Array.isArray(o))continue;let r=t[s];if(!r||typeof r!="object"||Array.isArray(r))continue;let p={...o,...r},i=o.__synx,x=r.__synx;if(i||x){let a={...i||{},...x||{}};Object.defineProperty(p,"__synx",{value:a,enumerable:!1,writable:!0,configurable:!0})}t[s]=p}}function Et(t,e,s,n){return t.replace(/\{(\w+(?:\.\w+)*)(?::(\w+(?:[./\\][\w./\\]*)?))?\}/g,(c,u,o)=>{if(o){if(o==="include"){if(!n||n.size===0)return c;if(n.size>1)return"INCLUDE_ERR: multiple !include \u2014 specify alias";let p=n.values().next().value,i=E(p,u);return i!=null?String(i):c}if(n){let p=n.get(o);if(p){let i=E(p,u);return i!=null?String(i):c}}return c}let r=E(e,u)??E(s,u);return r!=null?String(r):c})}function Ct(t,e){let s=new Map;if(!M||!C)return s;let n=e.basePath||(typeof process<"u"?process.cwd():"."),c=e.maxIncludeDepth??nt,u=e._includeDepth??0;if(u>=c)return s;for(let o of t)try{let r=G(n,o.path);rt(r);let p=M.readFileSync(r,"utf-8"),{root:i,mode:x}=v(p);x==="active"&&P(i,{...e,basePath:C.dirname(r),_includeDepth:u+1},void 0,s),s.set(o.alias,i)}catch{}return s}function Mt(t,e,s){let n=t[e];if(s.required&&(n==null||n==="")){t[e]=`CONSTRAINT_ERR: '${e}' is required`;return}if(n==null)return;if(s.type&&!(()=>{switch(s.type){case"int":return typeof n=="number"&&Number.isInteger(n);case"float":return typeof n=="number";case"bool":return typeof n=="boolean";case"string":return typeof n=="string";default:return!0}})()){t[e]=`CONSTRAINT_ERR: '${e}' expected type '${s.type}'`;return}if(s.enum){let u=String(n);if(!s.enum.includes(u)){t[e]=`CONSTRAINT_ERR: '${e}' must be one of [${s.enum.join("|")}]`;return}}let c=typeof n=="number"?n:typeof n=="string"&&(s.min!==void 0||s.max!==void 0)?n.length:null;if(c!==null){if(s.min!==void 0&&c<s.min){t[e]=`CONSTRAINT_ERR: '${e}' value ${c} is below min ${s.min}`;return}if(s.max!==void 0&&c>s.max){t[e]=`CONSTRAINT_ERR: '${e}' value ${c} exceeds max ${s.max}`;return}}if(s.pattern&&typeof n=="string"){if(s.pattern.length>128)return;try{if(!new RegExp(s.pattern).test(n)){t[e]=`CONSTRAINT_ERR: '${e}' does not match pattern /${s.pattern}/`;return}}catch{}}}function $t(t,e){let s=typeof e=="number"?e:parseFloat(String(e));if(isNaN(s))return String(e);let n=t.match(/^%\.(\d+)f$/);if(n)return s.toFixed(parseInt(n[1],10));let c=t.match(/^%0(\d+)d$/);if(c)return String(Math.round(s)).padStart(parseInt(c[1],10),"0");let u=t.match(/^%(\d+)d$/);return u?String(Math.round(s)).padStart(parseInt(u[1],10)):t==="%e"?s.toExponential():String(e)}function It(t,e){if(!M)return null;try{let s=M.readFileSync(t,"utf-8");for(let n of s.split(/\r?\n/))if(n.startsWith(e+" "))return n.substring(e.length+1)}catch{}return null}function Nt(t,e,s){if(!M)return;let n=[];try{n=M.readFileSync(t,"utf-8").split(/\r?\n/)}catch{}let c=`${e} ${s}`,u=n.findIndex(o=>o.startsWith(e+" "));u!==-1?n[u]=c:n.push(c);try{M.writeFileSync(t,n.filter(Boolean).join(`
6
6
  `)+`
7
- `,"utf-8")}catch{}}function at(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Rt(t,e,s){let r=p=>p.split(".").map(o=>parseInt(o,10)||0),a=r(t),u=r(s),l=Math.max(a.length,u.length),n=0;for(let p=0;p<l;p++){let o=a[p]??0,O=u[p]??0;if(o!==O){n=o>O?1:-1;break}}switch(e){case">=":return n>=0;case"<=":return n<=0;case">":return n>0;case"<":return n<0;case"==":case"=":return n===0;case"!=":return n!==0;default:return!1}}function _t(t,e,s){if(s==="json")try{let r=JSON.parse(t);return e.split(".").reduce((a,u)=>a?.[u],r)??null}catch{return null}try{let{root:r}=R(t);return M(r,e)??null}catch{return null}}function ut(t,e){let s=" ".repeat(e);if(t==null)return`${s}null
7
+ `,"utf-8")}catch{}}function ft(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function kt(t,e,s){let n=p=>p.split(".").map(i=>parseInt(i,10)||0),c=n(t),u=n(s),o=Math.max(c.length,u.length),r=0;for(let p=0;p<o;p++){let i=c[p]??0,x=u[p]??0;if(i!==x){r=i>x?1:-1;break}}switch(e){case">=":return r>=0;case"<=":return r<=0;case">":return r>0;case"<":return r<0;case"==":case"=":return r===0;case"!=":return r!==0;default:return!1}}function Rt(t,e,s){if(s==="json")try{let n=JSON.parse(t);return e.split(".").reduce((c,u)=>c?.[u],n)??null}catch{return null}try{let{root:n}=v(t);return E(n,e)??null}catch{return null}}function pt(t,e){let s=" ".repeat(e);if(t==null)return`${s}null
8
8
  `;if(typeof t=="boolean"||typeof t=="number")return`${s}${t}
9
9
  `;if(typeof t=="string")return`${s}${t}
10
- `;if(Array.isArray(t)){let r="";for(let a of t)r+=`${s} - ${String(a)}
11
- `;return r}if(typeof t=="object"){let r="";for(let[a,u]of Object.entries(t))if(a!=="__synx")if(u&&typeof u=="object"&&!Array.isArray(u))r+=`${s}${a}
12
- `,r+=ut(u,e+2);else if(Array.isArray(u)){r+=`${s}${a}
13
- `;for(let l of u)r+=`${s} - ${String(l)}
14
- `}else r+=`${s}${a} ${u??"null"}
15
- `;return r}return`${s}${String(t)}
16
- `}function ct(t){return t==="true"?!0:t==="false"?!1:t==="null"?null:/^-?\d+$/.test(t)?parseInt(t,10):/^-?\d+\.\d+$/.test(t)?parseFloat(t):t}var It={space:" ",pipe:"|",dash:"-",dot:".",semi:";",tab:" ",slash:"/"};function ot(t){return It[t]||t}function vt(t,e){let s=[...e];if(s.length<t.length){let l=s.reduce((p,o)=>p+o,0),n=l<100?(100-l)/(t.length-s.length):l/s.length;for(;s.length<t.length;)s.push(n)}let r=s.reduce((l,n)=>l+n,0);if(r<=0)return t[Math.floor(Math.random()*t.length)];let a=Math.random(),u=0;for(let l=0;l<t.length;l++)if(u+=s[l]/r,a<=u)return t[l];return t[t.length-1]}function lt(t){return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95}function Pt(t,e,s){let r=e.length,a=t.length,u="",l=0;for(;l<=a-r;){if(t.slice(l,l+r)===e){let n=l===0||!lt(t.charCodeAt(l-1)),p=l+r>=a||!lt(t.charCodeAt(l+r));if(n&&p){u+=s,l+=r;continue}}u+=t[l++]}for(;l<a;)u+=t[l++];return u}function Tt(t,e){let s=[...e.entries()].sort((a,u)=>u[0].length-a[0].length),r=t;for(let[a,u]of s)r=Pt(r,a,u);return r}function Dt(t,e,s){let r=Date.now(),a=s*1e3,u=W.get(t)??[],l=u.filter(n=>r-n<=a);return l.length>=e?(W.set(t,l),!1):(l.length===0&&u.length>0&&W.delete(t),l.push(r),W.set(t,l),!0)}function M(t,e){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];let s=e.split("."),r=t;for(let a of s){if(r==null||typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,a))return;r=r[a]}return r}var z=class extends Error{constructor(e){super(e),this.name="SynxError";let s=e.indexOf(":");this.code=s!==-1?e.slice(0,s):"SYNX_ERR"}};var H=class{static parse(e,s={}){let{root:r,mode:a}=R(e);return a==="active"&&_(r,s),r}static stringify(e,s=!1){let r="";return s&&(r+=`!active
17
- `),r+=ft(e,0),r}};function ft(t,e){let s="",r=" ".repeat(e);for(let[a,u]of Object.entries(t))if(Array.isArray(u)){s+=`${r}${a}
18
- `;for(let l of u)if(l&&typeof l=="object"&&!Array.isArray(l)){let n=Object.entries(l);if(n.length>0){let[p,o]=n[0];s+=`${r} - ${p} ${o}
19
- `;for(let O=1;O<n.length;O++)s+=`${r} ${n[O][0]} ${n[O][1]}
20
- `}}else s+=`${r} - ${l}
21
- `}else if(u&&typeof u=="object")s+=`${r}${a}
22
- `,s+=ft(u,e+2);else if(typeof u=="string"&&u.includes(`
23
- `)){s+=`${r}${a} |
24
- `;for(let l of u.split(`
25
- `))s+=`${r} ${l}
26
- `}else s+=`${r}${a} ${u}
27
- `;return s}var Vt=H;return St(Lt);})();
10
+ `;if(Array.isArray(t)){let n="";for(let c of t)n+=`${s} - ${String(c)}
11
+ `;return n}if(typeof t=="object"){let n="",c=t,u=Object.keys(c).filter(o=>o!=="__synx").sort();for(let o of u){let r=c[o];if(r&&typeof r=="object"&&!Array.isArray(r))n+=`${s}${o}
12
+ `,n+=pt(r,e+2);else if(Array.isArray(r)){n+=`${s}${o}
13
+ `;for(let p of r)n+=`${s} - ${String(p)}
14
+ `}else n+=`${s}${o} ${r??"null"}
15
+ `}return n}return`${s}${String(t)}
16
+ `}function X(t){return t==="true"?!0:t==="false"?!1:t==="null"?null:/^-?\d+$/.test(t)?parseInt(t,10):/^-?\d+\.\d+$/.test(t)?parseFloat(t):t}function Tt(t,e){let s=Math.abs(e),n=s%10,c=s%100;switch(t){case"ru":case"uk":case"be":case"pl":return n===1&&c!==11?"one":n>=2&&n<=4&&!(c>=12&&c<=14)?"few":"many";case"cs":case"sk":return s===1?"one":s>=2&&s<=4?"few":"other";case"ar":return s===0?"zero":s===1?"one":s===2?"two":c>=3&&c<=10?"few":c>=11&&c<=99?"many":"other";case"fr":case"pt":return s<=1?"one":"other";case"ja":case"zh":case"ko":case"vi":case"th":return"other";default:return s===1?"one":"other"}}var vt={space:" ",pipe:"|",dash:"-",dot:".",semi:";",tab:" ",slash:"/"};function dt(t){return vt[t]||t}function Pt(t,e){let s=[...e];if(s.length<t.length){let o=s.reduce((p,i)=>p+i,0),r=o<100?(100-o)/(t.length-s.length):o/s.length;for(;s.length<t.length;)s.push(r)}let n=s.reduce((o,r)=>o+r,0);if(n<=0)return t[Math.floor(Math.random()*t.length)];let c=Math.random(),u=0;for(let o=0;o<t.length;o++)if(u+=s[o]/n,c<=u)return t[o];return t[t.length-1]}function J(t){return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95}function Vt(t,e,s){let n=e.length,c=t.length,u="",o=0;for(;o<=c-n;){if(t.slice(o,o+n)===e){let r=o===0||!J(t.charCodeAt(o-1)),p=o+n>=c||!J(t.charCodeAt(o+n));if(r&&p){u+=s,o+=n;continue}}u+=t[o++]}for(;o<c;)u+=t[o++];return u}function Lt(t,e){let s=[...e.entries()].sort((c,u)=>u[0].length-c[0].length),n=t;for(let[c,u]of s)n=Vt(n,c,u);return n}function Dt(t,e){let s="",n=0,c=t.length;for(;n<c;){let u=t.charCodeAt(n);if(J(u)){let o=n,r=!1;for(;n<c;){let i=t.charCodeAt(n);if(J(i))n++;else if(i===46)r=!0,n++;else break}let p=t.substring(o,n);if(r&&p.indexOf(".")!==-1){let i=E(e,p);if(typeof i=="number"){s+=String(i);continue}}s+=p}else s+=t[n],n++}return s}function Xt(t,e,s){let n=Date.now(),c=s*1e3,u=K.get(t)??[],o=u.filter(r=>n-r<=c);return o.length>=e?(K.set(t,o),!1):(o.length===0&&u.length>0&&K.delete(t),o.push(n),K.set(t,o),!0)}function E(t,e){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];let s=e.split("."),n=t;for(let c of s){if(n==null||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,c))return;n=n[c]}return n}var Z=class extends Error{constructor(e){super(e),this.name="SynxError";let s=e.indexOf(":");this.code=s!==-1?e.slice(0,s):"SYNX_ERR"}};var Q=class{static parse(e,s={}){let{root:n,mode:c}=v(e);return c==="active"&&P(n,s),n}static stringify(e,s=!1){let n="";return s&&(n+=`!active
17
+ `),n+=yt(e,0),n}};function yt(t,e){let s="",n=" ".repeat(e);for(let[c,u]of Object.entries(t))if(Array.isArray(u)){s+=`${n}${c}
18
+ `;for(let o of u)if(o&&typeof o=="object"&&!Array.isArray(o)){let r=Object.entries(o);if(r.length>0){let[p,i]=r[0];s+=`${n} - ${p} ${i}
19
+ `;for(let x=1;x<r.length;x++)s+=`${n} ${r[x][0]} ${r[x][1]}
20
+ `}}else s+=`${n} - ${o}
21
+ `}else if(u&&typeof u=="object")s+=`${n}${c}
22
+ `,s+=yt(u,e+2);else if(typeof u=="string"&&u.includes(`
23
+ `)){s+=`${n}${c} |
24
+ `;for(let o of u.split(`
25
+ `))s+=`${n} ${o}
26
+ `}else s+=`${n}${c} ${u}
27
+ `;return s}var Ut=Q;return At(Ft);})();
28
28
  if(typeof window!=="undefined")window.Synx=SynxModule.default;
29
29
  //# sourceMappingURL=synx.browser.js.map