text: (()=>{var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};(()=>{"use strict";e.r(t),e.d(t,{functionInvoker:()=>Pr,invoker:()=>Er,parensRx:()=>wr});var r={};e.r(r),e.d(r,{abs:()=>S,acos:()=>W,asin:()=>K,atan:()=>U,ceil:()=>J,charCode:()=>I,codeChar:()=>M,concat:()=>b,cos:()=>F,cosh:()=>V,ends:()=>y,flat:()=>h,floor:()=>G,getTimeMs:()=>N,has:()=>m,isArray:()=>u,isNum:()=>i,len:()=>o,log10:()=>te,log2:()=>ee,logn:()=>Z,lowerCase:()=>k,max:()=>T,min:()=>O,objKeys:()=>H,padEnd:()=>B,push:()=>g,randInt:()=>D,randNum:()=>j,range:()=>q,replace:()=>x,reverse:()=>C,round:()=>Y,sign:()=>Q,sin:()=>_,sinh:()=>L,slen:()=>c,slice:()=>a,sortBy:()=>A,splice:()=>s,sqrt:()=>X,starts:()=>f,strIdx:()=>p,sub:()=>v,subIdx:()=>d,substr:()=>l,tan:()=>R,tanh:()=>z,toNum:()=>n,trim:()=>w,trimEnd:()=>P,trimStart:()=>E,upperCase:()=>$});const n=e=>Number(e),a=(e,t,r)=>e.slice(t,r),s=(e,t,r)=>e.splice(t,r),o=e=>e.length,c=e=>e.length,i=e=>""!==e&&!Number.isNaN(Number(e)),u=e=>Array.isArray(e),l=(e,t,r)=>e.substring(t,t+(r??e.length)),p=(e,t)=>e[t],v=(e,t)=>e.includes(t),d=(e,t)=>e.indexOf(t),m=(e,t)=>e.includes(t),f=(e,t)=>e.startsWith(t),y=(e,t)=>e.endsWith(t),x=(e,t,r)=>e.replace(new RegExp(t,"g"),r),h=e=>e.flat(),b=(e,t)=>e.concat(t),g=(e,t)=>e.push(...t),A=(e,t)=>e.sort(t),C=e=>e.reverse(),k=e=>e.toLowerCase(),$=e=>e.toUpperCase(),w=e=>e.trim(),E=e=>e.trimStart(),P=e=>e.trimEnd(),B=(e,t)=>e.padEnd(t),I=e=>e.charCodeAt(0),M=e=>String.fromCharCode(e),j=(e,t)=>e+Math.random()*(t-e),D=(e,t)=>Math.floor(j(e,t)),q=e=>[...Array(e).keys()],H=e=>Object.keys(e),N=()=>(new Date).getTime(),S=Math.abs,O=Math.min,T=Math.max,_=Math.sin,F=Math.cos,R=Math.tan,L=Math.sinh,V=Math.cosh,z=Math.tanh,K=Math.asin,W=Math.acos,U=Math.atan,X=Math.sqrt,Y=Math.round,G=Math.floor,J=Math.ceil,Q=Math.sign,Z=Math.log,ee=Math.log2,te=Math.log10,re={print:{returns:["null"]},"print-str":{returns:["null"]},"!":{exactArity:1,returns:["bool"]},"=":{minArity:2,returns:["bool"]},"!=":{minArity:2,returns:["bool"]},"+":{minArity:2,numeric:!0},"-":{minArity:1,numeric:!0},"*":{minArity:2,numeric:!0},"/":{minArity:2,numeric:!0},"//":{minArity:2,numeric:!0},"**":{minArity:1,maxArity:2,numeric:!0},"<":{minArity:2,numeric:!0},">":{minArity:2,numeric:!0},"<=":{minArity:2,numeric:!0},">=":{minArity:2,numeric:!0},"fast=":{exactArity:2},"fast!=":{exactArity:2},"fast+":{exactArity:2,numeric:!0},"fast-":{exactArity:2,numeric:!0},"fast*":{exactArity:2,numeric:!0},"fast/":{exactArity:2,numeric:!0},"fast//":{exactArity:2,numeric:!0},"fast<":{exactArity:2,numeric:!0},"fast>":{exactArity:2,numeric:!0},"fast<=":{exactArity:2,numeric:!0},"fast>=":{exactArity:2,numeric:!0},inc:{exactArity:1,numeric:!0},dec:{exactArity:1,numeric:!0},min:{minArity:2,numeric:!0},max:{minArity:2,numeric:!0},abs:{exactArity:1,numeric:!0},sqrt:{exactArity:1,numeric:!0},round:{minArity:1,maxArity:2,numeric:!0},floor:{exactArity:1,numeric:!0},ceil:{exactArity:1,numeric:!0},logn:{exactArity:1,numeric:!0},log2:{exactArity:1,numeric:!0},log10:{exactArity:1,numeric:!0},and:{minArity:1},or:{minArity:1},xor:{exactArity:2},"&":{exactArity:2,numeric:!0},"|":{exactArity:2,numeric:!0},"^":{exactArity:2,numeric:!0},"~":{exactArity:1,numeric:!0},"<<":{exactArity:2,numeric:!0},">>":{exactArity:2,numeric:!0},">>>":{exactArity:2,numeric:!0},"odd?":{exactArity:1,numeric:"in only",returns:["bool"]},"even?":{exactArity:1,numeric:"in only",returns:["bool"]},"pos?":{exactArity:1,numeric:"in only",returns:["bool"]},"neg?":{exactArity:1,numeric:"in only",returns:["bool"]},"zero?":{exactArity:1,numeric:"in only",returns:["bool"]},"null?":{exactArity:1,returns:["bool"]},"num?":{exactArity:1,returns:["bool"]},"bool?":{exactArity:1,returns:["bool"]},"str?":{exactArity:1,returns:["bool"]},"vec?":{exactArity:1,returns:["bool"]},"dict?":{exactArity:1,returns:["bool"]},"key?":{exactArity:1,returns:["bool"]},"func?":{exactArity:1,returns:["bool"]},"wild?":{exactArity:1,returns:["bool"]},"ext?":{exactArity:1,returns:["bool"]},"type-of":{exactArity:1,returns:["str"]},rem:{minArity:2,numeric:!0},sin:{exactArity:1,numeric:!0},cos:{exactArity:1,numeric:!0},tan:{exactArity:1,numeric:!0},asin:{exactArity:1,numeric:!0},acos:{exactArity:1,numeric:!0},atan:{exactArity:1,numeric:!0},sinh:{exactArity:1,numeric:!0},cosh:{exactArity:1,numeric:!0},tanh:{exactArity:1,numeric:!0},vec:{returns:["vec"]},dict:{returns:["dict"]},len:{exactArity:1,params:[["str","vec","dict"]],returns:["num"]},"to-num":{exactArity:1,params:[["str","num"]],returns:["num","null"]},"to-key":{exactArity:1,params:[["str","num"]],returns:["key"]},"to-vec":{exactArity:1,params:[["str","dict"]],returns:["vec"]},"substr?":{exactArity:2,params:["str","str"],returns:["bool"]},idx:{exactArity:2,params:["any",["str","vec"]],returns:["num"]},"set-at":{exactArity:3,params:["vec","any",["vec","dict"]],returns:["vec","dict"]},map:{minArity:2,returns:["vec"]},for:{minArity:2,returns:["vec"]},reduce:{minArity:2,maxArity:3},filter:{minArity:2,params:["any",["vec","dict","str"]],returns:["vec","str","dict"]},remove:{minArity:2,params:["any",["vec","dict","str"]],returns:["vec","str","dict"]},find:{minArity:2,params:["any",["vec","dict","str"]]},count:{minArity:2,params:["any",["vec","dict","str"]],returns:["num"]},repeat:{minArity:2,params:["any","num"]},"->":{minArity:2},str:{returns:["str"]},rand:{maxArity:2,numeric:!0,returns:["num"]},"rand-int":{maxArity:2,numeric:!0,returns:["num"]},".":{minArity:1},"..":{minArity:2},"...":{minArity:2},into:{exactArity:2,params:[["vec","dict"],["vec","dict"]],returns:["vec","dict"]},assoc:{exactArity:3,params:["any","any","dict"],returns:["dict"]},omit:{exactArity:2,params:["any","dict"],returns:["dict"]},insert:{exactArity:3,params:["any","num","vec"],returns:["vec"]},append:{exactArity:2,params:["any","vec"],returns:["vec"]},prepend:{exactArity:2,params:["any","vec"],returns:["vec"]},sect:{minArity:1,maxArity:3,params:[["vec","str"],"num","num"],returns:["vec","str"]},reverse:{exactArity:1,params:[["vec","str"]],returns:["vec","str"]},flatten:{exactArity:1,params:["vec"],returns:["vec"]},shuffle:{exactArity:1,params:["vec"],returns:["vec"]},sort:{exactArity:1,params:[["vec","str"]],returns:["vec"]},"sort-by":{exactArity:2,params:["any",["vec","dict","str"]],returns:["vec"]},distinct:{returns:["vec"]},"group-by":{exactArity:2,params:["any",["vec","dict","str"]],returns:["dict"]},"part-by":{exactArity:2,params:["any",["vec","dict","str"]],returns:["vec"]},frequencies:{exactArity:1,params:[["vec","str"]],returns:["dict"]},keys:{exactArity:1,params:["dict"]},vals:{exactArity:1,params:["dict"]},do:{minArity:1},val:{minArity:1},range:{minArity:1,maxArity:3,numeric:"in only",returns:["vec"]},"empty?":{exactArity:1,params:[["str","vec","dict"]],returns:["bool"]},split:{exactArity:2,params:["str","str"],returns:["vec"]},join:{exactArity:2,params:["str",["vec","dict","str"]],returns:["str"]},replace:{exactArity:3,params:["str","str","str"],returns:["str"]},"starts?":{exactArity:2,params:["str","str"],returns:["bool"]},"ends?":{exactArity:2,params:["str","str"],returns:["bool"]},"lower-case":{exactArity:1,params:["str"],returns:["str"]},"upper-case":{exactArity:1,params:["str"],returns:["str"]},trim:{exactArity:1,params:["str"],returns:["str"]},"trim-start":{exactArity:1,params:["str"],returns:["str"]},"trim-end":{exactArity:1,params:["str"],returns:["str"]},"str*":{exactArity:2,params:["str","num"],returns:["str"]},"char-code":{minArity:1,maxArity:2,params:[["str","num"],"num"],returns:["str","num","null"]},time:{exactArity:0,returns:["num"]},version:{exactArity:0,returns:["num"]},tests:{minArity:0,maxArity:1,params:["bool"],returns:["str"]},symbols:{exactArity:0,returns:["vec"]},eval:{exactArity:1,params:["str"]},about:{exactArity:1,params:[["str","func"]],returns:["dict"]},reset:{exactArity:0},recur:{}},ne=["function","fn","var","let","var!","let!","return","if","if!","when","unless","while","loop","match","catch"],ae={null:"null",str:"string",num:"number",bool:"boolean",key:"keyword",ref:"reference",vec:"vector",dict:"dictionary",func:"function",clo:"closure",wild:"wildcard",ext:"external"},se=e=>"bool"===e.t?e.v:"null"!==e.t;function oe(e,t,r){const{exactArity:n,maxArity:a,minArity:s}=re[e],o=(n,a)=>[{e:"Arity",m:`${e} needs ${n} argument${1!==a?"s":""}, not ${t}`,errCtx:r}];if(void 0!==n){if(t!==n)return o(`exactly ${n}`,n)}else{if(s&&!a&&t<s)return o(`at least ${s}`,s);if(!s&&a&&t>a)return o(`at most ${a}`,a);if(s&&a&&(t<s||t>a))return o(`between ${s} and ${a}`,a)}}function ce(e,t,r,n=!1){const{params:a,numeric:s}=re[e],c=o(t);if(s){const a=t.findIndex((e=>!!o(e)&&(n?!e.find((e=>"num"===e)):"num"!==e[0])));if(-1===a)return;const s=t[a].map((e=>ae[e])).join(", ");return[ie(`${e} takes numeric arguments only, not ${s}`,r)]}if(!a)return;const i=a.map(((e,r)=>{if(r>=c||!t[r]||"any"===e)return!1;const a=t[r];if(u(e)){if(n?!o(a)||a.some((t=>m(e,t))):1===o(a)&&m(e,a[0]))return!1;const t=a.map((e=>ae[e]));return`argument ${r+1} must be either: ${e.map((e=>ae[e])).join(", ")}, not ${t}`}{if(n?!o(a)||m(a,e):1===o(a)&&e===a[0])return!1;const t=a.map((e=>ae[e]));return`argument ${r+1} must be ${ae[e]}, not ${t}`}})).filter((e=>!!e));return o(i)?i.map((e=>ie(e,r))):void 0}const ie=(e,t)=>({e:"Type",m:e,errCtx:t});function ue(e,t){const r=t.map((e=>ae[e])).join(", ");return[ie(`number as operation argument must be string, vector, or dictionary, not ${r}`,e)]}function le(e,t){const r=t.map((e=>ae[e])).join(", ");return[ie(`keyword as operation argument must be dictionary or vector, not ${r}`,e)]}function pe(e,t,r){const n=[],a=[],s=t;for(let e=0,t=o(r);e<t;++e){const o=r[e];let c=!1;"clo"!==o.typ?("let"===o.typ||"var"===o.typ?s.push(o.value):de(s,o,e+1!==t&&r[e+1])&&(a.push(o),c=!0),n.push(c)):e+=o.value.length}return{name:e,length:o(r),captures:n,derefs:a}}function ve({name:e,length:t,captures:r,derefs:n},s,o){const c=[],i=n.map((e=>e.errCtx));for(let e=0,n=0;e<t;++e){const t=s[e];"clo"===t.typ?(g(c,a(s,e,e+1+t.value.length)),e+=t.value.length):r[n++]?c.push({typ:"val",value:o.shift(),errCtx:i.shift()}):c.push(t)}return{name:e,ins:c}}function de(e,t,r){return r&&"val"===t.typ&&"str"===t.value.t&&"exe"===r.typ||"npa"===t.typ&&!m(e,t.text)||"ref"===t.typ&&!m(e,t.value)}const{has:me,flat:fe,push:ye,slice:xe,splice:he}=r,{slen:be,starts:ge,sub:Ae,substr:Ce,strIdx:ke,subIdx:$e}=r,{isNum:we,len:Ee,toNum:Pe}=r,Be={t:"null",v:void 0},Ie={t:"bool",v:!1},Me=e=>!!e&&"errCtx"in e,je=(e,t=0)=>{if(Me(e))return"";const r=e[t];return Me(r)&&me(["sym","str"],r.typ)&&r.text||""};function De(e){const t=je(e,0),r=me(["#","@"],t);return r&&(e=xe(e,1)),`${r?t:""}(${e.map((e=>Me(e)?(({typ:e,text:t})=>"str"===e?`"${t}"`:t)(e):De(e))).join(" ")})`}const qe=e=>{if(1===Ee(e))return fe(e);const t=e[Ee(e)-1],r=xe(e,0,Ee(e)-1),n={typ:"pop",value:Ee(r),errCtx:t[0].errCtx};return fe([...r,[n],t])},He=(e,t)=>Me(e)?Se(e,t):Ne(e,t);function Ne(e,t,r=!0){if(!Ee(e))return[];const n=e=>He(e,t);let a=e.shift(),s=n(a);const{errCtx:o}=s[0];if(Me(a)&&"sym"===a.typ){if(a.text in re){const{exactArity:t,minArity:r}=re[a.text],n=t??r;n&&1!==n&&Ee(e)+1===n&&(e.unshift(a),a={typ:"sym",text:"@",errCtx:a.errCtx})}me(["var","let"],a.text)&&Ee(e)&&Ee(e)%2&&(e.unshift(a),e.push({typ:"sym",text:"%",errCtx:a.errCtx}),a={typ:"sym",text:"#",errCtx:a.errCtx});const{text:o,errCtx:c}=a,i=(e,t=c)=>[{typ:"err",value:e,errCtx:t}];if(me(["if","if!","when","unless","match"],o)&&!Ee(e))return i("provide a condition");if(me(["if","if!"],o)){if(1===Ee(e))return i("provide at least one branch");if(Ee(e)>3)return i(`provide one or two branches, not ${Ee(e)}`);const t=e.map(n),[r,a]=t;let s=t[2];return s||(s=[{typ:"val",value:Be,errCtx:c}]),[...r,..."if!"===o&&[{typ:"val",value:{t:"func",v:"!"},errCtx:c},{typ:"exe",value:1,errCtx:c}]||[],{typ:"if",value:Ee(a)+1,errCtx:c},...a,{typ:"jmp",value:Ee(s),errCtx:c},...s]}if("when"===o||"unless"===o){if(1===Ee(e))return i("provide a body");const t=e.map(n),[r,a]=[t[0],xe(t,1)],s=qe(a);return[...r,..."unless"===o?[{typ:"val",value:{t:"func",v:"!"}},{typ:"exe",value:1}]:[],{typ:"if",value:Ee(s)+1,errCtx:c},...s,{typ:"jmp",value:1,errCtx:c},{typ:"val",value:Be,errCtx:c}]}if("match"===o){const t=e.map(n),[r,a]=[t[0],xe(t,1)],s=Ee(a)%2?a.pop():[];if(!Ee(a))return i("provide at least one case");const o=Ee(s);let u=a.reduce(((e,t)=>e+Ee(t)),0)+(o||2)+Ee(a);const l=r;for(;Ee(a)>1;){const[e,t]=[a.shift(),a.shift()];ye(l,e),l.push({typ:"mat",value:Ee(t)+1,errCtx:c}),ye(l,t),u-=Ee(e)+Ee(t)+2,l.push({typ:"jmp",value:u,errCtx:c})}return Ee(s)?ye(l,s):(l.push({typ:"pop",value:1,errCtx:c}),l.push({typ:"val",value:Ie,errCtx:c})),l}if("catch"===o){if(Ee(e)<2)return i("provide at least 2 arguments");const t=n(e.pop());return[...fe(e.map(n)),{typ:"cat",value:Ee(t),errCtx:c},...t]}if("and"===o||"or"===o||"while"===o){const t=e.map(n);if(Ee(t)<2)return i("provide at least 2 arguments");const r=[];if("while"===o){const[e,n]=[t[0],xe(t,1)],a=qe(n),s=Ee(a)+2,o=-(Ee(e)+Ee(a)+3);return r.push({typ:"val",value:Be,errCtx:c}),ye(r,e),r.push({typ:"if",value:s,errCtx:c}),r.push({typ:"pop",value:1,errCtx:c}),ye(r,a),r.push({typ:"loo",value:o,errCtx:c}),r}let a=t.reduce(((e,t)=>e+Ee(t)),0);a+=Ee(t),a+=Pe("and"===o);const s="and"===o?"if":"or";for(let e=0;e<Ee(t);++e)ye(r,t[e]),a-=Ee(t[e]),r.push({typ:s,value:a,errCtx:c}),--a;return"and"===o&&ye(r,[{typ:"val",value:{t:"bool",v:!0},errCtx:c},{typ:"jmp",value:1,errCtx:c}]),r.push({typ:"val",value:Ie,errCtx:c}),r}if("loop"===o){if(Ee(e)<3)return i("provide at least 3 arguments");const t=e.map(n),r=e[1],a=qe(xe(t,2));return Me(r)?[{typ:"val",value:{t:"num",v:0},errCtx:c},{typ:"let",value:r.text,errCtx:c},...t[0],{typ:"let",value:r.text+"-limit",errCtx:c},{typ:"pop",value:1,errCtx:c},...a,{typ:"ref",value:r.text,errCtx:c},{typ:"val",value:{t:"func",v:"inc"},errCtx:c},{typ:"exe",value:1,errCtx:c},{typ:"let",value:r.text,errCtx:c},{typ:"ref",value:r.text+"-limit",errCtx:c},{typ:"val",value:{t:"func",v:"<"},errCtx:c},{typ:"exe",value:2,errCtx:c},{typ:"if",value:2,errCtx:c},{typ:"pop",value:1,errCtx:c},{typ:"loo",value:-(Ee(a)+10),errCtx:c}]:i("argument 2 must be symbol")}if("var"===o||"let"===o){const r=e.filter(((e,t)=>!(t%2))),a=e.filter(((e,t)=>!!(t%2)));if(!Ee(r))return i("provide at least 1 declaration name and value");if(Ee(r)>Ee(a))return i("provide a value after each declaration name");const s=[],u=`${o} name must be a new symbol or destructuring`;for(let e=0,l=Ee(r);e<l;++e){ye(s,n(a[e]));const l=r[e];if(Me(l)){const n=He(r[e],t);if(Ee(n)>1||"ref"!==n[0].typ)return i(u,n[0].errCtx);s.push({typ:o,value:n[0].value,errCtx:c})}else{const{shape:e,errors:t}=Oe([l],!0);if(Ee(t))return t;if(!Ee(e))return i(u);const r="var"===o?"dva":"dle";s.push({typ:r,value:e,errCtx:c})}}return s}if("var!"===o||"let!"===o){if(Ee(e)<2)return i("provide 1 declaration name and 1 function");const t=e.map(n),[r,a,s]=[t[0][0],t[1],xe(t,2)];if("ref"!==r.typ)return i("declaration name must be symbol",r.errCtx);const u=[{typ:"ref",value:r.value,errCtx:c}];ye(u,[...fe(s),...a]),u.push({typ:"exe",value:Ee(s)+1,errCtx:c});const l="var!"===o?"var":"let";return u.push({typ:l,value:r.value,errCtx:c}),u}if("#"===o||"@"===o||"fn"===o){const r=[],n=De([a,...e]),s=[];let u=!1;if("fn"===o){const n=Oe(e,!1);if(ye(s,n.shape.map((e=>e.name))),t=n.shape,ye(r,n.errors),!Ee(e))return i("provide a body");u=1===Ee(e),e.unshift({typ:"sym",text:"do",errCtx:c})}if("@"===o){const t=je(e,0);if(me(ne,t)){const{errCtx:r}=e[0];return i(`"${t}" syntax unavailable in partial closure`,r)}e=[{typ:"sym",text:"...",errCtx:c},...e,{typ:"sym",text:"args",errCtx:c}]}ye(r,Ne(e,t,"@"!==o));const l=r.filter((e=>"err"!==e.typ)),p=r.filter((e=>"err"===e.typ));return Ee(p)?p:(u&&(l.pop(),l.pop()),[{typ:"clo",value:pe(n,s,l),errCtx:c},...l])}if(re[o]&&r){const t=oe(o,Ee(e),c),r=(e,t=c)=>[{typ:"err",value:e,errCtx:t}];ye(s,t?.map((e=>r(e.m)[0]))??[]),t||2===Ee(e)&&re[`fast${o}`]&&(s=n({typ:"sym",text:`fast${o}`,errCtx:c}))}}const c=e.map(n),i=fe(c);if("return"===je([a]))return[...i,{typ:"ret",value:!!Ee(c),errCtx:o}];if("ref"===s[0].typ){const{value:e,errCtx:t}=s[0];s[0]={typ:"val",value:{t:"str",v:e},errCtx:t}}ye(i,s);const u=Ee(s)>1||me(["npa","upa"],s[0].typ)?"exa":"exe";return[...i,{typ:u,value:Ee(c),errCtx:o}]}function Se(e,t){if(Me(e)){const{errCtx:r}=e;if("str"===e.typ)return[{typ:"val",value:{t:"str",v:e.text},errCtx:r}];if("num"===e.typ)return[{typ:"val",value:{t:"num",v:Pe(e.text)},errCtx:r}];if("sym"===e.typ){const{text:n}=e,a=t.map((({name:e})=>e));if("true"===n||"false"===n)return[{typ:"val",value:{t:"bool",v:"true"===n},errCtx:r}];if("null"===n)return[{typ:"val",value:Be,errCtx:r}];if("_"===n)return[{typ:"val",value:{t:"wild",v:void 0},errCtx:r}];if(ge(n,":"))return[{typ:"val",value:{t:"key",v:n},errCtx:r}];if("%"===n||ge(n,"%")&&we(Ce(n,1))){const e="%"===n?0:Pe(Ce(n,1));return e<0?[{typ:"val",value:Be,errCtx:r}]:[{typ:"upa",value:e,text:n,errCtx:r}]}if(me(a,n)){const e=t.find((({name:e})=>e===n));return 1===Ee(e.position)?[{typ:"npa",value:e.position[0],text:n,errCtx:r}]:[{typ:"dpa",value:e.position,errCtx:r}]}return"args"===n?[{typ:"upa",value:-1,text:"args",errCtx:r}]:"PI"===n||"E"===n?[{typ:"val",value:{t:"num",v:"PI"===n?3.141592653589793:2.718281828459045},errCtx:r}]:re[n]?[{typ:"val",value:{t:"func",v:n},errCtx:r}]:[{typ:"ref",value:n,errCtx:r}]}return[]}return Ee(e)?Ne(e,t):[]}function Oe(e,t,r=[]){const n=[],a=[];let s=0;for(;Ee(e)>(t?0:1)&&(Me(e[0])||"vec"===je(e[0]));){const t=e.shift();if(Me(t)){const{typ:e,errCtx:o}=t;"sym"===e?n.push({name:t.text,position:[...r,s]}):a.push({typ:"err",value:"provide parameter name",errCtx:o})}else{t.shift();const e=Oe(t,!0,[...r,s]);ye(n,e.shape),ye(a,e.errors)}++s}return{shape:n,errors:a}}function Te({name:e,nodes:t}){const{shape:r,errors:n}=Oe(t,!1),a=[...n,...fe(t.map((e=>Se(e,r))))];for(let e=0,t=Ee(a);e<t;e++){const{typ:t,value:r,errCtx:n}=a[e];if("err"===t)return{e:"Parse",m:r,errCtx:n}}return{name:e,ins:a}}function _e(e){const t=[];for(let r=0,n=Ee(e);r<n;++r){const n=e[r];switch(n.typ){case"val":t.push({types:[n.value.t],val:n.value});break;case"exa":case"exe":{const e=t.pop(),r=he(t,Ee(t)-n.value,n.value),a=e=>r.findIndex((({types:t})=>t&&!e.find((e=>me(t,e))))),s=t=>e.val?e.val.t===t:e.types&&1===Ee(e.types)&&e.types[0]===t;if(e.val&&"func"===e.val.t){if("recur"===e.val.v){he(t,Ee(t)-n.value,n.value);break}const a=ce(e.val.v,r.map((e=>e.types??[])),n.errCtx,!0);if(a)return a;const{returns:s,numeric:o}=re[e.val.v];t.push(o&&"in only"!==o?{types:["num"]}:{types:s})}else if(s("num")){const e=a(["str","dict","vec"]);if(-1!==e)return ue(n.errCtx,r[e].types);t.push({})}else if(s("key")){const e=a(["dict","vec"]);if(-1!==e)return le(n.errCtx,r[e].types);t.push({})}else s("str")||s("bool")?t.push({}):e.types||e.val||t.push({});break}case"or":t.pop(),t.push({}),r+=n.value;break;case"cat":case"var":case"let":case"dva":case"dle":case"loo":case"jmp":break;case"clo":{const a=_e(xe(e,r+1,r+n.value.length));if(a)return a;t.push({})}case"ref":case"npa":case"upa":case"dpa":t.push({});break;case"if":{t.pop(),t.push({});const a=_e(xe(e,r+1,n.value+1));if(a)return a;r+=n.value-1;break}case"mat":t.pop(),t.pop(),r+=n.value,r+=e[r].value,t.push({});break;case"pop":he(t,Ee(t)-n.value,n.value);break;case"ret":n.value&&t.pop()}}}function Fe(e,t){const{tokens:r,stringError:n}=function(e,t,r=!0,n=!1){const a=[],s=e=>Ae("0123456789",e);let[o,c,i,u]=[!1,1,0,[1,0]],[l,p,v]=[!1,!1,!1];for(let d=0,m=be(e);d<m;++d){const f=ke(e,d),y=d+1!==m?ke(e,d+1):"";if(++i,"\\"===f&&o){a[Ee(a)-1].text+=r?{n:"\n",t:"\t",r:"\r",'"':'"'}[y]||("\\"===y?"\\":`\\${y}`):`\\${y}`,++i,++d;continue}const x={invokeId:t,line:c,col:i};if('"'===f){(o=!o)&&(u=[c,i],a.push({typ:"str",text:"",errCtx:x})),p=l=!1;continue}const h=Ae(" \t\n\r,",f);if(!o&&h){l=!1,p&&(p=","===f),"\n"===f&&(++c,i=0);continue}if(!o&&";"===f){const t=$e(Ce(e,++d),"\n"),r=Ce(e,d,t>0?t:m-d);d+=be(r),++c,i=0,n&&a.push({typ:"rem",text:r,errCtx:x});continue}const b=Ae("()[]{}",f);if(p&&!s(f)){const e="x"===f&&"0"===a[Ee(a)-1].text;v=v||e,p="b"===f&&"0"===a[Ee(a)-1].text||"."===f&&!Ae(a[Ee(a)-1].text,".")||v&&(e||Ae("ABCDEFabcdef",f)),p||b||h||(l=!0,a[Ee(a)-1].typ="sym")}if(l&&b&&(l=!1),!o&&!l&&!p){if(b){const e=-1===$e("[{(",f)?")":"(";a.push({typ:e,text:r?e:f,errCtx:x}),!r||"["!==f&&"{"!==f||a.push({typ:"sym",text:"["===f?"vec":"dict",errCtx:x});continue}p=s(f)||"."===f&&s(y)||"-"===f&&(s(y)||"."===y),v=l=!p;const e=l?"sym":"num";a.push({typ:e,text:"",errCtx:x})}a[Ee(a)-1].text+=f}return{tokens:a,stringError:o?u:void 0}}(e,t),a=function(e,t){const r=Ee(t)?t[0].errCtx.invokeId:"",n=[],a=(e,t)=>n.push({e:"Parse",m:e,errCtx:t});if(e){const[t,s]=e;return a("unmatched double quotation marks",{invokeId:r,line:t,col:s}),n}const s=e=>Ee(t.filter((({typ:t})=>t===e))),[o,c]=[s("("),s(")")];{const[e,n]=function(e,t,r){const n=r>=t,[a,s]=[n?"(":")",n?")":"("],o=n?1:-1;for(let t=Ee(e),r=n?0:t-1,c=0;n?r<t:r>=0;r+=o){const{typ:t,errCtx:{line:n,col:o}}=e[r];if(c+=Pe(t===a)-Pe(t===s),c<0)return[n,o]}return[0,0]}(t,o,c);e+n&&a("unmatched parenthesis",{invokeId:r,line:e,col:n})}let i;for(let e=0,r=!1;e<Ee(t);++e){if(r&&")"===t[e].typ){i=t[e];break}r="("===t[e].typ}return i&&a("empty expression forbidden",i.errCtx),n}(n,r);if(Ee(a))return{errors:a,funcs:{}};const s=[],o=[],c=function(e){const t=[],r=e=>{let t;"sym"===e[0].typ&&Ae("@#",e[0].text)&&(t=e.shift());const n=e.shift();if("("!==n.typ&&")"!==n.typ)return n;const a=t?[t]:[];for(;")"!==e[0].typ;)a.push(r(e));return e.shift(),a};for(;Ee(e);)t.push(r(e));return t}(xe(r)),i=function(e){const t=[],r=[];return e.forEach((e=>{if(!Me(e)&&Me(e[0])&&"function"===je(e)){const r=je(e,1);r?Ee(e)<3&&t.push({err:"empty function body",errCtx:e[0].errCtx}):t.push({err:"nameless function",errCtx:e[0].errCtx}),t.push({name:r,nodes:xe(e,2)})}else r.push(e)})),Ee(r)&&t.push({name:"entry",nodes:r}),t}(c),u=[];i.forEach((e=>{"err"in e?o.push({e:"Parse",m:e.err,errCtx:e.errCtx}):u.push({name:e.name,nodes:e.nodes})})),u.map(Te).forEach((e=>{"e"in e?o.push(e):s.push(e)})),ye(o,fe(s.map((e=>_e(e.ins)??[]))));const l={};return s.forEach((e=>l[e.name??""]=e)),{errors:o,funcs:l}}function Re(e,t){return e.dict.has(t)?{kind:"val",value:e.dict.get(t)}:{kind:"err",err:`"${t}" not found.`}}function Le(e,t,r){e.dict.set(t,r)}function Ve(e,t,r){return"test.function"!==t?{kind:"err",err:`operation "${t}" does not exist`}:(e.output+=r[0].v+"\n",{kind:"val",value:{t:"null",v:void 0}})}const ze=[{name:"Hello, world!",code:'"Hello, world!"',out:"Hello, world!"},{name:"Say Hello, world!",code:';This is a test comment\n           (print "Hello, world!")',out:"Hello, world!\nnull"},{name:"1 + 1 = 2",code:"(+ 1 1)",out:"2"},{name:"Negate 1 = -1",code:"(- 1)",out:"-1"},{name:"(1+1)+1+(1+1) = 5",code:"(+ (+ 1 1) 1 (+ 1 1))",out:"5"},{name:"Conditional head",code:"((if true + -) 12 9 1)",out:"22"},{name:"when and unless",code:'[(when 123 (print "hi") 234) (unless true (print "bye"))]',out:"hi\n[234 null]"},{name:"match and wildcard",code:'(match [1 2]\n             [0 0] (print "hello")\n             [0 2] (print "bye")\n             [1 _] "hey")',out:"hey"},{name:"Cond number head",code:"((if false 1 2) [:a :b :c])",out:":c"},{name:"and & short-circuit",code:'[(and true (if true null 1) (print "hi")) (and 1 2 3)]',out:"[false true]"},{name:"or & short-circuit",code:'[(or true (print "hi") 1) (or false (print-str "-> ") 1)]',out:"-> [true 1]"},{name:"String retrieve",code:'(2 "Hello")',out:"l"},{name:"Vector retrieve",code:"(2 [:a :b :c :d])",out:":c"},{name:"Key as operation",code:'[(:age {:name "Patrick" :age 24}) (:abc [:a :abc :c])]',out:"[24 :abc]"},{name:"Dictionary as op 1",code:'({"name" "Patrick" "age" 24} "age")',out:"24"},{name:"Dictionary as op 2",code:'({"name" "Patrick"} "age" 24)',out:'{"name" "Patrick", "age" 24}'},{name:"Equalities",code:'[(= 1 2 1)\n            (!= 1 2 1)\n            (= "Hello" "hello")\n            (!= "world" "world")\n            (= [0 [1]] [0 [1]])]',out:"[false true false false true]"},{name:"Define and retrieve",code:"(var a 1) a",out:"1"},{name:"Define and add",code:"(var a 1) (inc a)",out:"2"},{name:"Define op and call",code:"(var f +) (f 2 2)",out:"4"},{name:"Define vec and call",code:"(var f [1]) (f 1)",out:"1"},{name:"Define num and call",code:"(var f 1) (f [:a :b :c])",out:":b"},{name:"Apply op to var",code:"(var a 10) (var! a + 10)",out:"20"},{name:"Apply op to let",code:"(let a 10) (let! a (if true + -) (+ 2 3) 5)",out:"20"},{name:"Print simple vector",code:"[1 2 3]",out:"[1 2 3]"},{name:"Boolean select",code:"[(true 1 2) (false 1)]",out:"[1 null]"},{name:"Sum vector of numbers",code:"[(reduce + [1 2 3]) (reduce + 3 [1 2 3])]",out:"[6 9]"},{name:"Sum vectors of numbers",code:"(map + [1 2 3] [1 2 3 4])",out:"[2 4 6]"},{name:"For XY list",code:"(for vec [0 1] [0 1])",out:"[[0 0] [1 0] [0 1] [1 1]]"},{name:"Filter by integer",code:'(filter 2 [[1] [:a :b :c] "hello" "hi"])',out:'[[:a :b :c] "hello"]'},{name:"Comments, short decimal",code:';((print "Hello")\n           .456',out:"0.456"},{name:"Dictionary into vector",code:"(into [1 2] {3 4 5 6})",out:"[1 2 [3 4] [5 6]]"},{name:"Vector into dictionary",code:"(into {[0] 1 [2] 3} [[0] 2])",out:"{[0] 2, [2] 3}"},{name:"While loop",code:"(var n 5)\n           (while (< 0 n)\n             (print-str n)\n             (var n (dec n)))",out:"543210"},{name:"Loop",code:"(loop 3 i (print-str i))",out:"012null"},{name:"Catch error",code:'(catch\n             (:e (catch (let a :a) (+ 1 a) (0 errors)))\n             (print "hi"))',out:"Type"},{name:"Define with no call",code:'(function func (print "Nothing."))'},{name:"Call greet func",code:'(function greeting (print "Hello!")) (greeting)',out:"Hello!\nnull"},{name:"Call const value func",code:"(function const 123) (const)",out:"123"},{name:"Call identity funcs",code:"(function id1 %)\n           (function id2 x x)\n           [(id1 123) (id2 456)]",out:"[123 456]"},{name:"Call greet with name",code:'(function greeting name (print "Hello, " name "!"))\n           (greeting "Patrick")',out:"Hello, Patrick!\nnull"},{name:"Call with too few args",code:"(function func a b c [a b c]) (func 1 2)",out:"[1 2 null]"},{name:"Define func and call",code:"(function func a b (+ a b)) (var f func) (f 2 2)",out:"4"},{name:"Anonymous parameters",code:"(function avg<n? (< (/ (.. + %) (len %)) %1))\n           (avg<n? [0 10 20 30 40] 5)",out:"false"},{name:"Call parameter",code:'(function f x (x "hello")) (f print)',out:"hello\nnull"},{name:"Let and retrieve",code:"(function f (let a 1) a) (f)",out:"1"},{name:"Let num op and call",code:"(function f (let n 0) (n [1])) (f)",out:"1"},{name:"Explicit return",code:"(function f (return 123) (print 456)) (f)",out:"123"},{name:"Closure 1",code:"(let x 10)\n           (let closure #(+ x x))\n           (let x 11)\n           (closure)",out:"20"},{name:"Closure 2",code:"(filter #(or (.. = args) (even? %)) (range 10) 5)",out:"[0 2 4 5 6 8]"},{name:"Closure 3",code:"(function f #(+ x x))\n           (var x 10) (let c20 (f))\n           (var x 20) (let c40 (f))\n           [(c20) (c40)]",out:"[20 40]"},{name:"Closure with ext func",code:"(#(test.function %) 1)",out:"1\nnull"},{name:"Func returns closure",code:"(function f x #(x 2 2))\n           (let closure (f +))\n           (closure)",out:"4"},{name:"Dictionary closure",code:"(function f x #{x 2})\n           (let closure (f :a))\n           (closure)",out:"{:a 2}"},{name:"Vector closure",code:"(function f x #[1 x %])\n           (let closure (f 2))\n           (closure 3)",out:"[1 2 3]"},{name:"Closure as head",code:"(#[% %1 %2] 1 2 3)",out:"[1 2 3]"},{name:"Partial closure 1",code:"(@[] 1 2 3)",out:"[1 2 3]"},{name:"Partial closure 2",code:"(@((do +) 2) 2)",out:"4"},{name:"Parameterised closure 1",code:"((fn a b (+ a b)) 2 2)",out:"4"},{name:"Parameterised closure 2",code:"((fn a b (print-str a b) (+ a b)) 2 2)",out:"224"},{name:"Parameterised closure 3",code:"(reduce\n             (fn primes num\n               (if (find zero? (map (rem num) primes))\n                 primes\n                 (append num primes)))\n             [2]\n             (range 3 10))",out:"[2 3 5 7]"},{name:"Closure with inter-lets",code:"(let a + c 5 d 10)\n           (let closure (fn b (let d 1) (a b c d)))\n           (let a - c 4 d 11)\n           (closure 1)",out:"7"},{name:"Closure with inner-let",code:"(((fn x (let y 1) #[x y]) 2))",out:"[2 1]"},{name:"Closure with captured f",code:"[((fn x (@(val x))) 0) (var f val) ((fn x (@(f x))) 0)]",out:"[0 val 0]"},{name:"Destructure var",code:"(var [x [y]] [1 [2]]) [y x]",out:"[2 1]"},{name:"Destructure string",code:'(let [a b c] "hello") [a b c]',out:'["h" "e" "l"]'},{name:"Destructure function",code:"(function f a [[b c] d] e [e d c b a]) (f 0 [[1 2] 3] 4)",out:"[4 3 2 1 0]"},{name:"Destructuring closure",code:"(let f (fn a [b [c]] d [d c b a])) (f 0 [1 [2]] 3)",out:"[3 2 1 0]"},{name:"Destructuring fn decoy",code:"(let f (fn a [a [a]])) (f 0)",out:"[0 [0]]"},{name:"Implicit currying",code:"(-> 1 inc (+ 10))",out:"12"},{name:"String instead of number",code:'(function sum (.. + args))\n           (print (sum 2 2))\n           (sum 2 "hi")',out:"4",err:["Type"]},{name:"Reference non-existing",code:"x",err:["Reference"]},{name:"Expired let retrieve",code:"(function f (let a 1) a) (f) a",err:["Reference"]},{name:"Call non-existing",code:"(x)",err:["External"]},{name:"Call budget",code:"(function f (f)) (f)",err:["Budget"]},{name:"Loop budget",code:"(var n 10000)\n           (while (< 0 n)\n             (var n (dec n)))",err:["Budget"]},{name:"Range budget",code:"(range 10000)",err:["Budget"]},{name:"Head exe arity check",code:"(((fn +)) 1)",err:["Arity"]},{name:"Fibonacci 13",code:"(function fib n\n             (if (< n 2) n\n               (+ (fib (dec n))\n                  (fib (- n 2)))))\n           (fib 13)",out:"233"},{name:"dedupe (recur)",code:"(function dedupe list -out\n             (let out (or -out []))\n             (let next (if (out (0 list)) [] [(0 list)]))\n             (if (empty? list) out\n                 (recur (sect list) (into out next))))\n           (dedupe [1 1 2 3 3 3])",out:"[1 2 3]"},{name:"frequencies",code:'(function frequencies list\n             (reduce #(% %1 (inc (or (% %1) 0))) {} list))\n           (frequencies "12121212")',out:'{"1" 4, "2" 4}'},{name:"set get",code:"[($globals.time_offset 5.5) $globals.time_offset]",out:"[5.5 5.5]"},{name:"exe",code:"(test.function 123)",out:"123\nnull"},{name:"Empty parens",code:"()",err:["Parse"]},{name:"Imbalanced parens 1",code:'(print ("hello!")',err:["Parse"]},{name:"Imbalanced parens 2",code:'print "hello!")',err:["Parse"]},{name:"Imbalanced quotes",code:'(print "Hello)',err:["Parse"]},{name:"Function as op",code:"(function)",err:["Parse"]},{name:"Function without name",code:"(function (+))",err:["Parse"]},{name:"Function without body",code:"(function func)",err:["Parse"]},{name:"Variable not symbol",code:"(var 1 2)",err:["Parse"]},{name:"Parser type error 1",code:"(function f (+ 1 :a))",err:["Type"]},{name:"Parser type error 2",code:"(function f (+ 1 (into {} {})))",err:["Type"]},{name:"Parser type error 3",code:"(function f (if true (into 2 {}) (+ 2 2)))",err:["Type"]},{name:"Parser arity error 1",code:"(abs)",err:["Parse"]}],Ke=({v:e})=>e,We=({v:e})=>e,Ue=({v:e})=>e,Xe=({v:e})=>e,Ye=(e,t)=>o(e)===o(t)&&!e.some(((e,r)=>!Ge(e,t[r]))),Ge=(e,t)=>{if("wild"===e.t||"wild"===t.t)return!0;if(e.t!==t.t)return!1;switch(e.t){case"null":return!0;case"bool":case"num":case"ext":return e.v===t.v;case"vec":return Ye(e.v,Ue(t));case"dict":{const r=Xe(t);return o(e.v.keys)===o(r.keys)&&Ye(e.v.keys,r.keys)}case"str":case"ref":case"key":case"func":return We(e)===We(t);case"clo":return e.v.name===t.v.name}return 0},Je=e=>e.reduce(((e,t)=>e+Qe(t)),""),Qe=e=>{const t=e=>{return"str"===e.t?`"${t=e.v,t.split("").map((e=>'"'===e?'\\"':e)).join("")}"`:Qe(e);var t};if("clo"===e.t)return e.v.name??"";if("vec"===e.t)return`[${e.v.map(t).join(" ")}]`;if("dict"===e.t){const{keys:r,vals:n}=e.v,[a,s]=[r.map(t),n.map(t)],o=a.map(((e,t)=>`${e} ${s[t]}`));return`{${o.join(", ")}}`}return"null"===e.t?"null":"wild"===e.t?"_":`${e.v}`},Ze=e=>"vec"===e.t?a(e.v):"str"===e.t?[...e.v].map((e=>({t:"str",v:e}))):"dict"===e.t?e.v.keys.map(((t,r)=>({t:"vec",v:[t,e.v.vals[r]]}))):[],et=e=>{o(e)%2==1&&e.pop();const t=e.filter(((e,t)=>t%2==0)),r=e.filter(((e,t)=>t%2==1)),n=[],a=[];return t.forEach(((e,t)=>{const s=n.findIndex((t=>Ge(t,e)));-1===s?(n.push(e),a.push(r[t])):a[s]=r[t]})),{t:"dict",v:{keys:n,vals:a}}},tt=({keys:e,vals:t},r)=>{const n=e.findIndex((e=>Ge(e,r)));return-1===n?{t:"null",v:void 0}:t[n]},rt=({keys:e,vals:t},r,n)=>{const[s,o]=[a(e),a(t)],c=e.findIndex((e=>Ge(e,r)));return-1!==c?o[c]=n:(s.push(r),o.push(n)),{keys:s,vals:o}};function nt(e,t,r){if(!o(e)||"vec"!==r.t&&"dict"!==r.t||"vec"===r.t&&("num"!==e[0].t||e[0].v<0||e[0].v>o(r.v)))return r;if("vec"===r.t){const n=a(r.v),s=Ke(e[0]);return 1===o(e)?(n[s]=t,{t:"vec",v:n}):(n[s]=nt(a(e,1),t,n[s]),{t:"vec",v:n})}return 1===o(e)?{t:"dict",v:rt(r.v,e[0],t)}:{t:"dict",v:rt(r.v,e[0],nt(a(e,1),t,tt(r.v,e[0])))}}const{abs:at,sign:st,sqrt:ot,floor:ct,ceil:it,round:ut,max:lt,min:pt,logn:vt,log2:dt,log10:mt}=r,{cos:ft,sin:yt,tan:xt,acos:ht,asin:bt,atan:gt,sinh:At,cosh:Ct,tanh:kt}=r,{concat:$t,has:wt,flat:Et,push:Pt,reverse:Bt,slice:It,splice:Mt,sortBy:jt}=r,{ends:Dt,slen:qt,starts:Ht,sub:Nt,subIdx:St,substr:Ot,upperCase:Tt,lowerCase:_t}=r,{trim:Ft,trimStart:Rt,trimEnd:Lt,charCode:Vt,codeChar:zt,strIdx:Kt,replace:Wt}=r,{getTimeMs:Ut,randInt:Xt,randNum:Yt}=r,{isNum:Gt,len:Jt,objKeys:Qt,range:Zt,toNum:er,isArray:tr}=r,rr={};let nr,ar=[],sr=[],or={};const cr=e=>ar.push({t:"bool",v:e}),ir=e=>ar.push({t:"num",v:e}),ur=(e="")=>ar.push({t:"str",v:e}),lr=(e=[])=>ar.push({t:"vec",v:e}),pr=e=>ar.push({t:"dict",v:e}),vr=()=>ar.push({t:"null",v:void 0}),dr=e=>ar.push({t:"func",v:e});function mr(e,t,r,n){const c=e=>[ie(e,n)];switch(e){case"str":return void ar.push({t:"str",v:Je(t)});case"print":case"print-str":return r.print(Je(t),"print"===e),void vr();case"vec":return void lr(t);case"dict":return void ar.push(et(t));case"len":return void ir("str"===t[0].t?qt(t[0].v):"vec"===t[0].t?Jt(t[0].v):Jt(Xe(t[0]).keys));case"to-num":return void(Gt(t[0].v)?ir(er(t[0].v)):vr());case"to-key":return void ar.push({t:"key",v:`:${Qe(t[0])}`});case"to-vec":return void lr(Ze(t[0]));case"!":return void cr(!se(t[0]));case"=":case"!=":for(let r=1,n=Jt(t);r<n;++r)if(Ge(t[r-1],t[r])!==("="===e))return void cr(!1);return void cr(!0);case"-":return void ir(1===Jt(t)?-Ke(t[0]):t.map(Ke).reduce(((e,t)=>e-t)));case"**":return void ir(Ke(t[0])**(1===Jt(t)?2:Ke(t[1])));case"+":return void ir(t.map(Ke).reduce(((e,t)=>e+t)));case"*":return void ir(t.map(Ke).reduce(((e,t)=>e*t)));case"/":return void ir(t.map(Ke).reduce(((e,t)=>e/t)));case"//":return void ir(t.map(Ke).reduce(((e,t)=>ct(e/t))));case"fast=":case"fast!=":return void cr(Ge(t[0],t[1])===("fast="===e));case"fast-":return void ir(t[0].v-t[1].v);case"fast+":return void ir(t[0].v+t[1].v);case"fast*":return void ir(t[0].v*t[1].v);case"fast/":return void ir(t[0].v/t[1].v);case"fast//":return void ir(ct(t[0].v/t[1].v));case"fast<":return void cr(t[0].v<t[1].v);case"fast>":return void cr(t[0].v>t[1].v);case"fast<=":return void cr(t[0].v<=t[1].v);case"fast>=":return void cr(t[0].v>=t[1].v);case"rem":return void ir(t.map(Ke).reduce(((e,t)=>e%t)));case"min":return void ir(t.map(Ke).reduce(((e,t)=>pt(e,t))));case"max":return void ir(t.map(Ke).reduce(((e,t)=>lt(e,t))));case"<":case">":case"<=":case">=":for(let r=1,n=Jt(t);r<n;++r){const[n,a]=[t[r-1].v,t[r].v];if("<"===e&&n>=a||">"===e&&n<=a||"<="===e&&n>a||">="===e&&n<a)return void cr(!1)}return void cr(!0);case"inc":return void ir(t[0].v+1);case"dec":return void ir(t[0].v-1);case"abs":return void ir(at(t[0].v));case"round":if(2===Jt(t)){const e=10**t[0].v;ir(ut(t[1].v*e)/e)}else ir(ut(t[0].v));return;case"sin":case"cos":case"tan":case"sqrt":case"floor":case"ceil":case"logn":case"log2":case"log10":return void ir((0,{sin:yt,cos:ft,tan:xt,sqrt:ot,floor:ct,ceil:it,logn:vt,log2:dt,log10:mt}[e])(Ke(t[0])));case"asin":case"acos":case"atan":case"sinh":case"cosh":case"tanh":return void ir((0,{asin:bt,acos:ht,atan:gt,sinh:At,cosh:Ct,tanh:kt}[e])(Ke(t[0])));case"and":return void cr(t.every(se));case"or":return void cr(t.some(se));case"xor":return void(se(t[0])!==se(t[1])?ar.push(se(t[0])?t[0]:t[1]):cr(!1));case"&":case"|":case"^":case"<<":case">>":case">>>":const[i,u]=[Ke(t[0]),Ke(t[1])];return void ir("&"===e?i&u:"|"===e?i|u:"^"===e?i^u:"<<"===e?i<<u:">>"===e?i>>u:i>>>u);case"~":return void ir(~Ke(t[0]));case"odd?":case"even?":return void cr(Ke(t[0])%2==("odd?"===e?1:0));case"pos?":case"neg?":case"zero?":{const r=Ke(t[0]);return void cr("pos?"===e?r>0:"neg?"===e?r<0:!r)}case"null?":case"num?":case"bool?":case"str?":case"dict?":case"vec?":case"key?":case"func?":case"wild?":case"ext?":{const{t:r}=t[0];return void cr("func?"===e&&("func"===r||"clo"===r)||Ot(e,0,qt(e)-1)===r)}case"type-of":return void ur(t[0].t);case"substr?":return void cr(Nt(We(t[1]),We(t[0])));case"idx":{let e=-1;if("str"===t[0].t){if("str"!==t[1].t)return c("strings can only contain strings");e=St(t[1].v,t[0].v)}else"vec"===t[0].t&&(e=t[0].v.findIndex((e=>Ge(e,t[1]))));return void(-1===e?vr():ir(e))}case"set-at":{const[e,r,n]=t;return void ar.push(nt(Ue(e),r,n))}case"map":case"for":case"reduce":case"filter":case"remove":case"find":case"count":{const a=xr(r,t.shift(),n);if("map"===e||"for"===e){const e=t.findIndex((({t:e})=>"vec"!==e&&"str"!==e&&"dict"!==e));if(-1!==e)return c(`argument ${e+2} must be either: string, vector, dictionary, not ${ae[t[e].t]}`)}if("for"===e){const e=t.map(Ze),s=e.map(Jt),o=s.map(((e,t)=>It(s,0,t+1).reduce(((e,t)=>e*t))));o.unshift(1);const c=o.pop();if(c>r.loopBudget)return[{e:"Budget",m:"would exceed loop budget",errCtx:n}];const i=[];for(let t=0;t<c;++t){const r=o.map(((e,r)=>ct(t/e%s[r]))),n=a(e.map(((e,t)=>e[r[t]])));if(n)return n;i.push(ar.pop())}return void lr(i)}if("map"===e){const e=t.map(Ze),r=pt(...e.map(Jt)),n=[];for(let t=0;t<r;++t){const r=a(e.map((e=>e[t])));if(r)return r;n.push(ar.pop())}return void lr(n)}if("reduce"!==e){const r=t.shift(),n=Ze(r),s="remove"===e,o="find"===e,c="count"===e,i=[];let u=0;for(let e=0,r=Jt(n);e<r;++e){const r=a([n[e],...t]);if(r)return r;const l=se(ar.pop());if(c)u+=l?1:0;else if(o){if(l)return void ar.push(n[e])}else l!==s&&i.push(n[e])}switch(e){case"count":return void ir(u);case"find":return void vr()}return void("str"===r.t?ur(i.map((e=>Qe(e))).join("")):"dict"===r.t?ar.push(et(Et(i.map((e=>e.v))))):lr(i))}const s=t.pop();if(!wt(["vec","dict","str"],s.t))return c(`must reduce either: string, vector, dictionary, not ${ae[s.t]}`);const o=Ze(s);if(!Jt(o))return void(Jt(t)?ar.push(t[0]):lr());if(Jt(o)<2&&!Jt(t))return void Pt(ar,o);let i=(Jt(t)?t:o).shift();for(let e=0,t=Jt(o);e<t;++e){const t=a([i,o[e]]);if(t)return t;i=ar.pop()}return void ar.push(i)}case"repeat":{const e=t.shift(),a=[],s=Ke(t[0]);if(s>r.rangeBudget)return[{e:"Budget",m:"would exceed range budget",errCtx:n}];if(r.rangeBudget-=s,"func"===e.t||"clo"===e.t){const t=xr(r,e,n);for(let e=0;e<s;++e){const r=t([{t:"num",v:e}]);if(r)return r;a.push(ar.pop())}}else for(let t=0;t<s;++t)a.push(e);return void lr(a)}case"->":ar.push(t.shift());for(let e=0,a=Jt(t);e<a;++e){const a=xr(r,t[e],n)([ar.pop()]);if(a)return a.forEach((t=>t.m=`-> arg ${e+2}: ${t.m}`)),a}return;case"rand-int":case"rand":{const r=Jt(t),[n,a]=[r<2?0:Ke(t[0]),0===r?1+er("rand-int"===e):Ke(1===r?t[0]:t[1])];ir("rand-int"===e?Xt(n,a):Yt(n,a))}return;case"do":case"val":return void ar.push("do"===e?t.pop():t.shift());case".":case"..":case"...":{const a=xr(r,t.shift(),n);if("."===e)return a(t);let s=t;if(".."===e)s=Et(t.map((e=>"vec"===e.t?e.v:[e])));else{const e=s.pop();Pt(s,Et(["vec"===e.t?e.v:[e]]))}return a(s)}case"into":if("vec"===t[0].t)lr($t(t[0].v,Ze(t[1])));else if("vec"===t[1].t)ar.push(et($t(Et(Ze(t[0]).map(Ue)),t[1].v)));else{const{keys:e,vals:r}=Xe(t[0]),n=Xe(t[1]);pr({keys:$t(e,n.keys),vals:$t(r,n.vals)})}return;case"omit":return void ar.push((({keys:e,vals:t},r)=>{const[n,o]=[a(e),a(t)],c=e.findIndex((e=>Ge(e,r)));return-1!==c&&(s(n,c,1),s(o,c,1)),{t:"dict",v:{keys:n,vals:o}}})(Xe(t[1]),t[0]));case"assoc":return void pr(rt(Xe(t[2]),t[0],t[1]));case"append":return void lr($t(Ue(t[1]),[t[0]]));case"prepend":return void lr($t([t[0]],Ue(t[1])));case"insert":{const e=Ue(t[2]);let r=Ke(t[1]);return void(0===r?lr($t([t[0]],e)):-1===r?lr($t(e,[t[0]])):(r=r>0?pt(r,Jt(e)):lt(Jt(e)+1+r,0),lr($t($t(It(e,0,r),[t[0]]),It(e,r)))))}case"sect":{const e=t[0],r="vec"===e.t?Jt(e.v):qt(We(e));let n=0,a=r;switch(Jt(t)){case 1:n=1;break;case 2:{const e=Ke(t[1]);e<0?a+=e:n+=e;break}case 3:{const e=Ke(t[1]),s=Ke(t[2]);n=e<0?r+e+(s<0?s:0):n+e,a=(s<0?a:n)+s;break}}return n=lt(n,0),a=pt(a,r),n>a?void("vec"===e.t?lr:ur)():void("vec"===e.t?lr(It(e.v,n,a)):ur(Ot(We(t[0]),n,a-n)))}case"reverse":return void("str"===t[0].t?ur(Je(Bt(Ze(t[0])))):lr(Bt(Ze(t[0]))));case"flatten":{const e=Ue(t[0]),r=[],n=e=>e.forEach((e=>"vec"===e.t?n(e.v):r.push(e)));return n(e),void lr(r)}case"shuffle":{const e=It(Ue(t[0]));for(let t=Jt(e)-1;t;--t){const r=ct(Xt(0,t+1));[e[t],e[r]]=[e[r],e[t]]}return void lr(e)}case"sort":case"sort-by":{const a=Ze(t["sort"===e?0:1]);if(!Jt(a))return void lr();const s=[];if("sort"===e)Pt(s,a.map((e=>[e,e])));else{const e=xr(r,t[0],n);for(let t=0,r=Jt(a);t<r;++t){const r=e([a[t]]);if(r)return r;s.push([a[t],ar.pop()])}}const o=s[0][1].t;return s.some((([e,{t}])=>t!==o||!wt(["num","str"],t)))?c("can only sort by all number or all string"):(jt(s,"num"===o?([e,t],[r,n])=>Ke(t)>Ke(n)?1:-1:([e,t],[r,n])=>We(t)>We(n)?1:-1),void lr(s.map((([e])=>e))))}case"group-by":{const e=xr(r,t[0],n);let a={keys:[],vals:[]};if("dict"===t[1].t){const{keys:r,vals:n}=Xe(t[1]);for(let t=0,s=Jt(r);t<s;++t){const s=e([r[t],n[t]]);if(s)return s;const o=ar.pop(),c=a.keys.findIndex((e=>Ge(e,o)));if(-1===c)a.keys.push(o),a.vals.push({t:"dict",v:{keys:[r[t]],vals:[n[t]]}});else{const e=Xe(a.vals[c]);e.keys.push(r[t]),e.vals.push(n[t])}}}else{const r=Ze(t[1]);for(let t=0,n=Jt(r);t<n;++t){const n=e([r[t]]);if(n)return n;const s=ar.pop(),o=a.keys.findIndex((e=>Ge(e,s)));-1===o?(a.keys.push(s),a.vals.push({t:"vec",v:[r[t]]})):Ue(a.vals[o]).push(r[t])}}return void pr(a)}case"part-by":{const e=xr(r,t[0],n);if("dict"===t[1].t){const{keys:r,vals:n}=Xe(t[1]),a=[{keys:[],vals:[]},{keys:[],vals:[]}];for(let t=0,s=Jt(r);t<s;++t){const s=e([r[t],n[t]]);if(s)return s;const o=se(ar.pop())?0:1;a[o].keys.push(r[t]),a[o].vals.push(n[t])}lr(a.map((e=>({t:"dict",v:e}))))}else{const r=Ze(t[1]),n=[[],[]];for(let t=0,a=Jt(r);t<a;++t){const a=e([r[t]]);if(a)return a;n[se(ar.pop())?0:1].push(r[t])}lr(n.map((e=>({t:"vec",v:e}))))}return}case"frequencies":{const e=Ze(t[0]),r=[],n=[];return e.forEach((e=>{const t=r.findIndex((t=>Ge(e,t)));-1!==t?++n[t]:(r.push(e),n.push(1))})),void pr({keys:r,vals:n.map((e=>({t:"num",v:e})))})}case"distinct":{const e=1===Jt(t)&&"vec"===t[0].t?Ue(t[0]):t,r=[];return e.forEach((e=>{r.some((t=>Ge(e,t)))||r.push(e)})),void lr(r)}case"range":{const[e,a,s]=t.map(Ke),o=s&&s<0&&e<a,[c,i]=Jt(t)>1?o?[a-1,e-1]:[e,a]:[0,e],u=st((i-c)*(s||1))*(s||1),l=it(at((i-c)/u));if(!l)return void lr([]);if(l>r.rangeBudget)return[{e:"Budget",m:"would exceed range budget",errCtx:n}];r.rangeBudget-=l;const p=Zt(l).map((e=>e*u+c));return void lr(p.map((e=>({t:"num",v:e}))))}case"empty?":return void cr(!Jt(Ze(t[0])));case"keys":case"vals":return void lr(Xe(t[0])["keys"===e?"keys":"vals"]);case"split":return void lr(We(t[1]).split(We(t[0])).map((e=>({t:"str",v:e}))));case"join":return void ur(Ze(t[1]).map(Qe).join(We(t[0])));case"replace":return void ur(Wt(We(t[2]),We(t[0]),We(t[1])));case"starts?":case"ends?":return void cr(("starts?"===e?Ht:Dt)(We(t[1]),We(t[0])));case"upper-case":case"lower-case":case"trim":case"trim-start":case"trim-end":return void ur(("upper-case"===e?Tt:"lower-case"===e?_t:"trim"===e?Ft:"trim-start"===e?Rt:Lt)(We(t[0])));case"str*":{const e=We(t[0]);return void ur(Zt(lt(it(Ke(t[1])),0)).map((t=>e)).join(""))}case"char-code":if("str"===t[0].t){const e=Jt(t)>1?Ke(t[1]):0,r=We(t[0]);qt(r)<=e||e<0?vr():ir(Vt(Kt(r,e)))}else ur(zt(Ke(t[0])));return;case"time":return void ir(Ut());case"version":return void ir(220301);case"tests":return void ur(function(e,t=!0){const r=[];for(let t=0;t<o(ze);++t){const{name:n,code:a,err:s,out:o}=ze[t],c={dict:new Map,output:""},i={funcs:{},vars:{}},u=N(),l=e({get:e=>Re(c,e),set:(e,t)=>Le(c,e,t),print:(e,t)=>{c.output+=e+(t?"\n":"")},exe:(e,t)=>Ve(c,e,t),functions:[],env:i,loopBudget:1e4,rangeBudget:1e3,callBudget:1e3,recurBudget:1e4},a,a,!0),p="errors"===l.kind?l.errors:[],v=(s||[]).join()===p.map((({e})=>e)).join(),d=!o||w(c.output)===o,m=N()-u,[f,y,x,h,b]=[B(`${t+1}`,3),B(n,24),B(`${Y(m)}ms`,6),d||o+"\t!=\t"+w(c.output),v||p.map((({e,m:t,errCtx:{line:r,col:n}})=>`${e} ${r}:${n}: ${t}`))];r.push({okErr:v,okOut:d,elapsedMs:m,display:`${f} ${y} ${x} ${h} ${b}`})}const n=r.reduce(((e,{elapsedMs:t})=>e+t),0),a=o(r.filter((({okOut:e,okErr:t})=>e&&t)));return b(r.filter((e=>!t||!e.okOut||!e.okErr)).map((e=>e.display)),[`---- ${a}/${o(r)} tests passed in ${Y(n)}ms.`])}(kr,!(Jt(t)&&se(t[0]))).join("\n"));case"symbols":return void lr(function(e,t=!0){let r=[];t&&Pt(r,ne),Pt(r,["args","PI","E"]),r=$t(r,Qt(re)),r=$t(r,Qt(e.env.funcs)),r=$t(r,Qt(e.env.vars));const n=["entry"];return r=r.filter((e=>!wt(n,e))),jt(r,((e,t)=>e>t?1:-1))}(r,!1).map((e=>({t:"str",v:e}))));case"eval":{delete r.env.funcs.entry;const e=Jt(ar),a=`${n.invokeId} eval`,s=Ar(r,We(t[0]),a);return s?[{e:"Eval",m:"error within evaluated code",errCtx:n},...s]:void(e===Jt(ar)&&vr())}case"about":{const e=We(t[0]),r=re[e];if(!r)return void vr();const n=[],a=(e,t)=>n.push({t:"key",v:`:${e}`},t),s=e=>({t:"vec",v:e.map((e=>tr(e)?{t:"vec",v:e.map((e=>({t:"str",v:e})))}:{t:"str",v:e}))});return a("external?",{t:"bool",v:!!r.external}),r.exactArity?a("exact-arity",{t:"num",v:r.exactArity}):(r.minArity&&a("minimum-arity",{t:"num",v:r.minArity}),r.maxArity&&a("maximum-arity",{t:"num",v:r.maxArity})),(r.params||r.numeric)&&a("in-types",s(r.params?r.params:["num"])),(r.returns||!0===r.numeric)&&a("out-types",s(r.returns?r.returns:["num"])),void ar.push(et(n))}case"recur":return void(nr=t);case"reset":return r.env.vars={},r.env.funcs={},sr=[],void vr()}return[{e:"Unexpected",m:"operation doesn't exist",errCtx:n}]}const fr=(e,t)=>[{e:"Arity",m:`${ae[e]} as op requires one sole argument`,errCtx:t}];function yr(e,t,r,n){if(n){const n=oe(e,Jt(t),r);if(n)return n}return ce(e,t.map((e=>[e.t])),r)||!1}function xr(e,t,r,n=!0){if("str"===t.t||"func"===t.t){const a=t.v;return re[a]?re[a].external?e=>{const t=yr(a,e,r,n);if(t)return t;const s=rr[a](e);if("err"===s.kind)return[{e:"External",m:s.err,errCtx:r}];ar.push(s.value)}:t=>yr(a,t,r,n)||mr(a,t,e,r):a in e.env.funcs&&"entry"!==a?t=>gr(e,e.env.funcs[a],t):a in e.env.vars?xr(e,e.env.vars[a],r):a in or?xr(e,or[a],r):Ht(a,"$")?n=>{if(!Jt(n))return fr(t.t,r);const s=e.set(Ot(a,1),n[0]);return ar.push(n[0]),s?[{e:"External",m:s,errCtx:r}]:void 0}:t=>{const n=e.exe(a,t);if("val"!==n.kind)return[{e:"External",m:n.err,errCtx:r}];ar.push(n.value)}}if("clo"===t.t)return r=>gr(e,t.v,r);if("key"===t.t)return e=>{if(!Jt(e))return fr(t.t,r);if("dict"===e[0].t)ar.push(tt(Xe(e[0]),t));else{if("vec"!==e[0].t)return le(r,[e[0].t]);{const r=Ue(e[0]).find((e=>Ge(e,t)));ar.push(r??{t:"null",v:void 0})}}};if("num"===t.t){const e=ct(t.v);return n=>{if(!Jt(n))return fr(t.t,r);const a=n[0];if("str"!==a.t&&"vec"!==a.t&&"dict"!==a.t)return ue(r,[a.t]);const s=Ze(a),o=Jt(s);e>=0&&e>=o||e<0&&-e>o?vr():e<0?ar.push(s[o+e]):ar.push(s[e])}}if("vec"===t.t){const{v:e}=t;return n=>{if(!Jt(n))return fr(t.t,r);const a=e.find((e=>Ge(e,n[0])));a?ar.push(a):vr()}}if("dict"===t.t){const e=t.v;return t=>{if(1===Jt(t))ar.push(tt(e,t[0]));else{if(2!==Jt(t))return[{e:"Arity",m:"provide 1 or 2 arguments for dictionary",errCtx:r}];pr(rt(e,t[0],t[1]))}}}if("bool"===t.t){const e=t.v;return t=>{if(!Jt(t)||Jt(t)>2)return[{e:"Arity",m:"provide 1 or 2 arguments for boolean",errCtx:r}];ar.push(e?t[0]:Jt(t)>1?t[1]:{t:"null",v:void 0})}}return e=>[{e:"Operation",m:`${Qe(t)} is an invalid operation`,errCtx:r}]}function hr(e){const t=(e,t,r)=>rt(e,{t:"key",v:t},r);return e.map((({e,m:r,errCtx:n})=>{let a=t({keys:[],vals:[]},":e",{t:"str",v:e});return a=t(a,":m",{t:"str",v:r}),a=t(a,":line",{t:"num",v:n.line}),a=t(a,":col",{t:"num",v:n.col}),{t:"dict",v:a}}))}function br(e,t){let r=e;for(let e=0,n=Jt(t)-1;e<n;++e){const a=r[t[e]];if("vec"!==a.t)return"str"===a.t&&e+1===n&&t[e+1]<qt(a.v)?{t:"str",v:Kt(a.v,t[e+1])}:{t:"null",v:void 0};r=a.v}const n=t[Jt(t)-1];return n>=Jt(r)?{t:"null",v:void 0}:r[n]}function gr(e,t,r,n=!1){--e.callBudget,n||(sr.push({}),or=sr[Jt(sr)-1]);const a=Jt(ar);for(let n=0,s=Jt(t.ins);n<s;++n){const o=t.ins[n],{errCtx:c}=t.ins[n],i=e.loopBudget<1;if(i||e.callBudget<1)return[{e:"Budget",m:(i?"looped":"called")+" too many times",errCtx:c}];switch(o.typ){case"val":ar.push(o.value);break;case"var":e.env.vars[o.value]=ar[Jt(ar)-1];break;case"let":or[o.value]=ar[Jt(ar)-1];break;case"dle":case"dva":{const t=ar.pop();let r;o.value.forEach((({name:n,position:a})=>{r="dva"===o.typ?e.env.vars[n]=br([t],a):or[n]=br([t],a)})),ar.push(r);break}case"npa":case"upa":{const e=o.value;-1===e?lr(r):Jt(r)<=e?vr():ar.push(r[e]);break}case"dpa":ar.push(br(r,o.value));break;case"ref":{const t=o.value;if(re[t])dr(t);else if(Ht(t,"$")){const r=e.get(Ot(t,1));if("err"===r.kind)return[{e:"External",m:r.err,errCtx:c}];ar.push(r.value)}else if(t in e.env.vars)ar.push(e.env.vars[t]);else if(t in or)ar.push(or[t]);else{if(!(t in e.env.funcs))return[{e:"Reference",m:`"${t}" did not exist`,errCtx:c}];dr(t)}break}case"exa":case"exe":{const a=xr(e,ar.pop(),c,"exa"===o.typ),s=o.value,i=a(Mt(ar,Jt(ar)-s,s));if(i){const e=It(t.ins,n).findIndex((e=>"cat"===e.typ));if(-1!==e){n+=e,or.errors={t:"vec",v:hr(i)};break}return i}if(nr){if(sr[Jt(sr)-1]={},n=-1,r=nr,nr=void 0,--e.recurBudget,!e.recurBudget)return[{e:"Budget",m:"recurred too many times",errCtx:c}];break}break}case"or":se(ar[Jt(ar)-1])?n+=o.value:ar.pop();break;case"mat":{const e=ar[Jt(ar)-2];Ge(e,ar.pop())?ar.pop():n+=o.value;break}case"if":se(ar.pop())||(n+=o.value);break;case"jmp":case"cat":n+=o.value;break;case"loo":n+=o.value,--e.loopBudget;break;case"pop":1===o.value?ar.pop():Mt(ar,Jt(ar)-o.value,o.value);break;case"ret":o.value?Mt(ar,a,Jt(ar)-a-1):vr(),n=s;break;case"clo":{const a=It(o.value.derefs).map((t=>{const r="val"===t.typ&&"str"===t.value.t&&(or[t.value.v]??e.env.vars[t.value.v]);return r?{typ:"val",value:r}:t})),s=gr(e,{ins:a},r,!0);if(s)return s;const c=Jt(a),i=Mt(ar,Jt(ar)-c,c),u=It(t.ins,n+1,n+1+o.value.length);ar.push({t:"clo",v:ve(o.value,u,i)}),n+=o.value.length;break}}}n||(sr.pop(),or=sr[Jt(sr)-1],Mt(ar,a,Jt(ar)-(a+1)))}function Ar(e,t,r){const n=Fe(t,r);return Jt(n.errors)?n.errors:(e.env.funcs={...e.env.funcs,...n.funcs},"entry"in e.env.funcs?gr(e,e.env.funcs.entry,[]):void 0)}function Cr(e,t,r){const{callBudget:n,loopBudget:a,recurBudget:s,rangeBudget:o}=e;e.functions.forEach((({name:e,definition:t,handler:r})=>{if(re[e]&&!rr[e])throw"Redefining internal operations is disallowed.";re[e]={...t,external:!0},rr[e]=r}));const c=t();e.functions.forEach((({name:e})=>{delete re[e],delete rr[e]})),[e.callBudget,e.recurBudget]=[n,s],[e.loopBudget,e.rangeBudget]=[a,o],delete e.env.funcs.entry;const i=ar.pop();return[ar,sr]=[[],[]],r&&!c&&i&&e.print(Qe(i),!0),c?{kind:"errors",errors:c}:i?{kind:"val",value:i}:{kind:"empty"}}function kr(e,t,r,n=!1){return Cr(e,(()=>Ar(e,t,r)),n)}const $r=new Map,wr=/[\[\]\(\) ,]/;function Er(e,t,r,n=!0){return r=r?`-${r}`:`${N()}`,$r.set(r,t),Br(kr(e,t,r,n))}function Pr(e,t,r,n=!0){const a=function(e,t,r,n=!1){if(t in e.env.funcs)return Cr(e,(()=>gr(e,e.env.funcs[t],r)),n)}(e,t,r,n);return a?Br(a):[{type:"message",text:`Invoke Error: function '${t}' not found.`}]}function Br(e){if("errors"!==e.kind)return[];let t=[];const r=e=>t.push({type:"message",text:e}),n=e=>t.push({type:"error",text:e});return e.errors.forEach((({e,m:t,errCtx:{line:a,col:s,invokeId:o}})=>{const i=$r.get(o);if(!i)return void r(`${e} Error: ${o} line ${a} col ${s}: ${t}\n`);const u=i.split("\n")[a-1],p=l(u,s-1).split(wr)[0],v=E(l(u,0,s-1)),d=f(o,"-")?`${l(o,1)} `:"";if(r(`${d}${B(`${a}`,4)} ${v}`),p){const e=l(u,s-1+c(p));n(p),r(`${e}\n`)}else{const e=l(u,s);n(u[s-1]),r(`${e}\n`)}r(`${e} Error: ${t}.\n`)})),t}})();var r=insitux="undefined"==typeof insitux?{}:insitux;for(var n in t)r[n]=t[n];t.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})})();
  //# sourceMappingURL=insitux-apps-script.js.map