@dbml/parse 6.0.0 → 6.2.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/examples/compiler/stringUtils.test.d.ts +1 -0
- package/dist/__tests__/examples/interpreter/record/data.test.d.ts +1 -0
- package/dist/__tests__/examples/interpreter/record/fk.test.d.ts +1 -0
- package/dist/__tests__/examples/interpreter/record/increment.test.d.ts +1 -0
- package/dist/__tests__/examples/interpreter/record/multi_records.test.d.ts +1 -0
- package/dist/__tests__/examples/interpreter/record/pk.test.d.ts +1 -0
- package/dist/__tests__/examples/interpreter/record/table_partial.test.d.ts +1 -0
- package/dist/__tests__/examples/interpreter/record/type_compatibility.test.d.ts +1 -0
- package/dist/__tests__/examples/interpreter/record/unique.test.d.ts +1 -0
- package/dist/__tests__/examples/lexer/scientific-notation.test.d.ts +1 -0
- package/dist/__tests__/examples/services/definition/general.test.d.ts +1 -0
- package/dist/__tests__/examples/services/definition/records.test.d.ts +1 -0
- package/dist/__tests__/examples/services/references/general.test.d.ts +1 -0
- package/dist/__tests__/examples/services/references/records.test.d.ts +1 -0
- package/dist/__tests__/examples/services/suggestions/general.test.d.ts +1 -0
- package/dist/__tests__/examples/services/suggestions/suggestions_records.test.d.ts +1 -0
- package/dist/__tests__/examples/validator/records.test.d.ts +1 -0
- package/dist/__tests__/utils/compiler.d.ts +5 -5
- package/dist/__tests__/utils/mocks.d.ts +1 -0
- package/dist/__tests__/utils/testHelpers.d.ts +2 -2
- package/dist/dbml-parse.js +28 -26
- package/dist/dbml-parse.mjs +13766 -6576
- package/dist/src/compiler/index.d.ts +8 -4
- package/dist/src/compiler/queries/parse.d.ts +2 -1
- package/dist/src/compiler/queries/transform/index.d.ts +2 -1
- package/dist/src/compiler/queries/transform/renameTable.d.ts +1 -4
- package/dist/src/compiler/queries/transform/utils.d.ts +22 -0
- package/dist/src/compiler/queries/utils.d.ts +95 -0
- package/dist/src/compiler/types.d.ts +2 -1
- package/dist/src/core/analyzer/analyzer.d.ts +2 -3
- package/dist/src/core/analyzer/binder/binder.d.ts +1 -2
- package/dist/src/core/analyzer/binder/elementBinder/records.d.ts +22 -0
- package/dist/src/core/analyzer/binder/utils.d.ts +2 -1
- package/dist/src/core/analyzer/types.d.ts +2 -1
- package/dist/src/core/analyzer/utils.d.ts +11 -1
- package/dist/src/core/analyzer/validator/elementValidators/records.d.ts +26 -0
- package/dist/src/core/analyzer/validator/utils.d.ts +3 -3
- package/dist/src/core/analyzer/validator/validator.d.ts +1 -2
- package/dist/src/core/errors.d.ts +15 -1
- package/dist/src/core/interpreter/interpreter.d.ts +1 -2
- package/dist/src/core/interpreter/records/index.d.ts +10 -0
- package/dist/src/core/interpreter/records/utils/constraints/fk.d.ts +3 -0
- package/dist/src/core/interpreter/records/utils/constraints/helper.d.ts +10 -0
- package/dist/src/core/interpreter/records/utils/constraints/index.d.ts +3 -0
- package/dist/src/core/interpreter/records/utils/constraints/pk.d.ts +3 -0
- package/dist/src/core/interpreter/records/utils/constraints/unique.d.ts +3 -0
- package/dist/src/core/interpreter/records/utils/data/index.d.ts +2 -0
- package/dist/src/core/interpreter/records/utils/data/sqlTypes.d.ts +19 -0
- package/dist/src/core/interpreter/records/utils/data/values.d.ts +14 -0
- package/dist/src/core/interpreter/records/utils/index.d.ts +2 -0
- package/dist/src/core/interpreter/types.d.ts +39 -2
- package/dist/src/core/interpreter/utils.d.ts +4 -3
- package/dist/src/core/lexer/lexer.d.ts +1 -2
- package/dist/src/core/parser/nodes.d.ts +17 -6
- package/dist/src/core/parser/parser.d.ts +6 -4
- package/dist/src/core/parser/utils.d.ts +3 -3
- package/dist/src/core/report.d.ts +8 -5
- package/dist/src/core/utils.d.ts +0 -1
- package/dist/src/index.d.ts +3 -4
- package/dist/src/services/diagnostics/provider.d.ts +34 -0
- package/dist/src/services/index.d.ts +2 -1
- package/dist/src/services/suggestions/recordRowSnippet.d.ts +3 -0
- package/dist/src/services/suggestions/utils.d.ts +27 -1
- package/dist/src/services/types.d.ts +13 -2
- package/package.json +5 -3
- package/dist/src/core/serialization/serialize.d.ts +0 -4
- /package/dist/__tests__/examples/{services/definition.test.d.ts → binder/records.test.d.ts} +0 -0
- /package/dist/__tests__/examples/{services/references.test.d.ts → compiler/identifierUtils.test.d.ts} +0 -0
- /package/dist/__tests__/examples/{services/suggestions.test.d.ts → compiler/splitQualifiedIdentifier.test.d.ts} +0 -0
package/dist/dbml-parse.js
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var kc=typeof global=="object"&&global&&global.Object===Object&&global,FT=typeof self=="object"&&self&&self.Object===Object&&self,an=kc||FT||Function("return this")(),Gt=an.Symbol,Fc=Object.prototype,CT=Fc.hasOwnProperty,BT=Fc.toString,Cr=Gt?Gt.toStringTag:void 0;function GT(t){var r=CT.call(t,Cr),i=t[Cr];try{t[Cr]=void 0;var s=!0}catch{}var o=BT.call(t);return s&&(r?t[Cr]=i:delete t[Cr]),o}var VT=Object.prototype,$T=VT.toString;function WT(t){return $T.call(t)}var XT="[object Null]",HT="[object Undefined]",ql=Gt?Gt.toStringTag:void 0;function lr(t){return t==null?t===void 0?HT:XT:ql&&ql in Object(t)?GT(t):WT(t)}function Fn(t){return t!=null&&typeof t=="object"}var qT="[object Symbol]";function ts(t){return typeof t=="symbol"||Fn(t)&&lr(t)==qT}function Cc(t,r){for(var i=-1,s=t==null?0:t.length,o=Array(s);++i<s;)o[i]=r(t[i],i,t);return o}var Pt=Array.isArray,zl=Gt?Gt.prototype:void 0,Kl=zl?zl.toString:void 0;function Bc(t){if(typeof t=="string")return t;if(Pt(t))return Cc(t,Bc)+"";if(ts(t))return Kl?Kl.call(t):"";var r=t+"";return r=="0"&&1/t==-1/0?"-0":r}var zT=/\s/;function KT(t){for(var r=t.length;r--&&zT.test(t.charAt(r)););return r}var YT=/^\s+/;function JT(t){return t&&t.slice(0,KT(t)+1).replace(YT,"")}function ar(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}var Yl=NaN,QT=/^[-+]0x[0-9a-f]+$/i,ZT=/^0b[01]+$/i,jT=/^0o[0-7]+$/i,ev=parseInt;function tv(t){if(typeof t=="number")return t;if(ts(t))return Yl;if(ar(t)){var r=typeof t.valueOf=="function"?t.valueOf():t;t=ar(r)?r+"":r}if(typeof t!="string")return t===0?t:+t;t=JT(t);var i=ZT.test(t);return i||jT.test(t)?ev(t.slice(2),i?2:8):QT.test(t)?Yl:+t}var Jl=1/0,nv=17976931348623157e292;function rv(t){if(!t)return t===0?t:0;if(t=tv(t),t===Jl||t===-Jl){var r=t<0?-1:1;return r*nv}return t===t?t:0}function iv(t){var r=rv(t),i=r%1;return r===r?i?r-i:r:0}function ns(t){return t}var sv="[object AsyncFunction]",av="[object Function]",ov="[object GeneratorFunction]",uv="[object Proxy]";function Gc(t){if(!ar(t))return!1;var r=lr(t);return r==av||r==ov||r==sv||r==uv}var Da=an["__core-js_shared__"],Ql=function(){var t=/[^.]+$/.exec(Da&&Da.keys&&Da.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function lv(t){return!!Ql&&Ql in t}var cv=Function.prototype,fv=cv.toString;function Gn(t){if(t!=null){try{return fv.call(t)}catch{}try{return t+""}catch{}}return""}var hv=/[\\^$.*+?()[\]{}|]/g,pv=/^\[object .+?Constructor\]$/,dv=Function.prototype,Ev=Object.prototype,_v=dv.toString,gv=Ev.hasOwnProperty,Nv=RegExp("^"+_v.call(gv).replace(hv,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Tv(t){if(!ar(t)||lv(t))return!1;var r=Gc(t)?Nv:pv;return r.test(Gn(t))}function vv(t,r){return t?.[r]}function Vn(t,r){var i=vv(t,r);return Tv(i)?i:void 0}var ka=Vn(an,"WeakMap");function bv(t,r,i){switch(i.length){case 0:return t.call(r);case 1:return t.call(r,i[0]);case 2:return t.call(r,i[0],i[1]);case 3:return t.call(r,i[0],i[1],i[2])}return t.apply(r,i)}var mv=800,Iv=16,Av=Date.now;function wv(t){var r=0,i=0;return function(){var s=Av(),o=Iv-(s-i);if(i=s,o>0){if(++r>=mv)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}function Lv(t){return function(){return t}}var Zl=function(){try{var t=Vn(Object,"defineProperty");return t({},"",{}),t}catch{}}(),yv=Zl?function(t,r){return Zl(t,"toString",{configurable:!0,enumerable:!1,value:Lv(r),writable:!0})}:ns,xv=wv(yv);function Sv(t,r,i,s){t.length;for(var o=i+1;o--;)if(r(t[o],o,t))return o;return-1}var Ov=9007199254740991,Pv=/^(?:0|[1-9]\d*)$/;function Vc(t,r){var i=typeof t;return r=r??Ov,!!r&&(i=="number"||i!="symbol"&&Pv.test(t))&&t>-1&&t%1==0&&t<r}function $c(t,r){return t===r||t!==t&&r!==r}var jl=Math.max;function Rv(t,r,i){return r=jl(r===void 0?t.length-1:r,0),function(){for(var s=arguments,o=-1,l=jl(s.length-r,0),f=Array(l);++o<l;)f[o]=s[r+o];o=-1;for(var d=Array(r+1);++o<r;)d[o]=s[o];return d[r]=i(f),bv(t,this,d)}}function Dv(t,r){return xv(Rv(t,r,ns),t+"")}var Mv=9007199254740991;function za(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Mv}function rs(t){return t!=null&&za(t.length)&&!Gc(t)}var Uv=Object.prototype;function Wc(t){var r=t&&t.constructor,i=typeof r=="function"&&r.prototype||Uv;return t===i}function Xc(t,r){for(var i=-1,s=Array(t);++i<t;)s[i]=r(i);return s}var kv="[object Arguments]";function ec(t){return Fn(t)&&lr(t)==kv}var Hc=Object.prototype,Fv=Hc.hasOwnProperty,Cv=Hc.propertyIsEnumerable,Ka=ec(function(){return arguments}())?ec:function(t){return Fn(t)&&Fv.call(t,"callee")&&!Cv.call(t,"callee")};function Bv(){return!1}var qc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tc=qc&&typeof module=="object"&&module&&!module.nodeType&&module,Gv=tc&&tc.exports===qc,nc=Gv?an.Buffer:void 0,Vv=nc?nc.isBuffer:void 0,Fa=Vv||Bv,$v="[object Arguments]",Wv="[object Array]",Xv="[object Boolean]",Hv="[object Date]",qv="[object Error]",zv="[object Function]",Kv="[object Map]",Yv="[object Number]",Jv="[object Object]",Qv="[object RegExp]",Zv="[object Set]",jv="[object String]",eb="[object WeakMap]",tb="[object ArrayBuffer]",nb="[object DataView]",rb="[object Float32Array]",ib="[object Float64Array]",sb="[object Int8Array]",ab="[object Int16Array]",ob="[object Int32Array]",ub="[object Uint8Array]",lb="[object Uint8ClampedArray]",cb="[object Uint16Array]",fb="[object Uint32Array]",he={};he[rb]=he[ib]=he[sb]=he[ab]=he[ob]=he[ub]=he[lb]=he[cb]=he[fb]=!0;he[$v]=he[Wv]=he[tb]=he[Xv]=he[nb]=he[Hv]=he[qv]=he[zv]=he[Kv]=he[Yv]=he[Jv]=he[Qv]=he[Zv]=he[jv]=he[eb]=!1;function hb(t){return Fn(t)&&za(t.length)&&!!he[lr(t)]}function pb(t){return function(r){return t(r)}}var zc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vr=zc&&typeof module=="object"&&module&&!module.nodeType&&module,db=Vr&&Vr.exports===zc,Ma=db&&kc.process,rc=function(){try{var t=Vr&&Vr.require&&Vr.require("util").types;return t||Ma&&Ma.binding&&Ma.binding("util")}catch{}}(),ic=rc&&rc.isTypedArray,Kc=ic?pb(ic):hb,Eb=Object.prototype,_b=Eb.hasOwnProperty;function Yc(t,r){var i=Pt(t),s=!i&&Ka(t),o=!i&&!s&&Fa(t),l=!i&&!s&&!o&&Kc(t),f=i||s||o||l,d=f?Xc(t.length,String):[],m=d.length;for(var I in t)(r||_b.call(t,I))&&!(f&&(I=="length"||o&&(I=="offset"||I=="parent")||l&&(I=="buffer"||I=="byteLength"||I=="byteOffset")||Vc(I,m)))&&d.push(I);return d}function gb(t,r){return function(i){return t(r(i))}}var Nb=gb(Object.keys,Object),Tb=Object.prototype,vb=Tb.hasOwnProperty;function bb(t){if(!Wc(t))return Nb(t);var r=[];for(var i in Object(t))vb.call(t,i)&&i!="constructor"&&r.push(i);return r}function Ya(t){return rs(t)?Yc(t):bb(t)}function mb(t){var r=[];if(t!=null)for(var i in Object(t))r.push(i);return r}var Ib=Object.prototype,Ab=Ib.hasOwnProperty;function wb(t){if(!ar(t))return mb(t);var r=Wc(t),i=[];for(var s in t)s=="constructor"&&(r||!Ab.call(t,s))||i.push(s);return i}function Lb(t){return rs(t)?Yc(t,!0):wb(t)}var yb=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,xb=/^\w*$/;function Ja(t,r){if(Pt(t))return!1;var i=typeof t;return i=="number"||i=="symbol"||i=="boolean"||t==null||ts(t)?!0:xb.test(t)||!yb.test(t)||r!=null&&t in Object(r)}var Wr=Vn(Object,"create");function Sb(){this.__data__=Wr?Wr(null):{},this.size=0}function Ob(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}var Pb="__lodash_hash_undefined__",Rb=Object.prototype,Db=Rb.hasOwnProperty;function Mb(t){var r=this.__data__;if(Wr){var i=r[t];return i===Pb?void 0:i}return Db.call(r,t)?r[t]:void 0}var Ub=Object.prototype,kb=Ub.hasOwnProperty;function Fb(t){var r=this.__data__;return Wr?r[t]!==void 0:kb.call(r,t)}var Cb="__lodash_hash_undefined__";function Bb(t,r){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Wr&&r===void 0?Cb:r,this}function Cn(t){var r=-1,i=t==null?0:t.length;for(this.clear();++r<i;){var s=t[r];this.set(s[0],s[1])}}Cn.prototype.clear=Sb;Cn.prototype.delete=Ob;Cn.prototype.get=Mb;Cn.prototype.has=Fb;Cn.prototype.set=Bb;function Gb(){this.__data__=[],this.size=0}function is(t,r){for(var i=t.length;i--;)if($c(t[i][0],r))return i;return-1}var Vb=Array.prototype,$b=Vb.splice;function Wb(t){var r=this.__data__,i=is(r,t);if(i<0)return!1;var s=r.length-1;return i==s?r.pop():$b.call(r,i,1),--this.size,!0}function Xb(t){var r=this.__data__,i=is(r,t);return i<0?void 0:r[i][1]}function Hb(t){return is(this.__data__,t)>-1}function qb(t,r){var i=this.__data__,s=is(i,t);return s<0?(++this.size,i.push([t,r])):i[s][1]=r,this}function on(t){var r=-1,i=t==null?0:t.length;for(this.clear();++r<i;){var s=t[r];this.set(s[0],s[1])}}on.prototype.clear=Gb;on.prototype.delete=Wb;on.prototype.get=Xb;on.prototype.has=Hb;on.prototype.set=qb;var Xr=Vn(an,"Map");function zb(){this.size=0,this.__data__={hash:new Cn,map:new(Xr||on),string:new Cn}}function Kb(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}function ss(t,r){var i=t.__data__;return Kb(r)?i[typeof r=="string"?"string":"hash"]:i.map}function Yb(t){var r=ss(this,t).delete(t);return this.size-=r?1:0,r}function Jb(t){return ss(this,t).get(t)}function Qb(t){return ss(this,t).has(t)}function Zb(t,r){var i=ss(this,t),s=i.size;return i.set(t,r),this.size+=i.size==s?0:1,this}function un(t){var r=-1,i=t==null?0:t.length;for(this.clear();++r<i;){var s=t[r];this.set(s[0],s[1])}}un.prototype.clear=zb;un.prototype.delete=Yb;un.prototype.get=Jb;un.prototype.has=Qb;un.prototype.set=Zb;var jb="Expected a function";function Qa(t,r){if(typeof t!="function"||r!=null&&typeof r!="function")throw new TypeError(jb);var i=function(){var s=arguments,o=r?r.apply(this,s):s[0],l=i.cache;if(l.has(o))return l.get(o);var f=t.apply(this,s);return i.cache=l.set(o,f)||l,f};return i.cache=new(Qa.Cache||un),i}Qa.Cache=un;var em=500;function tm(t){var r=Qa(t,function(s){return i.size===em&&i.clear(),s}),i=r.cache;return r}var nm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rm=/\\(\\)?/g,im=tm(function(t){var r=[];return t.charCodeAt(0)===46&&r.push(""),t.replace(nm,function(i,s,o,l){r.push(o?l.replace(rm,"$1"):s||i)}),r});function sm(t){return t==null?"":Bc(t)}function Jc(t,r){return Pt(t)?t:Ja(t,r)?[t]:im(sm(t))}function as(t){if(typeof t=="string"||ts(t))return t;var r=t+"";return r=="0"&&1/t==-1/0?"-0":r}function Qc(t,r){r=Jc(r,t);for(var i=0,s=r.length;t!=null&&i<s;)t=t[as(r[i++])];return i&&i==s?t:void 0}function Zc(t,r,i){var s=t==null?void 0:Qc(t,r);return s===void 0?i:s}function jc(t,r){for(var i=-1,s=r.length,o=t.length;++i<s;)t[o+i]=r[i];return t}var sc=Gt?Gt.isConcatSpreadable:void 0;function am(t){return Pt(t)||Ka(t)||!!(sc&&t&&t[sc])}function om(t,r,i,s,o){var l=-1,f=t.length;for(i||(i=am),o||(o=[]);++l<f;){var d=t[l];i(d)?jc(o,d):o[o.length]=d}return o}function ac(t){var r=t==null?0:t.length;return r?om(t):[]}function um(){this.__data__=new on,this.size=0}function lm(t){var r=this.__data__,i=r.delete(t);return this.size=r.size,i}function cm(t){return this.__data__.get(t)}function fm(t){return this.__data__.has(t)}var hm=200;function pm(t,r){var i=this.__data__;if(i instanceof on){var s=i.__data__;if(!Xr||s.length<hm-1)return s.push([t,r]),this.size=++i.size,this;i=this.__data__=new un(s)}return i.set(t,r),this.size=i.size,this}function rn(t){var r=this.__data__=new on(t);this.size=r.size}rn.prototype.clear=um;rn.prototype.delete=lm;rn.prototype.get=cm;rn.prototype.has=fm;rn.prototype.set=pm;function ef(t,r){for(var i=-1,s=t==null?0:t.length,o=0,l=[];++i<s;){var f=t[i];r(f,i,t)&&(l[o++]=f)}return l}function dm(){return[]}var Em=Object.prototype,_m=Em.propertyIsEnumerable,oc=Object.getOwnPropertySymbols,gm=oc?function(t){return t==null?[]:(t=Object(t),ef(oc(t),function(r){return _m.call(t,r)}))}:dm;function Nm(t,r,i){var s=r(t);return Pt(t)?s:jc(s,i(t))}function uc(t){return Nm(t,Ya,gm)}var Ca=Vn(an,"DataView"),Ba=Vn(an,"Promise"),Ga=Vn(an,"Set"),lc="[object Map]",Tm="[object Object]",cc="[object Promise]",fc="[object Set]",hc="[object WeakMap]",pc="[object DataView]",vm=Gn(Ca),bm=Gn(Xr),mm=Gn(Ba),Im=Gn(Ga),Am=Gn(ka),bn=lr;(Ca&&bn(new Ca(new ArrayBuffer(1)))!=pc||Xr&&bn(new Xr)!=lc||Ba&&bn(Ba.resolve())!=cc||Ga&&bn(new Ga)!=fc||ka&&bn(new ka)!=hc)&&(bn=function(t){var r=lr(t),i=r==Tm?t.constructor:void 0,s=i?Gn(i):"";if(s)switch(s){case vm:return pc;case bm:return lc;case mm:return cc;case Im:return fc;case Am:return hc}return r});var dc=an.Uint8Array,wm="__lodash_hash_undefined__";function Lm(t){return this.__data__.set(t,wm),this}function ym(t){return this.__data__.has(t)}function Yi(t){var r=-1,i=t==null?0:t.length;for(this.__data__=new un;++r<i;)this.add(t[r])}Yi.prototype.add=Yi.prototype.push=Lm;Yi.prototype.has=ym;function xm(t,r){for(var i=-1,s=t==null?0:t.length;++i<s;)if(r(t[i],i,t))return!0;return!1}function Sm(t,r){return t.has(r)}var Om=1,Pm=2;function tf(t,r,i,s,o,l){var f=i&Om,d=t.length,m=r.length;if(d!=m&&!(f&&m>d))return!1;var I=l.get(t),T=l.get(r);if(I&&T)return I==r&&T==t;var y=-1,$=!0,J=i&Pm?new Yi:void 0;for(l.set(t,r),l.set(r,t);++y<d;){var ne=t[y],re=r[y];if(s)var j=f?s(re,ne,y,r,t,l):s(ne,re,y,t,r,l);if(j!==void 0){if(j)continue;$=!1;break}if(J){if(!xm(r,function(de,et){if(!Sm(J,et)&&(ne===de||o(ne,de,i,s,l)))return J.push(et)})){$=!1;break}}else if(!(ne===re||o(ne,re,i,s,l))){$=!1;break}}return l.delete(t),l.delete(r),$}function Rm(t){var r=-1,i=Array(t.size);return t.forEach(function(s,o){i[++r]=[o,s]}),i}function Dm(t){var r=-1,i=Array(t.size);return t.forEach(function(s){i[++r]=s}),i}var Mm=1,Um=2,km="[object Boolean]",Fm="[object Date]",Cm="[object Error]",Bm="[object Map]",Gm="[object Number]",Vm="[object RegExp]",$m="[object Set]",Wm="[object String]",Xm="[object Symbol]",Hm="[object ArrayBuffer]",qm="[object DataView]",Ec=Gt?Gt.prototype:void 0,Ua=Ec?Ec.valueOf:void 0;function zm(t,r,i,s,o,l,f){switch(i){case qm:if(t.byteLength!=r.byteLength||t.byteOffset!=r.byteOffset)return!1;t=t.buffer,r=r.buffer;case Hm:return!(t.byteLength!=r.byteLength||!l(new dc(t),new dc(r)));case km:case Fm:case Gm:return $c(+t,+r);case Cm:return t.name==r.name&&t.message==r.message;case Vm:case Wm:return t==r+"";case Bm:var d=Rm;case $m:var m=s&Mm;if(d||(d=Dm),t.size!=r.size&&!m)return!1;var I=f.get(t);if(I)return I==r;s|=Um,f.set(t,r);var T=tf(d(t),d(r),s,o,l,f);return f.delete(t),T;case Xm:if(Ua)return Ua.call(t)==Ua.call(r)}return!1}var Km=1,Ym=Object.prototype,Jm=Ym.hasOwnProperty;function Qm(t,r,i,s,o,l){var f=i&Km,d=uc(t),m=d.length,I=uc(r),T=I.length;if(m!=T&&!f)return!1;for(var y=m;y--;){var $=d[y];if(!(f?$ in r:Jm.call(r,$)))return!1}var J=l.get(t),ne=l.get(r);if(J&&ne)return J==r&&ne==t;var re=!0;l.set(t,r),l.set(r,t);for(var j=f;++y<m;){$=d[y];var de=t[$],et=r[$];if(s)var ht=f?s(et,de,$,r,t,l):s(de,et,$,t,r,l);if(!(ht===void 0?de===et||o(de,et,i,s,l):ht)){re=!1;break}j||(j=$=="constructor")}if(re&&!j){var Rt=t.constructor,ze=r.constructor;Rt!=ze&&"constructor"in t&&"constructor"in r&&!(typeof Rt=="function"&&Rt instanceof Rt&&typeof ze=="function"&&ze instanceof ze)&&(re=!1)}return l.delete(t),l.delete(r),re}var Zm=1,_c="[object Arguments]",gc="[object Array]",qi="[object Object]",jm=Object.prototype,Nc=jm.hasOwnProperty;function eI(t,r,i,s,o,l){var f=Pt(t),d=Pt(r),m=f?gc:bn(t),I=d?gc:bn(r);m=m==_c?qi:m,I=I==_c?qi:I;var T=m==qi,y=I==qi,$=m==I;if($&&Fa(t)){if(!Fa(r))return!1;f=!0,T=!1}if($&&!T)return l||(l=new rn),f||Kc(t)?tf(t,r,i,s,o,l):zm(t,r,m,i,s,o,l);if(!(i&Zm)){var J=T&&Nc.call(t,"__wrapped__"),ne=y&&Nc.call(r,"__wrapped__");if(J||ne){var re=J?t.value():t,j=ne?r.value():r;return l||(l=new rn),o(re,j,i,s,l)}}return $?(l||(l=new rn),Qm(t,r,i,s,o,l)):!1}function Za(t,r,i,s,o){return t===r?!0:t==null||r==null||!Fn(t)&&!Fn(r)?t!==t&&r!==r:eI(t,r,i,s,Za,o)}var tI=1,nI=2;function rI(t,r,i,s){var o=i.length,l=o;if(t==null)return!l;for(t=Object(t);o--;){var f=i[o];if(f[2]?f[1]!==t[f[0]]:!(f[0]in t))return!1}for(;++o<l;){f=i[o];var d=f[0],m=t[d],I=f[1];if(f[2]){if(m===void 0&&!(d in t))return!1}else{var T=new rn,y;if(!(y===void 0?Za(I,m,tI|nI,s,T):y))return!1}}return!0}function nf(t){return t===t&&!ar(t)}function iI(t){for(var r=Ya(t),i=r.length;i--;){var s=r[i],o=t[s];r[i]=[s,o,nf(o)]}return r}function rf(t,r){return function(i){return i==null?!1:i[t]===r&&(r!==void 0||t in Object(i))}}function sI(t){var r=iI(t);return r.length==1&&r[0][2]?rf(r[0][0],r[0][1]):function(i){return i===t||rI(i,t,r)}}function aI(t,r){return t!=null&&r in Object(t)}function oI(t,r,i){r=Jc(r,t);for(var s=-1,o=r.length,l=!1;++s<o;){var f=as(r[s]);if(!(l=t!=null&&i(t,f)))break;t=t[f]}return l||++s!=o?l:(o=t==null?0:t.length,!!o&&za(o)&&Vc(f,o)&&(Pt(t)||Ka(t)))}function uI(t,r){return t!=null&&oI(t,r,aI)}var lI=1,cI=2;function fI(t,r){return Ja(t)&&nf(r)?rf(as(t),r):function(i){var s=Zc(i,t);return s===void 0&&s===r?uI(i,t):Za(r,s,lI|cI)}}function sf(t){return function(r){return r?.[t]}}function hI(t){return function(r){return Qc(r,t)}}function pI(t){return Ja(t)?sf(as(t)):hI(t)}function af(t){return typeof t=="function"?t:t==null?ns:typeof t=="object"?Pt(t)?fI(t[0],t[1]):sI(t):pI(t)}function dI(t,r,i,s){for(var o=-1,l=t==null?0:t.length;++o<l;){var f=t[o];r(s,f,i(f),t)}return s}function EI(t){return function(r,i,s){for(var o=-1,l=Object(r),f=s(r),d=f.length;d--;){var m=f[++o];if(i(l[m],m,l)===!1)break}return r}}var of=EI();function _I(t,r){return t&&of(t,r,Ya)}function gI(t,r){return function(i,s){if(i==null)return i;if(!rs(i))return t(i,s);for(var o=i.length,l=-1,f=Object(i);++l<o&&s(f[l],l,f)!==!1;);return i}}var NI=gI(_I);function TI(t,r,i,s){return NI(t,function(o,l,f){r(s,o,i(o),f)}),s}function vI(t,r){return function(i,s){var o=Pt(i)?dI:TI,l=r?r():{};return o(i,t,af(s),l)}}function bI(t){return Fn(t)&&rs(t)}function me(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}function mI(t){return typeof t=="function"?t:ns}var II=Math.max,AI=Math.min;function wI(t,r,i){var s=t==null?0:t.length;if(!s)return-1;var o=s-1;return i!==void 0&&(o=iv(i),o=i<0?II(s+o,0):AI(o,s-1)),Sv(t,af(r),o)}function LI(t){return t&&t.length?t[0]:void 0}function Hr(t,r){return t==null?t:of(t,mI(r),Lb)}var ft=vI(function(t,r,i){t[i?0:1].push(r)},function(){return[[],[]]}),yI=Math.max;function xI(t){if(!(t&&t.length))return[];var r=0;return t=ef(t,function(i){if(bI(i))return r=yI(i.length,r),!0}),Xc(r,function(i){return Cc(t,sf(i))})}var Va=Dv(xI),A=(t=>(t.SPACE="<space>",t.TAB="<tab>",t.NEWLINE="<newline>",t.COMMA="<comma>",t.LPAREN="<lparen>",t.RPAREN="<rparen>",t.LBRACE="<lbrace>",t.RBRACE="<rbrace>",t.LBRACKET="<lbracket>",t.RBRACKET="<rbracket>",t.LANGLE="<langle>",t.RANGLE="<rangle>",t.OP="<op>",t.EOF="<eof>",t.NUMERIC_LITERAL="<number>",t.STRING_LITERAL="<string>",t.COLOR_LITERAL="<color>",t.FUNCTION_EXPRESSION="<function-expression>",t.QUOTED_STRING="<variable>",t.IDENTIFIER="<identifier>",t.SEMICOLON="<semicolon>",t.COLON="<colon>",t.SINGLE_LINE_COMMENT="<single-line-comment>",t.MULTILINE_COMMENT="<multiline-comment>",t))(A||{});function SI(t){switch(t.kind){case"<newline>":case"<space>":case"<tab>":case"<single-line-comment>":case"<multiline-comment>":return!0;default:return!1}}function OI(t){if(!t)return!1;switch(t){case"+":case"-":case"*":case"/":case"%":case"<":case">":case"=":case"!":case".":case"&":case"|":case"~":return!0;default:return!1}}function Tc(t){return t!==void 0&&t.kind==="<op>"}class Ze{constructor(r,i,s,o,l){this.kind=r,this.startPos=i,this.endPos=s,this.value=o,this.leadingTrivia=[],this.trailingTrivia=[],this.leadingInvalid=[],this.trailingInvalid=[],this.isInvalid=l,this.start=i.offset,this.end=s.offset}static create(r,i,s,o,l){return new Ze(r,i,s,o,l)}}function uf(t){return t.trailingTrivia.find(({kind:r})=>r===A.NEWLINE)!==void 0}function vc(t,r){return r.leadingTrivia.find(({kind:s})=>s===A.NEWLINE)!==void 0||uf(t)}function $a(t){return t.trailingTrivia.find(({kind:r})=>[A.SPACE,A.TAB].includes(r))!==void 0}function lf(t){return t.trailingTrivia.length===0?t.end:lf(me(t.trailingTrivia))}function cf(t){return t.leadingTrivia.length===0?t.start:cf(t.leadingTrivia[0])}function PI(t){return[A.SINGLE_LINE_COMMENT,A.MULTILINE_COMMENT].includes(t.kind)}class RI{constructor(){this.id=0}reset(){this.id=0}nextId(){return this.id++}}class Te{constructor(r,i,s){this.id=r,this.kind=i;const o=s.find(f=>f!==void 0&&!Number.isNaN(f.start));o?(this.startPos=o.startPos,this.fullStart=o instanceof Ze?cf(o):o.fullStart):(this.startPos={offset:NaN,column:NaN,line:NaN},this.fullStart=NaN);const l=[...s].reverse().find(f=>f!==void 0&&!Number.isNaN(f.end));l?(this.endPos=l.endPos,this.fullEnd=l instanceof Ze?lf(l):l.fullEnd):(this.endPos={offset:NaN,column:NaN,line:NaN},this.fullEnd=NaN),this.start=this.startPos.offset,this.end=this.endPos.offset}}var kn=(t=>(t.PROGRAM="<program>",t.ELEMENT_DECLARATION="<element-declaration>",t.ATTRIBUTE="<attribute>",t.IDENTIFIER_STREAM="<identifer-stream>",t.LITERAL="<literal>",t.VARIABLE="<variable>",t.PREFIX_EXPRESSION="<prefix-expression>",t.INFIX_EXPRESSION="<infix-expression>",t.POSTFIX_EXPRESSION="<postfix-expression>",t.FUNCTION_EXPRESSION="<function-expression>",t.FUNCTION_APPLICATION="<function-application>",t.BLOCK_EXPRESSION="<block-expression>",t.LIST_EXPRESSION="<list-expression>",t.TUPLE_EXPRESSION="<tuple-expression>",t.CALL_EXPRESSION="<call-expression>",t.PRIMARY_EXPRESSION="<primary-expression>",t.GROUP_EXPRESSION="<group-expression>",t.DUMMY="<dummy>",t.ARRAY="<array>",t))(kn||{});class qe extends Te{constructor({body:r=[],eof:i},s){super(s,"<program>",[...r,i]),this.body=r,this.eof=i}}class se extends Te{constructor({type:r,name:i,as:s,alias:o,attributeList:l,bodyColon:f,body:d},m){if(super(m,"<element-declaration>",[r,i,s,o,l,f,d]),d&&f&&!(d instanceof W||d instanceof se))throw new Error("If an element has a simple body, it must be a function application node");this.type=r,this.name=i,this.as=s,this.alias=o,this.attributeList=l,this.bodyColon=f,this.body=d}}class xt extends Te{constructor({identifiers:r=[]},i){super(i,"<identifer-stream>",r||[]),this.identifiers=r}}class St extends Te{constructor({name:r,colon:i,value:s},o){super(o,"<attribute>",[r,i,s]),this.name=r,this.value=s,this.colon=i}}class je extends Te{constructor({op:r,expression:i},s){super(s,"<prefix-expression>",[r,i]),this.op=r,this.expression=i}}class Vt extends Te{constructor({op:r,leftExpression:i,rightExpression:s},o){super(o,"<infix-expression>",[i,r,s]),this.op=r,this.leftExpression=i,this.rightExpression=s}}class os extends Te{constructor({op:r,expression:i},s){super(s,"<postfix-expression>",[i,r]),this.op=r,this.expression=i}}class bt extends Te{constructor({value:r},i){super(i,"<function-expression>",[r]),this.value=r}}class W extends Te{constructor({callee:r,args:i=[]},s){super(s,"<function-application>",[r,...i]),this.callee=r,this.args=i}}class ke extends Te{constructor({blockOpenBrace:r,body:i=[],blockCloseBrace:s},o){super(o,"<block-expression>",[r,...i,s]),this.blockOpenBrace=r,this.body=i,this.blockCloseBrace=s}}class _e extends Te{constructor({listOpenBracket:r,elementList:i=[],commaList:s=[],listCloseBracket:o},l){super(l,"<list-expression>",[r,...ff(i,s),o]),this.listOpenBracket=r,this.elementList=i,this.commaList=s,this.listCloseBracket=o}}class Wt extends Te{constructor({tupleOpenParen:r,elementList:i=[],commaList:s=[],tupleCloseParen:o},l){super(l,"<tuple-expression>",[r,...ff(i,s),o]),this.tupleOpenParen=r,this.elementList=i,this.commaList=s,this.tupleCloseParen=o}}class ja extends Wt{constructor({groupOpenParen:r,expression:i,groupCloseParen:s},o){super({tupleOpenParen:r,elementList:i&&[i],commaList:[],tupleCloseParen:s},o),this.kind="<group-expression>"}}class He extends Te{constructor({callee:r,argumentList:i},s){super(s,"<call-expression>",[r,i]),this.callee=r,this.argumentList=i}}class cr extends Te{constructor({literal:r},i){super(i,"<literal>",[r]),this.literal=r}}class ln extends Te{constructor({variable:r},i){super(i,"<variable>",[r]),this.variable=r}}class lt extends Te{constructor({expression:r},i){super(i,"<primary-expression>",[r]),this.expression=r}}class Br extends Te{constructor({pre:r},i){const s=Ze.create(A.SPACE,r.endPos,r.endPos," ",!1);super(i,"<dummy>",[s])}}class Bt extends Te{constructor({expression:r,indexer:i},s){super(s,"<array>",[r,i]),this.array=r,this.indexer=i}}function ff(t,r){if(!t||t.length===0)return r||[];if(!r||r.length===0)return t||[];const[i]=t,[s]=r;return(i.start<s.start?ac(Va(t,r)):ac(Va(r,t))).filter(o=>o!==null)}function DI(t,r=!1){return JSON.stringify(t,function(i,s){return!(this instanceof qe)&&i==="symbol"?s?.id:i==="symbol"?{symbolTable:s?.symbolTable,id:s?.id,references:s?.references.map(o=>o.id),declaration:s?.declaration?.id}:i==="referee"||i==="parent"||i==="declaration"?s?.id:i==="symbolTable"?Object.fromEntries(s.table):s},r?2:0)}class MI{constructor(){this.id=0}reset(){this.id=0}nextId(){return this.id++}}class eo{constructor({symbolTable:r},i){this.references=[],this.id=i,this.symbolTable=r}}class hf{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class pf{constructor({declaration:r},i){this.references=[],this.id=i,this.declaration=r}}class qr{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class to{constructor({declaration:r},i){this.references=[],this.id=i,this.declaration=r}}class df{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class Ef{constructor({declaration:r},i){this.references=[],this.id=i,this.declaration=r}}class _f{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class gf{constructor({symbolTable:r,declaration:i},s){this.references=[],this.id=s,this.symbolTable=r,this.declaration=i}}class Nf{constructor({declaration:r,tablePartialSymbol:i},s){this.references=[],this.id=s,this.declaration=r,this.tablePartialSymbol=i}}var _=(t=>(t[t.UNKNOWN_SYMBOL=1e3]="UNKNOWN_SYMBOL",t[t.UNEXPECTED_SYMBOL=1001]="UNEXPECTED_SYMBOL",t[t.UNEXPECTED_EOF=1002]="UNEXPECTED_EOF",t[t.UNEXPECTED_NEWLINE=1003]="UNEXPECTED_NEWLINE",t[t.UNKNOWN_TOKEN=1004]="UNKNOWN_TOKEN",t[t.UNEXPECTED_TOKEN=1005]="UNEXPECTED_TOKEN",t[t.UNEXPECTED_ELEMENT_DECLARATION=1006]="UNEXPECTED_ELEMENT_DECLARATION",t[t.MISSING_SPACES=1007]="MISSING_SPACES",t[t.UNKNOWN_PREFIX_OP=1008]="UNKNOWN_PREFIX_OP",t[t.INVALID_OPERAND=1009]="INVALID_OPERAND",t[t.EMPTY_ATTRIBUTE_NAME=1010]="EMPTY_ATTRIBUTE_NAME",t[t.INVALID_ESCAPE_SEQUENCE=1011]="INVALID_ESCAPE_SEQUENCE",t[t.INVALID_NAME=3e3]="INVALID_NAME",t[t.UNEXPECTED_NAME=3001]="UNEXPECTED_NAME",t[t.NAME_NOT_FOUND=3002]="NAME_NOT_FOUND",t[t.DUPLICATE_NAME=3003]="DUPLICATE_NAME",t[t.INVALID_ALIAS=3004]="INVALID_ALIAS",t[t.UNEXPECTED_ALIAS=3005]="UNEXPECTED_ALIAS",t[t.UNEXPECTED_SETTINGS=3006]="UNEXPECTED_SETTINGS",t[t.INVALID_SETTINGS=3007]="INVALID_SETTINGS",t[t.UNEXPECTED_SIMPLE_BODY=3008]="UNEXPECTED_SIMPLE_BODY",t[t.UNEXPECTED_COMPLEX_BODY=3009]="UNEXPECTED_COMPLEX_BODY",t[t.INVALID_TABLE_CONTEXT=3010]="INVALID_TABLE_CONTEXT",t[t.UNKNOWN_TABLE_SETTING=3011]="UNKNOWN_TABLE_SETTING",t[t.DUPLICATE_TABLE_SETTING=3012]="DUPLICATE_TABLE_SETTING",t[t.INVALID_TABLEGROUP_CONTEXT=3013]="INVALID_TABLEGROUP_CONTEXT",t[t.INVALID_TABLEGROUP_ELEMENT_NAME=3014]="INVALID_TABLEGROUP_ELEMENT_NAME",t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME=3015]="DUPLICATE_TABLEGROUP_ELEMENT_NAME",t[t.DUPLICATE_TABLEGROUP_FIELD_NAME=3016]="DUPLICATE_TABLEGROUP_FIELD_NAME",t[t.INVALID_TABLEGROUP_FIELD=3017]="INVALID_TABLEGROUP_FIELD",t[t.EMPTY_TABLE=3018]="EMPTY_TABLE",t[t.INVALID_COLUMN=3019]="INVALID_COLUMN",t[t.INVALID_COLUMN_NAME=3020]="INVALID_COLUMN_NAME",t[t.UNKNOWN_COLUMN_SETTING=3021]="UNKNOWN_COLUMN_SETTING",t[t.INVALID_COLUMN_TYPE=3022]="INVALID_COLUMN_TYPE",t[t.DUPLICATE_COLUMN_NAME=3023]="DUPLICATE_COLUMN_NAME",t[t.DUPLICATE_COLUMN_SETTING=3024]="DUPLICATE_COLUMN_SETTING",t[t.INVALID_COLUMN_SETTING_VALUE=3025]="INVALID_COLUMN_SETTING_VALUE",t[t.INVALID_ENUM_CONTEXT=3026]="INVALID_ENUM_CONTEXT",t[t.INVALID_ENUM_ELEMENT_NAME=3027]="INVALID_ENUM_ELEMENT_NAME",t[t.INVALID_ENUM_ELEMENT=3028]="INVALID_ENUM_ELEMENT",t[t.DUPLICATE_ENUM_ELEMENT_NAME=3029]="DUPLICATE_ENUM_ELEMENT_NAME",t[t.UNKNOWN_ENUM_ELEMENT_SETTING=3030]="UNKNOWN_ENUM_ELEMENT_SETTING",t[t.DUPLICATE_ENUM_ELEMENT_SETTING=3031]="DUPLICATE_ENUM_ELEMENT_SETTING",t[t.INVALID_ENUM_ELEMENT_SETTING=3032]="INVALID_ENUM_ELEMENT_SETTING",t[t.EMPTY_ENUM=3033]="EMPTY_ENUM",t[t.INVALID_REF_CONTEXT=3034]="INVALID_REF_CONTEXT",t[t.UNKNOWN_REF_SETTING=3035]="UNKNOWN_REF_SETTING",t[t.DUPLICATE_REF_SETTING=3036]="DUPLICATE_REF_SETTING",t[t.INVALID_REF_SETTING_VALUE=3037]="INVALID_REF_SETTING_VALUE",t[t.INVALID_REF_RELATIONSHIP=3038]="INVALID_REF_RELATIONSHIP",t[t.INVALID_REF_FIELD=3039]="INVALID_REF_FIELD",t[t.EMPTY_REF=3040]="EMPTY_REF",t[t.REF_REDEFINED=3041]="REF_REDEFINED",t[t.INVALID_NOTE_CONTEXT=3042]="INVALID_NOTE_CONTEXT",t[t.INVALID_NOTE=3043]="INVALID_NOTE",t[t.NOTE_REDEFINED=3044]="NOTE_REDEFINED",t[t.NOTE_CONTENT_REDEFINED=3045]="NOTE_CONTENT_REDEFINED",t[t.EMPTY_NOTE=3046]="EMPTY_NOTE",t[t.INVALID_INDEXES_CONTEXT=3047]="INVALID_INDEXES_CONTEXT",t[t.INVALID_INDEXES_FIELD=3048]="INVALID_INDEXES_FIELD",t[t.INVALID_INDEX=3049]="INVALID_INDEX",t[t.UNKNOWN_INDEX_SETTING=3050]="UNKNOWN_INDEX_SETTING",t[t.DUPLICATE_INDEX_SETTING=3051]="DUPLICATE_INDEX_SETTING",t[t.UNEXPECTED_INDEX_SETTING_VALUE=3052]="UNEXPECTED_INDEX_SETTING_VALUE",t[t.INVALID_INDEX_SETTING_VALUE=3053]="INVALID_INDEX_SETTING_VALUE",t[t.INVALID_PROJECT_CONTEXT=3054]="INVALID_PROJECT_CONTEXT",t[t.PROJECT_REDEFINED=3055]="PROJECT_REDEFINED",t[t.INVALID_PROJECT_FIELD=3056]="INVALID_PROJECT_FIELD",t[t.INVALID_CUSTOM_CONTEXT=3057]="INVALID_CUSTOM_CONTEXT",t[t.INVALID_CUSTOM_ELEMENT_VALUE=3058]="INVALID_CUSTOM_ELEMENT_VALUE",t[t.INVALID_ELEMENT_IN_SIMPLE_BODY=3059]="INVALID_ELEMENT_IN_SIMPLE_BODY",t[t.INVALID_TABLE_PARTIAL_CONTEXT=3060]="INVALID_TABLE_PARTIAL_CONTEXT",t[t.INVALID_TABLE_PARTIAL_ELEMENT_NAME=3061]="INVALID_TABLE_PARTIAL_ELEMENT_NAME",t[t.INVALID_TABLE_PARTIAL_SETTING_VALUE=3062]="INVALID_TABLE_PARTIAL_SETTING_VALUE",t[t.DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME=3063]="DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME",t[t.DUPLICATE_TABLE_PARTIAL_SETTING=3064]="DUPLICATE_TABLE_PARTIAL_SETTING",t[t.INVALID_TABLE_PARTIAL_INJECTION=3065]="INVALID_TABLE_PARTIAL_INJECTION",t[t.INVALID_TABLE_PARTIAL_INJECTION_OP=3066]="INVALID_TABLE_PARTIAL_INJECTION_OP",t[t.INVALID_TABLE_PARTIAL_INJECTION_NAME=3067]="INVALID_TABLE_PARTIAL_INJECTION_NAME",t[t.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME=3068]="DUPLICATE_TABLE_PARTIAL_INJECTION_NAME",t[t.UNKNOWN_TABLE_PARTIAL_SETTING=3069]="UNKNOWN_TABLE_PARTIAL_SETTING",t[t.INVALID_TABLE_SETTING_VALUE=3070]="INVALID_TABLE_SETTING_VALUE",t[t.INVALID_CHECKS_CONTEXT=3071]="INVALID_CHECKS_CONTEXT",t[t.INVALID_CHECKS_FIELD=3072]="INVALID_CHECKS_FIELD",t[t.INVALID_CHECK=3073]="INVALID_CHECK",t[t.UNKNOWN_CHECK_SETTING=3074]="UNKNOWN_CHECK_SETTING",t[t.DUPLICATE_CHECK_SETTING=3075]="DUPLICATE_CHECK_SETTING",t[t.INVALID_CHECK_SETTING_VALUE=3076]="INVALID_CHECK_SETTING_VALUE",t[t.BINDING_ERROR=4e3]="BINDING_ERROR",t[t.UNSUPPORTED=5e3]="UNSUPPORTED",t[t.CIRCULAR_REF=5001]="CIRCULAR_REF",t[t.SAME_ENDPOINT=5002]="SAME_ENDPOINT",t[t.UNEQUAL_FIELDS_BINARY_REF=5003]="UNEQUAL_FIELDS_BINARY_REF",t[t.CONFLICTING_SETTING=5004]="CONFLICTING_SETTING",t[t.TABLE_REAPPEAR_IN_TABLEGROUP=5005]="TABLE_REAPPEAR_IN_TABLEGROUP",t))(_||{});class g extends Error{constructor(r,i,s){super(i),this.code=r,this.diagnostic=i,this.nodeOrToken=s,this.start=s.start,this.end=s.end,this.name=this.constructor.name,Object.setPrototypeOf(this,g.prototype)}}class ct{constructor(r,i){this.value=r,this.errors=i===void 0?[]:i}getValue(){return this.value}getErrors(){return this.errors}chain(r){const i=r(this.value),s=[...this.errors,...i.errors];return new ct(i.value,s)}map(r){return new ct(r(this.value),this.errors)}}function Yr(t){return!!t.match(new RegExp("(\\p{L}|_|\\p{M})","gu"))}function or(t){if(!t)return!1;const r=t[0];return r>="0"&&r<="9"}function UI(t){const[r]=t;return or(r)||Yr(r)&&r.toLowerCase()>="a"&&r.toLowerCase()<="f"}function Un(t){return Yr(t)||or(t)}function kI(t){return t.split("").every(Un)?t:`"${t}"`}function bc(t,r){const i=[],s=Math.min(t.length,r.length);for(let o=0;o<s;o+=1)i.push(t[o],r[o]);return i.push(...t.slice(s),...r.slice(s)),i}function $r(t,r){return t>=r.start&&t<r.end}function Wa(t){return t instanceof je?`${t.op?.value}${Wa(t.expression)}`:t.expression.literal.value}function Xa(t){return t instanceof je?t.op?.value==="-"?-Xa(t.expression):Xa(t.expression):Number.parseFloat(t.expression.literal.value)}class ye{constructor(r){this.value=r}unwrap(){return this.value}unwrap_or(r){return this.value}and_then(r){return r(this.value)}map(r){return new ye(r(this.value))}isOk(){return!0}}class pe{constructor(){this.value=void 0}unwrap(){throw new Error("Trying to unwrap a None value")}unwrap_or(r){return r}and_then(r){return new pe}map(r){return new pe}isOk(){return!1}}const FI=["null","true","false"],Tf=["-","+"],$t="public";var F=(t=>(t.Table="table",t.Enum="enum",t.Ref="ref",t.Note="note",t.Project="project",t.Indexes="indexes",t.TableGroup="tablegroup",t.TablePartial="tablepartial",t.Check="checks",t))(F||{}),P=(t=>(t.Color="color",t.HeaderColor="headercolor",t.Note="note",t.PK="pk",t.PrimaryKey="primary key",t.Unique="unique",t.Ref="ref",t.NotNull="not null",t.Null="null",t.Increment="increment",t.Default="default",t.Name="name",t.Type="type",t.Check="check",t.Update="update",t.Delete="delete",t))(P||{});class CI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof qe||cn(this.declarationNode.parent).unwrap_or(void 0)!==F.Project?[new g(_.INVALID_CUSTOM_CONTEXT,"A Custom element can only appear in a Project",this.declarationNode)]:[]}validateName(r){return r?[new g(_.UNEXPECTED_NAME,"A Custom element shouldn't have a name",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_NAME,"A Custom element shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Custom element shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof ke)return[new g(_.UNEXPECTED_COMPLEX_BODY,"A Custom element can only have an inline field",r)];const i=[];return Fe(r.callee)||i.push(new g(_.INVALID_CUSTOM_ELEMENT_VALUE,"A Custom element value can only be a string",r)),r.args.length>0&&i.push(...r.args.map(s=>new g(_.INVALID_CUSTOM_ELEMENT_VALUE,"A Custom element value can only be a string",s))),i}}var U=(t=>(t.Schema="Schema",t.Table="Table",t.Column="Column",t.TableGroup="TableGroup",t.TableGroupField="TableGroup field",t.Enum="Enum",t.EnumField="Enum field",t.Note="Note",t.TablePartial="TablePartial",t.PartialInjection="PartialInjection",t))(U||{});function Jr(t){return`Schema:${t}`}function ur(t){return`Table:${t}`}function fr(t){return`Column:${t}`}function no(t){return`Enum:${t}`}function ro(t){return`Enum field:${t}`}function io(t){return`TableGroup:${t}`}function so(t){return`TableGroup field:${t}`}function BI(t){return`Note:${t}`}function ao(t){return`TablePartial:${t}`}function oo(t){return`PartialInjection:${t}`}function GI(t,r){switch(r){case"Column":return fr(t);case"Enum":return no(t);case"Enum field":return ro(t);case"Schema":return Jr(t);case"Table":return ur(t);case"TableGroup":return io(t);case"TableGroup field":return so(t);case"TablePartial":return ao(t);case"PartialInjection":return oo(t);default:throw new Error("Unreachable")}}function Qr(t){const[r,i]=t.split(":");return Object.values(U).includes(r)?new ye({name:i,kind:r}):new pe}class Bn{constructor(){this.table=new Map}has(r){return this.table.has(r)}set(r,i){this.table.set(r,i)}get(r,i){return this.table.get(r)||i!==void 0&&this.set(r,i)||i}entries(){return this.table.entries()}forEach(r){return this.table.forEach(r)}}class VI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_PROJECT_CONTEXT,"An Enum can only appear top-level",this.declarationNode)]:[]}validateName(r){return r?vf(r)?[]:[new g(_.INVALID_NAME,"An Enum name must be of the form <enum> or <schema>.<enum>",r)]:[new g(_.NAME_NOT_FOUND,"An Enum must have a name",this.declarationNode)]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"An Enum shouldn't have an alias",r)]:[]}registerElement(){const r=[];this.declarationNode.symbol=this.symbolFactory.create(hf,{declaration:this.declarationNode,symbolTable:new Bn});const{name:i}=this.declarationNode,s=Ge(i);if(s.isOk()){const o=s.unwrap(),l=o.pop(),f=us(o,this.publicSymbolTable,this.symbolFactory),d=no(l);f.has(d)&&r.push(new g(_.DUPLICATE_NAME,`Enum name ${l} already exists in schema '${o.join(".")||$t}'`,i)),f.set(d,this.declarationNode.symbol)}return r}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"An Enum shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return this.validateFields([r]);const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.length===0?[new g(_.EMPTY_ENUM,"An Enum must have at least one element",this.declarationNode)]:r.flatMap(i=>{const s=[];i.callee&&!we(i.callee)&&s.push(new g(_.INVALID_ENUM_ELEMENT_NAME,"An enum field must be an identifier or a quoted identifier",i.callee));const o=[...i.args];return me(o)instanceof _e?(s.push(...this.validateFieldSettings(me(o))),o.pop()):o[0]instanceof _e&&(s.push(...this.validateFieldSettings(o[0])),o.shift()),o.length>0&&s.push(...o.map(l=>new g(_.INVALID_ENUM_ELEMENT,"An Enum must have only a field and optionally a setting list",l))),s.push(...this.registerField(i)),s})}validateFieldSettings(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();for(const l in o){const f=o[l];switch(l){case"note":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_ENUM_ELEMENT_SETTING,"'note' can only appear once",d))),f.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_ENUM_ELEMENT_SETTING,"'note' must be a string",d))});break;default:f.forEach(d=>s.push(new g(_.UNKNOWN_ENUM_ELEMENT_SETTING,`Unknown enum field setting '${l}'`,d)))}}return s}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}registerField(r){if(r.callee&&we(r.callee)){const i=Me(r.callee).unwrap(),s=ro(i),o=this.symbolFactory.create(pf,{declaration:r});r.symbol=o;const l=this.declarationNode.symbol.symbolTable;if(l.has(s)){const f=l.get(s);return[new g(_.DUPLICATE_COLUMN_NAME,`Duplicate enum field ${i}`,r),new g(_.DUPLICATE_COLUMN_NAME,`Duplicate enum field ${i}`,f.declaration)]}l.set(s,o)}return[]}}class $I{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){const r=new g(_.INVALID_INDEXES_CONTEXT,"An Indexes can only appear inside a Table or a TablePartial",this.declarationNode);if(this.declarationNode.parent instanceof qe)return[r];const i=cn(this.declarationNode.parent).unwrap_or(void 0);return i&&[F.Table,F.TablePartial].includes(i)?[]:[r]}validateName(r){return r?[new g(_.UNEXPECTED_NAME,"An Indexes shouldn't have a name",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"An Indexes shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"An Indexes shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"An Indexes must have a complex body",r)];const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=[],o=[i.callee,...i.args];return me(o)instanceof _e&&s.push(...this.validateFieldSetting(o.pop())),o.forEach(l=>{for(;l instanceof He;)l.argumentList&&!Qi(l.argumentList).isOk()&&s.push(new g(_.INVALID_INDEXES_FIELD,"An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such",l.argumentList)),l=l.callee;Qi(l).isOk()||s.push(new g(_.INVALID_INDEXES_FIELD,"An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such",l))}),s})}validateFieldSetting(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();for(const l in o){const f=o[l];switch(l){case"note":case"name":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_INDEX_SETTING,`'${l}' can only appear once`,d))),f.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_INDEX_SETTING_VALUE,`'${l}' must be a string`,d))});break;case"unique":case"pk":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_INDEX_SETTING,`'${l}' can only appear once`,d))),f.forEach(d=>{ot(d.value)||s.push(new g(_.INVALID_INDEX_SETTING_VALUE,`'${l}' must not have a value`,d))});break;case"type":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_INDEX_SETTING,"'type' can only appear once",d))),f.forEach(d=>{we(d.value)||s.push(new g(_.INVALID_INDEX_SETTING_VALUE,`'type' must be "btree" or "hash"`,d))});break;default:f.forEach(d=>s.push(new g(_.UNKNOWN_INDEX_SETTING,`Unknown index setting '${l}'`,d)))}}return s}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}class WI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return!(this.declarationNode.parent instanceof qe)&&![F.Table,F.TableGroup,F.TablePartial,F.Project].includes(cn(this.declarationNode.parent).unwrap_or(void 0))?[new g(_.INVALID_NOTE_CONTEXT,"A Note can only appear inside a Table, a TableGroup, a TablePartial or a Project. Sticky note can only appear at the global scope.",this.declarationNode)]:[]}validateName(r){if(!(this.declarationNode.parent instanceof qe))return r?[new g(_.UNEXPECTED_NAME,"A Note shouldn't have a name",r)]:[];if(!r)return[new g(_.INVALID_NAME,"Sticky note must have a name",this.declarationNode)];const i=Ge(r);if(!i.isOk())return[new g(_.INVALID_NAME,"Invalid name for sticky note ",this.declarationNode)];const o=i.unwrap().join("."),l=BI(o);return this.publicSymbolTable.has(l)?[new g(_.DUPLICATE_NAME,`Sticky note "${o}" has already been defined`,r)]:(this.publicSymbolTable.set(l,this.declarationNode.symbol),[])}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A Ref shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Note shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return this.validateFields([r]);const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){const i=[];return r.length===0?[new g(_.EMPTY_NOTE,"A Note must have a content",this.declarationNode)]:(r.length>1&&r.slice(1).forEach(s=>i.push(new g(_.NOTE_CONTENT_REDEFINED,"A Note can only contain one string",s))),Fe(r[0].callee)||i.push(new g(_.INVALID_NOTE,"A Note content must be a quoted string",r[0])),r[0].args.length>0&&i.push(...r[0].args.map(s=>new g(_.INVALID_NOTE,"A Note can only contain one quoted string",s))),i)}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}class XI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_PROJECT_CONTEXT,"A Project can only appear top-level",this.declarationNode)]:[]}validateName(r){return r?hr(r)?[]:[new g(_.INVALID_NAME,"A Project's name is optional or must be an identifier or a quoted identifer",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A Project shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Project shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A Project's body must be a block",r)];const[i,s]=ft(r.body,o=>o instanceof W);return[...i.map(o=>new g(_.INVALID_PROJECT_FIELD,"A Project can not have inline fields",o)),...this.validateSubElements(s)]}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}class HI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof qe?[]:[new g(_.INVALID_REF_CONTEXT,"A Ref must appear top-level",this.declarationNode)]}validateName(r){return r?hr(r)?[]:[new g(_.INVALID_NAME,"A Ref's name is optional or must be an identifier or a quoted identifer",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A Ref shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Ref shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return this.validateFields([r]);const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){if(r.length===0)return[new g(_.EMPTY_REF,"A Ref must have at least one field",this.declarationNode)];const i=[];return r.length>1&&i.push(...r.slice(1).map(s=>new g(_.REF_REDEFINED,"A Ref can only contain one binary relationship",s))),r.forEach(s=>{if(s.callee&&!mc(s.callee)&&i.push(new g(_.INVALID_REF_FIELD,"A Ref field must be a binary relationship",s.callee)),s.callee&&mc(s.callee)){const l=ut(s.callee.leftExpression).unwrap_or({variables:[],tupleElements:[]}),f=l.variables.length+Math.min(l.tupleElements.length,1),d=ut(s.callee.rightExpression).unwrap_or({variables:[],tupleElements:[]}),m=d.variables.length+Math.min(d.tupleElements.length,1);f<2&&i.push(new g(_.INVALID_REF_FIELD,"Invalid column reference",s.callee.leftExpression||s.callee)),m<2&&i.push(new g(_.INVALID_REF_FIELD,"Invalid column reference",s.callee.rightExpression||s.callee))}s.callee&&!eA(s.callee)&&i.push(new g(_.UNEQUAL_FIELDS_BINARY_REF,"Unequal fields in ref endpoints",s.callee));const o=[...s.args];if(me(o)instanceof _e){const l=this.validateFieldSettings(me(o));i.push(...l),o.pop()}else o[0]instanceof _e&&(i.push(...this.validateFieldSettings(o[0])),o.shift());o.length>0&&i.push(...o.map(l=>new g(_.INVALID_REF_FIELD,"A Ref field should only have a single binary relationship",l)))}),i}validateFieldSettings(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();for(const l in o){const f=o[l];switch(l){case"delete":case"update":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_REF_SETTING,`'${l}' can only appear once`,d))),f.forEach(d=>{qI(d.value)||s.push(new g(_.INVALID_REF_SETTING_VALUE,`'${l}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`,d))});break;case"color":f.length>1&&s.push(...f.map(d=>new g(_.DUPLICATE_REF_SETTING,"'color' can only appear once",d))),f.forEach(d=>{ls(d.value)||s.push(new g(_.INVALID_REF_SETTING_VALUE,"'color' must be a color literal",d))});break;default:f.forEach(d=>s.push(new g(_.UNKNOWN_REF_SETTING,`Unknown ref setting '${l}'`,d)))}}return s}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}function qI(t){if(!(we(t)&&t.expression.variable.kind!==A.QUOTED_STRING)&&!(t instanceof xt))return!1;let r;if(t instanceof xt?r=zr(t).unwrap_or(""):r=t.expression.variable.value,r)switch(r.toLowerCase()){case"cascade":case"no action":case"set null":case"set default":case"restrict":return!0;default:return!1}return!1}class zI{constructor(r,i,s){this.declarationNode=r,this.symbolFactory=s,this.publicSymbolTable=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_TABLE_CONTEXT,"Table must appear top-level",this.declarationNode)]:[]}validateName(r){return r?r instanceof Bt?[new g(_.INVALID_NAME,"Invalid array as Table name, maybe you forget to add a space between the name and the setting list?",r)]:vf(r)?[]:[new g(_.INVALID_NAME,"A Table name must be of the form <table> or <schema>.<table>",r)]:[new g(_.NAME_NOT_FOUND,"A Table must have a name",this.declarationNode)]}validateAlias(r){return r?ZI(r)?[]:[new g(_.INVALID_ALIAS,"Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes",r)]:[]}validateSettingList(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();return Hr(o,(l,f)=>{switch(f){case P.HeaderColor:l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_SETTING,"'headercolor' can only appear once",d))),l.forEach(d=>{ls(d.value)||s.push(new g(_.INVALID_TABLE_SETTING_VALUE,"'headercolor' must be a color literal",d.value||d.name))});break;case P.Note:l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_SETTING,"'note' can only appear once",d))),l.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_TABLE_SETTING_VALUE,"'note' must be a string literal",d.value||d.name))});break;default:s.push(...l.map(d=>new g(_.UNKNOWN_TABLE_SETTING,`Unknown '${f}' setting`,d)))}}),s}registerElement(){const r=[];this.declarationNode.symbol=this.symbolFactory.create(qr,{declaration:this.declarationNode,symbolTable:new Bn});const{name:i,alias:s}=this.declarationNode,o=Ge(i);if(o.isOk()){const l=[...o.unwrap()],f=l.pop(),d=us(l,this.publicSymbolTable,this.symbolFactory),m=ur(f);d.has(m)&&r.push(new g(_.DUPLICATE_NAME,`Table name '${f}' already exists in schema '${l.join(".")||$t}'`,i)),d.set(m,this.declarationNode.symbol)}if(s&&hr(s)&&!KI(s.expression.variable.value,o.unwrap_or([]))){const l=Me(s).unwrap(),f=ur(l);this.publicSymbolTable.has(f)&&r.push(new g(_.DUPLICATE_NAME,`Table name '${l}' already exists`,i)),this.publicSymbolTable.set(f,this.declarationNode.symbol)}return r}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A Table's body must be a block",r)];const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){const i=o=>{const l=[];if(!o.callee)return[];o.args.length===0&&l.push(new g(_.INVALID_COLUMN,"A column must have a type",o.callee)),we(o.callee)||l.push(new g(_.INVALID_COLUMN_NAME,"A column name must be an identifier or a quoted identifier",o.callee)),o.args[0]&&!Af(o.args[0])&&l.push(new g(_.INVALID_COLUMN_TYPE,"Invalid column type",o.args[0]));const f=o.args.slice(1);return l.push(...this.validateFieldSetting(f)),l.push(...this.registerField(o)),l},s=o=>{const l=[];if(!o.callee)return[];if(!Ji(o.callee))l.push(new g(_.INVALID_TABLE_PARTIAL_INJECTION,"A partial injection should be of the form ~<table-partial>",o.callee));else{const f=Pe(o.callee.expression).unwrap_or(""),d=this.symbolFactory.create(gf,{symbolTable:new Bn,declaration:o}),m=oo(f),I=this.declarationNode.symbol.symbolTable;if(I.has(m)){const T=I.get(m);return[new g(_.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME,`Duplicate table partial injection '${f}'`,o),new g(_.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME,`Duplicate table partial injection '${f}'`,T.declaration)]}I.set(m,d)}return o.args.length&&l.push(...o.args.map(f=>new g(_.INVALID_TABLE_PARTIAL_INJECTION,"A partial injection does not have any trailing attributes",f))),l};return r.flatMap(o=>o.callee instanceof je&&o.callee.op?.value==="~"?s(o):i(o))}registerField(r){if(r.callee&&we(r.callee)){const i=Me(r.callee).unwrap(),s=fr(i),o=this.symbolFactory.create(to,{declaration:r});r.symbol=o;const l=this.declarationNode.symbol.symbolTable;if(l.has(s)){const f=l.get(s);return[new g(_.DUPLICATE_COLUMN_NAME,`Duplicate column ${i}`,r),new g(_.DUPLICATE_COLUMN_NAME,`Duplicate column ${i}`,f.declaration)]}l.set(s,o)}return[]}validateFieldSetting(r){if(!r.slice(0,-1).every(In)||!r.slice(-1).every(m=>In(m)||m instanceof _e))return[...r.map(m=>new g(_.INVALID_COLUMN,"These fields must be some inline settings optionally ended with a setting list",m))];if(r.length===0)return[];let i;me(r)instanceof _e&&(i=r.pop());const s=Ne(i),o=s.getErrors(),l=s.getValue();r.forEach(m=>{const I=Me(m).unwrap_or("").toLowerCase();if(I!=="pk"&&I!=="unique"){o.push(new g(_.INVALID_SETTINGS,"Inline column settings can only be `pk` or `unique`",m));return}l[I]===void 0?l[I]=[m]:l[I].push(m)});const f=l[P.PK]||[],d=l[P.PrimaryKey]||[];return f.length>=1&&d.length>=1&&o.push(...[...f,...d].map(m=>new g(_.DUPLICATE_COLUMN_SETTING,"Either one of 'primary key' and 'pk' can appear",m))),Hr(l,(m,I)=>{switch(I){case P.Note:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"note can only appear once",T))),m.forEach(T=>{Fe(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'note' must be a quoted string",T.value||T.name))});break;case P.Ref:m.forEach(T=>{If(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'ref' must be a valid unary relationship",T.value||T.name))});break;case P.PrimaryKey:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"primary key can only appear once",T))),m.forEach(T=>{ot(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'primary key' must not have a value",T.value||T.name))});break;case P.PK:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'pk' can only appear once",T))),m.forEach(T=>{T instanceof St&&!ot(T.value)&&o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'pk' must not have a value",T.value||T.name))});break;case P.NotNull:{m.length>1&&o.push(...m.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,"'not null' can only appear once",y)));const T=l[P.Null]||[];m.length>=1&&T.length>=1&&o.push(...[...m,...T].map(y=>new g(_.CONFLICTING_SETTING,"'not null' and 'null' can not be set at the same time",y))),m.forEach(y=>{ot(y.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'not null' must not have a value",y.value||y.name))});break}case P.Null:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'null' can only appear once",T))),m.forEach(T=>{ot(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'null' must not have a value",T.value||T.name))});break;case P.Unique:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'unique' can only appear once",T))),m.forEach(T=>{T instanceof St&&!ot(T.value)&&o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'unique' must not have a value",T.value||T.name))});break;case P.Increment:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'increment' can only appear once",T))),m.forEach(T=>{T instanceof St&&!ot(T.value)&&o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'increment' must not have a value",T.value||T.name))});break;case P.Default:m.length>1&&o.push(...m.map(T=>new g(_.DUPLICATE_COLUMN_SETTING,"'default' can only appear once",T))),m.forEach(T=>{mf(T.value)||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'default' must be an enum value, a string literal, number literal, function expression, true, false or null",T.value||T.name))});break;case P.Check:m.forEach(T=>{T.value instanceof bt||o.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'check' must be a function expression",T.value||T.name))});break;default:m.forEach(T=>o.push(new g(_.UNKNOWN_COLUMN_SETTING,`Unknown column setting '${I}'`,T)))}}),o}validateSubElements(r){const i=r.flatMap(o=>{if(o.parent=this.declarationNode,!o.type)return[];const l=Xt(o);return new l(o,this.publicSymbolTable,this.symbolFactory).validate()}),s=r.filter(o=>o.type?.value.toLowerCase()==="note");return s.length>1&&i.push(...s.map(o=>new g(_.NOTE_REDEFINED,"Duplicate notes are defined",o))),i}}function KI(t,r){return r.length===1&&t===r[0]}class YI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_TABLEGROUP_CONTEXT,"TableGroup must appear top-level",this.declarationNode)]:[]}validateName(r){return r?hr(r)?[]:[new g(_.INVALID_NAME,"A TableGroup name must be a single identifier",r)]:[new g(_.NAME_NOT_FOUND,"A TableGroup must have a name",this.declarationNode)]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A TableGroup shouldn't have an alias",r)]:[]}registerElement(){const{name:r}=this.declarationNode;this.declarationNode.symbol=this.symbolFactory.create(df,{declaration:this.declarationNode,symbolTable:new Bn});const i=Ge(r);if(i.isOk()){const s=i.unwrap(),o=s.pop(),l=us(s,this.publicSymbolTable,this.symbolFactory),f=io(o);if(l.has(f))return[new g(_.DUPLICATE_NAME,`TableGroup name '${o}' already exists`,r)];l.set(f,this.declarationNode.symbol)}return[]}validateSettingList(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();return Hr(o,(l,f)=>{switch(f){case"color":l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_SETTING,"'color' can only appear once",d))),l.forEach(d=>{ls(d.value)||s.push(new g(_.INVALID_TABLE_SETTING_VALUE,"'color' must be a color literal",d.value||d.name))});break;case"note":l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_SETTING,"'note' can only appear once",d))),l.filter(d=>!Fe(d.value)).forEach(d=>{s.push(new g(_.INVALID_TABLE_SETTING_VALUE,"'note' must be a string literal",d.value||d.name))});break;default:s.push(...l.map(d=>new g(_.UNKNOWN_TABLE_SETTING,`Unknown '${f}' setting`,d)));break}}),s}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A TableGroup's body must be a block",r)];const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.flatMap(i=>{const s=[];return i.callee&&!Ge(i.callee).isOk()&&s.push(new g(_.INVALID_TABLEGROUP_FIELD,"A TableGroup field must be of the form <table> or <schema>.<table>",i.callee)),this.registerField(i),i.args.length>0&&s.push(...i.args.map(o=>new g(_.INVALID_TABLEGROUP_FIELD,"A TableGroup field should only have a single Table name",o))),s})}validateSubElements(r){const i=r.flatMap(o=>{if(o.parent=this.declarationNode,!o.type)return[];const l=Xt(o);return new l(o,this.publicSymbolTable,this.symbolFactory).validate()}),s=r.filter(o=>o.type?.value.toLowerCase()==="note");return s.length>1&&i.push(...s.map(o=>new g(_.NOTE_REDEFINED,"Duplicate notes are defined",o))),i}registerField(r){if(r.callee&&we(r.callee)){const i=Me(r.callee).unwrap(),s=so(i),o=this.symbolFactory.create(Ef,{declaration:r});r.symbol=o;const l=this.declarationNode.symbol.symbolTable;if(l.has(s)){const f=l.get(s);return[new g(_.DUPLICATE_TABLEGROUP_FIELD_NAME,`${i} already exists in the group`,r),new g(_.DUPLICATE_TABLEGROUP_FIELD_NAME,`${i} already exists in the group`,f.declaration)]}l.set(s,o)}return[]}}class JI{constructor(r,i,s){this.declarationNode=r,this.symbolFactory=s,this.publicSymbolTable=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof se?[new g(_.INVALID_TABLE_PARTIAL_CONTEXT,"TablePartial must appear top-level",this.declarationNode)]:[]}validateName(r){return r?hr(r)?[]:[new g(_.INVALID_NAME,"A TablePartial name must be an identifier or a quoted identifer",r)]:[new g(_.NAME_NOT_FOUND,"A TablePartial must have a name",this.declarationNode)]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A TablePartial shouldn't have an alias",r)]:[]}validateSettingList(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();return Hr(o,(l,f)=>{switch(f){case P.HeaderColor:l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_PARTIAL_SETTING,`'${f}' can only appear once`,d))),l.forEach(d=>{ls(d.value)||s.push(new g(_.INVALID_TABLE_PARTIAL_SETTING_VALUE,`'${f}' must be a color literal`,d.value||d.name))});break;case P.Note:l.length>1&&s.push(...l.map(d=>new g(_.DUPLICATE_TABLE_PARTIAL_SETTING,`'${f}' can only appear once`,d))),l.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_TABLE_PARTIAL_SETTING_VALUE,`'${f}' must be a string literal`,d.value||d.name))});break;default:s.push(...l.map(d=>new g(_.UNKNOWN_TABLE_PARTIAL_SETTING,`Unknown '${f}' setting`,d)))}}),s}registerElement(){const{name:r}=this.declarationNode;this.declarationNode.symbol=this.symbolFactory.create(_f,{declaration:this.declarationNode,symbolTable:new Bn});const i=Ge(r);if(!i.isOk())return[];const s=i.unwrap(),o=s.pop(),l=us(s,this.publicSymbolTable,this.symbolFactory),f=ao(o);return l.has(f)?[new g(_.DUPLICATE_NAME,`TablePartial name '${o}' already exists`,r)]:(l.set(f,this.declarationNode.symbol),[])}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A TablePartial's body must be a block",r)];const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=[];i.args.length===0&&s.push(new g(_.INVALID_COLUMN,"A column must have a type",i.callee)),we(i.callee)||s.push(new g(_.INVALID_COLUMN_NAME,"A column name must be an identifier or a quoted identifier",i.callee)),i.args[0]&&!Af(i.args[0])&&s.push(new g(_.INVALID_COLUMN_TYPE,"Invalid column type",i.args[0]));const o=i.args.slice(1);return s.push(...this.validateFieldSetting(o),...this.registerField(i)),s})}registerField(r){if(!r.callee||!we(r.callee))return[];const i=Me(r.callee).unwrap(),s=fr(i),o=this.symbolFactory.create(to,{declaration:r});r.symbol=o;const l=this.declarationNode.symbol.symbolTable;if(l.has(s)){const f=l.get(s);return[new g(_.DUPLICATE_COLUMN_NAME,`Duplicate column ${i}`,r),new g(_.DUPLICATE_COLUMN_NAME,`Duplicate column ${i}`,f.declaration)]}return l.set(s,o),[]}validateFieldSetting(r){const i=me(r);if(!r.slice(0,-1).every(In)||!(In(i)||i instanceof _e))return[...r.map(I=>new g(_.INVALID_COLUMN,"These fields must be some inline settings optionally ended with a setting list",I))];if(r.length===0)return[];let s;me(r)instanceof _e&&(s=r.pop());const o=Ne(s),l=o.getErrors(),f=o.getValue();r.forEach(I=>{const T=Me(I).unwrap_or("").toLowerCase();if(T!==P.PK&&T!==P.Unique){l.push(new g(_.INVALID_SETTINGS,"Inline column settings can only be `pk` or `unique`",I));return}f[T]===void 0?f[T]=[I]:f[T].push(I)});const d=f[P.PK]||[],m=f[P.PrimaryKey]||[];return d.length>=1&&m.length>=1&&l.push(...[...d,...m].map(I=>new g(_.DUPLICATE_COLUMN_SETTING,"Either one of 'primary key' and 'pk' can appear",I))),Hr(f,(I,T)=>{switch(T){case P.Note:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{Fe(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must be a quoted string`,y.value||y.name))});break;case P.Ref:I.forEach(y=>{If(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must be a valid unary relationship`,y.value||y.name))});break;case P.PrimaryKey:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{ot(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.PK:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{y instanceof St&&!ot(y.value)&&l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.NotNull:{I.length>1&&l.push(...I.map($=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,$)));const y=f[P.Null]||[];I.length>=1&&y.length>=1&&l.push(...[...I,...y].map($=>new g(_.CONFLICTING_SETTING,"'not null' and 'null' can not be set at the same time",$))),I.forEach($=>{ot($.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,$.value||$.name))});break}case P.Null:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{ot(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.Unique:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{y instanceof St&&!ot(y.value)&&l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.Increment:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{y instanceof St&&!ot(y.value)&&l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must not have a value`,y.value||y.name))});break;case P.Default:I.length>1&&l.push(...I.map(y=>new g(_.DUPLICATE_COLUMN_SETTING,`'${T}' can only appear once`,y))),I.forEach(y=>{mf(y.value)||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,`'${T}' must be a string literal, number literal, function expression, true, false or null`,y.value||y.name))});break;case P.Check:I.forEach(y=>{y.value instanceof bt||l.push(new g(_.INVALID_COLUMN_SETTING_VALUE,"'check' must be a function expression",y.value||y.name))});break;default:I.forEach(y=>l.push(new g(_.UNKNOWN_COLUMN_SETTING,`Unknown column setting '${T}'`,y)))}}),l}validateSubElements(r){const i=r.flatMap(o=>{if(o.parent=this.declarationNode,!o.type)return[];const l=Xt(o);return new l(o,this.publicSymbolTable,this.symbolFactory).validate()}),s=r.filter(o=>o.type?.value.toLowerCase()===F.Note);return s.length>1&&i.push(...s.map(o=>new g(_.NOTE_REDEFINED,"Duplicate notes are defined",o))),i}}class QI{constructor(r,i,s){this.declarationNode=r,this.publicSymbolTable=i,this.symbolFactory=s}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){const r=new g(_.INVALID_CHECKS_CONTEXT,"A Checks can only appear inside a Table or a TablePartial",this.declarationNode);if(this.declarationNode.parent instanceof qe)return[r];const i=cn(this.declarationNode.parent).unwrap_or(void 0);return i&&[F.Table,F.TablePartial].includes(i)?[]:[r]}validateName(r){return r?[new g(_.UNEXPECTED_NAME,"A Checks shouldn't have a name",r)]:[]}validateAlias(r){return r?[new g(_.UNEXPECTED_ALIAS,"A Checks shouldn't have an alias",r)]:[]}validateSettingList(r){return r?[new g(_.UNEXPECTED_SETTINGS,"A Checks shouldn't have a setting list",r)]:[]}validateBody(r){if(!r)return[];if(r instanceof W)return[new g(_.UNEXPECTED_SIMPLE_BODY,"A Checks must have a complex body",r)];const[i,s]=ft(r.body,o=>o instanceof W);return[...this.validateFields(i),...this.validateSubElements(s)]}validateFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=[],o=[i.callee,...i.args];return me(o)instanceof _e&&s.push(...this.validateFieldSetting(o.pop())),(o.length>1||!(o[0]instanceof bt))&&s.push(new g(_.INVALID_CHECKS_FIELD,"A check field must be a function expression",i)),s})}validateFieldSetting(r){const i=Ne(r),s=i.getErrors(),o=i.getValue();for(const l in o){const f=o[l];switch(l){case"name":f.length>1&&f.forEach(d=>s.push(new g(_.DUPLICATE_CHECK_SETTING,`'${l}' can only appear once`,d))),f.forEach(d=>{Fe(d.value)||s.push(new g(_.INVALID_CHECK_SETTING_VALUE,`'${l}' must be a string`,d))});break;default:f.forEach(d=>s.push(new g(_.UNKNOWN_CHECK_SETTING,`Unknown check setting '${l}'`,d)))}}return s}validateSubElements(r){return r.flatMap(i=>{if(i.parent=this.declarationNode,!i.type)return[];const s=Xt(i);return new s(i,this.publicSymbolTable,this.symbolFactory).validate()})}}function Xt(t){switch(t.type.value.toLowerCase()){case F.Enum:return VI;case F.Table:return zI;case F.TableGroup:return YI;case F.Project:return XI;case F.Ref:return HI;case F.Note:return WI;case F.Indexes:return $I;case F.TablePartial:return JI;case F.Check:return QI;default:return CI}}function vf(t){return!!Ge(t).unwrap_or(!1)}function ZI(t){return hr(t)}function hr(t){return t instanceof lt&&t.expression instanceof ln}function Ji(t){return t instanceof je&&t.op?.value==="~"&&we(t.expression)}function us(t,r,i){t[0]===$t&&(t=t.slice(1));let s=r;for(const o of t){let l;const f=Jr(o);if(s.has(f)){if(l=s.get(f)?.symbolTable,!l)throw new Error("Expect a symbol table in a schema symbol")}else{l=new Bn;const d=i.create(eo,{symbolTable:l});s.set(f,d)}s=l}return s}function bf(t){return t==="-"||t==="<>"||t===">"||t==="<"}function ls(t){if(!(t instanceof lt)||!(t.expression instanceof cr)||t.expression.literal?.kind!==A.COLOR_LITERAL)return!1;const r=t.expression.literal.value;if(r.length!==4&&r.length!==7||r[0]!=="#")return!1;for(let i=1;i<r.length;i+=1)if(!UI(r[i]))return!1;return!0}function ot(t){return t===void 0}function mf(t){if(Fe(t)||mn(t)||In(t)&&["true","false","null"].includes(t.expression.variable.value.toLowerCase())||t instanceof je&&Tf.includes(t.op?.value)&&mn(t.expression)||t instanceof bt)return!0;if(!t||!lo(t))return!1;const r=An(t).unwrap();return r.length===2||r.length===3}function mn(t){return t instanceof je?Tf.includes(t.op.value)?mn(t.expression):!1:t instanceof lt&&t.expression instanceof cr&&t.expression.literal?.kind===A.NUMERIC_LITERAL}function If(t){if(!(t instanceof je)||!bf(t.op?.value))return!1;const r=Ge(t.expression).unwrap_or(void 0);return r!==void 0&&r.length>0}function jI(t){return t instanceof Wt&&t.elementList.every(we)}function Af(t){if(!(t instanceof He||uo(t)||t instanceof lt||t instanceof Bt))return!1;for(;t instanceof He||t instanceof Bt;)if(t instanceof He){if(t.callee===void 0||t.argumentList===void 0||!t.argumentList.elementList.every(i=>mn(i)||Fe(i)||In(i)))return!1;t=t.callee}else if(t instanceof Bt){if(t.array===void 0||t.indexer===void 0||!t.indexer.elementList.every(i=>!i.colon&&!i.value&&mn(i.name)))return!1;t=t.array}const r=Ge(t).unwrap_or(void 0);return r!==void 0&&r.length>0}function Ne(t){const r={},i=[];return t?(t.elementList.forEach(s=>{if(!s.name)return;if(s.name instanceof lt){i.push(new g(_.INVALID_SETTINGS,"A setting name must be a stream of identifiers",s.name));return}const o=zr(s.name).unwrap_or(void 0)?.toLowerCase();o&&(r[o]===void 0?r[o]=[s]:r[o].push(s))}),new ct(r,i)):new ct({})}function cn(t){const r=t?.type?.value.toLowerCase();switch(r){case F.Enum:case F.Table:case F.Indexes:case F.Note:case F.Project:case F.Ref:case F.TableGroup:case F.TablePartial:case F.Check:return new ye(r);default:return new pe}}function An(t){if(!t)return new pe;if(!uo(t))return new ye([t]);const r=An(t.leftExpression).unwrap_or(void 0);return r?(r.push(t.rightExpression),new ye(r)):new pe}function Ge(t){if(t===void 0)return new pe;const r=An(t).unwrap_or(void 0);if(!r)return new pe;const i=[];for(const s of r){const o=Pe(s).unwrap_or(void 0);if(typeof o!="string")return new pe;i.push(o)}return new ye(i)}function ut(t){if(t===void 0)return new pe;const r=An(t).unwrap_or(void 0);if(!r||r.length===0)return new pe;let i=[];if(!we(me(r))){const o=r.pop();if(jI(o))i=o.elementList;else return new pe}const s=r;return s.every(we)?new ye({variables:s,tupleElements:i}):new pe}function Pe(t){return we(t)?new ye(t.expression.variable.value):new pe}function Qi(t){if(Ic(t))return t instanceof bt?new ye({functional:[t],nonFunctional:[]}):new ye({functional:[],nonFunctional:[t]});if(t instanceof Wt&&t.elementList.every(Ic)){const r=t.elementList.filter(s=>s instanceof bt),i=t.elementList.filter(we);return new ye({functional:r,nonFunctional:i})}return new pe}function Me(t){const r=t?.expression.variable?.value;return r===void 0?new pe:new ye(r)}function Le(t){return Fe(t)?t.expression instanceof ln?new ye(t.expression.variable.value):new ye(t.expression.literal.value):new pe}function mc(t){return!(t instanceof Vt)||!bf(t.op?.value)?!1:ut(t.leftExpression).and_then(()=>ut(t.rightExpression)).unwrap_or(void 0)!==void 0}function eA(t){const r=ut(t.leftExpression),i=ut(t.rightExpression);if(!r.isOk()||!i.isOk())return!1;const{tupleElements:s}=r.unwrap(),{tupleElements:o}=i.unwrap();return s?.length===o?.length}function Ic(t){return t instanceof lt&&t.expression instanceof ln||t instanceof bt}function tA(t,r,i){if(!t||!In(t)||r.length===0)return new pe;const s=[...r],o=Ac(t).unwrap(),l=s.pop();if(!(l instanceof ke))return new pe;const f=me(s)instanceof _e?s.pop():void 0;if(s.length===3){const d=Ac(s[1]).value;return!d||!Ha(d)?new pe:new ye(i.create(se,{type:o,name:s[0],as:d,alias:s[2],attributeList:f,body:l}))}return s.length===1?new ye(i.create(se,{type:o,name:s[0],attributeList:f,body:l})):s.length===0?new ye(i.create(se,{type:o,attributeList:f,body:l})):new pe}function Ha(t){return t?.kind===A.IDENTIFIER&&t.value.toLowerCase()==="as"}function C(t){t&&(t instanceof Ze?nA(t):rA(t))}function nA(t){t.kind!==A.EOF&&(t.isInvalid=!0)}function rA(t){if(t instanceof se)C(t.type),C(t.name),C(t.as),C(t.alias),C(t.bodyColon),C(t.attributeList),C(t.body);else if(t instanceof xt)t.identifiers.forEach(C);else if(t instanceof St)C(t.name),C(t.colon),C(t.value);else if(t instanceof je)C(t.op),C(t.expression);else if(t instanceof Vt)C(t.leftExpression),C(t.op),C(t.rightExpression);else if(t instanceof os)C(t.op),C(t.expression);else if(t instanceof ke)C(t.blockOpenBrace),t.body.forEach(C),C(t.blockCloseBrace);else if(t instanceof _e)C(t.listOpenBracket),t.commaList.forEach(C),t.elementList.forEach(C),C(t.listCloseBracket);else if(t instanceof Wt)C(t.tupleOpenParen),t.commaList.forEach(C),t.elementList.forEach(C),C(t.tupleCloseParen);else if(t instanceof He)C(t.callee),C(t.argumentList);else if(t instanceof W)C(t.callee),t.args.forEach(C);else if(t instanceof lt)C(t.expression);else if(t instanceof bt)C(t.value);else if(t instanceof ln)C(t.variable);else if(t instanceof cr)C(t.literal);else{if(t instanceof ja)throw new Error("This case is handled by the TupleExpressionNode case");if(t instanceof Bt)C(t.array),C(t.indexer);else if(t instanceof qe)t.body.forEach(C),C(t.eof);else if(!(t instanceof Br))throw new Error("Unreachable case in markInvalidNode")}}function qa(t){return!!t?.isInvalid}function Xe(...t){return t.filter(r=>r!==void 0)}function iA(t){if(t instanceof qe)return Xe(...t.body,t.eof);if(t instanceof se)return Xe(t.type,t.name,t.as,t.alias,t.attributeList,t.bodyColon,t.body);if(t instanceof St)return Xe(t.name,t.colon,t.value);if(t instanceof xt)return t.identifiers;if(t instanceof cr)return t.literal?[t.literal]:[];if(t instanceof ln)return Xe(t.variable);if(t instanceof je)return Xe(t.op,t.expression);if(t instanceof Vt)return Xe(t.leftExpression,t.op,t.rightExpression);if(t instanceof os)return Xe(t.expression,t.op);if(t instanceof bt)return Xe(t.value);if(t instanceof W)return Xe(t.callee,...t.args);if(t instanceof ke)return Xe(t.blockOpenBrace,...t.body,t.blockCloseBrace);if(t instanceof _e)return Xe(t.listOpenBracket,...bc(t.elementList,t.commaList),t.listCloseBracket);if(t instanceof Wt)return Xe(t.tupleOpenParen,...bc(t.elementList,t.commaList),t.tupleCloseParen);if(t instanceof He)return Xe(t.callee,t.argumentList);if(t instanceof lt)return Xe(t.expression);if(t instanceof Bt)return Xe(t.array,t.indexer);throw t instanceof ja?new Error("This case is already handled by TupleExpressionNode"):new Error("Unreachable - no other possible cases")}function Ac(t){return we(t)?new ye(t.expression.variable):new pe}function Fe(t){return t instanceof lt&&(t.expression instanceof ln&&t.expression.variable instanceof Ze&&t.expression.variable.kind===A.QUOTED_STRING||t.expression instanceof cr&&t.expression.literal?.kind===A.STRING_LITERAL)}function we(t){return t instanceof lt&&t.expression instanceof ln&&t.expression.variable instanceof Ze}function In(t){return t instanceof lt&&t.expression instanceof ln&&t.expression.variable?.kind===A.IDENTIFIER}function uo(t){return t instanceof Vt&&t.leftExpression instanceof Te&&t.rightExpression instanceof Te&&t.op?.value==="."}function lo(t){return we(t)?!0:uo(t)&&we(t.rightExpression)&&lo(t.leftExpression)}function zr(t){if(t===void 0)return new pe;const r=t.identifiers.map(i=>i.value).join(" ");return r===""?new pe:new ye(r)}function sA(t){return Ge(t.name).map(r=>r.join("."))}class aA{constructor(r){this.start={offset:0,line:0,column:0},this.current={offset:0,line:0,column:0},this.tokens=[],this.errors=[],this.text=r}isAtEnd(){return this.current.offset>=this.text.length}advance(){const r=this.peek();return this.current={...this.current},r===`
|
|
2
|
-
`?(this.current.line+=1,this.current.column=0):this.current.column+=1,this.current.offset+=1,
|
|
3
|
-
`:this.addToken(
|
|
4
|
-
`))&&!this.check(
|
|
5
|
-
`)&&!
|
|
6
|
-
`,{allowNewline:!0,allowEof:!0,raw:!0,consumeStopSequence:!1})}multilineComment(){this.consumeUntil(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var hp=typeof global=="object"&&global&&global.Object===Object&&global,Iw=typeof self=="object"&&self&&self.Object===Object&&self,Bn=hp||Iw||Function("return this")(),Nn=Bn.Symbol,dp=Object.prototype,Aw=dp.hasOwnProperty,Lw=dp.toString,Wi=Nn?Nn.toStringTag:void 0;function Sw(t){var e=Aw.call(t,Wi),n=t[Wi];try{t[Wi]=void 0;var i=!0}catch{}var a=Lw.call(t);return i&&(e?t[Wi]=n:delete t[Wi]),a}var Ow=Object.prototype,xw=Ow.toString;function Dw(t){return xw.call(t)}var Rw="[object Null]",kw="[object Undefined]",Vh=Nn?Nn.toStringTag:void 0;function fi(t){return t==null?t===void 0?kw:Rw:Vh&&Vh in Object(t)?Sw(t):Dw(t)}function Ir(t){return t!=null&&typeof t=="object"}var Mw="[object Symbol]";function Ca(t){return typeof t=="symbol"||Ir(t)&&fi(t)==Mw}function pl(t,e){for(var n=-1,i=t==null?0:t.length,a=Array(i);++n<i;)a[n]=e(t[n],n,t);return a}var Nt=Array.isArray,Bh=Nn?Nn.prototype:void 0,$h=Bh?Bh.toString:void 0;function pp(t){if(typeof t=="string")return t;if(Nt(t))return pl(t,pp)+"";if(Ca(t))return $h?$h.call(t):"";var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var Pw=/\s/;function Cw(t){for(var e=t.length;e--&&Pw.test(t.charAt(e)););return e}var Fw=/^\s+/;function Uw(t){return t&&t.slice(0,Cw(t)+1).replace(Fw,"")}function si(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Gh=NaN,Vw=/^[-+]0x[0-9a-f]+$/i,Bw=/^0b[01]+$/i,$w=/^0o[0-7]+$/i,Gw=parseInt;function Ww(t){if(typeof t=="number")return t;if(Ca(t))return Gh;if(si(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=si(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=Uw(t);var n=Bw.test(t);return n||$w.test(t)?Gw(t.slice(2),n?2:8):Vw.test(t)?Gh:+t}var Wh=1/0,Hw=17976931348623157e292;function zw(t){if(!t)return t===0?t:0;if(t=Ww(t),t===Wh||t===-Wh){var e=t<0?-1:1;return e*Hw}return t===t?t:0}function qw(t){var e=zw(t),n=e%1;return e===e?n?e-n:e:0}function Fa(t){return t}var Xw="[object AsyncFunction]",Yw="[object Function]",Zw="[object GeneratorFunction]",Kw="[object Proxy]";function mp(t){if(!si(t))return!1;var e=fi(t);return e==Yw||e==Zw||e==Xw||e==Kw}var Su=Bn["__core-js_shared__"],Hh=function(){var t=/[^.]+$/.exec(Su&&Su.keys&&Su.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Jw(t){return!!Hh&&Hh in t}var jw=Function.prototype,Qw=jw.toString;function xr(t){if(t!=null){try{return Qw.call(t)}catch{}try{return t+""}catch{}}return""}var eI=/[\\^$.*+?()[\]{}|]/g,tI=/^\[object .+?Constructor\]$/,nI=Function.prototype,rI=Object.prototype,iI=nI.toString,sI=rI.hasOwnProperty,aI=RegExp("^"+iI.call(sI).replace(eI,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function oI(t){if(!si(t)||Jw(t))return!1;var e=mp(t)?aI:tI;return e.test(xr(t))}function uI(t,e){return t?.[e]}function Dr(t,e){var n=uI(t,e);return oI(n)?n:void 0}var $u=Dr(Bn,"WeakMap");function lI(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function cI(){}var fI=800,hI=16,dI=Date.now;function pI(t){var e=0,n=0;return function(){var i=dI(),a=hI-(i-n);if(n=i,a>0){if(++e>=fI)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}function mI(t){return function(){return t}}var va=function(){try{var t=Dr(Object,"defineProperty");return t({},"",{}),t}catch{}}(),gI=va?function(t,e){return va(t,"toString",{configurable:!0,enumerable:!1,value:mI(e),writable:!0})}:Fa,EI=pI(gI);function gp(t,e,n,i){for(var a=t.length,u=n+(i?1:-1);i?u--:++u<a;)if(e(t[u],u,t))return u;return-1}function TI(t){return t!==t}function NI(t,e,n){for(var i=n-1,a=t.length;++i<a;)if(t[i]===e)return i;return-1}function yI(t,e,n){return e===e?NI(t,e,n):gp(t,TI,n)}function Ep(t,e){var n=t==null?0:t.length;return!!n&&yI(t,e,0)>-1}var vI=9007199254740991,_I=/^(?:0|[1-9]\d*)$/;function Tp(t,e){var n=typeof t;return e=e??vI,!!e&&(n=="number"||n!="symbol"&&_I.test(t))&&t>-1&&t%1==0&&t<e}function Np(t,e,n){e=="__proto__"&&va?va(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function yp(t,e){return t===e||t!==t&&e!==e}var zh=Math.max;function bI(t,e,n){return e=zh(e===void 0?t.length-1:e,0),function(){for(var i=arguments,a=-1,u=zh(i.length-e,0),l=Array(u);++a<u;)l[a]=i[e+a];a=-1;for(var f=Array(e+1);++a<e;)f[a]=i[a];return f[e]=n(l),lI(t,this,f)}}function vp(t,e){return EI(bI(t,e,Fa),t+"")}var wI=9007199254740991;function ml(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=wI}function hi(t){return t!=null&&ml(t.length)&&!mp(t)}var II=Object.prototype;function gl(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||II;return t===n}function _p(t,e){for(var n=-1,i=Array(t);++n<t;)i[n]=e(n);return i}var AI="[object Arguments]";function qh(t){return Ir(t)&&fi(t)==AI}var bp=Object.prototype,LI=bp.hasOwnProperty,SI=bp.propertyIsEnumerable,Ua=qh(function(){return arguments}())?qh:function(t){return Ir(t)&&LI.call(t,"callee")&&!SI.call(t,"callee")};function OI(){return!1}var wp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Xh=wp&&typeof module=="object"&&module&&!module.nodeType&&module,xI=Xh&&Xh.exports===wp,Yh=xI?Bn.Buffer:void 0,DI=Yh?Yh.isBuffer:void 0,_a=DI||OI,RI="[object Arguments]",kI="[object Array]",MI="[object Boolean]",PI="[object Date]",CI="[object Error]",FI="[object Function]",UI="[object Map]",VI="[object Number]",BI="[object Object]",$I="[object RegExp]",GI="[object Set]",WI="[object String]",HI="[object WeakMap]",zI="[object ArrayBuffer]",qI="[object DataView]",XI="[object Float32Array]",YI="[object Float64Array]",ZI="[object Int8Array]",KI="[object Int16Array]",JI="[object Int32Array]",jI="[object Uint8Array]",QI="[object Uint8ClampedArray]",e0="[object Uint16Array]",t0="[object Uint32Array]",we={};we[XI]=we[YI]=we[ZI]=we[KI]=we[JI]=we[jI]=we[QI]=we[e0]=we[t0]=!0;we[RI]=we[kI]=we[zI]=we[MI]=we[qI]=we[PI]=we[CI]=we[FI]=we[UI]=we[VI]=we[BI]=we[$I]=we[GI]=we[WI]=we[HI]=!1;function n0(t){return Ir(t)&&ml(t.length)&&!!we[fi(t)]}function r0(t){return function(e){return t(e)}}var Ip=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Zi=Ip&&typeof module=="object"&&module&&!module.nodeType&&module,i0=Zi&&Zi.exports===Ip,Ou=i0&&hp.process,Zh=function(){try{var t=Zi&&Zi.require&&Zi.require("util").types;return t||Ou&&Ou.binding&&Ou.binding("util")}catch{}}(),Kh=Zh&&Zh.isTypedArray,El=Kh?r0(Kh):n0,s0=Object.prototype,a0=s0.hasOwnProperty;function Ap(t,e){var n=Nt(t),i=!n&&Ua(t),a=!n&&!i&&_a(t),u=!n&&!i&&!a&&El(t),l=n||i||a||u,f=l?_p(t.length,String):[],h=f.length;for(var m in t)(e||a0.call(t,m))&&!(l&&(m=="length"||a&&(m=="offset"||m=="parent")||u&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||Tp(m,h)))&&f.push(m);return f}function o0(t,e){return function(n){return t(e(n))}}var u0=o0(Object.keys,Object),l0=Object.prototype,c0=l0.hasOwnProperty;function Lp(t){if(!gl(t))return u0(t);var e=[];for(var n in Object(t))c0.call(t,n)&&n!="constructor"&&e.push(n);return e}function Tl(t){return hi(t)?Ap(t):Lp(t)}function f0(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}var h0=Object.prototype,d0=h0.hasOwnProperty;function p0(t){if(!si(t))return f0(t);var e=gl(t),n=[];for(var i in t)i=="constructor"&&(e||!d0.call(t,i))||n.push(i);return n}function m0(t){return hi(t)?Ap(t,!0):p0(t)}var g0=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,E0=/^\w*$/;function Nl(t,e){if(Nt(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||Ca(t)?!0:E0.test(t)||!g0.test(t)||e!=null&&t in Object(e)}var ji=Dr(Object,"create");function T0(){this.__data__=ji?ji(null):{},this.size=0}function N0(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var y0="__lodash_hash_undefined__",v0=Object.prototype,_0=v0.hasOwnProperty;function b0(t){var e=this.__data__;if(ji){var n=e[t];return n===y0?void 0:n}return _0.call(e,t)?e[t]:void 0}var w0=Object.prototype,I0=w0.hasOwnProperty;function A0(t){var e=this.__data__;return ji?e[t]!==void 0:I0.call(e,t)}var L0="__lodash_hash_undefined__";function S0(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=ji&&e===void 0?L0:e,this}function Ar(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}Ar.prototype.clear=T0;Ar.prototype.delete=N0;Ar.prototype.get=b0;Ar.prototype.has=A0;Ar.prototype.set=S0;function O0(){this.__data__=[],this.size=0}function Va(t,e){for(var n=t.length;n--;)if(yp(t[n][0],e))return n;return-1}var x0=Array.prototype,D0=x0.splice;function R0(t){var e=this.__data__,n=Va(e,t);if(n<0)return!1;var i=e.length-1;return n==i?e.pop():D0.call(e,n,1),--this.size,!0}function k0(t){var e=this.__data__,n=Va(e,t);return n<0?void 0:e[n][1]}function M0(t){return Va(this.__data__,t)>-1}function P0(t,e){var n=this.__data__,i=Va(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this}function $n(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}$n.prototype.clear=O0;$n.prototype.delete=R0;$n.prototype.get=k0;$n.prototype.has=M0;$n.prototype.set=P0;var Qi=Dr(Bn,"Map");function C0(){this.size=0,this.__data__={hash:new Ar,map:new(Qi||$n),string:new Ar}}function F0(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Ba(t,e){var n=t.__data__;return F0(e)?n[typeof e=="string"?"string":"hash"]:n.map}function U0(t){var e=Ba(this,t).delete(t);return this.size-=e?1:0,e}function V0(t){return Ba(this,t).get(t)}function B0(t){return Ba(this,t).has(t)}function $0(t,e){var n=Ba(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this}function Gn(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}Gn.prototype.clear=C0;Gn.prototype.delete=U0;Gn.prototype.get=V0;Gn.prototype.has=B0;Gn.prototype.set=$0;var G0="Expected a function";function yl(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(G0);var n=function(){var i=arguments,a=e?e.apply(this,i):i[0],u=n.cache;if(u.has(a))return u.get(a);var l=t.apply(this,i);return n.cache=u.set(a,l)||u,l};return n.cache=new(yl.Cache||Gn),n}yl.Cache=Gn;var W0=500;function H0(t){var e=yl(t,function(i){return n.size===W0&&n.clear(),i}),n=e.cache;return e}var z0=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,q0=/\\(\\)?/g,X0=H0(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(z0,function(n,i,a,u){e.push(a?u.replace(q0,"$1"):i||n)}),e});function Y0(t){return t==null?"":pp(t)}function Sp(t,e){return Nt(t)?t:Nl(t,e)?[t]:X0(Y0(t))}function $a(t){if(typeof t=="string"||Ca(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Op(t,e){e=Sp(e,t);for(var n=0,i=e.length;t!=null&&n<i;)t=t[$a(e[n++])];return n&&n==i?t:void 0}function xp(t,e,n){var i=t==null?void 0:Op(t,e);return i===void 0?n:i}function Dp(t,e){for(var n=-1,i=e.length,a=t.length;++n<i;)t[a+n]=e[n];return t}var Jh=Nn?Nn.isConcatSpreadable:void 0;function Z0(t){return Nt(t)||Ua(t)||!!(Jh&&t&&t[Jh])}function vl(t,e,n,i,a){var u=-1,l=t.length;for(n||(n=Z0),a||(a=[]);++u<l;){var f=t[u];n(f)?Dp(a,f):i||(a[a.length]=f)}return a}function jh(t){var e=t==null?0:t.length;return e?vl(t):[]}function K0(){this.__data__=new $n,this.size=0}function J0(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}function j0(t){return this.__data__.get(t)}function Q0(t){return this.__data__.has(t)}var eA=200;function tA(t,e){var n=this.__data__;if(n instanceof $n){var i=n.__data__;if(!Qi||i.length<eA-1)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new Gn(i)}return n.set(t,e),this.size=n.size,this}function Pn(t){var e=this.__data__=new $n(t);this.size=e.size}Pn.prototype.clear=K0;Pn.prototype.delete=J0;Pn.prototype.get=j0;Pn.prototype.has=Q0;Pn.prototype.set=tA;function _l(t,e){for(var n=-1,i=t==null?0:t.length,a=0,u=[];++n<i;){var l=t[n];e(l,n,t)&&(u[a++]=l)}return u}function nA(){return[]}var rA=Object.prototype,iA=rA.propertyIsEnumerable,Qh=Object.getOwnPropertySymbols,sA=Qh?function(t){return t==null?[]:(t=Object(t),_l(Qh(t),function(e){return iA.call(t,e)}))}:nA;function aA(t,e,n){var i=e(t);return Nt(t)?i:Dp(i,n(t))}function ed(t){return aA(t,Tl,sA)}var Gu=Dr(Bn,"DataView"),Wu=Dr(Bn,"Promise"),ti=Dr(Bn,"Set"),td="[object Map]",oA="[object Object]",nd="[object Promise]",rd="[object Set]",id="[object WeakMap]",sd="[object DataView]",uA=xr(Gu),lA=xr(Qi),cA=xr(Wu),fA=xr(ti),hA=xr($u),Mn=fi;(Gu&&Mn(new Gu(new ArrayBuffer(1)))!=sd||Qi&&Mn(new Qi)!=td||Wu&&Mn(Wu.resolve())!=nd||ti&&Mn(new ti)!=rd||$u&&Mn(new $u)!=id)&&(Mn=function(t){var e=fi(t),n=e==oA?t.constructor:void 0,i=n?xr(n):"";if(i)switch(i){case uA:return sd;case lA:return td;case cA:return nd;case fA:return rd;case hA:return id}return e});var ad=Bn.Uint8Array;function Rp(t){for(var e=-1,n=t==null?0:t.length,i=0,a=[];++e<n;){var u=t[e];u&&(a[i++]=u)}return a}var dA="__lodash_hash_undefined__";function pA(t){return this.__data__.set(t,dA),this}function mA(t){return this.__data__.has(t)}function ai(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new Gn;++e<n;)this.add(t[e])}ai.prototype.add=ai.prototype.push=pA;ai.prototype.has=mA;function gA(t,e){for(var n=-1,i=t==null?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1}function bl(t,e){return t.has(e)}var EA=1,TA=2;function kp(t,e,n,i,a,u){var l=n&EA,f=t.length,h=e.length;if(f!=h&&!(l&&h>f))return!1;var m=u.get(t),E=u.get(e);if(m&&E)return m==e&&E==t;var T=-1,A=!0,O=n&TA?new ai:void 0;for(u.set(t,e),u.set(e,t);++T<f;){var F=t[T],G=e[T];if(i)var H=l?i(G,F,T,e,t,u):i(F,G,T,t,e,u);if(H!==void 0){if(H)continue;A=!1;break}if(O){if(!gA(e,function(le,Me){if(!bl(O,Me)&&(F===le||a(F,le,n,i,u)))return O.push(Me)})){A=!1;break}}else if(!(F===G||a(F,G,n,i,u))){A=!1;break}}return u.delete(t),u.delete(e),A}function NA(t){var e=-1,n=Array(t.size);return t.forEach(function(i,a){n[++e]=[a,i]}),n}function wl(t){var e=-1,n=Array(t.size);return t.forEach(function(i){n[++e]=i}),n}var yA=1,vA=2,_A="[object Boolean]",bA="[object Date]",wA="[object Error]",IA="[object Map]",AA="[object Number]",LA="[object RegExp]",SA="[object Set]",OA="[object String]",xA="[object Symbol]",DA="[object ArrayBuffer]",RA="[object DataView]",od=Nn?Nn.prototype:void 0,xu=od?od.valueOf:void 0;function kA(t,e,n,i,a,u,l){switch(n){case RA:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case DA:return!(t.byteLength!=e.byteLength||!u(new ad(t),new ad(e)));case _A:case bA:case AA:return yp(+t,+e);case wA:return t.name==e.name&&t.message==e.message;case LA:case OA:return t==e+"";case IA:var f=NA;case SA:var h=i&yA;if(f||(f=wl),t.size!=e.size&&!h)return!1;var m=l.get(t);if(m)return m==e;i|=vA,l.set(t,e);var E=kp(f(t),f(e),i,a,u,l);return l.delete(t),E;case xA:if(xu)return xu.call(t)==xu.call(e)}return!1}var MA=1,PA=Object.prototype,CA=PA.hasOwnProperty;function FA(t,e,n,i,a,u){var l=n&MA,f=ed(t),h=f.length,m=ed(e),E=m.length;if(h!=E&&!l)return!1;for(var T=h;T--;){var A=f[T];if(!(l?A in e:CA.call(e,A)))return!1}var O=u.get(t),F=u.get(e);if(O&&F)return O==e&&F==t;var G=!0;u.set(t,e),u.set(e,t);for(var H=l;++T<h;){A=f[T];var le=t[A],Me=e[A];if(i)var Xe=l?i(Me,le,A,e,t,u):i(le,Me,A,t,e,u);if(!(Xe===void 0?le===Me||a(le,Me,n,i,u):Xe)){G=!1;break}H||(H=A=="constructor")}if(G&&!H){var at=t.constructor,Je=e.constructor;at!=Je&&"constructor"in t&&"constructor"in e&&!(typeof at=="function"&&at instanceof at&&typeof Je=="function"&&Je instanceof Je)&&(G=!1)}return u.delete(t),u.delete(e),G}var UA=1,ud="[object Arguments]",ld="[object Array]",la="[object Object]",VA=Object.prototype,cd=VA.hasOwnProperty;function BA(t,e,n,i,a,u){var l=Nt(t),f=Nt(e),h=l?ld:Mn(t),m=f?ld:Mn(e);h=h==ud?la:h,m=m==ud?la:m;var E=h==la,T=m==la,A=h==m;if(A&&_a(t)){if(!_a(e))return!1;l=!0,E=!1}if(A&&!E)return u||(u=new Pn),l||El(t)?kp(t,e,n,i,a,u):kA(t,e,h,n,i,a,u);if(!(n&UA)){var O=E&&cd.call(t,"__wrapped__"),F=T&&cd.call(e,"__wrapped__");if(O||F){var G=O?t.value():t,H=F?e.value():e;return u||(u=new Pn),a(G,H,n,i,u)}}return A?(u||(u=new Pn),FA(t,e,n,i,a,u)):!1}function Il(t,e,n,i,a){return t===e?!0:t==null||e==null||!Ir(t)&&!Ir(e)?t!==t&&e!==e:BA(t,e,n,i,Il,a)}var $A=1,GA=2;function WA(t,e,n,i){var a=n.length,u=a;if(t==null)return!u;for(t=Object(t);a--;){var l=n[a];if(l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++a<u;){l=n[a];var f=l[0],h=t[f],m=l[1];if(l[2]){if(h===void 0&&!(f in t))return!1}else{var E=new Pn,T;if(!(T===void 0?Il(m,h,$A|GA,i,E):T))return!1}}return!0}function Mp(t){return t===t&&!si(t)}function HA(t){for(var e=Tl(t),n=e.length;n--;){var i=e[n],a=t[i];e[n]=[i,a,Mp(a)]}return e}function Pp(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==void 0||t in Object(n))}}function zA(t){var e=HA(t);return e.length==1&&e[0][2]?Pp(e[0][0],e[0][1]):function(n){return n===t||WA(n,t,e)}}function qA(t,e){return t!=null&&e in Object(t)}function XA(t,e,n){e=Sp(e,t);for(var i=-1,a=e.length,u=!1;++i<a;){var l=$a(e[i]);if(!(u=t!=null&&n(t,l)))break;t=t[l]}return u||++i!=a?u:(a=t==null?0:t.length,!!a&&ml(a)&&Tp(l,a)&&(Nt(t)||Ua(t)))}function YA(t,e){return t!=null&&XA(t,e,qA)}var ZA=1,KA=2;function JA(t,e){return Nl(t)&&Mp(e)?Pp($a(t),e):function(n){var i=xp(n,t);return i===void 0&&i===e?YA(n,t):Il(e,i,ZA|KA)}}function Cp(t){return function(e){return e?.[t]}}function jA(t){return function(e){return Op(e,t)}}function QA(t){return Nl(t)?Cp($a(t)):jA(t)}function os(t){return typeof t=="function"?t:t==null?Fa:typeof t=="object"?Nt(t)?JA(t[0],t[1]):zA(t):QA(t)}function eL(t,e,n,i){for(var a=-1,u=t==null?0:t.length;++a<u;){var l=t[a];e(i,l,n(l),t)}return i}function tL(t){return function(e,n,i){for(var a=-1,u=Object(e),l=i(e),f=l.length;f--;){var h=l[++a];if(n(u[h],h,u)===!1)break}return e}}var Fp=tL();function nL(t,e){return t&&Fp(t,e,Tl)}function rL(t,e){return function(n,i){if(n==null)return n;if(!hi(n))return t(n,i);for(var a=n.length,u=-1,l=Object(n);++u<a&&i(l[u],u,l)!==!1;);return n}}var Al=rL(nL);function iL(t,e,n,i){return Al(t,function(a,u,l){e(i,a,n(a),l)}),i}function Ll(t,e){return function(n,i){var a=Nt(n)?eL:iL,u=e?e():{};return a(n,t,os(i),u)}}function Hu(t){return Ir(t)&&hi(t)}var sL=200;function aL(t,e,n,i){var a=-1,u=Ep,l=!0,f=t.length,h=[],m=e.length;if(!f)return h;e.length>=sL&&(u=bl,l=!1,e=new ai(e));e:for(;++a<f;){var E=t[a],T=E;if(E=E!==0?E:0,l&&T===T){for(var A=m;A--;)if(e[A]===T)continue e;h.push(E)}else u(e,T,i)||h.push(E)}return h}var oL=vp(function(t,e){return Hu(t)?aL(t,vl(e,1,Hu,!0)):[]});function Oe(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}function uL(t){return typeof t=="function"?t:Fa}function lL(t,e){var n=[];return Al(t,function(i,a,u){e(i,a,u)&&n.push(i)}),n}function Up(t,e){var n=Nt(t)?_l:lL;return n(t,os(e))}var cL=Math.max,fL=Math.min;function hL(t,e,n){var i=t==null?0:t.length;if(!i)return-1;var a=i-1;return n!==void 0&&(a=qw(n),a=n<0?cL(i+a,0):fL(a,i-1)),gp(t,os(e),a,!0)}function dL(t){return t&&t.length?t[0]:void 0}function pL(t,e){var n=-1,i=hi(t)?Array(t.length):[];return Al(t,function(a,u,l){i[++n]=e(a,u,l)}),i}function mL(t,e){var n=Nt(t)?pl:pL;return n(t,os(e))}function Ht(t,e){return vl(mL(t,e))}function es(t,e){return t==null?t:Fp(t,uL(e),m0)}var gL=Object.prototype,EL=gL.hasOwnProperty,Vp=Ll(function(t,e,n){EL.call(t,n)?t[n].push(e):Np(t,n,[e])}),TL="[object Map]",NL="[object Set]",yL=Object.prototype,vL=yL.hasOwnProperty;function Lr(t){if(t==null)return!0;if(hi(t)&&(Nt(t)||typeof t=="string"||typeof t.splice=="function"||_a(t)||El(t)||Ua(t)))return!t.length;var e=Mn(t);if(e==TL||e==NL)return!t.size;if(gl(t))return!Lp(t).length;for(var n in t)if(vL.call(t,n))return!1;return!0}var Bp=Ll(function(t,e,n){Np(t,n,e)}),ht=Ll(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]}),_L=1/0,bL=ti&&1/wl(new ti([,-0]))[1]==_L?function(t){return new ti(t)}:cI,wL=200;function IL(t,e,n){var i=-1,a=Ep,u=t.length,l=!0,f=[],h=f;if(u>=wL){var m=e?null:bL(t);if(m)return wl(m);l=!1,a=bl,h=new ai}else h=e?[]:f;e:for(;++i<u;){var E=t[i],T=e?e(E):E;if(E=E!==0?E:0,l&&T===T){for(var A=h.length;A--;)if(h[A]===T)continue e;e&&h.push(T),f.push(E)}else a(h,T,n)||(h!==f&&h.push(T),f.push(E))}return f}function AL(t,e){return t&&t.length?IL(t,os(e)):[]}var LL=Math.max;function SL(t){if(!(t&&t.length))return[];var e=0;return t=_l(t,function(n){if(Hu(n))return e=LL(n.length,e),!0}),_p(e,function(n){return pl(t,Cp(n))})}var zu=vp(SL),I=(t=>(t.SPACE="<space>",t.TAB="<tab>",t.NEWLINE="<newline>",t.COMMA="<comma>",t.LPAREN="<lparen>",t.RPAREN="<rparen>",t.LBRACE="<lbrace>",t.RBRACE="<rbrace>",t.LBRACKET="<lbracket>",t.RBRACKET="<rbracket>",t.LANGLE="<langle>",t.RANGLE="<rangle>",t.OP="<op>",t.EOF="<eof>",t.NUMERIC_LITERAL="<number>",t.STRING_LITERAL="<string>",t.COLOR_LITERAL="<color>",t.FUNCTION_EXPRESSION="<function-expression>",t.QUOTED_STRING="<variable>",t.IDENTIFIER="<identifier>",t.SEMICOLON="<semicolon>",t.COLON="<colon>",t.SINGLE_LINE_COMMENT="<single-line-comment>",t.MULTILINE_COMMENT="<multiline-comment>",t))(I||{});function OL(t){switch(t.kind){case"<newline>":case"<space>":case"<tab>":case"<single-line-comment>":case"<multiline-comment>":return!0;default:return!1}}function xL(t){if(!t)return!1;switch(t){case"+":case"-":case"*":case"/":case"%":case"<":case">":case"=":case"!":case".":case"&":case"|":case"~":return!0;default:return!1}}function fd(t){return t!==void 0&&t.kind==="<op>"}class Tt{constructor(e,n,i,a,u){this.kind=e,this.startPos=n,this.endPos=i,this.value=a,this.leadingTrivia=[],this.trailingTrivia=[],this.leadingInvalid=[],this.trailingInvalid=[],this.isInvalid=u,this.start=n.offset,this.end=i.offset}static create(e,n,i,a,u){return new Tt(e,n,i,a,u)}}function qu(t){return t.trailingTrivia.find(({kind:e})=>e===I.NEWLINE)!==void 0}function hd(t,e){return e.leadingTrivia.find(({kind:i})=>i===I.NEWLINE)!==void 0||qu(t)}function Xu(t){return t.trailingTrivia.find(({kind:e})=>[I.SPACE,I.TAB].includes(e))!==void 0}function $p(t){return t.trailingTrivia.length===0?t.end:$p(Oe(t.trailingTrivia))}function Gp(t){return t.leadingTrivia.length===0?t.start:Gp(t.leadingTrivia[0])}function DL(t){return[I.SINGLE_LINE_COMMENT,I.MULTILINE_COMMENT].includes(t.kind)}class RL{constructor(){this.id=0}reset(){this.id=0}nextId(){return this.id++}}class xe{constructor(e,n,i){this.id=e,this.kind=n;const a=i.find(l=>l!==void 0&&!Number.isNaN(l.start));a?(this.startPos=a.startPos,this.fullStart=a instanceof Tt?Gp(a):a.fullStart):(this.startPos={offset:NaN,column:NaN,line:NaN},this.fullStart=NaN);const u=[...i].reverse().find(l=>l!==void 0&&!Number.isNaN(l.end));u?(this.endPos=u.endPos,this.fullEnd=u instanceof Tt?$p(u):u.fullEnd):(this.endPos={offset:NaN,column:NaN,line:NaN},this.fullEnd=NaN),this.start=this.startPos.offset,this.end=this.endPos.offset}}var wr=(t=>(t.PROGRAM="<program>",t.ELEMENT_DECLARATION="<element-declaration>",t.ATTRIBUTE="<attribute>",t.IDENTIFIER_STREAM="<identifer-stream>",t.LITERAL="<literal>",t.VARIABLE="<variable>",t.PREFIX_EXPRESSION="<prefix-expression>",t.INFIX_EXPRESSION="<infix-expression>",t.POSTFIX_EXPRESSION="<postfix-expression>",t.FUNCTION_EXPRESSION="<function-expression>",t.FUNCTION_APPLICATION="<function-application>",t.BLOCK_EXPRESSION="<block-expression>",t.LIST_EXPRESSION="<list-expression>",t.TUPLE_EXPRESSION="<tuple-expression>",t.CALL_EXPRESSION="<call-expression>",t.PRIMARY_EXPRESSION="<primary-expression>",t.GROUP_EXPRESSION="<group-expression>",t.COMMA_EXPRESSION="<comma-expression>",t.EMPTY="<dummy>",t.ARRAY="<array>",t))(wr||{});class Ze extends xe{constructor({body:e=[],eof:n,source:i},a){super(a,"<program>",[...e,n]),this.source=i,this.body=e,this.eof=n}}class re extends xe{constructor({type:e,name:n,as:i,alias:a,attributeList:u,bodyColon:l,body:f},h){if(super(h,"<element-declaration>",[e,n,i,a,u,l,f]),f&&l&&!(f instanceof z||f instanceof re))throw new Error("If an element has a simple body, it must be a function application node");this.type=e,this.name=n,this.as=i,this.alias=a,this.attributeList=u,this.bodyColon=l,this.body=f}}class rn extends xe{constructor({identifiers:e=[]},n){super(n,"<identifer-stream>",e||[]),this.identifiers=e}}class sn extends xe{constructor({name:e,colon:n,value:i},a){super(a,"<attribute>",[e,n,i]),this.name=e,this.value=i,this.colon=n}}class ft extends xe{constructor({op:e,expression:n},i){super(i,"<prefix-expression>",[e,n]),this.op=e,this.expression=n}}class on extends xe{constructor({op:e,leftExpression:n,rightExpression:i},a){super(a,"<infix-expression>",[n,e,i]),this.op=e,this.leftExpression=n,this.rightExpression=i}}class Ga extends xe{constructor({op:e,expression:n},i){super(i,"<postfix-expression>",[n,e]),this.op=e,this.expression=n}}class st extends xe{constructor({value:e},n){super(n,"<function-expression>",[e]),this.value=e}}class z extends xe{constructor({callee:e,args:n=[]},i){super(i,"<function-application>",[e,...n]),this.callee=e,this.args=n}}class Ge extends xe{constructor({blockOpenBrace:e,body:n=[],blockCloseBrace:i},a){super(a,"<block-expression>",[e,...n,i]),this.blockOpenBrace=e,this.body=n,this.blockCloseBrace=i}}class Le extends xe{constructor({listOpenBracket:e,elementList:n=[],commaList:i=[],listCloseBracket:a},u){super(u,"<list-expression>",[e,...Ol(n,i),a]),this.listOpenBracket=e,this.elementList=n,this.commaList=i,this.listCloseBracket=a}}class ln extends xe{constructor({tupleOpenParen:e,elementList:n=[],commaList:i=[],tupleCloseParen:a},u){super(u,"<tuple-expression>",[e,...Ol(n,i),a]),this.tupleOpenParen=e,this.elementList=n,this.commaList=i,this.tupleCloseParen=a}}class Fn extends xe{constructor({elementList:e=[],commaList:n=[]},i){super(i,"<comma-expression>",[...Ol(e,n)]),this.elementList=e,this.commaList=n}}class Sl extends ln{constructor({groupOpenParen:e,expression:n,groupCloseParen:i},a){super({tupleOpenParen:e,elementList:n&&[n],commaList:[],tupleCloseParen:i},a),this.kind="<group-expression>"}}class Se extends xe{constructor({callee:e,argumentList:n},i){super(i,"<call-expression>",[e,n]),this.callee=e,this.argumentList=n}}class Rr extends xe{constructor({literal:e},n){super(n,"<literal>",[e]),this.literal=e}}class Wn extends xe{constructor({variable:e},n){super(n,"<variable>",[e]),this.variable=e}}class yt extends xe{constructor({expression:e},n){super(n,"<primary-expression>",[e]),this.expression=e}}class gn extends xe{constructor({prevToken:e},n){const i=Tt.create(I.SPACE,e.endPos,e.endPos," ",!1);super(n,"<dummy>",[i])}}class Tn extends xe{constructor({expression:e,indexer:n},i){super(i,"<array>",[e,n]),this.array=e,this.indexer=n}}function Ol(t,e){if(!t||t.length===0)return e||[];if(!e||e.length===0)return t||[];const[n]=t,[i]=e;return(n.start<i.start?jh(zu(t,e)):jh(zu(e,t))).filter(a=>a!==null)}class kL{constructor(){this.id=0}reset(){this.id=0}nextId(){return this.id++}}class xl{constructor({symbolTable:e},n){this.references=[],this.id=n,this.symbolTable=e}}class Wp{constructor({symbolTable:e,declaration:n},i){this.references=[],this.id=i,this.symbolTable=e,this.declaration=n}}class Hp{constructor({declaration:e},n){this.references=[],this.id=n,this.declaration=e}}class oi{constructor({symbolTable:e,declaration:n},i){this.references=[],this.id=i,this.symbolTable=e,this.declaration=n}}class di{constructor({declaration:e},n){this.references=[],this.id=n,this.declaration=e}}class zp{constructor({symbolTable:e,declaration:n},i){this.references=[],this.id=i,this.symbolTable=e,this.declaration=n}}class qp{constructor({declaration:e},n){this.references=[],this.id=n,this.declaration=e}}class Xp{constructor({symbolTable:e,declaration:n},i){this.references=[],this.id=i,this.symbolTable=e,this.declaration=n}}class Yp{constructor({symbolTable:e,declaration:n},i){this.references=[],this.id=i,this.symbolTable=e,this.declaration=n}}class pi{constructor({declaration:e,tablePartialSymbol:n},i){this.references=[],this.id=i,this.declaration=e,this.tablePartialSymbol=n}}var N=(t=>(t[t.UNKNOWN_SYMBOL=1e3]="UNKNOWN_SYMBOL",t[t.UNEXPECTED_SYMBOL=1001]="UNEXPECTED_SYMBOL",t[t.UNEXPECTED_EOF=1002]="UNEXPECTED_EOF",t[t.UNEXPECTED_NEWLINE=1003]="UNEXPECTED_NEWLINE",t[t.UNKNOWN_TOKEN=1004]="UNKNOWN_TOKEN",t[t.UNEXPECTED_TOKEN=1005]="UNEXPECTED_TOKEN",t[t.UNEXPECTED_ELEMENT_DECLARATION=1006]="UNEXPECTED_ELEMENT_DECLARATION",t[t.MISSING_SPACES=1007]="MISSING_SPACES",t[t.UNKNOWN_PREFIX_OP=1008]="UNKNOWN_PREFIX_OP",t[t.INVALID_OPERAND=1009]="INVALID_OPERAND",t[t.EMPTY_ATTRIBUTE_NAME=1010]="EMPTY_ATTRIBUTE_NAME",t[t.INVALID_ESCAPE_SEQUENCE=1011]="INVALID_ESCAPE_SEQUENCE",t[t.INVALID_NAME=3e3]="INVALID_NAME",t[t.UNEXPECTED_NAME=3001]="UNEXPECTED_NAME",t[t.NAME_NOT_FOUND=3002]="NAME_NOT_FOUND",t[t.DUPLICATE_NAME=3003]="DUPLICATE_NAME",t[t.INVALID_ALIAS=3004]="INVALID_ALIAS",t[t.UNEXPECTED_ALIAS=3005]="UNEXPECTED_ALIAS",t[t.UNEXPECTED_SETTINGS=3006]="UNEXPECTED_SETTINGS",t[t.INVALID_SETTINGS=3007]="INVALID_SETTINGS",t[t.UNEXPECTED_SIMPLE_BODY=3008]="UNEXPECTED_SIMPLE_BODY",t[t.UNEXPECTED_COMPLEX_BODY=3009]="UNEXPECTED_COMPLEX_BODY",t[t.INVALID_TABLE_CONTEXT=3010]="INVALID_TABLE_CONTEXT",t[t.UNKNOWN_TABLE_SETTING=3011]="UNKNOWN_TABLE_SETTING",t[t.DUPLICATE_TABLE_SETTING=3012]="DUPLICATE_TABLE_SETTING",t[t.INVALID_TABLEGROUP_CONTEXT=3013]="INVALID_TABLEGROUP_CONTEXT",t[t.INVALID_TABLEGROUP_ELEMENT_NAME=3014]="INVALID_TABLEGROUP_ELEMENT_NAME",t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME=3015]="DUPLICATE_TABLEGROUP_ELEMENT_NAME",t[t.DUPLICATE_TABLEGROUP_FIELD_NAME=3016]="DUPLICATE_TABLEGROUP_FIELD_NAME",t[t.INVALID_TABLEGROUP_FIELD=3017]="INVALID_TABLEGROUP_FIELD",t[t.EMPTY_TABLE=3018]="EMPTY_TABLE",t[t.INVALID_COLUMN=3019]="INVALID_COLUMN",t[t.INVALID_COLUMN_NAME=3020]="INVALID_COLUMN_NAME",t[t.UNKNOWN_COLUMN_SETTING=3021]="UNKNOWN_COLUMN_SETTING",t[t.INVALID_COLUMN_TYPE=3022]="INVALID_COLUMN_TYPE",t[t.DUPLICATE_COLUMN_NAME=3023]="DUPLICATE_COLUMN_NAME",t[t.DUPLICATE_COLUMN_SETTING=3024]="DUPLICATE_COLUMN_SETTING",t[t.INVALID_COLUMN_SETTING_VALUE=3025]="INVALID_COLUMN_SETTING_VALUE",t[t.INVALID_ENUM_CONTEXT=3026]="INVALID_ENUM_CONTEXT",t[t.INVALID_ENUM_ELEMENT_NAME=3027]="INVALID_ENUM_ELEMENT_NAME",t[t.INVALID_ENUM_ELEMENT=3028]="INVALID_ENUM_ELEMENT",t[t.DUPLICATE_ENUM_ELEMENT_NAME=3029]="DUPLICATE_ENUM_ELEMENT_NAME",t[t.UNKNOWN_ENUM_ELEMENT_SETTING=3030]="UNKNOWN_ENUM_ELEMENT_SETTING",t[t.DUPLICATE_ENUM_ELEMENT_SETTING=3031]="DUPLICATE_ENUM_ELEMENT_SETTING",t[t.INVALID_ENUM_ELEMENT_SETTING=3032]="INVALID_ENUM_ELEMENT_SETTING",t[t.EMPTY_ENUM=3033]="EMPTY_ENUM",t[t.INVALID_REF_CONTEXT=3034]="INVALID_REF_CONTEXT",t[t.UNKNOWN_REF_SETTING=3035]="UNKNOWN_REF_SETTING",t[t.DUPLICATE_REF_SETTING=3036]="DUPLICATE_REF_SETTING",t[t.INVALID_REF_SETTING_VALUE=3037]="INVALID_REF_SETTING_VALUE",t[t.INVALID_REF_RELATIONSHIP=3038]="INVALID_REF_RELATIONSHIP",t[t.INVALID_REF_FIELD=3039]="INVALID_REF_FIELD",t[t.EMPTY_REF=3040]="EMPTY_REF",t[t.REF_REDEFINED=3041]="REF_REDEFINED",t[t.INVALID_NOTE_CONTEXT=3042]="INVALID_NOTE_CONTEXT",t[t.INVALID_NOTE=3043]="INVALID_NOTE",t[t.NOTE_REDEFINED=3044]="NOTE_REDEFINED",t[t.NOTE_CONTENT_REDEFINED=3045]="NOTE_CONTENT_REDEFINED",t[t.EMPTY_NOTE=3046]="EMPTY_NOTE",t[t.INVALID_INDEXES_CONTEXT=3047]="INVALID_INDEXES_CONTEXT",t[t.INVALID_INDEXES_FIELD=3048]="INVALID_INDEXES_FIELD",t[t.INVALID_INDEX=3049]="INVALID_INDEX",t[t.UNKNOWN_INDEX_SETTING=3050]="UNKNOWN_INDEX_SETTING",t[t.DUPLICATE_INDEX_SETTING=3051]="DUPLICATE_INDEX_SETTING",t[t.UNEXPECTED_INDEX_SETTING_VALUE=3052]="UNEXPECTED_INDEX_SETTING_VALUE",t[t.INVALID_INDEX_SETTING_VALUE=3053]="INVALID_INDEX_SETTING_VALUE",t[t.INVALID_PROJECT_CONTEXT=3054]="INVALID_PROJECT_CONTEXT",t[t.PROJECT_REDEFINED=3055]="PROJECT_REDEFINED",t[t.INVALID_PROJECT_FIELD=3056]="INVALID_PROJECT_FIELD",t[t.INVALID_CUSTOM_CONTEXT=3057]="INVALID_CUSTOM_CONTEXT",t[t.INVALID_CUSTOM_ELEMENT_VALUE=3058]="INVALID_CUSTOM_ELEMENT_VALUE",t[t.INVALID_ELEMENT_IN_SIMPLE_BODY=3059]="INVALID_ELEMENT_IN_SIMPLE_BODY",t[t.INVALID_TABLE_PARTIAL_CONTEXT=3060]="INVALID_TABLE_PARTIAL_CONTEXT",t[t.INVALID_TABLE_PARTIAL_ELEMENT_NAME=3061]="INVALID_TABLE_PARTIAL_ELEMENT_NAME",t[t.INVALID_TABLE_PARTIAL_SETTING_VALUE=3062]="INVALID_TABLE_PARTIAL_SETTING_VALUE",t[t.DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME=3063]="DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME",t[t.DUPLICATE_TABLE_PARTIAL_SETTING=3064]="DUPLICATE_TABLE_PARTIAL_SETTING",t[t.INVALID_TABLE_PARTIAL_INJECTION=3065]="INVALID_TABLE_PARTIAL_INJECTION",t[t.INVALID_TABLE_PARTIAL_INJECTION_OP=3066]="INVALID_TABLE_PARTIAL_INJECTION_OP",t[t.INVALID_TABLE_PARTIAL_INJECTION_NAME=3067]="INVALID_TABLE_PARTIAL_INJECTION_NAME",t[t.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME=3068]="DUPLICATE_TABLE_PARTIAL_INJECTION_NAME",t[t.UNKNOWN_TABLE_PARTIAL_SETTING=3069]="UNKNOWN_TABLE_PARTIAL_SETTING",t[t.INVALID_TABLE_SETTING_VALUE=3070]="INVALID_TABLE_SETTING_VALUE",t[t.INVALID_CHECKS_CONTEXT=3071]="INVALID_CHECKS_CONTEXT",t[t.INVALID_CHECKS_FIELD=3072]="INVALID_CHECKS_FIELD",t[t.INVALID_CHECK=3073]="INVALID_CHECK",t[t.UNKNOWN_CHECK_SETTING=3074]="UNKNOWN_CHECK_SETTING",t[t.DUPLICATE_CHECK_SETTING=3075]="DUPLICATE_CHECK_SETTING",t[t.INVALID_CHECK_SETTING_VALUE=3076]="INVALID_CHECK_SETTING_VALUE",t[t.INVALID_RECORDS_CONTEXT=3077]="INVALID_RECORDS_CONTEXT",t[t.INVALID_RECORDS_NAME=3078]="INVALID_RECORDS_NAME",t[t.INVALID_RECORDS_FIELD=3079]="INVALID_RECORDS_FIELD",t[t.DUPLICATE_COLUMN_REFERENCES_IN_RECORDS=3080]="DUPLICATE_COLUMN_REFERENCES_IN_RECORDS",t[t.DUPLICATE_RECORDS_FOR_TABLE=3081]="DUPLICATE_RECORDS_FOR_TABLE",t[t.BINDING_ERROR=4e3]="BINDING_ERROR",t[t.UNSUPPORTED=5e3]="UNSUPPORTED",t[t.CIRCULAR_REF=5001]="CIRCULAR_REF",t[t.SAME_ENDPOINT=5002]="SAME_ENDPOINT",t[t.UNEQUAL_FIELDS_BINARY_REF=5003]="UNEQUAL_FIELDS_BINARY_REF",t[t.CONFLICTING_SETTING=5004]="CONFLICTING_SETTING",t[t.TABLE_REAPPEAR_IN_TABLEGROUP=5005]="TABLE_REAPPEAR_IN_TABLEGROUP",t))(N||{});class v extends Error{constructor(e,n,i){super(n),this.code=e,this.diagnostic=n,this.nodeOrToken=i,this.start=i.start,this.end=i.end,this.name=this.constructor.name,Object.setPrototypeOf(this,v.prototype)}toWarning(){return new en(this.code,this.message,this.nodeOrToken)}}class en extends Error{constructor(e,n,i){super(n),this.code=e,this.diagnostic=n,this.nodeOrToken=i,this.start=i.start,this.end=i.end,this.name=this.constructor.name,Object.setPrototypeOf(this,v.prototype)}}class ue{constructor(e,n,i){this.value=e,this.errors=n===void 0?[]:n,i?.length&&(this.warnings=i)}getValue(){return this.value}getErrors(){return this.errors}getWarnings(){return this.warnings||[]}chain(e){const n=e(this.value),i=[...this.errors,...n.errors],a=[...this.getWarnings(),...n.getWarnings()];return new ue(n.value,i,a)}map(e){return new ue(e(this.value),this.errors,this.warnings)}}function us(t){return!!t.match(new RegExp("(\\p{L}|_|\\p{M})","gu"))}function En(t){if(!t)return!1;const e=t[0];return e>="0"&&e<="9"}function ML(t){const[e]=t;return En(e)||us(e)&&e.toLowerCase()>="a"&&e.toLowerCase()<="f"}function yr(t){return us(t)||En(t)}function Du(t,e){const n=[],i=Math.min(t.length,e.length);for(let a=0;a<i;a+=1)n.push(t[a],e[a]);return n.push(...t.slice(i),...e.slice(i)),n}function sr(t,e){return t>=e.start&&t<e.end}function Yu(t){return t instanceof ft?`${t.op?.value}${Yu(t.expression)}`:t.expression.literal.value}function ni(t){return t instanceof ft?t.op?.value==="-"?-ni(t.expression):ni(t.expression):Number.parseFloat(t.expression.literal.value)}class Be{constructor(e){this.value=e}unwrap(){return this.value}unwrap_or(e){return this.value}and_then(e){return e(this.value)}map(e){return new Be(e(this.value))}isOk(){return!0}}class Ne{constructor(){this.value=void 0}unwrap(){throw new Error("Trying to unwrap a None value")}unwrap_or(e){return e}and_then(e){return new Ne}map(e){return new Ne}isOk(){return!1}}const Zp=["null","true","false"],Kp=["-","+"],Wt="public";var U=(t=>(t.Table="table",t.Enum="enum",t.Ref="ref",t.Note="note",t.Project="project",t.Indexes="indexes",t.TableGroup="tablegroup",t.TablePartial="tablepartial",t.Check="checks",t.Records="records",t))(U||{}),k=(t=>(t.Color="color",t.HeaderColor="headercolor",t.Note="note",t.PK="pk",t.PrimaryKey="primary key",t.Unique="unique",t.Ref="ref",t.NotNull="not null",t.Null="null",t.Increment="increment",t.Default="default",t.Name="name",t.Type="type",t.Check="check",t.Update="update",t.Delete="delete",t))(k||{});class PL{constructor(e,n,i){this.declarationNode=e,this.publicSymbolTable=n,this.symbolFactory=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof Ze||dt(this.declarationNode.parent).unwrap_or(void 0)!==U.Project?[new v(N.INVALID_CUSTOM_CONTEXT,"A Custom element can only appear in a Project",this.declarationNode)]:[]}validateName(e){return e?[new v(N.UNEXPECTED_NAME,"A Custom element shouldn't have a name",e)]:[]}validateAlias(e){return e?[new v(N.UNEXPECTED_NAME,"A Custom element shouldn't have an alias",e)]:[]}validateSettingList(e){return e?[new v(N.UNEXPECTED_SETTINGS,"A Custom element shouldn't have a setting list",e)]:[]}validateBody(e){if(!e)return[];if(e instanceof Ge)return[new v(N.UNEXPECTED_COMPLEX_BODY,"A Custom element can only have an inline field",e)];const n=[];return Ke(e.callee)||n.push(new v(N.INVALID_CUSTOM_ELEMENT_VALUE,"A Custom element value can only be a string",e)),e.args.length>0&&n.push(...e.args.map(i=>new v(N.INVALID_CUSTOM_ELEMENT_VALUE,"A Custom element value can only be a string",i))),n}}var M=(t=>(t.Schema="Schema",t.Table="Table",t.Column="Column",t.TableGroup="TableGroup",t.TableGroupField="TableGroup field",t.Enum="Enum",t.EnumField="Enum field",t.Note="Note",t.TablePartial="TablePartial",t.PartialInjection="PartialInjection",t))(M||{});function ls(t){return`Schema:${t}`}function ui(t){return`Table:${t}`}function Un(t){return`Column:${t}`}function Dl(t){return`Enum:${t}`}function Rl(t){return`Enum field:${t}`}function kl(t){return`TableGroup:${t}`}function Ml(t){return`TableGroup field:${t}`}function CL(t){return`Note:${t}`}function Pl(t){return`TablePartial:${t}`}function Cl(t){return`PartialInjection:${t}`}function FL(t,e){switch(e){case"Column":return Un(t);case"Enum":return Dl(t);case"Enum field":return Rl(t);case"Schema":return ls(t);case"Table":return ui(t);case"TableGroup":return kl(t);case"TableGroup field":return Ml(t);case"TablePartial":return Pl(t);case"PartialInjection":return Cl(t);default:throw new Error("Unreachable")}}function mi(t){const[e,n]=t.split(":");return Object.values(M).includes(e)?new Be({name:n,kind:e}):new Ne}class Sr{constructor(){this.table=new Map}has(e){return this.table.has(e)}set(e,n){this.table.set(e,n)}get(e,n){return this.table.get(e)||n!==void 0&&this.set(e,n)||n}entries(){return this.table.entries()}forEach(e){return this.table.forEach(e)}}class UL{constructor(e,n,i){this.declarationNode=e,this.publicSymbolTable=n,this.symbolFactory=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof re?[new v(N.INVALID_PROJECT_CONTEXT,"An Enum can only appear top-level",this.declarationNode)]:[]}validateName(e){return e?Fl(e)?[]:[new v(N.INVALID_NAME,"An Enum name must be of the form <enum> or <schema>.<enum>",e)]:[new v(N.NAME_NOT_FOUND,"An Enum must have a name",this.declarationNode)]}validateAlias(e){return e?[new v(N.UNEXPECTED_ALIAS,"An Enum shouldn't have an alias",e)]:[]}registerElement(){const e=[];this.declarationNode.symbol=this.symbolFactory.create(Wp,{declaration:this.declarationNode,symbolTable:new Sr});const{name:n}=this.declarationNode,i=qe(n);if(i.isOk()){const a=i.unwrap(),u=a.pop(),l=Wa(a,this.publicSymbolTable,this.symbolFactory),f=Dl(u);l.has(f)&&e.push(new v(N.DUPLICATE_NAME,`Enum name ${u} already exists in schema '${a.join(".")||Wt}'`,n)),l.set(f,this.declarationNode.symbol)}return e}validateSettingList(e){return e?[new v(N.UNEXPECTED_SETTINGS,"An Enum shouldn't have a setting list",e)]:[]}validateBody(e){if(!e)return[];if(e instanceof z)return this.validateFields([e]);const[n,i]=ht(e.body,a=>a instanceof z);return[...this.validateFields(n),...this.validateSubElements(i)]}validateFields(e){return e.length===0?[new v(N.EMPTY_ENUM,"An Enum must have at least one element",this.declarationNode)]:e.flatMap(n=>{const i=[];n.callee&&!De(n.callee)&&i.push(new v(N.INVALID_ENUM_ELEMENT_NAME,"An enum field must be an identifier or a quoted identifier",n.callee));const a=[...n.args];return Oe(a)instanceof Le?(i.push(...this.validateFieldSettings(Oe(a))),a.pop()):a[0]instanceof Le&&(i.push(...this.validateFieldSettings(a[0])),a.shift()),a.length>0&&i.push(...a.map(u=>new v(N.INVALID_ENUM_ELEMENT,"An Enum must have only a field and optionally a setting list",u))),i.push(...this.registerField(n)),i})}validateFieldSettings(e){const n=ke(e),i=n.getErrors(),a=n.getValue();for(const u in a){const l=a[u];switch(u){case"note":l.length>1&&l.forEach(f=>i.push(new v(N.DUPLICATE_ENUM_ELEMENT_SETTING,"'note' can only appear once",f))),l.forEach(f=>{Ke(f.value)||i.push(new v(N.INVALID_ENUM_ELEMENT_SETTING,"'note' must be a string",f))});break;default:l.forEach(f=>i.push(new v(N.UNKNOWN_ENUM_ELEMENT_SETTING,`Unknown enum field setting '${u}'`,f)))}}return i}validateSubElements(e){return e.flatMap(n=>{if(n.parent=this.declarationNode,!n.type)return[];const i=cn(n);return new i(n,this.publicSymbolTable,this.symbolFactory).validate()})}registerField(e){if(e.callee&&De(e.callee)){const n=ze(e.callee).unwrap(),i=Rl(n),a=this.symbolFactory.create(Hp,{declaration:e});e.symbol=a;const u=this.declarationNode.symbol.symbolTable;if(u.has(i)){const l=u.get(i);return[new v(N.DUPLICATE_COLUMN_NAME,`Duplicate enum field ${n}`,e),new v(N.DUPLICATE_COLUMN_NAME,`Duplicate enum field ${n}`,l.declaration)]}u.set(i,a)}return[]}}class VL{constructor(e,n,i){this.declarationNode=e,this.publicSymbolTable=n,this.symbolFactory=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){const e=new v(N.INVALID_INDEXES_CONTEXT,"An Indexes can only appear inside a Table or a TablePartial",this.declarationNode);if(this.declarationNode.parent instanceof Ze)return[e];const n=dt(this.declarationNode.parent).unwrap_or(void 0);return n&&[U.Table,U.TablePartial].includes(n)?[]:[e]}validateName(e){return e?[new v(N.UNEXPECTED_NAME,"An Indexes shouldn't have a name",e)]:[]}validateAlias(e){return e?[new v(N.UNEXPECTED_ALIAS,"An Indexes shouldn't have an alias",e)]:[]}validateSettingList(e){return e?[new v(N.UNEXPECTED_SETTINGS,"An Indexes shouldn't have a setting list",e)]:[]}validateBody(e){if(!e)return[];if(e instanceof z)return[new v(N.UNEXPECTED_SIMPLE_BODY,"An Indexes must have a complex body",e)];const[n,i]=ht(e.body,a=>a instanceof z);return[...this.validateFields(n),...this.validateSubElements(i)]}validateFields(e){return e.flatMap(n=>{if(!n.callee)return[];const i=[],a=[n.callee,...n.args];return Oe(a)instanceof Le&&i.push(...this.validateFieldSetting(a.pop())),a.forEach(u=>{for(;u instanceof Se;)u.argumentList&&!ba(u.argumentList).isOk()&&i.push(new v(N.INVALID_INDEXES_FIELD,"An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such",u.argumentList)),u=u.callee;ba(u).isOk()||i.push(new v(N.INVALID_INDEXES_FIELD,"An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such",u))}),i})}validateFieldSetting(e){const n=ke(e),i=n.getErrors(),a=n.getValue();for(const u in a){const l=a[u];switch(u){case"note":case"name":l.length>1&&l.forEach(f=>i.push(new v(N.DUPLICATE_INDEX_SETTING,`'${u}' can only appear once`,f))),l.forEach(f=>{Ke(f.value)||i.push(new v(N.INVALID_INDEX_SETTING_VALUE,`'${u}' must be a string`,f))});break;case"unique":case"pk":l.length>1&&l.forEach(f=>i.push(new v(N.DUPLICATE_INDEX_SETTING,`'${u}' can only appear once`,f))),l.forEach(f=>{Lt(f.value)||i.push(new v(N.INVALID_INDEX_SETTING_VALUE,`'${u}' must not have a value`,f))});break;case"type":l.length>1&&l.forEach(f=>i.push(new v(N.DUPLICATE_INDEX_SETTING,"'type' can only appear once",f))),l.forEach(f=>{De(f.value)||i.push(new v(N.INVALID_INDEX_SETTING_VALUE,`'type' must be "btree" or "hash"`,f))});break;default:l.forEach(f=>i.push(new v(N.UNKNOWN_INDEX_SETTING,`Unknown index setting '${u}'`,f)))}}return i}validateSubElements(e){return e.flatMap(n=>{if(n.parent=this.declarationNode,!n.type)return[];const i=cn(n);return new i(n,this.publicSymbolTable,this.symbolFactory).validate()})}}class BL{constructor(e,n,i){this.declarationNode=e,this.publicSymbolTable=n,this.symbolFactory=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return!(this.declarationNode.parent instanceof Ze)&&![U.Table,U.TableGroup,U.TablePartial,U.Project].includes(dt(this.declarationNode.parent).unwrap_or(void 0))?[new v(N.INVALID_NOTE_CONTEXT,"A Note can only appear inside a Table, a TableGroup, a TablePartial or a Project. Sticky note can only appear at the global scope.",this.declarationNode)]:[]}validateName(e){if(!(this.declarationNode.parent instanceof Ze))return e?[new v(N.UNEXPECTED_NAME,"A Note shouldn't have a name",e)]:[];if(!e)return[new v(N.INVALID_NAME,"Sticky note must have a name",this.declarationNode)];const n=qe(e);if(!n.isOk())return[new v(N.INVALID_NAME,"Invalid name for sticky note ",this.declarationNode)];const a=n.unwrap().join("."),u=CL(a);return this.publicSymbolTable.has(u)?[new v(N.DUPLICATE_NAME,`Sticky note "${a}" has already been defined`,e)]:(this.publicSymbolTable.set(u,this.declarationNode.symbol),[])}validateAlias(e){return e?[new v(N.UNEXPECTED_ALIAS,"A Ref shouldn't have an alias",e)]:[]}validateSettingList(e){return e?[new v(N.UNEXPECTED_SETTINGS,"A Note shouldn't have a setting list",e)]:[]}validateBody(e){if(!e)return[];if(e instanceof z)return this.validateFields([e]);const[n,i]=ht(e.body,a=>a instanceof z);return[...this.validateFields(n),...this.validateSubElements(i)]}validateFields(e){const n=[];return e.length===0?[new v(N.EMPTY_NOTE,"A Note must have a content",this.declarationNode)]:(e.length>1&&e.slice(1).forEach(i=>n.push(new v(N.NOTE_CONTENT_REDEFINED,"A Note can only contain one string",i))),Ke(e[0].callee)||n.push(new v(N.INVALID_NOTE,"A Note content must be a quoted string",e[0])),e[0].args.length>0&&n.push(...e[0].args.map(i=>new v(N.INVALID_NOTE,"A Note can only contain one quoted string",i))),n)}validateSubElements(e){return e.flatMap(n=>{if(n.parent=this.declarationNode,!n.type)return[];const i=cn(n);return new i(n,this.publicSymbolTable,this.symbolFactory).validate()})}}class $L{constructor(e,n,i){this.declarationNode=e,this.publicSymbolTable=n,this.symbolFactory=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof re?[new v(N.INVALID_PROJECT_CONTEXT,"A Project can only appear top-level",this.declarationNode)]:[]}validateName(e){return e?gi(e)?[]:[new v(N.INVALID_NAME,"A Project's name is optional or must be an identifier or a quoted identifer",e)]:[]}validateAlias(e){return e?[new v(N.UNEXPECTED_ALIAS,"A Project shouldn't have an alias",e)]:[]}validateSettingList(e){return e?[new v(N.UNEXPECTED_SETTINGS,"A Project shouldn't have a setting list",e)]:[]}validateBody(e){if(!e)return[];if(e instanceof z)return[new v(N.UNEXPECTED_SIMPLE_BODY,"A Project's body must be a block",e)];const[n,i]=ht(e.body,a=>a instanceof z);return[...n.map(a=>new v(N.INVALID_PROJECT_FIELD,"A Project can not have inline fields",a)),...this.validateSubElements(i)]}validateSubElements(e){return e.flatMap(n=>{if(n.parent=this.declarationNode,!n.type)return[];const i=cn(n);return new i(n,this.publicSymbolTable,this.symbolFactory).validate()})}}class GL{constructor(e,n,i){this.declarationNode=e,this.publicSymbolTable=n,this.symbolFactory=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof Ze?[]:[new v(N.INVALID_REF_CONTEXT,"A Ref must appear top-level",this.declarationNode)]}validateName(e){return e?gi(e)?[]:[new v(N.INVALID_NAME,"A Ref's name is optional or must be an identifier or a quoted identifer",e)]:[]}validateAlias(e){return e?[new v(N.UNEXPECTED_ALIAS,"A Ref shouldn't have an alias",e)]:[]}validateSettingList(e){return e?[new v(N.UNEXPECTED_SETTINGS,"A Ref shouldn't have a setting list",e)]:[]}validateBody(e){if(!e)return[];if(e instanceof z)return this.validateFields([e]);const[n,i]=ht(e.body,a=>a instanceof z);return[...this.validateFields(n),...this.validateSubElements(i)]}validateFields(e){if(e.length===0)return[new v(N.EMPTY_REF,"A Ref must have at least one field",this.declarationNode)];const n=[];return e.length>1&&n.push(...e.slice(1).map(i=>new v(N.REF_REDEFINED,"A Ref can only contain one binary relationship",i))),e.forEach(i=>{if(i.callee&&!dd(i.callee)&&n.push(new v(N.INVALID_REF_FIELD,"A Ref field must be a binary relationship",i.callee)),i.callee&&dd(i.callee)){const u=Ot(i.callee.leftExpression).unwrap_or({variables:[],tupleElements:[]}),l=u.variables.length+Math.min(u.tupleElements.length,1),f=Ot(i.callee.rightExpression).unwrap_or({variables:[],tupleElements:[]}),h=f.variables.length+Math.min(f.tupleElements.length,1);l<2&&n.push(new v(N.INVALID_REF_FIELD,"Invalid column reference",i.callee.leftExpression||i.callee)),h<2&&n.push(new v(N.INVALID_REF_FIELD,"Invalid column reference",i.callee.rightExpression||i.callee))}i.callee&&!JL(i.callee)&&n.push(new v(N.UNEQUAL_FIELDS_BINARY_REF,"Unequal fields in ref endpoints",i.callee));const a=[...i.args];if(Oe(a)instanceof Le){const u=this.validateFieldSettings(Oe(a));n.push(...u),a.pop()}else a[0]instanceof Le&&(n.push(...this.validateFieldSettings(a[0])),a.shift());a.length>0&&n.push(...a.map(u=>new v(N.INVALID_REF_FIELD,"A Ref field should only have a single binary relationship",u)))}),n}validateFieldSettings(e){const n=ke(e),i=n.getErrors(),a=n.getValue();for(const u in a){const l=a[u];switch(u){case"delete":case"update":l.length>1&&l.forEach(f=>i.push(new v(N.DUPLICATE_REF_SETTING,`'${u}' can only appear once`,f))),l.forEach(f=>{WL(f.value)||i.push(new v(N.INVALID_REF_SETTING_VALUE,`'${u}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`,f))});break;case"color":l.length>1&&i.push(...l.map(f=>new v(N.DUPLICATE_REF_SETTING,"'color' can only appear once",f))),l.forEach(f=>{Ha(f.value)||i.push(new v(N.INVALID_REF_SETTING_VALUE,"'color' must be a color literal",f))});break;default:l.forEach(f=>i.push(new v(N.UNKNOWN_REF_SETTING,`Unknown ref setting '${u}'`,f)))}}return i}validateSubElements(e){return e.flatMap(n=>{if(n.parent=this.declarationNode,!n.type)return[];const i=cn(n);return new i(n,this.publicSymbolTable,this.symbolFactory).validate()})}}function WL(t){if(!(De(t)&&t.expression.variable.kind!==I.QUOTED_STRING)&&!(t instanceof rn))return!1;let e;if(t instanceof rn?e=rs(t).unwrap_or(""):e=t.expression.variable.value,e)switch(e.toLowerCase()){case"cascade":case"no action":case"set null":case"set default":case"restrict":return!0;default:return!1}return!1}class HL{constructor(e,n,i){this.declarationNode=e,this.symbolFactory=i,this.publicSymbolTable=n}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof re?[new v(N.INVALID_TABLE_CONTEXT,"Table must appear top-level",this.declarationNode)]:[]}validateName(e){return e?e instanceof Tn?[new v(N.INVALID_NAME,"Invalid array as Table name, maybe you forget to add a space between the name and the setting list?",e)]:Fl(e)?[]:[new v(N.INVALID_NAME,"A Table name must be of the form <table> or <schema>.<table>",e)]:[new v(N.NAME_NOT_FOUND,"A Table must have a name",this.declarationNode)]}validateAlias(e){return e?KL(e)?[]:[new v(N.INVALID_ALIAS,"Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes",e)]:[]}validateSettingList(e){const n=ke(e),i=n.getErrors(),a=n.getValue();return es(a,(u,l)=>{switch(l){case k.HeaderColor:u.length>1&&i.push(...u.map(f=>new v(N.DUPLICATE_TABLE_SETTING,"'headercolor' can only appear once",f))),u.forEach(f=>{Ha(f.value)||i.push(new v(N.INVALID_TABLE_SETTING_VALUE,"'headercolor' must be a color literal",f.value||f.name))});break;case k.Note:u.length>1&&i.push(...u.map(f=>new v(N.DUPLICATE_TABLE_SETTING,"'note' can only appear once",f))),u.forEach(f=>{Ke(f.value)||i.push(new v(N.INVALID_TABLE_SETTING_VALUE,"'note' must be a string literal",f.value||f.name))});break;default:i.push(...u.map(f=>new v(N.UNKNOWN_TABLE_SETTING,`Unknown '${l}' setting`,f)))}}),i}registerElement(){const e=[];this.declarationNode.symbol=this.symbolFactory.create(oi,{declaration:this.declarationNode,symbolTable:new Sr});const{name:n,alias:i}=this.declarationNode,a=qe(n);if(a.isOk()){const u=[...a.unwrap()],l=u.pop(),f=Wa(u,this.publicSymbolTable,this.symbolFactory),h=ui(l);f.has(h)&&e.push(new v(N.DUPLICATE_NAME,`Table name '${l}' already exists in schema '${u.join(".")||Wt}'`,n)),f.set(h,this.declarationNode.symbol)}if(i&&gi(i)&&!zL(i.expression.variable.value,a.unwrap_or([]))){const u=ze(i).unwrap(),l=ui(u);this.publicSymbolTable.has(l)&&e.push(new v(N.DUPLICATE_NAME,`Table name '${u}' already exists`,n)),this.publicSymbolTable.set(l,this.declarationNode.symbol)}return e}validateBody(e){if(!e)return[];if(e instanceof z)return[new v(N.UNEXPECTED_SIMPLE_BODY,"A Table's body must be a block",e)];const[n,i]=ht(e.body,a=>a instanceof z);return[...this.validateFields(n),...this.validateSubElements(i)]}validateFields(e){const n=a=>{const u=[];if(!a.callee)return[];a.args.length===0&&u.push(new v(N.INVALID_COLUMN,"A column must have a type",a.callee)),De(a.callee)||u.push(new v(N.INVALID_COLUMN_NAME,"A column name must be an identifier or a quoted identifier",a.callee)),a.args[0]&&!em(a.args[0])&&u.push(new v(N.INVALID_COLUMN_TYPE,"Invalid column type",a.args[0]));const l=a.args.slice(1);return u.push(...this.validateFieldSetting(l)),u.push(...this.registerField(a)),u},i=a=>{const u=[];if(!a.callee)return[];if(!ts(a.callee))u.push(new v(N.INVALID_TABLE_PARTIAL_INJECTION,"A partial injection should be of the form ~<table-partial>",a.callee));else{const l=ve(a.callee.expression).unwrap_or(""),f=this.symbolFactory.create(Yp,{symbolTable:new Sr,declaration:a}),h=Cl(l),m=this.declarationNode.symbol.symbolTable;if(m.has(h)){const E=m.get(h);return[new v(N.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME,`Duplicate table partial injection '${l}'`,a),new v(N.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME,`Duplicate table partial injection '${l}'`,E.declaration)]}m.set(h,f)}return a.args.length&&u.push(...a.args.map(l=>new v(N.INVALID_TABLE_PARTIAL_INJECTION,"A partial injection does not have any trailing attributes",l))),u};return e.flatMap(a=>a.callee instanceof ft&&a.callee.op?.value==="~"?i(a):n(a))}registerField(e){if(e.callee&&De(e.callee)){const n=ze(e.callee).unwrap(),i=Un(n),a=this.symbolFactory.create(di,{declaration:e});e.symbol=a;const u=this.declarationNode.symbol.symbolTable;if(u.has(i)){const l=u.get(i);return[new v(N.DUPLICATE_COLUMN_NAME,`Duplicate column ${n}`,e),new v(N.DUPLICATE_COLUMN_NAME,`Duplicate column ${n}`,l.declaration)]}u.set(i,a)}return[]}validateFieldSetting(e){if(!e.slice(0,-1).every(yn)||!e.slice(-1).every(h=>yn(h)||h instanceof Le))return[...e.map(h=>new v(N.INVALID_COLUMN,"These fields must be some inline settings optionally ended with a setting list",h))];if(e.length===0)return[];let n;Oe(e)instanceof Le&&(n=e.pop());const i=ke(n),a=i.getErrors(),u=i.getValue();e.forEach(h=>{const m=ze(h).unwrap_or("").toLowerCase();if(m!=="pk"&&m!=="unique"){a.push(new v(N.INVALID_SETTINGS,"Inline column settings can only be `pk` or `unique`",h));return}u[m]===void 0?u[m]=[h]:u[m].push(h)});const l=u[k.PK]||[],f=u[k.PrimaryKey]||[];return l.length>=1&&f.length>=1&&a.push(...[...l,...f].map(h=>new v(N.DUPLICATE_COLUMN_SETTING,"Either one of 'primary key' and 'pk' can appear",h))),es(u,(h,m)=>{switch(m){case k.Note:h.length>1&&a.push(...h.map(E=>new v(N.DUPLICATE_COLUMN_SETTING,"note can only appear once",E))),h.forEach(E=>{Ke(E.value)||a.push(new v(N.INVALID_COLUMN_SETTING_VALUE,"'note' must be a quoted string",E.value||E.name))});break;case k.Ref:h.forEach(E=>{Qp(E.value)||a.push(new v(N.INVALID_COLUMN_SETTING_VALUE,"'ref' must be a valid unary relationship",E.value||E.name))});break;case k.PrimaryKey:h.length>1&&a.push(...h.map(E=>new v(N.DUPLICATE_COLUMN_SETTING,"primary key can only appear once",E))),h.forEach(E=>{Lt(E.value)||a.push(new v(N.INVALID_COLUMN_SETTING_VALUE,"'primary key' must not have a value",E.value||E.name))});break;case k.PK:h.length>1&&a.push(...h.map(E=>new v(N.DUPLICATE_COLUMN_SETTING,"'pk' can only appear once",E))),h.forEach(E=>{E instanceof sn&&!Lt(E.value)&&a.push(new v(N.INVALID_COLUMN_SETTING_VALUE,"'pk' must not have a value",E.value||E.name))});break;case k.NotNull:{h.length>1&&a.push(...h.map(T=>new v(N.DUPLICATE_COLUMN_SETTING,"'not null' can only appear once",T)));const E=u[k.Null]||[];h.length>=1&&E.length>=1&&a.push(...[...h,...E].map(T=>new v(N.CONFLICTING_SETTING,"'not null' and 'null' can not be set at the same time",T))),h.forEach(T=>{Lt(T.value)||a.push(new v(N.INVALID_COLUMN_SETTING_VALUE,"'not null' must not have a value",T.value||T.name))});break}case k.Null:h.length>1&&a.push(...h.map(E=>new v(N.DUPLICATE_COLUMN_SETTING,"'null' can only appear once",E))),h.forEach(E=>{Lt(E.value)||a.push(new v(N.INVALID_COLUMN_SETTING_VALUE,"'null' must not have a value",E.value||E.name))});break;case k.Unique:h.length>1&&a.push(...h.map(E=>new v(N.DUPLICATE_COLUMN_SETTING,"'unique' can only appear once",E))),h.forEach(E=>{E instanceof sn&&!Lt(E.value)&&a.push(new v(N.INVALID_COLUMN_SETTING_VALUE,"'unique' must not have a value",E.value||E.name))});break;case k.Increment:h.length>1&&a.push(...h.map(E=>new v(N.DUPLICATE_COLUMN_SETTING,"'increment' can only appear once",E))),h.forEach(E=>{E instanceof sn&&!Lt(E.value)&&a.push(new v(N.INVALID_COLUMN_SETTING_VALUE,"'increment' must not have a value",E.value||E.name))});break;case k.Default:h.length>1&&a.push(...h.map(E=>new v(N.DUPLICATE_COLUMN_SETTING,"'default' can only appear once",E))),h.forEach(E=>{jp(E.value)||a.push(new v(N.INVALID_COLUMN_SETTING_VALUE,"'default' must be an enum value, a string literal, number literal, function expression, true, false or null",E.value||E.name))});break;case k.Check:h.forEach(E=>{E.value instanceof st||a.push(new v(N.INVALID_COLUMN_SETTING_VALUE,"'check' must be a function expression",E.value||E.name))});break;default:h.forEach(E=>a.push(new v(N.UNKNOWN_COLUMN_SETTING,`Unknown column setting '${m}'`,E)))}}),a}validateSubElements(e){const n=e.flatMap(a=>{if(a.parent=this.declarationNode,!a.type)return[];const u=cn(a);return new u(a,this.publicSymbolTable,this.symbolFactory).validate()}),i=e.filter(a=>a.type?.value.toLowerCase()==="note");return i.length>1&&n.push(...i.map(a=>new v(N.NOTE_REDEFINED,"Duplicate notes are defined",a))),n}}function zL(t,e){return e.length===1&&t===e[0]}class qL{constructor(e,n,i){this.declarationNode=e,this.publicSymbolTable=n,this.symbolFactory=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof re?[new v(N.INVALID_TABLEGROUP_CONTEXT,"TableGroup must appear top-level",this.declarationNode)]:[]}validateName(e){return e?gi(e)?[]:[new v(N.INVALID_NAME,"A TableGroup name must be a single identifier",e)]:[new v(N.NAME_NOT_FOUND,"A TableGroup must have a name",this.declarationNode)]}validateAlias(e){return e?[new v(N.UNEXPECTED_ALIAS,"A TableGroup shouldn't have an alias",e)]:[]}registerElement(){const{name:e}=this.declarationNode;this.declarationNode.symbol=this.symbolFactory.create(zp,{declaration:this.declarationNode,symbolTable:new Sr});const n=qe(e);if(n.isOk()){const i=n.unwrap(),a=i.pop(),u=Wa(i,this.publicSymbolTable,this.symbolFactory),l=kl(a);if(u.has(l))return[new v(N.DUPLICATE_NAME,`TableGroup name '${a}' already exists`,e)];u.set(l,this.declarationNode.symbol)}return[]}validateSettingList(e){const n=ke(e),i=n.getErrors(),a=n.getValue();return es(a,(u,l)=>{switch(l){case"color":u.length>1&&i.push(...u.map(f=>new v(N.DUPLICATE_TABLE_SETTING,"'color' can only appear once",f))),u.forEach(f=>{Ha(f.value)||i.push(new v(N.INVALID_TABLE_SETTING_VALUE,"'color' must be a color literal",f.value||f.name))});break;case"note":u.length>1&&i.push(...u.map(f=>new v(N.DUPLICATE_TABLE_SETTING,"'note' can only appear once",f))),u.filter(f=>!Ke(f.value)).forEach(f=>{i.push(new v(N.INVALID_TABLE_SETTING_VALUE,"'note' must be a string literal",f.value||f.name))});break;default:i.push(...u.map(f=>new v(N.UNKNOWN_TABLE_SETTING,`Unknown '${l}' setting`,f)));break}}),i}validateBody(e){if(!e)return[];if(e instanceof z)return[new v(N.UNEXPECTED_SIMPLE_BODY,"A TableGroup's body must be a block",e)];const[n,i]=ht(e.body,a=>a instanceof z);return[...this.validateFields(n),...this.validateSubElements(i)]}validateFields(e){return e.flatMap(n=>{const i=[];return n.callee&&!qe(n.callee).isOk()&&i.push(new v(N.INVALID_TABLEGROUP_FIELD,"A TableGroup field must be of the form <table> or <schema>.<table>",n.callee)),this.registerField(n),n.args.length>0&&i.push(...n.args.map(a=>new v(N.INVALID_TABLEGROUP_FIELD,"A TableGroup field should only have a single Table name",a))),i})}validateSubElements(e){const n=e.flatMap(a=>{if(a.parent=this.declarationNode,!a.type)return[];const u=cn(a);return new u(a,this.publicSymbolTable,this.symbolFactory).validate()}),i=e.filter(a=>a.type?.value.toLowerCase()==="note");return i.length>1&&n.push(...i.map(a=>new v(N.NOTE_REDEFINED,"Duplicate notes are defined",a))),n}registerField(e){if(e.callee&&De(e.callee)){const n=ze(e.callee).unwrap(),i=Ml(n),a=this.symbolFactory.create(qp,{declaration:e});e.symbol=a;const u=this.declarationNode.symbol.symbolTable;if(u.has(i)){const l=u.get(i);return[new v(N.DUPLICATE_TABLEGROUP_FIELD_NAME,`${n} already exists in the group`,e),new v(N.DUPLICATE_TABLEGROUP_FIELD_NAME,`${n} already exists in the group`,l.declaration)]}u.set(i,a)}return[]}}class XL{constructor(e,n,i){this.declarationNode=e,this.symbolFactory=i,this.publicSymbolTable=n}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.registerElement(),...this.validateBody(this.declarationNode.body)]}validateContext(){return this.declarationNode.parent instanceof re?[new v(N.INVALID_TABLE_PARTIAL_CONTEXT,"TablePartial must appear top-level",this.declarationNode)]:[]}validateName(e){return e?gi(e)?[]:[new v(N.INVALID_NAME,"A TablePartial name must be an identifier or a quoted identifer",e)]:[new v(N.NAME_NOT_FOUND,"A TablePartial must have a name",this.declarationNode)]}validateAlias(e){return e?[new v(N.UNEXPECTED_ALIAS,"A TablePartial shouldn't have an alias",e)]:[]}validateSettingList(e){const n=ke(e),i=n.getErrors(),a=n.getValue();return es(a,(u,l)=>{switch(l){case k.HeaderColor:u.length>1&&i.push(...u.map(f=>new v(N.DUPLICATE_TABLE_PARTIAL_SETTING,`'${l}' can only appear once`,f))),u.forEach(f=>{Ha(f.value)||i.push(new v(N.INVALID_TABLE_PARTIAL_SETTING_VALUE,`'${l}' must be a color literal`,f.value||f.name))});break;case k.Note:u.length>1&&i.push(...u.map(f=>new v(N.DUPLICATE_TABLE_PARTIAL_SETTING,`'${l}' can only appear once`,f))),u.forEach(f=>{Ke(f.value)||i.push(new v(N.INVALID_TABLE_PARTIAL_SETTING_VALUE,`'${l}' must be a string literal`,f.value||f.name))});break;default:i.push(...u.map(f=>new v(N.UNKNOWN_TABLE_PARTIAL_SETTING,`Unknown '${l}' setting`,f)))}}),i}registerElement(){const{name:e}=this.declarationNode;this.declarationNode.symbol=this.symbolFactory.create(Xp,{declaration:this.declarationNode,symbolTable:new Sr});const n=qe(e);if(!n.isOk())return[];const i=n.unwrap(),a=i.pop(),u=Wa(i,this.publicSymbolTable,this.symbolFactory),l=Pl(a);return u.has(l)?[new v(N.DUPLICATE_NAME,`TablePartial name '${a}' already exists`,e)]:(u.set(l,this.declarationNode.symbol),[])}validateBody(e){if(!e)return[];if(e instanceof z)return[new v(N.UNEXPECTED_SIMPLE_BODY,"A TablePartial's body must be a block",e)];const[n,i]=ht(e.body,a=>a instanceof z);return[...this.validateFields(n),...this.validateSubElements(i)]}validateFields(e){return e.flatMap(n=>{if(!n.callee)return[];const i=[];n.args.length===0&&i.push(new v(N.INVALID_COLUMN,"A column must have a type",n.callee)),De(n.callee)||i.push(new v(N.INVALID_COLUMN_NAME,"A column name must be an identifier or a quoted identifier",n.callee)),n.args[0]&&!em(n.args[0])&&i.push(new v(N.INVALID_COLUMN_TYPE,"Invalid column type",n.args[0]));const a=n.args.slice(1);return i.push(...this.validateFieldSetting(a),...this.registerField(n)),i})}registerField(e){if(!e.callee||!De(e.callee))return[];const n=ze(e.callee).unwrap(),i=Un(n),a=this.symbolFactory.create(di,{declaration:e});e.symbol=a;const u=this.declarationNode.symbol.symbolTable;if(u.has(i)){const l=u.get(i);return[new v(N.DUPLICATE_COLUMN_NAME,`Duplicate column ${n}`,e),new v(N.DUPLICATE_COLUMN_NAME,`Duplicate column ${n}`,l.declaration)]}return u.set(i,a),[]}validateFieldSetting(e){const n=Oe(e);if(!e.slice(0,-1).every(yn)||!(yn(n)||n instanceof Le))return[...e.map(m=>new v(N.INVALID_COLUMN,"These fields must be some inline settings optionally ended with a setting list",m))];if(e.length===0)return[];let i;Oe(e)instanceof Le&&(i=e.pop());const a=ke(i),u=a.getErrors(),l=a.getValue();e.forEach(m=>{const E=ze(m).unwrap_or("").toLowerCase();if(E!==k.PK&&E!==k.Unique){u.push(new v(N.INVALID_SETTINGS,"Inline column settings can only be `pk` or `unique`",m));return}l[E]===void 0?l[E]=[m]:l[E].push(m)});const f=l[k.PK]||[],h=l[k.PrimaryKey]||[];return f.length>=1&&h.length>=1&&u.push(...[...f,...h].map(m=>new v(N.DUPLICATE_COLUMN_SETTING,"Either one of 'primary key' and 'pk' can appear",m))),es(l,(m,E)=>{switch(E){case k.Note:m.length>1&&u.push(...m.map(T=>new v(N.DUPLICATE_COLUMN_SETTING,`'${E}' can only appear once`,T))),m.forEach(T=>{Ke(T.value)||u.push(new v(N.INVALID_COLUMN_SETTING_VALUE,`'${E}' must be a quoted string`,T.value||T.name))});break;case k.Ref:m.forEach(T=>{Qp(T.value)||u.push(new v(N.INVALID_COLUMN_SETTING_VALUE,`'${E}' must be a valid unary relationship`,T.value||T.name))});break;case k.PrimaryKey:m.length>1&&u.push(...m.map(T=>new v(N.DUPLICATE_COLUMN_SETTING,`'${E}' can only appear once`,T))),m.forEach(T=>{Lt(T.value)||u.push(new v(N.INVALID_COLUMN_SETTING_VALUE,`'${E}' must not have a value`,T.value||T.name))});break;case k.PK:m.length>1&&u.push(...m.map(T=>new v(N.DUPLICATE_COLUMN_SETTING,`'${E}' can only appear once`,T))),m.forEach(T=>{T instanceof sn&&!Lt(T.value)&&u.push(new v(N.INVALID_COLUMN_SETTING_VALUE,`'${E}' must not have a value`,T.value||T.name))});break;case k.NotNull:{m.length>1&&u.push(...m.map(A=>new v(N.DUPLICATE_COLUMN_SETTING,`'${E}' can only appear once`,A)));const T=l[k.Null]||[];m.length>=1&&T.length>=1&&u.push(...[...m,...T].map(A=>new v(N.CONFLICTING_SETTING,"'not null' and 'null' can not be set at the same time",A))),m.forEach(A=>{Lt(A.value)||u.push(new v(N.INVALID_COLUMN_SETTING_VALUE,`'${E}' must not have a value`,A.value||A.name))});break}case k.Null:m.length>1&&u.push(...m.map(T=>new v(N.DUPLICATE_COLUMN_SETTING,`'${E}' can only appear once`,T))),m.forEach(T=>{Lt(T.value)||u.push(new v(N.INVALID_COLUMN_SETTING_VALUE,`'${E}' must not have a value`,T.value||T.name))});break;case k.Unique:m.length>1&&u.push(...m.map(T=>new v(N.DUPLICATE_COLUMN_SETTING,`'${E}' can only appear once`,T))),m.forEach(T=>{T instanceof sn&&!Lt(T.value)&&u.push(new v(N.INVALID_COLUMN_SETTING_VALUE,`'${E}' must not have a value`,T.value||T.name))});break;case k.Increment:m.length>1&&u.push(...m.map(T=>new v(N.DUPLICATE_COLUMN_SETTING,`'${E}' can only appear once`,T))),m.forEach(T=>{T instanceof sn&&!Lt(T.value)&&u.push(new v(N.INVALID_COLUMN_SETTING_VALUE,`'${E}' must not have a value`,T.value||T.name))});break;case k.Default:m.length>1&&u.push(...m.map(T=>new v(N.DUPLICATE_COLUMN_SETTING,`'${E}' can only appear once`,T))),m.forEach(T=>{jp(T.value)||u.push(new v(N.INVALID_COLUMN_SETTING_VALUE,`'${E}' must be a string literal, number literal, function expression, true, false or null`,T.value||T.name))});break;case k.Check:m.forEach(T=>{T.value instanceof st||u.push(new v(N.INVALID_COLUMN_SETTING_VALUE,"'check' must be a function expression",T.value||T.name))});break;default:m.forEach(T=>u.push(new v(N.UNKNOWN_COLUMN_SETTING,`Unknown column setting '${E}'`,T)))}}),u}validateSubElements(e){const n=e.flatMap(a=>{if(a.parent=this.declarationNode,!a.type)return[];const u=cn(a);return new u(a,this.publicSymbolTable,this.symbolFactory).validate()}),i=e.filter(a=>a.type?.value.toLowerCase()===U.Note);return i.length>1&&n.push(...i.map(a=>new v(N.NOTE_REDEFINED,"Duplicate notes are defined",a))),n}}class YL{constructor(e,n,i){this.declarationNode=e,this.publicSymbolTable=n,this.symbolFactory=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){const e=new v(N.INVALID_CHECKS_CONTEXT,"A Checks can only appear inside a Table or a TablePartial",this.declarationNode);if(this.declarationNode.parent instanceof Ze)return[e];const n=dt(this.declarationNode.parent).unwrap_or(void 0);return n&&[U.Table,U.TablePartial].includes(n)?[]:[e]}validateName(e){return e?[new v(N.UNEXPECTED_NAME,"A Checks shouldn't have a name",e)]:[]}validateAlias(e){return e?[new v(N.UNEXPECTED_ALIAS,"A Checks shouldn't have an alias",e)]:[]}validateSettingList(e){return e?[new v(N.UNEXPECTED_SETTINGS,"A Checks shouldn't have a setting list",e)]:[]}validateBody(e){if(!e)return[];if(e instanceof z)return[new v(N.UNEXPECTED_SIMPLE_BODY,"A Checks must have a complex body",e)];const[n,i]=ht(e.body,a=>a instanceof z);return[...this.validateFields(n),...this.validateSubElements(i)]}validateFields(e){return e.flatMap(n=>{if(!n.callee)return[];const i=[],a=[n.callee,...n.args];return Oe(a)instanceof Le&&i.push(...this.validateFieldSetting(a.pop())),(a.length>1||!(a[0]instanceof st))&&i.push(new v(N.INVALID_CHECKS_FIELD,"A check field must be a function expression",n)),i})}validateFieldSetting(e){const n=ke(e),i=n.getErrors(),a=n.getValue();for(const u in a){const l=a[u];switch(u){case"name":l.length>1&&l.forEach(f=>i.push(new v(N.DUPLICATE_CHECK_SETTING,`'${u}' can only appear once`,f))),l.forEach(f=>{Ke(f.value)||i.push(new v(N.INVALID_CHECK_SETTING_VALUE,`'${u}' must be a string`,f))});break;default:l.forEach(f=>i.push(new v(N.UNKNOWN_CHECK_SETTING,`Unknown check setting '${u}'`,f)))}}return i}validateSubElements(e){return e.flatMap(n=>{if(n.parent=this.declarationNode,!n.type)return[];const i=cn(n);return new i(n,this.publicSymbolTable,this.symbolFactory).validate()})}}class ZL{constructor(e,n,i){this.declarationNode=e,this.publicSymbolTable=n,this.symbolFactory=i}validate(){return[...this.validateContext(),...this.validateName(this.declarationNode.name),...this.validateAlias(this.declarationNode.alias),...this.validateSettingList(this.declarationNode.attributeList),...this.validateBody(this.declarationNode.body)]}validateContext(){const e=this.declarationNode.parent;return e instanceof Ze?[]:e instanceof re&&dt(e).unwrap_or(void 0)===U.Table?[]:[new v(N.INVALID_RECORDS_CONTEXT,"Records can only appear at top-level or inside a Table",this.declarationNode)]}validateName(e){return this.declarationNode.parent instanceof Ze?this.validateTopLevelName(e):this.validateInsideTableName(e)}validateTopLevelName(e){if(!(e instanceof Se))return[new v(N.INVALID_RECORDS_NAME,"Records at top-level must have a name in the form of table(col1, col2, ...) or schema.table(col1, col2, ...)",e||this.declarationNode.type)];const n=[];return(!e.callee||!Fl(e.callee))&&n.push(new v(N.INVALID_RECORDS_NAME,"Records table reference must be a valid table name",e.callee||e)),(!e.argumentList||!ns(e.argumentList))&&n.push(new v(N.INVALID_RECORDS_NAME,"Records column list must be simple column names",e.argumentList||e)),n}validateInsideTableName(e){return e&&!ns(e)?[new v(N.INVALID_RECORDS_NAME,"Records inside a Table can only have a column list like (col1, col2, ...)",e)]:[]}validateAlias(e){return e?[new v(N.UNEXPECTED_ALIAS,"Records cannot have an alias",e)]:[]}validateSettingList(e){return e?[new v(N.UNEXPECTED_SETTINGS,"Records cannot have a setting list",e)]:[]}validateBody(e){if(!e)return[];if(e instanceof z)return this.validateDataRow(e);const[n,i]=ht(e.body,a=>a instanceof z);return[...this.validateDataRows(n),...this.validateSubElements(i)]}validateDataRows(e){return e.flatMap(n=>this.validateDataRow(n))}validateDataRow(e){const n=[];if(!e.callee||e.args.length>0)return n.push(new v(N.INVALID_RECORDS_FIELD,"Invalid record row structure",e)),n;if(e.callee instanceof Fn)for(const i of e.callee.elementList)this.isValidRecordValue(i)||n.push(new v(N.INVALID_RECORDS_FIELD,"Records can only contain simple values (literals, null, true, false, or enum references). Complex expressions are not allowed.",i));else this.isValidRecordValue(e.callee)||n.push(new v(N.INVALID_RECORDS_FIELD,"Records can only contain simple values (literals, null, true, false, or enum references). Complex expressions are not allowed.",e.callee));return n}isValidRecordValue(e){if(e instanceof gn||St(e)||Ke(e)||e instanceof st)return!0;if(De(e)){const n=e.expression.variable.value.toLowerCase();return Zp.includes(n)}if(za(e)){const n=qe(e).unwrap_or(void 0);return n!==void 0&&n.length>0}return!1}validateSubElements(e){return e.flatMap(n=>{if(n.parent=this.declarationNode,!n.type)return[];const i=cn(n);return new i(n,this.publicSymbolTable,this.symbolFactory).validate()})}}function cn(t){switch(t.type.value.toLowerCase()){case U.Enum:return UL;case U.Table:return HL;case U.TableGroup:return qL;case U.Project:return $L;case U.Ref:return GL;case U.Note:return BL;case U.Indexes:return VL;case U.TablePartial:return XL;case U.Check:return YL;case U.Records:return ZL;default:return PL}}function Fl(t){return!!qe(t).unwrap_or(!1)}function KL(t){return gi(t)}function gi(t){return t instanceof yt&&t.expression instanceof Wn}function ts(t){return t instanceof ft&&t.op?.value==="~"&&De(t.expression)}function Wa(t,e,n){t[0]===Wt&&(t=t.slice(1));let i=e;for(const a of t){let u;const l=ls(a);if(i.has(l)){if(u=i.get(l)?.symbolTable,!u)throw new Error("Expect a symbol table in a schema symbol")}else{u=new Sr;const f=n.create(xl,{symbolTable:u});i.set(l,f)}i=u}return i}function Jp(t){return t==="-"||t==="<>"||t===">"||t==="<"}function Ha(t){if(!(t instanceof yt)||!(t.expression instanceof Rr)||t.expression.literal?.kind!==I.COLOR_LITERAL)return!1;const e=t.expression.literal.value;if(e.length!==4&&e.length!==7||e[0]!=="#")return!1;for(let n=1;n<e.length;n+=1)if(!ML(e[n]))return!1;return!0}function Lt(t){return t===void 0}function jp(t){if(Ke(t)||St(t)||yn(t)&&["true","false","null"].includes(t.expression.variable.value.toLowerCase())||t instanceof ft&&Kp.includes(t.op?.value)&&St(t.expression)||t instanceof st)return!0;if(!t||!Vl(t))return!1;const e=vn(t).unwrap();return e.length===2||e.length===3}function St(t){return t instanceof ft?Kp.includes(t.op.value)?St(t.expression):!1:t instanceof yt&&t.expression instanceof Rr&&t.expression.literal?.kind===I.NUMERIC_LITERAL}function Qp(t){if(!(t instanceof ft)||!Jp(t.op?.value))return!1;const e=qe(t.expression).unwrap_or(void 0);return e!==void 0&&e.length>0}function ns(t){return t instanceof ln&&t.elementList.every(De)}function em(t){if(!(t instanceof Se||za(t)||t instanceof yt||t instanceof Tn))return!1;for(;t instanceof Se||t instanceof Tn;)if(t instanceof Se){if(t.callee===void 0||t.argumentList===void 0||!t.argumentList.elementList.every(n=>St(n)||Ke(n)||yn(n)))return!1;t=t.callee}else if(t instanceof Tn){if(t.array===void 0||t.indexer===void 0||!t.indexer.elementList.every(n=>!n.colon&&!n.value&&St(n.name)))return!1;t=t.array}const e=qe(t).unwrap_or(void 0);return e!==void 0&&e.length>0}function ke(t){const e={},n=[];return t?(t.elementList.forEach(i=>{if(!i.name)return;if(i.name instanceof yt){n.push(new v(N.INVALID_SETTINGS,"A setting name must be a stream of identifiers",i.name));return}const a=rs(i.name).unwrap_or(void 0)?.toLowerCase();a&&(e[a]===void 0?e[a]=[i]:e[a].push(i))}),new ue(e,n)):new ue({})}function dt(t){const e=t?.type?.value.toLowerCase();switch(e){case U.Enum:case U.Table:case U.Indexes:case U.Note:case U.Project:case U.Ref:case U.TableGroup:case U.TablePartial:case U.Check:case U.Records:return new Be(e);default:return new Ne}}function vn(t){if(!t)return new Ne;if(!za(t))return new Be([t]);const e=vn(t.leftExpression).unwrap_or(void 0);return e?(e.push(t.rightExpression),new Be(e)):new Ne}function qe(t){if(t===void 0)return new Ne;const e=vn(t).unwrap_or(void 0);if(!e)return new Ne;const n=[];for(const i of e){const a=ve(i).unwrap_or(void 0);if(typeof a!="string")return new Ne;n.push(a)}return new Be(n)}function Ot(t){if(t===void 0)return new Ne;const e=vn(t).unwrap_or(void 0);if(!e||e.length===0)return new Ne;let n=[];if(!De(Oe(e))){const a=e.pop();if(ns(a))n=a.elementList;else return new Ne}const i=e;return i.every(De)?new Be({variables:i,tupleElements:n}):new Ne}function ve(t){return De(t)?new Be(t.expression.variable.value):new Ne}function ba(t){if(pd(t))return t instanceof st?new Be({functional:[t],nonFunctional:[]}):new Be({functional:[],nonFunctional:[t]});if(t instanceof ln&&t.elementList.every(pd)){const e=t.elementList.filter(i=>i instanceof st),n=t.elementList.filter(De);return new Be({functional:e,nonFunctional:n})}return new Ne}function ze(t){const e=t?.expression.variable?.value;return e===void 0?new Ne:new Be(e)}function Te(t){return Ke(t)?t.expression instanceof Wn?new Be(t.expression.variable.value):new Be(t.expression.literal.value):new Ne}function Or(t){return t instanceof yt&&t.expression instanceof Rr&&t.expression.literal?.kind===I.NUMERIC_LITERAL?Number(t.expression.literal.value):null}function Ul(t){if(t)return De(t)?t.referee:t instanceof on&&t.op?.value==="."?Ul(t.rightExpression):t.referee}function dd(t){return!(t instanceof on)||!Jp(t.op?.value)?!1:Ot(t.leftExpression).and_then(()=>Ot(t.rightExpression)).unwrap_or(void 0)!==void 0}function JL(t){const e=Ot(t.leftExpression),n=Ot(t.rightExpression);if(!e.isOk()||!n.isOk())return!1;const{tupleElements:i}=e.unwrap(),{tupleElements:a}=n.unwrap();return i?.length===a?.length}function pd(t){return t instanceof yt&&t.expression instanceof Wn||t instanceof st}function tm(t){if(!(t instanceof Se)||!t.callee)return new Ne;const e=vn(t.callee).unwrap_or(void 0);if(!e||e.length===0)return new Ne;if(!e.every(De))return new Ne;let n=[];return ns(t.argumentList)&&(n=[...t.argumentList.elementList]),new Be({variables:e,args:n})}function jL(t,e,n){let i=e,a=t;if(a instanceof Se&&a.argumentList&&(i=[a.argumentList,...i],a=a.callee),!a||!yn(a)||i.length===0)return new Ne;const u=[...i],l=md(a).unwrap(),f=u.pop();if(!(f instanceof Ge))return new Ne;const h=Oe(u)instanceof Le?u.pop():void 0;if(u.length===3){const m=md(u[1]).value;return!m||!Zu(m)?new Ne:new Be(n.create(re,{type:l,name:u[0],as:m,alias:u[2],attributeList:h,body:f}))}return u.length===1?new Be(n.create(re,{type:l,name:u[0],attributeList:h,body:f})):u.length===0?new Be(n.create(re,{type:l,attributeList:h,body:f})):new Ne}function Zu(t){return t?.kind===I.IDENTIFIER&&t.value.toLowerCase()==="as"}function W(t){t&&(t instanceof Tt?QL(t):eS(t))}function QL(t){t.kind!==I.EOF&&(t.isInvalid=!0)}function eS(t){if(t instanceof re)W(t.type),W(t.name),W(t.as),W(t.alias),W(t.bodyColon),W(t.attributeList),W(t.body);else if(t instanceof rn)t.identifiers.forEach(W);else if(t instanceof sn)W(t.name),W(t.colon),W(t.value);else if(t instanceof ft)W(t.op),W(t.expression);else if(t instanceof on)W(t.leftExpression),W(t.op),W(t.rightExpression);else if(t instanceof Ga)W(t.op),W(t.expression);else if(t instanceof Ge)W(t.blockOpenBrace),t.body.forEach(W),W(t.blockCloseBrace);else if(t instanceof Le)W(t.listOpenBracket),t.commaList.forEach(W),t.elementList.forEach(W),W(t.listCloseBracket);else if(t instanceof ln)W(t.tupleOpenParen),t.commaList.forEach(W),t.elementList.forEach(W),W(t.tupleCloseParen);else if(t instanceof Fn)t.commaList.forEach(W),t.elementList.forEach(W);else if(t instanceof Se)W(t.callee),W(t.argumentList);else if(t instanceof z)W(t.callee),t.args.forEach(W);else if(t instanceof yt)W(t.expression);else if(t instanceof st)W(t.value);else if(t instanceof Wn)W(t.variable);else if(t instanceof Rr)W(t.literal);else{if(t instanceof Sl)throw new Error("This case is handled by the TupleExpressionNode case");if(t instanceof Tn)W(t.array),W(t.indexer);else if(t instanceof Ze)t.body.forEach(W),W(t.eof);else if(!(t instanceof gn))throw new Error("Unreachable case in markInvalidNode")}}function Ku(t){return!!t?.isInvalid}function nt(...t){return t.filter(e=>e!==void 0)}function tS(t){if(t instanceof Ze)return nt(...t.body,t.eof);if(t instanceof re)return nt(t.type,t.name,t.as,t.alias,t.attributeList,t.bodyColon,t.body);if(t instanceof sn)return nt(t.name,t.colon,t.value);if(t instanceof rn)return t.identifiers;if(t instanceof Rr)return t.literal?[t.literal]:[];if(t instanceof Wn)return nt(t.variable);if(t instanceof ft)return nt(t.op,t.expression);if(t instanceof on)return nt(t.leftExpression,t.op,t.rightExpression);if(t instanceof Ga)return nt(t.expression,t.op);if(t instanceof st)return nt(t.value);if(t instanceof z)return nt(t.callee,...t.args);if(t instanceof Ge)return nt(t.blockOpenBrace,...t.body,t.blockCloseBrace);if(t instanceof Le)return nt(t.listOpenBracket,...Du(t.elementList,t.commaList),t.listCloseBracket);if(t instanceof ln)return nt(t.tupleOpenParen,...Du(t.elementList,t.commaList),t.tupleCloseParen);if(t instanceof Fn)return nt(...Du(t.elementList,t.commaList));if(t instanceof Se)return nt(t.callee,t.argumentList);if(t instanceof yt)return nt(t.expression);if(t instanceof Tn)return nt(t.array,t.indexer);throw t instanceof Sl?new Error("This case is already handled by TupleExpressionNode"):new Error("Unreachable - no other possible cases")}function md(t){return De(t)?new Be(t.expression.variable):new Ne}function Ke(t){return t instanceof yt&&(t.expression instanceof Wn&&t.expression.variable instanceof Tt&&t.expression.variable.kind===I.QUOTED_STRING||t.expression instanceof Rr&&t.expression.literal?.kind===I.STRING_LITERAL)}function De(t){return t instanceof yt&&t.expression instanceof Wn&&t.expression.variable instanceof Tt}function yn(t){return t instanceof yt&&t.expression instanceof Wn&&t.expression.variable?.kind===I.IDENTIFIER}function za(t){return t instanceof on&&t.leftExpression instanceof xe&&t.rightExpression instanceof xe&&t.op?.value==="."}function Vl(t){return De(t)?!0:za(t)&&De(t.rightExpression)&&Vl(t.leftExpression)}function rs(t){if(t===void 0)return new Ne;const e=t.identifiers.map(n=>n.value).join(" ");return e===""?new Ne:new Be(e)}function Ju(t){return qe(t?.name).map(e=>e.join("."))}class nS{constructor(e){this.start={offset:0,line:0,column:0},this.current={offset:0,line:0,column:0},this.tokens=[],this.errors=[],this.text=e}isAtEnd(){return this.current.offset>=this.text.length}advance(){const e=this.peek();return this.current={...this.current},e===`
|
|
2
|
+
`?(this.current.line+=1,this.current.column=0):this.current.column+=1,this.current.offset+=1,e}peek(e=0){if(!(this.current.offset+e>=this.text.length))return this.text[this.current.offset+e]}check(e){for(let n=0;n<e.length;n+=1)if(e[n]!==this.peek(n))return!1;return!0}match(e){return this.check(e)?(e.split("").forEach(()=>this.advance()),!0):!1}addToken(e,n=!1){this.tokens.push(this.createToken(e,n))}createToken(e,n=!1){return Tt.create(e,this.start,this.current,this.text.substring(this.start.offset,this.current.offset),n)}lex(){return this.scanTokens(),this.tokens.push(Tt.create(I.EOF,this.start,this.current,"",!1)),this.gatherTrivia(),this.gatherInvalid(),new ue(this.tokens,this.errors)}scanTokens(){for(;!this.isAtEnd();){const e=this.advance();switch(e){case" ":this.addToken(I.SPACE);break;case"\r":break;case`
|
|
3
|
+
`:this.addToken(I.NEWLINE);break;case" ":this.addToken(I.TAB);break;case",":this.addToken(I.COMMA);break;case"(":this.addToken(I.LPAREN);break;case")":this.addToken(I.RPAREN);break;case"[":this.addToken(I.LBRACKET);break;case"]":this.addToken(I.RBRACKET);break;case"{":this.addToken(I.LBRACE);break;case"}":this.addToken(I.RBRACE);break;case";":this.addToken(I.SEMICOLON);break;case":":this.addToken(I.COLON);break;case"'":this.match("''")?this.multilineStringLiteral():this.singleLineStringLiteral();break;case'"':this.quotedVariable();break;case"`":this.functionExpression();break;case"#":this.colorLiteral();break;case"/":this.match("/")?this.singleLineComment():this.match("*")?this.multilineComment():this.operator(e);break;default:if(xL(e)){this.operator(e);break}if(us(e)){this.identifier();break}if(En(e)){this.numericLiteralOrIdentifier();break}this.addToken(I.OP,!0),this.errors.push(new v(N.UNKNOWN_SYMBOL,`Unexpected token '${e}'`,this.createToken(I.OP,!0)));break}this.start={...this.current}}}gatherTrivia(){let e=!0,n=[],i;const a=[];for(const u of this.tokens)OL(u)?(n.push(u),u.kind===I.NEWLINE&&i&&(i.trailingTrivia=n,e=!0,i=void 0,n=[])):(e?u.leadingTrivia=n:i.trailingTrivia=n,a.push(u),n=[],i=u,e=!1);this.tokens=a}gatherInvalid(){let e;const n=[],i=[];for(e=0;e<this.tokens.length&&Ku(this.tokens[e]);e+=1)i.push(this.tokens[e]);let a=this.tokens[e];for(a.leadingInvalid=[...i,...a.leadingInvalid];e<this.tokens.length;e+=1){const u=this.tokens[e];Ku(u)?a.trailingInvalid.push(u):(a=u,n.push(u))}this.tokens=n}consumeUntil(e,n,{allowNewline:i,allowEof:a,raw:u,consumeStopSequence:l=!0}){let f="";for(;!this.isAtEnd()&&(i||!this.check(`
|
|
4
|
+
`))&&!this.check(n);)this.peek()==="\\"&&!u?(this.advance(),f+=this.escapedString()):f+=this.advance();if(this.isAtEnd()&&!a){const h=this.createToken(e,!0);this.tokens.push(h),this.errors.push(new v(N.UNEXPECTED_EOF,"EOF reached while parsing",h));return}if(this.check(`
|
|
5
|
+
`)&&!i){const h=this.createToken(e,!0);this.tokens.push(h),this.errors.push(new v(N.UNEXPECTED_NEWLINE,"Invalid newline encountered while parsing",h));return}l&&this.match(n),this.tokens.push(Tt.create(e,this.start,this.current,f,!1))}singleLineStringLiteral(){this.consumeUntil(I.STRING_LITERAL,"'",{allowNewline:!1,allowEof:!1,raw:!1})}multilineStringLiteral(){this.consumeUntil(I.STRING_LITERAL,"'''",{allowNewline:!0,allowEof:!1,raw:!1})}functionExpression(){this.consumeUntil(I.FUNCTION_EXPRESSION,"`",{allowNewline:!0,allowEof:!1,raw:!0})}quotedVariable(){this.consumeUntil(I.QUOTED_STRING,'"',{allowNewline:!1,allowEof:!1,raw:!1})}singleLineComment(){this.consumeUntil(I.SINGLE_LINE_COMMENT,`
|
|
6
|
+
`,{allowNewline:!0,allowEof:!0,raw:!0,consumeStopSequence:!1})}multilineComment(){this.consumeUntil(I.MULTILINE_COMMENT,"*/",{allowNewline:!0,allowEof:!1,raw:!0})}identifier(){for(;!this.isAtEnd()&&yr(this.peek());)this.advance();this.addToken(I.IDENTIFIER)}operator(e){switch(e){case"<":[">","="].includes(this.peek())&&this.advance();break;case">":this.peek()==="="&&this.advance();break;case"=":this.peek()==="="&&this.advance();break;case"!":this.peek()==="="&&this.advance();break}this.addToken(I.OP)}numericLiteralOrIdentifier(){let e=0;if(this.isAtEnd())return this.addToken(I.NUMERIC_LITERAL);for(;!this.isAtEnd();){const n=this.check(".");if(e+=n?1:0,e>1)break;if(this.check("e")||this.check("E")){const i=this.peek(1),a=i==="+"||i==="-",u=a?this.peek(2):i;if(u&&En(u)){for(this.advance(),a&&this.advance();!this.isAtEnd()&&En(this.peek());)this.advance();if(this.isAtEnd()||!yr(this.peek()))return this.addToken(I.NUMERIC_LITERAL);break}break}if(!n&&this.current.offset===this.text.length-1)return this.advance(),this.addToken(I.NUMERIC_LITERAL);if(!n&&!yr(this.peek()))return this.addToken(I.NUMERIC_LITERAL);if(!n&&!En(this.peek()))break;this.advance()}if(e>0){for(;!this.isAtEnd()&&(this.check(".")||yr(this.peek()));)this.advance();const n=this.createToken(I.NUMERIC_LITERAL,!0);this.tokens.push(n),this.errors.push(new v(N.UNKNOWN_TOKEN,"Invalid number",n))}else{for(;!this.isAtEnd()&&yr(this.peek());)this.advance();const n=this.createToken(I.IDENTIFIER,!1);this.tokens.push(n)}}colorLiteral(){for(;!this.isAtEnd()&&yr(this.peek());)this.advance();this.addToken(I.COLOR_LITERAL)}escapedString(){const e={column:this.current.column-1,offset:this.current.offset-1,line:this.current.line};if(this.isAtEnd())return"\\";switch(this.advance()){case"\r":return this.check(`
|
|
7
7
|
`)&&this.advance(),"";case`
|
|
8
8
|
`:return"";case"t":return" ";case"n":return`
|
|
9
|
-
`;case"\\":return"\\";case"r":return"\r";case"'":return"'";case'"':return'"';case"`":return"`";case"0":return"\0";case"b":return"\b";case"v":return"\v";case"f":return"\f";case" ":return"\\ ";case"u":{let i="";for(let s=0;s<=3;s+=1){if(this.isAtEnd()||!Un(this.peek()))return this.errors.push(new g(_.INVALID_ESCAPE_SEQUENCE,`Invalid unicode escape sequence '\\u${i}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`,Ze.create(A.STRING_LITERAL,r,this.current,`\\u${i}`,!0))),`\\u${i}`;i+=this.advance()}return String.fromCharCode(parseInt(i,16))}default:return this.text[this.current.offset-1]}}}var Ki=(t=>(t[t.ListExpression=0]="ListExpression",t[t.GroupExpression=1]="GroupExpression",t[t.BlockExpression=2]="BlockExpression",t))(Ki||{});class oA{constructor(){this.stack=[],this.numberOfNestedLParens=0,this.numberOfNestedLBrackets=0,this.numberOfNestedLBraces=0}push(r){this.stack.push(r),r===0&&(this.numberOfNestedLBrackets+=1),r===1&&(this.numberOfNestedLParens+=1),r===2&&(this.numberOfNestedLBraces+=1)}pop(){const r=this.stack.pop();return r===0&&(this.numberOfNestedLBrackets-=1),r===1&&(this.numberOfNestedLParens-=1),r===2&&(this.numberOfNestedLBraces-=1),r}top(){return me(this.stack)}isWithinGroupExpressionContext(){return this.numberOfNestedLParens>0}isWithinListExpressionContext(){return this.numberOfNestedLBrackets>0}isWithinBlockExpressionContext(){return this.numberOfNestedLBraces>0}withContextDo(r,i){return()=>{this.push(r);try{return i()}finally{this.pop()}}}findHandlerContext(r,i){if(!(this.numberOfNestedLBraces<=0&&this.numberOfNestedLBrackets<=0&&this.numberOfNestedLParens<=0))for(let s=i;s<r.length-1;s+=1)switch(r[s].kind){case A.COMMA:if(this.isWithinGroupExpressionContext()||this.isWithinListExpressionContext())return[...this.stack].reverse().find(l=>[1,0].includes(l));break;case A.RPAREN:if(this.isWithinGroupExpressionContext())return 1;break;case A.RBRACE:if(this.isWithinBlockExpressionContext())return 2;break;case A.RBRACKET:if(this.isWithinListExpressionContext())return 0;break}}}class uA{constructor(r){this.generator=r}create(r,i){return new r(i,this.generator.nextId())}}class M{constructor(r,i,s){this.token=r,this.partialNode=i,this.handlerContext=s}}class lA{constructor(r,i){this.current=0,this.errors=[],this.contextStack=new oA,this.synchronizeProgram=()=>{const s=this.peek();s.kind!==A.EOF?C(this.advance()):this.logError(s,_.UNEXPECTED_EOF,"Unexpected EOF")},this.synchronizeElementDeclarationName=()=>{for(;!this.isAtEnd();){const s=this.peek();if(Ha(s)||this.check(A.COLON,A.LBRACE,A.LBRACKET))break;C(s),this.advance()}},this.synchronizeElementDeclarationAlias=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.COLON,A.LBRACE,A.LBRACKET))break;C(s),this.advance()}},this.blockExpression=this.contextStack.withContextDo(Ki.BlockExpression,()=>{const s={body:[]},o=()=>this.nodeFactory.create(ke,s);try{this.consume("Expect an opening brace '{'",A.LBRACE),s.blockOpenBrace=this.previous()}catch(l){if(!(l instanceof M))throw l;if(!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeBlock()}for(;!this.isAtEnd()&&!this.check(A.RBRACE);)try{s.body.push(this.canBeField()?this.fieldDeclaration():this.expression())}catch(l){if(!(l instanceof M))throw l;if(s.body.push(l.partialNode),!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeBlock()}try{this.consume("Expect a closing brace '}'",A.RBRACE),s.blockCloseBrace=this.previous()}catch(l){if(!(l instanceof M))throw l;if(!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeBlock()}return o()}),this.synchronizeBlock=()=>{if(!this.check(A.RBRACE))for(C(this.advance());!this.isAtEnd();){const s=this.peek();if(this.check(A.RBRACE)||vc(this.previous(),s))break;C(s),this.advance()}},this.tupleExpression=this.contextStack.withContextDo(Ki.GroupExpression,()=>{const s={elementList:[],commaList:[]},o=()=>this.nodeFactory.create(ja,{groupOpenParen:s.tupleOpenParen,groupCloseParen:s.tupleCloseParen,expression:s.elementList[0]}),l=()=>this.nodeFactory.create(Wt,s);try{this.consume("Expect an opening parenthesis '('",A.LPAREN),s.tupleOpenParen=this.previous()}catch(f){if(!(f instanceof M))throw f;if(!this.canHandle(f))throw new M(f.token,l(),f.handlerContext);this.synchronizeTuple()}if(!this.isAtEnd()&&!this.check(A.RPAREN))try{s.elementList.push(this.normalExpression())}catch(f){if(!(f instanceof M))throw f;if(s.elementList.push(f.partialNode),!this.canHandle(f))throw new M(f.token,o(),f.handlerContext);this.synchronizeTuple()}for(;!this.isAtEnd()&&!this.check(A.RPAREN);)try{this.consume("Expect a comma ','",A.COMMA),s.commaList.push(this.previous()),s.elementList.push(this.normalExpression())}catch(f){if(!(f instanceof M))throw f;if(f.partialNode instanceof Te&&s.elementList.push(f.partialNode),!this.canHandle(f))throw new M(f.token,l(),f.handlerContext);this.synchronizeTuple()}try{this.consume("Expect a closing parenthesis ')'",A.RPAREN),s.tupleCloseParen=this.previous()}catch(f){if(!(f instanceof M))throw f;if(!this.canHandle(f))throw new M(f.token,l(),f.handlerContext);this.synchronizeTuple()}return s.elementList.length===1?o():l()}),this.synchronizeTuple=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.RPAREN,A.COMMA))break;C(s),this.advance()}},this.listExpression=this.contextStack.withContextDo(Ki.ListExpression,()=>{const s={elementList:[],commaList:[]},o=()=>this.nodeFactory.create(_e,s);try{this.consume("Expect an opening bracket '['",A.LBRACKET),s.listOpenBracket=this.previous()}catch(l){if(!(l instanceof M))throw l;if(!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeList()}if(!this.isAtEnd()&&!this.check(A.RBRACKET))try{s.elementList.push(this.attribute())}catch(l){if(!(l instanceof M))throw l;if(s.elementList.push(l.partialNode),!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeList()}for(;!this.isAtEnd()&&!this.check(A.RBRACKET);)try{this.consume("Expect a comma ','",A.COMMA),s.commaList.push(this.previous()),s.elementList.push(this.attribute())}catch(l){if(!(l instanceof M))throw l;if(l.partialNode instanceof Te&&s.elementList.push(l.partialNode),!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeList()}try{this.consume("Expect a closing bracket ']'",A.RBRACKET),s.listCloseBracket=this.previous()}catch(l){if(!(l instanceof M))throw l;if(!this.canHandle(l))throw new M(l.token,o(),l.handlerContext);this.synchronizeList()}return o()}),this.synchronizeList=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.COMMA,A.RBRACKET))break;C(s),this.advance()}},this.synchronizeAttributeName=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.COMMA,A.RBRACKET,A.COLON))break;C(s),this.advance()}},this.synchronizeAttributeValue=()=>{for(;!this.isAtEnd();){const s=this.peek();if(this.check(A.COMMA,A.RBRACKET))break;C(s),this.advance()}},this.tokens=r,this.nodeFactory=new uA(i)}isAtEnd(){return this.current>=this.tokens.length||this.tokens[this.current].kind===A.EOF}advance(){return this.isAtEnd()?me(this.tokens):this.tokens[this.current++]}peek(r=0){return r+this.current>=this.tokens.length?me(this.tokens):this.tokens[this.current+r]}match(...r){const i=this.check(...r);return i&&this.advance(),i}check(...r){const i=this.peek();return r.includes(i.kind)}previous(){return this.tokens[this.current-1]}canHandle(r){return r.handlerContext===void 0||r.handlerContext===this.contextStack.top()}consume(r,...i){if(!this.match(...i))throw this.logError(this.peek(),_.UNEXPECTED_TOKEN,r),new M(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}discardUntil(r,...i){if(this.isAtEnd()||!this.check(...i)){for(C(this.peek()),this.logError(this.advance(),_.UNEXPECTED_TOKEN,r);!this.isAtEnd()&&!this.check(...i);)C(this.advance());return!this.isAtEnd()}return!0}gatherInvalid(){const r=[],i=[];let s,o=0;for(;o<this.tokens.length&&this.tokens[o].isInvalid;o+=1)i.push(this.tokens[o]);for(s=this.tokens[o],s.leadingInvalid=[...i,...s.leadingInvalid],r.push(s),o+=1;o<this.tokens.length;o+=1){const l=this.tokens[o];l.isInvalid?s.trailingInvalid.push(l):(s=l,r.push(s))}this.tokens=r}parse(){const r=this.program(),i=this.advance(),s=this.nodeFactory.create(qe,{body:r,eof:i});return this.gatherInvalid(),new ct({ast:s,tokens:this.tokens},this.errors)}program(){const r=[];for(;!this.isAtEnd();)try{const i=this.elementDeclaration();r.push(i)}catch(i){if(!(i instanceof M))throw i;r.push(i.partialNode),this.synchronizeProgram()}return r}elementDeclaration(){const r={},i=()=>this.nodeFactory.create(se,r);try{this.consume("Expect an identifier",A.IDENTIFIER),r.type=this.previous()}catch(s){throw s instanceof M?new M(s.token,i(),s.handlerContext):s}if(!this.check(A.COLON,A.LBRACE,A.LBRACKET))try{r.name=this.normalExpression()}catch(s){if(!(s instanceof M))throw s;if(r.name=s.partialNode,!this.canHandle(s))throw new M(s.token,i(),s.handlerContext);this.synchronizeElementDeclarationName()}if(Ha(this.peek()))if(r.as=this.advance(),this.check(A.COLON,A.LBRACE,A.LBRACKET))this.logError(this.peek(),_.UNEXPECTED_TOKEN,"Expect an alias");else try{r.alias=this.normalExpression()}catch(s){if(!(s instanceof M))throw s;if(r.alias=s.partialNode,!this.canHandle(s))throw new M(s.token,i(),s.handlerContext);this.synchronizeElementDeclarationAlias()}try{r.attributeList=this.check(A.LBRACKET)?this.listExpression():void 0}catch(s){throw s instanceof M?(r.attributeList=s.partialNode,new M(s.token,i(),s.handlerContext)):s}if(!this.discardUntil("Expect an opening brace '{' or a colon ':'",A.LBRACE,A.COLON))return i();try{if(this.match(A.COLON)){r.bodyColon=this.previous();const s=this.expression();s instanceof se?(C(s),this.logError(s,_.UNEXPECTED_ELEMENT_DECLARATION,"An element's simple body must not be an element declaration")):r.body=s}else r.body=this.blockExpression()}catch(s){throw s instanceof M?(r.body=s.partialNode,new M(s.token,i(),s.handlerContext)):s}return this.nodeFactory.create(se,r)}fieldDeclaration(){const r={},i=()=>this.nodeFactory.create(se,r);try{this.consume("Expect an identifier",A.IDENTIFIER),r.type=this.previous()}catch(s){throw s instanceof M?(r.type=s.partialNode,new M(s.token,i(),s.handlerContext)):s}try{this.consume("Expect a colon ':'",A.COLON),r.bodyColon=this.previous()}catch(s){throw s instanceof M?(r.bodyColon=s.partialNode,new M(s.token,i(),s.handlerContext)):s}try{const s=this.expression();s instanceof se?this.errors.push(new g(_.INVALID_ELEMENT_IN_SIMPLE_BODY,"Simple body cannot be an element declaration",s)):r.body=s}catch(s){throw s instanceof M?(r.body=s.partialNode,new M(s.token,i(),s.handlerContext)):s}return this.nodeFactory.create(se,r)}expression(){const r={args:[]},i=()=>tA(r.callee,r.args,this.nodeFactory).unwrap_or(this.nodeFactory.create(W,r));try{r.callee=this.normalExpression()}catch(o){throw o instanceof M?(r.callee=o.partialNode,new M(o.token,i(),o.handlerContext)):o}if(this.shouldStopExpression())return i();let s=r.callee;for(;!this.shouldStopExpression();){$a(this.previous())||this.logError(s,_.MISSING_SPACES,"Expect a following space");try{s=this.normalExpression(),r.args.push(s)}catch(o){throw o instanceof M?(s=o.partialNode,r.args.push(s),new M(o.token,i(),o.handlerContext)):o}}return i()}shouldStopExpression(){if(this.isAtEnd()||uf(this.previous()))return!0;const r=this.peek().kind;return r===A.RBRACE||r===A.RBRACKET||r===A.RPAREN||r===A.COMMA||r===A.COLON}normalExpression(){return this.expression_bp(0)}expression_bp(r){let i=this.leftExpression_bp();for(;!this.isAtEnd();){const s=this.peek();if(s.kind===A.LPAREN){const{left:o}=wc(s);if(o<r||vc(this.previous(),s)&&!this.contextStack.isWithinGroupExpressionContext()&&!this.contextStack.isWithinListExpressionContext())break;try{i=this.nodeFactory.create(He,{callee:i,argumentList:this.tupleExpression()})}catch(l){throw l instanceof M?(i=this.nodeFactory.create(He,{callee:i,argumentList:l.partialNode}),new M(l.token,i,l.handlerContext)):l}}else if(s.kind===A.LBRACKET){if($a(this.previous()))break;try{i=this.nodeFactory.create(Bt,{expression:i,indexer:this.listExpression()})}catch(o){throw o instanceof M?(i=this.nodeFactory.create(Bt,{expression:i,indexer:o.partialNode}),new M(o.token,i,o.handlerContext)):o}}else if(Tc(s)){const o=s,l=wc(o);if(l.left!==null){if(l.left<=r)break;this.advance(),i=this.nodeFactory.create(os,{expression:i,op:o})}else{const f=fA(o);if(f.left===null||f.left<=r)break;this.advance();try{i=this.nodeFactory.create(Vt,{leftExpression:i,op:o,rightExpression:o.value==="."?this.extractOperand():this.expression_bp(f.right)})}catch(d){throw d instanceof M?(i=this.nodeFactory.create(Vt,{leftExpression:i,op:o,rightExpression:d.partialNode}),new M(d.token,i,d.handlerContext)):d}}}else break}return i}leftExpression_bp(){let r;if(Tc(this.peek())){const i={};i.op=this.peek();const s=pA(i.op);if(s.right===null)throw this.logError(i.op,_.UNKNOWN_PREFIX_OP,`Unexpected '${i.op.value}' in an expression`),new M(i.op,this.nodeFactory.create(Br,{pre:i.op}),this.contextStack.findHandlerContext(this.tokens,this.current));this.advance();try{i.expression=this.expression_bp(s.right)}catch(o){throw o instanceof M?(i.expression=o.partialNode,new M(o.token,this.nodeFactory.create(je,i),o.handlerContext)):o}r=this.nodeFactory.create(je,i)}else if(r=this.extractOperand(),r instanceof Br)throw new M(this.peek(),this.nodeFactory.create(Br,{pre:this.peek()}),this.contextStack.findHandlerContext(this.tokens,this.current));return r}extractOperand(){return this.check(A.NUMERIC_LITERAL,A.STRING_LITERAL,A.COLOR_LITERAL,A.QUOTED_STRING,A.IDENTIFIER)?this.primaryExpression():this.check(A.FUNCTION_EXPRESSION)?this.functionExpression():this.check(A.LBRACKET)?this.listExpression():this.check(A.LBRACE)?this.blockExpression():this.check(A.LPAREN)?this.tupleExpression():(this.peek().kind===A.EOF?this.logError(this.peek(),_.UNEXPECTED_EOF,"Unexpected EOF"):this.logError(this.peek(),_.INVALID_OPERAND,`Invalid start of operand "${this.peek().value}"`),this.nodeFactory.create(Br,{pre:this.previous()}))}functionExpression(){const r={};try{this.consume("Expect a function expression",A.FUNCTION_EXPRESSION),r.value=this.previous()}catch(i){throw i instanceof M?new M(i.token,this.nodeFactory.create(bt,r),i.handlerContext):i}return this.nodeFactory.create(bt,r)}canBeField(){return this.peek().kind===A.IDENTIFIER&&this.peek(1).kind===A.COLON}primaryExpression(){if(this.match(A.COLOR_LITERAL,A.STRING_LITERAL,A.NUMERIC_LITERAL))return this.nodeFactory.create(lt,{expression:this.nodeFactory.create(cr,{literal:this.previous()})});if(this.match(A.QUOTED_STRING,A.IDENTIFIER))return this.nodeFactory.create(lt,{expression:this.nodeFactory.create(ln,{variable:this.previous()})});throw this.logError(this.peek(),_.UNEXPECTED_TOKEN,"Expect a variable or literal"),new M(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}attribute(){const r={};if(this.check(A.COLON,A.RBRACKET,A.COMMA)){const i=this.peek();this.logError(i,_.EMPTY_ATTRIBUTE_NAME,"Expect a non-empty attribute name"),r.name=this.nodeFactory.create(xt,{identifiers:[]})}else try{r.name=this.attributeName()}catch(i){if(!(i instanceof M))throw i;if(r.name=i.partialNode,!this.canHandle(i))throw new M(i.token,this.nodeFactory.create(St,r),i.handlerContext);this.synchronizeAttributeName()}return this.match(A.COLON)&&(r.colon=this.previous(),r.value=this.attributeValue()),this.nodeFactory.create(St,r)}attributeValue(){let r;try{r=this.peek().kind===A.IDENTIFIER&&this.peek(1).kind===A.IDENTIFIER?this.attributeName():this.normalExpression()}catch(i){if(!(i instanceof M)||!this.canHandle(i))throw i;r=i.partialNode,this.synchronizeAttributeValue()}return r}attributeName(){const r=[];if(this.peek().kind!==A.IDENTIFIER)return this.primaryExpression();for(;!this.isAtEnd()&&!this.check(A.COLON,A.COMMA,A.RBRACKET);)try{this.consume("Expect an identifier",A.IDENTIFIER),r.push(this.previous())}catch(i){throw i instanceof M?new M(i.token,this.nodeFactory.create(xt,{identifiers:r}),i.handlerContext):i}return this.nodeFactory.create(xt,{identifiers:r})}logError(r,i,s){this.errors.push(new g(i,s,r))}}const cA={"+":{left:9,right:10},"*":{left:11,right:12},"-":{left:9,right:10},"/":{left:11,right:12},"%":{left:11,right:12},"<":{left:7,right:8},"<=":{left:7,right:8},">":{left:7,right:8},">=":{left:7,right:8},"<>":{left:7,right:8},"=":{left:2,right:3},"==":{left:4,right:5},"!=":{left:4,right:5},".":{left:16,right:17}};function fA(t){return cA[t.value]||{left:null,right:null}}const hA={"+":{left:null,right:15},"-":{left:null,right:15},"<":{left:null,right:15},">":{left:null,right:15},"<>":{left:null,right:15},"!":{left:null,right:15},"~":{left:null,right:15}};function pA(t){return hA[t.value]||{left:null,right:null}}const dA={"(":{left:14,right:null}};function wc(t){return dA[t.value]||{left:null,right:null}}class Lc{constructor(r,i){this.ast=r,this.symbolFactory=i,this.publicSchemaSymbol=this.symbolFactory.create(eo,{symbolTable:new Bn}),this.ast.symbol=this.publicSchemaSymbol,this.ast.symbol.declaration=this.ast}validate(){const r=[];this.ast.body.forEach(s=>{if(s.parent=this.ast,s.type===void 0)return;const o=Xt(s),l=new o(s,this.publicSchemaSymbol.symbolTable,this.symbolFactory);r.push(...l.validate())});const i=this.ast.body.filter(s=>cn(s).unwrap_or(void 0)===F.Project);return i.length>1&&i.forEach(s=>r.push(new g(_.PROJECT_REDEFINED,"Only one project can exist",s))),new ct(this.ast,r)}}class EA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return[]}}class _A{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.bindBody(this.declarationNode.body)}bindBody(r){if(!r)return[];if(r instanceof W)return[];const i=r.body.filter(s=>s instanceof se);return this.bindSubElements(i)}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class gA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return[];const i=r.body.filter(s=>s instanceof W);return this.bindSubElements(i)}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}var zi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Gr={exports:{}};var NA=Gr.exports,yc;function TA(){return yc||(yc=1,function(t,r){(function(){var i,s="4.17.21",o=200,l="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",f="Expected a function",d="Invalid `variable` option passed into `_.template`",m="__lodash_hash_undefined__",I=500,T="__lodash_placeholder__",y=1,$=2,J=4,ne=1,re=2,j=1,de=2,et=4,ht=8,Rt=16,ze=32,dr=64,qt=128,Er=256,fs=512,$f=30,Wf="...",Xf=800,Hf=16,po=1,qf=2,zf=3,wn=1/0,fn=9007199254740991,Kf=17976931348623157e292,jr=NaN,Dt=4294967295,Yf=Dt-1,Jf=Dt>>>1,Qf=[["ary",qt],["bind",j],["bindKey",de],["curry",ht],["curryRight",Rt],["flip",fs],["partial",ze],["partialRight",dr],["rearg",Er]],Wn="[object Arguments]",ei="[object Array]",Zf="[object AsyncFunction]",_r="[object Boolean]",gr="[object Date]",jf="[object DOMException]",ti="[object Error]",ni="[object Function]",Eo="[object GeneratorFunction]",mt="[object Map]",Nr="[object Number]",eh="[object Null]",zt="[object Object]",_o="[object Promise]",th="[object Proxy]",Tr="[object RegExp]",It="[object Set]",vr="[object String]",ri="[object Symbol]",nh="[object Undefined]",br="[object WeakMap]",rh="[object WeakSet]",mr="[object ArrayBuffer]",Xn="[object DataView]",hs="[object Float32Array]",ps="[object Float64Array]",ds="[object Int8Array]",Es="[object Int16Array]",_s="[object Int32Array]",gs="[object Uint8Array]",Ns="[object Uint8ClampedArray]",Ts="[object Uint16Array]",vs="[object Uint32Array]",ih=/\b__p \+= '';/g,sh=/\b(__p \+=) '' \+/g,ah=/(__e\(.*?\)|\b__t\)) \+\n'';/g,go=/&(?:amp|lt|gt|quot|#39);/g,No=/[&<>"']/g,oh=RegExp(go.source),uh=RegExp(No.source),lh=/<%-([\s\S]+?)%>/g,ch=/<%([\s\S]+?)%>/g,To=/<%=([\s\S]+?)%>/g,fh=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,hh=/^\w*$/,ph=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bs=/[\\^$.*+?()[\]{}|]/g,dh=RegExp(bs.source),ms=/^\s+/,Eh=/\s/,_h=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,gh=/\{\n\/\* \[wrapped with (.+)\] \*/,Nh=/,? & /,Th=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,vh=/[()=,{}\[\]\/\s]/,bh=/\\(\\)?/g,mh=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,vo=/\w*$/,Ih=/^[-+]0x[0-9a-f]+$/i,Ah=/^0b[01]+$/i,wh=/^\[object .+?Constructor\]$/,Lh=/^0o[0-7]+$/i,yh=/^(?:0|[1-9]\d*)$/,xh=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ii=/($^)/,Sh=/['\n\r\u2028\u2029\\]/g,si="\\ud800-\\udfff",Oh="\\u0300-\\u036f",Ph="\\ufe20-\\ufe2f",Rh="\\u20d0-\\u20ff",bo=Oh+Ph+Rh,mo="\\u2700-\\u27bf",Io="a-z\\xdf-\\xf6\\xf8-\\xff",Dh="\\xac\\xb1\\xd7\\xf7",Mh="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Uh="\\u2000-\\u206f",kh=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ao="A-Z\\xc0-\\xd6\\xd8-\\xde",wo="\\ufe0e\\ufe0f",Lo=Dh+Mh+Uh+kh,Is="['’]",Fh="["+si+"]",yo="["+Lo+"]",ai="["+bo+"]",xo="\\d+",Ch="["+mo+"]",So="["+Io+"]",Oo="[^"+si+Lo+xo+mo+Io+Ao+"]",As="\\ud83c[\\udffb-\\udfff]",Bh="(?:"+ai+"|"+As+")",Po="[^"+si+"]",ws="(?:\\ud83c[\\udde6-\\uddff]){2}",Ls="[\\ud800-\\udbff][\\udc00-\\udfff]",Hn="["+Ao+"]",Ro="\\u200d",Do="(?:"+So+"|"+Oo+")",Gh="(?:"+Hn+"|"+Oo+")",Mo="(?:"+Is+"(?:d|ll|m|re|s|t|ve))?",Uo="(?:"+Is+"(?:D|LL|M|RE|S|T|VE))?",ko=Bh+"?",Fo="["+wo+"]?",Vh="(?:"+Ro+"(?:"+[Po,ws,Ls].join("|")+")"+Fo+ko+")*",$h="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Wh="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Co=Fo+ko+Vh,Xh="(?:"+[Ch,ws,Ls].join("|")+")"+Co,Hh="(?:"+[Po+ai+"?",ai,ws,Ls,Fh].join("|")+")",qh=RegExp(Is,"g"),zh=RegExp(ai,"g"),ys=RegExp(As+"(?="+As+")|"+Hh+Co,"g"),Kh=RegExp([Hn+"?"+So+"+"+Mo+"(?="+[yo,Hn,"$"].join("|")+")",Gh+"+"+Uo+"(?="+[yo,Hn+Do,"$"].join("|")+")",Hn+"?"+Do+"+"+Mo,Hn+"+"+Uo,Wh,$h,xo,Xh].join("|"),"g"),Yh=RegExp("["+Ro+si+bo+wo+"]"),Jh=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Qh=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Zh=-1,fe={};fe[hs]=fe[ps]=fe[ds]=fe[Es]=fe[_s]=fe[gs]=fe[Ns]=fe[Ts]=fe[vs]=!0,fe[Wn]=fe[ei]=fe[mr]=fe[_r]=fe[Xn]=fe[gr]=fe[ti]=fe[ni]=fe[mt]=fe[Nr]=fe[zt]=fe[Tr]=fe[It]=fe[vr]=fe[br]=!1;var ce={};ce[Wn]=ce[ei]=ce[mr]=ce[Xn]=ce[_r]=ce[gr]=ce[hs]=ce[ps]=ce[ds]=ce[Es]=ce[_s]=ce[mt]=ce[Nr]=ce[zt]=ce[Tr]=ce[It]=ce[vr]=ce[ri]=ce[gs]=ce[Ns]=ce[Ts]=ce[vs]=!0,ce[ti]=ce[ni]=ce[br]=!1;var jh={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},ep={"&":"&","<":"<",">":">",'"':""","'":"'"},tp={"&":"&","<":"<",">":">",""":'"',"'":"'"},np={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},rp=parseFloat,ip=parseInt,Bo=typeof zi=="object"&&zi&&zi.Object===Object&&zi,sp=typeof self=="object"&&self&&self.Object===Object&&self,Re=Bo||sp||Function("return this")(),xs=r&&!r.nodeType&&r,Ln=xs&&!0&&t&&!t.nodeType&&t,Go=Ln&&Ln.exports===xs,Ss=Go&&Bo.process,pt=function(){try{var v=Ln&&Ln.require&&Ln.require("util").types;return v||Ss&&Ss.binding&&Ss.binding("util")}catch{}}(),Vo=pt&&pt.isArrayBuffer,$o=pt&&pt.isDate,Wo=pt&&pt.isMap,Xo=pt&&pt.isRegExp,Ho=pt&&pt.isSet,qo=pt&&pt.isTypedArray;function tt(v,L,w){switch(w.length){case 0:return v.call(L);case 1:return v.call(L,w[0]);case 2:return v.call(L,w[0],w[1]);case 3:return v.call(L,w[0],w[1],w[2])}return v.apply(L,w)}function ap(v,L,w,D){for(var X=-1,ie=v==null?0:v.length;++X<ie;){var xe=v[X];L(D,xe,w(xe),v)}return D}function dt(v,L){for(var w=-1,D=v==null?0:v.length;++w<D&&L(v[w],w,v)!==!1;);return v}function op(v,L){for(var w=v==null?0:v.length;w--&&L(v[w],w,v)!==!1;);return v}function zo(v,L){for(var w=-1,D=v==null?0:v.length;++w<D;)if(!L(v[w],w,v))return!1;return!0}function hn(v,L){for(var w=-1,D=v==null?0:v.length,X=0,ie=[];++w<D;){var xe=v[w];L(xe,w,v)&&(ie[X++]=xe)}return ie}function oi(v,L){var w=v==null?0:v.length;return!!w&&qn(v,L,0)>-1}function Os(v,L,w){for(var D=-1,X=v==null?0:v.length;++D<X;)if(w(L,v[D]))return!0;return!1}function Ee(v,L){for(var w=-1,D=v==null?0:v.length,X=Array(D);++w<D;)X[w]=L(v[w],w,v);return X}function pn(v,L){for(var w=-1,D=L.length,X=v.length;++w<D;)v[X+w]=L[w];return v}function Ps(v,L,w,D){var X=-1,ie=v==null?0:v.length;for(D&&ie&&(w=v[++X]);++X<ie;)w=L(w,v[X],X,v);return w}function up(v,L,w,D){var X=v==null?0:v.length;for(D&&X&&(w=v[--X]);X--;)w=L(w,v[X],X,v);return w}function Rs(v,L){for(var w=-1,D=v==null?0:v.length;++w<D;)if(L(v[w],w,v))return!0;return!1}var lp=Ds("length");function cp(v){return v.split("")}function fp(v){return v.match(Th)||[]}function Ko(v,L,w){var D;return w(v,function(X,ie,xe){if(L(X,ie,xe))return D=ie,!1}),D}function ui(v,L,w,D){for(var X=v.length,ie=w+(D?1:-1);D?ie--:++ie<X;)if(L(v[ie],ie,v))return ie;return-1}function qn(v,L,w){return L===L?Ip(v,L,w):ui(v,Yo,w)}function hp(v,L,w,D){for(var X=w-1,ie=v.length;++X<ie;)if(D(v[X],L))return X;return-1}function Yo(v){return v!==v}function Jo(v,L){var w=v==null?0:v.length;return w?Us(v,L)/w:jr}function Ds(v){return function(L){return L==null?i:L[v]}}function Ms(v){return function(L){return v==null?i:v[L]}}function Qo(v,L,w,D,X){return X(v,function(ie,xe,ue){w=D?(D=!1,ie):L(w,ie,xe,ue)}),w}function pp(v,L){var w=v.length;for(v.sort(L);w--;)v[w]=v[w].value;return v}function Us(v,L){for(var w,D=-1,X=v.length;++D<X;){var ie=L(v[D]);ie!==i&&(w=w===i?ie:w+ie)}return w}function ks(v,L){for(var w=-1,D=Array(v);++w<v;)D[w]=L(w);return D}function dp(v,L){return Ee(L,function(w){return[w,v[w]]})}function Zo(v){return v&&v.slice(0,nu(v)+1).replace(ms,"")}function nt(v){return function(L){return v(L)}}function Fs(v,L){return Ee(L,function(w){return v[w]})}function Ir(v,L){return v.has(L)}function jo(v,L){for(var w=-1,D=v.length;++w<D&&qn(L,v[w],0)>-1;);return w}function eu(v,L){for(var w=v.length;w--&&qn(L,v[w],0)>-1;);return w}function Ep(v,L){for(var w=v.length,D=0;w--;)v[w]===L&&++D;return D}var _p=Ms(jh),gp=Ms(ep);function Np(v){return"\\"+np[v]}function Tp(v,L){return v==null?i:v[L]}function zn(v){return Yh.test(v)}function vp(v){return Jh.test(v)}function bp(v){for(var L,w=[];!(L=v.next()).done;)w.push(L.value);return w}function Cs(v){var L=-1,w=Array(v.size);return v.forEach(function(D,X){w[++L]=[X,D]}),w}function tu(v,L){return function(w){return v(L(w))}}function dn(v,L){for(var w=-1,D=v.length,X=0,ie=[];++w<D;){var xe=v[w];(xe===L||xe===T)&&(v[w]=T,ie[X++]=w)}return ie}function li(v){var L=-1,w=Array(v.size);return v.forEach(function(D){w[++L]=D}),w}function mp(v){var L=-1,w=Array(v.size);return v.forEach(function(D){w[++L]=[D,D]}),w}function Ip(v,L,w){for(var D=w-1,X=v.length;++D<X;)if(v[D]===L)return D;return-1}function Ap(v,L,w){for(var D=w+1;D--;)if(v[D]===L)return D;return D}function Kn(v){return zn(v)?Lp(v):lp(v)}function At(v){return zn(v)?yp(v):cp(v)}function nu(v){for(var L=v.length;L--&&Eh.test(v.charAt(L)););return L}var wp=Ms(tp);function Lp(v){for(var L=ys.lastIndex=0;ys.test(v);)++L;return L}function yp(v){return v.match(ys)||[]}function xp(v){return v.match(Kh)||[]}var Sp=function v(L){L=L==null?Re:Yn.defaults(Re.Object(),L,Yn.pick(Re,Qh));var w=L.Array,D=L.Date,X=L.Error,ie=L.Function,xe=L.Math,ue=L.Object,Bs=L.RegExp,Op=L.String,Et=L.TypeError,ci=w.prototype,Pp=ie.prototype,Jn=ue.prototype,fi=L["__core-js_shared__"],hi=Pp.toString,oe=Jn.hasOwnProperty,Rp=0,ru=function(){var e=/[^.]+$/.exec(fi&&fi.keys&&fi.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),pi=Jn.toString,Dp=hi.call(ue),Mp=Re._,Up=Bs("^"+hi.call(oe).replace(bs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),di=Go?L.Buffer:i,En=L.Symbol,Ei=L.Uint8Array,iu=di?di.allocUnsafe:i,_i=tu(ue.getPrototypeOf,ue),su=ue.create,au=Jn.propertyIsEnumerable,gi=ci.splice,ou=En?En.isConcatSpreadable:i,Ar=En?En.iterator:i,yn=En?En.toStringTag:i,Ni=function(){try{var e=Rn(ue,"defineProperty");return e({},"",{}),e}catch{}}(),kp=L.clearTimeout!==Re.clearTimeout&&L.clearTimeout,Fp=D&&D.now!==Re.Date.now&&D.now,Cp=L.setTimeout!==Re.setTimeout&&L.setTimeout,Ti=xe.ceil,vi=xe.floor,Gs=ue.getOwnPropertySymbols,Bp=di?di.isBuffer:i,uu=L.isFinite,Gp=ci.join,Vp=tu(ue.keys,ue),Se=xe.max,Ce=xe.min,$p=D.now,Wp=L.parseInt,lu=xe.random,Xp=ci.reverse,Vs=Rn(L,"DataView"),wr=Rn(L,"Map"),$s=Rn(L,"Promise"),Qn=Rn(L,"Set"),Lr=Rn(L,"WeakMap"),yr=Rn(ue,"create"),bi=Lr&&new Lr,Zn={},Hp=Dn(Vs),qp=Dn(wr),zp=Dn($s),Kp=Dn(Qn),Yp=Dn(Lr),mi=En?En.prototype:i,xr=mi?mi.valueOf:i,cu=mi?mi.toString:i;function h(e){if(ve(e)&&!H(e)&&!(e instanceof Z)){if(e instanceof _t)return e;if(oe.call(e,"__wrapped__"))return fl(e)}return new _t(e)}var jn=function(){function e(){}return function(n){if(!ge(n))return{};if(su)return su(n);e.prototype=n;var a=new e;return e.prototype=i,a}}();function Ii(){}function _t(e,n){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=i}h.templateSettings={escape:lh,evaluate:ch,interpolate:To,variable:"",imports:{_:h}},h.prototype=Ii.prototype,h.prototype.constructor=h,_t.prototype=jn(Ii.prototype),_t.prototype.constructor=_t;function Z(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Dt,this.__views__=[]}function Jp(){var e=new Z(this.__wrapped__);return e.__actions__=Ke(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ke(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ke(this.__views__),e}function Qp(){if(this.__filtered__){var e=new Z(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Zp(){var e=this.__wrapped__.value(),n=this.__dir__,a=H(e),u=n<0,c=a?e.length:0,p=cE(0,c,this.__views__),E=p.start,N=p.end,b=N-E,x=u?N:E-1,S=this.__iteratees__,O=S.length,R=0,k=Ce(b,this.__takeCount__);if(!a||!u&&c==b&&k==b)return Mu(e,this.__actions__);var G=[];e:for(;b--&&R<k;){x+=n;for(var K=-1,V=e[x];++K<O;){var Q=S[K],ee=Q.iteratee,st=Q.type,We=ee(V);if(st==qf)V=We;else if(!We){if(st==po)continue e;break e}}G[R++]=V}return G}Z.prototype=jn(Ii.prototype),Z.prototype.constructor=Z;function xn(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var u=e[n];this.set(u[0],u[1])}}function jp(){this.__data__=yr?yr(null):{},this.size=0}function ed(e){var n=this.has(e)&&delete this.__data__[e];return this.size-=n?1:0,n}function td(e){var n=this.__data__;if(yr){var a=n[e];return a===m?i:a}return oe.call(n,e)?n[e]:i}function nd(e){var n=this.__data__;return yr?n[e]!==i:oe.call(n,e)}function rd(e,n){var a=this.__data__;return this.size+=this.has(e)?0:1,a[e]=yr&&n===i?m:n,this}xn.prototype.clear=jp,xn.prototype.delete=ed,xn.prototype.get=td,xn.prototype.has=nd,xn.prototype.set=rd;function Kt(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var u=e[n];this.set(u[0],u[1])}}function id(){this.__data__=[],this.size=0}function sd(e){var n=this.__data__,a=Ai(n,e);if(a<0)return!1;var u=n.length-1;return a==u?n.pop():gi.call(n,a,1),--this.size,!0}function ad(e){var n=this.__data__,a=Ai(n,e);return a<0?i:n[a][1]}function od(e){return Ai(this.__data__,e)>-1}function ud(e,n){var a=this.__data__,u=Ai(a,e);return u<0?(++this.size,a.push([e,n])):a[u][1]=n,this}Kt.prototype.clear=id,Kt.prototype.delete=sd,Kt.prototype.get=ad,Kt.prototype.has=od,Kt.prototype.set=ud;function Yt(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var u=e[n];this.set(u[0],u[1])}}function ld(){this.size=0,this.__data__={hash:new xn,map:new(wr||Kt),string:new xn}}function cd(e){var n=ki(this,e).delete(e);return this.size-=n?1:0,n}function fd(e){return ki(this,e).get(e)}function hd(e){return ki(this,e).has(e)}function pd(e,n){var a=ki(this,e),u=a.size;return a.set(e,n),this.size+=a.size==u?0:1,this}Yt.prototype.clear=ld,Yt.prototype.delete=cd,Yt.prototype.get=fd,Yt.prototype.has=hd,Yt.prototype.set=pd;function Sn(e){var n=-1,a=e==null?0:e.length;for(this.__data__=new Yt;++n<a;)this.add(e[n])}function dd(e){return this.__data__.set(e,m),this}function Ed(e){return this.__data__.has(e)}Sn.prototype.add=Sn.prototype.push=dd,Sn.prototype.has=Ed;function wt(e){var n=this.__data__=new Kt(e);this.size=n.size}function _d(){this.__data__=new Kt,this.size=0}function gd(e){var n=this.__data__,a=n.delete(e);return this.size=n.size,a}function Nd(e){return this.__data__.get(e)}function Td(e){return this.__data__.has(e)}function vd(e,n){var a=this.__data__;if(a instanceof Kt){var u=a.__data__;if(!wr||u.length<o-1)return u.push([e,n]),this.size=++a.size,this;a=this.__data__=new Yt(u)}return a.set(e,n),this.size=a.size,this}wt.prototype.clear=_d,wt.prototype.delete=gd,wt.prototype.get=Nd,wt.prototype.has=Td,wt.prototype.set=vd;function fu(e,n){var a=H(e),u=!a&&Mn(e),c=!a&&!u&&vn(e),p=!a&&!u&&!c&&rr(e),E=a||u||c||p,N=E?ks(e.length,Op):[],b=N.length;for(var x in e)(n||oe.call(e,x))&&!(E&&(x=="length"||c&&(x=="offset"||x=="parent")||p&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||jt(x,b)))&&N.push(x);return N}function hu(e){var n=e.length;return n?e[js(0,n-1)]:i}function bd(e,n){return Fi(Ke(e),On(n,0,e.length))}function md(e){return Fi(Ke(e))}function Ws(e,n,a){(a!==i&&!Lt(e[n],a)||a===i&&!(n in e))&&Jt(e,n,a)}function Sr(e,n,a){var u=e[n];(!(oe.call(e,n)&&Lt(u,a))||a===i&&!(n in e))&&Jt(e,n,a)}function Ai(e,n){for(var a=e.length;a--;)if(Lt(e[a][0],n))return a;return-1}function Id(e,n,a,u){return _n(e,function(c,p,E){n(u,c,a(c),E)}),u}function pu(e,n){return e&&Ut(n,Oe(n),e)}function Ad(e,n){return e&&Ut(n,Je(n),e)}function Jt(e,n,a){n=="__proto__"&&Ni?Ni(e,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):e[n]=a}function Xs(e,n){for(var a=-1,u=n.length,c=w(u),p=e==null;++a<u;)c[a]=p?i:Aa(e,n[a]);return c}function On(e,n,a){return e===e&&(a!==i&&(e=e<=a?e:a),n!==i&&(e=e>=n?e:n)),e}function gt(e,n,a,u,c,p){var E,N=n&y,b=n&$,x=n&J;if(a&&(E=c?a(e,u,c,p):a(e)),E!==i)return E;if(!ge(e))return e;var S=H(e);if(S){if(E=hE(e),!N)return Ke(e,E)}else{var O=Be(e),R=O==ni||O==Eo;if(vn(e))return Fu(e,N);if(O==zt||O==Wn||R&&!c){if(E=b||R?{}:nl(e),!N)return b?tE(e,Ad(E,e)):eE(e,pu(E,e))}else{if(!ce[O])return c?e:{};E=pE(e,O,N)}}p||(p=new wt);var k=p.get(e);if(k)return k;p.set(e,E),Pl(e)?e.forEach(function(V){E.add(gt(V,n,a,V,e,p))}):Sl(e)&&e.forEach(function(V,Q){E.set(Q,gt(V,n,a,Q,e,p))});var G=x?b?ca:la:b?Je:Oe,K=S?i:G(e);return dt(K||e,function(V,Q){K&&(Q=V,V=e[Q]),Sr(E,Q,gt(V,n,a,Q,e,p))}),E}function wd(e){var n=Oe(e);return function(a){return du(a,e,n)}}function du(e,n,a){var u=a.length;if(e==null)return!u;for(e=ue(e);u--;){var c=a[u],p=n[c],E=e[c];if(E===i&&!(c in e)||!p(E))return!1}return!0}function Eu(e,n,a){if(typeof e!="function")throw new Et(f);return kr(function(){e.apply(i,a)},n)}function Or(e,n,a,u){var c=-1,p=oi,E=!0,N=e.length,b=[],x=n.length;if(!N)return b;a&&(n=Ee(n,nt(a))),u?(p=Os,E=!1):n.length>=o&&(p=Ir,E=!1,n=new Sn(n));e:for(;++c<N;){var S=e[c],O=a==null?S:a(S);if(S=u||S!==0?S:0,E&&O===O){for(var R=x;R--;)if(n[R]===O)continue e;b.push(S)}else p(n,O,u)||b.push(S)}return b}var _n=$u(Mt),_u=$u(qs,!0);function Ld(e,n){var a=!0;return _n(e,function(u,c,p){return a=!!n(u,c,p),a}),a}function wi(e,n,a){for(var u=-1,c=e.length;++u<c;){var p=e[u],E=n(p);if(E!=null&&(N===i?E===E&&!it(E):a(E,N)))var N=E,b=p}return b}function yd(e,n,a,u){var c=e.length;for(a=z(a),a<0&&(a=-a>c?0:c+a),u=u===i||u>c?c:z(u),u<0&&(u+=c),u=a>u?0:Dl(u);a<u;)e[a++]=n;return e}function gu(e,n){var a=[];return _n(e,function(u,c,p){n(u,c,p)&&a.push(u)}),a}function De(e,n,a,u,c){var p=-1,E=e.length;for(a||(a=EE),c||(c=[]);++p<E;){var N=e[p];n>0&&a(N)?n>1?De(N,n-1,a,u,c):pn(c,N):u||(c[c.length]=N)}return c}var Hs=Wu(),Nu=Wu(!0);function Mt(e,n){return e&&Hs(e,n,Oe)}function qs(e,n){return e&&Nu(e,n,Oe)}function Li(e,n){return hn(n,function(a){return en(e[a])})}function Pn(e,n){n=Nn(n,e);for(var a=0,u=n.length;e!=null&&a<u;)e=e[kt(n[a++])];return a&&a==u?e:i}function Tu(e,n,a){var u=n(e);return H(e)?u:pn(u,a(e))}function Ve(e){return e==null?e===i?nh:eh:yn&&yn in ue(e)?lE(e):mE(e)}function zs(e,n){return e>n}function xd(e,n){return e!=null&&oe.call(e,n)}function Sd(e,n){return e!=null&&n in ue(e)}function Od(e,n,a){return e>=Ce(n,a)&&e<Se(n,a)}function Ks(e,n,a){for(var u=a?Os:oi,c=e[0].length,p=e.length,E=p,N=w(p),b=1/0,x=[];E--;){var S=e[E];E&&n&&(S=Ee(S,nt(n))),b=Ce(S.length,b),N[E]=!a&&(n||c>=120&&S.length>=120)?new Sn(E&&S):i}S=e[0];var O=-1,R=N[0];e:for(;++O<c&&x.length<b;){var k=S[O],G=n?n(k):k;if(k=a||k!==0?k:0,!(R?Ir(R,G):u(x,G,a))){for(E=p;--E;){var K=N[E];if(!(K?Ir(K,G):u(e[E],G,a)))continue e}R&&R.push(G),x.push(k)}}return x}function Pd(e,n,a,u){return Mt(e,function(c,p,E){n(u,a(c),p,E)}),u}function Pr(e,n,a){n=Nn(n,e),e=al(e,n);var u=e==null?e:e[kt(Tt(n))];return u==null?i:tt(u,e,a)}function vu(e){return ve(e)&&Ve(e)==Wn}function Rd(e){return ve(e)&&Ve(e)==mr}function Dd(e){return ve(e)&&Ve(e)==gr}function Rr(e,n,a,u,c){return e===n?!0:e==null||n==null||!ve(e)&&!ve(n)?e!==e&&n!==n:Md(e,n,a,u,Rr,c)}function Md(e,n,a,u,c,p){var E=H(e),N=H(n),b=E?ei:Be(e),x=N?ei:Be(n);b=b==Wn?zt:b,x=x==Wn?zt:x;var S=b==zt,O=x==zt,R=b==x;if(R&&vn(e)){if(!vn(n))return!1;E=!0,S=!1}if(R&&!S)return p||(p=new wt),E||rr(e)?ju(e,n,a,u,c,p):oE(e,n,b,a,u,c,p);if(!(a&ne)){var k=S&&oe.call(e,"__wrapped__"),G=O&&oe.call(n,"__wrapped__");if(k||G){var K=k?e.value():e,V=G?n.value():n;return p||(p=new wt),c(K,V,a,u,p)}}return R?(p||(p=new wt),uE(e,n,a,u,c,p)):!1}function Ud(e){return ve(e)&&Be(e)==mt}function Ys(e,n,a,u){var c=a.length,p=c,E=!u;if(e==null)return!p;for(e=ue(e);c--;){var N=a[c];if(E&&N[2]?N[1]!==e[N[0]]:!(N[0]in e))return!1}for(;++c<p;){N=a[c];var b=N[0],x=e[b],S=N[1];if(E&&N[2]){if(x===i&&!(b in e))return!1}else{var O=new wt;if(u)var R=u(x,S,b,e,n,O);if(!(R===i?Rr(S,x,ne|re,u,O):R))return!1}}return!0}function bu(e){if(!ge(e)||gE(e))return!1;var n=en(e)?Up:wh;return n.test(Dn(e))}function kd(e){return ve(e)&&Ve(e)==Tr}function Fd(e){return ve(e)&&Be(e)==It}function Cd(e){return ve(e)&&Wi(e.length)&&!!fe[Ve(e)]}function mu(e){return typeof e=="function"?e:e==null?Qe:typeof e=="object"?H(e)?wu(e[0],e[1]):Au(e):Xl(e)}function Js(e){if(!Ur(e))return Vp(e);var n=[];for(var a in ue(e))oe.call(e,a)&&a!="constructor"&&n.push(a);return n}function Bd(e){if(!ge(e))return bE(e);var n=Ur(e),a=[];for(var u in e)u=="constructor"&&(n||!oe.call(e,u))||a.push(u);return a}function Qs(e,n){return e<n}function Iu(e,n){var a=-1,u=Ye(e)?w(e.length):[];return _n(e,function(c,p,E){u[++a]=n(c,p,E)}),u}function Au(e){var n=ha(e);return n.length==1&&n[0][2]?il(n[0][0],n[0][1]):function(a){return a===e||Ys(a,e,n)}}function wu(e,n){return da(e)&&rl(n)?il(kt(e),n):function(a){var u=Aa(a,e);return u===i&&u===n?wa(a,e):Rr(n,u,ne|re)}}function yi(e,n,a,u,c){e!==n&&Hs(n,function(p,E){if(c||(c=new wt),ge(p))Gd(e,n,E,a,yi,u,c);else{var N=u?u(_a(e,E),p,E+"",e,n,c):i;N===i&&(N=p),Ws(e,E,N)}},Je)}function Gd(e,n,a,u,c,p,E){var N=_a(e,a),b=_a(n,a),x=E.get(b);if(x){Ws(e,a,x);return}var S=p?p(N,b,a+"",e,n,E):i,O=S===i;if(O){var R=H(b),k=!R&&vn(b),G=!R&&!k&&rr(b);S=b,R||k||G?H(N)?S=N:Ie(N)?S=Ke(N):k?(O=!1,S=Fu(b,!0)):G?(O=!1,S=Cu(b,!0)):S=[]:Fr(b)||Mn(b)?(S=N,Mn(N)?S=Ml(N):(!ge(N)||en(N))&&(S=nl(b))):O=!1}O&&(E.set(b,S),c(S,b,u,p,E),E.delete(b)),Ws(e,a,S)}function Lu(e,n){var a=e.length;if(a)return n+=n<0?a:0,jt(n,a)?e[n]:i}function yu(e,n,a){n.length?n=Ee(n,function(p){return H(p)?function(E){return Pn(E,p.length===1?p[0]:p)}:p}):n=[Qe];var u=-1;n=Ee(n,nt(B()));var c=Iu(e,function(p,E,N){var b=Ee(n,function(x){return x(p)});return{criteria:b,index:++u,value:p}});return pp(c,function(p,E){return jd(p,E,a)})}function Vd(e,n){return xu(e,n,function(a,u){return wa(e,u)})}function xu(e,n,a){for(var u=-1,c=n.length,p={};++u<c;){var E=n[u],N=Pn(e,E);a(N,E)&&Dr(p,Nn(E,e),N)}return p}function $d(e){return function(n){return Pn(n,e)}}function Zs(e,n,a,u){var c=u?hp:qn,p=-1,E=n.length,N=e;for(e===n&&(n=Ke(n)),a&&(N=Ee(e,nt(a)));++p<E;)for(var b=0,x=n[p],S=a?a(x):x;(b=c(N,S,b,u))>-1;)N!==e&&gi.call(N,b,1),gi.call(e,b,1);return e}function Su(e,n){for(var a=e?n.length:0,u=a-1;a--;){var c=n[a];if(a==u||c!==p){var p=c;jt(c)?gi.call(e,c,1):na(e,c)}}return e}function js(e,n){return e+vi(lu()*(n-e+1))}function Wd(e,n,a,u){for(var c=-1,p=Se(Ti((n-e)/(a||1)),0),E=w(p);p--;)E[u?p:++c]=e,e+=a;return E}function ea(e,n){var a="";if(!e||n<1||n>fn)return a;do n%2&&(a+=e),n=vi(n/2),n&&(e+=e);while(n);return a}function Y(e,n){return ga(sl(e,n,Qe),e+"")}function Xd(e){return hu(ir(e))}function Hd(e,n){var a=ir(e);return Fi(a,On(n,0,a.length))}function Dr(e,n,a,u){if(!ge(e))return e;n=Nn(n,e);for(var c=-1,p=n.length,E=p-1,N=e;N!=null&&++c<p;){var b=kt(n[c]),x=a;if(b==="__proto__"||b==="constructor"||b==="prototype")return e;if(c!=E){var S=N[b];x=u?u(S,b,N):i,x===i&&(x=ge(S)?S:jt(n[c+1])?[]:{})}Sr(N,b,x),N=N[b]}return e}var Ou=bi?function(e,n){return bi.set(e,n),e}:Qe,qd=Ni?function(e,n){return Ni(e,"toString",{configurable:!0,enumerable:!1,value:ya(n),writable:!0})}:Qe;function zd(e){return Fi(ir(e))}function Nt(e,n,a){var u=-1,c=e.length;n<0&&(n=-n>c?0:c+n),a=a>c?c:a,a<0&&(a+=c),c=n>a?0:a-n>>>0,n>>>=0;for(var p=w(c);++u<c;)p[u]=e[u+n];return p}function Kd(e,n){var a;return _n(e,function(u,c,p){return a=n(u,c,p),!a}),!!a}function xi(e,n,a){var u=0,c=e==null?u:e.length;if(typeof n=="number"&&n===n&&c<=Jf){for(;u<c;){var p=u+c>>>1,E=e[p];E!==null&&!it(E)&&(a?E<=n:E<n)?u=p+1:c=p}return c}return ta(e,n,Qe,a)}function ta(e,n,a,u){var c=0,p=e==null?0:e.length;if(p===0)return 0;n=a(n);for(var E=n!==n,N=n===null,b=it(n),x=n===i;c<p;){var S=vi((c+p)/2),O=a(e[S]),R=O!==i,k=O===null,G=O===O,K=it(O);if(E)var V=u||G;else x?V=G&&(u||R):N?V=G&&R&&(u||!k):b?V=G&&R&&!k&&(u||!K):k||K?V=!1:V=u?O<=n:O<n;V?c=S+1:p=S}return Ce(p,Yf)}function Pu(e,n){for(var a=-1,u=e.length,c=0,p=[];++a<u;){var E=e[a],N=n?n(E):E;if(!a||!Lt(N,b)){var b=N;p[c++]=E===0?0:E}}return p}function Ru(e){return typeof e=="number"?e:it(e)?jr:+e}function rt(e){if(typeof e=="string")return e;if(H(e))return Ee(e,rt)+"";if(it(e))return cu?cu.call(e):"";var n=e+"";return n=="0"&&1/e==-wn?"-0":n}function gn(e,n,a){var u=-1,c=oi,p=e.length,E=!0,N=[],b=N;if(a)E=!1,c=Os;else if(p>=o){var x=n?null:sE(e);if(x)return li(x);E=!1,c=Ir,b=new Sn}else b=n?[]:N;e:for(;++u<p;){var S=e[u],O=n?n(S):S;if(S=a||S!==0?S:0,E&&O===O){for(var R=b.length;R--;)if(b[R]===O)continue e;n&&b.push(O),N.push(S)}else c(b,O,a)||(b!==N&&b.push(O),N.push(S))}return N}function na(e,n){return n=Nn(n,e),e=al(e,n),e==null||delete e[kt(Tt(n))]}function Du(e,n,a,u){return Dr(e,n,a(Pn(e,n)),u)}function Si(e,n,a,u){for(var c=e.length,p=u?c:-1;(u?p--:++p<c)&&n(e[p],p,e););return a?Nt(e,u?0:p,u?p+1:c):Nt(e,u?p+1:0,u?c:p)}function Mu(e,n){var a=e;return a instanceof Z&&(a=a.value()),Ps(n,function(u,c){return c.func.apply(c.thisArg,pn([u],c.args))},a)}function ra(e,n,a){var u=e.length;if(u<2)return u?gn(e[0]):[];for(var c=-1,p=w(u);++c<u;)for(var E=e[c],N=-1;++N<u;)N!=c&&(p[c]=Or(p[c]||E,e[N],n,a));return gn(De(p,1),n,a)}function Uu(e,n,a){for(var u=-1,c=e.length,p=n.length,E={};++u<c;){var N=u<p?n[u]:i;a(E,e[u],N)}return E}function ia(e){return Ie(e)?e:[]}function sa(e){return typeof e=="function"?e:Qe}function Nn(e,n){return H(e)?e:da(e,n)?[e]:cl(ae(e))}var Yd=Y;function Tn(e,n,a){var u=e.length;return a=a===i?u:a,!n&&a>=u?e:Nt(e,n,a)}var ku=kp||function(e){return Re.clearTimeout(e)};function Fu(e,n){if(n)return e.slice();var a=e.length,u=iu?iu(a):new e.constructor(a);return e.copy(u),u}function aa(e){var n=new e.constructor(e.byteLength);return new Ei(n).set(new Ei(e)),n}function Jd(e,n){var a=n?aa(e.buffer):e.buffer;return new e.constructor(a,e.byteOffset,e.byteLength)}function Qd(e){var n=new e.constructor(e.source,vo.exec(e));return n.lastIndex=e.lastIndex,n}function Zd(e){return xr?ue(xr.call(e)):{}}function Cu(e,n){var a=n?aa(e.buffer):e.buffer;return new e.constructor(a,e.byteOffset,e.length)}function Bu(e,n){if(e!==n){var a=e!==i,u=e===null,c=e===e,p=it(e),E=n!==i,N=n===null,b=n===n,x=it(n);if(!N&&!x&&!p&&e>n||p&&E&&b&&!N&&!x||u&&E&&b||!a&&b||!c)return 1;if(!u&&!p&&!x&&e<n||x&&a&&c&&!u&&!p||N&&a&&c||!E&&c||!b)return-1}return 0}function jd(e,n,a){for(var u=-1,c=e.criteria,p=n.criteria,E=c.length,N=a.length;++u<E;){var b=Bu(c[u],p[u]);if(b){if(u>=N)return b;var x=a[u];return b*(x=="desc"?-1:1)}}return e.index-n.index}function Gu(e,n,a,u){for(var c=-1,p=e.length,E=a.length,N=-1,b=n.length,x=Se(p-E,0),S=w(b+x),O=!u;++N<b;)S[N]=n[N];for(;++c<E;)(O||c<p)&&(S[a[c]]=e[c]);for(;x--;)S[N++]=e[c++];return S}function Vu(e,n,a,u){for(var c=-1,p=e.length,E=-1,N=a.length,b=-1,x=n.length,S=Se(p-N,0),O=w(S+x),R=!u;++c<S;)O[c]=e[c];for(var k=c;++b<x;)O[k+b]=n[b];for(;++E<N;)(R||c<p)&&(O[k+a[E]]=e[c++]);return O}function Ke(e,n){var a=-1,u=e.length;for(n||(n=w(u));++a<u;)n[a]=e[a];return n}function Ut(e,n,a,u){var c=!a;a||(a={});for(var p=-1,E=n.length;++p<E;){var N=n[p],b=u?u(a[N],e[N],N,a,e):i;b===i&&(b=e[N]),c?Jt(a,N,b):Sr(a,N,b)}return a}function eE(e,n){return Ut(e,pa(e),n)}function tE(e,n){return Ut(e,el(e),n)}function Oi(e,n){return function(a,u){var c=H(a)?ap:Id,p=n?n():{};return c(a,e,B(u,2),p)}}function er(e){return Y(function(n,a){var u=-1,c=a.length,p=c>1?a[c-1]:i,E=c>2?a[2]:i;for(p=e.length>3&&typeof p=="function"?(c--,p):i,E&&$e(a[0],a[1],E)&&(p=c<3?i:p,c=1),n=ue(n);++u<c;){var N=a[u];N&&e(n,N,u,p)}return n})}function $u(e,n){return function(a,u){if(a==null)return a;if(!Ye(a))return e(a,u);for(var c=a.length,p=n?c:-1,E=ue(a);(n?p--:++p<c)&&u(E[p],p,E)!==!1;);return a}}function Wu(e){return function(n,a,u){for(var c=-1,p=ue(n),E=u(n),N=E.length;N--;){var b=E[e?N:++c];if(a(p[b],b,p)===!1)break}return n}}function nE(e,n,a){var u=n&j,c=Mr(e);function p(){var E=this&&this!==Re&&this instanceof p?c:e;return E.apply(u?a:this,arguments)}return p}function Xu(e){return function(n){n=ae(n);var a=zn(n)?At(n):i,u=a?a[0]:n.charAt(0),c=a?Tn(a,1).join(""):n.slice(1);return u[e]()+c}}function tr(e){return function(n){return Ps($l(Vl(n).replace(qh,"")),e,"")}}function Mr(e){return function(){var n=arguments;switch(n.length){case 0:return new e;case 1:return new e(n[0]);case 2:return new e(n[0],n[1]);case 3:return new e(n[0],n[1],n[2]);case 4:return new e(n[0],n[1],n[2],n[3]);case 5:return new e(n[0],n[1],n[2],n[3],n[4]);case 6:return new e(n[0],n[1],n[2],n[3],n[4],n[5]);case 7:return new e(n[0],n[1],n[2],n[3],n[4],n[5],n[6])}var a=jn(e.prototype),u=e.apply(a,n);return ge(u)?u:a}}function rE(e,n,a){var u=Mr(e);function c(){for(var p=arguments.length,E=w(p),N=p,b=nr(c);N--;)E[N]=arguments[N];var x=p<3&&E[0]!==b&&E[p-1]!==b?[]:dn(E,b);if(p-=x.length,p<a)return Yu(e,n,Pi,c.placeholder,i,E,x,i,i,a-p);var S=this&&this!==Re&&this instanceof c?u:e;return tt(S,this,E)}return c}function Hu(e){return function(n,a,u){var c=ue(n);if(!Ye(n)){var p=B(a,3);n=Oe(n),a=function(N){return p(c[N],N,c)}}var E=e(n,a,u);return E>-1?c[p?n[E]:E]:i}}function qu(e){return Zt(function(n){var a=n.length,u=a,c=_t.prototype.thru;for(e&&n.reverse();u--;){var p=n[u];if(typeof p!="function")throw new Et(f);if(c&&!E&&Ui(p)=="wrapper")var E=new _t([],!0)}for(u=E?u:a;++u<a;){p=n[u];var N=Ui(p),b=N=="wrapper"?fa(p):i;b&&Ea(b[0])&&b[1]==(qt|ht|ze|Er)&&!b[4].length&&b[9]==1?E=E[Ui(b[0])].apply(E,b[3]):E=p.length==1&&Ea(p)?E[N]():E.thru(p)}return function(){var x=arguments,S=x[0];if(E&&x.length==1&&H(S))return E.plant(S).value();for(var O=0,R=a?n[O].apply(this,x):S;++O<a;)R=n[O].call(this,R);return R}})}function Pi(e,n,a,u,c,p,E,N,b,x){var S=n&qt,O=n&j,R=n&de,k=n&(ht|Rt),G=n&fs,K=R?i:Mr(e);function V(){for(var Q=arguments.length,ee=w(Q),st=Q;st--;)ee[st]=arguments[st];if(k)var We=nr(V),at=Ep(ee,We);if(u&&(ee=Gu(ee,u,c,k)),p&&(ee=Vu(ee,p,E,k)),Q-=at,k&&Q<x){var Ae=dn(ee,We);return Yu(e,n,Pi,V.placeholder,a,ee,Ae,N,b,x-Q)}var yt=O?a:this,nn=R?yt[e]:e;return Q=ee.length,N?ee=IE(ee,N):G&&Q>1&&ee.reverse(),S&&b<Q&&(ee.length=b),this&&this!==Re&&this instanceof V&&(nn=K||Mr(nn)),nn.apply(yt,ee)}return V}function zu(e,n){return function(a,u){return Pd(a,e,n(u),{})}}function Ri(e,n){return function(a,u){var c;if(a===i&&u===i)return n;if(a!==i&&(c=a),u!==i){if(c===i)return u;typeof a=="string"||typeof u=="string"?(a=rt(a),u=rt(u)):(a=Ru(a),u=Ru(u)),c=e(a,u)}return c}}function oa(e){return Zt(function(n){return n=Ee(n,nt(B())),Y(function(a){var u=this;return e(n,function(c){return tt(c,u,a)})})})}function Di(e,n){n=n===i?" ":rt(n);var a=n.length;if(a<2)return a?ea(n,e):n;var u=ea(n,Ti(e/Kn(n)));return zn(n)?Tn(At(u),0,e).join(""):u.slice(0,e)}function iE(e,n,a,u){var c=n&j,p=Mr(e);function E(){for(var N=-1,b=arguments.length,x=-1,S=u.length,O=w(S+b),R=this&&this!==Re&&this instanceof E?p:e;++x<S;)O[x]=u[x];for(;b--;)O[x++]=arguments[++N];return tt(R,c?a:this,O)}return E}function Ku(e){return function(n,a,u){return u&&typeof u!="number"&&$e(n,a,u)&&(a=u=i),n=tn(n),a===i?(a=n,n=0):a=tn(a),u=u===i?n<a?1:-1:tn(u),Wd(n,a,u,e)}}function Mi(e){return function(n,a){return typeof n=="string"&&typeof a=="string"||(n=vt(n),a=vt(a)),e(n,a)}}function Yu(e,n,a,u,c,p,E,N,b,x){var S=n&ht,O=S?E:i,R=S?i:E,k=S?p:i,G=S?i:p;n|=S?ze:dr,n&=~(S?dr:ze),n&et||(n&=-4);var K=[e,n,c,k,O,G,R,N,b,x],V=a.apply(i,K);return Ea(e)&&ol(V,K),V.placeholder=u,ul(V,e,n)}function ua(e){var n=xe[e];return function(a,u){if(a=vt(a),u=u==null?0:Ce(z(u),292),u&&uu(a)){var c=(ae(a)+"e").split("e"),p=n(c[0]+"e"+(+c[1]+u));return c=(ae(p)+"e").split("e"),+(c[0]+"e"+(+c[1]-u))}return n(a)}}var sE=Qn&&1/li(new Qn([,-0]))[1]==wn?function(e){return new Qn(e)}:Oa;function Ju(e){return function(n){var a=Be(n);return a==mt?Cs(n):a==It?mp(n):dp(n,e(n))}}function Qt(e,n,a,u,c,p,E,N){var b=n&de;if(!b&&typeof e!="function")throw new Et(f);var x=u?u.length:0;if(x||(n&=-97,u=c=i),E=E===i?E:Se(z(E),0),N=N===i?N:z(N),x-=c?c.length:0,n&dr){var S=u,O=c;u=c=i}var R=b?i:fa(e),k=[e,n,a,u,c,S,O,p,E,N];if(R&&vE(k,R),e=k[0],n=k[1],a=k[2],u=k[3],c=k[4],N=k[9]=k[9]===i?b?0:e.length:Se(k[9]-x,0),!N&&n&(ht|Rt)&&(n&=-25),!n||n==j)var G=nE(e,n,a);else n==ht||n==Rt?G=rE(e,n,N):(n==ze||n==(j|ze))&&!c.length?G=iE(e,n,a,u):G=Pi.apply(i,k);var K=R?Ou:ol;return ul(K(G,k),e,n)}function Qu(e,n,a,u){return e===i||Lt(e,Jn[a])&&!oe.call(u,a)?n:e}function Zu(e,n,a,u,c,p){return ge(e)&&ge(n)&&(p.set(n,e),yi(e,n,i,Zu,p),p.delete(n)),e}function aE(e){return Fr(e)?i:e}function ju(e,n,a,u,c,p){var E=a&ne,N=e.length,b=n.length;if(N!=b&&!(E&&b>N))return!1;var x=p.get(e),S=p.get(n);if(x&&S)return x==n&&S==e;var O=-1,R=!0,k=a&re?new Sn:i;for(p.set(e,n),p.set(n,e);++O<N;){var G=e[O],K=n[O];if(u)var V=E?u(K,G,O,n,e,p):u(G,K,O,e,n,p);if(V!==i){if(V)continue;R=!1;break}if(k){if(!Rs(n,function(Q,ee){if(!Ir(k,ee)&&(G===Q||c(G,Q,a,u,p)))return k.push(ee)})){R=!1;break}}else if(!(G===K||c(G,K,a,u,p))){R=!1;break}}return p.delete(e),p.delete(n),R}function oE(e,n,a,u,c,p,E){switch(a){case Xn:if(e.byteLength!=n.byteLength||e.byteOffset!=n.byteOffset)return!1;e=e.buffer,n=n.buffer;case mr:return!(e.byteLength!=n.byteLength||!p(new Ei(e),new Ei(n)));case _r:case gr:case Nr:return Lt(+e,+n);case ti:return e.name==n.name&&e.message==n.message;case Tr:case vr:return e==n+"";case mt:var N=Cs;case It:var b=u≠if(N||(N=li),e.size!=n.size&&!b)return!1;var x=E.get(e);if(x)return x==n;u|=re,E.set(e,n);var S=ju(N(e),N(n),u,c,p,E);return E.delete(e),S;case ri:if(xr)return xr.call(e)==xr.call(n)}return!1}function uE(e,n,a,u,c,p){var E=a&ne,N=la(e),b=N.length,x=la(n),S=x.length;if(b!=S&&!E)return!1;for(var O=b;O--;){var R=N[O];if(!(E?R in n:oe.call(n,R)))return!1}var k=p.get(e),G=p.get(n);if(k&&G)return k==n&&G==e;var K=!0;p.set(e,n),p.set(n,e);for(var V=E;++O<b;){R=N[O];var Q=e[R],ee=n[R];if(u)var st=E?u(ee,Q,R,n,e,p):u(Q,ee,R,e,n,p);if(!(st===i?Q===ee||c(Q,ee,a,u,p):st)){K=!1;break}V||(V=R=="constructor")}if(K&&!V){var We=e.constructor,at=n.constructor;We!=at&&"constructor"in e&&"constructor"in n&&!(typeof We=="function"&&We instanceof We&&typeof at=="function"&&at instanceof at)&&(K=!1)}return p.delete(e),p.delete(n),K}function Zt(e){return ga(sl(e,i,dl),e+"")}function la(e){return Tu(e,Oe,pa)}function ca(e){return Tu(e,Je,el)}var fa=bi?function(e){return bi.get(e)}:Oa;function Ui(e){for(var n=e.name+"",a=Zn[n],u=oe.call(Zn,n)?a.length:0;u--;){var c=a[u],p=c.func;if(p==null||p==e)return c.name}return n}function nr(e){var n=oe.call(h,"placeholder")?h:e;return n.placeholder}function B(){var e=h.iteratee||xa;return e=e===xa?mu:e,arguments.length?e(arguments[0],arguments[1]):e}function ki(e,n){var a=e.__data__;return _E(n)?a[typeof n=="string"?"string":"hash"]:a.map}function ha(e){for(var n=Oe(e),a=n.length;a--;){var u=n[a],c=e[u];n[a]=[u,c,rl(c)]}return n}function Rn(e,n){var a=Tp(e,n);return bu(a)?a:i}function lE(e){var n=oe.call(e,yn),a=e[yn];try{e[yn]=i;var u=!0}catch{}var c=pi.call(e);return u&&(n?e[yn]=a:delete e[yn]),c}var pa=Gs?function(e){return e==null?[]:(e=ue(e),hn(Gs(e),function(n){return au.call(e,n)}))}:Pa,el=Gs?function(e){for(var n=[];e;)pn(n,pa(e)),e=_i(e);return n}:Pa,Be=Ve;(Vs&&Be(new Vs(new ArrayBuffer(1)))!=Xn||wr&&Be(new wr)!=mt||$s&&Be($s.resolve())!=_o||Qn&&Be(new Qn)!=It||Lr&&Be(new Lr)!=br)&&(Be=function(e){var n=Ve(e),a=n==zt?e.constructor:i,u=a?Dn(a):"";if(u)switch(u){case Hp:return Xn;case qp:return mt;case zp:return _o;case Kp:return It;case Yp:return br}return n});function cE(e,n,a){for(var u=-1,c=a.length;++u<c;){var p=a[u],E=p.size;switch(p.type){case"drop":e+=E;break;case"dropRight":n-=E;break;case"take":n=Ce(n,e+E);break;case"takeRight":e=Se(e,n-E);break}}return{start:e,end:n}}function fE(e){var n=e.match(gh);return n?n[1].split(Nh):[]}function tl(e,n,a){n=Nn(n,e);for(var u=-1,c=n.length,p=!1;++u<c;){var E=kt(n[u]);if(!(p=e!=null&&a(e,E)))break;e=e[E]}return p||++u!=c?p:(c=e==null?0:e.length,!!c&&Wi(c)&&jt(E,c)&&(H(e)||Mn(e)))}function hE(e){var n=e.length,a=new e.constructor(n);return n&&typeof e[0]=="string"&&oe.call(e,"index")&&(a.index=e.index,a.input=e.input),a}function nl(e){return typeof e.constructor=="function"&&!Ur(e)?jn(_i(e)):{}}function pE(e,n,a){var u=e.constructor;switch(n){case mr:return aa(e);case _r:case gr:return new u(+e);case Xn:return Jd(e,a);case hs:case ps:case ds:case Es:case _s:case gs:case Ns:case Ts:case vs:return Cu(e,a);case mt:return new u;case Nr:case vr:return new u(e);case Tr:return Qd(e);case It:return new u;case ri:return Zd(e)}}function dE(e,n){var a=n.length;if(!a)return e;var u=a-1;return n[u]=(a>1?"& ":"")+n[u],n=n.join(a>2?", ":" "),e.replace(_h,`{
|
|
10
|
-
/* [wrapped with `+
|
|
11
|
-
`)}function EE(e){return H(e)||Mn(e)||!!(ou&&e&&e[ou])}function jt(e,n){var a=typeof e;return n=n??fn,!!n&&(a=="number"||a!="symbol"&&yh.test(e))&&e>-1&&e%1==0&&e<n}function $e(e,n,a){if(!ge(a))return!1;var u=typeof n;return(u=="number"?Ye(a)&&jt(n,a.length):u=="string"&&n in a)?Lt(a[n],e):!1}function da(e,n){if(H(e))return!1;var a=typeof e;return a=="number"||a=="symbol"||a=="boolean"||e==null||it(e)?!0:hh.test(e)||!fh.test(e)||n!=null&&e in ue(n)}function _E(e){var n=typeof e;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?e!=="__proto__":e===null}function Ea(e){var n=Ui(e),a=h[n];if(typeof a!="function"||!(n in Z.prototype))return!1;if(e===a)return!0;var u=fa(a);return!!u&&e===u[0]}function gE(e){return!!ru&&ru in e}var NE=fi?en:Ra;function Ur(e){var n=e&&e.constructor,a=typeof n=="function"&&n.prototype||Jn;return e===a}function rl(e){return e===e&&!ge(e)}function il(e,n){return function(a){return a==null?!1:a[e]===n&&(n!==i||e in ue(a))}}function TE(e){var n=Vi(e,function(u){return a.size===I&&a.clear(),u}),a=n.cache;return n}function vE(e,n){var a=e[1],u=n[1],c=a|u,p=c<(j|de|qt),E=u==qt&&a==ht||u==qt&&a==Er&&e[7].length<=n[8]||u==(qt|Er)&&n[7].length<=n[8]&&a==ht;if(!(p||E))return e;u&j&&(e[2]=n[2],c|=a&j?0:et);var N=n[3];if(N){var b=e[3];e[3]=b?Gu(b,N,n[4]):N,e[4]=b?dn(e[3],T):n[4]}return N=n[5],N&&(b=e[5],e[5]=b?Vu(b,N,n[6]):N,e[6]=b?dn(e[5],T):n[6]),N=n[7],N&&(e[7]=N),u&qt&&(e[8]=e[8]==null?n[8]:Ce(e[8],n[8])),e[9]==null&&(e[9]=n[9]),e[0]=n[0],e[1]=c,e}function bE(e){var n=[];if(e!=null)for(var a in ue(e))n.push(a);return n}function mE(e){return pi.call(e)}function sl(e,n,a){return n=Se(n===i?e.length-1:n,0),function(){for(var u=arguments,c=-1,p=Se(u.length-n,0),E=w(p);++c<p;)E[c]=u[n+c];c=-1;for(var N=w(n+1);++c<n;)N[c]=u[c];return N[n]=a(E),tt(e,this,N)}}function al(e,n){return n.length<2?e:Pn(e,Nt(n,0,-1))}function IE(e,n){for(var a=e.length,u=Ce(n.length,a),c=Ke(e);u--;){var p=n[u];e[u]=jt(p,a)?c[p]:i}return e}function _a(e,n){if(!(n==="constructor"&&typeof e[n]=="function")&&n!="__proto__")return e[n]}var ol=ll(Ou),kr=Cp||function(e,n){return Re.setTimeout(e,n)},ga=ll(qd);function ul(e,n,a){var u=n+"";return ga(e,dE(u,AE(fE(u),a)))}function ll(e){var n=0,a=0;return function(){var u=$p(),c=Hf-(u-a);if(a=u,c>0){if(++n>=Xf)return arguments[0]}else n=0;return e.apply(i,arguments)}}function Fi(e,n){var a=-1,u=e.length,c=u-1;for(n=n===i?u:n;++a<n;){var p=js(a,c),E=e[p];e[p]=e[a],e[a]=E}return e.length=n,e}var cl=TE(function(e){var n=[];return e.charCodeAt(0)===46&&n.push(""),e.replace(ph,function(a,u,c,p){n.push(c?p.replace(bh,"$1"):u||a)}),n});function kt(e){if(typeof e=="string"||it(e))return e;var n=e+"";return n=="0"&&1/e==-wn?"-0":n}function Dn(e){if(e!=null){try{return hi.call(e)}catch{}try{return e+""}catch{}}return""}function AE(e,n){return dt(Qf,function(a){var u="_."+a[0];n&a[1]&&!oi(e,u)&&e.push(u)}),e.sort()}function fl(e){if(e instanceof Z)return e.clone();var n=new _t(e.__wrapped__,e.__chain__);return n.__actions__=Ke(e.__actions__),n.__index__=e.__index__,n.__values__=e.__values__,n}function wE(e,n,a){(a?$e(e,n,a):n===i)?n=1:n=Se(z(n),0);var u=e==null?0:e.length;if(!u||n<1)return[];for(var c=0,p=0,E=w(Ti(u/n));c<u;)E[p++]=Nt(e,c,c+=n);return E}function LE(e){for(var n=-1,a=e==null?0:e.length,u=0,c=[];++n<a;){var p=e[n];p&&(c[u++]=p)}return c}function yE(){var e=arguments.length;if(!e)return[];for(var n=w(e-1),a=arguments[0],u=e;u--;)n[u-1]=arguments[u];return pn(H(a)?Ke(a):[a],De(n,1))}var xE=Y(function(e,n){return Ie(e)?Or(e,De(n,1,Ie,!0)):[]}),SE=Y(function(e,n){var a=Tt(n);return Ie(a)&&(a=i),Ie(e)?Or(e,De(n,1,Ie,!0),B(a,2)):[]}),OE=Y(function(e,n){var a=Tt(n);return Ie(a)&&(a=i),Ie(e)?Or(e,De(n,1,Ie,!0),i,a):[]});function PE(e,n,a){var u=e==null?0:e.length;return u?(n=a||n===i?1:z(n),Nt(e,n<0?0:n,u)):[]}function RE(e,n,a){var u=e==null?0:e.length;return u?(n=a||n===i?1:z(n),n=u-n,Nt(e,0,n<0?0:n)):[]}function DE(e,n){return e&&e.length?Si(e,B(n,3),!0,!0):[]}function ME(e,n){return e&&e.length?Si(e,B(n,3),!0):[]}function UE(e,n,a,u){var c=e==null?0:e.length;return c?(a&&typeof a!="number"&&$e(e,n,a)&&(a=0,u=c),yd(e,n,a,u)):[]}function hl(e,n,a){var u=e==null?0:e.length;if(!u)return-1;var c=a==null?0:z(a);return c<0&&(c=Se(u+c,0)),ui(e,B(n,3),c)}function pl(e,n,a){var u=e==null?0:e.length;if(!u)return-1;var c=u-1;return a!==i&&(c=z(a),c=a<0?Se(u+c,0):Ce(c,u-1)),ui(e,B(n,3),c,!0)}function dl(e){var n=e==null?0:e.length;return n?De(e,1):[]}function kE(e){var n=e==null?0:e.length;return n?De(e,wn):[]}function FE(e,n){var a=e==null?0:e.length;return a?(n=n===i?1:z(n),De(e,n)):[]}function CE(e){for(var n=-1,a=e==null?0:e.length,u={};++n<a;){var c=e[n];u[c[0]]=c[1]}return u}function El(e){return e&&e.length?e[0]:i}function BE(e,n,a){var u=e==null?0:e.length;if(!u)return-1;var c=a==null?0:z(a);return c<0&&(c=Se(u+c,0)),qn(e,n,c)}function GE(e){var n=e==null?0:e.length;return n?Nt(e,0,-1):[]}var VE=Y(function(e){var n=Ee(e,ia);return n.length&&n[0]===e[0]?Ks(n):[]}),$E=Y(function(e){var n=Tt(e),a=Ee(e,ia);return n===Tt(a)?n=i:a.pop(),a.length&&a[0]===e[0]?Ks(a,B(n,2)):[]}),WE=Y(function(e){var n=Tt(e),a=Ee(e,ia);return n=typeof n=="function"?n:i,n&&a.pop(),a.length&&a[0]===e[0]?Ks(a,i,n):[]});function XE(e,n){return e==null?"":Gp.call(e,n)}function Tt(e){var n=e==null?0:e.length;return n?e[n-1]:i}function HE(e,n,a){var u=e==null?0:e.length;if(!u)return-1;var c=u;return a!==i&&(c=z(a),c=c<0?Se(u+c,0):Ce(c,u-1)),n===n?Ap(e,n,c):ui(e,Yo,c,!0)}function qE(e,n){return e&&e.length?Lu(e,z(n)):i}var zE=Y(_l);function _l(e,n){return e&&e.length&&n&&n.length?Zs(e,n):e}function KE(e,n,a){return e&&e.length&&n&&n.length?Zs(e,n,B(a,2)):e}function YE(e,n,a){return e&&e.length&&n&&n.length?Zs(e,n,i,a):e}var JE=Zt(function(e,n){var a=e==null?0:e.length,u=Xs(e,n);return Su(e,Ee(n,function(c){return jt(c,a)?+c:c}).sort(Bu)),u});function QE(e,n){var a=[];if(!(e&&e.length))return a;var u=-1,c=[],p=e.length;for(n=B(n,3);++u<p;){var E=e[u];n(E,u,e)&&(a.push(E),c.push(u))}return Su(e,c),a}function Na(e){return e==null?e:Xp.call(e)}function ZE(e,n,a){var u=e==null?0:e.length;return u?(a&&typeof a!="number"&&$e(e,n,a)?(n=0,a=u):(n=n==null?0:z(n),a=a===i?u:z(a)),Nt(e,n,a)):[]}function jE(e,n){return xi(e,n)}function e_(e,n,a){return ta(e,n,B(a,2))}function t_(e,n){var a=e==null?0:e.length;if(a){var u=xi(e,n);if(u<a&&Lt(e[u],n))return u}return-1}function n_(e,n){return xi(e,n,!0)}function r_(e,n,a){return ta(e,n,B(a,2),!0)}function i_(e,n){var a=e==null?0:e.length;if(a){var u=xi(e,n,!0)-1;if(Lt(e[u],n))return u}return-1}function s_(e){return e&&e.length?Pu(e):[]}function a_(e,n){return e&&e.length?Pu(e,B(n,2)):[]}function o_(e){var n=e==null?0:e.length;return n?Nt(e,1,n):[]}function u_(e,n,a){return e&&e.length?(n=a||n===i?1:z(n),Nt(e,0,n<0?0:n)):[]}function l_(e,n,a){var u=e==null?0:e.length;return u?(n=a||n===i?1:z(n),n=u-n,Nt(e,n<0?0:n,u)):[]}function c_(e,n){return e&&e.length?Si(e,B(n,3),!1,!0):[]}function f_(e,n){return e&&e.length?Si(e,B(n,3)):[]}var h_=Y(function(e){return gn(De(e,1,Ie,!0))}),p_=Y(function(e){var n=Tt(e);return Ie(n)&&(n=i),gn(De(e,1,Ie,!0),B(n,2))}),d_=Y(function(e){var n=Tt(e);return n=typeof n=="function"?n:i,gn(De(e,1,Ie,!0),i,n)});function E_(e){return e&&e.length?gn(e):[]}function __(e,n){return e&&e.length?gn(e,B(n,2)):[]}function g_(e,n){return n=typeof n=="function"?n:i,e&&e.length?gn(e,i,n):[]}function Ta(e){if(!(e&&e.length))return[];var n=0;return e=hn(e,function(a){if(Ie(a))return n=Se(a.length,n),!0}),ks(n,function(a){return Ee(e,Ds(a))})}function gl(e,n){if(!(e&&e.length))return[];var a=Ta(e);return n==null?a:Ee(a,function(u){return tt(n,i,u)})}var N_=Y(function(e,n){return Ie(e)?Or(e,n):[]}),T_=Y(function(e){return ra(hn(e,Ie))}),v_=Y(function(e){var n=Tt(e);return Ie(n)&&(n=i),ra(hn(e,Ie),B(n,2))}),b_=Y(function(e){var n=Tt(e);return n=typeof n=="function"?n:i,ra(hn(e,Ie),i,n)}),m_=Y(Ta);function I_(e,n){return Uu(e||[],n||[],Sr)}function A_(e,n){return Uu(e||[],n||[],Dr)}var w_=Y(function(e){var n=e.length,a=n>1?e[n-1]:i;return a=typeof a=="function"?(e.pop(),a):i,gl(e,a)});function Nl(e){var n=h(e);return n.__chain__=!0,n}function L_(e,n){return n(e),e}function Ci(e,n){return n(e)}var y_=Zt(function(e){var n=e.length,a=n?e[0]:0,u=this.__wrapped__,c=function(p){return Xs(p,e)};return n>1||this.__actions__.length||!(u instanceof Z)||!jt(a)?this.thru(c):(u=u.slice(a,+a+(n?1:0)),u.__actions__.push({func:Ci,args:[c],thisArg:i}),new _t(u,this.__chain__).thru(function(p){return n&&!p.length&&p.push(i),p}))});function x_(){return Nl(this)}function S_(){return new _t(this.value(),this.__chain__)}function O_(){this.__values__===i&&(this.__values__=Rl(this.value()));var e=this.__index__>=this.__values__.length,n=e?i:this.__values__[this.__index__++];return{done:e,value:n}}function P_(){return this}function R_(e){for(var n,a=this;a instanceof Ii;){var u=fl(a);u.__index__=0,u.__values__=i,n?c.__wrapped__=u:n=u;var c=u;a=a.__wrapped__}return c.__wrapped__=e,n}function D_(){var e=this.__wrapped__;if(e instanceof Z){var n=e;return this.__actions__.length&&(n=new Z(this)),n=n.reverse(),n.__actions__.push({func:Ci,args:[Na],thisArg:i}),new _t(n,this.__chain__)}return this.thru(Na)}function M_(){return Mu(this.__wrapped__,this.__actions__)}var U_=Oi(function(e,n,a){oe.call(e,a)?++e[a]:Jt(e,a,1)});function k_(e,n,a){var u=H(e)?zo:Ld;return a&&$e(e,n,a)&&(n=i),u(e,B(n,3))}function F_(e,n){var a=H(e)?hn:gu;return a(e,B(n,3))}var C_=Hu(hl),B_=Hu(pl);function G_(e,n){return De(Bi(e,n),1)}function V_(e,n){return De(Bi(e,n),wn)}function $_(e,n,a){return a=a===i?1:z(a),De(Bi(e,n),a)}function Tl(e,n){var a=H(e)?dt:_n;return a(e,B(n,3))}function vl(e,n){var a=H(e)?op:_u;return a(e,B(n,3))}var W_=Oi(function(e,n,a){oe.call(e,a)?e[a].push(n):Jt(e,a,[n])});function X_(e,n,a,u){e=Ye(e)?e:ir(e),a=a&&!u?z(a):0;var c=e.length;return a<0&&(a=Se(c+a,0)),Xi(e)?a<=c&&e.indexOf(n,a)>-1:!!c&&qn(e,n,a)>-1}var H_=Y(function(e,n,a){var u=-1,c=typeof n=="function",p=Ye(e)?w(e.length):[];return _n(e,function(E){p[++u]=c?tt(n,E,a):Pr(E,n,a)}),p}),q_=Oi(function(e,n,a){Jt(e,a,n)});function Bi(e,n){var a=H(e)?Ee:Iu;return a(e,B(n,3))}function z_(e,n,a,u){return e==null?[]:(H(n)||(n=n==null?[]:[n]),a=u?i:a,H(a)||(a=a==null?[]:[a]),yu(e,n,a))}var K_=Oi(function(e,n,a){e[a?0:1].push(n)},function(){return[[],[]]});function Y_(e,n,a){var u=H(e)?Ps:Qo,c=arguments.length<3;return u(e,B(n,4),a,c,_n)}function J_(e,n,a){var u=H(e)?up:Qo,c=arguments.length<3;return u(e,B(n,4),a,c,_u)}function Q_(e,n){var a=H(e)?hn:gu;return a(e,$i(B(n,3)))}function Z_(e){var n=H(e)?hu:Xd;return n(e)}function j_(e,n,a){(a?$e(e,n,a):n===i)?n=1:n=z(n);var u=H(e)?bd:Hd;return u(e,n)}function eg(e){var n=H(e)?md:zd;return n(e)}function tg(e){if(e==null)return 0;if(Ye(e))return Xi(e)?Kn(e):e.length;var n=Be(e);return n==mt||n==It?e.size:Js(e).length}function ng(e,n,a){var u=H(e)?Rs:Kd;return a&&$e(e,n,a)&&(n=i),u(e,B(n,3))}var rg=Y(function(e,n){if(e==null)return[];var a=n.length;return a>1&&$e(e,n[0],n[1])?n=[]:a>2&&$e(n[0],n[1],n[2])&&(n=[n[0]]),yu(e,De(n,1),[])}),Gi=Fp||function(){return Re.Date.now()};function ig(e,n){if(typeof n!="function")throw new Et(f);return e=z(e),function(){if(--e<1)return n.apply(this,arguments)}}function bl(e,n,a){return n=a?i:n,n=e&&n==null?e.length:n,Qt(e,qt,i,i,i,i,n)}function ml(e,n){var a;if(typeof n!="function")throw new Et(f);return e=z(e),function(){return--e>0&&(a=n.apply(this,arguments)),e<=1&&(n=i),a}}var va=Y(function(e,n,a){var u=j;if(a.length){var c=dn(a,nr(va));u|=ze}return Qt(e,u,n,a,c)}),Il=Y(function(e,n,a){var u=j|de;if(a.length){var c=dn(a,nr(Il));u|=ze}return Qt(n,u,e,a,c)});function Al(e,n,a){n=a?i:n;var u=Qt(e,ht,i,i,i,i,i,n);return u.placeholder=Al.placeholder,u}function wl(e,n,a){n=a?i:n;var u=Qt(e,Rt,i,i,i,i,i,n);return u.placeholder=wl.placeholder,u}function Ll(e,n,a){var u,c,p,E,N,b,x=0,S=!1,O=!1,R=!0;if(typeof e!="function")throw new Et(f);n=vt(n)||0,ge(a)&&(S=!!a.leading,O="maxWait"in a,p=O?Se(vt(a.maxWait)||0,n):p,R="trailing"in a?!!a.trailing:R);function k(Ae){var yt=u,nn=c;return u=c=i,x=Ae,E=e.apply(nn,yt),E}function G(Ae){return x=Ae,N=kr(Q,n),S?k(Ae):E}function K(Ae){var yt=Ae-b,nn=Ae-x,Hl=n-yt;return O?Ce(Hl,p-nn):Hl}function V(Ae){var yt=Ae-b,nn=Ae-x;return b===i||yt>=n||yt<0||O&&nn>=p}function Q(){var Ae=Gi();if(V(Ae))return ee(Ae);N=kr(Q,K(Ae))}function ee(Ae){return N=i,R&&u?k(Ae):(u=c=i,E)}function st(){N!==i&&ku(N),x=0,u=b=c=N=i}function We(){return N===i?E:ee(Gi())}function at(){var Ae=Gi(),yt=V(Ae);if(u=arguments,c=this,b=Ae,yt){if(N===i)return G(b);if(O)return ku(N),N=kr(Q,n),k(b)}return N===i&&(N=kr(Q,n)),E}return at.cancel=st,at.flush=We,at}var sg=Y(function(e,n){return Eu(e,1,n)}),ag=Y(function(e,n,a){return Eu(e,vt(n)||0,a)});function og(e){return Qt(e,fs)}function Vi(e,n){if(typeof e!="function"||n!=null&&typeof n!="function")throw new Et(f);var a=function(){var u=arguments,c=n?n.apply(this,u):u[0],p=a.cache;if(p.has(c))return p.get(c);var E=e.apply(this,u);return a.cache=p.set(c,E)||p,E};return a.cache=new(Vi.Cache||Yt),a}Vi.Cache=Yt;function $i(e){if(typeof e!="function")throw new Et(f);return function(){var n=arguments;switch(n.length){case 0:return!e.call(this);case 1:return!e.call(this,n[0]);case 2:return!e.call(this,n[0],n[1]);case 3:return!e.call(this,n[0],n[1],n[2])}return!e.apply(this,n)}}function ug(e){return ml(2,e)}var lg=Yd(function(e,n){n=n.length==1&&H(n[0])?Ee(n[0],nt(B())):Ee(De(n,1),nt(B()));var a=n.length;return Y(function(u){for(var c=-1,p=Ce(u.length,a);++c<p;)u[c]=n[c].call(this,u[c]);return tt(e,this,u)})}),ba=Y(function(e,n){var a=dn(n,nr(ba));return Qt(e,ze,i,n,a)}),yl=Y(function(e,n){var a=dn(n,nr(yl));return Qt(e,dr,i,n,a)}),cg=Zt(function(e,n){return Qt(e,Er,i,i,i,n)});function fg(e,n){if(typeof e!="function")throw new Et(f);return n=n===i?n:z(n),Y(e,n)}function hg(e,n){if(typeof e!="function")throw new Et(f);return n=n==null?0:Se(z(n),0),Y(function(a){var u=a[n],c=Tn(a,0,n);return u&&pn(c,u),tt(e,this,c)})}function pg(e,n,a){var u=!0,c=!0;if(typeof e!="function")throw new Et(f);return ge(a)&&(u="leading"in a?!!a.leading:u,c="trailing"in a?!!a.trailing:c),Ll(e,n,{leading:u,maxWait:n,trailing:c})}function dg(e){return bl(e,1)}function Eg(e,n){return ba(sa(n),e)}function _g(){if(!arguments.length)return[];var e=arguments[0];return H(e)?e:[e]}function gg(e){return gt(e,J)}function Ng(e,n){return n=typeof n=="function"?n:i,gt(e,J,n)}function Tg(e){return gt(e,y|J)}function vg(e,n){return n=typeof n=="function"?n:i,gt(e,y|J,n)}function bg(e,n){return n==null||du(e,n,Oe(n))}function Lt(e,n){return e===n||e!==e&&n!==n}var mg=Mi(zs),Ig=Mi(function(e,n){return e>=n}),Mn=vu(function(){return arguments}())?vu:function(e){return ve(e)&&oe.call(e,"callee")&&!au.call(e,"callee")},H=w.isArray,Ag=Vo?nt(Vo):Rd;function Ye(e){return e!=null&&Wi(e.length)&&!en(e)}function Ie(e){return ve(e)&&Ye(e)}function wg(e){return e===!0||e===!1||ve(e)&&Ve(e)==_r}var vn=Bp||Ra,Lg=$o?nt($o):Dd;function yg(e){return ve(e)&&e.nodeType===1&&!Fr(e)}function xg(e){if(e==null)return!0;if(Ye(e)&&(H(e)||typeof e=="string"||typeof e.splice=="function"||vn(e)||rr(e)||Mn(e)))return!e.length;var n=Be(e);if(n==mt||n==It)return!e.size;if(Ur(e))return!Js(e).length;for(var a in e)if(oe.call(e,a))return!1;return!0}function Sg(e,n){return Rr(e,n)}function Og(e,n,a){a=typeof a=="function"?a:i;var u=a?a(e,n):i;return u===i?Rr(e,n,i,a):!!u}function ma(e){if(!ve(e))return!1;var n=Ve(e);return n==ti||n==jf||typeof e.message=="string"&&typeof e.name=="string"&&!Fr(e)}function Pg(e){return typeof e=="number"&&uu(e)}function en(e){if(!ge(e))return!1;var n=Ve(e);return n==ni||n==Eo||n==Zf||n==th}function xl(e){return typeof e=="number"&&e==z(e)}function Wi(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=fn}function ge(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}function ve(e){return e!=null&&typeof e=="object"}var Sl=Wo?nt(Wo):Ud;function Rg(e,n){return e===n||Ys(e,n,ha(n))}function Dg(e,n,a){return a=typeof a=="function"?a:i,Ys(e,n,ha(n),a)}function Mg(e){return Ol(e)&&e!=+e}function Ug(e){if(NE(e))throw new X(l);return bu(e)}function kg(e){return e===null}function Fg(e){return e==null}function Ol(e){return typeof e=="number"||ve(e)&&Ve(e)==Nr}function Fr(e){if(!ve(e)||Ve(e)!=zt)return!1;var n=_i(e);if(n===null)return!0;var a=oe.call(n,"constructor")&&n.constructor;return typeof a=="function"&&a instanceof a&&hi.call(a)==Dp}var Ia=Xo?nt(Xo):kd;function Cg(e){return xl(e)&&e>=-fn&&e<=fn}var Pl=Ho?nt(Ho):Fd;function Xi(e){return typeof e=="string"||!H(e)&&ve(e)&&Ve(e)==vr}function it(e){return typeof e=="symbol"||ve(e)&&Ve(e)==ri}var rr=qo?nt(qo):Cd;function Bg(e){return e===i}function Gg(e){return ve(e)&&Be(e)==br}function Vg(e){return ve(e)&&Ve(e)==rh}var $g=Mi(Qs),Wg=Mi(function(e,n){return e<=n});function Rl(e){if(!e)return[];if(Ye(e))return Xi(e)?At(e):Ke(e);if(Ar&&e[Ar])return bp(e[Ar]());var n=Be(e),a=n==mt?Cs:n==It?li:ir;return a(e)}function tn(e){if(!e)return e===0?e:0;if(e=vt(e),e===wn||e===-wn){var n=e<0?-1:1;return n*Kf}return e===e?e:0}function z(e){var n=tn(e),a=n%1;return n===n?a?n-a:n:0}function Dl(e){return e?On(z(e),0,Dt):0}function vt(e){if(typeof e=="number")return e;if(it(e))return jr;if(ge(e)){var n=typeof e.valueOf=="function"?e.valueOf():e;e=ge(n)?n+"":n}if(typeof e!="string")return e===0?e:+e;e=Zo(e);var a=Ah.test(e);return a||Lh.test(e)?ip(e.slice(2),a?2:8):Ih.test(e)?jr:+e}function Ml(e){return Ut(e,Je(e))}function Xg(e){return e?On(z(e),-fn,fn):e===0?e:0}function ae(e){return e==null?"":rt(e)}var Hg=er(function(e,n){if(Ur(n)||Ye(n)){Ut(n,Oe(n),e);return}for(var a in n)oe.call(n,a)&&Sr(e,a,n[a])}),Ul=er(function(e,n){Ut(n,Je(n),e)}),Hi=er(function(e,n,a,u){Ut(n,Je(n),e,u)}),qg=er(function(e,n,a,u){Ut(n,Oe(n),e,u)}),zg=Zt(Xs);function Kg(e,n){var a=jn(e);return n==null?a:pu(a,n)}var Yg=Y(function(e,n){e=ue(e);var a=-1,u=n.length,c=u>2?n[2]:i;for(c&&$e(n[0],n[1],c)&&(u=1);++a<u;)for(var p=n[a],E=Je(p),N=-1,b=E.length;++N<b;){var x=E[N],S=e[x];(S===i||Lt(S,Jn[x])&&!oe.call(e,x))&&(e[x]=p[x])}return e}),Jg=Y(function(e){return e.push(i,Zu),tt(kl,i,e)});function Qg(e,n){return Ko(e,B(n,3),Mt)}function Zg(e,n){return Ko(e,B(n,3),qs)}function jg(e,n){return e==null?e:Hs(e,B(n,3),Je)}function eN(e,n){return e==null?e:Nu(e,B(n,3),Je)}function tN(e,n){return e&&Mt(e,B(n,3))}function nN(e,n){return e&&qs(e,B(n,3))}function rN(e){return e==null?[]:Li(e,Oe(e))}function iN(e){return e==null?[]:Li(e,Je(e))}function Aa(e,n,a){var u=e==null?i:Pn(e,n);return u===i?a:u}function sN(e,n){return e!=null&&tl(e,n,xd)}function wa(e,n){return e!=null&&tl(e,n,Sd)}var aN=zu(function(e,n,a){n!=null&&typeof n.toString!="function"&&(n=pi.call(n)),e[n]=a},ya(Qe)),oN=zu(function(e,n,a){n!=null&&typeof n.toString!="function"&&(n=pi.call(n)),oe.call(e,n)?e[n].push(a):e[n]=[a]},B),uN=Y(Pr);function Oe(e){return Ye(e)?fu(e):Js(e)}function Je(e){return Ye(e)?fu(e,!0):Bd(e)}function lN(e,n){var a={};return n=B(n,3),Mt(e,function(u,c,p){Jt(a,n(u,c,p),u)}),a}function cN(e,n){var a={};return n=B(n,3),Mt(e,function(u,c,p){Jt(a,c,n(u,c,p))}),a}var fN=er(function(e,n,a){yi(e,n,a)}),kl=er(function(e,n,a,u){yi(e,n,a,u)}),hN=Zt(function(e,n){var a={};if(e==null)return a;var u=!1;n=Ee(n,function(p){return p=Nn(p,e),u||(u=p.length>1),p}),Ut(e,ca(e),a),u&&(a=gt(a,y|$|J,aE));for(var c=n.length;c--;)na(a,n[c]);return a});function pN(e,n){return Fl(e,$i(B(n)))}var dN=Zt(function(e,n){return e==null?{}:Vd(e,n)});function Fl(e,n){if(e==null)return{};var a=Ee(ca(e),function(u){return[u]});return n=B(n),xu(e,a,function(u,c){return n(u,c[0])})}function EN(e,n,a){n=Nn(n,e);var u=-1,c=n.length;for(c||(c=1,e=i);++u<c;){var p=e==null?i:e[kt(n[u])];p===i&&(u=c,p=a),e=en(p)?p.call(e):p}return e}function _N(e,n,a){return e==null?e:Dr(e,n,a)}function gN(e,n,a,u){return u=typeof u=="function"?u:i,e==null?e:Dr(e,n,a,u)}var Cl=Ju(Oe),Bl=Ju(Je);function NN(e,n,a){var u=H(e),c=u||vn(e)||rr(e);if(n=B(n,4),a==null){var p=e&&e.constructor;c?a=u?new p:[]:ge(e)?a=en(p)?jn(_i(e)):{}:a={}}return(c?dt:Mt)(e,function(E,N,b){return n(a,E,N,b)}),a}function TN(e,n){return e==null?!0:na(e,n)}function vN(e,n,a){return e==null?e:Du(e,n,sa(a))}function bN(e,n,a,u){return u=typeof u=="function"?u:i,e==null?e:Du(e,n,sa(a),u)}function ir(e){return e==null?[]:Fs(e,Oe(e))}function mN(e){return e==null?[]:Fs(e,Je(e))}function IN(e,n,a){return a===i&&(a=n,n=i),a!==i&&(a=vt(a),a=a===a?a:0),n!==i&&(n=vt(n),n=n===n?n:0),On(vt(e),n,a)}function AN(e,n,a){return n=tn(n),a===i?(a=n,n=0):a=tn(a),e=vt(e),Od(e,n,a)}function wN(e,n,a){if(a&&typeof a!="boolean"&&$e(e,n,a)&&(n=a=i),a===i&&(typeof n=="boolean"?(a=n,n=i):typeof e=="boolean"&&(a=e,e=i)),e===i&&n===i?(e=0,n=1):(e=tn(e),n===i?(n=e,e=0):n=tn(n)),e>n){var u=e;e=n,n=u}if(a||e%1||n%1){var c=lu();return Ce(e+c*(n-e+rp("1e-"+((c+"").length-1))),n)}return js(e,n)}var LN=tr(function(e,n,a){return n=n.toLowerCase(),e+(a?Gl(n):n)});function Gl(e){return La(ae(e).toLowerCase())}function Vl(e){return e=ae(e),e&&e.replace(xh,_p).replace(zh,"")}function yN(e,n,a){e=ae(e),n=rt(n);var u=e.length;a=a===i?u:On(z(a),0,u);var c=a;return a-=n.length,a>=0&&e.slice(a,c)==n}function xN(e){return e=ae(e),e&&uh.test(e)?e.replace(No,gp):e}function SN(e){return e=ae(e),e&&dh.test(e)?e.replace(bs,"\\$&"):e}var ON=tr(function(e,n,a){return e+(a?"-":"")+n.toLowerCase()}),PN=tr(function(e,n,a){return e+(a?" ":"")+n.toLowerCase()}),RN=Xu("toLowerCase");function DN(e,n,a){e=ae(e),n=z(n);var u=n?Kn(e):0;if(!n||u>=n)return e;var c=(n-u)/2;return Di(vi(c),a)+e+Di(Ti(c),a)}function MN(e,n,a){e=ae(e),n=z(n);var u=n?Kn(e):0;return n&&u<n?e+Di(n-u,a):e}function UN(e,n,a){e=ae(e),n=z(n);var u=n?Kn(e):0;return n&&u<n?Di(n-u,a)+e:e}function kN(e,n,a){return a||n==null?n=0:n&&(n=+n),Wp(ae(e).replace(ms,""),n||0)}function FN(e,n,a){return(a?$e(e,n,a):n===i)?n=1:n=z(n),ea(ae(e),n)}function CN(){var e=arguments,n=ae(e[0]);return e.length<3?n:n.replace(e[1],e[2])}var BN=tr(function(e,n,a){return e+(a?"_":"")+n.toLowerCase()});function GN(e,n,a){return a&&typeof a!="number"&&$e(e,n,a)&&(n=a=i),a=a===i?Dt:a>>>0,a?(e=ae(e),e&&(typeof n=="string"||n!=null&&!Ia(n))&&(n=rt(n),!n&&zn(e))?Tn(At(e),0,a):e.split(n,a)):[]}var VN=tr(function(e,n,a){return e+(a?" ":"")+La(n)});function $N(e,n,a){return e=ae(e),a=a==null?0:On(z(a),0,e.length),n=rt(n),e.slice(a,a+n.length)==n}function WN(e,n,a){var u=h.templateSettings;a&&$e(e,n,a)&&(n=i),e=ae(e),n=Hi({},n,u,Qu);var c=Hi({},n.imports,u.imports,Qu),p=Oe(c),E=Fs(c,p),N,b,x=0,S=n.interpolate||ii,O="__p += '",R=Bs((n.escape||ii).source+"|"+S.source+"|"+(S===To?mh:ii).source+"|"+(n.evaluate||ii).source+"|$","g"),k="//# sourceURL="+(oe.call(n,"sourceURL")?(n.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Zh+"]")+`
|
|
12
|
-
`;
|
|
13
|
-
__e(`+
|
|
14
|
-
'`),
|
|
15
|
-
`+
|
|
16
|
-
__p += '`),
|
|
17
|
-
((__t = (`+
|
|
18
|
-
'`),x=
|
|
19
|
-
`;var
|
|
20
|
-
`+
|
|
9
|
+
`;case"\\":return"\\";case"r":return"\r";case"'":return"'";case'"':return'"';case"`":return"`";case"0":return"\0";case"b":return"\b";case"v":return"\v";case"f":return"\f";case" ":return"\\ ";case"u":{let n="";for(let i=0;i<=3;i+=1){if(this.isAtEnd()||!yr(this.peek()))return this.errors.push(new v(N.INVALID_ESCAPE_SEQUENCE,`Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`,Tt.create(I.STRING_LITERAL,e,this.current,`\\u${n}`,!0))),`\\u${n}`;n+=this.advance()}return String.fromCharCode(parseInt(n,16))}default:return this.text[this.current.offset-1]}}}var Ea=(t=>(t[t.ListExpression=0]="ListExpression",t[t.GroupExpression=1]="GroupExpression",t[t.BlockExpression=2]="BlockExpression",t))(Ea||{});class rS{constructor(){this.stack=[],this.numberOfNestedLParens=0,this.numberOfNestedLBrackets=0,this.numberOfNestedLBraces=0}push(e){this.stack.push(e),e===0&&(this.numberOfNestedLBrackets+=1),e===1&&(this.numberOfNestedLParens+=1),e===2&&(this.numberOfNestedLBraces+=1)}pop(){const e=this.stack.pop();return e===0&&(this.numberOfNestedLBrackets-=1),e===1&&(this.numberOfNestedLParens-=1),e===2&&(this.numberOfNestedLBraces-=1),e}top(){return Oe(this.stack)}isWithinGroupExpressionContext(){return this.numberOfNestedLParens>0}isWithinListExpressionContext(){return this.numberOfNestedLBrackets>0}isWithinBlockExpressionContext(){return this.numberOfNestedLBraces>0}withContextDo(e,n){return()=>{this.push(e);try{return n()}finally{this.pop()}}}findHandlerContext(e,n){if(!(this.numberOfNestedLBraces<=0&&this.numberOfNestedLBrackets<=0&&this.numberOfNestedLParens<=0))for(let i=n;i<e.length-1;i+=1)switch(e[i].kind){case I.COMMA:if(this.isWithinGroupExpressionContext()||this.isWithinListExpressionContext())return[...this.stack].reverse().find(u=>[1,0].includes(u));break;case I.RPAREN:if(this.isWithinGroupExpressionContext())return 1;break;case I.RBRACE:if(this.isWithinBlockExpressionContext())return 2;break;case I.RBRACKET:if(this.isWithinListExpressionContext())return 0;break}}}class iS{constructor(e){this.generator=e}create(e,n){return new e(n,this.generator.nextId())}}class B{constructor(e,n,i){this.token=e,this.partialNode=n,this.handlerContext=i}}class sS{constructor(e,n,i){this.current=0,this.errors=[],this.contextStack=new rS,this.synchronizeProgram=()=>{const a=this.peek();a.kind!==I.EOF?W(this.advance()):this.logError(a,N.UNEXPECTED_EOF,"Unexpected EOF")},this.synchronizeElementDeclarationName=()=>{for(;!this.isAtEnd();){const a=this.peek();if(Zu(a)||this.check(I.COLON,I.LBRACE,I.LBRACKET))break;W(a),this.advance()}},this.synchronizeElementDeclarationAlias=()=>{for(;!this.isAtEnd();){const a=this.peek();if(this.check(I.COLON,I.LBRACE,I.LBRACKET))break;W(a),this.advance()}},this.blockExpression=this.contextStack.withContextDo(Ea.BlockExpression,()=>{const a={body:[]},u=()=>this.nodeFactory.create(Ge,a);try{this.consume("Expect an opening brace '{'",I.LBRACE),a.blockOpenBrace=this.previous()}catch(l){if(!(l instanceof B))throw l;if(!this.canHandle(l))throw new B(l.token,u(),l.handlerContext);this.synchronizeBlock()}for(;!this.isAtEnd()&&!this.check(I.RBRACE);)try{a.body.push(this.canBeField()?this.fieldDeclaration():this.expression())}catch(l){if(!(l instanceof B))throw l;if(a.body.push(l.partialNode),!this.canHandle(l))throw new B(l.token,u(),l.handlerContext);this.synchronizeBlock()}try{this.consume("Expect a closing brace '}'",I.RBRACE),a.blockCloseBrace=this.previous()}catch(l){if(!(l instanceof B))throw l;if(!this.canHandle(l))throw new B(l.token,u(),l.handlerContext);this.synchronizeBlock()}return u()}),this.synchronizeBlock=()=>{if(!this.check(I.RBRACE))for(W(this.advance());!this.isAtEnd();){const a=this.peek();if(this.check(I.RBRACE)||hd(this.previous(),a))break;W(a),this.advance()}},this.tupleExpression=this.contextStack.withContextDo(Ea.GroupExpression,()=>{const a={elementList:[],commaList:[]},u=()=>this.nodeFactory.create(Sl,{groupOpenParen:a.tupleOpenParen,groupCloseParen:a.tupleCloseParen,expression:a.elementList[0]}),l=()=>this.nodeFactory.create(ln,a);try{this.consume("Expect an opening parenthesis '('",I.LPAREN),a.tupleOpenParen=this.previous()}catch(f){if(!(f instanceof B))throw f;if(!this.canHandle(f))throw new B(f.token,l(),f.handlerContext);this.synchronizeTuple()}if(!this.isAtEnd()&&!this.check(I.RPAREN))try{a.elementList.push(this.normalExpression())}catch(f){if(!(f instanceof B))throw f;if(a.elementList.push(f.partialNode),!this.canHandle(f))throw new B(f.token,u(),f.handlerContext);this.synchronizeTuple()}for(;!this.isAtEnd()&&!this.check(I.RPAREN);)try{this.consume("Expect a comma ','",I.COMMA),a.commaList.push(this.previous()),a.elementList.push(this.normalExpression())}catch(f){if(!(f instanceof B))throw f;if(f.partialNode instanceof xe&&a.elementList.push(f.partialNode),!this.canHandle(f))throw new B(f.token,l(),f.handlerContext);this.synchronizeTuple()}try{this.consume("Expect a closing parenthesis ')'",I.RPAREN),a.tupleCloseParen=this.previous()}catch(f){if(!(f instanceof B))throw f;if(!this.canHandle(f))throw new B(f.token,l(),f.handlerContext);this.synchronizeTuple()}return a.elementList.length===1?u():l()}),this.synchronizeTuple=()=>{for(;!this.isAtEnd();){const a=this.peek();if(this.check(I.RPAREN,I.COMMA))break;W(a),this.advance()}},this.listExpression=this.contextStack.withContextDo(Ea.ListExpression,()=>{const a={elementList:[],commaList:[]},u=()=>this.nodeFactory.create(Le,a);try{this.consume("Expect an opening bracket '['",I.LBRACKET),a.listOpenBracket=this.previous()}catch(l){if(!(l instanceof B))throw l;if(!this.canHandle(l))throw new B(l.token,u(),l.handlerContext);this.synchronizeList()}if(!this.isAtEnd()&&!this.check(I.RBRACKET))try{a.elementList.push(this.attribute())}catch(l){if(!(l instanceof B))throw l;if(a.elementList.push(l.partialNode),!this.canHandle(l))throw new B(l.token,u(),l.handlerContext);this.synchronizeList()}for(;!this.isAtEnd()&&!this.check(I.RBRACKET);)try{this.consume("Expect a comma ','",I.COMMA),a.commaList.push(this.previous()),a.elementList.push(this.attribute())}catch(l){if(!(l instanceof B))throw l;if(l.partialNode instanceof xe&&a.elementList.push(l.partialNode),!this.canHandle(l))throw new B(l.token,u(),l.handlerContext);this.synchronizeList()}try{this.consume("Expect a closing bracket ']'",I.RBRACKET),a.listCloseBracket=this.previous()}catch(l){if(!(l instanceof B))throw l;if(!this.canHandle(l))throw new B(l.token,u(),l.handlerContext);this.synchronizeList()}return u()}),this.synchronizeList=()=>{for(;!this.isAtEnd();){const a=this.peek();if(this.check(I.COMMA,I.RBRACKET))break;W(a),this.advance()}},this.synchronizeAttributeName=()=>{for(;!this.isAtEnd();){const a=this.peek();if(this.check(I.COMMA,I.RBRACKET,I.COLON))break;W(a),this.advance()}},this.synchronizeAttributeValue=()=>{for(;!this.isAtEnd();){const a=this.peek();if(this.check(I.COMMA,I.RBRACKET))break;W(a),this.advance()}},this.source=e,this.tokens=n,this.nodeFactory=new iS(i)}isAtEnd(){return this.current>=this.tokens.length||this.tokens[this.current].kind===I.EOF}advance(){return this.isAtEnd()?Oe(this.tokens):this.tokens[this.current++]}peek(e=0){return e+this.current>=this.tokens.length?Oe(this.tokens):this.tokens[this.current+e]}match(...e){const n=this.check(...e);return n&&this.advance(),n}check(...e){const n=this.peek();return e.includes(n.kind)}previous(){return this.tokens[this.current-1]}canHandle(e){return e.handlerContext===void 0||e.handlerContext===this.contextStack.top()}consume(e,...n){if(!this.match(...n))throw this.logError(this.peek(),N.UNEXPECTED_TOKEN,e),new B(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}discardUntil(e,...n){if(this.isAtEnd()||!this.check(...n)){for(W(this.peek()),this.logError(this.advance(),N.UNEXPECTED_TOKEN,e);!this.isAtEnd()&&!this.check(...n);)W(this.advance());return!this.isAtEnd()}return!0}gatherInvalid(){const e=[],n=[];let i,a=0;for(;a<this.tokens.length&&this.tokens[a].isInvalid;a+=1)n.push(this.tokens[a]);for(i=this.tokens[a],i.leadingInvalid=[...n,...i.leadingInvalid],e.push(i),a+=1;a<this.tokens.length;a+=1){const u=this.tokens[a];u.isInvalid?i.trailingInvalid.push(u):(i=u,e.push(i))}this.tokens=e}parse(){const e=this.program(),n=this.advance(),i=this.nodeFactory.create(Ze,{body:e,eof:n,source:this.source});return this.gatherInvalid(),new ue({ast:i,tokens:this.tokens},this.errors)}program(){const e=[];for(;!this.isAtEnd();)try{const n=this.elementDeclaration();e.push(n)}catch(n){if(!(n instanceof B))throw n;e.push(n.partialNode),this.synchronizeProgram()}return e}elementDeclaration(){const e={},n=()=>this.nodeFactory.create(re,e);try{this.consume("Expect an identifier",I.IDENTIFIER),e.type=this.previous()}catch(i){throw i instanceof B?new B(i.token,n(),i.handlerContext):i}if(!this.check(I.COLON,I.LBRACE,I.LBRACKET))try{e.name=this.normalExpression()}catch(i){if(!(i instanceof B))throw i;if(e.name=i.partialNode,!this.canHandle(i))throw new B(i.token,n(),i.handlerContext);this.synchronizeElementDeclarationName()}if(Zu(this.peek()))if(e.as=this.advance(),this.check(I.COLON,I.LBRACE,I.LBRACKET))this.logError(this.peek(),N.UNEXPECTED_TOKEN,"Expect an alias");else try{e.alias=this.normalExpression()}catch(i){if(!(i instanceof B))throw i;if(e.alias=i.partialNode,!this.canHandle(i))throw new B(i.token,n(),i.handlerContext);this.synchronizeElementDeclarationAlias()}try{e.attributeList=this.check(I.LBRACKET)?this.listExpression():void 0}catch(i){throw i instanceof B?(e.attributeList=i.partialNode,new B(i.token,n(),i.handlerContext)):i}if(!this.discardUntil("Expect an opening brace '{' or a colon ':'",I.LBRACE,I.COLON))return n();try{if(this.match(I.COLON)){e.bodyColon=this.previous();const i=this.expression();i instanceof re?(W(i),this.logError(i,N.UNEXPECTED_ELEMENT_DECLARATION,"An element's simple body must not be an element declaration")):e.body=i}else e.body=this.blockExpression()}catch(i){throw i instanceof B?(e.body=i.partialNode,new B(i.token,n(),i.handlerContext)):i}return this.nodeFactory.create(re,e)}fieldDeclaration(){const e={},n=()=>this.nodeFactory.create(re,e);try{this.consume("Expect an identifier",I.IDENTIFIER),e.type=this.previous()}catch(i){throw i instanceof B?(e.type=i.partialNode,new B(i.token,n(),i.handlerContext)):i}try{this.consume("Expect a colon ':'",I.COLON),e.bodyColon=this.previous()}catch(i){throw i instanceof B?(e.bodyColon=i.partialNode,new B(i.token,n(),i.handlerContext)):i}try{const i=this.expression();i instanceof re?this.errors.push(new v(N.INVALID_ELEMENT_IN_SIMPLE_BODY,"Simple body cannot be an element declaration",i)):e.body=i}catch(i){throw i instanceof B?(e.body=i.partialNode,new B(i.token,n(),i.handlerContext)):i}return this.nodeFactory.create(re,e)}expression(){const e={args:[]},n=()=>jL(e.callee,e.args,this.nodeFactory).unwrap_or(this.nodeFactory.create(z,e));try{e.callee=this.commaExpression()}catch(a){throw a instanceof B?(e.callee=a.partialNode,new B(a.token,n(),a.handlerContext)):a}if(this.shouldStopFunctionApplication())return n();let i=e.callee;for(;!this.shouldStopFunctionApplication();){Xu(this.previous())||this.logError(i,N.MISSING_SPACES,"Expect a following space");try{i=this.commaExpression(),e.args.push(i)}catch(a){throw a instanceof B?(i=a.partialNode,e.args.push(i),new B(a.token,n(),a.handlerContext)):a}}return n()}shouldStopFunctionApplication(){if(this.isAtEnd()||qu(this.previous()))return!0;const e=this.peek().kind;return[I.RBRACE,I.RBRACKET,I.RPAREN,I.COMMA,I.COLON].includes(e)}commaExpression(){const e=this.check(I.COMMA)?this.nodeFactory.create(gn,{prevToken:this.previous()}):this.normalExpression();if(!this.check(I.COMMA))return e;const n={elementList:[e],commaList:[]};do{if(n.commaList.push(this.advance()),this.shouldStopCommaExpression()){n.elementList.push(this.nodeFactory.create(gn,{prevToken:this.previous()}));break}if(this.check(I.COMMA)){n.elementList.push(this.nodeFactory.create(gn,{prevToken:this.previous()}));continue}try{const i=this.normalExpression();n.elementList.push(i)}catch(i){throw i instanceof B?(i.partialNode&&n.elementList.push(i.partialNode),new B(i.token,this.nodeFactory.create(Fn,n),i.handlerContext)):i}}while(!this.shouldStopCommaExpression()&&this.check(I.COMMA));return this.nodeFactory.create(Fn,n)}shouldStopCommaExpression(){if(this.isAtEnd()||qu(this.previous()))return!0;const e=this.peek().kind;return[I.RBRACE,I.LBRACE,I.RBRACKET,I.LBRACKET,I.RPAREN,I.LPAREN,I.COLON].includes(e)}normalExpression(){return this.expression_bp(0)}expression_bp(e){let n=this.leftExpression_bp();for(;!this.isAtEnd();){const i=this.peek();if(i.kind===I.LPAREN){const{left:a}=gd(i);if(a<e||hd(this.previous(),i)&&!this.contextStack.isWithinGroupExpressionContext()&&!this.contextStack.isWithinListExpressionContext())break;try{n=this.nodeFactory.create(Se,{callee:n,argumentList:this.tupleExpression()})}catch(u){throw u instanceof B?(n=this.nodeFactory.create(Se,{callee:n,argumentList:u.partialNode}),new B(u.token,n,u.handlerContext)):u}}else if(i.kind===I.LBRACKET){if(Xu(this.previous()))break;try{n=this.nodeFactory.create(Tn,{expression:n,indexer:this.listExpression()})}catch(a){throw a instanceof B?(n=this.nodeFactory.create(Tn,{expression:n,indexer:a.partialNode}),new B(a.token,n,a.handlerContext)):a}}else if(fd(i)){const a=i,u=gd(a);if(u.left!==null){if(u.left<=e)break;this.advance(),n=this.nodeFactory.create(Ga,{expression:n,op:a})}else{const l=oS(a);if(l.left===null||l.left<=e)break;this.advance();try{n=this.nodeFactory.create(on,{leftExpression:n,op:a,rightExpression:a.value==="."?this.extractOperand():this.expression_bp(l.right)})}catch(f){throw f instanceof B?(n=this.nodeFactory.create(on,{leftExpression:n,op:a,rightExpression:f.partialNode}),new B(f.token,n,f.handlerContext)):f}}}else break}return n}leftExpression_bp(){let e;if(fd(this.peek())){const n={};n.op=this.peek();const i=lS(n.op);if(i.right===null)throw this.logError(n.op,N.UNKNOWN_PREFIX_OP,`Unexpected '${n.op.value}' in an expression`),new B(n.op,this.nodeFactory.create(gn,{prevToken:n.op}),this.contextStack.findHandlerContext(this.tokens,this.current));this.advance();try{n.expression=this.expression_bp(i.right)}catch(a){throw a instanceof B?(n.expression=a.partialNode,new B(a.token,this.nodeFactory.create(ft,n),a.handlerContext)):a}e=this.nodeFactory.create(ft,n)}else if(e=this.extractOperand(),e instanceof gn)throw new B(this.peek(),this.nodeFactory.create(gn,{prevToken:this.peek()}),this.contextStack.findHandlerContext(this.tokens,this.current));return e}extractOperand(){return this.check(I.NUMERIC_LITERAL,I.STRING_LITERAL,I.COLOR_LITERAL,I.QUOTED_STRING,I.IDENTIFIER)?this.primaryExpression():this.check(I.FUNCTION_EXPRESSION)?this.functionExpression():this.check(I.LBRACKET)?this.listExpression():this.check(I.LBRACE)?this.blockExpression():this.check(I.LPAREN)?this.tupleExpression():(this.peek().kind===I.EOF?this.logError(this.peek(),N.UNEXPECTED_EOF,"Unexpected EOF"):this.logError(this.peek(),N.INVALID_OPERAND,`Invalid start of operand "${this.peek().value}"`),this.nodeFactory.create(gn,{prevToken:this.previous()}))}functionExpression(){const e={};try{this.consume("Expect a function expression",I.FUNCTION_EXPRESSION),e.value=this.previous()}catch(n){throw n instanceof B?new B(n.token,this.nodeFactory.create(st,e),n.handlerContext):n}return this.nodeFactory.create(st,e)}canBeField(){return this.peek().kind===I.IDENTIFIER&&this.peek(1).kind===I.COLON}primaryExpression(){if(this.match(I.COLOR_LITERAL,I.STRING_LITERAL,I.NUMERIC_LITERAL))return this.nodeFactory.create(yt,{expression:this.nodeFactory.create(Rr,{literal:this.previous()})});if(this.match(I.QUOTED_STRING,I.IDENTIFIER))return this.nodeFactory.create(yt,{expression:this.nodeFactory.create(Wn,{variable:this.previous()})});throw this.logError(this.peek(),N.UNEXPECTED_TOKEN,"Expect a variable or literal"),new B(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}attribute(){const e={};if(this.check(I.COLON,I.RBRACKET,I.COMMA)){const n=this.peek();this.logError(n,N.EMPTY_ATTRIBUTE_NAME,"Expect a non-empty attribute name"),e.name=this.nodeFactory.create(rn,{identifiers:[]})}else try{e.name=this.attributeName()}catch(n){if(!(n instanceof B))throw n;if(e.name=n.partialNode,!this.canHandle(n))throw new B(n.token,this.nodeFactory.create(sn,e),n.handlerContext);this.synchronizeAttributeName()}return this.match(I.COLON)&&(e.colon=this.previous(),e.value=this.attributeValue()),this.nodeFactory.create(sn,e)}attributeValue(){let e;try{e=this.peek().kind===I.IDENTIFIER&&this.peek(1).kind===I.IDENTIFIER?this.attributeName():this.normalExpression()}catch(n){if(!(n instanceof B)||!this.canHandle(n))throw n;e=n.partialNode,this.synchronizeAttributeValue()}return e}attributeName(){const e=[];if(this.peek().kind!==I.IDENTIFIER)return this.primaryExpression();for(;!this.isAtEnd()&&!this.check(I.COLON,I.COMMA,I.RBRACKET);)try{this.consume("Expect an identifier",I.IDENTIFIER),e.push(this.previous())}catch(n){throw n instanceof B?new B(n.token,this.nodeFactory.create(rn,{identifiers:e}),n.handlerContext):n}return this.nodeFactory.create(rn,{identifiers:e})}logError(e,n,i){this.errors.push(new v(n,i,e))}}const aS={"+":{left:9,right:10},"*":{left:11,right:12},"-":{left:9,right:10},"/":{left:11,right:12},"%":{left:11,right:12},"<":{left:7,right:8},"<=":{left:7,right:8},">":{left:7,right:8},">=":{left:7,right:8},"<>":{left:7,right:8},"=":{left:2,right:3},"==":{left:4,right:5},"!=":{left:4,right:5},".":{left:16,right:17}};function oS(t){return aS[t.value]||{left:null,right:null}}const uS={"+":{left:null,right:15},"-":{left:null,right:15},"<":{left:null,right:15},">":{left:null,right:15},"<>":{left:null,right:15},"!":{left:null,right:15},"~":{left:null,right:15}};function lS(t){return uS[t.value]||{left:null,right:null}}const cS={"(":{left:14,right:null}};function gd(t){return cS[t.value]||{left:null,right:null}}class Ed{constructor(e,n){this.ast=e,this.symbolFactory=n,this.publicSchemaSymbol=this.symbolFactory.create(xl,{symbolTable:new Sr}),this.ast.symbol=this.publicSchemaSymbol,this.ast.symbol.declaration=this.ast}validate(){const e=[];this.ast.body.forEach(i=>{if(i.parent=this.ast,i.type===void 0)return;const a=cn(i),u=new a(i,this.publicSchemaSymbol.symbolTable,this.symbolFactory);e.push(...u.validate())});const n=this.ast.body.filter(i=>dt(i).unwrap_or(void 0)===U.Project);return n.length>1&&n.forEach(i=>e.push(new v(N.PROJECT_REDEFINED,"Only one project can exist",i))),new ue(this.ast,e)}}class fS{constructor(e,n,i){this.declarationNode=e,this.ast=n,this.symbolFactory=i}bind(){return[]}}class hS{constructor(e,n,i){this.declarationNode=e,this.ast=n,this.symbolFactory=i}bind(){return this.bindBody(this.declarationNode.body)}bindBody(e){if(!e)return[];if(e instanceof z)return[];const n=e.body.filter(i=>i instanceof re);return this.bindSubElements(n)}bindSubElements(e){return e.flatMap(n=>{if(!n.type)return[];const i=fn(n);return new i(n,this.ast,this.symbolFactory).bind()})}}class dS{constructor(e,n,i){this.declarationNode=e,this.ast=n,this.symbolFactory=i}bind(){return this.declarationNode.body instanceof Ge?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e)return[];if(e instanceof z)return[];const n=e.body.filter(i=>i instanceof z);return this.bindSubElements(n)}bindSubElements(e){return e.flatMap(n=>{if(!n.type)return[];const i=fn(n);return new i(n,this.ast,this.symbolFactory).bind()})}}var ca=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},zi={exports:{}};var pS=zi.exports,Td;function mS(){return Td||(Td=1,function(t,e){(function(){var n,i="4.17.21",a=200,u="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",l="Expected a function",f="Invalid `variable` option passed into `_.template`",h="__lodash_hash_undefined__",m=500,E="__lodash_placeholder__",T=1,A=2,O=4,F=1,G=2,H=1,le=2,Me=4,Xe=8,at=16,Je=32,or=64,zt=128,ur=256,_n=512,lr=30,so="...",Rg=800,kg=16,ac=1,Mg=2,Pg=3,cr=1/0,qn=9007199254740991,Cg=17976931348623157e292,gs=NaN,hn=4294967295,Fg=hn-1,Ug=hn>>>1,Vg=[["ary",zt],["bind",H],["bindKey",le],["curry",Xe],["curryRight",at],["flip",_n],["partial",Je],["partialRight",or],["rearg",ur]],Pr="[object Arguments]",Es="[object Array]",Bg="[object AsyncFunction]",vi="[object Boolean]",_i="[object Date]",$g="[object DOMException]",Ts="[object Error]",Ns="[object Function]",oc="[object GeneratorFunction]",qt="[object Map]",bi="[object Number]",Gg="[object Null]",bn="[object Object]",uc="[object Promise]",Wg="[object Proxy]",wi="[object RegExp]",Xt="[object Set]",Ii="[object String]",ys="[object Symbol]",Hg="[object Undefined]",Ai="[object WeakMap]",zg="[object WeakSet]",Li="[object ArrayBuffer]",Cr="[object DataView]",ao="[object Float32Array]",oo="[object Float64Array]",uo="[object Int8Array]",lo="[object Int16Array]",co="[object Int32Array]",fo="[object Uint8Array]",ho="[object Uint8ClampedArray]",po="[object Uint16Array]",mo="[object Uint32Array]",qg=/\b__p \+= '';/g,Xg=/\b(__p \+=) '' \+/g,Yg=/(__e\(.*?\)|\b__t\)) \+\n'';/g,lc=/&(?:amp|lt|gt|quot|#39);/g,cc=/[&<>"']/g,Zg=RegExp(lc.source),Kg=RegExp(cc.source),Jg=/<%-([\s\S]+?)%>/g,jg=/<%([\s\S]+?)%>/g,fc=/<%=([\s\S]+?)%>/g,Qg=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,eE=/^\w*$/,tE=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,go=/[\\^$.*+?()[\]{}|]/g,nE=RegExp(go.source),Eo=/^\s+/,rE=/\s/,iE=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,sE=/\{\n\/\* \[wrapped with (.+)\] \*/,aE=/,? & /,oE=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,uE=/[()=,{}\[\]\/\s]/,lE=/\\(\\)?/g,cE=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,hc=/\w*$/,fE=/^[-+]0x[0-9a-f]+$/i,hE=/^0b[01]+$/i,dE=/^\[object .+?Constructor\]$/,pE=/^0o[0-7]+$/i,mE=/^(?:0|[1-9]\d*)$/,gE=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,vs=/($^)/,EE=/['\n\r\u2028\u2029\\]/g,_s="\\ud800-\\udfff",TE="\\u0300-\\u036f",NE="\\ufe20-\\ufe2f",yE="\\u20d0-\\u20ff",dc=TE+NE+yE,pc="\\u2700-\\u27bf",mc="a-z\\xdf-\\xf6\\xf8-\\xff",vE="\\xac\\xb1\\xd7\\xf7",_E="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",bE="\\u2000-\\u206f",wE=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",gc="A-Z\\xc0-\\xd6\\xd8-\\xde",Ec="\\ufe0e\\ufe0f",Tc=vE+_E+bE+wE,To="['’]",IE="["+_s+"]",Nc="["+Tc+"]",bs="["+dc+"]",yc="\\d+",AE="["+pc+"]",vc="["+mc+"]",_c="[^"+_s+Tc+yc+pc+mc+gc+"]",No="\\ud83c[\\udffb-\\udfff]",LE="(?:"+bs+"|"+No+")",bc="[^"+_s+"]",yo="(?:\\ud83c[\\udde6-\\uddff]){2}",vo="[\\ud800-\\udbff][\\udc00-\\udfff]",Fr="["+gc+"]",wc="\\u200d",Ic="(?:"+vc+"|"+_c+")",SE="(?:"+Fr+"|"+_c+")",Ac="(?:"+To+"(?:d|ll|m|re|s|t|ve))?",Lc="(?:"+To+"(?:D|LL|M|RE|S|T|VE))?",Sc=LE+"?",Oc="["+Ec+"]?",OE="(?:"+wc+"(?:"+[bc,yo,vo].join("|")+")"+Oc+Sc+")*",xE="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",DE="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",xc=Oc+Sc+OE,RE="(?:"+[AE,yo,vo].join("|")+")"+xc,kE="(?:"+[bc+bs+"?",bs,yo,vo,IE].join("|")+")",ME=RegExp(To,"g"),PE=RegExp(bs,"g"),_o=RegExp(No+"(?="+No+")|"+kE+xc,"g"),CE=RegExp([Fr+"?"+vc+"+"+Ac+"(?="+[Nc,Fr,"$"].join("|")+")",SE+"+"+Lc+"(?="+[Nc,Fr+Ic,"$"].join("|")+")",Fr+"?"+Ic+"+"+Ac,Fr+"+"+Lc,DE,xE,yc,RE].join("|"),"g"),FE=RegExp("["+wc+_s+dc+Ec+"]"),UE=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,VE=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],BE=-1,be={};be[ao]=be[oo]=be[uo]=be[lo]=be[co]=be[fo]=be[ho]=be[po]=be[mo]=!0,be[Pr]=be[Es]=be[Li]=be[vi]=be[Cr]=be[_i]=be[Ts]=be[Ns]=be[qt]=be[bi]=be[bn]=be[wi]=be[Xt]=be[Ii]=be[Ai]=!1;var _e={};_e[Pr]=_e[Es]=_e[Li]=_e[Cr]=_e[vi]=_e[_i]=_e[ao]=_e[oo]=_e[uo]=_e[lo]=_e[co]=_e[qt]=_e[bi]=_e[bn]=_e[wi]=_e[Xt]=_e[Ii]=_e[ys]=_e[fo]=_e[ho]=_e[po]=_e[mo]=!0,_e[Ts]=_e[Ns]=_e[Ai]=!1;var $E={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},GE={"&":"&","<":"<",">":">",'"':""","'":"'"},WE={"&":"&","<":"<",">":">",""":'"',"'":"'"},HE={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},zE=parseFloat,qE=parseInt,Dc=typeof ca=="object"&&ca&&ca.Object===Object&&ca,XE=typeof self=="object"&&self&&self.Object===Object&&self,je=Dc||XE||Function("return this")(),bo=e&&!e.nodeType&&e,fr=bo&&!0&&t&&!t.nodeType&&t,Rc=fr&&fr.exports===bo,wo=Rc&&Dc.process,Dt=function(){try{var b=fr&&fr.require&&fr.require("util").types;return b||wo&&wo.binding&&wo.binding("util")}catch{}}(),kc=Dt&&Dt.isArrayBuffer,Mc=Dt&&Dt.isDate,Pc=Dt&&Dt.isMap,Cc=Dt&&Dt.isRegExp,Fc=Dt&&Dt.isSet,Uc=Dt&&Dt.isTypedArray;function vt(b,S,L){switch(L.length){case 0:return b.call(S);case 1:return b.call(S,L[0]);case 2:return b.call(S,L[0],L[1]);case 3:return b.call(S,L[0],L[1],L[2])}return b.apply(S,L)}function YE(b,S,L,V){for(var J=-1,fe=b==null?0:b.length;++J<fe;){var We=b[J];S(V,We,L(We),b)}return V}function Rt(b,S){for(var L=-1,V=b==null?0:b.length;++L<V&&S(b[L],L,b)!==!1;);return b}function ZE(b,S){for(var L=b==null?0:b.length;L--&&S(b[L],L,b)!==!1;);return b}function Vc(b,S){for(var L=-1,V=b==null?0:b.length;++L<V;)if(!S(b[L],L,b))return!1;return!0}function Xn(b,S){for(var L=-1,V=b==null?0:b.length,J=0,fe=[];++L<V;){var We=b[L];S(We,L,b)&&(fe[J++]=We)}return fe}function ws(b,S){var L=b==null?0:b.length;return!!L&&Ur(b,S,0)>-1}function Io(b,S,L){for(var V=-1,J=b==null?0:b.length;++V<J;)if(L(S,b[V]))return!0;return!1}function Ae(b,S){for(var L=-1,V=b==null?0:b.length,J=Array(V);++L<V;)J[L]=S(b[L],L,b);return J}function Yn(b,S){for(var L=-1,V=S.length,J=b.length;++L<V;)b[J+L]=S[L];return b}function Ao(b,S,L,V){var J=-1,fe=b==null?0:b.length;for(V&&fe&&(L=b[++J]);++J<fe;)L=S(L,b[J],J,b);return L}function KE(b,S,L,V){var J=b==null?0:b.length;for(V&&J&&(L=b[--J]);J--;)L=S(L,b[J],J,b);return L}function Lo(b,S){for(var L=-1,V=b==null?0:b.length;++L<V;)if(S(b[L],L,b))return!0;return!1}var JE=So("length");function jE(b){return b.split("")}function QE(b){return b.match(oE)||[]}function Bc(b,S,L){var V;return L(b,function(J,fe,We){if(S(J,fe,We))return V=fe,!1}),V}function Is(b,S,L,V){for(var J=b.length,fe=L+(V?1:-1);V?fe--:++fe<J;)if(S(b[fe],fe,b))return fe;return-1}function Ur(b,S,L){return S===S?fT(b,S,L):Is(b,$c,L)}function eT(b,S,L,V){for(var J=L-1,fe=b.length;++J<fe;)if(V(b[J],S))return J;return-1}function $c(b){return b!==b}function Gc(b,S){var L=b==null?0:b.length;return L?xo(b,S)/L:gs}function So(b){return function(S){return S==null?n:S[b]}}function Oo(b){return function(S){return b==null?n:b[S]}}function Wc(b,S,L,V,J){return J(b,function(fe,We,ye){L=V?(V=!1,fe):S(L,fe,We,ye)}),L}function tT(b,S){var L=b.length;for(b.sort(S);L--;)b[L]=b[L].value;return b}function xo(b,S){for(var L,V=-1,J=b.length;++V<J;){var fe=S(b[V]);fe!==n&&(L=L===n?fe:L+fe)}return L}function Do(b,S){for(var L=-1,V=Array(b);++L<b;)V[L]=S(L);return V}function nT(b,S){return Ae(S,function(L){return[L,b[L]]})}function Hc(b){return b&&b.slice(0,Yc(b)+1).replace(Eo,"")}function _t(b){return function(S){return b(S)}}function Ro(b,S){return Ae(S,function(L){return b[L]})}function Si(b,S){return b.has(S)}function zc(b,S){for(var L=-1,V=b.length;++L<V&&Ur(S,b[L],0)>-1;);return L}function qc(b,S){for(var L=b.length;L--&&Ur(S,b[L],0)>-1;);return L}function rT(b,S){for(var L=b.length,V=0;L--;)b[L]===S&&++V;return V}var iT=Oo($E),sT=Oo(GE);function aT(b){return"\\"+HE[b]}function oT(b,S){return b==null?n:b[S]}function Vr(b){return FE.test(b)}function uT(b){return UE.test(b)}function lT(b){for(var S,L=[];!(S=b.next()).done;)L.push(S.value);return L}function ko(b){var S=-1,L=Array(b.size);return b.forEach(function(V,J){L[++S]=[J,V]}),L}function Xc(b,S){return function(L){return b(S(L))}}function Zn(b,S){for(var L=-1,V=b.length,J=0,fe=[];++L<V;){var We=b[L];(We===S||We===E)&&(b[L]=E,fe[J++]=L)}return fe}function As(b){var S=-1,L=Array(b.size);return b.forEach(function(V){L[++S]=V}),L}function cT(b){var S=-1,L=Array(b.size);return b.forEach(function(V){L[++S]=[V,V]}),L}function fT(b,S,L){for(var V=L-1,J=b.length;++V<J;)if(b[V]===S)return V;return-1}function hT(b,S,L){for(var V=L+1;V--;)if(b[V]===S)return V;return V}function Br(b){return Vr(b)?pT(b):JE(b)}function Yt(b){return Vr(b)?mT(b):jE(b)}function Yc(b){for(var S=b.length;S--&&rE.test(b.charAt(S)););return S}var dT=Oo(WE);function pT(b){for(var S=_o.lastIndex=0;_o.test(b);)++S;return S}function mT(b){return b.match(_o)||[]}function gT(b){return b.match(CE)||[]}var ET=function b(S){S=S==null?je:$r.defaults(je.Object(),S,$r.pick(je,VE));var L=S.Array,V=S.Date,J=S.Error,fe=S.Function,We=S.Math,ye=S.Object,Mo=S.RegExp,TT=S.String,kt=S.TypeError,Ls=L.prototype,NT=fe.prototype,Gr=ye.prototype,Ss=S["__core-js_shared__"],Os=NT.toString,Ee=Gr.hasOwnProperty,yT=0,Zc=function(){var r=/[^.]+$/.exec(Ss&&Ss.keys&&Ss.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}(),xs=Gr.toString,vT=Os.call(ye),_T=je._,bT=Mo("^"+Os.call(Ee).replace(go,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ds=Rc?S.Buffer:n,Kn=S.Symbol,Rs=S.Uint8Array,Kc=Ds?Ds.allocUnsafe:n,ks=Xc(ye.getPrototypeOf,ye),Jc=ye.create,jc=Gr.propertyIsEnumerable,Ms=Ls.splice,Qc=Kn?Kn.isConcatSpreadable:n,Oi=Kn?Kn.iterator:n,hr=Kn?Kn.toStringTag:n,Ps=function(){try{var r=Er(ye,"defineProperty");return r({},"",{}),r}catch{}}(),wT=S.clearTimeout!==je.clearTimeout&&S.clearTimeout,IT=V&&V.now!==je.Date.now&&V.now,AT=S.setTimeout!==je.setTimeout&&S.setTimeout,Cs=We.ceil,Fs=We.floor,Po=ye.getOwnPropertySymbols,LT=Ds?Ds.isBuffer:n,ef=S.isFinite,ST=Ls.join,OT=Xc(ye.keys,ye),He=We.max,et=We.min,xT=V.now,DT=S.parseInt,tf=We.random,RT=Ls.reverse,Co=Er(S,"DataView"),xi=Er(S,"Map"),Fo=Er(S,"Promise"),Wr=Er(S,"Set"),Di=Er(S,"WeakMap"),Ri=Er(ye,"create"),Us=Di&&new Di,Hr={},kT=Tr(Co),MT=Tr(xi),PT=Tr(Fo),CT=Tr(Wr),FT=Tr(Di),Vs=Kn?Kn.prototype:n,ki=Vs?Vs.valueOf:n,nf=Vs?Vs.toString:n;function p(r){if(Pe(r)&&!j(r)&&!(r instanceof ae)){if(r instanceof Mt)return r;if(Ee.call(r,"__wrapped__"))return ih(r)}return new Mt(r)}var zr=function(){function r(){}return function(s){if(!Re(s))return{};if(Jc)return Jc(s);r.prototype=s;var o=new r;return r.prototype=n,o}}();function Bs(){}function Mt(r,s){this.__wrapped__=r,this.__actions__=[],this.__chain__=!!s,this.__index__=0,this.__values__=n}p.templateSettings={escape:Jg,evaluate:jg,interpolate:fc,variable:"",imports:{_:p}},p.prototype=Bs.prototype,p.prototype.constructor=p,Mt.prototype=zr(Bs.prototype),Mt.prototype.constructor=Mt;function ae(r){this.__wrapped__=r,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=hn,this.__views__=[]}function UT(){var r=new ae(this.__wrapped__);return r.__actions__=pt(this.__actions__),r.__dir__=this.__dir__,r.__filtered__=this.__filtered__,r.__iteratees__=pt(this.__iteratees__),r.__takeCount__=this.__takeCount__,r.__views__=pt(this.__views__),r}function VT(){if(this.__filtered__){var r=new ae(this);r.__dir__=-1,r.__filtered__=!0}else r=this.clone(),r.__dir__*=-1;return r}function BT(){var r=this.__wrapped__.value(),s=this.__dir__,o=j(r),c=s<0,d=o?r.length:0,g=jN(0,d,this.__views__),y=g.start,_=g.end,w=_-y,x=c?_:y-1,D=this.__iteratees__,R=D.length,P=0,$=et(w,this.__takeCount__);if(!o||!c&&d==w&&$==w)return Lf(r,this.__actions__);var X=[];e:for(;w--&&P<$;){x+=s;for(var te=-1,Y=r[x];++te<R;){var ie=D[te],oe=ie.iteratee,It=ie.type,lt=oe(Y);if(It==Mg)Y=lt;else if(!lt){if(It==ac)continue e;break e}}X[P++]=Y}return X}ae.prototype=zr(Bs.prototype),ae.prototype.constructor=ae;function dr(r){var s=-1,o=r==null?0:r.length;for(this.clear();++s<o;){var c=r[s];this.set(c[0],c[1])}}function $T(){this.__data__=Ri?Ri(null):{},this.size=0}function GT(r){var s=this.has(r)&&delete this.__data__[r];return this.size-=s?1:0,s}function WT(r){var s=this.__data__;if(Ri){var o=s[r];return o===h?n:o}return Ee.call(s,r)?s[r]:n}function HT(r){var s=this.__data__;return Ri?s[r]!==n:Ee.call(s,r)}function zT(r,s){var o=this.__data__;return this.size+=this.has(r)?0:1,o[r]=Ri&&s===n?h:s,this}dr.prototype.clear=$T,dr.prototype.delete=GT,dr.prototype.get=WT,dr.prototype.has=HT,dr.prototype.set=zT;function wn(r){var s=-1,o=r==null?0:r.length;for(this.clear();++s<o;){var c=r[s];this.set(c[0],c[1])}}function qT(){this.__data__=[],this.size=0}function XT(r){var s=this.__data__,o=$s(s,r);if(o<0)return!1;var c=s.length-1;return o==c?s.pop():Ms.call(s,o,1),--this.size,!0}function YT(r){var s=this.__data__,o=$s(s,r);return o<0?n:s[o][1]}function ZT(r){return $s(this.__data__,r)>-1}function KT(r,s){var o=this.__data__,c=$s(o,r);return c<0?(++this.size,o.push([r,s])):o[c][1]=s,this}wn.prototype.clear=qT,wn.prototype.delete=XT,wn.prototype.get=YT,wn.prototype.has=ZT,wn.prototype.set=KT;function In(r){var s=-1,o=r==null?0:r.length;for(this.clear();++s<o;){var c=r[s];this.set(c[0],c[1])}}function JT(){this.size=0,this.__data__={hash:new dr,map:new(xi||wn),string:new dr}}function jT(r){var s=Qs(this,r).delete(r);return this.size-=s?1:0,s}function QT(r){return Qs(this,r).get(r)}function eN(r){return Qs(this,r).has(r)}function tN(r,s){var o=Qs(this,r),c=o.size;return o.set(r,s),this.size+=o.size==c?0:1,this}In.prototype.clear=JT,In.prototype.delete=jT,In.prototype.get=QT,In.prototype.has=eN,In.prototype.set=tN;function pr(r){var s=-1,o=r==null?0:r.length;for(this.__data__=new In;++s<o;)this.add(r[s])}function nN(r){return this.__data__.set(r,h),this}function rN(r){return this.__data__.has(r)}pr.prototype.add=pr.prototype.push=nN,pr.prototype.has=rN;function Zt(r){var s=this.__data__=new wn(r);this.size=s.size}function iN(){this.__data__=new wn,this.size=0}function sN(r){var s=this.__data__,o=s.delete(r);return this.size=s.size,o}function aN(r){return this.__data__.get(r)}function oN(r){return this.__data__.has(r)}function uN(r,s){var o=this.__data__;if(o instanceof wn){var c=o.__data__;if(!xi||c.length<a-1)return c.push([r,s]),this.size=++o.size,this;o=this.__data__=new In(c)}return o.set(r,s),this.size=o.size,this}Zt.prototype.clear=iN,Zt.prototype.delete=sN,Zt.prototype.get=aN,Zt.prototype.has=oN,Zt.prototype.set=uN;function rf(r,s){var o=j(r),c=!o&&Nr(r),d=!o&&!c&&tr(r),g=!o&&!c&&!d&&Zr(r),y=o||c||d||g,_=y?Do(r.length,TT):[],w=_.length;for(var x in r)(s||Ee.call(r,x))&&!(y&&(x=="length"||d&&(x=="offset"||x=="parent")||g&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||On(x,w)))&&_.push(x);return _}function sf(r){var s=r.length;return s?r[Yo(0,s-1)]:n}function lN(r,s){return ea(pt(r),mr(s,0,r.length))}function cN(r){return ea(pt(r))}function Uo(r,s,o){(o!==n&&!Kt(r[s],o)||o===n&&!(s in r))&&An(r,s,o)}function Mi(r,s,o){var c=r[s];(!(Ee.call(r,s)&&Kt(c,o))||o===n&&!(s in r))&&An(r,s,o)}function $s(r,s){for(var o=r.length;o--;)if(Kt(r[o][0],s))return o;return-1}function fN(r,s,o,c){return Jn(r,function(d,g,y){s(c,d,o(d),y)}),c}function af(r,s){return r&&pn(s,Ye(s),r)}function hN(r,s){return r&&pn(s,gt(s),r)}function An(r,s,o){s=="__proto__"&&Ps?Ps(r,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[s]=o}function Vo(r,s){for(var o=-1,c=s.length,d=L(c),g=r==null;++o<c;)d[o]=g?n:Nu(r,s[o]);return d}function mr(r,s,o){return r===r&&(o!==n&&(r=r<=o?r:o),s!==n&&(r=r>=s?r:s)),r}function Pt(r,s,o,c,d,g){var y,_=s&T,w=s&A,x=s&O;if(o&&(y=d?o(r,c,d,g):o(r)),y!==n)return y;if(!Re(r))return r;var D=j(r);if(D){if(y=ey(r),!_)return pt(r,y)}else{var R=tt(r),P=R==Ns||R==oc;if(tr(r))return xf(r,_);if(R==bn||R==Pr||P&&!d){if(y=w||P?{}:Zf(r),!_)return w?WN(r,hN(y,r)):GN(r,af(y,r))}else{if(!_e[R])return d?r:{};y=ty(r,R,_)}}g||(g=new Zt);var $=g.get(r);if($)return $;g.set(r,y),wh(r)?r.forEach(function(Y){y.add(Pt(Y,s,o,Y,r,g))}):_h(r)&&r.forEach(function(Y,ie){y.set(ie,Pt(Y,s,o,ie,r,g))});var X=x?w?su:iu:w?gt:Ye,te=D?n:X(r);return Rt(te||r,function(Y,ie){te&&(ie=Y,Y=r[ie]),Mi(y,ie,Pt(Y,s,o,ie,r,g))}),y}function dN(r){var s=Ye(r);return function(o){return of(o,r,s)}}function of(r,s,o){var c=o.length;if(r==null)return!c;for(r=ye(r);c--;){var d=o[c],g=s[d],y=r[d];if(y===n&&!(d in r)||!g(y))return!1}return!0}function uf(r,s,o){if(typeof r!="function")throw new kt(l);return $i(function(){r.apply(n,o)},s)}function Pi(r,s,o,c){var d=-1,g=ws,y=!0,_=r.length,w=[],x=s.length;if(!_)return w;o&&(s=Ae(s,_t(o))),c?(g=Io,y=!1):s.length>=a&&(g=Si,y=!1,s=new pr(s));e:for(;++d<_;){var D=r[d],R=o==null?D:o(D);if(D=c||D!==0?D:0,y&&R===R){for(var P=x;P--;)if(s[P]===R)continue e;w.push(D)}else g(s,R,c)||w.push(D)}return w}var Jn=Pf(dn),lf=Pf($o,!0);function pN(r,s){var o=!0;return Jn(r,function(c,d,g){return o=!!s(c,d,g),o}),o}function Gs(r,s,o){for(var c=-1,d=r.length;++c<d;){var g=r[c],y=s(g);if(y!=null&&(_===n?y===y&&!wt(y):o(y,_)))var _=y,w=g}return w}function mN(r,s,o,c){var d=r.length;for(o=ee(o),o<0&&(o=-o>d?0:d+o),c=c===n||c>d?d:ee(c),c<0&&(c+=d),c=o>c?0:Ah(c);o<c;)r[o++]=s;return r}function cf(r,s){var o=[];return Jn(r,function(c,d,g){s(c,d,g)&&o.push(c)}),o}function Qe(r,s,o,c,d){var g=-1,y=r.length;for(o||(o=ry),d||(d=[]);++g<y;){var _=r[g];s>0&&o(_)?s>1?Qe(_,s-1,o,c,d):Yn(d,_):c||(d[d.length]=_)}return d}var Bo=Cf(),ff=Cf(!0);function dn(r,s){return r&&Bo(r,s,Ye)}function $o(r,s){return r&&ff(r,s,Ye)}function Ws(r,s){return Xn(s,function(o){return xn(r[o])})}function gr(r,s){s=Qn(s,r);for(var o=0,c=s.length;r!=null&&o<c;)r=r[mn(s[o++])];return o&&o==c?r:n}function hf(r,s,o){var c=s(r);return j(r)?c:Yn(c,o(r))}function ot(r){return r==null?r===n?Hg:Gg:hr&&hr in ye(r)?JN(r):cy(r)}function Go(r,s){return r>s}function gN(r,s){return r!=null&&Ee.call(r,s)}function EN(r,s){return r!=null&&s in ye(r)}function TN(r,s,o){return r>=et(s,o)&&r<He(s,o)}function Wo(r,s,o){for(var c=o?Io:ws,d=r[0].length,g=r.length,y=g,_=L(g),w=1/0,x=[];y--;){var D=r[y];y&&s&&(D=Ae(D,_t(s))),w=et(D.length,w),_[y]=!o&&(s||d>=120&&D.length>=120)?new pr(y&&D):n}D=r[0];var R=-1,P=_[0];e:for(;++R<d&&x.length<w;){var $=D[R],X=s?s($):$;if($=o||$!==0?$:0,!(P?Si(P,X):c(x,X,o))){for(y=g;--y;){var te=_[y];if(!(te?Si(te,X):c(r[y],X,o)))continue e}P&&P.push(X),x.push($)}}return x}function NN(r,s,o,c){return dn(r,function(d,g,y){s(c,o(d),g,y)}),c}function Ci(r,s,o){s=Qn(s,r),r=Qf(r,s);var c=r==null?r:r[mn(Ft(s))];return c==null?n:vt(c,r,o)}function df(r){return Pe(r)&&ot(r)==Pr}function yN(r){return Pe(r)&&ot(r)==Li}function vN(r){return Pe(r)&&ot(r)==_i}function Fi(r,s,o,c,d){return r===s?!0:r==null||s==null||!Pe(r)&&!Pe(s)?r!==r&&s!==s:_N(r,s,o,c,Fi,d)}function _N(r,s,o,c,d,g){var y=j(r),_=j(s),w=y?Es:tt(r),x=_?Es:tt(s);w=w==Pr?bn:w,x=x==Pr?bn:x;var D=w==bn,R=x==bn,P=w==x;if(P&&tr(r)){if(!tr(s))return!1;y=!0,D=!1}if(P&&!D)return g||(g=new Zt),y||Zr(r)?qf(r,s,o,c,d,g):ZN(r,s,w,o,c,d,g);if(!(o&F)){var $=D&&Ee.call(r,"__wrapped__"),X=R&&Ee.call(s,"__wrapped__");if($||X){var te=$?r.value():r,Y=X?s.value():s;return g||(g=new Zt),d(te,Y,o,c,g)}}return P?(g||(g=new Zt),KN(r,s,o,c,d,g)):!1}function bN(r){return Pe(r)&&tt(r)==qt}function Ho(r,s,o,c){var d=o.length,g=d,y=!c;if(r==null)return!g;for(r=ye(r);d--;){var _=o[d];if(y&&_[2]?_[1]!==r[_[0]]:!(_[0]in r))return!1}for(;++d<g;){_=o[d];var w=_[0],x=r[w],D=_[1];if(y&&_[2]){if(x===n&&!(w in r))return!1}else{var R=new Zt;if(c)var P=c(x,D,w,r,s,R);if(!(P===n?Fi(D,x,F|G,c,R):P))return!1}}return!0}function pf(r){if(!Re(r)||sy(r))return!1;var s=xn(r)?bT:dE;return s.test(Tr(r))}function wN(r){return Pe(r)&&ot(r)==wi}function IN(r){return Pe(r)&&tt(r)==Xt}function AN(r){return Pe(r)&&aa(r.length)&&!!be[ot(r)]}function mf(r){return typeof r=="function"?r:r==null?Et:typeof r=="object"?j(r)?Tf(r[0],r[1]):Ef(r):Fh(r)}function zo(r){if(!Bi(r))return OT(r);var s=[];for(var o in ye(r))Ee.call(r,o)&&o!="constructor"&&s.push(o);return s}function LN(r){if(!Re(r))return ly(r);var s=Bi(r),o=[];for(var c in r)c=="constructor"&&(s||!Ee.call(r,c))||o.push(c);return o}function qo(r,s){return r<s}function gf(r,s){var o=-1,c=mt(r)?L(r.length):[];return Jn(r,function(d,g,y){c[++o]=s(d,g,y)}),c}function Ef(r){var s=ou(r);return s.length==1&&s[0][2]?Jf(s[0][0],s[0][1]):function(o){return o===r||Ho(o,r,s)}}function Tf(r,s){return lu(r)&&Kf(s)?Jf(mn(r),s):function(o){var c=Nu(o,r);return c===n&&c===s?yu(o,r):Fi(s,c,F|G)}}function Hs(r,s,o,c,d){r!==s&&Bo(s,function(g,y){if(d||(d=new Zt),Re(g))SN(r,s,y,o,Hs,c,d);else{var _=c?c(fu(r,y),g,y+"",r,s,d):n;_===n&&(_=g),Uo(r,y,_)}},gt)}function SN(r,s,o,c,d,g,y){var _=fu(r,o),w=fu(s,o),x=y.get(w);if(x){Uo(r,o,x);return}var D=g?g(_,w,o+"",r,s,y):n,R=D===n;if(R){var P=j(w),$=!P&&tr(w),X=!P&&!$&&Zr(w);D=w,P||$||X?j(_)?D=_:Ue(_)?D=pt(_):$?(R=!1,D=xf(w,!0)):X?(R=!1,D=Df(w,!0)):D=[]:Gi(w)||Nr(w)?(D=_,Nr(_)?D=Lh(_):(!Re(_)||xn(_))&&(D=Zf(w))):R=!1}R&&(y.set(w,D),d(D,w,c,g,y),y.delete(w)),Uo(r,o,D)}function Nf(r,s){var o=r.length;if(o)return s+=s<0?o:0,On(s,o)?r[s]:n}function yf(r,s,o){s.length?s=Ae(s,function(g){return j(g)?function(y){return gr(y,g.length===1?g[0]:g)}:g}):s=[Et];var c=-1;s=Ae(s,_t(q()));var d=gf(r,function(g,y,_){var w=Ae(s,function(x){return x(g)});return{criteria:w,index:++c,value:g}});return tT(d,function(g,y){return $N(g,y,o)})}function ON(r,s){return vf(r,s,function(o,c){return yu(r,c)})}function vf(r,s,o){for(var c=-1,d=s.length,g={};++c<d;){var y=s[c],_=gr(r,y);o(_,y)&&Ui(g,Qn(y,r),_)}return g}function xN(r){return function(s){return gr(s,r)}}function Xo(r,s,o,c){var d=c?eT:Ur,g=-1,y=s.length,_=r;for(r===s&&(s=pt(s)),o&&(_=Ae(r,_t(o)));++g<y;)for(var w=0,x=s[g],D=o?o(x):x;(w=d(_,D,w,c))>-1;)_!==r&&Ms.call(_,w,1),Ms.call(r,w,1);return r}function _f(r,s){for(var o=r?s.length:0,c=o-1;o--;){var d=s[o];if(o==c||d!==g){var g=d;On(d)?Ms.call(r,d,1):Jo(r,d)}}return r}function Yo(r,s){return r+Fs(tf()*(s-r+1))}function DN(r,s,o,c){for(var d=-1,g=He(Cs((s-r)/(o||1)),0),y=L(g);g--;)y[c?g:++d]=r,r+=o;return y}function Zo(r,s){var o="";if(!r||s<1||s>qn)return o;do s%2&&(o+=r),s=Fs(s/2),s&&(r+=r);while(s);return o}function ne(r,s){return hu(jf(r,s,Et),r+"")}function RN(r){return sf(Kr(r))}function kN(r,s){var o=Kr(r);return ea(o,mr(s,0,o.length))}function Ui(r,s,o,c){if(!Re(r))return r;s=Qn(s,r);for(var d=-1,g=s.length,y=g-1,_=r;_!=null&&++d<g;){var w=mn(s[d]),x=o;if(w==="__proto__"||w==="constructor"||w==="prototype")return r;if(d!=y){var D=_[w];x=c?c(D,w,_):n,x===n&&(x=Re(D)?D:On(s[d+1])?[]:{})}Mi(_,w,x),_=_[w]}return r}var bf=Us?function(r,s){return Us.set(r,s),r}:Et,MN=Ps?function(r,s){return Ps(r,"toString",{configurable:!0,enumerable:!1,value:_u(s),writable:!0})}:Et;function PN(r){return ea(Kr(r))}function Ct(r,s,o){var c=-1,d=r.length;s<0&&(s=-s>d?0:d+s),o=o>d?d:o,o<0&&(o+=d),d=s>o?0:o-s>>>0,s>>>=0;for(var g=L(d);++c<d;)g[c]=r[c+s];return g}function CN(r,s){var o;return Jn(r,function(c,d,g){return o=s(c,d,g),!o}),!!o}function zs(r,s,o){var c=0,d=r==null?c:r.length;if(typeof s=="number"&&s===s&&d<=Ug){for(;c<d;){var g=c+d>>>1,y=r[g];y!==null&&!wt(y)&&(o?y<=s:y<s)?c=g+1:d=g}return d}return Ko(r,s,Et,o)}function Ko(r,s,o,c){var d=0,g=r==null?0:r.length;if(g===0)return 0;s=o(s);for(var y=s!==s,_=s===null,w=wt(s),x=s===n;d<g;){var D=Fs((d+g)/2),R=o(r[D]),P=R!==n,$=R===null,X=R===R,te=wt(R);if(y)var Y=c||X;else x?Y=X&&(c||P):_?Y=X&&P&&(c||!$):w?Y=X&&P&&!$&&(c||!te):$||te?Y=!1:Y=c?R<=s:R<s;Y?d=D+1:g=D}return et(g,Fg)}function wf(r,s){for(var o=-1,c=r.length,d=0,g=[];++o<c;){var y=r[o],_=s?s(y):y;if(!o||!Kt(_,w)){var w=_;g[d++]=y===0?0:y}}return g}function If(r){return typeof r=="number"?r:wt(r)?gs:+r}function bt(r){if(typeof r=="string")return r;if(j(r))return Ae(r,bt)+"";if(wt(r))return nf?nf.call(r):"";var s=r+"";return s=="0"&&1/r==-cr?"-0":s}function jn(r,s,o){var c=-1,d=ws,g=r.length,y=!0,_=[],w=_;if(o)y=!1,d=Io;else if(g>=a){var x=s?null:XN(r);if(x)return As(x);y=!1,d=Si,w=new pr}else w=s?[]:_;e:for(;++c<g;){var D=r[c],R=s?s(D):D;if(D=o||D!==0?D:0,y&&R===R){for(var P=w.length;P--;)if(w[P]===R)continue e;s&&w.push(R),_.push(D)}else d(w,R,o)||(w!==_&&w.push(R),_.push(D))}return _}function Jo(r,s){return s=Qn(s,r),r=Qf(r,s),r==null||delete r[mn(Ft(s))]}function Af(r,s,o,c){return Ui(r,s,o(gr(r,s)),c)}function qs(r,s,o,c){for(var d=r.length,g=c?d:-1;(c?g--:++g<d)&&s(r[g],g,r););return o?Ct(r,c?0:g,c?g+1:d):Ct(r,c?g+1:0,c?d:g)}function Lf(r,s){var o=r;return o instanceof ae&&(o=o.value()),Ao(s,function(c,d){return d.func.apply(d.thisArg,Yn([c],d.args))},o)}function jo(r,s,o){var c=r.length;if(c<2)return c?jn(r[0]):[];for(var d=-1,g=L(c);++d<c;)for(var y=r[d],_=-1;++_<c;)_!=d&&(g[d]=Pi(g[d]||y,r[_],s,o));return jn(Qe(g,1),s,o)}function Sf(r,s,o){for(var c=-1,d=r.length,g=s.length,y={};++c<d;){var _=c<g?s[c]:n;o(y,r[c],_)}return y}function Qo(r){return Ue(r)?r:[]}function eu(r){return typeof r=="function"?r:Et}function Qn(r,s){return j(r)?r:lu(r,s)?[r]:rh(pe(r))}var FN=ne;function er(r,s,o){var c=r.length;return o=o===n?c:o,!s&&o>=c?r:Ct(r,s,o)}var Of=wT||function(r){return je.clearTimeout(r)};function xf(r,s){if(s)return r.slice();var o=r.length,c=Kc?Kc(o):new r.constructor(o);return r.copy(c),c}function tu(r){var s=new r.constructor(r.byteLength);return new Rs(s).set(new Rs(r)),s}function UN(r,s){var o=s?tu(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}function VN(r){var s=new r.constructor(r.source,hc.exec(r));return s.lastIndex=r.lastIndex,s}function BN(r){return ki?ye(ki.call(r)):{}}function Df(r,s){var o=s?tu(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}function Rf(r,s){if(r!==s){var o=r!==n,c=r===null,d=r===r,g=wt(r),y=s!==n,_=s===null,w=s===s,x=wt(s);if(!_&&!x&&!g&&r>s||g&&y&&w&&!_&&!x||c&&y&&w||!o&&w||!d)return 1;if(!c&&!g&&!x&&r<s||x&&o&&d&&!c&&!g||_&&o&&d||!y&&d||!w)return-1}return 0}function $N(r,s,o){for(var c=-1,d=r.criteria,g=s.criteria,y=d.length,_=o.length;++c<y;){var w=Rf(d[c],g[c]);if(w){if(c>=_)return w;var x=o[c];return w*(x=="desc"?-1:1)}}return r.index-s.index}function kf(r,s,o,c){for(var d=-1,g=r.length,y=o.length,_=-1,w=s.length,x=He(g-y,0),D=L(w+x),R=!c;++_<w;)D[_]=s[_];for(;++d<y;)(R||d<g)&&(D[o[d]]=r[d]);for(;x--;)D[_++]=r[d++];return D}function Mf(r,s,o,c){for(var d=-1,g=r.length,y=-1,_=o.length,w=-1,x=s.length,D=He(g-_,0),R=L(D+x),P=!c;++d<D;)R[d]=r[d];for(var $=d;++w<x;)R[$+w]=s[w];for(;++y<_;)(P||d<g)&&(R[$+o[y]]=r[d++]);return R}function pt(r,s){var o=-1,c=r.length;for(s||(s=L(c));++o<c;)s[o]=r[o];return s}function pn(r,s,o,c){var d=!o;o||(o={});for(var g=-1,y=s.length;++g<y;){var _=s[g],w=c?c(o[_],r[_],_,o,r):n;w===n&&(w=r[_]),d?An(o,_,w):Mi(o,_,w)}return o}function GN(r,s){return pn(r,uu(r),s)}function WN(r,s){return pn(r,Xf(r),s)}function Xs(r,s){return function(o,c){var d=j(o)?YE:fN,g=s?s():{};return d(o,r,q(c,2),g)}}function qr(r){return ne(function(s,o){var c=-1,d=o.length,g=d>1?o[d-1]:n,y=d>2?o[2]:n;for(g=r.length>3&&typeof g=="function"?(d--,g):n,y&&ut(o[0],o[1],y)&&(g=d<3?n:g,d=1),s=ye(s);++c<d;){var _=o[c];_&&r(s,_,c,g)}return s})}function Pf(r,s){return function(o,c){if(o==null)return o;if(!mt(o))return r(o,c);for(var d=o.length,g=s?d:-1,y=ye(o);(s?g--:++g<d)&&c(y[g],g,y)!==!1;);return o}}function Cf(r){return function(s,o,c){for(var d=-1,g=ye(s),y=c(s),_=y.length;_--;){var w=y[r?_:++d];if(o(g[w],w,g)===!1)break}return s}}function HN(r,s,o){var c=s&H,d=Vi(r);function g(){var y=this&&this!==je&&this instanceof g?d:r;return y.apply(c?o:this,arguments)}return g}function Ff(r){return function(s){s=pe(s);var o=Vr(s)?Yt(s):n,c=o?o[0]:s.charAt(0),d=o?er(o,1).join(""):s.slice(1);return c[r]()+d}}function Xr(r){return function(s){return Ao(Ph(Mh(s).replace(ME,"")),r,"")}}function Vi(r){return function(){var s=arguments;switch(s.length){case 0:return new r;case 1:return new r(s[0]);case 2:return new r(s[0],s[1]);case 3:return new r(s[0],s[1],s[2]);case 4:return new r(s[0],s[1],s[2],s[3]);case 5:return new r(s[0],s[1],s[2],s[3],s[4]);case 6:return new r(s[0],s[1],s[2],s[3],s[4],s[5]);case 7:return new r(s[0],s[1],s[2],s[3],s[4],s[5],s[6])}var o=zr(r.prototype),c=r.apply(o,s);return Re(c)?c:o}}function zN(r,s,o){var c=Vi(r);function d(){for(var g=arguments.length,y=L(g),_=g,w=Yr(d);_--;)y[_]=arguments[_];var x=g<3&&y[0]!==w&&y[g-1]!==w?[]:Zn(y,w);if(g-=x.length,g<o)return Gf(r,s,Ys,d.placeholder,n,y,x,n,n,o-g);var D=this&&this!==je&&this instanceof d?c:r;return vt(D,this,y)}return d}function Uf(r){return function(s,o,c){var d=ye(s);if(!mt(s)){var g=q(o,3);s=Ye(s),o=function(_){return g(d[_],_,d)}}var y=r(s,o,c);return y>-1?d[g?s[y]:y]:n}}function Vf(r){return Sn(function(s){var o=s.length,c=o,d=Mt.prototype.thru;for(r&&s.reverse();c--;){var g=s[c];if(typeof g!="function")throw new kt(l);if(d&&!y&&js(g)=="wrapper")var y=new Mt([],!0)}for(c=y?c:o;++c<o;){g=s[c];var _=js(g),w=_=="wrapper"?au(g):n;w&&cu(w[0])&&w[1]==(zt|Xe|Je|ur)&&!w[4].length&&w[9]==1?y=y[js(w[0])].apply(y,w[3]):y=g.length==1&&cu(g)?y[_]():y.thru(g)}return function(){var x=arguments,D=x[0];if(y&&x.length==1&&j(D))return y.plant(D).value();for(var R=0,P=o?s[R].apply(this,x):D;++R<o;)P=s[R].call(this,P);return P}})}function Ys(r,s,o,c,d,g,y,_,w,x){var D=s&zt,R=s&H,P=s&le,$=s&(Xe|at),X=s&_n,te=P?n:Vi(r);function Y(){for(var ie=arguments.length,oe=L(ie),It=ie;It--;)oe[It]=arguments[It];if($)var lt=Yr(Y),At=rT(oe,lt);if(c&&(oe=kf(oe,c,d,$)),g&&(oe=Mf(oe,g,y,$)),ie-=At,$&&ie<x){var Ve=Zn(oe,lt);return Gf(r,s,Ys,Y.placeholder,o,oe,Ve,_,w,x-ie)}var Jt=R?o:this,Rn=P?Jt[r]:r;return ie=oe.length,_?oe=fy(oe,_):X&&ie>1&&oe.reverse(),D&&w<ie&&(oe.length=w),this&&this!==je&&this instanceof Y&&(Rn=te||Vi(Rn)),Rn.apply(Jt,oe)}return Y}function Bf(r,s){return function(o,c){return NN(o,r,s(c),{})}}function Zs(r,s){return function(o,c){var d;if(o===n&&c===n)return s;if(o!==n&&(d=o),c!==n){if(d===n)return c;typeof o=="string"||typeof c=="string"?(o=bt(o),c=bt(c)):(o=If(o),c=If(c)),d=r(o,c)}return d}}function nu(r){return Sn(function(s){return s=Ae(s,_t(q())),ne(function(o){var c=this;return r(s,function(d){return vt(d,c,o)})})})}function Ks(r,s){s=s===n?" ":bt(s);var o=s.length;if(o<2)return o?Zo(s,r):s;var c=Zo(s,Cs(r/Br(s)));return Vr(s)?er(Yt(c),0,r).join(""):c.slice(0,r)}function qN(r,s,o,c){var d=s&H,g=Vi(r);function y(){for(var _=-1,w=arguments.length,x=-1,D=c.length,R=L(D+w),P=this&&this!==je&&this instanceof y?g:r;++x<D;)R[x]=c[x];for(;w--;)R[x++]=arguments[++_];return vt(P,d?o:this,R)}return y}function $f(r){return function(s,o,c){return c&&typeof c!="number"&&ut(s,o,c)&&(o=c=n),s=Dn(s),o===n?(o=s,s=0):o=Dn(o),c=c===n?s<o?1:-1:Dn(c),DN(s,o,c,r)}}function Js(r){return function(s,o){return typeof s=="string"&&typeof o=="string"||(s=Ut(s),o=Ut(o)),r(s,o)}}function Gf(r,s,o,c,d,g,y,_,w,x){var D=s&Xe,R=D?y:n,P=D?n:y,$=D?g:n,X=D?n:g;s|=D?Je:or,s&=~(D?or:Je),s&Me||(s&=-4);var te=[r,s,d,$,R,X,P,_,w,x],Y=o.apply(n,te);return cu(r)&&eh(Y,te),Y.placeholder=c,th(Y,r,s)}function ru(r){var s=We[r];return function(o,c){if(o=Ut(o),c=c==null?0:et(ee(c),292),c&&ef(o)){var d=(pe(o)+"e").split("e"),g=s(d[0]+"e"+(+d[1]+c));return d=(pe(g)+"e").split("e"),+(d[0]+"e"+(+d[1]-c))}return s(o)}}var XN=Wr&&1/As(new Wr([,-0]))[1]==cr?function(r){return new Wr(r)}:Iu;function Wf(r){return function(s){var o=tt(s);return o==qt?ko(s):o==Xt?cT(s):nT(s,r(s))}}function Ln(r,s,o,c,d,g,y,_){var w=s≤if(!w&&typeof r!="function")throw new kt(l);var x=c?c.length:0;if(x||(s&=-97,c=d=n),y=y===n?y:He(ee(y),0),_=_===n?_:ee(_),x-=d?d.length:0,s&or){var D=c,R=d;c=d=n}var P=w?n:au(r),$=[r,s,o,c,d,D,R,g,y,_];if(P&&uy($,P),r=$[0],s=$[1],o=$[2],c=$[3],d=$[4],_=$[9]=$[9]===n?w?0:r.length:He($[9]-x,0),!_&&s&(Xe|at)&&(s&=-25),!s||s==H)var X=HN(r,s,o);else s==Xe||s==at?X=zN(r,s,_):(s==Je||s==(H|Je))&&!d.length?X=qN(r,s,o,c):X=Ys.apply(n,$);var te=P?bf:eh;return th(te(X,$),r,s)}function Hf(r,s,o,c){return r===n||Kt(r,Gr[o])&&!Ee.call(c,o)?s:r}function zf(r,s,o,c,d,g){return Re(r)&&Re(s)&&(g.set(s,r),Hs(r,s,n,zf,g),g.delete(s)),r}function YN(r){return Gi(r)?n:r}function qf(r,s,o,c,d,g){var y=o&F,_=r.length,w=s.length;if(_!=w&&!(y&&w>_))return!1;var x=g.get(r),D=g.get(s);if(x&&D)return x==s&&D==r;var R=-1,P=!0,$=o&G?new pr:n;for(g.set(r,s),g.set(s,r);++R<_;){var X=r[R],te=s[R];if(c)var Y=y?c(te,X,R,s,r,g):c(X,te,R,r,s,g);if(Y!==n){if(Y)continue;P=!1;break}if($){if(!Lo(s,function(ie,oe){if(!Si($,oe)&&(X===ie||d(X,ie,o,c,g)))return $.push(oe)})){P=!1;break}}else if(!(X===te||d(X,te,o,c,g))){P=!1;break}}return g.delete(r),g.delete(s),P}function ZN(r,s,o,c,d,g,y){switch(o){case Cr:if(r.byteLength!=s.byteLength||r.byteOffset!=s.byteOffset)return!1;r=r.buffer,s=s.buffer;case Li:return!(r.byteLength!=s.byteLength||!g(new Rs(r),new Rs(s)));case vi:case _i:case bi:return Kt(+r,+s);case Ts:return r.name==s.name&&r.message==s.message;case wi:case Ii:return r==s+"";case qt:var _=ko;case Xt:var w=c&F;if(_||(_=As),r.size!=s.size&&!w)return!1;var x=y.get(r);if(x)return x==s;c|=G,y.set(r,s);var D=qf(_(r),_(s),c,d,g,y);return y.delete(r),D;case ys:if(ki)return ki.call(r)==ki.call(s)}return!1}function KN(r,s,o,c,d,g){var y=o&F,_=iu(r),w=_.length,x=iu(s),D=x.length;if(w!=D&&!y)return!1;for(var R=w;R--;){var P=_[R];if(!(y?P in s:Ee.call(s,P)))return!1}var $=g.get(r),X=g.get(s);if($&&X)return $==s&&X==r;var te=!0;g.set(r,s),g.set(s,r);for(var Y=y;++R<w;){P=_[R];var ie=r[P],oe=s[P];if(c)var It=y?c(oe,ie,P,s,r,g):c(ie,oe,P,r,s,g);if(!(It===n?ie===oe||d(ie,oe,o,c,g):It)){te=!1;break}Y||(Y=P=="constructor")}if(te&&!Y){var lt=r.constructor,At=s.constructor;lt!=At&&"constructor"in r&&"constructor"in s&&!(typeof lt=="function"&< instanceof lt&&typeof At=="function"&&At instanceof At)&&(te=!1)}return g.delete(r),g.delete(s),te}function Sn(r){return hu(jf(r,n,oh),r+"")}function iu(r){return hf(r,Ye,uu)}function su(r){return hf(r,gt,Xf)}var au=Us?function(r){return Us.get(r)}:Iu;function js(r){for(var s=r.name+"",o=Hr[s],c=Ee.call(Hr,s)?o.length:0;c--;){var d=o[c],g=d.func;if(g==null||g==r)return d.name}return s}function Yr(r){var s=Ee.call(p,"placeholder")?p:r;return s.placeholder}function q(){var r=p.iteratee||bu;return r=r===bu?mf:r,arguments.length?r(arguments[0],arguments[1]):r}function Qs(r,s){var o=r.__data__;return iy(s)?o[typeof s=="string"?"string":"hash"]:o.map}function ou(r){for(var s=Ye(r),o=s.length;o--;){var c=s[o],d=r[c];s[o]=[c,d,Kf(d)]}return s}function Er(r,s){var o=oT(r,s);return pf(o)?o:n}function JN(r){var s=Ee.call(r,hr),o=r[hr];try{r[hr]=n;var c=!0}catch{}var d=xs.call(r);return c&&(s?r[hr]=o:delete r[hr]),d}var uu=Po?function(r){return r==null?[]:(r=ye(r),Xn(Po(r),function(s){return jc.call(r,s)}))}:Au,Xf=Po?function(r){for(var s=[];r;)Yn(s,uu(r)),r=ks(r);return s}:Au,tt=ot;(Co&&tt(new Co(new ArrayBuffer(1)))!=Cr||xi&&tt(new xi)!=qt||Fo&&tt(Fo.resolve())!=uc||Wr&&tt(new Wr)!=Xt||Di&&tt(new Di)!=Ai)&&(tt=function(r){var s=ot(r),o=s==bn?r.constructor:n,c=o?Tr(o):"";if(c)switch(c){case kT:return Cr;case MT:return qt;case PT:return uc;case CT:return Xt;case FT:return Ai}return s});function jN(r,s,o){for(var c=-1,d=o.length;++c<d;){var g=o[c],y=g.size;switch(g.type){case"drop":r+=y;break;case"dropRight":s-=y;break;case"take":s=et(s,r+y);break;case"takeRight":r=He(r,s-y);break}}return{start:r,end:s}}function QN(r){var s=r.match(sE);return s?s[1].split(aE):[]}function Yf(r,s,o){s=Qn(s,r);for(var c=-1,d=s.length,g=!1;++c<d;){var y=mn(s[c]);if(!(g=r!=null&&o(r,y)))break;r=r[y]}return g||++c!=d?g:(d=r==null?0:r.length,!!d&&aa(d)&&On(y,d)&&(j(r)||Nr(r)))}function ey(r){var s=r.length,o=new r.constructor(s);return s&&typeof r[0]=="string"&&Ee.call(r,"index")&&(o.index=r.index,o.input=r.input),o}function Zf(r){return typeof r.constructor=="function"&&!Bi(r)?zr(ks(r)):{}}function ty(r,s,o){var c=r.constructor;switch(s){case Li:return tu(r);case vi:case _i:return new c(+r);case Cr:return UN(r,o);case ao:case oo:case uo:case lo:case co:case fo:case ho:case po:case mo:return Df(r,o);case qt:return new c;case bi:case Ii:return new c(r);case wi:return VN(r);case Xt:return new c;case ys:return BN(r)}}function ny(r,s){var o=s.length;if(!o)return r;var c=o-1;return s[c]=(o>1?"& ":"")+s[c],s=s.join(o>2?", ":" "),r.replace(iE,`{
|
|
10
|
+
/* [wrapped with `+s+`] */
|
|
11
|
+
`)}function ry(r){return j(r)||Nr(r)||!!(Qc&&r&&r[Qc])}function On(r,s){var o=typeof r;return s=s??qn,!!s&&(o=="number"||o!="symbol"&&mE.test(r))&&r>-1&&r%1==0&&r<s}function ut(r,s,o){if(!Re(o))return!1;var c=typeof s;return(c=="number"?mt(o)&&On(s,o.length):c=="string"&&s in o)?Kt(o[s],r):!1}function lu(r,s){if(j(r))return!1;var o=typeof r;return o=="number"||o=="symbol"||o=="boolean"||r==null||wt(r)?!0:eE.test(r)||!Qg.test(r)||s!=null&&r in ye(s)}function iy(r){var s=typeof r;return s=="string"||s=="number"||s=="symbol"||s=="boolean"?r!=="__proto__":r===null}function cu(r){var s=js(r),o=p[s];if(typeof o!="function"||!(s in ae.prototype))return!1;if(r===o)return!0;var c=au(o);return!!c&&r===c[0]}function sy(r){return!!Zc&&Zc in r}var ay=Ss?xn:Lu;function Bi(r){var s=r&&r.constructor,o=typeof s=="function"&&s.prototype||Gr;return r===o}function Kf(r){return r===r&&!Re(r)}function Jf(r,s){return function(o){return o==null?!1:o[r]===s&&(s!==n||r in ye(o))}}function oy(r){var s=ia(r,function(c){return o.size===m&&o.clear(),c}),o=s.cache;return s}function uy(r,s){var o=r[1],c=s[1],d=o|c,g=d<(H|le|zt),y=c==zt&&o==Xe||c==zt&&o==ur&&r[7].length<=s[8]||c==(zt|ur)&&s[7].length<=s[8]&&o==Xe;if(!(g||y))return r;c&H&&(r[2]=s[2],d|=o&H?0:Me);var _=s[3];if(_){var w=r[3];r[3]=w?kf(w,_,s[4]):_,r[4]=w?Zn(r[3],E):s[4]}return _=s[5],_&&(w=r[5],r[5]=w?Mf(w,_,s[6]):_,r[6]=w?Zn(r[5],E):s[6]),_=s[7],_&&(r[7]=_),c&zt&&(r[8]=r[8]==null?s[8]:et(r[8],s[8])),r[9]==null&&(r[9]=s[9]),r[0]=s[0],r[1]=d,r}function ly(r){var s=[];if(r!=null)for(var o in ye(r))s.push(o);return s}function cy(r){return xs.call(r)}function jf(r,s,o){return s=He(s===n?r.length-1:s,0),function(){for(var c=arguments,d=-1,g=He(c.length-s,0),y=L(g);++d<g;)y[d]=c[s+d];d=-1;for(var _=L(s+1);++d<s;)_[d]=c[d];return _[s]=o(y),vt(r,this,_)}}function Qf(r,s){return s.length<2?r:gr(r,Ct(s,0,-1))}function fy(r,s){for(var o=r.length,c=et(s.length,o),d=pt(r);c--;){var g=s[c];r[c]=On(g,o)?d[g]:n}return r}function fu(r,s){if(!(s==="constructor"&&typeof r[s]=="function")&&s!="__proto__")return r[s]}var eh=nh(bf),$i=AT||function(r,s){return je.setTimeout(r,s)},hu=nh(MN);function th(r,s,o){var c=s+"";return hu(r,ny(c,hy(QN(c),o)))}function nh(r){var s=0,o=0;return function(){var c=xT(),d=kg-(c-o);if(o=c,d>0){if(++s>=Rg)return arguments[0]}else s=0;return r.apply(n,arguments)}}function ea(r,s){var o=-1,c=r.length,d=c-1;for(s=s===n?c:s;++o<s;){var g=Yo(o,d),y=r[g];r[g]=r[o],r[o]=y}return r.length=s,r}var rh=oy(function(r){var s=[];return r.charCodeAt(0)===46&&s.push(""),r.replace(tE,function(o,c,d,g){s.push(d?g.replace(lE,"$1"):c||o)}),s});function mn(r){if(typeof r=="string"||wt(r))return r;var s=r+"";return s=="0"&&1/r==-cr?"-0":s}function Tr(r){if(r!=null){try{return Os.call(r)}catch{}try{return r+""}catch{}}return""}function hy(r,s){return Rt(Vg,function(o){var c="_."+o[0];s&o[1]&&!ws(r,c)&&r.push(c)}),r.sort()}function ih(r){if(r instanceof ae)return r.clone();var s=new Mt(r.__wrapped__,r.__chain__);return s.__actions__=pt(r.__actions__),s.__index__=r.__index__,s.__values__=r.__values__,s}function dy(r,s,o){(o?ut(r,s,o):s===n)?s=1:s=He(ee(s),0);var c=r==null?0:r.length;if(!c||s<1)return[];for(var d=0,g=0,y=L(Cs(c/s));d<c;)y[g++]=Ct(r,d,d+=s);return y}function py(r){for(var s=-1,o=r==null?0:r.length,c=0,d=[];++s<o;){var g=r[s];g&&(d[c++]=g)}return d}function my(){var r=arguments.length;if(!r)return[];for(var s=L(r-1),o=arguments[0],c=r;c--;)s[c-1]=arguments[c];return Yn(j(o)?pt(o):[o],Qe(s,1))}var gy=ne(function(r,s){return Ue(r)?Pi(r,Qe(s,1,Ue,!0)):[]}),Ey=ne(function(r,s){var o=Ft(s);return Ue(o)&&(o=n),Ue(r)?Pi(r,Qe(s,1,Ue,!0),q(o,2)):[]}),Ty=ne(function(r,s){var o=Ft(s);return Ue(o)&&(o=n),Ue(r)?Pi(r,Qe(s,1,Ue,!0),n,o):[]});function Ny(r,s,o){var c=r==null?0:r.length;return c?(s=o||s===n?1:ee(s),Ct(r,s<0?0:s,c)):[]}function yy(r,s,o){var c=r==null?0:r.length;return c?(s=o||s===n?1:ee(s),s=c-s,Ct(r,0,s<0?0:s)):[]}function vy(r,s){return r&&r.length?qs(r,q(s,3),!0,!0):[]}function _y(r,s){return r&&r.length?qs(r,q(s,3),!0):[]}function by(r,s,o,c){var d=r==null?0:r.length;return d?(o&&typeof o!="number"&&ut(r,s,o)&&(o=0,c=d),mN(r,s,o,c)):[]}function sh(r,s,o){var c=r==null?0:r.length;if(!c)return-1;var d=o==null?0:ee(o);return d<0&&(d=He(c+d,0)),Is(r,q(s,3),d)}function ah(r,s,o){var c=r==null?0:r.length;if(!c)return-1;var d=c-1;return o!==n&&(d=ee(o),d=o<0?He(c+d,0):et(d,c-1)),Is(r,q(s,3),d,!0)}function oh(r){var s=r==null?0:r.length;return s?Qe(r,1):[]}function wy(r){var s=r==null?0:r.length;return s?Qe(r,cr):[]}function Iy(r,s){var o=r==null?0:r.length;return o?(s=s===n?1:ee(s),Qe(r,s)):[]}function Ay(r){for(var s=-1,o=r==null?0:r.length,c={};++s<o;){var d=r[s];c[d[0]]=d[1]}return c}function uh(r){return r&&r.length?r[0]:n}function Ly(r,s,o){var c=r==null?0:r.length;if(!c)return-1;var d=o==null?0:ee(o);return d<0&&(d=He(c+d,0)),Ur(r,s,d)}function Sy(r){var s=r==null?0:r.length;return s?Ct(r,0,-1):[]}var Oy=ne(function(r){var s=Ae(r,Qo);return s.length&&s[0]===r[0]?Wo(s):[]}),xy=ne(function(r){var s=Ft(r),o=Ae(r,Qo);return s===Ft(o)?s=n:o.pop(),o.length&&o[0]===r[0]?Wo(o,q(s,2)):[]}),Dy=ne(function(r){var s=Ft(r),o=Ae(r,Qo);return s=typeof s=="function"?s:n,s&&o.pop(),o.length&&o[0]===r[0]?Wo(o,n,s):[]});function Ry(r,s){return r==null?"":ST.call(r,s)}function Ft(r){var s=r==null?0:r.length;return s?r[s-1]:n}function ky(r,s,o){var c=r==null?0:r.length;if(!c)return-1;var d=c;return o!==n&&(d=ee(o),d=d<0?He(c+d,0):et(d,c-1)),s===s?hT(r,s,d):Is(r,$c,d,!0)}function My(r,s){return r&&r.length?Nf(r,ee(s)):n}var Py=ne(lh);function lh(r,s){return r&&r.length&&s&&s.length?Xo(r,s):r}function Cy(r,s,o){return r&&r.length&&s&&s.length?Xo(r,s,q(o,2)):r}function Fy(r,s,o){return r&&r.length&&s&&s.length?Xo(r,s,n,o):r}var Uy=Sn(function(r,s){var o=r==null?0:r.length,c=Vo(r,s);return _f(r,Ae(s,function(d){return On(d,o)?+d:d}).sort(Rf)),c});function Vy(r,s){var o=[];if(!(r&&r.length))return o;var c=-1,d=[],g=r.length;for(s=q(s,3);++c<g;){var y=r[c];s(y,c,r)&&(o.push(y),d.push(c))}return _f(r,d),o}function du(r){return r==null?r:RT.call(r)}function By(r,s,o){var c=r==null?0:r.length;return c?(o&&typeof o!="number"&&ut(r,s,o)?(s=0,o=c):(s=s==null?0:ee(s),o=o===n?c:ee(o)),Ct(r,s,o)):[]}function $y(r,s){return zs(r,s)}function Gy(r,s,o){return Ko(r,s,q(o,2))}function Wy(r,s){var o=r==null?0:r.length;if(o){var c=zs(r,s);if(c<o&&Kt(r[c],s))return c}return-1}function Hy(r,s){return zs(r,s,!0)}function zy(r,s,o){return Ko(r,s,q(o,2),!0)}function qy(r,s){var o=r==null?0:r.length;if(o){var c=zs(r,s,!0)-1;if(Kt(r[c],s))return c}return-1}function Xy(r){return r&&r.length?wf(r):[]}function Yy(r,s){return r&&r.length?wf(r,q(s,2)):[]}function Zy(r){var s=r==null?0:r.length;return s?Ct(r,1,s):[]}function Ky(r,s,o){return r&&r.length?(s=o||s===n?1:ee(s),Ct(r,0,s<0?0:s)):[]}function Jy(r,s,o){var c=r==null?0:r.length;return c?(s=o||s===n?1:ee(s),s=c-s,Ct(r,s<0?0:s,c)):[]}function jy(r,s){return r&&r.length?qs(r,q(s,3),!1,!0):[]}function Qy(r,s){return r&&r.length?qs(r,q(s,3)):[]}var ev=ne(function(r){return jn(Qe(r,1,Ue,!0))}),tv=ne(function(r){var s=Ft(r);return Ue(s)&&(s=n),jn(Qe(r,1,Ue,!0),q(s,2))}),nv=ne(function(r){var s=Ft(r);return s=typeof s=="function"?s:n,jn(Qe(r,1,Ue,!0),n,s)});function rv(r){return r&&r.length?jn(r):[]}function iv(r,s){return r&&r.length?jn(r,q(s,2)):[]}function sv(r,s){return s=typeof s=="function"?s:n,r&&r.length?jn(r,n,s):[]}function pu(r){if(!(r&&r.length))return[];var s=0;return r=Xn(r,function(o){if(Ue(o))return s=He(o.length,s),!0}),Do(s,function(o){return Ae(r,So(o))})}function ch(r,s){if(!(r&&r.length))return[];var o=pu(r);return s==null?o:Ae(o,function(c){return vt(s,n,c)})}var av=ne(function(r,s){return Ue(r)?Pi(r,s):[]}),ov=ne(function(r){return jo(Xn(r,Ue))}),uv=ne(function(r){var s=Ft(r);return Ue(s)&&(s=n),jo(Xn(r,Ue),q(s,2))}),lv=ne(function(r){var s=Ft(r);return s=typeof s=="function"?s:n,jo(Xn(r,Ue),n,s)}),cv=ne(pu);function fv(r,s){return Sf(r||[],s||[],Mi)}function hv(r,s){return Sf(r||[],s||[],Ui)}var dv=ne(function(r){var s=r.length,o=s>1?r[s-1]:n;return o=typeof o=="function"?(r.pop(),o):n,ch(r,o)});function fh(r){var s=p(r);return s.__chain__=!0,s}function pv(r,s){return s(r),r}function ta(r,s){return s(r)}var mv=Sn(function(r){var s=r.length,o=s?r[0]:0,c=this.__wrapped__,d=function(g){return Vo(g,r)};return s>1||this.__actions__.length||!(c instanceof ae)||!On(o)?this.thru(d):(c=c.slice(o,+o+(s?1:0)),c.__actions__.push({func:ta,args:[d],thisArg:n}),new Mt(c,this.__chain__).thru(function(g){return s&&!g.length&&g.push(n),g}))});function gv(){return fh(this)}function Ev(){return new Mt(this.value(),this.__chain__)}function Tv(){this.__values__===n&&(this.__values__=Ih(this.value()));var r=this.__index__>=this.__values__.length,s=r?n:this.__values__[this.__index__++];return{done:r,value:s}}function Nv(){return this}function yv(r){for(var s,o=this;o instanceof Bs;){var c=ih(o);c.__index__=0,c.__values__=n,s?d.__wrapped__=c:s=c;var d=c;o=o.__wrapped__}return d.__wrapped__=r,s}function vv(){var r=this.__wrapped__;if(r instanceof ae){var s=r;return this.__actions__.length&&(s=new ae(this)),s=s.reverse(),s.__actions__.push({func:ta,args:[du],thisArg:n}),new Mt(s,this.__chain__)}return this.thru(du)}function _v(){return Lf(this.__wrapped__,this.__actions__)}var bv=Xs(function(r,s,o){Ee.call(r,o)?++r[o]:An(r,o,1)});function wv(r,s,o){var c=j(r)?Vc:pN;return o&&ut(r,s,o)&&(s=n),c(r,q(s,3))}function Iv(r,s){var o=j(r)?Xn:cf;return o(r,q(s,3))}var Av=Uf(sh),Lv=Uf(ah);function Sv(r,s){return Qe(na(r,s),1)}function Ov(r,s){return Qe(na(r,s),cr)}function xv(r,s,o){return o=o===n?1:ee(o),Qe(na(r,s),o)}function hh(r,s){var o=j(r)?Rt:Jn;return o(r,q(s,3))}function dh(r,s){var o=j(r)?ZE:lf;return o(r,q(s,3))}var Dv=Xs(function(r,s,o){Ee.call(r,o)?r[o].push(s):An(r,o,[s])});function Rv(r,s,o,c){r=mt(r)?r:Kr(r),o=o&&!c?ee(o):0;var d=r.length;return o<0&&(o=He(d+o,0)),oa(r)?o<=d&&r.indexOf(s,o)>-1:!!d&&Ur(r,s,o)>-1}var kv=ne(function(r,s,o){var c=-1,d=typeof s=="function",g=mt(r)?L(r.length):[];return Jn(r,function(y){g[++c]=d?vt(s,y,o):Ci(y,s,o)}),g}),Mv=Xs(function(r,s,o){An(r,o,s)});function na(r,s){var o=j(r)?Ae:gf;return o(r,q(s,3))}function Pv(r,s,o,c){return r==null?[]:(j(s)||(s=s==null?[]:[s]),o=c?n:o,j(o)||(o=o==null?[]:[o]),yf(r,s,o))}var Cv=Xs(function(r,s,o){r[o?0:1].push(s)},function(){return[[],[]]});function Fv(r,s,o){var c=j(r)?Ao:Wc,d=arguments.length<3;return c(r,q(s,4),o,d,Jn)}function Uv(r,s,o){var c=j(r)?KE:Wc,d=arguments.length<3;return c(r,q(s,4),o,d,lf)}function Vv(r,s){var o=j(r)?Xn:cf;return o(r,sa(q(s,3)))}function Bv(r){var s=j(r)?sf:RN;return s(r)}function $v(r,s,o){(o?ut(r,s,o):s===n)?s=1:s=ee(s);var c=j(r)?lN:kN;return c(r,s)}function Gv(r){var s=j(r)?cN:PN;return s(r)}function Wv(r){if(r==null)return 0;if(mt(r))return oa(r)?Br(r):r.length;var s=tt(r);return s==qt||s==Xt?r.size:zo(r).length}function Hv(r,s,o){var c=j(r)?Lo:CN;return o&&ut(r,s,o)&&(s=n),c(r,q(s,3))}var zv=ne(function(r,s){if(r==null)return[];var o=s.length;return o>1&&ut(r,s[0],s[1])?s=[]:o>2&&ut(s[0],s[1],s[2])&&(s=[s[0]]),yf(r,Qe(s,1),[])}),ra=IT||function(){return je.Date.now()};function qv(r,s){if(typeof s!="function")throw new kt(l);return r=ee(r),function(){if(--r<1)return s.apply(this,arguments)}}function ph(r,s,o){return s=o?n:s,s=r&&s==null?r.length:s,Ln(r,zt,n,n,n,n,s)}function mh(r,s){var o;if(typeof s!="function")throw new kt(l);return r=ee(r),function(){return--r>0&&(o=s.apply(this,arguments)),r<=1&&(s=n),o}}var mu=ne(function(r,s,o){var c=H;if(o.length){var d=Zn(o,Yr(mu));c|=Je}return Ln(r,c,s,o,d)}),gh=ne(function(r,s,o){var c=H|le;if(o.length){var d=Zn(o,Yr(gh));c|=Je}return Ln(s,c,r,o,d)});function Eh(r,s,o){s=o?n:s;var c=Ln(r,Xe,n,n,n,n,n,s);return c.placeholder=Eh.placeholder,c}function Th(r,s,o){s=o?n:s;var c=Ln(r,at,n,n,n,n,n,s);return c.placeholder=Th.placeholder,c}function Nh(r,s,o){var c,d,g,y,_,w,x=0,D=!1,R=!1,P=!0;if(typeof r!="function")throw new kt(l);s=Ut(s)||0,Re(o)&&(D=!!o.leading,R="maxWait"in o,g=R?He(Ut(o.maxWait)||0,s):g,P="trailing"in o?!!o.trailing:P);function $(Ve){var Jt=c,Rn=d;return c=d=n,x=Ve,y=r.apply(Rn,Jt),y}function X(Ve){return x=Ve,_=$i(ie,s),D?$(Ve):y}function te(Ve){var Jt=Ve-w,Rn=Ve-x,Uh=s-Jt;return R?et(Uh,g-Rn):Uh}function Y(Ve){var Jt=Ve-w,Rn=Ve-x;return w===n||Jt>=s||Jt<0||R&&Rn>=g}function ie(){var Ve=ra();if(Y(Ve))return oe(Ve);_=$i(ie,te(Ve))}function oe(Ve){return _=n,P&&c?$(Ve):(c=d=n,y)}function It(){_!==n&&Of(_),x=0,c=w=d=_=n}function lt(){return _===n?y:oe(ra())}function At(){var Ve=ra(),Jt=Y(Ve);if(c=arguments,d=this,w=Ve,Jt){if(_===n)return X(w);if(R)return Of(_),_=$i(ie,s),$(w)}return _===n&&(_=$i(ie,s)),y}return At.cancel=It,At.flush=lt,At}var Xv=ne(function(r,s){return uf(r,1,s)}),Yv=ne(function(r,s,o){return uf(r,Ut(s)||0,o)});function Zv(r){return Ln(r,_n)}function ia(r,s){if(typeof r!="function"||s!=null&&typeof s!="function")throw new kt(l);var o=function(){var c=arguments,d=s?s.apply(this,c):c[0],g=o.cache;if(g.has(d))return g.get(d);var y=r.apply(this,c);return o.cache=g.set(d,y)||g,y};return o.cache=new(ia.Cache||In),o}ia.Cache=In;function sa(r){if(typeof r!="function")throw new kt(l);return function(){var s=arguments;switch(s.length){case 0:return!r.call(this);case 1:return!r.call(this,s[0]);case 2:return!r.call(this,s[0],s[1]);case 3:return!r.call(this,s[0],s[1],s[2])}return!r.apply(this,s)}}function Kv(r){return mh(2,r)}var Jv=FN(function(r,s){s=s.length==1&&j(s[0])?Ae(s[0],_t(q())):Ae(Qe(s,1),_t(q()));var o=s.length;return ne(function(c){for(var d=-1,g=et(c.length,o);++d<g;)c[d]=s[d].call(this,c[d]);return vt(r,this,c)})}),gu=ne(function(r,s){var o=Zn(s,Yr(gu));return Ln(r,Je,n,s,o)}),yh=ne(function(r,s){var o=Zn(s,Yr(yh));return Ln(r,or,n,s,o)}),jv=Sn(function(r,s){return Ln(r,ur,n,n,n,s)});function Qv(r,s){if(typeof r!="function")throw new kt(l);return s=s===n?s:ee(s),ne(r,s)}function e_(r,s){if(typeof r!="function")throw new kt(l);return s=s==null?0:He(ee(s),0),ne(function(o){var c=o[s],d=er(o,0,s);return c&&Yn(d,c),vt(r,this,d)})}function t_(r,s,o){var c=!0,d=!0;if(typeof r!="function")throw new kt(l);return Re(o)&&(c="leading"in o?!!o.leading:c,d="trailing"in o?!!o.trailing:d),Nh(r,s,{leading:c,maxWait:s,trailing:d})}function n_(r){return ph(r,1)}function r_(r,s){return gu(eu(s),r)}function i_(){if(!arguments.length)return[];var r=arguments[0];return j(r)?r:[r]}function s_(r){return Pt(r,O)}function a_(r,s){return s=typeof s=="function"?s:n,Pt(r,O,s)}function o_(r){return Pt(r,T|O)}function u_(r,s){return s=typeof s=="function"?s:n,Pt(r,T|O,s)}function l_(r,s){return s==null||of(r,s,Ye(s))}function Kt(r,s){return r===s||r!==r&&s!==s}var c_=Js(Go),f_=Js(function(r,s){return r>=s}),Nr=df(function(){return arguments}())?df:function(r){return Pe(r)&&Ee.call(r,"callee")&&!jc.call(r,"callee")},j=L.isArray,h_=kc?_t(kc):yN;function mt(r){return r!=null&&aa(r.length)&&!xn(r)}function Ue(r){return Pe(r)&&mt(r)}function d_(r){return r===!0||r===!1||Pe(r)&&ot(r)==vi}var tr=LT||Lu,p_=Mc?_t(Mc):vN;function m_(r){return Pe(r)&&r.nodeType===1&&!Gi(r)}function g_(r){if(r==null)return!0;if(mt(r)&&(j(r)||typeof r=="string"||typeof r.splice=="function"||tr(r)||Zr(r)||Nr(r)))return!r.length;var s=tt(r);if(s==qt||s==Xt)return!r.size;if(Bi(r))return!zo(r).length;for(var o in r)if(Ee.call(r,o))return!1;return!0}function E_(r,s){return Fi(r,s)}function T_(r,s,o){o=typeof o=="function"?o:n;var c=o?o(r,s):n;return c===n?Fi(r,s,n,o):!!c}function Eu(r){if(!Pe(r))return!1;var s=ot(r);return s==Ts||s==$g||typeof r.message=="string"&&typeof r.name=="string"&&!Gi(r)}function N_(r){return typeof r=="number"&&ef(r)}function xn(r){if(!Re(r))return!1;var s=ot(r);return s==Ns||s==oc||s==Bg||s==Wg}function vh(r){return typeof r=="number"&&r==ee(r)}function aa(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=qn}function Re(r){var s=typeof r;return r!=null&&(s=="object"||s=="function")}function Pe(r){return r!=null&&typeof r=="object"}var _h=Pc?_t(Pc):bN;function y_(r,s){return r===s||Ho(r,s,ou(s))}function v_(r,s,o){return o=typeof o=="function"?o:n,Ho(r,s,ou(s),o)}function __(r){return bh(r)&&r!=+r}function b_(r){if(ay(r))throw new J(u);return pf(r)}function w_(r){return r===null}function I_(r){return r==null}function bh(r){return typeof r=="number"||Pe(r)&&ot(r)==bi}function Gi(r){if(!Pe(r)||ot(r)!=bn)return!1;var s=ks(r);if(s===null)return!0;var o=Ee.call(s,"constructor")&&s.constructor;return typeof o=="function"&&o instanceof o&&Os.call(o)==vT}var Tu=Cc?_t(Cc):wN;function A_(r){return vh(r)&&r>=-qn&&r<=qn}var wh=Fc?_t(Fc):IN;function oa(r){return typeof r=="string"||!j(r)&&Pe(r)&&ot(r)==Ii}function wt(r){return typeof r=="symbol"||Pe(r)&&ot(r)==ys}var Zr=Uc?_t(Uc):AN;function L_(r){return r===n}function S_(r){return Pe(r)&&tt(r)==Ai}function O_(r){return Pe(r)&&ot(r)==zg}var x_=Js(qo),D_=Js(function(r,s){return r<=s});function Ih(r){if(!r)return[];if(mt(r))return oa(r)?Yt(r):pt(r);if(Oi&&r[Oi])return lT(r[Oi]());var s=tt(r),o=s==qt?ko:s==Xt?As:Kr;return o(r)}function Dn(r){if(!r)return r===0?r:0;if(r=Ut(r),r===cr||r===-cr){var s=r<0?-1:1;return s*Cg}return r===r?r:0}function ee(r){var s=Dn(r),o=s%1;return s===s?o?s-o:s:0}function Ah(r){return r?mr(ee(r),0,hn):0}function Ut(r){if(typeof r=="number")return r;if(wt(r))return gs;if(Re(r)){var s=typeof r.valueOf=="function"?r.valueOf():r;r=Re(s)?s+"":s}if(typeof r!="string")return r===0?r:+r;r=Hc(r);var o=hE.test(r);return o||pE.test(r)?qE(r.slice(2),o?2:8):fE.test(r)?gs:+r}function Lh(r){return pn(r,gt(r))}function R_(r){return r?mr(ee(r),-qn,qn):r===0?r:0}function pe(r){return r==null?"":bt(r)}var k_=qr(function(r,s){if(Bi(s)||mt(s)){pn(s,Ye(s),r);return}for(var o in s)Ee.call(s,o)&&Mi(r,o,s[o])}),Sh=qr(function(r,s){pn(s,gt(s),r)}),ua=qr(function(r,s,o,c){pn(s,gt(s),r,c)}),M_=qr(function(r,s,o,c){pn(s,Ye(s),r,c)}),P_=Sn(Vo);function C_(r,s){var o=zr(r);return s==null?o:af(o,s)}var F_=ne(function(r,s){r=ye(r);var o=-1,c=s.length,d=c>2?s[2]:n;for(d&&ut(s[0],s[1],d)&&(c=1);++o<c;)for(var g=s[o],y=gt(g),_=-1,w=y.length;++_<w;){var x=y[_],D=r[x];(D===n||Kt(D,Gr[x])&&!Ee.call(r,x))&&(r[x]=g[x])}return r}),U_=ne(function(r){return r.push(n,zf),vt(Oh,n,r)});function V_(r,s){return Bc(r,q(s,3),dn)}function B_(r,s){return Bc(r,q(s,3),$o)}function $_(r,s){return r==null?r:Bo(r,q(s,3),gt)}function G_(r,s){return r==null?r:ff(r,q(s,3),gt)}function W_(r,s){return r&&dn(r,q(s,3))}function H_(r,s){return r&&$o(r,q(s,3))}function z_(r){return r==null?[]:Ws(r,Ye(r))}function q_(r){return r==null?[]:Ws(r,gt(r))}function Nu(r,s,o){var c=r==null?n:gr(r,s);return c===n?o:c}function X_(r,s){return r!=null&&Yf(r,s,gN)}function yu(r,s){return r!=null&&Yf(r,s,EN)}var Y_=Bf(function(r,s,o){s!=null&&typeof s.toString!="function"&&(s=xs.call(s)),r[s]=o},_u(Et)),Z_=Bf(function(r,s,o){s!=null&&typeof s.toString!="function"&&(s=xs.call(s)),Ee.call(r,s)?r[s].push(o):r[s]=[o]},q),K_=ne(Ci);function Ye(r){return mt(r)?rf(r):zo(r)}function gt(r){return mt(r)?rf(r,!0):LN(r)}function J_(r,s){var o={};return s=q(s,3),dn(r,function(c,d,g){An(o,s(c,d,g),c)}),o}function j_(r,s){var o={};return s=q(s,3),dn(r,function(c,d,g){An(o,d,s(c,d,g))}),o}var Q_=qr(function(r,s,o){Hs(r,s,o)}),Oh=qr(function(r,s,o,c){Hs(r,s,o,c)}),eb=Sn(function(r,s){var o={};if(r==null)return o;var c=!1;s=Ae(s,function(g){return g=Qn(g,r),c||(c=g.length>1),g}),pn(r,su(r),o),c&&(o=Pt(o,T|A|O,YN));for(var d=s.length;d--;)Jo(o,s[d]);return o});function tb(r,s){return xh(r,sa(q(s)))}var nb=Sn(function(r,s){return r==null?{}:ON(r,s)});function xh(r,s){if(r==null)return{};var o=Ae(su(r),function(c){return[c]});return s=q(s),vf(r,o,function(c,d){return s(c,d[0])})}function rb(r,s,o){s=Qn(s,r);var c=-1,d=s.length;for(d||(d=1,r=n);++c<d;){var g=r==null?n:r[mn(s[c])];g===n&&(c=d,g=o),r=xn(g)?g.call(r):g}return r}function ib(r,s,o){return r==null?r:Ui(r,s,o)}function sb(r,s,o,c){return c=typeof c=="function"?c:n,r==null?r:Ui(r,s,o,c)}var Dh=Wf(Ye),Rh=Wf(gt);function ab(r,s,o){var c=j(r),d=c||tr(r)||Zr(r);if(s=q(s,4),o==null){var g=r&&r.constructor;d?o=c?new g:[]:Re(r)?o=xn(g)?zr(ks(r)):{}:o={}}return(d?Rt:dn)(r,function(y,_,w){return s(o,y,_,w)}),o}function ob(r,s){return r==null?!0:Jo(r,s)}function ub(r,s,o){return r==null?r:Af(r,s,eu(o))}function lb(r,s,o,c){return c=typeof c=="function"?c:n,r==null?r:Af(r,s,eu(o),c)}function Kr(r){return r==null?[]:Ro(r,Ye(r))}function cb(r){return r==null?[]:Ro(r,gt(r))}function fb(r,s,o){return o===n&&(o=s,s=n),o!==n&&(o=Ut(o),o=o===o?o:0),s!==n&&(s=Ut(s),s=s===s?s:0),mr(Ut(r),s,o)}function hb(r,s,o){return s=Dn(s),o===n?(o=s,s=0):o=Dn(o),r=Ut(r),TN(r,s,o)}function db(r,s,o){if(o&&typeof o!="boolean"&&ut(r,s,o)&&(s=o=n),o===n&&(typeof s=="boolean"?(o=s,s=n):typeof r=="boolean"&&(o=r,r=n)),r===n&&s===n?(r=0,s=1):(r=Dn(r),s===n?(s=r,r=0):s=Dn(s)),r>s){var c=r;r=s,s=c}if(o||r%1||s%1){var d=tf();return et(r+d*(s-r+zE("1e-"+((d+"").length-1))),s)}return Yo(r,s)}var pb=Xr(function(r,s,o){return s=s.toLowerCase(),r+(o?kh(s):s)});function kh(r){return vu(pe(r).toLowerCase())}function Mh(r){return r=pe(r),r&&r.replace(gE,iT).replace(PE,"")}function mb(r,s,o){r=pe(r),s=bt(s);var c=r.length;o=o===n?c:mr(ee(o),0,c);var d=o;return o-=s.length,o>=0&&r.slice(o,d)==s}function gb(r){return r=pe(r),r&&Kg.test(r)?r.replace(cc,sT):r}function Eb(r){return r=pe(r),r&&nE.test(r)?r.replace(go,"\\$&"):r}var Tb=Xr(function(r,s,o){return r+(o?"-":"")+s.toLowerCase()}),Nb=Xr(function(r,s,o){return r+(o?" ":"")+s.toLowerCase()}),yb=Ff("toLowerCase");function vb(r,s,o){r=pe(r),s=ee(s);var c=s?Br(r):0;if(!s||c>=s)return r;var d=(s-c)/2;return Ks(Fs(d),o)+r+Ks(Cs(d),o)}function _b(r,s,o){r=pe(r),s=ee(s);var c=s?Br(r):0;return s&&c<s?r+Ks(s-c,o):r}function bb(r,s,o){r=pe(r),s=ee(s);var c=s?Br(r):0;return s&&c<s?Ks(s-c,o)+r:r}function wb(r,s,o){return o||s==null?s=0:s&&(s=+s),DT(pe(r).replace(Eo,""),s||0)}function Ib(r,s,o){return(o?ut(r,s,o):s===n)?s=1:s=ee(s),Zo(pe(r),s)}function Ab(){var r=arguments,s=pe(r[0]);return r.length<3?s:s.replace(r[1],r[2])}var Lb=Xr(function(r,s,o){return r+(o?"_":"")+s.toLowerCase()});function Sb(r,s,o){return o&&typeof o!="number"&&ut(r,s,o)&&(s=o=n),o=o===n?hn:o>>>0,o?(r=pe(r),r&&(typeof s=="string"||s!=null&&!Tu(s))&&(s=bt(s),!s&&Vr(r))?er(Yt(r),0,o):r.split(s,o)):[]}var Ob=Xr(function(r,s,o){return r+(o?" ":"")+vu(s)});function xb(r,s,o){return r=pe(r),o=o==null?0:mr(ee(o),0,r.length),s=bt(s),r.slice(o,o+s.length)==s}function Db(r,s,o){var c=p.templateSettings;o&&ut(r,s,o)&&(s=n),r=pe(r),s=ua({},s,c,Hf);var d=ua({},s.imports,c.imports,Hf),g=Ye(d),y=Ro(d,g),_,w,x=0,D=s.interpolate||vs,R="__p += '",P=Mo((s.escape||vs).source+"|"+D.source+"|"+(D===fc?cE:vs).source+"|"+(s.evaluate||vs).source+"|$","g"),$="//# sourceURL="+(Ee.call(s,"sourceURL")?(s.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++BE+"]")+`
|
|
12
|
+
`;r.replace(P,function(Y,ie,oe,It,lt,At){return oe||(oe=It),R+=r.slice(x,At).replace(EE,aT),ie&&(_=!0,R+=`' +
|
|
13
|
+
__e(`+ie+`) +
|
|
14
|
+
'`),lt&&(w=!0,R+=`';
|
|
15
|
+
`+lt+`;
|
|
16
|
+
__p += '`),oe&&(R+=`' +
|
|
17
|
+
((__t = (`+oe+`)) == null ? '' : __t) +
|
|
18
|
+
'`),x=At+Y.length,Y}),R+=`';
|
|
19
|
+
`;var X=Ee.call(s,"variable")&&s.variable;if(!X)R=`with (obj) {
|
|
20
|
+
`+R+`
|
|
21
21
|
}
|
|
22
|
-
`;else if(
|
|
23
|
-
`+(
|
|
24
|
-
`)+"var __t, __p = ''"+(
|
|
22
|
+
`;else if(uE.test(X))throw new J(f);R=(w?R.replace(qg,""):R).replace(Xg,"$1").replace(Yg,"$1;"),R="function("+(X||"obj")+`) {
|
|
23
|
+
`+(X?"":`obj || (obj = {});
|
|
24
|
+
`)+"var __t, __p = ''"+(_?", __e = _.escape":"")+(w?`, __j = Array.prototype.join;
|
|
25
25
|
function print() { __p += __j.call(arguments, '') }
|
|
26
26
|
`:`;
|
|
27
|
-
`)+
|
|
28
|
-
}`;var K=Wl(function(){return ie(p,k+"return "+O).apply(i,E)});if(K.source=O,ma(K))throw K;return K}function XN(e){return ae(e).toLowerCase()}function HN(e){return ae(e).toUpperCase()}function qN(e,n,a){if(e=ae(e),e&&(a||n===i))return Zo(e);if(!e||!(n=rt(n)))return e;var u=At(e),c=At(n),p=jo(u,c),E=eu(u,c)+1;return Tn(u,p,E).join("")}function zN(e,n,a){if(e=ae(e),e&&(a||n===i))return e.slice(0,nu(e)+1);if(!e||!(n=rt(n)))return e;var u=At(e),c=eu(u,At(n))+1;return Tn(u,0,c).join("")}function KN(e,n,a){if(e=ae(e),e&&(a||n===i))return e.replace(ms,"");if(!e||!(n=rt(n)))return e;var u=At(e),c=jo(u,At(n));return Tn(u,c).join("")}function YN(e,n){var a=$f,u=Wf;if(ge(n)){var c="separator"in n?n.separator:c;a="length"in n?z(n.length):a,u="omission"in n?rt(n.omission):u}e=ae(e);var p=e.length;if(zn(e)){var E=At(e);p=E.length}if(a>=p)return e;var N=a-Kn(u);if(N<1)return u;var b=E?Tn(E,0,N).join(""):e.slice(0,N);if(c===i)return b+u;if(E&&(N+=b.length-N),Ia(c)){if(e.slice(N).search(c)){var x,S=b;for(c.global||(c=Bs(c.source,ae(vo.exec(c))+"g")),c.lastIndex=0;x=c.exec(S);)var O=x.index;b=b.slice(0,O===i?N:O)}}else if(e.indexOf(rt(c),N)!=N){var R=b.lastIndexOf(c);R>-1&&(b=b.slice(0,R))}return b+u}function JN(e){return e=ae(e),e&&oh.test(e)?e.replace(go,wp):e}var QN=tr(function(e,n,a){return e+(a?" ":"")+n.toUpperCase()}),La=Xu("toUpperCase");function $l(e,n,a){return e=ae(e),n=a?i:n,n===i?vp(e)?xp(e):fp(e):e.match(n)||[]}var Wl=Y(function(e,n){try{return tt(e,i,n)}catch(a){return ma(a)?a:new X(a)}}),ZN=Zt(function(e,n){return dt(n,function(a){a=kt(a),Jt(e,a,va(e[a],e))}),e});function jN(e){var n=e==null?0:e.length,a=B();return e=n?Ee(e,function(u){if(typeof u[1]!="function")throw new Et(f);return[a(u[0]),u[1]]}):[],Y(function(u){for(var c=-1;++c<n;){var p=e[c];if(tt(p[0],this,u))return tt(p[1],this,u)}})}function eT(e){return wd(gt(e,y))}function ya(e){return function(){return e}}function tT(e,n){return e==null||e!==e?n:e}var nT=qu(),rT=qu(!0);function Qe(e){return e}function xa(e){return mu(typeof e=="function"?e:gt(e,y))}function iT(e){return Au(gt(e,y))}function sT(e,n){return wu(e,gt(n,y))}var aT=Y(function(e,n){return function(a){return Pr(a,e,n)}}),oT=Y(function(e,n){return function(a){return Pr(e,a,n)}});function Sa(e,n,a){var u=Oe(n),c=Li(n,u);a==null&&!(ge(n)&&(c.length||!u.length))&&(a=n,n=e,e=this,c=Li(n,Oe(n)));var p=!(ge(a)&&"chain"in a)||!!a.chain,E=en(e);return dt(c,function(N){var b=n[N];e[N]=b,E&&(e.prototype[N]=function(){var x=this.__chain__;if(p||x){var S=e(this.__wrapped__),O=S.__actions__=Ke(this.__actions__);return O.push({func:b,args:arguments,thisArg:e}),S.__chain__=x,S}return b.apply(e,pn([this.value()],arguments))})}),e}function uT(){return Re._===this&&(Re._=Mp),this}function Oa(){}function lT(e){return e=z(e),Y(function(n){return Lu(n,e)})}var cT=oa(Ee),fT=oa(zo),hT=oa(Rs);function Xl(e){return da(e)?Ds(kt(e)):$d(e)}function pT(e){return function(n){return e==null?i:Pn(e,n)}}var dT=Ku(),ET=Ku(!0);function Pa(){return[]}function Ra(){return!1}function _T(){return{}}function gT(){return""}function NT(){return!0}function TT(e,n){if(e=z(e),e<1||e>fn)return[];var a=Dt,u=Ce(e,Dt);n=B(n),e-=Dt;for(var c=ks(u,n);++a<e;)n(a);return c}function vT(e){return H(e)?Ee(e,kt):it(e)?[e]:Ke(cl(ae(e)))}function bT(e){var n=++Rp;return ae(e)+n}var mT=Ri(function(e,n){return e+n},0),IT=ua("ceil"),AT=Ri(function(e,n){return e/n},1),wT=ua("floor");function LT(e){return e&&e.length?wi(e,Qe,zs):i}function yT(e,n){return e&&e.length?wi(e,B(n,2),zs):i}function xT(e){return Jo(e,Qe)}function ST(e,n){return Jo(e,B(n,2))}function OT(e){return e&&e.length?wi(e,Qe,Qs):i}function PT(e,n){return e&&e.length?wi(e,B(n,2),Qs):i}var RT=Ri(function(e,n){return e*n},1),DT=ua("round"),MT=Ri(function(e,n){return e-n},0);function UT(e){return e&&e.length?Us(e,Qe):0}function kT(e,n){return e&&e.length?Us(e,B(n,2)):0}return h.after=ig,h.ary=bl,h.assign=Hg,h.assignIn=Ul,h.assignInWith=Hi,h.assignWith=qg,h.at=zg,h.before=ml,h.bind=va,h.bindAll=ZN,h.bindKey=Il,h.castArray=_g,h.chain=Nl,h.chunk=wE,h.compact=LE,h.concat=yE,h.cond=jN,h.conforms=eT,h.constant=ya,h.countBy=U_,h.create=Kg,h.curry=Al,h.curryRight=wl,h.debounce=Ll,h.defaults=Yg,h.defaultsDeep=Jg,h.defer=sg,h.delay=ag,h.difference=xE,h.differenceBy=SE,h.differenceWith=OE,h.drop=PE,h.dropRight=RE,h.dropRightWhile=DE,h.dropWhile=ME,h.fill=UE,h.filter=F_,h.flatMap=G_,h.flatMapDeep=V_,h.flatMapDepth=$_,h.flatten=dl,h.flattenDeep=kE,h.flattenDepth=FE,h.flip=og,h.flow=nT,h.flowRight=rT,h.fromPairs=CE,h.functions=rN,h.functionsIn=iN,h.groupBy=W_,h.initial=GE,h.intersection=VE,h.intersectionBy=$E,h.intersectionWith=WE,h.invert=aN,h.invertBy=oN,h.invokeMap=H_,h.iteratee=xa,h.keyBy=q_,h.keys=Oe,h.keysIn=Je,h.map=Bi,h.mapKeys=lN,h.mapValues=cN,h.matches=iT,h.matchesProperty=sT,h.memoize=Vi,h.merge=fN,h.mergeWith=kl,h.method=aT,h.methodOf=oT,h.mixin=Sa,h.negate=$i,h.nthArg=lT,h.omit=hN,h.omitBy=pN,h.once=ug,h.orderBy=z_,h.over=cT,h.overArgs=lg,h.overEvery=fT,h.overSome=hT,h.partial=ba,h.partialRight=yl,h.partition=K_,h.pick=dN,h.pickBy=Fl,h.property=Xl,h.propertyOf=pT,h.pull=zE,h.pullAll=_l,h.pullAllBy=KE,h.pullAllWith=YE,h.pullAt=JE,h.range=dT,h.rangeRight=ET,h.rearg=cg,h.reject=Q_,h.remove=QE,h.rest=fg,h.reverse=Na,h.sampleSize=j_,h.set=_N,h.setWith=gN,h.shuffle=eg,h.slice=ZE,h.sortBy=rg,h.sortedUniq=s_,h.sortedUniqBy=a_,h.split=GN,h.spread=hg,h.tail=o_,h.take=u_,h.takeRight=l_,h.takeRightWhile=c_,h.takeWhile=f_,h.tap=L_,h.throttle=pg,h.thru=Ci,h.toArray=Rl,h.toPairs=Cl,h.toPairsIn=Bl,h.toPath=vT,h.toPlainObject=Ml,h.transform=NN,h.unary=dg,h.union=h_,h.unionBy=p_,h.unionWith=d_,h.uniq=E_,h.uniqBy=__,h.uniqWith=g_,h.unset=TN,h.unzip=Ta,h.unzipWith=gl,h.update=vN,h.updateWith=bN,h.values=ir,h.valuesIn=mN,h.without=N_,h.words=$l,h.wrap=Eg,h.xor=T_,h.xorBy=v_,h.xorWith=b_,h.zip=m_,h.zipObject=I_,h.zipObjectDeep=A_,h.zipWith=w_,h.entries=Cl,h.entriesIn=Bl,h.extend=Ul,h.extendWith=Hi,Sa(h,h),h.add=mT,h.attempt=Wl,h.camelCase=LN,h.capitalize=Gl,h.ceil=IT,h.clamp=IN,h.clone=gg,h.cloneDeep=Tg,h.cloneDeepWith=vg,h.cloneWith=Ng,h.conformsTo=bg,h.deburr=Vl,h.defaultTo=tT,h.divide=AT,h.endsWith=yN,h.eq=Lt,h.escape=xN,h.escapeRegExp=SN,h.every=k_,h.find=C_,h.findIndex=hl,h.findKey=Qg,h.findLast=B_,h.findLastIndex=pl,h.findLastKey=Zg,h.floor=wT,h.forEach=Tl,h.forEachRight=vl,h.forIn=jg,h.forInRight=eN,h.forOwn=tN,h.forOwnRight=nN,h.get=Aa,h.gt=mg,h.gte=Ig,h.has=sN,h.hasIn=wa,h.head=El,h.identity=Qe,h.includes=X_,h.indexOf=BE,h.inRange=AN,h.invoke=uN,h.isArguments=Mn,h.isArray=H,h.isArrayBuffer=Ag,h.isArrayLike=Ye,h.isArrayLikeObject=Ie,h.isBoolean=wg,h.isBuffer=vn,h.isDate=Lg,h.isElement=yg,h.isEmpty=xg,h.isEqual=Sg,h.isEqualWith=Og,h.isError=ma,h.isFinite=Pg,h.isFunction=en,h.isInteger=xl,h.isLength=Wi,h.isMap=Sl,h.isMatch=Rg,h.isMatchWith=Dg,h.isNaN=Mg,h.isNative=Ug,h.isNil=Fg,h.isNull=kg,h.isNumber=Ol,h.isObject=ge,h.isObjectLike=ve,h.isPlainObject=Fr,h.isRegExp=Ia,h.isSafeInteger=Cg,h.isSet=Pl,h.isString=Xi,h.isSymbol=it,h.isTypedArray=rr,h.isUndefined=Bg,h.isWeakMap=Gg,h.isWeakSet=Vg,h.join=XE,h.kebabCase=ON,h.last=Tt,h.lastIndexOf=HE,h.lowerCase=PN,h.lowerFirst=RN,h.lt=$g,h.lte=Wg,h.max=LT,h.maxBy=yT,h.mean=xT,h.meanBy=ST,h.min=OT,h.minBy=PT,h.stubArray=Pa,h.stubFalse=Ra,h.stubObject=_T,h.stubString=gT,h.stubTrue=NT,h.multiply=RT,h.nth=qE,h.noConflict=uT,h.noop=Oa,h.now=Gi,h.pad=DN,h.padEnd=MN,h.padStart=UN,h.parseInt=kN,h.random=wN,h.reduce=Y_,h.reduceRight=J_,h.repeat=FN,h.replace=CN,h.result=EN,h.round=DT,h.runInContext=v,h.sample=Z_,h.size=tg,h.snakeCase=BN,h.some=ng,h.sortedIndex=jE,h.sortedIndexBy=e_,h.sortedIndexOf=t_,h.sortedLastIndex=n_,h.sortedLastIndexBy=r_,h.sortedLastIndexOf=i_,h.startCase=VN,h.startsWith=$N,h.subtract=MT,h.sum=UT,h.sumBy=kT,h.template=WN,h.times=TT,h.toFinite=tn,h.toInteger=z,h.toLength=Dl,h.toLower=XN,h.toNumber=vt,h.toSafeInteger=Xg,h.toString=ae,h.toUpper=HN,h.trim=qN,h.trimEnd=zN,h.trimStart=KN,h.truncate=YN,h.unescape=JN,h.uniqueId=bT,h.upperCase=QN,h.upperFirst=La,h.each=Tl,h.eachRight=vl,h.first=El,Sa(h,function(){var e={};return Mt(h,function(n,a){oe.call(h.prototype,a)||(e[a]=n)}),e}(),{chain:!1}),h.VERSION=s,dt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){h[e].placeholder=h}),dt(["drop","take"],function(e,n){Z.prototype[e]=function(a){a=a===i?1:Se(z(a),0);var u=this.__filtered__&&!n?new Z(this):this.clone();return u.__filtered__?u.__takeCount__=Ce(a,u.__takeCount__):u.__views__.push({size:Ce(a,Dt),type:e+(u.__dir__<0?"Right":"")}),u},Z.prototype[e+"Right"]=function(a){return this.reverse()[e](a).reverse()}}),dt(["filter","map","takeWhile"],function(e,n){var a=n+1,u=a==po||a==zf;Z.prototype[e]=function(c){var p=this.clone();return p.__iteratees__.push({iteratee:B(c,3),type:a}),p.__filtered__=p.__filtered__||u,p}}),dt(["head","last"],function(e,n){var a="take"+(n?"Right":"");Z.prototype[e]=function(){return this[a](1).value()[0]}}),dt(["initial","tail"],function(e,n){var a="drop"+(n?"":"Right");Z.prototype[e]=function(){return this.__filtered__?new Z(this):this[a](1)}}),Z.prototype.compact=function(){return this.filter(Qe)},Z.prototype.find=function(e){return this.filter(e).head()},Z.prototype.findLast=function(e){return this.reverse().find(e)},Z.prototype.invokeMap=Y(function(e,n){return typeof e=="function"?new Z(this):this.map(function(a){return Pr(a,e,n)})}),Z.prototype.reject=function(e){return this.filter($i(B(e)))},Z.prototype.slice=function(e,n){e=z(e);var a=this;return a.__filtered__&&(e>0||n<0)?new Z(a):(e<0?a=a.takeRight(-e):e&&(a=a.drop(e)),n!==i&&(n=z(n),a=n<0?a.dropRight(-n):a.take(n-e)),a)},Z.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Z.prototype.toArray=function(){return this.take(Dt)},Mt(Z.prototype,function(e,n){var a=/^(?:filter|find|map|reject)|While$/.test(n),u=/^(?:head|last)$/.test(n),c=h[u?"take"+(n=="last"?"Right":""):n],p=u||/^find/.test(n);c&&(h.prototype[n]=function(){var E=this.__wrapped__,N=u?[1]:arguments,b=E instanceof Z,x=N[0],S=b||H(E),O=function(Q){var ee=c.apply(h,pn([Q],N));return u&&R?ee[0]:ee};S&&a&&typeof x=="function"&&x.length!=1&&(b=S=!1);var R=this.__chain__,k=!!this.__actions__.length,G=p&&!R,K=b&&!k;if(!p&&S){E=K?E:new Z(this);var V=e.apply(E,N);return V.__actions__.push({func:Ci,args:[O],thisArg:i}),new _t(V,R)}return G&&K?e.apply(this,N):(V=this.thru(O),G?u?V.value()[0]:V.value():V)})}),dt(["pop","push","shift","sort","splice","unshift"],function(e){var n=ci[e],a=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",u=/^(?:pop|shift)$/.test(e);h.prototype[e]=function(){var c=arguments;if(u&&!this.__chain__){var p=this.value();return n.apply(H(p)?p:[],c)}return this[a](function(E){return n.apply(H(E)?E:[],c)})}}),Mt(Z.prototype,function(e,n){var a=h[n];if(a){var u=a.name+"";oe.call(Zn,u)||(Zn[u]=[]),Zn[u].push({name:n,func:a})}}),Zn[Pi(i,de).name]=[{name:"wrapper",func:i}],Z.prototype.clone=Jp,Z.prototype.reverse=Qp,Z.prototype.value=Zp,h.prototype.at=y_,h.prototype.chain=x_,h.prototype.commit=S_,h.prototype.next=O_,h.prototype.plant=R_,h.prototype.reverse=D_,h.prototype.toJSON=h.prototype.valueOf=h.prototype.value=M_,h.prototype.first=h.prototype.head,Ar&&(h.prototype[Ar]=P_),h},Yn=Sp();Ln?((Ln.exports=Yn)._=Yn,xs._=Yn):Re._=Yn}).call(NA)}(Gr,Gr.exports)),Gr.exports}var sn=TA();class vA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return!(this.declarationNode.parent instanceof se)||cn(this.declarationNode.parent).unwrap_or(void 0)!==F.Table?[]:this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=Ge(this.declarationNode.parent.name).map(d=>d.join(".")).unwrap_or("<unnamed>"),o=this.declarationNode.parent.symbol.symbolTable;return[i.callee,...i.args].flatMap(Ft).flatMap(d=>d.variables.length+d.tupleElements.length>1?[]:d.variables.length?d.variables[0]:d.tupleElements).flatMap(d=>{const m=Me(d).unwrap_or(void 0);if(m===void 0)return[];const I=fr(m),T=o.get(I);return T?(d.referee=T,T.references.push(d),[]):new g(_.BINDING_ERROR,`No column named '${m}' inside Table '${s}'`,d)})})}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class bA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.bindBody(this.declarationNode.body)}bindBody(r){if(!r)return[];if(r instanceof W)return[];const i=r.body.filter(s=>s instanceof se);return this.bindSubElements(i)}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class mA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return[];const i=r.body.filter(s=>s instanceof se);return this.bindSubElements(i)}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class IA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return!(this.declarationNode.parent instanceof qe)&&cn(this.declarationNode.parent).unwrap_or(void 0)!==F.Project?[]:this.bindBody(this.declarationNode.body)}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){return r.flatMap(i=>i.callee?[i.callee,...i.args].flatMap(Ft).flatMap(l=>{let f=l.tupleElements.length?l.tupleElements:l.variables.pop();const d=l.variables.pop();if(!f||!d)return[];Array.isArray(f)||(f=[f]);const m=l.variables;return f.flatMap(I=>Ct(this.ast,[...m.map(T=>({node:T,kind:U.Schema})),{node:d,kind:U.Table},{node:I,kind:U.Column}]))}):[])}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class wf{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}resolvePartialInjections(){const{body:r}=this.declarationNode;return(r?r instanceof ke?r.body:[r]:[]).filter(s=>s instanceof W&&Ji(s.callee)).reverse().flatMap(s=>{const o=ut(s.callee.expression).unwrap_or(void 0);if(!o)return[];const l=o.variables.pop(),f=o.variables;if(!l)return[];const d=Ct(this.ast,[...f.map(m=>({node:m,kind:U.Schema})),{node:l,kind:U.TablePartial}]);return d.length?d:(l.referee?.symbolTable?.forEach(m=>{const I=Pe(m.declaration.callee).unwrap_or(void 0);if(I===void 0)return;const T=this.symbolFactory.create(Nf,{declaration:s,tablePartialSymbol:l.referee}),y=fr(I),$=this.declarationNode.symbol?.symbolTable;$?.has(y)||$?.set(y,T)}),[])})}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){const i=r.filter(o=>!Ji(o.callee));return(o=>o.flatMap(l=>{if(!l.callee)return[];const f=[],d=[l.callee,...l.args];if(sn.last(d)instanceof _e){const m=sn.last(d),I=Ne(m).getValue();f.push(...I.ref?.flatMap(T=>T.value?this.bindInlineRef(T.value):[])||[]),f.push(...I.default?.flatMap(T=>T.value?this.tryToBindEnumFieldRef(T.value):[])||[]),d.pop()}return d[1]&&this.tryToBindColumnType(d[1]),f}))(i)}tryToBindColumnType(r){const i=ut(r).unwrap_or(void 0);if(!i)return;const s=i.variables.pop(),o=i.variables;s&&Ct(this.ast,[...o.map(l=>({node:l,kind:U.Schema})),{node:s,kind:U.Enum}])}tryToBindEnumFieldRef(r){if(Fe(r))return[];if(we(r)){const f=r.expression.variable?.value?.toLowerCase();if(f&&FI.includes(f))return[]}const i=ut(r).unwrap_or(void 0);if(!i)return[];const s=i.variables.pop(),o=i.variables.pop();if(!s||!o)return[];const l=i.variables;return Ct(this.ast,[...l.map(f=>({node:f,kind:U.Schema})),{node:o,kind:U.Enum},{node:s,kind:U.EnumField}])}bindInlineRef(r){return Ft(r).flatMap(s=>{const o=s.variables.pop(),l=s.variables.pop();if(!o)return[];const f=s.variables;return l?Ct(this.ast,[...f.map(d=>({node:d,kind:U.Schema})),{node:l,kind:U.Table},{node:o,kind:U.Column}]):Ct(this.declarationNode,[{node:o,kind:U.Column}])})}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class AA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){return r.flatMap(i=>i.callee?[i.callee,...i.args].flatMap(Ft).flatMap(l=>{const f=l.variables.pop();if(!f)return[];const d=l.variables;return Ct(this.ast,[...d.map(m=>({node:m,kind:U.Schema})),{node:f,kind:U.Table}])}):[])}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}class wA{constructor(r,i,s){this.declarationNode=r,this.ast=i,this.symbolFactory=s}bind(){return this.declarationNode.body instanceof ke?this.bindBody(this.declarationNode.body):[]}bindBody(r){if(!r)return[];if(r instanceof W)return this.bindFields([r]);const[i,s]=sn.partition(r.body,o=>o instanceof W);return[...this.bindFields(i),...this.bindSubElements(s)]}bindFields(r){return r.flatMap(i=>{if(!i.callee)return[];const s=[],o=[i.callee,...i.args];if(sn.last(o)instanceof _e){const l=sn.last(o),f=Ne(l).getValue();s.push(...f.ref?.flatMap(d=>d.value?this.bindInlineRef(d.value):[])||[]),o.pop()}return o[1]&&this.tryToBindColumnType(o[1]),s})}tryToBindColumnType(r){const i=ut(r).unwrap_or(void 0);if(!i)return;const s=i.variables.pop(),o=i.variables;s&&Ct(this.ast,[...o.map(l=>({node:l,kind:U.Schema})),{node:s,kind:U.Enum}])}bindInlineRef(r){return Ft(r).flatMap(s=>{const o=s.variables.pop(),l=s.variables.pop();if(!o)return[];const f=s.variables;return l?Ct(this.ast,[...f.map(d=>({node:d,kind:U.Schema})),{node:l,kind:U.Table},{node:o,kind:U.Column}]):Ct(this.declarationNode,[{node:o,kind:U.Column}])})}bindSubElements(r){return r.flatMap(i=>{if(!i.type)return[];const s=Ht(i);return new s(i,this.ast,this.symbolFactory).bind()})}}function LA(t){return[Jr,ur,no,io,fr,ro,so,ao,oo].map(r=>r(t))}function yA(t){if(t instanceof eo)return U.Schema;if(t instanceof qr)return U.Table;if(t instanceof to)return U.Column;if(t instanceof hf)return U.Enum;if(t instanceof pf)return U.EnumField;if(t instanceof df)return U.TableGroup;if(t instanceof Ef)return U.TableGroupField;if(t instanceof _f)return U.TablePartial;if(t instanceof Nf)return U.Column;if(t instanceof gf)return U.PartialInjection;throw new Error("No other possible symbol kind in getSymbolKind")}function Ht(t){switch(t.type.value.toLowerCase()){case F.Enum:return gA;case F.Table:return wf;case F.TableGroup:return AA;case F.Project:return mA;case F.Ref:return IA;case F.Note:return bA;case F.Indexes:return vA;case F.TablePartial:return wA;case F.Check:return EA;default:return _A}}function Ft(t){if(!t)return[];if(we(t))return[{variables:[t],tupleElements:[]}];if(t instanceof Vt){const r=ut(t).unwrap_or(void 0);return r?[r]:[...Ft(t.leftExpression),...Ft(t.rightExpression)]}if(t instanceof je||t instanceof os)return Ft(t.expression);if(t instanceof Wt){const r=ut(t).unwrap_or(void 0);return r?[r]:t.elementList.flatMap(Ft)}return[]}function Ct(t,r){if(!t.symbol?.symbolTable)throw new Error("lookupAndBindInScope should only be called with initial scope having a symbol table");let i=t.symbol.symbolTable,s=yA(t.symbol),o=t instanceof se?sA(t).unwrap_or("<invalid name>"):$t;if(t instanceof qe&&r.length){const{node:l,kind:f}=r[0];Me(l).unwrap_or("<unnamed>")===$t&&f===U.Schema&&r.shift()}for(const l of r){const{node:f,kind:d}=l,m=Me(f).unwrap_or("<unnamed>"),I=GI(m,d),T=i.get(I);if(!T)return[new g(_.BINDING_ERROR,`${d} '${m}' does not exist in ${o===void 0?"global scope":`${s} '${o}'`}`,f)];if(f.referee=T,T.references.push(f),o=m,s=d,!T.symbolTable)return[];i=T.symbolTable}return[]}class xA{constructor(r,i){this.ast=r,this.symbolFactory=i}resolvePartialInjections(){return this.ast.body.filter(r=>cn(r).unwrap_or("")===F.Table).flatMap(r=>new wf(r,this.ast,this.symbolFactory).resolvePartialInjections())}resolve(){const r=[];r.push(...this.resolvePartialInjections());for(const i of this.ast.body)if(i.type){const s=Ht(i),o=new s(i,this.ast,this.symbolFactory);r.push(...o.bind())}return new ct(this.ast,r)}}class SA{constructor(r){this.generator=r}create(r,i){return new r(i,this.generator.nextId())}}class OA{constructor(r,i){this.ast=r,this.symbolFactory=new SA(i)}analyze(){return new Lc(this.ast,this.symbolFactory).validate().chain(i=>new xA(i,this.symbolFactory).resolve())}validate(){return new Lc(this.ast,this.symbolFactory).validate().chain(i=>new ct(i,[]))}}function xc(t,r){const{variables:i,tupleElements:s}=ut(t).unwrap(),o=s.map(f=>Me(f).unwrap()),l=i.map(f=>Me(f).unwrap());return s.length?i.length===0?{schemaName:r.schemaName,tableName:r.name,fieldNames:o}:{tableName:l.pop(),schemaName:l.pop()||null,fieldNames:o}:i.length===1?{schemaName:r.schemaName,tableName:r.name,fieldNames:[l[0]]}:{fieldNames:[l.pop()],tableName:l.pop(),schemaName:l.pop()||null}}function Lf(t){switch(t){case"<":return["1","*"];case"<>":return["*","*"];case">":return["*","1"];case"-":return["1","1"];default:throw new Error("Invalid relation op")}}function q(t){return{start:{offset:t.startPos.offset,line:t.startPos.line+1,column:t.startPos.column+1},end:{offset:t.endPos.offset,line:t.endPos.line+1,column:t.endPos.column+1}}}function Zi(t){const r=An(t).unwrap_or(void 0)?.pop();return r instanceof Wt?r.elementList.map(i=>i.referee):[r.referee]}function $n(t){const r=Ge(t).unwrap();return{name:r.pop(),schemaName:r}}function Zr(t){return t.expression.literal.value}function yf(t,r){if(Array.isArray(t)){const o=t.map(({id:f})=>f).sort().join(","),l=r.map(({id:f})=>f).sort().join(",");return o<l?`${o}-${l}`:`${l}-${o}`}const i=t.id.toString(),s=r.id.toString();return i<s?`${i}-${s}`:`${s}-${i}`}function co(t,r){if(Array.isArray(t)){const o=t.map(({id:f})=>f).sort(),l=r.map(({id:f})=>f).sort();return Va(o,l).every(([f,d])=>f===d)}const i=t.id,s=r.id;return i===s}function Ot(t){const r=t.split(`
|
|
29
|
-
`),
|
|
30
|
-
`)}function xf(t){if(t){if(Fe(t))return{value:Le(t).unwrap(),type:"string"};if(mn(t))return{type:"number",value:Xa(t)};if(In(t))return{value:t.expression.variable.value.toLowerCase(),type:"boolean"};if(t instanceof bt&&t.value)return{value:t.value.value,type:"expression"};if(lo(t))return{value:An(t).map(me).and_then(Pe).unwrap(),type:"string"};throw new Error("Unreachable")}}function Sf(t){let r="",i=null;for(t instanceof He&&(i=t.argumentList.elementList.map(l=>mn(l)?Wa(l):Fe(l)?Le(l).unwrap():Pe(l).unwrap()).join(","),r=`(${i})`,t=t.callee);t instanceof He||t instanceof Bt;)t instanceof He?(r=`(${t.argumentList.elementList.map(f=>mn(f)?Wa(f):Fe(f)?Le(f).unwrap():Pe(f).unwrap()).join(",")})${r}`,t=t.callee):t instanceof Bt&&(r=`${`[${t.indexer.elementList.map(f=>f.name.expression.literal.value).join(",")}]`}${r}`,t=t.array);const{name:s,schemaName:o}=$n(t);return o.length>1?new ct({schemaName:o.length===0?null:o[0],type_name:`${s}${r}`,args:i},[new g(_.UNSUPPORTED,"Nested schema is not supported",t)]):new ct({schemaName:o.length===0?null:o[0],type_name:`${s}${r}`,args:i})}class Of{constructor(r,i){this.declarationNode=r,this.env=i,this.table={name:void 0,schemaName:void 0,alias:null,fields:[],token:void 0,indexes:[],partials:[],checks:[]},this.pkColumns=[]}interpret(){this.table.token=q(this.declarationNode),this.env.tables.set(this.declarationNode,this.table);const r=[...this.interpretName(this.declarationNode.name),...this.interpretAlias(this.declarationNode.alias),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.table.indexes.push({columns:this.pkColumns.map(({name:i,token:s})=>({value:i,type:"column",token:s})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(i=>{i.pk=!1})),r}interpretName(r){const{name:i,schemaName:s}=$n(r);return s.length>1?(this.table.name=i,this.table.schemaName=s.join("."),[new g(_.UNSUPPORTED,"Nested schema is not supported",r)]):(this.table.name=i,this.table.schemaName=s.length?s[0]:null,[])}interpretAlias(r){if(!r)return[];const i=Me(r).unwrap_or(null);return i&&(this.env.aliases.push({name:i,kind:"table",value:{tableName:this.table.name,schemaName:this.table.schemaName}}),this.table.alias=i),[]}interpretSettingList(r){const i=Ne(r).getValue();this.table.headerColor=i[P.HeaderColor]?.length?Zr(i[P.HeaderColor]?.at(0)?.value):void 0;const[s]=i[P.Note]||[];return this.table.note=s&&{value:Le(s?.value).map(Ot).unwrap(),token:q(s)},[]}interpretBody(r){const[i,s]=ft(r.body,o=>o instanceof W);return[...this.interpretFields(i),...this.interpretSubElements(s)]}interpretSubElements(r){return r.flatMap(i=>{switch(i.type?.value.toLowerCase()){case F.Note:return this.table.note={value:Le(i.body instanceof ke?i.body.body[0].callee:i.body.callee).map(Ot).unwrap(),token:q(i)},[];case F.Indexes:return this.interpretIndexes(i);case F.Check:return this.interpretChecks(i);default:return[]}})}interpretInjection(r,i){const s={order:i,token:q(r)};return s.name=Pe(r.expression).unwrap_or(""),this.table.partials.push(s),[]}interpretFields(r){const o=(this.declarationNode.symbol?.symbolTable?[...this.declarationNode.symbol.symbolTable.entries()]:[]).filter(([f])=>Qr(f).unwrap_or(null)?.kind===U.Column).length?[]:[new g(_.EMPTY_TABLE,"A Table must have at least one column",this.declarationNode)],l=r.flatMap((f,d)=>Ji(f.callee)?this.interpretInjection(f.callee,d):this.interpretColumn(f));return[...o,...l]}interpretColumn(r){const i=[],s={};s.name=Me(r.callee).unwrap();const o=Sf(r.args[0]);s.type=o.getValue(),i.push(...o.getErrors()),s.token=q(r),s.inline_refs=[];const l=r.args.slice(1);if(me(l)instanceof _e){const f=Ne(l.pop()).getValue();s.pk=!!f[P.PK]?.length||!!f[P.PrimaryKey]?.length,s.increment=!!f[P.Increment]?.length,s.unique=!!f[P.Unique]?.length,s.not_null=f[P.NotNull]?.length?!0:f[P.Null]?.length?!1:void 0,s.dbdefault=xf(f[P.Default]?.at(0)?.value);const d=f[P.Note]?.at(0);s.note=d&&{value:Le(d.value).map(Ot).unwrap(),token:q(d)};const m=f[P.Ref]||[];s.inline_refs=m.flatMap(T=>{const[y]=Zi(T.value.expression);if(co(y,r.symbol))return i.push(new g(_.SAME_ENDPOINT,"Two endpoints are the same",T)),[];const $=T.value.op,J=Ge(T.value.expression).unwrap();let ne;if(J.length===1){const[j]=J;ne={schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[j],relation:$.value,token:q(T)}}else if(J.length===2){const[j,de]=J;ne={schemaName:null,tableName:j,fieldNames:[de],relation:$.value,token:q(T)}}else if(J.length===3){const[j,de,et]=J;ne={schemaName:j,tableName:de,fieldNames:[et],relation:$.value,token:q(T)}}else{i.push(new g(_.UNSUPPORTED,"Nested schema is not supported",T));const j=J.pop(),de=J.pop();ne={schemaName:J.join("."),tableName:de,fieldNames:[j],relation:$.value,token:q(T)}}const re=this.registerInlineRefToEnv(r,y,ne,T);return i.push(...re),re.length===0?ne:[]});const I=f[P.Check]||[];s.checks=I.map(T=>{const y=q(T),$=T.value.value.value;return{token:y,expression:$}})}return s.pk||=l.some(f=>Pe(f).unwrap().toLowerCase()==="pk"),s.unique||=l.some(f=>Pe(f).unwrap().toLowerCase()==="unique"),this.table.fields.push(s),s.pk&&this.pkColumns.push(s),i}interpretIndexes(r){return this.table.indexes.push(...r.body.body.map(i=>{const s={columns:[]},o=i;s.token=q(o);const l=[o.callee,...o.args];if(me(l)instanceof _e){const f=Ne(l.pop()).getValue();s.pk=!!f[P.PK]?.length,s.unique=!!f[P.Unique]?.length,s.name=Le(f[P.Name]?.at(0)?.value).unwrap_or(void 0);const d=f[P.Note]?.at(0);s.note=d&&{value:Le(d.value).unwrap(),token:q(d)},s.type=Pe(f[P.Type]?.at(0)?.value).unwrap_or(void 0)}return l.flatMap(f=>{if(!(f instanceof He))return f;const d=[];for(;f instanceof He;)d.push(f.argumentList),f=f.callee;return d.push(f),d}).forEach(f=>{const{functional:d,nonFunctional:m}=Qi(f).unwrap();s.columns.push(...d.map(I=>({value:I.value.value,type:"expression",token:q(I)})),...m.map(I=>({value:Me(I).unwrap(),type:"column",token:q(I)})))}),s})),[]}interpretChecks(r){return this.table.checks.push(...r.body.body.map(i=>{const s={},o=i;if(s.token=q(o),o.args[0]instanceof _e){const l=Ne(o.args[0]).getValue();s.name=Le(l[P.Name]?.at(0)?.value).unwrap_or(void 0)}return s.expression=o.callee.value.value,s})),[]}registerInlineRefToEnv(r,i,s,o){const l=yf(r.symbol,i);if(this.env.refIds[l])return[new g(_.CIRCULAR_REF,"References with same endpoints exist",o),new g(_.CIRCULAR_REF,"References with same endpoints exist",this.env.refIds[l])];const f=Lf(s.relation);return this.env.refIds[l]=o,this.env.ref.set(o,{name:null,schemaName:null,token:s.token,endpoints:[{...s,relation:f[1]},{schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[Pe(r.callee).unwrap()],token:q(r),relation:f[0]}]}),[]}}class PA{constructor(r,i){this.declarationNode=r,this.env=i,this.note={name:void 0,content:void 0,token:void 0}}interpret(){return this.note.token=q(this.declarationNode),this.env.notes.set(this.declarationNode,this.note),[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)]}interpretName(r){const{name:i}=$n(r);return this.note.name=i,[]}interpretSettingList(r){const i=Ne(r).getValue();return this.note.headerColor=i.headercolor?.length?Zr(i.headercolor?.at(0)?.value):void 0,[]}interpretBody(r){const[i,s]=ft(r.body,o=>o instanceof W);return i.length!==1||s.length>0?[new g(_.INVALID_NOTE,"Invalid note syntax",r)]:[...this.interpretNote(i[0])]}interpretNote(r){const i=Zc(r,"callee.expression.literal.value","");return this.note.content=Ot(i),[]}}class Pf{constructor(r,i){this.declarationNode=r,this.env=i,this.container=this.declarationNode.parent instanceof se?this.env.tables.get(this.declarationNode.parent):void 0,this.ref={}}interpret(){return this.ref.token=q(this.declarationNode),this.env.ref.set(this.declarationNode,this.ref),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(r){const i=[],s=Ge(this.declarationNode.name).unwrap_or([]);return this.ref.name=s.pop()||null,s.length>1&&i.push(new g(_.UNSUPPORTED,"Nested schema is not supported",this.declarationNode.name)),this.ref.schemaName=s.join(".")||null,i}interpretBody(r){return r instanceof W?this.interpretField(r):this.interpretField(r.body[0])}interpretField(r){const i=r.callee.op.value,{leftExpression:s,rightExpression:o}=r.callee,l=Zi(s),f=Zi(o);if(co(l,f))return[new g(_.SAME_ENDPOINT,"Two endpoints are the same",r)];const d=yf(l,f);if(this.env.refIds[d])return[new g(_.CIRCULAR_REF,"References with same endpoints exist",this.declarationNode),new g(_.CIRCULAR_REF,"References with same endpoints exist",this.env.refIds[d])];if(r.args[0]){const I=Ne(r.args[0]).getValue(),T=I.delete?.at(0)?.value;this.ref.onDelete=T instanceof xt?zr(T).unwrap_or(void 0):Pe(T).unwrap_or(void 0);const y=I.update?.at(0)?.value;this.ref.onUpdate=y instanceof xt?zr(y).unwrap_or(void 0):Pe(y).unwrap_or(void 0),this.ref.color=I.color?.length?Zr(I.color?.at(0)?.value):void 0}const m=Lf(i);return this.ref.endpoints=[{...xc(s,this.container),relation:m[0],token:q(s)},{...xc(o,this.container),relation:m[1],token:q(o)}],this.env.refIds[d]=this.declarationNode,[]}}class Rf{constructor(r,i){this.declarationNode=r,this.env=i,this.tableGroup={tables:[]}}interpret(){const r=[];return this.tableGroup.token=q(this.declarationNode),this.env.tableGroups.set(this.declarationNode,this.tableGroup),r.push(...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)),r}interpretName(r){const i=[],{name:s,schemaName:o}=$n(r);return o.length>=2&&(this.tableGroup.name=s,this.tableGroup.schemaName=o.join("."),i.push(new g(_.UNSUPPORTED,"Nested schema is not supported",this.declarationNode.name))),this.tableGroup.name=s,this.tableGroup.schemaName=o[0]||null,i}interpretBody(r){const[i,s]=ft(r.body,o=>o instanceof W);return[...this.interpretFields(i),...this.interpretSubElements(s)]}interpretSubElements(r){return r.flatMap(i=>{switch(i.type?.value.toLowerCase()){case"note":this.tableGroup.note={value:Le(i.body instanceof ke?i.body.body[0].callee:i.body.callee).map(Ot).unwrap(),token:q(i)};break}return[]})}interpretFields(r){const i=[];return this.tableGroup.tables=r.map(s=>{const o=Ge(s.callee).unwrap();o.length>2&&i.push(new g(_.UNSUPPORTED,"Nested schema is not supported",s));const l=An(s.callee).unwrap().pop().referee.id;if(this.env.tableOwnerGroup[l]){const f=this.env.tableOwnerGroup[l],{schemaName:d,name:m}=this.env.tableGroups.get(f),I=d?`${d}.${m}`:m;i.push(new g(_.TABLE_REAPPEAR_IN_TABLEGROUP,`Table "${o.join(".")}" already appears in group "${I}"`,s))}else this.env.tableOwnerGroup[l]=this.declarationNode;return{name:o.pop(),schemaName:o.join(".")}}),i}interpretSettingList(r){const i=Ne(r).getValue();this.tableGroup.color=i.color?.length?Zr(i.color?.at(0)?.value):void 0;const[s]=i.note||[];return this.tableGroup.note=s&&{value:Le(s?.value).map(Ot).unwrap(),token:q(s)},[]}}class Df{constructor(r,i){this.declarationNode=r,this.env=i,this.enum={values:[]}}interpret(){return this.enum.token=q(this.declarationNode),this.env.enums.set(this.declarationNode,this.enum),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(r){const{name:i,schemaName:s}=$n(r);return s.length>1?(this.enum.name=i,this.enum.schemaName=s.join("."),[new g(_.UNSUPPORTED,"Nested schema is not supported",r)]):(this.enum.name=i,this.enum.schemaName=s.length?s[0]:null,[])}interpretBody(r){return r.body.flatMap(i=>{const s=i,o={};o.token=q(s),o.name=Pe(s.callee).unwrap();const f=Ne(s.args[0]).getValue().note?.at(0);return o.note=f&&{value:Le(f.value).map(Ot).unwrap(),token:q(f)},this.enum.values.push(o),[]})}}class Mf{constructor(r,i){this.declarationNode=r,this.env=i,this.tablePartial={name:void 0,fields:[],token:void 0,indexes:[],checks:[]},this.pkColumns=[]}interpret(){this.tablePartial.token=q(this.declarationNode),this.env.tablePartials.set(this.declarationNode,this.tablePartial);const r=[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.tablePartial.indexes.push({columns:this.pkColumns.map(({name:i,token:s})=>({value:i,type:"column",token:s})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(i=>{i.pk=!1})),r}interpretName(r){const{name:i}=$n(r);return this.tablePartial.name=i,[]}interpretSettingList(r){const i=Ne(r).getValue(),s=LI(i[P.HeaderColor]);this.tablePartial.headerColor=s?Zr(s.value):void 0;const[o]=i[P.Note]||[];return this.tablePartial.note=o&&{value:Le(o?.value).map(Ot).unwrap(),token:q(o)},[]}interpretBody(r){const[i,s]=ft(r.body,o=>o instanceof W);return[...this.interpretFields(i),...this.interpretSubElements(s)]}interpretSubElements(r){return r.flatMap(i=>{switch(i.type?.value.toLowerCase()){case F.Note:return this.tablePartial.note={value:Le(i.body instanceof ke?i.body.body[0].callee:i.body.callee).map(Ot).unwrap(),token:q(i)},[];case F.Indexes:return this.interpretIndexes(i);case F.Check:return this.interpretChecks(i);default:return[]}})}interpretFields(r){return r.flatMap(i=>this.interpretColumn(i))}interpretColumn(r){const i=[],s={};s.name=Me(r.callee).unwrap();const o=Sf(r.args[0]);s.type=o.getValue(),i.push(...o.getErrors()),s.token=q(r),s.inline_refs=[];const l=r.args.slice(1);if(me(l)instanceof _e){const f=Ne(l.pop()).getValue();s.pk=!!f[P.PK]?.length||!!f[P.PrimaryKey]?.length,s.increment=!!f[P.Increment]?.length,s.unique=!!f[P.Unique]?.length,s.not_null=f[P.NotNull]?.length?!0:f[P.Null]?.length?!1:void 0,s.dbdefault=xf(f[P.Default]?.at(0)?.value);const d=f[P.Note]?.at(0);s.note=d&&{value:Le(d.value).map(Ot).unwrap(),token:q(d)};const m=f[P.Ref]||[];s.inline_refs=m.flatMap(T=>{const[y]=Zi(T.value.expression);if(co(y,r.symbol))return i.push(new g(_.SAME_ENDPOINT,"Two endpoints are the same",T)),[];const $=T.value.op,J=Ge(T.value.expression).unwrap();let ne;if(J.length===2){const[re,j]=J;ne={schemaName:null,tableName:re,fieldNames:[j],relation:$.value,token:q(T)}}else if(J.length===3){const[re,j,de]=J;ne={schemaName:re,tableName:j,fieldNames:[de],relation:$.value,token:q(T)}}else{i.push(new g(_.UNSUPPORTED,"Unsupported",T));const re=J.pop(),j=J.pop();ne={schemaName:J.join("."),tableName:j,fieldNames:[re],relation:$.value,token:q(T)}}return ne});const I=f[P.Check]||[];s.checks=I.map(T=>{const y=q(T),$=T.value.value.value;return{token:y,expression:$}})}return s.pk||=l.some(f=>Pe(f).unwrap().toLowerCase()==="pk"),s.unique||=l.some(f=>Pe(f).unwrap().toLowerCase()==="unique"),this.tablePartial.fields.push(s),s.pk&&this.pkColumns.push(s),i}interpretIndexes(r){return this.tablePartial.indexes.push(...r.body.body.map(i=>{const s={columns:[]},o=i;s.token=q(o);const l=[o.callee,...o.args];if(me(l)instanceof _e){const f=Ne(l.pop()).getValue();s.pk=!!f[P.PK]?.length,s.unique=!!f[P.Unique]?.length,s.name=Le(f[P.Name]?.at(0)?.value).unwrap_or(void 0);const d=f[P.Note]?.at(0);s.note=d&&{value:Le(d.value).unwrap(),token:q(d)},s.type=Pe(f[P.Type]?.at(0)?.value).unwrap_or(void 0)}return l.flatMap(f=>{if(!(f instanceof He))return f;const d=[];let m=f;for(;m instanceof He;)d.push(m.argumentList),m=m.callee;return d.push(m),d}).forEach(f=>{const{functional:d,nonFunctional:m}=Qi(f).unwrap();s.columns.push(...d.map(I=>({value:I.value.value,type:"expression",token:q(I)})),...m.map(I=>({value:Me(I).unwrap(),type:"column",token:q(I)})))}),s})),[]}interpretChecks(r){return this.tablePartial.checks.push(...r.body.body.map(i=>{const s={},o=i;if(s.token=q(o),o.args[0]instanceof _e){const l=Ne(o.args[0]).getValue();s.name=Le(l[P.Name]?.at(0)?.value).unwrap_or(void 0)}return s.expression=o.callee.value.value,s})),[]}}class RA{constructor(r,i){this.declarationNode=r,this.env=i,this.project={enums:[],refs:[],tableGroups:[],tables:[],tablePartials:[]}}interpret(){return this.env.project.set(this.declarationNode,this.project),this.project.token=q(this.declarationNode),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(r){if(!r)return this.project.name=null,[];const{name:i}=$n(r);return this.project.name=i,[]}interpretBody(r){return r.body.flatMap(i=>{const s=i;switch(s.type?.value.toLowerCase()){case"table":{const o=new Of(s,this.env).interpret();return this.project.tables.push(this.env.tables.get(s)),o}case"ref":{const o=new Pf(s,this.env).interpret();return this.project.refs.push(this.env.ref.get(s)),o}case"tablegroup":{const o=new Rf(s,this.env).interpret();return this.project.tableGroups.push(this.env.tableGroups.get(s)),o}case"enum":{const o=new Df(s,this.env).interpret();return this.project.enums.push(this.env.enums.get(s)),o}case"note":return this.project.note={value:Le(s.body instanceof ke?s.body.body[0].callee:s.body.callee).map(Ot).unwrap(),token:q(s)},[];case"tablepartial":{const o=new Mf(s,this.env).interpret();return this.project.tablePartials.push(this.env.tablePartials.get(s)),o}default:return this.project[s.type.value.toLowerCase()]=Le(s.body.callee).unwrap(),[]}})}}function DA(t){return{schemas:[],tables:Array.from(t.tables.values()),notes:Array.from(t.notes.values()),refs:Array.from(t.ref.values()),enums:Array.from(t.enums.values()),tableGroups:Array.from(t.tableGroups.values()),aliases:t.aliases,project:Array.from(t.project.values())[0]||{},tablePartials:Array.from(t.tablePartials.values())}}class MA{constructor(r){this.ast=r,this.env={schema:[],tables:new Map,notes:new Map,refIds:{},ref:new Map,enums:new Map,tableOwnerGroup:{},tableGroups:new Map,aliases:[],project:new Map,tablePartials:new Map}}interpret(){const r=this.ast.body.flatMap(i=>{switch(cn(i).unwrap_or(void 0)){case F.Table:return new Of(i,this.env).interpret();case F.Note:return new PA(i,this.env).interpret();case F.Ref:return new Pf(i,this.env).interpret();case F.TableGroup:return new Rf(i,this.env).interpret();case F.TablePartial:return new Mf(i,this.env).interpret();case F.Enum:return new Df(i,this.env).interpret();case F.Project:return new RA(i,this.env).interpret();default:return[]}});return new ct(DA(this.env),r)}}var le=(t=>(t[t.Function=1]="Function",t[t.Constructor=2]="Constructor",t[t.Field=3]="Field",t[t.Variable=4]="Variable",t[t.Class=5]="Class",t[t.Struct=6]="Struct",t[t.Interface=7]="Interface",t[t.Module=8]="Module",t[t.Property=9]="Property",t[t.Event=10]="Event",t[t.Operator=11]="Operator",t[t.Unit=12]="Unit",t[t.Value=13]="Value",t[t.Constant=14]="Constant",t[t.Enum=15]="Enum",t[t.EnumMember=16]="EnumMember",t[t.Keyword=17]="Keyword",t[t.Text=18]="Text",t[t.Color=19]="Color",t[t.File=20]="File",t[t.Reference=21]="Reference",t[t.Customcolor=22]="Customcolor",t[t.Folder=23]="Folder",t[t.TypeParameter=24]="TypeParameter",t[t.User=25]="User",t[t.Issue=26]="Issue",t[t.Snippet=27]="Snippet",t))(le||{}),be=(t=>(t[t.None=0]="None",t[t.KeepWhitespace=1]="KeepWhitespace",t[t.InsertAsSnippet=4]="InsertAsSnippet",t))(be||{});function Kr(t){switch(t){case U.Schema:return le.Module;case U.Table:case U.TablePartial:return le.Class;case U.Column:case U.TableGroupField:return le.Field;case U.Enum:return le.Enum;case U.EnumField:return le.EnumMember;case U.TableGroup:return le.Struct;default:return le.Text}}function ji(t,r){if(!t||$a(t))return!1;for(const i of t.trailingTrivia){if(i.start>r)break;if(i.kind===A.NEWLINE&&i.end<=r)return!1}return!0}function Ue(){return{suggestions:[]}}function es(t){return{...t,suggestions:t.suggestions.map(r=>({...r,insertText:` ${r.insertText}`}))}}function cs(t){return{...t,suggestions:t.suggestions.map(r=>({...r,insertText:!r.insertText||!r.insertText.split("").every(Yr)?`"${r.insertText??""}"`:r.insertText}))}}function fo(t,r){return t.getOffsetAt(r)}class Uf{constructor(r,i=[]){this.compiler=r,this.triggerCharacters=i}provideCompletionItems(r,i){const s=fo(r,i),o=this.compiler.token.flatStream(),{token:l,index:f}=this.compiler.container.token(s),d=f===void 0?o[0]:o[f+1];if([...l?.trailingTrivia||[],...l?.leadingTrivia||[],...d?.leadingTrivia||[]].find(T=>PI(T)&&$r(s,T)))return Ue();if(f===void 0)return Dc();if([A.STRING_LITERAL,A.QUOTED_STRING].includes(l.kind)&&$r(s,l))return Ue();const m=this.compiler.container.element(s);if(this.compiler.container.scopeKind(s)===te.TOPLEVEL||m instanceof se&&m.type&&m.type.start<=s&&m.type.end>=s)return Dc();const I=[...this.compiler.container.stack(s)].reverse();for(const T of I)if(T instanceof je)switch(T.op?.value){case">":case"<":case"<>":case"-":return Sc(this.compiler,s,T);case"~":return UA(this.compiler,s)}else if(T instanceof Vt)switch(T.op?.value){case">":case"<":case"<>":case"-":return Sc(this.compiler,s,T);case".":return kf(this.compiler,s,T)}else{if(T instanceof St)return Oc(this.compiler,s,T);if(T instanceof _e)return Oc(this.compiler,s,T);if(T instanceof Wt)return kA(this.compiler,s);if(T instanceof W)return Rc(this.compiler,s,T);if(T instanceof se&&(T.bodyColon&&s>=T.bodyColon.end||T.body&&$r(s,T.body)))return Rc(this.compiler,s,void 0)}return Ue()}}function UA(t,r){return pr(t,r,t.parse.ast(),[U.TablePartial])}function Sc(t,r,i){const s=t.container.scopeKind(r);if([te.REF,te.TABLE,te.TABLEPARTIAL].includes(s)){const o=pr(t,r,t.container.element(r),[U.Table,U.Schema,U.Column]);return ji(i.op,r)?es(o):o}return Ue()}function pr(t,r,i,s){if(i===void 0)return Ue();let o=i;const l={suggestions:[]};for(;o;){if(o?.symbol?.symbolTable){const{symbol:f}=o;l.suggestions.push(...t.symbol.members(f).filter(({kind:d})=>s.includes(d)).map(({name:d,kind:m})=>({label:d,insertText:d,insertTextRules:be.KeepWhitespace,kind:Kr(m),sortText:Kr(m).toString().padStart(2,"0"),range:void 0})))}o=o instanceof se?o.parent:void 0}return cs(l)}function kA(t,r){switch(t.container.scopeKind(r)){case te.INDEXES:return Cf(t,r);case te.REF:{const s=[...t.container.stack(r)];for(;s.length>0;){const o=s.pop();if(o instanceof Vt&&o.op?.value===".")return kf(t,r,o)}}return Ff(t,r)}return Ue()}function Oc(t,r,i){const{token:s}=t.container.token(r);if([A.COMMA,A.LBRACKET].includes(s?.kind)){const o=Pc(t,r);return s?.kind===A.COMMA&&ji(s,r)?es(o):o}if(i.name&&i.name.start<=r&&i.name.end>=r)return Pc(t,r);if(i.name instanceof xt){const o=FA(t,r,zr(i.name).unwrap_or(""));return s?.kind===A.COLON&&ji(s,r)?es(o):o}return Ue()}function Pc(t,r){const i=t.container.element(r);if(i instanceof qe)return Ue();const s=t.container.scopeKind(r);if(i.body&&!$r(r,i.body)){let o;switch(s){case te.TABLE:case te.TABLEPARTIAL:o=[P.HeaderColor,P.Note];break;case te.TABLEGROUP:o=[P.Color,P.Note];break;default:o=[]}return{suggestions:o.map(l=>({label:l,insertText:`${l}: `,kind:le.Field,insertTextRules:be.KeepWhitespace,range:void 0}))}}switch(s){case te.TABLE:case te.TABLEPARTIAL:return{suggestions:[...[P.PK,P.PrimaryKey,P.Null,P.NotNull,P.Increment,P.Unique].map(o=>({label:o,insertText:o,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0})),...[P.Ref,P.Default,P.Note,P.Check].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))]};case te.ENUM:return{suggestions:[...[P.Note].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))]};case te.INDEXES:return{suggestions:[...[P.Unique,P.PK].map(o=>({label:o,insertText:o,insertTextRules:be.KeepWhitespace,kind:le.Property,range:void 0})),...[P.Note,P.Name,P.Type].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))]};case te.REF:return{suggestions:[P.Update,P.Delete,P.Color].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))};case te.CHECKS:return{suggestions:[P.Name].map(o=>({label:o,insertText:`${o}: `,kind:le.Property,insertTextRules:be.KeepWhitespace,range:void 0}))}}return Ue()}function FA(t,r,i){switch(i?.toLowerCase()){case"update":case"delete":return{suggestions:["cascade","set default","set null","restrict"].map(s=>({label:s,insertText:s,kind:le.Value,insertTextRules:be.KeepWhitespace,range:void 0}))};case"type":return{suggestions:["btree","hash"].map(s=>({label:s,insertText:`${s}`,kind:le.Value,insertTextRules:be.KeepWhitespace,range:void 0}))};case"default":return pr(t,r,t.container.element(r),[U.Schema,U.Enum])}return Ue()}function kf(t,r,i){const s=An(i).unwrap_or([]);if(s.pop(),s.some(l=>!we(l)))return Ue();const o=s.map(l=>Pe(l).unwrap());return cs({suggestions:t.symbol.ofName(o,t.container.element(r)).flatMap(({symbol:l})=>t.symbol.members(l)).map(({kind:l,name:f})=>({label:f,insertText:f,kind:Kr(l),range:void 0}))})}function Rc(t,r,i){switch(t.container.scopeKind(r)){case te.TABLE:case te.TABLEPARTIAL:return BA(t,r,i);case te.PROJECT:return GA(t,r,i);case te.INDEXES:return $A(t,r);case te.ENUM:return CA(t,r,i);case te.REF:{const o=Ff(t,r);return t.container.token(r).token?.kind===A.COLON&&ji(t.container.token(r).token,r)?es(o):o}case te.TABLEGROUP:return VA(t);default:return Ue()}}function Dc(){return{suggestions:["Table","TableGroup","Enum","Project","Ref","TablePartial"].map(t=>({label:t,insertText:t,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))}}function CA(t,r,i){return i?.callee&&ho(r,i)===1?pr(t,r,t.container.element(r),[U.Schema,U.Table,U.Column]):Ue()}function BA(t,r,i){const s=["Note","indexes","checks"];if(!i?.callee)return{suggestions:s.map(l=>({label:l,insertText:l,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))};const o=ho(r,i);return o===0?{suggestions:s.map(l=>({label:l,insertText:l,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))}:o===1?WA(t,r):Ue()}function GA(t,r,i){const s=["Table","TableGroup","Enum","Note","Ref","TablePartial"];return i?.callee?ho(r,i)===0?{suggestions:s.map(l=>({label:l,insertText:l,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))}:Ue():{suggestions:s.map(l=>({label:l,insertText:l,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))}}function Ff(t,r){return pr(t,r,t.container.element(r),[U.Schema,U.Table,U.Column])}function VA(t){return{suggestions:[...cs({suggestions:[...t.parse.publicSymbolTable().entries()].flatMap(([r])=>{const i=Qr(r).unwrap_or(void 0);if(i===void 0)return[];const{kind:s,name:o}=i;return s!==U.Table&&s!==U.Schema?[]:{label:o,insertText:o,insertTextRules:be.KeepWhitespace,kind:Kr(s),range:void 0}})}).suggestions,...["Note"].map(r=>({label:r,insertText:r,insertTextRules:be.KeepWhitespace,kind:le.Keyword,range:void 0}))]}}function $A(t,r){return Cf(t,r)}function WA(t,r){return{suggestions:[...["integer","int","tinyint","smallint","mediumint","bigint","bit","bool","binary","varbinary","logical","char","nchar","varchar","varchar2","nvarchar","nvarchar2","binary_float","binary_double","float","double","decimal","dec","real","money","smallmoney","enum","tinyblob","tinytext","blob","text","mediumblob","mediumtext","longblob","longtext","ntext","set","inet6","uuid","image","date","time","datetime","datetime2","timestamp","year","smalldatetime","datetimeoffset","XML","sql_variant","uniqueidentifier","CURSOR","BFILE","CLOB","NCLOB","RAW"].map(i=>({label:i,insertText:i,insertTextRules:be.KeepWhitespace,kind:le.TypeParameter,sortText:le.TypeParameter.toString().padStart(2,"0"),range:void 0})),...pr(t,r,t.container.element(r),[U.Enum,U.Schema]).suggestions]}}function Cf(t,r){const s=t.container.element(r)?.parent;if(!(s?.symbol instanceof qr))return Ue();const{symbolTable:o}=s.symbol;return cs({suggestions:[...o.entries()].flatMap(([l])=>{const f=Qr(l).unwrap_or(void 0);if(f===void 0)return[];const{name:d}=f;return{label:d,insertText:d,insertTextRules:be.KeepWhitespace,kind:Kr(U.Column),range:void 0}})})}function ho(t,r){if(!r.callee)return-1;const i=[r.callee,...r.args],s=i.findIndex(o=>t<=o.end);return s===-1?i.length:s}class Bf{constructor(r){this.compiler=r}provideDefinition(r,i){const{uri:s}=r,o=fo(r,i),l=[...this.compiler.container.stack(o)];for(;l.length!==0;){const f=l.pop();if(!f?.referee)continue;let d;if(f.referee?.declaration&&[kn.PRIMARY_EXPRESSION,kn.VARIABLE].includes(f?.kind)&&({declaration:d}=f.referee),d){const{startPos:m,endPos:I}=d;return[{range:{startColumn:m.column+1,startLineNumber:m.line+1,endColumn:I.column+1,endLineNumber:I.line+1},uri:s}]}}return[]}}class Gf{constructor(r){this.compiler=r}provideReferences(r,i){const{uri:s}=r,o=fo(r,i),l=[...this.compiler.container.stack(o)];for(;l.length!==0;){const f=l.pop();if(f&&[kn.ELEMENT_DECLARATION,kn.FUNCTION_APPLICATION,kn.PRIMARY_EXPRESSION].includes(f?.kind)){const{symbol:d}=f;if(d?.references.length)return d.references.map(({startPos:m,endPos:I})=>({range:{startColumn:m.column+1,startLineNumber:m.line+1,endColumn:I.column+1,endLineNumber:I.line+1},uri:s}))}}return[]}}const XA=Object.freeze(Object.defineProperty({__proto__:null,CompletionItemInsertTextRule:be,CompletionItemKind:le,DBMLCompletionItemProvider:Uf,DBMLDefinitionProvider:Bf,DBMLReferencesProvider:Gf},Symbol.toStringTag,{value:"Module"}));function HA(){return this.parse._().getValue().ast}function qA(){return this.parse._().getErrors()}function zA(){return this.parse._().getValue().tokens}function KA(){return this.parse._().getValue().rawDb}function YA(){return this.parse._().getValue().ast.symbol.symbolTable}function JA(){return this.parse.tokens().flatMap(t=>[...t.leadingInvalid,t,...t.trailingInvalid])}function QA(){return this.parse.tokens().filter(qa)}function ZA(t){return t.symbolTable?[...t.symbolTable.entries()].map(([r,i])=>({...Qr(r).unwrap(),symbol:i})):[]}function jA(t,r){if(t.length===0)return[];const i=[];for(let s=r;s;s=s instanceof se?s.parent:void 0){if(!s.symbol?.symbolTable)continue;const{symbolTable:o}=s.symbol;let l=[o],f=[];for(const d of t)f=l.flatMap(m=>LA(d).flatMap(I=>{const T=m.get(I),y=Qr(I).unwrap_or(void 0);return!T||!y?[]:{...y,symbol:T}})),l=f.flatMap(m=>m.symbol.symbolTable?m.symbol.symbolTable:[]);i.push(...f)}return i}function ew(t,r){return`${t.join(".")}@${r.id}`}function tw(t){const r=this.token.flatStream(),{index:i,token:s}=this.container.token(t),o=i===void 0?-1:wI(r,m=>!m.isInvalid,i);if(o===-1)return[this.parse.ast()];const l=r[o].start;let f=this.parse.ast();const d=[f];for(;;){const I=iA(f).find(T=>$r(l,T));if(I===void 0||I instanceof Ze)break;d.push(I),f=I}if(s?.kind===A.COLON)return d;for(;d.length>0;){let m=!1;const I=me(d);if(I instanceof W){const T=this.parse.source();for(let y=I.end;y<t;y+=1)T[y]===`
|
|
31
|
-
|
|
27
|
+
`)+R+`return __p
|
|
28
|
+
}`;var te=Ch(function(){return fe(g,$+"return "+R).apply(n,y)});if(te.source=R,Eu(te))throw te;return te}function Rb(r){return pe(r).toLowerCase()}function kb(r){return pe(r).toUpperCase()}function Mb(r,s,o){if(r=pe(r),r&&(o||s===n))return Hc(r);if(!r||!(s=bt(s)))return r;var c=Yt(r),d=Yt(s),g=zc(c,d),y=qc(c,d)+1;return er(c,g,y).join("")}function Pb(r,s,o){if(r=pe(r),r&&(o||s===n))return r.slice(0,Yc(r)+1);if(!r||!(s=bt(s)))return r;var c=Yt(r),d=qc(c,Yt(s))+1;return er(c,0,d).join("")}function Cb(r,s,o){if(r=pe(r),r&&(o||s===n))return r.replace(Eo,"");if(!r||!(s=bt(s)))return r;var c=Yt(r),d=zc(c,Yt(s));return er(c,d).join("")}function Fb(r,s){var o=lr,c=so;if(Re(s)){var d="separator"in s?s.separator:d;o="length"in s?ee(s.length):o,c="omission"in s?bt(s.omission):c}r=pe(r);var g=r.length;if(Vr(r)){var y=Yt(r);g=y.length}if(o>=g)return r;var _=o-Br(c);if(_<1)return c;var w=y?er(y,0,_).join(""):r.slice(0,_);if(d===n)return w+c;if(y&&(_+=w.length-_),Tu(d)){if(r.slice(_).search(d)){var x,D=w;for(d.global||(d=Mo(d.source,pe(hc.exec(d))+"g")),d.lastIndex=0;x=d.exec(D);)var R=x.index;w=w.slice(0,R===n?_:R)}}else if(r.indexOf(bt(d),_)!=_){var P=w.lastIndexOf(d);P>-1&&(w=w.slice(0,P))}return w+c}function Ub(r){return r=pe(r),r&&Zg.test(r)?r.replace(lc,dT):r}var Vb=Xr(function(r,s,o){return r+(o?" ":"")+s.toUpperCase()}),vu=Ff("toUpperCase");function Ph(r,s,o){return r=pe(r),s=o?n:s,s===n?uT(r)?gT(r):QE(r):r.match(s)||[]}var Ch=ne(function(r,s){try{return vt(r,n,s)}catch(o){return Eu(o)?o:new J(o)}}),Bb=Sn(function(r,s){return Rt(s,function(o){o=mn(o),An(r,o,mu(r[o],r))}),r});function $b(r){var s=r==null?0:r.length,o=q();return r=s?Ae(r,function(c){if(typeof c[1]!="function")throw new kt(l);return[o(c[0]),c[1]]}):[],ne(function(c){for(var d=-1;++d<s;){var g=r[d];if(vt(g[0],this,c))return vt(g[1],this,c)}})}function Gb(r){return dN(Pt(r,T))}function _u(r){return function(){return r}}function Wb(r,s){return r==null||r!==r?s:r}var Hb=Vf(),zb=Vf(!0);function Et(r){return r}function bu(r){return mf(typeof r=="function"?r:Pt(r,T))}function qb(r){return Ef(Pt(r,T))}function Xb(r,s){return Tf(r,Pt(s,T))}var Yb=ne(function(r,s){return function(o){return Ci(o,r,s)}}),Zb=ne(function(r,s){return function(o){return Ci(r,o,s)}});function wu(r,s,o){var c=Ye(s),d=Ws(s,c);o==null&&!(Re(s)&&(d.length||!c.length))&&(o=s,s=r,r=this,d=Ws(s,Ye(s)));var g=!(Re(o)&&"chain"in o)||!!o.chain,y=xn(r);return Rt(d,function(_){var w=s[_];r[_]=w,y&&(r.prototype[_]=function(){var x=this.__chain__;if(g||x){var D=r(this.__wrapped__),R=D.__actions__=pt(this.__actions__);return R.push({func:w,args:arguments,thisArg:r}),D.__chain__=x,D}return w.apply(r,Yn([this.value()],arguments))})}),r}function Kb(){return je._===this&&(je._=_T),this}function Iu(){}function Jb(r){return r=ee(r),ne(function(s){return Nf(s,r)})}var jb=nu(Ae),Qb=nu(Vc),ew=nu(Lo);function Fh(r){return lu(r)?So(mn(r)):xN(r)}function tw(r){return function(s){return r==null?n:gr(r,s)}}var nw=$f(),rw=$f(!0);function Au(){return[]}function Lu(){return!1}function iw(){return{}}function sw(){return""}function aw(){return!0}function ow(r,s){if(r=ee(r),r<1||r>qn)return[];var o=hn,c=et(r,hn);s=q(s),r-=hn;for(var d=Do(c,s);++o<r;)s(o);return d}function uw(r){return j(r)?Ae(r,mn):wt(r)?[r]:pt(rh(pe(r)))}function lw(r){var s=++yT;return pe(r)+s}var cw=Zs(function(r,s){return r+s},0),fw=ru("ceil"),hw=Zs(function(r,s){return r/s},1),dw=ru("floor");function pw(r){return r&&r.length?Gs(r,Et,Go):n}function mw(r,s){return r&&r.length?Gs(r,q(s,2),Go):n}function gw(r){return Gc(r,Et)}function Ew(r,s){return Gc(r,q(s,2))}function Tw(r){return r&&r.length?Gs(r,Et,qo):n}function Nw(r,s){return r&&r.length?Gs(r,q(s,2),qo):n}var yw=Zs(function(r,s){return r*s},1),vw=ru("round"),_w=Zs(function(r,s){return r-s},0);function bw(r){return r&&r.length?xo(r,Et):0}function ww(r,s){return r&&r.length?xo(r,q(s,2)):0}return p.after=qv,p.ary=ph,p.assign=k_,p.assignIn=Sh,p.assignInWith=ua,p.assignWith=M_,p.at=P_,p.before=mh,p.bind=mu,p.bindAll=Bb,p.bindKey=gh,p.castArray=i_,p.chain=fh,p.chunk=dy,p.compact=py,p.concat=my,p.cond=$b,p.conforms=Gb,p.constant=_u,p.countBy=bv,p.create=C_,p.curry=Eh,p.curryRight=Th,p.debounce=Nh,p.defaults=F_,p.defaultsDeep=U_,p.defer=Xv,p.delay=Yv,p.difference=gy,p.differenceBy=Ey,p.differenceWith=Ty,p.drop=Ny,p.dropRight=yy,p.dropRightWhile=vy,p.dropWhile=_y,p.fill=by,p.filter=Iv,p.flatMap=Sv,p.flatMapDeep=Ov,p.flatMapDepth=xv,p.flatten=oh,p.flattenDeep=wy,p.flattenDepth=Iy,p.flip=Zv,p.flow=Hb,p.flowRight=zb,p.fromPairs=Ay,p.functions=z_,p.functionsIn=q_,p.groupBy=Dv,p.initial=Sy,p.intersection=Oy,p.intersectionBy=xy,p.intersectionWith=Dy,p.invert=Y_,p.invertBy=Z_,p.invokeMap=kv,p.iteratee=bu,p.keyBy=Mv,p.keys=Ye,p.keysIn=gt,p.map=na,p.mapKeys=J_,p.mapValues=j_,p.matches=qb,p.matchesProperty=Xb,p.memoize=ia,p.merge=Q_,p.mergeWith=Oh,p.method=Yb,p.methodOf=Zb,p.mixin=wu,p.negate=sa,p.nthArg=Jb,p.omit=eb,p.omitBy=tb,p.once=Kv,p.orderBy=Pv,p.over=jb,p.overArgs=Jv,p.overEvery=Qb,p.overSome=ew,p.partial=gu,p.partialRight=yh,p.partition=Cv,p.pick=nb,p.pickBy=xh,p.property=Fh,p.propertyOf=tw,p.pull=Py,p.pullAll=lh,p.pullAllBy=Cy,p.pullAllWith=Fy,p.pullAt=Uy,p.range=nw,p.rangeRight=rw,p.rearg=jv,p.reject=Vv,p.remove=Vy,p.rest=Qv,p.reverse=du,p.sampleSize=$v,p.set=ib,p.setWith=sb,p.shuffle=Gv,p.slice=By,p.sortBy=zv,p.sortedUniq=Xy,p.sortedUniqBy=Yy,p.split=Sb,p.spread=e_,p.tail=Zy,p.take=Ky,p.takeRight=Jy,p.takeRightWhile=jy,p.takeWhile=Qy,p.tap=pv,p.throttle=t_,p.thru=ta,p.toArray=Ih,p.toPairs=Dh,p.toPairsIn=Rh,p.toPath=uw,p.toPlainObject=Lh,p.transform=ab,p.unary=n_,p.union=ev,p.unionBy=tv,p.unionWith=nv,p.uniq=rv,p.uniqBy=iv,p.uniqWith=sv,p.unset=ob,p.unzip=pu,p.unzipWith=ch,p.update=ub,p.updateWith=lb,p.values=Kr,p.valuesIn=cb,p.without=av,p.words=Ph,p.wrap=r_,p.xor=ov,p.xorBy=uv,p.xorWith=lv,p.zip=cv,p.zipObject=fv,p.zipObjectDeep=hv,p.zipWith=dv,p.entries=Dh,p.entriesIn=Rh,p.extend=Sh,p.extendWith=ua,wu(p,p),p.add=cw,p.attempt=Ch,p.camelCase=pb,p.capitalize=kh,p.ceil=fw,p.clamp=fb,p.clone=s_,p.cloneDeep=o_,p.cloneDeepWith=u_,p.cloneWith=a_,p.conformsTo=l_,p.deburr=Mh,p.defaultTo=Wb,p.divide=hw,p.endsWith=mb,p.eq=Kt,p.escape=gb,p.escapeRegExp=Eb,p.every=wv,p.find=Av,p.findIndex=sh,p.findKey=V_,p.findLast=Lv,p.findLastIndex=ah,p.findLastKey=B_,p.floor=dw,p.forEach=hh,p.forEachRight=dh,p.forIn=$_,p.forInRight=G_,p.forOwn=W_,p.forOwnRight=H_,p.get=Nu,p.gt=c_,p.gte=f_,p.has=X_,p.hasIn=yu,p.head=uh,p.identity=Et,p.includes=Rv,p.indexOf=Ly,p.inRange=hb,p.invoke=K_,p.isArguments=Nr,p.isArray=j,p.isArrayBuffer=h_,p.isArrayLike=mt,p.isArrayLikeObject=Ue,p.isBoolean=d_,p.isBuffer=tr,p.isDate=p_,p.isElement=m_,p.isEmpty=g_,p.isEqual=E_,p.isEqualWith=T_,p.isError=Eu,p.isFinite=N_,p.isFunction=xn,p.isInteger=vh,p.isLength=aa,p.isMap=_h,p.isMatch=y_,p.isMatchWith=v_,p.isNaN=__,p.isNative=b_,p.isNil=I_,p.isNull=w_,p.isNumber=bh,p.isObject=Re,p.isObjectLike=Pe,p.isPlainObject=Gi,p.isRegExp=Tu,p.isSafeInteger=A_,p.isSet=wh,p.isString=oa,p.isSymbol=wt,p.isTypedArray=Zr,p.isUndefined=L_,p.isWeakMap=S_,p.isWeakSet=O_,p.join=Ry,p.kebabCase=Tb,p.last=Ft,p.lastIndexOf=ky,p.lowerCase=Nb,p.lowerFirst=yb,p.lt=x_,p.lte=D_,p.max=pw,p.maxBy=mw,p.mean=gw,p.meanBy=Ew,p.min=Tw,p.minBy=Nw,p.stubArray=Au,p.stubFalse=Lu,p.stubObject=iw,p.stubString=sw,p.stubTrue=aw,p.multiply=yw,p.nth=My,p.noConflict=Kb,p.noop=Iu,p.now=ra,p.pad=vb,p.padEnd=_b,p.padStart=bb,p.parseInt=wb,p.random=db,p.reduce=Fv,p.reduceRight=Uv,p.repeat=Ib,p.replace=Ab,p.result=rb,p.round=vw,p.runInContext=b,p.sample=Bv,p.size=Wv,p.snakeCase=Lb,p.some=Hv,p.sortedIndex=$y,p.sortedIndexBy=Gy,p.sortedIndexOf=Wy,p.sortedLastIndex=Hy,p.sortedLastIndexBy=zy,p.sortedLastIndexOf=qy,p.startCase=Ob,p.startsWith=xb,p.subtract=_w,p.sum=bw,p.sumBy=ww,p.template=Db,p.times=ow,p.toFinite=Dn,p.toInteger=ee,p.toLength=Ah,p.toLower=Rb,p.toNumber=Ut,p.toSafeInteger=R_,p.toString=pe,p.toUpper=kb,p.trim=Mb,p.trimEnd=Pb,p.trimStart=Cb,p.truncate=Fb,p.unescape=Ub,p.uniqueId=lw,p.upperCase=Vb,p.upperFirst=vu,p.each=hh,p.eachRight=dh,p.first=uh,wu(p,function(){var r={};return dn(p,function(s,o){Ee.call(p.prototype,o)||(r[o]=s)}),r}(),{chain:!1}),p.VERSION=i,Rt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(r){p[r].placeholder=p}),Rt(["drop","take"],function(r,s){ae.prototype[r]=function(o){o=o===n?1:He(ee(o),0);var c=this.__filtered__&&!s?new ae(this):this.clone();return c.__filtered__?c.__takeCount__=et(o,c.__takeCount__):c.__views__.push({size:et(o,hn),type:r+(c.__dir__<0?"Right":"")}),c},ae.prototype[r+"Right"]=function(o){return this.reverse()[r](o).reverse()}}),Rt(["filter","map","takeWhile"],function(r,s){var o=s+1,c=o==ac||o==Pg;ae.prototype[r]=function(d){var g=this.clone();return g.__iteratees__.push({iteratee:q(d,3),type:o}),g.__filtered__=g.__filtered__||c,g}}),Rt(["head","last"],function(r,s){var o="take"+(s?"Right":"");ae.prototype[r]=function(){return this[o](1).value()[0]}}),Rt(["initial","tail"],function(r,s){var o="drop"+(s?"":"Right");ae.prototype[r]=function(){return this.__filtered__?new ae(this):this[o](1)}}),ae.prototype.compact=function(){return this.filter(Et)},ae.prototype.find=function(r){return this.filter(r).head()},ae.prototype.findLast=function(r){return this.reverse().find(r)},ae.prototype.invokeMap=ne(function(r,s){return typeof r=="function"?new ae(this):this.map(function(o){return Ci(o,r,s)})}),ae.prototype.reject=function(r){return this.filter(sa(q(r)))},ae.prototype.slice=function(r,s){r=ee(r);var o=this;return o.__filtered__&&(r>0||s<0)?new ae(o):(r<0?o=o.takeRight(-r):r&&(o=o.drop(r)),s!==n&&(s=ee(s),o=s<0?o.dropRight(-s):o.take(s-r)),o)},ae.prototype.takeRightWhile=function(r){return this.reverse().takeWhile(r).reverse()},ae.prototype.toArray=function(){return this.take(hn)},dn(ae.prototype,function(r,s){var o=/^(?:filter|find|map|reject)|While$/.test(s),c=/^(?:head|last)$/.test(s),d=p[c?"take"+(s=="last"?"Right":""):s],g=c||/^find/.test(s);d&&(p.prototype[s]=function(){var y=this.__wrapped__,_=c?[1]:arguments,w=y instanceof ae,x=_[0],D=w||j(y),R=function(ie){var oe=d.apply(p,Yn([ie],_));return c&&P?oe[0]:oe};D&&o&&typeof x=="function"&&x.length!=1&&(w=D=!1);var P=this.__chain__,$=!!this.__actions__.length,X=g&&!P,te=w&&!$;if(!g&&D){y=te?y:new ae(this);var Y=r.apply(y,_);return Y.__actions__.push({func:ta,args:[R],thisArg:n}),new Mt(Y,P)}return X&&te?r.apply(this,_):(Y=this.thru(R),X?c?Y.value()[0]:Y.value():Y)})}),Rt(["pop","push","shift","sort","splice","unshift"],function(r){var s=Ls[r],o=/^(?:push|sort|unshift)$/.test(r)?"tap":"thru",c=/^(?:pop|shift)$/.test(r);p.prototype[r]=function(){var d=arguments;if(c&&!this.__chain__){var g=this.value();return s.apply(j(g)?g:[],d)}return this[o](function(y){return s.apply(j(y)?y:[],d)})}}),dn(ae.prototype,function(r,s){var o=p[s];if(o){var c=o.name+"";Ee.call(Hr,c)||(Hr[c]=[]),Hr[c].push({name:s,func:o})}}),Hr[Ys(n,le).name]=[{name:"wrapper",func:n}],ae.prototype.clone=UT,ae.prototype.reverse=VT,ae.prototype.value=BT,p.prototype.at=mv,p.prototype.chain=gv,p.prototype.commit=Ev,p.prototype.next=Tv,p.prototype.plant=yv,p.prototype.reverse=vv,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=_v,p.prototype.first=p.prototype.head,Oi&&(p.prototype[Oi]=Nv),p},$r=ET();fr?((fr.exports=$r)._=$r,bo._=$r):je._=$r}).call(pS)}(zi,zi.exports)),zi.exports}var Cn=mS();class gS{constructor(e,n,i){this.declarationNode=e,this.ast=n,this.symbolFactory=i}bind(){return!(this.declarationNode.parent instanceof re)||dt(this.declarationNode.parent).unwrap_or(void 0)!==U.Table?[]:this.declarationNode.body instanceof Ge?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e)return[];if(e instanceof z)return this.bindFields([e]);const[n,i]=Cn.partition(e.body,a=>a instanceof z);return[...this.bindFields(n),...this.bindSubElements(i)]}bindFields(e){return e.flatMap(n=>{if(!n.callee)return[];const i=qe(this.declarationNode.parent.name).map(f=>f.join(".")).unwrap_or("<unnamed>"),a=this.declarationNode.parent.symbol.symbolTable;return[n.callee,...n.args].flatMap(tn).flatMap(f=>f.variables.length+f.tupleElements.length>1?[]:f.variables.length?f.variables[0]:f.tupleElements).flatMap(f=>{const h=ze(f).unwrap_or(void 0);if(h===void 0)return[];const m=Un(h),E=a.get(m);return E?(f.referee=E,E.references.push(f),[]):new v(N.BINDING_ERROR,`No column named '${h}' inside Table '${i}'`,f)})})}bindSubElements(e){return e.flatMap(n=>{if(!n.type)return[];const i=fn(n);return new i(n,this.ast,this.symbolFactory).bind()})}}class ES{constructor(e,n,i){this.declarationNode=e,this.ast=n,this.symbolFactory=i}bind(){return this.bindBody(this.declarationNode.body)}bindBody(e){if(!e)return[];if(e instanceof z)return[];const n=e.body.filter(i=>i instanceof re);return this.bindSubElements(n)}bindSubElements(e){return e.flatMap(n=>{if(!n.type)return[];const i=fn(n);return new i(n,this.ast,this.symbolFactory).bind()})}}class TS{constructor(e,n,i){this.declarationNode=e,this.ast=n,this.symbolFactory=i}bind(){return this.declarationNode.body instanceof Ge?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e)return[];if(e instanceof z)return[];const n=e.body.filter(i=>i instanceof re);return this.bindSubElements(n)}bindSubElements(e){return e.flatMap(n=>{if(!n.type)return[];const i=fn(n);return new i(n,this.ast,this.symbolFactory).bind()})}}class NS{constructor(e,n,i){this.declarationNode=e,this.ast=n,this.symbolFactory=i}bind(){return!(this.declarationNode.parent instanceof Ze)&&dt(this.declarationNode.parent).unwrap_or(void 0)!==U.Project?[]:this.bindBody(this.declarationNode.body)}bindBody(e){if(!e)return[];if(e instanceof z)return this.bindFields([e]);const[n,i]=Cn.partition(e.body,a=>a instanceof z);return[...this.bindFields(n),...this.bindSubElements(i)]}bindFields(e){return e.flatMap(n=>n.callee?[n.callee,...n.args].flatMap(tn).flatMap(u=>{let l=u.tupleElements.length?u.tupleElements:u.variables.pop();const f=u.variables.pop();if(!l||!f)return[];Array.isArray(l)||(l=[l]);const h=u.variables;return l.flatMap(m=>Bt(this.ast,[...h.map(E=>({node:E,kind:M.Schema})),{node:f,kind:M.Table},{node:m,kind:M.Column}]))}):[])}bindSubElements(e){return e.flatMap(n=>{if(!n.type)return[];const i=fn(n);return new i(n,this.ast,this.symbolFactory).bind()})}}class nm{constructor(e,n,i){this.declarationNode=e,this.ast=n,this.symbolFactory=i}bind(){return this.declarationNode.body instanceof Ge?this.bindBody(this.declarationNode.body):[]}resolvePartialInjections(){const{body:e}=this.declarationNode;return(e?e instanceof Ge?e.body:[e]:[]).filter(i=>i instanceof z&&ts(i.callee)).reverse().flatMap(i=>{const a=Ot(i.callee.expression).unwrap_or(void 0);if(!a)return[];const u=a.variables.pop(),l=a.variables;if(!u)return[];const f=Bt(this.ast,[...l.map(h=>({node:h,kind:M.Schema})),{node:u,kind:M.TablePartial}]);return f.length?f:(u.referee?.symbolTable?.forEach(h=>{const m=ve(h.declaration.callee).unwrap_or(void 0);if(m===void 0)return;const E=this.symbolFactory.create(pi,{declaration:i,tablePartialSymbol:u.referee}),T=Un(m),A=this.declarationNode.symbol?.symbolTable;A?.has(T)||A?.set(T,E)}),[])})}bindBody(e){if(!e)return[];if(e instanceof z)return this.bindFields([e]);const[n,i]=Cn.partition(e.body,a=>a instanceof z);return[...this.bindFields(n),...this.bindSubElements(i)]}bindFields(e){const n=e.filter(a=>!ts(a.callee));return(a=>a.flatMap(u=>{if(!u.callee)return[];const l=[],f=[u.callee,...u.args];if(Cn.last(f)instanceof Le){const h=Cn.last(f),m=ke(h).getValue();l.push(...m.ref?.flatMap(E=>E.value?this.bindInlineRef(E.value):[])||[]),l.push(...m.default?.flatMap(E=>E.value?this.tryToBindEnumFieldRef(E.value):[])||[]),f.pop()}return f[1]&&this.tryToBindColumnType(f[1]),l}))(n)}tryToBindColumnType(e){const n=Ot(e).unwrap_or(void 0);if(!n)return;const i=n.variables.pop(),a=n.variables;i&&Bt(this.ast,[...a.map(u=>({node:u,kind:M.Schema})),{node:i,kind:M.Enum}])}tryToBindEnumFieldRef(e){if(Ke(e))return[];if(De(e)){const l=e.expression.variable?.value?.toLowerCase();if(l&&Zp.includes(l))return[]}const n=Ot(e).unwrap_or(void 0);if(!n)return[];const i=n.variables.pop(),a=n.variables.pop();if(!i||!a)return[];const u=n.variables;return Bt(this.ast,[...u.map(l=>({node:l,kind:M.Schema})),{node:a,kind:M.Enum},{node:i,kind:M.EnumField}])}bindInlineRef(e){return tn(e).flatMap(i=>{const a=i.variables.pop(),u=i.variables.pop();if(!a)return[];const l=i.variables;return u?Bt(this.ast,[...l.map(f=>({node:f,kind:M.Schema})),{node:u,kind:M.Table},{node:a,kind:M.Column}]):Bt(this.declarationNode,[{node:a,kind:M.Column}])})}bindSubElements(e){return e.flatMap(n=>{if(!n.type)return[];const i=fn(n);return new i(n,this.ast,this.symbolFactory).bind()})}}class yS{constructor(e,n,i){this.declarationNode=e,this.ast=n,this.symbolFactory=i}bind(){return this.declarationNode.body instanceof Ge?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e)return[];if(e instanceof z)return this.bindFields([e]);const[n,i]=Cn.partition(e.body,a=>a instanceof z);return[...this.bindFields(n),...this.bindSubElements(i)]}bindFields(e){return e.flatMap(n=>n.callee?[n.callee,...n.args].flatMap(tn).flatMap(u=>{const l=u.variables.pop();if(!l)return[];const f=u.variables;return Bt(this.ast,[...f.map(h=>({node:h,kind:M.Schema})),{node:l,kind:M.Table}])}):[])}bindSubElements(e){return e.flatMap(n=>{if(!n.type)return[];const i=fn(n);return new i(n,this.ast,this.symbolFactory).bind()})}}class vS{constructor(e,n,i){this.declarationNode=e,this.ast=n,this.symbolFactory=i}bind(){return this.declarationNode.body instanceof Ge?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e)return[];if(e instanceof z)return this.bindFields([e]);const[n,i]=Cn.partition(e.body,a=>a instanceof z);return[...this.bindFields(n),...this.bindSubElements(i)]}bindFields(e){return e.flatMap(n=>{if(!n.callee)return[];const i=[],a=[n.callee,...n.args];if(Cn.last(a)instanceof Le){const u=Cn.last(a),l=ke(u).getValue();i.push(...l.ref?.flatMap(f=>f.value?this.bindInlineRef(f.value):[])||[]),a.pop()}return a[1]&&this.tryToBindColumnType(a[1]),i})}tryToBindColumnType(e){const n=Ot(e).unwrap_or(void 0);if(!n)return;const i=n.variables.pop(),a=n.variables;i&&Bt(this.ast,[...a.map(u=>({node:u,kind:M.Schema})),{node:i,kind:M.Enum}])}bindInlineRef(e){return tn(e).flatMap(i=>{const a=i.variables.pop(),u=i.variables.pop();if(!a)return[];const l=i.variables;return u?Bt(this.ast,[...l.map(f=>({node:f,kind:M.Schema})),{node:u,kind:M.Table},{node:a,kind:M.Column}]):Bt(this.declarationNode,[{node:a,kind:M.Column}])})}bindSubElements(e){return e.flatMap(n=>{if(!n.type)return[];const i=fn(n);return new i(n,this.ast,this.symbolFactory).bind()})}}function _S(t){return[ls,ui,Dl,kl,Un,Rl,Ml,Pl,Cl].map(e=>e(t))}function bS(t){if(t instanceof xl)return M.Schema;if(t instanceof oi)return M.Table;if(t instanceof di)return M.Column;if(t instanceof Wp)return M.Enum;if(t instanceof Hp)return M.EnumField;if(t instanceof zp)return M.TableGroup;if(t instanceof qp)return M.TableGroupField;if(t instanceof Xp)return M.TablePartial;if(t instanceof pi)return M.Column;if(t instanceof Yp)return M.PartialInjection;throw new Error("No other possible symbol kind in getSymbolKind")}class wS{constructor(e,n,i){this.declarationNode=e,this.ast=n,this.symbolFactory=i,this.boundColumns=new Map}bind(){const e=[];return this.declarationNode.name&&e.push(...this.bindRecordsName(this.declarationNode.name)),this.declarationNode.body instanceof Ge&&e.push(...this.bindBody(this.declarationNode.body)),e}bindRecordsName(e){return this.declarationNode.parent instanceof Ze?this.bindTopLevelName(e):this.bindInsideTableName(e)}bindTopLevelName(e){const n=tm(e).unwrap_or(void 0);if(!n)return[];const i=n.variables.pop(),a=n.variables;if(!i)return[];const u=Bt(this.ast,[...a.map(m=>({node:m,kind:M.Schema})),{node:i,kind:M.Table}]);if(u.length>0)return u;const l=i.referee;if(!l?.symbolTable)return[];const f=Ju(i.referee?.declaration).unwrap_or("<invalid name>"),h=[];for(const m of n.args){const E=ze(m).unwrap_or("<unnamed>"),T=Un(E),A=l.symbolTable.get(T);if(!A){h.push(new v(N.BINDING_ERROR,`Column '${E}' does not exist in Table '${f}'`,m));continue}m.referee=A,A.references.push(m);const O=this.boundColumns.get(A);O&&(h.push(new v(N.DUPLICATE_COLUMN_REFERENCES_IN_RECORDS,`Column '${E}' is referenced more than once in a Records for Table '${f}'`,O)),h.push(new v(N.DUPLICATE_COLUMN_REFERENCES_IN_RECORDS,`Column '${E}' is referenced more than once in a Records for Table '${f}'`,m))),this.boundColumns.set(A,m)}return h}bindInsideTableName(e){const n=this.declarationNode.parent;if(!(n instanceof re))return[];if(dt(n).unwrap_or(void 0)!==U.Table)return[];const a=n.symbol?.symbolTable;if(!a)return[];if(!ns(e))return[];const u=Ju(n).unwrap_or("<invalid name>"),l=[];for(const f of e.elementList){const h=ze(f).unwrap_or("<unnamed>"),m=Un(h),E=a.get(m);if(!E){l.push(new v(N.BINDING_ERROR,`Column '${h}' does not exist in Table '${u}'`,f));continue}f.referee=E,E.references.push(f)}return l}bindBody(e){if(!e)return[];if(e instanceof z)return this.bindDataRow(e);const n=e.body.filter(a=>a instanceof z),i=e.body.filter(a=>a instanceof re);return[...this.bindDataRows(n),...this.bindSubElements(i)]}bindDataRows(e){return e.flatMap(n=>this.bindDataRow(n))}bindDataRow(e){return e.callee?(e.callee instanceof Fn?e.callee.elementList:[e.callee]).flatMap(tn).flatMap(a=>{const u=a.variables.pop(),l=a.variables.pop();if(!u||!l)return[];const f=a.variables;return Bt(this.ast,[...f.map(h=>({node:h,kind:M.Schema})),{node:l,kind:M.Enum},{node:u,kind:M.EnumField}])}):[]}bindSubElements(e){return e.flatMap(n=>{if(!n.type)return[];const i=fn(n);return new i(n,this.ast,this.symbolFactory).bind()})}}function fn(t){switch(t.type.value.toLowerCase()){case U.Enum:return dS;case U.Table:return nm;case U.TableGroup:return yS;case U.Project:return TS;case U.Ref:return NS;case U.Note:return ES;case U.Indexes:return gS;case U.TablePartial:return vS;case U.Check:return fS;case U.Records:return wS;default:return hS}}function tn(t){if(!t)return[];if(De(t))return[{variables:[t],tupleElements:[]}];if(t instanceof on){const e=Ot(t).unwrap_or(void 0);return e?[e]:[...tn(t.leftExpression),...tn(t.rightExpression)]}if(t instanceof ft||t instanceof Ga)return tn(t.expression);if(t instanceof ln){const e=Ot(t).unwrap_or(void 0);return e?[e]:t.elementList.flatMap(tn)}return[]}function Bt(t,e){if(!t.symbol?.symbolTable)throw new Error("lookupAndBindInScope should only be called with initial scope having a symbol table");let n=t.symbol.symbolTable,i=bS(t.symbol),a=t instanceof re?Ju(t).unwrap_or("<invalid name>"):Wt;if(t instanceof Ze&&e.length){const{node:u,kind:l}=e[0];ze(u).unwrap_or("<unnamed>")===Wt&&l===M.Schema&&e.shift()}for(const u of e){const{node:l,kind:f}=u,h=ze(l).unwrap_or("<unnamed>"),m=FL(h,f),E=n.get(m);if(!E)return[new v(N.BINDING_ERROR,`${f} '${h}' does not exist in ${a===void 0?"global scope":`${i} '${a}'`}`,l)];if(l.referee=E,E.references.push(l),a=h,i=f,!E.symbolTable)return[];n=E.symbolTable}return[]}class IS{constructor(e,n){this.ast=e,this.symbolFactory=n}resolvePartialInjections(){return this.ast.body.filter(e=>dt(e).unwrap_or("")===U.Table).flatMap(e=>new nm(e,this.ast,this.symbolFactory).resolvePartialInjections())}resolve(){const e=[];e.push(...this.resolvePartialInjections());for(const n of this.ast.body)if(n.type){const i=fn(n),a=new i(n,this.ast,this.symbolFactory);e.push(...a.bind())}return new ue(this.ast,e)}}class AS{constructor(e){this.generator=e}create(e,n){return new e(n,this.generator.nextId())}}class LS{constructor(e,n){this.ast=e,this.symbolFactory=new AS(n)}analyze(){return new Ed(this.ast,this.symbolFactory).validate().chain(n=>new IS(n,this.symbolFactory).resolve())}validate(){return new Ed(this.ast,this.symbolFactory).validate().chain(n=>new ue(n,[]))}}function Nd(t,e){const{variables:n,tupleElements:i}=Ot(t).unwrap(),a=i.map(l=>ze(l).unwrap()),u=n.map(l=>ze(l).unwrap());return i.length?n.length===0?{schemaName:e.schemaName,tableName:e.name,fieldNames:a}:{tableName:u.pop(),schemaName:u.pop()||null,fieldNames:a}:n.length===1?{schemaName:e.schemaName,tableName:e.name,fieldNames:[u[0]]}:{fieldNames:[u.pop()],tableName:u.pop(),schemaName:u.pop()||null}}function Bl(t){switch(t){case"<":return["1","*"];case"<>":return["*","*"];case">":return["*","1"];case"-":return["1","1"];default:throw new Error("Invalid relation op")}}function Q(t){return{start:{offset:t.startPos.offset,line:t.startPos.line+1,column:t.startPos.column+1},end:{offset:t.endPos.offset,line:t.endPos.line+1,column:t.endPos.column+1}}}function wa(t){const e=vn(t).unwrap_or(void 0)?.pop();return e instanceof ln?e.elementList.map(n=>n.referee):[e.referee]}function kr(t){const e=qe(t).unwrap();return{name:e.pop(),schemaName:e}}function cs(t){return t.expression.literal.value}function rm(t,e){if(Array.isArray(t)){const a=t.map(({id:l})=>l).sort().join(","),u=e.map(({id:l})=>l).sort().join(",");return a<u?`${a}-${u}`:`${u}-${a}`}const n=t.id.toString(),i=e.id.toString();return n<i?`${n}-${i}`:`${i}-${n}`}function $l(t,e){if(Array.isArray(t)){const a=t.map(({id:l})=>l).sort(),u=e.map(({id:l})=>l).sort();return zu(a,u).every(([l,f])=>l===f)}const n=t.id,i=e.id;return n===i}function an(t){const e=t.split(`
|
|
29
|
+
`),n=e.slice(e.findIndex(u=>u.trimStart()!=="")),i=n.filter(u=>u.trimStart()),a=Math.min(...i.map(u=>u.length-u.trimStart().length));return n.map(u=>u.slice(a)).join(`
|
|
30
|
+
`)}function im(t){if(t){if(Ke(t))return{value:Te(t).unwrap(),type:"string"};if(St(t))return{type:"number",value:ni(t)};if(yn(t))return{value:t.expression.variable.value.toLowerCase(),type:"boolean"};if(t instanceof st&&t.value)return{value:t.value.value,type:"expression"};if(Vl(t))return{value:vn(t).map(Oe).and_then(ve).unwrap(),type:"string"};throw new Error("Unreachable")}}function sm(t,e){let n="",i=null,a,u;if(t instanceof Se){const E=t.argumentList.elementList;if(i=E.map(T=>St(T)?Yu(T):Ke(T)?Te(T).unwrap():ve(T).unwrap()).join(","),n=`(${i})`,E.length===2&&St(E[0])&&St(E[1])){const T=ni(E[0]),A=ni(E[1]);!isNaN(T)&&!isNaN(A)&&(a={precision:Math.trunc(T),scale:Math.trunc(A)})}else if(E.length===1&&St(E[0])){const T=ni(E[0]);isNaN(T)||(u={length:Math.trunc(T)})}t=t.callee}for(;t instanceof Se||t instanceof Tn;)t instanceof Se?(n=`(${t.argumentList.elementList.map(T=>St(T)?Yu(T):Ke(T)?Te(T).unwrap():ve(T).unwrap()).join(",")})${n}`,t=t.callee):t instanceof Tn&&(n=`${`[${t.indexer.elementList.map(T=>T.name.expression.literal.value).join(",")}]`}${n}`,t=t.array);const{name:l,schemaName:f}=kr(t),h=f.length===0?null:f[0],m=!![...e.enums.values()].find(E=>E.name===l&&E.schemaName===h);return f.length>1?new ue({schemaName:f.length===0?null:f[0],type_name:`${l}${n}`,args:i,numericParams:a,lengthParam:u,isEnum:m},[new v(N.UNSUPPORTED,"Nested schema is not supported",t)]):new ue({schemaName:f.length===0?null:f[0],type_name:`${l}${n}`,args:i,numericParams:a,lengthParam:u,isEnum:m})}function is(t,e){const n=[...e.tables.entries()].find(([,O])=>O===t)?.[0];if(!n)throw new Error("mergeTableAndPartials should be called after all tables are interpreted");if(!(n.body instanceof Ge))throw new Error("Table element should have a block body");const i=[...t.indexes],a=[...t.checks];let u=t.headerColor,l=t.note;const f=[...e.tablePartials.values()];for(const O of[...t.partials].reverse()){const{name:F}=O,G=f.find(H=>H.name===F);G&&(i.push(...G.indexes),a.push(...G.checks),G.headerColor!==void 0&&(u=G.headerColor),G.note!==void 0&&(l=G.note))}const h=new Map(t.fields.map(O=>[O.name,O])),m=new Set(h.keys()),E=new Map(f.map(O=>[O.name,O])),T=[];for(const O of n.body.body)if(O instanceof z)if(ts(O.callee)){const F=ve(O.callee.expression).unwrap_or(void 0),G=E.get(F);if(!G)continue;for(const H of G.fields)m.has(H.name)||T.push(H)}else{const F=ve(O.callee).unwrap(),G=h.get(F);if(!G)continue;T.push(G)}const A=AL([...T].reverse(),"name").reverse();return{...t,fields:A,indexes:i,checks:a,headerColor:u,note:l}}function SS(t,e){const n=[],i=[...e.tablePartials.values()],a=new Set(t.fields.map(u=>u.name));for(const u of[...t.partials].reverse()){const{name:l}=u,f=i.find(h=>h.name===l);if(f){for(const h of f.fields)if(!a.has(h.name))for(const m of h.inline_refs){const E=Bl(m.relation);n.push({name:null,schemaName:null,token:m.token,endpoints:[{schemaName:m.schemaName,tableName:m.tableName,fieldNames:m.fieldNames,token:m.token,relation:E[1]},{schemaName:t.schemaName,tableName:t.name,fieldNames:[h.name],token:h.token,relation:E[0]}]})}}}return n}class am{constructor(e,n){this.declarationNode=e,this.env=n,this.table={name:void 0,schemaName:void 0,alias:null,fields:[],token:void 0,indexes:[],partials:[],checks:[]},this.pkColumns=[]}interpret(){this.table.token=Q(this.declarationNode),this.env.tables.set(this.declarationNode,this.table);const e=[...this.interpretName(this.declarationNode.name),...this.interpretAlias(this.declarationNode.alias),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.table.indexes.push({columns:this.pkColumns.map(({name:n,token:i})=>({value:n,type:"column",token:i})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(n=>{n.pk=!1})),e}interpretName(e){const{name:n,schemaName:i}=kr(e);return i.length>1?(this.table.name=n,this.table.schemaName=i.join("."),[new v(N.UNSUPPORTED,"Nested schema is not supported",e)]):(this.table.name=n,this.table.schemaName=i.length?i[0]:null,[])}interpretAlias(e){if(!e)return[];const n=ze(e).unwrap_or(null);return n&&(this.env.aliases.push({name:n,kind:"table",value:{tableName:this.table.name,schemaName:this.table.schemaName}}),this.table.alias=n),[]}interpretSettingList(e){const n=ke(e).getValue();this.table.headerColor=n[k.HeaderColor]?.length?cs(n[k.HeaderColor]?.at(0)?.value):void 0;const[i]=n[k.Note]||[];return this.table.note=i&&{value:Te(i?.value).map(an).unwrap(),token:Q(i)},[]}interpretBody(e){const[n,i]=ht(e.body,a=>a instanceof z);return[...this.interpretFields(n),...this.interpretSubElements(i)]}interpretSubElements(e){return e.flatMap(n=>{switch(n.type?.value.toLowerCase()){case U.Note:return this.table.note={value:Te(n.body instanceof Ge?n.body.body[0].callee:n.body.callee).map(an).unwrap(),token:Q(n)},[];case U.Indexes:return this.interpretIndexes(n);case U.Check:return this.interpretChecks(n);case U.Records:return this.env.recordsElements.push(n),[];default:return[]}})}interpretInjection(e,n){const i={order:n,token:Q(e)};return i.name=ve(e.expression).unwrap_or(""),this.table.partials.push(i),[]}interpretFields(e){const a=(this.declarationNode.symbol?.symbolTable?[...this.declarationNode.symbol.symbolTable.entries()]:[]).filter(([l])=>mi(l).unwrap_or(null)?.kind===M.Column).length?[]:[new v(N.EMPTY_TABLE,"A Table must have at least one column",this.declarationNode)],u=e.flatMap((l,f)=>ts(l.callee)?this.interpretInjection(l.callee,f):this.interpretColumn(l));return[...a,...u]}interpretColumn(e){const n=[],i={};i.name=ze(e.callee).unwrap();const a=sm(e.args[0],this.env);i.type=a.getValue(),n.push(...a.getErrors()),i.token=Q(e),i.inline_refs=[];const u=e.args.slice(1);if(Oe(u)instanceof Le){const l=ke(u.pop()).getValue();i.pk=!!l[k.PK]?.length||!!l[k.PrimaryKey]?.length,i.increment=!!l[k.Increment]?.length,i.unique=!!l[k.Unique]?.length,i.not_null=l[k.NotNull]?.length?!0:l[k.Null]?.length?!1:void 0,i.dbdefault=im(l[k.Default]?.at(0)?.value);const f=l[k.Note]?.at(0);i.note=f&&{value:Te(f.value).map(an).unwrap(),token:Q(f)};const h=l[k.Ref]||[];i.inline_refs=h.flatMap(E=>{const[T]=wa(E.value.expression);if($l(T,e.symbol))return n.push(new v(N.SAME_ENDPOINT,"Two endpoints are the same",E)),[];const A=E.value.op,O=qe(E.value.expression).unwrap();let F;if(O.length===1){const[H]=O;F={schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[H],relation:A.value,token:Q(E)}}else if(O.length===2){const[H,le]=O;F={schemaName:null,tableName:H,fieldNames:[le],relation:A.value,token:Q(E)}}else if(O.length===3){const[H,le,Me]=O;F={schemaName:H,tableName:le,fieldNames:[Me],relation:A.value,token:Q(E)}}else{n.push(new v(N.UNSUPPORTED,"Nested schema is not supported",E));const H=O.pop(),le=O.pop();F={schemaName:O.join("."),tableName:le,fieldNames:[H],relation:A.value,token:Q(E)}}const G=this.registerInlineRefToEnv(e,T,F,E);return n.push(...G),G.length===0?F:[]});const m=l[k.Check]||[];i.checks=m.map(E=>{const T=Q(E),A=E.value.value.value;return{token:T,expression:A}})}return i.pk||=u.some(l=>ve(l).unwrap().toLowerCase()==="pk"),i.unique||=u.some(l=>ve(l).unwrap().toLowerCase()==="unique"),this.table.fields.push(i),i.pk&&this.pkColumns.push(i),n}interpretIndexes(e){return this.table.indexes.push(...e.body.body.map(n=>{const i={columns:[]},a=n;i.token=Q(a);const u=[a.callee,...a.args];if(Oe(u)instanceof Le){const l=ke(u.pop()).getValue();i.pk=!!l[k.PK]?.length,i.unique=!!l[k.Unique]?.length,i.name=Te(l[k.Name]?.at(0)?.value).unwrap_or(void 0);const f=l[k.Note]?.at(0);i.note=f&&{value:Te(f.value).unwrap(),token:Q(f)},i.type=ve(l[k.Type]?.at(0)?.value).unwrap_or(void 0)}return u.flatMap(l=>{if(!(l instanceof Se))return l;const f=[];for(;l instanceof Se;)f.push(l.argumentList),l=l.callee;return f.push(l),f}).forEach(l=>{const{functional:f,nonFunctional:h}=ba(l).unwrap();i.columns.push(...f.map(m=>({value:m.value.value,type:"expression",token:Q(m)})),...h.map(m=>({value:ze(m).unwrap(),type:"column",token:Q(m)})))}),i})),[]}interpretChecks(e){return this.table.checks.push(...e.body.body.map(n=>{const i={},a=n;if(i.token=Q(a),a.args[0]instanceof Le){const u=ke(a.args[0]).getValue();i.name=Te(u[k.Name]?.at(0)?.value).unwrap_or(void 0)}return i.expression=a.callee.value.value,i})),[]}registerInlineRefToEnv(e,n,i,a){const u=rm(e.symbol,n);if(this.env.refIds[u])return[new v(N.CIRCULAR_REF,"References with same endpoints exist",a),new v(N.CIRCULAR_REF,"References with same endpoints exist",this.env.refIds[u])];const l=Bl(i.relation);return this.env.refIds[u]=a,this.env.ref.set(a,{name:null,schemaName:null,token:i.token,endpoints:[{...i,relation:l[1]},{schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[ve(e.callee).unwrap()],token:Q(e),relation:l[0]}]}),[]}}class OS{constructor(e,n){this.declarationNode=e,this.env=n,this.note={name:void 0,content:void 0,token:void 0}}interpret(){return this.note.token=Q(this.declarationNode),this.env.notes.set(this.declarationNode,this.note),[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)]}interpretName(e){const{name:n}=kr(e);return this.note.name=n,[]}interpretSettingList(e){const n=ke(e).getValue();return this.note.headerColor=n.headercolor?.length?cs(n.headercolor?.at(0)?.value):void 0,[]}interpretBody(e){const[n,i]=ht(e.body,a=>a instanceof z);return n.length!==1||i.length>0?[new v(N.INVALID_NOTE,"Invalid note syntax",e)]:[...this.interpretNote(n[0])]}interpretNote(e){const n=xp(e,"callee.expression.literal.value","");return this.note.content=an(n),[]}}class om{constructor(e,n){this.declarationNode=e,this.env=n,this.container=this.declarationNode.parent instanceof re?this.env.tables.get(this.declarationNode.parent):void 0,this.ref={}}interpret(){return this.ref.token=Q(this.declarationNode),this.env.ref.set(this.declarationNode,this.ref),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){const n=[],i=qe(this.declarationNode.name).unwrap_or([]);return this.ref.name=i.pop()||null,i.length>1&&n.push(new v(N.UNSUPPORTED,"Nested schema is not supported",this.declarationNode.name)),this.ref.schemaName=i.join(".")||null,n}interpretBody(e){return e instanceof z?this.interpretField(e):this.interpretField(e.body[0])}interpretField(e){const n=e.callee.op.value,{leftExpression:i,rightExpression:a}=e.callee,u=wa(i),l=wa(a);if($l(u,l))return[new v(N.SAME_ENDPOINT,"Two endpoints are the same",e)];const f=rm(u,l);if(this.env.refIds[f])return[new v(N.CIRCULAR_REF,"References with same endpoints exist",this.declarationNode),new v(N.CIRCULAR_REF,"References with same endpoints exist",this.env.refIds[f])];if(e.args[0]){const m=ke(e.args[0]).getValue(),E=m.delete?.at(0)?.value;this.ref.onDelete=E instanceof rn?rs(E).unwrap_or(void 0):ve(E).unwrap_or(void 0);const T=m.update?.at(0)?.value;this.ref.onUpdate=T instanceof rn?rs(T).unwrap_or(void 0):ve(T).unwrap_or(void 0),this.ref.color=m.color?.length?cs(m.color?.at(0)?.value):void 0}const h=Bl(n);return this.ref.endpoints=[{...Nd(i,this.container),relation:h[0],token:Q(i)},{...Nd(a,this.container),relation:h[1],token:Q(a)}],this.env.refIds[f]=this.declarationNode,[]}}class um{constructor(e,n){this.declarationNode=e,this.env=n,this.tableGroup={tables:[]}}interpret(){const e=[];return this.tableGroup.token=Q(this.declarationNode),this.env.tableGroups.set(this.declarationNode,this.tableGroup),e.push(...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)),e}interpretName(e){const n=[],{name:i,schemaName:a}=kr(e);return a.length>=2&&(this.tableGroup.name=i,this.tableGroup.schemaName=a.join("."),n.push(new v(N.UNSUPPORTED,"Nested schema is not supported",this.declarationNode.name))),this.tableGroup.name=i,this.tableGroup.schemaName=a[0]||null,n}interpretBody(e){const[n,i]=ht(e.body,a=>a instanceof z);return[...this.interpretFields(n),...this.interpretSubElements(i)]}interpretSubElements(e){return e.flatMap(n=>{switch(n.type?.value.toLowerCase()){case"note":this.tableGroup.note={value:Te(n.body instanceof Ge?n.body.body[0].callee:n.body.callee).map(an).unwrap(),token:Q(n)};break}return[]})}interpretFields(e){const n=[];return this.tableGroup.tables=e.map(i=>{const a=qe(i.callee).unwrap();a.length>2&&n.push(new v(N.UNSUPPORTED,"Nested schema is not supported",i));const u=vn(i.callee).unwrap().pop().referee.id;if(this.env.tableOwnerGroup[u]){const l=this.env.tableOwnerGroup[u],{schemaName:f,name:h}=this.env.tableGroups.get(l),m=f?`${f}.${h}`:h;n.push(new v(N.TABLE_REAPPEAR_IN_TABLEGROUP,`Table "${a.join(".")}" already appears in group "${m}"`,i))}else this.env.tableOwnerGroup[u]=this.declarationNode;return{name:a.pop(),schemaName:a.join(".")}}),n}interpretSettingList(e){const n=ke(e).getValue();this.tableGroup.color=n.color?.length?cs(n.color?.at(0)?.value):void 0;const[i]=n.note||[];return this.tableGroup.note=i&&{value:Te(i?.value).map(an).unwrap(),token:Q(i)},[]}}class lm{constructor(e,n){this.declarationNode=e,this.env=n,this.enum={values:[]}}interpret(){return this.enum.token=Q(this.declarationNode),this.env.enums.set(this.declarationNode,this.enum),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){const{name:n,schemaName:i}=kr(e);return i.length>1?(this.enum.name=n,this.enum.schemaName=i.join("."),[new v(N.UNSUPPORTED,"Nested schema is not supported",e)]):(this.enum.name=n,this.enum.schemaName=i.length?i[0]:null,[])}interpretBody(e){return e.body.flatMap(n=>{const i=n,a={};a.token=Q(i),a.name=ve(i.callee).unwrap();const l=ke(i.args[0]).getValue().note?.at(0);return a.note=l&&{value:Te(l.value).map(an).unwrap(),token:Q(l)},this.enum.values.push(a),[]})}}class cm{constructor(e,n){this.declarationNode=e,this.env=n,this.tablePartial={name:void 0,fields:[],token:void 0,indexes:[],checks:[]},this.pkColumns=[]}interpret(){this.tablePartial.token=Q(this.declarationNode),this.env.tablePartials.set(this.declarationNode,this.tablePartial);const e=[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.tablePartial.indexes.push({columns:this.pkColumns.map(({name:n,token:i})=>({value:n,type:"column",token:i})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(n=>{n.pk=!1})),e}interpretName(e){const{name:n}=kr(e);return this.tablePartial.name=n,[]}interpretSettingList(e){const n=ke(e).getValue(),i=dL(n[k.HeaderColor]);this.tablePartial.headerColor=i?cs(i.value):void 0;const[a]=n[k.Note]||[];return this.tablePartial.note=a&&{value:Te(a?.value).map(an).unwrap(),token:Q(a)},[]}interpretBody(e){const[n,i]=ht(e.body,a=>a instanceof z);return[...this.interpretFields(n),...this.interpretSubElements(i)]}interpretSubElements(e){return e.flatMap(n=>{switch(n.type?.value.toLowerCase()){case U.Note:return this.tablePartial.note={value:Te(n.body instanceof Ge?n.body.body[0].callee:n.body.callee).map(an).unwrap(),token:Q(n)},[];case U.Indexes:return this.interpretIndexes(n);case U.Check:return this.interpretChecks(n);default:return[]}})}interpretFields(e){return e.flatMap(n=>this.interpretColumn(n))}interpretColumn(e){const n=[],i={};i.name=ze(e.callee).unwrap();const a=sm(e.args[0],this.env);i.type=a.getValue(),n.push(...a.getErrors()),i.token=Q(e),i.inline_refs=[];const u=e.args.slice(1);if(Oe(u)instanceof Le){const l=ke(u.pop()).getValue();i.pk=!!l[k.PK]?.length||!!l[k.PrimaryKey]?.length,i.increment=!!l[k.Increment]?.length,i.unique=!!l[k.Unique]?.length,i.not_null=l[k.NotNull]?.length?!0:l[k.Null]?.length?!1:void 0,i.dbdefault=im(l[k.Default]?.at(0)?.value);const f=l[k.Note]?.at(0);i.note=f&&{value:Te(f.value).map(an).unwrap(),token:Q(f)};const h=l[k.Ref]||[];i.inline_refs=h.flatMap(E=>{const[T]=wa(E.value.expression);if($l(T,e.symbol))return n.push(new v(N.SAME_ENDPOINT,"Two endpoints are the same",E)),[];const A=E.value.op,O=qe(E.value.expression).unwrap();let F;if(O.length===2){const[G,H]=O;F={schemaName:null,tableName:G,fieldNames:[H],relation:A.value,token:Q(E)}}else if(O.length===3){const[G,H,le]=O;F={schemaName:G,tableName:H,fieldNames:[le],relation:A.value,token:Q(E)}}else{n.push(new v(N.UNSUPPORTED,"Unsupported",E));const G=O.pop(),H=O.pop();F={schemaName:O.join("."),tableName:H,fieldNames:[G],relation:A.value,token:Q(E)}}return F});const m=l[k.Check]||[];i.checks=m.map(E=>{const T=Q(E),A=E.value.value.value;return{token:T,expression:A}})}return i.pk||=u.some(l=>ve(l).unwrap().toLowerCase()==="pk"),i.unique||=u.some(l=>ve(l).unwrap().toLowerCase()==="unique"),this.tablePartial.fields.push(i),i.pk&&this.pkColumns.push(i),n}interpretIndexes(e){return this.tablePartial.indexes.push(...e.body.body.map(n=>{const i={columns:[]},a=n;i.token=Q(a);const u=[a.callee,...a.args];if(Oe(u)instanceof Le){const l=ke(u.pop()).getValue();i.pk=!!l[k.PK]?.length,i.unique=!!l[k.Unique]?.length,i.name=Te(l[k.Name]?.at(0)?.value).unwrap_or(void 0);const f=l[k.Note]?.at(0);i.note=f&&{value:Te(f.value).unwrap(),token:Q(f)},i.type=ve(l[k.Type]?.at(0)?.value).unwrap_or(void 0)}return u.flatMap(l=>{if(!(l instanceof Se))return l;const f=[];let h=l;for(;h instanceof Se;)f.push(h.argumentList),h=h.callee;return f.push(h),f}).forEach(l=>{const{functional:f,nonFunctional:h}=ba(l).unwrap();i.columns.push(...f.map(m=>({value:m.value.value,type:"expression",token:Q(m)})),...h.map(m=>({value:ze(m).unwrap(),type:"column",token:Q(m)})))}),i})),[]}interpretChecks(e){return this.tablePartial.checks.push(...e.body.body.map(n=>{const i={},a=n;if(i.token=Q(a),a.args[0]instanceof Le){const u=ke(a.args[0]).getValue();i.name=Te(u[k.Name]?.at(0)?.value).unwrap_or(void 0)}return i.expression=a.callee.value.value,i})),[]}}class xS{constructor(e,n){this.declarationNode=e,this.env=n,this.project={enums:[],refs:[],tableGroups:[],tables:[],tablePartials:[]}}interpret(){return this.env.project.set(this.declarationNode,this.project),this.project.token=Q(this.declarationNode),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){if(!e)return this.project.name=null,[];const{name:n}=kr(e);return this.project.name=n,[]}interpretBody(e){return e.body.flatMap(n=>{const i=n;switch(i.type?.value.toLowerCase()){case"table":{const a=new am(i,this.env).interpret();return this.project.tables.push(this.env.tables.get(i)),a}case"ref":{const a=new om(i,this.env).interpret();return this.project.refs.push(this.env.ref.get(i)),a}case"tablegroup":{const a=new um(i,this.env).interpret();return this.project.tableGroups.push(this.env.tableGroups.get(i)),a}case"enum":{const a=new lm(i,this.env).interpret();return this.project.enums.push(this.env.enums.get(i)),a}case"note":return this.project.note={value:Te(i.body instanceof Ge?i.body.body[0].callee:i.body.callee).map(an).unwrap(),token:Q(i)},[];case"tablepartial":{const a=new cm(i,this.env).interpret();return this.project.tablePartials.push(this.env.tablePartials.get(i)),a}default:return this.project[i.type.value.toLowerCase()]=Te(i.body.callee).unwrap(),[]}})}}const yd={mysql:new Set(["int","integer","smallint","bigint","tinyint","mediumint"]),postgres:new Set(["int","integer","smallint","bigint","serial","bigserial","smallserial"]),mssql:new Set(["int","integer","smallint","bigint","tinyint"]),oracle:new Set(["int","integer","smallint"]),snowflake:new Set(["int","integer","smallint","bigint","tinyint"])},vd={mysql:new Set(["decimal","numeric","float","double","real"]),postgres:new Set(["decimal","numeric","real","float","double precision"]),mssql:new Set(["decimal","numeric","real","float"]),oracle:new Set(["number","decimal","numeric","float","real"]),snowflake:new Set(["number","decimal","numeric","float","double","real"])},_d={mysql:new Set(["bool","boolean","bit"]),postgres:new Set(["bool","boolean"]),mssql:new Set(["bit"]),oracle:new Set([]),snowflake:new Set(["boolean"])},bd={mysql:new Set(["varchar","char","text","tinytext","mediumtext","longtext","string"]),postgres:new Set(["varchar","char","character","character varying","text","string"]),mssql:new Set(["varchar","char","nvarchar","nchar","text","ntext","string"]),oracle:new Set(["varchar","varchar2","char","nvarchar2","nchar","string"]),snowflake:new Set(["varchar","char","text","string"])},wd={mysql:new Set(["binary","varbinary","blob","tinyblob","mediumblob","longblob"]),postgres:new Set(["bytea"]),mssql:new Set(["binary","varbinary"]),oracle:new Set(["blob","raw"]),snowflake:new Set(["binary","varbinary"])},Id={mysql:new Set(["date","datetime","timestamp","time"]),postgres:new Set(["date","timestamp","timestamptz","timestamp with time zone","timestamp without time zone","time","timetz","time with time zone","time without time zone"]),mssql:new Set(["date","datetime","datetime2","smalldatetime","time"]),oracle:new Set(["date","timestamp","timestamp with time zone","timestamp with local time zone"]),snowflake:new Set(["date","datetime","timestamp","time"])},Ad={mysql:new Set([]),postgres:new Set(["serial","smallserial","bigserial"]),mssql:new Set([]),oracle:new Set([]),snowflake:new Set([])};function Hn(t){return t.toLowerCase().trim().replace(/\s+/g," ")}function qa(t,e){const n=Hn(t);return e?yd[e].has(n):Object.values(yd).some(i=>i.has(n))}function Xa(t,e){const n=Hn(t);return e?vd[e].has(n):Object.values(vd).some(i=>i.has(n))}function Gl(t,e){return qa(t,e)||Xa(t,e)}function Ya(t,e){const n=Hn(t);return e?_d[e].has(n):Object.values(_d).some(i=>i.has(n))}function Ia(t,e){const n=Hn(t);return e?bd[e].has(n):Object.values(bd).some(i=>i.has(n))}function DS(t,e){const n=Hn(t);return e?wd[e].has(n):Object.values(wd).some(i=>i.has(n))}function Za(t,e){const n=Hn(t);return e?Id[e].has(n):Object.values(Id).some(i=>i.has(n))}function Ka(t,e){const n=Hn(t);return e?Ad[e].has(n):Object.values(Ad).some(i=>i.has(n))}function fm(t){const e=t.declaration;return e instanceof z&&e.args[0]||null}function RS(t){const e=fm(t);if(!(e instanceof Se))return{};if(!e.argumentList||e.argumentList.elementList.length!==2)return{};const n=Or(e.argumentList.elementList[0]),i=Or(e.argumentList.elementList[1]);return n===null||i===null?{}:{precision:Math.trunc(n),scale:Math.trunc(i)}}function kS(t){const e=fm(t);if(!(e instanceof Se))return{};if(!e.argumentList||e.argumentList.elementList.length!==1)return{};const n=Or(e.argumentList.elementList[0]);return n===null?{}:{length:Math.trunc(n)}}function hm(t,e){if(e)return"string";if(qa(t))return"integer";if(Xa(t))return"real";if(Ya(t))return"bool";if(Ia(t))return"string";const n=Hn(t);return n==="date"?"date":n==="time"||n==="timetz"||n==="time with time zone"||n==="time without time zone"?"time":Za(t)?"datetime":t}class Mr extends Error{}class MS extends Mr{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class PS extends Mr{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class CS extends Mr{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class ei extends Mr{}class dm extends Mr{constructor(e){super(`Invalid unit ${e}`)}}class rt extends Mr{}class nr extends Mr{constructor(){super("Zone is an abstract class")}}const C="numeric",un="short",xt="long",Aa={year:C,month:C,day:C},pm={year:C,month:un,day:C},FS={year:C,month:un,day:C,weekday:un},mm={year:C,month:xt,day:C},gm={year:C,month:xt,day:C,weekday:xt},Em={hour:C,minute:C},Tm={hour:C,minute:C,second:C},Nm={hour:C,minute:C,second:C,timeZoneName:un},ym={hour:C,minute:C,second:C,timeZoneName:xt},vm={hour:C,minute:C,hourCycle:"h23"},_m={hour:C,minute:C,second:C,hourCycle:"h23"},bm={hour:C,minute:C,second:C,hourCycle:"h23",timeZoneName:un},wm={hour:C,minute:C,second:C,hourCycle:"h23",timeZoneName:xt},Im={year:C,month:C,day:C,hour:C,minute:C},Am={year:C,month:C,day:C,hour:C,minute:C,second:C},Lm={year:C,month:un,day:C,hour:C,minute:C},Sm={year:C,month:un,day:C,hour:C,minute:C,second:C},US={year:C,month:un,day:C,weekday:un,hour:C,minute:C},Om={year:C,month:xt,day:C,hour:C,minute:C,timeZoneName:un},xm={year:C,month:xt,day:C,hour:C,minute:C,second:C,timeZoneName:un},Dm={year:C,month:xt,day:C,weekday:xt,hour:C,minute:C,timeZoneName:xt},Rm={year:C,month:xt,day:C,weekday:xt,hour:C,minute:C,second:C,timeZoneName:xt};class fs{get type(){throw new nr}get name(){throw new nr}get ianaName(){return this.name}get isUniversal(){throw new nr}offsetName(e,n){throw new nr}formatOffset(e,n){throw new nr}offset(e){throw new nr}equals(e){throw new nr}get isValid(){throw new nr}}let Ru=null;class Ja extends fs{static get instance(){return Ru===null&&(Ru=new Ja),Ru}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:n,locale:i}){return Wm(e,n,i)}formatOffset(e,n){return Ki(this.offset(e),n)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}const ju=new Map;function VS(t){let e=ju.get(t);return e===void 0&&(e=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),ju.set(t,e)),e}const BS={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function $S(t,e){const n=t.format(e).replace(/\u200E/g,""),i=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n),[,a,u,l,f,h,m,E]=i;return[l,a,u,f,h,m,E]}function GS(t,e){const n=t.formatToParts(e),i=[];for(let a=0;a<n.length;a++){const{type:u,value:l}=n[a],f=BS[u];u==="era"?i[f]=l:K(f)||(i[f]=parseInt(l,10))}return i}const ku=new Map;class Vn extends fs{static create(e){let n=ku.get(e);return n===void 0&&ku.set(e,n=new Vn(e)),n}static resetCache(){ku.clear(),ju.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=Vn.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:n,locale:i}){return Wm(e,n,i,this.name)}formatOffset(e,n){return Ki(this.offset(e),n)}offset(e){if(!this.valid)return NaN;const n=new Date(e);if(isNaN(n))return NaN;const i=VS(this.name);let[a,u,l,f,h,m,E]=i.formatToParts?GS(i,n):$S(i,n);f==="BC"&&(a=-Math.abs(a)+1);const A=Qa({year:a,month:u,day:l,hour:h===24?0:h,minute:m,second:E,millisecond:0});let O=+n;const F=O%1e3;return O-=F>=0?F:1e3+F,(A-O)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let Ld={};function WS(t,e={}){const n=JSON.stringify([t,e]);let i=Ld[n];return i||(i=new Intl.ListFormat(t,e),Ld[n]=i),i}const Qu=new Map;function el(t,e={}){const n=JSON.stringify([t,e]);let i=Qu.get(n);return i===void 0&&(i=new Intl.DateTimeFormat(t,e),Qu.set(n,i)),i}const tl=new Map;function HS(t,e={}){const n=JSON.stringify([t,e]);let i=tl.get(n);return i===void 0&&(i=new Intl.NumberFormat(t,e),tl.set(n,i)),i}const nl=new Map;function zS(t,e={}){const{base:n,...i}=e,a=JSON.stringify([t,i]);let u=nl.get(a);return u===void 0&&(u=new Intl.RelativeTimeFormat(t,e),nl.set(a,u)),u}let qi=null;function qS(){return qi||(qi=new Intl.DateTimeFormat().resolvedOptions().locale,qi)}const rl=new Map;function km(t){let e=rl.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),rl.set(t,e)),e}const il=new Map;function XS(t){let e=il.get(t);if(!e){const n=new Intl.Locale(t);e="getWeekInfo"in n?n.getWeekInfo():n.weekInfo,"minimalDays"in e||(e={...Mm,...e}),il.set(t,e)}return e}function YS(t){const e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));const n=t.indexOf("-u-");if(n===-1)return[t];{let i,a;try{i=el(t).resolvedOptions(),a=t}catch{const h=t.substring(0,n);i=el(h).resolvedOptions(),a=h}const{numberingSystem:u,calendar:l}=i;return[a,u,l]}}function ZS(t,e,n){return(n||e)&&(t.includes("-u-")||(t+="-u"),n&&(t+=`-ca-${n}`),e&&(t+=`-nu-${e}`)),t}function KS(t){const e=[];for(let n=1;n<=12;n++){const i=Z.utc(2009,n,1);e.push(t(i))}return e}function JS(t){const e=[];for(let n=1;n<=7;n++){const i=Z.utc(2016,11,13+n);e.push(t(i))}return e}function fa(t,e,n,i){const a=t.listingMode();return a==="error"?null:a==="en"?n(e):i(e)}function jS(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||km(t.locale).numberingSystem==="latn"}class QS{constructor(e,n,i){this.padTo=i.padTo||0,this.floor=i.floor||!1;const{padTo:a,floor:u,...l}=i;if(!n||Object.keys(l).length>0){const f={useGrouping:!1,...i};i.padTo>0&&(f.minimumIntegerDigits=i.padTo),this.inf=HS(e,f)}}format(e){if(this.inf){const n=this.floor?Math.floor(e):e;return this.inf.format(n)}else{const n=this.floor?Math.floor(e):Xl(e,3);return $e(n,this.padTo)}}}class e1{constructor(e,n,i){this.opts=i,this.originalZone=void 0;let a;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){const l=-1*(e.offset/60),f=l>=0?`Etc/GMT+${l}`:`Etc/GMT${l}`;e.offset!==0&&Vn.create(f).valid?(a=f,this.dt=e):(a="UTC",this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type==="system"?this.dt=e:e.zone.type==="iana"?(this.dt=e,a=e.zone.name):(a="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);const u={...this.opts};u.timeZone=u.timeZone||a,this.dtf=el(n,u)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(n=>{if(n.type==="timeZoneName"){const i=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...n,value:i}}else return n}):e}resolvedOptions(){return this.dtf.resolvedOptions()}}class t1{constructor(e,n,i){this.opts={style:"long",...i},!n&&$m()&&(this.rtf=zS(e,i))}format(e,n){return this.rtf?this.rtf.format(e,n):b1(n,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,n){return this.rtf?this.rtf.formatToParts(e,n):[]}}const Mm={firstDay:1,minimalDays:4,weekend:[6,7]};class me{static fromOpts(e){return me.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,n,i,a,u=!1){const l=e||Fe.defaultLocale,f=l||(u?"en-US":qS()),h=n||Fe.defaultNumberingSystem,m=i||Fe.defaultOutputCalendar,E=al(a)||Fe.defaultWeekSettings;return new me(f,h,m,E,l)}static resetCache(){qi=null,Qu.clear(),tl.clear(),nl.clear(),rl.clear(),il.clear()}static fromObject({locale:e,numberingSystem:n,outputCalendar:i,weekSettings:a}={}){return me.create(e,n,i,a)}constructor(e,n,i,a,u){const[l,f,h]=YS(e);this.locale=l,this.numberingSystem=n||f||null,this.outputCalendar=i||h||null,this.weekSettings=a,this.intl=ZS(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=u,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=jS(this)),this.fastNumbersCached}listingMode(){const e=this.isEnglish(),n=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&n?"en":"intl"}clone(e){return!e||Object.getOwnPropertyNames(e).length===0?this:me.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,al(e.weekSettings)||this.weekSettings,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,n=!1){return fa(this,e,qm,()=>{const i=this.intl==="ja"||this.intl.startsWith("ja-");n&=!i;const a=n?{month:e,day:"numeric"}:{month:e},u=n?"format":"standalone";if(!this.monthsCache[u][e]){const l=i?f=>this.dtFormatter(f,a).format():f=>this.extract(f,a,"month");this.monthsCache[u][e]=KS(l)}return this.monthsCache[u][e]})}weekdays(e,n=!1){return fa(this,e,Zm,()=>{const i=n?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},a=n?"format":"standalone";return this.weekdaysCache[a][e]||(this.weekdaysCache[a][e]=JS(u=>this.extract(u,i,"weekday"))),this.weekdaysCache[a][e]})}meridiems(){return fa(this,void 0,()=>Km,()=>{if(!this.meridiemCache){const e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[Z.utc(2016,11,13,9),Z.utc(2016,11,13,19)].map(n=>this.extract(n,e,"dayperiod"))}return this.meridiemCache})}eras(e){return fa(this,e,Jm,()=>{const n={era:e};return this.eraCache[e]||(this.eraCache[e]=[Z.utc(-40,1,1),Z.utc(2017,1,1)].map(i=>this.extract(i,n,"era"))),this.eraCache[e]})}extract(e,n,i){const a=this.dtFormatter(e,n),u=a.formatToParts(),l=u.find(f=>f.type.toLowerCase()===i);return l?l.value:null}numberFormatter(e={}){return new QS(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,n={}){return new e1(e,this.intl,n)}relFormatter(e={}){return new t1(this.intl,this.isEnglish(),e)}listFormatter(e={}){return WS(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||km(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Gm()?XS(this.locale):Mm}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let Mu=null;class ct extends fs{static get utcInstance(){return Mu===null&&(Mu=new ct(0)),Mu}static instance(e){return e===0?ct.utcInstance:new ct(e)}static parseSpecifier(e){if(e){const n=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(n)return new ct(eo(n[1],n[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Ki(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Ki(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,n){return Ki(this.fixed,n)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return!0}}class n1 extends fs{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function ir(t,e){if(K(t)||t===null)return e;if(t instanceof fs)return t;if(u1(t)){const n=t.toLowerCase();return n==="default"?e:n==="local"||n==="system"?Ja.instance:n==="utc"||n==="gmt"?ct.utcInstance:ct.parseSpecifier(n)||Vn.create(t)}else return ar(t)?ct.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new n1(t)}const Wl={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},Sd={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},r1=Wl.hanidec.replace(/[\[|\]]/g,"").split("");function i1(t){let e=parseInt(t,10);if(isNaN(e)){e="";for(let n=0;n<t.length;n++){const i=t.charCodeAt(n);if(t[n].search(Wl.hanidec)!==-1)e+=r1.indexOf(t[n]);else for(const a in Sd){const[u,l]=Sd[a];i>=u&&i<=l&&(e+=i-u)}}return parseInt(e,10)}else return e}const sl=new Map;function s1(){sl.clear()}function jt({numberingSystem:t},e=""){const n=t||"latn";let i=sl.get(n);i===void 0&&(i=new Map,sl.set(n,i));let a=i.get(e);return a===void 0&&(a=new RegExp(`${Wl[n]}${e}`),i.set(e,a)),a}let Od=()=>Date.now(),xd="system",Dd=null,Rd=null,kd=null,Md=60,Pd,Cd=null;class Fe{static get now(){return Od}static set now(e){Od=e}static set defaultZone(e){xd=e}static get defaultZone(){return ir(xd,Ja.instance)}static get defaultLocale(){return Dd}static set defaultLocale(e){Dd=e}static get defaultNumberingSystem(){return Rd}static set defaultNumberingSystem(e){Rd=e}static get defaultOutputCalendar(){return kd}static set defaultOutputCalendar(e){kd=e}static get defaultWeekSettings(){return Cd}static set defaultWeekSettings(e){Cd=al(e)}static get twoDigitCutoffYear(){return Md}static set twoDigitCutoffYear(e){Md=e%100}static get throwOnInvalid(){return Pd}static set throwOnInvalid(e){Pd=e}static resetCaches(){me.resetCache(),Vn.resetCache(),Z.resetCache(),s1()}}class nn{constructor(e,n){this.reason=e,this.explanation=n}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const Pm=[0,31,59,90,120,151,181,212,243,273,304,334],Cm=[0,31,60,91,121,152,182,213,244,274,305,335];function $t(t,e){return new nn("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function Hl(t,e,n){const i=new Date(Date.UTC(t,e-1,n));t<100&&t>=0&&i.setUTCFullYear(i.getUTCFullYear()-1900);const a=i.getUTCDay();return a===0?7:a}function Fm(t,e,n){return n+(hs(t)?Cm:Pm)[e-1]}function Um(t,e){const n=hs(t)?Cm:Pm,i=n.findIndex(u=>u<e),a=e-n[i];return{month:i+1,day:a}}function zl(t,e){return(t-e+7)%7+1}function La(t,e=4,n=1){const{year:i,month:a,day:u}=t,l=Fm(i,a,u),f=zl(Hl(i,a,u),n);let h=Math.floor((l-f+14-e)/7),m;return h<1?(m=i-1,h=ss(m,e,n)):h>ss(i,e,n)?(m=i+1,h=1):m=i,{weekYear:m,weekNumber:h,weekday:f,...to(t)}}function Fd(t,e=4,n=1){const{weekYear:i,weekNumber:a,weekday:u}=t,l=zl(Hl(i,1,e),n),f=ri(i);let h=a*7+u-l-7+e,m;h<1?(m=i-1,h+=ri(m)):h>f?(m=i+1,h-=ri(i)):m=i;const{month:E,day:T}=Um(m,h);return{year:m,month:E,day:T,...to(t)}}function Pu(t){const{year:e,month:n,day:i}=t,a=Fm(e,n,i);return{year:e,ordinal:a,...to(t)}}function Ud(t){const{year:e,ordinal:n}=t,{month:i,day:a}=Um(e,n);return{year:e,month:i,day:a,...to(t)}}function Vd(t,e){if(!K(t.localWeekday)||!K(t.localWeekNumber)||!K(t.localWeekYear)){if(!K(t.weekday)||!K(t.weekNumber)||!K(t.weekYear))throw new ei("Cannot mix locale-based week fields with ISO-based week fields");return K(t.localWeekday)||(t.weekday=t.localWeekday),K(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),K(t.localWeekYear)||(t.weekYear=t.localWeekYear),delete t.localWeekday,delete t.localWeekNumber,delete t.localWeekYear,{minDaysInFirstWeek:e.getMinDaysInFirstWeek(),startOfWeek:e.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function a1(t,e=4,n=1){const i=ja(t.weekYear),a=Gt(t.weekNumber,1,ss(t.weekYear,e,n)),u=Gt(t.weekday,1,7);return i?a?u?!1:$t("weekday",t.weekday):$t("week",t.weekNumber):$t("weekYear",t.weekYear)}function o1(t){const e=ja(t.year),n=Gt(t.ordinal,1,ri(t.year));return e?n?!1:$t("ordinal",t.ordinal):$t("year",t.year)}function Vm(t){const e=ja(t.year),n=Gt(t.month,1,12),i=Gt(t.day,1,Sa(t.year,t.month));return e?n?i?!1:$t("day",t.day):$t("month",t.month):$t("year",t.year)}function Bm(t){const{hour:e,minute:n,second:i,millisecond:a}=t,u=Gt(e,0,23)||e===24&&n===0&&i===0&&a===0,l=Gt(n,0,59),f=Gt(i,0,59),h=Gt(a,0,999);return u?l?f?h?!1:$t("millisecond",a):$t("second",i):$t("minute",n):$t("hour",e)}function K(t){return typeof t>"u"}function ar(t){return typeof t=="number"}function ja(t){return typeof t=="number"&&t%1===0}function u1(t){return typeof t=="string"}function l1(t){return Object.prototype.toString.call(t)==="[object Date]"}function $m(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Gm(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function c1(t){return Array.isArray(t)?t:[t]}function Bd(t,e,n){if(t.length!==0)return t.reduce((i,a)=>{const u=[e(a),a];return i&&n(i[0],u[0])===i[0]?i:u},null)[1]}function f1(t,e){return e.reduce((n,i)=>(n[i]=t[i],n),{})}function li(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function al(t){if(t==null)return null;if(typeof t!="object")throw new rt("Week settings must be an object");if(!Gt(t.firstDay,1,7)||!Gt(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!Gt(e,1,7)))throw new rt("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function Gt(t,e,n){return ja(t)&&t>=e&&t<=n}function h1(t,e){return t-e*Math.floor(t/e)}function $e(t,e=2){const n=t<0;let i;return n?i="-"+(""+-t).padStart(e,"0"):i=(""+t).padStart(e,"0"),i}function rr(t){if(!(K(t)||t===null||t===""))return parseInt(t,10)}function vr(t){if(!(K(t)||t===null||t===""))return parseFloat(t)}function ql(t){if(!(K(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function Xl(t,e,n="round"){const i=10**e;switch(n){case"expand":return t>0?Math.ceil(t*i)/i:Math.floor(t*i)/i;case"trunc":return Math.trunc(t*i)/i;case"round":return Math.round(t*i)/i;case"floor":return Math.floor(t*i)/i;case"ceil":return Math.ceil(t*i)/i;default:throw new RangeError(`Value rounding ${n} is out of range`)}}function hs(t){return t%4===0&&(t%100!==0||t%400===0)}function ri(t){return hs(t)?366:365}function Sa(t,e){const n=h1(e-1,12)+1,i=t+(e-n)/12;return n===2?hs(i)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function Qa(t){let e=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond);return t.year<100&&t.year>=0&&(e=new Date(e),e.setUTCFullYear(t.year,t.month-1,t.day)),+e}function $d(t,e,n){return-zl(Hl(t,1,e),n)+e-1}function ss(t,e=4,n=1){const i=$d(t,e,n),a=$d(t+1,e,n);return(ri(t)-i+a)/7}function ol(t){return t>99?t:t>Fe.twoDigitCutoffYear?1900+t:2e3+t}function Wm(t,e,n,i=null){const a=new Date(t),u={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};i&&(u.timeZone=i);const l={timeZoneName:e,...u},f=new Intl.DateTimeFormat(n,l).formatToParts(a).find(h=>h.type.toLowerCase()==="timezonename");return f?f.value:null}function eo(t,e){let n=parseInt(t,10);Number.isNaN(n)&&(n=0);const i=parseInt(e,10)||0,a=n<0||Object.is(n,-0)?-i:i;return n*60+a}function Hm(t){const e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new rt(`Invalid unit value ${t}`);return e}function Oa(t,e){const n={};for(const i in t)if(li(t,i)){const a=t[i];if(a==null)continue;n[e(i)]=Hm(a)}return n}function Ki(t,e){const n=Math.trunc(Math.abs(t/60)),i=Math.trunc(Math.abs(t%60)),a=t>=0?"+":"-";switch(e){case"short":return`${a}${$e(n,2)}:${$e(i,2)}`;case"narrow":return`${a}${n}${i>0?`:${i}`:""}`;case"techie":return`${a}${$e(n,2)}${$e(i,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function to(t){return f1(t,["hour","minute","second","millisecond"])}const d1=["January","February","March","April","May","June","July","August","September","October","November","December"],zm=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],p1=["J","F","M","A","M","J","J","A","S","O","N","D"];function qm(t){switch(t){case"narrow":return[...p1];case"short":return[...zm];case"long":return[...d1];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const Xm=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Ym=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],m1=["M","T","W","T","F","S","S"];function Zm(t){switch(t){case"narrow":return[...m1];case"short":return[...Ym];case"long":return[...Xm];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Km=["AM","PM"],g1=["Before Christ","Anno Domini"],E1=["BC","AD"],T1=["B","A"];function Jm(t){switch(t){case"narrow":return[...T1];case"short":return[...E1];case"long":return[...g1];default:return null}}function N1(t){return Km[t.hour<12?0:1]}function y1(t,e){return Zm(e)[t.weekday-1]}function v1(t,e){return qm(e)[t.month-1]}function _1(t,e){return Jm(e)[t.year<0?0:1]}function b1(t,e,n="always",i=!1){const a={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},u=["hours","minutes","seconds"].indexOf(t)===-1;if(n==="auto"&&u){const T=t==="days";switch(e){case 1:return T?"tomorrow":`next ${a[t][0]}`;case-1:return T?"yesterday":`last ${a[t][0]}`;case 0:return T?"today":`this ${a[t][0]}`}}const l=Object.is(e,-0)||e<0,f=Math.abs(e),h=f===1,m=a[t],E=i?h?m[1]:m[2]||m[1]:h?a[t][0]:t;return l?`${f} ${E} ago`:`in ${f} ${E}`}function Gd(t,e){let n="";for(const i of t)i.literal?n+=i.val:n+=e(i.val);return n}const w1={D:Aa,DD:pm,DDD:mm,DDDD:gm,t:Em,tt:Tm,ttt:Nm,tttt:ym,T:vm,TT:_m,TTT:bm,TTTT:wm,f:Im,ff:Lm,fff:Om,ffff:Dm,F:Am,FF:Sm,FFF:xm,FFFF:Rm};class it{static create(e,n={}){return new it(e,n)}static parseFormat(e){let n=null,i="",a=!1;const u=[];for(let l=0;l<e.length;l++){const f=e.charAt(l);f==="'"?((i.length>0||a)&&u.push({literal:a||/^\s+$/.test(i),val:i===""?"'":i}),n=null,i="",a=!a):a||f===n?i+=f:(i.length>0&&u.push({literal:/^\s+$/.test(i),val:i}),i=f,n=f)}return i.length>0&&u.push({literal:a||/^\s+$/.test(i),val:i}),u}static macroTokenToFormatOpts(e){return w1[e]}constructor(e,n){this.opts=n,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,n){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...n}).format()}dtFormatter(e,n={}){return this.loc.dtFormatter(e,{...this.opts,...n})}formatDateTime(e,n){return this.dtFormatter(e,n).format()}formatDateTimeParts(e,n){return this.dtFormatter(e,n).formatToParts()}formatInterval(e,n){return this.dtFormatter(e.start,n).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,n){return this.dtFormatter(e,n).resolvedOptions()}num(e,n=0,i=void 0){if(this.opts.forceSimple)return $e(e,n);const a={...this.opts};return n>0&&(a.padTo=n),i&&(a.signDisplay=i),this.loc.numberFormatter(a).format(e)}formatDateTimeFromString(e,n){const i=this.loc.listingMode()==="en",a=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",u=(O,F)=>this.loc.extract(e,O,F),l=O=>e.isOffsetFixed&&e.offset===0&&O.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,O.format):"",f=()=>i?N1(e):u({hour:"numeric",hourCycle:"h12"},"dayperiod"),h=(O,F)=>i?v1(e,O):u(F?{month:O}:{month:O,day:"numeric"},"month"),m=(O,F)=>i?y1(e,O):u(F?{weekday:O}:{weekday:O,month:"long",day:"numeric"},"weekday"),E=O=>{const F=it.macroTokenToFormatOpts(O);return F?this.formatWithSystemDefault(e,F):O},T=O=>i?_1(e,O):u({era:O},"era"),A=O=>{switch(O){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12===0?12:e.hour%12);case"hh":return this.num(e.hour%12===0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return l({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return l({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return l({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return f();case"d":return a?u({day:"numeric"},"day"):this.num(e.day);case"dd":return a?u({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return m("short",!0);case"cccc":return m("long",!0);case"ccccc":return m("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return m("short",!1);case"EEEE":return m("long",!1);case"EEEEE":return m("narrow",!1);case"L":return a?u({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return a?u({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return h("short",!0);case"LLLL":return h("long",!0);case"LLLLL":return h("narrow",!0);case"M":return a?u({month:"numeric"},"month"):this.num(e.month);case"MM":return a?u({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return h("short",!1);case"MMMM":return h("long",!1);case"MMMMM":return h("narrow",!1);case"y":return a?u({year:"numeric"},"year"):this.num(e.year);case"yy":return a?u({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return a?u({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return a?u({year:"numeric"},"year"):this.num(e.year,6);case"G":return T("short");case"GG":return T("long");case"GGGGG":return T("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return E(O)}};return Gd(it.parseFormat(n),A)}formatDurationFromString(e,n){const i=this.opts.signMode==="negativeLargestOnly"?-1:1,a=E=>{switch(E[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},u=(E,T)=>A=>{const O=a(A);if(O){const F=T.isNegativeDuration&&O!==T.largestUnit?i:1;let G;return this.opts.signMode==="negativeLargestOnly"&&O!==T.largestUnit?G="never":this.opts.signMode==="all"?G="always":G="auto",this.num(E.get(O)*F,A.length,G)}else return A},l=it.parseFormat(n),f=l.reduce((E,{literal:T,val:A})=>T?E:E.concat(A),[]),h=e.shiftTo(...f.map(a).filter(E=>E)),m={isNegativeDuration:h<0,largestUnit:Object.keys(h.values)[0]};return Gd(l,u(h,m))}}const jm=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Ei(...t){const e=t.reduce((n,i)=>n+i.source,"");return RegExp(`^${e}$`)}function Ti(...t){return e=>t.reduce(([n,i,a],u)=>{const[l,f,h]=u(e,a);return[{...n,...l},f||i,h]},[{},null,1]).slice(0,2)}function Ni(t,...e){if(t==null)return[null,null];for(const[n,i]of e){const a=n.exec(t);if(a)return i(a)}return[null,null]}function Qm(...t){return(e,n)=>{const i={};let a;for(a=0;a<t.length;a++)i[t[a]]=rr(e[n+a]);return[i,null,n+a]}}const eg=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,I1=`(?:${eg.source}?(?:\\[(${jm.source})\\])?)?`,Yl=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,tg=RegExp(`${Yl.source}${I1}`),Zl=RegExp(`(?:[Tt]${tg.source})?`),A1=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,L1=/(\d{4})-?W(\d\d)(?:-?(\d))?/,S1=/(\d{4})-?(\d{3})/,O1=Qm("weekYear","weekNumber","weekDay"),x1=Qm("year","ordinal"),D1=/(\d{4})-(\d\d)-(\d\d)/,ng=RegExp(`${Yl.source} ?(?:${eg.source}|(${jm.source}))?`),R1=RegExp(`(?: ${ng.source})?`);function ii(t,e,n){const i=t[e];return K(i)?n:rr(i)}function k1(t,e){return[{year:ii(t,e),month:ii(t,e+1,1),day:ii(t,e+2,1)},null,e+3]}function yi(t,e){return[{hours:ii(t,e,0),minutes:ii(t,e+1,0),seconds:ii(t,e+2,0),milliseconds:ql(t[e+3])},null,e+4]}function ds(t,e){const n=!t[e]&&!t[e+1],i=eo(t[e+1],t[e+2]),a=n?null:ct.instance(i);return[{},a,e+3]}function ps(t,e){const n=t[e]?Vn.create(t[e]):null;return[{},n,e+1]}const M1=RegExp(`^T?${Yl.source}$`),P1=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function C1(t){const[e,n,i,a,u,l,f,h,m]=t,E=e[0]==="-",T=h&&h[0]==="-",A=(O,F=!1)=>O!==void 0&&(F||O&&E)?-O:O;return[{years:A(vr(n)),months:A(vr(i)),weeks:A(vr(a)),days:A(vr(u)),hours:A(vr(l)),minutes:A(vr(f)),seconds:A(vr(h),h==="-0"),milliseconds:A(ql(m),T)}]}const F1={GMT:0,EDT:-4*60,EST:-5*60,CDT:-5*60,CST:-6*60,MDT:-6*60,MST:-7*60,PDT:-7*60,PST:-8*60};function Kl(t,e,n,i,a,u,l){const f={year:e.length===2?ol(rr(e)):rr(e),month:zm.indexOf(n)+1,day:rr(i),hour:rr(a),minute:rr(u)};return l&&(f.second=rr(l)),t&&(f.weekday=t.length>3?Xm.indexOf(t)+1:Ym.indexOf(t)+1),f}const U1=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function V1(t){const[,e,n,i,a,u,l,f,h,m,E,T]=t,A=Kl(e,a,i,n,u,l,f);let O;return h?O=F1[h]:m?O=0:O=eo(E,T),[A,new ct(O)]}function B1(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const $1=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,G1=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,W1=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Wd(t){const[,e,n,i,a,u,l,f]=t;return[Kl(e,a,i,n,u,l,f),ct.utcInstance]}function H1(t){const[,e,n,i,a,u,l,f]=t;return[Kl(e,f,n,i,a,u,l),ct.utcInstance]}const z1=Ei(A1,Zl),q1=Ei(L1,Zl),X1=Ei(S1,Zl),Y1=Ei(tg),rg=Ti(k1,yi,ds,ps),Z1=Ti(O1,yi,ds,ps),K1=Ti(x1,yi,ds,ps),J1=Ti(yi,ds,ps);function j1(t){return Ni(t,[z1,rg],[q1,Z1],[X1,K1],[Y1,J1])}function Q1(t){return Ni(B1(t),[U1,V1])}function eO(t){return Ni(t,[$1,Wd],[G1,Wd],[W1,H1])}function tO(t){return Ni(t,[P1,C1])}const nO=Ti(yi);function rO(t){return Ni(t,[M1,nO])}const iO=Ei(D1,R1),sO=Ei(ng),aO=Ti(yi,ds,ps);function oO(t){return Ni(t,[iO,rg],[sO,aO])}const Hd="Invalid Duration",ig={weeks:{days:7,hours:7*24,minutes:7*24*60,seconds:7*24*60*60,milliseconds:7*24*60*60*1e3},days:{hours:24,minutes:24*60,seconds:24*60*60,milliseconds:24*60*60*1e3},hours:{minutes:60,seconds:60*60,milliseconds:60*60*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},uO={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:91*24,minutes:91*24*60,seconds:91*24*60*60,milliseconds:91*24*60*60*1e3},months:{weeks:4,days:30,hours:30*24,minutes:30*24*60,seconds:30*24*60*60,milliseconds:30*24*60*60*1e3},...ig},Vt=146097/400,Jr=146097/4800,lO={years:{quarters:4,months:12,weeks:Vt/7,days:Vt,hours:Vt*24,minutes:Vt*24*60,seconds:Vt*24*60*60,milliseconds:Vt*24*60*60*1e3},quarters:{months:3,weeks:Vt/28,days:Vt/4,hours:Vt*24/4,minutes:Vt*24*60/4,seconds:Vt*24*60*60/4,milliseconds:Vt*24*60*60*1e3/4},months:{weeks:Jr/7,days:Jr,hours:Jr*24,minutes:Jr*24*60,seconds:Jr*24*60*60,milliseconds:Jr*24*60*60*1e3},...ig},br=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],cO=br.slice(0).reverse();function kn(t,e,n=!1){const i={values:n?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new ce(i)}function sg(t,e){let n=e.milliseconds??0;for(const i of cO.slice(1))e[i]&&(n+=e[i]*t[i].milliseconds);return n}function zd(t,e){const n=sg(t,e)<0?-1:1;br.reduceRight((i,a)=>{if(K(e[a]))return i;if(i){const u=e[i]*n,l=t[a][i],f=Math.floor(u/l);e[a]+=f*n,e[i]-=f*l*n}return a},null),br.reduce((i,a)=>{if(K(e[a]))return i;if(i){const u=e[i]%1;e[i]-=u,e[a]+=u*t[i][a]}return a},null)}function qd(t){const e={};for(const[n,i]of Object.entries(t))i!==0&&(e[n]=i);return e}class ce{constructor(e){const n=e.conversionAccuracy==="longterm"||!1;let i=n?lO:uO;e.matrix&&(i=e.matrix),this.values=e.values,this.loc=e.loc||me.create(),this.conversionAccuracy=n?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=i,this.isLuxonDuration=!0}static fromMillis(e,n){return ce.fromObject({milliseconds:e},n)}static fromObject(e,n={}){if(e==null||typeof e!="object")throw new rt(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new ce({values:Oa(e,ce.normalizeUnit),loc:me.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(e){if(ar(e))return ce.fromMillis(e);if(ce.isDuration(e))return e;if(typeof e=="object")return ce.fromObject(e);throw new rt(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,n){const[i]=tO(e);return i?ce.fromObject(i,n):ce.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,n){const[i]=rO(e);return i?ce.fromObject(i,n):ce.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,n=null){if(!e)throw new rt("need to specify a reason the Duration is invalid");const i=e instanceof nn?e:new nn(e,n);if(Fe.throwOnInvalid)throw new CS(i);return new ce({invalid:i})}static normalizeUnit(e){const n={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e&&e.toLowerCase()];if(!n)throw new dm(e);return n}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,n={}){const i={...n,floor:n.round!==!1&&n.floor!==!1};return this.isValid?it.create(this.loc,i).formatDurationFromString(this,e):Hd}toHuman(e={}){if(!this.isValid)return Hd;const n=e.showZeros!==!1,i=br.map(a=>{const u=this.values[a];return K(u)||u===0&&!n?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:a.slice(0,-1)}).format(u)}).filter(a=>a);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(i)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return this.years!==0&&(e+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+"M"),this.weeks!==0&&(e+=this.weeks+"W"),this.days!==0&&(e+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+="T"),this.hours!==0&&(e+=this.hours+"H"),this.minutes!==0&&(e+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(e+=Xl(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;const n=this.toMillis();return n<0||n>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},Z.fromMillis(n,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?sg(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const n=ce.fromDurationLike(e),i={};for(const a of br)(li(n.values,a)||li(this.values,a))&&(i[a]=n.get(a)+this.get(a));return kn(this,{values:i},!0)}minus(e){if(!this.isValid)return this;const n=ce.fromDurationLike(e);return this.plus(n.negate())}mapUnits(e){if(!this.isValid)return this;const n={};for(const i of Object.keys(this.values))n[i]=Hm(e(this.values[i],i));return kn(this,{values:n},!0)}get(e){return this[ce.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const n={...this.values,...Oa(e,ce.normalizeUnit)};return kn(this,{values:n})}reconfigure({locale:e,numberingSystem:n,conversionAccuracy:i,matrix:a}={}){const l={loc:this.loc.clone({locale:e,numberingSystem:n}),matrix:a,conversionAccuracy:i};return kn(this,l)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return zd(this.matrix,e),kn(this,{values:e},!0)}rescale(){if(!this.isValid)return this;const e=qd(this.normalize().shiftToAll().toObject());return kn(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(l=>ce.normalizeUnit(l));const n={},i={},a=this.toObject();let u;for(const l of br)if(e.indexOf(l)>=0){u=l;let f=0;for(const m in i)f+=this.matrix[m][l]*i[m],i[m]=0;ar(a[l])&&(f+=a[l]);const h=Math.trunc(f);n[l]=h,i[l]=(f*1e3-h*1e3)/1e3}else ar(a[l])&&(i[l]=a[l]);for(const l in i)i[l]!==0&&(n[u]+=l===u?i[l]:i[l]/this.matrix[u][l]);return zd(this.matrix,n),kn(this,{values:n},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const e={};for(const n of Object.keys(this.values))e[n]=this.values[n]===0?0:-this.values[n];return kn(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;const e=qd(this.values);return kn(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function n(i,a){return i===void 0||i===0?a===void 0||a===0:i===a}for(const i of br)if(!n(this.values[i],e.values[i]))return!1;return!0}}const jr="Invalid Interval";function fO(t,e){return!t||!t.isValid?Ce.invalid("missing or invalid start"):!e||!e.isValid?Ce.invalid("missing or invalid end"):e<t?Ce.invalid("end before start",`The end of an interval must be after its start, but you had start=${t.toISO()} and end=${e.toISO()}`):null}class Ce{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,n=null){if(!e)throw new rt("need to specify a reason the Interval is invalid");const i=e instanceof nn?e:new nn(e,n);if(Fe.throwOnInvalid)throw new PS(i);return new Ce({invalid:i})}static fromDateTimes(e,n){const i=Hi(e),a=Hi(n),u=fO(i,a);return u??new Ce({start:i,end:a})}static after(e,n){const i=ce.fromDurationLike(n),a=Hi(e);return Ce.fromDateTimes(a,a.plus(i))}static before(e,n){const i=ce.fromDurationLike(n),a=Hi(e);return Ce.fromDateTimes(a.minus(i),a)}static fromISO(e,n){const[i,a]=(e||"").split("/",2);if(i&&a){let u,l;try{u=Z.fromISO(i,n),l=u.isValid}catch{l=!1}let f,h;try{f=Z.fromISO(a,n),h=f.isValid}catch{h=!1}if(l&&h)return Ce.fromDateTimes(u,f);if(l){const m=ce.fromISO(a,n);if(m.isValid)return Ce.after(u,m)}else if(h){const m=ce.fromISO(i,n);if(m.isValid)return Ce.before(f,m)}}return Ce.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds",n){if(!this.isValid)return NaN;const i=this.start.startOf(e,n);let a;return n?.useLocaleWeeks?a=this.end.reconfigure({locale:i.locale}):a=this.end,a=a.startOf(e,n),Math.floor(a.diff(i,e).get(e))+(a.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:n}={}){return this.isValid?Ce.fromDateTimes(e||this.s,n||this.e):this}splitAt(...e){if(!this.isValid)return[];const n=e.map(Hi).filter(l=>this.contains(l)).sort((l,f)=>l.toMillis()-f.toMillis()),i=[];let{s:a}=this,u=0;for(;a<this.e;){const l=n[u]||this.e,f=+l>+this.e?this.e:l;i.push(Ce.fromDateTimes(a,f)),a=f,u+=1}return i}splitBy(e){const n=ce.fromDurationLike(e);if(!this.isValid||!n.isValid||n.as("milliseconds")===0)return[];let{s:i}=this,a=1,u;const l=[];for(;i<this.e;){const f=this.start.plus(n.mapUnits(h=>h*a));u=+f>+this.e?this.e:f,l.push(Ce.fromDateTimes(i,u)),i=u,a+=1}return l}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const n=this.s>e.s?this.s:e.s,i=this.e<e.e?this.e:e.e;return n>=i?null:Ce.fromDateTimes(n,i)}union(e){if(!this.isValid)return this;const n=this.s<e.s?this.s:e.s,i=this.e>e.e?this.e:e.e;return Ce.fromDateTimes(n,i)}static merge(e){const[n,i]=e.sort((a,u)=>a.s-u.s).reduce(([a,u],l)=>u?u.overlaps(l)||u.abutsStart(l)?[a,u.union(l)]:[a.concat([u]),l]:[a,l],[[],null]);return i&&n.push(i),n}static xor(e){let n=null,i=0;const a=[],u=e.map(h=>[{time:h.s,type:"s"},{time:h.e,type:"e"}]),l=Array.prototype.concat(...u),f=l.sort((h,m)=>h.time-m.time);for(const h of f)i+=h.type==="s"?1:-1,i===1?n=h.time:(n&&+n!=+h.time&&a.push(Ce.fromDateTimes(n,h.time)),n=null);return Ce.merge(a)}difference(...e){return Ce.xor([this].concat(e)).map(n=>this.intersection(n)).filter(n=>n&&!n.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:jr}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=Aa,n={}){return this.isValid?it.create(this.s.loc.clone(n),e).formatInterval(this):jr}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:jr}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:jr}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:jr}toFormat(e,{separator:n=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${n}${this.e.toFormat(e)}`:jr}toDuration(e,n){return this.isValid?this.e.diff(this.s,e,n):ce.invalid(this.invalidReason)}mapEndpoints(e){return Ce.fromDateTimes(e(this.s),e(this.e))}}class ha{static hasDST(e=Fe.defaultZone){const n=Z.now().setZone(e).set({month:12});return!e.isUniversal&&n.offset!==n.set({month:6}).offset}static isValidIANAZone(e){return Vn.isValidZone(e)}static normalizeZone(e){return ir(e,Fe.defaultZone)}static getStartOfWeek({locale:e=null,locObj:n=null}={}){return(n||me.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:n=null}={}){return(n||me.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:n=null}={}){return(n||me.create(e)).getWeekendDays().slice()}static months(e="long",{locale:n=null,numberingSystem:i=null,locObj:a=null,outputCalendar:u="gregory"}={}){return(a||me.create(n,i,u)).months(e)}static monthsFormat(e="long",{locale:n=null,numberingSystem:i=null,locObj:a=null,outputCalendar:u="gregory"}={}){return(a||me.create(n,i,u)).months(e,!0)}static weekdays(e="long",{locale:n=null,numberingSystem:i=null,locObj:a=null}={}){return(a||me.create(n,i,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:n=null,numberingSystem:i=null,locObj:a=null}={}){return(a||me.create(n,i,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return me.create(e).meridiems()}static eras(e="short",{locale:n=null}={}){return me.create(n,null,"gregory").eras(e)}static features(){return{relative:$m(),localeWeek:Gm()}}}function Xd(t,e){const n=a=>a.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),i=n(e)-n(t);return Math.floor(ce.fromMillis(i).as("days"))}function hO(t,e,n){const i=[["years",(h,m)=>m.year-h.year],["quarters",(h,m)=>m.quarter-h.quarter+(m.year-h.year)*4],["months",(h,m)=>m.month-h.month+(m.year-h.year)*12],["weeks",(h,m)=>{const E=Xd(h,m);return(E-E%7)/7}],["days",Xd]],a={},u=t;let l,f;for(const[h,m]of i)n.indexOf(h)>=0&&(l=h,a[h]=m(t,e),f=u.plus(a),f>e?(a[h]--,t=u.plus(a),t>e&&(f=t,a[h]--,t=u.plus(a))):t=f);return[t,a,f,l]}function dO(t,e,n,i){let[a,u,l,f]=hO(t,e,n);const h=e-a,m=n.filter(T=>["hours","minutes","seconds","milliseconds"].indexOf(T)>=0);m.length===0&&(l<e&&(l=a.plus({[f]:1})),l!==a&&(u[f]=(u[f]||0)+h/(l-a)));const E=ce.fromObject(u,i);return m.length>0?ce.fromMillis(h,i).shiftTo(...m).plus(E):E}const pO="missing Intl.DateTimeFormat.formatToParts support";function he(t,e=n=>n){return{regex:t,deser:([n])=>e(i1(n))}}const mO=" ",ag=`[ ${mO}]`,og=new RegExp(ag,"g");function gO(t){return t.replace(/\./g,"\\.?").replace(og,ag)}function Yd(t){return t.replace(/\./g,"").replace(og," ").toLowerCase()}function Qt(t,e){return t===null?null:{regex:RegExp(t.map(gO).join("|")),deser:([n])=>t.findIndex(i=>Yd(n)===Yd(i))+e}}function Zd(t,e){return{regex:t,deser:([,n,i])=>eo(n,i),groups:e}}function da(t){return{regex:t,deser:([e])=>e}}function EO(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function TO(t,e){const n=jt(e),i=jt(e,"{2}"),a=jt(e,"{3}"),u=jt(e,"{4}"),l=jt(e,"{6}"),f=jt(e,"{1,2}"),h=jt(e,"{1,3}"),m=jt(e,"{1,6}"),E=jt(e,"{1,9}"),T=jt(e,"{2,4}"),A=jt(e,"{4,6}"),O=H=>({regex:RegExp(EO(H.val)),deser:([le])=>le,literal:!0}),G=(H=>{if(t.literal)return O(H);switch(H.val){case"G":return Qt(e.eras("short"),0);case"GG":return Qt(e.eras("long"),0);case"y":return he(m);case"yy":return he(T,ol);case"yyyy":return he(u);case"yyyyy":return he(A);case"yyyyyy":return he(l);case"M":return he(f);case"MM":return he(i);case"MMM":return Qt(e.months("short",!0),1);case"MMMM":return Qt(e.months("long",!0),1);case"L":return he(f);case"LL":return he(i);case"LLL":return Qt(e.months("short",!1),1);case"LLLL":return Qt(e.months("long",!1),1);case"d":return he(f);case"dd":return he(i);case"o":return he(h);case"ooo":return he(a);case"HH":return he(i);case"H":return he(f);case"hh":return he(i);case"h":return he(f);case"mm":return he(i);case"m":return he(f);case"q":return he(f);case"qq":return he(i);case"s":return he(f);case"ss":return he(i);case"S":return he(h);case"SSS":return he(a);case"u":return da(E);case"uu":return da(f);case"uuu":return he(n);case"a":return Qt(e.meridiems(),0);case"kkkk":return he(u);case"kk":return he(T,ol);case"W":return he(f);case"WW":return he(i);case"E":case"c":return he(n);case"EEE":return Qt(e.weekdays("short",!1),1);case"EEEE":return Qt(e.weekdays("long",!1),1);case"ccc":return Qt(e.weekdays("short",!0),1);case"cccc":return Qt(e.weekdays("long",!0),1);case"Z":case"ZZ":return Zd(new RegExp(`([+-]${f.source})(?::(${i.source}))?`),2);case"ZZZ":return Zd(new RegExp(`([+-]${f.source})(${i.source})?`),2);case"z":return da(/[a-z_+-/]{1,256}?/i);case" ":return da(/[^\S\n\r]/);default:return O(H)}})(t)||{invalidReason:pO};return G.token=t,G}const NO={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function yO(t,e,n){const{type:i,value:a}=t;if(i==="literal"){const h=/^\s+$/.test(a);return{literal:!h,val:h?" ":a}}const u=e[i];let l=i;i==="hour"&&(e.hour12!=null?l=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?l="hour12":l="hour24":l=n.hour12?"hour12":"hour24");let f=NO[l];if(typeof f=="object"&&(f=f[u]),f)return{literal:!1,val:f}}function vO(t){return[`^${t.map(n=>n.regex).reduce((n,i)=>`${n}(${i.source})`,"")}$`,t]}function _O(t,e,n){const i=t.match(e);if(i){const a={};let u=1;for(const l in n)if(li(n,l)){const f=n[l],h=f.groups?f.groups+1:1;!f.literal&&f.token&&(a[f.token.val[0]]=f.deser(i.slice(u,u+h))),u+=h}return[i,a]}else return[i,{}]}function bO(t){const e=u=>{switch(u){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let n=null,i;return K(t.z)||(n=Vn.create(t.z)),K(t.Z)||(n||(n=new ct(t.Z)),i=t.Z),K(t.q)||(t.M=(t.q-1)*3+1),K(t.h)||(t.h<12&&t.a===1?t.h+=12:t.h===12&&t.a===0&&(t.h=0)),t.G===0&&t.y&&(t.y=-t.y),K(t.u)||(t.S=ql(t.u)),[Object.keys(t).reduce((u,l)=>{const f=e(l);return f&&(u[f]=t[l]),u},{}),n,i]}let Cu=null;function wO(){return Cu||(Cu=Z.fromMillis(1555555555555)),Cu}function IO(t,e){if(t.literal)return t;const n=it.macroTokenToFormatOpts(t.val),i=fg(n,e);return i==null||i.includes(void 0)?t:i}function ug(t,e){return Array.prototype.concat(...t.map(n=>IO(n,e)))}class lg{constructor(e,n){if(this.locale=e,this.format=n,this.tokens=ug(it.parseFormat(n),e),this.units=this.tokens.map(i=>TO(i,e)),this.disqualifyingUnit=this.units.find(i=>i.invalidReason),!this.disqualifyingUnit){const[i,a]=vO(this.units);this.regex=RegExp(i,"i"),this.handlers=a}}explainFromTokens(e){if(this.isValid){const[n,i]=_O(e,this.regex,this.handlers),[a,u,l]=i?bO(i):[null,null,void 0];if(li(i,"a")&&li(i,"H"))throw new ei("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:n,matches:i,result:a,zone:u,specificOffset:l}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function cg(t,e,n){return new lg(t,n).explainFromTokens(e)}function AO(t,e,n){const{result:i,zone:a,specificOffset:u,invalidReason:l}=cg(t,e,n);return[i,a,u,l]}function fg(t,e){if(!t)return null;const i=it.create(e,t).dtFormatter(wO()),a=i.formatToParts(),u=i.resolvedOptions();return a.map(l=>yO(l,t,u))}const Fu="Invalid DateTime",Kd=864e13;function Xi(t){return new nn("unsupported zone",`the zone "${t.name}" is not supported`)}function Uu(t){return t.weekData===null&&(t.weekData=La(t.c)),t.weekData}function Vu(t){return t.localWeekData===null&&(t.localWeekData=La(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function _r(t,e){const n={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new Z({...n,...e,old:n})}function hg(t,e,n){let i=t-e*60*1e3;const a=n.offset(i);if(e===a)return[i,e];i-=(a-e)*60*1e3;const u=n.offset(i);return a===u?[i,a]:[t-Math.min(a,u)*60*1e3,Math.max(a,u)]}function pa(t,e){t+=e*60*1e3;const n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function Ta(t,e,n){return hg(Qa(t),e,n)}function Jd(t,e){const n=t.o,i=t.c.year+Math.trunc(e.years),a=t.c.month+Math.trunc(e.months)+Math.trunc(e.quarters)*3,u={...t.c,year:i,month:a,day:Math.min(t.c.day,Sa(i,a))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},l=ce.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),f=Qa(u);let[h,m]=hg(f,n,t.zone);return l!==0&&(h+=l,m=t.zone.offset(h)),{ts:h,o:m}}function Qr(t,e,n,i,a,u){const{setZone:l,zone:f}=n;if(t&&Object.keys(t).length!==0||e){const h=e||f,m=Z.fromObject(t,{...n,zone:h,specificOffset:u});return l?m:m.setZone(f)}else return Z.invalid(new nn("unparsable",`the input "${a}" can't be parsed as ${i}`))}function ma(t,e,n=!0){return t.isValid?it.create(me.create("en-US"),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(t,e):null}function Bu(t,e,n){const i=t.c.year>9999||t.c.year<0;let a="";if(i&&t.c.year>=0&&(a+="+"),a+=$e(t.c.year,i?6:4),n==="year")return a;if(e){if(a+="-",a+=$e(t.c.month),n==="month")return a;a+="-"}else if(a+=$e(t.c.month),n==="month")return a;return a+=$e(t.c.day),a}function jd(t,e,n,i,a,u,l){let f=!n||t.c.millisecond!==0||t.c.second!==0,h="";switch(l){case"day":case"month":case"year":break;default:if(h+=$e(t.c.hour),l==="hour")break;if(e){if(h+=":",h+=$e(t.c.minute),l==="minute")break;f&&(h+=":",h+=$e(t.c.second))}else{if(h+=$e(t.c.minute),l==="minute")break;f&&(h+=$e(t.c.second))}if(l==="second")break;f&&(!i||t.c.millisecond!==0)&&(h+=".",h+=$e(t.c.millisecond,3))}return a&&(t.isOffsetFixed&&t.offset===0&&!u?h+="Z":t.o<0?(h+="-",h+=$e(Math.trunc(-t.o/60)),h+=":",h+=$e(Math.trunc(-t.o%60))):(h+="+",h+=$e(Math.trunc(t.o/60)),h+=":",h+=$e(Math.trunc(t.o%60)))),u&&(h+="["+t.zone.ianaName+"]"),h}const dg={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},LO={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},SO={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Na=["year","month","day","hour","minute","second","millisecond"],OO=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],xO=["year","ordinal","hour","minute","second","millisecond"];function ya(t){const e={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[t.toLowerCase()];if(!e)throw new dm(t);return e}function Qd(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return ya(t)}}function DO(t){if(Yi===void 0&&(Yi=Fe.now()),t.type!=="iana")return t.offset(Yi);const e=t.name;let n=ul.get(e);return n===void 0&&(n=t.offset(Yi),ul.set(e,n)),n}function ep(t,e){const n=ir(e.zone,Fe.defaultZone);if(!n.isValid)return Z.invalid(Xi(n));const i=me.fromObject(e);let a,u;if(K(t.year))a=Fe.now();else{for(const h of Na)K(t[h])&&(t[h]=dg[h]);const l=Vm(t)||Bm(t);if(l)return Z.invalid(l);const f=DO(n);[a,u]=Ta(t,f,n)}return new Z({ts:a,zone:n,loc:i,o:u})}function tp(t,e,n){const i=K(n.round)?!0:n.round,a=K(n.rounding)?"trunc":n.rounding,u=(f,h)=>(f=Xl(f,i||n.calendary?0:2,n.calendary?"round":a),e.loc.clone(n).relFormatter(n).format(f,h)),l=f=>n.calendary?e.hasSame(t,f)?0:e.startOf(f).diff(t.startOf(f),f).get(f):e.diff(t,f).get(f);if(n.unit)return u(l(n.unit),n.unit);for(const f of n.units){const h=l(f);if(Math.abs(h)>=1)return u(h,f)}return u(t>e?-0:0,n.units[n.units.length-1])}function np(t){let e={},n;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],n=Array.from(t).slice(0,t.length-1)):n=Array.from(t),[e,n]}let Yi;const ul=new Map;class Z{constructor(e){const n=e.zone||Fe.defaultZone;let i=e.invalid||(Number.isNaN(e.ts)?new nn("invalid input"):null)||(n.isValid?null:Xi(n));this.ts=K(e.ts)?Fe.now():e.ts;let a=null,u=null;if(!i)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(n))[a,u]=[e.old.c,e.old.o];else{const f=ar(e.o)&&!e.old?e.o:n.offset(this.ts);a=pa(this.ts,f),i=Number.isNaN(a.year)?new nn("invalid input"):null,a=i?null:a,u=i?null:f}this._zone=n,this.loc=e.loc||me.create(),this.invalid=i,this.weekData=null,this.localWeekData=null,this.c=a,this.o=u,this.isLuxonDateTime=!0}static now(){return new Z({})}static local(){const[e,n]=np(arguments),[i,a,u,l,f,h,m]=n;return ep({year:i,month:a,day:u,hour:l,minute:f,second:h,millisecond:m},e)}static utc(){const[e,n]=np(arguments),[i,a,u,l,f,h,m]=n;return e.zone=ct.utcInstance,ep({year:i,month:a,day:u,hour:l,minute:f,second:h,millisecond:m},e)}static fromJSDate(e,n={}){const i=l1(e)?e.valueOf():NaN;if(Number.isNaN(i))return Z.invalid("invalid input");const a=ir(n.zone,Fe.defaultZone);return a.isValid?new Z({ts:i,zone:a,loc:me.fromObject(n)}):Z.invalid(Xi(a))}static fromMillis(e,n={}){if(ar(e))return e<-Kd||e>Kd?Z.invalid("Timestamp out of range"):new Z({ts:e,zone:ir(n.zone,Fe.defaultZone),loc:me.fromObject(n)});throw new rt(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,n={}){if(ar(e))return new Z({ts:e*1e3,zone:ir(n.zone,Fe.defaultZone),loc:me.fromObject(n)});throw new rt("fromSeconds requires a numerical input")}static fromObject(e,n={}){e=e||{};const i=ir(n.zone,Fe.defaultZone);if(!i.isValid)return Z.invalid(Xi(i));const a=me.fromObject(n),u=Oa(e,Qd),{minDaysInFirstWeek:l,startOfWeek:f}=Vd(u,a),h=Fe.now(),m=K(n.specificOffset)?i.offset(h):n.specificOffset,E=!K(u.ordinal),T=!K(u.year),A=!K(u.month)||!K(u.day),O=T||A,F=u.weekYear||u.weekNumber;if((O||E)&&F)throw new ei("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(A&&E)throw new ei("Can't mix ordinal dates with month/day");const G=F||u.weekday&&!O;let H,le,Me=pa(h,m);G?(H=OO,le=LO,Me=La(Me,l,f)):E?(H=xO,le=SO,Me=Pu(Me)):(H=Na,le=dg);let Xe=!1;for(const lr of H){const so=u[lr];K(so)?Xe?u[lr]=le[lr]:u[lr]=Me[lr]:Xe=!0}const at=G?a1(u,l,f):E?o1(u):Vm(u),Je=at||Bm(u);if(Je)return Z.invalid(Je);const or=G?Fd(u,l,f):E?Ud(u):u,[zt,ur]=Ta(or,m,i),_n=new Z({ts:zt,zone:i,o:ur,loc:a});return u.weekday&&O&&e.weekday!==_n.weekday?Z.invalid("mismatched weekday",`you can't specify both a weekday of ${u.weekday} and a date of ${_n.toISO()}`):_n.isValid?_n:Z.invalid(_n.invalid)}static fromISO(e,n={}){const[i,a]=j1(e);return Qr(i,a,n,"ISO 8601",e)}static fromRFC2822(e,n={}){const[i,a]=Q1(e);return Qr(i,a,n,"RFC 2822",e)}static fromHTTP(e,n={}){const[i,a]=eO(e);return Qr(i,a,n,"HTTP",n)}static fromFormat(e,n,i={}){if(K(e)||K(n))throw new rt("fromFormat requires an input string and a format");const{locale:a=null,numberingSystem:u=null}=i,l=me.fromOpts({locale:a,numberingSystem:u,defaultToEN:!0}),[f,h,m,E]=AO(l,e,n);return E?Z.invalid(E):Qr(f,h,i,`format ${n}`,e,m)}static fromString(e,n,i={}){return Z.fromFormat(e,n,i)}static fromSQL(e,n={}){const[i,a]=oO(e);return Qr(i,a,n,"SQL",e)}static invalid(e,n=null){if(!e)throw new rt("need to specify a reason the DateTime is invalid");const i=e instanceof nn?e:new nn(e,n);if(Fe.throwOnInvalid)throw new MS(i);return new Z({invalid:i})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,n={}){const i=fg(e,me.fromObject(n));return i?i.map(a=>a?a.val:null).join(""):null}static expandFormat(e,n={}){return ug(it.parseFormat(e),me.fromObject(n)).map(a=>a.val).join("")}static resetCache(){Yi=void 0,ul.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Uu(this).weekYear:NaN}get weekNumber(){return this.isValid?Uu(this).weekNumber:NaN}get weekday(){return this.isValid?Uu(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Vu(this).weekday:NaN}get localWeekNumber(){return this.isValid?Vu(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Vu(this).weekYear:NaN}get ordinal(){return this.isValid?Pu(this.c).ordinal:NaN}get monthShort(){return this.isValid?ha.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?ha.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?ha.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?ha.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const e=864e5,n=6e4,i=Qa(this.c),a=this.zone.offset(i-e),u=this.zone.offset(i+e),l=this.zone.offset(i-a*n),f=this.zone.offset(i-u*n);if(l===f)return[this];const h=i-l*n,m=i-f*n,E=pa(h,l),T=pa(m,f);return E.hour===T.hour&&E.minute===T.minute&&E.second===T.second&&E.millisecond===T.millisecond?[_r(this,{ts:h}),_r(this,{ts:m})]:[this]}get isInLeapYear(){return hs(this.year)}get daysInMonth(){return Sa(this.year,this.month)}get daysInYear(){return this.isValid?ri(this.year):NaN}get weeksInWeekYear(){return this.isValid?ss(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?ss(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){const{locale:n,numberingSystem:i,calendar:a}=it.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:n,numberingSystem:i,outputCalendar:a}}toUTC(e=0,n={}){return this.setZone(ct.instance(e),n)}toLocal(){return this.setZone(Fe.defaultZone)}setZone(e,{keepLocalTime:n=!1,keepCalendarTime:i=!1}={}){if(e=ir(e,Fe.defaultZone),e.equals(this.zone))return this;if(e.isValid){let a=this.ts;if(n||i){const u=e.offset(this.ts),l=this.toObject();[a]=Ta(l,u,e)}return _r(this,{ts:a,zone:e})}else return Z.invalid(Xi(e))}reconfigure({locale:e,numberingSystem:n,outputCalendar:i}={}){const a=this.loc.clone({locale:e,numberingSystem:n,outputCalendar:i});return _r(this,{loc:a})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const n=Oa(e,Qd),{minDaysInFirstWeek:i,startOfWeek:a}=Vd(n,this.loc),u=!K(n.weekYear)||!K(n.weekNumber)||!K(n.weekday),l=!K(n.ordinal),f=!K(n.year),h=!K(n.month)||!K(n.day),m=f||h,E=n.weekYear||n.weekNumber;if((m||l)&&E)throw new ei("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(h&&l)throw new ei("Can't mix ordinal dates with month/day");let T;u?T=Fd({...La(this.c,i,a),...n},i,a):K(n.ordinal)?(T={...this.toObject(),...n},K(n.day)&&(T.day=Math.min(Sa(T.year,T.month),T.day))):T=Ud({...Pu(this.c),...n});const[A,O]=Ta(T,this.o,this.zone);return _r(this,{ts:A,o:O})}plus(e){if(!this.isValid)return this;const n=ce.fromDurationLike(e);return _r(this,Jd(this,n))}minus(e){if(!this.isValid)return this;const n=ce.fromDurationLike(e).negate();return _r(this,Jd(this,n))}startOf(e,{useLocaleWeeks:n=!1}={}){if(!this.isValid)return this;const i={},a=ce.normalizeUnit(e);switch(a){case"years":i.month=1;case"quarters":case"months":i.day=1;case"weeks":case"days":i.hour=0;case"hours":i.minute=0;case"minutes":i.second=0;case"seconds":i.millisecond=0;break}if(a==="weeks")if(n){const u=this.loc.getStartOfWeek(),{weekday:l}=this;l<u&&(i.weekNumber=this.weekNumber-1),i.weekday=u}else i.weekday=1;if(a==="quarters"){const u=Math.ceil(this.month/3);i.month=(u-1)*3+1}return this.set(i)}endOf(e,n){return this.isValid?this.plus({[e]:1}).startOf(e,n).minus(1):this}toFormat(e,n={}){return this.isValid?it.create(this.loc.redefaultToEN(n)).formatDateTimeFromString(this,e):Fu}toLocaleString(e=Aa,n={}){return this.isValid?it.create(this.loc.clone(n),e).formatDateTime(this):Fu}toLocaleParts(e={}){return this.isValid?it.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:n=!1,suppressMilliseconds:i=!1,includeOffset:a=!0,extendedZone:u=!1,precision:l="milliseconds"}={}){if(!this.isValid)return null;l=ya(l);const f=e==="extended";let h=Bu(this,f,l);return Na.indexOf(l)>=3&&(h+="T"),h+=jd(this,f,n,i,a,u,l),h}toISODate({format:e="extended",precision:n="day"}={}){return this.isValid?Bu(this,e==="extended",ya(n)):null}toISOWeekDate(){return ma(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:n=!1,includeOffset:i=!0,includePrefix:a=!1,extendedZone:u=!1,format:l="extended",precision:f="milliseconds"}={}){return this.isValid?(f=ya(f),(a&&Na.indexOf(f)>=3?"T":"")+jd(this,l==="extended",n,e,i,u,f)):null}toRFC2822(){return ma(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return ma(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Bu(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:n=!1,includeOffsetSpace:i=!0}={}){let a="HH:mm:ss.SSS";return(n||e)&&(i&&(a+=" "),n?a+="z":e&&(a+="ZZ")),ma(this,a,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Fu}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const n={...this.c};return e.includeConfig&&(n.outputCalendar=this.outputCalendar,n.numberingSystem=this.loc.numberingSystem,n.locale=this.loc.locale),n}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,n="milliseconds",i={}){if(!this.isValid||!e.isValid)return ce.invalid("created by diffing an invalid DateTime");const a={locale:this.locale,numberingSystem:this.numberingSystem,...i},u=c1(n).map(ce.normalizeUnit),l=e.valueOf()>this.valueOf(),f=l?this:e,h=l?e:this,m=dO(f,h,u,a);return l?m.negate():m}diffNow(e="milliseconds",n={}){return this.diff(Z.now(),e,n)}until(e){return this.isValid?Ce.fromDateTimes(this,e):this}hasSame(e,n,i){if(!this.isValid)return!1;const a=e.valueOf(),u=this.setZone(e.zone,{keepLocalTime:!0});return u.startOf(n,i)<=a&&a<=u.endOf(n,i)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const n=e.base||Z.fromObject({},{zone:this.zone}),i=e.padding?this<n?-e.padding:e.padding:0;let a=["years","months","days","hours","minutes","seconds"],u=e.unit;return Array.isArray(e.unit)&&(a=e.unit,u=void 0),tp(n,this.plus(i),{...e,numeric:"always",units:a,unit:u})}toRelativeCalendar(e={}){return this.isValid?tp(e.base||Z.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(Z.isDateTime))throw new rt("min requires all arguments be DateTimes");return Bd(e,n=>n.valueOf(),Math.min)}static max(...e){if(!e.every(Z.isDateTime))throw new rt("max requires all arguments be DateTimes");return Bd(e,n=>n.valueOf(),Math.max)}static fromFormatExplain(e,n,i={}){const{locale:a=null,numberingSystem:u=null}=i,l=me.fromOpts({locale:a,numberingSystem:u,defaultToEN:!0});return cg(l,e,n)}static fromStringExplain(e,n,i={}){return Z.fromFormatExplain(e,n,i)}static buildFormatParser(e,n={}){const{locale:i=null,numberingSystem:a=null}=n,u=me.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0});return new lg(u,e)}static fromFormatParser(e,n,i={}){if(K(e)||K(n))throw new rt("fromFormatParser requires an input string and a format parser");const{locale:a=null,numberingSystem:u=null}=i,l=me.fromOpts({locale:a,numberingSystem:u,defaultToEN:!0});if(!l.equals(n.locale))throw new rt(`fromFormatParser called with a locale of ${l}, but the format parser was created for ${n.locale}`);const{result:f,zone:h,specificOffset:m,invalidReason:E}=n.explainFromTokens(e);return E?Z.invalid(E):Qr(f,h,i,`format ${n.format}`,e,m)}static get DATE_SHORT(){return Aa}static get DATE_MED(){return pm}static get DATE_MED_WITH_WEEKDAY(){return FS}static get DATE_FULL(){return mm}static get DATE_HUGE(){return gm}static get TIME_SIMPLE(){return Em}static get TIME_WITH_SECONDS(){return Tm}static get TIME_WITH_SHORT_OFFSET(){return Nm}static get TIME_WITH_LONG_OFFSET(){return ym}static get TIME_24_SIMPLE(){return vm}static get TIME_24_WITH_SECONDS(){return _m}static get TIME_24_WITH_SHORT_OFFSET(){return bm}static get TIME_24_WITH_LONG_OFFSET(){return wm}static get DATETIME_SHORT(){return Im}static get DATETIME_SHORT_WITH_SECONDS(){return Am}static get DATETIME_MED(){return Lm}static get DATETIME_MED_WITH_SECONDS(){return Sm}static get DATETIME_MED_WITH_WEEKDAY(){return US}static get DATETIME_FULL(){return Om}static get DATETIME_FULL_WITH_SECONDS(){return xm}static get DATETIME_HUGE(){return Dm}static get DATETIME_HUGE_WITH_SECONDS(){return Rm}}function Hi(t){if(Z.isDateTime(t))return t;if(t&&t.valueOf&&ar(t.valueOf()))return Z.fromJSDate(t);if(t&&typeof t=="object")return Z.fromObject(t);throw new rt(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function pg(t){return yn(t)?t.expression.variable?.value?.toLowerCase()==="null":t instanceof gn}function mg(t){return Te(t).unwrap_or(void 0)===""}function RO(t){return t instanceof st}function Jl(t){const e=Or(t);if(e!==null)return e;if(St(t)&&t instanceof ft&&t.expression){const n=t.op?.value,i=Or(t.expression);if(i!==null)return n==="-"?-i:i}return null}function no(t){if(t==null)return null;if(typeof t=="number")return t;if(typeof t=="string"){const i=Number(t);return isNaN(i)?null:i}if(typeof t=="boolean")return t?1:0;const e=Jl(t);if(e!==null)return e;const n=Te(t).unwrap_or(void 0);if(n!==void 0){const i=Number(n);if(!isNaN(i))return i}return null}function kO(t){if(t==null)return null;if(typeof t=="number")return Number.isInteger(t)?t:null;if(typeof t=="string"){const i=Number(t);return isNaN(i)||!Number.isInteger(i)?null:i}if(typeof t=="boolean")return t?1:0;const e=Jl(t);if(e!==null)return Number.isInteger(e)?e:null;const n=Te(t).unwrap_or(void 0);if(n!==void 0){const i=Number(n);if(!isNaN(i)&&Number.isInteger(i))return i}return null}const ll=["true","yes","y","t","1"],cl=["false","no","n","f","0"];function ro(t){if(t==null)return null;if(typeof t=="boolean")return t;if(typeof t=="number")return t===0?!1:t===1?!0:null;if(typeof t=="string"){const i=t.toLowerCase();return ll.includes(i)?!0:cl.includes(i)?!1:null}if(yn(t)){const i=t.expression.variable?.value?.toLowerCase();if(i==="true")return!0;if(i==="false")return!1}const e=Or(t);if(e===0)return!1;if(e===1)return!0;const n=Te(t)?.unwrap_or("").toLowerCase();if(n){if(ll.includes(n))return!0;if(cl.includes(n))return!1}return null}function MO(t){if(t==null)return null;if(typeof t=="string")return t;const e=qe(t).unwrap_or(void 0);return e?Oe(e):Te(t).unwrap_or(null)}function xa(t){if(t==null)return null;if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();const e=Te(t).unwrap_or(null)??ro(t)??no(t);return e===null?null:e.toString()}const PO=["yyyy-MM-dd","M/d/yyyy","d MMM yyyy","MMM d, yyyy"],CO=["yyyy-MM-dd HH:mm:ss","yyyy-MM-dd HH:mm:ss.SSS","yyyy-MM-dd HH:mm:ss.SSSZZ","yyyy-MM-dd HH:mm:ssZZ"],FO=["HH:mm:ss","HH:mm:ssZZ","HH:mm:ss.SSS","HH:mm:ss.SSSZZ"];function jl(t){if(t==null)return null;const e=typeof t=="string"?t:Te(t).unwrap_or(null);if(e===null)return null;for(const a of FO){const u=Z.fromFormat(e,a,{setZone:!0});if(u.isValid)return u.toISOTime({suppressMilliseconds:!0,includeOffset:i(u)})}for(const a of PO){const u=Z.fromFormat(e,a,{setZone:!0});if(u.isValid)return u.toISODate()}for(const a of CO){const u=Z.fromFormat(e,a,{setZone:!0});if(u.isValid)return u.toISO({suppressMilliseconds:!0,includeOffset:i(u)})}const n=Z.fromISO(e,{setZone:!0});if(n.isValid)return n.toISO({suppressMilliseconds:!0,includeOffset:i(n)});return null;function i(a){return a.zone.type!=="system"}}function Da(t,e,n){return e.map((i,a)=>{const u=t[i]?.value;if(u==null&&n&&n[a]){const l=n[a];if(l?.dbdefault)return JSON.stringify(l.dbdefault.value)}return JSON.stringify(u)}).join("|")}function Ql(t,e,n){return e.some((i,a)=>{const u=t[i]?.value;return u==null&&n&&n[a]&&n[a]?.dbdefault?!1:u==null})}function UO(t){return t.increment||Ka(t.type.type_name)}function rp(t,e,n){return t?`${t}.${e}.${n}`:`${e}.${n}`}function ci(t,e,n){return n.length===1?rp(t,e,n[0]):`(${n.map(a=>rp(t,e,a)).join(", ")})`}function ec(t,e){return e.length===1?JSON.stringify(t[e[0]]?.value):`(${e.map(i=>JSON.stringify(t[i]?.value)).join(", ")})`}function io(t,e,n){const i=e.map(a=>t.columnNodes[a]).filter(Boolean);return i.length>0?i.map(a=>new v(N.INVALID_RECORDS_FIELD,n,a)):[new v(N.INVALID_RECORDS_FIELD,n,t.node)]}const tc=t=>t>1?"Composite PK":"PK";function gg(t){return Ht(Array.from(t.records),([e,n])=>{if(Lr(n))return[];t.cachedMergedTables.has(e)||t.cachedMergedTables.set(e,is(e,t));const i=t.cachedMergedTables.get(e),a=GO(i),u=WO(n),l=Bp(i.fields,"name");return Ht(a,f=>VO(f,n,u,l,i))})}function VO(t,e,n,i,a){const u=HO(t,n,i,a,e);if(!Lr(u))return u;const l=Rp(t.map(A=>i[A])),f=l.every(A=>A&&UO(A)),[h,m]=ht(e,A=>Ql(A.values,t,l)),E=f?[]:BO(h,t,a),T=$O(m,t,l,a);return[...E,...T]}function BO(t,e,n){if(Lr(t))return[];const i=tc(e.length),a=ci(n.schemaName,n.name,e),u=`NULL in ${i}: ${a} cannot be NULL`;return Ht(t,l=>io(l,e,u))}function $O(t,e,n,i){const a=Vp(t,l=>Da(l.values,e,n)),u=Up(a,l=>l.length>1);return Ht(u,l=>{const f=tc(e.length),h=ci(i.schemaName,i.name,e);return Ht(l.slice(1),m=>{const E=ec(m.values,e),T=`Duplicate ${f}: ${h} = ${E}`;return io(m,e,T)})})}function GO(t){return[...t.fields.filter(e=>e.pk).map(e=>[e.name]),...t.indexes.filter(e=>e.pk).map(e=>e.columns.map(n=>n.value))]}function WO(t){return new Set(t.flatMap(e=>Object.keys(e.values)))}function HO(t,e,n,i,a){const u=oL(t,Array.from(e));if(Lr(u))return[];const l=T=>{const A=n[T];return A&&!A.increment&&!Ka(A.type.type_name)&&!A.dbdefault},f=u.filter(l);if(Lr(f))return[];const h=tc(f.length),m=ci(i.schemaName,i.name,f),E=`${h}: Column ${m} is missing from record and has no default value`;return a.map(T=>new v(N.INVALID_RECORDS_FIELD,E,T.node))}const zO=t=>t>1?"Composite UNIQUE":"UNIQUE";function Eg(t){return Ht(Array.from(t.records),([e,n])=>{t.cachedMergedTables.has(e)||t.cachedMergedTables.set(e,is(e,t));const i=t.cachedMergedTables.get(e);if(Lr(n))return[];const a=qO(i),u=Bp(i.fields,"name");return Ht(a,l=>{const f=Rp(l.map(h=>u[h]));return XO(n,l,f,i)})})}function qO(t){return[...t.fields.filter(e=>e.unique).map(e=>[e.name]),...t.indexes.filter(e=>e.unique).map(e=>e.columns.map(n=>n.value))]}function XO(t,e,n,i){const a=t.filter(f=>!Ql(f.values,e,n)),u=Vp(a,f=>Da(f.values,e,n)),l=Up(u,f=>f.length>1);return Ht(l,f=>{const h=zO(e.length),m=ci(i.schemaName,i.name,e);return Ht(f.slice(1),E=>{const T=ec(E.values,e),A=`Duplicate ${h}: ${m} = ${T}`;return io(E,e,A)})})}function Tg(t){const e=[...t.ref.values(),...Ht(Array.from(t.tables.values()),i=>SS(i,t))],n=YO(t);return Ht(e,i=>ZO(i,n))}function YO(t){const e=new Map;for(const n of t.tables.values()){const i=fl(n.schemaName,n.name),a=t.records.get(n)||[];t.cachedMergedTables.has(n)||t.cachedMergedTables.set(n,is(n,t));const u=t.cachedMergedTables.get(n);e.set(i,{mergedTable:u,rows:a})}return e}function fl(t,e){return t?`${t}.${e}`:`${Wt}.${e}`}function ga(t,e,n,i){if(Lr(t.rows))return[];const a=new Set(e.rows.map(f=>Da(f.values,i.fieldNames))),l=t.rows.filter(f=>!Ql(f.values,n.fieldNames)).filter(f=>{const h=Da(f.values,n.fieldNames);return!a.has(h)});return Ht(l,f=>{const h=ci(t.mergedTable.schemaName,t.mergedTable.name,n.fieldNames),m=ci(e.mergedTable.schemaName,e.mergedTable.name,i.fieldNames),E=ec(f.values,n.fieldNames),T=`FK violation: ${h} = ${E} does not exist in ${m}`;return io(f,n.fieldNames,T)})}function ZO(t,e){if(!t.endpoints)return[];const[n,i]=t.endpoints,a=e.get(fl(n.schemaName,n.tableName)),u=e.get(fl(i.schemaName,i.tableName));return!a||!u?[]:KO(a,u,n,i)}function KO(t,e,n,i){const a=n.relation,u=i.relation;return a==="1"&&u==="1"||a==="*"&&u==="*"?[...ga(t,e,n,i),...ga(e,t,i,n)]:a==="*"&&u==="1"?ga(t,e,n,i):a==="1"&&u==="*"?ga(e,t,i,n):[]}class JO{constructor(e){this.env=e,this.tableToRecordMap=new Map}interpret(e){const n=[],i=[];for(const u of e){const{table:l,mergedColumns:f}=jO(u,this.env),h=this.tableToRecordMap.get(l);if(h){n.push(new v(N.DUPLICATE_RECORDS_FOR_TABLE,`Duplicate Records blocks for the same Table '${l.name}' - A Table can only have one Records block`,h)),n.push(new v(N.DUPLICATE_RECORDS_FOR_TABLE,`Duplicate Records blocks for the same Table '${l.name}' - A Table can only have one Records block`,u));continue}this.tableToRecordMap.set(l,u);for(const m of u.body.body){const E=m,T=QO(E,f,this.env);n.push(...T.getErrors()),i.push(...T.getWarnings());const A=T.getValue();if(!A.row)continue;this.env.records.has(l)||this.env.records.set(l,[]),this.env.records.get(l).push({values:A.row,node:E,columnNodes:A.columnNodes})}}const a=this.validateConstraints();return i.push(...a),new ue(void 0,n,i)}validateConstraints(){const e=[];return e.push(...gg(this.env).map(n=>n.toWarning())),e.push(...Eg(this.env).map(n=>n.toWarning())),e.push(...Tg(this.env).map(n=>n.toWarning())),e}}function jO(t,e){const n=t.name,i=t.parent;if(i instanceof re){const m=e.tables.get(i),E=is(m,e);if(!n)return{table:m,mergedTable:E,mergedColumns:E.fields};const T=n.elementList.map(A=>E.fields.find(O=>O.name===ve(A).unwrap()));return{table:m,mergedTable:E,mergedColumns:T}}const a=tm(n).unwrap(),u=Oe(a.variables).referee.declaration,l=e.tables.get(u),f=is(l,e),h=a.args.map(m=>f.fields.find(E=>E.name===ve(m).unwrap()));return{table:l,mergedTable:f,mergedColumns:h}}function QO(t,e,n){const i=[],a=[],u={},l={},f=t.callee instanceof Fn?t.callee.elementList:[t.callee];if(f.length!==e.length)return i.push(new v(N.INVALID_RECORDS_FIELD,`Expected ${e.length} values but got ${f.length}`,t)),new ue({row:null,columnNodes:{}},i,a);for(let h=0;h<e.length;h++){const m=f[h],E=e[h];l[E.name]=m;const T=tx(m,E,n);i.push(...T.getErrors()),a.push(...T.getWarnings());const A=T.getValue();A!==null&&(u[E.name]=A)}return new ue({row:u,columnNodes:l},i,a)}function ex(t,e){return t instanceof st?t.value?.value||"":!isNaN(t.start)&&!isNaN(t.end)?e.slice(t.start,t.end):""}function tx(t,e,n){const i=e.type.type_name.split("(")[0],{increment:a,not_null:u,dbdefault:l}=e,f=e.type.isEnum||!1,h=hm(i,f),m=xa(t),E=m!==null?m:ex(t,n.source),T=m!==null?h:"expression";if(t instanceof st)return new ue({value:t.value?.value||"",type:"expression"},[],[]);if(pg(t)||mg(t)&&!Ia(i)){const A=l&&l.value.toString().toLowerCase()!=="null",O=Ka(i);return u&&!A&&!a&&!O?new ue({value:null,type:h},[],[new en(N.INVALID_RECORDS_FIELD,`NULL not allowed for non-nullable column '${e.name}' without default and increment`,t)]):new ue({value:null,type:h},[],[])}if(f){const A=([...n.enums.values()].find(F=>F.schemaName===e.type.schemaName&&F.name===e.type.type_name)?.values||[]).map(F=>F.name);let O=Te(t).unwrap_or(void 0);return O===void 0&&(O=qe(t).unwrap_or([]).pop()),A.includes(O)?new ue({value:O,type:h},[],[]):new ue({value:O,type:h},[],[new en(N.INVALID_RECORDS_FIELD,`Invalid enum value for column '${e.name}'`,t)])}if(Gl(i)){const A=no(t);if(A===null)return new ue({value:E,type:T},[],[new en(N.INVALID_RECORDS_FIELD,`Invalid numeric value for column '${e.name}'`,t)]);if(qa(i)&&!Number.isInteger(A))return new ue({value:Math.floor(A),type:h},[],[new en(N.INVALID_RECORDS_FIELD,`Invalid integer value ${A} for column '${e.name}': expected integer, got decimal`,t)]);if(Xa(i)&&e.type.numericParams){const{precision:O,scale:F}=e.type.numericParams,H=A.toString().split("."),le=H[0].replace(/^-/,""),Me=H[1]||"",Xe=le.length+Me.length,at=Me.length;if(Xe>O)return new ue({value:A,type:h},[],[new en(N.INVALID_RECORDS_FIELD,`Numeric value ${A} for column '${e.name}' exceeds precision: expected at most ${O} total digits, got ${Xe}`,t)]);if(at>F)return new ue({value:A,type:h},[],[new en(N.INVALID_RECORDS_FIELD,`Numeric value ${A} for column '${e.name}' exceeds scale: expected at most ${F} decimal digits, got ${at}`,t)])}return new ue({value:A,type:h},[],[])}if(Ya(i)){const A=ro(t);return A===null?new ue({value:E,type:T},[],[new en(N.INVALID_RECORDS_FIELD,`Invalid boolean value for column '${e.name}'`,t)]):new ue({value:A,type:h},[],[])}if(Za(i)){const A=jl(t);return A===null?new ue({value:E,type:T},[],[new en(N.INVALID_RECORDS_FIELD,`Invalid datetime value for column '${e.name}', expected valid datetime format (e.g., 'YYYY-MM-DD', 'HH:MM:SS', 'YYYY-MM-DD HH:MM:SS', 'MM/DD/YYYY', 'D MMM YYYY', or 'MMM D, YYYY')`,t)]):new ue({value:A,type:h},[],[])}if(Ia(i)){const A=xa(t);if(A===null)return new ue({value:E,type:T},[],[new en(N.INVALID_RECORDS_FIELD,`Invalid string value for column '${e.name}'`,t)]);if(e.type.lengthParam){const{length:O}=e.type.lengthParam,F=new TextEncoder().encode(A).length;if(F>O)return new ue({value:A,type:h},[],[new en(N.INVALID_RECORDS_FIELD,`String value for column '${e.name}' exceeds maximum length: expected at most ${O} bytes (UTF-8), got ${F} bytes`,t)])}return new ue({value:A,type:"string"},[],[])}return new ue({value:E,type:T},[],[])}function ip(t){return{...t,fields:t.fields.map(e=>({...e,type:{...e.type,isEnum:void 0,lengthParam:void 0,numericParams:void 0}}))}}function nx(t){const e=[];for(const[n,i]of t.records){if(!i.length)continue;const a=Object.keys(i[0].columnNodes);e.push({schemaName:n.schemaName||void 0,tableName:n.name,columns:a,values:i.map(u=>a.map(l=>{const f=u.values[l];return f?{value:f.value,type:f.type}:{value:null,type:"expression"}}))})}return{schemas:[],tables:Array.from(t.tables.values()).map(ip),notes:Array.from(t.notes.values()),refs:Array.from(t.ref.values()),enums:Array.from(t.enums.values()),tableGroups:Array.from(t.tableGroups.values()),aliases:t.aliases,project:Array.from(t.project.values())[0]||{},tablePartials:Array.from(t.tablePartials.values()).map(ip),records:e}}class rx{constructor(e){this.ast=e,this.env={schema:[],tables:new Map,notes:new Map,refIds:{},ref:new Map,enums:new Map,tableOwnerGroup:{},tableGroups:new Map,aliases:[],project:new Map,tablePartials:new Map,records:new Map,recordsElements:[],cachedMergedTables:new Map,source:e.source}}interpret(){const e=this.ast.body.flatMap(i=>{switch(dt(i).unwrap_or(void 0)){case U.Table:return new am(i,this.env).interpret();case U.Note:return new OS(i,this.env).interpret();case U.Ref:return new om(i,this.env).interpret();case U.TableGroup:return new um(i,this.env).interpret();case U.TablePartial:return new cm(i,this.env).interpret();case U.Enum:return new lm(i,this.env).interpret();case U.Project:return new xS(i,this.env).interpret();case U.Records:return this.env.recordsElements.push(i),[];default:return[]}}),n=[];if(this.env.recordsElements.length){const i=new JO(this.env).interpret(this.env.recordsElements);e.push(...i.getErrors()),n.push(...i.getWarnings())}return new ue(nx(this.env),e,n)}}var ge=(t=>(t[t.Function=1]="Function",t[t.Constructor=2]="Constructor",t[t.Field=3]="Field",t[t.Variable=4]="Variable",t[t.Class=5]="Class",t[t.Struct=6]="Struct",t[t.Interface=7]="Interface",t[t.Module=8]="Module",t[t.Property=9]="Property",t[t.Event=10]="Event",t[t.Operator=11]="Operator",t[t.Unit=12]="Unit",t[t.Value=13]="Value",t[t.Constant=14]="Constant",t[t.Enum=15]="Enum",t[t.EnumMember=16]="EnumMember",t[t.Keyword=17]="Keyword",t[t.Text=18]="Text",t[t.Color=19]="Color",t[t.File=20]="File",t[t.Reference=21]="Reference",t[t.Customcolor=22]="Customcolor",t[t.Folder=23]="Folder",t[t.TypeParameter=24]="TypeParameter",t[t.User=25]="User",t[t.Issue=26]="Issue",t[t.Snippet=27]="Snippet",t))(ge||{}),Ie=(t=>(t[t.None=0]="None",t[t.KeepWhitespace=1]="KeepWhitespace",t[t.InsertAsSnippet=4]="InsertAsSnippet",t))(Ie||{}),Ra=(t=>(t[t.Hint=1]="Hint",t[t.Info=2]="Info",t[t.Warning=4]="Warning",t[t.Error=8]="Error",t))(Ra||{});function Ng(t){return t?t.split("").every(e=>us(e)||En(e))&&!En(t[0]):!1}function yg(t){return Ng(t)?t:`"${Ji(t)}"`}function vg(t){let e="",n=0;const i={n:`
|
|
31
|
+
`,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0","\\":"\\",'"':'"',"'":"'","`":"`"};for(;n<t.length;)if(t[n]==="\\"&&n+1<t.length){const a=t[n+1];if(a==="u"&&n+5<t.length){const u=t.slice(n+2,n+6);if(/^[0-9a-fA-F]{4}$/.test(u)){e+=String.fromCharCode(parseInt(u,16)),n+=6;continue}}a in i?(e+=i[a],n+=2):(e+=a,n+=2)}else e+=t[n],n++;return e}function Ji(t){let e="";for(let n=0;n<t.length;n++){const i=t[n];switch(i){case"\\":e+="\\\\";break;case'"':e+='\\"';break;case"'":e+="\\'";break;case`
|
|
32
|
+
`:e+="\\n";break;case" ":e+="\\t";break;case"\r":e+="\\r";break;case"\b":e+="\\b";break;case"\f":e+="\\f";break;case"\v":e+="\\v";break;case"\0":e+="\\0";break;default:e+=i}}return e}function ix(t){if(t==null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="number")return String(t);if(typeof t=="string")return`'${Ji(t)}'`;const{value:e,type:n}=t;if(e==null)return"null";if(n==="expression")return`\`${e}\``;if(Ya(n)){const a=ro(e);return a!==null?a?"true":"false":`\`${e}\``}if(Gl(n)){const a=no(e);return a!==null?String(a):`\`${e}\``}if(Za(n)){const a=jl(e);return a!==null?`'${Ji(a)}'`:`\`${e}\``}const i=xa(e);return i!==null?`'${Ji(i)}'`:`\`${e}\``}function _g(t){const e=/"(?:[^"\\]|\\.)*"|[^."]+/g;return(t.match(e)||[]).map(i=>{if(i.startsWith('"')&&i.endsWith('"')){const a=i.slice(1,-1);return vg(a)}return i.trim()}).filter(i=>i.length>0)}function as(t){switch(t){case M.Schema:return ge.Module;case M.Table:case M.TablePartial:return ge.Class;case M.Column:case M.TableGroupField:return ge.Field;case M.Enum:return ge.Enum;case M.EnumField:return ge.EnumMember;case M.TableGroup:return ge.Struct;default:return ge.Text}}function ka(t,e){if(!t||Xu(t))return!1;for(const n of t.trailingTrivia){if(n.start>e)break;if(n.kind===I.NEWLINE&&n.end<=e)return!1}return!0}function de(){return{suggestions:[]}}function Ma(t){return{...t,suggestions:t.suggestions.map(e=>({...e,insertText:` ${e.insertText}`}))}}function ms(t){return{...t,suggestions:t.suggestions.map(e=>({...e,insertText:e.quoted?e.insertText:yg(e.insertText??""),quoted:!0}))}}function hl(t,e=", "){const n=t.suggestions.map(i=>typeof i.label=="string"?i.label:i.label.label).join(e);return n?{...t,suggestions:[{label:"* (all)",insertText:n,insertTextRules:Ie.KeepWhitespace,kind:ge.Snippet,sortText:"00",range:void 0},...t.suggestions]}:t}function nc(t,e){return t<e.start||t>e.end?!1:e.body?t<e.body.start||t>e.body.end:!0}function dl(t){return t.commaList.length+t.elementList.length===0}function sx(t){const e=[];for(const[n,i]of t.symbolTable.entries()){const a=mi(n).unwrap_or(void 0);if(a===void 0||a.kind!==M.Column||!(i instanceof di||i instanceof pi))continue;const u=rc(i,a.name);u&&e.push(u)}return e}function rc(t,e){const n=Un(e),i=t instanceof pi?t.tablePartialSymbol.symbolTable.get(n)?.declaration:t.declaration;if(!(i instanceof z))return null;const a=ve(i.callee).unwrap_or(null),u=ve(i.args[0]).unwrap_or(null);return a===null||u===null?null:{name:a,type:u}}function ax(t,e,n,i){const a=t.container.element(i);return!(a instanceof re)||dt(a).unwrap_or(void 0)!==U.Records||!(a.body instanceof Ge)||!a.body||!sr(i,a.body)||e.getLineContent(n.lineNumber).trim()!==""?null:a.parent instanceof Ze?ox(t,a):ux(t,a)}function ox(t,e){if(!(e.name instanceof Se))return de();const n=e.name.argumentList?.elementList||[],i=n.map(l=>Ul(l));if(!i||i.length===0)return de();const a=n.map((l,f)=>{const h=i[f];if(!h||!(h instanceof di||h instanceof pi))return null;const m=ve(l).unwrap_or(void 0);return m?rc(h,m):null}).filter(l=>l!==null);return a.length===0?de():{suggestions:[{label:"Record row snippet",insertText:a.map((l,f)=>`\${${f+1}:${l.name} (${l.type})}`).join(", "),insertTextRules:Ie.InsertAsSnippet,kind:ge.Snippet,range:void 0}]}}function ux(t,e){const n=e.parent;if(!(n instanceof re))return de();const i=n.symbol;if(!(i instanceof oi))return de();let a;if(e.name instanceof ln){const l=e.name.elementList,f=l.map(h=>Ul(h)).filter(h=>h!==void 0);a=l.map((h,m)=>{const E=f[m];if(!E||!(E instanceof di||E instanceof pi))return null;const T=ve(h).unwrap_or(void 0);return T===void 0?null:rc(E,T)}).filter(h=>h!==null)}else{const l=sx(i);if(!l)return de();a=l}return a.length===0?de():{suggestions:[{label:"Record row snippet",insertText:a.map((l,f)=>`\${${f+1}:${l.name} (${l.type})}`).join(", "),insertTextRules:Ie.InsertAsSnippet,kind:ge.Snippet,range:void 0}]}}function ic(t,e){return t.getOffsetAt(e)}class bg{constructor(e,n=[]){this.compiler=e,this.triggerCharacters=n}provideCompletionItems(e,n){const i=ic(e,n),a=ax(this.compiler,e,n,i);if(a!==null)return a;const u=this.compiler.token.flatStream(),{token:l,index:f}=this.compiler.container.token(i),h=f===void 0?u[0]:u[f+1];if([...l?.trailingTrivia||[],...l?.leadingTrivia||[],...h?.leadingTrivia||[]].find(T=>DL(T)&&sr(i,T)))return de();if(f===void 0)return lp();if([I.STRING_LITERAL,I.QUOTED_STRING].includes(l.kind)&&sr(i,l))return de();const m=this.compiler.container.element(i);if(this.compiler.container.scopeKind(i)===se.TOPLEVEL||m instanceof re&&m.type&&m.type.start<=i&&m.type.end>=i)return lp();const E=[...this.compiler.container.stack(i)].reverse();for(const T of E)if(T instanceof ft)switch(T.op?.value){case">":case"<":case"<>":case"-":return sp(this.compiler,i,T);case"~":return lx(this.compiler,i)}else if(T instanceof on)switch(T.op?.value){case">":case"<":case"<>":case"-":return sp(this.compiler,i,T);case".":return wg(this.compiler,i,T)}else{if(T instanceof sn)return ap(this.compiler,i,T);if(T instanceof Le)return ap(this.compiler,i,T);if(T instanceof ln)return cx(this.compiler,i,T);if(T instanceof Fn)return fx(this.compiler,i);if(T instanceof Se)return Ag(this.compiler,i,T);if(T instanceof z)return up(this.compiler,i,T);if(T instanceof re){if(nc(i,T))return gx(this.compiler,i,T);if(T.bodyColon&&i>=T.bodyColon.end||T.body&&sr(i,T.body))return up(this.compiler,i,void 0)}}return de()}}function lx(t,e){return zn(t,e,t.parse.ast(),[M.TablePartial])}function sp(t,e,n){const i=t.container.scopeKind(e);if([se.REF,se.TABLE,se.TABLEPARTIAL].includes(i)){const a=zn(t,e,t.container.element(e),[M.Table,M.Schema,M.Column]);return ka(n.op,e)?Ma(a):a}return de()}function Pa(t,e,n){return ms({suggestions:t.symbol.members(e).filter(({kind:i})=>n.includes(i)).map(({name:i,kind:a})=>({label:i,insertText:i,insertTextRules:Ie.KeepWhitespace,kind:as(a),sortText:as(a).toString().padStart(2,"0"),range:void 0}))})}function zn(t,e,n,i){if(n===void 0)return de();let a=n;const u={suggestions:[]};for(;a;){if(a?.symbol?.symbolTable){const{symbol:l}=a;u.suggestions.push(...Pa(t,l,i).suggestions)}a=a instanceof re?a.parent:void 0}return ms(u)}function cx(t,e,n){const i=t.container.scopeKind(e),a=t.container.element(e),u=[...t.container.stack(e)];for(const l of u)if(l instanceof Se&&l.argumentList===n)return Ag(t,e,l);if(a instanceof re&&dt(a).unwrap_or(void 0)===U.Records&&!(a.name instanceof Se)&&nc(e,a)){const l=a.parent?.symbol||a.name?.referee;if(l){const f=Pa(t,l,[M.Column]);return dl(n)?hl(f):f}}switch(i){case se.INDEXES:return Lg(t,e);case se.REF:for(;u.length>0;){const l=u.pop();if(l instanceof on&&l.op?.value===".")return wg(t,e,l)}return Ig(t,e)}return de()}function fx(t,e){return t.container.scopeKind(e)===se.RECORDS?zn(t,e,t.container.element(e),[M.Schema,M.Enum,M.EnumField]):de()}function ap(t,e,n){const{token:i}=t.container.token(e);if([I.COMMA,I.LBRACKET].includes(i?.kind)){const a=op(t,e);return i?.kind===I.COMMA&&ka(i,e)?Ma(a):a}if(n.name&&n.name.start<=e&&n.name.end>=e)return op(t,e);if(n.name instanceof rn){const a=hx(t,e,rs(n.name).unwrap_or(""));return i?.kind===I.COLON&&ka(i,e)?Ma(a):a}return de()}function op(t,e){const n=t.container.element(e);if(n instanceof Ze)return de();const i=t.container.scopeKind(e);if(n.body&&!sr(e,n.body)){let a;switch(i){case se.TABLE:case se.TABLEPARTIAL:a=[k.HeaderColor,k.Note];break;case se.TABLEGROUP:a=[k.Color,k.Note];break;default:a=[]}return{suggestions:a.map(u=>({label:u,insertText:`${u}: `,kind:ge.Field,insertTextRules:Ie.KeepWhitespace,range:void 0}))}}switch(i){case se.TABLE:case se.TABLEPARTIAL:return{suggestions:[...[k.PK,k.PrimaryKey,k.Null,k.NotNull,k.Increment,k.Unique].map(a=>({label:a,insertText:a,kind:ge.Property,insertTextRules:Ie.KeepWhitespace,range:void 0})),...[k.Ref,k.Default,k.Note,k.Check].map(a=>({label:a,insertText:`${a}: `,kind:ge.Property,insertTextRules:Ie.KeepWhitespace,range:void 0}))]};case se.ENUM:return{suggestions:[...[k.Note].map(a=>({label:a,insertText:`${a}: `,kind:ge.Property,insertTextRules:Ie.KeepWhitespace,range:void 0}))]};case se.INDEXES:return{suggestions:[...[k.Unique,k.PK].map(a=>({label:a,insertText:a,insertTextRules:Ie.KeepWhitespace,kind:ge.Property,range:void 0})),...[k.Note,k.Name,k.Type].map(a=>({label:a,insertText:`${a}: `,kind:ge.Property,insertTextRules:Ie.KeepWhitespace,range:void 0}))]};case se.REF:return{suggestions:[k.Update,k.Delete,k.Color].map(a=>({label:a,insertText:`${a}: `,kind:ge.Property,insertTextRules:Ie.KeepWhitespace,range:void 0}))};case se.CHECKS:return{suggestions:[k.Name].map(a=>({label:a,insertText:`${a}: `,kind:ge.Property,insertTextRules:Ie.KeepWhitespace,range:void 0}))}}return de()}function hx(t,e,n){switch(n?.toLowerCase()){case"update":case"delete":return{suggestions:["cascade","set default","set null","restrict"].map(i=>({label:i,insertText:i,kind:ge.Value,insertTextRules:Ie.KeepWhitespace,range:void 0}))};case"type":return{suggestions:["btree","hash"].map(i=>({label:i,insertText:`${i}`,kind:ge.Value,insertTextRules:Ie.KeepWhitespace,range:void 0}))};case"default":return zn(t,e,t.container.element(e),[M.Schema,M.Enum])}return de()}function wg(t,e,n){const i=vn(n).unwrap_or([]);if(i.pop(),i.some(u=>!De(u)))return de();const a=i.map(u=>ve(u).unwrap());return ms({suggestions:t.symbol.ofName(a,t.container.element(e)).flatMap(({symbol:u})=>t.symbol.members(u)).map(({kind:u,name:l})=>({label:l,insertText:l,kind:as(u),range:void 0}))})}function up(t,e,n){switch(t.container.scopeKind(e)){case se.TABLE:case se.TABLEPARTIAL:return px(t,e,n);case se.PROJECT:return mx(t,e,n);case se.INDEXES:return Tx(t,e);case se.ENUM:return dx(t,e,n);case se.REF:{const a=Ig(t,e);return t.container.token(e).token?.kind===I.COLON&&ka(t.container.token(e).token,e)?Ma(a):a}case se.TABLEGROUP:return Ex(t);default:return de()}}function lp(){return{suggestions:["Table","TableGroup","Enum","Project","Ref","TablePartial","Records"].map(t=>({label:t,insertText:t,insertTextRules:Ie.KeepWhitespace,kind:ge.Keyword,range:void 0}))}}function dx(t,e,n){return n?.callee&&sc(e,n)===1?zn(t,e,t.container.element(e),[M.Schema,M.Table,M.Column]):de()}function px(t,e,n){const i=["Note","indexes","checks","Records"];if(!n?.callee)return{suggestions:i.map(u=>({label:u,insertText:u,insertTextRules:Ie.KeepWhitespace,kind:ge.Keyword,range:void 0}))};const a=sc(e,n);return a===0?{suggestions:i.map(u=>({label:u,insertText:u,insertTextRules:Ie.KeepWhitespace,kind:ge.Keyword,range:void 0}))}:a===1?Nx(t,e):de()}function mx(t,e,n){const i=["Table","TableGroup","Enum","Note","Ref","TablePartial"];return n?.callee?sc(e,n)===0?{suggestions:i.map(u=>({label:u,insertText:u,insertTextRules:Ie.KeepWhitespace,kind:ge.Keyword,range:void 0}))}:de():{suggestions:i.map(u=>({label:u,insertText:u,insertTextRules:Ie.KeepWhitespace,kind:ge.Keyword,range:void 0}))}}function Ig(t,e){return zn(t,e,t.container.element(e),[M.Schema,M.Table,M.Column])}function gx(t,e,n){return dt(n).unwrap_or(void 0)===U.Records?zn(t,e,n.parent,[M.Schema,M.Table]):de()}function Ag(t,e,n){const i=t.container.element(e),a=n.callee&&sr(e,n.callee),u=n.argumentList&&sr(e,n.argumentList);if(i instanceof re&&dt(i).unwrap_or(void 0)===U.Records&&nc(e,i)){if(a)return zn(t,e,i.parent,[M.Schema,M.Table]);if(!u)return de();const f=n.callee;if(!f)return de();const h=vn(f).unwrap_or([f]),E=h[h.length-1]?.referee;if(!E)return de();const T=Pa(t,E,[M.Column]),{argumentList:A}=n;return!A||!dl(A)?T:hl(T)}const l=[...t.container.stack(e)];for(const f of l){if(!u||!(f instanceof z)||f.callee!==n||ve(n.callee).unwrap_or("").toLowerCase()!==U.Records)continue;const h=t.container.element(e).symbol;if(!h)return de();const m=Pa(t,h,[M.Column]),{argumentList:E}=n;return!E||!dl(E)?m:hl(m)}return de()}function Ex(t){return{suggestions:[...ms({suggestions:[...t.parse.publicSymbolTable().entries()].flatMap(([e])=>{const n=mi(e).unwrap_or(void 0);if(n===void 0)return[];const{kind:i,name:a}=n;return i!==M.Table&&i!==M.Schema?[]:{label:a,insertText:a,insertTextRules:Ie.KeepWhitespace,kind:as(i),range:void 0}})}).suggestions,...["Note"].map(e=>({label:e,insertText:e,insertTextRules:Ie.KeepWhitespace,kind:ge.Keyword,range:void 0}))]}}function Tx(t,e){return Lg(t,e)}function Nx(t,e){return{suggestions:[...["integer","int","tinyint","smallint","mediumint","bigint","bit","bool","binary","varbinary","logical","char","nchar","varchar","varchar2","nvarchar","nvarchar2","binary_float","binary_double","float","double","decimal","dec","real","money","smallmoney","enum","tinyblob","tinytext","blob","text","mediumblob","mediumtext","longblob","longtext","ntext","set","inet6","uuid","image","date","time","datetime","datetime2","timestamp","year","smalldatetime","datetimeoffset","XML","sql_variant","uniqueidentifier","CURSOR","BFILE","CLOB","NCLOB","RAW"].map(n=>({label:n,insertText:n,insertTextRules:Ie.KeepWhitespace,kind:ge.TypeParameter,sortText:ge.TypeParameter.toString().padStart(2,"0"),range:void 0})),...zn(t,e,t.container.element(e),[M.Enum,M.Schema]).suggestions]}}function Lg(t,e){const i=t.container.element(e)?.parent;if(!(i?.symbol instanceof oi))return de();const{symbolTable:a}=i.symbol;return ms({suggestions:[...a.entries()].flatMap(([u])=>{const l=mi(u).unwrap_or(void 0);if(l===void 0)return[];const{name:f}=l;return{label:f,insertText:f,insertTextRules:Ie.KeepWhitespace,kind:as(M.Column),range:void 0}})})}function sc(t,e){if(!e.callee)return-1;const n=[e.callee,...e.args],i=n.findIndex(a=>t<=a.end);return i===-1?n.length:i}class Sg{constructor(e){this.compiler=e}provideDefinition(e,n){const{uri:i}=e,a=ic(e,n),u=[...this.compiler.container.stack(a)];for(;u.length!==0;){const l=u.pop();if(!l?.referee)continue;let f;if(l.referee?.declaration&&[wr.PRIMARY_EXPRESSION,wr.VARIABLE].includes(l?.kind)&&({declaration:f}=l.referee),f){const{startPos:h,endPos:m}=f;return[{range:{startColumn:h.column+1,startLineNumber:h.line+1,endColumn:m.column+1,endLineNumber:m.line+1},uri:i}]}}return[]}}class Og{constructor(e){this.compiler=e}provideReferences(e,n){const{uri:i}=e,a=ic(e,n),u=[...this.compiler.container.stack(a)];for(;u.length!==0;){const l=u.pop();if(l&&[wr.ELEMENT_DECLARATION,wr.FUNCTION_APPLICATION,wr.PRIMARY_EXPRESSION].includes(l?.kind)){const{symbol:f}=l;if(f?.references.length)return f.references.map(({startPos:h,endPos:m})=>({range:{startColumn:h.column+1,startLineNumber:h.line+1,endColumn:m.column+1,endLineNumber:m.line+1},uri:i}))}}return[]}}class xg{constructor(e){this.compiler=e}provideDiagnostics(){const e=[],n=this.compiler.parse._(),i=n.getErrors();for(const u of i)e.push(this.createDiagnostic(u,"error"));const a=n.getWarnings();for(const u of a)e.push(this.createDiagnostic(u,"warning"));return e}provideErrors(){return this.compiler.parse._().getErrors().map(n=>this.createDiagnostic(n,"error"))}provideWarnings(){return this.compiler.parse._().getWarnings().map(n=>this.createDiagnostic(n,"warning"))}provideMarkers(){return this.provideDiagnostics().map(n=>({severity:this.getSeverityValue(n.type),message:n.text,startLineNumber:n.startRow,startColumn:n.startColumn,endLineNumber:n.endRow,endColumn:n.endColumn,code:n.code?String(n.code):void 0}))}createDiagnostic(e,n){const a=e.nodeOrToken,u=a.startPos,l=a.endPos;return{type:n,text:e.diagnostic,startRow:u.line+1,startColumn:u.column+1,endRow:l.line+1,endColumn:l.column+1,code:e.code}}getSeverityValue(e){return e==="error"?Ra.Error:Ra.Warning}}const yx=Object.freeze(Object.defineProperty({__proto__:null,CompletionItemInsertTextRule:Ie,CompletionItemKind:ge,DBMLCompletionItemProvider:bg,DBMLDefinitionProvider:Sg,DBMLDiagnosticsProvider:xg,DBMLReferencesProvider:Og,MarkerSeverity:Ra},Symbol.toStringTag,{value:"Module"}));function vx(){return this.parse._().getValue().ast}function _x(){return this.parse._().getErrors()}function bx(){return this.parse._().getWarnings()}function wx(){return this.parse._().getValue().tokens}function Ix(){return this.parse._().getValue().rawDb}function Ax(){return this.parse._().getValue().ast.symbol.symbolTable}function Lx(){return this.parse.tokens().flatMap(t=>[...t.leadingInvalid,t,...t.trailingInvalid])}function Sx(){return this.parse.tokens().filter(Ku)}function Ox(t){return t.symbolTable?[...t.symbolTable.entries()].map(([e,n])=>({...mi(e).unwrap(),symbol:n})):[]}function xx(t,e){if(t.length===0)return[];const n=[];for(let i=e;i;i=i instanceof re?i.parent:void 0){if(!i.symbol?.symbolTable)continue;const{symbolTable:a}=i.symbol;let u=[a],l=[];for(const f of t)l=u.flatMap(h=>_S(f).flatMap(m=>{const E=h.get(m),T=mi(m).unwrap_or(void 0);return!E||!T?[]:{...T,symbol:E}})),u=l.flatMap(h=>h.symbol.symbolTable?h.symbol.symbolTable:[]);n.push(...l)}return n}function Dx(t,e){return`${t.join(".")}@${e.id}`}function Rx(t){const e=this.token.flatStream(),{index:n,token:i}=this.container.token(t),a=n===void 0?-1:hL(e,h=>!h.isInvalid,n);if(a===-1)return[this.parse.ast()];const u=e[a].start;let l=this.parse.ast();const f=[l];for(;;){const m=tS(l).find(E=>sr(u,E));if(m===void 0||m instanceof Tt)break;f.push(m),l=m}if(i?.kind===I.COLON)return f;for(;f.length>0;){let h=!1;const m=Oe(f);if(m instanceof z){const E=this.parse.source();for(let T=m.end;T<t;T+=1)E[T]===`
|
|
33
|
+
`&&(f.pop(),h=!0)}else m instanceof ft||m instanceof on?this.container.token(t).token!==m.op&&(f.pop(),h=!0):m instanceof Le?m.listCloseBracket&&m.end<=t&&(f.pop(),h=!0):m instanceof ln?m.tupleCloseParen&&m.end<=t&&(f.pop(),h=!0):m instanceof Fn?m.end<=t&&(f.pop(),h=!0):m instanceof Ge?m.blockCloseBrace&&m.end<=t&&(f.pop(),h=!0):m instanceof rn||m.end<t&&(f.pop(),h=!0);if(h){const E=Oe(f);E instanceof re&&E.end<=t&&f.pop()}if(!h)break}return f}function kx(t){const e=this.token.flatStream().findIndex(n=>n.start>=t);return e===void 0?{token:void 0,index:void 0}:e<=0?{token:void 0,index:void 0}:{token:this.token.flatStream()[e-1],index:e-1}}function Mx(t){const e=this.container.stack(t);for(let n=e.length-1;n>=0;n-=1)if(e[n]instanceof re)return e[n];return this.parse.ast()}function Px(t){return this.container.element(t)?.symbol?.symbolTable}var se=(t=>(t[t.TABLE=0]="TABLE",t[t.ENUM=1]="ENUM",t[t.TABLEGROUP=2]="TABLEGROUP",t[t.INDEXES=3]="INDEXES",t[t.NOTE=4]="NOTE",t[t.REF=5]="REF",t[t.PROJECT=6]="PROJECT",t[t.CUSTOM=7]="CUSTOM",t[t.TOPLEVEL=8]="TOPLEVEL",t[t.TABLEPARTIAL=9]="TABLEPARTIAL",t[t.CHECKS=10]="CHECKS",t[t.RECORDS=11]="RECORDS",t))(se||{});function Cx(t){const e=this.container.element(t);if(e instanceof Ze)return se.TOPLEVEL;switch(e.type?.value.toLowerCase()){case"table":return se.TABLE;case"enum":return se.ENUM;case"ref":return se.REF;case"tablegroup":return se.TABLEGROUP;case"indexes":return se.INDEXES;case"note":return se.NOTE;case"project":return se.PROJECT;case"tablepartial":return se.TABLEPARTIAL;case"checks":return se.CHECKS;case"records":return se.RECORDS;default:return se.CUSTOM}}function Dg(t,e){const n=[...e].sort((a,u)=>u.start-a.start);let i=t;for(const{start:a,end:u,newText:l}of n)i=i.substring(0,a)+l+i.substring(u);return i}function cp(t){if(typeof t!="string")return{schema:t.schema??Wt,table:t.table};const e=_g(t);if(e.length===0)return{schema:Wt,table:""};if(e.length===1)return{schema:Wt,table:e[0]};if(e.length===2)return{schema:e[0],table:e[1]};const n=e[e.length-1];return{schema:e.slice(0,-1).join("."),table:n}}function Fx(t,e,n){const i=ui(n);if(e===Wt){const f=t.get(i);return f instanceof oi?f:null}const a=ls(e),u=t.get(a);if(!u||!u.symbolTable)return null;const l=u.symbolTable.get(i);return l instanceof oi?l:null}function Ux(t){return t.startsWith('"')&&t.endsWith('"')&&t.length>=2?t.slice(1,-1):t}function fp(t){return t?t.split("").every(e=>us(e)||En(e))&&!En(t[0]):!1}function Vx(t,e){if(!t.declaration)return!1;const n=t.declaration;if(!n.name)return!1;const i=n.name;return e.substring(i.start,i.end).includes('"')}function Bx(t,e,n){const i=!fp(e),a=!fp(t),u=n||i,l=n||a;return{schema:t,table:e,formattedSchema:l?`"${t}"`:t,formattedTable:u?`"${e}"`:e,shouldQuoteSchema:l,shouldQuoteTable:u}}function $x(t,e,n,i,a){const u=ui(a);let l;if(i===Wt)l=t.get(u);else{const f=ls(i),h=t.get(f);if(!h||!h.symbolTable)return!1;l=h.symbolTable.get(u)}return!(!l||e===i&&n===a)}function Gx(t,e,n){let i=t.start-1;for(;i>=0&&/\s/.test(n[i]);)i--;if(i<0||n[i]!==".")return null;for(i--;i>=0&&/\s/.test(n[i]);)i--;if(i<0)return null;let a,u;if(n[i]==='"'){for(u=i+1,i--;i>=0&&n[i]!=='"';)i--;if(i<0)return null;a=i}else{for(u=i+1;i>=0&&/[a-zA-Z0-9_]/.test(n[i]);)i--;a=i+1}const l=n.substring(a,u);return Ux(l)===e?{start:a,end:t.end}:null}function Wx(t,e,n,i){const a=[],u=new Set;for(const l of t){const h=Gx(l,e,i)??{start:l.start,end:l.end},m=`${h.start}-${h.end}`;if(u.has(m))continue;u.add(m);const E=n.schema!==Wt?`${n.formattedSchema}.${n.formattedTable}`:n.formattedTable;a.push({start:h.start,end:h.end,newText:E})}return a}function Hx(t,e){const n=this.parse.source(),i=this.parse.publicSymbolTable(),a=cp(t),u=cp(e),l=a.schema,f=a.table,h=u.schema,m=u.table,E=Fx(i,l,f);if(!E||$x(i,l,f,h,m))return n;const T=Vx(E,n),A=Bx(h,m,T),O=[];if(E.declaration){const G=E.declaration;G.name&&O.push(G.name)}for(const G of E.references)n.substring(G.start,G.end).replace(/"/g,"")===f&&O.push(G);const F=Wx(O,l,A,n);return Dg(n,F)}class zx{constructor(){this.source="",this.cache=new Map,this.nodeIdGenerator=new RL,this.symbolIdGenerator=new kL,this.token={invalidStream:this.query(Sx),flatStream:this.query(Lx)},this.parse={source:()=>this.source,_:this.query(this.interpret),ast:this.query(vx),errors:this.query(_x),warnings:this.query(bx),tokens:this.query(wx),rawDb:this.query(Ix),publicSymbolTable:this.query(Ax)},this.container={stack:this.query(Rx),token:this.query(kx),element:this.query(Mx),scope:this.query(Px),scopeKind:this.query(Cx)},this.symbol={ofName:this.query(xx,Dx),members:this.query(Ox)}}setSource(e){this.source=e,this.cache.clear(),this.nodeIdGenerator.reset(),this.symbolIdGenerator.reset()}query(e,n){const i=Symbol();return(...a)=>{if(a.length===0){if(this.cache.has(i))return this.cache.get(i);const h=e.apply(this,a);return this.cache.set(i,h),h}const u=n?n(...a):a[0];let l=this.cache.get(i);if(l instanceof Map&&l.has(u))return l.get(u);const f=e.apply(this,a);return l instanceof Map||(l=new Map,this.cache.set(i,l)),l.set(u,f),f}}interpret(){const e=new nS(this.source).lex().chain(n=>new sS(this.source,n,this.nodeIdGenerator).parse()).chain(({ast:n,tokens:i})=>new LS(n,this.symbolIdGenerator).analyze().map(()=>({ast:n,tokens:i})));return e.getErrors().length>0?e:e.chain(({ast:n,tokens:i})=>new rx(n).interpret().map(a=>({ast:n,tokens:i,rawDb:a})))}renameTable(e,n){return Hx.call(this,e,n)}applyTextEdits(e){return Dg(this.parse.source(),e)}initMonacoServices(){return{definitionProvider:new Sg(this),referenceProvider:new Og(this),autocompletionProvider:new bg(this),diagnosticsProvider:new xg(this)}}}exports.CompileError=v;exports.CompileErrorCode=N;exports.Compiler=zx;exports.ElementDeclarationNode=re;exports.ElementKind=U;exports.FALSY_VALUES=cl;exports.ProgramNode=Ze;exports.ScopeKind=se;exports.SyntaxNode=xe;exports.SyntaxNodeKind=wr;exports.SyntaxToken=Tt;exports.SyntaxTokenKind=I;exports.TRUTHY_VALUES=ll;exports.addDoubleQuoteIfNeeded=yg;exports.escapeString=Ji;exports.extractNumericLiteral=Or;exports.extractSignedNumber=Jl;exports.formatRecordValue=ix;exports.getLengthTypeParam=kS;exports.getNumericTypeParams=RS;exports.getRecordValueType=hm;exports.isBinaryType=DS;exports.isBooleanType=Ya;exports.isDateTimeType=Za;exports.isEmptyStringLiteral=mg;exports.isFloatType=Xa;exports.isFunctionExpression=RO;exports.isIntegerType=qa;exports.isNullish=pg;exports.isNumericType=Gl;exports.isSerialType=Ka;exports.isStringType=Ia;exports.isValidIdentifier=Ng;exports.normalizeTypeName=Hn;exports.services=yx;exports.splitQualifiedIdentifier=_g;exports.tryExtractBoolean=ro;exports.tryExtractDateTime=jl;exports.tryExtractEnum=MO;exports.tryExtractInteger=kO;exports.tryExtractNumeric=no;exports.tryExtractString=xa;exports.unescapeString=vg;exports.validateForeignKeys=Tg;exports.validatePrimaryKey=gg;exports.validateUnique=Eg;
|