@dbml/parse 6.2.0-alpha.0 → 6.2.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__/utils/compiler.d.ts +5 -5
- package/dist/__tests__/utils/mocks.d.ts +0 -1
- package/dist/__tests__/utils/testHelpers.d.ts +2 -2
- package/dist/dbml-parse.js +12 -33
- package/dist/dbml-parse.mjs +5297 -17115
- package/dist/src/compiler/index.d.ts +4 -8
- package/dist/src/compiler/queries/parse.d.ts +1 -2
- package/dist/src/compiler/queries/transform/index.d.ts +1 -2
- package/dist/src/compiler/queries/transform/renameTable.d.ts +4 -1
- package/dist/src/compiler/types.d.ts +1 -2
- package/dist/src/core/analyzer/analyzer.d.ts +3 -2
- package/dist/src/core/analyzer/binder/binder.d.ts +2 -1
- package/dist/src/core/analyzer/binder/utils.d.ts +1 -2
- package/dist/src/core/analyzer/types.d.ts +1 -2
- package/dist/src/core/analyzer/utils.d.ts +1 -11
- package/dist/src/core/analyzer/validator/utils.d.ts +3 -3
- package/dist/src/core/analyzer/validator/validator.d.ts +2 -1
- package/dist/src/core/errors.d.ts +1 -15
- package/dist/src/core/interpreter/interpreter.d.ts +2 -1
- package/dist/src/core/interpreter/types.d.ts +2 -39
- package/dist/src/core/interpreter/utils.d.ts +3 -4
- package/dist/src/core/lexer/lexer.d.ts +2 -1
- package/dist/src/core/parser/nodes.d.ts +6 -17
- package/dist/src/core/parser/parser.d.ts +4 -6
- package/dist/src/core/parser/utils.d.ts +3 -3
- package/dist/src/core/report.d.ts +5 -8
- package/dist/src/core/serialization/serialize.d.ts +4 -0
- package/dist/src/core/utils.d.ts +1 -0
- package/dist/src/index.d.ts +4 -3
- package/dist/src/services/index.d.ts +1 -2
- package/dist/src/services/suggestions/utils.d.ts +1 -27
- package/dist/src/services/types.d.ts +2 -13
- package/package.json +6 -18
- package/dist/__tests__/examples/compiler/stringUtils.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/data.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/fk.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/increment.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/multi_records.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/pk.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/table_partial.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/type_compatibility.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/unique.test.d.ts +0 -1
- package/dist/__tests__/examples/lexer/scientific-notation.test.d.ts +0 -1
- package/dist/__tests__/examples/services/definition/general.test.d.ts +0 -1
- package/dist/__tests__/examples/services/definition/records.test.d.ts +0 -1
- package/dist/__tests__/examples/services/references/general.test.d.ts +0 -1
- package/dist/__tests__/examples/services/references/records.test.d.ts +0 -1
- package/dist/__tests__/examples/services/suggestions/general.test.d.ts +0 -1
- package/dist/__tests__/examples/services/suggestions/suggestions_records.test.d.ts +0 -1
- package/dist/__tests__/examples/validator/records.test.d.ts +0 -1
- package/dist/src/compiler/queries/transform/utils.d.ts +0 -22
- package/dist/src/compiler/queries/utils.d.ts +0 -95
- package/dist/src/core/analyzer/binder/elementBinder/records.d.ts +0 -22
- package/dist/src/core/analyzer/validator/elementValidators/records.d.ts +0 -26
- package/dist/src/core/interpreter/records/index.d.ts +0 -10
- package/dist/src/core/interpreter/records/utils/constraints/fk.d.ts +0 -3
- package/dist/src/core/interpreter/records/utils/constraints/helper.d.ts +0 -10
- package/dist/src/core/interpreter/records/utils/constraints/index.d.ts +0 -3
- package/dist/src/core/interpreter/records/utils/constraints/pk.d.ts +0 -3
- package/dist/src/core/interpreter/records/utils/constraints/unique.d.ts +0 -3
- package/dist/src/core/interpreter/records/utils/data/index.d.ts +0 -2
- package/dist/src/core/interpreter/records/utils/data/sqlTypes.d.ts +0 -19
- package/dist/src/core/interpreter/records/utils/data/values.d.ts +0 -14
- package/dist/src/core/interpreter/records/utils/index.d.ts +0 -2
- package/dist/src/services/diagnostics/provider.d.ts +0 -34
- package/dist/src/services/suggestions/recordRowSnippet.d.ts +0 -3
- /package/dist/__tests__/examples/{binder/records.test.d.ts → services/definition.test.d.ts} +0 -0
- /package/dist/__tests__/examples/{compiler/identifierUtils.test.d.ts → services/references.test.d.ts} +0 -0
- /package/dist/__tests__/examples/{compiler/splitQualifiedIdentifier.test.d.ts → services/suggestions.test.d.ts} +0 -0
package/dist/dbml-parse.js
CHANGED
|
@@ -1,33 +1,12 @@
|
|
|
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
|
|
3
|
-
`:this.addToken(
|
|
4
|
-
`))&&!this.check(
|
|
5
|
-
`)&&!
|
|
6
|
-
`,{allowNewline:!0,allowEof:!0,raw:!0,consumeStopSequence:!1})}multilineComment(){this.consumeUntil(
|
|
7
|
-
`)&&this.advance()
|
|
8
|
-
`: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 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
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
function print() { __p += __j.call(arguments, '') }
|
|
26
|
-
`:`;
|
|
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;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n&&e(r,Symbol.toStringTag,{value:`Module`}),r},n=typeof global==`object`&&global&&global.Object===Object&&global,r=n,i=typeof self==`object`&&self&&self.Object===Object&&self,a=r||i||Function(`return this`)(),o=a,s=o.Symbol,c=s,l=Object.prototype,u=l.hasOwnProperty,d=l.toString,f=c?c.toStringTag:void 0;function ee(e){var t=u.call(e,f),n=e[f];try{e[f]=void 0;var r=!0}catch{}var i=d.call(e);return r&&(t?e[f]=n:delete e[f]),i}var te=ee,ne=Object.prototype.toString;function re(e){return ne.call(e)}var ie=re,ae=`[object Null]`,oe=`[object Undefined]`,se=c?c.toStringTag:void 0;function ce(e){return e==null?e===void 0?oe:ae:se&&se in Object(e)?te(e):ie(e)}var le=ce;function ue(e){return typeof e==`object`&&!!e}var de=ue,fe=`[object Symbol]`;function pe(e){return typeof e==`symbol`||de(e)&&le(e)==fe}var me=pe;function he(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var ge=he,_e=Array.isArray,ve=_e,ye=1/0,be=c?c.prototype:void 0,xe=be?be.toString:void 0;function Se(e){if(typeof e==`string`)return e;if(ve(e))return ge(e,Se)+``;if(me(e))return xe?xe.call(e):``;var t=e+``;return t==`0`&&1/e==-ye?`-0`:t}var Ce=Se,we=/\s/;function Te(e){for(var t=e.length;t--&&we.test(e.charAt(t)););return t}var Ee=Te,De=/^\s+/;function Oe(e){return e&&e.slice(0,Ee(e)+1).replace(De,``)}var ke=Oe;function Ae(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var je=Ae,Me=NaN,Ne=/^[-+]0x[0-9a-f]+$/i,Pe=/^0b[01]+$/i,Fe=/^0o[0-7]+$/i,Ie=parseInt;function Le(e){if(typeof e==`number`)return e;if(me(e))return Me;if(je(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=je(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=ke(e);var n=Pe.test(e);return n||Fe.test(e)?Ie(e.slice(2),n?2:8):Ne.test(e)?Me:+e}var Re=Le,ze=1/0,Be=17976931348623157e292;function Ve(e){return e?(e=Re(e),e===ze||e===-ze?(e<0?-1:1)*Be:e===e?e:0):e===0?e:0}var He=Ve;function Ue(e){var t=He(e),n=t%1;return t===t?n?t-n:t:0}var We=Ue;function Ge(e){return e}var Ke=Ge,qe=`[object AsyncFunction]`,Je=`[object Function]`,Ye=`[object GeneratorFunction]`,Xe=`[object Proxy]`;function Ze(e){if(!je(e))return!1;var t=le(e);return t==Je||t==Ye||t==qe||t==Xe}var Qe=Ze,$e=o[`__core-js_shared__`],et=$e,tt=function(){var e=/[^.]+$/.exec(et&&et.keys&&et.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function nt(e){return!!tt&&tt in e}var rt=nt,it=Function.prototype.toString;function at(e){if(e!=null){try{return it.call(e)}catch{}try{return e+``}catch{}}return``}var ot=at,st=/[\\^$.*+?()[\]{}|]/g,ct=/^\[object .+?Constructor\]$/,lt=Function.prototype,ut=Object.prototype,dt=lt.toString,ft=ut.hasOwnProperty,pt=RegExp(`^`+dt.call(ft).replace(st,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function mt(e){return!je(e)||rt(e)?!1:(Qe(e)?pt:ct).test(ot(e))}var ht=mt;function gt(e,t){return e?.[t]}var _t=gt;function vt(e,t){var n=_t(e,t);return ht(n)?n:void 0}var yt=vt,bt=yt(o,`WeakMap`),xt=bt;function St(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}var Ct=St,wt=800,Tt=16,Et=Date.now;function Dt(e){var t=0,n=0;return function(){var r=Et(),i=Tt-(r-n);if(n=r,i>0){if(++t>=wt)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Ot=Dt;function kt(e){return function(){return e}}var At=kt,jt=function(){try{var e=yt(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),Mt=jt,Nt=Mt?function(e,t){return Mt(e,`toString`,{configurable:!0,enumerable:!1,value:At(t),writable:!0})}:Ke,Pt=Nt,Ft=Ot(Pt),It=Ft;function Lt(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}var Rt=Lt,zt=9007199254740991,Bt=/^(?:0|[1-9]\d*)$/;function Vt(e,t){var n=typeof e;return t??=zt,!!t&&(n==`number`||n!=`symbol`&&Bt.test(e))&&e>-1&&e%1==0&&e<t}var Ht=Vt;function Ut(e,t){return e===t||e!==e&&t!==t}var Wt=Ut,Gt=Math.max;function Kt(e,t,n){return t=Gt(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,a=Gt(r.length-t,0),o=Array(a);++i<a;)o[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(o),Ct(e,this,s)}}var qt=Kt;function Jt(e,t){return It(qt(e,t,Ke),e+``)}var Yt=Jt,Xt=9007199254740991;function Zt(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=Xt}var Qt=Zt;function $t(e){return e!=null&&Qt(e.length)&&!Qe(e)}var en=$t,tn=Object.prototype;function nn(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||tn)}var rn=nn;function an(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var on=an,sn=`[object Arguments]`;function cn(e){return de(e)&&le(e)==sn}var ln=cn,un=Object.prototype,dn=un.hasOwnProperty,fn=un.propertyIsEnumerable,pn=ln(function(){return arguments}())?ln:function(e){return de(e)&&dn.call(e,`callee`)&&!fn.call(e,`callee`)},mn=pn;function hn(){return!1}var gn=hn,_n=typeof exports==`object`&&exports&&!exports.nodeType&&exports,vn=_n&&typeof module==`object`&&module&&!module.nodeType&&module,yn=vn&&vn.exports===_n?o.Buffer:void 0,bn=(yn?yn.isBuffer:void 0)||gn,xn=bn,Sn=`[object Arguments]`,Cn=`[object Array]`,wn=`[object Boolean]`,Tn=`[object Date]`,En=`[object Error]`,Dn=`[object Function]`,On=`[object Map]`,kn=`[object Number]`,An=`[object Object]`,jn=`[object RegExp]`,Mn=`[object Set]`,Nn=`[object String]`,Pn=`[object WeakMap]`,Fn=`[object ArrayBuffer]`,In=`[object DataView]`,Ln=`[object Float32Array]`,Rn=`[object Float64Array]`,zn=`[object Int8Array]`,Bn=`[object Int16Array]`,Vn=`[object Int32Array]`,Hn=`[object Uint8Array]`,Un=`[object Uint8ClampedArray]`,Wn=`[object Uint16Array]`,Gn=`[object Uint32Array]`,p={};p[Ln]=p[Rn]=p[zn]=p[Bn]=p[Vn]=p[Hn]=p[Un]=p[Wn]=p[Gn]=!0,p[Sn]=p[Cn]=p[Fn]=p[wn]=p[In]=p[Tn]=p[En]=p[Dn]=p[On]=p[kn]=p[An]=p[jn]=p[Mn]=p[Nn]=p[Pn]=!1;function Kn(e){return de(e)&&Qt(e.length)&&!!p[le(e)]}var qn=Kn;function Jn(e){return function(t){return e(t)}}var Yn=Jn,Xn=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Zn=Xn&&typeof module==`object`&&module&&!module.nodeType&&module,Qn=Zn&&Zn.exports===Xn&&r.process,$n=function(){try{return Zn&&Zn.require&&Zn.require(`util`).types||Qn&&Qn.binding&&Qn.binding(`util`)}catch{}}(),er=$n,tr=er&&er.isTypedArray,nr=tr?Yn(tr):qn,rr=nr,ir=Object.prototype.hasOwnProperty;function ar(e,t){var n=ve(e),r=!n&&mn(e),i=!n&&!r&&xn(e),a=!n&&!r&&!i&&rr(e),o=n||r||i||a,s=o?on(e.length,String):[],c=s.length;for(var l in e)(t||ir.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||Ht(l,c)))&&s.push(l);return s}var or=ar;function sr(e,t){return function(n){return e(t(n))}}var cr=sr,lr=cr(Object.keys,Object),ur=lr,dr=Object.prototype.hasOwnProperty;function fr(e){if(!rn(e))return ur(e);var t=[];for(var n in Object(e))dr.call(e,n)&&n!=`constructor`&&t.push(n);return t}var pr=fr;function mr(e){return en(e)?or(e):pr(e)}var hr=mr;function gr(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var _r=gr,vr=Object.prototype.hasOwnProperty;function yr(e){if(!je(e))return _r(e);var t=rn(e),n=[];for(var r in e)r==`constructor`&&(t||!vr.call(e,r))||n.push(r);return n}var br=yr;function xr(e){return en(e)?or(e,!0):br(e)}var Sr=xr,Cr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,wr=/^\w*$/;function Tr(e,t){if(ve(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||me(e)?!0:wr.test(e)||!Cr.test(e)||t!=null&&e in Object(t)}var Er=Tr,Dr=yt(Object,`create`),Or=Dr;function kr(){this.__data__=Or?Or(null):{},this.size=0}var Ar=kr;function jr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Mr=jr,Nr=`__lodash_hash_undefined__`,Pr=Object.prototype.hasOwnProperty;function Fr(e){var t=this.__data__;if(Or){var n=t[e];return n===Nr?void 0:n}return Pr.call(t,e)?t[e]:void 0}var Ir=Fr,Lr=Object.prototype.hasOwnProperty;function Rr(e){var t=this.__data__;return Or?t[e]!==void 0:Lr.call(t,e)}var zr=Rr,Br=`__lodash_hash_undefined__`;function Vr(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Or&&t===void 0?Br:t,this}var Hr=Vr;function Ur(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Ur.prototype.clear=Ar,Ur.prototype.delete=Mr,Ur.prototype.get=Ir,Ur.prototype.has=zr,Ur.prototype.set=Hr;var Wr=Ur;function Gr(){this.__data__=[],this.size=0}var Kr=Gr;function qr(e,t){for(var n=e.length;n--;)if(Wt(e[n][0],t))return n;return-1}var Jr=qr,Yr=Array.prototype.splice;function Xr(e){var t=this.__data__,n=Jr(t,e);return n<0?!1:(n==t.length-1?t.pop():Yr.call(t,n,1),--this.size,!0)}var Zr=Xr;function Qr(e){var t=this.__data__,n=Jr(t,e);return n<0?void 0:t[n][1]}var $r=Qr;function ei(e){return Jr(this.__data__,e)>-1}var ti=ei;function ni(e,t){var n=this.__data__,r=Jr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var ri=ni;function ii(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ii.prototype.clear=Kr,ii.prototype.delete=Zr,ii.prototype.get=$r,ii.prototype.has=ti,ii.prototype.set=ri;var ai=ii,oi=yt(o,`Map`),si=oi;function ci(){this.size=0,this.__data__={hash:new Wr,map:new(si||ai),string:new Wr}}var li=ci;function ui(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}var di=ui;function fi(e,t){var n=e.__data__;return di(t)?n[typeof t==`string`?`string`:`hash`]:n.map}var pi=fi;function mi(e){var t=pi(this,e).delete(e);return this.size-=t?1:0,t}var hi=mi;function gi(e){return pi(this,e).get(e)}var _i=gi;function vi(e){return pi(this,e).has(e)}var yi=vi;function bi(e,t){var n=pi(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}var xi=bi;function Si(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Si.prototype.clear=li,Si.prototype.delete=hi,Si.prototype.get=_i,Si.prototype.has=yi,Si.prototype.set=xi;var Ci=Si,wi=`Expected a function`;function Ti(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(wi);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(Ti.Cache||Ci),n}Ti.Cache=Ci;var Ei=Ti,Di=500;function Oi(e){var t=Ei(e,function(e){return n.size===Di&&n.clear(),e}),n=t.cache;return t}var ki=Oi,Ai=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ji=/\\(\\)?/g,Mi=ki(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(Ai,function(e,n,r,i){t.push(r?i.replace(ji,`$1`):n||e)}),t}),Ni=Mi;function Pi(e){return e==null?``:Ce(e)}var Fi=Pi;function Ii(e,t){return ve(e)?e:Er(e,t)?[e]:Ni(Fi(e))}var Li=Ii,Ri=1/0;function zi(e){if(typeof e==`string`||me(e))return e;var t=e+``;return t==`0`&&1/e==-Ri?`-0`:t}var Bi=zi;function Vi(e,t){t=Li(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[Bi(t[n++])];return n&&n==r?e:void 0}var Hi=Vi;function Ui(e,t,n){var r=e==null?void 0:Hi(e,t);return r===void 0?n:r}var Wi=Ui;function Gi(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var Ki=Gi,qi=c?c.isConcatSpreadable:void 0;function Ji(e){return ve(e)||mn(e)||!!(qi&&e&&e[qi])}var Yi=Ji;function Xi(e,t,n,r,i){var a=-1,o=e.length;for(n||=Yi,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?Xi(s,t-1,n,r,i):Ki(i,s):r||(i[i.length]=s)}return i}var Zi=Xi;function Qi(e){return e!=null&&e.length?Zi(e,1):[]}var $i=Qi;function ea(){this.__data__=new ai,this.size=0}var ta=ea;function na(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}var ra=na;function ia(e){return this.__data__.get(e)}var aa=ia;function oa(e){return this.__data__.has(e)}var sa=oa,ca=200;function la(e,t){var n=this.__data__;if(n instanceof ai){var r=n.__data__;if(!si||r.length<ca-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Ci(r)}return n.set(e,t),this.size=n.size,this}var ua=la;function da(e){this.size=(this.__data__=new ai(e)).size}da.prototype.clear=ta,da.prototype.delete=ra,da.prototype.get=aa,da.prototype.has=sa,da.prototype.set=ua;var fa=da;function pa(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}var ma=pa;function ha(){return[]}var ga=ha,_a=Object.prototype.propertyIsEnumerable,va=Object.getOwnPropertySymbols,ya=va?function(e){return e==null?[]:(e=Object(e),ma(va(e),function(t){return _a.call(e,t)}))}:ga,ba=ya;function xa(e,t,n){var r=t(e);return ve(e)?r:Ki(r,n(e))}var Sa=xa;function Ca(e){return Sa(e,hr,ba)}var wa=Ca,Ta=yt(o,`DataView`),Ea=Ta,Da=yt(o,`Promise`),Oa=Da,ka=yt(o,`Set`),Aa=ka,ja=`[object Map]`,Ma=`[object Object]`,Na=`[object Promise]`,Pa=`[object Set]`,Fa=`[object WeakMap]`,Ia=`[object DataView]`,La=ot(Ea),Ra=ot(si),za=ot(Oa),Ba=ot(Aa),Va=ot(xt),Ha=le;(Ea&&Ha(new Ea(new ArrayBuffer(1)))!=Ia||si&&Ha(new si)!=ja||Oa&&Ha(Oa.resolve())!=Na||Aa&&Ha(new Aa)!=Pa||xt&&Ha(new xt)!=Fa)&&(Ha=function(e){var t=le(e),n=t==Ma?e.constructor:void 0,r=n?ot(n):``;if(r)switch(r){case La:return Ia;case Ra:return ja;case za:return Na;case Ba:return Pa;case Va:return Fa}return t});var Ua=Ha,Wa=o.Uint8Array,Ga=Wa,Ka=`__lodash_hash_undefined__`;function qa(e){return this.__data__.set(e,Ka),this}var Ja=qa;function Ya(e){return this.__data__.has(e)}var Xa=Ya;function Za(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Ci;++t<n;)this.add(e[t])}Za.prototype.add=Za.prototype.push=Ja,Za.prototype.has=Xa;var Qa=Za;function $a(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var eo=$a;function to(e,t){return e.has(t)}var no=to,ro=1,io=2;function ao(e,t,n,r,i,a){var o=n&ro,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,ee=n&io?new Qa:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var te=e[d],ne=t[d];if(r)var re=o?r(ne,te,d,t,e,a):r(te,ne,d,e,t,a);if(re!==void 0){if(re)continue;f=!1;break}if(ee){if(!eo(t,function(e,t){if(!no(ee,t)&&(te===e||i(te,e,n,r,a)))return ee.push(t)})){f=!1;break}}else if(!(te===ne||i(te,ne,n,r,a))){f=!1;break}}return a.delete(e),a.delete(t),f}var oo=ao;function so(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}var co=so;function lo(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var uo=lo,fo=1,po=2,mo=`[object Boolean]`,ho=`[object Date]`,go=`[object Error]`,_o=`[object Map]`,vo=`[object Number]`,yo=`[object RegExp]`,bo=`[object Set]`,xo=`[object String]`,So=`[object Symbol]`,Co=`[object ArrayBuffer]`,wo=`[object DataView]`,To=c?c.prototype:void 0,Eo=To?To.valueOf:void 0;function Do(e,t,n,r,i,a,o){switch(n){case wo:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Co:return!(e.byteLength!=t.byteLength||!a(new Ga(e),new Ga(t)));case mo:case ho:case vo:return Wt(+e,+t);case go:return e.name==t.name&&e.message==t.message;case yo:case xo:return e==t+``;case _o:var s=co;case bo:var c=r&fo;if(s||=uo,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=po,o.set(e,t);var u=oo(s(e),s(t),r,i,a,o);return o.delete(e),u;case So:if(Eo)return Eo.call(e)==Eo.call(t)}return!1}var Oo=Do,ko=1,Ao=Object.prototype.hasOwnProperty;function jo(e,t,n,r,i,a){var o=n&ko,s=wa(e),c=s.length;if(c!=wa(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:Ao.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var ee=!0;a.set(e,t),a.set(t,e);for(var te=o;++l<c;){u=s[l];var ne=e[u],re=t[u];if(r)var ie=o?r(re,ne,u,t,e,a):r(ne,re,u,e,t,a);if(!(ie===void 0?ne===re||i(ne,re,n,r,a):ie)){ee=!1;break}te||=u==`constructor`}if(ee&&!te){var ae=e.constructor,oe=t.constructor;ae!=oe&&`constructor`in e&&`constructor`in t&&!(typeof ae==`function`&&ae instanceof ae&&typeof oe==`function`&&oe instanceof oe)&&(ee=!1)}return a.delete(e),a.delete(t),ee}var Mo=jo,No=1,Po=`[object Arguments]`,Fo=`[object Array]`,Io=`[object Object]`,Lo=Object.prototype.hasOwnProperty;function Ro(e,t,n,r,i,a){var o=ve(e),s=ve(t),c=o?Fo:Ua(e),l=s?Fo:Ua(t);c=c==Po?Io:c,l=l==Po?Io:l;var u=c==Io,d=l==Io,f=c==l;if(f&&xn(e)){if(!xn(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new fa,o||rr(e)?oo(e,t,n,r,i,a):Oo(e,t,c,n,r,i,a);if(!(n&No)){var ee=u&&Lo.call(e,`__wrapped__`),te=d&&Lo.call(t,`__wrapped__`);if(ee||te){var ne=ee?e.value():e,re=te?t.value():t;return a||=new fa,i(ne,re,n,r,a)}}return f?(a||=new fa,Mo(e,t,n,r,i,a)):!1}var zo=Ro;function Bo(e,t,n,r,i){return e===t?!0:e==null||t==null||!de(e)&&!de(t)?e!==e&&t!==t:zo(e,t,n,r,Bo,i)}var Vo=Bo,Ho=1,Uo=2;function Wo(e,t,n,r){var i=n.length,a=i,o=!r;if(e==null)return!a;for(e=Object(e);i--;){var s=n[i];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<a;){s=n[i];var c=s[0],l=e[c],u=s[1];if(o&&s[2]){if(l===void 0&&!(c in e))return!1}else{var d=new fa;if(r)var f=r(l,u,c,e,t,d);if(!(f===void 0?Vo(u,l,Ho|Uo,r,d):f))return!1}}return!0}var Go=Wo;function Ko(e){return e===e&&!je(e)}var qo=Ko;function Jo(e){for(var t=hr(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,qo(i)]}return t}var Yo=Jo;function Xo(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==void 0||e in Object(n))}}var Zo=Xo;function Qo(e){var t=Yo(e);return t.length==1&&t[0][2]?Zo(t[0][0],t[0][1]):function(n){return n===e||Go(n,e,t)}}var $o=Qo;function es(e,t){return e!=null&&t in Object(e)}var ts=es;function ns(e,t,n){t=Li(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=Bi(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:(i=e==null?0:e.length,!!i&&Qt(i)&&Ht(o,i)&&(ve(e)||mn(e)))}var rs=ns;function is(e,t){return e!=null&&rs(e,t,ts)}var as=is,os=1,ss=2;function cs(e,t){return Er(e)&&qo(t)?Zo(Bi(e),t):function(n){var r=Wi(n,e);return r===void 0&&r===t?as(n,e):Vo(t,r,os|ss)}}var ls=cs;function us(e){return function(t){return t?.[e]}}var ds=us;function fs(e){return function(t){return Hi(t,e)}}var ps=fs;function ms(e){return Er(e)?ds(Bi(e)):ps(e)}var hs=ms;function gs(e){return typeof e==`function`?e:e==null?Ke:typeof e==`object`?ve(e)?ls(e[0],e[1]):$o(e):hs(e)}var _s=gs;function vs(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}var ys=vs;function bs(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var xs=bs,Ss=xs(),Cs=Ss;function ws(e,t){return e&&Cs(e,t,hr)}var Ts=ws;function Es(e,t){return function(n,r){if(n==null)return n;if(!en(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Object(n);(t?a--:++a<i)&&r(o[a],a,o)!==!1;);return n}}var Ds=Es,Os=Ds(Ts),ks=Os;function As(e,t,n,r){return ks(e,function(e,i,a){t(r,e,n(e),a)}),r}var js=As;function Ms(e,t){return function(n,r){var i=ve(n)?ys:js,a=t?t():{};return i(n,e,_s(r,2),a)}}var Ns=Ms;function Ps(e){return de(e)&&en(e)}var Fs=Ps;function Is(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var m=Is;function Ls(e){return typeof e==`function`?e:Ke}var Rs=Ls,zs=Math.max,Bs=Math.min;function Vs(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=r-1;return n!==void 0&&(i=We(n),i=n<0?zs(r+i,0):Bs(i,r-1)),Rt(e,_s(t,3),i,!0)}var Hs=Vs;function Us(e){return e&&e.length?e[0]:void 0}var Ws=Us;function Gs(e,t){return e==null?e:Cs(e,Rs(t),Sr)}var Ks=Gs,qs=Ns(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]}),h=qs,Js=Math.max;function Ys(e){if(!(e&&e.length))return[];var t=0;return e=ma(e,function(e){if(Fs(e))return t=Js(e.length,t),!0}),on(t,function(t){return ge(e,ds(t))})}var Xs=Ys,Zs=Yt(Xs),Qs=Zs;let g=function(e){return e.SPACE=`<space>`,e.TAB=`<tab>`,e.NEWLINE=`<newline>`,e.COMMA=`<comma>`,e.LPAREN=`<lparen>`,e.RPAREN=`<rparen>`,e.LBRACE=`<lbrace>`,e.RBRACE=`<rbrace>`,e.LBRACKET=`<lbracket>`,e.RBRACKET=`<rbracket>`,e.LANGLE=`<langle>`,e.RANGLE=`<rangle>`,e.OP=`<op>`,e.EOF=`<eof>`,e.NUMERIC_LITERAL=`<number>`,e.STRING_LITERAL=`<string>`,e.COLOR_LITERAL=`<color>`,e.FUNCTION_EXPRESSION=`<function-expression>`,e.QUOTED_STRING=`<variable>`,e.IDENTIFIER=`<identifier>`,e.SEMICOLON=`<semicolon>`,e.COLON=`<colon>`,e.SINGLE_LINE_COMMENT=`<single-line-comment>`,e.MULTILINE_COMMENT=`<multiline-comment>`,e}({});function $s(e){switch(e.kind){case g.NEWLINE:case g.SPACE:case g.TAB:case g.SINGLE_LINE_COMMENT:case g.MULTILINE_COMMENT:return!0;default:return!1}}function ec(e){if(!e)return!1;switch(e){case`+`:case`-`:case`*`:case`/`:case`%`:case`<`:case`>`:case`=`:case`!`:case`.`:case`&`:case`|`:case`~`:return!0;default:return!1}}function tc(e){return e!==void 0&&e.kind===g.OP}var _=class e{constructor(e,t,n,r,i){this.kind=e,this.startPos=t,this.endPos=n,this.value=r,this.leadingTrivia=[],this.trailingTrivia=[],this.leadingInvalid=[],this.trailingInvalid=[],this.isInvalid=i,this.start=t.offset,this.end=n.offset}static create(t,n,r,i,a){return new e(t,n,r,i,a)}};function nc(e){return e.trailingTrivia.find(({kind:e})=>e===g.NEWLINE)!==void 0}function rc(e,t){return t.leadingTrivia.find(({kind:e})=>e===g.NEWLINE)!==void 0||nc(e)}function ic(e){return e.trailingTrivia.find(({kind:e})=>[g.SPACE,g.TAB].includes(e))!==void 0}function ac(e){return e.trailingTrivia.length===0?e.end:ac(m(e.trailingTrivia))}function oc(e){return e.leadingTrivia.length===0?e.start:oc(e.leadingTrivia[0])}function sc(e){return[g.SINGLE_LINE_COMMENT,g.MULTILINE_COMMENT].includes(e.kind)}var cc=class{constructor(){this.id=0}reset(){this.id=0}nextId(){return this.id++}},v=class{constructor(e,t,n){this.id=e,this.kind=t;let r=n.find(e=>e!==void 0&&!Number.isNaN(e.start));r?(this.startPos=r.startPos,this.fullStart=r instanceof _?oc(r):r.fullStart):(this.startPos={offset:NaN,column:NaN,line:NaN},this.fullStart=NaN);let i=[...n].reverse().find(e=>e!==void 0&&!Number.isNaN(e.end));i?(this.endPos=i.endPos,this.fullEnd=i instanceof _?ac(i):i.fullEnd):(this.endPos={offset:NaN,column:NaN,line:NaN},this.fullEnd=NaN),this.start=this.startPos.offset,this.end=this.endPos.offset}};let y=function(e){return e.PROGRAM=`<program>`,e.ELEMENT_DECLARATION=`<element-declaration>`,e.ATTRIBUTE=`<attribute>`,e.IDENTIFIER_STREAM=`<identifer-stream>`,e.LITERAL=`<literal>`,e.VARIABLE=`<variable>`,e.PREFIX_EXPRESSION=`<prefix-expression>`,e.INFIX_EXPRESSION=`<infix-expression>`,e.POSTFIX_EXPRESSION=`<postfix-expression>`,e.FUNCTION_EXPRESSION=`<function-expression>`,e.FUNCTION_APPLICATION=`<function-application>`,e.BLOCK_EXPRESSION=`<block-expression>`,e.LIST_EXPRESSION=`<list-expression>`,e.TUPLE_EXPRESSION=`<tuple-expression>`,e.CALL_EXPRESSION=`<call-expression>`,e.PRIMARY_EXPRESSION=`<primary-expression>`,e.GROUP_EXPRESSION=`<group-expression>`,e.DUMMY=`<dummy>`,e.ARRAY=`<array>`,e}({});var b=class extends v{constructor({body:e=[],eof:t},n){super(n,y.PROGRAM,[...e,t]),this.body=e,this.eof=t}},x=class e extends v{constructor({type:t,name:n,as:r,alias:i,attributeList:a,bodyColon:o,body:s},c){if(super(c,y.ELEMENT_DECLARATION,[t,n,r,i,a,o,s]),s&&o&&!(s instanceof w||s instanceof e))throw Error(`If an element has a simple body, it must be a function application node`);this.type=t,this.name=n,this.as=r,this.alias=i,this.attributeList=a,this.bodyColon=o,this.body=s}},lc=class extends v{constructor({identifiers:e=[]},t){super(t,y.IDENTIFIER_STREAM,e||[]),this.identifiers=e}},uc=class extends v{constructor({name:e,colon:t,value:n},r){super(r,y.ATTRIBUTE,[e,t,n]),this.name=e,this.value=n,this.colon=t}},S=class extends v{constructor({op:e,expression:t},n){super(n,y.PREFIX_EXPRESSION,[e,t]),this.op=e,this.expression=t}},dc=class extends v{constructor({op:e,leftExpression:t,rightExpression:n},r){super(r,y.INFIX_EXPRESSION,[t,e,n]),this.op=e,this.leftExpression=t,this.rightExpression=n}},fc=class extends v{constructor({op:e,expression:t},n){super(n,y.POSTFIX_EXPRESSION,[t,e]),this.op=e,this.expression=t}},C=class extends v{constructor({value:e},t){super(t,y.FUNCTION_EXPRESSION,[e]),this.value=e}},w=class extends v{constructor({callee:e,args:t=[]},n){super(n,y.FUNCTION_APPLICATION,[e,...t]),this.callee=e,this.args=t}},T=class extends v{constructor({blockOpenBrace:e,body:t=[],blockCloseBrace:n},r){super(r,y.BLOCK_EXPRESSION,[e,...t,n]),this.blockOpenBrace=e,this.body=t,this.blockCloseBrace=n}},E=class extends v{constructor({listOpenBracket:e,elementList:t=[],commaList:n=[],listCloseBracket:r},i){super(i,y.LIST_EXPRESSION,[e,...yc(t,n),r]),this.listOpenBracket=e,this.elementList=t,this.commaList=n,this.listCloseBracket=r}},pc=class extends v{constructor({tupleOpenParen:e,elementList:t=[],commaList:n=[],tupleCloseParen:r},i){super(i,y.TUPLE_EXPRESSION,[e,...yc(t,n),r]),this.tupleOpenParen=e,this.elementList=t,this.commaList=n,this.tupleCloseParen=r}},mc=class extends pc{constructor({groupOpenParen:e,expression:t,groupCloseParen:n},r){super({tupleOpenParen:e,elementList:t&&[t],commaList:[],tupleCloseParen:n},r),this.kind=y.GROUP_EXPRESSION}},D=class extends v{constructor({callee:e,argumentList:t},n){super(n,y.CALL_EXPRESSION,[e,t]),this.callee=e,this.argumentList=t}},hc=class extends v{constructor({literal:e},t){super(t,y.LITERAL,[e]),this.literal=e}},gc=class extends v{constructor({variable:e},t){super(t,y.VARIABLE,[e]),this.variable=e}},O=class extends v{constructor({expression:e},t){super(t,y.PRIMARY_EXPRESSION,[e]),this.expression=e}},_c=class extends v{constructor({pre:e},t){let n=_.create(g.SPACE,e.endPos,e.endPos,` `,!1);super(t,y.DUMMY,[n])}},vc=class extends v{constructor({expression:e,indexer:t},n){super(n,y.ARRAY,[e,t]),this.array=e,this.indexer=t}};function yc(e,t){if(!e||e.length===0)return t||[];if(!t||t.length===0)return e||[];let[n]=e,[r]=t;return(n.start<r.start?$i(Qs(e,t)):$i(Qs(t,e))).filter(e=>e!==null)}function bc(e,t=!1){return JSON.stringify(e,function(e,t){return!(this instanceof b)&&e===`symbol`?t?.id:e===`symbol`?{symbolTable:t?.symbolTable,id:t?.id,references:t?.references.map(e=>e.id),declaration:t?.declaration?.id}:e===`referee`||e===`parent`||e===`declaration`?t?.id:e===`symbolTable`?Object.fromEntries(t.table):t},t?2:0)}var xc=class{constructor(){this.id=0}reset(){this.id=0}nextId(){return this.id++}},Sc=class{constructor({symbolTable:e},t){this.references=[],this.id=t,this.symbolTable=e}},Cc=class{constructor({symbolTable:e,declaration:t},n){this.references=[],this.id=n,this.symbolTable=e,this.declaration=t}},wc=class{constructor({declaration:e},t){this.references=[],this.id=t,this.declaration=e}},Tc=class{constructor({symbolTable:e,declaration:t},n){this.references=[],this.id=n,this.symbolTable=e,this.declaration=t}},Ec=class{constructor({declaration:e},t){this.references=[],this.id=t,this.declaration=e}},Dc=class{constructor({symbolTable:e,declaration:t},n){this.references=[],this.id=n,this.symbolTable=e,this.declaration=t}},Oc=class{constructor({declaration:e},t){this.references=[],this.id=t,this.declaration=e}},kc=class{constructor({symbolTable:e,declaration:t},n){this.references=[],this.id=n,this.symbolTable=e,this.declaration=t}},Ac=class{constructor({symbolTable:e,declaration:t},n){this.references=[],this.id=n,this.symbolTable=e,this.declaration=t}},jc=class{constructor({declaration:e,tablePartialSymbol:t},n){this.references=[],this.id=n,this.declaration=e,this.tablePartialSymbol=t}};let k=function(e){return e[e.UNKNOWN_SYMBOL=1e3]=`UNKNOWN_SYMBOL`,e[e.UNEXPECTED_SYMBOL=1001]=`UNEXPECTED_SYMBOL`,e[e.UNEXPECTED_EOF=1002]=`UNEXPECTED_EOF`,e[e.UNEXPECTED_NEWLINE=1003]=`UNEXPECTED_NEWLINE`,e[e.UNKNOWN_TOKEN=1004]=`UNKNOWN_TOKEN`,e[e.UNEXPECTED_TOKEN=1005]=`UNEXPECTED_TOKEN`,e[e.UNEXPECTED_ELEMENT_DECLARATION=1006]=`UNEXPECTED_ELEMENT_DECLARATION`,e[e.MISSING_SPACES=1007]=`MISSING_SPACES`,e[e.UNKNOWN_PREFIX_OP=1008]=`UNKNOWN_PREFIX_OP`,e[e.INVALID_OPERAND=1009]=`INVALID_OPERAND`,e[e.EMPTY_ATTRIBUTE_NAME=1010]=`EMPTY_ATTRIBUTE_NAME`,e[e.INVALID_ESCAPE_SEQUENCE=1011]=`INVALID_ESCAPE_SEQUENCE`,e[e.INVALID_NAME=3e3]=`INVALID_NAME`,e[e.UNEXPECTED_NAME=3001]=`UNEXPECTED_NAME`,e[e.NAME_NOT_FOUND=3002]=`NAME_NOT_FOUND`,e[e.DUPLICATE_NAME=3003]=`DUPLICATE_NAME`,e[e.INVALID_ALIAS=3004]=`INVALID_ALIAS`,e[e.UNEXPECTED_ALIAS=3005]=`UNEXPECTED_ALIAS`,e[e.UNEXPECTED_SETTINGS=3006]=`UNEXPECTED_SETTINGS`,e[e.INVALID_SETTINGS=3007]=`INVALID_SETTINGS`,e[e.UNEXPECTED_SIMPLE_BODY=3008]=`UNEXPECTED_SIMPLE_BODY`,e[e.UNEXPECTED_COMPLEX_BODY=3009]=`UNEXPECTED_COMPLEX_BODY`,e[e.INVALID_TABLE_CONTEXT=3010]=`INVALID_TABLE_CONTEXT`,e[e.UNKNOWN_TABLE_SETTING=3011]=`UNKNOWN_TABLE_SETTING`,e[e.DUPLICATE_TABLE_SETTING=3012]=`DUPLICATE_TABLE_SETTING`,e[e.INVALID_TABLEGROUP_CONTEXT=3013]=`INVALID_TABLEGROUP_CONTEXT`,e[e.INVALID_TABLEGROUP_ELEMENT_NAME=3014]=`INVALID_TABLEGROUP_ELEMENT_NAME`,e[e.DUPLICATE_TABLEGROUP_ELEMENT_NAME=3015]=`DUPLICATE_TABLEGROUP_ELEMENT_NAME`,e[e.DUPLICATE_TABLEGROUP_FIELD_NAME=3016]=`DUPLICATE_TABLEGROUP_FIELD_NAME`,e[e.INVALID_TABLEGROUP_FIELD=3017]=`INVALID_TABLEGROUP_FIELD`,e[e.EMPTY_TABLE=3018]=`EMPTY_TABLE`,e[e.INVALID_COLUMN=3019]=`INVALID_COLUMN`,e[e.INVALID_COLUMN_NAME=3020]=`INVALID_COLUMN_NAME`,e[e.UNKNOWN_COLUMN_SETTING=3021]=`UNKNOWN_COLUMN_SETTING`,e[e.INVALID_COLUMN_TYPE=3022]=`INVALID_COLUMN_TYPE`,e[e.DUPLICATE_COLUMN_NAME=3023]=`DUPLICATE_COLUMN_NAME`,e[e.DUPLICATE_COLUMN_SETTING=3024]=`DUPLICATE_COLUMN_SETTING`,e[e.INVALID_COLUMN_SETTING_VALUE=3025]=`INVALID_COLUMN_SETTING_VALUE`,e[e.INVALID_ENUM_CONTEXT=3026]=`INVALID_ENUM_CONTEXT`,e[e.INVALID_ENUM_ELEMENT_NAME=3027]=`INVALID_ENUM_ELEMENT_NAME`,e[e.INVALID_ENUM_ELEMENT=3028]=`INVALID_ENUM_ELEMENT`,e[e.DUPLICATE_ENUM_ELEMENT_NAME=3029]=`DUPLICATE_ENUM_ELEMENT_NAME`,e[e.UNKNOWN_ENUM_ELEMENT_SETTING=3030]=`UNKNOWN_ENUM_ELEMENT_SETTING`,e[e.DUPLICATE_ENUM_ELEMENT_SETTING=3031]=`DUPLICATE_ENUM_ELEMENT_SETTING`,e[e.INVALID_ENUM_ELEMENT_SETTING=3032]=`INVALID_ENUM_ELEMENT_SETTING`,e[e.EMPTY_ENUM=3033]=`EMPTY_ENUM`,e[e.INVALID_REF_CONTEXT=3034]=`INVALID_REF_CONTEXT`,e[e.UNKNOWN_REF_SETTING=3035]=`UNKNOWN_REF_SETTING`,e[e.DUPLICATE_REF_SETTING=3036]=`DUPLICATE_REF_SETTING`,e[e.INVALID_REF_SETTING_VALUE=3037]=`INVALID_REF_SETTING_VALUE`,e[e.INVALID_REF_RELATIONSHIP=3038]=`INVALID_REF_RELATIONSHIP`,e[e.INVALID_REF_FIELD=3039]=`INVALID_REF_FIELD`,e[e.EMPTY_REF=3040]=`EMPTY_REF`,e[e.REF_REDEFINED=3041]=`REF_REDEFINED`,e[e.INVALID_NOTE_CONTEXT=3042]=`INVALID_NOTE_CONTEXT`,e[e.INVALID_NOTE=3043]=`INVALID_NOTE`,e[e.NOTE_REDEFINED=3044]=`NOTE_REDEFINED`,e[e.NOTE_CONTENT_REDEFINED=3045]=`NOTE_CONTENT_REDEFINED`,e[e.EMPTY_NOTE=3046]=`EMPTY_NOTE`,e[e.INVALID_INDEXES_CONTEXT=3047]=`INVALID_INDEXES_CONTEXT`,e[e.INVALID_INDEXES_FIELD=3048]=`INVALID_INDEXES_FIELD`,e[e.INVALID_INDEX=3049]=`INVALID_INDEX`,e[e.UNKNOWN_INDEX_SETTING=3050]=`UNKNOWN_INDEX_SETTING`,e[e.DUPLICATE_INDEX_SETTING=3051]=`DUPLICATE_INDEX_SETTING`,e[e.UNEXPECTED_INDEX_SETTING_VALUE=3052]=`UNEXPECTED_INDEX_SETTING_VALUE`,e[e.INVALID_INDEX_SETTING_VALUE=3053]=`INVALID_INDEX_SETTING_VALUE`,e[e.INVALID_PROJECT_CONTEXT=3054]=`INVALID_PROJECT_CONTEXT`,e[e.PROJECT_REDEFINED=3055]=`PROJECT_REDEFINED`,e[e.INVALID_PROJECT_FIELD=3056]=`INVALID_PROJECT_FIELD`,e[e.INVALID_CUSTOM_CONTEXT=3057]=`INVALID_CUSTOM_CONTEXT`,e[e.INVALID_CUSTOM_ELEMENT_VALUE=3058]=`INVALID_CUSTOM_ELEMENT_VALUE`,e[e.INVALID_ELEMENT_IN_SIMPLE_BODY=3059]=`INVALID_ELEMENT_IN_SIMPLE_BODY`,e[e.INVALID_TABLE_PARTIAL_CONTEXT=3060]=`INVALID_TABLE_PARTIAL_CONTEXT`,e[e.INVALID_TABLE_PARTIAL_ELEMENT_NAME=3061]=`INVALID_TABLE_PARTIAL_ELEMENT_NAME`,e[e.INVALID_TABLE_PARTIAL_SETTING_VALUE=3062]=`INVALID_TABLE_PARTIAL_SETTING_VALUE`,e[e.DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME=3063]=`DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME`,e[e.DUPLICATE_TABLE_PARTIAL_SETTING=3064]=`DUPLICATE_TABLE_PARTIAL_SETTING`,e[e.INVALID_TABLE_PARTIAL_INJECTION=3065]=`INVALID_TABLE_PARTIAL_INJECTION`,e[e.INVALID_TABLE_PARTIAL_INJECTION_OP=3066]=`INVALID_TABLE_PARTIAL_INJECTION_OP`,e[e.INVALID_TABLE_PARTIAL_INJECTION_NAME=3067]=`INVALID_TABLE_PARTIAL_INJECTION_NAME`,e[e.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME=3068]=`DUPLICATE_TABLE_PARTIAL_INJECTION_NAME`,e[e.UNKNOWN_TABLE_PARTIAL_SETTING=3069]=`UNKNOWN_TABLE_PARTIAL_SETTING`,e[e.INVALID_TABLE_SETTING_VALUE=3070]=`INVALID_TABLE_SETTING_VALUE`,e[e.INVALID_CHECKS_CONTEXT=3071]=`INVALID_CHECKS_CONTEXT`,e[e.INVALID_CHECKS_FIELD=3072]=`INVALID_CHECKS_FIELD`,e[e.INVALID_CHECK=3073]=`INVALID_CHECK`,e[e.UNKNOWN_CHECK_SETTING=3074]=`UNKNOWN_CHECK_SETTING`,e[e.DUPLICATE_CHECK_SETTING=3075]=`DUPLICATE_CHECK_SETTING`,e[e.INVALID_CHECK_SETTING_VALUE=3076]=`INVALID_CHECK_SETTING_VALUE`,e[e.BINDING_ERROR=4e3]=`BINDING_ERROR`,e[e.UNSUPPORTED=5e3]=`UNSUPPORTED`,e[e.CIRCULAR_REF=5001]=`CIRCULAR_REF`,e[e.SAME_ENDPOINT=5002]=`SAME_ENDPOINT`,e[e.UNEQUAL_FIELDS_BINARY_REF=5003]=`UNEQUAL_FIELDS_BINARY_REF`,e[e.CONFLICTING_SETTING=5004]=`CONFLICTING_SETTING`,e[e.TABLE_REAPPEAR_IN_TABLEGROUP=5005]=`TABLE_REAPPEAR_IN_TABLEGROUP`,e}({});var A=class e extends Error{constructor(t,n,r){super(n),this.code=t,this.diagnostic=n,this.nodeOrToken=r,this.start=r.start,this.end=r.end,this.name=this.constructor.name,Object.setPrototypeOf(this,e.prototype)}},Mc=class e{constructor(e,t){this.value=e,this.errors=t===void 0?[]:t}getValue(){return this.value}getErrors(){return this.errors}chain(t){let n=t(this.value),r=[...this.errors,...n.errors];return new e(n.value,r)}map(t){return new e(t(this.value),this.errors)}};function Nc(e){return!!e.match(/(\p{L}|_|\p{M})/gu)}function Pc(e){if(!e)return!1;let t=e[0];return t>=`0`&&t<=`9`}function Fc(e){let[t]=e;return Pc(t)||Nc(t)&&t.toLowerCase()>=`a`&&t.toLowerCase()<=`f`}function Ic(e){return Nc(e)||Pc(e)}function Lc(e){return e.split(``).every(Ic)?e:`"${e}"`}function Rc(e,t){let n=[],r=Math.min(e.length,t.length);for(let i=0;i<r;i+=1)n.push(e[i],t[i]);return n.push(...e.slice(r),...t.slice(r)),n}function zc(e,t){return e>=t.start&&e<t.end}function Bc(e){return e instanceof S?`${e.op?.value}${Bc(e.expression)}`:e.expression.literal.value}function Vc(e){return e instanceof S?e.op?.value===`-`?-Vc(e.expression):Vc(e.expression):Number.parseFloat(e.expression.literal.value)}var j=class e{constructor(e){this.value=e}unwrap(){return this.value}unwrap_or(e){return this.value}and_then(e){return e(this.value)}map(t){return new e(t(this.value))}isOk(){return!0}},M=class e{constructor(){this.value=void 0}unwrap(){throw Error(`Trying to unwrap a None value`)}unwrap_or(e){return e}and_then(t){return new e}map(t){return new e}isOk(){return!1}};const Hc=[`null`,`true`,`false`],Uc=[`-`,`+`],Wc=`public`;let N=function(e){return e.Table=`table`,e.Enum=`enum`,e.Ref=`ref`,e.Note=`note`,e.Project=`project`,e.Indexes=`indexes`,e.TableGroup=`tablegroup`,e.TablePartial=`tablepartial`,e.Check=`checks`,e}({}),P=function(e){return e.Color=`color`,e.HeaderColor=`headercolor`,e.Note=`note`,e.PK=`pk`,e.PrimaryKey=`primary key`,e.Unique=`unique`,e.Ref=`ref`,e.NotNull=`not null`,e.Null=`null`,e.Increment=`increment`,e.Default=`default`,e.Name=`name`,e.Type=`type`,e.Check=`check`,e.Update=`update`,e.Delete=`delete`,e}({});var Gc=class{constructor(e,t,n){this.declarationNode=e,this.publicSymbolTable=t,this.symbolFactory=n}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 b||kl(this.declarationNode.parent).unwrap_or(void 0)!==N.Project?[new A(k.INVALID_CUSTOM_CONTEXT,`A Custom element can only appear in a Project`,this.declarationNode)]:[]}validateName(e){return e?[new A(k.UNEXPECTED_NAME,`A Custom element shouldn't have a name`,e)]:[]}validateAlias(e){return e?[new A(k.UNEXPECTED_NAME,`A Custom element shouldn't have an alias`,e)]:[]}validateSettingList(e){return e?[new A(k.UNEXPECTED_SETTINGS,`A Custom element shouldn't have a setting list`,e)]:[]}validateBody(e){if(!e)return[];if(e instanceof T)return[new A(k.UNEXPECTED_COMPLEX_BODY,`A Custom element can only have an inline field`,e)];let t=[];return G(e.callee)||t.push(new A(k.INVALID_CUSTOM_ELEMENT_VALUE,`A Custom element value can only be a string`,e)),e.args.length>0&&t.push(...e.args.map(e=>new A(k.INVALID_CUSTOM_ELEMENT_VALUE,`A Custom element value can only be a string`,e))),t}};let F=function(e){return e.Schema=`Schema`,e.Table=`Table`,e.Column=`Column`,e.TableGroup=`TableGroup`,e.TableGroupField=`TableGroup field`,e.Enum=`Enum`,e.EnumField=`Enum field`,e.Note=`Note`,e.TablePartial=`TablePartial`,e.PartialInjection=`PartialInjection`,e}({});function Kc(e){return`${F.Schema}:${e}`}function qc(e){return`${F.Table}:${e}`}function Jc(e){return`${F.Column}:${e}`}function Yc(e){return`${F.Enum}:${e}`}function Xc(e){return`${F.EnumField}:${e}`}function Zc(e){return`${F.TableGroup}:${e}`}function Qc(e){return`${F.TableGroupField}:${e}`}function $c(e){return`${F.Note}:${e}`}function el(e){return`${F.TablePartial}:${e}`}function tl(e){return`${F.PartialInjection}:${e}`}function nl(e,t){switch(t){case F.Column:return Jc(e);case F.Enum:return Yc(e);case F.EnumField:return Xc(e);case F.Schema:return Kc(e);case F.Table:return qc(e);case F.TableGroup:return Zc(e);case F.TableGroupField:return Qc(e);case F.TablePartial:return el(e);case F.PartialInjection:return tl(e);default:throw Error(`Unreachable`)}}function rl(e){let[t,n]=e.split(`:`);return Object.values(F).includes(t)?new j({name:n,kind:t}):new M}var il=class{constructor(){this.table=new Map}has(e){return this.table.has(e)}set(e,t){this.table.set(e,t)}get(e,t){return this.table.get(e)||t!==void 0&&this.set(e,t)||t}entries(){return this.table.entries()}forEach(e){return this.table.forEach(e)}},al=class{constructor(e,t,n){this.declarationNode=e,this.publicSymbolTable=t,this.symbolFactory=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 x?[new A(k.INVALID_PROJECT_CONTEXT,`An Enum can only appear top-level`,this.declarationNode)]:[]}validateName(e){return e?_l(e)?[]:[new A(k.INVALID_NAME,`An Enum name must be of the form <enum> or <schema>.<enum>`,e)]:[new A(k.NAME_NOT_FOUND,`An Enum must have a name`,this.declarationNode)]}validateAlias(e){return e?[new A(k.UNEXPECTED_ALIAS,`An Enum shouldn't have an alias`,e)]:[]}registerElement(){let e=[];this.declarationNode.symbol=this.symbolFactory.create(Cc,{declaration:this.declarationNode,symbolTable:new il});let{name:t}=this.declarationNode,n=R(t);if(n.isOk()){let r=n.unwrap(),i=r.pop(),a=xl(r,this.publicSymbolTable,this.symbolFactory),o=Yc(i);a.has(o)&&e.push(new A(k.DUPLICATE_NAME,`Enum name ${i} already exists in schema '${r.join(`.`)||`public`}'`,t)),a.set(o,this.declarationNode.symbol)}return e}validateSettingList(e){return e?[new A(k.UNEXPECTED_SETTINGS,`An Enum shouldn't have a setting list`,e)]:[]}validateBody(e){if(!e)return[];if(e instanceof w)return this.validateFields([e]);let[t,n]=h(e.body,e=>e instanceof w);return[...this.validateFields(t),...this.validateSubElements(n)]}validateFields(e){return e.length===0?[new A(k.EMPTY_ENUM,`An Enum must have at least one element`,this.declarationNode)]:e.flatMap(e=>{let t=[];e.callee&&!K(e.callee)&&t.push(new A(k.INVALID_ENUM_ELEMENT_NAME,`An enum field must be an identifier or a quoted identifier`,e.callee));let n=[...e.args];return m(n)instanceof E?(t.push(...this.validateFieldSettings(m(n))),n.pop()):n[0]instanceof E&&(t.push(...this.validateFieldSettings(n[0])),n.shift()),n.length>0&&t.push(...n.map(e=>new A(k.INVALID_ENUM_ELEMENT,`An Enum must have only a field and optionally a setting list`,e))),t.push(...this.registerField(e)),t})}validateFieldSettings(e){let t=L(e),n=t.getErrors(),r=t.getValue();for(let e in r){let t=r[e];switch(e){case`note`:t.length>1&&t.forEach(e=>n.push(new A(k.DUPLICATE_ENUM_ELEMENT_SETTING,`'note' can only appear once`,e))),t.forEach(e=>{G(e.value)||n.push(new A(k.INVALID_ENUM_ELEMENT_SETTING,`'note' must be a string`,e))});break;default:t.forEach(t=>n.push(new A(k.UNKNOWN_ENUM_ELEMENT_SETTING,`Unknown enum field setting '${e}'`,t)))}}return n}validateSubElements(e){return e.flatMap(e=>(e.parent=this.declarationNode,e.type?new(gl(e))(e,this.publicSymbolTable,this.symbolFactory).validate():[]))}registerField(e){if(e.callee&&K(e.callee)){let t=V(e.callee).unwrap(),n=Xc(t),r=this.symbolFactory.create(wc,{declaration:e});e.symbol=r;let i=this.declarationNode.symbol.symbolTable;if(i.has(n)){let r=i.get(n);return[new A(k.DUPLICATE_COLUMN_NAME,`Duplicate enum field ${t}`,e),new A(k.DUPLICATE_COLUMN_NAME,`Duplicate enum field ${t}`,r.declaration)]}i.set(n,r)}return[]}},ol=class{constructor(e,t,n){this.declarationNode=e,this.publicSymbolTable=t,this.symbolFactory=n}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(){let e=new A(k.INVALID_INDEXES_CONTEXT,`An Indexes can only appear inside a Table or a TablePartial`,this.declarationNode);if(this.declarationNode.parent instanceof b)return[e];let t=kl(this.declarationNode.parent).unwrap_or(void 0);return t&&[N.Table,N.TablePartial].includes(t)?[]:[e]}validateName(e){return e?[new A(k.UNEXPECTED_NAME,`An Indexes shouldn't have a name`,e)]:[]}validateAlias(e){return e?[new A(k.UNEXPECTED_ALIAS,`An Indexes shouldn't have an alias`,e)]:[]}validateSettingList(e){return e?[new A(k.UNEXPECTED_SETTINGS,`An Indexes shouldn't have a setting list`,e)]:[]}validateBody(e){if(!e)return[];if(e instanceof w)return[new A(k.UNEXPECTED_SIMPLE_BODY,`An Indexes must have a complex body`,e)];let[t,n]=h(e.body,e=>e instanceof w);return[...this.validateFields(t),...this.validateSubElements(n)]}validateFields(e){return e.flatMap(e=>{if(!e.callee)return[];let t=[],n=[e.callee,...e.args];return m(n)instanceof E&&t.push(...this.validateFieldSetting(n.pop())),n.forEach(e=>{for(;e instanceof D;)e.argumentList&&!jl(e.argumentList).isOk()&&t.push(new A(k.INVALID_INDEXES_FIELD,`An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such`,e.argumentList)),e=e.callee;jl(e).isOk()||t.push(new A(k.INVALID_INDEXES_FIELD,`An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such`,e))}),t})}validateFieldSetting(e){let t=L(e),n=t.getErrors(),r=t.getValue();for(let e in r){let t=r[e];switch(e){case`note`:case`name`:t.length>1&&t.forEach(t=>n.push(new A(k.DUPLICATE_INDEX_SETTING,`'${e}' can only appear once`,t))),t.forEach(t=>{G(t.value)||n.push(new A(k.INVALID_INDEX_SETTING_VALUE,`'${e}' must be a string`,t))});break;case`unique`:case`pk`:t.length>1&&t.forEach(t=>n.push(new A(k.DUPLICATE_INDEX_SETTING,`'${e}' can only appear once`,t))),t.forEach(t=>{I(t.value)||n.push(new A(k.INVALID_INDEX_SETTING_VALUE,`'${e}' must not have a value`,t))});break;case`type`:t.length>1&&t.forEach(e=>n.push(new A(k.DUPLICATE_INDEX_SETTING,`'type' can only appear once`,e))),t.forEach(e=>{K(e.value)||n.push(new A(k.INVALID_INDEX_SETTING_VALUE,`'type' must be "btree" or "hash"`,e))});break;default:t.forEach(t=>n.push(new A(k.UNKNOWN_INDEX_SETTING,`Unknown index setting '${e}'`,t)))}}return n}validateSubElements(e){return e.flatMap(e=>(e.parent=this.declarationNode,e.type?new(gl(e))(e,this.publicSymbolTable,this.symbolFactory).validate():[]))}},sl=class{constructor(e,t,n){this.declarationNode=e,this.publicSymbolTable=t,this.symbolFactory=n}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 b)&&![N.Table,N.TableGroup,N.TablePartial,N.Project].includes(kl(this.declarationNode.parent).unwrap_or(void 0))?[new A(k.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 b))return e?[new A(k.UNEXPECTED_NAME,`A Note shouldn't have a name`,e)]:[];if(!e)return[new A(k.INVALID_NAME,`Sticky note must have a name`,this.declarationNode)];let t=R(e);if(!t.isOk())return[new A(k.INVALID_NAME,`Invalid name for sticky note `,this.declarationNode)];let n=t.unwrap().join(`.`),r=$c(n);return this.publicSymbolTable.has(r)?[new A(k.DUPLICATE_NAME,`Sticky note "${n}" has already been defined`,e)]:(this.publicSymbolTable.set(r,this.declarationNode.symbol),[])}validateAlias(e){return e?[new A(k.UNEXPECTED_ALIAS,`A Ref shouldn't have an alias`,e)]:[]}validateSettingList(e){return e?[new A(k.UNEXPECTED_SETTINGS,`A Note shouldn't have a setting list`,e)]:[]}validateBody(e){if(!e)return[];if(e instanceof w)return this.validateFields([e]);let[t,n]=h(e.body,e=>e instanceof w);return[...this.validateFields(t),...this.validateSubElements(n)]}validateFields(e){let t=[];return e.length===0?[new A(k.EMPTY_NOTE,`A Note must have a content`,this.declarationNode)]:(e.length>1&&e.slice(1).forEach(e=>t.push(new A(k.NOTE_CONTENT_REDEFINED,`A Note can only contain one string`,e))),G(e[0].callee)||t.push(new A(k.INVALID_NOTE,`A Note content must be a quoted string`,e[0])),e[0].args.length>0&&t.push(...e[0].args.map(e=>new A(k.INVALID_NOTE,`A Note can only contain one quoted string`,e))),t)}validateSubElements(e){return e.flatMap(e=>(e.parent=this.declarationNode,e.type?new(gl(e))(e,this.publicSymbolTable,this.symbolFactory).validate():[]))}},cl=class{constructor(e,t,n){this.declarationNode=e,this.publicSymbolTable=t,this.symbolFactory=n}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 x?[new A(k.INVALID_PROJECT_CONTEXT,`A Project can only appear top-level`,this.declarationNode)]:[]}validateName(e){return e?yl(e)?[]:[new A(k.INVALID_NAME,`A Project's name is optional or must be an identifier or a quoted identifer`,e)]:[]}validateAlias(e){return e?[new A(k.UNEXPECTED_ALIAS,`A Project shouldn't have an alias`,e)]:[]}validateSettingList(e){return e?[new A(k.UNEXPECTED_SETTINGS,`A Project shouldn't have a setting list`,e)]:[]}validateBody(e){if(!e)return[];if(e instanceof w)return[new A(k.UNEXPECTED_SIMPLE_BODY,`A Project's body must be a block`,e)];let[t,n]=h(e.body,e=>e instanceof w);return[...t.map(e=>new A(k.INVALID_PROJECT_FIELD,`A Project can not have inline fields`,e)),...this.validateSubElements(n)]}validateSubElements(e){return e.flatMap(e=>(e.parent=this.declarationNode,e.type?new(gl(e))(e,this.publicSymbolTable,this.symbolFactory).validate():[]))}},ll=class{constructor(e,t,n){this.declarationNode=e,this.publicSymbolTable=t,this.symbolFactory=n}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 b?[]:[new A(k.INVALID_REF_CONTEXT,`A Ref must appear top-level`,this.declarationNode)]}validateName(e){return e?yl(e)?[]:[new A(k.INVALID_NAME,`A Ref's name is optional or must be an identifier or a quoted identifer`,e)]:[]}validateAlias(e){return e?[new A(k.UNEXPECTED_ALIAS,`A Ref shouldn't have an alias`,e)]:[]}validateSettingList(e){return e?[new A(k.UNEXPECTED_SETTINGS,`A Ref shouldn't have a setting list`,e)]:[]}validateBody(e){if(!e)return[];if(e instanceof w)return this.validateFields([e]);let[t,n]=h(e.body,e=>e instanceof w);return[...this.validateFields(t),...this.validateSubElements(n)]}validateFields(e){if(e.length===0)return[new A(k.EMPTY_REF,`A Ref must have at least one field`,this.declarationNode)];let t=[];return e.length>1&&t.push(...e.slice(1).map(e=>new A(k.REF_REDEFINED,`A Ref can only contain one binary relationship`,e))),e.forEach(e=>{if(e.callee&&!Ml(e.callee)&&t.push(new A(k.INVALID_REF_FIELD,`A Ref field must be a binary relationship`,e.callee)),e.callee&&Ml(e.callee)){let n=z(e.callee.leftExpression).unwrap_or({variables:[],tupleElements:[]}),r=n.variables.length+Math.min(n.tupleElements.length,1),i=z(e.callee.rightExpression).unwrap_or({variables:[],tupleElements:[]}),a=i.variables.length+Math.min(i.tupleElements.length,1);r<2&&t.push(new A(k.INVALID_REF_FIELD,`Invalid column reference`,e.callee.leftExpression||e.callee)),a<2&&t.push(new A(k.INVALID_REF_FIELD,`Invalid column reference`,e.callee.rightExpression||e.callee))}e.callee&&!Nl(e.callee)&&t.push(new A(k.UNEQUAL_FIELDS_BINARY_REF,`Unequal fields in ref endpoints`,e.callee));let n=[...e.args];if(m(n)instanceof E){let e=this.validateFieldSettings(m(n));t.push(...e),n.pop()}else n[0]instanceof E&&(t.push(...this.validateFieldSettings(n[0])),n.shift());n.length>0&&t.push(...n.map(e=>new A(k.INVALID_REF_FIELD,`A Ref field should only have a single binary relationship`,e)))}),t}validateFieldSettings(e){let t=L(e),n=t.getErrors(),r=t.getValue();for(let e in r){let t=r[e];switch(e){case`delete`:case`update`:t.length>1&&t.forEach(t=>n.push(new A(k.DUPLICATE_REF_SETTING,`'${e}' can only appear once`,t))),t.forEach(t=>{ul(t.value)||n.push(new A(k.INVALID_REF_SETTING_VALUE,`'${e}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`,t))});break;case`color`:t.length>1&&n.push(...t.map(e=>new A(k.DUPLICATE_REF_SETTING,`'color' can only appear once`,e))),t.forEach(e=>{Cl(e.value)||n.push(new A(k.INVALID_REF_SETTING_VALUE,`'color' must be a color literal`,e))});break;default:t.forEach(t=>n.push(new A(k.UNKNOWN_REF_SETTING,`Unknown ref setting '${e}'`,t)))}}return n}validateSubElements(e){return e.flatMap(e=>(e.parent=this.declarationNode,e.type?new(gl(e))(e,this.publicSymbolTable,this.symbolFactory).validate():[]))}};function ul(e){if(!(K(e)&&e.expression.variable.kind!==g.QUOTED_STRING)&&!(e instanceof lc))return!1;let t;if(t=e instanceof lc?Gl(e).unwrap_or(``):e.expression.variable.value,t)switch(t.toLowerCase()){case`cascade`:case`no action`:case`set null`:case`set default`:case`restrict`:return!0;default:return!1}return!1}var dl=class{constructor(e,t,n){this.declarationNode=e,this.symbolFactory=n,this.publicSymbolTable=t}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 x?[new A(k.INVALID_TABLE_CONTEXT,`Table must appear top-level`,this.declarationNode)]:[]}validateName(e){return e?e instanceof vc?[new A(k.INVALID_NAME,`Invalid array as Table name, maybe you forget to add a space between the name and the setting list?`,e)]:_l(e)?[]:[new A(k.INVALID_NAME,`A Table name must be of the form <table> or <schema>.<table>`,e)]:[new A(k.NAME_NOT_FOUND,`A Table must have a name`,this.declarationNode)]}validateAlias(e){return e?vl(e)?[]:[new A(k.INVALID_ALIAS,`Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes`,e)]:[]}validateSettingList(e){let t=L(e),n=t.getErrors();return Ks(t.getValue(),(e,t)=>{switch(t){case P.HeaderColor:e.length>1&&n.push(...e.map(e=>new A(k.DUPLICATE_TABLE_SETTING,`'headercolor' can only appear once`,e))),e.forEach(e=>{Cl(e.value)||n.push(new A(k.INVALID_TABLE_SETTING_VALUE,`'headercolor' must be a color literal`,e.value||e.name))});break;case P.Note:e.length>1&&n.push(...e.map(e=>new A(k.DUPLICATE_TABLE_SETTING,`'note' can only appear once`,e))),e.forEach(e=>{G(e.value)||n.push(new A(k.INVALID_TABLE_SETTING_VALUE,`'note' must be a string literal`,e.value||e.name))});break;default:n.push(...e.map(e=>new A(k.UNKNOWN_TABLE_SETTING,`Unknown '${t}' setting`,e)))}}),n}registerElement(){let e=[];this.declarationNode.symbol=this.symbolFactory.create(Tc,{declaration:this.declarationNode,symbolTable:new il});let{name:t,alias:n}=this.declarationNode,r=R(t);if(r.isOk()){let n=[...r.unwrap()],i=n.pop(),a=xl(n,this.publicSymbolTable,this.symbolFactory),o=qc(i);a.has(o)&&e.push(new A(k.DUPLICATE_NAME,`Table name '${i}' already exists in schema '${n.join(`.`)||`public`}'`,t)),a.set(o,this.declarationNode.symbol)}if(n&&yl(n)&&!fl(n.expression.variable.value,r.unwrap_or([]))){let r=V(n).unwrap(),i=qc(r);this.publicSymbolTable.has(i)&&e.push(new A(k.DUPLICATE_NAME,`Table name '${r}' already exists`,t)),this.publicSymbolTable.set(i,this.declarationNode.symbol)}return e}validateBody(e){if(!e)return[];if(e instanceof w)return[new A(k.UNEXPECTED_SIMPLE_BODY,`A Table's body must be a block`,e)];let[t,n]=h(e.body,e=>e instanceof w);return[...this.validateFields(t),...this.validateSubElements(n)]}validateFields(e){let t=e=>{let t=[];if(!e.callee)return[];e.args.length===0&&t.push(new A(k.INVALID_COLUMN,`A column must have a type`,e.callee)),K(e.callee)||t.push(new A(k.INVALID_COLUMN_NAME,`A column name must be an identifier or a quoted identifier`,e.callee)),e.args[0]&&!Ol(e.args[0])&&t.push(new A(k.INVALID_COLUMN_TYPE,`Invalid column type`,e.args[0]));let n=e.args.slice(1);return t.push(...this.validateFieldSetting(n)),t.push(...this.registerField(e)),t},n=e=>{let t=[];if(!e.callee)return[];if(!bl(e.callee))t.push(new A(k.INVALID_TABLE_PARTIAL_INJECTION,`A partial injection should be of the form ~<table-partial>`,e.callee));else{let t=B(e.callee.expression).unwrap_or(``),n=this.symbolFactory.create(Ac,{symbolTable:new il,declaration:e}),r=tl(t),i=this.declarationNode.symbol.symbolTable;if(i.has(r)){let n=i.get(r);return[new A(k.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME,`Duplicate table partial injection '${t}'`,e),new A(k.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME,`Duplicate table partial injection '${t}'`,n.declaration)]}i.set(r,n)}return e.args.length&&t.push(...e.args.map(e=>new A(k.INVALID_TABLE_PARTIAL_INJECTION,`A partial injection does not have any trailing attributes`,e))),t};return e.flatMap(e=>e.callee instanceof S&&e.callee.op?.value===`~`?n(e):t(e))}registerField(e){if(e.callee&&K(e.callee)){let t=V(e.callee).unwrap(),n=Jc(t),r=this.symbolFactory.create(Ec,{declaration:e});e.symbol=r;let i=this.declarationNode.symbol.symbolTable;if(i.has(n)){let r=i.get(n);return[new A(k.DUPLICATE_COLUMN_NAME,`Duplicate column ${t}`,e),new A(k.DUPLICATE_COLUMN_NAME,`Duplicate column ${t}`,r.declaration)]}i.set(n,r)}return[]}validateFieldSetting(e){if(!e.slice(0,-1).every(Hl)||!e.slice(-1).every(e=>Hl(e)||e instanceof E))return[...e.map(e=>new A(k.INVALID_COLUMN,`These fields must be some inline settings optionally ended with a setting list`,e))];if(e.length===0)return[];let t;m(e)instanceof E&&(t=e.pop());let n=L(t),r=n.getErrors(),i=n.getValue();e.forEach(e=>{let t=V(e).unwrap_or(``).toLowerCase();if(t!==`pk`&&t!==`unique`){r.push(new A(k.INVALID_SETTINGS,"Inline column settings can only be `pk` or `unique`",e));return}i[t]===void 0?i[t]=[e]:i[t].push(e)});let a=i[P.PK]||[],o=i[P.PrimaryKey]||[];return a.length>=1&&o.length>=1&&r.push(...[...a,...o].map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`Either one of 'primary key' and 'pk' can appear`,e))),Ks(i,(e,t)=>{switch(t){case P.Note:e.length>1&&r.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`note can only appear once`,e))),e.forEach(e=>{G(e.value)||r.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'note' must be a quoted string`,e.value||e.name))});break;case P.Ref:e.forEach(e=>{El(e.value)||r.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'ref' must be a valid unary relationship`,e.value||e.name))});break;case P.PrimaryKey:e.length>1&&r.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`primary key can only appear once`,e))),e.forEach(e=>{I(e.value)||r.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'primary key' must not have a value`,e.value||e.name))});break;case P.PK:e.length>1&&r.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`'pk' can only appear once`,e))),e.forEach(e=>{e instanceof uc&&!I(e.value)&&r.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'pk' must not have a value`,e.value||e.name))});break;case P.NotNull:{e.length>1&&r.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`'not null' can only appear once`,e)));let t=i[P.Null]||[];e.length>=1&&t.length>=1&&r.push(...[...e,...t].map(e=>new A(k.CONFLICTING_SETTING,`'not null' and 'null' can not be set at the same time`,e))),e.forEach(e=>{I(e.value)||r.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'not null' must not have a value`,e.value||e.name))});break}case P.Null:e.length>1&&r.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`'null' can only appear once`,e))),e.forEach(e=>{I(e.value)||r.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'null' must not have a value`,e.value||e.name))});break;case P.Unique:e.length>1&&r.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`'unique' can only appear once`,e))),e.forEach(e=>{e instanceof uc&&!I(e.value)&&r.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'unique' must not have a value`,e.value||e.name))});break;case P.Increment:e.length>1&&r.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`'increment' can only appear once`,e))),e.forEach(e=>{e instanceof uc&&!I(e.value)&&r.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'increment' must not have a value`,e.value||e.name))});break;case P.Default:e.length>1&&r.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`'default' can only appear once`,e))),e.forEach(e=>{wl(e.value)||r.push(new A(k.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 P.Check:e.forEach(e=>{e.value instanceof C||r.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'check' must be a function expression`,e.value||e.name))});break;default:e.forEach(e=>r.push(new A(k.UNKNOWN_COLUMN_SETTING,`Unknown column setting '${t}'`,e)))}}),r}validateSubElements(e){let t=e.flatMap(e=>(e.parent=this.declarationNode,e.type?new(gl(e))(e,this.publicSymbolTable,this.symbolFactory).validate():[])),n=e.filter(e=>e.type?.value.toLowerCase()===`note`);return n.length>1&&t.push(...n.map(e=>new A(k.NOTE_REDEFINED,`Duplicate notes are defined`,e))),t}};function fl(e,t){return t.length===1&&e===t[0]}var pl=class{constructor(e,t,n){this.declarationNode=e,this.publicSymbolTable=t,this.symbolFactory=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 x?[new A(k.INVALID_TABLEGROUP_CONTEXT,`TableGroup must appear top-level`,this.declarationNode)]:[]}validateName(e){return e?yl(e)?[]:[new A(k.INVALID_NAME,`A TableGroup name must be a single identifier`,e)]:[new A(k.NAME_NOT_FOUND,`A TableGroup must have a name`,this.declarationNode)]}validateAlias(e){return e?[new A(k.UNEXPECTED_ALIAS,`A TableGroup shouldn't have an alias`,e)]:[]}registerElement(){let{name:e}=this.declarationNode;this.declarationNode.symbol=this.symbolFactory.create(Dc,{declaration:this.declarationNode,symbolTable:new il});let t=R(e);if(t.isOk()){let n=t.unwrap(),r=n.pop(),i=xl(n,this.publicSymbolTable,this.symbolFactory),a=Zc(r);if(i.has(a))return[new A(k.DUPLICATE_NAME,`TableGroup name '${r}' already exists`,e)];i.set(a,this.declarationNode.symbol)}return[]}validateSettingList(e){let t=L(e),n=t.getErrors();return Ks(t.getValue(),(e,t)=>{switch(t){case`color`:e.length>1&&n.push(...e.map(e=>new A(k.DUPLICATE_TABLE_SETTING,`'color' can only appear once`,e))),e.forEach(e=>{Cl(e.value)||n.push(new A(k.INVALID_TABLE_SETTING_VALUE,`'color' must be a color literal`,e.value||e.name))});break;case`note`:e.length>1&&n.push(...e.map(e=>new A(k.DUPLICATE_TABLE_SETTING,`'note' can only appear once`,e))),e.filter(e=>!G(e.value)).forEach(e=>{n.push(new A(k.INVALID_TABLE_SETTING_VALUE,`'note' must be a string literal`,e.value||e.name))});break;default:n.push(...e.map(e=>new A(k.UNKNOWN_TABLE_SETTING,`Unknown '${t}' setting`,e)));break}}),n}validateBody(e){if(!e)return[];if(e instanceof w)return[new A(k.UNEXPECTED_SIMPLE_BODY,`A TableGroup's body must be a block`,e)];let[t,n]=h(e.body,e=>e instanceof w);return[...this.validateFields(t),...this.validateSubElements(n)]}validateFields(e){return e.flatMap(e=>{let t=[];return e.callee&&!R(e.callee).isOk()&&t.push(new A(k.INVALID_TABLEGROUP_FIELD,`A TableGroup field must be of the form <table> or <schema>.<table>`,e.callee)),this.registerField(e),e.args.length>0&&t.push(...e.args.map(e=>new A(k.INVALID_TABLEGROUP_FIELD,`A TableGroup field should only have a single Table name`,e))),t})}validateSubElements(e){let t=e.flatMap(e=>(e.parent=this.declarationNode,e.type?new(gl(e))(e,this.publicSymbolTable,this.symbolFactory).validate():[])),n=e.filter(e=>e.type?.value.toLowerCase()===`note`);return n.length>1&&t.push(...n.map(e=>new A(k.NOTE_REDEFINED,`Duplicate notes are defined`,e))),t}registerField(e){if(e.callee&&K(e.callee)){let t=V(e.callee).unwrap(),n=Qc(t),r=this.symbolFactory.create(Oc,{declaration:e});e.symbol=r;let i=this.declarationNode.symbol.symbolTable;if(i.has(n)){let r=i.get(n);return[new A(k.DUPLICATE_TABLEGROUP_FIELD_NAME,`${t} already exists in the group`,e),new A(k.DUPLICATE_TABLEGROUP_FIELD_NAME,`${t} already exists in the group`,r.declaration)]}i.set(n,r)}return[]}},ml=class{constructor(e,t,n){this.declarationNode=e,this.symbolFactory=n,this.publicSymbolTable=t}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 x?[new A(k.INVALID_TABLE_PARTIAL_CONTEXT,`TablePartial must appear top-level`,this.declarationNode)]:[]}validateName(e){return e?yl(e)?[]:[new A(k.INVALID_NAME,`A TablePartial name must be an identifier or a quoted identifer`,e)]:[new A(k.NAME_NOT_FOUND,`A TablePartial must have a name`,this.declarationNode)]}validateAlias(e){return e?[new A(k.UNEXPECTED_ALIAS,`A TablePartial shouldn't have an alias`,e)]:[]}validateSettingList(e){let t=L(e),n=t.getErrors();return Ks(t.getValue(),(e,t)=>{switch(t){case P.HeaderColor:e.length>1&&n.push(...e.map(e=>new A(k.DUPLICATE_TABLE_PARTIAL_SETTING,`'${t}' can only appear once`,e))),e.forEach(e=>{Cl(e.value)||n.push(new A(k.INVALID_TABLE_PARTIAL_SETTING_VALUE,`'${t}' must be a color literal`,e.value||e.name))});break;case P.Note:e.length>1&&n.push(...e.map(e=>new A(k.DUPLICATE_TABLE_PARTIAL_SETTING,`'${t}' can only appear once`,e))),e.forEach(e=>{G(e.value)||n.push(new A(k.INVALID_TABLE_PARTIAL_SETTING_VALUE,`'${t}' must be a string literal`,e.value||e.name))});break;default:n.push(...e.map(e=>new A(k.UNKNOWN_TABLE_PARTIAL_SETTING,`Unknown '${t}' setting`,e)))}}),n}registerElement(){let{name:e}=this.declarationNode;this.declarationNode.symbol=this.symbolFactory.create(kc,{declaration:this.declarationNode,symbolTable:new il});let t=R(e);if(!t.isOk())return[];let n=t.unwrap(),r=n.pop(),i=xl(n,this.publicSymbolTable,this.symbolFactory),a=el(r);return i.has(a)?[new A(k.DUPLICATE_NAME,`TablePartial name '${r}' already exists`,e)]:(i.set(a,this.declarationNode.symbol),[])}validateBody(e){if(!e)return[];if(e instanceof w)return[new A(k.UNEXPECTED_SIMPLE_BODY,`A TablePartial's body must be a block`,e)];let[t,n]=h(e.body,e=>e instanceof w);return[...this.validateFields(t),...this.validateSubElements(n)]}validateFields(e){return e.flatMap(e=>{if(!e.callee)return[];let t=[];e.args.length===0&&t.push(new A(k.INVALID_COLUMN,`A column must have a type`,e.callee)),K(e.callee)||t.push(new A(k.INVALID_COLUMN_NAME,`A column name must be an identifier or a quoted identifier`,e.callee)),e.args[0]&&!Ol(e.args[0])&&t.push(new A(k.INVALID_COLUMN_TYPE,`Invalid column type`,e.args[0]));let n=e.args.slice(1);return t.push(...this.validateFieldSetting(n),...this.registerField(e)),t})}registerField(e){if(!e.callee||!K(e.callee))return[];let t=V(e.callee).unwrap(),n=Jc(t),r=this.symbolFactory.create(Ec,{declaration:e});e.symbol=r;let i=this.declarationNode.symbol.symbolTable;if(i.has(n)){let r=i.get(n);return[new A(k.DUPLICATE_COLUMN_NAME,`Duplicate column ${t}`,e),new A(k.DUPLICATE_COLUMN_NAME,`Duplicate column ${t}`,r.declaration)]}return i.set(n,r),[]}validateFieldSetting(e){let t=m(e);if(!e.slice(0,-1).every(Hl)||!(Hl(t)||t instanceof E))return[...e.map(e=>new A(k.INVALID_COLUMN,`These fields must be some inline settings optionally ended with a setting list`,e))];if(e.length===0)return[];let n;m(e)instanceof E&&(n=e.pop());let r=L(n),i=r.getErrors(),a=r.getValue();e.forEach(e=>{let t=V(e).unwrap_or(``).toLowerCase();if(t!==P.PK&&t!==P.Unique){i.push(new A(k.INVALID_SETTINGS,"Inline column settings can only be `pk` or `unique`",e));return}a[t]===void 0?a[t]=[e]:a[t].push(e)});let o=a[P.PK]||[],s=a[P.PrimaryKey]||[];return o.length>=1&&s.length>=1&&i.push(...[...o,...s].map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`Either one of 'primary key' and 'pk' can appear`,e))),Ks(a,(e,t)=>{switch(t){case P.Note:e.length>1&&i.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`'${t}' can only appear once`,e))),e.forEach(e=>{G(e.value)||i.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'${t}' must be a quoted string`,e.value||e.name))});break;case P.Ref:e.forEach(e=>{El(e.value)||i.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'${t}' must be a valid unary relationship`,e.value||e.name))});break;case P.PrimaryKey:e.length>1&&i.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`'${t}' can only appear once`,e))),e.forEach(e=>{I(e.value)||i.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'${t}' must not have a value`,e.value||e.name))});break;case P.PK:e.length>1&&i.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`'${t}' can only appear once`,e))),e.forEach(e=>{e instanceof uc&&!I(e.value)&&i.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'${t}' must not have a value`,e.value||e.name))});break;case P.NotNull:{e.length>1&&i.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`'${t}' can only appear once`,e)));let n=a[P.Null]||[];e.length>=1&&n.length>=1&&i.push(...[...e,...n].map(e=>new A(k.CONFLICTING_SETTING,`'not null' and 'null' can not be set at the same time`,e))),e.forEach(e=>{I(e.value)||i.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'${t}' must not have a value`,e.value||e.name))});break}case P.Null:e.length>1&&i.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`'${t}' can only appear once`,e))),e.forEach(e=>{I(e.value)||i.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'${t}' must not have a value`,e.value||e.name))});break;case P.Unique:e.length>1&&i.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`'${t}' can only appear once`,e))),e.forEach(e=>{e instanceof uc&&!I(e.value)&&i.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'${t}' must not have a value`,e.value||e.name))});break;case P.Increment:e.length>1&&i.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`'${t}' can only appear once`,e))),e.forEach(e=>{e instanceof uc&&!I(e.value)&&i.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'${t}' must not have a value`,e.value||e.name))});break;case P.Default:e.length>1&&i.push(...e.map(e=>new A(k.DUPLICATE_COLUMN_SETTING,`'${t}' can only appear once`,e))),e.forEach(e=>{wl(e.value)||i.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'${t}' must be a string literal, number literal, function expression, true, false or null`,e.value||e.name))});break;case P.Check:e.forEach(e=>{e.value instanceof C||i.push(new A(k.INVALID_COLUMN_SETTING_VALUE,`'check' must be a function expression`,e.value||e.name))});break;default:e.forEach(e=>i.push(new A(k.UNKNOWN_COLUMN_SETTING,`Unknown column setting '${t}'`,e)))}}),i}validateSubElements(e){let t=e.flatMap(e=>(e.parent=this.declarationNode,e.type?new(gl(e))(e,this.publicSymbolTable,this.symbolFactory).validate():[])),n=e.filter(e=>e.type?.value.toLowerCase()===N.Note);return n.length>1&&t.push(...n.map(e=>new A(k.NOTE_REDEFINED,`Duplicate notes are defined`,e))),t}},hl=class{constructor(e,t,n){this.declarationNode=e,this.publicSymbolTable=t,this.symbolFactory=n}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(){let e=new A(k.INVALID_CHECKS_CONTEXT,`A Checks can only appear inside a Table or a TablePartial`,this.declarationNode);if(this.declarationNode.parent instanceof b)return[e];let t=kl(this.declarationNode.parent).unwrap_or(void 0);return t&&[N.Table,N.TablePartial].includes(t)?[]:[e]}validateName(e){return e?[new A(k.UNEXPECTED_NAME,`A Checks shouldn't have a name`,e)]:[]}validateAlias(e){return e?[new A(k.UNEXPECTED_ALIAS,`A Checks shouldn't have an alias`,e)]:[]}validateSettingList(e){return e?[new A(k.UNEXPECTED_SETTINGS,`A Checks shouldn't have a setting list`,e)]:[]}validateBody(e){if(!e)return[];if(e instanceof w)return[new A(k.UNEXPECTED_SIMPLE_BODY,`A Checks must have a complex body`,e)];let[t,n]=h(e.body,e=>e instanceof w);return[...this.validateFields(t),...this.validateSubElements(n)]}validateFields(e){return e.flatMap(e=>{if(!e.callee)return[];let t=[],n=[e.callee,...e.args];return m(n)instanceof E&&t.push(...this.validateFieldSetting(n.pop())),(n.length>1||!(n[0]instanceof C))&&t.push(new A(k.INVALID_CHECKS_FIELD,`A check field must be a function expression`,e)),t})}validateFieldSetting(e){let t=L(e),n=t.getErrors(),r=t.getValue();for(let e in r){let t=r[e];switch(e){case`name`:t.length>1&&t.forEach(t=>n.push(new A(k.DUPLICATE_CHECK_SETTING,`'${e}' can only appear once`,t))),t.forEach(t=>{G(t.value)||n.push(new A(k.INVALID_CHECK_SETTING_VALUE,`'${e}' must be a string`,t))});break;default:t.forEach(t=>n.push(new A(k.UNKNOWN_CHECK_SETTING,`Unknown check setting '${e}'`,t)))}}return n}validateSubElements(e){return e.flatMap(e=>(e.parent=this.declarationNode,e.type?new(gl(e))(e,this.publicSymbolTable,this.symbolFactory).validate():[]))}};function gl(e){switch(e.type.value.toLowerCase()){case N.Enum:return al;case N.Table:return dl;case N.TableGroup:return pl;case N.Project:return cl;case N.Ref:return ll;case N.Note:return sl;case N.Indexes:return ol;case N.TablePartial:return ml;case N.Check:return hl;default:return Gc}}function _l(e){return!!R(e).unwrap_or(!1)}function vl(e){return yl(e)}function yl(e){return e instanceof O&&e.expression instanceof gc}function bl(e){return e instanceof S&&e.op?.value===`~`&&K(e.expression)}function xl(e,t,n){e[0]===`public`&&(e=e.slice(1));let r=t;for(let t of e){let e,i=Kc(t);if(r.has(i)){if(e=r.get(i)?.symbolTable,!e)throw Error(`Expect a symbol table in a schema symbol`)}else{e=new il;let t=n.create(Sc,{symbolTable:e});r.set(i,t)}r=e}return r}function Sl(e){return e===`-`||e===`<>`||e===`>`||e===`<`}function Cl(e){if(!(e instanceof O)||!(e.expression instanceof hc)||e.expression.literal?.kind!==g.COLOR_LITERAL)return!1;let t=e.expression.literal.value;if(t.length!==4&&t.length!==7||t[0]!==`#`)return!1;for(let e=1;e<t.length;e+=1)if(!Fc(t[e]))return!1;return!0}function I(e){return e===void 0}function wl(e){if(G(e)||Tl(e)||Hl(e)&&[`true`,`false`,`null`].includes(e.expression.variable.value.toLowerCase())||e instanceof S&&Uc.includes(e.op?.value)&&Tl(e.expression)||e instanceof C)return!0;if(!e||!Wl(e))return!1;let t=Al(e).unwrap();return t.length===2||t.length===3}function Tl(e){return e instanceof S?Uc.includes(e.op.value)?Tl(e.expression):!1:e instanceof O&&e.expression instanceof hc&&e.expression.literal?.kind===g.NUMERIC_LITERAL}function El(e){if(!(e instanceof S)||!Sl(e.op?.value))return!1;let t=R(e.expression).unwrap_or(void 0);return t!==void 0&&t.length>0}function Dl(e){return e instanceof pc&&e.elementList.every(K)}function Ol(e){if(!(e instanceof D||Ul(e)||e instanceof O||e instanceof vc))return!1;for(;e instanceof D||e instanceof vc;)if(e instanceof D){if(e.callee===void 0||e.argumentList===void 0||!e.argumentList.elementList.every(e=>Tl(e)||G(e)||Hl(e)))return!1;e=e.callee}else if(e instanceof vc){if(e.array===void 0||e.indexer===void 0||!e.indexer.elementList.every(e=>!e.colon&&!e.value&&Tl(e.name)))return!1;e=e.array}let t=R(e).unwrap_or(void 0);return t!==void 0&&t.length>0}function L(e){let t={},n=[];return e?(e.elementList.forEach(e=>{if(!e.name)return;if(e.name instanceof O){n.push(new A(k.INVALID_SETTINGS,`A setting name must be a stream of identifiers`,e.name));return}let r=Gl(e.name).unwrap_or(void 0)?.toLowerCase();r&&(t[r]===void 0?t[r]=[e]:t[r].push(e))}),new Mc(t,n)):new Mc({})}function kl(e){let t=e?.type?.value.toLowerCase();switch(t){case N.Enum:case N.Table:case N.Indexes:case N.Note:case N.Project:case N.Ref:case N.TableGroup:case N.TablePartial:case N.Check:return new j(t);default:return new M}}function Al(e){if(!e)return new M;if(!Ul(e))return new j([e]);let t=Al(e.leftExpression).unwrap_or(void 0);return t?(t.push(e.rightExpression),new j(t)):new M}function R(e){if(e===void 0)return new M;let t=Al(e).unwrap_or(void 0);if(!t)return new M;let n=[];for(let e of t){let t=B(e).unwrap_or(void 0);if(typeof t!=`string`)return new M;n.push(t)}return new j(n)}function z(e){if(e===void 0)return new M;let t=Al(e).unwrap_or(void 0);if(!t||t.length===0)return new M;let n=[];if(!K(m(t))){let e=t.pop();if(Dl(e))n=e.elementList;else return new M}let r=t;return r.every(K)?new j({variables:r,tupleElements:n}):new M}function B(e){return K(e)?new j(e.expression.variable.value):new M}function jl(e){return Pl(e)?e instanceof C?new j({functional:[e],nonFunctional:[]}):new j({functional:[],nonFunctional:[e]}):e instanceof pc&&e.elementList.every(Pl)?new j({functional:e.elementList.filter(e=>e instanceof C),nonFunctional:e.elementList.filter(K)}):new M}function V(e){let t=e?.expression.variable?.value;return t===void 0?new M:new j(t)}function H(e){return G(e)?e.expression instanceof gc?new j(e.expression.variable.value):new j(e.expression.literal.value):new M}function Ml(e){return!(e instanceof dc)||!Sl(e.op?.value)?!1:z(e.leftExpression).and_then(()=>z(e.rightExpression)).unwrap_or(void 0)!==void 0}function Nl(e){let t=z(e.leftExpression),n=z(e.rightExpression);if(!t.isOk()||!n.isOk())return!1;let{tupleElements:r}=t.unwrap(),{tupleElements:i}=n.unwrap();return r?.length===i?.length}function Pl(e){return e instanceof O&&e.expression instanceof gc||e instanceof C}function Fl(e,t,n){if(!e||!Hl(e)||t.length===0)return new M;let r=[...t],i=Vl(e).unwrap(),a=r.pop();if(!(a instanceof T))return new M;let o=m(r)instanceof E?r.pop():void 0;if(r.length===3){let e=Vl(r[1]).value;return!e||!Il(e)?new M:new j(n.create(x,{type:i,name:r[0],as:e,alias:r[2],attributeList:o,body:a}))}return r.length===1?new j(n.create(x,{type:i,name:r[0],attributeList:o,body:a})):r.length===0?new j(n.create(x,{type:i,attributeList:o,body:a})):new M}function Il(e){return e?.kind===g.IDENTIFIER&&e.value.toLowerCase()===`as`}function U(e){e&&(e instanceof _?Ll(e):Rl(e))}function Ll(e){e.kind!==g.EOF&&(e.isInvalid=!0)}function Rl(e){if(e instanceof x)U(e.type),U(e.name),U(e.as),U(e.alias),U(e.bodyColon),U(e.attributeList),U(e.body);else if(e instanceof lc)e.identifiers.forEach(U);else if(e instanceof uc)U(e.name),U(e.colon),U(e.value);else if(e instanceof S)U(e.op),U(e.expression);else if(e instanceof dc)U(e.leftExpression),U(e.op),U(e.rightExpression);else if(e instanceof fc)U(e.op),U(e.expression);else if(e instanceof T)U(e.blockOpenBrace),e.body.forEach(U),U(e.blockCloseBrace);else if(e instanceof E)U(e.listOpenBracket),e.commaList.forEach(U),e.elementList.forEach(U),U(e.listCloseBracket);else if(e instanceof pc)U(e.tupleOpenParen),e.commaList.forEach(U),e.elementList.forEach(U),U(e.tupleCloseParen);else if(e instanceof D)U(e.callee),U(e.argumentList);else if(e instanceof w)U(e.callee),e.args.forEach(U);else if(e instanceof O)U(e.expression);else if(e instanceof C)U(e.value);else if(e instanceof gc)U(e.variable);else if(e instanceof hc)U(e.literal);else if(e instanceof mc)throw Error(`This case is handled by the TupleExpressionNode case`);else if(e instanceof vc)U(e.array),U(e.indexer);else if(e instanceof b)e.body.forEach(U),U(e.eof);else if(!(e instanceof _c))throw Error(`Unreachable case in markInvalidNode`)}function zl(e){return!!e?.isInvalid}function W(...e){return e.filter(e=>e!==void 0)}function Bl(e){if(e instanceof b)return W(...e.body,e.eof);if(e instanceof x)return W(e.type,e.name,e.as,e.alias,e.attributeList,e.bodyColon,e.body);if(e instanceof uc)return W(e.name,e.colon,e.value);if(e instanceof lc)return e.identifiers;if(e instanceof hc)return e.literal?[e.literal]:[];if(e instanceof gc)return W(e.variable);if(e instanceof S)return W(e.op,e.expression);if(e instanceof dc)return W(e.leftExpression,e.op,e.rightExpression);if(e instanceof fc)return W(e.expression,e.op);if(e instanceof C)return W(e.value);if(e instanceof w)return W(e.callee,...e.args);if(e instanceof T)return W(e.blockOpenBrace,...e.body,e.blockCloseBrace);if(e instanceof E)return W(e.listOpenBracket,...Rc(e.elementList,e.commaList),e.listCloseBracket);if(e instanceof pc)return W(e.tupleOpenParen,...Rc(e.elementList,e.commaList),e.tupleCloseParen);if(e instanceof D)return W(e.callee,e.argumentList);if(e instanceof O)return W(e.expression);if(e instanceof vc)return W(e.array,e.indexer);throw e instanceof mc?Error(`This case is already handled by TupleExpressionNode`):Error(`Unreachable - no other possible cases`)}function Vl(e){return K(e)?new j(e.expression.variable):new M}function G(e){return e instanceof O&&(e.expression instanceof gc&&e.expression.variable instanceof _&&e.expression.variable.kind===g.QUOTED_STRING||e.expression instanceof hc&&e.expression.literal?.kind===g.STRING_LITERAL)}function K(e){return e instanceof O&&e.expression instanceof gc&&e.expression.variable instanceof _}function Hl(e){return e instanceof O&&e.expression instanceof gc&&e.expression.variable?.kind===g.IDENTIFIER}function Ul(e){return e instanceof dc&&e.leftExpression instanceof v&&e.rightExpression instanceof v&&e.op?.value===`.`}function Wl(e){return K(e)?!0:Ul(e)&&K(e.rightExpression)&&Wl(e.leftExpression)}function Gl(e){if(e===void 0)return new M;let t=e.identifiers.map(e=>e.value).join(` `);return t===``?new M:new j(t)}function Kl(e){return R(e.name).map(e=>e.join(`.`))}var ql=class{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(){let 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 t=0;t<e.length;t+=1)if(e[t]!==this.peek(t))return!1;return!0}match(e){return this.check(e)?(e.split(``).forEach(()=>this.advance()),!0):!1}addToken(e,t=!1){this.tokens.push(this.createToken(e,t))}createToken(e,t=!1){return _.create(e,this.start,this.current,this.text.substring(this.start.offset,this.current.offset),t)}lex(){return this.scanTokens(),this.tokens.push(_.create(g.EOF,this.start,this.current,``,!1)),this.gatherTrivia(),this.gatherInvalid(),new Mc(this.tokens,this.errors)}scanTokens(){for(;!this.isAtEnd();){let e=this.advance();switch(e){case` `:this.addToken(g.SPACE);break;case`\r`:break;case`
|
|
3
|
+
`:this.addToken(g.NEWLINE);break;case` `:this.addToken(g.TAB);break;case`,`:this.addToken(g.COMMA);break;case`(`:this.addToken(g.LPAREN);break;case`)`:this.addToken(g.RPAREN);break;case`[`:this.addToken(g.LBRACKET);break;case`]`:this.addToken(g.RBRACKET);break;case`{`:this.addToken(g.LBRACE);break;case`}`:this.addToken(g.RBRACE);break;case`;`:this.addToken(g.SEMICOLON);break;case`:`:this.addToken(g.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(ec(e)){this.operator(e);break}if(Nc(e)){this.identifier();break}if(Pc(e)){this.numericLiteralOrIdentifier();break}this.addToken(g.OP,!0),this.errors.push(new A(k.UNKNOWN_SYMBOL,`Unexpected token '${e}'`,this.createToken(g.OP,!0)));break}this.start={...this.current}}}gatherTrivia(){let e=!0,t=[],n,r=[];for(let i of this.tokens)$s(i)?(t.push(i),i.kind===g.NEWLINE&&n&&(n.trailingTrivia=t,e=!0,n=void 0,t=[])):(e?i.leadingTrivia=t:n.trailingTrivia=t,r.push(i),t=[],n=i,e=!1);this.tokens=r}gatherInvalid(){let e,t=[],n=[];for(e=0;e<this.tokens.length&&zl(this.tokens[e]);e+=1)n.push(this.tokens[e]);let r=this.tokens[e];for(r.leadingInvalid=[...n,...r.leadingInvalid];e<this.tokens.length;e+=1){let n=this.tokens[e];zl(n)?r.trailingInvalid.push(n):(r=n,t.push(n))}this.tokens=t}consumeUntil(e,t,{allowNewline:n,allowEof:r,raw:i,consumeStopSequence:a=!0}){let o=``;for(;!this.isAtEnd()&&(n||!this.check(`
|
|
4
|
+
`))&&!this.check(t);)this.peek()===`\\`&&!i?(this.advance(),o+=this.escapedString()):o+=this.advance();if(this.isAtEnd()&&!r){let t=this.createToken(e,!0);this.tokens.push(t),this.errors.push(new A(k.UNEXPECTED_EOF,`EOF reached while parsing`,t));return}if(this.check(`
|
|
5
|
+
`)&&!n){let t=this.createToken(e,!0);this.tokens.push(t),this.errors.push(new A(k.UNEXPECTED_NEWLINE,`Invalid newline encountered while parsing`,t));return}a&&this.match(t),this.tokens.push(_.create(e,this.start,this.current,o,!1))}singleLineStringLiteral(){this.consumeUntil(g.STRING_LITERAL,`'`,{allowNewline:!1,allowEof:!1,raw:!1})}multilineStringLiteral(){this.consumeUntil(g.STRING_LITERAL,`'''`,{allowNewline:!0,allowEof:!1,raw:!1})}functionExpression(){this.consumeUntil(g.FUNCTION_EXPRESSION,"`",{allowNewline:!0,allowEof:!1,raw:!0})}quotedVariable(){this.consumeUntil(g.QUOTED_STRING,`"`,{allowNewline:!1,allowEof:!1,raw:!1})}singleLineComment(){this.consumeUntil(g.SINGLE_LINE_COMMENT,`
|
|
6
|
+
`,{allowNewline:!0,allowEof:!0,raw:!0,consumeStopSequence:!1})}multilineComment(){this.consumeUntil(g.MULTILINE_COMMENT,`*/`,{allowNewline:!0,allowEof:!1,raw:!0})}identifier(){for(;!this.isAtEnd()&&Ic(this.peek());)this.advance();this.addToken(g.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;default:break}this.addToken(g.OP)}numericLiteralOrIdentifier(){let e=0;if(this.isAtEnd())return this.addToken(g.NUMERIC_LITERAL);for(;!this.isAtEnd();){let t=this.check(`.`);if(e+=t?1:0,e>1)break;if(!t&&this.current.offset===this.text.length-1)return this.advance(),this.addToken(g.NUMERIC_LITERAL);if(!t&&!Ic(this.peek()))return this.addToken(g.NUMERIC_LITERAL);if(!t&&!Pc(this.peek()))break;this.advance()}if(e>0){for(;!this.isAtEnd()&&(this.check(`.`)||Ic(this.peek()));)this.advance();let e=this.createToken(g.NUMERIC_LITERAL,!0);this.tokens.push(e),this.errors.push(new A(k.UNKNOWN_TOKEN,`Invalid number`,e))}else{for(;!this.isAtEnd()&&Ic(this.peek());)this.advance();let e=this.createToken(g.IDENTIFIER,!1);this.tokens.push(e)}}colorLiteral(){for(;!this.isAtEnd()&&Ic(this.peek());)this.advance();this.addToken(g.COLOR_LITERAL)}escapedString(){let 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
|
+
`)&&this.advance(),``;case`
|
|
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 t=``;for(let n=0;n<=3;n+=1){if(this.isAtEnd()||!Ic(this.peek()))return this.errors.push(new A(k.INVALID_ESCAPE_SEQUENCE,`Invalid unicode escape sequence '\\u${t}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`,_.create(g.STRING_LITERAL,e,this.current,`\\u${t}`,!0))),`\\u${t}`;t+=this.advance()}return String.fromCharCode(parseInt(t,16))}default:return this.text[this.current.offset-1]}}};let q=function(e){return e[e.ListExpression=0]=`ListExpression`,e[e.GroupExpression=1]=`GroupExpression`,e[e.BlockExpression=2]=`BlockExpression`,e}({});var Jl=class{constructor(){this.stack=[],this.numberOfNestedLParens=0,this.numberOfNestedLBrackets=0,this.numberOfNestedLBraces=0}push(e){this.stack.push(e),e===q.ListExpression&&(this.numberOfNestedLBrackets+=1),e===q.GroupExpression&&(this.numberOfNestedLParens+=1),e===q.BlockExpression&&(this.numberOfNestedLBraces+=1)}pop(){let e=this.stack.pop();return e===q.ListExpression&&--this.numberOfNestedLBrackets,e===q.GroupExpression&&--this.numberOfNestedLParens,e===q.BlockExpression&&--this.numberOfNestedLBraces,e}top(){return m(this.stack)}isWithinGroupExpressionContext(){return this.numberOfNestedLParens>0}isWithinListExpressionContext(){return this.numberOfNestedLBrackets>0}isWithinBlockExpressionContext(){return this.numberOfNestedLBraces>0}withContextDo(e,t){return()=>{this.push(e);try{return t()}finally{this.pop()}}}findHandlerContext(e,t){if(!(this.numberOfNestedLBraces<=0&&this.numberOfNestedLBrackets<=0&&this.numberOfNestedLParens<=0))for(let n=t;n<e.length-1;n+=1)switch(e[n].kind){case g.COMMA:if(this.isWithinGroupExpressionContext()||this.isWithinListExpressionContext())return[...this.stack].reverse().find(e=>[q.GroupExpression,q.ListExpression].includes(e));break;case g.RPAREN:if(this.isWithinGroupExpressionContext())return q.GroupExpression;break;case g.RBRACE:if(this.isWithinBlockExpressionContext())return q.BlockExpression;break;case g.RBRACKET:if(this.isWithinListExpressionContext())return q.ListExpression;break;default:break}}},Yl=class{constructor(e){this.generator=e}create(e,t){return new e(t,this.generator.nextId())}},J=class{constructor(e,t,n){this.token=e,this.partialNode=t,this.handlerContext=n}},Xl=class{constructor(e,t){this.current=0,this.errors=[],this.contextStack=new Jl,this.synchronizeProgram=()=>{let e=this.peek();e.kind===g.EOF?this.logError(e,k.UNEXPECTED_EOF,`Unexpected EOF`):U(this.advance())},this.synchronizeElementDeclarationName=()=>{for(;!this.isAtEnd();){let e=this.peek();if(Il(e)||this.check(g.COLON,g.LBRACE,g.LBRACKET))break;U(e),this.advance()}},this.synchronizeElementDeclarationAlias=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(g.COLON,g.LBRACE,g.LBRACKET))break;U(e),this.advance()}},this.blockExpression=this.contextStack.withContextDo(q.BlockExpression,()=>{let e={body:[]},t=()=>this.nodeFactory.create(T,e);try{this.consume(`Expect an opening brace '{'`,g.LBRACE),e.blockOpenBrace=this.previous()}catch(e){if(!(e instanceof J))throw e;if(!this.canHandle(e))throw new J(e.token,t(),e.handlerContext);this.synchronizeBlock()}for(;!this.isAtEnd()&&!this.check(g.RBRACE);)try{e.body.push(this.canBeField()?this.fieldDeclaration():this.expression())}catch(n){if(!(n instanceof J))throw n;if(e.body.push(n.partialNode),!this.canHandle(n))throw new J(n.token,t(),n.handlerContext);this.synchronizeBlock()}try{this.consume(`Expect a closing brace '}'`,g.RBRACE),e.blockCloseBrace=this.previous()}catch(e){if(!(e instanceof J))throw e;if(!this.canHandle(e))throw new J(e.token,t(),e.handlerContext);this.synchronizeBlock()}return t()}),this.synchronizeBlock=()=>{if(!this.check(g.RBRACE))for(U(this.advance());!this.isAtEnd();){let e=this.peek();if(this.check(g.RBRACE)||rc(this.previous(),e))break;U(e),this.advance()}},this.tupleExpression=this.contextStack.withContextDo(q.GroupExpression,()=>{let e={elementList:[],commaList:[]},t=()=>this.nodeFactory.create(mc,{groupOpenParen:e.tupleOpenParen,groupCloseParen:e.tupleCloseParen,expression:e.elementList[0]}),n=()=>this.nodeFactory.create(pc,e);try{this.consume(`Expect an opening parenthesis '('`,g.LPAREN),e.tupleOpenParen=this.previous()}catch(e){if(!(e instanceof J))throw e;if(!this.canHandle(e))throw new J(e.token,n(),e.handlerContext);this.synchronizeTuple()}if(!this.isAtEnd()&&!this.check(g.RPAREN))try{e.elementList.push(this.normalExpression())}catch(n){if(!(n instanceof J))throw n;if(e.elementList.push(n.partialNode),!this.canHandle(n))throw new J(n.token,t(),n.handlerContext);this.synchronizeTuple()}for(;!this.isAtEnd()&&!this.check(g.RPAREN);)try{this.consume(`Expect a comma ','`,g.COMMA),e.commaList.push(this.previous()),e.elementList.push(this.normalExpression())}catch(t){if(!(t instanceof J))throw t;if(t.partialNode instanceof v&&e.elementList.push(t.partialNode),!this.canHandle(t))throw new J(t.token,n(),t.handlerContext);this.synchronizeTuple()}try{this.consume(`Expect a closing parenthesis ')'`,g.RPAREN),e.tupleCloseParen=this.previous()}catch(e){if(!(e instanceof J))throw e;if(!this.canHandle(e))throw new J(e.token,n(),e.handlerContext);this.synchronizeTuple()}return e.elementList.length===1?t():n()}),this.synchronizeTuple=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(g.RPAREN,g.COMMA))break;U(e),this.advance()}},this.listExpression=this.contextStack.withContextDo(q.ListExpression,()=>{let e={elementList:[],commaList:[]},t=()=>this.nodeFactory.create(E,e);try{this.consume(`Expect an opening bracket '['`,g.LBRACKET),e.listOpenBracket=this.previous()}catch(e){if(!(e instanceof J))throw e;if(!this.canHandle(e))throw new J(e.token,t(),e.handlerContext);this.synchronizeList()}if(!this.isAtEnd()&&!this.check(g.RBRACKET))try{e.elementList.push(this.attribute())}catch(n){if(!(n instanceof J))throw n;if(e.elementList.push(n.partialNode),!this.canHandle(n))throw new J(n.token,t(),n.handlerContext);this.synchronizeList()}for(;!this.isAtEnd()&&!this.check(g.RBRACKET);)try{this.consume(`Expect a comma ','`,g.COMMA),e.commaList.push(this.previous()),e.elementList.push(this.attribute())}catch(n){if(!(n instanceof J))throw n;if(n.partialNode instanceof v&&e.elementList.push(n.partialNode),!this.canHandle(n))throw new J(n.token,t(),n.handlerContext);this.synchronizeList()}try{this.consume(`Expect a closing bracket ']'`,g.RBRACKET),e.listCloseBracket=this.previous()}catch(e){if(!(e instanceof J))throw e;if(!this.canHandle(e))throw new J(e.token,t(),e.handlerContext);this.synchronizeList()}return t()}),this.synchronizeList=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(g.COMMA,g.RBRACKET))break;U(e),this.advance()}},this.synchronizeAttributeName=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(g.COMMA,g.RBRACKET,g.COLON))break;U(e),this.advance()}},this.synchronizeAttributeValue=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(g.COMMA,g.RBRACKET))break;U(e),this.advance()}},this.tokens=e,this.nodeFactory=new Yl(t)}isAtEnd(){return this.current>=this.tokens.length||this.tokens[this.current].kind===g.EOF}advance(){return this.isAtEnd()?m(this.tokens):this.tokens[this.current++]}peek(e=0){return e+this.current>=this.tokens.length?m(this.tokens):this.tokens[this.current+e]}match(...e){let t=this.check(...e);return t&&this.advance(),t}check(...e){let t=this.peek();return e.includes(t.kind)}previous(){return this.tokens[this.current-1]}canHandle(e){return e.handlerContext===void 0||e.handlerContext===this.contextStack.top()}consume(e,...t){if(!this.match(...t))throw this.logError(this.peek(),k.UNEXPECTED_TOKEN,e),new J(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}discardUntil(e,...t){if(this.isAtEnd()||!this.check(...t)){for(U(this.peek()),this.logError(this.advance(),k.UNEXPECTED_TOKEN,e);!this.isAtEnd()&&!this.check(...t);)U(this.advance());return!this.isAtEnd()}return!0}gatherInvalid(){let e=[],t=[],n,r=0;for(;r<this.tokens.length&&this.tokens[r].isInvalid;r+=1)t.push(this.tokens[r]);for(n=this.tokens[r],n.leadingInvalid=[...t,...n.leadingInvalid],e.push(n),r+=1;r<this.tokens.length;r+=1){let t=this.tokens[r];t.isInvalid?n.trailingInvalid.push(t):(n=t,e.push(n))}this.tokens=e}parse(){let e=this.program(),t=this.advance(),n=this.nodeFactory.create(b,{body:e,eof:t});return this.gatherInvalid(),new Mc({ast:n,tokens:this.tokens},this.errors)}program(){let e=[];for(;!this.isAtEnd();)try{let t=this.elementDeclaration();e.push(t)}catch(t){if(!(t instanceof J))throw t;e.push(t.partialNode),this.synchronizeProgram()}return e}elementDeclaration(){let e={},t=()=>this.nodeFactory.create(x,e);try{this.consume(`Expect an identifier`,g.IDENTIFIER),e.type=this.previous()}catch(e){throw e instanceof J?new J(e.token,t(),e.handlerContext):e}if(!this.check(g.COLON,g.LBRACE,g.LBRACKET))try{e.name=this.normalExpression()}catch(n){if(!(n instanceof J))throw n;if(e.name=n.partialNode,!this.canHandle(n))throw new J(n.token,t(),n.handlerContext);this.synchronizeElementDeclarationName()}if(Il(this.peek()))if(e.as=this.advance(),this.check(g.COLON,g.LBRACE,g.LBRACKET))this.logError(this.peek(),k.UNEXPECTED_TOKEN,`Expect an alias`);else try{e.alias=this.normalExpression()}catch(n){if(!(n instanceof J))throw n;if(e.alias=n.partialNode,!this.canHandle(n))throw new J(n.token,t(),n.handlerContext);this.synchronizeElementDeclarationAlias()}try{e.attributeList=this.check(g.LBRACKET)?this.listExpression():void 0}catch(n){throw n instanceof J?(e.attributeList=n.partialNode,new J(n.token,t(),n.handlerContext)):n}if(!this.discardUntil(`Expect an opening brace '{' or a colon ':'`,g.LBRACE,g.COLON))return t();try{if(this.match(g.COLON)){e.bodyColon=this.previous();let t=this.expression();t instanceof x?(U(t),this.logError(t,k.UNEXPECTED_ELEMENT_DECLARATION,`An element's simple body must not be an element declaration`)):e.body=t}else e.body=this.blockExpression()}catch(n){throw n instanceof J?(e.body=n.partialNode,new J(n.token,t(),n.handlerContext)):n}return this.nodeFactory.create(x,e)}fieldDeclaration(){let e={},t=()=>this.nodeFactory.create(x,e);try{this.consume(`Expect an identifier`,g.IDENTIFIER),e.type=this.previous()}catch(n){throw n instanceof J?(e.type=n.partialNode,new J(n.token,t(),n.handlerContext)):n}try{this.consume(`Expect a colon ':'`,g.COLON),e.bodyColon=this.previous()}catch(n){throw n instanceof J?(e.bodyColon=n.partialNode,new J(n.token,t(),n.handlerContext)):n}try{let t=this.expression();t instanceof x?this.errors.push(new A(k.INVALID_ELEMENT_IN_SIMPLE_BODY,`Simple body cannot be an element declaration`,t)):e.body=t}catch(n){throw n instanceof J?(e.body=n.partialNode,new J(n.token,t(),n.handlerContext)):n}return this.nodeFactory.create(x,e)}expression(){let e={args:[]},t=()=>Fl(e.callee,e.args,this.nodeFactory).unwrap_or(this.nodeFactory.create(w,e));try{e.callee=this.normalExpression()}catch(n){throw n instanceof J?(e.callee=n.partialNode,new J(n.token,t(),n.handlerContext)):n}if(this.shouldStopExpression())return t();let n=e.callee;for(;!this.shouldStopExpression();){ic(this.previous())||this.logError(n,k.MISSING_SPACES,`Expect a following space`);try{n=this.normalExpression(),e.args.push(n)}catch(r){throw r instanceof J?(n=r.partialNode,e.args.push(n),new J(r.token,t(),r.handlerContext)):r}}return t()}shouldStopExpression(){if(this.isAtEnd()||nc(this.previous()))return!0;let e=this.peek().kind;return e===g.RBRACE||e===g.RBRACKET||e===g.RPAREN||e===g.COMMA||e===g.COLON}normalExpression(){return this.expression_bp(0)}expression_bp(e){let t=this.leftExpression_bp();for(;!this.isAtEnd();){let n=this.peek();if(n.kind===g.LPAREN){let{left:r}=nu(n);if(r<e||rc(this.previous(),n)&&!this.contextStack.isWithinGroupExpressionContext()&&!this.contextStack.isWithinListExpressionContext())break;try{t=this.nodeFactory.create(D,{callee:t,argumentList:this.tupleExpression()})}catch(e){throw e instanceof J?(t=this.nodeFactory.create(D,{callee:t,argumentList:e.partialNode}),new J(e.token,t,e.handlerContext)):e}}else if(n.kind===g.LBRACKET){if(ic(this.previous()))break;try{t=this.nodeFactory.create(vc,{expression:t,indexer:this.listExpression()})}catch(e){throw e instanceof J?(t=this.nodeFactory.create(vc,{expression:t,indexer:e.partialNode}),new J(e.token,t,e.handlerContext)):e}}else if(tc(n)){let r=n,i=nu(r);if(i.left!==null){if(i.left<=e)break;this.advance(),t=this.nodeFactory.create(fc,{expression:t,op:r})}else{let n=Ql(r);if(n.left===null||n.left<=e)break;this.advance();try{t=this.nodeFactory.create(dc,{leftExpression:t,op:r,rightExpression:r.value===`.`?this.extractOperand():this.expression_bp(n.right)})}catch(e){throw e instanceof J?(t=this.nodeFactory.create(dc,{leftExpression:t,op:r,rightExpression:e.partialNode}),new J(e.token,t,e.handlerContext)):e}}}else break}return t}leftExpression_bp(){let e;if(tc(this.peek())){let t={};t.op=this.peek();let n=eu(t.op);if(n.right===null)throw this.logError(t.op,k.UNKNOWN_PREFIX_OP,`Unexpected '${t.op.value}' in an expression`),new J(t.op,this.nodeFactory.create(_c,{pre:t.op}),this.contextStack.findHandlerContext(this.tokens,this.current));this.advance();try{t.expression=this.expression_bp(n.right)}catch(e){throw e instanceof J?(t.expression=e.partialNode,new J(e.token,this.nodeFactory.create(S,t),e.handlerContext)):e}e=this.nodeFactory.create(S,t)}else if(e=this.extractOperand(),e instanceof _c)throw new J(this.peek(),this.nodeFactory.create(_c,{pre:this.peek()}),this.contextStack.findHandlerContext(this.tokens,this.current));return e}extractOperand(){return this.check(g.NUMERIC_LITERAL,g.STRING_LITERAL,g.COLOR_LITERAL,g.QUOTED_STRING,g.IDENTIFIER)?this.primaryExpression():this.check(g.FUNCTION_EXPRESSION)?this.functionExpression():this.check(g.LBRACKET)?this.listExpression():this.check(g.LBRACE)?this.blockExpression():this.check(g.LPAREN)?this.tupleExpression():(this.peek().kind===g.EOF?this.logError(this.peek(),k.UNEXPECTED_EOF,`Unexpected EOF`):this.logError(this.peek(),k.INVALID_OPERAND,`Invalid start of operand "${this.peek().value}"`),this.nodeFactory.create(_c,{pre:this.previous()}))}functionExpression(){let e={};try{this.consume(`Expect a function expression`,g.FUNCTION_EXPRESSION),e.value=this.previous()}catch(t){throw t instanceof J?new J(t.token,this.nodeFactory.create(C,e),t.handlerContext):t}return this.nodeFactory.create(C,e)}canBeField(){return this.peek().kind===g.IDENTIFIER&&this.peek(1).kind===g.COLON}primaryExpression(){if(this.match(g.COLOR_LITERAL,g.STRING_LITERAL,g.NUMERIC_LITERAL))return this.nodeFactory.create(O,{expression:this.nodeFactory.create(hc,{literal:this.previous()})});if(this.match(g.QUOTED_STRING,g.IDENTIFIER))return this.nodeFactory.create(O,{expression:this.nodeFactory.create(gc,{variable:this.previous()})});throw this.logError(this.peek(),k.UNEXPECTED_TOKEN,`Expect a variable or literal`),new J(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}attribute(){let e={};if(this.check(g.COLON,g.RBRACKET,g.COMMA)){let t=this.peek();this.logError(t,k.EMPTY_ATTRIBUTE_NAME,`Expect a non-empty attribute name`),e.name=this.nodeFactory.create(lc,{identifiers:[]})}else try{e.name=this.attributeName()}catch(t){if(!(t instanceof J))throw t;if(e.name=t.partialNode,!this.canHandle(t))throw new J(t.token,this.nodeFactory.create(uc,e),t.handlerContext);this.synchronizeAttributeName()}return this.match(g.COLON)&&(e.colon=this.previous(),e.value=this.attributeValue()),this.nodeFactory.create(uc,e)}attributeValue(){let e;try{e=this.peek().kind===g.IDENTIFIER&&this.peek(1).kind===g.IDENTIFIER?this.attributeName():this.normalExpression()}catch(t){if(!(t instanceof J)||!this.canHandle(t))throw t;e=t.partialNode,this.synchronizeAttributeValue()}return e}attributeName(){let e=[];if(this.peek().kind!==g.IDENTIFIER)return this.primaryExpression();for(;!this.isAtEnd()&&!this.check(g.COLON,g.COMMA,g.RBRACKET);)try{this.consume(`Expect an identifier`,g.IDENTIFIER),e.push(this.previous())}catch(t){throw t instanceof J?new J(t.token,this.nodeFactory.create(lc,{identifiers:e}),t.handlerContext):t}return this.nodeFactory.create(lc,{identifiers:e})}logError(e,t,n){this.errors.push(new A(t,n,e))}},Zl={"+":{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 Ql(e){return Zl[e.value]||{left:null,right:null}}var $l={"+":{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 eu(e){return $l[e.value]||{left:null,right:null}}var tu={"(":{left:14,right:null}};function nu(e){return tu[e.value]||{left:null,right:null}}var ru=class{constructor(e,t){this.ast=e,this.symbolFactory=t,this.publicSchemaSymbol=this.symbolFactory.create(Sc,{symbolTable:new il}),this.ast.symbol=this.publicSchemaSymbol,this.ast.symbol.declaration=this.ast}validate(){let e=[];this.ast.body.forEach(t=>{if(t.parent=this.ast,t.type===void 0)return;let n=new(gl(t))(t,this.publicSchemaSymbol.symbolTable,this.symbolFactory);e.push(...n.validate())});let t=this.ast.body.filter(e=>kl(e).unwrap_or(void 0)===N.Project);return t.length>1&&t.forEach(t=>e.push(new A(k.PROJECT_REDEFINED,`Only one project can exist`,t))),new Mc(this.ast,e)}},iu=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return[]}},au=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.bindBody(this.declarationNode.body)}bindBody(e){if(!e||e instanceof w)return[];let t=e.body.filter(e=>e instanceof x);return this.bindSubElements(t)}bindSubElements(e){return e.flatMap(e=>e.type?new(gu(e))(e,this.ast,this.symbolFactory).bind():[])}},ou=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof T?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e||e instanceof w)return[];let t=e.body.filter(e=>e instanceof w);return this.bindSubElements(t)}bindSubElements(e){return e.flatMap(e=>e.type?new(gu(e))(e,this.ast,this.symbolFactory).bind():[])}},su=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return!(this.declarationNode.parent instanceof x)||kl(this.declarationNode.parent).unwrap_or(void 0)!==N.Table||!(this.declarationNode.body instanceof T)?[]:this.bindBody(this.declarationNode.body)}bindBody(e){if(!e)return[];if(e instanceof w)return this.bindFields([e]);let[t,n]=h(e.body,e=>e instanceof w);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return e.flatMap(e=>{if(!e.callee)return[];let t=R(this.declarationNode.parent.name).map(e=>e.join(`.`)).unwrap_or(`<unnamed>`),n=this.declarationNode.parent.symbol.symbolTable;return[e.callee,...e.args].flatMap(_u).flatMap(e=>e.variables.length+e.tupleElements.length>1?[]:e.variables.length?e.variables[0]:e.tupleElements).flatMap(e=>{let r=V(e).unwrap_or(void 0);if(r===void 0)return[];let i=Jc(r),a=n.get(i);return a?(e.referee=a,a.references.push(e),[]):new A(k.BINDING_ERROR,`No column named '${r}' inside Table '${t}'`,e)})})}bindSubElements(e){return e.flatMap(e=>e.type?new(gu(e))(e,this.ast,this.symbolFactory).bind():[])}},cu=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.bindBody(this.declarationNode.body)}bindBody(e){if(!e||e instanceof w)return[];let t=e.body.filter(e=>e instanceof x);return this.bindSubElements(t)}bindSubElements(e){return e.flatMap(e=>e.type?new(gu(e))(e,this.ast,this.symbolFactory).bind():[])}},lu=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof T?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e||e instanceof w)return[];let t=e.body.filter(e=>e instanceof x);return this.bindSubElements(t)}bindSubElements(e){return e.flatMap(e=>e.type?new(gu(e))(e,this.ast,this.symbolFactory).bind():[])}},uu=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return!(this.declarationNode.parent instanceof b)&&kl(this.declarationNode.parent).unwrap_or(void 0)!==N.Project?[]:this.bindBody(this.declarationNode.body)}bindBody(e){if(!e)return[];if(e instanceof w)return this.bindFields([e]);let[t,n]=h(e.body,e=>e instanceof w);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return e.flatMap(e=>e.callee?[e.callee,...e.args].flatMap(_u).flatMap(e=>{let t=e.tupleElements.length?e.tupleElements:e.variables.pop(),n=e.variables.pop();if(!t||!n)return[];Array.isArray(t)||(t=[t]);let r=e.variables;return t.flatMap(e=>vu(this.ast,[...r.map(e=>({node:e,kind:F.Schema})),{node:n,kind:F.Table},{node:e,kind:F.Column}]))}):[])}bindSubElements(e){return e.flatMap(e=>e.type?new(gu(e))(e,this.ast,this.symbolFactory).bind():[])}},du=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof T?this.bindBody(this.declarationNode.body):[]}resolvePartialInjections(){let{body:e}=this.declarationNode;return(e?e instanceof T?e.body:[e]:[]).filter(e=>e instanceof w&&bl(e.callee)).reverse().flatMap(e=>{let t=z(e.callee.expression).unwrap_or(void 0);if(!t)return[];let n=t.variables.pop(),r=t.variables;if(!n)return[];let i=vu(this.ast,[...r.map(e=>({node:e,kind:F.Schema})),{node:n,kind:F.TablePartial}]);return i.length?i:(n.referee?.symbolTable?.forEach(t=>{let r=B(t.declaration.callee).unwrap_or(void 0);if(r===void 0)return;let i=this.symbolFactory.create(jc,{declaration:e,tablePartialSymbol:n.referee}),a=Jc(r),o=this.declarationNode.symbol?.symbolTable;o?.has(a)||o?.set(a,i)}),[])})}bindBody(e){if(!e)return[];if(e instanceof w)return this.bindFields([e]);let[t,n]=h(e.body,e=>e instanceof w);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return(e=>e.flatMap(e=>{if(!e.callee)return[];let t=[],n=[e.callee,...e.args];if(m(n)instanceof E){let e=L(m(n)).getValue();t.push(...e.ref?.flatMap(e=>e.value?this.bindInlineRef(e.value):[])||[]),t.push(...e.default?.flatMap(e=>e.value?this.tryToBindEnumFieldRef(e.value):[])||[]),n.pop()}return n[1]&&this.tryToBindColumnType(n[1]),t}))(e.filter(e=>!bl(e.callee)))}tryToBindColumnType(e){let t=z(e).unwrap_or(void 0);if(!t)return;let n=t.variables.pop(),r=t.variables;n&&vu(this.ast,[...r.map(e=>({node:e,kind:F.Schema})),{node:n,kind:F.Enum}])}tryToBindEnumFieldRef(e){if(G(e))return[];if(K(e)){let t=e.expression.variable?.value?.toLowerCase();if(t&&Hc.includes(t))return[]}let t=z(e).unwrap_or(void 0);if(!t)return[];let n=t.variables.pop(),r=t.variables.pop();if(!n||!r)return[];let i=t.variables;return vu(this.ast,[...i.map(e=>({node:e,kind:F.Schema})),{node:r,kind:F.Enum},{node:n,kind:F.EnumField}])}bindInlineRef(e){return _u(e).flatMap(e=>{let t=e.variables.pop(),n=e.variables.pop();if(!t)return[];let r=e.variables;return n?vu(this.ast,[...r.map(e=>({node:e,kind:F.Schema})),{node:n,kind:F.Table},{node:t,kind:F.Column}]):vu(this.declarationNode,[{node:t,kind:F.Column}])})}bindSubElements(e){return e.flatMap(e=>e.type?new(gu(e))(e,this.ast,this.symbolFactory).bind():[])}},fu=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof T?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e)return[];if(e instanceof w)return this.bindFields([e]);let[t,n]=h(e.body,e=>e instanceof w);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return e.flatMap(e=>e.callee?[e.callee,...e.args].flatMap(_u).flatMap(e=>{let t=e.variables.pop();if(!t)return[];let n=e.variables;return vu(this.ast,[...n.map(e=>({node:e,kind:F.Schema})),{node:t,kind:F.Table}])}):[])}bindSubElements(e){return e.flatMap(e=>e.type?new(gu(e))(e,this.ast,this.symbolFactory).bind():[])}},pu=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof T?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e)return[];if(e instanceof w)return this.bindFields([e]);let[t,n]=h(e.body,e=>e instanceof w);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return e.flatMap(e=>{if(!e.callee)return[];let t=[],n=[e.callee,...e.args];if(m(n)instanceof E){let e=L(m(n)).getValue();t.push(...e.ref?.flatMap(e=>e.value?this.bindInlineRef(e.value):[])||[]),n.pop()}return n[1]&&this.tryToBindColumnType(n[1]),t})}tryToBindColumnType(e){let t=z(e).unwrap_or(void 0);if(!t)return;let n=t.variables.pop(),r=t.variables;n&&vu(this.ast,[...r.map(e=>({node:e,kind:F.Schema})),{node:n,kind:F.Enum}])}bindInlineRef(e){return _u(e).flatMap(e=>{let t=e.variables.pop(),n=e.variables.pop();if(!t)return[];let r=e.variables;return n?vu(this.ast,[...r.map(e=>({node:e,kind:F.Schema})),{node:n,kind:F.Table},{node:t,kind:F.Column}]):vu(this.declarationNode,[{node:t,kind:F.Column}])})}bindSubElements(e){return e.flatMap(e=>e.type?new(gu(e))(e,this.ast,this.symbolFactory).bind():[])}};function mu(e){return[Kc,qc,Yc,Zc,Jc,Xc,Qc,el,tl].map(t=>t(e))}function hu(e){if(e instanceof Sc)return F.Schema;if(e instanceof Tc)return F.Table;if(e instanceof Ec)return F.Column;if(e instanceof Cc)return F.Enum;if(e instanceof wc)return F.EnumField;if(e instanceof Dc)return F.TableGroup;if(e instanceof Oc)return F.TableGroupField;if(e instanceof kc)return F.TablePartial;if(e instanceof jc)return F.Column;if(e instanceof Ac)return F.PartialInjection;throw Error(`No other possible symbol kind in getSymbolKind`)}function gu(e){switch(e.type.value.toLowerCase()){case N.Enum:return ou;case N.Table:return du;case N.TableGroup:return fu;case N.Project:return lu;case N.Ref:return uu;case N.Note:return cu;case N.Indexes:return su;case N.TablePartial:return pu;case N.Check:return iu;default:return au}}function _u(e){if(!e)return[];if(K(e))return[{variables:[e],tupleElements:[]}];if(e instanceof dc){let t=z(e).unwrap_or(void 0);return t?[t]:[..._u(e.leftExpression),..._u(e.rightExpression)]}if(e instanceof S||e instanceof fc)return _u(e.expression);if(e instanceof pc){let t=z(e).unwrap_or(void 0);return t?[t]:e.elementList.flatMap(_u)}return[]}function vu(e,t){if(!e.symbol?.symbolTable)throw Error(`lookupAndBindInScope should only be called with initial scope having a symbol table`);let n=e.symbol.symbolTable,r=hu(e.symbol),i=e instanceof x?Kl(e).unwrap_or(`<invalid name>`):Wc;if(e instanceof b&&t.length){let{node:e,kind:n}=t[0];V(e).unwrap_or(`<unnamed>`)===`public`&&n===F.Schema&&t.shift()}for(let e of t){let{node:t,kind:a}=e,o=V(t).unwrap_or(`<unnamed>`),s=nl(o,a),c=n.get(s);if(!c)return[new A(k.BINDING_ERROR,`${a} '${o}' does not exist in ${i===void 0?`global scope`:`${r} '${i}'`}`,t)];if(t.referee=c,c.references.push(t),i=o,r=a,!c.symbolTable)return[];n=c.symbolTable}return[]}var yu=class{constructor(e,t){this.ast=e,this.symbolFactory=t}resolvePartialInjections(){return this.ast.body.filter(e=>kl(e).unwrap_or(``)===N.Table).flatMap(e=>new du(e,this.ast,this.symbolFactory).resolvePartialInjections())}resolve(){let e=[];e.push(...this.resolvePartialInjections());for(let t of this.ast.body)if(t.type){let n=new(gu(t))(t,this.ast,this.symbolFactory);e.push(...n.bind())}return new Mc(this.ast,e)}},bu=class{constructor(e){this.generator=e}create(e,t){return new e(t,this.generator.nextId())}},xu=class{constructor(e,t){this.ast=e,this.symbolFactory=new bu(t)}analyze(){return new ru(this.ast,this.symbolFactory).validate().chain(e=>new yu(e,this.symbolFactory).resolve())}validate(){return new ru(this.ast,this.symbolFactory).validate().chain(e=>new Mc(e,[]))}};function Su(e,t){let{variables:n,tupleElements:r}=z(e).unwrap(),i=r.map(e=>V(e).unwrap()),a=n.map(e=>V(e).unwrap());return r.length?n.length===0?{schemaName:t.schemaName,tableName:t.name,fieldNames:i}:{tableName:a.pop(),schemaName:a.pop()||null,fieldNames:i}:n.length===1?{schemaName:t.schemaName,tableName:t.name,fieldNames:[a[0]]}:{fieldNames:[a.pop()],tableName:a.pop(),schemaName:a.pop()||null}}function Cu(e){switch(e){case`<`:return[`1`,`*`];case`<>`:return[`*`,`*`];case`>`:return[`*`,`1`];case`-`:return[`1`,`1`];default:throw Error(`Invalid relation op`)}}function Y(e){return{start:{offset:e.startPos.offset,line:e.startPos.line+1,column:e.startPos.column+1},end:{offset:e.endPos.offset,line:e.endPos.line+1,column:e.endPos.column+1}}}function wu(e){let t=Al(e).unwrap_or(void 0)?.pop();return t instanceof pc?t.elementList.map(e=>e.referee):[t.referee]}function Tu(e){let t=R(e).unwrap();return{name:t.pop(),schemaName:t}}function Eu(e){return e.expression.literal.value}function Du(e,t){if(Array.isArray(e)){let n=e.map(({id:e})=>e).sort().join(`,`),r=t.map(({id:e})=>e).sort().join(`,`);return n<r?`${n}-${r}`:`${r}-${n}`}let n=e.id.toString(),r=t.id.toString();return n<r?`${n}-${r}`:`${r}-${n}`}function Ou(e,t){return Array.isArray(e)?Qs(e.map(({id:e})=>e).sort(),t.map(({id:e})=>e).sort()).every(([e,t])=>e===t):e.id===t.id}function ku(e){let t=e.split(`
|
|
10
|
+
`),n=t.slice(t.findIndex(e=>e.trimStart()!==``)),r=n.filter(e=>e.trimStart()),i=Math.min(...r.map(e=>e.length-e.trimStart().length));return n.map(e=>e.slice(i)).join(`
|
|
11
|
+
`)}function Au(e){if(e){if(G(e))return{value:H(e).unwrap(),type:`string`};if(Tl(e))return{type:`number`,value:Vc(e)};if(Hl(e))return{value:e.expression.variable.value.toLowerCase(),type:`boolean`};if(e instanceof C&&e.value)return{value:e.value.value,type:`expression`};if(Wl(e))return{value:Al(e).map(m).and_then(B).unwrap(),type:`string`};throw Error(`Unreachable`)}}function ju(e){let t=``,n=null;for(e instanceof D&&(n=e.argumentList.elementList.map(e=>Tl(e)?Bc(e):G(e)?H(e).unwrap():B(e).unwrap()).join(`,`),t=`(${n})`,e=e.callee);e instanceof D||e instanceof vc;)e instanceof D?(t=`(${e.argumentList.elementList.map(e=>Tl(e)?Bc(e):G(e)?H(e).unwrap():B(e).unwrap()).join(`,`)})${t}`,e=e.callee):e instanceof vc&&(t=`${`[${e.indexer.elementList.map(e=>e.name.expression.literal.value).join(`,`)}]`}${t}`,e=e.array);let{name:r,schemaName:i}=Tu(e);return i.length>1?new Mc({schemaName:i.length===0?null:i[0],type_name:`${r}${t}`,args:n},[new A(k.UNSUPPORTED,`Nested schema is not supported`,e)]):new Mc({schemaName:i.length===0?null:i[0],type_name:`${r}${t}`,args:n})}var Mu=class{constructor(e,t){this.declarationNode=e,this.env=t,this.table={name:void 0,schemaName:void 0,alias:null,fields:[],token:void 0,indexes:[],partials:[],checks:[]},this.pkColumns=[]}interpret(){this.table.token=Y(this.declarationNode),this.env.tables.set(this.declarationNode,this.table);let 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:e,token:t})=>({value:e,type:`column`,token:t})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(e=>{e.pk=!1})),e}interpretName(e){let{name:t,schemaName:n}=Tu(e);return n.length>1?(this.table.name=t,this.table.schemaName=n.join(`.`),[new A(k.UNSUPPORTED,`Nested schema is not supported`,e)]):(this.table.name=t,this.table.schemaName=n.length?n[0]:null,[])}interpretAlias(e){if(!e)return[];let t=V(e).unwrap_or(null);return t&&(this.env.aliases.push({name:t,kind:`table`,value:{tableName:this.table.name,schemaName:this.table.schemaName}}),this.table.alias=t),[]}interpretSettingList(e){let t=L(e).getValue();this.table.headerColor=t[P.HeaderColor]?.length?Eu(t[P.HeaderColor]?.at(0)?.value):void 0;let[n]=t[P.Note]||[];return this.table.note=n&&{value:H(n?.value).map(ku).unwrap(),token:Y(n)},[]}interpretBody(e){let[t,n]=h(e.body,e=>e instanceof w);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case N.Note:return this.table.note={value:H(e.body instanceof T?e.body.body[0].callee:e.body.callee).map(ku).unwrap(),token:Y(e)},[];case N.Indexes:return this.interpretIndexes(e);case N.Check:return this.interpretChecks(e);default:return[]}})}interpretInjection(e,t){let n={order:t,token:Y(e)};return n.name=B(e.expression).unwrap_or(``),this.table.partials.push(n),[]}interpretFields(e){let t=(this.declarationNode.symbol?.symbolTable?[...this.declarationNode.symbol.symbolTable.entries()]:[]).filter(([e])=>rl(e).unwrap_or(null)?.kind===F.Column).length?[]:[new A(k.EMPTY_TABLE,`A Table must have at least one column`,this.declarationNode)],n=e.flatMap((e,t)=>bl(e.callee)?this.interpretInjection(e.callee,t):this.interpretColumn(e));return[...t,...n]}interpretColumn(e){let t=[],n={};n.name=V(e.callee).unwrap();let r=ju(e.args[0]);n.type=r.getValue(),t.push(...r.getErrors()),n.token=Y(e),n.inline_refs=[];let i=e.args.slice(1);if(m(i)instanceof E){let r=L(i.pop()).getValue();n.pk=!!r[P.PK]?.length||!!r[P.PrimaryKey]?.length,n.increment=!!r[P.Increment]?.length,n.unique=!!r[P.Unique]?.length,n.not_null=r[P.NotNull]?.length?!0:r[P.Null]?.length?!1:void 0,n.dbdefault=Au(r[P.Default]?.at(0)?.value);let a=r[P.Note]?.at(0);n.note=a&&{value:H(a.value).map(ku).unwrap(),token:Y(a)},n.inline_refs=(r[P.Ref]||[]).flatMap(n=>{let[r]=wu(n.value.expression);if(Ou(r,e.symbol))return t.push(new A(k.SAME_ENDPOINT,`Two endpoints are the same`,n)),[];let i=n.value.op,a=R(n.value.expression).unwrap(),o;if(a.length===1){let[e]=a;o={schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[e],relation:i.value,token:Y(n)}}else if(a.length===2){let[e,t]=a;o={schemaName:null,tableName:e,fieldNames:[t],relation:i.value,token:Y(n)}}else if(a.length===3){let[e,t,r]=a;o={schemaName:e,tableName:t,fieldNames:[r],relation:i.value,token:Y(n)}}else{t.push(new A(k.UNSUPPORTED,`Nested schema is not supported`,n));let e=a.pop(),r=a.pop();o={schemaName:a.join(`.`),tableName:r,fieldNames:[e],relation:i.value,token:Y(n)}}let s=this.registerInlineRefToEnv(e,r,o,n);return t.push(...s),s.length===0?o:[]}),n.checks=(r[P.Check]||[]).map(e=>({token:Y(e),expression:e.value.value.value}))}return n.pk||=i.some(e=>B(e).unwrap().toLowerCase()===`pk`),n.unique||=i.some(e=>B(e).unwrap().toLowerCase()===`unique`),this.table.fields.push(n),n.pk&&this.pkColumns.push(n),t}interpretIndexes(e){return this.table.indexes.push(...e.body.body.map(e=>{let t={columns:[]},n=e;t.token=Y(n);let r=[n.callee,...n.args];if(m(r)instanceof E){let e=L(r.pop()).getValue();t.pk=!!e[P.PK]?.length,t.unique=!!e[P.Unique]?.length,t.name=H(e[P.Name]?.at(0)?.value).unwrap_or(void 0);let n=e[P.Note]?.at(0);t.note=n&&{value:H(n.value).unwrap(),token:Y(n)},t.type=B(e[P.Type]?.at(0)?.value).unwrap_or(void 0)}return r.flatMap(e=>{if(!(e instanceof D))return e;let t=[];for(;e instanceof D;)t.push(e.argumentList),e=e.callee;return t.push(e),t}).forEach(e=>{let{functional:n,nonFunctional:r}=jl(e).unwrap();t.columns.push(...n.map(e=>({value:e.value.value,type:`expression`,token:Y(e)})),...r.map(e=>({value:V(e).unwrap(),type:`column`,token:Y(e)})))}),t})),[]}interpretChecks(e){return this.table.checks.push(...e.body.body.map(e=>{let t={},n=e;return t.token=Y(n),n.args[0]instanceof E&&(t.name=H(L(n.args[0]).getValue()[P.Name]?.at(0)?.value).unwrap_or(void 0)),t.expression=n.callee.value.value,t})),[]}registerInlineRefToEnv(e,t,n,r){let i=Du(e.symbol,t);if(this.env.refIds[i])return[new A(k.CIRCULAR_REF,`References with same endpoints exist`,r),new A(k.CIRCULAR_REF,`References with same endpoints exist`,this.env.refIds[i])];let a=Cu(n.relation);return this.env.refIds[i]=r,this.env.ref.set(r,{name:null,schemaName:null,token:n.token,endpoints:[{...n,relation:a[1]},{schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[B(e.callee).unwrap()],token:Y(e),relation:a[0]}]}),[]}},Nu=class{constructor(e,t){this.declarationNode=e,this.env=t,this.note={name:void 0,content:void 0,token:void 0}}interpret(){return this.note.token=Y(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){let{name:t}=Tu(e);return this.note.name=t,[]}interpretSettingList(e){let t=L(e).getValue();return this.note.headerColor=t.headercolor?.length?Eu(t.headercolor?.at(0)?.value):void 0,[]}interpretBody(e){let[t,n]=h(e.body,e=>e instanceof w);return t.length!==1||n.length>0?[new A(k.INVALID_NOTE,`Invalid note syntax`,e)]:[...this.interpretNote(t[0])]}interpretNote(e){let t=Wi(e,`callee.expression.literal.value`,``);return this.note.content=ku(t),[]}},Pu=class{constructor(e,t){this.declarationNode=e,this.env=t,this.container=this.declarationNode.parent instanceof x?this.env.tables.get(this.declarationNode.parent):void 0,this.ref={}}interpret(){return this.ref.token=Y(this.declarationNode),this.env.ref.set(this.declarationNode,this.ref),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){let t=[],n=R(this.declarationNode.name).unwrap_or([]);return this.ref.name=n.pop()||null,n.length>1&&t.push(new A(k.UNSUPPORTED,`Nested schema is not supported`,this.declarationNode.name)),this.ref.schemaName=n.join(`.`)||null,t}interpretBody(e){return e instanceof w?this.interpretField(e):this.interpretField(e.body[0])}interpretField(e){let t=e.callee.op.value,{leftExpression:n,rightExpression:r}=e.callee,i=wu(n),a=wu(r);if(Ou(i,a))return[new A(k.SAME_ENDPOINT,`Two endpoints are the same`,e)];let o=Du(i,a);if(this.env.refIds[o])return[new A(k.CIRCULAR_REF,`References with same endpoints exist`,this.declarationNode),new A(k.CIRCULAR_REF,`References with same endpoints exist`,this.env.refIds[o])];if(e.args[0]){let t=L(e.args[0]).getValue(),n=t.delete?.at(0)?.value;this.ref.onDelete=n instanceof lc?Gl(n).unwrap_or(void 0):B(n).unwrap_or(void 0);let r=t.update?.at(0)?.value;this.ref.onUpdate=r instanceof lc?Gl(r).unwrap_or(void 0):B(r).unwrap_or(void 0),this.ref.color=t.color?.length?Eu(t.color?.at(0)?.value):void 0}let s=Cu(t);return this.ref.endpoints=[{...Su(n,this.container),relation:s[0],token:Y(n)},{...Su(r,this.container),relation:s[1],token:Y(r)}],this.env.refIds[o]=this.declarationNode,[]}},Fu=class{constructor(e,t){this.declarationNode=e,this.env=t,this.tableGroup={tables:[]}}interpret(){let e=[];return this.tableGroup.token=Y(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){let t=[],{name:n,schemaName:r}=Tu(e);return r.length>=2&&(this.tableGroup.name=n,this.tableGroup.schemaName=r.join(`.`),t.push(new A(k.UNSUPPORTED,`Nested schema is not supported`,this.declarationNode.name))),this.tableGroup.name=n,this.tableGroup.schemaName=r[0]||null,t}interpretBody(e){let[t,n]=h(e.body,e=>e instanceof w);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case`note`:this.tableGroup.note={value:H(e.body instanceof T?e.body.body[0].callee:e.body.callee).map(ku).unwrap(),token:Y(e)};break;default:break}return[]})}interpretFields(e){let t=[];return this.tableGroup.tables=e.map(e=>{let n=R(e.callee).unwrap();n.length>2&&t.push(new A(k.UNSUPPORTED,`Nested schema is not supported`,e));let r=Al(e.callee).unwrap().pop().referee.id;if(this.env.tableOwnerGroup[r]){let i=this.env.tableOwnerGroup[r],{schemaName:a,name:o}=this.env.tableGroups.get(i),s=a?`${a}.${o}`:o;t.push(new A(k.TABLE_REAPPEAR_IN_TABLEGROUP,`Table "${n.join(`.`)}" already appears in group "${s}"`,e))}else this.env.tableOwnerGroup[r]=this.declarationNode;return{name:n.pop(),schemaName:n.join(`.`)}}),t}interpretSettingList(e){let t=L(e).getValue();this.tableGroup.color=t.color?.length?Eu(t.color?.at(0)?.value):void 0;let[n]=t.note||[];return this.tableGroup.note=n&&{value:H(n?.value).map(ku).unwrap(),token:Y(n)},[]}},Iu=class{constructor(e,t){this.declarationNode=e,this.env=t,this.enum={values:[]}}interpret(){return this.enum.token=Y(this.declarationNode),this.env.enums.set(this.declarationNode,this.enum),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){let{name:t,schemaName:n}=Tu(e);return n.length>1?(this.enum.name=t,this.enum.schemaName=n.join(`.`),[new A(k.UNSUPPORTED,`Nested schema is not supported`,e)]):(this.enum.name=t,this.enum.schemaName=n.length?n[0]:null,[])}interpretBody(e){return e.body.flatMap(e=>{let t=e,n={};n.token=Y(t),n.name=B(t.callee).unwrap();let r=L(t.args[0]).getValue().note?.at(0);return n.note=r&&{value:H(r.value).map(ku).unwrap(),token:Y(r)},this.enum.values.push(n),[]})}},Lu=class{constructor(e,t){this.declarationNode=e,this.env=t,this.tablePartial={name:void 0,fields:[],token:void 0,indexes:[],checks:[]},this.pkColumns=[]}interpret(){this.tablePartial.token=Y(this.declarationNode),this.env.tablePartials.set(this.declarationNode,this.tablePartial);let 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:e,token:t})=>({value:e,type:`column`,token:t})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(e=>{e.pk=!1})),e}interpretName(e){let{name:t}=Tu(e);return this.tablePartial.name=t,[]}interpretSettingList(e){let t=L(e).getValue(),n=Ws(t[P.HeaderColor]);this.tablePartial.headerColor=n?Eu(n.value):void 0;let[r]=t[P.Note]||[];return this.tablePartial.note=r&&{value:H(r?.value).map(ku).unwrap(),token:Y(r)},[]}interpretBody(e){let[t,n]=h(e.body,e=>e instanceof w);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case N.Note:return this.tablePartial.note={value:H(e.body instanceof T?e.body.body[0].callee:e.body.callee).map(ku).unwrap(),token:Y(e)},[];case N.Indexes:return this.interpretIndexes(e);case N.Check:return this.interpretChecks(e);default:return[]}})}interpretFields(e){return e.flatMap(e=>this.interpretColumn(e))}interpretColumn(e){let t=[],n={};n.name=V(e.callee).unwrap();let r=ju(e.args[0]);n.type=r.getValue(),t.push(...r.getErrors()),n.token=Y(e),n.inline_refs=[];let i=e.args.slice(1);if(m(i)instanceof E){let r=L(i.pop()).getValue();n.pk=!!r[P.PK]?.length||!!r[P.PrimaryKey]?.length,n.increment=!!r[P.Increment]?.length,n.unique=!!r[P.Unique]?.length,n.not_null=r[P.NotNull]?.length?!0:r[P.Null]?.length?!1:void 0,n.dbdefault=Au(r[P.Default]?.at(0)?.value);let a=r[P.Note]?.at(0);n.note=a&&{value:H(a.value).map(ku).unwrap(),token:Y(a)},n.inline_refs=(r[P.Ref]||[]).flatMap(n=>{let[r]=wu(n.value.expression);if(Ou(r,e.symbol))return t.push(new A(k.SAME_ENDPOINT,`Two endpoints are the same`,n)),[];let i=n.value.op,a=R(n.value.expression).unwrap(),o;if(a.length===2){let[e,t]=a;o={schemaName:null,tableName:e,fieldNames:[t],relation:i.value,token:Y(n)}}else if(a.length===3){let[e,t,r]=a;o={schemaName:e,tableName:t,fieldNames:[r],relation:i.value,token:Y(n)}}else{t.push(new A(k.UNSUPPORTED,`Unsupported`,n));let e=a.pop(),r=a.pop();o={schemaName:a.join(`.`),tableName:r,fieldNames:[e],relation:i.value,token:Y(n)}}return o}),n.checks=(r[P.Check]||[]).map(e=>({token:Y(e),expression:e.value.value.value}))}return n.pk||=i.some(e=>B(e).unwrap().toLowerCase()===`pk`),n.unique||=i.some(e=>B(e).unwrap().toLowerCase()===`unique`),this.tablePartial.fields.push(n),n.pk&&this.pkColumns.push(n),t}interpretIndexes(e){return this.tablePartial.indexes.push(...e.body.body.map(e=>{let t={columns:[]},n=e;t.token=Y(n);let r=[n.callee,...n.args];if(m(r)instanceof E){let e=L(r.pop()).getValue();t.pk=!!e[P.PK]?.length,t.unique=!!e[P.Unique]?.length,t.name=H(e[P.Name]?.at(0)?.value).unwrap_or(void 0);let n=e[P.Note]?.at(0);t.note=n&&{value:H(n.value).unwrap(),token:Y(n)},t.type=B(e[P.Type]?.at(0)?.value).unwrap_or(void 0)}return r.flatMap(e=>{if(!(e instanceof D))return e;let t=[],n=e;for(;n instanceof D;)t.push(n.argumentList),n=n.callee;return t.push(n),t}).forEach(e=>{let{functional:n,nonFunctional:r}=jl(e).unwrap();t.columns.push(...n.map(e=>({value:e.value.value,type:`expression`,token:Y(e)})),...r.map(e=>({value:V(e).unwrap(),type:`column`,token:Y(e)})))}),t})),[]}interpretChecks(e){return this.tablePartial.checks.push(...e.body.body.map(e=>{let t={},n=e;return t.token=Y(n),n.args[0]instanceof E&&(t.name=H(L(n.args[0]).getValue()[P.Name]?.at(0)?.value).unwrap_or(void 0)),t.expression=n.callee.value.value,t})),[]}},Ru=class{constructor(e,t){this.declarationNode=e,this.env=t,this.project={enums:[],refs:[],tableGroups:[],tables:[],tablePartials:[]}}interpret(){return this.env.project.set(this.declarationNode,this.project),this.project.token=Y(this.declarationNode),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){if(!e)return this.project.name=null,[];let{name:t}=Tu(e);return this.project.name=t,[]}interpretBody(e){return e.body.flatMap(e=>{let t=e;switch(t.type?.value.toLowerCase()){case`table`:{let e=new Mu(t,this.env).interpret();return this.project.tables.push(this.env.tables.get(t)),e}case`ref`:{let e=new Pu(t,this.env).interpret();return this.project.refs.push(this.env.ref.get(t)),e}case`tablegroup`:{let e=new Fu(t,this.env).interpret();return this.project.tableGroups.push(this.env.tableGroups.get(t)),e}case`enum`:{let e=new Iu(t,this.env).interpret();return this.project.enums.push(this.env.enums.get(t)),e}case`note`:return this.project.note={value:H(t.body instanceof T?t.body.body[0].callee:t.body.callee).map(ku).unwrap(),token:Y(t)},[];case`tablepartial`:{let e=new Lu(t,this.env).interpret();return this.project.tablePartials.push(this.env.tablePartials.get(t)),e}default:return this.project[t.type.value.toLowerCase()]=H(t.body.callee).unwrap(),[]}})}};function zu(e){return{schemas:[],tables:Array.from(e.tables.values()),notes:Array.from(e.notes.values()),refs:Array.from(e.ref.values()),enums:Array.from(e.enums.values()),tableGroups:Array.from(e.tableGroups.values()),aliases:e.aliases,project:Array.from(e.project.values())[0]||{},tablePartials:Array.from(e.tablePartials.values())}}var Bu=class{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}}interpret(){let e=this.ast.body.flatMap(e=>{switch(kl(e).unwrap_or(void 0)){case N.Table:return new Mu(e,this.env).interpret();case N.Note:return new Nu(e,this.env).interpret();case N.Ref:return new Pu(e,this.env).interpret();case N.TableGroup:return new Fu(e,this.env).interpret();case N.TablePartial:return new Lu(e,this.env).interpret();case N.Enum:return new Iu(e,this.env).interpret();case N.Project:return new Ru(e,this.env).interpret();default:return[]}});return new Mc(zu(this.env),e)}};let X=function(e){return e[e.Function=1]=`Function`,e[e.Constructor=2]=`Constructor`,e[e.Field=3]=`Field`,e[e.Variable=4]=`Variable`,e[e.Class=5]=`Class`,e[e.Struct=6]=`Struct`,e[e.Interface=7]=`Interface`,e[e.Module=8]=`Module`,e[e.Property=9]=`Property`,e[e.Event=10]=`Event`,e[e.Operator=11]=`Operator`,e[e.Unit=12]=`Unit`,e[e.Value=13]=`Value`,e[e.Constant=14]=`Constant`,e[e.Enum=15]=`Enum`,e[e.EnumMember=16]=`EnumMember`,e[e.Keyword=17]=`Keyword`,e[e.Text=18]=`Text`,e[e.Color=19]=`Color`,e[e.File=20]=`File`,e[e.Reference=21]=`Reference`,e[e.Customcolor=22]=`Customcolor`,e[e.Folder=23]=`Folder`,e[e.TypeParameter=24]=`TypeParameter`,e[e.User=25]=`User`,e[e.Issue=26]=`Issue`,e[e.Snippet=27]=`Snippet`,e}({}),Z=function(e){return e[e.None=0]=`None`,e[e.KeepWhitespace=1]=`KeepWhitespace`,e[e.InsertAsSnippet=4]=`InsertAsSnippet`,e}({});function Vu(e){switch(e){case F.Schema:return X.Module;case F.Table:case F.TablePartial:return X.Class;case F.Column:case F.TableGroupField:return X.Field;case F.Enum:return X.Enum;case F.EnumField:return X.EnumMember;case F.TableGroup:return X.Struct;default:return X.Text}}function Hu(e,t){if(!e||ic(e))return!1;for(let n of e.trailingTrivia){if(n.start>t)break;if(n.kind===g.NEWLINE&&n.end<=t)return!1}return!0}function Q(){return{suggestions:[]}}function Uu(e){return{...e,suggestions:e.suggestions.map(e=>({...e,insertText:` ${e.insertText}`}))}}function Wu(e){return{...e,suggestions:e.suggestions.map(e=>({...e,insertText:!e.insertText||!e.insertText.split(``).every(Nc)?`"${e.insertText??``}"`:e.insertText}))}}function Gu(e,t){return e.getOffsetAt(t)}var Ku=class{constructor(e,t=[]){this.compiler=e,this.triggerCharacters=t}provideCompletionItems(e,t){let n=Gu(e,t),r=this.compiler.token.flatStream(),{token:i,index:a}=this.compiler.container.token(n),o=a===void 0?r[0]:r[a+1];if([...i?.trailingTrivia||[],...i?.leadingTrivia||[],...o?.leadingTrivia||[]].find(e=>sc(e)&&zc(n,e)))return Q();if(a===void 0)return nd();if([g.STRING_LITERAL,g.QUOTED_STRING].includes(i.kind)&&zc(n,i))return Q();let s=this.compiler.container.element(n);if(this.compiler.container.scopeKind(n)===$.TOPLEVEL||s instanceof x&&s.type&&s.type.start<=n&&s.type.end>=n)return nd();let c=[...this.compiler.container.stack(n)].reverse();for(let e of c)if(e instanceof S)switch(e.op?.value){case`>`:case`<`:case`<>`:case`-`:return Ju(this.compiler,n,e);case`~`:return qu(this.compiler,n);default:}else if(e instanceof dc)switch(e.op?.value){case`>`:case`<`:case`<>`:case`-`:return Ju(this.compiler,n,e);case`.`:return ed(this.compiler,n,e);default:}else if(e instanceof uc)return Zu(this.compiler,n,e);else if(e instanceof E)return Zu(this.compiler,n,e);else if(e instanceof pc)return Xu(this.compiler,n);else if(e instanceof w)return td(this.compiler,n,e);else if(e instanceof x&&(e.bodyColon&&n>=e.bodyColon.end||e.body&&zc(n,e.body)))return td(this.compiler,n,void 0);return Q()}};function qu(e,t){return Yu(e,t,e.parse.ast(),[F.TablePartial])}function Ju(e,t,n){let r=e.container.scopeKind(t);if([$.REF,$.TABLE,$.TABLEPARTIAL].includes(r)){let r=Yu(e,t,e.container.element(t),[F.Table,F.Schema,F.Column]);return Hu(n.op,t)?Uu(r):r}return Q()}function Yu(e,t,n,r){if(n===void 0)return Q();let i=n,a={suggestions:[]};for(;i;){if(i?.symbol?.symbolTable){let{symbol:t}=i;a.suggestions.push(...e.symbol.members(t).filter(({kind:e})=>r.includes(e)).map(({name:e,kind:t})=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:Vu(t),sortText:Vu(t).toString().padStart(2,`0`),range:void 0})))}i=i instanceof x?i.parent:void 0}return Wu(a)}function Xu(e,t){switch(e.container.scopeKind(t)){case $.INDEXES:return ud(e,t);case $.REF:{let n=[...e.container.stack(t)];for(;n.length>0;){let r=n.pop();if(r instanceof dc&&r.op?.value===`.`)return ed(e,t,r)}}return od(e,t);default:break}return Q()}function Zu(e,t,n){let{token:r}=e.container.token(t);if([g.COMMA,g.LBRACKET].includes(r?.kind)){let n=Qu(e,t);return r?.kind===g.COMMA&&Hu(r,t)?Uu(n):n}if(n.name&&n.name.start<=t&&n.name.end>=t)return Qu(e,t);if(n.name instanceof lc){let i=$u(e,t,Gl(n.name).unwrap_or(``));return r?.kind===g.COLON&&Hu(r,t)?Uu(i):i}return Q()}function Qu(e,t){let n=e.container.element(t);if(n instanceof b)return Q();let r=e.container.scopeKind(t);if(n.body&&!zc(t,n.body)){let e;switch(r){case $.TABLE:case $.TABLEPARTIAL:e=[P.HeaderColor,P.Note];break;case $.TABLEGROUP:e=[P.Color,P.Note];break;default:e=[]}return{suggestions:e.map(e=>({label:e,insertText:`${e}: `,kind:X.Field,insertTextRules:Z.KeepWhitespace,range:void 0}))}}switch(r){case $.TABLE:case $.TABLEPARTIAL:return{suggestions:[...[P.PK,P.PrimaryKey,P.Null,P.NotNull,P.Increment,P.Unique].map(e=>({label:e,insertText:e,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0})),...[P.Ref,P.Default,P.Note,P.Check].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))]};case $.ENUM:return{suggestions:[...[P.Note].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))]};case $.INDEXES:return{suggestions:[...[P.Unique,P.PK].map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Property,range:void 0})),...[P.Note,P.Name,P.Type].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))]};case $.REF:return{suggestions:[P.Update,P.Delete,P.Color].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))};case $.CHECKS:return{suggestions:[P.Name].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))};default:break}return Q()}function $u(e,t,n){switch(n?.toLowerCase()){case`update`:case`delete`:return{suggestions:[`cascade`,`set default`,`set null`,`restrict`].map(e=>({label:e,insertText:e,kind:X.Value,insertTextRules:Z.KeepWhitespace,range:void 0}))};case`type`:return{suggestions:[`btree`,`hash`].map(e=>({label:e,insertText:`${e}`,kind:X.Value,insertTextRules:Z.KeepWhitespace,range:void 0}))};case`default`:return Yu(e,t,e.container.element(t),[F.Schema,F.Enum]);default:break}return Q()}function ed(e,t,n){let r=Al(n).unwrap_or([]);if(r.pop(),r.some(e=>!K(e)))return Q();let i=r.map(e=>B(e).unwrap());return Wu({suggestions:e.symbol.ofName(i,e.container.element(t)).flatMap(({symbol:t})=>e.symbol.members(t)).map(({kind:e,name:t})=>({label:t,insertText:t,kind:Vu(e),range:void 0}))})}function td(e,t,n){switch(e.container.scopeKind(t)){case $.TABLE:case $.TABLEPARTIAL:return id(e,t,n);case $.PROJECT:return ad(e,t,n);case $.INDEXES:return cd(e,t);case $.ENUM:return rd(e,t,n);case $.REF:{let n=od(e,t);return e.container.token(t).token?.kind===g.COLON&&Hu(e.container.token(t).token,t)?Uu(n):n}case $.TABLEGROUP:return sd(e);default:return Q()}}function nd(){return{suggestions:[`Table`,`TableGroup`,`Enum`,`Project`,`Ref`,`TablePartial`].map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))}}function rd(e,t,n){return n?.callee&&dd(t,n)===1?Yu(e,t,e.container.element(t),[F.Schema,F.Table,F.Column]):Q()}function id(e,t,n){let r=[`Note`,`indexes`,`checks`];if(!n?.callee)return{suggestions:r.map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))};let i=dd(t,n);return i===0?{suggestions:r.map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))}:i===1?ld(e,t):Q()}function ad(e,t,n){return!n?.callee||dd(t,n)===0?{suggestions:[`Table`,`TableGroup`,`Enum`,`Note`,`Ref`,`TablePartial`].map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))}:Q()}function od(e,t){return Yu(e,t,e.container.element(t),[F.Schema,F.Table,F.Column])}function sd(e){return{suggestions:[...Wu({suggestions:[...e.parse.publicSymbolTable().entries()].flatMap(([e])=>{let t=rl(e).unwrap_or(void 0);if(t===void 0)return[];let{kind:n,name:r}=t;return n!==F.Table&&n!==F.Schema?[]:{label:r,insertText:r,insertTextRules:Z.KeepWhitespace,kind:Vu(n),range:void 0}})}).suggestions,...[`Note`].map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))]}}function cd(e,t){return ud(e,t)}function ld(e,t){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`.split(`.`).map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.TypeParameter,sortText:X.TypeParameter.toString().padStart(2,`0`),range:void 0})),...Yu(e,t,e.container.element(t),[F.Enum,F.Schema]).suggestions]}}function ud(e,t){let n=e.container.element(t)?.parent;if(!(n?.symbol instanceof Tc))return Q();let{symbolTable:r}=n.symbol;return Wu({suggestions:[...r.entries()].flatMap(([e])=>{let t=rl(e).unwrap_or(void 0);if(t===void 0)return[];let{name:n}=t;return{label:n,insertText:n,insertTextRules:Z.KeepWhitespace,kind:Vu(F.Column),range:void 0}})})}function dd(e,t){if(!t.callee)return-1;let n=[t.callee,...t.args],r=n.findIndex(t=>e<=t.end);return r===-1?n.length:r}var fd=class{constructor(e){this.compiler=e}provideDefinition(e,t){let{uri:n}=e,r=Gu(e,t),i=[...this.compiler.container.stack(r)];for(;i.length!==0;){let e=i.pop();if(!e?.referee)continue;let t;if(e.referee?.declaration&&[y.PRIMARY_EXPRESSION,y.VARIABLE].includes(e?.kind)&&({declaration:t}=e.referee),t){let{startPos:e,endPos:r}=t;return[{range:{startColumn:e.column+1,startLineNumber:e.line+1,endColumn:r.column+1,endLineNumber:r.line+1},uri:n}]}}return[]}},pd=class{constructor(e){this.compiler=e}provideReferences(e,t){let{uri:n}=e,r=Gu(e,t),i=[...this.compiler.container.stack(r)];for(;i.length!==0;){let e=i.pop();if(e&&[y.ELEMENT_DECLARATION,y.FUNCTION_APPLICATION,y.PRIMARY_EXPRESSION].includes(e?.kind)){let{symbol:t}=e;if(t?.references.length)return t.references.map(({startPos:e,endPos:t})=>({range:{startColumn:e.column+1,startLineNumber:e.line+1,endColumn:t.column+1,endLineNumber:t.line+1},uri:n}))}}return[]}},md=t({CompletionItemInsertTextRule:()=>Z,CompletionItemKind:()=>X,DBMLCompletionItemProvider:()=>Ku,DBMLDefinitionProvider:()=>fd,DBMLReferencesProvider:()=>pd},1);function hd(){return this.parse._().getValue().ast}function gd(){return this.parse._().getErrors()}function _d(){return this.parse._().getValue().tokens}function vd(){return this.parse._().getValue().rawDb}function yd(){return this.parse._().getValue().ast.symbol.symbolTable}function bd(){return this.parse.tokens().flatMap(e=>[...e.leadingInvalid,e,...e.trailingInvalid])}function xd(){return this.parse.tokens().filter(zl)}function Sd(e){return e.symbolTable?[...e.symbolTable.entries()].map(([e,t])=>({...rl(e).unwrap(),symbol:t})):[]}function Cd(e,t){if(e.length===0)return[];let n=[];for(let r=t;r;r=r instanceof x?r.parent:void 0){if(!r.symbol?.symbolTable)continue;let{symbolTable:t}=r.symbol,i=[t],a=[];for(let t of e)a=i.flatMap(e=>mu(t).flatMap(t=>{let n=e.get(t),r=rl(t).unwrap_or(void 0);return!n||!r?[]:{...r,symbol:n}})),i=a.flatMap(e=>e.symbol.symbolTable?e.symbol.symbolTable:[]);n.push(...a)}return n}function wd(e,t){return`${e.join(`.`)}@${t.id}`}function Td(e){let t=this.token.flatStream(),{index:n,token:r}=this.container.token(e),i=n===void 0?-1:Hs(t,e=>!e.isInvalid,n);if(i===-1)return[this.parse.ast()];let a=t[i].start,o=this.parse.ast(),s=[o];for(;;){let e=Bl(o).find(e=>zc(a,e));if(e===void 0||e instanceof _)break;s.push(e),o=e}if(r?.kind===g.COLON)return s;for(;s.length>0;){let t=!1,n=m(s);if(n instanceof w){let r=this.parse.source();for(let i=n.end;i<e;i+=1)r[i]===`
|
|
12
|
+
`&&(s.pop(),t=!0)}else n instanceof S||n instanceof dc?this.container.token(e).token!==n.op&&(s.pop(),t=!0):n instanceof E?n.listCloseBracket&&n.end<=e&&(s.pop(),t=!0):n instanceof pc?n.tupleCloseParen&&n.end<=e&&(s.pop(),t=!0):n instanceof T?n.blockCloseBrace&&n.end<=e&&(s.pop(),t=!0):n instanceof lc||n.end<e&&(s.pop(),t=!0);if(t){let t=m(s);t instanceof x&&t.end<=e&&s.pop()}if(!t)break}return s}function Ed(e){let t=this.token.flatStream().findIndex(t=>t.start>=e);return t===void 0||t<=0?{token:void 0,index:void 0}:{token:this.token.flatStream()[t-1],index:t-1}}function Dd(e){let t=this.container.stack(e);for(let e=t.length-1;e>=0;--e)if(t[e]instanceof x)return t[e];return this.parse.ast()}function Od(e){return this.container.element(e)?.symbol?.symbolTable}let $=function(e){return e[e.TABLE=0]=`TABLE`,e[e.ENUM=1]=`ENUM`,e[e.TABLEGROUP=2]=`TABLEGROUP`,e[e.INDEXES=3]=`INDEXES`,e[e.NOTE=4]=`NOTE`,e[e.REF=5]=`REF`,e[e.PROJECT=6]=`PROJECT`,e[e.CUSTOM=7]=`CUSTOM`,e[e.TOPLEVEL=8]=`TOPLEVEL`,e[e.TABLEPARTIAL=9]=`TABLEPARTIAL`,e[e.CHECKS=10]=`CHECKS`,e}({});function kd(e){let t=this.container.element(e);if(t instanceof b)return $.TOPLEVEL;switch(t.type?.value.toLowerCase()){case`table`:return $.TABLE;case`enum`:return $.ENUM;case`ref`:return $.REF;case`tablegroup`:return $.TABLEGROUP;case`indexes`:return $.INDEXES;case`note`:return $.NOTE;case`project`:return $.PROJECT;case`tablepartial`:return $.TABLEPARTIAL;case`checks`:return $.CHECKS;default:return $.CUSTOM}}function Ad(e,t){let n=[...t].sort((e,t)=>t.start-e.start),r=e;for(let{start:e,end:t,newText:i}of n)r=r.substring(0,e)+i+r.substring(t);return r}function jd(e){return e.startsWith(`"`)&&e.endsWith(`"`)&&e.length>=2?e.slice(1,-1):e}function Md(e){if(typeof e!=`string`)return{schema:e.schema??`public`,table:e.table};let t=e.split(`.`);if(t.length===1)return{schema:Wc,table:jd(t[0])};if(t.length===2)return{schema:jd(t[0]),table:jd(t[1])};let n=t.pop();return{schema:jd(t.join(`.`)),table:jd(n)}}function Nd(e){return e?e.split(``).every(e=>Nc(e)||Pc(e))&&!Pc(e[0]):!1}function Pd(e,t){if(!e.declaration)return!1;let n=e.declaration;if(!n.name)return!1;let r=n.name;return t.substring(r.start,r.end).includes(`"`)}function Fd(e,t,n){let r=!Nd(t),i=!Nd(e),a=n||r,o=n||i;return{schema:e,table:t,formattedSchema:o?`"${e}"`:e,formattedTable:a?`"${t}"`:t,shouldQuoteSchema:o,shouldQuoteTable:a}}function Id(e,t,n){let r=qc(n);if(t===`public`){let t=e.get(r);return t instanceof Tc?t:null}let i=Kc(t),a=e.get(i);if(!a||!a.symbolTable)return null;let o=a.symbolTable.get(r);return o instanceof Tc?o:null}function Ld(e,t,n,r,i){let a=qc(i),o;if(r===`public`)o=e.get(a);else{let t=Kc(r),n=e.get(t);if(!n||!n.symbolTable)return!1;o=n.symbolTable.get(a)}return!(!o||t===r&&n===i)}function Rd(e,t,n){let r=e.start-1;for(;r>=0&&/\s/.test(n[r]);)r--;if(r<0||n[r]!==`.`)return null;for(r--;r>=0&&/\s/.test(n[r]);)r--;if(r<0)return null;let i,a;if(n[r]===`"`){for(a=r+1,r--;r>=0&&n[r]!==`"`;)r--;if(r<0)return null;i=r}else{for(a=r+1;r>=0&&/[a-zA-Z0-9_]/.test(n[r]);)r--;i=r+1}return jd(n.substring(i,a))===t?{start:i,end:e.end}:null}function zd(e,t,n,r){let i=[],a=new Set;for(let o of e){let e=Rd(o,t,r)??{start:o.start,end:o.end},s=`${e.start}-${e.end}`;if(a.has(s))continue;a.add(s);let c=n.schema===`public`?n.formattedTable:`${n.formattedSchema}.${n.formattedTable}`;i.push({start:e.start,end:e.end,newText:c})}return i}function Bd(e,t){let n=this.parse.source(),r=this.parse.publicSymbolTable(),i=Md(e),a=Md(t),o=i.schema,s=i.table,c=a.schema,l=a.table,u=Id(r,o,s);if(!u||Ld(r,o,s,c,l))return n;let d=Fd(c,l,Pd(u,n)),f=[];if(u.declaration){let e=u.declaration;e.name&&f.push(e.name)}for(let e of u.references)n.substring(e.start,e.end).replace(/"/g,``)===s&&f.push(e);return Ad(n,zd(f,o,d,n))}var Vd=class{constructor(){this.source=``,this.cache=new Map,this.nodeIdGenerator=new cc,this.symbolIdGenerator=new xc,this.token={invalidStream:this.query(xd),flatStream:this.query(bd)},this.parse={source:()=>this.source,_:this.query(this.interpret),ast:this.query(hd),errors:this.query(gd),tokens:this.query(_d),rawDb:this.query(vd),publicSymbolTable:this.query(yd)},this.container={stack:this.query(Td),token:this.query(Ed),element:this.query(Dd),scope:this.query(Od),scopeKind:this.query(kd)},this.symbol={ofName:this.query(Cd,wd),members:this.query(Sd)}}setSource(e){this.source=e,this.cache.clear(),this.nodeIdGenerator.reset(),this.symbolIdGenerator.reset()}query(e,t){let n=Symbol();return((...r)=>{if(r.length===0){if(this.cache.has(n))return this.cache.get(n);let t=e.apply(this,r);return this.cache.set(n,t),t}let i=t?t(...r):r[0],a=this.cache.get(n);if(a instanceof Map&&a.has(i))return a.get(i);let o=e.apply(this,r);return a instanceof Map||(a=new Map,this.cache.set(n,a)),a.set(i,o),o})}interpret(){let e=new ql(this.source).lex().chain(e=>new Xl(e,this.nodeIdGenerator).parse()).chain(({ast:e,tokens:t})=>new xu(e,this.symbolIdGenerator).analyze().map(()=>({ast:e,tokens:t})));return e.getErrors().length>0?e:e.chain(({ast:e,tokens:t})=>new Bu(e).interpret().map(n=>({ast:e,tokens:t,rawDb:n})))}renameTable(e,t){return Bd.call(this,e,t)}applyTextEdits(e){return Ad(this.parse.source(),e)}initMonacoServices(){return{definitionProvider:new fd(this),referenceProvider:new pd(this),autocompletionProvider:new Ku(this)}}};exports.CompileError=A,exports.CompileErrorCode=k,exports.Compiler=Vd,exports.ElementDeclarationNode=x,exports.ElementKind=N,exports.ProgramNode=b,exports.ScopeKind=$,exports.SyntaxNode=v,exports.SyntaxNodeKind=y,exports.SyntaxToken=_,exports.SyntaxTokenKind=g,exports.addQuoteIfNeeded=Lc,exports.serialize=bc,Object.defineProperty(exports,`services`,{enumerable:!0,get:function(){return md}});
|